powerpc: capture the violated protection key on fault
RFC v7 23/25 powerpc: capture the violated protection key on fault
Capture the protection key that got violated in paca. This value will be later used to inform the signal handler.
Signed-off-by Ram Pai <[email protected]>
--- arch/powerpc/include/asm/paca.h | 1 + arch/powerpc/kernel/asm-offsets.c | 1 + arch/powerpc/mm/fault.c | 8 ++++++++ 3 files changed, 10 insertions(+), 0 deletions(-)
arch/powerpc/include/asm/paca.h +1 -0
@@ -94,6 +94,7 @@ struct paca_struct {u64 dscr_default;/* per-CPU default DSCR */ #ifdef CONFIG_PPC64_MEMORY_PROTECTION_KEYS u64 paca_amr;/* value of amr at exception */ +u16 paca_pkey;/* exception causing pkey */ #endif /* CONFIG_PPC64_MEMORY_PROTECTION_KEYS */ #ifdef CONFIG_PPC_STD_MMU_64
arch/powerpc/kernel/asm-offsets.c +1 -0
@@ -244,6 +244,7 @@ int main(void)#ifdef CONFIG_PPC64_MEMORY_PROTECTION_KEYS OFFSET (PACA_AMR , paca_struct, paca_amr); +OFFSET (PACA_PKEY , paca_struct, paca_pkey);#endif /* CONFIG_PPC64_MEMORY_PROTECTION_KEYS */ OFFSET (ACCOUNT_STARTTIME , paca_struct, accounting.starttime);
arch/powerpc/mm/fault.c +8 -0
@@ -265,6 +265,7 @@ int do_page_fault(struct pt_regs *regs, unsigned long address,if (error_code &DSISR_KEYFAULT ) { code =SEGV_PKUERR ;get_paca ()->paca_amr =read_amr (); +get_paca ()->paca_pkey =get_pte_pkey (current->mm, address); goto bad_area_nosemaphore; }#endif /* CONFIG_PPC64_MEMORY_PROTECTION_KEYS */
@@ -453,6 +454,13 @@ int do_page_fault(struct pt_regs *regs, unsigned long address,if (!arch_vma_access_permitted (vma, flags &FAULT_FLAG_WRITE , is_exec,0 )) {get_paca ()->paca_amr =read_amr (); +/* +* 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 lets use vma_pkey() to get the key; instead +* of get_pte_pkey(). +*/ +get_paca ()->paca_pkey =vma_pkey (vma); code =SEGV_PKUERR ; goto bad_area; }
Signature · 1 line
1.7.1