RISC-V: Various XIP fixes
v2 cover RISC-V: Various XIP fixes
I found a handful of XIP-related bit rot when chasing down a LKP-reported issue. They're not really related, aside from all being XIP-related. I thought I had an XIP build test, I'll make sure to add/resurrect one when I get back around to these.
Changes since v1 <[email protected]>:
* Defines the mapping functions themselves to have no-op bodies, as opposed to wrapping their uses.
* 2-4 are new patches.
PATCH v2 1/4 RISC-V: Avoid empty create_*_mapping definitions
From: Palmer Dabbelt <[email protected]>
At least one use of these, that in create_fdt_early_page_table(), triggers warnings and should cause a real error (create_pmd_mpping() ends up skipped on XIP_KERNEL).
--- arch/riscv/mm/init.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
arch/riscv/mm/init.c +3 -3
@@ -567,9 +567,9 @@ static void __init create_p4d_mapping(p4d_t *p4dp, create_pte_mapping(__nextp, __va, __pa, __sz, __prot)#define fixmap_pgd_next ((uintptr_t)fixmap_pte)#define early_dtb_pgd_next ((uintptr_t)early_dtb_pmd) -#define create_p4d_mapping (__pmdp, __va, __pa, __sz, __prot) -#define create_pud_mapping (__pmdp, __va, __pa, __sz, __prot) -#define create_pmd_mapping (__pmdp, __va, __pa, __sz, __prot) +#define create_p4d_mapping (__pmdp, __va, __pa, __sz, __prot) do {} while(0) +#define create_pud_mapping (__pmdp, __va, __pa, __sz, __prot) do {} while(0) +#define create_pmd_mapping (__pmdp, __va, __pa, __sz, __prot) do {} while(0)#endif /* __PAGETABLE_PMD_FOLDED */ void __init create_pgd_mapping(pgd_t *pgdp,
Signature · 1 line
2.34.1
Re: [PATCH v2 1/4] RISC-V: Avoid empty create_*_mapping definitions
Quoted 1 line · Palmer Dabbelt
(
create_pmd_mpping()ends up skipped onXIP_KERNEL).
Does it? There is always the semicolon left as the body of the conditional (which is why you get the empty-body warning in the first place).
Signature · 8 lines
Andreas Schwab, [email protected] GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510 2552 DF73 E780 A9DA AEC1 "And now for something completely different." _______________________________________________ linux-riscv mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-riscv
Re: [PATCH v2 1/4] RISC-V: Avoid empty create_*_mapping definitions
Quoted 7 lines · On Wed, 20 Apr 2022 15:11:37 PDT (-0700), [email protected] wrote:
Quoted 1 line · Palmer Dabbelt
(
create_pmd_mpping()ends up skipped onXIP_KERNEL).Does it? There is always the semicolon left as the body of the conditional (which is why you get the empty-body warning in the first place).
Yep, you're right. I fixed up the commit message, thanks!
PATCH v2 2/4 RISC-V: ignore xipImage
In reply to Palmer DabbeltFrom: Palmer Dabbelt <[email protected]>
This built file shows up in "git status" without an explicit ignore.
--- arch/riscv/boot/.gitignore | 1 + 1 file changed, 1 insertion(+)
arch/riscv/boot/.gitignore +1 -0
@@ -4,3 +4,4 @@ Image.* loader loader.lds loader.bin +xipImage
Signature · 1 line
2.34.1
Re: [PATCH v2 2/4] RISC-V: ignore xipImage
Quoted 22 lines · Palmer Dabbelt
From: Palmer Dabbelt <[email protected]>
This built file shows up in "git status" without an explicit ignore.
Signed-off-by Palmer Dabbelt <[email protected]>--- arch/riscv/boot/.gitignore | 1 + 1 file changed, 1 insertion(+)arch/riscv/boot/.gitignore +1
-1@@ -4,3 +4,4 @@ Image.* loader loader.lds loader.bin +xipImage --2.34.1
Signature · 4 lines
Best Regards Guo Ren ML: https://lore.kernel.org/linux-csky/
PATCH v2 3/4 RISC-V: Split out the XIP fixups into their own file
In reply to Palmer DabbeltFrom: Palmer Dabbelt <[email protected]>
This was broken by the original refactoring (as the XIP definitions depend on <asm/pgtable.h>) and then more broken by the merge (as I accidentally took the old version). This fixes both breakages, while also pulling this out of <asm/asm.h> to avoid polluting most assembly files with the XIP fixups.
--- arch/riscv/include/asm/asm.h | 26 ------------------------ arch/riscv/include/asm/xip_fixup.h | 32 ++++++++++++++++++++++++++++++ arch/riscv/kernel/head.S | 1 + arch/riscv/kernel/suspend_entry.S | 1 + 4 files changed, 34 insertions(+), 26 deletions(-) create mode 100644 arch/riscv/include/asm/xip_fixup.h
arch/riscv/include/asm/asm.h +0 -26
@@ -67,30 +67,4 @@#error "Unexpected __SIZEOF_SHORT__"#endif -#ifdef __ASSEMBLY__ - -/* Common assembly source macros */ - -#ifdef CONFIG_XIP_KERNEL -.macro XIP_FIXUP_OFFSET reg - REG_L t0, _xip_fixup - add \reg, \reg, t0 -.endm -.macro XIP_FIXUP_FLASH_OFFSET reg - la t1, __data_loc - REG_L t1, _xip_phys_offset - sub \reg, \reg, t1 - add \reg, \reg, t0 -.endm -_xip_fixup: .dword CONFIG_PHYS_RAM_BASE - CONFIG_XIP_PHYS_ADDR - XIP_OFFSET -_xip_phys_offset: .dword CONFIG_XIP_PHYS_ADDR + XIP_OFFSET -#else -.macro XIP_FIXUP_OFFSET reg -.endm -.macro XIP_FIXUP_FLASH_OFFSET reg -.endm -#endif /* CONFIG_XIP_KERNEL */ - -#endif /* __ASSEMBLY__ */ -#endif /* _ASM_RISCV_ASM_H */
arch/riscv/include/asm/xip_fixup.h new file +32 -0
@@ -0,0 +1,32 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* +* XIP fixup macros, only useful in assembly. +*/ +#ifndef _ASM_RISCV_XIP_FIXUP_H +#define _ASM_RISCV_XIP_FIXUP_H + +#include <linux/pgtable.h> + +#ifdef CONFIG_XIP_KERNEL +.macro XIP_FIXUP_OFFSET reg + REG_L t0, _xip_fixup + add \reg, \reg, t0 +.endm +.macro XIP_FIXUP_FLASH_OFFSET reg + la t1, __data_loc + li t0, XIP_OFFSET_MASK + and t1, t1, t0 + li t1, XIP_OFFSET + sub t0, t0, t1 + sub \reg, \reg, t0 +.endm + +_xip_fixup: .dword CONFIG_PHYS_RAM_BASE - CONFIG_XIP_PHYS_ADDR - XIP_OFFSET +#else +.macro XIP_FIXUP_OFFSET reg +.endm +.macro XIP_FIXUP_FLASH_OFFSET reg +.endm +#endif /* CONFIG_XIP_KERNEL */ + +#endif
arch/riscv/kernel/head.S +1 -0
@@ -14,6 +14,7 @@ #include <asm/hwcap.h> #include <asm/image.h> +#include <asm/xip_fixup.h> #include "efi-header.S" __HEAD
arch/riscv/kernel/suspend_entry.S +1 -0
@@ -8,6 +8,7 @@ #include <asm/asm.h> #include <asm/asm-offsets.h> #include <asm/csr.h> +#include <asm/xip_fixup.h> .text .altmacro
Signature · 7 lines
2.34.1 _______________________________________________ linux-riscv mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-riscv
Re: [PATCH v2 3/4] RISC-V: Split out the XIP fixups into their own file
Quoted 70 lines · Palmer Dabbelt
From: Palmer Dabbelt <[email protected]>
This was broken by the original refactoring (as the XIP definitions depend on <
asm/pgtable.h>) and then more broken by the merge (as I accidentally took the old version). This fixes both breakages, while also pulling this out of <asm/asm.h> to avoid polluting most assembly files with the XIP fixups.Fixes bee7fbc38579 ("RISC-V CPU Idle Support")Fixes 63b13e64a829 ("RISC-V: Add arch functions for non-retentive suspend entry/exit")Signed-off-by Palmer Dabbelt <[email protected]>--- arch/riscv/include/asm/asm.h | 26 ------------------------ arch/riscv/include/asm/xip_fixup.h | 32 ++++++++++++++++++++++++++++++ arch/riscv/kernel/head.S | 1 + arch/riscv/kernel/suspend_entry.S | 1 + 4 files changed, 34 insertions(+), 26 deletions(-) create mode 100644 arch/riscv/include/asm/xip_fixup.harch/riscv/include/asm/asm.h +0
-26@@ -67,30 +67,4 @@#error "Unexpected __SIZEOF_SHORT__"#endif -#ifdef __ASSEMBLY__ - -/* Common assembly source macros */ - -#ifdef CONFIG_XIP_KERNEL -.macro XIP_FIXUP_OFFSET reg - REG_L t0, _xip_fixup - add \reg, \reg, t0 -.endm -.macro XIP_FIXUP_FLASH_OFFSET reg - la t1, __data_loc - REG_L t1, _xip_phys_offset - sub \reg, \reg, t1 - add \reg, \reg, t0 -.endm -_xip_fixup: .dword CONFIG_PHYS_RAM_BASE - CONFIG_XIP_PHYS_ADDR - XIP_OFFSET -_xip_phys_offset: .dword CONFIG_XIP_PHYS_ADDR + XIP_OFFSET -#else -.macro XIP_FIXUP_OFFSET reg -.endm -.macro XIP_FIXUP_FLASH_OFFSET reg -.endm -#endif /* CONFIG_XIP_KERNEL */ - -#endif /* __ASSEMBLY__ */ -#endif /* _ASM_RISCV_ASM_H */ arch/riscv/include/asm/xip_fixup.h new file +9
-0@@ -0,0 +1,32 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* +* XIP fixup macros, only useful in assembly. +*/ +#ifndef _ASM_RISCV_XIP_FIXUP_H +#define _ASM_RISCV_XIP_FIXUP_H + +#include <linux/pgtable.h> +
arch/riscv/include/asm/xip_fixup.h line 19
Quoted 10 lines
arch/riscv/include/asm/xip_fixup.h new file +10
-0+#ifdef CONFIG_XIP_KERNEL +.macro XIP_FIXUP_OFFSET reg + REG_L t0, _xip_fixup + add \reg, \reg, t0 +.endm +.macro XIP_FIXUP_FLASH_OFFSET reg + la t1, __data_loc + li t0, XIP_OFFSET_MASK + and t1, t1, t0 + li t1, XIP_OFFSET
I still prefer the style:REG_L t1, _xip_phys_offset
..._xip_phys_offset: .dword CONFIG_XIP_PHYS_ADDR + XIP_OFFSET
Because it's more clear and has the same style as your _xip_fixup.
Others:
arch/riscv/include/asm/xip_fixup.h line 22
Quoted 3 lines
arch/riscv/include/asm/xip_fixup.h new file +3
-0+sub t0, t0, t1 + sub \reg, \reg, t0 +.endm
-.endm
Quoted 36 lines
arch/riscv/include/asm/xip_fixup.h new file +10
-0+ +_xip_fixup: .dword CONFIG_PHYS_RAM_BASE - CONFIG_XIP_PHYS_ADDR - XIP_OFFSET +#else +.macro XIP_FIXUP_OFFSET reg +.endm +.macro XIP_FIXUP_FLASH_OFFSET reg +.endm +#endif /* CONFIG_XIP_KERNEL */ + +#endif arch/riscv/kernel/head.S +1
-0@@ -14,6 +14,7 @@ #include <asm/hwcap.h> #include <asm/image.h> +#include <asm/xip_fixup.h> #include "efi-header.S" __HEADarch/riscv/kernel/suspend_entry.S +1
-1@@ -8,6 +8,7 @@ #include <asm/asm.h> #include <asm/asm-offsets.h> #include <asm/csr.h> +#include <asm/xip_fixup.h> .text .altmacro --2.34.1
Signature · 9 lines
Best Regards Guo Ren ML: https://lore.kernel.org/linux-csky/ _______________________________________________ linux-riscv mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-riscv
Re: [PATCH v2 3/4] RISC-V: Split out the XIP fixups into their own file
Quoted 86 lines · On Wed, 20 Apr 2022 23:45:23 PDT (-0700), [email protected] wrote:
Quoted 70 lines · Palmer Dabbelt
From: Palmer Dabbelt <[email protected]>
This was broken by the original refactoring (as the XIP definitions depend on <
asm/pgtable.h>) and then more broken by the merge (as I accidentally took the old version). This fixes both breakages, while also pulling this out of <asm/asm.h> to avoid polluting most assembly files with the XIP fixups.Fixes bee7fbc38579 ("RISC-V CPU Idle Support")Fixes 63b13e64a829 ("RISC-V: Add arch functions for non-retentive suspend entry/exit")Signed-off-by Palmer Dabbelt <[email protected]>--- arch/riscv/include/asm/asm.h | 26 ------------------------ arch/riscv/include/asm/xip_fixup.h | 32 ++++++++++++++++++++++++++++++ arch/riscv/kernel/head.S | 1 + arch/riscv/kernel/suspend_entry.S | 1 + 4 files changed, 34 insertions(+), 26 deletions(-) create mode 100644 arch/riscv/include/asm/xip_fixup.harch/riscv/include/asm/asm.h +0
-26@@ -67,30 +67,4 @@#error "Unexpected __SIZEOF_SHORT__"#endif -#ifdef __ASSEMBLY__ - -/* Common assembly source macros */ - -#ifdef CONFIG_XIP_KERNEL -.macro XIP_FIXUP_OFFSET reg - REG_L t0, _xip_fixup - add \reg, \reg, t0 -.endm -.macro XIP_FIXUP_FLASH_OFFSET reg - la t1, __data_loc - REG_L t1, _xip_phys_offset - sub \reg, \reg, t1 - add \reg, \reg, t0 -.endm -_xip_fixup: .dword CONFIG_PHYS_RAM_BASE - CONFIG_XIP_PHYS_ADDR - XIP_OFFSET -_xip_phys_offset: .dword CONFIG_XIP_PHYS_ADDR + XIP_OFFSET -#else -.macro XIP_FIXUP_OFFSET reg -.endm -.macro XIP_FIXUP_FLASH_OFFSET reg -.endm -#endif /* CONFIG_XIP_KERNEL */ - -#endif /* __ASSEMBLY__ */ -#endif /* _ASM_RISCV_ASM_H */ arch/riscv/include/asm/xip_fixup.h new file +9
-0@@ -0,0 +1,32 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* +* XIP fixup macros, only useful in assembly. +*/ +#ifndef _ASM_RISCV_XIP_FIXUP_H +#define _ASM_RISCV_XIP_FIXUP_H + +#include <linux/pgtable.h> +arch/riscv/include/asm/xip_fixup.h line 19
Quoted 10 lines
arch/riscv/include/asm/xip_fixup.h new file +10
-0+#ifdef CONFIG_XIP_KERNEL +.macro XIP_FIXUP_OFFSET reg + REG_L t0, _xip_fixup + add \reg, \reg, t0 +.endm +.macro XIP_FIXUP_FLASH_OFFSET reg + la t1, __data_loc + li t0, XIP_OFFSET_MASK + and t1, t1, t0 + li t1, XIP_OFFSETI still prefer the style:
REG_Lt1,_xip_phys_offset
..._xip_phys_offset: .dwordCONFIG_XIP_PHYS_ADDR+XIP_OFFSET
Quoted 1 line
Because it's more clear and has the same style as your
_xip_fixup.
Thanks, not quite shure how I pulled the old version over. I've fixed this one up.
Quoted 43 lines
Others:
Reviewed-by Guo Ren <[email protected]>arch/riscv/include/asm/xip_fixup.h line 22
Quoted 3 lines
arch/riscv/include/asm/xip_fixup.h new file +3
-0+sub t0, t0, t1 + sub \reg, \reg, t0 +.endm-.endm
Quoted 36 lines
arch/riscv/include/asm/xip_fixup.h new file +10
-0+ +_xip_fixup: .dword CONFIG_PHYS_RAM_BASE - CONFIG_XIP_PHYS_ADDR - XIP_OFFSET +#else +.macro XIP_FIXUP_OFFSET reg +.endm +.macro XIP_FIXUP_FLASH_OFFSET reg +.endm +#endif /* CONFIG_XIP_KERNEL */ + +#endif arch/riscv/kernel/head.S +1
-0@@ -14,6 +14,7 @@ #include <asm/hwcap.h> #include <asm/image.h> +#include <asm/xip_fixup.h> #include "efi-header.S" __HEADarch/riscv/kernel/suspend_entry.S +1
-1@@ -8,6 +8,7 @@ #include <asm/asm.h> #include <asm/asm-offsets.h> #include <asm/csr.h> +#include <asm/xip_fixup.h> .text .altmacro --2.34.1
PATCH v2 4/4 RISC-V: Fix the XIP build
In reply to Palmer DabbeltFrom: Palmer Dabbelt <[email protected]>
A handful of functions unused functions were enabled during XIP builds, which themselves didn't build correctly. This just disables the functions entirely.
--- arch/riscv/mm/init.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/riscv/mm/init.c +1 -1
@@ -660,7 +660,7 @@ static __init pgprot_t pgprot_from_va(uintptr_t va) }#endif /* CONFIG_STRICT_KERNEL_RWX */ -#ifdef CONFIG_64BIT +#if defined(CONFIG_64BIT ) && !defined(CONFIG_XIP_KERNEL )static void __init disable_pgtable_l5 (void ) { pgtable_l5_enabled = false;
Signature · 7 lines
2.34.1 _______________________________________________ linux-riscv mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-riscv
Re: [PATCH v2 4/4] RISC-V: Fix the XIP build
Quoted 29 lines · Palmer Dabbelt
From: Palmer Dabbelt <[email protected]>
A handful of functions unused functions were enabled during XIP builds, which themselves didn't build correctly. This just disables the functions entirely.
Fixes e8a62cc26ddf ("riscv: Implement sv48 support")Signed-off-by Palmer Dabbelt <[email protected]>--- arch/riscv/mm/init.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/riscv/mm/init.c +1
-2@@ -660,7 +660,7 @@ static __init pgprot_t pgprot_from_va(uintptr_t va) }#endif /* CONFIG_STRICT_KERNEL_RWX */ -#ifdef CONFIG_64BIT +#if defined(CONFIG_64BIT ) && !defined(CONFIG_XIP_KERNEL )static void __init disable_pgtable_l5 (void ) { pgtable_l5_enabled = false; --2.34.1
Signature · 9 lines
Best Regards Guo Ren ML: https://lore.kernel.org/linux-csky/ _______________________________________________ linux-riscv mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-riscv