[PATCH v6 11/24] goldish_pipe: convert to pin_user_pages() and put_user_page()

2019-11-19 Thread John Hubbard
1. Call the new global pin_user_pages_fast(), from pin_goldfish_pages(). 2. As required by pin_user_pages(), release these pages via put_user_page(). In this case, do so via put_user_pages_dirty_lock(). That has the side effect of calling set_page_dirty_lock(), instead of set_page_dirty(). This

[PATCH v6 15/24] fs/io_uring: set FOLL_PIN via pin_user_pages()

2019-11-19 Thread John Hubbard
Convert fs/io_uring to use the new pin_user_pages() call, which sets FOLL_PIN. Setting FOLL_PIN is now required for code that requires tracking of pinned pages, and therefore for any code that calls put_user_page(). In partial anticipation of this work, the io_uring code was already calling

[PATCH v6 20/24] powerpc: book3s64: convert to pin_user_pages() and put_user_page()

2019-11-19 Thread John Hubbard
1. Convert from get_user_pages() to pin_user_pages(). 2. As required by pin_user_pages(), release these pages via put_user_page(). In this case, do so via put_user_pages_dirty_lock(). That has the side effect of calling set_page_dirty_lock(), instead of set_page_dirty(). This is probably more

[PATCH v6 01/24] mm/gup: pass flags arg to __gup_device_* functions

2019-11-19 Thread John Hubbard
A subsequent patch requires access to gup flags, so pass the flags argument through to the __gup_device_* functions. Also placate checkpatch.pl by shortening a nearby line. Reviewed-by: Jan Kara Reviewed-by: Jérôme Glisse Reviewed-by: Ira Weiny Cc: Kirill A. Shutemov Signed-off-by: John

[PATCH v6 03/24] mm/gup: move try_get_compound_head() to top, fix minor issues

2019-11-19 Thread John Hubbard
An upcoming patch uses try_get_compound_head() more widely, so move it to the top of gup.c. Also fix a tiny spelling error and a checkpatch.pl warning. Reviewed-by: Jan Kara Reviewed-by: Ira Weiny Signed-off-by: John Hubbard --- mm/gup.c | 29 +++-- 1 file changed, 15

[PATCH v6 08/24] media/v4l2-core: set pages dirty upon releasing DMA buffers

2019-11-19 Thread John Hubbard
After DMA is complete, and the device and CPU caches are synchronized, it's still required to mark the CPU pages as dirty, if the data was coming from the device. However, this driver was just issuing a bare put_page() call, without any set_page_dirty*() call. Fix the problem, by calling

[PATCH v6 14/24] drm/via: set FOLL_PIN via pin_user_pages_fast()

2019-11-19 Thread John Hubbard
Convert drm/via to use the new pin_user_pages_fast() call, which sets FOLL_PIN. Setting FOLL_PIN is now required for code that requires tracking of pinned pages, and therefore for any code that calls put_user_page(). In partial anticipation of this work, the drm/via driver was already calling

[PATCH v6 12/24] IB/{core, hw, umem}: set FOLL_PIN via pin_user_pages*(), fix up ODP

2019-11-19 Thread John Hubbard
Convert infiniband to use the new pin_user_pages*() calls. Also, revert earlier changes to Infiniband ODP that had it using put_user_page(). ODP is "Case 3" in Documentation/core-api/pin_user_pages.rst, which is to say, normal get_user_pages() and put_page() is the API to use there. The new

[PATCH v6 21/24] mm/gup_benchmark: use proper FOLL_WRITE flags instead of hard-coding "1"

2019-11-19 Thread John Hubbard
Fix the gup benchmark flags to use the symbolic FOLL_WRITE, instead of a hard-coded "1" value. Also, clean up the filtering of gup flags a little, by just doing it once before issuing any of the get_user_pages*() calls. This makes it harder to overlook, instead of having little "gup_flags & 1"

[PATCH v6 24/24] mm, tree-wide: rename put_user_page*() to unpin_user_page*()

2019-11-19 Thread John Hubbard
In order to provide a clearer, more symmetric API for pinning and unpinning DMA pages. This way, pin_user_pages*() calls match up with unpin_user_pages*() calls, and the API is a lot closer to being self-explanatory. Signed-off-by: John Hubbard --- Documentation/core-api/pin_user_pages.rst |

[PATCH v6 02/24] mm/gup: factor out duplicate code from four routines

2019-11-19 Thread John Hubbard
There are four locations in gup.c that have a fair amount of code duplication. This means that changing one requires making the same changes in four places, not to mention reading the same code four times, and wondering if there are subtle differences. Factor out the common code into static

[PATCH v6 13/24] mm/process_vm_access: set FOLL_PIN via pin_user_pages_remote()

2019-11-19 Thread John Hubbard
Convert process_vm_access to use the new pin_user_pages_remote() call, which sets FOLL_PIN. Setting FOLL_PIN is now required for code that requires tracking of pinned pages. Also, release the pages via put_user_page*(). Also, rename "pages" to "pinned_pages", as this makes for easier reading of

[PATCH v6 17/24] mm/gup: track FOLL_PIN pages

2019-11-19 Thread John Hubbard
Add tracking of pages that were pinned via FOLL_PIN. As mentioned in the FOLL_PIN documentation, callers who effectively set FOLL_PIN are required to ultimately free such pages via put_user_page(). The effect is similar to FOLL_GET, and may be thought of as "FOLL_GET for DIO and/or RDMA use".

