summaryrefslogtreecommitdiff
path: root/arch
diff options
context:
space:
mode:
authorLai Jiangshan <laijs@linux.alibaba.com>2021-12-07 12:52:30 +0300
committerPaolo Bonzini <pbonzini@redhat.com>2021-12-10 17:38:01 +0300
commit777ab82d7ce0451fd47bb57e331548deba57394e (patch)
tree5e00debaa29d98948bea76576ba01d36dbff5cce /arch
parentc8cc43c1eae2910ac96daa4216e0fb3391ad0504 (diff)
downloadlinux-777ab82d7ce0451fd47bb57e331548deba57394e.tar.xz
KVM: X86: Raise #GP when clearing CR0_PG in 64 bit mode
In the SDM: If the logical processor is in 64-bit mode or if CR4.PCIDE = 1, an attempt to clear CR0.PG causes a general-protection exception (#GP). Software should transition to compatibility mode and clear CR4.PCIDE before attempting to disable paging. Signed-off-by: Lai Jiangshan <laijs@linux.alibaba.com> Message-Id: <20211207095230.53437-1-jiangshanlai@gmail.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'arch')
-rw-r--r--arch/x86/kvm/x86.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index e0aa4dd53c7f..c473498c8512 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -890,7 +890,8 @@ int kvm_set_cr0(struct kvm_vcpu *vcpu, unsigned long cr0)
!load_pdptrs(vcpu, vcpu->arch.walk_mmu, kvm_read_cr3(vcpu)))
return 1;
- if (!(cr0 & X86_CR0_PG) && kvm_read_cr4_bits(vcpu, X86_CR4_PCIDE))
+ if (!(cr0 & X86_CR0_PG) &&
+ (is_64_bit_mode(vcpu) || kvm_read_cr4_bits(vcpu, X86_CR4_PCIDE)))
return 1;
static_call(kvm_x86_set_cr0)(vcpu, cr0);