]> 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, 21 Dec 2022 00:06:50 +0000 (00:06 +0000)
commit8c020ba5efde6a09656f1c08f9ed7ab6e5636cf5
tree3290cdaf1c9ceca0d704497a4bc7bc0944e79b28
parentf2e02c7394346c9d504bea32c6d02fde88dd51ee
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>
target/i386/kvm/kvm.c
target/i386/kvm/xen-emu.c
target/i386/kvm/xen-emu.h