[PATCH v6 22/24] mm/gup_benchmark: support pin_user_pages() and related calls

2019-11-19 Thread John Hubbard
Up until now, gup_benchmark supported testing of the following kernel functions: * get_user_pages(): via the '-U' command line option * get_user_pages_longterm(): via the '-L' command line option * get_user_pages_fast(): as the default (no options required) Add test coverage for the new

Re: [PATCH 03/12] powerpc: Replace cpu_up/down with device_online/offline

2019-11-19 Thread Qais Yousef
On 11/19/19 12:19, Michael Ellerman wrote: > Qais Yousef writes: > > The core device API performs extra housekeeping bits that are missing > > from directly calling cpu_up/down. > > > > See commit a6717c01ddc2 ("powerpc/rtas: use device model APIs and > > serialization during LPM") for an example

[PATCH v6 00/24] mm/gup: track dma-pinned pages: FOLL_PIN

2019-11-19 Thread John Hubbard
Hi, Christoph Hellwig has a preference to do things a little differently, for the devmap cleanup in patch 5 ("mm: devmap: refactor 1-based refcounting for ZONE_DEVICE pages"). That came up in a different review thread, because the patch is out for review in two locations. Here's that review

[PATCH v6 05/24] mm: devmap: refactor 1-based refcounting for ZONE_DEVICE pages

2019-11-19 Thread John Hubbard
An upcoming patch changes and complicates the refcounting and especially the "put page" aspects of it. In order to keep everything clean, refactor the devmap page release routines: * Rename put_devmap_managed_page() to page_is_devmap_managed(), and limit the functionality to "read only": return

[PATCH v6 16/24] net/xdp: set FOLL_PIN via pin_user_pages()

2019-11-19 Thread John Hubbard
Convert net/xdp to use the new pin_longterm_pages() call, which sets FOLL_PIN. Setting FOLL_PIN is now required for code that requires tracking of pinned pages. In partial anticipation of this work, the net/xdp code was already calling put_user_page() instead of put_page(). Therefore, in order to

[PATCH v6 19/24] vfio, mm: pin_user_pages (FOLL_PIN) and put_user_page() conversion

2019-11-19 Thread John Hubbard
1. Change vfio from get_user_pages_remote(), to pin_user_pages_remote(). 2. Because all FOLL_PIN-acquired pages must be released via put_user_page(), also convert the put_page() call over to put_user_pages_dirty_lock(). Note that this effectively changes the code's behavior in

Re: [PATCH v4 0/3] Append new variables to vmcoreinfo (TCR_EL1.T1SZ for arm64 and MAX_PHYSMEM_BITS for all archs)

2019-11-19 Thread Bhupesh Sharma
On Tue, Nov 19, 2019 at 12:03 PM Prabhakar Kushwaha wrote: > > Hi Akashi, > > On Fri, Nov 15, 2019 at 7:29 AM AKASHI Takahiro > wrote: > > > > Bhupesh, > > > > On Fri, Nov 15, 2019 at 01:24:17AM +0530, Bhupesh Sharma wrote: > > > Hi Akashi, > > > > > > On Wed, Nov 13, 2019 at 12:11 PM AKASHI

Re: [PATCH 1/3] dma-direct: unify the dma_capable definitions

2019-11-19 Thread Krzysztof Kozlowski
On Tue, 19 Nov 2019 at 17:27, Marek Szyprowski wrote: > > Hi Christoph, > > On 13.11.2019 08:35, Christoph Hellwig wrote: > > Currently each architectures that wants to override dma_to_phys and > > phys_to_dma also has to provide dma_capable. But there isn't really > > any good reason for that.

Re: [PATCH v11 1/4] kasan: support backing vmalloc space with real shadow memory

