Skip to contentSkip to conversation

remove PROT_SAO support and disable

PATCH Applied Nicholas Piggin 4 participants 9 messages Jul 3, 2020 – Jul 24, 2020

Subsystems (8)
lore
Share & tools
lore

Nicholas Piggin

author reviewer
#0 lore raw

v2 cover remove PROT_SAO support and disable

It was suggested that I post this to a wider audience on account of the change to supported userspace features in patch 2 particularly.

Thanks,
Nick

Nicholas Piggin (3):
powerpc: remove stale calc_vm_prot_bits comment powerpc/64s: remove PROT_SAO support powerpc/64s/hash: disable subpage_prot syscall by default

 arch/powerpc/Kconfig                          |  7 +++-
 arch/powerpc/configs/powernv_defconfig        |  1 -
 arch/powerpc/configs/pseries_defconfig        |  1 -
 arch/powerpc/include/asm/book3s/64/pgtable.h  |  8 ++--
 arch/powerpc/include/asm/cputable.h           | 10 ++---
 arch/powerpc/include/asm/kvm_book3s_64.h      |  5 ++-
 arch/powerpc/include/asm/mman.h               | 30 ++-----------
 arch/powerpc/include/asm/nohash/64/pgtable.h  |  2 -
 arch/powerpc/include/uapi/asm/mman.h          |  2 +-
 arch/powerpc/kernel/dt_cpu_ftrs.c             |  2 +-
 arch/powerpc/mm/book3s64/hash_utils.c         |  2 -
 include/linux/mm.h                            |  2 -
 include/trace/events/mmflags.h                |  2 -
 mm/ksm.c                                      |  4 --
 tools/testing/selftests/powerpc/mm/.gitignore |  1 -
 tools/testing/selftests/powerpc/mm/Makefile   |  4 +-
 tools/testing/selftests/powerpc/mm/prot_sao.c | 42 -------------------
 17 files changed, 25 insertions(+), 100 deletions(-)
 delete mode 100644 tools/testing/selftests/powerpc/mm/prot_sao.c
Signature · 1 line
2.23.0
author reviewer
#1 lore raw

PATCH v2 1/3 powerpc: remove stale calc_vm_prot_bits comment

This comment is wrong, we wouldn't use calc_vm_prot_bits here because we are being called by calc_vm_prot_bits to modify its behaviour.

---
 arch/powerpc/include/asm/mman.h | 4 ----
 1 file changed, 4 deletions(-)
arch/powerpc/include/asm/mman.h +0 -4
index d610c2e07b28..4ba303ea27f5 100644
@@ -13,10 +13,6 @@
 #include <linux/pkeys.h>
 #include <asm/cpu_has_feature.h>
 
