[PATCH] powerpc: Force inlining of csum_add()

2021-05-10 Thread Christophe Leroy
Commit 328e7e487a46 ("powerpc: force inlining of csum_partial() to avoid multiple csum_partial() with GCC10") inlined csum_partial(). Now that csum_partial() is inlined, GCC outlines csum_add() when called by csum_partial(). c064fb28 : c064fb28: 7c 63 20 14 addcr3,r3,r4 c064fb2c:

Re: [PATCH] powerpc/legacy_serial: Fix UBSAN: array-index-out-of-bounds

2021-05-10 Thread Christophe Leroy
Le 11/05/2021 à 03:16, Michael Ellerman a écrit : Segher Boessenkool writes: On Sat, May 08, 2021 at 06:36:21AM +, Christophe Leroy wrote: UBSAN complains when a pointer is calculated with invalid 'legacy_serial_console' index, allthough the index is verified before dereferencing the p

[PATCH kernel v2] powerpc/makefile: Do not redefine $(CPP) for preprocessor

2021-05-10 Thread Alexey Kardashevskiy
The $(CPP) (do only preprocessing) macro is already defined in Makefile. However POWERPC redefines it and adds $(KBUILD_CFLAGS) which results in flags duplication. Which is not a big deal by itself except for the flags which depend on other flags and the compiler checks them as it parses the comman

Re: [V3 PATCH 06/16] powerpc/pseries/vas: Define VAS/NXGZIP HCALLs and structs

2021-05-10 Thread Haren Myneni
On Mon, 2021-05-10 at 15:49 +1000, Nicholas Piggin wrote: > Excerpts from Haren Myneni's message of April 18, 2021 7:05 am: > > This patch adds HCALLs and other definitions. Also define structs > > that are used in VAS implementation on powerVM. > > > > Signed-off-by: Haren Myneni > > --- > > ar

Re: [V3 PATCH 07/16] powerpc/vas: Define QoS credit flag to allocate window

2021-05-10 Thread Haren Myneni
On Mon, 2021-05-10 at 15:54 +1000, Nicholas Piggin wrote: > Excerpts from Haren Myneni's message of April 18, 2021 7:06 am: > > pHyp introduces two different type of credits: Default and Quality > > of service (QoS). > > > > The total number of default credits available on each LPAR depends > > on

Re: [V3 PATCH 09/16] powerpc/pseries/vas: Implement to get all capabilities

2021-05-10 Thread Haren Myneni
On Mon, 2021-05-10 at 16:13 +1000, Nicholas Piggin wrote: > Excerpts from Haren Myneni's message of April 18, 2021 7:08 am: > > pHyp provides various VAS capabilities such as GZIP default and QoS > > capabilities which are used to determine total number of credits > > available in LPAR, maximum win

Re: [PATCH V3 02/16] powerpc/vas: Move VAS API to common book3s platform

2021-05-10 Thread Michael Ellerman
Nicholas Piggin writes: > Excerpts from Haren Myneni's message of April 18, 2021 7:02 am: >> >> Using the same /dev/crypto/nx-gzip interface for both powerNV and >> pseries. > > The pseries NX driver will use the powernv VAS API ? > >> So this patch creates platforms/book3s/ and moves VAS API >>

[PATCH] s390/hvc_iucv: Drop unnecessary NULL check after container_of

2021-05-10 Thread Guenter Roeck
The result of container_of() operations is never NULL unless the extracted element is the first element of the embedded structure. This is not the case here. The NULL check is therefore unnecessary and misleading. Remove it. This change was made automatically with the following Coccinelle script.

Re: [PATCH v3 1/3] audit: replace magic audit syscall class numbers with macros

2021-05-10 Thread Paul Moore
On Fri, Apr 30, 2021 at 4:36 PM Richard Guy Briggs wrote: > > Replace audit syscall class magic numbers with macros. > > This required putting the macros into new header file > include/linux/auditscm.h since the syscall macros were included for both 64 > bit and 32 bit in any compat code, causing

Re: [PATCH] powerpc/legacy_serial: Fix UBSAN: array-index-out-of-bounds

2021-05-10 Thread Michael Ellerman
Segher Boessenkool writes: > On Sat, May 08, 2021 at 06:36:21AM +, Christophe Leroy wrote: >> UBSAN complains when a pointer is calculated with invalid >> 'legacy_serial_console' index, allthough the index is verified >> before dereferencing the pointer. > > Addressing like this is UB already

