History

powerpc/64s: Remove PROT_SAO support

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.

Nicholas Piggin committed 6 years ago

Commit 5c9fa161 parent f4ac17713 files · +17 −90Browse files

Unified · Split

13 files
  1. arch/powerpc/include/asm/book3s/64/pgtable.h +5 −3
  2. arch/powerpc/include/asm/cputable.h +5 −5
  3. arch/powerpc/include/asm/mman.h +4 −22
  4. arch/powerpc/include/asm/nohash/64/pgtable.h +0 −2
  5. arch/powerpc/include/uapi/asm/mman.h +1 −1
  6. arch/powerpc/kernel/dt_cpu_ftrs.c +1 −1
  7. arch/powerpc/mm/book3s64/hash_utils.c +0 −2
  8. include/linux/mm.h +0 −2
  9. include/trace/events/mmflags.h +0 −2
  10. mm/ksm.c +0 −4
  11. tools/testing/selftests/powerpc/mm/.gitignore +0 −1
  12. tools/testing/selftests/powerpc/mm/Makefile +1 −3
  13. tools/testing/selftests/powerpc/mm/prot_sao.c +0 −42
arch/powerpc/include/asm/book3s/64/pgtable.h+5−3
@@ -20,9 +20,13 @@ · 19 unmodified lines
2020 #define _PAGE_RW (_PAGE_READ | _PAGE_WRITE)
2121 #define _PAGE_RWX (_PAGE_READ | _PAGE_WRITE | _PAGE_EXEC)
2222 #define _PAGE_PRIVILEGED 0x00008 /* kernel access only */
23−#define _PAGE_SAO 0x00010 /* Strong access order */
23+
24+#define _PAGE_CACHE_CTL 0x00030 /* Bits for the folowing cache modes */
25+ /* No bits set is normal cacheable memory */
26+ /* 0x00010 unused, is SAO bit on radix POWER9 */
2427 #define _PAGE_NON_IDEMPOTENT 0x00020 /* non idempotent memory */
2528 #define _PAGE_TOLERANT 0x00030 /* tolerant memory, cache inhibited */
29+
2630 #define _PAGE_DIRTY 0x00080 /* C: page changed */
2731 #define _PAGE_ACCESSED 0x00100 /* R: page referenced */
2832 /*
@@ -824,8 +828,6 @@ static inline void __set_pte_at(struct mm_struct *mm, unsigned long addr, · 795 unmodified lines
824828 return hash__set_pte_at(mm, addr, ptep, pte, percpu);
825829 }
826830
827−#define _PAGE_CACHE_CTL (_PAGE_SAO | _PAGE_NON_IDEMPOTENT | _PAGE_TOLERANT)
828−
829831 #define pgprot_noncached pgprot_noncached
830832 static inline pgprot_t pgprot_noncached(pgprot_t prot)
831833 {
arch/powerpc/include/asm/cputable.h+5−5
@@ -191,7 +191,7 @@ static inline void cpu_feature_keys_init(void) { } · 190 unmodified lines
191191 #define CPU_FTR_SPURR LONG_ASM_CONST(0x0000000001000000)
192192 #define CPU_FTR_DSCR LONG_ASM_CONST(0x0000000002000000)
193193 #define CPU_FTR_VSX LONG_ASM_CONST(0x0000000004000000)
194−#define CPU_FTR_SAO LONG_ASM_CONST(0x0000000008000000)
194+// Free LONG_ASM_CONST(0x0000000008000000)
195195 #define CPU_FTR_CP_USE_DCBTZ LONG_ASM_CONST(0x0000000010000000)
196196 #define CPU_FTR_UNALIGNED_LD_STD LONG_ASM_CONST(0x0000000020000000)
197197 #define CPU_FTR_ASYM_SMT LONG_ASM_CONST(0x0000000040000000)
@@ -435,7 +435,7 @@ static inline void cpu_feature_keys_init(void) { } · 237 unmodified lines
435435 CPU_FTR_MMCRA | CPU_FTR_SMT | \
436436 CPU_FTR_COHERENT_ICACHE | \
437437 CPU_FTR_PURR | CPU_FTR_SPURR | CPU_FTR_REAL_LE | \
438− CPU_FTR_DSCR | CPU_FTR_SAO | CPU_FTR_ASYM_SMT | \
438+ CPU_FTR_DSCR | CPU_FTR_ASYM_SMT | \
439439 CPU_FTR_STCX_CHECKS_ADDRESS | CPU_FTR_POPCNTB | CPU_FTR_POPCNTD | \
440440 CPU_FTR_CFAR | CPU_FTR_HVMODE | \
441441 CPU_FTR_VMX_COPY | CPU_FTR_HAS_PPR | CPU_FTR_DABRX )
@@ -444,7 +444,7 @@ static inline void cpu_feature_keys_init(void) { } · 2 unmodified lines
444444 CPU_FTR_MMCRA | CPU_FTR_SMT | \
445445 CPU_FTR_COHERENT_ICACHE | \
446446 CPU_FTR_PURR | CPU_FTR_SPURR | CPU_FTR_REAL_LE | \
447− CPU_FTR_DSCR | CPU_FTR_SAO | \
447+ CPU_FTR_DSCR | \
448448 CPU_FTR_STCX_CHECKS_ADDRESS | CPU_FTR_POPCNTB | CPU_FTR_POPCNTD | \
449449 CPU_FTR_CFAR | CPU_FTR_HVMODE | CPU_FTR_VMX_COPY | \
450450 CPU_FTR_DBELL | CPU_FTR_HAS_PPR | CPU_FTR_DAWR | \
@@ -455,7 +455,7 @@ static inline void cpu_feature_keys_init(void) { } · 4 unmodified lines
455455 CPU_FTR_MMCRA | CPU_FTR_SMT | \
456456 CPU_FTR_COHERENT_ICACHE | \
457457 CPU_FTR_PURR | CPU_FTR_SPURR | CPU_FTR_REAL_LE | \
458− CPU_FTR_DSCR | CPU_FTR_SAO | \
458+ CPU_FTR_DSCR | \
459459 CPU_FTR_STCX_CHECKS_ADDRESS | CPU_FTR_POPCNTB | CPU_FTR_POPCNTD | \
460460 CPU_FTR_CFAR | CPU_FTR_HVMODE | CPU_FTR_VMX_COPY | \
461461 CPU_FTR_DBELL | CPU_FTR_HAS_PPR | CPU_FTR_ARCH_207S | \
@@ -473,7 +473,7 @@ static inline void cpu_feature_keys_init(void) { } · 11 unmodified lines
473473 CPU_FTR_MMCRA | CPU_FTR_SMT | \
474474 CPU_FTR_COHERENT_ICACHE | \
475475 CPU_FTR_PURR | CPU_FTR_SPURR | CPU_FTR_REAL_LE | \
476− CPU_FTR_DSCR | CPU_FTR_SAO | \
476+ CPU_FTR_DSCR | \
477477 CPU_FTR_STCX_CHECKS_ADDRESS | CPU_FTR_POPCNTB | CPU_FTR_POPCNTD | \
478478 CPU_FTR_CFAR | CPU_FTR_HVMODE | CPU_FTR_VMX_COPY | \
479479 CPU_FTR_DBELL | CPU_FTR_HAS_PPR | CPU_FTR_ARCH_207S | \
arch/powerpc/include/asm/mman.h+4−22
@@ -13,38 +13,20 @@ · 12 unmodified lines
1313 #include <linux/pkeys.h>
1414 #include <asm/cpu_has_feature.h>
1515
16+#ifdef CONFIG_PPC_MEM_KEYS
1617 static inline unsigned long arch_calc_vm_prot_bits(unsigned long prot,
1718 unsigned long pkey)
1819 {
19−#ifdef CONFIG_PPC_MEM_KEYS
20− return (((prot & PROT_SAO) ? VM_SAO : 0) | pkey_to_vmflag_bits(pkey));
21−#else
22− return ((prot & PROT_SAO) ? VM_SAO : 0);
23−#endif
20+ return pkey_to_vmflag_bits(pkey);
2421 }
2522 #define arch_calc_vm_prot_bits(prot, pkey) arch_calc_vm_prot_bits(prot, pkey)
2623
2724 static inline pgprot_t arch_vm_get_page_prot(unsigned long vm_flags)
2825 {
29−#ifdef CONFIG_PPC_MEM_KEYS
30− return (vm_flags & VM_SAO) ?
31− __pgprot(_PAGE_SAO | vmflag_to_pte_pkey_bits(vm_flags)) :
32− __pgprot(0 | vmflag_to_pte_pkey_bits(vm_flags));
33−#else
34− return (vm_flags & VM_SAO) ? __pgprot(_PAGE_SAO) : __pgprot(0);
35−#endif
26+ return __pgprot(vmflag_to_pte_pkey_bits(vm_flags));
3627 }
3728 #define arch_vm_get_page_prot(vm_flags) arch_vm_get_page_prot(vm_flags)
38−
39−static inline bool arch_validate_prot(unsigned long prot, unsigned long addr)
40−{
41− if (prot & ~(PROT_READ | PROT_WRITE | PROT_EXEC | PROT_SEM | PROT_SAO))
42− return false;
43− if ((prot & PROT_SAO) && !cpu_has_feature(CPU_FTR_SAO))
44− return false;
45− return true;
46−}
47−#define arch_validate_prot arch_validate_prot
29+#endif
4830
4931 #endif /* CONFIG_PPC64 */
5032 #endif /* _ASM_POWERPC_MMAN_H */
arch/powerpc/include/asm/nohash/64/pgtable.h+0−2
@@ -82,8 +82,6 @@ · 81 unmodified lines
8282 */
8383 #include <asm/nohash/pte-book3e.h>
8484
85−#define _PAGE_SAO 0
86−
8785 #define PTE_RPN_MASK (~((1UL << PTE_RPN_SHIFT) - 1))
8886
8987 /*
arch/powerpc/include/uapi/asm/mman.h+1−1
@@ -11,7 +11,7 @@ · 10 unmodified lines
1111 #include <asm-generic/mman-common.h>
1212
1313
14−#define PROT_SAO 0x10 /* Strong Access Ordering */
14+#define PROT_SAO 0x10 /* Unsupported since v5.9 */
1515
1616 #define MAP_RENAME MAP_ANONYMOUS /* In SunOS terminology */
1717 #define MAP_NORESERVE 0x40 /* don't reserve swap pages */
arch/powerpc/kernel/dt_cpu_ftrs.c+1−1
@@ -622,7 +622,7 @@ static struct dt_cpu_feature_match __initdata · 621 unmodified lines
622622 {"processor-control-facility-v3", feat_enable_dbell, CPU_FTR_DBELL},
623623 {"processor-utilization-of-resources-register", feat_enable_purr, 0},
624624 {"no-execute", feat_enable, 0},
625− {"strong-access-ordering", feat_enable, CPU_FTR_SAO},
625+ /* strong-access-ordering is unused */
626626 {"cache-inhibited-large-page", feat_enable_large_ci, 0},
627627 {"coprocessor-icswx", feat_enable, 0},
628628 {"hypervisor-virtualization-interrupt", feat_enable_hvi, 0},
arch/powerpc/mm/book3s64/hash_utils.c+0−2
@@ -232,8 +232,6 @@ unsigned long htab_convert_pte_flags(unsigned long pteflags) · 231 unmodified lines
232232 rflags |= HPTE_R_I;
233233 else if ((pteflags & _PAGE_CACHE_CTL) == _PAGE_NON_IDEMPOTENT)
234234 rflags |= (HPTE_R_I | HPTE_R_G);
235− else if ((pteflags & _PAGE_CACHE_CTL) == _PAGE_SAO)
236− rflags |= (HPTE_R_W | HPTE_R_I | HPTE_R_M);
237235 else
238236 /*
239237 * Add memory coherence if cache inhibited is not set
include/linux/mm.h+0−2
@@ -317,8 +317,6 @@ extern unsigned int kobjsize(const void *objp); · 316 unmodified lines
317317
318318 #if defined(CONFIG_X86)
319319 # define VM_PAT VM_ARCH_1 /* PAT reserves whole VMA at once (x86) */
320−#elif defined(CONFIG_PPC)
321−# define VM_SAO VM_ARCH_1 /* Strong Access Ordering (powerpc) */
322320 #elif defined(CONFIG_PARISC)
323321 # define VM_GROWSUP VM_ARCH_1
324322 #elif defined(CONFIG_IA64)
include/trace/events/mmflags.h+0−2
@@ -114,8 +114,6 @@ IF_HAVE_PG_IDLE(PG_idle, "idle" ) · 113 unmodified lines
114114
115115 #if defined(CONFIG_X86)
116116 #define __VM_ARCH_SPECIFIC_1 {VM_PAT, "pat" }
117−#elif defined(CONFIG_PPC)
118−#define __VM_ARCH_SPECIFIC_1 {VM_SAO, "sao" }
119117 #elif defined(CONFIG_PARISC) || defined(CONFIG_IA64)
120118 #define __VM_ARCH_SPECIFIC_1 {VM_GROWSUP, "growsup" }
121119 #elif !defined(CONFIG_MMU)
mm/ksm.c+0−4
@@ -2452,10 +2452,6 @@ int ksm_madvise(struct vm_area_struct *vma, unsigned long start, · 2451 unmodified lines
24522452 if (vma_is_dax(vma))
24532453 return 0;
24542454
2455−#ifdef VM_SAO
2456− if (*vm_flags & VM_SAO)
2457− return 0;
2458−#endif
24592455 #ifdef VM_SPARC_ADI
24602456 if (*vm_flags & VM_SPARC_ADI)
24612457 return 0;
tools/testing/selftests/powerpc/mm/.gitignore+0−1
@@ -2,7 +2,6 @@ · 1 unmodified line
22 hugetlb_vs_thp_test
33 subpage_prot
44 tempfile
5−prot_sao
65 segv_errors
76 wild_bctr
87 large_vm_fork_separation
tools/testing/selftests/powerpc/mm/Makefile+1−3
@@ -2,7 +2,7 @@ · 1 unmodified line
22 noarg:
33 $(MAKE) -C ../
44
5−TEST_GEN_PROGS := hugetlb_vs_thp_test subpage_prot prot_sao segv_errors wild_bctr \
5+TEST_GEN_PROGS := hugetlb_vs_thp_test subpage_prot segv_errors wild_bctr \
66 large_vm_fork_separation bad_accesses pkey_exec_prot
77 TEST_GEN_PROGS_EXTENDED := tlbie_test
88 TEST_GEN_FILES := tempfile
@@ -12,8 +12,6 @@ include ../../lib.mk · 3 unmodified lines
1212
1313 $(TEST_GEN_PROGS): ../harness.c ../utils.c
1414
15−$(OUTPUT)/prot_sao: ../utils.c
16−
1715 $(OUTPUT)/wild_bctr: CFLAGS += -m64
1816 $(OUTPUT)/large_vm_fork_separation: CFLAGS += -m64
1917 $(OUTPUT)/bad_accesses: CFLAGS += -m64
tools/testing/selftests/powerpc/mm/prot_sao.c+0−42
@@ -1,42 +0,0 @@
1−// SPDX-License-Identifier: GPL-2.0-only
2−/*
3− * Copyright 2016, Michael Ellerman, IBM Corp.
4− */
5−
6−#include <stdio.h>
7−#include <stdlib.h>
8−#include <string.h>
9−#include <sys/mman.h>
10−
11−#include <asm/cputable.h>
12−
13−#include "utils.h"
14−
15−#define SIZE (64 * 1024)
16−
17−int test_prot_sao(void)
18−{
19− char *p;
20−
21− /* 2.06 or later should support SAO */
22− SKIP_IF(!have_hwcap(PPC_FEATURE_ARCH_2_06));
23−
24− /*
25− * Ensure we can ask for PROT_SAO.
26− * We can't really verify that it does the right thing, but at least we
27− * confirm the kernel will accept it.
28− */
29− p = mmap(NULL, SIZE, PROT_READ | PROT_WRITE | PROT_SAO,
30− MAP_ANONYMOUS | MAP_PRIVATE, -1, 0);
31− FAIL_IF(p == MAP_FAILED);
32−
33− /* Write to the mapping, to at least cause a fault */
34− memset(p, 0xaa, SIZE);
35−
36− return 0;
37−}
38−
39−int main(void)
40−{
41− return test_harness(test_prot_sao, "prot-sao");
42−}

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t