-/*
- * This file is included by linux/mman.h, so we can't use cacl_vm_prot_bits()
- * here.  How important is the optimization?
- */
 static inline unsigned long arch_calc_vm_prot_bits(unsigned long prot,
 		unsigned long pkey)
 {
Signature · 1 line
2.23.0
author reviewer
#2 lore raw

PATCH v2 2/3 powerpc/64s: remove PROT_SAO support

In reply to Nicholas Piggin

ISA v3.1 does not support the SAO storage control attribute required to implement PROT_SAO. PROT_SAO was used by specialised system software (Lx86) that has been discontinued for about 7 years, and is not thought to be used elsewhere, so removal should not cause problems.

We rather remove it than keep support for older processors, because live migrating guest partitions to newer processors may not be possible if SAO is in use (or worse allowed with silent races).

- PROT_SAO stays in the uapi header so code using it would still build.
- arch_validate_prot() is removed, the generic version rejects PROT_SAO so applications would get a failure at mmap() time.

---
 arch/powerpc/include/asm/book3s/64/pgtable.h  |  8 ++--
 arch/powerpc/include/asm/cputable.h           | 10 ++---
 arch/powerpc/include/asm/kvm_book3s_64.h      |  5 ++-
 arch/powerpc/include/asm/mman.h               | 26 ++----------
 arch/powerpc/include/asm/nohash/64/pgtable.h  |  2 -
 arch/powerpc/include/uapi/asm/mman.h          |  2 +-
 arch/powerpc/kernel/dt_cpu_ftrs.c             |  2 +-
 arch/powerpc/mm/book3s64/hash_utils.c         |  2 -
 include/linux/mm.h                            |  2 -
 include/trace/events/mmflags.h                |  2 -
 mm/ksm.c                                      |  4 --
 tools/testing/selftests/powerpc/mm/.gitignore |  1 -
 tools/testing/selftests/powerpc/mm/Makefile   |  4 +-
 tools/testing/selftests/powerpc/mm/prot_sao.c | 42 -------------------
 14 files changed, 20 insertions(+), 92 deletions(-)
 delete mode 100644 tools/testing/selftests/powerpc/mm/prot_sao.c
arch/powerpc/include/asm/book3s/64/pgtable.h +5 -3
index 25c3cb8272c0..8e9aca96143b 100644
@@ -20,9 +20,13 @@
 #define _PAGE_RW		(_PAGE_READ | _PAGE_WRITE)
 #define _PAGE_RWX		(_PAGE_READ | _PAGE_WRITE | _PAGE_EXEC)
 #define _PAGE_PRIVILEGED	0x00008 /* kernel access only */
-#define _PAGE_SAO		0x00010 /* Strong access order */
+
+#define _PAGE_CACHE_CTL		0x00030 /* Bits for the folowing cache modes */
+			/*	No bits set is normal cacheable memory */
+			/*	0x00010 unused, is SAO bit on radix POWER9 */
 #define _PAGE_NON_IDEMPOTENT	0x00020 /* non idempotent memory */
 #define _PAGE_TOLERANT		0x00030 /* tolerant memory, cache inhibited */
+
 #define _PAGE_DIRTY		0x00080 /* C: page changed */
 #define _PAGE_ACCESSED		0x00100 /* R: page referenced */
 /*
@@ -825,8 +829,6 @@ static inline void __set_pte_at(struct mm_struct *mm, unsigned long addr,
 	return hash__set_pte_at(mm, addr, ptep, pte, percpu);
 }
 
-#define _PAGE_CACHE_CTL	(_PAGE_SAO | _PAGE_NON_IDEMPOTENT | _PAGE_TOLERANT)
-
 #define pgprot_noncached pgprot_noncached
 static inline pgprot_t pgprot_noncached(pgprot_t prot)
 {
arch/powerpc/include/asm/cputable.h +5 -5
index bac2252c839e..87284750535d 100644
@@ -191,7 +191,7 @@ static inline void cpu_feature_keys_init(void) { }
 #define CPU_FTR_SPURR			LONG_ASM_CONST(0x0000000001000000)
 #define CPU_FTR_DSCR			LONG_ASM_CONST(0x0000000002000000)
 #define CPU_FTR_VSX			LONG_ASM_CONST(0x0000000004000000)
-#define CPU_FTR_SAO			LONG_ASM_CONST(0x0000000008000000)
+// Free					LONG_ASM_CONST(0x0000000008000000)
 #define CPU_FTR_CP_USE_DCBTZ		LONG_ASM_CONST(0x0000000010000000)
 #define CPU_FTR_UNALIGNED_LD_STD	LONG_ASM_CONST(0x0000000020000000)
 #define CPU_FTR_ASYM_SMT		LONG_ASM_CONST(0x0000000040000000)
@@ -435,7 +435,7 @@ static inline void cpu_feature_keys_init(void) { }
 	    CPU_FTR_MMCRA | CPU_FTR_SMT | \
 	    CPU_FTR_COHERENT_ICACHE | \
 	    CPU_FTR_PURR | CPU_FTR_SPURR | CPU_FTR_REAL_LE | \
-	    CPU_FTR_DSCR | CPU_FTR_SAO  | CPU_FTR_ASYM_SMT | \
+	    CPU_FTR_DSCR | CPU_FTR_ASYM_SMT | \
 	    CPU_FTR_STCX_CHECKS_ADDRESS | CPU_FTR_POPCNTB | CPU_FTR_POPCNTD | \
 	    CPU_FTR_CFAR | CPU_FTR_HVMODE | \
 	    CPU_FTR_VMX_COPY | CPU_FTR_HAS_PPR | CPU_FTR_DABRX | CPU_FTR_PKEY)
@@ -444,7 +444,7 @@ static inline void cpu_feature_keys_init(void) { }
 	    CPU_FTR_MMCRA | CPU_FTR_SMT | \
 	    CPU_FTR_COHERENT_ICACHE | \
 	    CPU_FTR_PURR | CPU_FTR_SPURR | CPU_FTR_REAL_LE | \
-	    CPU_FTR_DSCR | CPU_FTR_SAO  | \
+	    CPU_FTR_DSCR | \
 	    CPU_FTR_STCX_CHECKS_ADDRESS | CPU_FTR_POPCNTB | CPU_FTR_POPCNTD | \
 	    CPU_FTR_CFAR | CPU_FTR_HVMODE | CPU_FTR_VMX_COPY | \
 	    CPU_FTR_DBELL | CPU_FTR_HAS_PPR | CPU_FTR_DAWR | \
@@ -455,7 +455,7 @@ static inline void cpu_feature_keys_init(void) { }
 	    CPU_FTR_MMCRA | CPU_FTR_SMT | \
 	    CPU_FTR_COHERENT_ICACHE | \
 	    CPU_FTR_PURR | CPU_FTR_SPURR | CPU_FTR_REAL_LE | \
-	    CPU_FTR_DSCR | CPU_FTR_SAO  | \
+	    CPU_FTR_DSCR | \
 	    CPU_FTR_STCX_CHECKS_ADDRESS | CPU_FTR_POPCNTB | CPU_FTR_POPCNTD | \
 	    CPU_FTR_CFAR | CPU_FTR_HVMODE | CPU_FTR_VMX_COPY | \
 	    CPU_FTR_DBELL | CPU_FTR_HAS_PPR | CPU_FTR_ARCH_207S | \
@@ -473,7 +473,7 @@ static inline void cpu_feature_keys_init(void) { }
 	    CPU_FTR_MMCRA | CPU_FTR_SMT | \
 	    CPU_FTR_COHERENT_ICACHE | \
 	    CPU_FTR_PURR | CPU_FTR_SPURR | CPU_FTR_REAL_LE | \
-	    CPU_FTR_DSCR | CPU_FTR_SAO  | \
+	    CPU_FTR_DSCR | \
 	    CPU_FTR_STCX_CHECKS_ADDRESS | CPU_FTR_POPCNTB | CPU_FTR_POPCNTD | \
 	    CPU_FTR_CFAR | CPU_FTR_HVMODE | CPU_FTR_VMX_COPY | \
 	    CPU_FTR_DBELL | CPU_FTR_HAS_PPR | CPU_FTR_ARCH_207S | \
arch/powerpc/include/asm/kvm_book3s_64.h +3 -2
index 9bb9bb370b53..fac39ff659d4 100644
@@ -398,9 +398,10 @@ static inline bool hpte_cache_flags_ok(unsigned long hptel, bool is_ci)
 {
 	unsigned int wimg = hptel & HPTE_R_WIMG;
 
-	/* Handle SAO */
+	/* Handle SAO for POWER7,8,9 */
 	if (wimg = (HPTE_R_W | HPTE_R_I | HPTE_R_M) &&
-	    cpu_has_feature(CPU_FTR_ARCH_206))
+	    cpu_has_feature(CPU_FTR_ARCH_206) &&
+	    !cpu_has_feature(CPU_FTR_ARCH_31))
 		wimg = HPTE_R_M;
 
 	if (!is_ci)
