[PATCH v6 3/3] riscv: Check relocations at compile time

2021-05-18 Thread Alexandre Ghiti
Relocating kernel at runtime is done very early in the boot process, so it is not convenient to check for relocations there and react in case a relocation was not expected. There exists a script in scripts/ that extracts the relocations from vmlinux that is then used at postlink to check the

[PATCH v2 0/2] mm: unify the allocation of pglist_data instances

2021-05-18 Thread Miles Chen
This patches is created to fix the __pa() warning messages when CONFIG_DEBUG_VIRTUAL=y by unifying the allocation of pglist_data instances. In current implementation of node_data, if CONFIG_NEED_MULTIPLE_NODES=y, pglist_data is allocated by a memblock API. If CONFIG_NEED_MULTIPLE_NODES=n, we use

[PATCH v2 2/2] mm: replace contig_page_data with node_data

2021-05-18 Thread Miles Chen
Replace contig_page_data with node_data. Change the definition of NODE_DATA(nid) from (_page_data) to (node_data[0]). Remove contig_page_data from the tree. Cc: Mike Rapoport Cc: Baoquan He Cc: Kazu Signed-off-by: Miles Chen --- Documentation/admin-guide/kdump/vmcoreinfo.rst | 13

[PATCH v2 1/2] mm: introduce prepare_node_data

2021-05-18 Thread Miles Chen
When CONFIG_NEED_MULTIPLE_NODES=y (CONFIG_NUMA=y), the pglist_data is allocated by a memblock API and stored in an array named node_data[]. When CONFIG_NEED_MULTIPLE_NODES=n (CONFIG_NUMA=n), the pglist_data is defined as global variable contig_page_data. The difference causes problems when we

[PATCH v6 1/3] riscv: Introduce CONFIG_RELOCATABLE

2021-05-18 Thread Alexandre Ghiti
This config allows to compile 64b kernel as PIE and to relocate it at any virtual address at runtime: this paves the way to KASLR. Runtime relocation is possible since relocation metadata are embedded into the kernel. Note that relocating at runtime introduces an overhead even if the kernel is

[PATCH v6 0/3] Introduce 64b relocatable kernel

2021-05-18 Thread Alexandre Ghiti
After multiple attempts, this patchset is now based on the fact that the 64b kernel mapping was moved outside the linear mapping. The first patch allows to build relocatable kernels but is not selected by default. That patch should ease KASLR implementation a lot.

[PATCH v6 2/3] powerpc: Move script to check relocations at compile time in scripts/

2021-05-18 Thread Alexandre Ghiti
Relocating kernel at runtime is done very early in the boot process, so it is not convenient to check for relocations there and react in case a relocation was not expected. Powerpc architecture has a script that allows to check at compile time for such unexpected relocations: extract the common

Re: [PATCH v2 0/2] mm: unify the allocation of pglist_data instances

2021-05-18 Thread Mike Rapoport
Hello Miles, On Tue, May 18, 2021 at 05:24:44PM +0800, Miles Chen wrote: > This patches is created to fix the __pa() warning messages when > CONFIG_DEBUG_VIRTUAL=y by unifying the allocation of pglist_data > instances. > > In current implementation of node_data, if CONFIG_NEED_MULTIPLE_NODES=y,

Re: [PATCH v3 5/6] sched/fair: Consider SMT in ASYM_PACKING load balance

2021-05-18 Thread Ricardo Neri
On Fri, May 14, 2021 at 07:14:15PM -0700, Ricardo Neri wrote: > On Fri, May 14, 2021 at 11:47:45AM +0200, Peter Zijlstra wrote: > > On Thu, May 13, 2021 at 08:49:08AM -0700, Ricardo Neri wrote: > > > include/linux/sched/topology.h | 1 + > > > kernel/sched/fair.c| 101

Re: [PATCH v8 27/30] powerpc/kprobes: Don't allow breakpoints on suffixes

2021-05-18 Thread Christophe Leroy
Le 06/05/2020 à 05:40, Jordan Niethe a écrit : Do not allow inserting breakpoints on the suffix of a prefix instruction in kprobes. Signed-off-by: Jordan Niethe --- v8: Add this back from v3 --- arch/powerpc/kernel/kprobes.c | 13 + 1 file changed, 13 insertions(+) diff

