Skip to content

Commit 8bb5021

Browse files
committed
Merge tag 'powerpc-5.9-4' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux
Pull powerpc fixes from Michael Ellerman: - Revert our removal of PROT_SAO, at least one user expressed an interest in using it on Power9. Instead don't allow it to be used in guests unless enabled explicitly at compile time. - A fix for a crash introduced by a recent change to FP handling. - Revert a change to our idle code that left Power10 with no idle support. - One minor fix for the new scv system call path to set PPR. - Fix a crash in our "generic" PMU if branch stack events were enabled. - A fix for the IMC PMU, to correctly identify host kernel samples. - The ADB_PMU powermac code was found to be incompatible with VMAP_STACK, so make them incompatible in Kconfig until the code can be fixed. - A build fix in drivers/video/fbdev/controlfb.c, and a documentation fix. Thanks to Alexey Kardashevskiy, Athira Rajeev, Christophe Leroy, Giuseppe Sacco, Madhavan Srinivasan, Milton Miller, Nicholas Piggin, Pratik Rajesh Sampat, Randy Dunlap, Shawn Anastasio, Vaidyanathan Srinivasan. * tag 'powerpc-5.9-4' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux: powerpc/32s: Disable VMAP stack which CONFIG_ADB_PMU Revert "powerpc/powernv/idle: Replace CPU feature check with PVR check" powerpc/perf: Fix reading of MSR[HV/PR] bits in trace-imc powerpc/perf: Fix crashes with generic_compat_pmu & BHRB powerpc/64s: Fix crash in load_fp_state() due to fpexc_mode powerpc/64s: scv entry should set PPR Documentation/powerpc: fix malformed table in syscall64-abi video: fbdev: controlfb: Fix build for COMPILE_TEST=y && PPC_PMAC=n selftests/powerpc: Update PROT_SAO test to skip ISA 3.1 powerpc/64s: Disallow PROT_SAO in LPARs by default Revert "powerpc/64s: Remove PROT_SAO support"
2 parents 6f0306d + 4a133eb commit 8bb5021

File tree

22 files changed

+144
-30
lines changed

22 files changed

+144
-30
lines changed

Documentation/powerpc/syscall64-abi.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,16 +49,18 @@ Register preservation rules
4949
Register preservation rules match the ELF ABI calling sequence with the
5050
following differences:
5151

52-
=========== ============= ========================================
5352
--- For the sc instruction, differences with the ELF ABI ---
53+
=========== ============= ========================================
5454
r0 Volatile (System call number.)
5555
r3 Volatile (Parameter 1, and return value.)
5656
r4-r8 Volatile (Parameters 2-6.)
5757
cr0 Volatile (cr0.SO is the return error condition.)
5858
cr1, cr5-7 Nonvolatile
5959
lr Nonvolatile
60+
=========== ============= ========================================
6061

6162
--- For the scv 0 instruction, differences with the ELF ABI ---
63+
=========== ============= ========================================
6264
r0 Volatile (System call number.)
6365
r3 Volatile (Parameter 1, and return value.)
6466
r4-r8 Volatile (Parameters 2-6.)

arch/powerpc/Kconfig

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -860,6 +860,18 @@ config PPC_SUBPAGE_PROT
860860

861861
If unsure, say N here.
862862

863+
config PPC_PROT_SAO_LPAR
864+
bool "Support PROT_SAO mappings in LPARs"
865+
depends on PPC_BOOK3S_64
866+
help
867+
This option adds support for PROT_SAO mappings from userspace
868+
inside LPARs on supported CPUs.
869+
870+
This may cause issues when performing guest migration from
871+
a CPU that supports SAO to one that does not.
872+
873+
If unsure, say N here.
874+
863875
config PPC_COPRO_BASE
864876
bool
865877

arch/powerpc/include/asm/book3s/64/pgtable.h

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,9 @@
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-
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 */
23+
#define _PAGE_SAO 0x00010 /* Strong access order */
2724
#define _PAGE_NON_IDEMPOTENT 0x00020 /* non idempotent memory */
2825
#define _PAGE_TOLERANT 0x00030 /* tolerant memory, cache inhibited */
29-
3026
#define _PAGE_DIRTY 0x00080 /* C: page changed */
3127
#define _PAGE_ACCESSED 0x00100 /* R: page referenced */
3228
/*
@@ -828,6 +824,8 @@ static inline void __set_pte_at(struct mm_struct *mm, unsigned long addr,
828824
return hash__set_pte_at(mm, addr, ptep, pte, percpu);
829825
}
830826

827+
#define _PAGE_CACHE_CTL (_PAGE_SAO | _PAGE_NON_IDEMPOTENT | _PAGE_TOLERANT)
828+
831829
#define pgprot_noncached pgprot_noncached
832830
static inline pgprot_t pgprot_noncached(pgprot_t prot)
833831
{

arch/powerpc/include/asm/cputable.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ static inline void cpu_feature_keys_init(void) { }
196196
#define CPU_FTR_SPURR LONG_ASM_CONST(0x0000000001000000)
197197
#define CPU_FTR_DSCR LONG_ASM_CONST(0x0000000002000000)
198198
#define CPU_FTR_VSX LONG_ASM_CONST(0x0000000004000000)
199-
// Free LONG_ASM_CONST(0x0000000008000000)
199+
#define CPU_FTR_SAO LONG_ASM_CONST(0x0000000008000000)
200200
#define CPU_FTR_CP_USE_DCBTZ LONG_ASM_CONST(0x0000000010000000)
201201
#define CPU_FTR_UNALIGNED_LD_STD LONG_ASM_CONST(0x0000000020000000)
202202
#define CPU_FTR_ASYM_SMT LONG_ASM_CONST(0x0000000040000000)
@@ -441,7 +441,7 @@ static inline void cpu_feature_keys_init(void) { }
441441
CPU_FTR_MMCRA | CPU_FTR_SMT | \
442442
CPU_FTR_COHERENT_ICACHE | \
443443
CPU_FTR_PURR | CPU_FTR_SPURR | CPU_FTR_REAL_LE | \
444-
CPU_FTR_DSCR | CPU_FTR_ASYM_SMT | \
444+
CPU_FTR_DSCR | CPU_FTR_SAO | CPU_FTR_ASYM_SMT | \
445445
CPU_FTR_STCX_CHECKS_ADDRESS | CPU_FTR_POPCNTB | CPU_FTR_POPCNTD | \
446446
CPU_FTR_CFAR | CPU_FTR_HVMODE | \
447447
CPU_FTR_VMX_COPY | CPU_FTR_HAS_PPR | CPU_FTR_DABRX )
@@ -450,7 +450,7 @@ static inline void cpu_feature_keys_init(void) { }
450450
CPU_FTR_MMCRA | CPU_FTR_SMT | \
451451
CPU_FTR_COHERENT_ICACHE | \
452452
CPU_FTR_PURR | CPU_FTR_SPURR | CPU_FTR_REAL_LE | \
453-
CPU_FTR_DSCR | \
453+
CPU_FTR_DSCR | CPU_FTR_SAO | \
454454
CPU_FTR_STCX_CHECKS_ADDRESS | CPU_FTR_POPCNTB | CPU_FTR_POPCNTD | \
455455
CPU_FTR_CFAR | CPU_FTR_HVMODE | CPU_FTR_VMX_COPY | \
456456
CPU_FTR_DBELL | CPU_FTR_HAS_PPR | CPU_FTR_DAWR | \
@@ -461,7 +461,7 @@ static inline void cpu_feature_keys_init(void) { }
461461
CPU_FTR_MMCRA | CPU_FTR_SMT | \
462462
CPU_FTR_COHERENT_ICACHE | \
463463
CPU_FTR_PURR | CPU_FTR_SPURR | CPU_FTR_REAL_LE | \
464-
CPU_FTR_DSCR | \
464+
CPU_FTR_DSCR | CPU_FTR_SAO | \
465465
CPU_FTR_STCX_CHECKS_ADDRESS | CPU_FTR_POPCNTB | CPU_FTR_POPCNTD | \
466466
CPU_FTR_CFAR | CPU_FTR_HVMODE | CPU_FTR_VMX_COPY | \
467467
CPU_FTR_DBELL | CPU_FTR_HAS_PPR | CPU_FTR_ARCH_207S | \
@@ -479,7 +479,7 @@ static inline void cpu_feature_keys_init(void) { }
479479
CPU_FTR_MMCRA | CPU_FTR_SMT | \
480480
CPU_FTR_COHERENT_ICACHE | \
481481
CPU_FTR_PURR | CPU_FTR_SPURR | CPU_FTR_REAL_LE | \
482-
CPU_FTR_DSCR | \
482+
CPU_FTR_DSCR | CPU_FTR_SAO | \
483483
CPU_FTR_STCX_CHECKS_ADDRESS | CPU_FTR_POPCNTB | CPU_FTR_POPCNTD | \
484484
CPU_FTR_CFAR | CPU_FTR_HVMODE | CPU_FTR_VMX_COPY | \
485485
CPU_FTR_DBELL | CPU_FTR_HAS_PPR | CPU_FTR_ARCH_207S | \

arch/powerpc/include/asm/mman.h

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,43 @@
1313
#include <linux/pkeys.h>
1414
#include <asm/cpu_has_feature.h>
1515

16-
#ifdef CONFIG_PPC_MEM_KEYS
1716
static inline unsigned long arch_calc_vm_prot_bits(unsigned long prot,
1817
unsigned long pkey)
1918
{
20-
return pkey_to_vmflag_bits(pkey);
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
2124
}
2225
#define arch_calc_vm_prot_bits(prot, pkey) arch_calc_vm_prot_bits(prot, pkey)
2326

2427
static inline pgprot_t arch_vm_get_page_prot(unsigned long vm_flags)
2528
{
26-
return __pgprot(vmflag_to_pte_pkey_bits(vm_flags));
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
2736
}
2837
#define arch_vm_get_page_prot(vm_flags) arch_vm_get_page_prot(vm_flags)
29-
#endif
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) {
44+
if (!cpu_has_feature(CPU_FTR_SAO))
45+
return false;
46+
if (firmware_has_feature(FW_FEATURE_LPAR) &&
47+
!IS_ENABLED(CONFIG_PPC_PROT_SAO_LPAR))
48+
return false;
49+
}
50+
return true;
51+
}
52+
#define arch_validate_prot arch_validate_prot
3053

3154
#endif /* CONFIG_PPC64 */
3255
#endif /* _ASM_POWERPC_MMAN_H */

arch/powerpc/include/asm/nohash/64/pgtable.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@
8282
*/
8383
#include <asm/nohash/pte-book3e.h>
8484

85+
#define _PAGE_SAO 0
86+
8587
#define PTE_RPN_MASK (~((1UL << PTE_RPN_SHIFT) - 1))
8688

8789
/*

arch/powerpc/include/uapi/asm/mman.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#include <asm-generic/mman-common.h>
1212

1313

14-
#define PROT_SAO 0x10 /* Unsupported since v5.9 */
14+
#define PROT_SAO 0x10 /* Strong Access Ordering */
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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -653,7 +653,7 @@ static struct dt_cpu_feature_match __initdata
653653
{"processor-control-facility-v3", feat_enable_dbell, CPU_FTR_DBELL},
654654
{"processor-utilization-of-resources-register", feat_enable_purr, 0},
655655
{"no-execute", feat_enable, 0},
656-
/* strong-access-ordering is unused */
656+
{"strong-access-ordering", feat_enable, CPU_FTR_SAO},
657657
{"cache-inhibited-large-page", feat_enable_large_ci, 0},
658658
{"coprocessor-icswx", feat_enable, 0},
659659
{"hypervisor-virtualization-interrupt", feat_enable_hvi, 0},

arch/powerpc/kernel/entry_64.S

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,10 @@ END_FTR_SECTION_IFSET(CPU_FTR_TM)
113113
ld r11,exception_marker@toc(r2)
114114
std r11,-16(r10) /* "regshere" marker */
115115

116+
BEGIN_FTR_SECTION
117+
HMT_MEDIUM
118+
END_FTR_SECTION_IFSET(CPU_FTR_HAS_PPR)
119+
116120
/*
117121
* RECONCILE_IRQ_STATE without calling trace_hardirqs_off(), which
118122
* would clobber syscall parameters. Also we always enter with IRQs

arch/powerpc/kernel/process.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,7 @@ void notrace restore_math(struct pt_regs *regs)
548548
* are live for the user thread).
549549
*/
550550
if ((!(msr & MSR_FP)) && should_restore_fp())
551-
new_msr |= MSR_FP | current->thread.fpexc_mode;
551+
new_msr |= MSR_FP;
552552

553553
if ((!(msr & MSR_VEC)) && should_restore_altivec())
554554
new_msr |= MSR_VEC;
@@ -559,11 +559,17 @@ void notrace restore_math(struct pt_regs *regs)
559559
}
560560

561561
if (new_msr) {
562+
unsigned long fpexc_mode = 0;
563+
562564
msr_check_and_set(new_msr);
563565

564-
if (new_msr & MSR_FP)
566+
if (new_msr & MSR_FP) {
565567
do_restore_fp();
566568

569+
// This also covers VSX, because VSX implies FP
570+
fpexc_mode = current->thread.fpexc_mode;
571+
}
572+
567573
if (new_msr & MSR_VEC)
568574
do_restore_altivec();
569575

@@ -572,7 +578,7 @@ void notrace restore_math(struct pt_regs *regs)
572578

573579
msr_check_and_clear(new_msr);
574580

575-
regs->msr |= new_msr;
581+
regs->msr |= new_msr | fpexc_mode;
576582
}
577583
}
578584
#endif

0 commit comments

Comments
 (0)