Skip to contentSkip to conversation

powerpc/mm/hash: Always clear UPRT and Host Radix bits when setting up CPU

PATCH Applied Aneesh Kumar K.V 4 participants 7 messages Feb 22, 2017 – Feb 27, 2017 PowerPC

lore
Share & tools
lore
#0 lore raw

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.

Fixes fe036a0605d60 ("powerpc/64/kexec: Fix MMU cleanup on radix")
---
 arch/powerpc/kernel/cpu_setup_power.S | 4 ++++
 1 file changed, 4 insertions(+)
arch/powerpc/kernel/cpu_setup_power.S +4 -0
index 917188615bf5..7fe8c79e6937 100644
@@ -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
#1 lore raw
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")
---
 arch/powerpc/kernel/cpu_setup_power.S | 4 ++++
 1 file changed, 4 insertions(+)
arch/powerpc/kernel/cpu_setup_power.S +2 -0
index 917188615bf5..7fe8c79e6937 100644
@@ -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.

#2 lore raw
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")
---
  arch/powerpc/kernel/cpu_setup_power.S | 4 ++++
  1 file changed, 4 insertions(+)
arch/powerpc/kernel/cpu_setup_power.S +2 -0
index 917188615bf5..7fe8c79e6937 100644
@@ -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 -0
  	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?

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

#3 lore raw
In reply to Aneesh Kumar K.V
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")
---
 arch/powerpc/kernel/cpu_setup_power.S | 4 ++++
 1 file changed, 4 insertions(+)
arch/powerpc/kernel/cpu_setup_power.S +2 -0
index 917188615bf5..7fe8c79e6937 100644
@@ -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

#4 lore raw
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")
---
  arch/powerpc/kernel/cpu_setup_power.S | 4 ++++
  1 file changed, 4 insertions(+)
arch/powerpc/kernel/cpu_setup_power.S +2 -0
index 917188615bf5..7fe8c79e6937 100644
@@ -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 -0
  	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

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

#5 lore raw
In reply to Aneesh Kumar K.V
Quoted 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")

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

#6 lore raw
In reply to Aneesh Kumar K.V
Quoted 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")

Applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/fda2d27db6eae5c2468f9e4657539b

cheers