OpenCloudOS-Kernel/arch/x86/kvm/vmx
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
..
capabilities.h KVM: VMX: Treat UMIP as emulated if and only if the host doesn't have UMIP 2023-05-26 13:50:42 -07:00
hyperv.c KVM: VMX: Rename "KVM is using eVMCS" static key to match its wrapper 2023-03-14 10:28:58 -04:00
hyperv.h KVM: VMX: Rename "KVM is using eVMCS" static key to match its wrapper 2023-03-14 10:28:58 -04:00
nested.c KVM VMX changes for 6.5: 2023-07-01 07:20:04 -04:00
nested.h KVM: nVMX: Reword comments about generating nested CR0/4 read shadows 2022-11-30 16:27:17 -08:00
pmu_intel.c KVM VMX changes for 6.5: 2023-07-01 07:20:04 -04:00
posted_intr.c KVM: x86: Unify pr_fmt to use module name for all KVM modules 2022-12-29 15:47:35 -05:00
posted_intr.h KVM: VMX: enable IPI virtualization 2022-06-08 04:47:37 -04:00
run_flags.h KVM: VMX: Prevent guest RSB poisoning attacks with eIBRS 2022-06-27 10:34:00 +02:00
sgx.c KVM: VMX: Inject #GP, not #UD, if SGX2 ENCLS leafs are unsupported 2023-06-02 10:12:03 -07:00
sgx.h KVM: VMX: Enable SGX virtualization for SGX1, SGX2 and LC 2021-04-20 04:18:56 -04:00
vmcs.h KVM: VMX: Handle NMI VM-Exits in noinstr region 2023-01-24 10:36:41 -08:00
vmcs12.c KVM: x86: Unify pr_fmt to use module name for all KVM modules 2022-12-29 15:47:35 -05:00
vmcs12.h bug: introduce ASSERT_STRUCT_OFFSET 2022-11-09 12:31:16 -05:00
vmcs_shadow_fields.h KVM: Fix some out-dated function names in comment 2020-01-21 13:57:27 +01:00
vmenter.S KVM: VMX: Make VMREAD error path play nice with noinstr 2023-07-29 11:05:26 -04:00
vmx.c KVM: VMX: Don't fudge CR0 and CR4 for restricted L2 guest 2023-07-29 11:05:32 -04:00
vmx.h KVM: x86/pmu: Move handling PERF_GLOBAL_CTRL and friends to common x86 2023-06-06 17:31:44 -07:00
vmx_ops.h KVM: VMX: Use vmread_error() to report VM-Fail in "goto" path 2023-07-29 11:05:26 -04:00