Re: [PATCH v4 1/2] powerpc: Add Power11 architected and raw mode

2024-02-21 Thread Michael Ellerman
On Wed, 21 Feb 2024 15:46:22 +1100, Michael Ellerman wrote:
> Add CPU table entries for raw and architected mode. Most fields are
> copied from the Power10 table entries.
> 
> CPU, MMU and user (ELF_HWCAP) features are unchanged vs P10. However
> userspace can detect P11 because the AT_PLATFORM value changes to
> "power11".
> 
> [...]

Applied to powerpc/next.

[1/2] powerpc: Add Power11 architected and raw mode
  https://git.kernel.org/powerpc/c/c2ed087ed35ca569d8179924ba560be248c758e5
[2/2] powerpc/perf: Power11 Performance Monitoring support
  https://git.kernel.org/powerpc/c/b22ea627225b53ec7ce25c19d6df9fa8217d1643

cheers


[PATCH v4 1/2] powerpc: Add Power11 architected and raw mode

2024-02-20 Thread Michael Ellerman
From: Madhavan Srinivasan 

Add CPU table entries for raw and architected mode. Most fields are
copied from the Power10 table entries.

CPU, MMU and user (ELF_HWCAP) features are unchanged vs P10. However
userspace can detect P11 because the AT_PLATFORM value changes to
"power11".

The logical PVR value of 0x0F07, passed to firmware via the
ibm_arch_vec, indicates the kernel can support a P11 compatible CPU,
which means at least ISA v3.1 compliant.

Signed-off-by: Madhavan Srinivasan 
Signed-off-by: Michael Ellerman 
---
 arch/powerpc/include/asm/cputable.h   |  3 ++
 arch/powerpc/include/asm/mmu.h|  1 +
 arch/powerpc/include/asm/reg.h|  2 ++
 arch/powerpc/kernel/cpu_specs_book3s_64.h | 34 +++
 arch/powerpc/kernel/dt_cpu_ftrs.c | 10 +++
 arch/powerpc/kernel/prom_init.c   | 10 ++-
 arch/powerpc/kvm/book3s_hv.c  |  1 +
 7 files changed, 60 insertions(+), 1 deletion(-)

v4: mpe: Rename PVR_ARCH_31N to PVR_ARCH_31_P11, to clarify that it indicates
P11 compatibility. Flesh out change log with some more detail.

diff --git a/arch/powerpc/include/asm/cputable.h 
b/arch/powerpc/include/asm/cputable.h
index 48471ca388dd..07a204d21034 100644
--- a/arch/powerpc/include/asm/cputable.h
+++ b/arch/powerpc/include/asm/cputable.h
@@ -454,6 +454,9 @@ static inline void cpu_feature_keys_init(void) { }
CPU_FTR_ARCH_300 | CPU_FTR_ARCH_31 | \
CPU_FTR_DAWR | CPU_FTR_DAWR1 | \
CPU_FTR_DEXCR_NPHIE)
+
+#define CPU_FTRS_POWER11   CPU_FTRS_POWER10
+
 #define CPU_FTRS_CELL  (CPU_FTR_LWSYNC | \
CPU_FTR_PPCAS_ARCH_V2 | CPU_FTR_CTRL | \
CPU_FTR_ALTIVEC_COMP | CPU_FTR_MMCRA | CPU_FTR_SMT | \
diff --git a/arch/powerpc/include/asm/mmu.h b/arch/powerpc/include/asm/mmu.h
index d8b7e246a32f..61ebe5eff2c9 100644
--- a/arch/powerpc/include/asm/mmu.h
+++ b/arch/powerpc/include/asm/mmu.h
@@ -133,6 +133,7 @@
 #define MMU_FTRS_POWER8MMU_FTRS_POWER6
 #define MMU_FTRS_POWER9MMU_FTRS_POWER6
 #define MMU_FTRS_POWER10   MMU_FTRS_POWER6
+#define MMU_FTRS_POWER11   MMU_FTRS_POWER6
 #define MMU_FTRS_CELL  MMU_FTRS_DEFAULT_HPTE_ARCH_V2 | \
MMU_FTR_CI_LARGE_PAGE
 #define MMU_FTRS_PA6T  MMU_FTRS_DEFAULT_HPTE_ARCH_V2 | \
diff --git a/arch/powerpc/include/asm/reg.h b/arch/powerpc/include/asm/reg.h
index 7fd09f25452d..58d6348e4ea0 100644
--- a/arch/powerpc/include/asm/reg.h
+++ b/arch/powerpc/include/asm/reg.h
@@ -1364,6 +1364,7 @@
 #define PVR_HX_C2000   0x0066
 #define PVR_POWER9 0x004E
 #define PVR_POWER100x0080
+#define PVR_POWER110x0082
 #define PVR_BE 0x0070
 #define PVR_PA6T   0x0090
 
@@ -1375,6 +1376,7 @@
 #define PVR_ARCH_207   0x0f04
 #define PVR_ARCH_300   0x0f05
 #define PVR_ARCH_310x0f06
+#define PVR_ARCH_31_P110x0f07
 
 /* Macros for setting and retrieving special purpose registers */
 #ifndef __ASSEMBLY__
diff --git a/arch/powerpc/kernel/cpu_specs_book3s_64.h 
b/arch/powerpc/kernel/cpu_specs_book3s_64.h
index 3ff9757df4c0..98d4274a1b6b 100644
--- a/arch/powerpc/kernel/cpu_specs_book3s_64.h
+++ b/arch/powerpc/kernel/cpu_specs_book3s_64.h
@@ -60,6 +60,9 @@
 PPC_FEATURE2_ISEL | PPC_FEATURE2_TAR | \
 PPC_FEATURE2_VEC_CRYPTO)
 
+#define COMMON_USER_POWER11COMMON_USER_POWER10
+#define COMMON_USER2_POWER11   COMMON_USER2_POWER10
+
 static struct cpu_spec cpu_specs[] __initdata = {
{   /* PPC970 */
.pvr_mask   = 0x,
@@ -281,6 +284,20 @@ static struct cpu_spec cpu_specs[] __initdata = {
.cpu_restore= __restore_cpu_power10,
.platform   = "power10",
},
+   {   /* 3.1-compliant processor, i.e. Power11 "architected" mode */
+   .pvr_mask   = 0x,
+   .pvr_value  = 0x0f07,
+   .cpu_name   = "Power11 (architected)",
+   .cpu_features   = CPU_FTRS_POWER11,
+   .cpu_user_features  = COMMON_USER_POWER11,
+   .cpu_user_features2 = COMMON_USER2_POWER11,
+   .mmu_features   = MMU_FTRS_POWER11,
+   .icache_bsize   = 128,
+   .dcache_bsize   = 128,
+   .cpu_setup  = __setup_cpu_power10,
+   .cpu_restore= __restore_cpu_power10,
+   .platform   = "power11",
+   },
{   /* Power7 */
.pvr_mask   = 0x,
.pvr_value  = 0x003f,
@@ -451,6 +468,23 @@ static struct cpu_spec cpu_specs[] __initdata = {
.machine_check_early= __machine_check_early_realmode_p10,
.platform   = "power10",
},
+   {   /* Power11