2019-11-19 Thread Andrey Ryabinin
On 11/18/19 6:29 AM, Daniel Axtens wrote: > Qian Cai writes: > >> On Thu, 2019-10-31 at 20:39 +1100, Daniel Axtens wrote: >>> /* >>> * In this function, newly allocated vm_struct has VM_UNINITIALIZED >>> * flag. It means that vm_struct is not fully initialized. >>> @@ -3377,6

[PATCH v6 07/24] IB/umem: use get_user_pages_fast() to pin DMA pages

2019-11-19 Thread John Hubbard
And get rid of the mmap_sem calls, as part of that. Note that get_user_pages_fast() will, if necessary, fall back to __gup_longterm_unlocked(), which takes the mmap_sem as needed. Reviewed-by: Jan Kara Reviewed-by: Jason Gunthorpe Reviewed-by: Ira Weiny Signed-off-by: John Hubbard ---

[PATCH v6 10/24] mm/gup: introduce pin_user_pages*() and FOLL_PIN

2019-11-19 Thread John Hubbard
Introduce pin_user_pages*() variations of get_user_pages*() calls, and also pin_longterm_pages*() variations. For now, these are placeholder calls, until the various call sites are converted to use the correct get_user_pages*() or pin_user_pages*() API. These variants will eventually all set

[PATCH v6 18/24] media/v4l2-core: pin_user_pages (FOLL_PIN) and put_user_page() conversion

2019-11-19 Thread John Hubbard
1. Change v4l2 from get_user_pages() to pin_user_pages(). 2. Because all FOLL_PIN-acquired pages must be released via put_user_page(), also convert the put_page() call over to put_user_pages_dirty_lock(). Acked-by: Hans Verkuil Cc: Ira Weiny Signed-off-by: John Hubbard ---

Re: [PATCH 1/3] dma-direct: unify the dma_capable definitions

2019-11-19 Thread Marek Szyprowski
Hi Christoph, On 13.11.2019 08:35, Christoph Hellwig wrote: > Currently each architectures that wants to override dma_to_phys and > phys_to_dma also has to provide dma_capable. But there isn't really > any good reason for that. powerpc and mips just have copies of the > generic one minus the

[PATCH v6 04/24] mm: Cleanup __put_devmap_managed_page() vs ->page_free()

2019-11-19 Thread John Hubbard
From: Dan Williams After the removal of the device-public infrastructure there are only 2 ->page_free() call backs in the kernel. One of those is a device-private callback in the nouveau driver, the other is a generic wakeup needed in the DAX case. In the hopes that all ->page_free() callbacks

[PATCH v6 09/24] vfio, mm: fix get_user_pages_remote() and FOLL_LONGTERM

2019-11-19 Thread John Hubbard
As it says in the updated comment in gup.c: current FOLL_LONGTERM behavior is incompatible with FAULT_FLAG_ALLOW_RETRY because of the FS DAX check requirement on vmas. However, the corresponding restriction in get_user_pages_remote() was slightly stricter than is actually required: it forbade all

[PATCH v6 06/24] goldish_pipe: rename local pin_user_pages() routine

2019-11-19 Thread John Hubbard
1. Avoid naming conflicts: rename local static function from "pin_user_pages()" to "pin_goldfish_pages()". An upcoming patch will introduce a global pin_user_pages() function. Reviewed-by: Jan Kara Reviewed-by: Jérôme Glisse Reviewed-by: Ira Weiny Signed-off-by: John Hubbard ---

[PATCH v6 23/24] selftests/vm: run_vmtests: invoke gup_benchmark with basic FOLL_PIN coverage

2019-11-19 Thread John Hubbard
It's good to have basic unit test coverage of the new FOLL_PIN behavior. Fortunately, the gup_benchmark unit test is extremely fast (a few milliseconds), so adding it the the run_vmtests suite is going to cause no noticeable change in running time. So, add two new invocations to run_vmtests: 1)

PCIPOCALYPSE

2019-11-19 Thread Oliver O'Halloran
This series does a few things and probably needs to be split into two or three smaller ones. I figured I'd post it as-is since I'm sick of sitting on it and some people wanted people to take a look at it. There's three parts: 1) Reworking EEH to move the "pseudo-generic" into the platform

[Very RFC 11/46] powerpc/eeh: Convert various printfs to use edev, not pci_dn

2019-11-19 Thread Oliver O'Halloran
We use the pci_dn to retrieve the domain, bus, device, and function numbers for an EEH device. We now have that in the eeh_dev so covert the various printk()s we have around the place to source that information from the eeh_dev. Signed-off-by: Oliver O'Halloran --- arch/powerpc/kernel/eeh.c

[Very RFC 26/46] powernv/pci: Remove pdn from pnv_pci_cfg_{read|write}

2019-11-19 Thread Oliver O'Halloran
Remove the use of pci_dn from the low-level config space access functions. These are used by the eeh's config ops and the bus config ops that we provide to the PCI core. Signed-off-by: Oliver O'Halloran --- arch/powerpc/platforms/powernv/eeh-powernv.c | 14 +++

[Very RFC 25/46] powernv/pci: Remove pdn from pnv_pci_config_check_eeh()

2019-11-19 Thread Oliver O'Halloran
Despite the name this function is generic PowerNV PCI code rather than anything EEH specific. Convert to take a phb and bdfn rather than a pci_dn. Signed-off-by: Oliver O'Halloran --- arch/powerpc/platforms/powernv/pci.c | 32 ++-- 1 file changed, 21 insertions(+), 11

[Very RFC 32/46] powernv/pci: Remove open-coded PE lookup in iommu_bypass_supported()

2019-11-19 Thread Oliver O'Halloran
Signed-off-by: Oliver O'Halloran --- arch/powerpc/platforms/powernv/pci-ioda.c | 6 ++ 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c b/arch/powerpc/platforms/powernv/pci-ioda.c index 98d858999a2d..7e88de18ead6 100644 ---

[Very RFC 45/46] powernv/pci: Remove requirement for a pdn in config accessors

2019-11-19 Thread Oliver O'Halloran
:toot: Signed-off-by: Oliver O'Halloran --- arch/powerpc/platforms/powernv/pci.c | 10 -- 1 file changed, 10 deletions(-) diff --git a/arch/powerpc/platforms/powernv/pci.c b/arch/powerpc/platforms/powernv/pci.c index 0eeea8652426..6383dcfec606 100644 ---

[PATCH RESEND v17 04/13] namei: allow set_root() to produce errors

2019-11-19 Thread Aleksa Sarai
For LOOKUP_BENEATH and LOOKUP_IN_ROOT it is necessary to ensure that set_root() is never called, and thus (for hardening purposes) it should return an error rather than permit a breakout from the root. In addition, move all of the repetitive set_root() calls to nd_jump_root(). Signed-off-by:

[PATCH RESEND v17 11/13] open: introduce openat2(2) syscall

2019-11-19 Thread Aleksa Sarai
/* Background. */ For a very long time, extending openat(2) with new features has been incredibly frustrating. This stems from the fact that openat(2) is possibly the most famous counter-example to the mantra "don't silently accept garbage from userspace" -- it doesn't check whether unknown flags

