Re: [PATCH 20/25] powerpc: Handle exceptions caused by pkey violation
From: Aneesh Kumar K.V <hidden>
Date: 2017-10-29 14:03:41
Michael Ellerman [off-list ref] writes:
Ram Pai [off-list ref] writes:quoted
Handle Data and Instruction exceptions caused by memory protection-key. The CPU will detect the key fault if the HPTE is already programmed with the key. However if the HPTE is not hashed, a key fault will not be detected by the hardware. The software will detect pkey violation in such a case.That seems like the wrong trade off to me. It means every fault has to go through arch_vma_access_permitted(), which is at least a function call in the best case, even when pkeys are not in use, and/or the range in question is not protected by a key.
We don't really need to call arch_vma_access_permitted() in arch/powerpc/ do_page_fault(). Core kernel does that in handle_mm_fault(). So if the first fault is a bad access handle_mm_fault handle this. If it is a valid access we insert the right hash page table entry and then we do a wrong access, we detect that a key fault in the low level hash fault handler. IIUC, the call the arch_vma_access_permitted() from arch/powerpc/ can go away? -aneesh