]> www.infradead.org Git - users/dwmw2/qemu.git/commit
i386/hvm: Set Xen vCPU ID in KVM
authorDavid Woodhouse <dwmw@amazon.co.uk>
Fri, 16 Dec 2022 11:05:29 +0000 (11:05 +0000)
committerDavid Woodhouse <dwmw@amazon.co.uk>
Wed, 11 Jan 2023 08:07:51 +0000 (08:07 +0000)
commitebb8333668c9b66369e1d1747d6f49aaf3fb8db1
tree3e363a5902e953692ba43de30b93eb75be61e753
parentadbca73d5ccb4c3c8ab3fdae4280ce9be1c3fd4b
i386/hvm: Set Xen vCPU ID in KVM

There are (at least) three different vCPU ID number spaces. One is the
internal KVM vCPU index, based purely on which vCPU was chronologically
created in the kernel first. If userspace threads are all spawned and
create their KVM vCPUs in essentially random order, then the KVM indices
are basically random too.

The second number space is the APIC ID space, which is consistent and
useful for referencing vCPUs. MSIs will specify the target vCPU using
the APIC ID, for example, and the KVM Xen APIs also take an APIC ID
from userspace whenever a vCPU needs to be specified (as opposed to
just using the appropriate vCPU fd).

The third number space is not normally relevant to the kernel, and is
the ACPI/MADT/Xen CPU number which corresponds to cs->cpu_index. But
Xen timer hypercalls use it, and Xen timer hypercalls *really* want
to be accelerated in the kernel rather than handled in userspace, so
the kernel needs to be told.

Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
Reviewed-by: Paul Durrant <paul@xen.org>
target/i386/kvm/kvm.c
target/i386/kvm/xen-emu.c
target/i386/kvm/xen-emu.h