arch/powerpc/include/asm/mman.h +4 -22
index 4ba303ea27f5..7c07728af300 100644
@@ -13,38 +13,20 @@
 #include <linux/pkeys.h>
 #include <asm/cpu_has_feature.h>
 
+#ifdef CONFIG_PPC_MEM_KEYS
 static inline unsigned long arch_calc_vm_prot_bits(unsigned long prot,
 		unsigned long pkey)
 {
-#ifdef CONFIG_PPC_MEM_KEYS
-	return (((prot & PROT_SAO) ? VM_SAO : 0) | pkey_to_vmflag_bits(pkey));
-#else
-	return ((prot & PROT_SAO) ? VM_SAO : 0);
-#endif
+	return pkey_to_vmflag_bits(pkey);
 }
 #define arch_calc_vm_prot_bits(prot, pkey) arch_calc_vm_prot_bits(prot, pkey)
 
 static inline pgprot_t arch_vm_get_page_prot(unsigned long vm_flags)
 {
-#ifdef CONFIG_PPC_MEM_KEYS
-	return (vm_flags & VM_SAO) ?
-		__pgprot(_PAGE_SAO | vmflag_to_pte_pkey_bits(vm_flags)) :
-		__pgprot(0 | vmflag_to_pte_pkey_bits(vm_flags));
-#else
-	return (vm_flags & VM_SAO) ? __pgprot(_PAGE_SAO) : __pgprot(0);
-#endif
+	return __pgprot(vmflag_to_pte_pkey_bits(vm_flags));
 }
 #define arch_vm_get_page_prot(vm_flags) arch_vm_get_page_prot(vm_flags)
