Skip to content

Commit bbecb1c

Browse files
committed
Merge branch 'fixes' of git://git.armlinux.org.uk/~rmk/linux-arm
Pull ARM fixes from Russell King: - LPAE fixes for kernel-readonly regions - Fix for get_user_pages_fast on LPAE systems - avoid tying decompressor to a particular platform if DEBUG_LL is enabled - BUG if we attempt to return to userspace but the to-be-restored PSR value keeps us in privileged mode (defeating an issue that ftracetest found) * 'fixes' of git://git.armlinux.org.uk/~rmk/linux-arm: ARM: BUG if jumping to usermode address in kernel mode ARM: 8722/1: mm: make STRICT_KERNEL_RWX effective for LPAE ARM: 8721/1: mm: dump: check hardware RO bit for LPAE ARM: make decompressor debug output user selectable ARM: fix get_user_pages_fast
2 parents dec0029 + 8bafae2 commit bbecb1c

File tree

6 files changed

+42
-6
lines changed

6 files changed

+42
-6
lines changed

arch/arm/Kconfig.debug

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1776,9 +1776,9 @@ config DEBUG_UART_8250_FLOW_CONTROL
17761776
default y if ARCH_EBSA110 || DEBUG_FOOTBRIDGE_COM1 || DEBUG_GEMINI || ARCH_RPC
17771777

17781778
config DEBUG_UNCOMPRESS
1779-
bool
1779+
bool "Enable decompressor debugging via DEBUG_LL output"
17801780
depends on ARCH_MULTIPLATFORM || PLAT_SAMSUNG || ARM_SINGLE_ARMV7M
1781-
default y if DEBUG_LL && !DEBUG_OMAP2PLUS_UART && \
1781+
depends on DEBUG_LL && !DEBUG_OMAP2PLUS_UART && \
17821782
(!DEBUG_TEGRA_UART || !ZBOOT_ROM) && \
17831783
!DEBUG_BRCMSTB_UART
17841784
help

arch/arm/include/asm/assembler.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -518,4 +518,22 @@ THUMB( orr \reg , \reg , #PSR_T_BIT )
518518
#endif
519519
.endm
520520

521+
.macro bug, msg, line
522+
#ifdef CONFIG_THUMB2_KERNEL
523+
1: .inst 0xde02
524+
#else
525+
1: .inst 0xe7f001f2
526+
#endif
527+
#ifdef CONFIG_DEBUG_BUGVERBOSE
528+
.pushsection .rodata.str, "aMS", %progbits, 1
529+
2: .asciz "\msg"
530+
.popsection
531+
.pushsection __bug_table, "aw"
532+
.align 2
533+
.word 1b, 2b
534+
.hword \line
535+
.popsection
536+
#endif
537+
.endm
538+
521539
#endif /* __ASM_ASSEMBLER_H__ */

arch/arm/include/asm/pgtable.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,18 @@ static inline pte_t *pmd_page_vaddr(pmd_t pmd)
232232
#define pte_valid_user(pte) \
233233
(pte_valid(pte) && pte_isset((pte), L_PTE_USER) && pte_young(pte))
234234

235+
static inline bool pte_access_permitted(pte_t pte, bool write)
236+
{
237+
pteval_t mask = L_PTE_PRESENT | L_PTE_USER;
238+
pteval_t needed = mask;
239+
240+
if (write)
241+
mask |= L_PTE_RDONLY;
242+
243+
return (pte_val(pte) & mask) == needed;
244+
}
245+
#define pte_access_permitted pte_access_permitted
246+
235247
#if __LINUX_ARM_ARCH__ < 6
236248
static inline void __sync_icache_dcache(pte_t pteval)
237249
{

arch/arm/kernel/entry-header.S

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,8 @@
300300
mov r2, sp
301301
ldr r1, [r2, #\offset + S_PSR] @ get calling cpsr
302302
ldr lr, [r2, #\offset + S_PC]! @ get pc
303+
tst r1, #0xcf
304+
bne 1f
303305
msr spsr_cxsf, r1 @ save in spsr_svc
304306
#if defined(CONFIG_CPU_V6) || defined(CONFIG_CPU_32v6K)
305307
@ We must avoid clrex due to Cortex-A15 erratum #830321
@@ -314,6 +316,7 @@
314316
@ after ldm {}^
315317
add sp, sp, #\offset + PT_REGS_SIZE
316318
movs pc, lr @ return & move spsr_svc into cpsr
319+
1: bug "Returning to usermode but unexpected PSR bits set?", \@
317320
#elif defined(CONFIG_CPU_V7M)
318321
@ V7M restore.
319322
@ Note that we don't need to do clrex here as clearing the local
@@ -329,6 +332,8 @@
329332
ldr r1, [sp, #\offset + S_PSR] @ get calling cpsr
330333
ldr lr, [sp, #\offset + S_PC] @ get pc
331334
add sp, sp, #\offset + S_SP
335+
tst r1, #0xcf
336+
bne 1f
332337
msr spsr_cxsf, r1 @ save in spsr_svc
333338

334339
@ We must avoid clrex due to Cortex-A15 erratum #830321
@@ -341,6 +346,7 @@
341346
.endif
342347
add sp, sp, #PT_REGS_SIZE - S_SP
343348
movs pc, lr @ return & move spsr_svc into cpsr
349+
1: bug "Returning to usermode but unexpected PSR bits set?", \@
344350
#endif /* !CONFIG_THUMB2_KERNEL */
345351
.endm
346352

arch/arm/mm/dump.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,8 @@ static const struct prot_bits section_bits[] = {
129129
.val = PMD_SECT_USER,
130130
.set = "USR",
131131
}, {
132-
.mask = L_PMD_SECT_RDONLY,
133-
.val = L_PMD_SECT_RDONLY,
132+
.mask = L_PMD_SECT_RDONLY | PMD_SECT_AP2,
133+
.val = L_PMD_SECT_RDONLY | PMD_SECT_AP2,
134134
.set = "ro",
135135
.clear = "RW",
136136
#elif __LINUX_ARM_ARCH__ >= 6

arch/arm/mm/init.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -629,8 +629,8 @@ static struct section_perm ro_perms[] = {
629629
.start = (unsigned long)_stext,
630630
.end = (unsigned long)__init_begin,
631631
#ifdef CONFIG_ARM_LPAE
632-
.mask = ~L_PMD_SECT_RDONLY,
633-
.prot = L_PMD_SECT_RDONLY,
632+
.mask = ~(L_PMD_SECT_RDONLY | PMD_SECT_AP2),
633+
.prot = L_PMD_SECT_RDONLY | PMD_SECT_AP2,
634634
#else
635635
.mask = ~(PMD_SECT_APX | PMD_SECT_AP_WRITE),
636636
.prot = PMD_SECT_APX | PMD_SECT_AP_WRITE,

0 commit comments

Comments
 (0)