x86/mm/pkeys: Add arch-specific VMA protection bits
[cascardo/linux.git] / arch / x86 / include / asm / mmu_context.h
index bfd9b2a..94c4c8b 100644 (file)
@@ -275,4 +275,15 @@ static inline void arch_unmap(struct mm_struct *mm, struct vm_area_struct *vma,
                mpx_notify_unmap(mm, vma, start, end);
 }
 
+static inline int vma_pkey(struct vm_area_struct *vma)
+{
+       u16 pkey = 0;
+#ifdef CONFIG_X86_INTEL_MEMORY_PROTECTION_KEYS
+       unsigned long vma_pkey_mask = VM_PKEY_BIT0 | VM_PKEY_BIT1 |
+                                     VM_PKEY_BIT2 | VM_PKEY_BIT3;
+       pkey = (vma->vm_flags & vma_pkey_mask) >> VM_PKEY_SHIFT;
+#endif
+       return pkey;
+}
+
 #endif /* _ASM_X86_MMU_CONTEXT_H */