Merge tag 'powerpc-4.20-4' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux

Pull powerpc fixes from Michael Ellerman:
"One notable fix for our change to split pt_regs between user/kernel,
we forgot to update BPF to use the user-visible type which was an ABI
break for BPF programs.

A slightly ugly but minimal fix to do_syscall_trace_enter() so that we
use tracehook_report_syscall_entry() properly. We'll rework the code
in next to avoid the empty if body.

Seven commits fixing bugs in the new papr_scm (Storage Class Memory)
driver. The driver was finally able to be tested on the other
hypervisor which exposed several bugs. The fixes are all fairly
minimal at least.

Fix a crash in our MSI code if an MSI-capable device is plugged into a
non-MSI capable PHB, only seen on older hardware (MPC8378).

Fix our legacy serial code to look for "stdout-path" since the device
trees were updated to use that instead of "linux,stdout-path".

A change to the COFF zImage code to fix booting old powermacs.

A couple of minor build fixes.

Thanks to: Benjamin Herrenschmidt, Daniel Axtens, Dmitry V. Levin,
Elvira Khabirova, Oliver O'Halloran, Paul Mackerras, Radu Rendec, Rob
Herring, Sandipan Das"

* tag 'powerpc-4.20-4' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux:
powerpc/ptrace: replace ptrace_report_syscall() with a tracehook call
powerpc/mm: Fallback to RAM if the altmap is unusable
powerpc/papr_scm: Use ibm,unit-guid as the iset cookie
powerpc/papr_scm: Fix DIMM device registration race
powerpc/papr_scm: Remove endian conversions
powerpc/papr_scm: Update DT properties
powerpc/papr_scm: Fix resource end address
powerpc/papr_scm: Use depend instead of select
powerpc/bpf: Fix broken uapi for BPF_PROG_TYPE_PERF_EVENT
powerpc/boot: Fix build failures with -j 1
powerpc: Look for "stdout-path" when setting up legacy consoles
powerpc/msi: Fix NULL pointer access in teardown code
powerpc/mm: Fix linux page tables build with some configs
powerpc: Fix COFF zImage booting on old powermacs

+80 -20
+1 -1
arch/powerpc/boot/Makefile
··· 197 $(obj)/zImage.coff.lds $(obj)/zImage.ps3.lds : $(obj)/%: $(srctree)/$(src)/%.S 198 $(Q)cp $< $@ 199 200 - $(obj)/serial.c: $(obj)/autoconf.h 201 202 $(obj)/autoconf.h: $(obj)/%: $(objtree)/include/generated/% 203 $(Q)cp $< $@
··· 197 $(obj)/zImage.coff.lds $(obj)/zImage.ps3.lds : $(obj)/%: $(srctree)/$(src)/%.S 198 $(Q)cp $< $@ 199 200 + $(srctree)/$(src)/serial.c: $(obj)/autoconf.h 201 202 $(obj)/autoconf.h: $(obj)/%: $(objtree)/include/generated/% 203 $(Q)cp $< $@
+3 -1
arch/powerpc/boot/crt0.S
··· 15 RELA = 7 16 RELACOUNT = 0x6ffffff9 17 18 - .text 19 /* A procedure descriptor used when booting this as a COFF file. 20 * When making COFF, this comes first in the link and we're 21 * linked at 0x500000. ··· 23 .globl _zimage_start_opd 24 _zimage_start_opd: 25 .long 0x500000, 0, 0, 0 26 27 #ifdef __powerpc64__ 28 .balign 8
··· 15 RELA = 7 16 RELACOUNT = 0x6ffffff9 17 18 + .data 19 /* A procedure descriptor used when booting this as a COFF file. 20 * When making COFF, this comes first in the link and we're 21 * linked at 0x500000. ··· 23 .globl _zimage_start_opd 24 _zimage_start_opd: 25 .long 0x500000, 0, 0, 0 26 + .text 27 + b _zimage_start 28 29 #ifdef __powerpc64__ 30 .balign 8
+2
arch/powerpc/include/asm/perf_event.h
··· 26 #include <asm/ptrace.h> 27 #include <asm/reg.h> 28 29 /* 30 * Overload regs->result to specify whether we should use the MSR (result 31 * is zero) or the SIAR (result is non zero).
··· 26 #include <asm/ptrace.h> 27 #include <asm/reg.h> 28 29 + #define perf_arch_bpf_user_pt_regs(regs) &regs->user_regs 30 + 31 /* 32 * Overload regs->result to specify whether we should use the MSR (result 33 * is zero) or the SIAR (result is non zero).
-1
arch/powerpc/include/uapi/asm/Kbuild
··· 1 # UAPI Header export list 2 include include/uapi/asm-generic/Kbuild.asm 3 4 - generic-y += bpf_perf_event.h 5 generic-y += param.h 6 generic-y += poll.h 7 generic-y += resource.h
··· 1 # UAPI Header export list 2 include include/uapi/asm-generic/Kbuild.asm 3 4 generic-y += param.h 5 generic-y += poll.h 6 generic-y += resource.h
+9
arch/powerpc/include/uapi/asm/bpf_perf_event.h
···
··· 1 + /* SPDX-License-Identifier: GPL-2.0 */ 2 + #ifndef _UAPI__ASM_BPF_PERF_EVENT_H__ 3 + #define _UAPI__ASM_BPF_PERF_EVENT_H__ 4 + 5 + #include <asm/ptrace.h> 6 + 7 + typedef struct user_pt_regs bpf_user_pt_regs_t; 8 + 9 + #endif /* _UAPI__ASM_BPF_PERF_EVENT_H__ */
+5 -1
arch/powerpc/kernel/legacy_serial.c
··· 372 373 /* Now find out if one of these is out firmware console */ 374 path = of_get_property(of_chosen, "linux,stdout-path", NULL); 375 if (path != NULL) { 376 stdout = of_find_node_by_path(path); 377 if (stdout) ··· 597 /* We are getting a weird phandle from OF ... */ 598 /* ... So use the full path instead */ 599 name = of_get_property(of_chosen, "linux,stdout-path", NULL); 600 if (name == NULL) { 601 - DBG(" no linux,stdout-path !\n"); 602 return -ENODEV; 603 } 604 prom_stdout = of_find_node_by_path(name);
··· 372 373 /* Now find out if one of these is out firmware console */ 374 path = of_get_property(of_chosen, "linux,stdout-path", NULL); 375 + if (path == NULL) 376 + path = of_get_property(of_chosen, "stdout-path", NULL); 377 if (path != NULL) { 378 stdout = of_find_node_by_path(path); 379 if (stdout) ··· 595 /* We are getting a weird phandle from OF ... */ 596 /* ... So use the full path instead */ 597 name = of_get_property(of_chosen, "linux,stdout-path", NULL); 598 + if (name == NULL) 599 + name = of_get_property(of_chosen, "stdout-path", NULL); 600 if (name == NULL) { 601 + DBG(" no stdout-path !\n"); 602 return -ENODEV; 603 } 604 prom_stdout = of_find_node_by_path(name);
+6 -1
arch/powerpc/kernel/msi.c
··· 34 { 35 struct pci_controller *phb = pci_bus_to_host(dev->bus); 36 37 - phb->controller_ops.teardown_msi_irqs(dev); 38 }
··· 34 { 35 struct pci_controller *phb = pci_bus_to_host(dev->bus); 36 37 + /* 38 + * We can be called even when arch_setup_msi_irqs() returns -ENOSYS, 39 + * so check the pointer again. 40 + */ 41 + if (phb->controller_ops.teardown_msi_irqs) 42 + phb->controller_ops.teardown_msi_irqs(dev); 43 }
+6 -1
arch/powerpc/kernel/ptrace.c
··· 3266 user_exit(); 3267 3268 if (test_thread_flag(TIF_SYSCALL_EMU)) { 3269 - ptrace_report_syscall(regs); 3270 /* 3271 * Returning -1 will skip the syscall execution. We want to 3272 * avoid clobbering any register also, thus, not 'gotoing' 3273 * skip label. 3274 */ 3275 return -1; 3276 } 3277
··· 3266 user_exit(); 3267 3268 if (test_thread_flag(TIF_SYSCALL_EMU)) { 3269 /* 3270 + * A nonzero return code from tracehook_report_syscall_entry() 3271 + * tells us to prevent the syscall execution, but we are not 3272 + * going to execute it anyway. 3273 + * 3274 * Returning -1 will skip the syscall execution. We want to 3275 * avoid clobbering any register also, thus, not 'gotoing' 3276 * skip label. 3277 */ 3278 + if (tracehook_report_syscall_entry(regs)) 3279 + ; 3280 return -1; 3281 } 3282
+1
arch/powerpc/mm/dump_linuxpagetables.c
··· 19 #include <linux/hugetlb.h> 20 #include <linux/io.h> 21 #include <linux/mm.h> 22 #include <linux/sched.h> 23 #include <linux/seq_file.h> 24 #include <asm/fixmap.h>
··· 19 #include <linux/hugetlb.h> 20 #include <linux/io.h> 21 #include <linux/mm.h> 22 + #include <linux/highmem.h> 23 #include <linux/sched.h> 24 #include <linux/seq_file.h> 25 #include <asm/fixmap.h>
+16 -3
arch/powerpc/mm/init_64.c
··· 188 pr_debug("vmemmap_populate %lx..%lx, node %d\n", start, end, node); 189 190 for (; start < end; start += page_size) { 191 - void *p; 192 int rc; 193 194 if (vmemmap_populated(start, page_size)) 195 continue; 196 197 if (altmap) 198 p = altmap_alloc_block_buf(page_size, altmap); 199 - else 200 p = vmemmap_alloc_block_buf(page_size, node); 201 if (!p) 202 return -ENOMEM; ··· 260 { 261 unsigned long page_size = 1 << mmu_psize_defs[mmu_vmemmap_psize].shift; 262 unsigned long page_order = get_order(page_size); 263 264 start = _ALIGN_DOWN(start, page_size); 265 266 pr_debug("vmemmap_free %lx...%lx\n", start, end); 267 ··· 292 page = pfn_to_page(addr >> PAGE_SHIFT); 293 section_base = pfn_to_page(vmemmap_section_start(start)); 294 nr_pages = 1 << page_order; 295 296 - if (altmap) { 297 vmem_altmap_free(altmap, nr_pages); 298 } else if (PageReserved(page)) { 299 /* allocated from bootmem */
··· 188 pr_debug("vmemmap_populate %lx..%lx, node %d\n", start, end, node); 189 190 for (; start < end; start += page_size) { 191 + void *p = NULL; 192 int rc; 193 194 if (vmemmap_populated(start, page_size)) 195 continue; 196 197 + /* 198 + * Allocate from the altmap first if we have one. This may 199 + * fail due to alignment issues when using 16MB hugepages, so 200 + * fall back to system memory if the altmap allocation fail. 201 + */ 202 if (altmap) 203 p = altmap_alloc_block_buf(page_size, altmap); 204 + if (!p) 205 p = vmemmap_alloc_block_buf(page_size, node); 206 if (!p) 207 return -ENOMEM; ··· 255 { 256 unsigned long page_size = 1 << mmu_psize_defs[mmu_vmemmap_psize].shift; 257 unsigned long page_order = get_order(page_size); 258 + unsigned long alt_start = ~0, alt_end = ~0; 259 + unsigned long base_pfn; 260 261 start = _ALIGN_DOWN(start, page_size); 262 + if (altmap) { 263 + alt_start = altmap->base_pfn; 264 + alt_end = altmap->base_pfn + altmap->reserve + 265 + altmap->free + altmap->alloc + altmap->align; 266 + } 267 268 pr_debug("vmemmap_free %lx...%lx\n", start, end); 269 ··· 280 page = pfn_to_page(addr >> PAGE_SHIFT); 281 section_base = pfn_to_page(vmemmap_section_start(start)); 282 nr_pages = 1 << page_order; 283 + base_pfn = PHYS_PFN(addr); 284 285 + if (base_pfn >= alt_start && base_pfn < alt_end) { 286 vmem_altmap_free(altmap, nr_pages); 287 } else if (PageReserved(page)) { 288 /* allocated from bootmem */
+1 -2
arch/powerpc/platforms/pseries/Kconfig
··· 140 Bus device driver for GX bus based adapters. 141 142 config PAPR_SCM 143 - depends on PPC_PSERIES && MEMORY_HOTPLUG 144 - select LIBNVDIMM 145 tristate "Support for the PAPR Storage Class Memory interface" 146 help 147 Enable access to hypervisor provided storage class memory.
··· 140 Bus device driver for GX bus based adapters. 141 142 config PAPR_SCM 143 + depends on PPC_PSERIES && MEMORY_HOTPLUG && LIBNVDIMM 144 tristate "Support for the PAPR Storage Class Memory interface" 145 help 146 Enable access to hypervisor provided storage class memory.
+30 -9
arch/powerpc/platforms/pseries/papr_scm.c
··· 55 do { 56 rc = plpar_hcall(H_SCM_BIND_MEM, ret, p->drc_index, 0, 57 p->blocks, BIND_ANY_ADDR, token); 58 - token = be64_to_cpu(ret[0]); 59 cond_resched(); 60 } while (rc == H_BUSY); 61 ··· 64 return -ENXIO; 65 } 66 67 - p->bound_addr = be64_to_cpu(ret[1]); 68 69 dev_dbg(&p->pdev->dev, "bound drc %x to %pR\n", p->drc_index, &p->res); 70 ··· 82 do { 83 rc = plpar_hcall(H_SCM_UNBIND_MEM, ret, p->drc_index, 84 p->bound_addr, p->blocks, token); 85 - token = be64_to_cpu(ret); 86 cond_resched(); 87 } while (rc == H_BUSY); 88 ··· 223 goto err; 224 } 225 226 /* now add the region */ 227 228 memset(&mapping, 0, sizeof(mapping)); ··· 260 261 static int papr_scm_probe(struct platform_device *pdev) 262 { 263 - uint32_t drc_index, metadata_size, unit_cap[2]; 264 struct device_node *dn = pdev->dev.of_node; 265 struct papr_scm_priv *p; 266 int rc; 267 268 /* check we have all the required DT properties */ ··· 274 return -ENODEV; 275 } 276 277 - if (of_property_read_u32_array(dn, "ibm,unit-capacity", unit_cap, 2)) { 278 - dev_err(&pdev->dev, "%pOF: missing unit-capacity!\n", dn); 279 return -ENODEV; 280 } 281 ··· 298 299 p->dn = dn; 300 p->drc_index = drc_index; 301 - p->block_size = unit_cap[0]; 302 - p->blocks = unit_cap[1]; 303 304 /* might be zero */ 305 p->metadata_size = metadata_size; ··· 317 318 /* setup the resource for the newly bound range */ 319 p->res.start = p->bound_addr; 320 - p->res.end = p->bound_addr + p->blocks * p->block_size; 321 p->res.name = pdev->name; 322 p->res.flags = IORESOURCE_MEM; 323
··· 55 do { 56 rc = plpar_hcall(H_SCM_BIND_MEM, ret, p->drc_index, 0, 57 p->blocks, BIND_ANY_ADDR, token); 58 + token = ret[0]; 59 cond_resched(); 60 } while (rc == H_BUSY); 61 ··· 64 return -ENXIO; 65 } 66 67 + p->bound_addr = ret[1]; 68 69 dev_dbg(&p->pdev->dev, "bound drc %x to %pR\n", p->drc_index, &p->res); 70 ··· 82 do { 83 rc = plpar_hcall(H_SCM_UNBIND_MEM, ret, p->drc_index, 84 p->bound_addr, p->blocks, token); 85 + token = ret[0]; 86 cond_resched(); 87 } while (rc == H_BUSY); 88 ··· 223 goto err; 224 } 225 226 + if (nvdimm_bus_check_dimm_count(p->bus, 1)) 227 + goto err; 228 + 229 /* now add the region */ 230 231 memset(&mapping, 0, sizeof(mapping)); ··· 257 258 static int papr_scm_probe(struct platform_device *pdev) 259 { 260 struct device_node *dn = pdev->dev.of_node; 261 + u32 drc_index, metadata_size; 262 + u64 blocks, block_size; 263 struct papr_scm_priv *p; 264 + const char *uuid_str; 265 + u64 uuid[2]; 266 int rc; 267 268 /* check we have all the required DT properties */ ··· 268 return -ENODEV; 269 } 270 271 + if (of_property_read_u64(dn, "ibm,block-size", &block_size)) { 272 + dev_err(&pdev->dev, "%pOF: missing block-size!\n", dn); 273 + return -ENODEV; 274 + } 275 + 276 + if (of_property_read_u64(dn, "ibm,number-of-blocks", &blocks)) { 277 + dev_err(&pdev->dev, "%pOF: missing number-of-blocks!\n", dn); 278 + return -ENODEV; 279 + } 280 + 281 + if (of_property_read_string(dn, "ibm,unit-guid", &uuid_str)) { 282 + dev_err(&pdev->dev, "%pOF: missing unit-guid!\n", dn); 283 return -ENODEV; 284 } 285 ··· 282 283 p->dn = dn; 284 p->drc_index = drc_index; 285 + p->block_size = block_size; 286 + p->blocks = blocks; 287 + 288 + /* We just need to ensure that set cookies are unique across */ 289 + uuid_parse(uuid_str, (uuid_t *) uuid); 290 + p->nd_set.cookie1 = uuid[0]; 291 + p->nd_set.cookie2 = uuid[1]; 292 293 /* might be zero */ 294 p->metadata_size = metadata_size; ··· 296 297 /* setup the resource for the newly bound range */ 298 p->res.start = p->bound_addr; 299 + p->res.end = p->bound_addr + p->blocks * p->block_size - 1; 300 p->res.name = pdev->name; 301 p->res.flags = IORESOURCE_MEM; 302