FAILED: patch "[PATCH] riscv: Get rid of CONFIG_PHYS_RAM_BASE in kernel physical" failed to apply to 5.13-stable tree
Subsystems (2)
[email protected]
maintainerThe patch below does not apply to the 5.13-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 6d7f91d914bc90a15ebc426440c26081337ceaa1 Mon Sep 17 00:00:00 2001
From: Alexandre Ghiti <[email protected]>
Date: Wed, 21 Jul 2021 09:59:35 +0200
Subject: [PATCH] riscv: Get rid of CONFIG_PHYS_RAM_BASE in kernel physical
address conversion
The usage of CONFIG_PHYS_RAM_BASE for all kernel types was a mistake:
this value is implementation-specific and this breaks the genericity of the RISC-V kernel.
Fix this by introducing a new variable phys_ram_base that holds this value at runtime and use it in the kernel physical address conversion macro. Since this value is used only for XIP kernels, evaluate it only if CONFIG_XIP_KERNEL is set which in addition optimizes this macro for standard kernels at compile-time.
arch/riscv/include/asm/page.h +4 -3
@@ -103,6 +103,7 @@ struct kernel_mapping { };extern struct kernel_mapping kernel_map; +extern phys_addr_t phys_ram_base;#ifdef CONFIG_64BIT #define is_kernel_mapping (x) \
@@ -113,9 +114,9 @@ extern struct kernel_mapping kernel_map;#define linear_mapping_pa_to_va (x) ((void *)((unsigned long)(x) + kernel_map.va_pa_offset))#define kernel_mapping_pa_to_va (y) ({ \ unsigned long _y = y; \ - (_y >= CONFIG_PHYS_RAM_BASE) ? \ - (void *)((unsigned long)(_y) + kernel_map.va_kernel_pa_offset + XIP_OFFSET) : \ - (void *)((unsigned long)(_y) + kernel_map.va_kernel_xip_pa_offset); \ + (IS_ENABLED(CONFIG_XIP_KERNEL) && _y < phys_ram_base) ? \ + (void *)((unsigned long)(_y) + kernel_map.va_kernel_xip_pa_offset) : \ + (void *)((unsigned long)(_y) + kernel_map.va_kernel_pa_offset + XIP_OFFSET); \ })#define __pa_to_va_nodebug (x) linear_mapping_pa_to_va(x)
arch/riscv/mm/init.c +12 -5
@@ -36,6 +36,9 @@ EXPORT_SYMBOL(kernel_map);#define kernel_map (*(struct kernel_mapping *)XIP_FIXUP(&kernel_map))#endif +phys_addr_t phys_ram_base__ro_after_init ; +EXPORT_SYMBOL (phys_ram_base); +#ifdef CONFIG_XIP_KERNEL extern char _xiprom[], _exiprom[];#endif
@@ -160,7 +163,7 @@ static void __init setup_bootmem(void)phys_addr_t vmlinux_end =__pa_symbol (&_end);phys_addr_t vmlinux_start =__pa_symbol (&_start);phys_addr_t __maybe_unused max_mapped_addr; -phys_addr_t dram_end; +phys_addr_t phys_ram_end;#ifdef CONFIG_XIP_KERNEL vmlinux_start =__pa_symbol (&_sdata);
@@ -181,9 +184,12 @@ static void __init setup_bootmem(void)#endif memblock_reserve (vmlinux_start, vmlinux_end - vmlinux_start); - dram_end =memblock_end_of_DRAM (); + phys_ram_end =memblock_end_of_DRAM ();#ifndef CONFIG_64BIT +#ifndef CONFIG_XIP_KERNEL + phys_ram_base =memblock_start_of_DRAM (); +#endif /* * memblock allocator is not aware of the fact that last 4K bytes of * the addressable memory can not be mapped because of IS_ERR_VALUE
@@ -194,12 +200,12 @@ static void __init setup_bootmem(void)* be done in create_kernel_page_table. */ max_mapped_addr =__pa (~(ulong )0 ); -if (max_mapped_addr == (dram_end -1 )) +if (max_mapped_addr == (phys_ram_end -1 ))memblock_set_current_limit (max_mapped_addr -4096 );#endif - min_low_pfn =PFN_UP (memblock_start_of_DRAM ()); - max_low_pfn = max_pfn =PFN_DOWN (dram_end); + min_low_pfn =PFN_UP (phys_ram_base); + max_low_pfn = max_pfn =PFN_DOWN (phys_ram_end); dma32_phys_limit =min (4UL *SZ_1G , (unsigned long )PFN_PHYS (max_low_pfn));set_max_mapnr (max_low_pfn -ARCH_PFN_OFFSET );
@@ -558,6 +564,7 @@ asmlinkage void __init setup_vm(uintptr_t dtb_pa) kernel_map.xiprom = (uintptr_t )CONFIG_XIP_PHYS_ADDR ; kernel_map.xiprom_sz = (uintptr_t )(&_exiprom) - (uintptr_t )(&_xiprom); + phys_ram_base =CONFIG_PHYS_RAM_BASE ; kernel_map.phys_addr = (uintptr_t )CONFIG_PHYS_RAM_BASE ; kernel_map.size = (uintptr_t )(&_end) - (uintptr_t )(&_sdata);
Alex Ghiti
reviewerHi Greg,
Le 9/08/2021 à 12:42, [email protected] a écrit :
Quoted 2 lines
The patch below does not apply to the 5.13-stable tree.
I don't know when stable was cc on this patch, this fixes something introduced in 5.14-rc1, so this is not normal it can't be applied.
Sorry for the noise,
Alex
Quoted 120 lines
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From
6d7f91d914bc90a15ebc426440c26081337ceaa1Mon Sep 17 00:00:00 2001
From: Alexandre Ghiti <[email protected]>
Date: Wed, 21 Jul 2021 09:59:35 +0200
Subject: [PATCH] riscv: Get rid ofCONFIG_PHYS_RAM_BASEin kernel physical
address conversionThe usage of
CONFIG_PHYS_RAM_BASEfor all kernel types was a mistake:
this value is implementation-specific and this breaks the genericity of the RISC-V kernel.Fix this by introducing a new variable
phys_ram_basethat holds this value at runtime and use it in the kernel physical address conversion macro. Since this value is used only for XIP kernels, evaluate it only ifCONFIG_XIP_KERNELis set which in addition optimizes this macro for standard kernels at compile-time.Signed-off-by Alexandre Ghiti <[email protected]>Tested-by Emil Renner Berthing <[email protected]>Reviewed-by Jisheng Zhang <[email protected]>Fixes 44c922572952 ("RISC-V: enable XIP")Signed-off-by Palmer Dabbelt <[email protected]>arch/riscv/include/asm/page.h +4
-3@@ -103,6 +103,7 @@ struct kernel_mapping { };extern struct kernel_mapping kernel_map; +extern phys_addr_t phys_ram_base;#ifdef CONFIG_64BIT #define is_kernel_mapping (x) \@@ -113,9 +114,9 @@ extern struct kernel_mapping kernel_map;#define linear_mapping_pa_to_va (x) ((void *)((unsigned long)(x) + kernel_map.va_pa_offset))#define kernel_mapping_pa_to_va (y) ({ \ unsigned long _y = y; \ - (_y >= CONFIG_PHYS_RAM_BASE) ? \ - (void *)((unsigned long)(_y) + kernel_map.va_kernel_pa_offset + XIP_OFFSET) : \ - (void *)((unsigned long)(_y) + kernel_map.va_kernel_xip_pa_offset); \ + (IS_ENABLED(CONFIG_XIP_KERNEL) && _y < phys_ram_base) ? \ + (void *)((unsigned long)(_y) + kernel_map.va_kernel_xip_pa_offset) : \ + (void *)((unsigned long)(_y) + kernel_map.va_kernel_pa_offset + XIP_OFFSET); \ })#define __pa_to_va_nodebug (x) linear_mapping_pa_to_va(x)arch/riscv/mm/init.c +12
-5@@ -36,6 +36,9 @@ EXPORT_SYMBOL(kernel_map);#define kernel_map (*(struct kernel_mapping *)XIP_FIXUP(&kernel_map))#endif +phys_addr_t phys_ram_base__ro_after_init ; +EXPORT_SYMBOL (phys_ram_base); +#ifdef CONFIG_XIP_KERNEL extern char _xiprom[], _exiprom[];#endif @@ -160,7 +163,7 @@ static void __init setup_bootmem(void)phys_addr_t vmlinux_end =__pa_symbol (&_end);phys_addr_t vmlinux_start =__pa_symbol (&_start);phys_addr_t __maybe_unused max_mapped_addr; -phys_addr_t dram_end; +phys_addr_t phys_ram_end;#ifdef CONFIG_XIP_KERNEL vmlinux_start =__pa_symbol (&_sdata);@@ -181,9 +184,12 @@ static void __init setup_bootmem(void)#endif memblock_reserve (vmlinux_start, vmlinux_end - vmlinux_start); - dram_end =memblock_end_of_DRAM (); + phys_ram_end =memblock_end_of_DRAM ();#ifndef CONFIG_64BIT +#ifndef CONFIG_XIP_KERNEL + phys_ram_base =memblock_start_of_DRAM (); +#endif /* * memblock allocator is not aware of the fact that last 4K bytes of * the addressable memory can not be mapped because of IS_ERR_VALUE @@ -194,12 +200,12 @@ static void __init setup_bootmem(void)* be done in create_kernel_page_table. */ max_mapped_addr =__pa (~(ulong )0 ); -if (max_mapped_addr == (dram_end -1 )) +if (max_mapped_addr == (phys_ram_end -1 ))memblock_set_current_limit (max_mapped_addr -4096 );#endif - min_low_pfn =PFN_UP (memblock_start_of_DRAM ()); - max_low_pfn = max_pfn =PFN_DOWN (dram_end); + min_low_pfn =PFN_UP (phys_ram_base); + max_low_pfn = max_pfn =PFN_DOWN (phys_ram_end); dma32_phys_limit =min (4UL *SZ_1G , (unsigned long )PFN_PHYS (max_low_pfn));set_max_mapnr (max_low_pfn -ARCH_PFN_OFFSET );@@ -558,6 +564,7 @@ asmlinkage void __init setup_vm(uintptr_t dtb_pa) kernel_map.xiprom = (uintptr_t )CONFIG_XIP_PHYS_ADDR ; kernel_map.xiprom_sz = (uintptr_t )(&_exiprom) - (uintptr_t )(&_xiprom); + phys_ram_base =CONFIG_PHYS_RAM_BASE ; kernel_map.phys_addr = (uintptr_t )CONFIG_PHYS_RAM_BASE ; kernel_map.size = (uintptr_t )(&_end) - (uintptr_t )(&_sdata);
Greg KH
maintainerQuoted 4 lines · Alex Ghiti
Hi Greg,
Le 9/08/2021 à 12:42, [email protected] a écrit :
Quoted 1 line
Quoted 39 lines
Quoted 1 line
The patch below does not apply to the 5.13-stable tree.
I don't know when stable was cc on this patch, this fixes something introduced in 5.14-rc1, so this is not normal it can't be applied.
Sorry for the noise,
Alex
Quoted 30 lines
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From
6d7f91d914bc90a15ebc426440c26081337ceaa1Mon Sep 17 00:00:00 2001
From: Alexandre Ghiti <[email protected]>
Date: Wed, 21 Jul 2021 09:59:35 +0200
Subject: [PATCH] riscv: Get rid ofCONFIG_PHYS_RAM_BASEin kernel physical
address conversionThe usage of
CONFIG_PHYS_RAM_BASEfor all kernel types was a mistake:
this value is implementation-specific and this breaks the genericity of the RISC-V kernel.Fix this by introducing a new variable
phys_ram_basethat holds this value at runtime and use it in the kernel physical address conversion macro. Since this value is used only for XIP kernels, evaluate it only ifCONFIG_XIP_KERNELis set which in addition optimizes this macro for standard kernels at compile-time.Signed-off-by Alexandre Ghiti <[email protected]>Tested-by Emil Renner Berthing <[email protected]>Reviewed-by Jisheng Zhang <[email protected]>Fixes 44c922572952 ("RISC-V: enable XIP")
But this commit id is in 5.13, is that incorrect?
Just verifying,
greg k-h
Quoted 40 lines · Greg KH
Quoted 39 lines · Alex Ghiti
Hi Greg,
Le 9/08/2021 à 12:42, [email protected] a écrit :
Quoted 2 lines
The patch below does not apply to the 5.13-stable tree.
I don't know when stable was cc on this patch, this fixes something introduced in 5.14-rc1, so this is not normal it can't be applied.
Sorry for the noise,
Alex
Quoted 26 lines
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From
6d7f91d914bc90a15ebc426440c26081337ceaa1Mon Sep 17 00:00:00 2001
From: Alexandre Ghiti <[email protected]>
Date: Wed, 21 Jul 2021 09:59:35 +0200
Subject: [PATCH] riscv: Get rid ofCONFIG_PHYS_RAM_BASEin kernel physical
address conversionThe usage of
CONFIG_PHYS_RAM_BASEfor all kernel types was a mistake:
this value is implementation-specific and this breaks the genericity of the RISC-V kernel.Fix this by introducing a new variable
phys_ram_basethat holds this value at runtime and use it in the kernel physical address conversion macro. Since this value is used only for XIP kernels, evaluate it only ifCONFIG_XIP_KERNELis set which in addition optimizes this macro for standard kernels at compile-time.
Quoted 6 lines
Quoted 4 lines
Quoted 4 lines
Signed-off-by Alexandre Ghiti <[email protected]>Tested-by Emil Renner Berthing <[email protected]>Reviewed-by Jisheng Zhang <[email protected]>Fixes 44c922572952 ("RISC-V: enable XIP")But this commit id is in 5.13, is that incorrect?
I wasn't sure what to do here: IMO this fixes a bug that was there the whole time, it's just not one that actually manifests until the refactoring. I figured I'd put the farther back tag just to be safe, in case someone had picked up the feature (more likely a distro tree, but IIUC they're also looking here).
Alex Ghiti
reviewerLe 10/08/2021 à 17:07, Palmer Dabbelt a écrit :
Quoted 46 lines · Greg KH
Quoted 45 lines · Alex Ghiti
Quoted 44 lines
Hi Greg,
Le 9/08/2021 à 12:42, [email protected] a écrit :
Quoted 2 lines
The patch below does not apply to the 5.13-stable tree.
I don't know when stable was cc on this patch, this fixes something introduced in 5.14-rc1, so this is not normal it can't be applied.
Sorry for the noise,
Alex
Quoted 2 lines
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git
commit
Quoted 9 lines
id to <[email protected]>.
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From
6d7f91d914bc90a15ebc426440c26081337ceaa1Mon Sep 17 00:00:002001
Quoted 3 lines
From: Alexandre Ghiti <[email protected]>
Date: Wed, 21 Jul 2021 09:59:35 +0200
Subject: [PATCH] riscv: Get rid ofCONFIG_PHYS_RAM_BASEin kernelphysical
Quoted 4 lines
address conversion
The usage of
CONFIG_PHYS_RAM_BASEfor all kernel types was a mistake:
this value is implementation-specific and this breaks thegenericity of
Quoted 5 lines
the RISC-V kernel.
Fix this by introducing a new variable
phys_ram_basethat holds this value at runtime and use it in the kernel physical address conversion macro. Since this value is used only for XIP kernels, evaluate itonly if
Quoted 3 lines
CONFIG_XIP_KERNELis set which in addition optimizes this macro for standard kernels at compile-time.
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
Quoted 4 lines
Signed-off-by Alexandre Ghiti <[email protected]>Tested-by Emil Renner Berthing <[email protected]>Reviewed-by Jisheng Zhang <[email protected]>Fixes 44c922572952 ("RISC-V: enable XIP")But this commit id is in 5.13, is that incorrect?
I wasn't sure what to do here: IMO this fixes a bug that was there the whole time, it's just not one that actually manifests until the refactoring. I figured I'd put the farther back tag just to be safe, in case someone had picked up the feature (more likely a distro tree, but IIUC they're also looking here).
Ok I understand why it got to stable but the Fixes tag is wrong to me, it should be commit 7094e6acaf7a ("riscv: Simplify xip and !xip kernel address conversion macros") because this is the one that makes use of CONFIG_PHYS_RAM_BASE for *all* kernels, and not only xip kernel, which was wrong. The original problem comes from this commit introduced in v5.14-rc1 so it should not be backported.
Alex