Re: [PATCH v3 15/15] powerpc/32s: Activate CONFIG_VMAP_STACK

2019-11-19 Thread Christophe Leroy
Michael Ellerman a écrit : Christophe Leroy writes: A few changes to retrieve DAR and DSISR from struct regs instead of retrieving them directly, as they may have changed due to a TLB miss. Also modifies hash_page() and friends to work with virtual data addresses instead of physical ones.

Re: [PATCH v2 1/2] kasan: support instrumented bitops combined with generic bitops

2019-11-19 Thread Daniel Axtens
> But the docs do seem to indicate that it's atomic (for whatever that > means for a single read operation?), so you are right, it should live in > instrumented-atomic.h. Actually, on further inspection, test_bit has lived in bitops/non-atomic.h since it was added in 4117b02132d1 ("[PATCH]

[Very RFC 01/46] powerpc/eeh: Don't attempt to restore VF config space after reset

2019-11-19 Thread Oliver O'Halloran
After resetting a VF we call eeh_restore_vf_config() to restore several registers in the VFs config space. For physical functions this is normally handled by the pci_reinit_device() OPAL call which requests firmware to re-program the device with whatever defaults were set at boot time. We can't

[Very RFC 15/46] powernv/eeh: Use pnv_eeh_*_config() for internal config ops

2019-11-19 Thread Oliver O'Halloran
Use the pnv_eeh_{read|write}_config() functions that take an edev rather than a pci_dn. This allows us to remove most of the explict uses of pci_dn in the PowerNV EEH backend and localises them into a few functions which we can fix later. Signed-off-by: Oliver O'Halloran ---

[Very RFC 23/46] powerpc/eeh: Moving finding the parent PE into the platform

2019-11-19 Thread Oliver O'Halloran
Currently the generic EEH code uses the pci_dn of a device to look up the PE of the device's parent bridge, or physical function. The generic function to insert the edev (and possibly create the eeh_pe) is called from the probe functions already so this is a relatively minor change. The existing

[Very RFC 22/46] powernv/eeh: Allocate eeh_dev's when needed

2019-11-19 Thread Oliver O'Halloran
Have the PowerNV EEH backend allocate the eeh_dev if needed rather than using the one attached to the pci_dn. This gets us most of the way towards decoupling pci_dn from the PowerNV EEH code. Signed-off-by: Oliver O'Halloran --- We should probably be free()ing the eeh_dev somewhere. The pci_dev

[Very RFC 35/46] powernv/pci: Remove open-coded PE lookup in pnv_pci_release_device

2019-11-19 Thread Oliver O'Halloran
Signed-off-by: Oliver O'Halloran --- arch/powerpc/platforms/powernv/pci-ioda.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c b/arch/powerpc/platforms/powernv/pci-ioda.c index 4f38652c7cd7..8525642b1256 100644 ---

[PATCH RESEND v17 07/13] namei: LOOKUP_NO_XDEV: block mountpoint crossing

2019-11-19 Thread Aleksa Sarai
/* Background. */ The need to contain path operations within a mountpoint has been a long-standing usecase that userspace has historically implemented manually with liberal usage of stat(). find, rsync, tar and many other programs implement these semantics -- but it'd be much simpler to have a

[PATCH v2] powerpc: Add const qual to local_read() parameter

2019-11-19 Thread Michael Ellerman
From: Eric Dumazet A patch in net-next triggered a compile error on powerpc: include/linux/u64_stats_sync.h: In function 'u64_stats_read': include/asm-generic/local64.h:30:37: warning: passing argument 1 of 'local_read' discards 'const' qualifier from pointer target type This seems

[Very RFC 10/46] powerpc/eeh: Pass eeh_dev to eeh_ops->restore_config()

2019-11-19 Thread Oliver O'Halloran
Remove another pdn usage. Signed-off-by: Oliver O'Halloran --- arch/powerpc/include/asm/eeh.h | 2 +- arch/powerpc/kernel/eeh.c| 5 ++--- arch/powerpc/kernel/eeh_pe.c | 6 ++ arch/powerpc/platforms/powernv/eeh-powernv.c | 11 +--

[Very RFC 17/46] powernv/eeh: add pnv_eeh_find_edev()

2019-11-19 Thread Oliver O'Halloran
To get away from using pci_dn we need a way to find the edev for a given bdfn. The easiest way to do this is to find the ioda_pe for that BDFN in the PHB's reverse mapping table and scan the device list of the corresponding eeh_pe. Is this slow? Yeah probably. Is it slower than the existing

[Very RFC 34/46] powernv/pci: Remove open-coded PE lookup in pnv_pci_enable_device_hook()

2019-11-19 Thread Oliver O'Halloran
Signed-off-by: Oliver O'Halloran --- arch/powerpc/platforms/powernv/pci-ioda.c | 7 +-- 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c b/arch/powerpc/platforms/powernv/pci-ioda.c index 7e88de18ead6..4f38652c7cd7 100644 ---

[Very RFC 33/46] powernv/pci: Remove open-coded PE lookup in iommu notifier