-
-static inline bool arch_validate_prot(unsigned long prot, unsigned long addr)
-{
-	if (prot & ~(PROT_READ | PROT_WRITE | PROT_EXEC | PROT_SEM | PROT_SAO))
-		return false;
-	if ((prot & PROT_SAO) && !cpu_has_feature(CPU_FTR_SAO))
-		return false;
-	return true;
-}
-#define arch_validate_prot arch_validate_prot
+#endif
 
 #endif /* CONFIG_PPC64 */
 #endif	/* _ASM_POWERPC_MMAN_H */
arch/powerpc/include/asm/nohash/64/pgtable.h +0 -2
index 6cb8aa357191..59ee9fa4ae09 100644
@@ -82,8 +82,6 @@
  */
 #include <asm/nohash/pte-book3e.h>
 
-#define _PAGE_SAO	0
-
 #define PTE_RPN_MASK	(~((1UL << PTE_RPN_SHIFT) - 1))
 
 /*
arch/powerpc/include/uapi/asm/mman.h +1 -1
index c0c737215b00..3a700351feca 100644
@@ -11,7 +11,7 @@
 #include <asm-generic/mman-common.h>
 
 
-#define PROT_SAO	0x10		/* Strong Access Ordering */
+#define PROT_SAO	0x10		/* Unsupported since v5.9 */
 
 #define MAP_RENAME      MAP_ANONYMOUS   /* In SunOS terminology */
 #define MAP_NORESERVE   0x40            /* don't reserve swap pages */
arch/powerpc/kernel/dt_cpu_ftrs.c +1 -1
index 3a409517c031..41412c198e70 100644
@@ -622,7 +622,7 @@ static struct dt_cpu_feature_match __initdata
 	{"processor-control-facility-v3", feat_enable_dbell, CPU_FTR_DBELL},
 	{"processor-utilization-of-resources-register", feat_enable_purr, 0},
 	{"no-execute", feat_enable, 0},
-	{"strong-access-ordering", feat_enable, CPU_FTR_SAO},
+	/* strong-access-ordering is unused */
 	{"cache-inhibited-large-page", feat_enable_large_ci, 0},
 	{"coprocessor-icswx", feat_enable, 0},
 	{"hypervisor-virtualization-interrupt", feat_enable_hvi, 0},
arch/powerpc/mm/book3s64/hash_utils.c +0 -2
index 468169e33c86..e35d8dae4f84 100644
@@ -232,8 +232,6 @@ unsigned long htab_convert_pte_flags(unsigned long pteflags)
 		rflags |= HPTE_R_I;
 	else if ((pteflags & _PAGE_CACHE_CTL) = _PAGE_NON_IDEMPOTENT)
 		rflags |= (HPTE_R_I | HPTE_R_G);
-	else if ((pteflags & _PAGE_CACHE_CTL) = _PAGE_SAO)
-		rflags |= (HPTE_R_W | HPTE_R_I | HPTE_R_M);
 	else
 		/*
 		 * Add memory coherence if cache inhibited is not set
include/linux/mm.h +0 -2
index dc7b87310c10..6c8333d6c991 100644
@@ -317,8 +317,6 @@ extern unsigned int kobjsize(const void *objp);
 
 #if defined(CONFIG_X86)
 # define VM_PAT		VM_ARCH_1	/* PAT reserves whole VMA at once (x86) */
-#elif defined(CONFIG_PPC)
-# define VM_SAO		VM_ARCH_1	/* Strong Access Ordering (powerpc) */
 #elif defined(CONFIG_PARISC)
 # define VM_GROWSUP	VM_ARCH_1
 #elif defined(CONFIG_IA64)
include/trace/events/mmflags.h +0 -2
index 5fb752034386..939092dbcb8b 100644
@@ -114,8 +114,6 @@ IF_HAVE_PG_IDLE(PG_idle,		"idle"		)
 
 #if defined(CONFIG_X86)
 #define __VM_ARCH_SPECIFIC_1 {VM_PAT,     "pat"           }