[PATCH v2] powerpc/legacy_serial: Fix UBSAN: array-index-out-of-bounds

2021-05-10 Thread Michael Ellerman
From: Christophe Leroy UBSAN complains when a pointer is calculated with invalid 'legacy_serial_console' index, allthough the index is verified before dereferencing the pointer. Fix it by checking 'legacy_serial_console' validity before calculating pointers. Fixes: 0bd3f9e953bd ("powerpc/legacy

[PATCH -next] ppc: boot: Fix a typo in the file decompress.c

2021-05-10 Thread Zhang Jianhua
s/input buffer/output buffer/ s/length of the input buffer/length of the input buffer/ Signed-off-by: Zhang Jianhua --- arch/powerpc/boot/decompress.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/powerpc/boot/decompress.c b/arch/powerpc/boot/decompress.c

Re: [PATCH] powerpc/legacy_serial: Fix UBSAN: array-index-out-of-bounds

2021-05-10 Thread Segher Boessenkool
On Sat, May 08, 2021 at 06:36:21AM +, Christophe Leroy wrote: > UBSAN complains when a pointer is calculated with invalid > 'legacy_serial_console' index, allthough the index is verified > before dereferencing the pointer. Addressing like this is UB already. You could just move this: > -

Re: [V3 PATCH 12/16] powerpc/pseries/vas: sysfs interface to export capabilities

2021-05-10 Thread Haren Myneni
On Mon, 2021-05-10 at 16:34 +1000, Nicholas Piggin wrote: > Excerpts from Haren Myneni's message of April 18, 2021 7:10 am: > > pHyp provides GZIP default and GZIP QoS capabilities which gives > > the total number of credits are available in LPAR. This patch > > creates sysfs entries and exports LP

Re: [V3 PATCH 15/16] crypto/nx: Get NX capabilities for GZIP coprocessor type

2021-05-10 Thread Haren Myneni
On Mon, 2021-05-10 at 16:38 +1000, Nicholas Piggin wrote: > Excerpts from Haren Myneni's message of April 18, 2021 7:12 am: > > phyp provides NX capabilities which gives recommended minimum > > compression / decompression length and maximum request buffer size > > in bytes. > > > > Changes to get

Re: [V3 PATCH 03/16] powerpc/vas: Create take/drop task reference functions

2021-05-10 Thread Haren Myneni
On Mon, 2021-05-10 at 15:28 +1000, Nicholas Piggin wrote: > Excerpts from Haren Myneni's message of April 18, 2021 7:03 am: > > Take task reference when each window opens and drops during close. > > This functionality is needed for powerNV and pseries. So this patch > > defines the existing code as

Re: [PATCH V3 02/16] powerpc/vas: Move VAS API to common book3s platform

2021-05-10 Thread Haren Myneni
On Mon, 2021-05-10 at 15:19 +1000, Nicholas Piggin wrote: > Excerpts from Haren Myneni's message of April 18, 2021 7:02 am: > > Using the same /dev/crypto/nx-gzip interface for both powerNV and > > pseries. > > The pseries NX driver will use the powernv VAS API ? Yes, both powerNV and pseries driv

Re: [V3 PATCH 05/16] powerpc/vas: Define and use common vas_window struct

2021-05-10 Thread Haren Myneni
On Mon, 2021-05-10 at 15:37 +1000, Nicholas Piggin wrote: > Excerpts from Haren Myneni's message of April 18, 2021 7:04 am: > > > > Empty email? > > Thanks, > Nick Sorry, My mistake. Here is the patch and will add in V4 series. [V3 PATCH 05/16] powerpc/vas: Define and use common vas_window st

Re: [V3 PATCH 01/16] powerpc/powernv/vas: Rename register/unregister functions

2021-05-10 Thread Haren Myneni
On Mon, 2021-05-10 at 15:10 +1000, Nicholas Piggin wrote: > Excerpts from Haren Myneni's message of April 18, 2021 7:00 am: > > powerNV and pseries drivers register / unregister to the > > corresponding > > VAS code separately. So rename powerNV VAS API register/unregister > > functions. > > The p

Re: [PATCH 01/11] PCI: Use sysfs_emit() and sysfs_emit_at() in "show" functions

2021-05-10 Thread Logan Gunthorpe
On 2021-05-09 10:14 p.m., Krzysztof Wilczyński wrote: > The sysfs_emit() and sysfs_emit_at() functions were introduced to make > it less ambiguous which function is preferred when writing to the output > buffer in a device attribute's "show" callback [1]. > > Convert the PCI sysfs object "show"

Re: [PATCH v6 08/15] swiotlb: Bounce data from/to restricted DMA pool if available

2021-05-10 Thread Christoph Hellwig
> +static inline bool is_dev_swiotlb_force(struct device *dev) > +{ > +#ifdef CONFIG_DMA_RESTRICTED_POOL > + if (dev->dma_io_tlb_mem) > + return true; > +#endif /* CONFIG_DMA_RESTRICTED_POOL */ > + return false; > +} > + > /* If SWIOTLB is active, use its maximum mapping

Re: [PATCH v6 05/15] swiotlb: Add a new get_io_tlb_mem getter

2021-05-10 Thread Christoph Hellwig
> +static inline struct io_tlb_mem *get_io_tlb_mem(struct device *dev) > +{ > +#ifdef CONFIG_DMA_RESTRICTED_POOL > + if (dev && dev->dma_io_tlb_mem) > + return dev->dma_io_tlb_mem; > +#endif /* CONFIG_DMA_RESTRICTED_POOL */ > + > + return io_tlb_default_mem; Given that we're al

Re: [PATCH v6 04/15] swiotlb: Add restricted DMA pool initialization

2021-05-10 Thread Christoph Hellwig
> +#ifdef CONFIG_DMA_RESTRICTED_POOL > +#include > +#include > +#include > +#include > +#include > +#endif I don't think any of this belongs into swiotlb.c. Marking swiotlb_init_io_tlb_mem non-static and having all this code in a separate file is probably a better idea. > +#ifdef CONFIG_DMA

Re: [PATCH v6 02/15] swiotlb: Refactor swiotlb_create_debugfs

2021-05-10 Thread Christoph Hellwig
Looks good, Reviewed-by: Christoph Hellwig

Re: [PATCH v6 01/15] swiotlb: Refactor swiotlb init functions

2021-05-10 Thread Christoph Hellwig
Looks good, Reviewed-by: Christoph Hellwig

[PATCH v1 1/1] powerpc/prom_init: Move custom isspace() to its own namespace

2021-05-10 Thread Andy Shevchenko
If by some reason any of the headers will include ctype.h we will have a name collision. Avoid this by moving isspace() to the dedicate namespace. First appearance of the code is in the commit cf68787b68a2 ("powerpc/prom_init: Evaluate mem kernel parameter for early allocation"). Reported-by: ker

Re: [RFC PATCH 0/7] Memory hotplug/hotremove at subsection size

2021-05-10 Thread Zi Yan
On 7 May 2021, at 10:00, David Hildenbrand wrote: > On 07.05.21 13:55, Michal Hocko wrote: >> [I haven't read through respective patches due to lack of time but let >> me comment on the general idea and the underlying justification] >> >> On Thu 06-05-21 17:31:09, David Hildenbrand wrote: >>> On

[PATCH 1/1] powerpc/pseries/ras: Delete a redundant condition branch

2021-05-10 Thread Zhen Lei
The statement of the last "if (xxx)" branch is the same as the "else" branch. Delete it to simplify code. No functional change. Signed-off-by: Zhen Lei --- arch/powerpc/platforms/pseries/ras.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/arch/powerpc/platforms/pseries/ras.c b/arch/powe

Re: [PATCH] ppc64/numa: consider the max numa node for migratable LPAR

2021-05-10 Thread Laurent Dufour
Le 10/05/2021 à 12:21, Srikar Dronamraju a écrit : * Laurent Dufour [2021-04-29 20:19:01]: When a LPAR is migratable, we should consider the maximum possible NUMA node instead the number of NUMA node from the actual system. The DT property 'ibm,current-associativity-domains' is defining the m

Re: [PATCH 01/11] PCI: Use sysfs_emit() and sysfs_emit_at() in "show" functions

2021-05-10 Thread Krzysztof Wilczyński
[+cc Joe for visibility] [...] > spin_lock(&resource_alignment_lock); > if (resource_alignment_param) > - count = scnprintf(buf, PAGE_SIZE, "%s", > resource_alignment_param); > + count = sysfs_emit(buf, "%s", resource_alignment_param); > spin_unlock(&reso

Re: [PATCH] ppc64/numa: consider the max numa node for migratable LPAR

2021-05-10 Thread Srikar Dronamraju
* Laurent Dufour [2021-04-29 20:19:01]: > When a LPAR is migratable, we should consider the maximum possible NUMA > node instead the number of NUMA node from the actual system. > > The DT property 'ibm,current-associativity-domains' is defining the maximum > number of nodes the LPAR can see when

Re: [PATCH v5 00/16] Restricted DMA

2021-05-10 Thread Claire Chang
v6: https://lore.kernel.org/patchwork/cover/1423201/

[PATCH v6 15/15] of: Add plumbing for restricted DMA pool

2021-05-10 Thread Claire Chang
If a device is not behind an IOMMU, we look up the device node and set up the restricted DMA when the restricted-dma-pool is presented. Signed-off-by: Claire Chang --- drivers/of/address.c| 25 + drivers/of/device.c | 3 +++ drivers/of/of_private.h | 5 + 3

[PATCH v6 14/15] dt-bindings: of: Add restricted DMA pool

2021-05-10 Thread Claire Chang
Introduce the new compatible string, restricted-dma-pool, for restricted DMA. One can specify the address and length of the restricted DMA memory region by restricted-dma-pool in the reserved-memory node. Signed-off-by: Claire Chang --- .../reserved-memory/reserved-memory.txt | 27

[PATCH v6 13/15] dma-direct: Allocate memory from restricted DMA pool if available

2021-05-10 Thread Claire Chang
The restricted DMA pool is preferred if available. The restricted DMA pools provide a basic level of protection against the DMA overwriting buffer contents at unexpected times. However, to protect against general data leakage and system memory corruption, the system needs to provide a way to lock

[PATCH v6 12/15] swiotlb: Add restricted DMA alloc/free support.

2021-05-10 Thread Claire Chang
Add the functions, swiotlb_{alloc,free} to support the memory allocation from restricted DMA pool. Signed-off-by: Claire Chang --- include/linux/swiotlb.h | 4 kernel/dma/swiotlb.c| 35 +-- 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/

[PATCH v6 11/15] dma-direct: Add a new wrapper __dma_direct_free_pages()

2021-05-10 Thread Claire Chang
Add a new wrapper __dma_direct_free_pages() that will be useful later for swiotlb_free(). Signed-off-by: Claire Chang --- kernel/dma/direct.c | 14 ++ 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/kernel/dma/direct.c b/kernel/dma/direct.c index 078f7087e466..eb409832

[PATCH v6 10/15] swiotlb: Refactor swiotlb_tbl_unmap_single

2021-05-10 Thread Claire Chang
Add a new function, release_slots, to make the code reusable for supporting different bounce buffer pools, e.g. restricted DMA pool. Signed-off-by: Claire Chang --- kernel/dma/swiotlb.c | 35 --- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/kern

[PATCH v6 09/15] swiotlb: Move alloc_size to find_slots

2021-05-10 Thread Claire Chang
Move the maintenance of alloc_size to find_slots for better code reusability later. Signed-off-by: Claire Chang --- kernel/dma/swiotlb.c | 10 +- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/kernel/dma/swiotlb.c b/kernel/dma/swiotlb.c index 3f1ad080a4bc..ef04d8f7708f 100

[PATCH v6 08/15] swiotlb: Bounce data from/to restricted DMA pool if available

2021-05-10 Thread Claire Chang
Regardless of swiotlb setting, the restricted DMA pool is preferred if available. The restricted DMA pools provide a basic level of protection against the DMA overwriting buffer contents at unexpected times. However, to protect against general data leakage and system memory corruption, the system

[PATCH v6 07/15] swiotlb: Update is_swiotlb_active to add a struct device argument

2021-05-10 Thread Claire Chang
Update is_swiotlb_active to add a struct device argument. This will be useful later to allow for restricted DMA pool. Signed-off-by: Claire Chang --- drivers/gpu/drm/i915/gem/i915_gem_internal.c | 2 +- drivers/gpu/drm/nouveau/nouveau_ttm.c| 2 +- drivers/pci/xen-pcifront.c

[PATCH v6 06/15] swiotlb: Update is_swiotlb_buffer to add a struct device argument

2021-05-10 Thread Claire Chang
Update is_swiotlb_buffer to add a struct device argument. This will be useful later to allow for restricted DMA pool. Signed-off-by: Claire Chang --- drivers/iommu/dma-iommu.c | 12 ++-- drivers/xen/swiotlb-xen.c | 2 +- include/linux/swiotlb.h | 6 +++--- kernel/dma/direct.c |

[PATCH v6 05/15] swiotlb: Add a new get_io_tlb_mem getter

2021-05-10 Thread Claire Chang
Add a new getter, get_io_tlb_mem, to help select the io_tlb_mem struct. The restricted DMA pool is preferred if available. Signed-off-by: Claire Chang --- include/linux/swiotlb.h | 11 +++ 1 file changed, 11 insertions(+) diff --git a/include/linux/swiotlb.h b/include/linux/swiotlb.h in

[PATCH v6 04/15] swiotlb: Add restricted DMA pool initialization

2021-05-10 Thread Claire Chang
Add the initialization function to create restricted DMA pools from matching reserved-memory nodes. Signed-off-by: Claire Chang --- include/linux/device.h | 4 +++ include/linux/swiotlb.h | 3 +- kernel/dma/swiotlb.c| 79 + 3 files changed, 85 inser

[PATCH v6 03/15] swiotlb: Add DMA_RESTRICTED_POOL

2021-05-10 Thread Claire Chang
Add a new kconfig symbol, DMA_RESTRICTED_POOL, for restricted DMA pool. Signed-off-by: Claire Chang --- kernel/dma/Kconfig | 14 ++ 1 file changed, 14 insertions(+) diff --git a/kernel/dma/Kconfig b/kernel/dma/Kconfig index 77b405508743..3e961dc39634 100644 --- a/kernel/dma/Kconfig

[PATCH v6 02/15] swiotlb: Refactor swiotlb_create_debugfs

2021-05-10 Thread Claire Chang
Split the debugfs creation to make the code reusable for supporting different bounce buffer pools, e.g. restricted DMA pool. Signed-off-by: Claire Chang --- kernel/dma/swiotlb.c | 22 -- 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/kernel/dma/swiotlb.c b/ker

[PATCH v6 01/15] swiotlb: Refactor swiotlb init functions

2021-05-10 Thread Claire Chang
Add a new function, swiotlb_init_io_tlb_mem, for the io_tlb_mem struct initialization to make the code reusable. Note that we now also call set_memory_decrypted in swiotlb_init_with_tbl. Signed-off-by: Claire Chang --- kernel/dma/swiotlb.c | 51 ++-- 1 fi

[PATCH v6 00/15] Restricted DMA

2021-05-10 Thread Claire Chang
From: Claire Chang This series implements mitigations for lack of DMA access control on systems without an IOMMU, which could result in the DMA accessing the system memory at unexpected times and/or unexpected addresses, possibly leading to data leakage or corruption. For example, we plan to use

Re: [PATCH v4 06/11] powerpc/pseries/iommu: Add ddw_property_create() and refactor enable_ddw()

2021-05-10 Thread Alexey Kardashevskiy
On 5/1/21 02:31, Leonardo Bras wrote: Code used to create a ddw property that was previously scattered in enable_ddw() is now gathered in ddw_property_create(), which deals with allocation and filling the property, letting it ready for of_property_add(), which now occurs in sequence. This cre

Re: [PATCH v4 07/11] powerpc/pseries/iommu: Reorganize iommu_table_setparms*() with new helper

2021-05-10 Thread Alexey Kardashevskiy
On 5/1/21 02:31, Leonardo Bras wrote: Add a new helper _iommu_table_setparms(), and use it in iommu_table_setparms() and iommu_table_setparms_lpar() to avoid duplicated code. Also, setting tbl->it_ops was happening outsite iommu_table_setparms*(), so move it to the new helper. Since we need t

Re: [PATCH v4 02/11] powerpc/kernel/iommu: Add new iommu_table_in_use() helper

2021-05-10 Thread Alexey Kardashevskiy
On 5/1/21 02:31, Leonardo Bras wrote: Having a function to check if the iommu table has any allocation helps deciding if a tbl can be reset for using a new DMA window. It should be enough to replace all instances of !bitmap_empty(tbl...). iommu_table_in_use() skips reserved memory, so we don

Re: [PATCH] powerpc/pmu: Make the generic compat PMU use the architected events

2021-05-10 Thread Madhavan Srinivasan
On 5/4/21 1:13 PM, Paul Mackerras wrote: This changes generic-compat-pmu.c so that it only uses architected events defined in Power ISA v3.0B, rather than event encodings which, while common to all the IBM Power Systems implementations, are nevertheless implementation-specific rather than archi