diff options
author | Paolo Bonzini <pbonzini@redhat.com> | 2016-02-23 14:19:20 +0100 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2016-03-08 12:33:39 +0100 |
commit | bb9eadf0c35f2e7eb5ca6468f46ebb7473b85537 (patch) | |
tree | 3fb92f61097ab74cdcd5d4b803bf8d534adb4939 /arch/x86/kvm | |
parent | 6bb69c9b69c315200ddc2bc79aee14c0184cf5b2 (diff) | |
download | linux-bb9eadf0c35f2e7eb5ca6468f46ebb7473b85537.tar.gz linux-bb9eadf0c35f2e7eb5ca6468f46ebb7473b85537.tar.bz2 linux-bb9eadf0c35f2e7eb5ca6468f46ebb7473b85537.zip |
KVM: MMU: micro-optimize gpte_access
Avoid AND-NOT, most x86 processor lack an instruction for it.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'arch/x86/kvm')
-rw-r--r-- | arch/x86/kvm/paging_tmpl.h | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/arch/x86/kvm/paging_tmpl.h b/arch/x86/kvm/paging_tmpl.h index a1f5459edcec..6013f3685ef4 100644 --- a/arch/x86/kvm/paging_tmpl.h +++ b/arch/x86/kvm/paging_tmpl.h @@ -189,8 +189,11 @@ static inline unsigned FNAME(gpte_access)(struct kvm_vcpu *vcpu, u64 gpte) ((gpte & VMX_EPT_EXECUTABLE_MASK) ? ACC_EXEC_MASK : 0) | ACC_USER_MASK; #else - access = (gpte & (PT_WRITABLE_MASK | PT_USER_MASK)) | ACC_EXEC_MASK; - access &= ~(gpte >> PT64_NX_SHIFT); + BUILD_BUG_ON(ACC_EXEC_MASK != PT_PRESENT_MASK); + BUILD_BUG_ON(ACC_EXEC_MASK != 1); + access = gpte & (PT_WRITABLE_MASK | PT_USER_MASK | PT_PRESENT_MASK); + /* Combine NX with P (which is set here) to get ACC_EXEC_MASK. */ + access ^= (gpte >> PT64_NX_SHIFT); #endif return access; |