2019-11-19 Thread Oliver O'Halloran
Signed-off-by: Oliver O'Halloran --- arch/powerpc/platforms/powernv/pci.c | 9 - 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/arch/powerpc/platforms/powernv/pci.c b/arch/powerpc/platforms/powernv/pci.c index 5b1f4677cdce..0eeea8652426 100644 ---

[Very RFC 46/46] HACK: prevent pdn's from being created

2019-11-19 Thread Oliver O'Halloran
Not-Signed-off-by: Oliver O'Halloran --- arch/powerpc/kernel/pci_dn.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/arch/powerpc/kernel/pci_dn.c b/arch/powerpc/kernel/pci_dn.c index f790a8d06f50..0e05c1d7633a 100644 --- a/arch/powerpc/kernel/pci_dn.c +++ b/arch/powerpc/kernel/pci_dn.c

Re: [PATCH v5 00/48] QUICC Engine support on ARM, ARM64, PPC64

2019-11-19 Thread Timur Tabi
On 11/18/19 5:22 AM, Rasmus Villemoes wrote: There have been several attempts in the past few years to allow building the QUICC engine drivers for platforms other than PPC32. This is yet another attempt. v4 can be found here:

[PATCH RESEND v17 10/13] namei: LOOKUP_{IN_ROOT, BENEATH}: permit limited ".." resolution

2019-11-19 Thread Aleksa Sarai
Allow LOOKUP_BENEATH and LOOKUP_IN_ROOT to safely permit ".." resolution (in the case of LOOKUP_BENEATH the resolution will still fail if ".." resolution would resolve a path outside of the root -- while LOOKUP_IN_ROOT will chroot(2)-style scope it). Magic-link jumps are still disallowed

[Very RFC 03/46] powernv/pci: Remove dma_dev_setup() for NPU PHBs

2019-11-19 Thread Oliver O'Halloran
The pnv_pci_dma_dev_setup() only does something when: 1) There PHB contains VFs, or 2) The PHB defines a dma_dev_setup() callback in the pnv_phb structure. Neither is true for NPU PHBs, so don't set the callback in the pci_controller_ops. Signed-off-by: Oliver O'Halloran ---

[Very RFC 02/46] powernv/pci: Add helper to find ioda_pe from BDFN

2019-11-19 Thread Oliver O'Halloran
Linux has a look-up table for mapping BDFNs to PEs which is updated when we call into OPAL to update the PHB's internally BDFN<->PE mapping. We can use this table to the PE for a device without needing to use the cached value inside the pci_dn. We'd like to get rid of pci_dn eventually so this

[Very RFC 14/46] powernv/eeh: Remove un-necessary call to eeh_add_device_early()

2019-11-19 Thread Oliver O'Halloran
eeh_add_device_early() is used to initialise the EEH state for a PCI device based on the contents of it's devicetree node. It doesn't do anything unless EEH_FLAG_PROBE_MODE_DEVTREE is set and that only happens on pseries. Remove the call to eeh_add_device_early() in the powernv code to squash

[PATCH RESEND v17 08/13] namei: LOOKUP_BENEATH: O_BENEATH-like scoped resolution

2019-11-19 Thread Aleksa Sarai
/* Background. */ There are many circumstances when userspace wants to resolve a path and ensure that it doesn't go outside of a particular root directory during resolution. Obvious examples include archive extraction tools, as well as other security-conscious userspace programs. FreeBSD spun out

[Very RFC 07/46] powernv/pci: Rework IODA PE device accounting

2019-11-19 Thread Oliver O'Halloran
The current process for configuring the IODA PEs for normal PCI devices is abit stupid. After assigning MMIO resources for the devices on a bus the actual PE asignment occurs when pcibios_setup_bridge() is called for the parent bridge. In pcibios_setup_bridge() we: 1. Assign all 256 devfn's for

[Very RFC 21/46] powernv/eeh: Rework finding an existing edev in probe_pdev()

2019-11-19 Thread Oliver O'Halloran
Use the pnv_eeh_find_edev() helper to look up the eeh_dev for a device rather than doing it via the pci_dn. Signed-off-by: Oliver O'Halloran --- arch/powerpc/platforms/powernv/eeh-powernv.c | 44 ++-- 1 file changed, 31 insertions(+), 13 deletions(-) diff --git

[Very RFC 24/46] powernv/pci: Make the pre-cfg EEH freeze check use eeh_dev rather than pci_dn

2019-11-19 Thread Oliver O'Halloran
Squash another usage in preperation for making the config accessors pci_dn. Signed-off-by: Oliver O'Halloran --- We might want to move this into eeh-powernv.c --- arch/powerpc/platforms/powernv/pci.c | 37 +--- 1 file changed, 17 insertions(+), 20 deletions(-) diff

[Very RFC 36/46] powernv/npu: Remove open-coded PE lookup for GPU device

2019-11-19 Thread Oliver O'Halloran
Signed-off-by: Oliver O'Halloran --- arch/powerpc/platforms/powernv/npu-dma.c | 13 ++--- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/arch/powerpc/platforms/powernv/npu-dma.c b/arch/powerpc/platforms/powernv/npu-dma.c index b95b9e3c4c98..68bfaef44862 100644 ---

[Very RFC 44/46] powerpc/pci: Don't set pdn->pe_number when applying the weird P8 NVLink PE hack

