Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'powerpc-7.1-1' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux

Pull powerpc updates from Madhavan Srinivasan:

- powerpc support for huge pfnmaps

- Cleanups to use masked user access

- Rework pnv_ioda_pick_m64_pe() to use better bitmap API

- Convert powerpc to AUDIT_ARCH_COMPAT_GENERIC

- Backup region offset update to eflcorehdr

- Fixes for wii/ps3 platform

- Implement JIT support for private stack in powerpc

- Implement JIT support for fsession in powerpc64 trampoline

- Add support for instruction array and indirect jump in powerpc

- Misc selftest fixes and cleanups

Thanks to Abhishek Dubey, Aditya Gupta, Alex Williamson, Amit Machhiwal,
Andrew Donnellan, Bartosz Golaszewski, Cédric Le Goater, Chen Ni,
Christophe Leroy (CS GROUP), Hari Bathini, J. Neuschäfer, Mukesh Kumar
Chaurasiya (IBM), Nam Cao, Nilay Shroff, Pavithra Prakash, Randy Dunlap,
Ritesh Harjani (IBM), Shrikanth Hegde, Sourabh Jain, Vaibhav Jain,
Venkat Rao Bagalkote, and Yury Norov (NVIDIA)

* tag 'powerpc-7.1-1' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux: (47 commits)
mailmap: Add entry for Andrew Donnellan
powerpc32/bpf: fix loading fsession func metadata using PPC_LI32
selftest/bpf: Enable gotox tests for powerpc64
powerpc64/bpf: Add support for indirect jump
selftest/bpf: Enable instruction array test for powerpc
powerpc/bpf: Add support for instruction array
powerpc32/bpf: Add fsession support
powerpc64/bpf: Implement fsession support
selftests/bpf: Enable private stack tests for powerpc64
powerpc64/bpf: Implement JIT support for private stack
powerpc: pci-ioda: Optimize pnv_ioda_pick_m64_pe()
powerpc: pci-ioda: use bitmap_alloc() in pnv_ioda_pick_m64_pe()
powerpc/net: Inline checksum wrappers and convert to scoped user access
powerpc/sstep: Convert to scoped user access
powerpc/align: Convert emulate_spe() to scoped user access
powerpc/ptrace: Convert gpr32_set_common_user() to scoped user access
powerpc/futex: Use masked user access
powerpc/audit: Convert powerpc to AUDIT_ARCH_COMPAT_GENERIC
cpuidle: powerpc: avoid double clear when breaking snooze
powerpc/ps3: spu.c: fix enum and Return kernel-doc warnings
...

