Re: [PATCH kernel] pseries/iommu/ddw: Fix kdump to work in absence of ibm,dma-window
On 6/27/22 14:10, Russell Currey wrote: On Thu, 2022-06-16 at 17:59 +1000, Alexey Kardashevskiy wrote: The pseries platform uses 32bit default DMA window (always 4K pages) and optional 64bit DMA window available via DDW ("Dynamic DMA Windows"), 64K or 2M pages. For ages the default one was not removed and a huge window was created in addition. Things changed with SRIOV-enabled PowerVM which creates a default-and-bigger DMA window in 64bit space (still using 4K pages) for IOV VFs so certain OSes do not need to use the DDW API in order to utilize all available TCE budget. Linux on the other hand removes the default window and creates a bigger one (with more TCEs or/and a bigger page size - 64K/2M) in a bid to map the entire RAM, and if the new window size is smaller than that - it still uses this new bigger window. The result is that the default window is removed but the "ibm,dma-window" property is not. When kdump is invoked, the existing code tries reusing the existing 64bit DMA window which location and parameters are stored in the device tree but this fails as the new property does not make it to the kdump device tree blob. So the code falls back to the default window which does not exist anymore although the device tree says that it does. The result of that is that PCI devices become unusable and cannot be used for kdumping. This preserves the DMA64 and DIRECT64 properties in the device tree blob for the crash kernel. Since the crash kernel setup is done after device drivers are loaded and probed, the proper DMA config is stored at least for boot time devices. Because DDW window is optional and the code configures the default window first, the existing code creates an IOMMU table descriptor for the non-existing default DMA window. It is harmless for kdump as it does not touch the actual window (only reads what is mapped and marks those IO pages as used) but it is bad for kexec which clears it thinking it is a smaller default window rather than a bigger DDW window. This removes the "ibm,dma-window" property from the device tree after a bigger window is created and the crash kernel setup picks it up. Signed-off-by: Alexey Kardashevskiy Hey Alexey, great description of the problem. Would this need a Fixes: tag? May be. But which patch does it fix really - the one which did not preserve the dma64 properties or the one which started removing the default window? :) --- arch/powerpc/kexec/file_load_64.c | 52 +++ arch/powerpc/platforms/pseries/iommu.c | 88 +++- -- 2 files changed, 102 insertions(+), 38 deletions(-) diff --git a/arch/powerpc/kexec/file_load_64.c b/arch/powerpc/kexec/file_load_64.c index b4981b651d9a..b4b486b68b63 100644 --- a/arch/powerpc/kexec/file_load_64.c +++ b/arch/powerpc/kexec/file_load_64.c @@ -1038,6 +1038,48 @@ static int update_cpus_node(void *fdt) return ret; } +static int copy_dma_property(void *fdt, int node_offset, const struct device_node *dn, + const char *propname) +{ + const void *prop, *fdtprop; + int len = 0, fdtlen = 0, ret; + + prop = of_get_property(dn, propname, ); + fdtprop = fdt_getprop(fdt, node_offset, propname, ); + + if (fdtprop && !prop) + ret = fdt_delprop(fdt, node_offset, propname); + else if (prop) + ret = fdt_setprop(fdt, node_offset, propname, prop, len); If fdtprop and prop are both false, ret is returned uninitialised. + + return ret; +} + +static int update_pci_nodes(void *fdt, const char *dmapropname) +{ + struct device_node *dn; + int pci_offset, root_offset, ret = 0; + + if (!firmware_has_feature(FW_FEATURE_LPAR)) + return 0; + + root_offset = fdt_path_offset(fdt, "/"); + for_each_node_with_property(dn, dmapropname) { + pci_offset = fdt_subnode_offset(fdt, root_offset, of_node_full_name(dn)); + if (pci_offset < 0) + continue; + + ret = copy_dma_property(fdt, pci_offset, dn, "ibm,dma-window"); + if (ret < 0) + break; + ret = copy_dma_property(fdt, pci_offset, dn, dmapropname); + if (ret < 0) + break; + } + + return ret; +} + /** * setup_new_fdt_ppc64 - Update the flattend device-tree of the kernel * being loaded. @@ -1099,6 +1141,16 @@ int setup_new_fdt_ppc64(const struct kimage *image, void *fdt, if (ret < 0) goto out; +#define DIRECT64_PROPNAME "linux,direct64-ddr-window-info" +#define DMA64_PROPNAME "linux,dma64-ddr-window-info" Instead of having these defined in two different places, could they be moved out of iommu.c and into a header? Though we hardcode ibm,dma- window everywhere anyway. These properties are for pseries only and making them visible to other platforms seemed too much (I should have
Re: [PATCH v2 3/3] arch/*/: remove CONFIG_VIRT_TO_BUS
Hii Geert Am 28.06.2022 um 09:12 schrieb Michael Schmitz: Hi Geert, On 27/06/22 20:26, Geert Uytterhoeven wrote: Hi Michael, On Sat, Jun 18, 2022 at 3:06 AM Michael Schmitz wrote: Am 18.06.2022 um 00:57 schrieb Arnd Bergmann: From: Arnd Bergmann All architecture-independent users of virt_to_bus() and bus_to_virt() have been fixed to use the dma mapping interfaces or have been removed now. This means the definitions on most architectures, and the CONFIG_VIRT_TO_BUS symbol are now obsolete and can be removed. The only exceptions to this are a few network and scsi drivers for m68k Amiga and VME machines and ppc32 Macintosh. These drivers work correctly with the old interfaces and are probably not worth changing. The Amiga SCSI drivers are all old WD33C93 ones, and replacing virt_to_bus by virt_to_phys in the dma_setup() function there would cause no functional change at all. FTR, the sgiwd93 driver use dma_map_single(). Thanks! From what I see, it doesn't have to deal with bounce buffers though? Leaving the bounce buffer handling in place, and taking a few other liberties - this is what converting the easiest case (a3000 SCSI) might look like. Any obvious mistakes? The mvme147 driver would be very similar to handle (after conversion to a platform device). The driver allocates bounce buffers using kmalloc if it hits an unaligned data buffer - can such buffers still even happen these days? If I understand dma_map_single() correctly, the resulting dma handle would be equally misaligned? To allocate a bounce buffer, would it be OK to use dma_alloc_coherent() even though AFAIU memory used for DMA buffers generally isn't consistent on m68k? Thinking ahead to the other two Amiga drivers - I wonder whether allocating a static bounce buffer or a DMA pool at driver init is likely to succeed if the kernel runs from the low 16 MB RAM chunk? It certainly won't succeed if the kernel runs from a higher memory address, so the present bounce buffer logic around amiga_chip_alloc() might still need to be used here. Leaves the question whether converting the gvp11 and a2091 drivers is actually worth it, if bounce buffers still have to be handled explicitly. Untested (except for compile testing), un-checkpatched, don't try this on any disk with valuable data ... Cheers, Michael >From e8c6aa068d27901c49dfb7442d4200cc966350a5 Mon Sep 17 00:00:00 2001 From: Michael Schmitz Date: Tue, 28 Jun 2022 12:45:08 +1200 Subject: [PATCH] scsi - convert m68k WD33C93 drivers to DMA API Use dma_map_single() for gvp11 driver (leave bounce buffer logic unchanged). Compile-tested only. Signed-off-by: Michael Schmitz --- drivers/scsi/a3000.c | 22 -- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/a3000.c b/drivers/scsi/a3000.c index dd161885eed1..3c62e8bafb8f 100644 --- a/drivers/scsi/a3000.c +++ b/drivers/scsi/a3000.c @@ -7,6 +7,7 @@ #include #include #include +#include #include #include @@ -25,8 +26,11 @@ struct a3000_hostdata { struct WD33C93_hostdata wh; struct a3000_scsiregs *regs; + struct device *dev; }; +#define DMA_DIR(d) ((d == DATA_OUT_DIR) ? DMA_TO_DEVICE : DMA_FROM_DEVICE) + static irqreturn_t a3000_intr(int irq, void *data) { struct Scsi_Host *instance = data; @@ -49,12 +53,16 @@ static irqreturn_t a3000_intr(int irq, void *data) static int dma_setup(struct scsi_cmnd *cmd, int dir_in) { struct scsi_pointer *scsi_pointer = WD33C93_scsi_pointer(cmd); + unsigned long len = scsi_pointer->this_residual; struct Scsi_Host *instance = cmd->device->host; struct a3000_hostdata *hdata = shost_priv(instance); struct WD33C93_hostdata *wh = >wh; struct a3000_scsiregs *regs = hdata->regs; unsigned short cntr = CNTR_PDMD | CNTR_INTEN; - unsigned long addr = virt_to_bus(scsi_pointer->ptr); + dma_addr_t addr; + + addr = dma_map_single(hdata->dev, scsi_pointer->ptr, len, DMA_DIR(dir_in)); + scsi_pointer->dma_handle = addr; /* * if the physical address has the wrong alignment, or if @@ -79,7 +87,7 @@ static int dma_setup(struct scsi_cmnd *cmd, int dir_in) scsi_pointer->this_residual); } - addr = virt_to_bus(wh->dma_bounce_buffer); + addr = virt_to_phys(wh->dma_bounce_buffer); } /* setup dma direction */ @@ -166,6 +174,10 @@ static void dma_stop(struct Scsi_Host *instance, struct scsi_cmnd *SCpnt, wh->dma_bounce_len = 0; } } + dma_unmap_single(hdata->dev, scsi_pointer->dma_handle, + scsi_pointer->this_residual, + DMA_DIR(wh->dma_dir)); + } static struct scsi_host_template amiga_a3000_scsi_template = { @@ -193,6 +205,11 @@ static int __init amiga_a3000_scsi_probe(struct platform_device *pdev) wd33c93_regs wdregs; struct a3000_hostdata *hdata; + if (dma_set_mask(>dev, DMA_BIT_MASK(32))) { + dev_warn(>dev, "cannot use 32 bit DMA\n"); + return -ENODEV; + } + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); if (!res) return -ENODEV; @@ -216,6
Re: [PATCH V5 04/26] sparc/mm: Move protection_map[] inside the platform
On 6/27/22 22:44, Sam Ravnborg wrote: > Hi Anshuman, > > On Mon, Jun 27, 2022 at 10:28:11AM +0530, Anshuman Khandual wrote: >> This moves protection_map[] inside the platform and while here, also enable >> ARCH_HAS_VM_GET_PAGE_PROT on 32 bit platforms via DECLARE_VM_GET_PAGE_PROT. >> >> Cc: "David S. Miller" >> Cc: sparcli...@vger.kernel.org >> Cc: linux-ker...@vger.kernel.org >> Signed-off-by: Anshuman Khandual >> --- >> arch/sparc/Kconfig | 2 +- >> arch/sparc/include/asm/pgtable_32.h | 19 --- >> arch/sparc/include/asm/pgtable_64.h | 19 --- >> arch/sparc/mm/init_32.c | 20 >> arch/sparc/mm/init_64.c | 3 +++ >> 5 files changed, 24 insertions(+), 39 deletions(-) >> >> diff --git a/arch/sparc/Kconfig b/arch/sparc/Kconfig >> index ba449c47effd..09f868613a4d 100644 >> --- a/arch/sparc/Kconfig >> +++ b/arch/sparc/Kconfig >> @@ -13,6 +13,7 @@ config 64BIT >> config SPARC >> bool >> default y >> +select ARCH_HAS_VM_GET_PAGE_PROT >> select ARCH_MIGHT_HAVE_PC_PARPORT if SPARC64 && PCI >> select ARCH_MIGHT_HAVE_PC_SERIO >> select DMA_OPS >> @@ -84,7 +85,6 @@ config SPARC64 >> select PERF_USE_VMALLOC >> select ARCH_HAVE_NMI_SAFE_CMPXCHG >> select HAVE_C_RECORDMCOUNT >> -select ARCH_HAS_VM_GET_PAGE_PROT >> select HAVE_ARCH_AUDITSYSCALL >> select ARCH_SUPPORTS_ATOMIC_RMW >> select ARCH_SUPPORTS_DEBUG_PAGEALLOC >> diff --git a/arch/sparc/include/asm/pgtable_32.h >> b/arch/sparc/include/asm/pgtable_32.h >> index 4866625da314..8ff549004fac 100644 >> --- a/arch/sparc/include/asm/pgtable_32.h >> +++ b/arch/sparc/include/asm/pgtable_32.h >> @@ -64,25 +64,6 @@ void paging_init(void); >> >> extern unsigned long ptr_in_current_pgd; >> >> -/* xwr */ >> -#define __P000 PAGE_NONE >> -#define __P001 PAGE_READONLY >> -#define __P010 PAGE_COPY >> -#define __P011 PAGE_COPY >> -#define __P100 PAGE_READONLY >> -#define __P101 PAGE_READONLY >> -#define __P110 PAGE_COPY >> -#define __P111 PAGE_COPY >> - >> -#define __S000 PAGE_NONE >> -#define __S001 PAGE_READONLY >> -#define __S010 PAGE_SHARED >> -#define __S011 PAGE_SHARED >> -#define __S100 PAGE_READONLY >> -#define __S101 PAGE_READONLY >> -#define __S110 PAGE_SHARED >> -#define __S111 PAGE_SHARED >> - >> /* First physical page can be anywhere, the following is needed so that >> * va-->pa and vice versa conversions work properly without performance >> * hit for all __pa()/__va() operations. >> diff --git a/arch/sparc/include/asm/pgtable_64.h >> b/arch/sparc/include/asm/pgtable_64.h >> index 4679e45c8348..a779418ceba9 100644 >> --- a/arch/sparc/include/asm/pgtable_64.h >> +++ b/arch/sparc/include/asm/pgtable_64.h >> @@ -187,25 +187,6 @@ bool kern_addr_valid(unsigned long addr); >> #define _PAGE_SZHUGE_4U _PAGE_SZ4MB_4U >> #define _PAGE_SZHUGE_4V _PAGE_SZ4MB_4V >> >> -/* These are actually filled in at boot time by sun4{u,v}_pgprot_init() */ >> -#define __P000 __pgprot(0) >> -#define __P001 __pgprot(0) >> -#define __P010 __pgprot(0) >> -#define __P011 __pgprot(0) >> -#define __P100 __pgprot(0) >> -#define __P101 __pgprot(0) >> -#define __P110 __pgprot(0) >> -#define __P111 __pgprot(0) >> - >> -#define __S000 __pgprot(0) >> -#define __S001 __pgprot(0) >> -#define __S010 __pgprot(0) >> -#define __S011 __pgprot(0) >> -#define __S100 __pgprot(0) >> -#define __S101 __pgprot(0) >> -#define __S110 __pgprot(0) >> -#define __S111 __pgprot(0) >> - >> #ifndef __ASSEMBLY__ >> >> pte_t mk_pte_io(unsigned long, pgprot_t, int, unsigned long); >> diff --git a/arch/sparc/mm/init_32.c b/arch/sparc/mm/init_32.c >> index 1e9f577f084d..8693e4e28b86 100644 >> --- a/arch/sparc/mm/init_32.c >> +++ b/arch/sparc/mm/init_32.c >> @@ -302,3 +302,23 @@ void sparc_flush_page_to_ram(struct page *page) >> __flush_page_to_ram(vaddr); >> } >> EXPORT_SYMBOL(sparc_flush_page_to_ram); >> + >> +static pgprot_t protection_map[16] __ro_after_init = { > This can be const - like done for powerpc and others. > sparc32 and sparc64 uses each their own - and I do not see sparc32 do > any modifications to protection_map. Indeed protection_map[] arrays are independent both for sparc32 and spacr64. sparc32 platform never changes the protection_map[] array during boot. Sure, will make it into a const instead. Thanks for pointing this out. > > With this change: > Reviewed-by: Sam Ravnborg >
Re: [PATCH v3 0/3] phase out CONFIG_VIRT_TO_BUS
Hi Arnd! > If there are no more issues identified with this series, I'll merge it > through the asm-generic tree. The SCSI patches can also get merged > separately through the SCSI maintainers' tree if they prefer. I put patches 1 and 2 in scsi-staging to see if anything breaks... -- Martin K. Petersen Oracle Linux Engineering
[PATCH AUTOSEL 5.4 10/27] powerpc/prom_init: Fix build failure with GCC_PLUGIN_STRUCTLEAK_BYREF_ALL and KASAN
From: Christophe Leroy [ Upstream commit ca5dabcff1df6bc8c413922b5fa63cc602858803 ] When CONFIG_KASAN is selected, we expect prom_init to use __memset() because it is too early to use memset(). But with CONFIG_GCC_PLUGIN_STRUCTLEAK_BYREF_ALL, the compiler adds calls to memset() to clear objects on stack, hence the following failure: PROMCHK arch/powerpc/kernel/prom_init_check Error: External symbol 'memset' referenced from prom_init.c make[2]: *** [arch/powerpc/kernel/Makefile:204 : arch/powerpc/kernel/prom_init_check] Erreur 1 prom_find_machine_type() is called from prom_init() and is called only once, so lets put compat[] in BSS instead of stack to avoid that. Signed-off-by: Christophe Leroy Signed-off-by: Michael Ellerman Link: https://lore.kernel.org/r/3802811f7cf94f730be44688539c01bba3a3b5c0.1654875808.git.christophe.le...@csgroup.eu Signed-off-by: Sasha Levin --- arch/powerpc/kernel/prom_init.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/powerpc/kernel/prom_init.c b/arch/powerpc/kernel/prom_init.c index 7f4e2c031a9a..0391b3225970 100644 --- a/arch/powerpc/kernel/prom_init.c +++ b/arch/powerpc/kernel/prom_init.c @@ -2237,7 +2237,7 @@ static void __init prom_init_stdout(void) static int __init prom_find_machine_type(void) { - char compat[256]; + static char compat[256] __prombss; int len, i = 0; #ifdef CONFIG_PPC64 phandle rtas; -- 2.35.1
[PATCH AUTOSEL 5.10 15/34] powerpc/prom_init: Fix build failure with GCC_PLUGIN_STRUCTLEAK_BYREF_ALL and KASAN
From: Christophe Leroy [ Upstream commit ca5dabcff1df6bc8c413922b5fa63cc602858803 ] When CONFIG_KASAN is selected, we expect prom_init to use __memset() because it is too early to use memset(). But with CONFIG_GCC_PLUGIN_STRUCTLEAK_BYREF_ALL, the compiler adds calls to memset() to clear objects on stack, hence the following failure: PROMCHK arch/powerpc/kernel/prom_init_check Error: External symbol 'memset' referenced from prom_init.c make[2]: *** [arch/powerpc/kernel/Makefile:204 : arch/powerpc/kernel/prom_init_check] Erreur 1 prom_find_machine_type() is called from prom_init() and is called only once, so lets put compat[] in BSS instead of stack to avoid that. Signed-off-by: Christophe Leroy Signed-off-by: Michael Ellerman Link: https://lore.kernel.org/r/3802811f7cf94f730be44688539c01bba3a3b5c0.1654875808.git.christophe.le...@csgroup.eu Signed-off-by: Sasha Levin --- arch/powerpc/kernel/prom_init.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/powerpc/kernel/prom_init.c b/arch/powerpc/kernel/prom_init.c index 9e71c0739f08..03c5ef29bd31 100644 --- a/arch/powerpc/kernel/prom_init.c +++ b/arch/powerpc/kernel/prom_init.c @@ -2265,7 +2265,7 @@ static void __init prom_init_stdout(void) static int __init prom_find_machine_type(void) { - char compat[256]; + static char compat[256] __prombss; int len, i = 0; #ifdef CONFIG_PPC64 phandle rtas; -- 2.35.1
[PATCH AUTOSEL 5.15 18/41] powerpc/prom_init: Fix build failure with GCC_PLUGIN_STRUCTLEAK_BYREF_ALL and KASAN
From: Christophe Leroy [ Upstream commit ca5dabcff1df6bc8c413922b5fa63cc602858803 ] When CONFIG_KASAN is selected, we expect prom_init to use __memset() because it is too early to use memset(). But with CONFIG_GCC_PLUGIN_STRUCTLEAK_BYREF_ALL, the compiler adds calls to memset() to clear objects on stack, hence the following failure: PROMCHK arch/powerpc/kernel/prom_init_check Error: External symbol 'memset' referenced from prom_init.c make[2]: *** [arch/powerpc/kernel/Makefile:204 : arch/powerpc/kernel/prom_init_check] Erreur 1 prom_find_machine_type() is called from prom_init() and is called only once, so lets put compat[] in BSS instead of stack to avoid that. Signed-off-by: Christophe Leroy Signed-off-by: Michael Ellerman Link: https://lore.kernel.org/r/3802811f7cf94f730be44688539c01bba3a3b5c0.1654875808.git.christophe.le...@csgroup.eu Signed-off-by: Sasha Levin --- arch/powerpc/kernel/prom_init.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/powerpc/kernel/prom_init.c b/arch/powerpc/kernel/prom_init.c index f845065c860e..ff685940e272 100644 --- a/arch/powerpc/kernel/prom_init.c +++ b/arch/powerpc/kernel/prom_init.c @@ -2300,7 +2300,7 @@ static void __init prom_init_stdout(void) static int __init prom_find_machine_type(void) { - char compat[256]; + static char compat[256] __prombss; int len, i = 0; #ifdef CONFIG_PPC64 phandle rtas; -- 2.35.1
[PATCH AUTOSEL 5.18 25/53] powerpc/prom_init: Fix build failure with GCC_PLUGIN_STRUCTLEAK_BYREF_ALL and KASAN
From: Christophe Leroy [ Upstream commit ca5dabcff1df6bc8c413922b5fa63cc602858803 ] When CONFIG_KASAN is selected, we expect prom_init to use __memset() because it is too early to use memset(). But with CONFIG_GCC_PLUGIN_STRUCTLEAK_BYREF_ALL, the compiler adds calls to memset() to clear objects on stack, hence the following failure: PROMCHK arch/powerpc/kernel/prom_init_check Error: External symbol 'memset' referenced from prom_init.c make[2]: *** [arch/powerpc/kernel/Makefile:204 : arch/powerpc/kernel/prom_init_check] Erreur 1 prom_find_machine_type() is called from prom_init() and is called only once, so lets put compat[] in BSS instead of stack to avoid that. Signed-off-by: Christophe Leroy Signed-off-by: Michael Ellerman Link: https://lore.kernel.org/r/3802811f7cf94f730be44688539c01bba3a3b5c0.1654875808.git.christophe.le...@csgroup.eu Signed-off-by: Sasha Levin --- arch/powerpc/kernel/prom_init.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/powerpc/kernel/prom_init.c b/arch/powerpc/kernel/prom_init.c index 0ac5faacc909..46247645c134 100644 --- a/arch/powerpc/kernel/prom_init.c +++ b/arch/powerpc/kernel/prom_init.c @@ -2300,7 +2300,7 @@ static void __init prom_init_stdout(void) static int __init prom_find_machine_type(void) { - char compat[256]; + static char compat[256] __prombss; int len, i = 0; #ifdef CONFIG_PPC64 phandle rtas; -- 2.35.1
Re: [RFC PATCH v3 11/12] powerpc: Remove unreachable() from WARN_ON()
On 25/06/22 12:16, Christophe Leroy wrote: Le 24/06/2022 à 20:32, Sathvika Vasireddy a écrit : objtool is throwing *unannotated intra-function call* warnings with a few instructions that are marked unreachable. Remove unreachable() from WARN_ON() to fix these warnings, as the codegen remains same with and without unreachable() in WARN_ON(). Did you try the two exemples described in commit 1e688dd2a3d6 ("powerpc/bug: Provide better flexibility to WARN_ON/__WARN_FLAGS() with asm goto") ? Without your patch: 0640 : 640: 81 23 00 84 lwz r9,132(r3) 644: 71 29 40 00 andi. r9,r9,16384 648: 40 82 00 0c bne 654 64c: 80 63 00 0c lwz r3,12(r3) 650: 4e 80 00 20 blr 654: 0f e0 00 00 twuir0,0 0658 : 658: 2c 04 00 00 cmpwi r4,0 65c: 41 82 00 0c beq 668 660: 7c 63 23 96 divwu r3,r3,r4 664: 4e 80 00 20 blr 668: 0f e0 00 00 twuir0,0 66c: 38 60 00 00 li r3,0 670: 4e 80 00 20 blr With your patch: 0640 : 640: 81 23 00 84 lwz r9,132(r3) 644: 71 29 40 00 andi. r9,r9,16384 648: 40 82 00 0c bne 654 64c: 80 63 00 0c lwz r3,12(r3) 650: 4e 80 00 20 blr 654: 0f e0 00 00 twuir0,0 658: 4b ff ff f4 b 64c <== 065c : 65c: 2c 04 00 00 cmpwi r4,0 660: 41 82 00 0c beq 66c 664: 7c 63 23 96 divwu r3,r3,r4 668: 4e 80 00 20 blr 66c: 0f e0 00 00 twuir0,0 670: 38 60 00 00 li r3,0<== 674: 4e 80 00 20 blr <== 678: 38 60 00 00 li r3,0 67c: 4e 80 00 20 blr The builtin variant of unreachable (__builtin_unreachable()) works, and the codegen remains the same. How about using that instead of unreachable() ? - Sathvika
RE: [PATCH V5 12/26] hexagon/mm: Enable ARCH_HAS_VM_GET_PAGE_PROT
> -Original Message- > From: Anshuman Khandual ... > WARNING: This email originated from outside of Qualcomm. Please be wary > of any links or attachments, and do not enable macros. > > This enables ARCH_HAS_VM_GET_PAGE_PROT on the platform and exports > standard > vm_get_page_prot() implementation via DECLARE_VM_GET_PAGE_PROT, > which looks > up a private and static protection_map[] array. Subsequently all __SXXX and > __PXXX macros can be dropped which are no longer needed. > > Cc: Brian Cain > Cc: linux-hexa...@vger.kernel.org > Cc: linux-ker...@vger.kernel.org > Signed-off-by: Anshuman Khandual > --- > arch/hexagon/Kconfig | 1 + > arch/hexagon/include/asm/pgtable.h | 27 --- > arch/hexagon/mm/init.c | 42 ++ > 3 files changed, 43 insertions(+), 27 deletions(-) > > diff --git a/arch/hexagon/Kconfig b/arch/hexagon/Kconfig > index 54eadf265178..bc4ceecd0588 100644 > --- a/arch/hexagon/Kconfig > +++ b/arch/hexagon/Kconfig > @@ -6,6 +6,7 @@ config HEXAGON > def_bool y > select ARCH_32BIT_OFF_T > select ARCH_HAS_SYNC_DMA_FOR_DEVICE > + select ARCH_HAS_VM_GET_PAGE_PROT > select ARCH_NO_PREEMPT > select DMA_GLOBAL_POOL > # Other pending projects/to-do items. > diff --git a/arch/hexagon/include/asm/pgtable.h > b/arch/hexagon/include/asm/pgtable.h > index 0610724d6a28..f7048c18b6f9 100644 > --- a/arch/hexagon/include/asm/pgtable.h > +++ b/arch/hexagon/include/asm/pgtable.h > @@ -126,33 +126,6 @@ extern unsigned long _dflt_cache_att; > */ > #define CACHEDEF (CACHE_DEFAULT << 6) > > -/* Private (copy-on-write) page protections. */ > -#define __P000 __pgprot(_PAGE_PRESENT | _PAGE_USER | CACHEDEF) > -#define __P001 __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | > CACHEDEF) > -#define __P010 __P000 /* Write-only copy-on-write */ > -#define __P011 __P001 /* Read/Write copy-on-write */ > -#define __P100 __pgprot(_PAGE_PRESENT | _PAGE_USER | \ > - _PAGE_EXECUTE | CACHEDEF) > -#define __P101 __pgprot(_PAGE_PRESENT | _PAGE_USER | > _PAGE_EXECUTE | \ > - _PAGE_READ | CACHEDEF) > -#define __P110 __P100 /* Write/execute copy-on-write */ > -#define __P111 __P101 /* Read/Write/Execute, copy-on-write */ > - > -/* Shared page protections. */ > -#define __S000 __P000 > -#define __S001 __P001 > -#define __S010 __pgprot(_PAGE_PRESENT | _PAGE_USER | \ > - _PAGE_WRITE | CACHEDEF) > -#define __S011 __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | > \ > - _PAGE_WRITE | CACHEDEF) > -#define __S100 __pgprot(_PAGE_PRESENT | _PAGE_USER | \ > - _PAGE_EXECUTE | CACHEDEF) > -#define __S101 __P101 > -#define __S110 __pgprot(_PAGE_PRESENT | _PAGE_USER | \ > - _PAGE_EXECUTE | _PAGE_WRITE | CACHEDEF) > -#define __S111 __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | > \ > - _PAGE_EXECUTE | _PAGE_WRITE | CACHEDEF) > - > extern pgd_t swapper_pg_dir[PTRS_PER_PGD]; /* located in head.S */ > > /* HUGETLB not working currently */ > diff --git a/arch/hexagon/mm/init.c b/arch/hexagon/mm/init.c > index 3167a3b5c97b..146115c9de61 100644 > --- a/arch/hexagon/mm/init.c > +++ b/arch/hexagon/mm/init.c > @@ -234,3 +234,45 @@ void __init setup_arch_memory(void) > * which is called by start_kernel() later on in the process > */ > } > + > +static const pgprot_t protection_map[16] = { > + [VM_NONE] = > __pgprot(_PAGE_PRESENT | > _PAGE_USER | > + CACHEDEF), > + [VM_READ] = > __pgprot(_PAGE_PRESENT | > _PAGE_USER | > + _PAGE_READ > | CACHEDEF), > + [VM_WRITE] = > __pgprot(_PAGE_PRESENT | > _PAGE_USER | > + CACHEDEF), > + [VM_WRITE | VM_READ]= > __pgprot(_PAGE_PRESENT | > _PAGE_USER | > + _PAGE_READ > | CACHEDEF), > + [VM_EXEC] = > __pgprot(_PAGE_PRESENT | > _PAGE_USER | > + > _PAGE_EXECUTE | CACHEDEF), > + [VM_EXEC | VM_READ] = > __pgprot(_PAGE_PRESENT | > _PAGE_USER | > + > _PAGE_EXECUTE | _PAGE_READ | > + CACHEDEF), > + [VM_EXEC | VM_WRITE]= > __pgprot(_PAGE_PRESENT | > _PAGE_USER | > + > _PAGE_EXECUTE | CACHEDEF), > + [VM_EXEC
Re: [PATCH RESEND v5 15/18] PCI: dwc: Add dw_ prefix to the pcie_port structure name
On 24/06/2022 16:34, Serge Semin wrote: All of the DW PCIe core driver entities have names with the dw_ prefix in order to easily distinguish local and common PCIe name spaces. All except the pcie_port structure which contains the DW PCIe Root Port descriptor. For historical reason the structure has retained the original name since commit 340cba6092c2 ("pci: Add PCIe driver for Samsung Exynos") when the DW PCIe IP-core support was added to the kernel. Let's finally fix that by adding the dw_ prefix to the structure name and by adding the _rp suffix to be similar to the EP counterpart. Thus the name will be coherent with the common driver naming policy. It shall make the driver code more readable eliminating visual confusion between the local and generic PCI name spaces. Signed-off-by: Serge Semin Reviewed-by: Rob Herring --- Changelog v4: - This is a new patch created on the v4 lap of the series. --- drivers/pci/controller/dwc/pci-dra7xx.c | 12 +++ drivers/pci/controller/dwc/pci-exynos.c | 6 ++-- drivers/pci/controller/dwc/pci-imx6.c | 6 ++-- drivers/pci/controller/dwc/pci-keystone.c | 20 +-- drivers/pci/controller/dwc/pci-layerscape.c | 2 +- drivers/pci/controller/dwc/pci-meson.c| 2 +- drivers/pci/controller/dwc/pcie-al.c | 6 ++-- drivers/pci/controller/dwc/pcie-armada8k.c| 4 +-- drivers/pci/controller/dwc/pcie-artpec6.c | 4 +-- .../pci/controller/dwc/pcie-designware-host.c | 36 +-- .../pci/controller/dwc/pcie-designware-plat.c | 2 +- drivers/pci/controller/dwc/pcie-designware.h | 30 drivers/pci/controller/dwc/pcie-dw-rockchip.c | 4 +-- drivers/pci/controller/dwc/pcie-fu740.c | 2 +- drivers/pci/controller/dwc/pcie-histb.c | 10 +++--- drivers/pci/controller/dwc/pcie-intel-gw.c| 6 ++-- drivers/pci/controller/dwc/pcie-keembay.c | 4 +-- drivers/pci/controller/dwc/pcie-kirin.c | 2 +- drivers/pci/controller/dwc/pcie-qcom.c| 4 +-- drivers/pci/controller/dwc/pcie-spear13xx.c | 6 ++-- drivers/pci/controller/dwc/pcie-tegra194.c| 22 ++-- drivers/pci/controller/dwc/pcie-uniphier.c| 10 +++--- drivers/pci/controller/dwc/pcie-visconti.c| 6 ++-- 23 files changed, 103 insertions(+), 103 deletions(-) diff --git a/drivers/pci/controller/dwc/pci-dra7xx.c b/drivers/pci/controller/dwc/pci-dra7xx.c index dfcdeb432dc8..a174b680b2a7 100644 --- a/drivers/pci/controller/dwc/pci-dra7xx.c +++ b/drivers/pci/controller/dwc/pci-dra7xx.c @@ -178,7 +178,7 @@ static void dra7xx_pcie_enable_interrupts(struct dra7xx_pcie *dra7xx) dra7xx_pcie_enable_msi_interrupts(dra7xx); } -static int dra7xx_pcie_host_init(struct pcie_port *pp) +static int dra7xx_pcie_host_init(struct dw_pcie_rp *pp) { struct dw_pcie *pci = to_dw_pcie_from_pp(pp); struct dra7xx_pcie *dra7xx = to_dra7xx_pcie(pci); @@ -202,7 +202,7 @@ static const struct irq_domain_ops intx_domain_ops = { .xlate = pci_irqd_intx_xlate, }; -static int dra7xx_pcie_handle_msi(struct pcie_port *pp, int index) +static int dra7xx_pcie_handle_msi(struct dw_pcie_rp *pp, int index) { struct dw_pcie *pci = to_dw_pcie_from_pp(pp); unsigned long val; @@ -224,7 +224,7 @@ static int dra7xx_pcie_handle_msi(struct pcie_port *pp, int index) return 1; } -static void dra7xx_pcie_handle_msi_irq(struct pcie_port *pp) +static void dra7xx_pcie_handle_msi_irq(struct dw_pcie_rp *pp) { struct dw_pcie *pci = to_dw_pcie_from_pp(pp); int ret, i, count, num_ctrls; @@ -255,8 +255,8 @@ static void dra7xx_pcie_msi_irq_handler(struct irq_desc *desc) { struct irq_chip *chip = irq_desc_get_chip(desc); struct dra7xx_pcie *dra7xx; + struct dw_pcie_rp *pp; struct dw_pcie *pci; - struct pcie_port *pp; unsigned long reg; u32 bit; @@ -344,7 +344,7 @@ static irqreturn_t dra7xx_pcie_irq_handler(int irq, void *arg) return IRQ_HANDLED; } -static int dra7xx_pcie_init_irq_domain(struct pcie_port *pp) +static int dra7xx_pcie_init_irq_domain(struct dw_pcie_rp *pp) { struct dw_pcie *pci = to_dw_pcie_from_pp(pp); struct device *dev = pci->dev; @@ -475,7 +475,7 @@ static int dra7xx_add_pcie_port(struct dra7xx_pcie *dra7xx, { int ret; struct dw_pcie *pci = dra7xx->pci; - struct pcie_port *pp = >pp; + struct dw_pcie_rp *pp = >pp; struct device *dev = pci->dev; pp->irq = platform_get_irq(pdev, 1); diff --git a/drivers/pci/controller/dwc/pci-exynos.c b/drivers/pci/controller/dwc/pci-exynos.c index 467c8d1cd7e4..2044d191fba6 100644 --- a/drivers/pci/controller/dwc/pci-exynos.c +++ b/drivers/pci/controller/dwc/pci-exynos.c @@ -249,7 +249,7 @@ static int exynos_pcie_link_up(struct dw_pcie *pci) return (val & PCIE_ELBI_XMLH_LINKUP); } -static int exynos_pcie_host_init(struct pcie_port
Re: [PATCH RESEND v5 15/18] PCI: dwc: Add dw_ prefix to the pcie_port structure name
On Fri, Jun 24, 2022 at 04:34:25PM +0200, Serge Semin wrote: > All of the DW PCIe core driver entities have names with the dw_ prefix in > order to easily distinguish local and common PCIe name spaces. All except > the pcie_port structure which contains the DW PCIe Root Port descriptor. > For historical reason the structure has retained the original name since > commit 340cba6092c2 ("pci: Add PCIe driver for Samsung Exynos") when > the DW PCIe IP-core support was added to the kernel. Let's finally fix > that by adding the dw_ prefix to the structure name and by adding the _rp > suffix to be similar to the EP counterpart. Thus the name will be coherent > with the common driver naming policy. It shall make the driver code more > readable eliminating visual confusion between the local and generic PCI > name spaces. > > Signed-off-by: Serge Semin > Reviewed-by: Rob Herring Sorry, I never replied in the thread for the last patch, your reasoning for not changing the parameter name made sense. For the ARTPEC-6 parts, Acked-by: Jesper Nilsson /^JN - Jesper Nilsson -- Jesper Nilsson -- jesper.nils...@axis.com
[Bug 216183] Kernel 5.19-rc4 boots ok with CONFIG_PPC_RADIX_MMU=y but fails to boot with CONFIG_PPC_HASH_MMU_NATIVE=y
https://bugzilla.kernel.org/show_bug.cgi?id=216183 --- Comment #1 from Erhard F. (erhar...@mailbox.org) --- Created attachment 301290 --> https://bugzilla.kernel.org/attachment.cgi?id=301290=edit kernel .config (kernel 5.19-rc4, Talos II) -- You may reply to this email to add a comment. You are receiving this mail because: You are watching the assignee of the bug.
[Bug 216183] New: Kernel 5.19-rc4 boots ok with CONFIG_PPC_RADIX_MMU=y but fails to boot with CONFIG_PPC_HASH_MMU_NATIVE=y
https://bugzilla.kernel.org/show_bug.cgi?id=216183 Bug ID: 216183 Summary: Kernel 5.19-rc4 boots ok with CONFIG_PPC_RADIX_MMU=y but fails to boot with CONFIG_PPC_HASH_MMU_NATIVE=y Product: Platform Specific/Hardware Version: 2.5 Kernel Version: 5.19-rc4 Hardware: PPC-64 OS: Linux Tree: Mainline Status: NEW Severity: normal Priority: P1 Component: PPC-64 Assignee: platform_ppc...@kernel-bugs.osdl.org Reporter: erhar...@mailbox.org Regression: No Created attachment 301289 --> https://bugzilla.kernel.org/attachment.cgi?id=301289=edit kernel dmesg (kernel 5.19-rc4, Talos II) 5.19-rc4 boots ok when CONFIG_PPC_RADIX_MMU=y CONFIG_PPC_RADIX_MMU_DEFAULT=y is enabled in the .config but fails to boot when MMU is changed to # CONFIG_PPC_RADIX_MMU is not set CONFIG_PPC_HASH_MMU_NATIVE=y in the same .config. [...] Disabling lock debugging due to kernel taint Oops: Machine check, sig: 7 [#1] BE PAGE_SIZE=4K MMU=Hash SMP NR_CPUS=32 NUMA PowerNV Modules linked in: cbc aes_generic snd_hda_codec_hdmi libaes snd_hda_intel snd_intel_dspcfg xhci_pci snd_hda_codec snd_hwdep xhci_hcd snd_hda_core cfg80211 drm_ttm_helper ghash_generic rfkill ofpart ttm i2c_algo_bit snd_pcm powernv_flash vmx_crypto(+) ibmpowernv at24(+) usbcore drm_display_helper mtd gf128mul snd_timer hwmon opal_prd regmap_i2c usb_common drm_kms_helper sysimgblt syscopyarea snd sysfillrect fb_sys_fops soundcore zram pkcs8_key_parser zsmalloc powernv_cpufreq drm fuse drm_panel_orientation_quirks backlight configfs CPU: 9 PID: 0 Comm: swapper/9 Tainted: G M 5.19.0-rc4-P9 #4 NIP: LR: CTR: 00ac408f3f6b677d REGS: c007ffe7e900 TRAP: c0008354 Tainted: G M (5.19.0-rc4-P9) MSR: 03010100 <> CR: c007ffe7ed40 XER: c0003d07e680 CFAR: 0003 IRQMASK: 3 GPR00: c007ffe7eaa0 c007ffe7e990 GPR04: GPR08: GPR12: GPR16: c007ffe7eaa0 c007ffe7ea30 GPR20: c004a3b4 c1237e00 GPR24: GPR28: NIP [] 0x0 LR [] 0x0 Call Trace: [c007ffe7eaa0] [c1237e00] 0xc1237e00 (unreliable) Instruction dump: ---[ end trace ]--- input: HDA ATI HDMI HDMI/DP,pcm=3 as /devices/pci:00/:00:00.0/:01:00.1/sound/card0/input0 Adding 16777212k swap on /dev/nvme0n1p4. Priority:-2 extents:1 across:16777212k SSFS at24 7-0050: 256 byte spd EEPROM, read-only at24 7-0052: 256 byte spd EEPROM, read-only at24 8-0054: 256 byte spd EEPROM, read-only at24 8-0056: 256 byte spd EEPROM, read-only EXT4-fs (nvme0n1p2): mounting ext2 file system using the ext4 subsystem [drm] radeon kernel modesetting enabled. EXT4-fs (nvme0n1p2): mounted filesystem without journal. Quota mode: disabled. EXT4-fs (zram1): mounting ext2 file system using the ext4 subsystem EXT4-fs (zram1): mounted filesystem without journal. Quota mode: disabled. Oops: Machine check, sig: 7 [#2] BE PAGE_SIZE=4K MMU=Hash SMP NR_CPUS=32 NUMA PowerNV Modules linked in: xts ecb ctr evdev cbc aes_generic snd_hda_codec_hdmi libaes snd_hda_intel snd_intel_dspcfg xhci_pci snd_hda_codec snd_hwdep radeon(+) xhci_hcd snd_hda_core cfg80211 drm_ttm_helper ghash_generic rfkill ofpart ttm i2c_algo_bit snd_pcm powernv_flash vmx_crypto ibmpowernv at24 usbcore drm_display_helper mtd gf128mul snd_timer hwmon opal_prd regmap_i2c usb_common drm_kms_helper sysimgblt syscopyarea snd sysfillrect fb_sys_fops soundcore zram pkcs8_key_parser zsmalloc powernv_cpufreq drm fuse drm_panel_orientation_quirks backlight configfs CPU: 1 PID: 0 Comm: swapper/1 Tainted: G M D 5.19.0-rc4-P9 #4 NIP: LR: CTR: 0063d2a43fc97e45 REGS: c007ffede900 TRAP: c0008354 Tainted: G M D (5.19.0-rc4-P9) MSR: 03010100 <> CR: c007ffeded40 XER: c0003d016680 CFAR: 0003 IRQMASK: 3 GPR00: c007ffedeaa0 c007ffede990 GPR04: GPR08: GPR12: GPR16: c007ffedeaa0 c007ffedea30
Re: [PATCH RESEND v9 4/5] arm: dts: stih407-family: Harmonize DWC USB3 DT nodes name
On Sun, Jun 26, 2022 at 12:42:48PM +0200, Krzysztof Kozlowski wrote: > On 24/06/2022 22:45, Serge Semin wrote: > > On Fri, Jun 24, 2022 at 07:18:57PM +0200, Krzysztof Kozlowski wrote: > >> On 24/06/2022 16:16, Serge Semin wrote: > >>> In accordance with the DWC USB3 bindings the corresponding node > >>> name is suppose to comply with the Generic USB HCD DT schema, which > >>> requires the USB nodes to have the name acceptable by the regexp: > >>> "^usb(@.*)?" . Make sure the "snps,dwc3"-compatible nodes are correctly > >>> named. > >>> > >>> Signed-off-by: Serge Semin > >>> Acked-by: Krzysztof Kozlowski > >>> Reviewed-by: Patrice Chotard > >>> --- > >>> arch/arm/boot/dts/stih407-family.dtsi | 2 +- > >>> 1 file changed, 1 insertion(+), 1 deletion(-) > >>> > >>> diff --git a/arch/arm/boot/dts/stih407-family.dtsi > >>> b/arch/arm/boot/dts/stih407-family.dtsi > >>> index 1713f7878117..7ba528315dbe 100644 > >>> --- a/arch/arm/boot/dts/stih407-family.dtsi > >>> +++ b/arch/arm/boot/dts/stih407-family.dtsi > >>> @@ -725,7 +725,7 @@ st_dwc3: dwc3@8f94000 { > >>> > >>> status = "disabled"; > >>> > >>> - dwc3: dwc3@990 { > >>> + dwc3: usb@990 { > >> > > > >> This does not apply. What tree is it based on? > > > > That's weird. The series has been rebased onto the mainline kernel > > v5.19-rc3. > > Do you have the stih407 dtsi fixed on your local repo? > > It conflicts with my change: > https://lore.kernel.org/all/20220526203632.831039-1-krzysztof.kozlow...@linaro.org/ > > I'll apply with local fixups. Ok. Thanks. -Sergey > > > Best regards, > Krzysztof
Re: [PATCH v2 3/3] arch/*/: remove CONFIG_VIRT_TO_BUS
Hi Geert, On 27/06/22 20:26, Geert Uytterhoeven wrote: Hi Michael, On Sat, Jun 18, 2022 at 3:06 AM Michael Schmitz wrote: Am 18.06.2022 um 00:57 schrieb Arnd Bergmann: From: Arnd Bergmann All architecture-independent users of virt_to_bus() and bus_to_virt() have been fixed to use the dma mapping interfaces or have been removed now. This means the definitions on most architectures, and the CONFIG_VIRT_TO_BUS symbol are now obsolete and can be removed. The only exceptions to this are a few network and scsi drivers for m68k Amiga and VME machines and ppc32 Macintosh. These drivers work correctly with the old interfaces and are probably not worth changing. The Amiga SCSI drivers are all old WD33C93 ones, and replacing virt_to_bus by virt_to_phys in the dma_setup() function there would cause no functional change at all. FTR, the sgiwd93 driver use dma_map_single(). Thanks! From what I see, it doesn't have to deal with bounce buffers though? Cheers, Michael Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- ge...@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds
Re: [RFC PATCH v2 0/3] powerpc/pseries: add support for local secure storage called Platform KeyStore(PKS)
On 6/22/22 14:56, Nayna Jain wrote: > * Renamed PKS driver to PLPKS to avoid naming conflict as mentioned by > Dave Hanson. Thank you for doing this! The new naming looks much less likely to cause confusion.
Re: [PATCH] spi: mpc52xx-psc: Switch to using core message queue
On Mon, 13 Jun 2022 13:19:46 +0100, Mark Brown wrote: > We deprecated open coding of the transfer queue back in 2017 so it's high > time we finished up converting drivers to use the standard message queue > code. The mpc52xx-psc driver is fairly straightforward so convert to use > transfer_one_message(), it looks like the driver would be a good fit for > transfer_one() with a little bit of updating but this smaller change seems > safer. > > [...] Applied to https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-next Thanks! [1/1] spi: mpc52xx-psc: Switch to using core message queue commit: 145cfc3840e5931a789a8e2e76af841ab4cad44b All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted. You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed. If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced. Please add any relevant lists and maintainers to the CCs when replying to this mail. Thanks, Mark
[linux-next:master] BUILD REGRESSION aab35c3d5112df6e329a1a5a5a1881e5c4ca3821
tree/branch: https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master branch HEAD: aab35c3d5112df6e329a1a5a5a1881e5c4ca3821 Add linux-next specific files for 20220627 Error/Warning: (recently discovered and may have been fixed) arch/powerpc/kernel/interrupt.c:542:55: error: suggest braces around empty body in an 'if' statement [-Werror=empty-body] arch/powerpc/kernel/interrupt.c:542:55: warning: suggest braces around empty body in an 'if' statement [-Wempty-body] drivers/gpu/drm/amd/amdgpu/../display/dc/core/dc_link.c:1025:33: warning: variable 'pre_connection_type' set but not used [-Wunused-but-set-variable] drivers/ntb/test/ntb_perf.c:1145: undefined reference to `__umoddi3' drivers/pci/endpoint/functions/pci-epf-vntb.c:975:5: warning: no previous prototype for 'pci_read' [-Wmissing-prototypes] drivers/pci/endpoint/functions/pci-epf-vntb.c:984:5: warning: no previous prototype for 'pci_write' [-Wmissing-prototypes] vmlinux.o: warning: objtool: __ct_user_enter+0x8c: call to ftrace_likely_update() leaves .noinstr.text section vmlinux.o: warning: objtool: ct_idle_enter+0x19: call to ftrace_likely_update() leaves .noinstr.text section vmlinux.o: warning: objtool: ct_idle_exit+0x3e: call to ftrace_likely_update() leaves .noinstr.text section vmlinux.o: warning: objtool: ct_irq_enter+0x6a: call to ftrace_likely_update() leaves .noinstr.text section vmlinux.o: warning: objtool: ct_irq_exit+0x6a: call to ftrace_likely_update() leaves .noinstr.text section vmlinux.o: warning: objtool: ct_kernel_enter.constprop.0+0x2a: call to ftrace_likely_update() leaves .noinstr.text section vmlinux.o: warning: objtool: ct_kernel_enter_state+0x2d: call to ftrace_likely_update() leaves .noinstr.text section vmlinux.o: warning: objtool: ct_kernel_exit.constprop.0+0x53: call to ftrace_likely_update() leaves .noinstr.text section vmlinux.o: warning: objtool: ct_kernel_exit_state+0x2d: call to ftrace_likely_update() leaves .noinstr.text section vmlinux.o: warning: objtool: ct_nmi_enter+0x4b: call to ftrace_likely_update() leaves .noinstr.text section Unverified Error/Warning (likely false positive, please contact us if interested): drivers/acpi/scan.c:615:35: warning: Uninitialized variable: acpi_device_bus_id->bus_id [uninitvar] drivers/phy/qualcomm/phy-qcom-qmp-combo.c:1701:19: warning: Value stored to 'qmp' during its initialization is never read [clang-analyzer-deadcode.DeadStores] drivers/soc/mediatek/mtk-mutex.c:799:1: internal compiler error: in arc_ifcvt, at config/arc/arc.c:9637 drivers/staging/media/zoran/zr36016.c:430:1: internal compiler error: in arc_ifcvt, at config/arc/arc.c:9637 drivers/staging/media/zoran/zr36050.c:829:1: internal compiler error: in arc_ifcvt, at config/arc/arc.c:9637 drivers/staging/media/zoran/zr36060.c:869:1: internal compiler error: in arc_ifcvt, at config/arc/arc.c:9637 drivers/thunderbolt/tmu.c:758:1: internal compiler error: in arc_ifcvt, at config/arc/arc.c:9637 sound/soc/sof/intel/mtl.c:547:1: internal compiler error: in arc_ifcvt, at config/arc/arc.c:9637 Error/Warning ids grouped by kconfigs: gcc_recent_errors |-- alpha-allyesconfig | |-- drivers-gpu-drm-amd-amdgpu-..-display-dc-core-dc_link.c:warning:variable-pre_connection_type-set-but-not-used | |-- drivers-pci-endpoint-functions-pci-epf-vntb.c:warning:no-previous-prototype-for-pci_read | `-- drivers-pci-endpoint-functions-pci-epf-vntb.c:warning:no-previous-prototype-for-pci_write |-- arc-allyesconfig | |-- drivers-gpu-drm-amd-amdgpu-..-display-dc-core-dc_link.c:warning:variable-pre_connection_type-set-but-not-used | |-- drivers-pci-endpoint-functions-pci-epf-vntb.c:warning:no-previous-prototype-for-pci_read | |-- drivers-pci-endpoint-functions-pci-epf-vntb.c:warning:no-previous-prototype-for-pci_write | |-- drivers-soc-mediatek-mtk-mutex.c:internal-compiler-error:in-arc_ifcvt-at-config-arc-arc.c | |-- drivers-staging-media-zoran-zr36016.c:internal-compiler-error:in-arc_ifcvt-at-config-arc-arc.c | |-- drivers-staging-media-zoran-zr36050.c:internal-compiler-error:in-arc_ifcvt-at-config-arc-arc.c | |-- drivers-staging-media-zoran-zr36060.c:internal-compiler-error:in-arc_ifcvt-at-config-arc-arc.c | |-- drivers-thunderbolt-tmu.c:internal-compiler-error:in-arc_ifcvt-at-config-arc-arc.c | `-- sound-soc-sof-intel-mtl.c:internal-compiler-error:in-arc_ifcvt-at-config-arc-arc.c |-- arm-allyesconfig | |-- drivers-gpu-drm-amd-amdgpu-..-display-dc-core-dc_link.c:warning:variable-pre_connection_type-set-but-not-used | |-- drivers-pci-endpoint-functions-pci-epf-vntb.c:warning:no-previous-prototype-for-pci_read | `-- drivers-pci-endpoint-functions-pci-epf-vntb.c:warning:no-previous-prototype-for-pci_write |-- arm64-allyesconfig | |-- drivers-gpu-drm-amd-amdgpu-..-display-dc-core-dc_link.c:warning:variable-pre_connection_type-set-but-not-used | |-- drivers-pci-endpoint-functions-pci-epf-vntb.c:warning:no-previous-prototype-for-pci_r
[PATCH powerpc v2] powerpc/bpf: Fix use of user_pt_regs in uapi
Trying to build a .c file that includes : $ cat test_bpf_headers.c #include throws the below error: /usr/include/linux/bpf_perf_event.h:14:28: error: field ‘regs’ has incomplete type 14 | bpf_user_pt_regs_t regs; |^~~~ This is because we typedef bpf_user_pt_regs_t to 'struct user_pt_regs' in arch/powerpc/include/uaps/asm/bpf_perf_event.h, but 'struct user_pt_regs' is not exposed to userspace. Powerpc has both pt_regs and user_pt_regs structures. However, unlike arm64 and s390, we expose user_pt_regs to userspace as just 'pt_regs'. As such, we should typedef bpf_user_pt_regs_t to 'struct pt_regs' for userspace. Within the kernel though, we want to typedef bpf_user_pt_regs_t to 'struct user_pt_regs'. Remove arch/powerpc/include/uapi/asm/bpf_perf_event.h so that the uapi/asm-generic version of the header is exposed to userspace. Introduce arch/powerpc/include/asm/bpf_perf_event.h so that we can typedef bpf_user_pt_regs_t to 'struct user_pt_regs' for use within the kernel. Note that this was not showing up with the bpf selftest build since tools/include/uapi/asm/bpf_perf_event.h didn't include the powerpc variant. Fixes: a6460b03f945ee ("powerpc/bpf: Fix broken uapi for BPF_PROG_TYPE_PERF_EVENT") Cc: sta...@vger.kernel.org # v4.20+ Signed-off-by: Naveen N. Rao --- v2: Add arch/powerpc/include/asm/bpf_perf_event.h arch/powerpc/include/asm/bpf_perf_event.h | 9 + arch/powerpc/include/uapi/asm/bpf_perf_event.h | 9 - 2 files changed, 9 insertions(+), 9 deletions(-) create mode 100644 arch/powerpc/include/asm/bpf_perf_event.h delete mode 100644 arch/powerpc/include/uapi/asm/bpf_perf_event.h diff --git a/arch/powerpc/include/asm/bpf_perf_event.h b/arch/powerpc/include/asm/bpf_perf_event.h new file mode 100644 index 00..a207467dd0a755 --- /dev/null +++ b/arch/powerpc/include/asm/bpf_perf_event.h @@ -0,0 +1,9 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _ASM_BPF_PERF_EVENT_H +#define _ASM_BPF_PERF_EVENT_H + +#include + +typedef struct user_pt_regs bpf_user_pt_regs_t; + +#endif /* _ASM_BPF_PERF_EVENT_H */ diff --git a/arch/powerpc/include/uapi/asm/bpf_perf_event.h b/arch/powerpc/include/uapi/asm/bpf_perf_event.h deleted file mode 100644 index 5e1e648aeec4c8..00 --- a/arch/powerpc/include/uapi/asm/bpf_perf_event.h +++ /dev/null @@ -1,9 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ -#ifndef _UAPI__ASM_BPF_PERF_EVENT_H__ -#define _UAPI__ASM_BPF_PERF_EVENT_H__ - -#include - -typedef struct user_pt_regs bpf_user_pt_regs_t; - -#endif /* _UAPI__ASM_BPF_PERF_EVENT_H__ */ base-commit: f85bb0e4405d64c657c3b10ca134bc8fff9afaaa -- 2.36.1
Re: [PATCH V5 04/26] sparc/mm: Move protection_map[] inside the platform
Hi Anshuman, On Mon, Jun 27, 2022 at 10:28:11AM +0530, Anshuman Khandual wrote: > This moves protection_map[] inside the platform and while here, also enable > ARCH_HAS_VM_GET_PAGE_PROT on 32 bit platforms via DECLARE_VM_GET_PAGE_PROT. > > Cc: "David S. Miller" > Cc: sparcli...@vger.kernel.org > Cc: linux-ker...@vger.kernel.org > Signed-off-by: Anshuman Khandual > --- > arch/sparc/Kconfig | 2 +- > arch/sparc/include/asm/pgtable_32.h | 19 --- > arch/sparc/include/asm/pgtable_64.h | 19 --- > arch/sparc/mm/init_32.c | 20 > arch/sparc/mm/init_64.c | 3 +++ > 5 files changed, 24 insertions(+), 39 deletions(-) > > diff --git a/arch/sparc/Kconfig b/arch/sparc/Kconfig > index ba449c47effd..09f868613a4d 100644 > --- a/arch/sparc/Kconfig > +++ b/arch/sparc/Kconfig > @@ -13,6 +13,7 @@ config 64BIT > config SPARC > bool > default y > + select ARCH_HAS_VM_GET_PAGE_PROT > select ARCH_MIGHT_HAVE_PC_PARPORT if SPARC64 && PCI > select ARCH_MIGHT_HAVE_PC_SERIO > select DMA_OPS > @@ -84,7 +85,6 @@ config SPARC64 > select PERF_USE_VMALLOC > select ARCH_HAVE_NMI_SAFE_CMPXCHG > select HAVE_C_RECORDMCOUNT > - select ARCH_HAS_VM_GET_PAGE_PROT > select HAVE_ARCH_AUDITSYSCALL > select ARCH_SUPPORTS_ATOMIC_RMW > select ARCH_SUPPORTS_DEBUG_PAGEALLOC > diff --git a/arch/sparc/include/asm/pgtable_32.h > b/arch/sparc/include/asm/pgtable_32.h > index 4866625da314..8ff549004fac 100644 > --- a/arch/sparc/include/asm/pgtable_32.h > +++ b/arch/sparc/include/asm/pgtable_32.h > @@ -64,25 +64,6 @@ void paging_init(void); > > extern unsigned long ptr_in_current_pgd; > > -/* xwr */ > -#define __P000 PAGE_NONE > -#define __P001 PAGE_READONLY > -#define __P010 PAGE_COPY > -#define __P011 PAGE_COPY > -#define __P100 PAGE_READONLY > -#define __P101 PAGE_READONLY > -#define __P110 PAGE_COPY > -#define __P111 PAGE_COPY > - > -#define __S000 PAGE_NONE > -#define __S001 PAGE_READONLY > -#define __S010 PAGE_SHARED > -#define __S011 PAGE_SHARED > -#define __S100 PAGE_READONLY > -#define __S101 PAGE_READONLY > -#define __S110 PAGE_SHARED > -#define __S111 PAGE_SHARED > - > /* First physical page can be anywhere, the following is needed so that > * va-->pa and vice versa conversions work properly without performance > * hit for all __pa()/__va() operations. > diff --git a/arch/sparc/include/asm/pgtable_64.h > b/arch/sparc/include/asm/pgtable_64.h > index 4679e45c8348..a779418ceba9 100644 > --- a/arch/sparc/include/asm/pgtable_64.h > +++ b/arch/sparc/include/asm/pgtable_64.h > @@ -187,25 +187,6 @@ bool kern_addr_valid(unsigned long addr); > #define _PAGE_SZHUGE_4U _PAGE_SZ4MB_4U > #define _PAGE_SZHUGE_4V _PAGE_SZ4MB_4V > > -/* These are actually filled in at boot time by sun4{u,v}_pgprot_init() */ > -#define __P000 __pgprot(0) > -#define __P001 __pgprot(0) > -#define __P010 __pgprot(0) > -#define __P011 __pgprot(0) > -#define __P100 __pgprot(0) > -#define __P101 __pgprot(0) > -#define __P110 __pgprot(0) > -#define __P111 __pgprot(0) > - > -#define __S000 __pgprot(0) > -#define __S001 __pgprot(0) > -#define __S010 __pgprot(0) > -#define __S011 __pgprot(0) > -#define __S100 __pgprot(0) > -#define __S101 __pgprot(0) > -#define __S110 __pgprot(0) > -#define __S111 __pgprot(0) > - > #ifndef __ASSEMBLY__ > > pte_t mk_pte_io(unsigned long, pgprot_t, int, unsigned long); > diff --git a/arch/sparc/mm/init_32.c b/arch/sparc/mm/init_32.c > index 1e9f577f084d..8693e4e28b86 100644 > --- a/arch/sparc/mm/init_32.c > +++ b/arch/sparc/mm/init_32.c > @@ -302,3 +302,23 @@ void sparc_flush_page_to_ram(struct page *page) > __flush_page_to_ram(vaddr); > } > EXPORT_SYMBOL(sparc_flush_page_to_ram); > + > +static pgprot_t protection_map[16] __ro_after_init = { This can be const - like done for powerpc and others. sparc32 and sparc64 uses each their own - and I do not see sparc32 do any modifications to protection_map. With this change: Reviewed-by: Sam Ravnborg > + [VM_NONE] = PAGE_NONE, > + [VM_READ] = PAGE_READONLY, > + [VM_WRITE] = PAGE_COPY, > + [VM_WRITE | VM_READ]= PAGE_COPY, > + [VM_EXEC] = PAGE_READONLY, > + [VM_EXEC | VM_READ] = PAGE_READONLY, > + [VM_EXEC | VM_WRITE]= PAGE_COPY, > + [VM_EXEC | VM_WRITE | VM_READ] = PAGE_COPY, > + [VM_SHARED] = PAGE_NONE, > + [VM_SHARED | VM_READ] = PAGE_READONLY, > + [VM_SHARED | VM_WRITE]
[PATCH v5.4] powerpc/ftrace: Remove ftrace init tramp once kernel init is complete
commit 84ade0a6655bee803d176525ef457175cbf4df22 upstream. Stop using the ftrace trampoline for init section once kernel init is complete. Fixes: 67361cf8071286 ("powerpc/ftrace: Handle large kernel configs") Cc: sta...@vger.kernel.org # v4.20+ Signed-off-by: Naveen N. Rao Signed-off-by: Michael Ellerman Link: https://lore.kernel.org/r/20220516071422.463738-1-naveen.n@linux.vnet.ibm.com --- arch/powerpc/include/asm/ftrace.h | 5 - arch/powerpc/kernel/trace/ftrace.c | 15 --- arch/powerpc/mm/mem.c | 2 ++ 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/arch/powerpc/include/asm/ftrace.h b/arch/powerpc/include/asm/ftrace.h index f54a08a2cd7092..017336f2b0864a 100644 --- a/arch/powerpc/include/asm/ftrace.h +++ b/arch/powerpc/include/asm/ftrace.h @@ -96,7 +96,7 @@ static inline bool arch_syscall_match_sym_name(const char *sym, const char *name #endif /* PPC64_ELF_ABI_v1 */ #endif /* CONFIG_FTRACE_SYSCALLS */ -#ifdef CONFIG_PPC64 +#if defined(CONFIG_PPC64) && defined(CONFIG_FUNCTION_TRACER) #include static inline void this_cpu_disable_ftrace(void) @@ -108,9 +108,12 @@ static inline void this_cpu_enable_ftrace(void) { get_paca()->ftrace_enabled = 1; } + +void ftrace_free_init_tramp(void); #else /* CONFIG_PPC64 */ static inline void this_cpu_disable_ftrace(void) { } static inline void this_cpu_enable_ftrace(void) { } +static inline void ftrace_free_init_tramp(void) { } #endif /* CONFIG_PPC64 */ #endif /* !__ASSEMBLY__ */ diff --git a/arch/powerpc/kernel/trace/ftrace.c b/arch/powerpc/kernel/trace/ftrace.c index 7ea0ca044b6500..d816e714f2f489 100644 --- a/arch/powerpc/kernel/trace/ftrace.c +++ b/arch/powerpc/kernel/trace/ftrace.c @@ -328,9 +328,7 @@ static int setup_mcount_compiler_tramp(unsigned long tramp) /* Is this a known long jump tramp? */ for (i = 0; i < NUM_FTRACE_TRAMPS; i++) - if (!ftrace_tramps[i]) - break; - else if (ftrace_tramps[i] == tramp) + if (ftrace_tramps[i] == tramp) return 0; /* Is this a known plt tramp? */ @@ -868,6 +866,17 @@ void arch_ftrace_update_code(int command) extern unsigned int ftrace_tramp_text[], ftrace_tramp_init[]; +void ftrace_free_init_tramp(void) +{ + int i; + + for (i = 0; i < NUM_FTRACE_TRAMPS && ftrace_tramps[i]; i++) + if (ftrace_tramps[i] == (unsigned long)ftrace_tramp_init) { + ftrace_tramps[i] = 0; + return; + } +} + int __init ftrace_dyn_arch_init(void) { int i; diff --git a/arch/powerpc/mm/mem.c b/arch/powerpc/mm/mem.c index c48705c726ac6d..d427f70556eab5 100644 --- a/arch/powerpc/mm/mem.c +++ b/arch/powerpc/mm/mem.c @@ -48,6 +48,7 @@ #include #include #include +#include #include @@ -346,6 +347,7 @@ void free_initmem(void) mark_initmem_nx(); init_mem_is_free = true; free_initmem_default(POISON_FREE_INITMEM); + ftrace_free_init_tramp(); } /** base-commit: 23db944f754e99abf814a79a2273b0191d35e4ff -- 2.36.1
[PATCH v5.15] powerpc/ftrace: Remove ftrace init tramp once kernel init is complete
commit 84ade0a6655bee803d176525ef457175cbf4df22 upstream. Stop using the ftrace trampoline for init section once kernel init is complete. Fixes: 67361cf8071286 ("powerpc/ftrace: Handle large kernel configs") Cc: sta...@vger.kernel.org # v4.20+ Signed-off-by: Naveen N. Rao Signed-off-by: Michael Ellerman Link: https://lore.kernel.org/r/20220516071422.463738-1-naveen.n@linux.vnet.ibm.com --- arch/powerpc/include/asm/ftrace.h | 4 +++- arch/powerpc/kernel/trace/ftrace.c | 15 --- arch/powerpc/mm/mem.c | 2 ++ 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/arch/powerpc/include/asm/ftrace.h b/arch/powerpc/include/asm/ftrace.h index debe8c4f706260..02d32d6422cd8b 100644 --- a/arch/powerpc/include/asm/ftrace.h +++ b/arch/powerpc/include/asm/ftrace.h @@ -96,7 +96,7 @@ static inline bool arch_syscall_match_sym_name(const char *sym, const char *name #endif /* PPC64_ELF_ABI_v1 */ #endif /* CONFIG_FTRACE_SYSCALLS */ -#ifdef CONFIG_PPC64 +#if defined(CONFIG_PPC64) && defined(CONFIG_FUNCTION_TRACER) #include static inline void this_cpu_disable_ftrace(void) @@ -120,11 +120,13 @@ static inline u8 this_cpu_get_ftrace_enabled(void) return get_paca()->ftrace_enabled; } +void ftrace_free_init_tramp(void); #else /* CONFIG_PPC64 */ static inline void this_cpu_disable_ftrace(void) { } static inline void this_cpu_enable_ftrace(void) { } static inline void this_cpu_set_ftrace_enabled(u8 ftrace_enabled) { } static inline u8 this_cpu_get_ftrace_enabled(void) { return 1; } +static inline void ftrace_free_init_tramp(void) { } #endif /* CONFIG_PPC64 */ #endif /* !__ASSEMBLY__ */ diff --git a/arch/powerpc/kernel/trace/ftrace.c b/arch/powerpc/kernel/trace/ftrace.c index d89c5df4f20620..660040c2d7b543 100644 --- a/arch/powerpc/kernel/trace/ftrace.c +++ b/arch/powerpc/kernel/trace/ftrace.c @@ -336,9 +336,7 @@ static int setup_mcount_compiler_tramp(unsigned long tramp) /* Is this a known long jump tramp? */ for (i = 0; i < NUM_FTRACE_TRAMPS; i++) - if (!ftrace_tramps[i]) - break; - else if (ftrace_tramps[i] == tramp) + if (ftrace_tramps[i] == tramp) return 0; /* Is this a known plt tramp? */ @@ -881,6 +879,17 @@ void arch_ftrace_update_code(int command) extern unsigned int ftrace_tramp_text[], ftrace_tramp_init[]; +void ftrace_free_init_tramp(void) +{ + int i; + + for (i = 0; i < NUM_FTRACE_TRAMPS && ftrace_tramps[i]; i++) + if (ftrace_tramps[i] == (unsigned long)ftrace_tramp_init) { + ftrace_tramps[i] = 0; + return; + } +} + int __init ftrace_dyn_arch_init(void) { int i; diff --git a/arch/powerpc/mm/mem.c b/arch/powerpc/mm/mem.c index 05b9c3f31456c6..543a044560e935 100644 --- a/arch/powerpc/mm/mem.c +++ b/arch/powerpc/mm/mem.c @@ -22,6 +22,7 @@ #include #include #include +#include #include @@ -314,6 +315,7 @@ void free_initmem(void) mark_initmem_nx(); init_mem_is_free = true; free_initmem_default(POISON_FREE_INITMEM); + ftrace_free_init_tramp(); } /* base-commit: 18a33c8dabb88b50b860e0177a73933f2c0ddf68 -- 2.36.1
[PATCH v5.10] powerpc/ftrace: Remove ftrace init tramp once kernel init is complete
commit 84ade0a6655bee803d176525ef457175cbf4df22 upstream. Stop using the ftrace trampoline for init section once kernel init is complete. Fixes: 67361cf8071286 ("powerpc/ftrace: Handle large kernel configs") Cc: sta...@vger.kernel.org # v4.20+ Signed-off-by: Naveen N. Rao Signed-off-by: Michael Ellerman Link: https://lore.kernel.org/r/20220516071422.463738-1-naveen.n@linux.vnet.ibm.com --- arch/powerpc/include/asm/ftrace.h | 4 +++- arch/powerpc/kernel/trace/ftrace.c | 15 --- arch/powerpc/mm/mem.c | 2 ++ 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/arch/powerpc/include/asm/ftrace.h b/arch/powerpc/include/asm/ftrace.h index bc76970b6ee532..e647dfcb319171 100644 --- a/arch/powerpc/include/asm/ftrace.h +++ b/arch/powerpc/include/asm/ftrace.h @@ -96,7 +96,7 @@ static inline bool arch_syscall_match_sym_name(const char *sym, const char *name #endif /* PPC64_ELF_ABI_v1 */ #endif /* CONFIG_FTRACE_SYSCALLS */ -#ifdef CONFIG_PPC64 +#if defined(CONFIG_PPC64) && defined(CONFIG_FUNCTION_TRACER) #include static inline void this_cpu_disable_ftrace(void) @@ -120,11 +120,13 @@ static inline u8 this_cpu_get_ftrace_enabled(void) return get_paca()->ftrace_enabled; } +void ftrace_free_init_tramp(void); #else /* CONFIG_PPC64 */ static inline void this_cpu_disable_ftrace(void) { } static inline void this_cpu_enable_ftrace(void) { } static inline void this_cpu_set_ftrace_enabled(u8 ftrace_enabled) { } static inline u8 this_cpu_get_ftrace_enabled(void) { return 1; } +static inline void ftrace_free_init_tramp(void) { } #endif /* CONFIG_PPC64 */ #endif /* !__ASSEMBLY__ */ diff --git a/arch/powerpc/kernel/trace/ftrace.c b/arch/powerpc/kernel/trace/ftrace.c index 42761ebec9f755..d24aea4fed7a35 100644 --- a/arch/powerpc/kernel/trace/ftrace.c +++ b/arch/powerpc/kernel/trace/ftrace.c @@ -336,9 +336,7 @@ static int setup_mcount_compiler_tramp(unsigned long tramp) /* Is this a known long jump tramp? */ for (i = 0; i < NUM_FTRACE_TRAMPS; i++) - if (!ftrace_tramps[i]) - break; - else if (ftrace_tramps[i] == tramp) + if (ftrace_tramps[i] == tramp) return 0; /* Is this a known plt tramp? */ @@ -882,6 +880,17 @@ void arch_ftrace_update_code(int command) extern unsigned int ftrace_tramp_text[], ftrace_tramp_init[]; +void ftrace_free_init_tramp(void) +{ + int i; + + for (i = 0; i < NUM_FTRACE_TRAMPS && ftrace_tramps[i]; i++) + if (ftrace_tramps[i] == (unsigned long)ftrace_tramp_init) { + ftrace_tramps[i] = 0; + return; + } +} + int __init ftrace_dyn_arch_init(void) { int i; diff --git a/arch/powerpc/mm/mem.c b/arch/powerpc/mm/mem.c index 22eb1c718e6224..1ed276d2305fab 100644 --- a/arch/powerpc/mm/mem.c +++ b/arch/powerpc/mm/mem.c @@ -51,6 +51,7 @@ #include #include #include +#include #include @@ -347,6 +348,7 @@ void free_initmem(void) mark_initmem_nx(); init_mem_is_free = true; free_initmem_default(POISON_FREE_INITMEM); + ftrace_free_init_tramp(); } /** base-commit: 9cae50bdfafa0ce87eb2693401efeae2cd30b417 -- 2.36.1
[PATCH v5.18] powerpc/ftrace: Remove ftrace init tramp once kernel init is complete
commit 84ade0a6655bee803d176525ef457175cbf4df22 upstream. Stop using the ftrace trampoline for init section once kernel init is complete. Fixes: 67361cf8071286 ("powerpc/ftrace: Handle large kernel configs") Cc: sta...@vger.kernel.org # v4.20+ Signed-off-by: Naveen N. Rao Signed-off-by: Michael Ellerman Link: https://lore.kernel.org/r/20220516071422.463738-1-naveen.n@linux.vnet.ibm.com --- arch/powerpc/include/asm/ftrace.h | 4 +++- arch/powerpc/kernel/trace/ftrace.c | 15 --- arch/powerpc/mm/mem.c | 2 ++ 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/arch/powerpc/include/asm/ftrace.h b/arch/powerpc/include/asm/ftrace.h index d83758acd1c7c3..44a37a2b6a1cfa 100644 --- a/arch/powerpc/include/asm/ftrace.h +++ b/arch/powerpc/include/asm/ftrace.h @@ -86,7 +86,7 @@ static inline bool arch_syscall_match_sym_name(const char *sym, const char *name #endif /* PPC64_ELF_ABI_v1 */ #endif /* CONFIG_FTRACE_SYSCALLS */ -#ifdef CONFIG_PPC64 +#if defined(CONFIG_PPC64) && defined(CONFIG_FUNCTION_TRACER) #include static inline void this_cpu_disable_ftrace(void) @@ -110,11 +110,13 @@ static inline u8 this_cpu_get_ftrace_enabled(void) return get_paca()->ftrace_enabled; } +void ftrace_free_init_tramp(void); #else /* CONFIG_PPC64 */ static inline void this_cpu_disable_ftrace(void) { } static inline void this_cpu_enable_ftrace(void) { } static inline void this_cpu_set_ftrace_enabled(u8 ftrace_enabled) { } static inline u8 this_cpu_get_ftrace_enabled(void) { return 1; } +static inline void ftrace_free_init_tramp(void) { } #endif /* CONFIG_PPC64 */ #endif /* !__ASSEMBLY__ */ diff --git a/arch/powerpc/kernel/trace/ftrace.c b/arch/powerpc/kernel/trace/ftrace.c index 4ee04aacf9f13c..a778f2ae1f3f50 100644 --- a/arch/powerpc/kernel/trace/ftrace.c +++ b/arch/powerpc/kernel/trace/ftrace.c @@ -306,9 +306,7 @@ static int setup_mcount_compiler_tramp(unsigned long tramp) /* Is this a known long jump tramp? */ for (i = 0; i < NUM_FTRACE_TRAMPS; i++) - if (!ftrace_tramps[i]) - break; - else if (ftrace_tramps[i] == tramp) + if (ftrace_tramps[i] == tramp) return 0; /* Is this a known plt tramp? */ @@ -863,6 +861,17 @@ void arch_ftrace_update_code(int command) extern unsigned int ftrace_tramp_text[], ftrace_tramp_init[]; +void ftrace_free_init_tramp(void) +{ + int i; + + for (i = 0; i < NUM_FTRACE_TRAMPS && ftrace_tramps[i]; i++) + if (ftrace_tramps[i] == (unsigned long)ftrace_tramp_init) { + ftrace_tramps[i] = 0; + return; + } +} + int __init ftrace_dyn_arch_init(void) { int i; diff --git a/arch/powerpc/mm/mem.c b/arch/powerpc/mm/mem.c index 4d221d033804ef..149635e5c16534 100644 --- a/arch/powerpc/mm/mem.c +++ b/arch/powerpc/mm/mem.c @@ -22,6 +22,7 @@ #include #include #include +#include #include @@ -312,6 +313,7 @@ void free_initmem(void) ppc_md.progress = ppc_printk_progress; mark_initmem_nx(); free_initmem_default(POISON_FREE_INITMEM); + ftrace_free_init_tramp(); } /* base-commit: 7afbac05cb1c95e286ce97a40ee1c9f1791446c7 -- 2.36.1
Re: [PATCH v3 1/5] of: constify of_property_check_flags() prop argument
On Mon, Jun 20, 2022 at 12:41:19PM +0200, Clément Léger wrote: > This argument is not modified and thus can be set as const. > > Signed-off-by: Clément Léger > --- > include/linux/of.h | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) I already applied this patch, don't resend it. Rob
Re: drivers/usb/host/ehci-fsl: Fix interrupt setup in host mode.
On Sun, Jun 26, 2022 at 2:03 PM Darren Stevens wrote: > > Hello Sergei > > On 26/06/2022, Sergei Shtylyov wrote: > > Hello! > > > > On 6/25/22 11:41 PM, Darren Stevens wrote: > > > >> In patch a1a2b7125e10 (Drop static setup of IRQ resource from DT > >> core) we stopped platform_get_resource() from returning the IRQ, as all > > > > In commit a1a2b7125e10 ("Drop static setup of IRQ resource from DT core") > > > >> drivers were supposed to have switched to platform_get_irq() > >> Unfortunately the Freescale EHCI driver in host mode got missed. Fix > >> it. Also fix allocation of resources to work with current kernel. > > > >The basic rule (especially for the fixes) is "do one thing per patch". > > I thought I'd done that, this is the minimum amount of changes that fix what > changed in the specified commit. > > > [...] > >> @@ -92,15 +89,18 @@ static int fsl_ehci_drv_probe(struct platform_device > >> *pdev) > >> goto err1; > >> } > >> > >> -res = platform_get_resource(pdev, IORESOURCE_MEM, 0); > >> -hcd->regs = devm_ioremap_resource(>dev, res); > >> +tmp = of_address_to_resource(dn, 0, ); > > > >Hm, why? What does this fix? > > With baseline the mouse and keyboard on our machines don't work - dmesg > reports no interrupt. Fixing the interrupt detection throws a 'invalid > resoure' error instead (No idea why), which these lines fix. Both problems > disappear if we revert the 'fixes' patch. > I see the problem. You need to keep the platform_device_add_resources() call in fsl-mph-dr-of.c so that the memory resource is copied from the parent to the child device. Rob
Re: [RFC PATCH v3 11/12] powerpc: Remove unreachable() from WARN_ON()
Le 27/06/2022 à 17:35, Sathvika Vasireddy a écrit : > > On 25/06/22 12:16, Christophe Leroy wrote: >> >> Le 24/06/2022 à 20:32, Sathvika Vasireddy a écrit : >>> objtool is throwing *unannotated intra-function call* >>> warnings with a few instructions that are marked >>> unreachable. Remove unreachable() from WARN_ON() >>> to fix these warnings, as the codegen remains same >>> with and without unreachable() in WARN_ON(). >> Did you try the two exemples described in commit 1e688dd2a3d6 >> ("powerpc/bug: Provide better flexibility to WARN_ON/__WARN_FLAGS() with >> asm goto") ? >> >> Without your patch: >> >> 0640 : >> 640: 81 23 00 84 lwz r9,132(r3) >> 644: 71 29 40 00 andi. r9,r9,16384 >> 648: 40 82 00 0c bne 654 >> 64c: 80 63 00 0c lwz r3,12(r3) >> 650: 4e 80 00 20 blr >> 654: 0f e0 00 00 twui r0,0 >> >> 0658 : >> 658: 2c 04 00 00 cmpwi r4,0 >> 65c: 41 82 00 0c beq 668 >> 660: 7c 63 23 96 divwu r3,r3,r4 >> 664: 4e 80 00 20 blr >> 668: 0f e0 00 00 twui r0,0 >> 66c: 38 60 00 00 li r3,0 >> 670: 4e 80 00 20 blr >> >> >> With your patch: >> >> 0640 : >> 640: 81 23 00 84 lwz r9,132(r3) >> 644: 71 29 40 00 andi. r9,r9,16384 >> 648: 40 82 00 0c bne 654 >> 64c: 80 63 00 0c lwz r3,12(r3) >> 650: 4e 80 00 20 blr >> 654: 0f e0 00 00 twui r0,0 >> 658: 4b ff ff f4 b 64c <== >> >> 065c : >> 65c: 2c 04 00 00 cmpwi r4,0 >> 660: 41 82 00 0c beq 66c >> 664: 7c 63 23 96 divwu r3,r3,r4 >> 668: 4e 80 00 20 blr >> 66c: 0f e0 00 00 twui r0,0 >> 670: 38 60 00 00 li r3,0 <== >> 674: 4e 80 00 20 blr <== >> 678: 38 60 00 00 li r3,0 >> 67c: 4e 80 00 20 blr >> > The builtin variant of unreachable (__builtin_unreachable()) works. > > How about using that instead of unreachable() ? > That seems odd. Look at linux/compiler.h It seems like unreachable() exists to help objtool. Christophe
Re: [PATCH RFC] drivers/usb/ehci-fsl: Fix interrupt setup in host mode.
On Tue, Jun 21, 2022 at 4:09 PM Darren Stevens wrote: > > In patch a1a2b7125e1079 (Drop static setup of IRQ resource from DT > core) we stopped platform_get_resource() from returning the IRQ, as all > drivers were supposed to have switched to platform_get_irq() > Unfortunately the Freescale EHCI driver in host mode got missed. Fix > it. Also fix allocation of resources to work with current kernel. > > Fixes:a1a2b7125e1079 (Drop static setup of IRQ resource from DT core) > Reported-by Christian Zigotzky > Signed-off-by Darren Stevens > --- > Tested on AmigaOne X5000/20 and X5000/40 not sure if this is entirely > correct fix though. Contains code by Rob Herring (in fsl-mph-dr-of.c) > > diff --git a/drivers/usb/host/ehci-fsl.c b/drivers/usb/host/ehci-fsl.c > index 385be30..d0bf7fb 100644 > --- a/drivers/usb/host/ehci-fsl.c > +++ b/drivers/usb/host/ehci-fsl.c > @@ -23,6 +23,7 @@ > #include > #include > #include > +#include > #include > > #include "ehci.h" > @@ -46,9 +47,10 @@ static struct hc_driver __read_mostly > fsl_ehci_hc_driver; */ > static int fsl_ehci_drv_probe(struct platform_device *pdev) > { > + struct device_node *dn = pdev->dev.of_node; > struct fsl_usb2_platform_data *pdata; > struct usb_hcd *hcd; > - struct resource *res; > + struct resource res; > int irq; > int retval; > u32 tmp; > @@ -76,14 +78,10 @@ static int fsl_ehci_drv_probe(struct > platform_device *pdev) return -ENODEV; > } > > - res = platform_get_resource(pdev, IORESOURCE_IRQ, 0); Ah, this was the part I was missing... > - if (!res) { > - dev_err(>dev, > - "Found HC with no IRQ. Check %s setup!\n", > - dev_name(>dev)); > - return -ENODEV; > + irq = platform_get_irq(pdev, 0); > + if (irq < 0) { > + return irq; > } > - irq = res->start; > > hcd = __usb_create_hcd(_ehci_hc_driver, pdev->dev.parent, >>dev, dev_name(>dev), NULL); > @@ -92,15 +90,21 @@ static int fsl_ehci_drv_probe(struct > platform_device *pdev) goto err1; > } > > - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); > - hcd->regs = devm_ioremap_resource(>dev, res); > + platform_set_drvdata(pdev, hcd); > + pdev->dev.platform_data = pdata; > + > + tmp = of_address_to_resource(dn, 0, ); There's no need to change this. platform_get_resource() still works for IORESOURCE_MEM. Plus, drivers shouldn't use of_address_to_resource(). > + if (tmp) > + return tmp; > + > + hcd->regs = devm_ioremap_resource(>dev, ); > if (IS_ERR(hcd->regs)) { > retval = PTR_ERR(hcd->regs); > goto err2; > } > > - hcd->rsrc_start = res->start; > - hcd->rsrc_len = resource_size(res); > + hcd->rsrc_start = res.start; > + hcd->rsrc_len = resource_size(); > > pdata->regs = hcd->regs; > > diff --git a/drivers/usb/host/fsl-mph-dr-of.c > b/drivers/usb/host/fsl-mph-dr-of.c index 44a7e58..766e4ab 100644 > --- a/drivers/usb/host/fsl-mph-dr-of.c > +++ b/drivers/usb/host/fsl-mph-dr-of.c > @@ -80,8 +80,6 @@ static struct platform_device > *fsl_usb2_device_register( const char *name, int id) > { > struct platform_device *pdev; > - const struct resource *res = ofdev->resource; > - unsigned int num = ofdev->num_resources; > int retval; > > pdev = platform_device_alloc(name, id); > @@ -106,11 +104,8 @@ static struct platform_device > *fsl_usb2_device_register( if (retval) > goto error; > > - if (num) { > - retval = platform_device_add_resources(pdev, res, num); > - if (retval) > - goto error; > - } > + pdev->dev.of_node = ofdev->dev.of_node; > + pdev->dev.of_node_reused = true; > > retval = platform_device_add(pdev); > if (retval)
Re: [RFC PATCH v3 11/12] powerpc: Remove unreachable() from WARN_ON()
On 25/06/22 12:16, Christophe Leroy wrote: Le 24/06/2022 à 20:32, Sathvika Vasireddy a écrit : objtool is throwing *unannotated intra-function call* warnings with a few instructions that are marked unreachable. Remove unreachable() from WARN_ON() to fix these warnings, as the codegen remains same with and without unreachable() in WARN_ON(). Did you try the two exemples described in commit 1e688dd2a3d6 ("powerpc/bug: Provide better flexibility to WARN_ON/__WARN_FLAGS() with asm goto") ? Without your patch: 0640 : 640: 81 23 00 84 lwz r9,132(r3) 644: 71 29 40 00 andi. r9,r9,16384 648: 40 82 00 0c bne 654 64c: 80 63 00 0c lwz r3,12(r3) 650: 4e 80 00 20 blr 654: 0f e0 00 00 twuir0,0 0658 : 658: 2c 04 00 00 cmpwi r4,0 65c: 41 82 00 0c beq 668 660: 7c 63 23 96 divwu r3,r3,r4 664: 4e 80 00 20 blr 668: 0f e0 00 00 twuir0,0 66c: 38 60 00 00 li r3,0 670: 4e 80 00 20 blr With your patch: 0640 : 640: 81 23 00 84 lwz r9,132(r3) 644: 71 29 40 00 andi. r9,r9,16384 648: 40 82 00 0c bne 654 64c: 80 63 00 0c lwz r3,12(r3) 650: 4e 80 00 20 blr 654: 0f e0 00 00 twuir0,0 658: 4b ff ff f4 b 64c <== 065c : 65c: 2c 04 00 00 cmpwi r4,0 660: 41 82 00 0c beq 66c 664: 7c 63 23 96 divwu r3,r3,r4 668: 4e 80 00 20 blr 66c: 0f e0 00 00 twuir0,0 670: 38 60 00 00 li r3,0<== 674: 4e 80 00 20 blr <== 678: 38 60 00 00 li r3,0 67c: 4e 80 00 20 blr The builtin variant of unreachable (__builtin_unreachable()) works. How about using that instead of unreachable() ? - Sathvika
Re: [PATCH 1/2] powerpc/numa: Return the first online node instead of 0
Srikar Dronamraju writes: > * Aneesh Kumar K.V [2022-06-23 18:24:41]: > >> If early cpu to node mapping finds an invalid node id, return >> the first online node instead of node 0. >> >> With commit e75130f20b1f ("powerpc/numa: Offline memoryless cpuless node 0") >> the kernel marks node 0 offline in certain scenarios. >> >> Signed-off-by: Aneesh Kumar K.V >> --- >> arch/powerpc/include/asm/topology.h | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/arch/powerpc/include/asm/topology.h >> b/arch/powerpc/include/asm/topology.h >> index 8a4d4f4d9749..704088b1d53c 100644 >> --- a/arch/powerpc/include/asm/topology.h >> +++ b/arch/powerpc/include/asm/topology.h >> @@ -60,7 +60,7 @@ static inline int early_cpu_to_node(int cpu) >> * Fall back to node 0 if nid is unset (it should be, except bugs). >> * This allows callers to safely do NODE_DATA(early_cpu_to_node(cpu)). >> */ >> -return (nid < 0) ? 0 : nid; >> +return (nid < 0) ? first_online_node : nid; > > Looks good but just two queries. > > 1. Is there a possibility of early_cpu_to_node() being called before any > node is online? The kernel operate with node 0 online most of the early boot and mark it offline in mem_topology_setup() just before parse_numa_properties(). So we should find some nodes set online. > > 2. first_online_node is actually not a variable, it returns the lowest > online node. Right? If lets a early_cpu_to_node() for the same CPU across a > node online/offline may end up giving two different nids. Right? > The change is specific to a case where we find uninitialized numa_cpu_lookup_table. ie, the firmware didn't specify the mapping for the cpu. I do agree that for such cpus the node mapping can change because of the above. I am not sure whether this can cause any issue in practice. But returning node 0 which can be marked offline can result in crashes? > >> } >> >> int of_drconf_to_nid_single(struct drmem_lmb *lmb); >> -- >> 2.36.1 >> > > -- > Thanks and Regards > Srikar Dronamraju
[PATCH 12/13] selftests/powerpc/ptrace: Use more interesting values
The ptrace-gpr test uses fixed values to test that registers can be read/written via ptrace. In particular it sets all GPRs to 1, which means the test could miss some types of bugs - eg. if the kernel was only returning the low word. So generate some random values at startup and use those instead. Signed-off-by: Michael Ellerman --- .../selftests/powerpc/ptrace/ptrace-gpr.c | 71 +++ 1 file changed, 57 insertions(+), 14 deletions(-) diff --git a/tools/testing/selftests/powerpc/ptrace/ptrace-gpr.c b/tools/testing/selftests/powerpc/ptrace/ptrace-gpr.c index b574ea26395c..c5dcb8c02616 100644 --- a/tools/testing/selftests/powerpc/ptrace/ptrace-gpr.c +++ b/tools/testing/selftests/powerpc/ptrace/ptrace-gpr.c @@ -7,18 +7,18 @@ #include "ptrace.h" #include "ptrace-gpr.h" #include "reg.h" +#include /* Tracer and Tracee Shared Data */ int shm_id; int *cptr, *pptr; -double a = FPR_1; -double b = FPR_2; -double c = FPR_3; - extern void gpr_child_loop(int *read_flag, int *write_flag, unsigned long *gpr_buf, double *fpr_buf); +unsigned long child_gpr_val, parent_gpr_val; +double child_fpr_val, parent_fpr_val; + static int child(void) { unsigned long gpr_buf[32]; @@ -30,16 +30,16 @@ static int child(void) memset(fpr_buf, 0, sizeof(fpr_buf)); for (i = 0; i < 32; i++) { - gpr_buf[i] = GPR_1; - fpr_buf[i] = a; + gpr_buf[i] = child_gpr_val; + fpr_buf[i] = child_fpr_val; } gpr_child_loop([0], [1], gpr_buf, fpr_buf); shmdt((void *)cptr); - FAIL_IF(validate_gpr(gpr_buf, GPR_3)); - FAIL_IF(validate_fpr_double(fpr_buf, c)); + FAIL_IF(validate_gpr(gpr_buf, parent_gpr_val)); + FAIL_IF(validate_fpr_double(fpr_buf, parent_fpr_val)); return 0; } @@ -47,24 +47,67 @@ static int child(void) int trace_gpr(pid_t child) { unsigned long gpr[18]; - __u64 fpr[32]; + __u64 tmp, fpr[32]; FAIL_IF(start_trace(child)); FAIL_IF(show_gpr(child, gpr)); - FAIL_IF(validate_gpr(gpr, GPR_1)); + FAIL_IF(validate_gpr(gpr, child_gpr_val)); FAIL_IF(show_fpr(child, fpr)); - FAIL_IF(validate_fpr(fpr, FPR_1_REP)); - FAIL_IF(write_gpr(child, GPR_3)); - FAIL_IF(write_fpr(child, FPR_3_REP)); + + memcpy(, _fpr_val, sizeof(tmp)); + FAIL_IF(validate_fpr(fpr, tmp)); + + FAIL_IF(write_gpr(child, parent_gpr_val)); + + memcpy(, _fpr_val, sizeof(tmp)); + FAIL_IF(write_fpr(child, tmp)); + FAIL_IF(stop_trace(child)); return TEST_PASS; } +#ifndef __LONG_WIDTH__ +#define __LONG_WIDTH__ (sizeof(long) * 8) +#endif + +static uint64_t rand_reg(void) +{ + uint64_t result; + long r; + + r = random(); + + // Small values are typical + result = r & 0x; + if (r & 0x1) + return result; + + // Pointers tend to have high bits set + result |= random() << (__LONG_WIDTH__ - 31); + if (r & 0x10) + return result; + + // And sometimes we want a full 64-bit value + result ^= random() << 16; + + return result; +} + int ptrace_gpr(void) { - pid_t pid; + unsigned long seed; int ret, status; + pid_t pid; + + seed = getpid() ^ time(NULL); + printf("srand(%lu)\n", seed); + srand(seed); + + child_gpr_val = rand_reg(); + child_fpr_val = rand_reg(); + parent_gpr_val = rand_reg(); + parent_fpr_val = rand_reg(); shm_id = shmget(IPC_PRIVATE, sizeof(int) * 2, 0777|IPC_CREAT); pid = fork(); -- 2.35.3
[PATCH 13/13] selftests/powerpc/ptrace: Add peek/poke of FPRs
Currently the ptrace-gpr test only tests the GET/SET(FP)REGS ptrace APIs. But there's an alternate (older) API, called PEEK/POKEUSR. Add some minimal testing of PEEK/POKEUSR of the FPRs. This is sufficient to detect the bug that was fixed recently in the 32-bit ptrace FPR handling. Depends-on: 8e127846 ("powerpc/32: Fix overread/overwrite of thread_struct via ptrace") Signed-off-by: Michael Ellerman --- .../selftests/powerpc/ptrace/ptrace-gpr.c | 24 ++- .../testing/selftests/powerpc/ptrace/ptrace.h | 65 +++ 2 files changed, 87 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/powerpc/ptrace/ptrace-gpr.c b/tools/testing/selftests/powerpc/ptrace/ptrace-gpr.c index c5dcb8c02616..9ed87d297799 100644 --- a/tools/testing/selftests/powerpc/ptrace/ptrace-gpr.c +++ b/tools/testing/selftests/powerpc/ptrace/ptrace-gpr.c @@ -46,22 +46,42 @@ static int child(void) int trace_gpr(pid_t child) { + __u64 tmp, fpr[32], *peeked_fprs; unsigned long gpr[18]; - __u64 tmp, fpr[32]; FAIL_IF(start_trace(child)); + + // Check child GPRs match what we expect using GETREGS FAIL_IF(show_gpr(child, gpr)); FAIL_IF(validate_gpr(gpr, child_gpr_val)); - FAIL_IF(show_fpr(child, fpr)); + // Check child FPRs match what we expect using GETFPREGS + FAIL_IF(show_fpr(child, fpr)); memcpy(, _fpr_val, sizeof(tmp)); FAIL_IF(validate_fpr(fpr, tmp)); + // Check child FPRs match what we expect using PEEKUSR + peeked_fprs = peek_fprs(child); + FAIL_IF(!peeked_fprs); + FAIL_IF(validate_fpr(peeked_fprs, tmp)); + free(peeked_fprs); + + // Write child GPRs using SETREGS FAIL_IF(write_gpr(child, parent_gpr_val)); + // Write child FPRs using SETFPREGS memcpy(, _fpr_val, sizeof(tmp)); FAIL_IF(write_fpr(child, tmp)); + // Check child FPRs match what we just set, using PEEKUSR + peeked_fprs = peek_fprs(child); + FAIL_IF(!peeked_fprs); + FAIL_IF(validate_fpr(peeked_fprs, tmp)); + + // Write child FPRs using POKEUSR + FAIL_IF(poke_fprs(child, (unsigned long *)peeked_fprs)); + + // Child will check its FPRs match before exiting FAIL_IF(stop_trace(child)); return TEST_PASS; diff --git a/tools/testing/selftests/powerpc/ptrace/ptrace.h b/tools/testing/selftests/powerpc/ptrace/ptrace.h index 4672e848604f..4e0233c0f2b3 100644 --- a/tools/testing/selftests/powerpc/ptrace/ptrace.h +++ b/tools/testing/selftests/powerpc/ptrace/ptrace.h @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -440,6 +441,70 @@ int show_gpr(pid_t child, unsigned long *gpr) return TEST_PASS; } +long sys_ptrace(enum __ptrace_request request, pid_t pid, unsigned long addr, unsigned long data) +{ + return syscall(__NR_ptrace, request, pid, (void *)addr, data); +} + +// 33 because of FPSCR +#define PT_NUM_FPRS(33 * (sizeof(__u64) / sizeof(unsigned long))) + +__u64 *peek_fprs(pid_t child) +{ + unsigned long *fprs, *p, addr; + long ret; + int i; + + fprs = malloc(sizeof(unsigned long) * PT_NUM_FPRS); + if (!fprs) { + perror("malloc() failed"); + return NULL; + } + + for (i = 0, p = fprs; i < PT_NUM_FPRS; i++, p++) { + addr = sizeof(unsigned long) * (PT_FPR0 + i); + ret = sys_ptrace(PTRACE_PEEKUSER, child, addr, (unsigned long)p); + if (ret) { + perror("ptrace(PTRACE_PEEKUSR) failed"); + return NULL; + } + } + + addr = sizeof(unsigned long) * (PT_FPR0 + i); + ret = sys_ptrace(PTRACE_PEEKUSER, child, addr, (unsigned long)); + if (!ret) { + printf("ptrace(PTRACE_PEEKUSR) succeeded unexpectedly!\n"); + return NULL; + } + + return (__u64 *)fprs; +} + +int poke_fprs(pid_t child, unsigned long *fprs) +{ + unsigned long *p, addr; + long ret; + int i; + + for (i = 0, p = fprs; i < PT_NUM_FPRS; i++, p++) { + addr = sizeof(unsigned long) * (PT_FPR0 + i); + ret = sys_ptrace(PTRACE_POKEUSER, child, addr, *p); + if (ret) { + perror("ptrace(PTRACE_POKEUSR) failed"); + return -1; + } + } + + addr = sizeof(unsigned long) * (PT_FPR0 + i); + ret = sys_ptrace(PTRACE_POKEUSER, child, addr, addr); + if (!ret) { + printf("ptrace(PTRACE_POKEUSR) succeeded unexpectedly!\n"); + return -1; + } + + return 0; +} + int write_gpr(pid_t child, unsigned long val) { struct pt_regs *regs; -- 2.35.3
[PATCH 10/13] selftests/powerpc/ptrace: Do more of ptrace-gpr in asm
The ptrace-gpr test includes some inline asm to load GPR and FPR registers. It then goes back to C to wait for the parent to trace it and then checks register contents. The split between inline asm and C is fragile, it relies on the compiler not using any non-volatile GPRs after the inline asm block. It also requires a very large and unwieldy inline asm block. So convert the logic to set registers, wait, and store registers to a single asm function, meaning there's no window for the compiler to intervene. Signed-off-by: Michael Ellerman --- .../selftests/powerpc/include/basic_asm.h | 8 +++ .../testing/selftests/powerpc/ptrace/Makefile | 1 + .../selftests/powerpc/ptrace/ptrace-gpr.S | 52 +++ .../selftests/powerpc/ptrace/ptrace-gpr.c | 29 +-- 4 files changed, 73 insertions(+), 17 deletions(-) create mode 100644 tools/testing/selftests/powerpc/ptrace/ptrace-gpr.S diff --git a/tools/testing/selftests/powerpc/include/basic_asm.h b/tools/testing/selftests/powerpc/include/basic_asm.h index 2d7f6e592dd9..26cde8ea1f49 100644 --- a/tools/testing/selftests/powerpc/include/basic_asm.h +++ b/tools/testing/selftests/powerpc/include/basic_asm.h @@ -94,4 +94,12 @@ PPC_LL r0, STACK_FRAME_LR_POS(%r1); \ mtlrr0; +.macro OP_REGS op, reg_width, start_reg, end_reg, base_reg, base_reg_offset=0, skip=0 + .set i, \start_reg + .rept (\end_reg - \start_reg + 1) + \op i, (\reg_width * (i - \skip) + \base_reg_offset)(\base_reg) + .set i, i + 1 + .endr +.endm + #endif /* _SELFTESTS_POWERPC_BASIC_ASM_H */ diff --git a/tools/testing/selftests/powerpc/ptrace/Makefile b/tools/testing/selftests/powerpc/ptrace/Makefile index 3434a624ed77..2f02cb54224d 100644 --- a/tools/testing/selftests/powerpc/ptrace/Makefile +++ b/tools/testing/selftests/powerpc/ptrace/Makefile @@ -35,6 +35,7 @@ $(TM_TESTS): CFLAGS += -I../tm -mhtm CFLAGS += -I../../../../../usr/include -fno-pie +$(OUTPUT)/ptrace-gpr: ptrace-gpr.S $(OUTPUT)/ptrace-pkey $(OUTPUT)/core-pkey: LDLIBS += -pthread $(TEST_GEN_PROGS): ../harness.c ../utils.c ../lib/reg.S diff --git a/tools/testing/selftests/powerpc/ptrace/ptrace-gpr.S b/tools/testing/selftests/powerpc/ptrace/ptrace-gpr.S new file mode 100644 index ..070e8443e3cc --- /dev/null +++ b/tools/testing/selftests/powerpc/ptrace/ptrace-gpr.S @@ -0,0 +1,52 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * test helper assembly functions + * + * Copyright (C) 2016 Simon Guo, IBM Corporation. + * Copyright 2022 Michael Ellerman, IBM Corporation. + */ +#include "basic_asm.h" + +#define GPR_SIZE __SIZEOF_LONG__ +#define FIRST_GPR 14 +#define NUM_GPRS (32 - FIRST_GPR) +#define STACK_SIZE (NUM_GPRS * GPR_SIZE) + +// gpr_child_loop(int *read_flag, int *write_flag, +// unsigned long *gpr_buf, double *fpr_buf); +FUNC_START(gpr_child_loop) + // r3 = read_flag + // r4 = write_flag + // r5 = gpr_buf + // r6 = fpr_buf + PUSH_BASIC_STACK(STACK_SIZE) + + // Save non-volatile GPRs + OP_REGS PPC_STL, GPR_SIZE, FIRST_GPR, 31, %r1, STACK_FRAME_LOCAL(0, 0), FIRST_GPR + + // Load GPRs with expected values + OP_REGS PPC_LL, GPR_SIZE, FIRST_GPR, 31, r5, 0, FIRST_GPR + + // Load FPRs with expected values + OP_REGS lfd, 8, 0, 31, r6 + + // Signal to parent that we're ready + li r0, 1 + stw r0, 0(r4) + + // Wait for parent to finish +1: lwz r0, 0(r3) + cmpwi r0, 0 + beq 1b // Loop while flag is zero + + // Save GPRs back to caller buffer + OP_REGS PPC_STL, GPR_SIZE, FIRST_GPR, 31, r5, 0, FIRST_GPR + + // Save FPRs + OP_REGS stfd, 8, 0, 31, r6 + + // Reload non-volatile GPRs + OP_REGS PPC_LL, GPR_SIZE, FIRST_GPR, 31, %r1, STACK_FRAME_LOCAL(0, 0), FIRST_GPR + + POP_BASIC_STACK(STACK_SIZE) + blr diff --git a/tools/testing/selftests/powerpc/ptrace/ptrace-gpr.c b/tools/testing/selftests/powerpc/ptrace/ptrace-gpr.c index 1468e89c044b..4e7a7eb01e3a 100644 --- a/tools/testing/selftests/powerpc/ptrace/ptrace-gpr.c +++ b/tools/testing/selftests/powerpc/ptrace/ptrace-gpr.c @@ -16,32 +16,27 @@ double a = FPR_1; double b = FPR_2; double c = FPR_3; +extern void gpr_child_loop(int *read_flag, int *write_flag, + unsigned long *gpr_buf, double *fpr_buf); + void gpr(void) { - unsigned long gpr_buf[18]; + unsigned long gpr_buf[32]; double fpr_buf[32]; + int i; cptr = (int *)shmat(shm_id, NULL, 0); + memset(gpr_buf, 0, sizeof(gpr_buf)); + memset(fpr_buf, 0, sizeof(fpr_buf)); - asm __volatile__( - ASM_LOAD_GPR_IMMED(gpr_1) - ASM_LOAD_FPR(flt_1) - : - : [gpr_1]"i"(GPR_1), [flt_1] "b" () - : "memory", "r6", "r7", "r8", "r9", "r10", - "r11", "r12", "r13", "r14", "r15",
[PATCH 09/13] selftests/powerpc/ptrace: Build the ptrace-gpr test as 32-bit when possible
The ptrace-gpr test can now be built 32-bit, so do that if that's the compiler default rather than forcing a 64-bit build. Signed-off-by: Michael Ellerman --- tools/testing/selftests/powerpc/ptrace/Makefile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/powerpc/ptrace/Makefile b/tools/testing/selftests/powerpc/ptrace/Makefile index 8611b0670587..3434a624ed77 100644 --- a/tools/testing/selftests/powerpc/ptrace/Makefile +++ b/tools/testing/selftests/powerpc/ptrace/Makefile @@ -11,7 +11,6 @@ TM_TESTS += ptrace-tm-vsx TESTS_64 := $(TM_TESTS) TESTS_64 += core-pkey TESTS_64 += perf-hwbreak -TESTS_64 += ptrace-gpr TESTS_64 += ptrace-hwbreak TESTS_64 += ptrace-perf-hwbreak TESTS_64 += ptrace-pkey @@ -19,7 +18,9 @@ TESTS_64 += ptrace-syscall TESTS_64 += ptrace-tar TESTS_64 += ptrace-vsx -TEST_GEN_PROGS := $(TESTS_64) +TESTS += ptrace-gpr + +TEST_GEN_PROGS := $(TESTS) $(TESTS_64) LOCAL_HDRS += $(patsubst %,$(selfdir)/powerpc/ptrace/%,$(wildcard *.h)) -- 2.35.3
[PATCH 11/13] selftests/powerpc/ptrace: Make child errors more obvious
Use the FAIL_IF() macro so that errors in the child report a line number, rather than just silently exiting. Signed-off-by: Michael Ellerman --- tools/testing/selftests/powerpc/ptrace/ptrace-gpr.c | 13 + 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/tools/testing/selftests/powerpc/ptrace/ptrace-gpr.c b/tools/testing/selftests/powerpc/ptrace/ptrace-gpr.c index 4e7a7eb01e3a..b574ea26395c 100644 --- a/tools/testing/selftests/powerpc/ptrace/ptrace-gpr.c +++ b/tools/testing/selftests/powerpc/ptrace/ptrace-gpr.c @@ -19,7 +19,7 @@ double c = FPR_3; extern void gpr_child_loop(int *read_flag, int *write_flag, unsigned long *gpr_buf, double *fpr_buf); -void gpr(void) +static int child(void) { unsigned long gpr_buf[32]; double fpr_buf[32]; @@ -38,13 +38,10 @@ void gpr(void) shmdt((void *)cptr); - if (validate_gpr(gpr_buf, GPR_3)) - exit(1); + FAIL_IF(validate_gpr(gpr_buf, GPR_3)); + FAIL_IF(validate_fpr_double(fpr_buf, c)); - if (validate_fpr_double(fpr_buf, c)) - exit(1); - - exit(0); + return 0; } int trace_gpr(pid_t child) @@ -76,7 +73,7 @@ int ptrace_gpr(void) return TEST_FAIL; } if (pid == 0) - gpr(); + exit(child()); if (pid) { pptr = (int *)shmat(shm_id, NULL, 0); -- 2.35.3
[PATCH 05/13] selftests/powerpc: Don't save TOC by default in asm helpers
Thare are some asm helpers for creating/popping stack frames in basic_asm.h. They always save/restore r2 (TOC pointer), but none of the selftests change r2, so it's unnecessary to save it by default. Signed-off-by: Michael Ellerman --- tools/testing/selftests/powerpc/include/basic_asm.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tools/testing/selftests/powerpc/include/basic_asm.h b/tools/testing/selftests/powerpc/include/basic_asm.h index faec7b11c041..be380aa779f8 100644 --- a/tools/testing/selftests/powerpc/include/basic_asm.h +++ b/tools/testing/selftests/powerpc/include/basic_asm.h @@ -58,11 +58,9 @@ #define PUSH_BASIC_STACK(_extra) \ mflrr0; \ std r0, STACK_FRAME_LR_POS(%r1); \ - stdu%r1, -(((_extra + 15) & ~15) + STACK_FRAME_MIN_SIZE)(%r1); \ - std %r2, STACK_FRAME_TOC_POS(%r1); + stdu%r1, -(((_extra + 15) & ~15) + STACK_FRAME_MIN_SIZE)(%r1); #define POP_BASIC_STACK(_extra) \ - ld %r2, STACK_FRAME_TOC_POS(%r1); \ addi%r1, %r1, (((_extra + 15) & ~15) + STACK_FRAME_MIN_SIZE); \ ld r0, STACK_FRAME_LR_POS(%r1); \ mtlrr0; -- 2.35.3
[PATCH 08/13] selftests/powerpc/ptrace: Convert to load/store doubles
Some of the ptrace tests check the contents of floating pointer registers. Currently these use float, which is always 4 bytes, but the ptrace API supports saving/restoring 8 bytes per register, so switch to using doubles to exercise the code more fully. Signed-off-by: Michael Ellerman --- tools/testing/selftests/powerpc/include/reg.h | 68 +- tools/testing/selftests/powerpc/lib/reg.S | 70 +-- .../selftests/powerpc/ptrace/ptrace-gpr.c | 16 ++--- .../selftests/powerpc/ptrace/ptrace-gpr.h | 14 ++-- .../selftests/powerpc/ptrace/ptrace-tm-gpr.c | 18 ++--- .../powerpc/ptrace/ptrace-tm-spd-gpr.c| 20 +++--- .../testing/selftests/powerpc/ptrace/ptrace.h | 14 ++-- 7 files changed, 111 insertions(+), 109 deletions(-) diff --git a/tools/testing/selftests/powerpc/include/reg.h b/tools/testing/selftests/powerpc/include/reg.h index bc7f610c2c6d..7f0dc2f62496 100644 --- a/tools/testing/selftests/powerpc/include/reg.h +++ b/tools/testing/selftests/powerpc/include/reg.h @@ -123,44 +123,44 @@ "li 30, %[" #_asm_symbol_name_immed "];" \ "li 31, %[" #_asm_symbol_name_immed "];" -#define ASM_LOAD_FPR_SINGLE_PRECISION(_asm_symbol_name_addr) \ - "lfs 0, 0(%[" #_asm_symbol_name_addr "]);" \ - "lfs 1, 0(%[" #_asm_symbol_name_addr "]);" \ - "lfs 2, 0(%[" #_asm_symbol_name_addr "]);" \ - "lfs 3, 0(%[" #_asm_symbol_name_addr "]);" \ - "lfs 4, 0(%[" #_asm_symbol_name_addr "]);" \ - "lfs 5, 0(%[" #_asm_symbol_name_addr "]);" \ - "lfs 6, 0(%[" #_asm_symbol_name_addr "]);" \ - "lfs 7, 0(%[" #_asm_symbol_name_addr "]);" \ - "lfs 8, 0(%[" #_asm_symbol_name_addr "]);" \ - "lfs 9, 0(%[" #_asm_symbol_name_addr "]);" \ - "lfs 10, 0(%[" #_asm_symbol_name_addr "]);" \ - "lfs 11, 0(%[" #_asm_symbol_name_addr "]);" \ - "lfs 12, 0(%[" #_asm_symbol_name_addr "]);" \ - "lfs 13, 0(%[" #_asm_symbol_name_addr "]);" \ - "lfs 14, 0(%[" #_asm_symbol_name_addr "]);" \ - "lfs 15, 0(%[" #_asm_symbol_name_addr "]);" \ - "lfs 16, 0(%[" #_asm_symbol_name_addr "]);" \ - "lfs 17, 0(%[" #_asm_symbol_name_addr "]);" \ - "lfs 18, 0(%[" #_asm_symbol_name_addr "]);" \ - "lfs 19, 0(%[" #_asm_symbol_name_addr "]);" \ - "lfs 20, 0(%[" #_asm_symbol_name_addr "]);" \ - "lfs 21, 0(%[" #_asm_symbol_name_addr "]);" \ - "lfs 22, 0(%[" #_asm_symbol_name_addr "]);" \ - "lfs 23, 0(%[" #_asm_symbol_name_addr "]);" \ - "lfs 24, 0(%[" #_asm_symbol_name_addr "]);" \ - "lfs 25, 0(%[" #_asm_symbol_name_addr "]);" \ - "lfs 26, 0(%[" #_asm_symbol_name_addr "]);" \ - "lfs 27, 0(%[" #_asm_symbol_name_addr "]);" \ - "lfs 28, 0(%[" #_asm_symbol_name_addr "]);" \ - "lfs 29, 0(%[" #_asm_symbol_name_addr "]);" \ - "lfs 30, 0(%[" #_asm_symbol_name_addr "]);" \ - "lfs 31, 0(%[" #_asm_symbol_name_addr "]);" +#define ASM_LOAD_FPR(_asm_symbol_name_addr) \ + "lfd 0, 0(%[" #_asm_symbol_name_addr "]);" \ + "lfd 1, 0(%[" #_asm_symbol_name_addr "]);" \ + "lfd 2, 0(%[" #_asm_symbol_name_addr "]);" \ + "lfd 3, 0(%[" #_asm_symbol_name_addr "]);" \ + "lfd 4, 0(%[" #_asm_symbol_name_addr "]);" \ + "lfd 5, 0(%[" #_asm_symbol_name_addr "]);" \ + "lfd 6, 0(%[" #_asm_symbol_name_addr "]);" \ + "lfd 7, 0(%[" #_asm_symbol_name_addr "]);" \ + "lfd 8, 0(%[" #_asm_symbol_name_addr "]);" \ + "lfd 9, 0(%[" #_asm_symbol_name_addr "]);" \ + "lfd 10, 0(%[" #_asm_symbol_name_addr "]);" \ + "lfd 11, 0(%[" #_asm_symbol_name_addr "]);" \ + "lfd 12, 0(%[" #_asm_symbol_name_addr "]);" \ + "lfd 13, 0(%[" #_asm_symbol_name_addr "]);" \ + "lfd 14, 0(%[" #_asm_symbol_name_addr "]);" \ + "lfd 15, 0(%[" #_asm_symbol_name_addr "]);" \ + "lfd 16, 0(%[" #_asm_symbol_name_addr "]);" \ + "lfd 17, 0(%[" #_asm_symbol_name_addr "]);" \ + "lfd 18, 0(%[" #_asm_symbol_name_addr "]);" \ + "lfd 19, 0(%[" #_asm_symbol_name_addr "]);" \ + "lfd 20, 0(%[" #_asm_symbol_name_addr "]);" \ + "lfd 21, 0(%[" #_asm_symbol_name_addr "]);" \ + "lfd 22, 0(%[" #_asm_symbol_name_addr "]);" \ + "lfd 23, 0(%[" #_asm_symbol_name_addr "]);" \ + "lfd 24, 0(%[" #_asm_symbol_name_addr "]);" \ + "lfd 25, 0(%[" #_asm_symbol_name_addr "]);" \ + "lfd 26, 0(%[" #_asm_symbol_name_addr "]);" \ + "lfd 27, 0(%[" #_asm_symbol_name_addr "]);" \ +
[PATCH 03/13] selftests/powerpc/ptrace: Split CFLAGS better
Currently all ptrace tests are built 64-bit and with TM enabled. Only the TM tests need TM enabled, so split those out into a separate variable so that can be specified precisely. Split the rest of the tests into a variable, and add -m64 to CFLAGS for those tests, so that in a subsequent patch some tests can be made to build 32-bit. Signed-off-by: Michael Ellerman --- .../testing/selftests/powerpc/ptrace/Makefile | 33 --- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/tools/testing/selftests/powerpc/ptrace/Makefile b/tools/testing/selftests/powerpc/ptrace/Makefile index 0b0652d88b1b..8611b0670587 100644 --- a/tools/testing/selftests/powerpc/ptrace/Makefile +++ b/tools/testing/selftests/powerpc/ptrace/Makefile @@ -1,15 +1,38 @@ # SPDX-License-Identifier: GPL-2.0 -TEST_GEN_PROGS := ptrace-gpr ptrace-tm-gpr ptrace-tm-spd-gpr \ - ptrace-tar ptrace-tm-tar ptrace-tm-spd-tar ptrace-vsx ptrace-tm-vsx \ - ptrace-tm-spd-vsx ptrace-tm-spr ptrace-hwbreak ptrace-pkey core-pkey \ - perf-hwbreak ptrace-syscall ptrace-perf-hwbreak + +TM_TESTS := ptrace-tm-gpr +TM_TESTS += ptrace-tm-spd-gpr +TM_TESTS += ptrace-tm-spd-tar +TM_TESTS += ptrace-tm-spd-vsx +TM_TESTS += ptrace-tm-spr +TM_TESTS += ptrace-tm-tar +TM_TESTS += ptrace-tm-vsx + +TESTS_64 := $(TM_TESTS) +TESTS_64 += core-pkey +TESTS_64 += perf-hwbreak +TESTS_64 += ptrace-gpr +TESTS_64 += ptrace-hwbreak +TESTS_64 += ptrace-perf-hwbreak +TESTS_64 += ptrace-pkey +TESTS_64 += ptrace-syscall +TESTS_64 += ptrace-tar +TESTS_64 += ptrace-vsx + +TEST_GEN_PROGS := $(TESTS_64) LOCAL_HDRS += $(patsubst %,$(selfdir)/powerpc/ptrace/%,$(wildcard *.h)) top_srcdir = ../../../../.. include ../../lib.mk -CFLAGS += -m64 -I../../../../../usr/include -I../tm -mhtm -fno-pie +TM_TESTS := $(patsubst %,$(OUTPUT)/%,$(TM_TESTS)) +TESTS_64 := $(patsubst %,$(OUTPUT)/%,$(TESTS_64)) + +$(TESTS_64): CFLAGS += -m64 +$(TM_TESTS): CFLAGS += -I../tm -mhtm + +CFLAGS += -I../../../../../usr/include -fno-pie $(OUTPUT)/ptrace-pkey $(OUTPUT)/core-pkey: LDLIBS += -pthread -- 2.35.3
[PATCH 07/13] selftests/powerpc/ptrace: Drop unused load_fpr_single_precision()
This function is never called, drop it. Signed-off-by: Michael Ellerman --- tools/testing/selftests/powerpc/include/reg.h | 1 - tools/testing/selftests/powerpc/lib/reg.S | 37 --- 2 files changed, 38 deletions(-) diff --git a/tools/testing/selftests/powerpc/include/reg.h b/tools/testing/selftests/powerpc/include/reg.h index c422be8a42b2..bc7f610c2c6d 100644 --- a/tools/testing/selftests/powerpc/include/reg.h +++ b/tools/testing/selftests/powerpc/include/reg.h @@ -160,7 +160,6 @@ #ifndef __ASSEMBLER__ void store_gpr(unsigned long *addr); void load_gpr(unsigned long *addr); -void load_fpr_single_precision(float *addr); void store_fpr_single_precision(float *addr); #endif /* end of __ASSEMBLER__ */ diff --git a/tools/testing/selftests/powerpc/lib/reg.S b/tools/testing/selftests/powerpc/lib/reg.S index 9304ea7d59b9..dd37b8e6f84c 100644 --- a/tools/testing/selftests/powerpc/lib/reg.S +++ b/tools/testing/selftests/powerpc/lib/reg.S @@ -53,43 +53,6 @@ FUNC_START(store_gpr) blr FUNC_END(store_gpr) -/* Single Precision Float - float buf[32] */ -FUNC_START(load_fpr_single_precision) - lfs 0, 0*4(3) - lfs 1, 1*4(3) - lfs 2, 2*4(3) - lfs 3, 3*4(3) - lfs 4, 4*4(3) - lfs 5, 5*4(3) - lfs 6, 6*4(3) - lfs 7, 7*4(3) - lfs 8, 8*4(3) - lfs 9, 9*4(3) - lfs 10, 10*4(3) - lfs 11, 11*4(3) - lfs 12, 12*4(3) - lfs 13, 13*4(3) - lfs 14, 14*4(3) - lfs 15, 15*4(3) - lfs 16, 16*4(3) - lfs 17, 17*4(3) - lfs 18, 18*4(3) - lfs 19, 19*4(3) - lfs 20, 20*4(3) - lfs 21, 21*4(3) - lfs 22, 22*4(3) - lfs 23, 23*4(3) - lfs 24, 24*4(3) - lfs 25, 25*4(3) - lfs 26, 26*4(3) - lfs 27, 27*4(3) - lfs 28, 28*4(3) - lfs 29, 29*4(3) - lfs 30, 30*4(3) - lfs 31, 31*4(3) - blr -FUNC_END(load_fpr_single_precision) - /* Single Precision Float - float buf[32] */ FUNC_START(store_fpr_single_precision) stfs 0, 0*4(3) -- 2.35.3
[PATCH v3 0/4] Extending NMI watchdog during LPM
When a partition is transferred, once it arrives at the destination node, the partition is active but much of its memory must be transferred from the start node. It depends on the activity in the partition, but the more CPU the partition has, the more memory to be transferred is likely to be. This causes latency when accessing pages that need to be transferred, and often, for large partitions, it triggers the NMI watchdog. The NMI watchdog causes the CPU stack to dump where it appears to be stuck. In this case, it does not bring much information since it can happen during any memory access of the kernel. In addition, the NMI interrupt mechanism is not secure and can generate a dump system in the event that the interruption is taken while MSR[RI]=0. Depending on the LPAR size and load, it may be interesting to extend the NMI watchdog timer during the LPM. That's configurable through sysctl with the new introduced variable (specific to powerpc) nmi_watchdog_factor. This value represents the percentage added to watchdog_tresh to set the NMI watchdog timeout during a LPM. Changes in v3: - don't export watchdog_mutex - fix a comment in mobilty.c, wait_for_vasi_session_completed() - fix a build issue when !CONFIG_PPC_WATCHDOG - rework some printk and rename the sysctl variable. v2: https://lore.kernel.org/all/20220614135414.37746-1-lduf...@linux.ibm.com/ Laurent Dufour (4): powerpc/mobility: wait for memory transfer to complete watchdog: export lockup_detector_reconfigure powerpc/watchdog: introduce a NMI watchdog's factor pseries/mobility: set NMI watchdog factor during LPM Documentation/admin-guide/sysctl/kernel.rst | 12 +++ arch/powerpc/include/asm/nmi.h | 2 + arch/powerpc/kernel/watchdog.c | 21 - arch/powerpc/platforms/pseries/mobility.c | 85 - include/linux/nmi.h | 2 + kernel/watchdog.c | 21 +++-- 6 files changed, 135 insertions(+), 8 deletions(-) -- 2.36.1
[PATCH 06/13] selftests/powerpc: Add 32-bit support to asm helpers
Add support for 32-bit builds to the asm helpers. Signed-off-by: Michael Ellerman --- .../selftests/powerpc/include/basic_asm.h | 47 +++ 1 file changed, 38 insertions(+), 9 deletions(-) diff --git a/tools/testing/selftests/powerpc/include/basic_asm.h b/tools/testing/selftests/powerpc/include/basic_asm.h index be380aa779f8..2d7f6e592dd9 100644 --- a/tools/testing/selftests/powerpc/include/basic_asm.h +++ b/tools/testing/selftests/powerpc/include/basic_asm.h @@ -5,6 +5,16 @@ #include #include +#ifdef __powerpc64__ +#define PPC_LL ld +#define PPC_STLstd +#define PPC_STLU stdu +#else +#define PPC_LL lwz +#define PPC_STLstw +#define PPC_STLU stwu +#endif + #define LOAD_REG_IMMEDIATE(reg, expr) \ lis reg, (expr)@highest;\ ori reg, reg, (expr)@higher;\ @@ -14,16 +24,20 @@ /* * Note: These macros assume that variables being stored on the stack are - * doublewords, while this is usually the case it may not always be the + * sizeof(long), while this is usually the case it may not always be the * case for each use case. */ +#ifdef __powerpc64__ + +// ABIv2 #if defined(_CALL_ELF) && _CALL_ELF == 2 #define STACK_FRAME_MIN_SIZE 32 #define STACK_FRAME_TOC_POS 24 #define __STACK_FRAME_PARAM(_param) (32 + ((_param)*8)) #define __STACK_FRAME_LOCAL(_num_params, _var_num) \ ((STACK_FRAME_PARAM(_num_params)) + ((_var_num)*8)) -#else + +#else // ABIv1 below #define STACK_FRAME_MIN_SIZE 112 #define STACK_FRAME_TOC_POS 40 #define __STACK_FRAME_PARAM(i) (48 + ((i)*8)) @@ -34,7 +48,24 @@ */ #define __STACK_FRAME_LOCAL(_num_params, _var_num) \ (112 + ((_var_num)*8)) -#endif + + +#endif // ABIv2 + +// Common 64-bit +#define STACK_FRAME_LR_POS 16 +#define STACK_FRAME_CR_POS 8 + +#else // 32-bit below + +#define STACK_FRAME_MIN_SIZE 16 +#define STACK_FRAME_LR_POS 4 + +#define __STACK_FRAME_PARAM(_param) (STACK_FRAME_MIN_SIZE + ((_param)*4)) +#define __STACK_FRAME_LOCAL(_num_params, _var_num) \ + ((STACK_FRAME_PARAM(_num_params)) + ((_var_num)*4)) + +#endif // __powerpc64__ /* Parameter x saved to the stack */ #define STACK_FRAME_PARAM(var)__STACK_FRAME_PARAM(var) @@ -42,8 +73,6 @@ /* Local variable x saved to the stack after x parameters */ #define STACK_FRAME_LOCAL(num_params, var)\ __STACK_FRAME_LOCAL(num_params, var) -#define STACK_FRAME_LR_POS 16 -#define STACK_FRAME_CR_POS 8 /* * It is very important to note here that _extra is the extra amount of @@ -56,13 +85,13 @@ * preprocessed incorrectly, hence r0. */ #define PUSH_BASIC_STACK(_extra) \ - mflrr0; \ - std r0, STACK_FRAME_LR_POS(%r1); \ - stdu%r1, -(((_extra + 15) & ~15) + STACK_FRAME_MIN_SIZE)(%r1); + mflr r0; \ + PPC_STL r0, STACK_FRAME_LR_POS(%r1); \ + PPC_STLU %r1, -(((_extra + 15) & ~15) + STACK_FRAME_MIN_SIZE)(%r1); #define POP_BASIC_STACK(_extra) \ addi%r1, %r1, (((_extra + 15) & ~15) + STACK_FRAME_MIN_SIZE); \ - ld r0, STACK_FRAME_LR_POS(%r1); \ + PPC_LL r0, STACK_FRAME_LR_POS(%r1); \ mtlrr0; #endif /* _SELFTESTS_POWERPC_BASIC_ASM_H */ -- 2.35.3
[PATCH 04/13] selftests/powerpc: Don't save CR by default in asm helpers
Thare are some asm helpers for creating/popping stack frames in basic_asm.h. They always save/restore CR, but none of the selftests tests touch non-volatile CR fields, so it's unnecessary to save them by default. Signed-off-by: Michael Ellerman --- tools/testing/selftests/powerpc/include/basic_asm.h | 4 1 file changed, 4 deletions(-) diff --git a/tools/testing/selftests/powerpc/include/basic_asm.h b/tools/testing/selftests/powerpc/include/basic_asm.h index 807e83e821ec..faec7b11c041 100644 --- a/tools/testing/selftests/powerpc/include/basic_asm.h +++ b/tools/testing/selftests/powerpc/include/basic_asm.h @@ -59,14 +59,10 @@ mflrr0; \ std r0, STACK_FRAME_LR_POS(%r1); \ stdu%r1, -(((_extra + 15) & ~15) + STACK_FRAME_MIN_SIZE)(%r1); \ - mfcrr0; \ - stw r0, STACK_FRAME_CR_POS(%r1); \ std %r2, STACK_FRAME_TOC_POS(%r1); #define POP_BASIC_STACK(_extra) \ ld %r2, STACK_FRAME_TOC_POS(%r1); \ - lwz r0, STACK_FRAME_CR_POS(%r1); \ - mtcrr0; \ addi%r1, %r1, (((_extra + 15) & ~15) + STACK_FRAME_MIN_SIZE); \ ld r0, STACK_FRAME_LR_POS(%r1); \ mtlrr0; -- 2.35.3
[PATCH 01/13] selftests/powerpc: Ensure 16-byte stack pointer alignment
The PUSH/POP_BASIC_STACK helpers in basic_asm.h do not ensure that the stack pointer is always 16-byte aligned, which is required per the ABI. Fix the macros to do the alignment if the caller fails to. Currently only one caller passes a non-aligned size, tm_signal_self(), which hasn't been caught in testing, presumably because it's a leaf function. Signed-off-by: Michael Ellerman --- tools/testing/selftests/powerpc/include/basic_asm.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/powerpc/include/basic_asm.h b/tools/testing/selftests/powerpc/include/basic_asm.h index 886dc026fe7a..807e83e821ec 100644 --- a/tools/testing/selftests/powerpc/include/basic_asm.h +++ b/tools/testing/selftests/powerpc/include/basic_asm.h @@ -58,7 +58,7 @@ #define PUSH_BASIC_STACK(_extra) \ mflrr0; \ std r0, STACK_FRAME_LR_POS(%r1); \ - stdu%r1, -(_extra + STACK_FRAME_MIN_SIZE)(%r1); \ + stdu%r1, -(((_extra + 15) & ~15) + STACK_FRAME_MIN_SIZE)(%r1); \ mfcrr0; \ stw r0, STACK_FRAME_CR_POS(%r1); \ std %r2, STACK_FRAME_TOC_POS(%r1); @@ -67,7 +67,7 @@ ld %r2, STACK_FRAME_TOC_POS(%r1); \ lwz r0, STACK_FRAME_CR_POS(%r1); \ mtcrr0; \ - addi%r1, %r1, (_extra + STACK_FRAME_MIN_SIZE); \ + addi%r1, %r1, (((_extra + 15) & ~15) + STACK_FRAME_MIN_SIZE); \ ld r0, STACK_FRAME_LR_POS(%r1); \ mtlrr0; -- 2.35.3
[PATCH 02/13] selftests/powerpc/ptrace: Set LOCAL_HDRS
Set LOCAL_HDRS so header changes cause rebuilds. The lib.mk logic adds all the headers in LOCAL_HDRS as dependencies, so there's no need to also list them explicitly. Signed-off-by: Michael Ellerman --- tools/testing/selftests/powerpc/ptrace/Makefile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/powerpc/ptrace/Makefile b/tools/testing/selftests/powerpc/ptrace/Makefile index a500639da97a..0b0652d88b1b 100644 --- a/tools/testing/selftests/powerpc/ptrace/Makefile +++ b/tools/testing/selftests/powerpc/ptrace/Makefile @@ -4,12 +4,13 @@ TEST_GEN_PROGS := ptrace-gpr ptrace-tm-gpr ptrace-tm-spd-gpr \ ptrace-tm-spd-vsx ptrace-tm-spr ptrace-hwbreak ptrace-pkey core-pkey \ perf-hwbreak ptrace-syscall ptrace-perf-hwbreak +LOCAL_HDRS += $(patsubst %,$(selfdir)/powerpc/ptrace/%,$(wildcard *.h)) + top_srcdir = ../../../../.. include ../../lib.mk CFLAGS += -m64 -I../../../../../usr/include -I../tm -mhtm -fno-pie -$(OUTPUT)/ptrace-pkey $(OUTPUT)/core-pkey: child.h $(OUTPUT)/ptrace-pkey $(OUTPUT)/core-pkey: LDLIBS += -pthread -$(TEST_GEN_PROGS): ../harness.c ../utils.c ../lib/reg.S ptrace.h +$(TEST_GEN_PROGS): ../harness.c ../utils.c ../lib/reg.S -- 2.35.3
[PATCH v3 2/4] watchdog: export lockup_detector_reconfigure
In some circumstances it may be interesting to reconfigure the watchdog from inside the kernel. On PowerPC, this may helpful before and after a LPAR migration (LPM) is initiated, because it implies some latencies, watchdog, and especially NMI watchdog is expected to be triggered during this operation. Reconfiguring the watchdog with a factor, would prevent it to happen too frequently during LPM. Rename lockup_detector_reconfigure() as __lockup_detector_reconfigure() and create a new function lockup_detector_reconfigure() calling __lockup_detector_reconfigure() under the protection of watchdog_mutex. Cc: Christoph Hellwig Signed-off-by: Laurent Dufour --- include/linux/nmi.h | 2 ++ kernel/watchdog.c | 21 - 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/include/linux/nmi.h b/include/linux/nmi.h index 750c7f395ca9..f700ff2df074 100644 --- a/include/linux/nmi.h +++ b/include/linux/nmi.h @@ -122,6 +122,8 @@ int watchdog_nmi_probe(void); int watchdog_nmi_enable(unsigned int cpu); void watchdog_nmi_disable(unsigned int cpu); +void lockup_detector_reconfigure(void); + /** * touch_nmi_watchdog - restart NMI watchdog timeout. * diff --git a/kernel/watchdog.c b/kernel/watchdog.c index 20a7a55e62b6..90e6c41d5e33 100644 --- a/kernel/watchdog.c +++ b/kernel/watchdog.c @@ -541,7 +541,7 @@ int lockup_detector_offline_cpu(unsigned int cpu) return 0; } -static void lockup_detector_reconfigure(void) +static void __lockup_detector_reconfigure(void) { cpus_read_lock(); watchdog_nmi_stop(); @@ -561,6 +561,13 @@ static void lockup_detector_reconfigure(void) __lockup_detector_cleanup(); } +void lockup_detector_reconfigure(void) +{ + mutex_lock(_mutex); + __lockup_detector_reconfigure(); + mutex_unlock(_mutex); +} + /* * Create the watchdog infrastructure and configure the detector(s). */ @@ -577,13 +584,13 @@ static __init void lockup_detector_setup(void) return; mutex_lock(_mutex); - lockup_detector_reconfigure(); + __lockup_detector_reconfigure(); softlockup_initialized = true; mutex_unlock(_mutex); } #else /* CONFIG_SOFTLOCKUP_DETECTOR */ -static void lockup_detector_reconfigure(void) +void __lockup_detector_reconfigure(void) { cpus_read_lock(); watchdog_nmi_stop(); @@ -591,9 +598,13 @@ static void lockup_detector_reconfigure(void) watchdog_nmi_start(); cpus_read_unlock(); } +static inline void lockup_detector_reconfigure(void) +{ + __lockup_detector_reconfigure(); +} static inline void lockup_detector_setup(void) { - lockup_detector_reconfigure(); + __lockup_detector_reconfigure(); } #endif /* !CONFIG_SOFTLOCKUP_DETECTOR */ @@ -633,7 +644,7 @@ static void proc_watchdog_update(void) { /* Remove impossible cpus to keep sysctl output clean. */ cpumask_and(_cpumask, _cpumask, cpu_possible_mask); - lockup_detector_reconfigure(); + __lockup_detector_reconfigure(); } /* -- 2.36.1
[PATCH v3 4/4] pseries/mobility: set NMI watchdog factor during LPM
During a LPM, while the memory transfer is in progress on the arrival side, some latencies is generated when accessing not yet transferred pages on the arrival side. Thus, the NMI watchdog may be triggered too frequently, which increases the risk to hit a NMI interrupt in a bad place in the kernel, leading to a kernel panic. Disabling the Hard Lockup Watchdog until the memory transfer could be a too strong work around, some users would want this timeout to be eventually triggered if the system is hanging even during LPM. Introduce a new sysctl variable nmi_watchdog_factor. It allows to apply a factor to the NMI watchdog timeout during a LPM. Just before the CPU are stopped for the switchover sequence, the NMI watchdog timer is set to watchdog_tresh + factor% A value of 0 has no effect. The default value is 200, meaning that the NMI watchdog is set to 30s during LPM (based on a 10s watchdog_tresh value). Once the memory transfer is achieved, the factor is reset to 0. Setting this value to a high number is like disabling the NMI watchdog during a LPM. Signed-off-by: Laurent Dufour --- Documentation/admin-guide/sysctl/kernel.rst | 12 ++ arch/powerpc/platforms/pseries/mobility.c | 43 + 2 files changed, 55 insertions(+) diff --git a/Documentation/admin-guide/sysctl/kernel.rst b/Documentation/admin-guide/sysctl/kernel.rst index ddccd1077462..0bb0b7f27e96 100644 --- a/Documentation/admin-guide/sysctl/kernel.rst +++ b/Documentation/admin-guide/sysctl/kernel.rst @@ -592,6 +592,18 @@ to the guest kernel command line (see Documentation/admin-guide/kernel-parameters.rst). +nmi_watchdog_factor (PPC only) +== + +Factor apply to to the NMI watchdog timeout (only when ``nmi_watchdog`` is +set to 1). This factor represents the percentage added to +``watchdog_thresh`` when calculating the NMI watchdog timeout during a +LPM. The soft lockup timeout is not impacted. + +A value of 0 means no change. The default value is 200 meaning the NMI +watchdog is set to 30s (based on ``watchdog_thresh`` equal to 10). + + numa_balancing == diff --git a/arch/powerpc/platforms/pseries/mobility.c b/arch/powerpc/platforms/pseries/mobility.c index 907a779074d6..649155faafc2 100644 --- a/arch/powerpc/platforms/pseries/mobility.c +++ b/arch/powerpc/platforms/pseries/mobility.c @@ -48,6 +48,39 @@ struct update_props_workarea { #define MIGRATION_SCOPE(1) #define PRRN_SCOPE -2 +#ifdef CONFIG_PPC_WATCHDOG +static unsigned int nmi_wd_factor = 200; + +#ifdef CONFIG_SYSCTL +static struct ctl_table nmi_wd_factor_ctl_table[] = { + { + .procname = "nmi_watchdog_factor", + .data = _wd_factor, + .maxlen = sizeof(int), + .mode = 0644, + .proc_handler = proc_douintvec_minmax, + }, + {} +}; +static struct ctl_table nmi_wd_factor_sysctl_root[] = { + { + .procname = "kernel", + .mode = 0555, + .child = nmi_wd_factor_ctl_table, + }, + {} +}; + +static int __init register_nmi_wd_factor_sysctl(void) +{ + register_sysctl_table(nmi_wd_factor_sysctl_root); + + return 0; +} +device_initcall(register_nmi_wd_factor_sysctl); +#endif /* CONFIG_SYSCTL */ +#endif /* CONFIG_PPC_WATCHDOG */ + static int mobility_rtas_call(int token, char *buf, s32 scope) { int rc; @@ -702,13 +735,20 @@ static int pseries_suspend(u64 handle) static int pseries_migrate_partition(u64 handle) { int ret; + unsigned int factor = 0; +#ifdef CONFIG_PPC_WATCHDOG + factor = nmi_wd_factor; +#endif ret = wait_for_vasi_session_suspending(handle); if (ret) return ret; vas_migration_handler(VAS_SUSPEND); + if (factor) + watchdog_nmi_set_lpm_factor(factor); + ret = pseries_suspend(handle); if (ret == 0) { post_mobility_fixup(); @@ -716,6 +756,9 @@ static int pseries_migrate_partition(u64 handle) } else pseries_cancel_migration(handle, ret); + if (factor) + watchdog_nmi_set_lpm_factor(0); + vas_migration_handler(VAS_RESUME); return ret; -- 2.36.1
[PATCH v3 1/4] powerpc/mobility: wait for memory transfer to complete
In pseries_migration_partition(), loop until the memory transfer is complete. This way the calling drmgr process will not exit earlier, allowing callbacks to be run only once the migration is fully completed. If reading the VASI state is done after the hypervisor has completed the migration, the HCALL is returning H_PARAMETER. We can safely assume that the memory transfer is achieved if this happens. This will also allow to manage the NMI watchdog state in the next commits. Reviewed-by: Nathan Lynch Signed-off-by: Laurent Dufour --- arch/powerpc/platforms/pseries/mobility.c | 42 +-- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/arch/powerpc/platforms/pseries/mobility.c b/arch/powerpc/platforms/pseries/mobility.c index 78f3f74c7056..907a779074d6 100644 --- a/arch/powerpc/platforms/pseries/mobility.c +++ b/arch/powerpc/platforms/pseries/mobility.c @@ -427,6 +427,43 @@ static int wait_for_vasi_session_suspending(u64 handle) return ret; } +static void wait_for_vasi_session_completed(u64 handle) +{ + unsigned long state = 0; + int ret; + + pr_info("waiting for memory transfert to complete...\n"); + + /* +* Wait for transition from H_VASI_RESUMED to H_VASI_COMPLETED. +*/ + while (true) { + ret = poll_vasi_state(handle, ); + + /* +* If the memory transfer is already complete and the migration +* has been cleaned up by the hypervisor, H_PARAMETER is return, +* which is translate in EINVAL by poll_vasi_state(). +*/ + if (ret == -EINVAL || (!ret && state == H_VASI_COMPLETED)) { + pr_info("memory transfert completed.\n"); + break; + } + + if (ret) { + pr_err("H_VASI_STATE return error (%d)\n", ret); + break; + } + + if (state != H_VASI_RESUMED) { + pr_err("unexpected H_VASI_STATE result %lu\n", state); + break; + } + + msleep(500); + } +} + static void prod_single(unsigned int target_cpu) { long hvrc; @@ -673,9 +710,10 @@ static int pseries_migrate_partition(u64 handle) vas_migration_handler(VAS_SUSPEND); ret = pseries_suspend(handle); - if (ret == 0) + if (ret == 0) { post_mobility_fixup(); - else + wait_for_vasi_session_completed(handle); + } else pseries_cancel_migration(handle, ret); vas_migration_handler(VAS_RESUME); -- 2.36.1
[PATCH v3 3/4] powerpc/watchdog: introduce a NMI watchdog's factor
Introduce a factor which would apply to the NMI watchdog timeout. This factor is a percentage added to the watchdog_tresh value. The value is set under the watchdog_mutex protection and lockup_detector_reconfigure() is called to recompute wd_panic_timeout_tb. Once the factor is set, it remains until it is set back to 0, which means no impact. Signed-off-by: Laurent Dufour --- arch/powerpc/include/asm/nmi.h | 2 ++ arch/powerpc/kernel/watchdog.c | 21 - 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/arch/powerpc/include/asm/nmi.h b/arch/powerpc/include/asm/nmi.h index ea0e487f87b1..7d6a8d9b0543 100644 --- a/arch/powerpc/include/asm/nmi.h +++ b/arch/powerpc/include/asm/nmi.h @@ -5,8 +5,10 @@ #ifdef CONFIG_PPC_WATCHDOG extern void arch_touch_nmi_watchdog(void); long soft_nmi_interrupt(struct pt_regs *regs); +void watchdog_nmi_set_lpm_factor(u64 factor); #else static inline void arch_touch_nmi_watchdog(void) {} +static inline void watchdog_nmi_set_lpm_factor(u64 factor) {} #endif #ifdef CONFIG_NMI_IPI diff --git a/arch/powerpc/kernel/watchdog.c b/arch/powerpc/kernel/watchdog.c index 7d28b9553654..80851b228f71 100644 --- a/arch/powerpc/kernel/watchdog.c +++ b/arch/powerpc/kernel/watchdog.c @@ -91,6 +91,10 @@ static cpumask_t wd_smp_cpus_pending; static cpumask_t wd_smp_cpus_stuck; static u64 wd_smp_last_reset_tb; +#ifdef CONFIG_PPC_PSERIES +static u64 wd_factor; +#endif + /* * Try to take the exclusive watchdog action / NMI IPI / printing lock. * wd_smp_lock must be held. If this fails, we should return and wait @@ -527,7 +531,13 @@ static int stop_watchdog_on_cpu(unsigned int cpu) static void watchdog_calc_timeouts(void) { - wd_panic_timeout_tb = watchdog_thresh * ppc_tb_freq; + u64 threshold = watchdog_thresh; + +#ifdef CONFIG_PPC_PSERIES + threshold += (READ_ONCE(wd_factor) * threshold) / 100; +#endif + + wd_panic_timeout_tb = threshold * ppc_tb_freq; /* Have the SMP detector trigger a bit later */ wd_smp_panic_timeout_tb = wd_panic_timeout_tb * 3 / 2; @@ -570,3 +580,12 @@ int __init watchdog_nmi_probe(void) } return 0; } + +#ifdef CONFIG_PPC_PSERIES +void watchdog_nmi_set_lpm_factor(u64 factor) +{ + pr_info("Set the NMI watchdog factor to %llu%%\n", factor); + WRITE_ONCE(wd_factor, factor); + lockup_detector_reconfigure(); +} +#endif -- 2.36.1
[PATCH 5.18 071/181] perf test topology: Use !strncmp(right platform) to fix guest PPC comparision check
From: Athira Rajeev [ Upstream commit b236371421df57b93fc49c4b9d0e53bd1aab2b2e ] commit cfd7092c31aed728 ("perf test session topology: Fix test to skip the test in guest environment") added check to skip the testcase if the socket_id can't be fetched from topology info. But the condition check uses strncmp which should be changed to !strncmp and to correctly match platform. Fix this condition check. Fixes: cfd7092c31aed728 ("perf test session topology: Fix test to skip the test in guest environment") Reported-by: Thomas Richter Signed-off-by: Athira Jajeev Acked-by: Ian Rogers Cc: Athira Rajeev Cc: Disha Goel Cc: Jiri Olsa Cc: Kajol Jain Cc: linuxppc-dev@lists.ozlabs.org Cc: Madhavan Srinivasan Cc: Michael Ellerman Cc: Nageswara R Sastry Link: https://lore.kernel.org/r/20220610135939.63361-1-atraj...@linux.vnet.ibm.com Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: Sasha Levin --- tools/perf/tests/topology.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/perf/tests/topology.c b/tools/perf/tests/topology.c index d23a9e322ff5..0b4f61b6cc6b 100644 --- a/tools/perf/tests/topology.c +++ b/tools/perf/tests/topology.c @@ -115,7 +115,7 @@ static int check_cpu_topology(char *path, struct perf_cpu_map *map) * physical_package_id will be set to -1. Hence skip this * test if physical_package_id returns -1 for cpu from perf_cpu_map. */ - if (strncmp(session->header.env.arch, "powerpc", 7)) { + if (!strncmp(session->header.env.arch, "ppc64le", 7)) { if (cpu__get_socket_id(perf_cpu_map__cpu(map, 0)) == -1) return TEST_SKIP; } -- 2.35.1
Re: [PATCH] powerpc: perf: Fix refcount leak bug in imc-pmu.c
> On 18-Jun-2022, at 12:43 PM, Liang He wrote: > > In update_events_in_group(), of_find_node_by_phandle() will return > a node pointer with refcount incremented. We should use of_node_put() > in fail path or when it is not used anymore. > > Signed-off-by: Liang He Reviewed-by: Athira Rajeev > --- > arch/powerpc/perf/imc-pmu.c | 10 -- > 1 file changed, 8 insertions(+), 2 deletions(-) > > diff --git a/arch/powerpc/perf/imc-pmu.c b/arch/powerpc/perf/imc-pmu.c > index d7976ab40d38..d517aba94d1b 100644 > --- a/arch/powerpc/perf/imc-pmu.c > +++ b/arch/powerpc/perf/imc-pmu.c > @@ -240,8 +240,10 @@ static int update_events_in_group(struct device_node > *node, struct imc_pmu *pmu) > ct = of_get_child_count(pmu_events); > > /* Get the event prefix */ > - if (of_property_read_string(node, "events-prefix", )) > + if (of_property_read_string(node, "events-prefix", )) { > + of_node_put(pmu_events); > return 0; > + } > > /* Get a global unit and scale data if available */ > if (of_property_read_string(node, "scale", _scale)) > @@ -255,8 +257,10 @@ static int update_events_in_group(struct device_node > *node, struct imc_pmu *pmu) > > /* Allocate memory for the events */ > pmu->events = kcalloc(ct, sizeof(struct imc_events), GFP_KERNEL); > - if (!pmu->events) > + if (!pmu->events) { > + of_node_put(pmu_events); > return -ENOMEM; > + } > > ct = 0; > /* Parse the events and update the struct */ > @@ -266,6 +270,8 @@ static int update_events_in_group(struct device_node > *node, struct imc_pmu *pmu) > ct++; > } > > + of_node_put(pmu_events); > + > /* Allocate memory for attribute group */ > attr_group = kzalloc(sizeof(*attr_group), GFP_KERNEL); > if (!attr_group) { > -- > 2.25.1 >
Re: [PATCH v2 3/3] arch/*/: remove CONFIG_VIRT_TO_BUS
Hi Michael, On Sat, Jun 18, 2022 at 3:06 AM Michael Schmitz wrote: > Am 18.06.2022 um 00:57 schrieb Arnd Bergmann: > > From: Arnd Bergmann > > > > All architecture-independent users of virt_to_bus() and bus_to_virt() > > have been fixed to use the dma mapping interfaces or have been > > removed now. This means the definitions on most architectures, and the > > CONFIG_VIRT_TO_BUS symbol are now obsolete and can be removed. > > > > The only exceptions to this are a few network and scsi drivers for m68k > > Amiga and VME machines and ppc32 Macintosh. These drivers work correctly > > with the old interfaces and are probably not worth changing. > > The Amiga SCSI drivers are all old WD33C93 ones, and replacing > virt_to_bus by virt_to_phys in the dma_setup() function there would > cause no functional change at all. FTR, the sgiwd93 driver use dma_map_single(). Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- ge...@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds
Re: [PATCH v2 3/3] arch/*/: remove CONFIG_VIRT_TO_BUS
Arnd, Am 26.06.2022 um 20:36 schrieb Arnd Bergmann: There are no platform specific header files other than asm/amigahw.h and asm/mvme147hw.h, currently only holding register address definitions. Would it be OK to add m68k_virt_to_bus() in there if it can't remain in asm/virtconvert.h, Geert? In that case, I would just leave it under the current name and not change m68k at all. I don't like the m68k_virt_to_bus() name because there is not anything CPU specific in what it does, and keeping it in a common header does nothing to prevent it from being used on other platforms either. Fair enough. 32bit powerpc is a different matter though. It's similar, but unrelated. The two apple ethernet drivers (bmac and mace) can again either get changed to use the dma-mapping interfaces, or get a custom pmac_virt_to_bus()/ pmac_bus_to_virt() helper. Hmmm - I see Finn had done the DMA API conversion on macmace.c which might give some hints on what to do about mace.c ... no idea about bmac.c though. And again, haven't got hardware to test, so custom helpers is it, then. Ok. Again, no platform specific headers to shift renamed helpers to, so may as well keep this as-is. Cheers, Michael Arnd
Re: [RFC PATCH v2 2/3] fs: define a firmware security filesystem named fwsecurityfs
On Sun, Jun 26, 2022 at 11:48:06AM -0400, Mimi Zohar wrote: > On Thu, 2022-06-23 at 09:23 -0400, James Bottomley wrote: > > On Thu, 2022-06-23 at 10:54 +0200, Greg Kroah-Hartman wrote: > > [...] > > > > diff --git a/fs/fwsecurityfs/inode.c b/fs/fwsecurityfs/inode.c > > > > new file mode 100644 > > > > index ..5d06dc0de059 > > > > --- /dev/null > > > > +++ b/fs/fwsecurityfs/inode.c > > > > @@ -0,0 +1,159 @@ > > > > +// SPDX-License-Identifier: GPL-2.0-only > > > > +/* > > > > + * Copyright (C) 2022 IBM Corporation > > > > + * Author: Nayna Jain > > > > + */ > > > > + > > > > +#include > > > > +#include > > > > +#include > > > > +#include > > > > +#include > > > > +#include > > > > +#include > > > > +#include > > > > +#include > > > > +#include > > > > +#include > > > > +#include > > > > +#include > > > > + > > > > +#include "internal.h" > > > > + > > > > +int fwsecurityfs_remove_file(struct dentry *dentry) > > > > +{ > > > > + drop_nlink(d_inode(dentry)); > > > > + dput(dentry); > > > > + return 0; > > > > +}; > > > > +EXPORT_SYMBOL_GPL(fwsecurityfs_remove_file); > > > > + > > > > +int fwsecurityfs_create_file(const char *name, umode_t mode, > > > > + u16 filesize, struct dentry > > > > *parent, > > > > + struct dentry *dentry, > > > > + const struct file_operations > > > > *fops) > > > > +{ > > > > + struct inode *inode; > > > > + int error; > > > > + struct inode *dir; > > > > + > > > > + if (!parent) > > > > + return -EINVAL; > > > > + > > > > + dir = d_inode(parent); > > > > + pr_debug("securityfs: creating file '%s'\n", name); > > > > > > Did you forget to call simple_pin_fs() here or anywhere else? > > > > > > And this can be just one function with the directory creation file, > > > just check the mode and you will be fine. Look at securityfs as an > > > example of how to make this simpler. > > > > Actually, before you go down this route can you consider the namespace > > ramifications. In fact we're just having to rework securityfs to pull > > out all the simple_pin_... calls because simple_pin_... is completely > > inimical to namespaces. > > > > The first thing to consider is if you simply use securityfs you'll > > inherit all the simple_pin_... removal work and be namespace ready. It > > could be that creating a new filesystem that can't be namespaced is the > > right thing to do here, but at least ask the question: would we ever > > want any of these files to be presented selectively inside containers? > > If the answer is "yes" then simple_pin_... is the wrong interface. > > Greg, the securityfs changes James is referring to are part of the IMA > namespacing patch set: > https://lore.kernel.org/linux-integrity/20220420140633.753772-1-stef...@linux.ibm.com/ > > I'd really appreciate your reviewing the first two patches: > [PATCH v12 01/26] securityfs: rework dentry creation > [PATCH v12 02/26] securityfs: Extend securityfs with namespacing > support Looks like others have already reviewed them, they seem sane to me if they past testing. thanks, greg k-h
[PATCH V2] powerpc/memhotplug: Add add_pages override for PPC
With commit ffa0b64e3be5 ("powerpc: Fix virt_addr_valid() for 64-bit Book3E & 32-bit") the kernel now validate the addr against high_memory value. This results in the below BUG_ON with dax pfns. [ 635.798741][T26531] kernel BUG at mm/page_alloc.c:5521! 1:mon> e cpu 0x1: Vector: 700 (Program Check) at [c7287630] pc: c055ed48: free_pages.part.0+0x48/0x110 lr: c053ca70: tlb_finish_mmu+0x80/0xd0 sp: c72878d0 msr: 8282b033 current = 0xcafabe00 paca= 0xc0037300 irqmask: 0x03 irq_happened: 0x05 pid = 26531, comm = 50-landscape-sy kernel BUG at :5521! Linux version 5.19.0-rc3-14659-g4ec05be7c2e1 (kvaneesh@ltc-boston8) (gcc (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0, GNU ld (GNU Binutils for Ubuntu) 2.34) #625 SMP Thu Jun 23 00:35:43 CDT 2022 1:mon> t [link register ] c053ca70 tlb_finish_mmu+0x80/0xd0 [c72878d0] c053ca54 tlb_finish_mmu+0x64/0xd0 (unreliable) [c7287900] c0539424 exit_mmap+0xe4/0x2a0 [c72879e0] c019fc1c mmput+0xcc/0x210 [c7287a20] c0629230 begin_new_exec+0x5e0/0xf40 [c7287ae0] c070b3cc load_elf_binary+0x3ac/0x1e00 [c7287c10] c0627af0 bprm_execve+0x3b0/0xaf0 [c7287cd0] c0628414 do_execveat_common.isra.0+0x1e4/0x310 [c7287d80] c062858c sys_execve+0x4c/0x60 [c7287db0] c002c1b0 system_call_exception+0x160/0x2c0 [c7287e10] c000c53c system_call_common+0xec/0x250 The fix is to make sure we update high_memory on memory hotplug. This is similar to what x86 does in commit 3072e413e305 ("mm/memory_hotplug: introduce add_pages") Fixes: ffa0b64e3be5 ("powerpc: Fix virt_addr_valid() for 64-bit Book3E & 32-bit") Cc: Kefeng Wang Cc: Christophe Leroy Signed-off-by: Aneesh Kumar K.V --- arch/powerpc/Kconfig | 4 arch/powerpc/mm/mem.c | 32 +++- 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig index c2ce2e60c8f0..7aa12e88c580 100644 --- a/arch/powerpc/Kconfig +++ b/arch/powerpc/Kconfig @@ -358,6 +358,10 @@ config ARCH_SUSPEND_NONZERO_CPU def_bool y depends on PPC_POWERNV || PPC_PSERIES +config ARCH_HAS_ADD_PAGES + def_bool y + depends on ARCH_ENABLE_MEMORY_HOTPLUG + config PPC_DCR_NATIVE bool diff --git a/arch/powerpc/mm/mem.c b/arch/powerpc/mm/mem.c index 52b77684acda..2a63920c369d 100644 --- a/arch/powerpc/mm/mem.c +++ b/arch/powerpc/mm/mem.c @@ -105,6 +105,36 @@ void __ref arch_remove_linear_mapping(u64 start, u64 size) vm_unmap_aliases(); } +/* + * After memory hotplug the variables max_pfn, max_low_pfn and high_memory need + * updating. + */ +static void update_end_of_memory_vars(u64 start, u64 size) +{ + unsigned long end_pfn = PFN_UP(start + size); + + if (end_pfn > max_pfn) { + max_pfn = end_pfn; + max_low_pfn = end_pfn; + high_memory = (void *)__va(max_pfn * PAGE_SIZE - 1) + 1; + } +} + +int __ref add_pages(int nid, unsigned long start_pfn, unsigned long nr_pages, + struct mhp_params *params) +{ + int ret; + + ret = __add_pages(nid, start_pfn, nr_pages, params); + WARN_ON_ONCE(ret); + + /* update max_pfn, max_low_pfn and high_memory */ + update_end_of_memory_vars(start_pfn << PAGE_SHIFT, + nr_pages << PAGE_SHIFT); + + return ret; +} + int __ref arch_add_memory(int nid, u64 start, u64 size, struct mhp_params *params) { @@ -115,7 +145,7 @@ int __ref arch_add_memory(int nid, u64 start, u64 size, rc = arch_create_linear_mapping(nid, start, size, params); if (rc) return rc; - rc = __add_pages(nid, start_pfn, nr_pages, params); + rc = add_pages(nid, start_pfn, nr_pages, params); if (rc) arch_remove_linear_mapping(start, size); return rc; -- 2.36.1
Re: [PATCH RESEND v2 0/7] soc: fsl: guts: cleanups and serial_number support
On Wed, Jun 22, 2022 at 01:03:33PM +0200, Michael Walle wrote: > Am 2022-04-04 11:56, schrieb Michael Walle: > > [Resend because of new development cycle. Shawn, can this series get > > through your tree? Sorry you weren't on CC on the former submissions.] > > > > This series converts the guts driver from a platform driver to just an > > core_initcall. The driver itself cannot (or rather should never) be > > unloaded because others depends on detecting the current SoC revision > > to apply chip errata. Other SoC drivers do it the same way. Overall I > > got rid of all the global static variables. > > > > The last patch finally adds unique id support to the guts driver. DT > > binding can be found at: > > Documentation/devicetree/bindings/nvmem/fsl,layerscape-sfp.yaml > > > > changes since v1: > > - call kfree() in error case, thanks Dan > > - add missing of_node_put(np), thanks Dan > > > > Michael Walle (7): > > soc: fsl: guts: machine variable might be unset > > soc: fsl: guts: remove module_exit() and fsl_guts_remove() > > soc: fsl: guts: embed fsl_guts_get_svr() in probe() > > soc: fsl: guts: allocate soc_dev_attr on the heap > > soc: fsl: guts: use of_root instead of own reference > > soc: fsl: guts: drop platform driver > > soc: fsl: guts: add serial_number support > > > > drivers/soc/fsl/guts.c | 219 ++--- > > 1 file changed, 118 insertions(+), 101 deletions(-) > > There goes another kernel release without any comments on this > series :( > > Shawn, can you pick this up and give it some time in linux-next? Okay, I just picked the series up to IMX tree. Leo, let me know if you want to drop it from IMX tree. Shawn
Re: [PATCH 3/3] powerpc/mm: Use VMALLOC_START to validate addr
Christophe Leroy writes: > Le 23/06/2022 à 14:29, Aneesh Kumar K.V a écrit : >> Instead of high_memory use VMALLOC_START to validate that the address is >> not in the vmalloc range. >> >> Cc: Kefeng Wang >> Cc: Christophe Leroy >> Signed-off-by: Aneesh Kumar K.V >> --- >> arch/powerpc/include/asm/page.h | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/arch/powerpc/include/asm/page.h >> b/arch/powerpc/include/asm/page.h >> index e5f75c70eda8..256cad69e42e 100644 >> --- a/arch/powerpc/include/asm/page.h >> +++ b/arch/powerpc/include/asm/page.h >> @@ -134,7 +134,7 @@ static inline bool pfn_valid(unsigned long pfn) >> >> #define virt_addr_valid(vaddr) ({ >> \ >> unsigned long _addr = (unsigned long)vaddr; \ >> -_addr >= PAGE_OFFSET && _addr < (unsigned long)high_memory && \ >> +_addr >= PAGE_OFFSET && _addr < (unsigned long)VMALLOC_START && \ >> pfn_valid(virt_to_pfn(_addr)); \ >> }) >> > > What about booke/64 ? > > The test will be _addr >= 0xc000 && _addr < > 0x8000 so the test will be always false. > Ok, I didn't realize that booke/64 have vmalloc range below direct map. I guess we should drop patch 3. -aneesh
Re: [PATCH] powerpc/papr_scm: Fix nvdimm event mappings
Hi Kajol, A few comments below ... Kajol Jain writes: > Commit 4c08d4bbc089 ("powerpc/papr_scm: Add perf interface support") > adds performance monitoring support for papr-scm nvdimm devices via ^ We're talking about a commit that's already happened so we should use past tense, so "added". > perf interface. It also adds one array in papr_scm_priv "added" > structure called "nvdimm_events_map", to dynamically save the stat_id > for events specified in nvdimm driver code "nd_perf.c". > > Right now the mapping is done based on the result of > H_SCM_PERFORMANCE_STATS hcall, when all the stats are > requested. Currently there is an assumption, that a > certain stat will always be found at a specific offset > in the stat buffer. ^ "returned by the hypervisor." To make it clear where the stat buffer comes from, and that it's out of our control. > The assumption may not be true or documented as part of PAPR > documentation. That reads as the assumption "may not be documented as part of PAPR". I think what you mean is the assumption *is not* documented by PAPR, and although it happens to be true on current systems it may not be true in future. > Fixing it, by adding a static mapping for nvdimm events to Fix it > corresponding stat-id, and removing the map from > papr_scm_priv structure. > > Fixes: 4c08d4bbc089 ("powerpc/papr_scm: Add perf interface support") > Reported-by: Aneesh Kumar K.V > Signed-off-by: Kajol Jain > --- > arch/powerpc/platforms/pseries/papr_scm.c | 59 ++- > 1 file changed, 25 insertions(+), 34 deletions(-) > > diff --git a/arch/powerpc/platforms/pseries/papr_scm.c > b/arch/powerpc/platforms/pseries/papr_scm.c > index 181b855b3050..5434c654a797 100644 > --- a/arch/powerpc/platforms/pseries/papr_scm.c > +++ b/arch/powerpc/platforms/pseries/papr_scm.c > @@ -350,6 +347,26 @@ static ssize_t drc_pmem_query_stats(struct papr_scm_priv > *p, > #ifdef CONFIG_PERF_EVENTS > #define to_nvdimm_pmu(_pmu) container_of(_pmu, struct nvdimm_pmu, pmu) > > +static const char * const nvdimm_events_map[] = { > + "N/A", > + "CtlResCt", > + "CtlResTm", > + "PonSecs ", > + "MemLife ", > + "CritRscU", > + "HostLCnt", > + "HostSCnt", > + "HostSDur", > + "HostLDur", > + "MedRCnt ", > + "MedWCnt ", > + "MedRDur ", > + "MedWDur ", > + "CchRHCnt", > + "CchWHCnt", > + "FastWCnt", > +}; The order of the strings in that array becomes ABI. Because it defines the mapping from perf_event.attr.config (perf user ABI) to the actual event we request from the hypervisor. So I'd like that made more explicit by using designated initialisers, eg: static const char * const nvdimm_events_map[] = { [1] = "CtlResCt", [2] = "CtlResTm", ... That way an accidental reordering of the array won't break anything. You shouldn't need to specify 0 either as it's not used. > @@ -370,7 +387,7 @@ static int papr_scm_pmu_get_value(struct perf_event > *event, struct device *dev, > > stat = >scm_statistic[0]; > memcpy(>stat_id, > ->nvdimm_events_map[event->attr.config * > sizeof(stat->stat_id)], > +nvdimm_events_map[event->attr.config], > sizeof(stat->stat_id)); It's not clear that this won't index off the end of the array. There is a check in papr_scm_pmu_event_init(), but I'd probably be happier if we did an explicit check in here as well, eg: if (event->attr.config >= ARRAY_SIZE(nvdimm_events_map)) return -EINVAL; > stat->stat_val = 0; > > @@ -460,10 +477,9 @@ static void papr_scm_pmu_del(struct perf_event *event, > int flags) > > static int papr_scm_pmu_check_events(struct papr_scm_priv *p, struct > nvdimm_pmu *nd_pmu) > { > - struct papr_scm_perf_stat *stat; > struct papr_scm_perf_stats *stats; > u32 available_events; > - int index, rc = 0; > + int rc = 0; You shouldn't need to initialise rc here. It's not used until the call to drc_pmem_query_stats() below. > available_events = (p->stat_buffer_len - sizeof(struct > papr_scm_perf_stats)) > / sizeof(struct papr_scm_perf_stat); > @@ -473,34 +489,12 @@ static int papr_scm_pmu_check_events(struct > papr_scm_priv *p, struct nvdimm_pmu > /* Allocate the buffer for phyp where stats are written */ > stats = kzalloc(p->stat_buffer_len, GFP_KERNEL); > if (!stats) { > - rc = -ENOMEM; > - return rc; > + return -ENOMEM; > } > > /* Called to get list of events supported */ > rc = drc_pmem_query_stats(p, stats, 0); > - if (rc) > - goto out; > > - /* > - * Allocate memory and populate nvdimm_event_map. > - * Allocate an extra element for NULL entry > - */ > - p->nvdimm_events_map = kcalloc(available_events + 1, > -
Re: [PATCH V5 02/26] mm/mmap: Define DECLARE_VM_GET_PAGE_PROT
Le 27/06/2022 à 06:58, Anshuman Khandual a écrit : > This just converts the generic vm_get_page_prot() implementation into a new > macro i.e DECLARE_VM_GET_PAGE_PROT which later can be used across platforms > when enabling them with ARCH_HAS_VM_GET_PAGE_PROT. This does not create any > functional change. > > Cc: Andrew Morton > Cc: linux...@kvack.org > Cc: linux-ker...@vger.kernel.org > Suggested-by: Christoph Hellwig > Signed-off-by: Anshuman Khandual Reviewed-by: Christophe Leroy > --- > include/linux/pgtable.h | 28 > mm/mmap.c | 26 +- > 2 files changed, 29 insertions(+), 25 deletions(-) > > diff --git a/include/linux/pgtable.h b/include/linux/pgtable.h > index 3cdc16cfd867..014ee8f0fbaa 100644 > --- a/include/linux/pgtable.h > +++ b/include/linux/pgtable.h > @@ -1689,4 +1689,32 @@ typedef unsigned int pgtbl_mod_mask; > #define MAX_PTRS_PER_P4D PTRS_PER_P4D > #endif > > +/* description of effects of mapping type and prot in current implementation. > + * this is due to the limited x86 page protection hardware. The expected > + * behavior is in parens: > + * > + * map_type prot > + * PROT_NONE PROT_READ PROT_WRITE PROT_EXEC > + * MAP_SHAREDr: (no) no r: (yes) yesr: (no) yes r: (no) > yes > + * w: (no) no w: (no) no w: (yes) yesw: (no) no > + * x: (no) no x: (no) yes x: (no) yes x: (yes) yes > + * > + * MAP_PRIVATE r: (no) no r: (yes) yesr: (no) yes r: (no) > yes > + * w: (no) no w: (no) no w: (copy) copy w: (no) no > + * x: (no) no x: (no) yes x: (no) yes x: (yes) yes > + * > + * On arm64, PROT_EXEC has the following behaviour for both MAP_SHARED and > + * MAP_PRIVATE (with Enhanced PAN supported): > + * r: (no) no > + * w: (no) no > + * x: (yes) yes > + */ > +#define DECLARE_VM_GET_PAGE_PROT \ > +pgprot_t vm_get_page_prot(unsigned long vm_flags)\ > +{\ > + return protection_map[vm_flags &\ > + (VM_READ | VM_WRITE | VM_EXEC | VM_SHARED)];\ > +}\ > +EXPORT_SYMBOL(vm_get_page_prot); > + > #endif /* _LINUX_PGTABLE_H */ > diff --git a/mm/mmap.c b/mm/mmap.c > index b01f0280bda2..b46d5e931bb3 100644 > --- a/mm/mmap.c > +++ b/mm/mmap.c > @@ -81,26 +81,6 @@ static void unmap_region(struct mm_struct *mm, > struct vm_area_struct *vma, struct vm_area_struct *prev, > unsigned long start, unsigned long end); > > -/* description of effects of mapping type and prot in current implementation. > - * this is due to the limited x86 page protection hardware. The expected > - * behavior is in parens: > - * > - * map_type prot > - * PROT_NONE PROT_READ PROT_WRITE PROT_EXEC > - * MAP_SHAREDr: (no) no r: (yes) yesr: (no) yes r: (no) > yes > - * w: (no) no w: (no) no w: (yes) yesw: (no) no > - * x: (no) no x: (no) yes x: (no) yes x: (yes) yes > - * > - * MAP_PRIVATE r: (no) no r: (yes) yesr: (no) yes r: (no) > yes > - * w: (no) no w: (no) no w: (copy) copy w: (no) no > - * x: (no) no x: (no) yes x: (no) yes x: (yes) yes > - * > - * On arm64, PROT_EXEC has the following behaviour for both MAP_SHARED and > - * MAP_PRIVATE (with Enhanced PAN supported): > - * r: (no) no > - * w: (no) no > - * x: (yes) yes > - */ > #ifdef __P000 > pgprot_t protection_map[16] __ro_after_init = { > [VM_NONE] = __P000, > @@ -123,11 +103,7 @@ pgprot_t protection_map[16] __ro_after_init = { > #endif > > #ifndef CONFIG_ARCH_HAS_VM_GET_PAGE_PROT > -pgprot_t vm_get_page_prot(unsigned long vm_flags) > -{ > - return protection_map[vm_flags & (VM_READ|VM_WRITE|VM_EXEC|VM_SHARED)]; > -} > -EXPORT_SYMBOL(vm_get_page_prot); > +DECLARE_VM_GET_PAGE_PROT > #endif /* CONFIG_ARCH_HAS_VM_GET_PAGE_PROT */ > > static pgprot_t vm_pgprot_modify(pgprot_t oldprot, unsigned long vm_flags)