linux-brain/arch/x86/kvm
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
..
vmx KVM: nVMX: Ensure 64-bit shift when checking VMFUNC bitmap 2021-07-14 16:53:23 +02:00
Kconfig kvm: x86: add host poll control msrs 2019-06-18 11:43:46 +02:00
Makefile KVM: x86: fix TRACE_INCLUDE_PATH and remove -I. header search paths 2019-01-25 19:12:37 +01:00
cpuid.c kvm/svm: PKU not currently supported 2020-02-11 04:35:40 -08:00
cpuid.h KVM: x86: reinstate vendor-agnostic check on SPEC_CTRL cpuid bits 2021-01-06 14:48:36 +01:00
debugfs.c KVM: no need to check return value of debugfs_create functions 2019-08-05 12:55:49 +02:00
emulate.c KVM: x86: Update emulator context mode if SYSENTER xfers to 64-bit mode 2021-02-10 09:25:31 +01:00
hyperv.c KVM: x86: Protect kvm_hv_msr_[get|set]_crash_data() from Spectre-v1/L1TF attacks 2020-02-11 04:35:38 -08:00
hyperv.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 499 2019-06-19 17:09:53 +02:00
i8254.c kvm: x86: Add memcg accounting to KVM allocations 2019-02-20 22:48:30 +01:00
i8254.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
i8259.c KVM: x86: Refactor picdev_write() to prevent Spectre-v1/L1TF attacks 2020-02-11 04:35:37 -08:00
ioapic.c KVM: x86: Protect ioapic_read_indirect() from Spectre-v1/L1TF attacks 2020-02-11 04:35:38 -08:00
ioapic.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
irq.c KVM: x86: Fix split-irqchip vs interrupt injection window request 2020-12-02 08:49:46 +01:00
irq.h KVM/arm updates for 5.3 2019-07-11 15:14:16 +02:00
irq_comm.c KVM: x86: don't notify userspace IOAPIC on edge-triggered interrupt EOI 2020-02-28 17:22:22 +01:00
kvm_cache_regs.h KVM: x86: Mark CR4.TSD as being possibly owned by the guest 2020-07-16 08:16:44 +02:00
lapic.c kvm: LAPIC: Restore guard to prevent illegal APIC register access 2021-06-23 14:41:23 +02:00
lapic.h KVM: SVM: Fix potential wrong physical id in avic_handle_ldr_update 2019-10-22 18:47:50 +02:00
mmu.c KVM: x86/mmu: Remove the defunct update_pte() paging hook 2021-05-19 10:08:20 +02:00
mmu.h KVM: x86: fix shift out of bounds reported by UBSAN 2021-01-12 20:16:25 +01:00
mmu_audit.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 499 2019-06-19 17:09:53 +02:00
mmutrace.h KVM: x86: fix incorrect comparison in trace event 2020-10-01 13:17:35 +02:00
mtrr.c KVM: x86: Protect MSR-based index computations in fixed_msr_to_seg_unit() from Spectre-v1/L1TF attacks 2020-02-11 04:35:39 -08:00
page_track.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 499 2019-06-19 17:09:53 +02:00
paging_tmpl.h KVM: nVMX: Plumb L2 GPA through to PML emulation 2020-06-30 15:37:07 -04:00
pmu.c KVM: x86: Add fixed counters to PMU filter 2019-07-20 09:00:48 +02:00
pmu.h KVM: x86: Protect MSR-based index computations in pmu.h from Spectre-v1/L1TF attacks 2020-02-11 04:35:38 -08:00
pmu_amd.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 499 2019-06-19 17:09:53 +02:00
svm.c KVM: SVM: Call SEV Guest Decommission if ASID binding fails 2021-07-11 12:52:07 +02:00
trace.h KVM: x86: Ensure liveliness of nested VM-Enter fail tracepoint message 2021-06-16 11:59:44 +02:00
tss.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
x86.c KVM: x86: Immediately reset the MMU context when the SMM flag is cleared 2021-06-23 14:41:29 +02:00
x86.h kvm: x86: replace kvm_spec_ctrl_test_value with runtime test on the host 2021-03-04 10:26:09 +01:00