Re: [PATCH] powerpc: Kconfig: disable CONFIG_COMPAT for clang < 12

2021-05-18 Thread Nathan Chancellor
On 5/18/2021 1:58 PM, Nick Desaulniers wrote: Until clang-12, clang would attempt to assemble 32b powerpc assembler in 64b emulation mode when using a 64b target triple with -m32, leading to errors during the build of the compat VDSO. Simply disable all of CONFIG_COMPAT; users should upgrade to

Re: [PATCH v2] powerpc/powernv/pci: fix header guard

2021-05-18 Thread Nathan Chancellor
On 5/18/2021 1:40 PM, Nick Desaulniers wrote: While looking at -Wundef warnings, the #if CONFIG_EEH stood out as a possible candidate to convert to #ifdef CONFIG_EEH. It seems that based on Kconfig dependencies it's not possible to build this file without CONFIG_EEH enabled, but based on

Re: [PATCH v5 3/9] mm/mremap: Use pmd/pud_poplulate to update page table entries

2021-05-18 Thread Nathan Chancellor
Hi Aneesh, On Thu, Apr 22, 2021 at 11:13:17AM +0530, Aneesh Kumar K.V wrote: > pmd/pud_populate is the right interface to be used to set the respective > page table entries. Some architectures like ppc64 do assume that > set_pmd/pud_at > can only be used to set a hugepage PTE. Since we are not

Re: [PATCH v8 27/30] powerpc/kprobes: Don't allow breakpoints on suffixes

2021-05-18 Thread Gabriel Paubert
On Tue, May 18, 2021 at 08:43:39PM +0200, Christophe Leroy wrote: > > > Le 06/05/2020 à 05:40, Jordan Niethe a écrit : > > Do not allow inserting breakpoints on the suffix of a prefix instruction > > in kprobes. > > > > Signed-off-by: Jordan Niethe > > --- > > v8: Add this back from v3 > > ---

Re: [PATCH v2 0/2] mm: unify the allocation of pglist_data instances

2021-05-18 Thread Miles Chen
On Tue, 2021-05-18 at 19:09 +0300, Mike Rapoport wrote: > Hello Miles, > > On Tue, May 18, 2021 at 05:24:44PM +0800, Miles Chen wrote: > > This patches is created to fix the __pa() warning messages when > > CONFIG_DEBUG_VIRTUAL=y by unifying the allocation of pglist_data > > instances. > > > >

Re: [PATCH v5 5/9] powerpc/mm/book3s64: Update tlb flush routines to take a page walk cache flush argument

2021-05-18 Thread Guenter Roeck
On 5/18/21 5:26 PM, Michael Ellerman wrote: [ ... ] That was the generic header change in the patch. I was commenting about the ppc64 specific change causing build failures. Ah, sorry. I wasn't aware that the following is valid C code void f1() { return f2(); ^^ } as long as

Re: Linux powerpc new system call instruction and ABI

2021-05-18 Thread Dmitry V. Levin
Hi, On Thu, Jun 11, 2020 at 06:12:01PM +1000, Nicholas Piggin wrote: [...] > - Error handling: The consensus among kernel, glibc, and musl is to move to > using negative return values in r3 rather than CR0[SO]=1 to indicate error, > which matches most other architectures, and is closer to a

Re: [PATCH v6 2/3] powerpc: Move script to check relocations at compile time in scripts/

2021-05-18 Thread Michael Ellerman
Alexandre Ghiti writes: > Relocating kernel at runtime is done very early in the boot process, so > it is not convenient to check for relocations there and react in case a > relocation was not expected. > > Powerpc architecture has a script that allows to check at compile time > for such

[PATCH v2] powerpc/powernv/pci: fix header guard

2021-05-18 Thread Nick Desaulniers
While looking at -Wundef warnings, the #if CONFIG_EEH stood out as a possible candidate to convert to #ifdef CONFIG_EEH. It seems that based on Kconfig dependencies it's not possible to build this file without CONFIG_EEH enabled, but based on upstream discussion, it's not clear yet that

Re: [PATCH v5 5/9] powerpc/mm/book3s64: Update tlb flush routines to take a page walk cache flush argument

2021-05-18 Thread Segher Boessenkool
On Wed, May 19, 2021 at 10:26:22AM +1000, Michael Ellerman wrote: > Guenter Roeck writes: > > Ah, sorry. I wasn't aware that the following is valid C code > > > > void f1() > > { > > return f2(); > > ^^ > > } > > > > as long as f2() is void as well. Confusing, but we live and learn.

[PATCH] powerpc: Kconfig: disable CONFIG_COMPAT for clang < 12

2021-05-18 Thread Nick Desaulniers
Until clang-12, clang would attempt to assemble 32b powerpc assembler in 64b emulation mode when using a 64b target triple with -m32, leading to errors during the build of the compat VDSO. Simply disable all of CONFIG_COMPAT; users should upgrade to the latest release of clang for proper support.

Re: [PATCH v5 5/9] powerpc/mm/book3s64: Update tlb flush routines to take a page walk cache flush argument

2021-05-18 Thread Michael Ellerman
Guenter Roeck writes: > On 5/17/21 6:55 AM, Aneesh Kumar K.V wrote: >> Guenter Roeck writes: >> >>> On 5/17/21 1:40 AM, Aneesh Kumar K.V wrote: On 5/15/21 10:05 PM, Guenter Roeck wrote: > On Thu, Apr 22, 2021 at 11:13:19AM +0530, Aneesh Kumar K.V wrote: >> >> ... >> >   extern

[Bug 213069] kernel BUG at arch/powerpc/include/asm/book3s/64/hash-4k.h:147! Oops: Exception in kernel mode, sig: 5 [#1]

2021-05-18 Thread bugzilla-daemon
https://bugzilla.kernel.org/show_bug.cgi?id=213069 Michael Ellerman (mich...@ellerman.id.au) changed: What|Removed |Added Status|ASSIGNED|RESOLVED

Re: [PATCH v2 0/2] mm: unify the allocation of pglist_data instances

2021-05-18 Thread Miles Chen
On Wed, 2021-05-19 at 06:48 +0300, Mike Rapoport wrote: > On Wed, May 19, 2021 at 08:12:06AM +0800, Miles Chen wrote: > > On Tue, 2021-05-18 at 19:09 +0300, Mike Rapoport wrote: > > > Hello Miles, > > > > > > On Tue, May 18, 2021 at 05:24:44PM +0800, Miles Chen wrote: > > > > This patches is

[PATCH net-next] ibmveth: fix kobj_to_dev.cocci warnings

2021-05-18 Thread YueHaibing
Use kobj_to_dev() instead of container_of() Generated by: scripts/coccinelle/api/kobj_to_dev.cocci Signed-off-by: YueHaibing --- drivers/net/ethernet/ibm/ibmveth.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/net/ethernet/ibm/ibmveth.c

Re: [PATCH v2 0/2] mm: unify the allocation of pglist_data instances

2021-05-18 Thread Mike Rapoport
On Wed, May 19, 2021 at 08:12:06AM +0800, Miles Chen wrote: > On Tue, 2021-05-18 at 19:09 +0300, Mike Rapoport wrote: > > Hello Miles, > > > > On Tue, May 18, 2021 at 05:24:44PM +0800, Miles Chen wrote: > > > This patches is created to fix the __pa() warning messages when > > >

Re: Linux powerpc new system call instruction and ABI

2021-05-18 Thread Nicholas Piggin
Excerpts from Dmitry V. Levin's message of May 19, 2021 9:13 am: > Hi, > > On Thu, Jun 11, 2020 at 06:12:01PM +1000, Nicholas Piggin wrote: > [...] >> - Error handling: The consensus among kernel, glibc, and musl is to move to >> using negative return values in r3 rather than CR0[SO]=1 to

Re: [PATCH v5 3/9] mm/mremap: Use pmd/pud_poplulate to update page table entries

2021-05-18 Thread Aneesh Kumar K.V
Nathan Chancellor writes: > Hi Aneesh, > > On Thu, Apr 22, 2021 at 11:13:17AM +0530, Aneesh Kumar K.V wrote: >> pmd/pud_populate is the right interface to be used to set the respective >> page table entries. Some architectures like ppc64 do assume that >> set_pmd/pud_at >> can only be used to

Re: Linux powerpc new system call instruction and ABI

2021-05-18 Thread Nicholas Piggin
Excerpts from Nicholas Piggin's message of May 19, 2021 12:50 pm: > Excerpts from Dmitry V. Levin's message of May 19, 2021 9:13 am: >> Hi, >> >> On Thu, Jun 11, 2020 at 06:12:01PM +1000, Nicholas Piggin wrote: >> [...] >>> - Error handling: The consensus among kernel, glibc, and musl is to move

Re: [PATCH net-next] ibmveth: fix kobj_to_dev.cocci warnings

2021-05-18 Thread Lijun Pan
> On May 18, 2021, at 9:28 PM, YueHaibing wrote: > > Use kobj_to_dev() instead of container_of() > > Generated by: scripts/coccinelle/api/kobj_to_dev.cocci > > Signed-off-by: YueHaibing > --- Acked-by: Lijun Pan > drivers/net/ethernet/ibm/ibmveth.c | 3 +-- > 1 file changed, 1

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

2021-05-18 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

[PATCH v7 00/15] Restricted DMA

2021-05-18 Thread 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 the PCI-e bus for

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

2021-05-18 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 95f482c4408c..2ec6711071de

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

2021-05-18 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 v7 07/15] swiotlb: Update is_swiotlb_active to add a struct device argument

2021-05-18 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 v7 10/15] swiotlb: Refactor swiotlb_tbl_unmap_single

2021-05-18 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

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

2021-05-18 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

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

2021-05-18 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

Re: [PATCH] powerpc/powernv/pci: remove dead code from !CONFIG_EEH

2021-05-18 Thread Michael Ellerman
Nick Desaulniers writes: > On Thu, Apr 22, 2021 at 6:13 PM Oliver O'Halloran wrote: >> >> On Fri, Apr 23, 2021 at 9:09 AM Daniel Axtens wrote: >> > >> > Hi Nick, >> > >> > > While looking at -Wundef warnings, the #if CONFIG_EEH stood out as a >> > > possible candidate to convert to #ifdef

Re: [FSL P50x0] KVM HV doesn't work anymore

2021-05-18 Thread Christian Zigotzky
> On 17. May 2021, at 11:43, Christian Zigotzky wrote: > > On 17 May 2021 at 09:42am, Nicholas Piggin wrote: >> Excerpts from Christian Zigotzky's message of May 15, 2021 11:46 pm: >>> On 15 May 2021 at 12:08pm Christophe Leroy wrote: > Le 15/05/2021 à 11:48, Christian Zigotzky a

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

2021-05-18 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| 76 + 3 files changed, 82

[PATCH v7 02/15] swiotlb: Refactor swiotlb_create_debugfs

2021-05-18 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 | 25 +++-- 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/kernel/dma/swiotlb.c

[PATCH v7 03/15] swiotlb: Add DMA_RESTRICTED_POOL

2021-05-18 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 v7 06/15] swiotlb: Update is_swiotlb_buffer to add a struct device argument

2021-05-18 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 v7 05/15] swiotlb: Add a new get_io_tlb_mem getter

2021-05-18 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

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

2021-05-18 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 v7 14/15] dt-bindings: of: Add restricted DMA pool

2021-05-18 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 v7 15/15] of: Add plumbing for restricted DMA pool

2021-05-18 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

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

2021-05-18 Thread Claire Chang
I didn't move this to a separate file because I feel it might be confusing for swiotlb_alloc/free (and need more functions to be non-static). Maybe instead of moving to a separate file, we can try to come up with a better naming?

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

2021-05-18 Thread Claire Chang
Still keep this function because directly using dev->dma_io_tlb_mem will cause issues for memory allocation for existing devices. The pool can't support atomic coherent allocation so we need to distinguish the per device pool and the default pool in swiotlb_alloc.

Re: [PATCH v6 00/15] Restricted DMA

2021-05-18 Thread Claire Chang
v7: https://lore.kernel.org/patchwork/cover/1431031/ On Mon, May 10, 2021 at 5:50 PM Claire Chang wrote: > > 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

[PATCH 1/1] powerpc/ps3: Fix error return code in ps3_register_devices()

2021-05-18 Thread Zhen Lei
When call ps3_start_probe_thread() failed, further initialization should be stopped and the returned error code should be propagated. Reported-by: Hulk Robot Signed-off-by: Zhen Lei --- arch/powerpc/platforms/ps3/device-init.c | 2 ++ 1 file changed, 2 insertions(+) diff --git