Skip to content

Commit b84eeed

Browse files
committed
Merge tag 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rmk/linux
Pull ARM fixes from Russell King: - Fix kernel mapping for XIP kernels - Fix SMP support for XIP kernels - Fix complication corner case with CFI - Fix a typo in nommu code - Fix cacheflush syscall when PAN is enabled on LPAE platforms * tag 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rmk/linux: ARM: fix cacheflush with PAN ARM: 9435/1: ARM/nommu: Fix typo "absence" ARM: 9434/1: cfi: Fix compilation corner case ARM: 9420/1: smp: Fix SMP for xip kernels ARM: 9419/1: mm: Fix kernel memory mapping for xip kernels
2 parents e06bc45 + ca29cfc commit b84eeed

File tree

7 files changed

+50
-17
lines changed

7 files changed

+50
-17
lines changed

arch/arm/kernel/head.S

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,27 +252,31 @@ __create_page_tables:
252252
*/
253253
add r0, r4, #KERNEL_OFFSET >> (SECTION_SHIFT - PMD_ENTRY_ORDER)
254254
ldr r6, =(_end - 1)
255+
256+
/* For XIP, kernel_sec_start/kernel_sec_end are currently in RO memory */
257+
#ifndef CONFIG_XIP_KERNEL
255258
adr_l r5, kernel_sec_start @ _pa(kernel_sec_start)
256259
#if defined CONFIG_CPU_ENDIAN_BE8 || defined CONFIG_CPU_ENDIAN_BE32
257260
str r8, [r5, #4] @ Save physical start of kernel (BE)
258261
#else
259262
str r8, [r5] @ Save physical start of kernel (LE)
263+
#endif
260264
#endif
261265
orr r3, r8, r7 @ Add the MMU flags
262266
add r6, r4, r6, lsr #(SECTION_SHIFT - PMD_ENTRY_ORDER)
263267
1: str r3, [r0], #1 << PMD_ENTRY_ORDER
264268
add r3, r3, #1 << SECTION_SHIFT
265269
cmp r0, r6
266270
bls 1b
271+
#ifndef CONFIG_XIP_KERNEL
267272
eor r3, r3, r7 @ Remove the MMU flags
268273
adr_l r5, kernel_sec_end @ _pa(kernel_sec_end)
269274
#if defined CONFIG_CPU_ENDIAN_BE8 || defined CONFIG_CPU_ENDIAN_BE32
270275
str r3, [r5, #4] @ Save physical end of kernel (BE)
271276
#else
272277
str r3, [r5] @ Save physical end of kernel (LE)
273278
#endif
274-
275-
#ifdef CONFIG_XIP_KERNEL
279+
#else
276280
/*
277281
* Map the kernel image separately as it is not located in RAM.
278282
*/
@@ -407,7 +411,11 @@ ENTRY(secondary_startup)
407411
/*
408412
* Use the page tables supplied from __cpu_up.
409413
*/
414+
#ifdef CONFIG_XIP_KERNEL
415+
ldr r3, =(secondary_data + PLAT_PHYS_OFFSET - PAGE_OFFSET)
416+
#else
410417
adr_l r3, secondary_data
418+
#endif
411419
mov_l r12, __secondary_switched
412420
ldrd r4, r5, [r3, #0] @ get secondary_data.pgdir
413421
ARM_BE8(eor r4, r4, r5) @ Swap r5 and r4 in BE:

arch/arm/kernel/psci_smp.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,15 @@ extern void secondary_startup(void);
4545
static int psci_boot_secondary(unsigned int cpu, struct task_struct *idle)
4646
{
4747
if (psci_ops.cpu_on)
48+
#ifdef CONFIG_XIP_KERNEL
49+
return psci_ops.cpu_on(cpu_logical_map(cpu),
50+
((phys_addr_t)(&secondary_startup)
51+
- XIP_VIRT_ADDR(CONFIG_XIP_PHYS_ADDR)
52+
+ CONFIG_XIP_PHYS_ADDR));
53+
#else
4854
return psci_ops.cpu_on(cpu_logical_map(cpu),
4955
virt_to_idmap(&secondary_startup));
56+
#endif
5057
return -ENODEV;
5158
}
5259

arch/arm/kernel/traps.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -570,6 +570,7 @@ static int bad_syscall(int n, struct pt_regs *regs)
570570
static inline int
571571
__do_cache_op(unsigned long start, unsigned long end)
572572
{
573+
unsigned int ua_flags;
573574
int ret;
574575

575576
do {
@@ -578,7 +579,9 @@ __do_cache_op(unsigned long start, unsigned long end)
578579
if (fatal_signal_pending(current))
579580
return 0;
580581

582+
ua_flags = uaccess_save_and_enable();
581583
ret = flush_icache_user_range(start, start + chunk);
584+
uaccess_restore(ua_flags);
582585
if (ret)
583586
return ret;
584587

arch/arm/mm/dma-mapping-nommu.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ void arch_setup_dma_ops(struct device *dev, bool coherent)
3939
/*
4040
* Cache support for v7m is optional, so can be treated as
4141
* coherent if no cache has been detected. Note that it is not
42-
* enough to check if MPU is in use or not since in absense of
42+
* enough to check if MPU is in use or not since in absence of
4343
* MPU system memory map is used.
4444
*/
4545
dev->dma_coherent = cacheid ? coherent : true;

arch/arm/mm/idmap.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,15 @@ static void identity_mapping_add(pgd_t *pgd, const char *text_start,
8484
unsigned long addr, end;
8585
unsigned long next;
8686

87+
#ifdef CONFIG_XIP_KERNEL
88+
addr = (phys_addr_t)(text_start) - XIP_VIRT_ADDR(CONFIG_XIP_PHYS_ADDR)
89+
+ CONFIG_XIP_PHYS_ADDR;
90+
end = (phys_addr_t)(text_end) - XIP_VIRT_ADDR(CONFIG_XIP_PHYS_ADDR)
91+
+ CONFIG_XIP_PHYS_ADDR;
92+
#else
8793
addr = virt_to_idmap(text_start);
8894
end = virt_to_idmap(text_end);
95+
#endif
8996
pr_info("Setting up static identity map for 0x%lx - 0x%lx\n", addr, end);
9097

9198
prot |= PMD_TYPE_SECT | PMD_SECT_AP_WRITE | PMD_SECT_AF;

arch/arm/mm/mmu.c

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1402,18 +1402,6 @@ static void __init devicemaps_init(const struct machine_desc *mdesc)
14021402
create_mapping(&map);
14031403
}
14041404

1405-
/*
1406-
* Map the kernel if it is XIP.
1407-
* It is always first in the modulearea.
1408-
*/
1409-
#ifdef CONFIG_XIP_KERNEL
1410-
map.pfn = __phys_to_pfn(CONFIG_XIP_PHYS_ADDR & SECTION_MASK);
1411-
map.virtual = MODULES_VADDR;
1412-
map.length = ((unsigned long)_exiprom - map.virtual + ~SECTION_MASK) & SECTION_MASK;
1413-
map.type = MT_ROM;
1414-
create_mapping(&map);
1415-
#endif
1416-
14171405
/*
14181406
* Map the cache flushing regions.
14191407
*/
@@ -1603,12 +1591,27 @@ static void __init map_kernel(void)
16031591
* This will only persist until we turn on proper memory management later on
16041592
* and we remap the whole kernel with page granularity.
16051593
*/
1594+
#ifdef CONFIG_XIP_KERNEL
1595+
phys_addr_t kernel_nx_start = kernel_sec_start;
1596+
#else
16061597
phys_addr_t kernel_x_start = kernel_sec_start;
16071598
phys_addr_t kernel_x_end = round_up(__pa(__init_end), SECTION_SIZE);
16081599
phys_addr_t kernel_nx_start = kernel_x_end;
1600+
#endif
16091601
phys_addr_t kernel_nx_end = kernel_sec_end;
16101602
struct map_desc map;
16111603

1604+
/*
1605+
* Map the kernel if it is XIP.
1606+
* It is always first in the modulearea.
1607+
*/
1608+
#ifdef CONFIG_XIP_KERNEL
1609+
map.pfn = __phys_to_pfn(CONFIG_XIP_PHYS_ADDR & SECTION_MASK);
1610+
map.virtual = MODULES_VADDR;
1611+
map.length = ((unsigned long)_exiprom - map.virtual + ~SECTION_MASK) & SECTION_MASK;
1612+
map.type = MT_ROM;
1613+
create_mapping(&map);
1614+
#else
16121615
map.pfn = __phys_to_pfn(kernel_x_start);
16131616
map.virtual = __phys_to_virt(kernel_x_start);
16141617
map.length = kernel_x_end - kernel_x_start;
@@ -1618,7 +1621,7 @@ static void __init map_kernel(void)
16181621
/* If the nx part is small it may end up covered by the tail of the RWX section */
16191622
if (kernel_x_end == kernel_nx_end)
16201623
return;
1621-
1624+
#endif
16221625
map.pfn = __phys_to_pfn(kernel_nx_start);
16231626
map.virtual = __phys_to_virt(kernel_nx_start);
16241627
map.length = kernel_nx_end - kernel_nx_start;
@@ -1764,6 +1767,11 @@ void __init paging_init(const struct machine_desc *mdesc)
17641767
{
17651768
void *zero_page;
17661769

1770+
#ifdef CONFIG_XIP_KERNEL
1771+
/* Store the kernel RW RAM region start/end in these variables */
1772+
kernel_sec_start = CONFIG_PHYS_OFFSET & SECTION_MASK;
1773+
kernel_sec_end = round_up(__pa(_end), SECTION_SIZE);
1774+
#endif
17671775
pr_debug("physical kernel sections: 0x%08llx-0x%08llx\n",
17681776
kernel_sec_start, kernel_sec_end);
17691777

arch/arm/mm/proc-v7.S

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ SYM_TYPED_FUNC_START(cpu_v7_dcache_clean_area)
9494
ret lr
9595
SYM_FUNC_END(cpu_v7_dcache_clean_area)
9696

97-
#ifdef CONFIG_ARM_PSCI
97+
#if defined(CONFIG_ARM_PSCI) && defined(CONFIG_HARDEN_BRANCH_PREDICTOR)
9898
.arch_extension sec
9999
SYM_TYPED_FUNC_START(cpu_v7_smc_switch_mm)
100100
stmfd sp!, {r0 - r3}

0 commit comments

Comments
 (0)