# \[PATCH\] powerpc/pseries: Fix update of LPAR security flavor after LPM

- Subsystems: LINUX FOR POWERPC (32-BIT AND 64-BIT), THE REST
- Maintainers: Madhavan Srinivasan, Linus Torvalds
- Status: LANDED (c18956e6e0b9 · 2021-08-06 22:53)
- Landed in mainline as c18956e6e0b9 on 2021-08-06.
- List: linuxppc-dev
- 2 messages, 2 authors
- Page: https://ratatoskr.run/linuxppc-dev/2021/08/1468971/t

## \[PATCH\] powerpc/pseries: Fix update of LPAR security flavor after LPM

- From: Laurent Dufour \<hidden\>
- Date: 2021-08-05 15:25:48 
- Message: https://ratatoskr.run/linuxppc-dev/2021/08/1468971.md

```text
After LPM, when migrating from a system with security mitigation enabled to
a system with mitigation disabled, the security flavor exposed in /proc is
not correctly set back to 0.

Do not assume the value of the security flavor is set to 0 when entering
init_cpu_char_feature_flags(), so when called after a LPM, the value is set
correctly even if the mitigation are not turned off.

Fixes: 6ce56e1ac380 ("powerpc/pseries: export LPAR security flavor in
lparcfg")

Cc: <redacted> # 5.13.x
Signed-off-by: Laurent Dufour <redacted>
---
 arch/powerpc/platforms/pseries/setup.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/platforms/pseries/setup.c b/arch/powerpc/platforms/pseries/setup.c
index 6b0886668465..0dfaa6ab44cc 100644
--- a/arch/powerpc/platforms/pseries/setup.c
+++ b/arch/powerpc/platforms/pseries/setup.c
@@ -539,9 +539,10 @@ static void init_cpu_char_feature_flags(struct h_cpu_char_result *result)
 	 * H_CPU_BEHAV_FAVOUR_SECURITY_H could be set only if
 	 * H_CPU_BEHAV_FAVOUR_SECURITY is.
 	 */
-	if (!(result->behaviour & H_CPU_BEHAV_FAVOUR_SECURITY))
+	if (!(result->behaviour & H_CPU_BEHAV_FAVOUR_SECURITY)) {
 		security_ftr_clear(SEC_FTR_FAVOUR_SECURITY);
-	else if (result->behaviour & H_CPU_BEHAV_FAVOUR_SECURITY_H)
+		pseries_security_flavor = 0;
+	} else if (result->behaviour & H_CPU_BEHAV_FAVOUR_SECURITY_H)
 		pseries_security_flavor = 1;
 	else
 		pseries_security_flavor = 2;
-- 
2.32.0

```

## Re: \[PATCH\] powerpc/pseries: Fix update of LPAR security flavor after LPM

- From: Michael Ellerman \<hidden\>
- Date: 2021-08-13 11:59:13 
- Message: https://ratatoskr.run/linuxppc-dev/2021/08/1476944.md

```text
On Thu, 5 Aug 2021 17:23:08 +0200, Laurent Dufour wrote:
> After LPM, when migrating from a system with security mitigation enabled to
> a system with mitigation disabled, the security flavor exposed in /proc is
> not correctly set back to 0.
> 
> Do not assume the value of the security flavor is set to 0 when entering
> init_cpu_char_feature_flags(), so when called after a LPM, the value is set
> correctly even if the mitigation are not turned off.
> 
> [...]

Applied to powerpc/fixes.

[1/1] powerpc/pseries: Fix update of LPAR security flavor after LPM
      https://git.kernel.org/powerpc/c/c18956e6e0b95f78dad2773ecc8c61a9e41f6405

cheers
```
