kvm: x86: hyperv: make VP_INDEX managed by userspace
Hyper-V identifies vCPUs by Virtual Processor Index, which can be queried via HV_X64_MSR_VP_INDEX msr. It is defined by the spec as a sequential number which can't exceed the maximum number of vCPUs per VM. APIC ids can be sparse and thus aren't a valid replacement for VP indices. Current KVM uses its internal vcpu index as VP_INDEX. However, to make it predictable and persistent across VM migrations, the userspace has to control the value of VP_INDEX. This patch achieves that, by storing vp_index explicitly on vcpu, and allowing HV_X64_MSR_VP_INDEX to be set from the host side. For compatibility it's initialized to KVM vcpu index. Also a few variables are renamed to make clear distinction betweed this Hyper-V vp_index and KVM vcpu_id (== APIC id). Besides, a new capability, KVM_CAP_HYPERV_VP_INDEX, is added to allow the userspace to skip attempting msr writes where unsupported, to avoid spamming error logs. Signed-off-by: Roman Kagan <rkagan@virtuozzo.com> Signed-off-by: Radim Krčmář <rkrcmar@redhat.com>
This commit is contained in:

committato da
Radim Krčmář

parent
52a5c155cf
commit
d3457c877b
@@ -4338,3 +4338,12 @@ This capability enables a newer version of Hyper-V Synthetic interrupt
|
||||
controller (SynIC). The only difference with KVM_CAP_HYPERV_SYNIC is that KVM
|
||||
doesn't clear SynIC message and event flags pages when they are enabled by
|
||||
writing to the respective MSRs.
|
||||
|
||||
8.12 KVM_CAP_HYPERV_VP_INDEX
|
||||
|
||||
Architectures: x86
|
||||
|
||||
This capability indicates that userspace can load HV_X64_MSR_VP_INDEX msr. Its
|
||||
value is used to denote the target vcpu for a SynIC interrupt. For
|
||||
compatibilty, KVM initializes this msr to KVM's internal vcpu index. When this
|
||||
capability is absent, userspace can still query this msr's value.
|
||||
|
Fai riferimento in un nuovo problema
Block a user