diff options
Diffstat (limited to 'arch/x86/kvm/vmx.c')
-rw-r--r-- | arch/x86/kvm/vmx.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index 0cf74a641dec..fe9a9cfadbd6 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c | |||
@@ -3227,6 +3227,14 @@ static int vmx_set_cr4(struct kvm_vcpu *vcpu, unsigned long cr4) | |||
3227 | if (!is_paging(vcpu)) { | 3227 | if (!is_paging(vcpu)) { |
3228 | hw_cr4 &= ~X86_CR4_PAE; | 3228 | hw_cr4 &= ~X86_CR4_PAE; |
3229 | hw_cr4 |= X86_CR4_PSE; | 3229 | hw_cr4 |= X86_CR4_PSE; |
3230 | /* | ||
3231 | * SMEP is disabled if CPU is in non-paging mode in | ||
3232 | * hardware. However KVM always uses paging mode to | ||
3233 | * emulate guest non-paging mode with TDP. | ||
3234 | * To emulate this behavior, SMEP needs to be manually | ||
3235 | * disabled when guest switches to non-paging mode. | ||
3236 | */ | ||
3237 | hw_cr4 &= ~X86_CR4_SMEP; | ||
3230 | } else if (!(cr4 & X86_CR4_PAE)) { | 3238 | } else if (!(cr4 & X86_CR4_PAE)) { |
3231 | hw_cr4 &= ~X86_CR4_PAE; | 3239 | hw_cr4 &= ~X86_CR4_PAE; |
3232 | } | 3240 | } |