Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fa6bd996 authored by Li Yang's avatar Li Yang Committed by Kumar Gala
Browse files

powerpc/fsl-booke: Fix InstructionTLBError execute permission check



In CONFIG_PTE_64BIT the PTE format has unique permission bits for user
and supervisor execute.  However on !CONFIG_PTE_64BIT we overload the
supervisor bit to imply user execute with _PAGE_USER set.  This allows
us to use the same permission check mask for user or supervisor code on
!CONFIG_PTE_64BIT.

However, on CONFIG_PTE_64BIT we map _PAGE_EXEC to _PAGE_BAP_UX so we
need a different permission mask based on the fault coming from a kernel
address or user space.

Without unique permission masks we see issues like the following with
modules:

Unable to handle kernel paging request for instruction fetch
Faulting instruction address: 0xf938d040
Oops: Kernel access of bad area, sig: 11 [#1]

Signed-off-by: default avatarLi Yang <leoli@freescale.com>
Signed-off-by: default avatarJin Qing <b24347@freescale.com>
Signed-off-by: default avatarKumar Gala <galak@kernel.crashing.org>
parent 131c6c9e
Loading
Loading
Loading
Loading
+10 −3
Original line number Original line Diff line number Diff line
@@ -639,6 +639,13 @@ interrupt_base:
	rlwinm	r12,r12,0,16,1
	rlwinm	r12,r12,0,16,1
	mtspr	SPRN_MAS1,r12
	mtspr	SPRN_MAS1,r12


	/* Make up the required permissions for kernel code */
#ifdef CONFIG_PTE_64BIT
	li	r13,_PAGE_PRESENT | _PAGE_BAP_SX
	oris	r13,r13,_PAGE_ACCESSED@h
#else
	li	r13,_PAGE_PRESENT | _PAGE_ACCESSED | _PAGE_EXEC
#endif
	b	4f
	b	4f


	/* Get the PGD for the current thread */
	/* Get the PGD for the current thread */
@@ -646,15 +653,15 @@ interrupt_base:
	mfspr	r11,SPRN_SPRG_THREAD
	mfspr	r11,SPRN_SPRG_THREAD
	lwz	r11,PGDIR(r11)
	lwz	r11,PGDIR(r11)


4:
	/* Make up the required permissions for user code */
	/* Make up the required permissions */
#ifdef CONFIG_PTE_64BIT
#ifdef CONFIG_PTE_64BIT
	li	r13,_PAGE_PRESENT | _PAGE_EXEC
	li	r13,_PAGE_PRESENT | _PAGE_BAP_UX
	oris	r13,r13,_PAGE_ACCESSED@h
	oris	r13,r13,_PAGE_ACCESSED@h
#else
#else
	li	r13,_PAGE_PRESENT | _PAGE_ACCESSED | _PAGE_EXEC
	li	r13,_PAGE_PRESENT | _PAGE_ACCESSED | _PAGE_EXEC
#endif
#endif


4:
	FIND_PTE
	FIND_PTE
	andc.	r13,r13,r11		/* Check permission */
	andc.	r13,r13,r11		/* Check permission */