Re: [PATCH 0/2] of: phandle_cache, fix refcounts, remove stale entry

2018-12-13 Thread Frank Rowand
Hi Michael Bringmann, On 12/13/18 10:42 PM, frowand.l...@gmail.com wrote: > From: Frank Rowand > > Non-overlay dynamic devicetree node removal may leave the node in > the phandle cache. Subsequent calls to of_find_node_by_phandle() > will incorrectly find the stale entry. This bug exposed the

[PATCH 2/2] of: __of_detach_node() - remove node from phandle cache

2018-12-13 Thread frowand . list
From: Frank Rowand Non-overlay dynamic devicetree node removal may leave the node in the phandle cache. Subsequent calls to of_find_node_by_phandle() will incorrectly find the stale entry. Remove the node from the cache. Add paranoia checks in of_find_node_by_phandle() as a second level of def

[PATCH 1/2] of: of_node_get()/of_node_put() nodes held in phandle cache

2018-12-13 Thread frowand . list
From: Frank Rowand The phandle cache contains struct device_node pointers. The refcount of the pointers was not incremented while in the cache, allowing use after free error after kfree() of the node. Add the proper increment and decrement of the use count. Fixes: 0b3ce78e90fc ("of: cache phan

[PATCH 0/2] of: phandle_cache, fix refcounts, remove stale entry

2018-12-13 Thread frowand . list
From: Frank Rowand Non-overlay dynamic devicetree node removal may leave the node in the phandle cache. Subsequent calls to of_find_node_by_phandle() will incorrectly find the stale entry. This bug exposed the foloowing phandle cache refcount bug. The refcount of phandle_cache entries is not i

Re: [PATCH] powerpc/prom: fix early DEBUG messages

2018-12-13 Thread Michael Ellerman
Christophe Leroy writes: > diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c > index fe758cedb93f..d8e56e03c9c6 100644 > --- a/arch/powerpc/kernel/prom.c > +++ b/arch/powerpc/kernel/prom.c > @@ -749,7 +749,11 @@ void __init early_init_devtree(void *params) > memblock_allo

lockdep WARN_ON in ppc440 with -next

2018-12-13 Thread Joel Stanley
Hello, I was booting next-20181213 in qemu with lockdep enabled and saw this: spin_lock-torture:--- Start of test [debug]: nwriters_stress=2 nreaders_stress=0 stat_interval=60 verbose=1 shuffle_interval=3 stutter=5 shutdown_secs=0 onoff_interval=0 onoff_holdoff=0 spin_lock-torture: Creating

[PATCH V4 8/8] KVM: PPC: Book3S HV: Allow passthrough of an emulated device to an L3 guest

2018-12-13 Thread Suraj Jitindar Singh
Previously when a device was being emulated by an L1 guest for an L2 guest, that device couldn't then be passed through to an L3 guest. This was because the L1 guest had no method for accessing L3 memory. The hcall H_COPY_TOFROM_GUEST provides this access. Thus this setup for passthrough can now b

[PATCH V4 7/8] KVM: PPC: Introduce new hcall H_COPY_TOFROM_GUEST to access quadrants 1 & 2

2018-12-13 Thread Suraj Jitindar Singh
A guest cannot access quadrants 1 or 2 as this would result in an exception. Thus introduce the hcall H_COPY_TOFROM_GUEST to be used by a guest when it wants to perform an access to quadrants 1 or 2, for example when it wants to access memory for one of its nested guests. Also provide an implement

[PATCH V4 6/8] KVM: PPC: Book3S HV: Allow passthrough of an emulated device to an L2 guest

2018-12-13 Thread Suraj Jitindar Singh
Allow for a device which is being emulated at L0 (the host) for an L1 guest to be passed through to a nested (L2) guest. The existing kvmppc_hv_emulate_mmio function can be used here. The main challenge is that for a load the result must be stored into the L2 gpr, not an L1 gpr as would normally b

[PATCH V4 5/8] KVM: PPC: Update kvmppc_st and kvmppc_ld to use quadrants

2018-12-13 Thread Suraj Jitindar Singh
The functions kvmppc_st and kvmppc_ld are used to access guest memory from the host using a guest effective address. They do so by translating through the process table to obtain a guest real address and then using kvm_read_guest or kvm_write_guest to make the access with the guest real address. T

[PATCH V4 4/8] KVM: PPC: Add load_from_eaddr and store_to_eaddr to the kvmppc_ops struct

2018-12-13 Thread Suraj Jitindar Singh
The kvmppc_ops struct is used to store function pointers to kvm implementation specific functions. Introduce two new functions load_from_eaddr and store_to_eaddr to be used to load from and store to a guest effective address respectively. Also implement these for the kvm-hv module. If we are usin

[PATCH V4 3/8] KVM: PPC: Book3S HV: Implement functions to access quadrants 1 & 2

2018-12-13 Thread Suraj Jitindar Singh
The POWER9 radix mmu has the concept of quadrants. The quadrant number is the two high bits of the effective address and determines the fully qualified address to be used for the translation. The fully qualified address consists of the effective lpid, the effective pid and the effective address. Th

[PATCH V4 2/8] KVM: PPC: Book3S HV: Add function kvmhv_vcpu_is_radix()

2018-12-13 Thread Suraj Jitindar Singh
There exists a function kvm_is_radix() which is used to determine if a kvm instance is using the radix mmu. However this only applies to the first level (L1) guest. Add a function kvmhv_vcpu_is_radix() which can be used to determine if the current execution context of the vcpu is radix, accounting

[PATCH V4 1/8] KVM: PPC: Only report KVM_CAP_SPAPR_TCE_VFIO on powernv machines

2018-12-13 Thread Suraj Jitindar Singh
The kvm capability KVM_CAP_SPAPR_TCE_VFIO is used to indicate the availability of in kernel tce acceleration for vfio. However it is currently the case that this is only available on a powernv machine, not for a pseries machine. Thus make this capability dependent on having the cpu feature CPU_FTR

[PATCH V4 0/8] KVM: PPC: Implement passthrough of emulated devices for nested guests

2018-12-13 Thread Suraj Jitindar Singh
This patch series allows for emulated devices to be passed through to nested guests, irrespective of at which level the device is being emulated. Note that the emulated device must be using dma, not virtio. For example, passing through an emulated e1000: 1. Emulate the device at L(n) for L(n+1)

Re: [PATCH kernel v5 03/20] powerpc/vfio/iommu/kvm: Do not pin device memory

2018-12-13 Thread Paul Mackerras
On Thu, Dec 13, 2018 at 05:17:17PM +1100, Alexey Kardashevskiy wrote: > This new memory does not have page structs as it is not plugged to > the host so gup() will fail anyway. > > This adds 2 helpers: > - mm_iommu_newdev() to preregister the "memory device" memory so > the rest of API can still b

[PATCH V3 8/8] KVM: PPC: Book3S HV: Allow passthrough of an emulated device to an L3 guest

2018-12-13 Thread Suraj Jitindar Singh
Previously when a device was being emulated by an L1 guest for an L2 guest, that device couldn't then be passed through to an L3 guest. This was because the L1 guest had no method for accessing L3 memory. The hcall H_COPY_TOFROM_GUEST provides this access. Thus this setup for passthrough can now b

[PATCH V3 7/8] KVM: PPC: Introduce new hcall H_COPY_TOFROM_GUEST to access quadrants 1 & 2

2018-12-13 Thread Suraj Jitindar Singh
A guest cannot access quadrants 1 or 2 as this would result in an exception. Thus introduce the hcall H_COPY_TOFROM_GUEST to be used by a guest when it wants to perform an access to quadrants 1 or 2, for example when it wants to access memory for one of its nested guests. Also provide an implement

[PATCH V3 6/8] KVM: PPC: Book3S HV: Allow passthrough of an emulated device to an L2 guest

2018-12-13 Thread Suraj Jitindar Singh
Allow for a device which is being emulated at L0 (the host) for an L1 guest to be passed through to a nested (L2) guest. The existing kvmppc_hv_emulate_mmio function can be used here. The main challenge is that for a load the result must be stored into the L2 gpr, not an L1 gpr as would normally b

[PATCH V3 5/8] KVM: PPC: Update kvmppc_st and kvmppc_ld to use quadrants

2018-12-13 Thread Suraj Jitindar Singh
The functions kvmppc_st and kvmppc_ld are used to access guest memory from the host using a guest effective address. They do so by translating through the process table to obtain a guest real address and then using kvm_read_guest or kvm_write_guest to make the access with the guest real address. T

[PATCH V3 4/8] KVM: PPC: Add load_from_eaddr and store_to_eaddr to the kvmppc_ops struct

2018-12-13 Thread Suraj Jitindar Singh
The kvmppc_ops struct is used to store function pointers to kvm implementation specific functions. Introduce two new functions load_from_eaddr and store_to_eaddr to be used to load from and store to a guest effective address respectively. Also implement these for the kvm-hv module. If we are usin

[PATCH V3 3/8] KVM: PPC: Book3S HV: Implement functions to access quadrants 1 & 2

2018-12-13 Thread Suraj Jitindar Singh
The POWER9 radix mmu has the concept of quadrants. The quadrant number is the two high bits of the effective address and determines the fully qualified address to be used for the translation. The fully qualified address consists of the effective lpid, the effective pid and the effective address. Th

[PATCH V3 2/8] KVM: PPC: Book3S HV: Add function kvmhv_vcpu_is_radix()

2018-12-13 Thread Suraj Jitindar Singh
There exists a function kvm_is_radix() which is used to determine if a kvm instance is using the radix mmu. However this only applies to the first level (L1) guest. Add a function kvmhv_vcpu_is_radix() which can be used to determine if the current execution context of the vcpu is radix, accounting

[PATCH V3 1/8] KVM: PPC: Only report KVM_CAP_SPAPR_TCE_VFIO on powernv machines

2018-12-13 Thread Suraj Jitindar Singh
The kvm capability KVM_CAP_SPAPR_TCE_VFIO is used to indicate the availability of in kernel tce acceleration for vfio. However it is currently the case that this is only available on a powernv machine, not for a pseries machine. Thus make this capability dependent on having the cpu feature CPU_FTR

[PATCH V3 0/8] KVM: PPC: Implement passthrough of emulated devices for nested guests

2018-12-13 Thread Suraj Jitindar Singh
This patch series allows for emulated devices to be passed through to nested guests, irrespective of at which level the device is being emulated. Note that the emulated device must be using dma, not virtio. For example, passing through an emulated e1000: 1. Emulate the device at L(n) for L(n+1)

Re: [PATCH V2 7/8] KVM: PPC: Introduce new hcall H_COPY_TOFROM_GUEST to access quadrants 1 & 2

2018-12-13 Thread Suraj Jitindar Singh
On Thu, 2018-12-13 at 16:24 +1100, Paul Mackerras wrote: > On Mon, Dec 10, 2018 at 02:58:24PM +1100, Suraj Jitindar Singh wrote: > > A guest cannot access quadrants 1 or 2 as this would result in an > > exception. Thus introduce the hcall H_COPY_TOFROM_GUEST to be used > > by a > > guest when it wa

Re: [PATCH] powerpc/mm: make NULL pointer deferences explicit on bad page faults.

2018-12-13 Thread Michael Ellerman
Hi Christophe, You know it's the trivial patches that are going to get lots of review comments :) Christophe Leroy writes: > As several other arches including x86, this patch makes it explicit > that a bad page fault is a NULL pointer dereference when the fault > address is lower than PAGE_SIZE

Re: [PATCH v1 2/2] powerpc/pseries: Add debugfs interface to retrieve VPHN info

2018-12-13 Thread Michael Ellerman
Hi Naveen, "Naveen N. Rao" writes: > Hi Michael, > > Naveen N. Rao wrote: >> Add debugfs interface to retrieve associativity information for lpar >> vcpus (debugfs/vphn/lpar) and the hypervisor cpus (debugfs/vphn/hyp). >> This information is useful to derive various metrics, including the vcpu >>

[PATCH] kernel/dma/direct: Do not include SME mask in the DMA supported check

2018-12-13 Thread Lendacky, Thomas
The dma_direct_supported() function intends to check the DMA mask against specific values. However, the phys_to_dma() function includes the SME encryption mask, which defeats the intended purpose of the check. This results in drivers that support less than 48-bit DMA (SME encryption mask is bit 47)

Re: use generic DMA mapping code in powerpc V4

2018-12-13 Thread Christian Zigotzky
On 13 December 2018 at 6:48PM, Christian Zigotzky wrote: On 13 December 2018 at 2:34PM, Christian Zigotzky wrote: On 13 December 2018 at 12:25PM, Christoph Hellwig wrote: On Thu, Dec 13, 2018 at 12:19:26PM +0100, Christian Zigotzky wrote: I tried it again but I get the following error message:

[PATCH v6 24/27] syscall_get_arch: add "struct task_struct *" argument

2018-12-13 Thread Dmitry V. Levin
This argument is required to extend the generic ptrace API with PTRACE_GET_SYSCALL_INFO request: syscall_get_arch() is going to be called from ptrace_request() along with syscall_get_nr(), syscall_get_arguments(), syscall_get_error(), and syscall_get_return_value() functions with a tracee as their

[PATCH v6 00/27] ptrace: add PTRACE_GET_SYSCALL_INFO request

2018-12-13 Thread Dmitry V. Levin
PTRACE_GET_SYSCALL_INFO is a generic ptrace API that lets ptracer obtain details of the syscall the tracee is blocked in. There are two reasons for a special syscall-related ptrace request. Firstly, with the current ptrace API there are cases when ptracer cannot retrieve necessary information abo

Re: [PATCH] dma-direct: Fix return value of dma_direct_supported

2018-12-13 Thread Christoph Hellwig
On Thu, Dec 13, 2018 at 07:45:57PM +, Lendacky, Thomas wrote: > So I think this needs to be __phys_to_dma() here. I only recently got a > system that had a device where the driver only supported 32-bit DMA and > found that when SME is active this returns 0 and causes the driver to fail > to ini

Re: [PATCH] dma-direct: Fix return value of dma_direct_supported

2018-12-13 Thread Lendacky, Thomas
On 10/04/2018 10:13 AM, Alexander Duyck wrote: > On Thu, Oct 4, 2018 at 4:25 AM Robin Murphy wrote: >> >> On 04/10/18 00:48, Alexander Duyck wrote: >>> It appears that in commit 9d7a224b463e ("dma-direct: always allow dma mask >>> <= physiscal memory size") the logic of the test was changed from a

[PATCH 2/2] s390/pci: handle function enumeration after sriov enablement

2018-12-13 Thread Sebastian Ott
Implement pcibios_sriov_{add|del}_vfs as empty functions. VF creation will be triggered by the hotplug code. Signed-off-by: Sebastian Ott --- arch/s390/pci/pci.c | 11 +++ 1 file changed, 11 insertions(+) diff --git a/arch/s390/pci/pci.c b/arch/s390/pci/pci.c index 9f6f392a4461..b5f8db6

[PATCH 1/2] PCI: provide pcibios_sriov_add_vfs

2018-12-13 Thread Sebastian Ott
Move VF detection and device creation code to weak functions such that architectures can provide a different implementation. Signed-off-by: Sebastian Ott --- drivers/pci/iov.c | 43 +++ include/linux/pci.h | 2 ++ 2 files changed, 33 insertions(+), 12 d

Re: use generic DMA mapping code in powerpc V4

2018-12-13 Thread Christian Zigotzky
On 13 December 2018 at 2:34PM, Christian Zigotzky wrote: On 13 December 2018 at 12:25PM, Christoph Hellwig wrote: On Thu, Dec 13, 2018 at 12:19:26PM +0100, Christian Zigotzky wrote: I tried it again but I get the following error message: MODPOST vmlinux.o arch/powerpc/kernel/dma-iommu.o: In fu

[PATCH v6 25/27] powerpc/ptrace: replace ptrace_report_syscall() with a tracehook call

2018-12-13 Thread Dmitry V. Levin
From: Elvira Khabirova Arch code should use tracehook_*() helpers, as documented in include/linux/tracehook.h, ptrace_report_syscall() is not expected to be used outside that file. The patch does not look very nice, but at least it is correct and opens the way for PTRACE_GET_SYSCALL_INFO API. C

[PATCH v6 18/27] powerpc: define syscall_get_error()

2018-12-13 Thread Dmitry V. Levin
syscall_get_error() is required to be implemented on this architecture in addition to already implemented syscall_get_nr(), syscall_get_arguments(), syscall_get_return_value(), and syscall_get_arch() functions in order to extend the generic ptrace API with PTRACE_GET_SYSCALL_INFO request. Cc: Mich

Re: [PATCH v1 03/13] powerpc/mm/32s: rework mmu_mapin_ram()

2018-12-13 Thread Christophe Leroy
Hi Again, Le 13/12/2018 à 13:16, Christophe Leroy a écrit : Hi, On 12/03/2018 09:55 PM, Jonathan Neuschäfer wrote: Hi, On Thu, Nov 29, 2018 at 07:00:16PM +, Christophe Leroy wrote: This patch reworks mmu_mapin_ram() to be more generic and map as much blocks as possible. It now supports b

[PATCH] powerpc/prom: fix early DEBUG messages

2018-12-13 Thread Christophe Leroy
This patch fixes early DEBUG messages in prom.c: - Use %px instead of %p to see the addresses - Use %x instead of %llx when phys_addr_t is not 64 bits. Signed-off-by: Christophe Leroy --- arch/powerpc/kernel/prom.c | 8 ++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/arch/

Re: use generic DMA mapping code in powerpc V4

2018-12-13 Thread Christian Zigotzky
On 13 December 2018 at 12:25PM, Christoph Hellwig wrote: On Thu, Dec 13, 2018 at 12:19:26PM +0100, Christian Zigotzky wrote: I tried it again but I get the following error message: MODPOST vmlinux.o arch/powerpc/kernel/dma-iommu.o: In function `.dma_iommu_get_required_mask': (.text+0x274): unde

Re: [PATCH v1 03/13] powerpc/mm/32s: rework mmu_mapin_ram()

2018-12-13 Thread Christophe Leroy
Hi, On 12/03/2018 09:55 PM, Jonathan Neuschäfer wrote: Hi, On Thu, Nov 29, 2018 at 07:00:16PM +, Christophe Leroy wrote: This patch reworks mmu_mapin_ram() to be more generic and map as much blocks as possible. It now supports blocks not starting at address 0. It scans DBATs array to find

Re: use generic DMA mapping code in powerpc V4

2018-12-13 Thread Christoph Hellwig
On Thu, Dec 13, 2018 at 12:19:26PM +0100, Christian Zigotzky wrote: > I tried it again but I get the following error message: > > MODPOST vmlinux.o > arch/powerpc/kernel/dma-iommu.o: In function `.dma_iommu_get_required_mask': > (.text+0x274): undefined reference to `.dma_direct_get_required_mask'

Re: use generic DMA mapping code in powerpc V4

2018-12-13 Thread Christian Zigotzky
On 13 December 2018 at 10:47AM, Christian Zigotzky wrote: On 13 December 2018 at 10:10AM, Christoph Hellwig wrote: On Thu, Dec 13, 2018 at 09:41:50AM +0100, Christian Zigotzky wrote: Today I tried the first patch (0001-get_required_mask.patch) with the last good commit (977706f9755d2d697aa6f45b

Re: [PATCH v1 2/2] powerpc/pseries: Add debugfs interface to retrieve VPHN info

2018-12-13 Thread Naveen N. Rao
Hi Michael, Naveen N. Rao wrote: Add debugfs interface to retrieve associativity information for lpar vcpus (debugfs/vphn/lpar) and the hypervisor cpus (debugfs/vphn/hyp). This information is useful to derive various metrics, including the vcpu dispatch statistics in a SPLPAR environment. Any

Re: use generic DMA mapping code in powerpc V4

2018-12-13 Thread Christian Zigotzky
On 13 December 2018 at 10:10AM, Christoph Hellwig wrote: On Thu, Dec 13, 2018 at 09:41:50AM +0100, Christian Zigotzky wrote: Today I tried the first patch (0001-get_required_mask.patch) with the last good commit (977706f9755d2d697aa6f45b4f9f0e07516efeda). Unfortunately this patch is already incl

Re: use generic DMA mapping code in powerpc V4

2018-12-13 Thread Christoph Hellwig
On Thu, Dec 13, 2018 at 09:41:50AM +0100, Christian Zigotzky wrote: > Today I tried the first patch (0001-get_required_mask.patch) with the last > good commit (977706f9755d2d697aa6f45b4f9f0e07516efeda). Unfortunately this > patch is already included in the last good commit > (977706f9755d2d697aa

[PATCH v5 5/5] powerpc: generate uapi header and system call table files

2018-12-13 Thread Firoz Khan
System call table generation script must be run to gener- ate unistd_32/64.h and syscall_table_32/64/c32/spu.h files. This patch will have changes which will invokes the script. This patch will generate unistd_32/64.h and syscall_table- _32/64/c32/spu.h files by the syscall table generation script

[PATCH v5 4/5] powerpc: split compat syscall table out from native table

2018-12-13 Thread Firoz Khan
PowerPC uses a syscall table with native and compat calls interleaved, which is a slightly simpler way to define two matching tables. As we move to having the tables generated, that advantage is no longer important, but the interleaved table gets in the way of using the same scripts as on the othe

[PATCH v5 3/5] powerpc: add system call table generation support

2018-12-13 Thread Firoz Khan
The system call tables are in different format in all architecture and it will be difficult to manually add or modify the system calls in the respective files. To make it easy by keeping a script and which will generate the uapi header and syscall table file. This change will also help to unify the

[PATCH v5 2/5] powerpc: move macro definition from asm/systbl.h

2018-12-13 Thread Firoz Khan
Move the macro definition for compat_sys_sigsuspend from asm/systbl.h to the file which it is getting included. One of the patch in this patch series is generating uapi header and syscall table files. In order to come up with a common implimentation across all architecture, we need to do this chan

[PATCH v5 1/5] powerpc: add __NR_syscalls along with NR_syscalls

2018-12-13 Thread Firoz Khan
NR_syscalls macro holds the number of system call exist in powerpc architecture. We have to change the value of NR_syscalls, if we add or delete a system call. One of the patch in this patch series has a script which will generate a uapi header based on syscall.tbl file. The syscall.tbl file conta

[PATCH v5 0/5] powerpc: system call table generation support

2018-12-13 Thread Firoz Khan
The purpose of this patch series is, we can easily add/modify/delete system call table support by cha- nging entry in syscall.tbl file instead of manually changing many files. The other goal is to unify the system call table generation support implementation across all the architectures. The sy

Re: use generic DMA mapping code in powerpc V4

2018-12-13 Thread Christian Zigotzky
On 12 December 2018 at 3:39PM, Christian Zigotzky wrote: Hi Christoph, Thanks a lot for your reply. I will test your patches tomorrow. Cheers, Christian Sent from my iPhone On 12. Dec 2018, at 15:15, Christoph Hellwig wrote: Thanks for bisecting. I've spent some time going over the conver

Re: [PATCH] powerpc/8xx: hide itlbie and dtlbie symbols

2018-12-13 Thread Christophe Leroy
Le 12/12/2018 à 14:05, Michael Ellerman a écrit : Christophe Leroy writes: When disassembling InstructionTLBError we get the following messy code: c000138c: 7d 84 63 78 mr r4,r12 c0001390: 75 25 58 00 andis. r5,r9,22528 c0001394: 75 2a 40 00 andis. r10,

[PATCH v2] powerpc/8xx: hide itlbie and dtlbie symbols

2018-12-13 Thread Christophe Leroy
When disassembling InstructionTLBError we get the following messy code: c000138c: 7d 84 63 78 mr r4,r12 c0001390: 75 25 58 00 andis. r5,r9,22528 c0001394: 75 2a 40 00 andis. r10,r9,16384 c0001398: 41 a2 00 08 beq c00013a0 c000139c: 7c 00 22