powerpc/mm/hash: Always clear UPRT and Host Radix bits when setting up CPU
PATCH 1/1 powerpc/mm/hash: Always clear UPRT and Host Radix bits when setting up CPU
We will set LPCR with correct value for radix during int. This make sure we start with a sanitized value of LPCR. In case of kexec, cpus can have LPCR value based on the previous translation mode we were running.
--- arch/powerpc/kernel/cpu_setup_power.S | 4 ++++ 1 file changed, 4 insertions(+)
arch/powerpc/kernel/cpu_setup_power.S +4 -0
@@ -101,6 +101,8 @@ _GLOBAL(__setup_cpu_power9) mfspr r3,SPRN_LPCR LOAD_REG_IMMEDIATE(r4, LPCR_PECEDH | LPCR_PECE_HVEE | LPCR_HVICE) or r3, r3, r4 + LOAD_REG_IMMEDIATE(r4, LPCR_UPRT | LPCR_HR) + andc r3, r3, r4 bl __init_LPCR bl __init_HFSCR bl __init_tlb_power9
@@ -122,6 +124,8 @@ _GLOBAL(__restore_cpu_power9) mfspr r3,SPRN_LPCR LOAD_REG_IMMEDIATE(r4, LPCR_PECEDH | LPCR_PECE_HVEE | LPCR_HVICE) or r3, r3, r4 + LOAD_REG_IMMEDIATE(r4, LPCR_UPRT | LPCR_HR) + andc r3, r3, r4 bl __init_LPCR bl __init_HFSCR bl __init_tlb_power9
Signature · 1 line
2.7.4
Quoted 26 lines · Aneesh Kumar K.V
We will set LPCR with correct value for radix during int. This make sure we start with a sanitized value of LPCR. In case of kexec, cpus can have LPCR value based on the previous translation mode we were running.
Fixes fe036a0605d60 ("powerpc/64/kexec: Fix MMU cleanup on radix")Cc [email protected] # v4.9+Acked-by Michael Neuling <[email protected]>Signed-off-by Aneesh Kumar K.V <[email protected]>--- arch/powerpc/kernel/cpu_setup_power.S | 4 ++++ 1 file changed, 4 insertions(+)arch/powerpc/kernel/cpu_setup_power.S +2
-0@@ -101,6 +101,8 @@ _GLOBAL(__setup_cpu_power9) mfspr r3,SPRN_LPCR LOAD_REG_IMMEDIATE(r4, LPCR_PECEDH | LPCR_PECE_HVEE | LPCR_HVICE) or r3, r3, r4 + LOAD_REG_IMMEDIATE(r4, LPCR_UPRT | LPCR_HR) + andc r3, r3, r4 bl __init_LPCR bl __init_HFSCR bl __init_tlb_power9
arch/powerpc/kernel/cpu_setup_power.S _GLOBAL(__restore_cpu_power9) · line 131
Quoted 8 lines
arch/powerpc/kernel/cpu_setup_power.S +2
-0@@ -122,6 +124,8 @@ _GLOBAL(__restore_cpu_power9) mfspr r3,SPRN_LPCR LOAD_REG_IMMEDIATE(r4, LPCR_PECEDH | LPCR_PECE_HVEE | LPCR_HVICE) or r3, r3, r4 + LOAD_REG_IMMEDIATE(r4, LPCR_UPRT | LPCR_HR) + andc r3, r3, r4 bl __init_LPCR bl __init_HFSCR bl __init_tlb_power9
What about LPCR_GTSE and other bits?
Balbir Singh.
Quoted 28 lines · Balbir Singh
Quoted 27 lines · Aneesh Kumar K.V
We will set LPCR with correct value for radix during int. This make sure we start with a sanitized value of LPCR. In case of kexec, cpus can have LPCR value based on the previous translation mode we were running.
Fixes fe036a0605d60 ("powerpc/64/kexec: Fix MMU cleanup on radix")Cc [email protected] # v4.9+Acked-by Michael Neuling <[email protected]>Signed-off-by Aneesh Kumar K.V <[email protected]>--- arch/powerpc/kernel/cpu_setup_power.S | 4 ++++ 1 file changed, 4 insertions(+)arch/powerpc/kernel/cpu_setup_power.S +2
-0@@ -101,6 +101,8 @@ _GLOBAL(__setup_cpu_power9) mfspr r3,SPRN_LPCR LOAD_REG_IMMEDIATE(r4, LPCR_PECEDH | LPCR_PECE_HVEE | LPCR_HVICE) or r3, r3, r4 + LOAD_REG_IMMEDIATE(r4, LPCR_UPRT | LPCR_HR) + andc r3, r3, r4 bl __init_LPCR bl __init_HFSCR bl __init_tlb_power9@@ -122,6 +124,8 @@ _GLOBAL(__restore_cpu_power9) mfspr r3,SPRN_LPCR
Quoted 10 lines
arch/powerpc/kernel/cpu_setup_power.S _GLOBAL(__setup_cpu_power9) · line 108
Quoted 7 lines
arch/powerpc/kernel/cpu_setup_power.S +2
-0LOAD_REG_IMMEDIATE(r4, LPCR_PECEDH | LPCR_PECE_HVEE | LPCR_HVICE) or r3, r3, r4 + LOAD_REG_IMMEDIATE(r4, LPCR_UPRT | LPCR_HR) + andc r3, r3, r4 bl __init_LPCR bl __init_HFSCR bl __init_tlb_power9What about
LPCR_GTSEand other bits?
That is set by the hypervisor for guest. We don't set that and expect to inherit that from a previous run for baremetal. Also setting that in the context of LPID 0 shouldn't have any impact.
-aneesh
Quoted 26 lines · Aneesh Kumar K.V
We will set LPCR with correct value for radix during int. This make sure we start with a sanitized value of LPCR. In case of kexec, cpus can have LPCR value based on the previous translation mode we were running.
Fixes fe036a0605d60 ("powerpc/64/kexec: Fix MMU cleanup on radix")Cc [email protected] # v4.9+Acked-by Michael Neuling <[email protected]>Signed-off-by Aneesh Kumar K.V <[email protected]>--- arch/powerpc/kernel/cpu_setup_power.S | 4 ++++ 1 file changed, 4 insertions(+)arch/powerpc/kernel/cpu_setup_power.S +2
-0@@ -101,6 +101,8 @@ _GLOBAL(__setup_cpu_power9) mfspr r3,SPRN_LPCR LOAD_REG_IMMEDIATE(r4, LPCR_PECEDH | LPCR_PECE_HVEE | LPCR_HVICE) or r3, r3, r4 + LOAD_REG_IMMEDIATE(r4, LPCR_UPRT | LPCR_HR) + andc r3, r3, r4 bl __init_LPCR bl __init_HFSCR bl __init_tlb_power9
arch/powerpc/kernel/cpu_setup_power.S _GLOBAL(__restore_cpu_power9) · line 131
Quoted 8 lines
arch/powerpc/kernel/cpu_setup_power.S +2
-0@@ -122,6 +124,8 @@ _GLOBAL(__restore_cpu_power9) mfspr r3,SPRN_LPCR LOAD_REG_IMMEDIATE(r4, LPCR_PECEDH | LPCR_PECE_HVEE | LPCR_HVICE) or r3, r3, r4 + LOAD_REG_IMMEDIATE(r4, LPCR_UPRT | LPCR_HR) + andc r3, r3, r4 bl __init_LPCR bl __init_HFSCR bl __init_tlb_power9
My previous comment mentions GTSE, but really we should be clearing LPCR to 0 and setting it to sane values in __init_LPCR
Balbir
Quoted 29 lines · Balbir Singh
Quoted 28 lines · Aneesh Kumar K.V
We will set LPCR with correct value for radix during int. This make sure we start with a sanitized value of LPCR. In case of kexec, cpus can have LPCR value based on the previous translation mode we were running.
Fixes fe036a0605d60 ("powerpc/64/kexec: Fix MMU cleanup on radix")Cc [email protected] # v4.9+Acked-by Michael Neuling <[email protected]>Signed-off-by Aneesh Kumar K.V <[email protected]>--- arch/powerpc/kernel/cpu_setup_power.S | 4 ++++ 1 file changed, 4 insertions(+)arch/powerpc/kernel/cpu_setup_power.S +2
-0@@ -101,6 +101,8 @@ _GLOBAL(__setup_cpu_power9) mfspr r3,SPRN_LPCR LOAD_REG_IMMEDIATE(r4, LPCR_PECEDH | LPCR_PECE_HVEE | LPCR_HVICE) or r3, r3, r4 + LOAD_REG_IMMEDIATE(r4, LPCR_UPRT | LPCR_HR) + andc r3, r3, r4 bl __init_LPCR bl __init_HFSCR bl __init_tlb_power9@@ -122,6 +124,8 @@ _GLOBAL(__restore_cpu_power9) mfspr r3,SPRN_LPCR LOAD_REG_IMMEDIATE(r4, LPCR_PECEDH | LPCR_PECE_HVEE | LPCR_HVICE)
Quoted 10 lines
arch/powerpc/kernel/cpu_setup_power.S _GLOBAL(__setup_cpu_power9) · line 108
Quoted 6 lines
arch/powerpc/kernel/cpu_setup_power.S +2
-0or r3, r3, r4 + LOAD_REG_IMMEDIATE(r4, LPCR_UPRT | LPCR_HR) + andc r3, r3, r4 bl __init_LPCR bl __init_HFSCR bl __init_tlb_power9My previous comment mentions GTSE, but really we should be clearing LPCR to 0 and setting it to sane values in
__init_LPCR
IIUC we do want to inherit values from firmware/skiboot. Hence the explicit usage of mfspr/or. What we want to clear here are values we updated/changed based on translation mode.
-aneesh
Michael Ellerman
reviewerQuoted 8 lines · Aneesh Kumar K.V
We will set LPCR with correct value for radix during int. This make sure we start with a sanitized value of LPCR. In case of kexec, cpus can have LPCR value based on the previous translation mode we were running.
Fixes fe036a0605d60 ("powerpc/64/kexec: Fix MMU cleanup on radix")Cc [email protected] # v4.9+Acked-by Michael Neuling <[email protected]>Signed-off-by Aneesh Kumar K.V <[email protected]>
I can merge this, but the proper fix is to set a sensible value on the kexec down path.
That way you can kexec into an older kernel, which doesn't have this fix. For this specific case maybe that's not really an issue, because this is Power9 only and there aren't any old kernels that are expected to work.
cheers
Michael Ellerman
AppliedQuoted 8 lines · Aneesh Kumar K.V
We will set LPCR with correct value for radix during int. This make sure we start with a sanitized value of LPCR. In case of kexec, cpus can have LPCR value based on the previous translation mode we were running.
Fixes fe036a0605d60 ("powerpc/64/kexec: Fix MMU cleanup on radix")Cc [email protected] # v4.9+Acked-by Michael Neuling <[email protected]>Signed-off-by Aneesh Kumar K.V <[email protected]>
Applied to powerpc next, thanks.
https://git.kernel.org/powerpc/c/fda2d27db6eae5c2468f9e4657539b
cheers