Skip to content

Commit 4e2bbec

Browse files
RISC-V: Various XIP fixes
This fixes a handful of issues with the XIP support, which has bit rotted some lately. * palmer/riscv-xip: RISC-V: Fix the XIP build RISC-V: Split out the XIP fixups into their own file RISC-V: ignore xipImage RISC-V: Avoid empty create_*_mapping definitions
2 parents 324373f + d9e418d commit 4e2bbec

File tree

6 files changed

+38
-30
lines changed

6 files changed

+38
-30
lines changed

arch/riscv/boot/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ Image.*
44
loader
55
loader.lds
66
loader.bin
7+
xipImage

arch/riscv/include/asm/asm.h

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -67,30 +67,4 @@
6767
#error "Unexpected __SIZEOF_SHORT__"
6868
#endif
6969

70-
#ifdef __ASSEMBLY__
71-
72-
/* Common assembly source macros */
73-
74-
#ifdef CONFIG_XIP_KERNEL
75-
.macro XIP_FIXUP_OFFSET reg
76-
REG_L t0, _xip_fixup
77-
add \reg, \reg, t0
78-
.endm
79-
.macro XIP_FIXUP_FLASH_OFFSET reg
80-
la t1, __data_loc
81-
REG_L t1, _xip_phys_offset
82-
sub \reg, \reg, t1
83-
add \reg, \reg, t0
84-
.endm
85-
_xip_fixup: .dword CONFIG_PHYS_RAM_BASE - CONFIG_XIP_PHYS_ADDR - XIP_OFFSET
86-
_xip_phys_offset: .dword CONFIG_XIP_PHYS_ADDR + XIP_OFFSET
87-
#else
88-
.macro XIP_FIXUP_OFFSET reg
89-
.endm
90-
.macro XIP_FIXUP_FLASH_OFFSET reg
91-
.endm
92-
#endif /* CONFIG_XIP_KERNEL */
93-
94-
#endif /* __ASSEMBLY__ */
95-
9670
#endif /* _ASM_RISCV_ASM_H */

arch/riscv/include/asm/xip_fixup.h

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/* SPDX-License-Identifier: GPL-2.0-only */
2+
/*
3+
* XIP fixup macros, only useful in assembly.
4+
*/
5+
#ifndef _ASM_RISCV_XIP_FIXUP_H
6+
#define _ASM_RISCV_XIP_FIXUP_H
7+
8+
#include <linux/pgtable.h>
9+
10+
#ifdef CONFIG_XIP_KERNEL
11+
.macro XIP_FIXUP_OFFSET reg
12+
REG_L t0, _xip_fixup
13+
add \reg, \reg, t0
14+
.endm
15+
.macro XIP_FIXUP_FLASH_OFFSET reg
16+
la t1, __data_loc
17+
REG_L t1, _xip_phys_offset
18+
sub \reg, \reg, t1
19+
add \reg, \reg, t0
20+
.endm
21+
22+
_xip_fixup: .dword CONFIG_PHYS_RAM_BASE - CONFIG_XIP_PHYS_ADDR - XIP_OFFSET
23+
_xip_phys_offset: .dword CONFIG_XIP_PHYS_ADDR + XIP_OFFSET
24+
#else
25+
.macro XIP_FIXUP_OFFSET reg
26+
.endm
27+
.macro XIP_FIXUP_FLASH_OFFSET reg
28+
.endm
29+
#endif /* CONFIG_XIP_KERNEL */
30+
31+
#endif

arch/riscv/kernel/head.S

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <asm/cpu_ops_sbi.h>
1515
#include <asm/hwcap.h>
1616
#include <asm/image.h>
17+
#include <asm/xip_fixup.h>
1718
#include "efi-header.S"
1819

1920
__HEAD

arch/riscv/kernel/suspend_entry.S

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <asm/asm.h>
99
#include <asm/asm-offsets.h>
1010
#include <asm/csr.h>
11+
#include <asm/xip_fixup.h>
1112

1213
.text
1314
.altmacro

arch/riscv/mm/init.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -567,9 +567,9 @@ static void __init create_p4d_mapping(p4d_t *p4dp,
567567
create_pte_mapping(__nextp, __va, __pa, __sz, __prot)
568568
#define fixmap_pgd_next ((uintptr_t)fixmap_pte)
569569
#define early_dtb_pgd_next ((uintptr_t)early_dtb_pmd)
570-
#define create_p4d_mapping(__pmdp, __va, __pa, __sz, __prot)
571-
#define create_pud_mapping(__pmdp, __va, __pa, __sz, __prot)
572-
#define create_pmd_mapping(__pmdp, __va, __pa, __sz, __prot)
570+
#define create_p4d_mapping(__pmdp, __va, __pa, __sz, __prot) do {} while(0)
571+
#define create_pud_mapping(__pmdp, __va, __pa, __sz, __prot) do {} while(0)
572+
#define create_pmd_mapping(__pmdp, __va, __pa, __sz, __prot) do {} while(0)
573573
#endif /* __PAGETABLE_PMD_FOLDED */
574574

575575
void __init create_pgd_mapping(pgd_t *pgdp,
@@ -660,7 +660,7 @@ static __init pgprot_t pgprot_from_va(uintptr_t va)
660660
}
661661
#endif /* CONFIG_STRICT_KERNEL_RWX */
662662

663-
#ifdef CONFIG_64BIT
663+
#if defined(CONFIG_64BIT) && !defined(CONFIG_XIP_KERNEL)
664664
static void __init disable_pgtable_l5(void)
665665
{
666666
pgtable_l5_enabled = false;

0 commit comments

Comments
 (0)