2019-11-19 Thread Oliver O'Halloran
P8 needs to shove four GPUs into three PEs for $reasons. Remove the pdn->pe_assignment done there since we just use the pe_rmap[] now. Signed-off-by: Oliver O'Halloran --- arch/powerpc/platforms/powernv/pci-ioda.c | 6 ++ 1 file changed, 2 insertions(+), 4 deletions(-) diff --git

Re: [RFC PATCH 1/4] libnvdimm/namespace: Make namespace size validation arch dependent

2019-11-19 Thread Aneesh Kumar K.V
On 11/19/19 11:28 PM, Dan Williams wrote: On Mon, Nov 18, 2019 at 1:52 AM Aneesh Kumar K.V wrote: Dan Williams writes: On Sat, Nov 16, 2019 at 4:15 AM Aneesh Kumar K.V wrote: Considering the direct-map map size is not going to be user selectable, do you agree that we can skip

[PATCH RESEND v17 02/13] nsfs: clean-up ns_get_path() signature to return int

2019-11-19 Thread Aleksa Sarai
ns_get_path() and ns_get_path_cb() only ever return either NULL or an ERR_PTR. It is far more idiomatic to simply return an integer, and it makes all of the callers of ns_get_path() more straightforward to read. Fixes: e149ed2b805f ("take the targets of /proc/*/ns/* symlinks to separate fs")

[Very RFC 04/46] powernv/pci: Move dma_{dev|bus}_setup into pci-ioda.c

2019-11-19 Thread Oliver O'Halloran
These functions are only used from pci-ioda.c. Move them in there and remove the prototypes from the header files. Signed-off-by: Oliver O'Halloran --- arch/powerpc/platforms/powernv/pci-ioda.c | 43 +++ arch/powerpc/platforms/powernv/pci.c | 43 ---

[Very RFC 18/46] powernv/pci: Add pci_bus_to_pnvhb() helper

2019-11-19 Thread Oliver O'Halloran
Add a helper to go from a pci_bus structure to the pnv_phb that hosts that bus. There's a lot of instances of the following pattern: struct pci_controller *hose = pci_bus_to_host(pdev->bus); struct pnv_phb *phb = hose->private_data; Without any other uses of the pci_controller

[Very RFC 19/46] powernv/eeh: Use standard PCI capability lookup functions

2019-11-19 Thread Oliver O'Halloran
We have a pci_dev so we can use the functions provided by the PCI core for looking up capabilities. This should be safe since these are only called when initialising the eeh_dev when the device is first probed and not in the EEH recovery path where config accesses are blocked. This might cause a

[Very RFC 27/46] powernv/pci: Clear reserved PE freezes

2019-11-19 Thread Oliver O'Halloran
When we scan an empty slot the PHB gets an Unsupported Request from the downstream bridge when there's no device present at that BDFN. Some older PHBs (p7-IOC) don't allow further config space accesses while the PE is frozen, so clear it here without bothering with the diagnostic log.

[Very RFC 42/46] powernv/pci: Don't clear pdn->pe_number in pnv_pci_release_device

2019-11-19 Thread Oliver O'Halloran
Nothing looks at it anymore. Signed-off-by: Oliver O'Halloran --- arch/powerpc/platforms/powernv/pci-ioda.c | 12 1 file changed, 12 deletions(-) diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c b/arch/powerpc/platforms/powernv/pci-ioda.c index d3e375d71cdc..45d940730c30

[Very RFC 43/46] powernv/pci: Do not set pdn->pe_number for NPU/CAPI devices

2019-11-19 Thread Oliver O'Halloran
The only thing we need the pdn for in this function is setting the pe_number field, which we don't use anymore. Fix the weird refcounting behaviour while we're here. Signed-off-by: Oliver O'Halloran --- Either Fred, or Reza also fixed this in some patch lately and that'll probably get merged

[PATCH RESEND v17 06/13] namei: LOOKUP_NO_MAGICLINKS: block magic-link resolution

2019-11-19 Thread Aleksa Sarai
/* Background. */ There has always been a special class of symlink-like objects in procfs (and a few other pseudo-filesystems) which allow for non-lexical resolution of paths using nd_jump_link(). These "magic-links" do not follow traditional mount namespace boundaries, and have been used

[PATCH RESEND v17 05/13] namei: LOOKUP_NO_SYMLINKS: block symlink resolution

2019-11-19 Thread Aleksa Sarai
/* Background. */ Userspace cannot easily resolve a path without resolving symlinks, and would have to manually resolve each path component with O_PATH and O_NOFOLLOW. This is clearly inefficient, and can be fairly easy to screw up (resulting in possible security bugs). Linus has mentioned that

[PATCH RESEND v17 13/13] Documentation: path-lookup: include new LOOKUP flags

2019-11-19 Thread Aleksa Sarai
Now that we have new LOOKUP flags, we should document them in the relevant path-walking documentation. And now that we've settled on a common name for nd_jump_link() style symlinks ("magic links"), use that term where magic-link semantics are described. Signed-off-by: Aleksa Sarai ---

[Very RFC 12/46] powerpc/eeh: Split eeh_probe into probe_pdn and probe_pdev

2019-11-19 Thread Oliver O'Halloran
The EEH core has a concept of "early probe" and "late probe." When the EEH_PROBE_MODE_DEVTREE flag is set (i.e pseries) we call the eeh_ops->probe() function in eeh_add_device_early() so the eeh_dev state is initialised based on the pci_dn. It's important to realise that this happens *long* before

[Very RFC 13/46] powerpc/eeh: Rework how pdev_probe() is used

