linux-stable/arch/powerpc/mm
Christophe Leroy 232ca1eeca powerpc/32s: Fix DSI and ISI exceptions for CONFIG_VMAP_STACK
hash_page() needs to read page tables from kernel memory. When entire
kernel memory is mapped by BATs, which is normally the case when
CONFIG_STRICT_KERNEL_RWX is not set, it works even if the page hosting
the page table is not referenced in the MMU hash table.

However, if the page where the page table resides is not covered by
a BAT, a DSI fault can be encountered from hash_page(), and it loops
forever. This can happen when CONFIG_STRICT_KERNEL_RWX is selected
and the alignment of the different regions is too small to allow
covering the entire memory with BATs. This also happens when
CONFIG_DEBUG_PAGEALLOC is selected or when booting with 'nobats'
flag.

Also, if the page containing the kernel stack is not present in the
MMU hash table, registers cannot be saved and a recursive DSI fault
is encountered.

To allow hash_page() to properly do its job at all time and load the
MMU hash table whenever needed, it must run with data MMU disabled.
This means it must be called before re-enabling data MMU. To allow
this, registers clobbered by hash_page() and create_hpte() have to
be saved in the thread struct together with SRR0, SSR1, DAR and DSISR.
It is also necessary to ensure that DSI prolog doesn't overwrite
regs saved by prolog of the current running exception. That means:
- DSI can only use SPRN_SPRG_SCRATCH0
- Exceptions must free SPRN_SPRG_SCRATCH0 before writing to the stack.

This also fixes the Oops reported by Erhard when create_hpte() is
called by add_hash_page().

Due to prolog size increase, a few more exceptions had to get split
in two parts.

Fixes: cd08f109e2 ("powerpc/32s: Enable CONFIG_VMAP_STACK")
Reported-by: Erhard F. <erhard_f@mailbox.org>
Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
Tested-by: Erhard F. <erhard_f@mailbox.org>
Tested-by: Larry Finger <Larry.Finger@lwfinger.net>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://bugzilla.kernel.org/show_bug.cgi?id=206501
Link: https://lore.kernel.org/r/64a4aa44686e9fd4b01333401367029771d9b231.1581761633.git.christophe.leroy@c-s.fr
2020-02-18 21:31:11 +11:00
..
book3s32 powerpc/32s: Fix DSI and ISI exceptions for CONFIG_VMAP_STACK 2020-02-18 21:31:11 +11:00
book3s64 powerpc updates for 5.6 2020-02-04 13:06:46 +00:00
kasan powerpc/32s: Fix DSI and ISI exceptions for CONFIG_VMAP_STACK 2020-02-18 21:31:11 +11:00
nohash powerpc/8xx: Fix permanently mapped IMMR region. 2020-01-23 21:31:14 +11:00
ptdump powerpc/ptdump: Fix W+X verification 2020-01-23 21:31:13 +11:00
Makefile powerpc/mm: Move ioremap functions out of pgtable_32/64.c 2019-08-27 13:03:35 +10:00
copro_fault.c
dma-noncoherent.c dma-mapping: drop the dev argument to arch_sync_dma_for_* 2019-11-20 20:31:38 +01:00
drmem.c
fault.c Merge branch 'topic/user-access-begin' into next 2020-02-01 21:47:17 +11:00
highmem.c
hugetlbpage.c powerpc/hugetlb: Fix 512k hugepages on 8xx with 16k page size 2020-02-17 12:47:05 +11:00
init-common.c powerpc: introduce kernstart_virt_addr to store the kernel base 2019-11-13 19:27:32 +11:00
init_32.c powerpc: move memstart_addr and kernstart_addr to init-common.c 2019-11-13 19:27:28 +11:00
init_64.c Merge branch 'topic/kaslr-book3e32' into next 2019-11-14 19:23:33 +11:00
ioremap.c powerpc/mm: split out early ioremap path. 2019-08-27 13:03:35 +10:00
ioremap_32.c powerpc/ioremap: warn on early use of ioremap() 2019-11-19 19:38:38 +11:00
ioremap_64.c powerpc/ioremap: warn on early use of ioremap() 2019-11-19 19:38:38 +11:00
mem.c powerpc/32: Add support of KASAN_VMALLOC 2020-01-27 22:37:33 +11:00
mmap.c
mmu_context.c
mmu_decl.h powerpc/ptdump: don't entirely rebuild kernel when selecting CONFIG_PPC_DEBUG_WX 2020-01-23 21:31:11 +11:00
numa.c proc: convert everything to "struct proc_ops" 2020-02-04 03:05:26 +00:00
pgtable-frag.c mm: treewide: clarify pgtable_page_{ctor,dtor}() naming 2019-09-26 10:10:44 -07:00
pgtable.c
pgtable_32.c powerpc/ptdump: Fix W+X verification call in mark_rodata_ro() 2020-01-23 21:31:12 +11:00
pgtable_64.c powerpc/mm: Move ioremap functions out of pgtable_32/64.c 2019-08-27 13:03:35 +10:00
slice.c powerpc/mm: Mark get_slice_psize() & slice_addr_is_low() as notrace 2019-12-23 21:12:51 +11:00