powerpc/64: option to force run-at-load to test relocation
Nicholas Piggin
reviewerPATCH 1/1 powerpc/64: option to force run-at-load to test relocation
This adds a config option that can help exercise the case when the kernel is not running at PAGE_OFFSET.
--- arch/powerpc/Kconfig | 9 +++++++++ arch/powerpc/kernel/head_64.S | 4 ++++ arch/powerpc/kernel/setup-common.c | 3 +++ 3 files changed, 16 insertions(+)
arch/powerpc/Kconfig +9 -0
@@ -478,6 +478,15 @@ config RELOCATABLE setting can still be useful to bootwrappers that need to know the load address of the kernel (eg. u-boot/mkimage). +config RELOCATABLE_TEST + bool "Test relocatable kernel" + depends on (PPC64 && RELOCATABLE) + default n + help + This runs the relocatable kernel at the address it was initially + loaded at, which tends to be non-zero and therefore test the + relocation code. + config CRASH_DUMP bool "Build a kdump crash kernel" depends on PPC64 || 6xx || FSL_BOOKE || (44x && !SMP)
arch/powerpc/kernel/head_64.S +4 -0
@@ -111,8 +111,12 @@ __secondary_hold_acknowledge: .globl __run_at_load __run_at_load: DEFINE_FIXED_SYMBOL(__run_at_load) +#ifdef CONFIG_RELOCATABLE_TEST + .long 0x1 /* Test relocation, do not relocate to 0 */ +#else .long 0x72756e30 /* "run0" -- relocate to 0 by default */ #endif +#endif . = 0x60 /*
arch/powerpc/kernel/setup-common.c +3 -0
@@ -795,6 +795,9 @@ static __init void print_system_info(void)pr_info ("mmu_features = 0x%08x\n" , cur_cpu_spec->mmu_features);#ifdef CONFIG_PPC64 pr_info ("firmware_features = 0x%016lx\n" , powerpc_firmware_features); + +if (get_paca ()->kernelbase !=PAGE_OFFSET ) +pr_info ("kernelbase = 0x%llx\n" ,get_paca ()->kernelbase);#endif #ifdef CONFIG_PPC_STD_MMU_64
Signature · 1 line
2.9.3
Quoted 35 lines · Nicholas Piggin
This adds a config option that can help exercise the case when the kernel is not running at
PAGE_OFFSET.Signed-off-by Nicholas Piggin <[email protected]>--- arch/powerpc/Kconfig | 9 +++++++++ arch/powerpc/kernel/head_64.S | 4 ++++ arch/powerpc/kernel/setup-common.c | 3 +++ 3 files changed, 16 insertions(+)arch/powerpc/Kconfig +9
-0@@ -478,6 +478,15 @@ config RELOCATABLE setting can still be useful to bootwrappers that need to know the load address of the kernel (eg. u-boot/mkimage). +config RELOCATABLE_TEST + bool "Test relocatable kernel" + depends on (PPC64 && RELOCATABLE) + default n + help + This runs the relocatable kernel at the address it was initially + loaded at, which tends to be non-zero and therefore test the + relocation code. + config CRASH_DUMP bool "Build a kdump crash kernel" depends on PPC64 || 6xx || FSL_BOOKE || (44x && !SMP)arch/powerpc/kernel/head_64.S +0
-0
arch/powerpc/kernel/head_64.S __secondary_hold_acknowledge: · line 119
Quoted 9 lines
arch/powerpc/kernel/head_64.S +4
-0@@ -111,8 +111,12 @@ __secondary_hold_acknowledge: .globl __run_at_load __run_at_load: DEFINE_FIXED_SYMBOL(__run_at_load) +#ifdef CONFIG_RELOCATABLE_TEST + .long 0x1 /* Test relocation, do not relocate to 0 */ +#else .long 0x72756e30 /* "run0" -- relocate to 0 by default */ #endif +#endif
Could we do something like
config RELOCATION_VALUE
default 0x72756e30 default 1 if CONFIG_RELOCTABLE_TEST
and then get
.long CONFIG_RELOCATION_VALUE
Quoted 8 lines
arch/powerpc/kernel/head_64.S +0
-0. = 0x60 /*arch/powerpc/kernel/setup-common.c +0
-0
arch/powerpc/kernel/setup-common.c static __init void print_system_info(void) · line 802
Quoted 8 lines
arch/powerpc/kernel/setup-common.c +3
-0@@ -795,6 +795,9 @@ static __init void print_system_info(void)pr_info ("mmu_features = 0x%08x\n" , cur_cpu_spec->mmu_features);#ifdef CONFIG_PPC64 pr_info ("firmware_features = 0x%016lx\n" , powerpc_firmware_features); + +if (get_paca ()->kernelbase !=PAGE_OFFSET ) +pr_info ("kernelbase = 0x%llx\n" ,get_paca ()->kernelbase);#endif
Do we need this? We get physical_offset if we are relocated.
arch/powerpc/kernel/setup-common.c static __init void print_system_info(void) · line 803
Quoted 2 lines
arch/powerpc/kernel/setup-common.c +0
-0#ifdef CONFIG_PPC_STD_MMU_64
Balbir Singh.
Nicholas Piggin
reviewerQuoted 48 lines · On Wed, 12 Oct 2016 18:35:21 +1100 Balbir Singh <[email protected]> wrote:
Quoted 35 lines · Nicholas Piggin
This adds a config option that can help exercise the case when the kernel is not running at
PAGE_OFFSET.Signed-off-by Nicholas Piggin <[email protected]>--- arch/powerpc/Kconfig | 9 +++++++++ arch/powerpc/kernel/head_64.S | 4 ++++ arch/powerpc/kernel/setup-common.c | 3 +++ 3 files changed, 16 insertions(+)arch/powerpc/Kconfig +9
-0@@ -478,6 +478,15 @@ config RELOCATABLE setting can still be useful to bootwrappers that need to know the load address of the kernel (eg. u-boot/mkimage). +config RELOCATABLE_TEST + bool "Test relocatable kernel" + depends on (PPC64 && RELOCATABLE) + default n + help + This runs the relocatable kernel at the address it was initially + loaded at, which tends to be non-zero and therefore test the + relocation code. + config CRASH_DUMP bool "Build a kdump crash kernel" depends on PPC64 || 6xx || FSL_BOOKE || (44x && !SMP)arch/powerpc/kernel/head_64.S +0
-0arch/powerpc/kernel/head_64.S __secondary_hold_acknowledge: · line 119
Quoted 9 lines
arch/powerpc/kernel/head_64.S +4
-0@@ -111,8 +111,12 @@ __secondary_hold_acknowledge: .globl __run_at_load __run_at_load: DEFINE_FIXED_SYMBOL(__run_at_load) +#ifdef CONFIG_RELOCATABLE_TEST + .long 0x1 /* Test relocation, do not relocate to 0 */ +#else .long 0x72756e30 /* "run0" -- relocate to 0 by default */ #endif +#endifCould we do something like
Quoted 7 lines
config
RELOCATION_VALUEdefault 0x72756e30 default 1 if CONFIG_RELOCTABLE_TESTand then get
.long
CONFIG_RELOCATION_VALUE
Normally I'm up for reducing ifdefs in S and c files, but in this case I'm not sure. I like being able to see the two possible values in the source. I don't really mind though. If you or Michael feel strongly, I'm happy to change it.
Quoted 9 lines
Quoted 9 lines
arch/powerpc/kernel/head_64.S +0
-0. = 0x60 /*arch/powerpc/kernel/setup-common.c +0
-0@@ -795,6 +795,9 @@ static __init void print_system_info(void)pr_info ("mmu_features = 0x%08x\n" , cur_cpu_spec->mmu_features);#ifdef CONFIG_PPC64
Quoted 8 lines
arch/powerpc/kernel/setup-common.c static __init void print_system_info(void) · line 802
Quoted 6 lines
arch/powerpc/kernel/setup-common.c +3
-0pr_info ("firmware_features = 0x%016lx\n" , powerpc_firmware_features); + +if (get_paca ()->kernelbase !=PAGE_OFFSET ) +pr_info ("kernelbase = 0x%llx\n" ,get_paca ()->kernelbase);#endif Do we need this? We get
physical_offsetif we are relocated.
You're right, that hunk can go.
Thanks,
Nick
Quoted 55 lines · Nicholas Piggin
Quoted 52 lines · On Wed, 12 Oct 2016 18:35:21 +1100 Balbir Singh <[email protected]> wrote:
Quoted 35 lines · Nicholas Piggin
This adds a config option that can help exercise the case when the kernel is not running at
PAGE_OFFSET.Signed-off-by Nicholas Piggin <[email protected]>--- arch/powerpc/Kconfig | 9 +++++++++ arch/powerpc/kernel/head_64.S | 4 ++++ arch/powerpc/kernel/setup-common.c | 3 +++ 3 files changed, 16 insertions(+)arch/powerpc/Kconfig +9
-0@@ -478,6 +478,15 @@ config RELOCATABLE setting can still be useful to bootwrappers that need to know the load address of the kernel (eg. u-boot/mkimage). +config RELOCATABLE_TEST + bool "Test relocatable kernel" + depends on (PPC64 && RELOCATABLE) + default n + help + This runs the relocatable kernel at the address it was initially + loaded at, which tends to be non-zero and therefore test the + relocation code. + config CRASH_DUMP bool "Build a kdump crash kernel" depends on PPC64 || 6xx || FSL_BOOKE || (44x && !SMP)arch/powerpc/kernel/head_64.S +0
-0arch/powerpc/kernel/head_64.S __secondary_hold_acknowledge: · line 119
Quoted 9 lines
arch/powerpc/kernel/head_64.S +4
-0@@ -111,8 +111,12 @@ __secondary_hold_acknowledge: .globl __run_at_load __run_at_load: DEFINE_FIXED_SYMBOL(__run_at_load) +#ifdef CONFIG_RELOCATABLE_TEST + .long 0x1 /* Test relocation, do not relocate to 0 */ +#else .long 0x72756e30 /* "run0" -- relocate to 0 by default */ #endif +#endifCould we do something like
config
RELOCATION_VALUEdefault 0x72756e30 default 1 if CONFIG_RELOCTABLE_TEST
Quoted 9 lines
Quoted 3 lines
and then get
.long
CONFIG_RELOCATION_VALUENormally I'm up for reducing ifdefs in S and c files, but in this case I'm not sure. I like being able to see the two possible values in the source. I don't really mind though. If you or Michael feel strongly, I'm happy to change it.
I guess it depends, for me parsing two .long's under #ifdef seems a little more work than a .long with a constant depending on the configuration.
I don't feel too strongly about it either
Balbir Singh.
Michael Ellerman
reviewerQuoted 18 lines · Balbir Singh
Quoted 5 lines · Nicholas Piggin
arch/powerpc/kernel/head_64.S +0
-0arch/powerpc/kernel/head_64.S __secondary_hold_acknowledge: · line 119
Quoted 9 lines
arch/powerpc/kernel/head_64.S +4
-0@@ -111,8 +111,12 @@ __secondary_hold_acknowledge: .globl __run_at_load __run_at_load: DEFINE_FIXED_SYMBOL(__run_at_load) +#ifdef CONFIG_RELOCATABLE_TEST + .long 0x1 /* Test relocation, do not relocate to 0 */ +#else .long 0x72756e30 /* "run0" -- relocate to 0 by default */ #endif +#endifCould we do something like
Quoted 3 lines
config
RELOCATION_VALUEdefault 0x72756e30 default 1 if CONFIG_RELOCTABLE_TEST
I'm not a fan of using kconfig logic when plain #defines would achieve the same result, eg:
#ifdef CONFIG_RELOCATABLE_TEST
#define RUN_AT_LOAD_DEFAULT 1 /* Test relocation, do not relocate to 0 */
#else
#define RUN_AT_LOAD_DEFAULT 0x72756e30 /* "run0" -- relocate to 0 by default */ #endif
.globl __run_at_load
__run_at_load:DEFINE_FIXED_SYMBOL(__run_at_load)
.long RUN_AT_LOAD_DEFAULT
Which is probably nicer to look at than Nick's version, but not by a huge margin. I'd merge either.
cheers