2019-11-19 Thread Oliver O'Halloran
Adjust how the EEH core uses the eeh_ops->probe_pdev() so that it returns the eeh_dev for the passed-in pci_dev. Currently mapping an pci_dev to an eeh_dev is done by finding the pci_dn for the pci_dev, then using the back-pointer to the eeh_dev stashed in the pci_dn. We want to move away from

[Very RFC 28/46] powernv/iov: Move SR-IOV PF state out of pci_dn

2019-11-19 Thread Oliver O'Halloran
Move the SR-IOV into a platform specific structure. I'm sure stashing all the SR-IOV state in pci_dn seemed like a good idea at the time, but it results in a lot of powernv specifics being leaked out of the platform directory. Moving all the PHB3/4 specific M64 BAR wrangling into a PowerNV

[Very RFC 37/46] powernv/pci: Use the PHB's rmap for pnv_ioda_to_pe()

2019-11-19 Thread Oliver O'Halloran
Rather than using the pdn->pe_number for a device as an index into the IODA PE array we can use the reverse map. This maps the RID (i.e. bdfn) to the PE number associated with it. Firmware maintains a copy of the rmap which is used by the hardware for determining which PE to use when handling a

[PATCH RESEND v17 01/13] namei: only return -ECHILD from follow_dotdot_rcu()

2019-11-19 Thread Aleksa Sarai
It's over-zealous to return hard errors under RCU-walk here, given that a REF-walk will be triggered for all other cases handling ".." under RCU. The original purpose of this check was to ensure that if a rename occurs such that a directory is moved outside of the bind-mount which the resolution

[PATCH RESEND v17 12/13] selftests: add openat2(2) selftests

2019-11-19 Thread Aleksa Sarai
Test all of the various openat2(2) flags. A small stress-test of a symlink-rename attack is included to show that the protections against ".."-based attacks are sufficient. The main things these self-tests are enforcing are: * The struct+usize ABI for openat2(2) and copy_struct_from_user() to

[Very RFC 09/46] powerpc/eeh: Pass eeh_dev to eeh_ops->{read|write}_config()

2019-11-19 Thread Oliver O'Halloran
Switch the eeh_ops->{read|write}_config methods to take an eeh_dev structure rather than a pci_dn structure to specify the target device. This removes a lot of the uses of pci_dn in both the EEH core and in the platform EEH support. Signed-off-by: Oliver O'Halloran ---

[Very RFC 08/46] powerpc/eeh: Calculate VF index rather than looking it up in pci_dn

2019-11-19 Thread Oliver O'Halloran
Find the VF index based on the BDFN of the device rather than using a cached value in the pci_dn. This is probably slower than looking up the cached value in the pci_dn, but it's done infrequently (only in the EEH recovery path) and it's just arithmatic. We need this here because the functions to

[Very RFC 20/46] powernv/eeh: Look up device info from pci_dev

2019-11-19 Thread Oliver O'Halloran
Most of what we fetch from the pci_dn is also in the pci_dev structure. Convert the pnv_eeh_probe_pdev() to use the pdev fields rather than the pci_dn so we can get rid of pci_dn eventually. Signed-off-by: Oliver O'Halloran --- arch/powerpc/platforms/powernv/eeh-powernv.c | 26

[Very RFC 31/46] powernv/pci: Remove open-coded PE lookup in pnv_pci_ioda_dma_dev_setup()

2019-11-19 Thread Oliver O'Halloran
Use the helper to look up the pnv_ioda_pe for the device we're configuring DMA for. In the VF case there's no need set pdn->pe_number since nothing looks at it any more. Signed-off-by: Oliver O'Halloran --- arch/powerpc/platforms/powernv/pci-ioda.c | 3 +-- 1 file changed, 1 insertion(+), 2

[Very RFC 41/46] powernv/eeh: Remove pdn setup for SR-IOV VFs

2019-11-19 Thread Oliver O'Halloran
We don't need a pci_dn for the VF any more, so we can skip adding them. Signed-off-by: Oliver O'Halloran --- arch/powerpc/platforms/powernv/pci-ioda.c | 16 1 file changed, 16 deletions(-) diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c

[Very RFC 40/46] powernv/npu: Don't drop refcount when looking up GPU pci_devs

2019-11-19 Thread Oliver O'Halloran
The comment here implies that we don't need to take a ref to the pci_dev because the ioda_pe will always have one. This implies that the current expection is that the pci_dev for an NPU device will *never* be torn down since the ioda_pe having a ref to the device will prevent the release function

[PATCH] selftests/powerpc: spectre_v2 test must be built 64-bit

2019-11-19 Thread Michael Ellerman
The spectre_v2 test must be built 64-bit, it includes hand-written asm that is 64-bit only, and segfaults if built 32-bit. Fixes: c790c3d2b0ec ("selftests/powerpc: Add a test of spectre_v2 mitigations") Signed-off-by: Michael Ellerman --- tools/testing/selftests/powerpc/security/Makefile | 2 ++

Re: [PATCH v2] powerpc: Add const qual to local_read() parameter

2019-11-19 Thread Stephen Rothwell
Hi all, On Wed, 20 Nov 2019 12:14:51 +1100 Michael Ellerman wrote: > > From: Eric Dumazet > > A patch in net-next triggered a compile error on powerpc: > > include/linux/u64_stats_sync.h: In function 'u64_stats_read': > include/asm-generic/local64.h:30:37: warning: passing argument 1 of

