]> xenbits.xensource.com Git - people/pauldu/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>
Fri, 27 Jan 2023 09:04:08 +0000 (10:04 +0100)
commit131e610c0452a75b31690297ff6f1e07a93c44f3
tree48984f0bb3b09c29a4773c75689b9f17f2892db2
parent622e89a7ab39d9938c54bc0e7412578377e016a9
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