linux-brain/arch/x86/kvm/vmx
Sean Christopherson 032fd28ed5 KVM: nVMX: Ensure 64-bit shift when checking VMFUNC bitmap
[ Upstream commit 0e75225dfa4c5d5d51291f54a3d2d5895bad38da ]

Use BIT_ULL() instead of an open-coded shift to check whether or not a
function is enabled in L1's VMFUNC bitmap.  This is a benign bug as KVM
supports only bit 0, and will fail VM-Enter if any other bits are set,
i.e. bits 63:32 are guaranteed to be zero.

Note, "function" is bounded by hardware as VMFUNC will #UD before taking
a VM-Exit if the function is greater than 63.

Before:
  if ((vmcs12->vm_function_control & (1 << function)) == 0)
   0x000000000001a916 <+118>:	mov    $0x1,%eax
   0x000000000001a91b <+123>:	shl    %cl,%eax
   0x000000000001a91d <+125>:	cltq
   0x000000000001a91f <+127>:	and    0x128(%rbx),%rax

After:
  if (!(vmcs12->vm_function_control & BIT_ULL(function & 63)))
   0x000000000001a955 <+117>:	mov    0x128(%rbx),%rdx
   0x000000000001a95c <+124>:	bt     %rax,%rdx

Fixes: 27c42a1bb8 ("KVM: nVMX: Enable VMFUNC for the L1 hypervisor")
Signed-off-by: Sean Christopherson <seanjc@google.com>
Message-Id: <20210609234235.1244004-3-seanjc@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2021-07-14 16:53:23 +02:00
..
capabilities.h KVM: nVMX: clear PIN_BASED_POSTED_INTR from nested pinbased_ctls only when apicv is globally disabled 2020-02-28 17:22:23 +01:00
evmcs.c x86/kvm/nVMX: fix VMCLEAR when Enlightened VMCS is in use 2019-07-02 18:56:00 +02:00
evmcs.h KVM/Hyper-V/VMX: Add direct tlb flush support 2019-09-24 13:37:14 +02:00
nested.c KVM: nVMX: Ensure 64-bit shift when checking VMFUNC bitmap 2021-07-14 16:53:23 +02:00
nested.h KVM: nVMX: clear PIN_BASED_POSTED_INTR from nested pinbased_ctls only when apicv is globally disabled 2020-02-28 17:22:23 +01:00
ops.h x86/kvm: fix a missing-prototypes "vmread_error" 2020-05-10 10:31:31 +02:00
pmu_intel.c KVM: x86/pmu: Fix UBSAN shift-out-of-bounds warning in intel_pmu_refresh() 2021-02-03 23:25:57 +01:00
vmcs.h KVM: VMX: Leave preemption timer running when it's disabled 2019-06-18 17:10:46 +02:00
vmcs12.c KVM: nVMX: Move vmcs12 code to dedicated files 2018-12-14 12:34:30 +01:00
vmcs12.h KVM/arm updates for 5.3 2019-07-11 15:14:16 +02:00
vmcs_shadow_fields.h KVM: nVMX: shadow pin based execution controls 2019-06-18 17:10:50 +02:00
vmenter.S KVM: VMX: Explicitly clear RFLAGS.CF and RFLAGS.ZF in VM-Exit RSB path 2020-05-14 07:58:25 +02:00
vmx.c kvm: x86: replace kvm_spec_ctrl_test_value with runtime test on the host 2021-03-04 10:26:09 +01:00
vmx.h KVM: VMX: Stop context switching MSR_IA32_UMWAIT_CONTROL 2020-06-30 15:37:07 -04:00