linux-stable/arch/x86/kvm
Sean Christopherson c4abd73520 KVM: VMX: Don't fudge CR0 and CR4 for restricted L2 guest
Stuff CR0 and/or CR4 to be compliant with a restricted guest if and only
if KVM itself is not configured to utilize unrestricted guests, i.e. don't
stuff CR0/CR4 for a restricted L2 that is running as the guest of an
unrestricted L1.  Any attempt to VM-Enter a restricted guest with invalid
CR0/CR4 values should fail, i.e. in a nested scenario, KVM (as L0) should
never observe a restricted L2 with incompatible CR0/CR4, since nested
VM-Enter from L1 should have failed.

And if KVM does observe an active, restricted L2 with incompatible state,
e.g. due to a KVM bug, fudging CR0/CR4 instead of letting VM-Enter fail
does more harm than good, as KVM will often neglect to undo the side
effects, e.g. won't clear rmode.vm86_active on nested VM-Exit, and thus
the damage can easily spill over to L1.  On the other hand, letting
VM-Enter fail due to bad guest state is more likely to contain the damage
to L2 as KVM relies on hardware to perform most guest state consistency
checks, i.e. KVM needs to be able to reflect a failed nested VM-Enter into
L1 irrespective of (un)restricted guest behavior.

Cc: Jim Mattson <jmattson@google.com>
Cc: stable@vger.kernel.org
Fixes: bddd82d19e ("KVM: nVMX: KVM needs to unset "unrestricted guest" VM-execution control in vmcs02 if vmcs12 doesn't set it")
Signed-off-by: Sean Christopherson <seanjc@google.com>
Message-Id: <20230613203037.1968489-3-seanjc@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2023-07-29 11:05:32 -04:00
..
mmu KVM VMX changes for 6.5: 2023-07-01 07:20:04 -04:00
svm KVM: x86: Disallow KVM_SET_SREGS{2} if incoming CR0 is invalid 2023-07-29 11:05:31 -04:00
vmx KVM: VMX: Don't fudge CR0 and CR4 for restricted L2 guest 2023-07-29 11:05:32 -04:00
.gitignore KVM: x86: use a separate asm-offsets.c file 2022-11-09 12:10:17 -05:00
Kconfig kvm: Remove "select SRCU" 2023-04-05 13:47:42 +00:00
Makefile KVM: x86: Introduce .hv_inject_synthetic_vmexit_post_tlb_flush() nested hook 2022-11-18 12:59:13 -05:00
cpuid.c KVM x86/pmu changes for 6.5: 2023-07-01 07:18:51 -04:00
cpuid.h KVM: x86: Add dedicated helper to get CPUID entry with significant index 2022-07-14 11:38:32 -04:00
debugfs.c KVM: x86: Unify pr_fmt to use module name for all KVM modules 2022-12-29 15:47:35 -05:00
emulate.c KVM: x86: Assert that the emulator doesn't load CS with garbage in !RM 2023-03-23 16:07:52 -07:00
fpu.h KVM: x86: Move FPU register accessors into fpu.h 2021-06-17 13:09:24 -04:00
hyperv.c KVM x86 PMU changes for 6.3: 2023-02-15 08:23:24 -05:00
hyperv.h KVM: x86: Hyper-V invariant TSC control 2022-12-29 15:33:29 -05:00
i8254.c KVM: x86: Unify pr_fmt to use module name for all KVM modules 2022-12-29 15:47:35 -05:00
i8254.h KVM: x86: PIT: Preserve state of speaker port data bit 2022-06-08 13:06:20 -04:00
i8259.c KVM: x86: Fix poll command 2023-06-01 13:44:13 -07:00
ioapic.c KVM: x86/ioapic: Resample the pending state of an IRQ when unmasking 2023-03-27 10:13:28 -04:00
ioapic.h x86/kvm: remove unused ack_notifier callbacks 2021-11-18 07:05:57 -05:00
irq.c KVM: x86: Unify pr_fmt to use module name for all KVM modules 2022-12-29 15:47:35 -05:00
irq.h x86/kvm: remove unused ack_notifier callbacks 2021-11-18 07:05:57 -05:00
irq_comm.c KVM: x86: Unify pr_fmt to use module name for all KVM modules 2022-12-29 15:47:35 -05:00
kvm-asm-offsets.c KVM: SVM: move MSR_IA32_SPEC_CTRL save/restore to assembly 2022-11-09 12:25:53 -05:00
kvm_cache_regs.h KVM: x86: Add helpers to query individual CR0/CR4 bits 2023-03-22 10:10:53 -07:00
kvm_emulate.h KVM: x86: Use emulator callbacks instead of duplicating "host flags" 2023-01-31 17:29:09 -08:00
kvm_onhyperv.c KVM: x86/mmu: Move filling of Hyper-V's TLB range struct into Hyper-V code 2023-04-10 15:17:29 -07:00
kvm_onhyperv.h s390: 2023-05-01 12:06:20 -07:00
lapic.c KVM: x86: VMX: set irr_pending in kvm_apic_update_irr 2023-07-29 11:05:24 -04:00
lapic.h KVM: x86: Split out logic to generate "readable" APIC regs mask to helper 2023-01-24 10:04:35 -08:00
mmu.h KVM: x86/mmu: Refresh CR0.WP prior to checking for emulated permission faults 2023-04-10 15:25:36 -07:00
mtrr.c KVM: x86: Make kvm_mtrr_valid() static now that there are no external users 2023-06-01 13:41:06 -07:00
pmu.c KVM: x86/svm/pmu: Add AMD PerfMonV2 support 2023-06-06 17:31:44 -07:00
pmu.h KVM: x86/pmu: Disable vPMU if the minimum num of counters isn't met 2023-06-06 17:31:44 -07:00
reverse_cpuid.h KVM: x86/cpuid: Add a KVM-only leaf to redirect AMD PerfMonV2 flag 2023-06-06 17:31:44 -07:00
smm.c KVM: x86: Use emulator callbacks instead of duplicating "host flags" 2023-01-31 17:29:09 -08:00
smm.h KVM: x86: smm: preserve interrupt shadow in SMRAM 2022-11-09 12:31:26 -05:00
trace.h KVM: x86/xen: Add CPL to Xen hypercall tracepoint 2022-11-28 13:31:01 -05:00
tss.h
x86.c KVM: x86: Disallow KVM_SET_SREGS{2} if incoming CR0 is invalid 2023-07-29 11:05:31 -04:00
x86.h KVM: x86: Make kvm_mtrr_valid() static now that there are no external users 2023-06-01 13:41:06 -07:00
xen.c KVM: x86/xen: update Xen CPUID Leaf 4 (tsc info) sub-leaves, if present 2023-01-24 10:05:20 -08:00
xen.h KVM: x86/xen: update Xen CPUID Leaf 4 (tsc info) sub-leaves, if present 2023-01-24 10:05:20 -08:00