KVM: x86: Add is_executable_pte()
authorBen Hutchings <ben@decadent.org.uk>
Sat, 19 Oct 2019 17:10:55 +0000 (18:10 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 16 Nov 2019 09:29:52 +0000 (10:29 +0100)
Extracted from commit d3e328f2cb01 "kvm: x86: mmu: Verify that
restored PTE has needed perms in fast page fault".

Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
arch/x86/kvm/mmu.c

index a1edd19a1665cbc4c3bcd647bbf2b44989ddba0b..96a0601a47c41425d90b1cb41058ea6f1c43d542 100644 (file)
@@ -338,6 +338,11 @@ static int is_last_spte(u64 pte, int level)
        return 0;
 }
 
+static bool is_executable_pte(u64 spte)
+{
+       return (spte & (shadow_x_mask | shadow_nx_mask)) == shadow_x_mask;
+}
+
 static kvm_pfn_t spte_to_pfn(u64 pte)
 {
        return (pte & PT64_BASE_ADDR_MASK) >> PAGE_SHIFT;