Re: [RFC PATCH 1/4] libnvdimm/namespace: Make namespace size validation arch dependent

2019-11-19 Thread Dan Williams
On Tue, Nov 19, 2019 at 7:19 PM Aneesh Kumar K.V wrote: > > On 11/19/19 11:28 PM, Dan Williams wrote: > > On Mon, Nov 18, 2019 at 1:52 AM Aneesh Kumar K.V > > wrote: > >> > >> Dan Williams writes: > >> > >>> On Sat, Nov 16, 2019 at 4:15 AM Aneesh Kumar K.V > >>> wrote: > > >> > >> >

[PATCH RESEND v17 03/13] namei: allow nd_jump_link() to produce errors

2019-11-19 Thread Aleksa Sarai
In preparation for LOOKUP_NO_MAGICLINKS, it's necessary to add the ability for nd_jump_link() to return an error which the corresponding get_link() caller must propogate back up to the VFS. Suggested-by: Al Viro Signed-off-by: Aleksa Sarai --- fs/namei.c | 3 ++-

[PATCH V10] mm/debug: Add tests validating architecture page table helpers

2019-11-19 Thread Anshuman Khandual
This adds tests which will validate architecture page table helpers and other accessors in their compliance with expected generic MM semantics. This will help various architectures in validating changes to existing page table helpers or addition of new ones. This test covers basic page table

[PATCH] update to "kasan: support backing vmalloc space with real shadow memory"

2019-11-19 Thread Daniel Axtens
Hi Andrew, This is a quick fixup to patch 1 of the "kasan: support backing vmalloc space with real shadow memory" series, v11, which you pulled in to your mmotm tree. There are 2 changes: - A fixup to the per-cpu allocator path to avoid allocating memory under a spinlock, thanks Qian Cai.

Re: [PATCH 1/3] dma-direct: unify the dma_capable definitions

2019-11-19 Thread Marek Szyprowski
Hi On 19.11.2019 17:46, Christoph Hellwig wrote: > On Tue, Nov 19, 2019 at 11:26:39AM +0100, Marek Szyprowski wrote: >> Christoph: Let me know if this is a proper fix for you, then I will send >> it as a full patch. > Besides the point from Robin, which is really older than you patch > I'm not a

Re: [PATCH v6 15/24] fs/io_uring: set FOLL_PIN via pin_user_pages()

2019-11-19 Thread John Hubbard
On 11/19/19 8:10 AM, Jens Axboe wrote: > On 11/19/19 1:16 AM, John Hubbard wrote: >> Convert fs/io_uring to use the new pin_user_pages() call, which sets >> FOLL_PIN. Setting FOLL_PIN is now required for code that requires >> tracking of pinned pages, and therefore for any code that calls >>

Re: [PATCH v6 17/24] mm/gup: track FOLL_PIN pages

2019-11-19 Thread John Hubbard
On 11/19/19 3:37 AM, Jan Kara wrote: > On Tue 19-11-19 00:16:36, John Hubbard wrote: >> @@ -2025,6 +2149,20 @@ static int __record_subpages(struct page *page, >> unsigned long addr, >> return nr; >> } >> >> +static bool __pin_compound_head(struct page *head, int refs, unsigned int >>

[Very RFC 06/46] powerpc/iov: Move VF pdev fixup into pcibios_fixup_iov()

2019-11-19 Thread Oliver O'Halloran
Move this out of the PHB's dma_dev_setup() callback and into the ppc_md.pcibios_fixup_iov callback. This ensures that the VF PE's pdev pointer is always valid for the whole time the device is added the bus. This isn't strictly required, but it's slightly a slightly more logical place to do the

[Very RFC 05/46] powernv/pci: Remove the pnv_phb dma_dev_setup callback

2019-11-19 Thread Oliver O'Halloran
This is only ever set for IODA PHBs. The only call site is in pnv_pci_dma_dev_setup(), which is also only used by normal IODA PHBs, so remove the callback in favour of a direct call. Signed-off-by: Oliver O'Halloran --- arch/powerpc/platforms/powernv/pci-ioda.c | 4 +---

[Very RFC 16/46] powernv/eeh: Use eeh_edev_warn() rather than open-coding a BDFN print

2019-11-19 Thread Oliver O'Halloran
Neaten things up a bit and remove a pci_dn use. Signed-off-by: Oliver O'Halloran --- arch/powerpc/platforms/powernv/eeh-powernv.c | 6 ++ 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/arch/powerpc/platforms/powernv/eeh-powernv.c

[Very RFC 29/46] powernv/pci: Remove open-coded PE lookup in PELT-V setup

2019-11-19 Thread Oliver O'Halloran
Signed-off-by: Oliver O'Halloran --- arch/powerpc/platforms/powernv/pci-ioda.c | 32 +-- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c b/arch/powerpc/platforms/powernv/pci-ioda.c index 1c90feed233d..5bd7c1b058da

[Very RFC 30/46] powernv/pci: Remove open-coded PE lookup in PELT-V teardown

2019-11-19 Thread Oliver O'Halloran
Signed-off-by: Oliver O'Halloran --- arch/powerpc/platforms/powernv/pci-ioda.c | 12 +++- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c b/arch/powerpc/platforms/powernv/pci-ioda.c index 5bd7c1b058da..d4b5ee926222 100644 ---

  1   2   >