Re: [PATCH v2 1/2] KVM: nVMX: don't use vcpu->arch.efer when checking host state on nested state load

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 11/15/21 16:50, Sean Christopherson wrote:
   When loading nested state, don't use check vcpu->arch.efer to get the
   L1 host's 64-bit vs. 32-bit state and don't check it for consistency
   with respect to VM_EXIT_HOST_ADDR_SPACE_SIZE, as register state in vCPU
   may be stale when KVM_SET_NESTED_STATE is called and conceptually does
   not exist.  When the CPU is in non-root mode, i.e. when restoring L2
   state in KVM, there is no snapshot of L1 host state, it is (conditionally)
   loaded on VM-Exit.  E.g. EFER is either preserved on exit, loaded from the
   VMCS (vmcs12 in this case), or loaded from the MSR load list.

   Use vmcs12.VM_EXIT_HOST_ADDR_SPACE_SIZE to determine the target mode of
   the L1 host, as it is the source of truth in this case.  Perform the EFER
   vs. vmcs12.VM_EXIT_HOST_ADDR_SPACE_SIZE consistency check only on VM-Enter,
   as conceptually there's no "current" L1 EFER to check.

   Note, KVM still checks vmcs12.HOST_EFER for consistency if
   if vmcs12.VM_EXIT_LOAD_IA32_EFER is set, i.e. this skips only the check
   against current vCPU state, which does not exist, when loading nested state.

Queued with some further edits and nested_vmx_check_address_state_size renamed to nested_vmx_check_address_*space*_size.

I think the "!!" are best left in place though, because "!!(a & b)" is idiomatic. Comparing "!(a & b)" would leave the reader wondering about the inversion, and "(bool)(a & b)" is just too ugly and magic. The compiler anyway converts the "!!" to "!= 0" very early on, and never performs back-to-back logical NOTs.

Paolo




[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux