Skip to content

Commit b3c03fe

Browse files
jgoulywilldeacon
authored andcommitted
arm64: convert protection key into vm_flags and pgprot values
Modify arch_calc_vm_prot_bits() and vm_get_page_prot() such that the pkey value is set in the vm_flags and then into the pgprot value. Signed-off-by: Joey Gouly <[email protected]> Cc: Catalin Marinas <[email protected]> Cc: Will Deacon <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Will Deacon <[email protected]>
1 parent b66db4f commit b3c03fe

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

arch/arm64/include/asm/mman.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#include <uapi/asm/mman.h>
88

99
static inline unsigned long arch_calc_vm_prot_bits(unsigned long prot,
10-
unsigned long pkey __always_unused)
10+
unsigned long pkey)
1111
{
1212
unsigned long ret = 0;
1313

@@ -17,6 +17,14 @@ static inline unsigned long arch_calc_vm_prot_bits(unsigned long prot,
1717
if (system_supports_mte() && (prot & PROT_MTE))
1818
ret |= VM_MTE;
1919

20+
#ifdef CONFIG_ARCH_HAS_PKEYS
21+
if (system_supports_poe()) {
22+
ret |= pkey & BIT(0) ? VM_PKEY_BIT0 : 0;
23+
ret |= pkey & BIT(1) ? VM_PKEY_BIT1 : 0;
24+
ret |= pkey & BIT(2) ? VM_PKEY_BIT2 : 0;
25+
}
26+
#endif
27+
2028
return ret;
2129
}
2230
#define arch_calc_vm_prot_bits(prot, pkey) arch_calc_vm_prot_bits(prot, pkey)

arch/arm64/mm/mmap.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,17 @@ pgprot_t vm_get_page_prot(unsigned long vm_flags)
102102
if (vm_flags & VM_MTE)
103103
prot |= PTE_ATTRINDX(MT_NORMAL_TAGGED);
104104

105+
#ifdef CONFIG_ARCH_HAS_PKEYS
106+
if (system_supports_poe()) {
107+
if (vm_flags & VM_PKEY_BIT0)
108+
prot |= PTE_PO_IDX_0;
109+
if (vm_flags & VM_PKEY_BIT1)
110+
prot |= PTE_PO_IDX_1;
111+
if (vm_flags & VM_PKEY_BIT2)
112+
prot |= PTE_PO_IDX_2;
113+
}
114+
#endif
115+
105116
return __pgprot(prot);
106117
}
107118
EXPORT_SYMBOL(vm_get_page_prot);

0 commit comments

Comments
 (0)