On Sun, Oct 29, 2017 at 07:33:25PM +0530, Aneesh Kumar K.V wrote: > Michael Ellerman <m...@ellerman.id.au> writes: > > > Ram Pai <linux...@us.ibm.com> writes: > > > >> 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?
Yes. since handle_mm_fault() checks for key-violation, we can leverage that in __do_page_fault(), instead of calling arch_vma_access_permitted(). Have fixed it in the next version of patches, about to to hit the mailing list this week. RP