-#elif defined(CONFIG_PPC)
-#define __VM_ARCH_SPECIFIC_1 {VM_SAO,     "sao"           }
 #elif defined(CONFIG_PARISC) || defined(CONFIG_IA64)
 #define __VM_ARCH_SPECIFIC_1 {VM_GROWSUP,	"growsup"	}
 #elif !defined(CONFIG_MMU)
mm/ksm.c +0 -4
index 4102034cd55a..d1cfa18689b5 100644
@@ -2452,10 +2452,6 @@ int ksm_madvise(struct vm_area_struct *vma, unsigned long start,
 		if (vma_is_dax(vma))
 			return 0;
 
-#ifdef VM_SAO
-		if (*vm_flags & VM_SAO)
-			return 0;
-#endif
 #ifdef VM_SPARC_ADI
 		if (*vm_flags & VM_SPARC_ADI)
 			return 0;
tools/testing/selftests/powerpc/mm/.gitignore +0 -1
index 2ca523255b1b..ff296c94f627 100644
@@ -2,7 +2,6 @@
 hugetlb_vs_thp_test
 subpage_prot
 tempfile
-prot_sao
 segv_errors
 wild_bctr
 large_vm_fork_separation
tools/testing/selftests/powerpc/mm/Makefile +1 -3
index b9103c4bb414..9b8a7b3069c5 100644
@@ -2,7 +2,7 @@
 noarg:
 	$(MAKE) -C ../
 
-TEST_GEN_PROGS := hugetlb_vs_thp_test subpage_prot prot_sao segv_errors wild_bctr \
+TEST_GEN_PROGS := hugetlb_vs_thp_test subpage_prot segv_errors wild_bctr \
 		  large_vm_fork_separation bad_accesses
 TEST_GEN_PROGS_EXTENDED := tlbie_test
 TEST_GEN_FILES := tempfile
@@ -12,8 +12,6 @@ include ../../lib.mk
 
 $(TEST_GEN_PROGS): ../harness.c
 
-$(OUTPUT)/prot_sao: ../utils.c
-
 $(OUTPUT)/wild_bctr: CFLAGS += -m64
 $(OUTPUT)/large_vm_fork_separation: CFLAGS += -m64
 $(OUTPUT)/bad_accesses: CFLAGS += -m64
tools/testing/selftests/powerpc/mm/prot_sao.c deleted +0 -42

42 lines not on this page · raw message

Signature · 1 line
2.23.0
#3 lore raw

Re: [PATCH v2 2/3] powerpc/64s: remove PROT_SAO support

Quoted 8 lines · Nicholas Piggin

ISA v3.1 does not support the SAO storage control attribute required to implement PROT_SAO. PROT_SAO was used by specialised system software (Lx86) that has been discontinued for about 7 years, and is not thought to be used elsewhere, so removal should not cause problems.

We rather remove it than keep support for older processors, because live migrating guest partitions to newer processors may not be possible if SAO is in use (or worse allowed with silent races).

This is actually a real problem for KVM, because now we have the capabilities of the host affecting the characteristics of the guest virtual machine in a manner which userspace (e.g. QEMU) is unable to control.

It would probably be better to disallow SAO on all machines than have it available on some hosts and not others. (Yes I know there is a check on CPU_FTR_ARCH_206 in there, but that has been a no-op since we removed the PPC970 KVM support.)

Solving this properly will probably require creating a new KVM host capability and associated machine parameter in QEMU, along with a new machine type.

[snip]

Quoted 5 lines
arch/powerpc/include/asm/kvm_book3s_64.h +0 -0
index 9bb9bb370b53..fac39ff659d4 100644

arch/powerpc/include/asm/kvm_book3s_64.h static inline bool hpte_cache_flags_ok(unsigned long hptel, bool is_ci) · line 405

Quoted 10 lines
arch/powerpc/include/asm/kvm_book3s_64.h +3 -2
@@ -398,9 +398,10 @@ static inline bool hpte_cache_flags_ok(unsigned long hptel, bool is_ci)
 {
 	unsigned int wimg = hptel & HPTE_R_WIMG;
 
-	/* Handle SAO */
+	/* Handle SAO for POWER7,8,9 */
 	if (wimg = (HPTE_R_W | HPTE_R_I | HPTE_R_M) &&
-	    cpu_has_feature(CPU_FTR_ARCH_206))
+	    cpu_has_feature(CPU_FTR_ARCH_206) &&
+	    !cpu_has_feature(CPU_FTR_ARCH_31))
 		wimg = HPTE_R_M;

Paul.

author reviewer
#4 lore raw

Re: [PATCH v2 2/3] powerpc/64s: remove PROT_SAO support

Excerpts from Paul Mackerras's message of July 9, 2020 2:34 pm:

Quoted 15 lines · Nicholas Piggin
Quoted 8 lines

ISA v3.1 does not support the SAO storage control attribute required to implement PROT_SAO. PROT_SAO was used by specialised system software (Lx86) that has been discontinued for about 7 years, and is not thought to be used elsewhere, so removal should not cause problems.

We rather remove it than keep support for older processors, because live migrating guest partitions to newer processors may not be possible if SAO is in use (or worse allowed with silent races).

This is actually a real problem for KVM, because now we have the capabilities of the host affecting the characteristics of the guest virtual machine in a manner which userspace (e.g. QEMU) is unable to control.

Quoted 4 lines

It would probably be better to disallow SAO on all machines than have it available on some hosts and not others. (Yes I know there is a check on CPU_FTR_ARCH_206 in there, but that has been a no-op since we removed the PPC970 KVM support.)

This change doesn't change the SAO difference on the host processors though, just tries to slightly improve it from silently broken to maybe complaining a bit.

I didn't want to stop some very old image that uses this and is running okay on an existing host from working, but maybe the existence of such a thing would contradict my reasoning. But then if we don't care about it why care about this KVM behaviour difference at all?

Quoted 3 lines

Solving this properly will probably require creating a new KVM host capability and associated machine parameter in QEMU, along with a new machine type.

Rather than answer any of these questions, I might take the KVM change out and that can be dealt with separately from guest SAO removal.

Thanks,
Nick

Quoted 21 lines

[snip]

Quoted 5 lines
arch/powerpc/include/asm/kvm_book3s_64.h +0 -0
index 9bb9bb370b53..fac39ff659d4 100644

arch/powerpc/include/asm/kvm_book3s_64.h static inline bool hpte_cache_flags_ok(unsigned long hptel, bool is_ci) · line 405

Quoted 10 lines
arch/powerpc/include/asm/kvm_book3s_64.h +3 -2
@@ -398,9 +398,10 @@ static inline bool hpte_cache_flags_ok(unsigned long hptel, bool is_ci)
 {
 	unsigned int wimg = hptel & HPTE_R_WIMG;
 
-	/* Handle SAO */
+	/* Handle SAO for POWER7,8,9 */
 	if (wimg == (HPTE_R_W | HPTE_R_I | HPTE_R_M) &&
-	    cpu_has_feature(CPU_FTR_ARCH_206))
+	    cpu_has_feature(CPU_FTR_ARCH_206) &&
+	    !cpu_has_feature(CPU_FTR_ARCH_31))
 		wimg = HPTE_R_M;

Paul.

#5 lore raw

Re: [PATCH v2 2/3] powerpc/64s: remove PROT_SAO support

In reply to Nicholas Piggin
Quoted 4 lines

It would probably be better to disallow SAO on all machines than have it available on some hosts and not others. (Yes I know there is a check on CPU_FTR_ARCH_206 in there, but that has been a no-op since we removed the PPC970 KVM support.)

May I ask a very stupid question here -- is that meant to imply KVM cannot emulate a 970, or that KVM (at least HV, anyway) won't work on a 970?

Signature · 3 lines
------------------------------------ personal: http://www.cameronkaiser.com/ --
  Cameron Kaiser * Floodgap Systems * www.floodgap.com * [email protected]
-- This is an Honour System Virus. Please delete all your files. Thank you. ---
#6 lore raw

Re: [PATCH v2 2/3] powerpc/64s: remove PROT_SAO support

In reply to Nicholas Piggin
Quoted 7 lines · Cameron Kaiser
Quoted 4 lines

It would probably be better to disallow SAO on all machines than have it available on some hosts and not others. (Yes I know there is a check on CPU_FTR_ARCH_206 in there, but that has been a no-op since we removed the PPC970 KVM support.)

May I ask a very stupid question here -- is that meant to imply KVM cannot emulate a 970, or that KVM (at least HV, anyway) won't work on a 970?

The PVR is able to be accessed from supervisor mode in the Power ISA, which means that a guest under KVM-HV always sees the real PVR of the CPU; it can't be spoofed by KVM. So for the first half of your question, about emulating a 970, the answer is "no" or at least "not completely". (KVM-PR can of course make the machine look like anything you want, pretty much, at the expense of lower performance.)

What I was referring to in my original message is that we used to be able to run KVM-HV on a PPC970 as a host, and we took that out. So the answer to the second half of your question is yes.

Paul.

author reviewer
#7 lore raw

PATCH v2 3/3 powerpc/64s/hash: disable subpage_prot syscall by default

In reply to Nicholas Piggin

The subpage_prot syscall was added for specialised system software (Lx86) that has been discontinued for about 7 years, and is not thought to be used elsewhere, so disable it by default.

---
 arch/powerpc/Kconfig                   | 7 +++++--
 arch/powerpc/configs/powernv_defconfig | 1 -
 arch/powerpc/configs/pseries_defconfig | 1 -
 3 files changed, 5 insertions(+), 4 deletions(-)
arch/powerpc/Kconfig +5 -2
index 9fa23eb320ff..04c6ca17661a 100644
@@ -833,13 +833,16 @@ config FORCE_MAX_ZONEORDER
 	  this in mind when choosing a value for this option.
 
 config PPC_SUBPAGE_PROT
-	bool "Support setting protections for 4k subpages"
+	bool "Support setting protections for 4k subpages (subpage_prot syscall)"
+	default n
 	depends on PPC_BOOK3S_64 && PPC_64K_PAGES
 	help
-	  This option adds support for a system call to allow user programs
+	  This option adds support for system call to allow user programs
 	  to set access permissions (read/write, readonly, or no access)
 	  on the 4k subpages of each 64k page.
 
+	  If unsure, say N here.
+
 config PPC_COPRO_BASE
 	bool
 
arch/powerpc/configs/powernv_defconfig +0 -1
index 2de9aadf0f50..afc0dd73a1e6 100644
@@ -64,7 +64,6 @@ CONFIG_HWPOISON_INJECT=m
 CONFIG_TRANSPARENT_HUGEPAGE=y
 CONFIG_DEFERRED_STRUCT_PAGE_INIT=y
 CONFIG_PPC_64K_PAGES=y
-CONFIG_PPC_SUBPAGE_PROT=y
 CONFIG_SCHED_SMT=y
 CONFIG_PM=y
 CONFIG_HOTPLUG_PCI=y
arch/powerpc/configs/pseries_defconfig +0 -1
index dfa4a726333b..894e8d85fb48 100644
@@ -57,7 +57,6 @@ CONFIG_MEMORY_HOTREMOVE=y
 CONFIG_KSM=y
 CONFIG_TRANSPARENT_HUGEPAGE=y
 CONFIG_PPC_64K_PAGES=y
-CONFIG_PPC_SUBPAGE_PROT=y
 CONFIG_SCHED_SMT=y
 CONFIG_HOTPLUG_PCI=y
 CONFIG_HOTPLUG_PCI_RPA=m
Signature · 1 line
2.23.0
#8 lore raw
In reply to Nicholas Piggin
Quoted 6 lines · Nicholas Piggin

It was suggested that I post this to a wider audience on account of the change to supported userspace features in patch 2 particularly.

Thanks,
Nick

Quoted 6 lines

Nicholas Piggin (3):
powerpc: remove stale calc_vm_prot_bits comment powerpc/64s: remove PROT_SAO support powerpc/64s/hash: disable subpage_prot syscall by default

[...]

Applied to powerpc/next.

[1/3] powerpc: Remove stale calc_vm_prot_bits() comment

      https://git.kernel.org/powerpc/c/f4ac1774f2cba44994ce9ac0a65772e4656ac2df
[2/3] powerpc/64s: Remove PROT_SAO support
      https://git.kernel.org/powerpc/c/5c9fa16e8abd342ce04dc830c1ebb2a03abf6c05
[3/3] powerpc/64s/hash: Disable subpage_prot syscall by default
      https://git.kernel.org/powerpc/c/63396ada804c676e070bd1b8663046f18698ab27

cheers