+688 -567
+3
.mailmap
··· 75 75 Andreas Hindborg <a.hindborg@kernel.org> <a.hindborg@samsung.com> 76 76 Andrej Shadura <andrew.shadura@collabora.co.uk> 77 77 Andrej Shadura <andrew@shadura.me> <andrew@beldisplaytech.com> 78 + Andrew Donnellan <andrew+kernel@donnellan.id.au> <andrew@donnellan.id.au> 79 + Andrew Donnellan <andrew+kernel@donnellan.id.au> <ajd@linux.ibm.com> 80 + Andrew Donnellan <andrew+kernel@donnellan.id.au> <andrew.donnellan@au1.ibm.com> 78 81 Andrew Morton <akpm@linux-foundation.org> 79 82 Andrew Murray <amurray@thegoodpenguin.co.uk> <amurray@embedded-bits.co.uk> 80 83 Andrew Murray <amurray@thegoodpenguin.co.uk> <andrew.murray@arm.com>
+2 -4
arch/powerpc/Kconfig
··· 172 172 select ARCH_STACKWALK 173 173 select ARCH_SUPPORTS_ATOMIC_RMW 174 174 select ARCH_SUPPORTS_DEBUG_PAGEALLOC if PPC_BOOK3S || PPC_8xx 175 + select ARCH_SUPPORTS_HUGE_PFNMAP if PPC_BOOK3S_64 && TRANSPARENT_HUGEPAGE 175 176 select ARCH_SUPPORTS_PAGE_TABLE_CHECK if !HUGETLB_PAGE 176 177 select ARCH_SUPPORTS_SCHED_MC if SMP 177 178 select ARCH_SUPPORTS_SCHED_SMT if PPC64 && SMP ··· 189 188 select ARCH_WANT_OPTIMIZE_DAX_VMEMMAP if PPC_RADIX_MMU 190 189 select ARCH_WANTS_MODULES_DATA_IN_VMALLOC if PPC_BOOK3S_32 || PPC_8xx 191 190 select ARCH_WEAK_RELEASE_ACQUIRE 191 + select AUDIT_ARCH_COMPAT_GENERIC 192 192 select BINFMT_ELF 193 193 select BUILDTIME_TABLE_SORT 194 194 select CLONE_BACKWARDS ··· 371 369 config GENERIC_TBSYNC 372 370 bool 373 371 default y if PPC32 && SMP 374 - 375 - config AUDIT_ARCH 376 - bool 377 - default y 378 372 379 373 config GENERIC_BUG 380 374 bool
+4 -4
arch/powerpc/boot/dts/wii.dts
··· 29 29 bootargs = "root=/dev/mmcblk0p2 rootwait udbg-immortal"; 30 30 }; 31 31 32 - memory { 32 + memory@0 { 33 33 device_type = "memory"; 34 34 reg = <0x00000000 0x01800000 /* MEM1 24MB 1T-SRAM */ 35 35 0x10000000 0x04000000>; /* MEM2 64MB GDDR3 */ ··· 246 246 compatible = "gpio-leds"; 247 247 248 248 /* This is the blue LED in the disk drive slot */ 249 - drive-slot { 249 + led-0 { 250 250 label = "wii:blue:drive_slot"; 251 251 gpios = <&GPIO 5 GPIO_ACTIVE_HIGH>; 252 252 panic-indicator; ··· 256 256 gpio-keys { 257 257 compatible = "gpio-keys"; 258 258 259 - power { 259 + button-power { 260 260 label = "Power Button"; 261 261 gpios = <&GPIO 0 GPIO_ACTIVE_HIGH>; 262 262 linux,code = <KEY_POWER>; 263 263 }; 264 264 265 - eject { 265 + button-eject { 266 266 label = "Eject Button"; 267 267 gpios = <&GPIO 6 GPIO_ACTIVE_HIGH>; 268 268 linux,code = <KEY_EJECTCD>;
+40 -3
arch/powerpc/include/asm/book3s/64/pgtable.h
··· 107 107 * in here, on radix we expect them to be zero. 108 108 */ 109 109 #define _HPAGE_CHG_MASK (PTE_RPN_MASK | _PAGE_HPTEFLAGS | _PAGE_DIRTY | \ 110 - _PAGE_ACCESSED | H_PAGE_THP_HUGE | _PAGE_PTE | \ 111 - _PAGE_SOFT_DIRTY) 110 + _PAGE_ACCESSED | H_PAGE_THP_HUGE | _PAGE_SPECIAL | \ 111 + _PAGE_PTE | _PAGE_SOFT_DIRTY) 112 112 /* 113 113 * user access blocked by key 114 114 */ ··· 1289 1289 return pud; 1290 1290 } 1291 1291 1292 + #ifdef CONFIG_ARCH_SUPPORTS_PMD_PFNMAP 1293 + static inline bool pmd_special(pmd_t pmd) 1294 + { 1295 + return pte_special(pmd_pte(pmd)); 1296 + } 1297 + 1298 + static inline pmd_t pmd_mkspecial(pmd_t pmd) 1299 + { 1300 + return pte_pmd(pte_mkspecial(pmd_pte(pmd))); 1301 + } 1302 + #endif 1303 + 1304 + #ifdef CONFIG_ARCH_SUPPORTS_PUD_PFNMAP 1305 + static inline bool pud_special(pud_t pud) 1306 + { 1307 + return pte_special(pud_pte(pud)); 1308 + } 1309 + 1310 + static inline pud_t pud_mkspecial(pud_t pud) 1311 + { 1312 + return pte_pud(pte_mkspecial(pud_pte(pud))); 1313 + } 1314 + #endif 1292 1315 1293 1316 #define __HAVE_ARCH_PMDP_SET_ACCESS_FLAGS 1294 1317 extern int pmdp_set_access_flags(struct vm_area_struct *vma, ··· 1336 1313 { 1337 1314 pmd_t old_pmd; 1338 1315 1316 + /* 1317 + * Non-present PMDs can be migration entries or device-private THP 1318 + * entries. This can happen at 2 places: 1319 + * - When the address space is being unmapped zap_huge_pmd(), and we 1320 + * encounter non-present pmds. 1321 + * - migrate_vma_collect_huge_pmd() could calls this during migration 1322 + * of device-private pmd entries. 1323 + */ 1324 + if (!pmd_present(*pmdp)) { 1325 + old_pmd = READ_ONCE(*pmdp); 1326 + pmd_clear(pmdp); 1327 + goto out; 1328 + } 1329 + 1339 1330 if (radix_enabled()) { 1340 1331 old_pmd = radix__pmdp_huge_get_and_clear(mm, addr, pmdp); 1341 1332 } else { 1342 1333 old_pmd = hash__pmdp_huge_get_and_clear(mm, addr, pmdp); 1343 1334 } 1344 1335 1336 + out: 1345 1337 page_table_check_pmd_clear(mm, addr, old_pmd); 1346 1338 1347 1339 return old_pmd; ··· 1438 1400 return false; 1439 1401 return true; 1440 1402 } 1441 - extern void serialize_against_pte_lookup(struct mm_struct *mm); 1442 1403 1443 1404 #endif /* CONFIG_TRANSPARENT_HUGEPAGE */ 1444 1405
-1
arch/powerpc/include/asm/book3s/64/tlbflush-radix.h
··· 92 92 #define radix__flush_tlb_page(vma,addr) radix__local_flush_tlb_page(vma,addr) 93 93 #define radix__flush_tlb_page_psize(mm,addr,p) radix__local_flush_tlb_page_psize(mm,addr,p) 94 94 #endif 95 - extern void radix__flush_tlb_pwc(struct mmu_gather *tlb, unsigned long addr); 96 95 extern void radix__flush_tlb_collapsed_pmd(struct mm_struct *mm, unsigned long addr); 97 96 extern void radix__flush_tlb_all(void); 98 97
+18 -4
arch/powerpc/include/asm/checksum.h
··· 8 8 9 9 #include <linux/bitops.h> 10 10 #include <linux/in6.h> 11 + #include <linux/uaccess.h> 11 12 /* 12 13 * Computes the checksum of a memory block at src, length len, 13 14 * and adds in "sum" (32-bit), while copying the block to dst. ··· 22 21 extern __wsum csum_partial_copy_generic(const void *src, void *dst, int len); 23 22 24 23 #define _HAVE_ARCH_COPY_AND_CSUM_FROM_USER 25 - extern __wsum csum_and_copy_from_user(const void __user *src, void *dst, 26 - int len); 24 + static inline __wsum csum_and_copy_from_user(const void __user *src, void *dst, int len) 25 + { 26 + scoped_user_read_access_size(src, len, efault) 27 + return csum_partial_copy_generic((void __force *)src, dst, len); 28 + 29 + efault: 30 + return 0; 31 + } 32 + 27 33 #define HAVE_CSUM_COPY_USER 28 - extern __wsum csum_and_copy_to_user(const void *src, void __user *dst, 29 - int len); 34 + static inline __wsum csum_and_copy_to_user(const void *src, void __user *dst, int len) 35 + { 36 + scoped_user_write_access_size(dst, len, efault) 37 + return csum_partial_copy_generic(src, (void __force *)dst, len); 38 + 39 + efault: 40 + return 0; 41 + } 30 42 31 43 #define _HAVE_ARCH_CSUM_AND_COPY 32 44 #define csum_partial_copy_nocheck(src, dst, len) \
+2 -4
arch/powerpc/include/asm/futex.h
··· 33 33 { 34 34 int oldval = 0, ret; 35 35 36 - if (!user_access_begin(uaddr, sizeof(u32))) 37 - return -EFAULT; 36 + uaddr = masked_user_access_begin(uaddr); 38 37 39 38 switch (op) { 40 39 case FUTEX_OP_SET: ··· 68 69 int ret = 0; 69 70 u32 prev; 70 71 71 - if (!user_access_begin(uaddr, sizeof(u32))) 72 - return -EFAULT; 72 + uaddr = masked_user_access_begin(uaddr); 73 73 74 74 __asm__ __volatile__ ( 75 75 PPC_ATOMIC_ENTRY_BARRIER
+11 -3
arch/powerpc/include/asm/kexec.h
··· 66 66 unsigned long start_address) __noreturn; 67 67 void kexec_copy_flush(struct kimage *image); 68 68 69 - #ifdef CONFIG_KEXEC_FILE 70 - extern const struct kexec_file_ops kexec_elf64_ops; 71 69 70 + #if defined(CONFIG_KEXEC_FILE) || defined(CONFIG_CRASH_DUMP) 72 71 #define ARCH_HAS_KIMAGE_ARCH 73 - 74 72 struct kimage_arch { 75 73 struct crash_mem *exclude_ranges; 76 74 ··· 76 78 void *backup_buf; 77 79 void *fdt; 78 80 }; 81 + #endif 82 + 83 + #ifdef CONFIG_KEXEC_FILE 84 + extern const struct kexec_file_ops kexec_elf64_ops; 79 85 80 86 char *setup_kdump_cmdline(struct kimage *image, char *cmdline, 81 87 unsigned long cmdline_len); ··· 147 145 148 146 unsigned int arch_crash_get_elfcorehdr_size(void); 149 147 #define crash_get_elfcorehdr_size arch_crash_get_elfcorehdr_size 148 + 149 + int machine_kexec_post_load(struct kimage *image); 150 + #define machine_kexec_post_load machine_kexec_post_load 151 + 150 152 #endif /* CONFIG_CRASH_HOTPLUG */ 151 153 152 154 extern int crashing_cpu; ··· 165 159 extern void crash_kexec_prepare(void); 166 160 extern void crash_kexec_secondary(struct pt_regs *regs); 167 161 162 + extern void sync_backup_region_phdr(struct kimage *image, Elf64_Ehdr *ehdr, 163 + bool phdr_to_kimage); 168 164 static inline bool kdump_in_progress(void) 169 165 { 170 166 return crashing_cpu >= 0;
+14
arch/powerpc/include/asm/pgtable.h
··· 63 63 return __pgprot(pte_flags); 64 64 } 65 65 66 + #ifdef CONFIG_PPC64 67 + #define pmd_pgprot pmd_pgprot 68 + static inline pgprot_t pmd_pgprot(pmd_t pmd) 69 + { 70 + return pte_pgprot(pmd_pte(pmd)); 71 + } 72 + 73 + #define pud_pgprot pud_pgprot 74 + static inline pgprot_t pud_pgprot(pud_t pud) 75 + { 76 + return pte_pgprot(pud_pte(pud)); 77 + } 78 + #endif /* CONFIG_PPC64 */ 79 + 66 80 static inline pgprot_t pgprot_nx(pgprot_t prot) 67 81 { 68 82 return pte_pgprot(pte_exprotect(__pte(pgprot_val(prot))));
+9 -6
arch/powerpc/include/asm/ps3.h
··· 65 65 66 66 /** 67 67 * struct ps3_dma_region - A per device dma state variables structure 68 + * @dev: device structure 68 69 * @did: The HV device id. 69 70 * @page_size: The ioc pagesize. 70 71 * @region_type: The HV region type. ··· 109 108 dma_addr_t bus_addr, 110 109 unsigned long len); 111 110 }; 111 + 112 + struct ps3_system_bus_device; 113 + 112 114 /** 113 115 * struct ps3_dma_region_init - Helper to initialize structure variables 114 116 * 115 117 * Helper to properly initialize variables prior to calling 116 118 * ps3_system_bus_device_register. 117 119 */ 118 - 119 - struct ps3_system_bus_device; 120 - 121 120 int ps3_dma_region_init(struct ps3_system_bus_device *dev, 122 121 struct ps3_dma_region *r, enum ps3_dma_page_size page_size, 123 122 enum ps3_dma_region_type region_type, void *addr, unsigned long len); ··· 157 156 int (*free)(struct ps3_mmio_region *); 158 157 }; 159 158 /** 160 - * struct ps3_mmio_region_init - Helper to initialize structure variables 159 + * ps3_mmio_region_init - Helper to initialize structure variables 161 160 * 162 161 * Helper to properly initialize variables prior to calling 163 162 * ps3_system_bus_device_register. 163 + * 164 + * Returns: %0 on success, %-errno on error (or BUG()) 164 165 */ 165 166 166 167 int ps3_mmio_region_init(struct ps3_system_bus_device *dev, ··· 408 405 } 409 406 410 407 /** 411 - * ps3_system_bus_set_drvdata - 408 + * ps3_system_bus_set_drvdata - set driver's private data for this device 412 409 * @dev: device structure 413 410 * @data: Data to set 414 411 */ ··· 467 464 * enum ps3_lpm_tb_type - Type of trace buffer lv1 should use. 468 465 * 469 466 * @PS3_LPM_TB_TYPE_NONE: Do not use a trace buffer. 470 - * @PS3_LPM_RIGHTS_USE_TB: Use the lv1 internal trace buffer. Must have 467 + * @PS3_LPM_TB_TYPE_INTERNAL: Use the lv1 internal trace buffer. Must have 471 468 * rights @PS3_LPM_RIGHTS_USE_TB. 472 469 */ 473 470
+7
arch/powerpc/include/asm/unistd32.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0-or-later */ 2 + #ifndef _ASM_POWERPC_UNISTD32_H_ 3 + #define _ASM_POWERPC_UNISTD32_H_ 4 + 5 + #include <asm/unistd_32.h> 6 + 7 + #endif /* _ASM_POWERPC_UNISTD32_H_ */
-3
arch/powerpc/kernel/Makefile
··· 149 149 pci-common.o pci_of_scan.o 150 150 obj-$(CONFIG_PCI_MSI) += msi.o 151 151 152 - obj-$(CONFIG_AUDIT) += audit.o 153 - obj64-$(CONFIG_AUDIT) += compat_audit.o 154 - 155 152 obj-y += trace/ 156 153 157 154 ifneq ($(CONFIG_PPC_INDIRECT_PIO),y)
+33 -42
arch/powerpc/kernel/align.c
··· 165 165 temp.ll = data.ll = 0; 166 166 p = addr; 167 167 168 - if (!user_read_access_begin(addr, nb)) 169 - return -EFAULT; 170 - 171 - switch (nb) { 172 - case 8: 173 - unsafe_get_user(temp.v[0], p++, Efault_read); 174 - unsafe_get_user(temp.v[1], p++, Efault_read); 175 - unsafe_get_user(temp.v[2], p++, Efault_read); 176 - unsafe_get_user(temp.v[3], p++, Efault_read); 177 - fallthrough; 178 - case 4: 179 - unsafe_get_user(temp.v[4], p++, Efault_read); 180 - unsafe_get_user(temp.v[5], p++, Efault_read); 181 - fallthrough; 182 - case 2: 183 - unsafe_get_user(temp.v[6], p++, Efault_read); 184 - unsafe_get_user(temp.v[7], p++, Efault_read); 168 + scoped_user_read_access_size(addr, nb, efault) { 169 + switch (nb) { 170 + case 8: 171 + unsafe_get_user(temp.v[0], p++, efault); 172 + unsafe_get_user(temp.v[1], p++, efault); 173 + unsafe_get_user(temp.v[2], p++, efault); 174 + unsafe_get_user(temp.v[3], p++, efault); 175 + fallthrough; 176 + case 4: 177 + unsafe_get_user(temp.v[4], p++, efault); 178 + unsafe_get_user(temp.v[5], p++, efault); 179 + fallthrough; 180 + case 2: 181 + unsafe_get_user(temp.v[6], p++, efault); 182 + unsafe_get_user(temp.v[7], p++, efault); 183 + } 185 184 } 186 - user_read_access_end(); 187 185 188 186 switch (instr) { 189 187 case EVLDD: ··· 250 252 if (flags & ST) { 251 253 p = addr; 252 254 253 - if (!user_write_access_begin(addr, nb)) 254 - return -EFAULT; 255 - 256 - switch (nb) { 257 - case 8: 258 - unsafe_put_user(data.v[0], p++, Efault_write); 259 - unsafe_put_user(data.v[1], p++, Efault_write); 260 - unsafe_put_user(data.v[2], p++, Efault_write); 261 - unsafe_put_user(data.v[3], p++, Efault_write); 262 - fallthrough; 263 - case 4: 264 - unsafe_put_user(data.v[4], p++, Efault_write); 265 - unsafe_put_user(data.v[5], p++, Efault_write); 266 - fallthrough; 267 - case 2: 268 - unsafe_put_user(data.v[6], p++, Efault_write); 269 - unsafe_put_user(data.v[7], p++, Efault_write); 255 + scoped_user_write_access_size(addr, nb, efault) { 256 + switch (nb) { 257 + case 8: 258 + unsafe_put_user(data.v[0], p++, efault); 259 + unsafe_put_user(data.v[1], p++, efault); 260 + unsafe_put_user(data.v[2], p++, efault); 261 + unsafe_put_user(data.v[3], p++, efault); 262 + fallthrough; 263 + case 4: 264 + unsafe_put_user(data.v[4], p++, efault); 265 + unsafe_put_user(data.v[5], p++, efault); 266 + fallthrough; 267 + case 2: 268 + unsafe_put_user(data.v[6], p++, efault); 269 + unsafe_put_user(data.v[7], p++, efault); 270 + } 270 271 } 271 - user_write_access_end(); 272 272 } else { 273 273 *evr = data.w[0]; 274 274 regs->gpr[reg] = data.w[1]; ··· 274 278 275 279 return 1; 276 280 277 - Efault_read: 278 - user_read_access_end(); 279 - return -EFAULT; 280 - 281 - Efault_write: 282 - user_write_access_end(); 281 + efault: 283 282 return -EFAULT; 284 283 } 285 284 #endif /* CONFIG_SPE */
-87
arch/powerpc/kernel/audit.c
··· 1 - // SPDX-License-Identifier: GPL-2.0 2 - #include <linux/init.h> 3 - #include <linux/types.h> 4 - #include <linux/audit.h> 5 - #include <asm/unistd.h> 6 - 7 - #include "audit_32.h" 8 - 9 - static unsigned dir_class[] = { 10 - #include <asm-generic/audit_dir_write.h> 11 - ~0U 12 - }; 13 - 14 - static unsigned read_class[] = { 15 - #include <asm-generic/audit_read.h> 16 - ~0U 17 - }; 18 - 19 - static unsigned write_class[] = { 20 - #include <asm-generic/audit_write.h> 21 - ~0U 22 - }; 23 - 24 - static unsigned chattr_class[] = { 25 - #include <asm-generic/audit_change_attr.h> 26 - ~0U 27 - }; 28 - 29 - static unsigned signal_class[] = { 30 - #include <asm-generic/audit_signal.h> 31 - ~0U 32 - }; 33 - 34 - int audit_classify_arch(int arch) 35 - { 36 - #ifdef CONFIG_PPC64 37 - if (arch == AUDIT_ARCH_PPC) 38 - return 1; 39 - #endif 40 - return 0; 41 - } 42 - 43 - int audit_classify_syscall(int abi, unsigned syscall) 44 - { 45 - #ifdef CONFIG_PPC64 46 - if (abi == AUDIT_ARCH_PPC) 47 - return ppc32_classify_syscall(syscall); 48 - #endif 49 - switch(syscall) { 50 - case __NR_open: 51 - return AUDITSC_OPEN; 52 - case __NR_openat: 53 - return AUDITSC_OPENAT; 54 - case __NR_socketcall: 55 - return AUDITSC_SOCKETCALL; 56 - case __NR_execve: 57 - return AUDITSC_EXECVE; 58 - case __NR_openat2: 59 - return AUDITSC_OPENAT2; 60 - default: 61 - return AUDITSC_NATIVE; 62 - } 63 - } 64 - 65 - static int __init audit_classes_init(void) 66 - { 67 - #ifdef CONFIG_PPC64 68 - extern __u32 ppc32_dir_class[]; 69 - extern __u32 ppc32_write_class[]; 70 - extern __u32 ppc32_read_class[]; 71 - extern __u32 ppc32_chattr_class[]; 72 - extern __u32 ppc32_signal_class[]; 73 - audit_register_class(AUDIT_CLASS_WRITE_32, ppc32_write_class); 74 - audit_register_class(AUDIT_CLASS_READ_32, ppc32_read_class); 75 - audit_register_class(AUDIT_CLASS_DIR_WRITE_32, ppc32_dir_class); 76 - audit_register_class(AUDIT_CLASS_CHATTR_32, ppc32_chattr_class); 77 - audit_register_class(AUDIT_CLASS_SIGNAL_32, ppc32_signal_class); 78 - #endif 79 - audit_register_class(AUDIT_CLASS_WRITE, write_class); 80 - audit_register_class(AUDIT_CLASS_READ, read_class); 81 - audit_register_class(AUDIT_CLASS_DIR_WRITE, dir_class); 82 - audit_register_class(AUDIT_CLASS_CHATTR, chattr_class); 83 - audit_register_class(AUDIT_CLASS_SIGNAL, signal_class); 84 - return 0; 85 - } 86 - 87 - __initcall(audit_classes_init);
-48
arch/powerpc/kernel/compat_audit.c
··· 1 - // SPDX-License-Identifier: GPL-2.0 2 - #include <linux/audit_arch.h> 3 - #include <asm/unistd_32.h> 4 - 5 - #include "audit_32.h" 6 - 7 - unsigned ppc32_dir_class[] = { 8 - #include <asm-generic/audit_dir_write.h> 9 - ~0U 10 - }; 11 - 12 - unsigned ppc32_chattr_class[] = { 13 - #include <asm-generic/audit_change_attr.h> 14 - ~0U 15 - }; 16 - 17 - unsigned ppc32_write_class[] = { 18 - #include <asm-generic/audit_write.h> 19 - ~0U 20 - }; 21 - 22 - unsigned ppc32_read_class[] = { 23 - #include <asm-generic/audit_read.h> 24 - ~0U 25 - }; 26 - 27 - unsigned ppc32_signal_class[] = { 28 - #include <asm-generic/audit_signal.h> 29 - ~0U 30 - }; 31 - 32 - int ppc32_classify_syscall(unsigned syscall) 33 - { 34 - switch(syscall) { 35 - case __NR_open: 36 - return AUDITSC_OPEN; 37 - case __NR_openat: 38 - return AUDITSC_OPENAT; 39 - case __NR_socketcall: 40 - return AUDITSC_SOCKETCALL; 41 - case __NR_execve: 42 - return AUDITSC_EXECVE; 43 - case __NR_openat2: 44 - return AUDITSC_OPENAT2; 45 - default: 46 - return AUDITSC_COMPAT; 47 - } 48 - }
+2 -1
arch/powerpc/kernel/kgdb.c
··· 101 101 } 102 102 103 103 /** 104 - * 105 104 * kgdb_skipexception - Bail out of KGDB when we've been triggered. 106 105 * @exception: Exception vector number 107 106 * @regs: Current &struct pt_regs. ··· 108 109 * On some architectures we need to skip a breakpoint exception when 109 110 * it occurs after a breakpoint has been removed. 110 111 * 112 + * Return: return %1 if the breakpoint for this address has been removed, 113 + * otherwise return %0 111 114 */ 112 115 int kgdb_skipexception(int exception, struct pt_regs *regs) 113 116 {
+29 -31
arch/powerpc/kernel/ptrace/ptrace-view.c
··· 758 758 const void *kbuf = NULL; 759 759 compat_ulong_t reg; 760 760 761 - if (!user_read_access_begin(u, count)) 762 - return -EFAULT; 761 + scoped_user_read_access_size(ubuf, count, efault) { 762 + u = ubuf; 763 + pos /= sizeof(reg); 764 + count /= sizeof(reg); 763 765 764 - pos /= sizeof(reg); 765 - count /= sizeof(reg); 766 + for (; count > 0 && pos < PT_MSR; --count) { 767 + unsafe_get_user(reg, u++, efault); 768 + regs[pos++] = reg; 769 + } 766 770 767 - for (; count > 0 && pos < PT_MSR; --count) { 768 - unsafe_get_user(reg, u++, Efault); 769 - regs[pos++] = reg; 771 + if (count > 0 && pos == PT_MSR) { 772 + unsafe_get_user(reg, u++, efault); 773 + set_user_msr(target, reg); 774 + ++pos; 775 + --count; 776 + } 777 + 778 + for (; count > 0 && pos <= PT_MAX_PUT_REG; --count) { 779 + unsafe_get_user(reg, u++, efault); 780 + regs[pos++] = reg; 781 + } 782 + for (; count > 0 && pos < PT_TRAP; --count, ++pos) 783 + unsafe_get_user(reg, u++, efault); 784 + 785 + if (count > 0 && pos == PT_TRAP) { 786 + unsafe_get_user(reg, u++, efault); 787 + set_user_trap(target, reg); 788 + ++pos; 789 + --count; 790 + } 770 791 } 771 - 772 - if (count > 0 && pos == PT_MSR) { 773 - unsafe_get_user(reg, u++, Efault); 774 - set_user_msr(target, reg); 775 - ++pos; 776 - --count; 777 - } 778 - 779 - for (; count > 0 && pos <= PT_MAX_PUT_REG; --count) { 780 - unsafe_get_user(reg, u++, Efault); 781 - regs[pos++] = reg; 782 - } 783 - for (; count > 0 && pos < PT_TRAP; --count, ++pos) 784 - unsafe_get_user(reg, u++, Efault); 785 - 786 - if (count > 0 && pos == PT_TRAP) { 787 - unsafe_get_user(reg, u++, Efault); 788 - set_user_trap(target, reg); 789 - ++pos; 790 - --count; 791 - } 792 - user_read_access_end(); 793 792 794 793 ubuf = u; 795 794 pos *= sizeof(reg); ··· 797 798 (PT_TRAP + 1) * sizeof(reg), -1); 798 799 return 0; 799 800 800 - Efault: 801 - user_read_access_end(); 801 + efault: 802 802 return -EFAULT; 803 803 } 804 804
+4
arch/powerpc/kernel/setup-common.c
··· 865 865 cur_cpu_spec->cpu_user_features, 866 866 cur_cpu_spec->cpu_user_features2); 867 867 pr_info("mmu_features = 0x%08x\n", cur_cpu_spec->mmu_features); 868 + pr_info(" possible = 0x%016lx\n", 869 + (unsigned long)MMU_FTRS_POSSIBLE); 870 + pr_info(" always = 0x%016lx\n", 871 + (unsigned long)MMU_FTRS_ALWAYS); 868 872 #ifdef CONFIG_PPC64 869 873 pr_info("firmware_features = 0x%016lx\n", powerpc_firmware_features); 870 874 #ifdef CONFIG_PPC_BOOK3S
+64
arch/powerpc/kexec/crash.c
··· 27 27 #include <asm/debug.h> 28 28 #include <asm/interrupt.h> 29 29 #include <asm/kexec_ranges.h> 30 + #include <asm/crashdump-ppc64.h> 30 31 31 32 /* 32 33 * The primary CPU waits a while for all secondary CPUs to enter. This is to ··· 400 399 ppc_md.kexec_cpu_down(1, 0); 401 400 } 402 401 402 + #ifdef CONFIG_CRASH_DUMP 403 + /** 404 + * sync_backup_region_phdr - synchronize backup region offset between 405 + * kexec image and ELF core header. 406 + * @image: Kexec image. 407 + * @ehdr: ELF core header. 408 + * @phdr_to_kimage: If true, read the offset from the ELF program header 409 + * and update the kimage backup region. If false, update 410 + * the ELF program header offset from the kimage backup 411 + * region. 412 + * 413 + * Note: During kexec_load, this is called with phdr_to_kimage = true. For 414 + * kexec_file_load and ELF core header recreation during memory hotplug 415 + * events, it is called with phdr_to_kimage = false. 416 + * 417 + * Returns nothing. 418 + */ 419 + void sync_backup_region_phdr(struct kimage *image, Elf64_Ehdr *ehdr, bool phdr_to_kimage) 420 + { 421 + Elf64_Phdr *phdr; 422 + unsigned int i; 423 + 424 + phdr = (Elf64_Phdr *)(ehdr + 1); 425 + for (i = 0; i < ehdr->e_phnum; i++, phdr++) { 426 + if (phdr->p_paddr == BACKUP_SRC_START) { 427 + if (phdr_to_kimage) 428 + image->arch.backup_start = phdr->p_offset; 429 + else 430 + phdr->p_offset = image->arch.backup_start; 431 + 432 + kexec_dprintk("Backup region offset updated to 0x%lx\n", 433 + image->arch.backup_start); 434 + return; 435 + } 436 + } 437 + } 438 + #endif /* CONFIG_CRASH_DUMP */ 439 + 403 440 #ifdef CONFIG_CRASH_HOTPLUG 441 + 442 + int machine_kexec_post_load(struct kimage *image) 443 + { 444 + int i; 445 + unsigned long mem; 446 + unsigned char *ptr; 447 + 448 + if (image->type != KEXEC_TYPE_CRASH) 449 + return 0; 450 + 451 + if (image->file_mode) 452 + return 0; 453 + 454 + for (i = 0; i < image->nr_segments; i++) { 455 + mem = image->segment[i].mem; 456 + ptr = (char *)__va(mem); 457 + 458 + if (ptr && memcmp(ptr, ELFMAG, SELFMAG) == 0) 459 + sync_backup_region_phdr(image, (Elf64_Ehdr *) ptr, true); 460 + } 461 + return 0; 462 + } 463 + 404 464 #undef pr_fmt 405 465 #define pr_fmt(fmt) "crash hp: " fmt 406 466 ··· 535 473 pr_err("Updated crash elfcorehdr elfsz %lu > memsz %lu", elfsz, memsz); 536 474 goto out; 537 475 } 476 + 477 + sync_backup_region_phdr(image, (Elf64_Ehdr *) elfbuf, false); 538 478 539 479 ptr = __va(mem); 540 480 if (ptr) {
+1 -28
arch/powerpc/kexec/file_load_64.c
··· 374 374 return 0; 375 375 } 376 376 377 - /** 378 - * update_backup_region_phdr - Update backup region's offset for the core to 379 - * export the region appropriately. 380 - * @image: Kexec image. 381 - * @ehdr: ELF core header. 382 - * 383 - * Assumes an exclusive program header is setup for the backup region 384 - * in the ELF headers 385 - * 386 - * Returns nothing. 387 - */ 388 - static void update_backup_region_phdr(struct kimage *image, Elf64_Ehdr *ehdr) 389 - { 390 - Elf64_Phdr *phdr; 391 - unsigned int i; 392 - 393 - phdr = (Elf64_Phdr *)(ehdr + 1); 394 - for (i = 0; i < ehdr->e_phnum; i++) { 395 - if (phdr->p_paddr == BACKUP_SRC_START) { 396 - phdr->p_offset = image->arch.backup_start; 397 - kexec_dprintk("Backup region offset updated to 0x%lx\n", 398 - image->arch.backup_start); 399 - return; 400 - } 401 - } 402 - } 403 - 404 377 static unsigned int kdump_extra_elfcorehdr_size(struct crash_mem *cmem) 405 378 { 406 379 #if defined(CONFIG_CRASH_HOTPLUG) && defined(CONFIG_MEMORY_HOTPLUG) ··· 418 445 } 419 446 420 447 /* Fix the offset for backup region in the ELF header */ 421 - update_backup_region_phdr(image, headers); 448 + sync_backup_region_phdr(image, headers, false); 422 449 423 450 kbuf->buffer = headers; 424 451 kbuf->mem = KEXEC_BUF_MEM_UNKNOWN;
+1 -2
arch/powerpc/lib/Makefile
··· 62 62 obj64-$(CONFIG_KPROBES_SANITY_TEST) += test_emulate_step.o \ 63 63 test_emulate_step_exec_instr.o 64 64 65 - obj-y += checksum_$(BITS).o checksum_wrappers.o \ 66 - string_$(BITS).o 65 + obj-y += checksum_$(BITS).o string_$(BITS).o 67 66 68 67 obj-y += sstep.o 69 68 obj-$(CONFIG_PPC_FPU) += ldstfp.o
-39
arch/powerpc/lib/checksum_wrappers.c
··· 1 - // SPDX-License-Identifier: GPL-2.0-or-later 2 - /* 3 - * 4 - * Copyright (C) IBM Corporation, 2010 5 - * 6 - * Author: Anton Blanchard <anton@au.ibm.com> 7 - */ 8 - #include <linux/export.h> 9 - #include <linux/compiler.h> 10 - #include <linux/types.h> 11 - #include <asm/checksum.h> 12 - #include <linux/uaccess.h> 13 - 14 - __wsum csum_and_copy_from_user(const void __user *src, void *dst, 15 - int len) 16 - { 17 - __wsum csum; 18 - 19 - if (unlikely(!user_read_access_begin(src, len))) 20 - return 0; 21 - 22 - csum = csum_partial_copy_generic((void __force *)src, dst, len); 23 - 24 - user_read_access_end(); 25 - return csum; 26 - } 27 - 28 - __wsum csum_and_copy_to_user(const void *src, void __user *dst, int len) 29 - { 30 - __wsum csum; 31 - 32 - if (unlikely(!user_write_access_begin(dst, len))) 33 - return 0; 34 - 35 - csum = csum_partial_copy_generic(src, (void __force *)dst, len); 36 - 37 - user_write_access_end(); 38 - return csum; 39 - }
+33 -44
arch/powerpc/lib/sstep.c
··· 329 329 static nokprobe_inline int 330 330 read_mem_aligned(unsigned long *dest, unsigned long ea, int nb, struct pt_regs *regs) 331 331 { 332 - int err; 332 + void __user *uea = (void __user *)ea; 333 333 334 334 if (is_kernel_addr(ea)) 335 335 return __read_mem_aligned(dest, ea, nb, regs); 336 336 337 - if (user_read_access_begin((void __user *)ea, nb)) { 338 - err = __read_mem_aligned(dest, ea, nb, regs); 339 - user_read_access_end(); 340 - } else { 341 - err = -EFAULT; 342 - regs->dar = ea; 343 - } 337 + scoped_user_read_access_size(uea, nb, efault) 338 + return __read_mem_aligned(dest, (unsigned long)uea, nb, regs); 344 339 345 - return err; 340 + efault: 341 + regs->dar = ea; 342 + return -EFAULT; 346 343 } 347 344 348 345 /* ··· 382 385 383 386 static nokprobe_inline int copy_mem_in(u8 *dest, unsigned long ea, int nb, struct pt_regs *regs) 384 387 { 385 - int err; 388 + void __user *uea = (void __user *)ea; 386 389 387 390 if (is_kernel_addr(ea)) 388 391 return __copy_mem_in(dest, ea, nb, regs); 389 392 390 - if (user_read_access_begin((void __user *)ea, nb)) { 391 - err = __copy_mem_in(dest, ea, nb, regs); 392 - user_read_access_end(); 393 - } else { 394 - err = -EFAULT; 395 - regs->dar = ea; 396 - } 393 + scoped_user_read_access_size(uea, nb, efault) 394 + return __copy_mem_in(dest, (unsigned long)uea, nb, regs); 397 395 398 - return err; 396 + efault: 397 + regs->dar = ea; 398 + return -EFAULT; 399 399 } 400 400 401 401 static nokprobe_inline int read_mem_unaligned(unsigned long *dest, ··· 459 465 static nokprobe_inline int 460 466 write_mem_aligned(unsigned long val, unsigned long ea, int nb, struct pt_regs *regs) 461 467 { 462 - int err; 468 + void __user *uea = (void __user *)ea; 463 469 464 470 if (is_kernel_addr(ea)) 465 471 return __write_mem_aligned(val, ea, nb, regs); 466 472 467 - if (user_write_access_begin((void __user *)ea, nb)) { 468 - err = __write_mem_aligned(val, ea, nb, regs); 469 - user_write_access_end(); 470 - } else { 471 - err = -EFAULT; 472 - regs->dar = ea; 473 - } 473 + scoped_user_write_access_size(uea, nb, efault) 474 + return __write_mem_aligned(val, (unsigned long)uea, nb, regs); 474 475 475 - return err; 476 + efault: 477 + regs->dar = ea; 478 + return -EFAULT; 476 479 } 477 480 478 481 /* ··· 512 521 513 522 static nokprobe_inline int copy_mem_out(u8 *dest, unsigned long ea, int nb, struct pt_regs *regs) 514 523 { 515 - int err; 524 + void __user *uea = (void __user *)ea; 516 525 517 526 if (is_kernel_addr(ea)) 518 527 return __copy_mem_out(dest, ea, nb, regs); 519 528 520 - if (user_write_access_begin((void __user *)ea, nb)) { 521 - err = __copy_mem_out(dest, ea, nb, regs); 522 - user_write_access_end(); 523 - } else { 524 - err = -EFAULT; 525 - regs->dar = ea; 526 - } 529 + scoped_user_write_access_size(uea, nb, efault) 530 + return __copy_mem_out(dest, (unsigned long)uea, nb, regs); 527 531 528 - return err; 532 + efault: 533 + regs->dar = ea; 534 + return -EFAULT; 529 535 } 530 536 531 537 static nokprobe_inline int write_mem_unaligned(unsigned long val, ··· 1053 1065 1054 1066 int emulate_dcbz(unsigned long ea, struct pt_regs *regs) 1055 1067 { 1068 + void __user *uea = (void __user *)ea; 1056 1069 int err; 1057 1070 unsigned long size = l1_dcache_bytes(); 1058 1071 ··· 1062 1073 if (!address_ok(regs, ea, size)) 1063 1074 return -EFAULT; 1064 1075 1065 - if (is_kernel_addr(ea)) { 1076 + if (is_kernel_addr(ea)) 1066 1077 err = __emulate_dcbz(ea); 1067 - } else if (user_write_access_begin((void __user *)ea, size)) { 1068 - err = __emulate_dcbz(ea); 1069 - user_write_access_end(); 1070 - } else { 1071 - err = -EFAULT; 1072 - } 1078 + else 1079 + scoped_user_write_access_size(uea, size, efault) 1080 + err = __emulate_dcbz((unsigned long)uea); 1073 1081 1074 1082 if (err) 1075 1083 regs->dar = ea; 1076 1084 1077 - 1078 1085 return err; 1086 + 1087 + efault: 1088 + regs->dar = ea; 1089 + return -EFAULT; 1079 1090 } 1080 1091 NOKPROBE_SYMBOL(emulate_dcbz); 1081 1092
+21
arch/powerpc/mm/book3s64/hash_pgtable.c
··· 221 221 return old; 222 222 } 223 223 224 + static void do_nothing(void *arg) 225 + { 226 + 227 + } 228 + 229 + /* 230 + * Serialize against __find_linux_pte() which does lock-less 231 + * lookup in page tables with local interrupts disabled. For huge pages 232 + * it casts pmd_t to pte_t. Since format of pte_t is different from 233 + * pmd_t we want to prevent transit from pmd pointing to page table 234 + * to pmd pointing to huge page (and back) while interrupts are disabled. 235 + * We clear pmd to possibly replace it with page table pointer in 236 + * different code paths. So make sure we wait for the parallel 237 + * __find_linux_pte() to finish. 238 + */ 239 + static void serialize_against_pte_lookup(struct mm_struct *mm) 240 + { 241 + smp_mb(); 242 + smp_call_function_many(mm_cpumask(mm), do_nothing, mm, 1); 243 + } 244 + 224 245 pmd_t hash__pmdp_collapse_flush(struct vm_area_struct *vma, unsigned long address, 225 246 pmd_t *pmdp) 226 247 {
-2
arch/powerpc/mm/book3s64/internal.h
··· 31 31 32 32 void hpt_do_stress(unsigned long ea, unsigned long hpte_group); 33 33 34 - void exit_lazy_flush_tlb(struct mm_struct *mm, bool always_flush); 35 - 36 34 #endif /* ARCH_POWERPC_MM_BOOK3S64_INTERNAL_H */
+9 -31
arch/powerpc/mm/book3s64/pgtable.c
··· 23 23 #include <mm/mmu_decl.h> 24 24 #include <trace/events/thp.h> 25 25 26 - #include "internal.h" 27 - 28 26 struct mmu_psize_def mmu_psize_defs[MMU_PAGE_COUNT]; 29 27 EXPORT_SYMBOL_GPL(mmu_psize_defs); 30 28 ··· 148 150 return set_pte_at_unchecked(mm, addr, pudp_ptep(pudp), pud_pte(pud)); 149 151 } 150 152 151 - static void do_serialize(void *arg) 152 - { 153 - /* We've taken the IPI, so try to trim the mask while here */ 154 - if (radix_enabled()) { 155 - struct mm_struct *mm = arg; 156 - exit_lazy_flush_tlb(mm, false); 157 - } 158 - } 159 - 160 - /* 161 - * Serialize against __find_linux_pte() which does lock-less 162 - * lookup in page tables with local interrupts disabled. For huge pages 163 - * it casts pmd_t to pte_t. Since format of pte_t is different from 164 - * pmd_t we want to prevent transit from pmd pointing to page table 165 - * to pmd pointing to huge page (and back) while interrupts are disabled. 166 - * We clear pmd to possibly replace it with page table pointer in 167 - * different code paths. So make sure we wait for the parallel 168 - * __find_linux_pte() to finish. 169 - */ 170 - void serialize_against_pte_lookup(struct mm_struct *mm) 171 - { 172 - smp_mb(); 173 - smp_call_function_many(mm_cpumask(mm), do_serialize, mm, 1); 174 - } 175 - 176 153 /* 177 154 * We use this to invalidate a pmdp entry before switching from a 178 155 * hugepte to regular pmd entry. ··· 182 209 unsigned long addr, pmd_t *pmdp, int full) 183 210 { 184 211 pmd_t pmd; 212 + bool was_present = pmd_present(*pmdp); 213 + 185 214 VM_BUG_ON(addr & ~HPAGE_PMD_MASK); 186 - VM_BUG_ON((pmd_present(*pmdp) && !pmd_trans_huge(*pmdp)) || 187 - !pmd_present(*pmdp)); 215 + VM_BUG_ON(was_present && !pmd_trans_huge(*pmdp)); 216 + /* 217 + * Check pmdp_huge_get_and_clear() for non-present pmd case. 218 + */ 188 219 pmd = pmdp_huge_get_and_clear(vma->vm_mm, addr, pmdp); 189 220 /* 190 221 * if it not a fullmm flush, then we can possibly end up converting 191 222 * this PMD pte entry to a regular level 0 PTE by a parallel page fault. 192 - * Make sure we flush the tlb in this case. 223 + * Make sure we flush the tlb in this case. TLB flush not needed for 224 + * non-present case. 193 225 */ 194 - if (!full) 226 + if (was_present && !full) 195 227 flush_pmd_tlb_range(vma, addr, addr + HPAGE_PMD_SIZE); 196 228 return pmd; 197 229 }
+27 -34
arch/powerpc/mm/book3s64/radix_tlb.c
··· 19 19 #include <asm/cputhreads.h> 20 20 #include <asm/plpar_wrappers.h> 21 21 22 - #include "internal.h" 23 - 24 22 /* 25 23 * tlbiel instruction for radix, set invalidation 26 24 * i.e., r=1 and is=01 or is=10 or is=11 ··· 185 187 trace_tlbie(0, 0, rb, rs, ric, prs, r); 186 188 } 187 189 188 - static __always_inline void __tlbie_lpid_va(unsigned long va, unsigned long lpid, 190 + static __always_inline void __tlbie_va_lpid(unsigned long va, unsigned long lpid, 189 191 unsigned long ap, unsigned long ric) 190 192 { 191 193 unsigned long rb,rs,prs,r; ··· 249 251 } 250 252 } 251 253 252 - static inline void fixup_tlbie_lpid_va(unsigned long va, unsigned long lpid, 254 + static inline void fixup_tlbie_va_lpid(unsigned long va, unsigned long lpid, 253 255 unsigned long ap) 254 256 { 255 257 if (cpu_has_feature(CPU_FTR_P9_TLBIE_ERAT_BUG)) { 256 258 asm volatile("ptesync": : :"memory"); 257 - __tlbie_lpid_va(va, 0, ap, RIC_FLUSH_TLB); 259 + __tlbie_va_lpid(va, 0, ap, RIC_FLUSH_TLB); 258 260 } 259 261 260 262 if (cpu_has_feature(CPU_FTR_P9_TLBIE_STQ_BUG)) { 261 263 asm volatile("ptesync": : :"memory"); 262 - __tlbie_lpid_va(va, lpid, ap, RIC_FLUSH_TLB); 264 + __tlbie_va_lpid(va, lpid, ap, RIC_FLUSH_TLB); 263 265 } 264 266 } 265 267 ··· 278 280 279 281 if (cpu_has_feature(CPU_FTR_P9_TLBIE_STQ_BUG)) { 280 282 asm volatile("ptesync": : :"memory"); 281 - __tlbie_lpid_va(va, lpid, mmu_get_ap(MMU_PAGE_64K), RIC_FLUSH_TLB); 283 + __tlbie_va_lpid(va, lpid, mmu_get_ap(MMU_PAGE_64K), RIC_FLUSH_TLB); 282 284 } 283 285 } 284 286 ··· 529 531 t->psize, t->also_pwc); 530 532 } 531 533 532 - static __always_inline void _tlbie_lpid_va(unsigned long va, unsigned long lpid, 534 + static __always_inline void _tlbie_va_lpid(unsigned long va, unsigned long lpid, 533 535 unsigned long psize, unsigned long ric) 534 536 { 535 537 unsigned long ap = mmu_get_ap(psize); 536 538 537 539 asm volatile("ptesync": : :"memory"); 538 - __tlbie_lpid_va(va, lpid, ap, ric); 539 - fixup_tlbie_lpid_va(va, lpid, ap); 540 + __tlbie_va_lpid(va, lpid, ap, ric); 541 + fixup_tlbie_va_lpid(va, lpid, ap); 540 542 asm volatile("eieio; tlbsync; ptesync": : :"memory"); 541 543 } 542 544 ··· 658 660 * If always_flush is true, then flush even if this CPU can't be removed 659 661 * from mm_cpumask. 660 662 */ 661 - void exit_lazy_flush_tlb(struct mm_struct *mm, bool always_flush) 663 + static void exit_lazy_flush_tlb(struct mm_struct *mm) 662 664 { 663 665 unsigned long pid = mm->context.id; 664 666 int cpu = smp_processor_id(); ··· 701 703 if (cpumask_test_cpu(cpu, mm_cpumask(mm))) { 702 704 dec_mm_active_cpus(mm); 703 705 cpumask_clear_cpu(cpu, mm_cpumask(mm)); 704 - always_flush = true; 705 706 } 706 707 707 708 out: 708 - if (always_flush) 709 - _tlbiel_pid(pid, RIC_FLUSH_ALL); 709 + _tlbiel_pid(pid, RIC_FLUSH_ALL); 710 710 } 711 711 712 712 #ifdef CONFIG_SMP 713 713 static void do_exit_flush_lazy_tlb(void *arg) 714 714 { 715 715 struct mm_struct *mm = arg; 716 - exit_lazy_flush_tlb(mm, true); 716 + exit_lazy_flush_tlb(mm); 717 717 } 718 718 719 719 static void exit_flush_lazy_tlbs(struct mm_struct *mm) ··· 773 777 * to trim. 774 778 */ 775 779 if (tick_and_test_trim_clock()) { 776 - exit_lazy_flush_tlb(mm, true); 780 + exit_lazy_flush_tlb(mm); 777 781 return FLUSH_TYPE_NONE; 778 782 } 779 783 } ··· 819 823 if (current->mm == mm) 820 824 return FLUSH_TYPE_LOCAL; 821 825 if (cpumask_test_cpu(cpu, mm_cpumask(mm))) 822 - exit_lazy_flush_tlb(mm, true); 826 + exit_lazy_flush_tlb(mm); 823 827 return FLUSH_TYPE_NONE; 824 828 } 825 829 ··· 885 889 } else if (type == FLUSH_TYPE_GLOBAL) { 886 890 if (!mmu_has_feature(MMU_FTR_GTSE)) { 887 891 unsigned long tgt = H_RPTI_TARGET_CMMU; 888 - unsigned long type = H_RPTI_TYPE_TLB | H_RPTI_TYPE_PWC | 889 - H_RPTI_TYPE_PRT; 892 + unsigned long type = H_RPTI_TYPE_ALL; 890 893 891 894 if (atomic_read(&mm->context.copros) > 0) 892 895 tgt |= H_RPTI_TARGET_NMMU; ··· 981 986 { 982 987 if (!mmu_has_feature(MMU_FTR_GTSE)) { 983 988 unsigned long tgt = H_RPTI_TARGET_CMMU | H_RPTI_TARGET_NMMU; 984 - unsigned long type = H_RPTI_TYPE_TLB | H_RPTI_TYPE_PWC | 985 - H_RPTI_TYPE_PRT; 989 + unsigned long type = H_RPTI_TYPE_ALL; 986 990 987 991 pseries_rpt_invalidate(0, tgt, type, H_RPTI_PAGE_ALL, 988 992 start, end); ··· 1145 1151 { 1146 1152 int psize = radix_get_mmu_psize(page_size); 1147 1153 1148 - _tlbie_lpid_va(addr, lpid, psize, RIC_FLUSH_TLB); 1154 + _tlbie_va_lpid(addr, lpid, psize, RIC_FLUSH_TLB); 1149 1155 } 1150 1156 EXPORT_SYMBOL_GPL(radix__flush_tlb_lpid_page); 1151 1157 ··· 1335 1341 unsigned long tgt, type, pg_sizes; 1336 1342 1337 1343 tgt = H_RPTI_TARGET_CMMU; 1338 - type = H_RPTI_TYPE_TLB | H_RPTI_TYPE_PWC | 1339 - H_RPTI_TYPE_PRT; 1344 + type = H_RPTI_TYPE_ALL; 1340 1345 pg_sizes = psize_to_rpti_pgsize(mmu_virtual_psize); 1341 1346 1342 1347 if (atomic_read(&mm->context.copros) > 0) ··· 1408 1415 trace_tlbie(0, 0, rb, rs, ric, prs, r); 1409 1416 } 1410 1417 1411 - static __always_inline void __tlbie_va_lpid(unsigned long va, unsigned long pid, 1418 + static __always_inline void __tlbie_va_pid_lpid(unsigned long va, unsigned long pid, 1412 1419 unsigned long lpid, 1413 1420 unsigned long ap, unsigned long ric) 1414 1421 { ··· 1440 1447 1441 1448 if (cpu_has_feature(CPU_FTR_P9_TLBIE_STQ_BUG)) { 1442 1449 asm volatile("ptesync" : : : "memory"); 1443 - __tlbie_va_lpid(va, pid, lpid, mmu_get_ap(MMU_PAGE_64K), 1450 + __tlbie_va_pid_lpid(va, pid, lpid, mmu_get_ap(MMU_PAGE_64K), 1444 1451 RIC_FLUSH_TLB); 1445 1452 } 1446 1453 } ··· 1471 1478 asm volatile("eieio; tlbsync; ptesync" : : : "memory"); 1472 1479 } 1473 1480 1474 - static inline void fixup_tlbie_va_range_lpid(unsigned long va, 1481 + static inline void fixup_tlbie_va_range_pid_lpid(unsigned long va, 1475 1482 unsigned long pid, 1476 1483 unsigned long lpid, 1477 1484 unsigned long ap) ··· 1483 1490 1484 1491 if (cpu_has_feature(CPU_FTR_P9_TLBIE_STQ_BUG)) { 1485 1492 asm volatile("ptesync" : : : "memory"); 1486 - __tlbie_va_lpid(va, pid, lpid, ap, RIC_FLUSH_TLB); 1493 + __tlbie_va_pid_lpid(va, pid, lpid, ap, RIC_FLUSH_TLB); 1487 1494 } 1488 1495 } 1489 1496 1490 - static inline void __tlbie_va_range_lpid(unsigned long start, unsigned long end, 1497 + static inline void __tlbie_va_range_pid_lpid(unsigned long start, unsigned long end, 1491 1498 unsigned long pid, unsigned long lpid, 1492 1499 unsigned long page_size, 1493 1500 unsigned long psize) ··· 1496 1503 unsigned long ap = mmu_get_ap(psize); 1497 1504 1498 1505 for (addr = start; addr < end; addr += page_size) 1499 - __tlbie_va_lpid(addr, pid, lpid, ap, RIC_FLUSH_TLB); 1506 + __tlbie_va_pid_lpid(addr, pid, lpid, ap, RIC_FLUSH_TLB); 1500 1507 1501 - fixup_tlbie_va_range_lpid(addr - page_size, pid, lpid, ap); 1508 + fixup_tlbie_va_range_pid_lpid(addr - page_size, pid, lpid, ap); 1502 1509 } 1503 1510 1504 - static inline void _tlbie_va_range_lpid(unsigned long start, unsigned long end, 1511 + static inline void _tlbie_va_range_pid_lpid(unsigned long start, unsigned long end, 1505 1512 unsigned long pid, unsigned long lpid, 1506 1513 unsigned long page_size, 1507 1514 unsigned long psize, bool also_pwc) ··· 1509 1516 asm volatile("ptesync" : : : "memory"); 1510 1517 if (also_pwc) 1511 1518 __tlbie_pid_lpid(pid, lpid, RIC_FLUSH_PWC); 1512 - __tlbie_va_range_lpid(start, end, pid, lpid, page_size, psize); 1519 + __tlbie_va_range_pid_lpid(start, end, pid, lpid, page_size, psize); 1513 1520 asm volatile("eieio; tlbsync; ptesync" : : : "memory"); 1514 1521 } 1515 1522 ··· 1560 1567 _tlbie_pid_lpid(pid, lpid, RIC_FLUSH_TLB); 1561 1568 return; 1562 1569 } 1563 - _tlbie_va_range_lpid(start, end, pid, lpid, 1570 + _tlbie_va_range_pid_lpid(start, end, pid, lpid, 1564 1571 (1UL << def->shift), psize, false); 1565 1572 } 1566 1573 }
+1
arch/powerpc/mm/pgtable-frag.c
··· 25 25 count = ((unsigned long)pte_frag & ~PAGE_MASK) >> PTE_FRAG_SIZE_SHIFT; 26 26 /* We allow PTE_FRAG_NR fragments from a PTE page */ 27 27 if (atomic_sub_and_test(PTE_FRAG_NR - count, &ptdesc->pt_frag_refcount)) { 28 + folio_clear_active(ptdesc_folio(ptdesc)); 28 29 pagetable_dtor(ptdesc); 29 30 pagetable_free(ptdesc); 30 31 }
+9 -1
arch/powerpc/net/bpf_jit.h
··· 178 178 bool is_subprog; 179 179 bool exception_boundary; 180 180 bool exception_cb; 181 + void __percpu *priv_sp; 182 + unsigned int priv_stack_size; 181 183 }; 184 + 185 + /* Memory size & magic-value to detect private stack overflow/underflow */ 186 + #define PRIV_STACK_GUARD_SZ 16 187 + #define PRIV_STACK_GUARD_VAL 0xEB9F12345678eb9fULL 182 188 183 189 #define bpf_to_ppc(r) (ctx->b2p[r]) 184 190 ··· 218 212 void bpf_jit_build_fentry_stubs(u32 *image, struct codegen_context *ctx); 219 213 void bpf_jit_realloc_regs(struct codegen_context *ctx); 220 214 int bpf_jit_emit_exit_insn(u32 *image, struct codegen_context *ctx, int tmp_reg, long exit_addr); 221 - 215 + void prepare_for_fsession_fentry(u32 *image, struct codegen_context *ctx, int cookie_cnt, 216 + int cookie_off, int retval_off); 217 + void store_func_meta(u32 *image, struct codegen_context *ctx, u64 func_meta, int func_meta_off); 222 218 int bpf_add_extable_entry(struct bpf_prog *fp, u32 *image, u32 *fimage, int pass, 223 219 struct codegen_context *ctx, int insn_idx, 224 220 int jmp_off, int dst_reg, u32 code);
+164 -15
arch/powerpc/net/bpf_jit_comp.c
··· 129 129 return true; 130 130 } 131 131 132 + static void priv_stack_init_guard(void __percpu *priv_stack_ptr, int alloc_size) 133 + { 134 + int cpu, underflow_idx = (alloc_size - PRIV_STACK_GUARD_SZ) >> 3; 135 + u64 *stack_ptr; 136 + 137 + for_each_possible_cpu(cpu) { 138 + stack_ptr = per_cpu_ptr(priv_stack_ptr, cpu); 139 + stack_ptr[0] = PRIV_STACK_GUARD_VAL; 140 + stack_ptr[1] = PRIV_STACK_GUARD_VAL; 141 + stack_ptr[underflow_idx] = PRIV_STACK_GUARD_VAL; 142 + stack_ptr[underflow_idx + 1] = PRIV_STACK_GUARD_VAL; 143 + } 144 + } 145 + 146 + static void priv_stack_check_guard(void __percpu *priv_stack_ptr, int alloc_size, 147 + struct bpf_prog *fp) 148 + { 149 + int cpu, underflow_idx = (alloc_size - PRIV_STACK_GUARD_SZ) >> 3; 150 + u64 *stack_ptr; 151 + 152 + for_each_possible_cpu(cpu) { 153 + stack_ptr = per_cpu_ptr(priv_stack_ptr, cpu); 154 + if (stack_ptr[0] != PRIV_STACK_GUARD_VAL || 155 + stack_ptr[1] != PRIV_STACK_GUARD_VAL || 156 + stack_ptr[underflow_idx] != PRIV_STACK_GUARD_VAL || 157 + stack_ptr[underflow_idx + 1] != PRIV_STACK_GUARD_VAL) { 158 + pr_err("BPF private stack overflow/underflow detected for prog %s\n", 159 + bpf_jit_get_prog_name(fp)); 160 + break; 161 + } 162 + } 163 + } 164 + 132 165 struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *fp) 133 166 { 134 167 u32 proglen; 135 168 u32 alloclen; 136 169 u8 *image = NULL; 137 - u32 *code_base; 138 - u32 *addrs; 139 - struct powerpc_jit_data *jit_data; 170 + u32 *code_base = NULL; 171 + u32 *addrs = NULL; 172 + struct powerpc_jit_data *jit_data = NULL; 140 173 struct codegen_context cgctx; 141 174 int pass; 142 175 int flen; 176 + int priv_stack_alloc_size; 177 + void __percpu *priv_stack_ptr = NULL; 143 178 struct bpf_binary_header *fhdr = NULL; 144 179 struct bpf_binary_header *hdr = NULL; 145 180 struct bpf_prog *org_fp = fp; 146 - struct bpf_prog *tmp_fp; 181 + struct bpf_prog *tmp_fp = NULL; 147 182 bool bpf_blinded = false; 148 183 bool extra_pass = false; 149 184 u8 *fimage = NULL; 150 - u32 *fcode_base; 185 + u32 *fcode_base = NULL; 151 186 u32 extable_len; 152 187 u32 fixup_len; 153 188 ··· 206 171 goto out; 207 172 } 208 173 fp->aux->jit_data = jit_data; 174 + } 175 + 176 + priv_stack_ptr = fp->aux->priv_stack_ptr; 177 + if (!priv_stack_ptr && fp->aux->jits_use_priv_stack) { 178 + /* 179 + * Allocate private stack of size equivalent to 180 + * verifier-calculated stack size plus two memory 181 + * guard regions to detect private stack overflow 182 + * and underflow. 183 + */ 184 + priv_stack_alloc_size = round_up(fp->aux->stack_depth, 16) + 185 + 2 * PRIV_STACK_GUARD_SZ; 186 + priv_stack_ptr = __alloc_percpu_gfp(priv_stack_alloc_size, 16, GFP_KERNEL); 187 + if (!priv_stack_ptr) { 188 + fp = org_fp; 189 + goto out_priv_stack; 190 + } 191 + 192 + priv_stack_init_guard(priv_stack_ptr, priv_stack_alloc_size); 193 + fp->aux->priv_stack_ptr = priv_stack_ptr; 209 194 } 210 195 211 196 flen = fp->len; ··· 264 209 cgctx.is_subprog = bpf_is_subprog(fp); 265 210 cgctx.exception_boundary = fp->aux->exception_boundary; 266 211 cgctx.exception_cb = fp->aux->exception_cb; 212 + cgctx.priv_sp = priv_stack_ptr; 213 + cgctx.priv_stack_size = 0; 214 + if (priv_stack_ptr) { 215 + /* 216 + * priv_stack_size required for setting bpf FP inside 217 + * percpu allocation. 218 + * stack_size is marked 0 to prevent allocation on 219 + * general stack and offset calculation don't go for 220 + * a toss in bpf_jit_stack_offsetof() & bpf_jit_stack_local() 221 + */ 222 + cgctx.priv_stack_size = cgctx.stack_size; 223 + cgctx.stack_size = 0; 224 + } 267 225 268 226 /* Scouting faux-generate pass 0 */ 269 227 if (bpf_jit_build_body(fp, NULL, NULL, &cgctx, addrs, 0, false)) { ··· 373 305 goto out_addrs; 374 306 } 375 307 bpf_prog_fill_jited_linfo(fp, addrs); 308 + /* 309 + * On ABI V1, executable code starts after the function 310 + * descriptor, so adjust base accordingly. 311 + */ 312 + bpf_prog_update_insn_ptrs(fp, addrs, 313 + (void *)fimage + FUNCTION_DESCR_SIZE); 314 + 376 315 out_addrs: 316 + if (!image && priv_stack_ptr) { 317 + fp->aux->priv_stack_ptr = NULL; 318 + free_percpu(priv_stack_ptr); 319 + } 320 + out_priv_stack: 377 321 kfree(addrs); 378 322 kfree(jit_data); 379 323 fp->aux->jit_data = NULL; ··· 499 419 if (fp->jited) { 500 420 struct powerpc_jit_data *jit_data = fp->aux->jit_data; 501 421 struct bpf_binary_header *hdr; 422 + void __percpu *priv_stack_ptr; 423 + int priv_stack_alloc_size; 502 424 503 425 /* 504 426 * If we fail the final pass of JIT (from jit_subprogs), ··· 514 432 } 515 433 hdr = bpf_jit_binary_pack_hdr(fp); 516 434 bpf_jit_binary_pack_free(hdr, NULL); 435 + priv_stack_ptr = fp->aux->priv_stack_ptr; 436 + if (priv_stack_ptr) { 437 + priv_stack_alloc_size = round_up(fp->aux->stack_depth, 16) + 438 + 2 * PRIV_STACK_GUARD_SZ; 439 + priv_stack_check_guard(priv_stack_ptr, priv_stack_alloc_size, fp); 440 + free_percpu(priv_stack_ptr); 441 + } 517 442 WARN_ON_ONCE(!bpf_prog_kallsyms_verify_off(fp)); 518 443 } 519 444 ··· 540 451 bool bpf_jit_supports_kfunc_call(void) 541 452 { 542 453 return IS_ENABLED(CONFIG_PPC64); 454 + } 455 + 456 + bool bpf_jit_supports_private_stack(void) 457 + { 458 + return IS_ENABLED(CONFIG_PPC64); 459 + } 460 + 461 + bool bpf_jit_supports_fsession(void) 462 + { 463 + /* 464 + * TODO: Remove after validating support 465 + * for fsession and trampoline on ppc32. 466 + */ 467 + if (IS_ENABLED(CONFIG_PPC32)) 468 + return -EOPNOTSUPP; 469 + return true; 543 470 } 544 471 545 472 bool bpf_jit_supports_arena(void) ··· 830 725 struct bpf_tramp_links *tlinks, 831 726 void *func_addr) 832 727 { 833 - int regs_off, nregs_off, ip_off, run_ctx_off, retval_off, nvr_off, alt_lr_off, r4_off = 0; 728 + int regs_off, func_meta_off, ip_off, run_ctx_off, retval_off; 729 + int nvr_off, alt_lr_off, r4_off = 0; 834 730 struct bpf_tramp_links *fmod_ret = &tlinks[BPF_TRAMP_MODIFY_RETURN]; 835 731 struct bpf_tramp_links *fentry = &tlinks[BPF_TRAMP_FENTRY]; 836 732 struct bpf_tramp_links *fexit = &tlinks[BPF_TRAMP_FEXIT]; 837 733 int i, ret, nr_regs, retaddr_off, bpf_frame_size = 0; 838 734 struct codegen_context codegen_ctx, *ctx; 735 + int cookie_off, cookie_cnt, cookie_ctx_off; 736 + int fsession_cnt = bpf_fsession_cnt(tlinks); 737 + u64 func_meta; 839 738 u32 *image = (u32 *)rw_image; 840 739 ppc_inst_t branch_insn; 841 740 u32 *branches = NULL; ··· 875 766 * [ reg argN ] 876 767 * [ ... ] 877 768 * regs_off [ reg_arg1 ] prog_ctx 878 - * nregs_off [ args count ] ((u64 *)prog_ctx)[-1] 769 + * func_meta_off [ args count ] ((u64 *)prog_ctx)[-1] 879 770 * ip_off [ traced function ] ((u64 *)prog_ctx)[-2] 771 + * [ stack cookieN ] 880 772 * [ ... ] 773 + * cookie_off [ stack cookie1 ] 881 774 * run_ctx_off [ bpf_tramp_run_ctx ] 882 775 * [ reg argN ] 883 776 * [ ... ] ··· 911 800 run_ctx_off = bpf_frame_size; 912 801 bpf_frame_size += round_up(sizeof(struct bpf_tramp_run_ctx), SZL); 913 802 803 + /* room for session cookies */ 804 + cookie_off = bpf_frame_size; 805 + cookie_cnt = bpf_fsession_cookie_cnt(tlinks); 806 + bpf_frame_size += cookie_cnt * 8; 807 + 914 808 /* Room for IP address argument */ 915 809 ip_off = bpf_frame_size; 916 810 if (flags & BPF_TRAMP_F_IP_ARG) 917 811 bpf_frame_size += SZL; 918 812 919 - /* Room for args count */ 920 - nregs_off = bpf_frame_size; 813 + /* Room for function metadata, arg regs count */ 814 + func_meta_off = bpf_frame_size; 921 815 bpf_frame_size += SZL; 922 816 923 - /* Room for args */ 817 + /* Room for arg regs */ 924 818 regs_off = bpf_frame_size; 925 819 bpf_frame_size += nr_regs * SZL; 926 820 ··· 1024 908 EMIT(PPC_RAW_STL(_R3, _R1, retaddr_off)); 1025 909 } 1026 910 1027 - /* Save function arg count -- see bpf_get_func_arg_cnt() */ 1028 - EMIT(PPC_RAW_LI(_R3, nr_regs)); 1029 - EMIT(PPC_RAW_STL(_R3, _R1, nregs_off)); 911 + /* Save function arg regs count -- see bpf_get_func_arg_cnt() */ 912 + func_meta = nr_regs; 913 + store_func_meta(image, ctx, func_meta, func_meta_off); 1030 914 1031 915 /* Save nv regs */ 1032 916 EMIT(PPC_RAW_STL(_R25, _R1, nvr_off)); ··· 1040 924 return ret; 1041 925 } 1042 926 1043 - for (i = 0; i < fentry->nr_links; i++) 927 + if (fsession_cnt) { 928 + /* 929 + * Clear all the session cookies' values 930 + * Clear the return value to make sure fentry always get 0 931 + */ 932 + prepare_for_fsession_fentry(image, ctx, cookie_cnt, cookie_off, retval_off); 933 + } 934 + 935 + cookie_ctx_off = (regs_off - cookie_off) / 8; 936 + 937 + for (i = 0; i < fentry->nr_links; i++) { 938 + if (bpf_prog_calls_session_cookie(fentry->links[i])) { 939 + u64 meta = func_meta | (cookie_ctx_off << BPF_TRAMP_COOKIE_INDEX_SHIFT); 940 + 941 + store_func_meta(image, ctx, meta, func_meta_off); 942 + cookie_ctx_off--; 943 + } 944 + 1044 945 if (invoke_bpf_prog(image, ro_image, ctx, fentry->links[i], regs_off, retval_off, 1045 946 run_ctx_off, flags & BPF_TRAMP_F_RET_FENTRY_RET)) 1046 947 return -EINVAL; 948 + } 1047 949 1048 950 if (fmod_ret->nr_links) { 1049 951 branches = kcalloc(fmod_ret->nr_links, sizeof(u32), GFP_KERNEL); ··· 1123 989 image[branches[i]] = ppc_inst_val(branch_insn); 1124 990 } 1125 991 1126 - for (i = 0; i < fexit->nr_links; i++) 992 + /* set the "is_return" flag for fsession */ 993 + func_meta |= (1ULL << BPF_TRAMP_IS_RETURN_SHIFT); 994 + if (fsession_cnt) 995 + store_func_meta(image, ctx, func_meta, func_meta_off); 996 + 997 + cookie_ctx_off = (regs_off - cookie_off) / 8; 998 + 999 + for (i = 0; i < fexit->nr_links; i++) { 1000 + if (bpf_prog_calls_session_cookie(fexit->links[i])) { 1001 + u64 meta = func_meta | (cookie_ctx_off << BPF_TRAMP_COOKIE_INDEX_SHIFT); 1002 + 1003 + store_func_meta(image, ctx, meta, func_meta_off); 1004 + cookie_ctx_off--; 1005 + } 1006 + 1127 1007 if (invoke_bpf_prog(image, ro_image, ctx, fexit->links[i], regs_off, retval_off, 1128 1008 run_ctx_off, false)) { 1129 1009 ret = -EINVAL; 1130 1010 goto cleanup; 1131 1011 } 1012 + } 1132 1013 1133 1014 if (flags & BPF_TRAMP_F_CALL_ORIG) { 1134 1015 if (ro_image) /* image is NULL for dummy pass */
+35
arch/powerpc/net/bpf_jit_comp32.c
··· 123 123 } 124 124 } 125 125 126 + void prepare_for_fsession_fentry(u32 *image, struct codegen_context *ctx, int cookie_cnt, 127 + int cookie_off, int retval_off) 128 + { 129 + /* 130 + * Set session cookies value 131 + * Clear cookies field on stack 132 + * Ensure retval to be cleared on fentry 133 + */ 134 + EMIT(PPC_RAW_LI(bpf_to_ppc(TMP_REG), 0)); 135 + 136 + for (int i = 0; i < cookie_cnt; i++) { 137 + EMIT(PPC_RAW_STW(bpf_to_ppc(TMP_REG), _R1, cookie_off + 4 * i)); 138 + EMIT(PPC_RAW_STW(bpf_to_ppc(TMP_REG), _R1, cookie_off + 4 * i + 4)); 139 + } 140 + 141 + EMIT(PPC_RAW_STW(bpf_to_ppc(TMP_REG), _R1, retval_off)); 142 + EMIT(PPC_RAW_STW(bpf_to_ppc(TMP_REG), _R1, retval_off + 4)); 143 + } 144 + 145 + void store_func_meta(u32 *image, struct codegen_context *ctx, 146 + u64 func_meta, int func_meta_off) 147 + { 148 + /* 149 + * Store func_meta to stack: [R1 + func_meta_off] = func_meta 150 + * func_meta := argument count in first byte + cookie value 151 + */ 152 + /* Store lower word */ 153 + PPC_LI32(bpf_to_ppc(TMP_REG), (u32)func_meta); 154 + EMIT(PPC_RAW_STW(bpf_to_ppc(TMP_REG), _R1, func_meta_off)); 155 + 156 + /* Store upper word */ 157 + PPC_LI32(bpf_to_ppc(TMP_REG), (u32)(func_meta >> 32)); 158 + EMIT(PPC_RAW_STW(bpf_to_ppc(TMP_REG), _R1, func_meta_off + 4)); 159 + } 160 + 126 161 void bpf_jit_build_prologue(u32 *image, struct codegen_context *ctx) 127 162 { 128 163 int i;
+61 -3
arch/powerpc/net/bpf_jit_comp64.c
··· 179 179 BUG(); 180 180 } 181 181 182 + void prepare_for_fsession_fentry(u32 *image, struct codegen_context *ctx, int cookie_cnt, 183 + int cookie_off, int retval_off) 184 + { 185 + EMIT(PPC_RAW_LI(bpf_to_ppc(TMP_REG_1), 0)); 186 + 187 + for (int i = 0; i < cookie_cnt; i++) 188 + EMIT(PPC_RAW_STD(bpf_to_ppc(TMP_REG_1), _R1, cookie_off + 8 * i)); 189 + EMIT(PPC_RAW_STD(bpf_to_ppc(TMP_REG_1), _R1, retval_off)); 190 + } 191 + 192 + void store_func_meta(u32 *image, struct codegen_context *ctx, 193 + u64 func_meta, int func_meta_off) 194 + { 195 + /* 196 + * Store func_meta to stack at [R1 + func_meta_off] = func_meta 197 + * 198 + * func_meta : 199 + * bit[63]: is_return flag 200 + * byte[1]: cookie offset from ctx 201 + * byte[0]: args count 202 + */ 203 + PPC_LI64(bpf_to_ppc(TMP_REG_1), func_meta); 204 + EMIT(PPC_RAW_STD(bpf_to_ppc(TMP_REG_1), _R1, func_meta_off)); 205 + } 206 + 182 207 void bpf_jit_realloc_regs(struct codegen_context *ctx) 183 208 { 209 + } 210 + 211 + static void emit_fp_priv_stack(u32 *image, struct codegen_context *ctx) 212 + { 213 + PPC_LI64(bpf_to_ppc(BPF_REG_FP), (__force long)ctx->priv_sp); 214 + /* 215 + * Load base percpu pointer of private stack allocation. 216 + * Runtime per-cpu address = (base + data_offset) + (guard + stack_size) 217 + */ 218 + #ifdef CONFIG_SMP 219 + /* Load percpu data offset */ 220 + EMIT(PPC_RAW_LD(bpf_to_ppc(TMP_REG_1), _R13, 221 + offsetof(struct paca_struct, data_offset))); 222 + EMIT(PPC_RAW_ADD(bpf_to_ppc(BPF_REG_FP), 223 + bpf_to_ppc(TMP_REG_1), bpf_to_ppc(BPF_REG_FP))); 224 + #endif 225 + EMIT(PPC_RAW_ADDI(bpf_to_ppc(BPF_REG_FP), bpf_to_ppc(BPF_REG_FP), 226 + PRIV_STACK_GUARD_SZ + round_up(ctx->priv_stack_size, 16))); 184 227 } 185 228 186 229 /* ··· 350 307 * Exception_cb not restricted from using stack area or arena. 351 308 * Setup frame pointer to point to the bpf stack area 352 309 */ 353 - if (bpf_is_seen_register(ctx, bpf_to_ppc(BPF_REG_FP))) 354 - EMIT(PPC_RAW_ADDI(bpf_to_ppc(BPF_REG_FP), _R1, 355 - STACK_FRAME_MIN_SIZE + ctx->stack_size)); 310 + if (bpf_is_seen_register(ctx, bpf_to_ppc(BPF_REG_FP))) { 311 + if (ctx->priv_sp) { 312 + /* Set up fp in private stack */ 313 + emit_fp_priv_stack(image, ctx); 314 + } else { 315 + /* Setup frame pointer to point to the bpf stack area */ 316 + EMIT(PPC_RAW_ADDI(bpf_to_ppc(BPF_REG_FP), _R1, 317 + STACK_FRAME_MIN_SIZE + ctx->stack_size)); 318 + } 319 + } 356 320 357 321 if (ctx->arena_vm_start) 358 322 PPC_LI64(bpf_to_ppc(ARENA_VM_START), ctx->arena_vm_start); ··· 1706 1656 PPC_LI64(dst_reg, imm64); 1707 1657 /* Adjust for two bpf instructions */ 1708 1658 addrs[++i] = ctx->idx * 4; 1659 + break; 1660 + 1661 + /* 1662 + * JUMP reg 1663 + */ 1664 + case BPF_JMP | BPF_JA | BPF_X: 1665 + EMIT(PPC_RAW_MTCTR(dst_reg)); 1666 + EMIT(PPC_RAW_BCTR()); 1709 1667 break; 1710 1668 1711 1669 /*
+2 -2
arch/powerpc/platforms/44x/uic.c
··· 309 309 310 310 cascade_virq = irq_of_parse_and_map(np, 0); 311 311 312 - irq_set_handler_data(cascade_virq, uic); 313 - irq_set_chained_handler(cascade_virq, uic_irq_cascade); 312 + irq_set_chained_handler_and_data(cascade_virq, 313 + uic_irq_cascade, uic); 314 314 315 315 /* FIXME: setup critical cascade?? */ 316 316 }
+2 -2
arch/powerpc/platforms/52xx/media5200.c
··· 176 176 177 177 of_node_put(fpga_np); 178 178 179 - irq_set_handler_data(cascade_virq, &media5200_irq); 180 - irq_set_chained_handler(cascade_virq, media5200_irq_cascade); 179 + irq_set_chained_handler_and_data(cascade_virq, media5200_irq_cascade, 180 + &media5200_irq); 181 181 182 182 return; 183 183
+1 -2
arch/powerpc/platforms/52xx/mpc52xx_gpt.c
··· 253 253 return; 254 254 } 255 255 256 - irq_set_handler_data(cascade_virq, gpt); 257 - irq_set_chained_handler(cascade_virq, mpc52xx_gpt_irq_cascade); 256 + irq_set_chained_handler_and_data(cascade_virq, mpc52xx_gpt_irq_cascade, gpt); 258 257 259 258 /* If the GPT is currently disabled, then change it to be in Input 260 259 * Capture mode. If the mode is non-zero, then the pin could be
+16 -15
arch/powerpc/platforms/embedded6xx/Kconfig
··· 51 51 This option enables support for the Motorola (now Emerson) MVME5100 52 52 board. 53 53 54 + config GAMECUBE 55 + bool "Nintendo-GameCube" 56 + depends on EMBEDDED6xx 57 + select GAMECUBE_COMMON 58 + help 59 + Select GAMECUBE if configuring for the Nintendo GameCube. 60 + More information at: <http://gc-linux.sourceforge.net/> 61 + 62 + config WII 63 + bool "Nintendo-Wii" 64 + depends on EMBEDDED6xx 65 + select GAMECUBE_COMMON 66 + help 67 + Select WII if configuring for the Nintendo Wii. 68 + More information at: <http://gc-linux.sourceforge.net/> 69 + 54 70 config TSI108_BRIDGE 55 71 bool 56 72 select FORCE_PCI ··· 93 77 94 78 If in doubt, say N here. 95 79 96 - config GAMECUBE 97 - bool "Nintendo-GameCube" 98 - depends on EMBEDDED6xx 99 - select GAMECUBE_COMMON 100 - help 101 - Select GAMECUBE if configuring for the Nintendo GameCube. 102 - More information at: <http://gc-linux.sourceforge.net/> 103 - 104 - config WII 105 - bool "Nintendo-Wii" 106 - depends on EMBEDDED6xx 107 - select GAMECUBE_COMMON 108 - help 109 - Select WII if configuring for the Nintendo Wii. 110 - More information at: <http://gc-linux.sourceforge.net/>
+8 -19
arch/powerpc/platforms/powernv/pci-ioda.c
··· 292 292 293 293 static struct pnv_ioda_pe *pnv_ioda_pick_m64_pe(struct pci_bus *bus, bool all) 294 294 { 295 + unsigned long *pe_alloc __free(bitmap) = NULL; 295 296 struct pnv_phb *phb = pci_bus_to_pnvhb(bus); 296 297 struct pnv_ioda_pe *master_pe, *pe; 297 - unsigned long size, *pe_alloc; 298 - int i; 298 + unsigned int i; 299 299 300 300 /* Root bus shouldn't use M64 */ 301 301 if (pci_is_root_bus(bus)) 302 302 return NULL; 303 303 304 - /* Allocate bitmap */ 305 - size = ALIGN(phb->ioda.total_pe_num / 8, sizeof(unsigned long)); 306 - pe_alloc = kzalloc(size, GFP_KERNEL); 304 + pe_alloc = bitmap_zalloc(phb->ioda.total_pe_num, GFP_KERNEL); 307 305 if (!pe_alloc) { 308 306 pr_warn("%s: Out of memory !\n", 309 307 __func__); ··· 312 314 pnv_ioda_reserve_m64_pe(bus, pe_alloc, all); 313 315 314 316 /* 315 - * the current bus might not own M64 window and that's all 317 + * Figure out the master PE and put all slave PEs to master 318 + * PE's list to form compound PE. 319 + * 320 + * The current bus might not own M64 window and that's all 316 321 * contributed by its child buses. For the case, we needn't 317 322 * pick M64 dependent PE#. 318 323 */ 319 - if (bitmap_empty(pe_alloc, phb->ioda.total_pe_num)) { 320 - kfree(pe_alloc); 321 - return NULL; 322 - } 323 - 324 - /* 325 - * Figure out the master PE and put all slave PEs to master 326 - * PE's list to form compound PE. 327 - */ 328 324 master_pe = NULL; 329 - i = -1; 330 - while ((i = find_next_bit(pe_alloc, phb->ioda.total_pe_num, i + 1)) < 331 - phb->ioda.total_pe_num) { 325 + for_each_set_bit(i, pe_alloc, phb->ioda.total_pe_num) { 332 326 pe = &phb->ioda.pe_array[i]; 333 327 334 328 phb->ioda.m64_segmap[pe->pe_number] = pe->pe_number; ··· 335 345 } 336 346 } 337 347 338 - kfree(pe_alloc); 339 348 return master_pe; 340 349 } 341 350
+6 -4
arch/powerpc/platforms/ps3/spu.c
··· 26 26 27 27 /** 28 28 * enum spe_type - Type of spe to create. 29 - * @spe_type_logical: Standard logical spe. 29 + * @SPE_TYPE_LOGICAL: Standard logical spe. 30 30 * 31 31 * For use with lv1_construct_logical_spe(). The current HV does not support 32 32 * any types other than those listed. ··· 64 64 65 65 /** 66 66 * enum spe_ex_state - Logical spe execution state. 67 - * @spe_ex_state_unexecutable: Uninitialized. 68 - * @spe_ex_state_executable: Enabled, not ready. 69 - * @spe_ex_state_executed: Ready for use. 67 + * @SPE_EX_STATE_UNEXECUTABLE: Uninitialized. 68 + * @SPE_EX_STATE_EXECUTABLE: Enabled, not ready. 69 + * @SPE_EX_STATE_EXECUTED: Ready for use. 70 70 * 71 71 * The execution state (status) of the logical spe as reported in 72 72 * struct spe_shadow:spe_execution_status. ··· 185 185 * 186 186 * The current HV requires the spu shadow regs to be mapped with the 187 187 * PTE page protection bits set as read-only. 188 + * 189 + * Returns: %0 on success or -errno on error. 188 190 */ 189 191 190 192 static int __init setup_areas(struct spu *spu)
+17 -30
arch/powerpc/sysdev/xive/common.c
··· 548 548 static int xive_find_target_in_mask(const struct cpumask *mask, 549 549 unsigned int fuzz) 550 550 { 551 - int cpu, first, num, i; 551 + int cpu, first; 552 552 553 553 /* Pick up a starting point CPU in the mask based on fuzz */ 554 - num = min_t(int, cpumask_weight(mask), nr_cpu_ids); 555 - first = fuzz % num; 556 - 557 - /* Locate it */ 558 - cpu = cpumask_first(mask); 559 - for (i = 0; i < first && cpu < nr_cpu_ids; i++) 560 - cpu = cpumask_next(cpu, mask); 561 - 562 - /* Sanity check */ 563 - if (WARN_ON(cpu >= nr_cpu_ids)) 564 - cpu = cpumask_first(cpu_online_mask); 565 - 566 - /* Remember first one to handle wrap-around */ 567 - first = cpu; 554 + fuzz %= cpumask_weight(mask); 555 + first = cpumask_nth(fuzz, mask); 556 + WARN_ON(first >= nr_cpu_ids); 568 557 569 558 /* 570 559 * Now go through the entire mask until we find a valid 571 560 * target. 572 561 */ 573 - do { 574 - /* 575 - * We re-check online as the fallback case passes us 576 - * an untested affinity mask 577 - */ 562 + for_each_cpu_wrap(cpu, mask, first) { 578 563 if (cpu_online(cpu) && xive_try_pick_target(cpu)) 579 564 return cpu; 580 - cpu = cpumask_next(cpu, mask); 581 - /* Wrap around */ 582 - if (cpu >= nr_cpu_ids) 583 - cpu = cpumask_first(mask); 584 - } while (cpu != first); 565 + } 585 566 586 567 return -1; 587 568 } ··· 1019 1038 return xd; 1020 1039 } 1021 1040 1022 - static void xive_irq_free_data(unsigned int virq) 1041 + static void xive_irq_free_data(struct irq_domain *domain, unsigned int virq) 1023 1042 { 1024 - struct xive_irq_data *xd = irq_get_chip_data(virq); 1043 + struct xive_irq_data *xd; 1044 + struct irq_data *data = irq_domain_get_irq_data(domain, virq); 1025 1045 1046 + if (!data) 1047 + return; 1048 + 1049 + xd = irq_data_get_irq_chip_data(data); 1026 1050 if (!xd) 1027 1051 return; 1028 - irq_set_chip_data(virq, NULL); 1052 + 1053 + irq_domain_reset_irq_data(data); 1029 1054 xive_cleanup_irq_data(xd); 1030 1055 kfree(xd); 1031 1056 } ··· 1292 1305 1293 1306 static void xive_irq_domain_unmap(struct irq_domain *d, unsigned int virq) 1294 1307 { 1295 - xive_irq_free_data(virq); 1308 + xive_irq_free_data(d, virq); 1296 1309 } 1297 1310 1298 1311 static int xive_irq_domain_xlate(struct irq_domain *h, struct device_node *ct, ··· 1430 1443 pr_debug("%s %d #%d\n", __func__, virq, nr_irqs); 1431 1444 1432 1445 for (i = 0; i < nr_irqs; i++) 1433 - xive_irq_free_data(virq + i); 1446 + xive_irq_free_data(domain, virq + i); 1434 1447 } 1435 1448 #endif 1436 1449
+4 -1
drivers/cpuidle/cpuidle-powernv.c
··· 95 95 96 96 HMT_medium(); 97 97 ppc64_runlatch_on(); 98 - clear_thread_flag(TIF_POLLING_NRFLAG); 98 + 99 + /* Avoid double clear when breaking */ 100 + if (!dev->poll_time_limit) 101 + clear_thread_flag(TIF_POLLING_NRFLAG); 99 102 100 103 local_irq_disable(); 101 104
+4 -1
drivers/cpuidle/cpuidle-pseries.c
··· 64 64 } 65 65 66 66 HMT_medium(); 67 - clear_thread_flag(TIF_POLLING_NRFLAG); 67 + 68 + /* Avoid double clear when breaking */ 69 + if (!dev->poll_time_limit) 70 + clear_thread_flag(TIF_POLLING_NRFLAG); 68 71 69 72 raw_local_irq_disable(); 70 73
+7 -12
drivers/vfio/pci/vfio_pci_core.c
··· 1670 1670 if (vdev->pm_runtime_engaged || !__vfio_pci_memory_enabled(vdev)) 1671 1671 return VM_FAULT_SIGBUS; 1672 1672 1673 - switch (order) { 1674 - case 0: 1673 + if (!order) 1675 1674 return vmf_insert_pfn(vmf->vma, vmf->address, pfn); 1676 - #ifdef CONFIG_ARCH_SUPPORTS_PMD_PFNMAP 1677 - case PMD_ORDER: 1675 + 1676 + if (IS_ENABLED(CONFIG_ARCH_SUPPORTS_PMD_PFNMAP) && order == PMD_ORDER) 1678 1677 return vmf_insert_pfn_pmd(vmf, pfn, false); 1679 - #endif 1680 - #ifdef CONFIG_ARCH_SUPPORTS_PUD_PFNMAP 1681 - case PUD_ORDER: 1678 + 1679 + if (IS_ENABLED(CONFIG_ARCH_SUPPORTS_PUD_PFNMAP) && order == PUD_ORDER) 1682 1680 return vmf_insert_pfn_pud(vmf, pfn, false); 1683 - break; 1684 - #endif 1685 - default: 1686 - return VM_FAULT_FALLBACK; 1687 - } 1681 + 1682 + return VM_FAULT_FALLBACK; 1688 1683 } 1689 1684 EXPORT_SYMBOL_GPL(vfio_pci_vmf_insert_pfn); 1690 1685
+1 -1
tools/testing/selftests/bpf/prog_tests/bpf_insn_array.c
··· 3 3 #include <bpf/bpf.h> 4 4 #include <test_progs.h> 5 5 6 - #ifdef __x86_64__ 6 + #if defined(__x86_64__) || defined(__powerpc__) 7 7 static int map_create(__u32 map_type, __u32 max_entries) 8 8 { 9 9 const char *map_name = "insn_array";
+13 -17
tools/testing/selftests/bpf/prog_tests/struct_ops_private_stack.c
··· 5 5 #include "struct_ops_private_stack_fail.skel.h" 6 6 #include "struct_ops_private_stack_recur.skel.h" 7 7 8 + #if defined(__x86_64__) || defined(__aarch64__) || defined(__powerpc64__) 8 9 static void test_private_stack(void) 9 10 { 10 11 struct struct_ops_private_stack *skel; ··· 15 14 skel = struct_ops_private_stack__open(); 16 15 if (!ASSERT_OK_PTR(skel, "struct_ops_private_stack__open")) 17 16 return; 18 - 19 - if (skel->data->skip) { 20 - test__skip(); 21 - goto cleanup; 22 - } 23 17 24 18 err = struct_ops_private_stack__load(skel); 25 19 if (!ASSERT_OK(err, "struct_ops_private_stack__load")) ··· 44 48 if (!ASSERT_OK_PTR(skel, "struct_ops_private_stack_fail__open")) 45 49 return; 46 50 47 - if (skel->data->skip) { 48 - test__skip(); 49 - goto cleanup; 50 - } 51 - 52 51 err = struct_ops_private_stack_fail__load(skel); 53 52 ASSERT_ERR(err, "struct_ops_private_stack_fail__load"); 54 53 55 - cleanup: 56 54 struct_ops_private_stack_fail__destroy(skel); 57 55 } 58 56 ··· 59 69 skel = struct_ops_private_stack_recur__open(); 60 70 if (!ASSERT_OK_PTR(skel, "struct_ops_private_stack_recur__open")) 61 71 return; 62 - 63 - if (skel->data->skip) { 64 - test__skip(); 65 - goto cleanup; 66 - } 67 72 68 73 err = struct_ops_private_stack_recur__load(skel); 69 74 if (!ASSERT_OK(err, "struct_ops_private_stack_recur__load")) ··· 78 93 struct_ops_private_stack_recur__destroy(skel); 79 94 } 80 95 81 - void test_struct_ops_private_stack(void) 96 + static void __test_struct_ops_private_stack(void) 82 97 { 83 98 if (test__start_subtest("private_stack")) 84 99 test_private_stack(); ··· 86 101 test_private_stack_fail(); 87 102 if (test__start_subtest("private_stack_recur")) 88 103 test_private_stack_recur(); 104 + } 105 + #else 106 + static void __test_struct_ops_private_stack(void) 107 + { 108 + test__skip(); 109 + } 110 + #endif 111 + 112 + void test_struct_ops_private_stack(void) 113 + { 114 + __test_struct_ops_private_stack(); 89 115 }
-6
tools/testing/selftests/bpf/progs/struct_ops_private_stack.c
··· 7 7 8 8 char _license[] SEC("license") = "GPL"; 9 9 10 - #if defined(__TARGET_ARCH_x86) || defined(__TARGET_ARCH_arm64) 11 - bool skip __attribute((__section__(".data"))) = false; 12 - #else 13 - bool skip = true; 14 - #endif 15 - 16 10 void bpf_testmod_ops3_call_test_2(void) __ksym; 17 11 18 12 int val_i, val_j;
-6
tools/testing/selftests/bpf/progs/struct_ops_private_stack_fail.c
··· 7 7 8 8 char _license[] SEC("license") = "GPL"; 9 9 10 - #if defined(__TARGET_ARCH_x86) || defined(__TARGET_ARCH_arm64) 11 - bool skip __attribute((__section__(".data"))) = false; 12 - #else 13 - bool skip = true; 14 - #endif 15 - 16 10 void bpf_testmod_ops3_call_test_2(void) __ksym; 17 11 18 12 int val_i, val_j;
-6
tools/testing/selftests/bpf/progs/struct_ops_private_stack_recur.c
··· 7 7 8 8 char _license[] SEC("license") = "GPL"; 9 9 10 - #if defined(__TARGET_ARCH_x86) || defined(__TARGET_ARCH_arm64) 11 - bool skip __attribute((__section__(".data"))) = false; 12 - #else 13 - bool skip = true; 14 - #endif 15 - 16 10 void bpf_testmod_ops3_call_test_1(void) __ksym; 17 11 18 12 int val_i, val_j;
+2 -2
tools/testing/selftests/bpf/progs/verifier_gotox.c
··· 6 6 #include "bpf_misc.h" 7 7 #include "../../../include/linux/filter.h" 8 8 9 - #if defined(__TARGET_ARCH_x86) || defined(__TARGET_ARCH_arm64) 9 + #if defined(__TARGET_ARCH_x86) || defined(__TARGET_ARCH_arm64) || defined(__TARGET_ARCH_powerpc) 10 10 11 11 #define DEFINE_SIMPLE_JUMP_TABLE_PROG(NAME, SRC_REG, OFF, IMM, OUTCOME) \ 12 12 \ ··· 384 384 : __clobber_all); 385 385 } 386 386 387 - #endif /* __TARGET_ARCH_x86 || __TARGET_ARCH_arm64 */ 387 + #endif /* __TARGET_ARCH_x86 || __TARGET_ARCH_arm64 || __TARGET_ARCH_powerpc*/ 388 388 389 389 char _license[] SEC("license") = "GPL";
+1 -1
tools/testing/selftests/powerpc/vphn/Makefile
··· 5 5 include ../../lib.mk 6 6 include ../flags.mk 7 7 8 - CFLAGS += -m64 -I$(CURDIR) 8 + CFLAGS += -m64 -I$(CURDIR) -fno-strict-aliasing 9 9 10 10 $(TEST_GEN_PROGS): ../harness.c 11 11