Skip to contentSkip to conversation

powerpc: Fix booting P9 hash with CONFIG_PPC_RADIX_MMU=N

PATCH Applied Michael Neuling 4 participants 8 messages May 24, 2017 – May 25, 2017 PowerPC

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 powerpc: Fix booting P9 hash with CONFIG_PPC_RADIX_MMU=N

Currently if you disable CONFIG_PPC_RADIX_MMU you'll crash on boot on a P9. This is because we still set MMU_FTR_TYPE_RADIX via ibm,pa-features and MMU_FTR_TYPE_RADIX is what's used for code patching in much of the asm code (ie. slb_miss_realmode)

This patch fixes the problem by stopping MMU_FTR_TYPE_RADIX from being set from ibm.pa-features.

We may eventually end up removing the CONFIG_PPC_RADIX_MMU option completely but until then this fixes the issue.

---
 arch/powerpc/kernel/prom.c | 2 ++
 1 file changed, 2 insertions(+)
arch/powerpc/kernel/prom.c +2 -0
index 40c4887c27..f830562974 100644
@@ -161,7 +161,9 @@ static struct ibm_pa_feature {
 	{ .pabyte = 0,  .pabit = 3, .cpu_features  = CPU_FTR_CTRL },
 	{ .pabyte = 0,  .pabit = 6, .cpu_features  = CPU_FTR_NOEXECUTE },
 	{ .pabyte = 1,  .pabit = 2, .mmu_features  = MMU_FTR_CI_LARGE_PAGE },
+#ifdef CONFIG_PPC_RADIX_MMU
 	{ .pabyte = 40, .pabit = 0, .mmu_features  = MMU_FTR_TYPE_RADIX },
+#endif
 	{ .pabyte = 1,  .pabit = 1, .invert = 1, .cpu_features = CPU_FTR_NODSISRALIGN },
 	{ .pabyte = 5,  .pabit = 0, .cpu_features  = CPU_FTR_REAL_LE,
 				    .cpu_user_ftrs = PPC_FEATURE_TRUE_LE },
Signature · 1 line
2.11.0
#1 lore raw
Quoted 32 lines · Michael Neuling

Currently if you disable CONFIG_PPC_RADIX_MMU you'll crash on boot on a P9. This is because we still set MMU_FTR_TYPE_RADIX via ibm,pa-features and MMU_FTR_TYPE_RADIX is what's used for code patching in much of the asm code (ie. slb_miss_realmode)

This patch fixes the problem by stopping MMU_FTR_TYPE_RADIX from being set from ibm.pa-features.

We may eventually end up removing the CONFIG_PPC_RADIX_MMU option completely but until then this fixes the issue.

---
 arch/powerpc/kernel/prom.c | 2 ++
 1 file changed, 2 insertions(+)
arch/powerpc/kernel/prom.c +2 -0
index 40c4887c27..f830562974 100644
@@ -161,7 +161,9 @@ static struct ibm_pa_feature {
 	{ .pabyte = 0,  .pabit = 3, .cpu_features  = CPU_FTR_CTRL },
 	{ .pabyte = 0,  .pabit = 6, .cpu_features  = CPU_FTR_NOEXECUTE },
 	{ .pabyte = 1,  .pabit = 2, .mmu_features  = MMU_FTR_CI_LARGE_PAGE },
+#ifdef CONFIG_PPC_RADIX_MMU
 	{ .pabyte = 40, .pabit = 0, .mmu_features  = MMU_FTR_TYPE_RADIX },
+#endif
 	{ .pabyte = 1,  .pabit = 1, .invert = 1, .cpu_features = CPU_FTR_NODSISRALIGN },
 	{ .pabyte = 5,  .pabit = 0, .cpu_features  = CPU_FTR_REAL_LE,
 				    .cpu_user_ftrs = PPC_FEATURE_TRUE_LE },
Signature · 1 line
2.11.0

Instead can we do that feature removal in mmu_early_init_devtree. ie, something like

arch/powerpc/mm/init_64.c +1 -1
index 8f6f2a173e47..8f43f3827bac 100644
@@ -394,7 +394,7 @@ void __init mmu_early_init_devtree(void)
 {
 	/* Disable radix mode based on kernel command line. */
 	/* We don't yet have the machinery to do radix as a guest. */
-	if (disable_radix || !(mfmsr() & MSR_HV))
+	if (!IS_ENABLED(CONFIG_PPC_RADIX_MMU) || disable_radix || !(mfmsr() & MSR_HV))
 		cur_cpu_spec->mmu_features &= ~MMU_FTR_TYPE_RADIX;
 
 	/*
#2 lore raw
Quoted 16 lines · Aneesh Kumar K.V

Michael Neuling <[email protected]> writes:
=20

Quoted 14 lines

Currently if you disable CONFIG_PPC_RADIX_MMU you'll crash on boot on a P9. This is because we still set MMU_FTR_TYPE_RADIX via ibm,pa-features and MMU_FTR_TYPE_RADIX is what's used for code patching in much of the asm code (ie. slb_miss_realmode)
=20
This patch fixes the problem by stopping MMU_FTR_TYPE_RADIX from being set from ibm.pa-features.
=20
We may eventually end up removing the CONFIG_PPC_RADIX_MMU option completely but until then this fixes the issue.
=20

---
=C2=A0arch/powerpc/kernel/prom.c | 2 ++

Quoted 8 lines
Quoted 8 lines

=C2=A01 file changed, 2 insertions(+)
=20

arch/powerpc/kernel/prom.c +0 -0
index 40c4887c27..f830562974 100644
@@ -161,7 +161,9 @@ static struct ibm_pa_feature {

=C2=A0 { .pabyte =3D 0,=C2=A0=C2=A0.pabit =3D 3, .cpu_features=C2=A0=C2=

=A0=3D CPU_FTR_CTRL },

Quoted 1 line
Quoted 1 line

=C2=A0 { .pabyte =3D 0,=C2=A0=C2=A0.pabit =3D 6, .cpu_features=C2=A0=C2=

=A0=3D CPU_FTR_NOEXECUTE },

Quoted 1 line
Quoted 1 line

=C2=A0 { .pabyte =3D 1,=C2=A0=C2=A0.pabit =3D 2, .mmu_features=C2=A0=C2=

=A0=3D MMU_FTR_CI_LARGE_PAGE

Quoted 3 lines
Quoted 3 lines

},
+#ifdef CONFIG_PPC_RADIX_MMU
=C2=A0 { .pabyte =3D 40, .pabit =3D 0, .mmu_features=C2=A0=C2=A0=3D MMU=

_FTR_TYPE_RADIX },

Quoted 2 lines
Quoted 2 lines

+#endif
=C2=A0 { .pabyte =3D 1,=C2=A0=C2=A0.pabit =3D 1, .invert =3D 1, .cpu_fe=

atures =3D

Quoted 2 lines
Quoted 2 lines

CPU_FTR_NODSISRALIGN },
=C2=A0 { .pabyte =3D 5,=C2=A0=C2=A0.pabit =3D 0, .cpu_features=C2=A0=C2=

=A0=3D CPU_FTR_REAL_LE,

Quoted 1 line
Quoted 1 line

=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0.cpu_user_ftrs =3D PPC_FEATURE_TRUE_L=

E },

Quoted 5 lines
Quoted 2 lines

--=C2=A0
2.11.0

=20
Instead can we do that feature removal in mmu_early_init_devtree. ie, something like

It looks like mmu_early_init_devtree() gets called after parsing ibm,pa_fea= tures
so that should work.

Quoted 11 lines
arch/powerpc/mm/init_64.c +0 -0
index 8f6f2a173e47..8f43f3827bac 100644
@@ -394,7 +394,7 @@ void __init mmu_early_init_devtree(v
 oid)
 =C2=A0{

=C2=A0 /* Disable radix mode based on kernel command line. */
=C2=A0 /* We don't yet have the machinery to do radix as a guest. */

arch/powerpc/mm/init_64.c +0 -1
-	if (disable_radix || !(mfmsr() & MSR_HV))

arch/powerpc/kernel/prom.c

Quoted 1 line
arch/powerpc/kernel/prom.c +1 -0
+	if (!IS_ENABLED(CONFIG_PPC_RADIX_MMU) || disable_radix || !(mfmsr() &=

MSR_HV))

What tree is this patch against? Linus' tree doesn't look like that.

Mikey

Quoted 4 lines

=C2=A0 cur_cpu_spec->mmu_features &=3D ~MMU_FTR_TYPE_RADIX;
=C2=A0
=C2=A0 /*
=20

#3 lore raw
Quoted 17 lines · Michael Neuling
Quoted 16 lines · Aneesh Kumar K.V

Michael Neuling <[email protected]> writes:
=20

Quoted 14 lines

Currently if you disable CONFIG_PPC_RADIX_MMU you'll crash on boot on a P9. This is because we still set MMU_FTR_TYPE_RADIX via ibm,pa-features and MMU_FTR_TYPE_RADIX is what's used for code patching in much of the asm code (ie. slb_miss_realmode)
=20
This patch fixes the problem by stopping MMU_FTR_TYPE_RADIX from being set from ibm.pa-features.
=20
We may eventually end up removing the CONFIG_PPC_RADIX_MMU option completely but until then this fixes the issue.
=20

---
=C2=A0arch/powerpc/kernel/prom.c | 2 ++

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

=C2=A01 file changed, 2 insertions(+)
=20

arch/powerpc/kernel/prom.c +0 -0
index 40c4887c27..f830562974 100644
@@ -161,7 +161,9 @@ static struct ibm_pa_feature {

=C2=A0 { .pabyte =3D 0,=C2=A0=C2=A0.pabit =3D 3, .cpu_features=C2=A0=

=C2=A0=3D CPU_FTR_CTRL },

Quoted 1 line
Quoted 1 line
Quoted 1 line

=C2=A0 { .pabyte =3D 0,=C2=A0=C2=A0.pabit =3D 6, .cpu_features=C2=A0=

=C2=A0=3D CPU_FTR_NOEXECUTE },

Quoted 1 line
Quoted 1 line
Quoted 1 line

=C2=A0 { .pabyte =3D 1,=C2=A0=C2=A0.pabit =3D 2, .mmu_features=C2=A0=

=C2=A0=3D MMU_FTR_CI_LARGE_PAGE

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

},
+#ifdef CONFIG_PPC_RADIX_MMU
=C2=A0 { .pabyte =3D 40, .pabit =3D 0, .mmu_features=C2=A0=C2=A0=3D MM=

U_FTR_TYPE_RADIX },

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

+#endif
=C2=A0 { .pabyte =3D 1,=C2=A0=C2=A0.pabit =3D 1, .invert =3D 1, .cpu_f=

eatures =3D

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

CPU_FTR_NODSISRALIGN },
=C2=A0 { .pabyte =3D 5,=C2=A0=C2=A0.pabit =3D 0, .cpu_features=C2=A0=

=C2=A0=3D CPU_FTR_REAL_LE,

Quoted 1 line
Quoted 1 line
Quoted 1 line

=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0.cpu_user_ftrs =3D PPC_FEATURE_TRUE_=

LE },

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

--=C2=A0
2.11.0

=20
Instead can we do that feature removal in mmu_early_init_devtree. ie, something like

It looks like mmu_early_init_devtree() gets called after parsing ibm,pa_f=

eatures

Quoted 12 lines

so that should work.

Quoted 10 lines
arch/powerpc/mm/init_64.c +0 -0
index 8f6f2a173e47..8f43f3827bac 100644
@@ -394,7 +394,7 @@ void __init mmu_early_init_devtree(v
 oid)
 =C2=A0{

=C2=A0 /* Disable radix mode based on kernel command line. */
=C2=A0 /* We don't yet have the machinery to do radix as a guest. */

arch/powerpc/mm/init_64.c +0 -1
-	if (disable_radix || !(mfmsr() & MSR_HV))
Quoted 1 line
Quoted 1 line

arch/powerpc/kernel/prom.c

Quoted 1 line
arch/powerpc/kernel/prom.c +1 -0
+	if (!IS_ENABLED(CONFIG_PPC_RADIX_MMU) || disable_radix || !(mfmsr() =

& MSR_HV))

Quoted 3 lines

What tree is this patch against? Linus' tree doesn't look like that.

mpe/next at the time of this merge window. Do you want me to send a complete patch against latest mpe/next ?

-aneesh

#4 lore raw
Quoted 6 lines · Aneesh Kumar K.V

Michael Neuling <[email protected]> writes:
=20

Quoted 4 lines · Aneesh Kumar K.V
Quoted 3 lines

Michael Neuling <[email protected]> writes:
=20

Quoted 1 line

Currently if you disable CONFIG_PPC_RADIX_MMU you'll crash on boot =

on

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

a P9. This is because we still set MMU_FTR_TYPE_RADIX via ibm,pa-features and MMU_FTR_TYPE_RADIX is what's used for code patc=

hing

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

in much of the asm code (ie. slb_miss_realmode)
=20
This patch fixes the problem by stopping MMU_FTR_TYPE_RADIX from be=

ing

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines

arch/powerpc/kernel/prom.=

Quoted 11 lines

set from ibm.pa-features.
=20
We may eventually end up removing the CONFIG_PPC_RADIX_MMU option completely but until then this fixes the issue.
=20

---
=C2=A0arch/powerpc/kernel/prom.c | 2 ++
=C2=A01 file changed, 2 insertions(+)
=20

arch/powerpc/kernel/prom.= renamed from arch/powerpc/kernel/prom.c +0 -0

c

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

index 40c4887c27..f830562974 100644

arch/powerpc/kernel/prom.c +0 -0
@@ -161,7 +161,9 @@ static struct ibm_pa_feature {

=C2=A0 { .pabyte =3D 0,=C2=A0=C2=A0.pabit =3D 3, .cpu_features=C2=

=A0=C2=A0=3D CPU_FTR_CTRL },

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

=C2=A0 { .pabyte =3D 0,=C2=A0=C2=A0.pabit =3D 6, .cpu_features=C2=

=A0=C2=A0=3D CPU_FTR_NOEXECUTE

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

},
=C2=A0 { .pabyte =3D 1,=C2=A0=C2=A0.pabit =3D 2, .mmu_features=C2=

=A0=C2=A0=3D

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

MMU_FTR_CI_LARGE_PAGE
},
+#ifdef CONFIG_PPC_RADIX_MMU
=C2=A0 { .pabyte =3D 40, .pabit =3D 0, .mmu_features=C2=A0=C2=A0=3D=

MMU_FTR_TYPE_RADIX

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

},
+#endif
=C2=A0 { .pabyte =3D 1,=C2=A0=C2=A0.pabit =3D 1, .invert =3D 1, .cp=

u_features =3D

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

CPU_FTR_NODSISRALIGN },
=C2=A0 { .pabyte =3D 5,=C2=A0=C2=A0.pabit =3D 0, .cpu_features=C2=

=A0=C2=A0=3D CPU_FTR_REAL_LE,

Quoted 22 lines
Quoted 22 lines
Quoted 7 lines
Quoted 4 lines

=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0.cpu_user_ftrs =3D
PPC_FEATURE_TRUE_LE },
--=C2=A0
2.11.0

=20
Instead can we do that feature removal in mmu_early_init_devtree. ie, something like

=20
It looks like mmu_early_init_devtree() gets called after parsing ibm,pa_features
so that should work.
=20

Quoted 10 lines
arch/powerpc/mm/init_64.c +0 -0
index 8f6f2a173e47..8f43f3827bac 100644
@@ -394,7 +394,7 @@ void __init mmu_early_init_devtree(v
 oid)
 =C2=A0{

=C2=A0 /* Disable radix mode based on kernel command line. */
=C2=A0 /* We don't yet have the machinery to do radix as a guest. */

arch/powerpc/mm/init_64.c +0 -1
-	if (disable_radix || !(mfmsr() & MSR_HV))
Quoted 4 lines
Quoted 4 lines
Quoted 2 lines
Quoted 2 lines
arch/powerpc/kernel/prom.c +1 -0
+	if (!IS_ENABLED(CONFIG_PPC_RADIX_MMU) || disable_radix ||

!(mfmsr() & MSR_HV))

=20
What tree is this patch against?=C2=A0=C2=A0Linus' tree doesn't look li=

ke that.

Quoted 4 lines
Quoted 1 line

=20

=20
mpe/next at the time of this merge window. Do you want me to send a complete patch against latest mpe/next ?

If you can test the broken case to make sure it fixes it... Sure!

Thanks,
Mikey

#5 lore raw
In reply to Michael Neuling
Quoted 17 lines · Michael Neuling
Quoted 16 lines · Aneesh Kumar K.V

Michael Neuling <[email protected]> writes:
=20

Quoted 14 lines

Currently if you disable CONFIG_PPC_RADIX_MMU you'll crash on boot on a P9. This is because we still set MMU_FTR_TYPE_RADIX via ibm,pa-features and MMU_FTR_TYPE_RADIX is what's used for code patching in much of the asm code (ie. slb_miss_realmode)
=20
This patch fixes the problem by stopping MMU_FTR_TYPE_RADIX from being set from ibm.pa-features.
=20
We may eventually end up removing the CONFIG_PPC_RADIX_MMU option completely but until then this fixes the issue.
=20

---
=C2=A0arch/powerpc/kernel/prom.c | 2 ++

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

=C2=A01 file changed, 2 insertions(+)
=20

arch/powerpc/kernel/prom.c +0 -0
index 40c4887c27..f830562974 100644
@@ -161,7 +161,9 @@ static struct ibm_pa_feature {

=C2=A0 { .pabyte =3D 0,=C2=A0=C2=A0.pabit =3D 3, .cpu_features=C2=A0=

=C2=A0=3D CPU_FTR_CTRL },

Quoted 1 line
Quoted 1 line
Quoted 1 line

=C2=A0 { .pabyte =3D 0,=C2=A0=C2=A0.pabit =3D 6, .cpu_features=C2=A0=

=C2=A0=3D CPU_FTR_NOEXECUTE },

Quoted 1 line
Quoted 1 line
Quoted 1 line

=C2=A0 { .pabyte =3D 1,=C2=A0=C2=A0.pabit =3D 2, .mmu_features=C2=A0=

=C2=A0=3D MMU_FTR_CI_LARGE_PAGE

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

},
+#ifdef CONFIG_PPC_RADIX_MMU
=C2=A0 { .pabyte =3D 40, .pabit =3D 0, .mmu_features=C2=A0=C2=A0=3D MM=

U_FTR_TYPE_RADIX },

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

+#endif
=C2=A0 { .pabyte =3D 1,=C2=A0=C2=A0.pabit =3D 1, .invert =3D 1, .cpu_f=

eatures =3D

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

CPU_FTR_NODSISRALIGN },
=C2=A0 { .pabyte =3D 5,=C2=A0=C2=A0.pabit =3D 0, .cpu_features=C2=A0=

=C2=A0=3D CPU_FTR_REAL_LE,

Quoted 1 line
Quoted 1 line
Quoted 1 line

=C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0.cpu_user_ftrs =3D PPC_FEATURE_TRUE_=

LE },

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

--=C2=A0
2.11.0

=20
Instead can we do that feature removal in mmu_early_init_devtree. ie, something like

It looks like mmu_early_init_devtree() gets called after parsing ibm,pa_f=

eatures

Quoted 1 line

so that should work.

But why is doing it later preferable?

Mikey's patch means it will never be set at any point during boot, which seems obviously better to me.

cheers

#6 lore raw
Quoted 43 lines · Michael Ellerman
Quoted 41 lines · Michael Neuling
Quoted 39 lines · Aneesh Kumar K.V
Quoted 30 lines · Michael Neuling

Currently if you disable CONFIG_PPC_RADIX_MMU you'll crash on boot on a P9. This is because we still set MMU_FTR_TYPE_RADIX via ibm,pa-features and MMU_FTR_TYPE_RADIX is what's used for code patching in much of the asm code (ie. slb_miss_realmode)

This patch fixes the problem by stopping MMU_FTR_TYPE_RADIX from being set from ibm.pa-features.

We may eventually end up removing the CONFIG_PPC_RADIX_MMU option completely but until then this fixes the issue.

---
  arch/powerpc/kernel/prom.c | 2 ++
  1 file changed, 2 insertions(+)
arch/powerpc/kernel/prom.c +2 -0
index 40c4887c27..f830562974 100644
@@ -161,7 +161,9 @@ static struct ibm_pa_feature {
  	{ .pabyte = 0,  .pabit = 3, .cpu_features  = CPU_FTR_CTRL },
  	{ .pabyte = 0,  .pabit = 6, .cpu_features  = CPU_FTR_NOEXECUTE },
  	{ .pabyte = 1,  .pabit = 2, .mmu_features  = MMU_FTR_CI_LARGE_PAGE
 },
+#ifdef CONFIG_PPC_RADIX_MMU
  	{ .pabyte = 40, .pabit = 0, .mmu_features  = MMU_FTR_TYPE_RADIX },
+#endif
  	{ .pabyte = 1,  .pabit = 1, .invert = 1, .cpu_features =
 CPU_FTR_NODSISRALIGN },
Quoted 4 lines

{ .pabyte = 5, .pabit = 0, .cpu_features = CPU_FTR_REAL_LE,
.cpu_user_ftrs = PPC_FEATURE_TRUE_LE },

Signature · 1 line
2.11.0

Instead can we do that feature removal in mmu_early_init_devtree. ie, something like

Quoted 7 lines
Quoted 2 lines

It looks like mmu_early_init_devtree() gets called after parsing ibm,pa_features so that should work.

But why is doing it later preferable?

Mikey's patch means it will never be set at any point during boot, which seems obviously better to me.

My suggestion was w.r.t consolidating different ways of clearing RADIX_MMU feature flag into one place. Also I was not sure we want to conditionally parse the pa-feature device tree. Instead we parse it without any #ifdef in there and clear things which are not supported by the kernel either via command line or via Kconfig.

-aneesh

#7 lore raw
In reply to Michael Neuling
Quoted 5 lines · Michael Neuling

Currently if you disable CONFIG_PPC_RADIX_MMU you'll crash on boot on a P9. This is because we still set MMU_FTR_TYPE_RADIX via ibm,pa-features and MMU_FTR_TYPE_RADIX is what's used for code patching in much of the asm code (ie. slb_miss_realmode)

Quoted 7 lines

This patch fixes the problem by stopping MMU_FTR_TYPE_RADIX from being set from ibm.pa-features.

We may eventually end up removing the CONFIG_PPC_RADIX_MMU option completely but until then this fixes the issue.

Applied to powerpc fixes, thanks.

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

cheers