| From d8fd953d50284c3d4328a9b364aa1fdf21f8a678 Mon Sep 17 00:00:00 2001 |
| From: Sasha Levin <sashal@kernel.org> |
| Date: Thu, 9 Jul 2020 08:59:24 +0530 |
| Subject: powerpc/book3s64/pkeys: Use PVR check instead of cpu feature |
| |
| From: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com> |
| |
| [ Upstream commit d79e7a5f26f1d179cbb915a8bf2469b6d7431c29 ] |
| |
| We are wrongly using CPU_FTRS_POWER8 to check for P8 support. Instead, we should |
| use PVR value. Now considering we are using CPU_FTRS_POWER8, that |
| implies we returned true for P9 with older firmware. Keep the same behavior |
| by checking for P9 PVR value. |
| |
| Fixes: cf43d3b26452 ("powerpc: Enable pkey subsystem") |
| Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com> |
| Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> |
| Link: https://lore.kernel.org/r/20200709032946.881753-2-aneesh.kumar@linux.ibm.com |
| Signed-off-by: Sasha Levin <sashal@kernel.org> |
| --- |
| arch/powerpc/mm/book3s64/pkeys.c | 16 ++++++++++------ |
| 1 file changed, 10 insertions(+), 6 deletions(-) |
| |
| diff --git a/arch/powerpc/mm/book3s64/pkeys.c b/arch/powerpc/mm/book3s64/pkeys.c |
| index 268ce9581676a..fa237c8c161f7 100644 |
| --- a/arch/powerpc/mm/book3s64/pkeys.c |
| +++ b/arch/powerpc/mm/book3s64/pkeys.c |
| @@ -83,13 +83,17 @@ static int pkey_initialize(void) |
| scan_pkey_feature(); |
| |
| /* |
| - * Let's assume 32 pkeys on P8 bare metal, if its not defined by device |
| - * tree. We make this exception since skiboot forgot to expose this |
| - * property on power8. |
| + * Let's assume 32 pkeys on P8/P9 bare metal, if its not defined by device |
| + * tree. We make this exception since some version of skiboot forgot to |
| + * expose this property on power8/9. |
| */ |
| - if (!pkeys_devtree_defined && !firmware_has_feature(FW_FEATURE_LPAR) && |
| - cpu_has_feature(CPU_FTRS_POWER8)) |
| - pkeys_total = 32; |
| + if (!pkeys_devtree_defined && !firmware_has_feature(FW_FEATURE_LPAR)) { |
| + unsigned long pvr = mfspr(SPRN_PVR); |
| + |
| + if (PVR_VER(pvr) == PVR_POWER8 || PVR_VER(pvr) == PVR_POWER8E || |
| + PVR_VER(pvr) == PVR_POWER8NVL || PVR_VER(pvr) == PVR_POWER9) |
| + pkeys_total = 32; |
| + } |
| |
| /* |
| * Adjust the upper limit, based on the number of bits supported by |
| -- |
| 2.25.1 |
| |