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
20#define _PAGE_RW (_PAGE_READ | _PAGE_WRITE)20#define _PAGE_RW (_PAGE_READ | _PAGE_WRITE)
21#define _PAGE_RWX (_PAGE_READ | _PAGE_WRITE | _PAGE_EXEC)21#define _PAGE_RWX (_PAGE_READ | _PAGE_WRITE | _PAGE_EXEC)
22#define _PAGE_PRIVILEGED 0x00008 /* kernel access only */22#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 */
24#define _PAGE_NON_IDEMPOTENT 0x00020 /* non idempotent memory */27#define _PAGE_NON_IDEMPOTENT 0x00020 /* non idempotent memory */
25#define _PAGE_TOLERANT 0x00030 /* tolerant memory, cache inhibited */28#define _PAGE_TOLERANT 0x00030 /* tolerant memory, cache inhibited */
29
26#define _PAGE_DIRTY 0x00080 /* C: page changed */30#define _PAGE_DIRTY 0x00080 /* C: page changed */
27#define _PAGE_ACCESSED 0x00100 /* R: page referenced */31#define _PAGE_ACCESSED 0x00100 /* R: page referenced */
28/*32/*
@@ -824,8 +828,6 @@ static inline void __set_pte_at(struct mm_struct *mm, unsigned long addr, · 795 unmodified lines
824 return hash__set_pte_at(mm, addr, ptep, pte, percpu);828 return hash__set_pte_at(mm, addr, ptep, pte, percpu);
825}829}
826 830
827#define _PAGE_CACHE_CTL (_PAGE_SAO | _PAGE_NON_IDEMPOTENT | _PAGE_TOLERANT)
828
829#define pgprot_noncached pgprot_noncached831#define pgprot_noncached pgprot_noncached
830static inline pgprot_t pgprot_noncached(pgprot_t prot)832static inline pgprot_t pgprot_noncached(pgprot_t prot)
831{833{
arch/powerpc/include/asm/cputable.h+5−5
@@ -191,7 +191,7 @@ static inline void cpu_feature_keys_init(void) { } · 190 unmodified lines
191#define CPU_FTR_SPURR LONG_ASM_CONST(0x0000000001000000)191#define CPU_FTR_SPURR LONG_ASM_CONST(0x0000000001000000)
192#define CPU_FTR_DSCR LONG_ASM_CONST(0x0000000002000000)192#define CPU_FTR_DSCR LONG_ASM_CONST(0x0000000002000000)
193#define CPU_FTR_VSX LONG_ASM_CONST(0x0000000004000000)193#define CPU_FTR_VSX LONG_ASM_CONST(0x0000000004000000)
194#define CPU_FTR_SAO LONG_ASM_CONST(0x0000000008000000)194// Free LONG_ASM_CONST(0x0000000008000000)
195#define CPU_FTR_CP_USE_DCBTZ LONG_ASM_CONST(0x0000000010000000)195#define CPU_FTR_CP_USE_DCBTZ LONG_ASM_CONST(0x0000000010000000)
196#define CPU_FTR_UNALIGNED_LD_STD LONG_ASM_CONST(0x0000000020000000)196#define CPU_FTR_UNALIGNED_LD_STD LONG_ASM_CONST(0x0000000020000000)
197#define CPU_FTR_ASYM_SMT LONG_ASM_CONST(0x0000000040000000)197#define CPU_FTR_ASYM_SMT LONG_ASM_CONST(0x0000000040000000)
@@ -435,7 +435,7 @@ static inline void cpu_feature_keys_init(void) { } · 237 unmodified lines
435 CPU_FTR_MMCRA | CPU_FTR_SMT | \435 CPU_FTR_MMCRA | CPU_FTR_SMT | \
436 CPU_FTR_COHERENT_ICACHE | \436 CPU_FTR_COHERENT_ICACHE | \
437 CPU_FTR_PURR | CPU_FTR_SPURR | CPU_FTR_REAL_LE | \437 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 | \
439 CPU_FTR_STCX_CHECKS_ADDRESS | CPU_FTR_POPCNTB | CPU_FTR_POPCNTD | \439 CPU_FTR_STCX_CHECKS_ADDRESS | CPU_FTR_POPCNTB | CPU_FTR_POPCNTD | \
440 CPU_FTR_CFAR | CPU_FTR_HVMODE | \440 CPU_FTR_CFAR | CPU_FTR_HVMODE | \
441 CPU_FTR_VMX_COPY | CPU_FTR_HAS_PPR | CPU_FTR_DABRX )441 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
444 CPU_FTR_MMCRA | CPU_FTR_SMT | \444 CPU_FTR_MMCRA | CPU_FTR_SMT | \
445 CPU_FTR_COHERENT_ICACHE | \445 CPU_FTR_COHERENT_ICACHE | \
446 CPU_FTR_PURR | CPU_FTR_SPURR | CPU_FTR_REAL_LE | \446 CPU_FTR_PURR | CPU_FTR_SPURR | CPU_FTR_REAL_LE | \
447 CPU_FTR_DSCR | CPU_FTR_SAO | \447 CPU_FTR_DSCR | \
448 CPU_FTR_STCX_CHECKS_ADDRESS | CPU_FTR_POPCNTB | CPU_FTR_POPCNTD | \448 CPU_FTR_STCX_CHECKS_ADDRESS | CPU_FTR_POPCNTB | CPU_FTR_POPCNTD | \
449 CPU_FTR_CFAR | CPU_FTR_HVMODE | CPU_FTR_VMX_COPY | \449 CPU_FTR_CFAR | CPU_FTR_HVMODE | CPU_FTR_VMX_COPY | \
450 CPU_FTR_DBELL | CPU_FTR_HAS_PPR | CPU_FTR_DAWR | \450 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
455 CPU_FTR_MMCRA | CPU_FTR_SMT | \455 CPU_FTR_MMCRA | CPU_FTR_SMT | \
456 CPU_FTR_COHERENT_ICACHE | \456 CPU_FTR_COHERENT_ICACHE | \
457 CPU_FTR_PURR | CPU_FTR_SPURR | CPU_FTR_REAL_LE | \457 CPU_FTR_PURR | CPU_FTR_SPURR | CPU_FTR_REAL_LE | \
458 CPU_FTR_DSCR | CPU_FTR_SAO | \458 CPU_FTR_DSCR | \
459 CPU_FTR_STCX_CHECKS_ADDRESS | CPU_FTR_POPCNTB | CPU_FTR_POPCNTD | \459 CPU_FTR_STCX_CHECKS_ADDRESS | CPU_FTR_POPCNTB | CPU_FTR_POPCNTD | \
460 CPU_FTR_CFAR | CPU_FTR_HVMODE | CPU_FTR_VMX_COPY | \460 CPU_FTR_CFAR | CPU_FTR_HVMODE | CPU_FTR_VMX_COPY | \
461 CPU_FTR_DBELL | CPU_FTR_HAS_PPR | CPU_FTR_ARCH_207S | \461 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
473 CPU_FTR_MMCRA | CPU_FTR_SMT | \473 CPU_FTR_MMCRA | CPU_FTR_SMT | \
474 CPU_FTR_COHERENT_ICACHE | \474 CPU_FTR_COHERENT_ICACHE | \
475 CPU_FTR_PURR | CPU_FTR_SPURR | CPU_FTR_REAL_LE | \475 CPU_FTR_PURR | CPU_FTR_SPURR | CPU_FTR_REAL_LE | \
476 CPU_FTR_DSCR | CPU_FTR_SAO | \476 CPU_FTR_DSCR | \
477 CPU_FTR_STCX_CHECKS_ADDRESS | CPU_FTR_POPCNTB | CPU_FTR_POPCNTD | \477 CPU_FTR_STCX_CHECKS_ADDRESS | CPU_FTR_POPCNTB | CPU_FTR_POPCNTD | \
478 CPU_FTR_CFAR | CPU_FTR_HVMODE | CPU_FTR_VMX_COPY | \478 CPU_FTR_CFAR | CPU_FTR_HVMODE | CPU_FTR_VMX_COPY | \
479 CPU_FTR_DBELL | CPU_FTR_HAS_PPR | CPU_FTR_ARCH_207S | \479 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
13#include <linux/pkeys.h>13#include <linux/pkeys.h>
14#include <asm/cpu_has_feature.h>14#include <asm/cpu_has_feature.h>
15 15
16#ifdef CONFIG_PPC_MEM_KEYS
16static inline unsigned long arch_calc_vm_prot_bits(unsigned long prot,17static inline unsigned long arch_calc_vm_prot_bits(unsigned long prot,
17 unsigned long pkey)18 unsigned long pkey)
18{19{
19#ifdef CONFIG_PPC_MEM_KEYS20 return pkey_to_vmflag_bits(pkey);
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
24}21}
25#define arch_calc_vm_prot_bits(prot, pkey) arch_calc_vm_prot_bits(prot, pkey)22#define arch_calc_vm_prot_bits(prot, pkey) arch_calc_vm_prot_bits(prot, pkey)
26 23
27static inline pgprot_t arch_vm_get_page_prot(unsigned long vm_flags)24static inline pgprot_t arch_vm_get_page_prot(unsigned long vm_flags)
28{25{
29#ifdef CONFIG_PPC_MEM_KEYS26 return __pgprot(vmflag_to_pte_pkey_bits(vm_flags));
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
36}27}
37#define arch_vm_get_page_prot(vm_flags) arch_vm_get_page_prot(vm_flags)28#define arch_vm_get_page_prot(vm_flags) arch_vm_get_page_prot(vm_flags)
38 29#endif
39static 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
48 30
49#endif /* CONFIG_PPC64 */31#endif /* CONFIG_PPC64 */
50#endif /* _ASM_POWERPC_MMAN_H */32#endif /* _ASM_POWERPC_MMAN_H */
arch/powerpc/include/asm/nohash/64/pgtable.h+0−2
@@ -82,8 +82,6 @@ · 81 unmodified lines
82 */82 */
83#include <asm/nohash/pte-book3e.h>83#include <asm/nohash/pte-book3e.h>
84 84
85#define _PAGE_SAO 0
86
87#define PTE_RPN_MASK (~((1UL << PTE_RPN_SHIFT) - 1))85#define PTE_RPN_MASK (~((1UL << PTE_RPN_SHIFT) - 1))
88 86
89/*87/*
arch/powerpc/include/uapi/asm/mman.h+1−1
@@ -11,7 +11,7 @@ · 10 unmodified lines
11#include <asm-generic/mman-common.h>11#include <asm-generic/mman-common.h>
12 12
13 13
14#define PROT_SAO 0x10 /* Strong Access Ordering */14#define PROT_SAO 0x10 /* Unsupported since v5.9 */
15 15
16#define MAP_RENAME MAP_ANONYMOUS /* In SunOS terminology */16#define MAP_RENAME MAP_ANONYMOUS /* In SunOS terminology */
17#define MAP_NORESERVE 0x40 /* don't reserve swap pages */17#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
622 {"processor-control-facility-v3", feat_enable_dbell, CPU_FTR_DBELL},622 {"processor-control-facility-v3", feat_enable_dbell, CPU_FTR_DBELL},
623 {"processor-utilization-of-resources-register", feat_enable_purr, 0},623 {"processor-utilization-of-resources-register", feat_enable_purr, 0},
624 {"no-execute", feat_enable, 0},624 {"no-execute", feat_enable, 0},
625 {"strong-access-ordering", feat_enable, CPU_FTR_SAO},625 /* strong-access-ordering is unused */
626 {"cache-inhibited-large-page", feat_enable_large_ci, 0},626 {"cache-inhibited-large-page", feat_enable_large_ci, 0},
627 {"coprocessor-icswx", feat_enable, 0},627 {"coprocessor-icswx", feat_enable, 0},
628 {"hypervisor-virtualization-interrupt", feat_enable_hvi, 0},628 {"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
232 rflags |= HPTE_R_I;232 rflags |= HPTE_R_I;
233 else if ((pteflags & _PAGE_CACHE_CTL) == _PAGE_NON_IDEMPOTENT)233 else if ((pteflags & _PAGE_CACHE_CTL) == _PAGE_NON_IDEMPOTENT)
234 rflags |= (HPTE_R_I | HPTE_R_G);234 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);
237 else235 else
238 /*236 /*
239 * Add memory coherence if cache inhibited is not set237 * 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
317 317
318#if defined(CONFIG_X86)318#if defined(CONFIG_X86)
319# define VM_PAT VM_ARCH_1 /* PAT reserves whole VMA at once (x86) */319# 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) */
322#elif defined(CONFIG_PARISC)320#elif defined(CONFIG_PARISC)
323# define VM_GROWSUP VM_ARCH_1321# define VM_GROWSUP VM_ARCH_1
324#elif defined(CONFIG_IA64)322#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
114 114
115#if defined(CONFIG_X86)115#if defined(CONFIG_X86)
116#define __VM_ARCH_SPECIFIC_1 {VM_PAT, "pat" }116#define __VM_ARCH_SPECIFIC_1 {VM_PAT, "pat" }
117#elif defined(CONFIG_PPC)
118#define __VM_ARCH_SPECIFIC_1 {VM_SAO, "sao" }
119#elif defined(CONFIG_PARISC) || defined(CONFIG_IA64)117#elif defined(CONFIG_PARISC) || defined(CONFIG_IA64)
120#define __VM_ARCH_SPECIFIC_1 {VM_GROWSUP, "growsup" }118#define __VM_ARCH_SPECIFIC_1 {VM_GROWSUP, "growsup" }
121#elif !defined(CONFIG_MMU)119#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
2452 if (vma_is_dax(vma))2452 if (vma_is_dax(vma))
2453 return 0;2453 return 0;
2454 2454
2455#ifdef VM_SAO
2456 if (*vm_flags & VM_SAO)
2457 return 0;
2458#endif
2459#ifdef VM_SPARC_ADI2455#ifdef VM_SPARC_ADI
2460 if (*vm_flags & VM_SPARC_ADI)2456 if (*vm_flags & VM_SPARC_ADI)
2461 return 0;2457 return 0;
tools/testing/selftests/powerpc/mm/.gitignore+0−1
@@ -2,7 +2,6 @@ · 1 unmodified line
2hugetlb_vs_thp_test2hugetlb_vs_thp_test
3subpage_prot3subpage_prot
4tempfile4tempfile
5prot_sao
6segv_errors5segv_errors
7wild_bctr6wild_bctr
8large_vm_fork_separation7large_vm_fork_separation
tools/testing/selftests/powerpc/mm/Makefile+1−3
@@ -2,7 +2,7 @@ · 1 unmodified line
2noarg:2noarg:
3 $(MAKE) -C ../3 $(MAKE) -C ../
4 4
5TEST_GEN_PROGS := hugetlb_vs_thp_test subpage_prot prot_sao segv_errors wild_bctr \5TEST_GEN_PROGS := hugetlb_vs_thp_test subpage_prot segv_errors wild_bctr \
6 large_vm_fork_separation bad_accesses pkey_exec_prot6 large_vm_fork_separation bad_accesses pkey_exec_prot
7TEST_GEN_PROGS_EXTENDED := tlbie_test7TEST_GEN_PROGS_EXTENDED := tlbie_test
8TEST_GEN_FILES := tempfile8TEST_GEN_FILES := tempfile
@@ -12,8 +12,6 @@ include ../../lib.mk · 3 unmodified lines
12 12
13$(TEST_GEN_PROGS): ../harness.c ../utils.c13$(TEST_GEN_PROGS): ../harness.c ../utils.c
14 14
15$(OUTPUT)/prot_sao: ../utils.c
16
17$(OUTPUT)/wild_bctr: CFLAGS += -m6415$(OUTPUT)/wild_bctr: CFLAGS += -m64
18$(OUTPUT)/large_vm_fork_separation: CFLAGS += -m6416$(OUTPUT)/large_vm_fork_separation: CFLAGS += -m64
19$(OUTPUT)/bad_accesses: CFLAGS += -m6417$(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
17int 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
39int 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