Commit f2ed480f authored by Aneesh Kumar K.V's avatar Aneesh Kumar K.V Committed by Michael Ellerman

powerpc/mm/keys: Update documentation and remove unnecessary check

Adds more code comments. We also remove an unnecessary pkey check
after we check for pkey error in this patch.
Signed-off-by: default avatarAneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
parent b9ee31e1
...@@ -297,7 +297,12 @@ static bool access_error(bool is_write, bool is_exec, ...@@ -297,7 +297,12 @@ static bool access_error(bool is_write, bool is_exec,
if (unlikely(!(vma->vm_flags & (VM_READ | VM_EXEC | VM_WRITE)))) if (unlikely(!(vma->vm_flags & (VM_READ | VM_EXEC | VM_WRITE))))
return true; return true;
/*
* We should ideally do the vma pkey access check here. But in the
* fault path, handle_mm_fault() also does the same check. To avoid
* these multiple checks, we skip it here and handle access error due
* to pkeys later.
*/
return false; return false;
} }
...@@ -518,26 +523,17 @@ static int __do_page_fault(struct pt_regs *regs, unsigned long address, ...@@ -518,26 +523,17 @@ static int __do_page_fault(struct pt_regs *regs, unsigned long address,
#ifdef CONFIG_PPC_MEM_KEYS #ifdef CONFIG_PPC_MEM_KEYS
/* /*
* if the HPTE is not hashed, hardware will not detect * we skipped checking for access error due to key earlier.
* a key fault. Lets check if we failed because of a * Check that using handle_mm_fault error return.
* software detected key fault.
*/ */
if (unlikely(fault & VM_FAULT_SIGSEGV) && if (unlikely(fault & VM_FAULT_SIGSEGV) &&
!arch_vma_access_permitted(vma, flags & FAULT_FLAG_WRITE, !arch_vma_access_permitted(vma, is_write, is_exec, 0)) {
is_exec, 0)) {
/*
* The PGD-PDT...PMD-PTE tree may not have been fully setup.
* Hence we cannot walk the tree to locate the PTE, to locate
* the key. Hence let's use vma_pkey() to get the key; instead
* of get_mm_addr_key().
*/
int pkey = vma_pkey(vma); int pkey = vma_pkey(vma);
if (likely(pkey)) {
up_read(&mm->mmap_sem); up_read(&mm->mmap_sem);
return bad_key_fault_exception(regs, address, pkey); return bad_key_fault_exception(regs, address, pkey);
} }
}
#endif /* CONFIG_PPC_MEM_KEYS */ #endif /* CONFIG_PPC_MEM_KEYS */
major |= fault & VM_FAULT_MAJOR; major |= fault & VM_FAULT_MAJOR;
......
...@@ -119,18 +119,15 @@ int pkey_initialize(void) ...@@ -119,18 +119,15 @@ int pkey_initialize(void)
#else #else
os_reserved = 0; os_reserved = 0;
#endif #endif
initial_allocation_mask = ~0x0;
pkey_amr_uamor_mask = ~0x0ul;
pkey_iamr_mask = ~0x0ul;
/* /*
* Bits are in LE format. NOTE: 1, 0 are reserved. * key 0, 1 are reserved.
* key 0 is the default key, which allows read/write/execute. * key 0 is the default key, which allows read/write/execute.
* key 1 is recommended not to be used. PowerISA(3.0) page 1015, * key 1 is recommended not to be used. PowerISA(3.0) page 1015,
* programming note. * programming note.
*/ */
initial_allocation_mask = ~0x0;
/* register mask is in BE format */
pkey_amr_uamor_mask = ~0x0ul;
pkey_iamr_mask = ~0x0ul;
for (i = 2; i < (pkeys_total - os_reserved); i++) { for (i = 2; i < (pkeys_total - os_reserved); i++) {
initial_allocation_mask &= ~(0x1 << i); initial_allocation_mask &= ~(0x1 << i);
pkey_amr_uamor_mask &= ~(0x3ul << pkeyshift(i)); pkey_amr_uamor_mask &= ~(0x3ul << pkeyshift(i));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment