···2222 | nios2: | TODO |2323 | openrisc: | TODO |2424 | parisc: | TODO |2525- | powerpc: | ok |2525+ | powerpc: | TODO |2626 | riscv: | ok |2727 | s390: | ok |2828 | sh: | TODO |
+3-1
Documentation/powerpc/syscall64-abi.rst
···4949Register preservation rules match the ELF ABI calling sequence with the5050following differences:51515252-=========== ============= ========================================5352--- For the sc instruction, differences with the ELF ABI ---5353+=========== ============= ========================================5454r0 Volatile (System call number.)5555r3 Volatile (Parameter 1, and return value.)5656r4-r8 Volatile (Parameters 2-6.)5757cr0 Volatile (cr0.SO is the return error condition.)5858cr1, cr5-7 Nonvolatile5959lr Nonvolatile6060+=========== ============= ========================================60616162--- For the scv 0 instruction, differences with the ELF ABI ---6363+=========== ============= ========================================6264r0 Volatile (System call number.)6365r3 Volatile (Parameter 1, and return value.)6466r4-r8 Volatile (Parameters 2-6.)
+12-1
arch/powerpc/Kconfig
···116116 #117117 select ARCH_32BIT_OFF_T if PPC32118118 select ARCH_HAS_DEBUG_VIRTUAL119119- select ARCH_HAS_DEBUG_VM_PGTABLE120119 select ARCH_HAS_DEVMEM_IS_ALLOWED121120 select ARCH_HAS_ELF_RANDOMIZE122121 select ARCH_HAS_FORTIFY_SOURCE···856857 This option adds support for system call to allow user programs857858 to set access permissions (read/write, readonly, or no access)858859 on the 4k subpages of each 64k page.860860+861861+ If unsure, say N here.862862+863863+config PPC_PROT_SAO_LPAR864864+ bool "Support PROT_SAO mappings in LPARs"865865+ depends on PPC_BOOK3S_64866866+ help867867+ This option adds support for PROT_SAO mappings from userspace868868+ inside LPARs on supported CPUs.869869+870870+ This may cause issues when performing guest migration from871871+ a CPU that supports SAO to one that does not.859872860873 If unsure, say N here.861874
+5-5
arch/powerpc/include/asm/book3s/64/mmu.h
···239239240240extern void hash__setup_initial_memory_limit(phys_addr_t first_memblock_base,241241 phys_addr_t first_memblock_size);242242-extern void radix__setup_initial_memory_limit(phys_addr_t first_memblock_base,243243- phys_addr_t first_memblock_size);244242static inline void setup_initial_memory_limit(phys_addr_t first_memblock_base,245243 phys_addr_t first_memblock_size)246244{247247- if (early_radix_enabled())248248- return radix__setup_initial_memory_limit(first_memblock_base,249249- first_memblock_size);245245+ /*246246+ * Hash has more strict restrictions. At this point we don't247247+ * know which translations we will pick. Hence go with hash248248+ * restrictions.249249+ */250250 return hash__setup_initial_memory_limit(first_memblock_base,251251 first_memblock_size);252252}
+3-5
arch/powerpc/include/asm/book3s/64/pgtable.h
···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 */2323-2424-#define _PAGE_CACHE_CTL 0x00030 /* Bits for the folowing cache modes */2525- /* No bits set is normal cacheable memory */2626- /* 0x00010 unused, is SAO bit on radix POWER9 */2323+#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 */2929-3026#define _PAGE_DIRTY 0x00080 /* C: page changed */3127#define _PAGE_ACCESSED 0x00100 /* R: page referenced */3228/*···823827 return radix__set_pte_at(mm, addr, ptep, pte, percpu);824828 return hash__set_pte_at(mm, addr, ptep, pte, percpu);825829}830830+831831+#define _PAGE_CACHE_CTL (_PAGE_SAO | _PAGE_NON_IDEMPOTENT | _PAGE_TOLERANT)826832827833#define pgprot_noncached pgprot_noncached828834static inline pgprot_t pgprot_noncached(pgprot_t prot)
···113113 ld r11,exception_marker@toc(r2)114114 std r11,-16(r10) /* "regshere" marker */115115116116+BEGIN_FTR_SECTION117117+ HMT_MEDIUM118118+END_FTR_SECTION_IFSET(CPU_FTR_HAS_PPR)119119+116120 /*117121 * RECONCILE_IRQ_STATE without calling trace_hardirqs_off(), which118122 * would clobber syscall parameters. Also we always enter with IRQs
+9-3
arch/powerpc/kernel/process.c
···548548 * are live for the user thread).549549 */550550 if ((!(msr & MSR_FP)) && should_restore_fp())551551- new_msr |= MSR_FP | current->thread.fpexc_mode;551551+ new_msr |= MSR_FP;552552553553 if ((!(msr & MSR_VEC)) && should_restore_altivec())554554 new_msr |= MSR_VEC;···559559 }560560561561 if (new_msr) {562562+ unsigned long fpexc_mode = 0;563563+562564 msr_check_and_set(new_msr);563565564564- if (new_msr & MSR_FP)566566+ if (new_msr & MSR_FP) {565567 do_restore_fp();568568+569569+ // This also covers VSX, because VSX implies FP570570+ fpexc_mode = current->thread.fpexc_mode;571571+ }566572567573 if (new_msr & MSR_VEC)568574 do_restore_altivec();···578572579573 msr_check_and_clear(new_msr);580574581581- regs->msr |= new_msr;575575+ regs->msr |= new_msr | fpexc_mode;582576 }583577}584578#endif
···232232 rflags |= HPTE_R_I;233233 else if ((pteflags & _PAGE_CACHE_CTL) == _PAGE_NON_IDEMPOTENT)234234 rflags |= (HPTE_R_I | HPTE_R_G);235235+ else if ((pteflags & _PAGE_CACHE_CTL) == _PAGE_SAO)236236+ rflags |= (HPTE_R_W | HPTE_R_I | HPTE_R_M);235237 else236238 /*237239 * Add memory coherence if cache inhibited is not set
-15
arch/powerpc/mm/book3s64/radix_pgtable.c
···734734 }735735}736736737737-void radix__setup_initial_memory_limit(phys_addr_t first_memblock_base,738738- phys_addr_t first_memblock_size)739739-{740740- /*741741- * We don't currently support the first MEMBLOCK not mapping 0742742- * physical on those processors743743- */744744- BUG_ON(first_memblock_base != 0);745745-746746- /*747747- * Radix mode is not limited by RMA / VRMA addressing.748748- */749749- ppc64_rma_size = ULONG_MAX;750750-}751751-752737#ifdef CONFIG_MEMORY_HOTPLUG753738static void free_pte_table(pte_t *pte_start, pmd_t *pmd)754739{
+9-2
arch/powerpc/mm/init_64.c
···452452 if (!(mfmsr() & MSR_HV))453453 early_check_vec5();454454455455- if (early_radix_enabled())455455+ if (early_radix_enabled()) {456456 radix__early_init_devtree();457457- else457457+ /*458458+ * We have finalized the translation we are going to use by now.459459+ * Radix mode is not limited by RMA / VRMA addressing.460460+ * Hence don't limit memblock allocations.461461+ */462462+ ppc64_rma_size = ULONG_MAX;463463+ memblock_set_current_limit(MEMBLOCK_ALLOC_ANYWHERE);464464+ } else458465 hash__early_init_devtree();459466}460467#endif /* CONFIG_PPC_BOOK3S_64 */
+14-5
arch/powerpc/perf/core-book3s.c
···15571557 ret = 0;15581558 out:15591559 if (has_branch_stack(event)) {15601560- power_pmu_bhrb_enable(event);15611561- cpuhw->bhrb_filter = ppmu->bhrb_filter_map(15621562- event->attr.branch_sample_type);15601560+ u64 bhrb_filter = -1;15611561+15621562+ if (ppmu->bhrb_filter_map)15631563+ bhrb_filter = ppmu->bhrb_filter_map(15641564+ event->attr.branch_sample_type);15651565+15661566+ if (bhrb_filter != -1) {15671567+ cpuhw->bhrb_filter = bhrb_filter;15681568+ power_pmu_bhrb_enable(event);15691569+ }15631570 }1564157115651572 perf_pmu_enable(event->pmu);···18881881 int n;18891882 int err;18901883 struct cpu_hw_events *cpuhw;18911891- u64 bhrb_filter;1892188418931885 if (!ppmu)18941886 return -ENOENT;···19931987 err = power_check_constraints(cpuhw, events, cflags, n + 1);1994198819951989 if (has_branch_stack(event)) {19961996- bhrb_filter = ppmu->bhrb_filter_map(19901990+ u64 bhrb_filter = -1;19911991+19921992+ if (ppmu->bhrb_filter_map)19931993+ bhrb_filter = ppmu->bhrb_filter_map(19971994 event->attr.branch_sample_type);1998199519991996 if (bhrb_filter == -1) {
+2-2
arch/powerpc/perf/imc-pmu.c
···12891289 header->misc = 0;1290129012911291 if (cpu_has_feature(CPU_FTR_ARCH_31)) {12921292- switch (IMC_TRACE_RECORD_VAL_HVPR(mem->val)) {12921292+ switch (IMC_TRACE_RECORD_VAL_HVPR(be64_to_cpu(READ_ONCE(mem->val)))) {12931293 case 0:/* when MSR HV and PR not set in the trace-record */12941294 header->misc |= PERF_RECORD_MISC_GUEST_KERNEL;12951295 break;···12971297 header->misc |= PERF_RECORD_MISC_GUEST_USER;12981298 break;12991299 case 2: /* MSR HV is 1 and PR is 0 */13001300- header->misc |= PERF_RECORD_MISC_HYPERVISOR;13001300+ header->misc |= PERF_RECORD_MISC_KERNEL;13011301 break;13021302 case 3: /* MSR HV is 1 and PR is 1 */13031303 header->misc |= PERF_RECORD_MISC_USER;
···11+// SPDX-License-Identifier: GPL-2.0-only22+/*33+ * Copyright 2016, Michael Ellerman, IBM Corp.44+ */55+66+#include <stdio.h>77+#include <stdlib.h>88+#include <string.h>99+#include <sys/mman.h>1010+#include <unistd.h>1111+1212+#include <asm/cputable.h>1313+1414+#include "utils.h"1515+1616+#define SIZE (64 * 1024)1717+1818+int test_prot_sao(void)1919+{2020+ char *p;2121+2222+ /*2323+ * SAO was introduced in 2.06 and removed in 3.1. It's disabled in2424+ * guests/LPARs by default, so also skip if we are running in a guest.2525+ */2626+ SKIP_IF(!have_hwcap(PPC_FEATURE_ARCH_2_06) ||2727+ have_hwcap2(PPC_FEATURE2_ARCH_3_1) ||2828+ access("/proc/device-tree/rtas/ibm,hypertas-functions", F_OK) == 0);2929+3030+ /*3131+ * Ensure we can ask for PROT_SAO.3232+ * We can't really verify that it does the right thing, but at least we3333+ * confirm the kernel will accept it.3434+ */3535+ p = mmap(NULL, SIZE, PROT_READ | PROT_WRITE | PROT_SAO,3636+ MAP_ANONYMOUS | MAP_PRIVATE, -1, 0);3737+ FAIL_IF(p == MAP_FAILED);3838+3939+ /* Write to the mapping, to at least cause a fault */4040+ memset(p, 0xaa, SIZE);4141+4242+ return 0;4343+}4444+4545+int main(void)4646+{4747+ return test_harness(test_prot_sao, "prot-sao");4848+}