Re: [PATCH 1/2] sched/swait: allow swake_up() to return

2017-11-12 Thread Peter Xu
On Fri, Nov 10, 2017 at 09:05:20AM +0100, Peter Zijlstra wrote: > On Fri, Nov 10, 2017 at 03:10:17PM +0800, Peter Xu wrote: > > I came to this when reading kvm_vcpu_wake_up(), so that only affects > > some statistic which may not be that critical. However I don't know > &

Re: [PATCH 1/2] sched/swait: allow swake_up() to return

2017-11-12 Thread Peter Xu
On Mon, Nov 13, 2017 at 11:33:43AM +0800, Peter Xu wrote: > On Fri, Nov 10, 2017 at 09:05:20AM +0100, Peter Zijlstra wrote: > > On Fri, Nov 10, 2017 at 03:10:17PM +0800, Peter Xu wrote: > > > I came to this when reading kvm_vcpu_wake_up(), so that only affects > > > some

Re: [PATCH] vfio-pci: Disable binding to PFs with SR-IOV enabled

2018-07-12 Thread Peter Xu
re simply refuse to bind to PFs with SR-IOV enabled > with a warning message indicating the issue. Users can resolve this > by re-binding to the host driver and disabling SR-IOV before > attempting to use the device with vfio-pci. > > Signed-off-by: Alex Williamson Reviewed-by: Peter Xu -- Peter Xu

Re: [PATCH v10 2/4] fw_cfg: do DMA read operation

2018-01-23 Thread Peter Xu
pu_to_be64(virt_to_phys(address)), > + .length = cpu_to_be32(length), > + .control = cpu_to_be32(control) > + }; > + > + dma = virt_to_phys(d); > + > + iowrite32be((u64)dma >> 32, fw_cfg_reg_dma); > + iowrite32be(dma, fw_cfg_reg_dma + 4); We can do it with iowrite64be(virt_to_phys(d)) too? In all cases I think it's good enough and no worth for a repost. For the DMA transfer part: Acked-by: Peter Xu Thanks, -- Peter Xu

[PATCH] iommu/vt-d: use domain instead of cache fetching

2018-01-09 Thread Peter Xu
it's fixed as a side effect of commit 13cf01744608 ("iommu/vt-d: Make use of iova deferred flushing", 2017-08-15). But IMHO it's still good to have this patch upstream. CC: Alex Williamson Signed-off-by: Peter Xu --- drivers/iommu/intel-iommu.c | 3 +-- 1 file changed, 1 inse

[PATCH] fw_cfg: don't use DMA mapping for fw_cfg device

2018-01-15 Thread Peter Xu
_init+0x80/0x80 [1.018392] ---[ end trace d00a5b71608a8f59 ]--- Bug: https://bugzilla.redhat.com/show_bug.cgi?id=1533367 Fixes: e90cb816599b ("fw_cfg: do DMA read operation", 2017-11-28) CC: Marc-André Lureau CC: Michael S. Tsirkin Signed-off-by: Peter Xu -- This is ba

Re: [PATCH] fw_cfg: don't use DMA mapping for fw_cfg device

2018-01-15 Thread Peter Xu
On Mon, Jan 15, 2018 at 12:22:48PM +0100, Marc-Andre Lureau wrote: > Hi > > On Mon, Jan 15, 2018 at 9:55 AM, Peter Xu wrote: > > fw_cfg device does not need IOMMU protection, so use physical addresses > > always. That's how QEMU implements fw_cfg. Otherwise we

Re: [PATCH 3/3] vfio/pci: Add ioeventfd support

2018-03-06 Thread Peter Xu
ds_list); > > ret = vfio_add_group_dev(&pdev->dev, &vfio_pci_ops, vdev); > if (ret) { -- Peter Xu

Re: [PATCH 1/3] vfio/pci: Pull BAR mapping setup from read-write path

2018-03-06 Thread Peter Xu
On Wed, Feb 28, 2018 at 01:14:46PM -0700, Alex Williamson wrote: > This creates a common helper that we'll use for ioeventfd setup. > > Signed-off-by: Alex Williamson Reviewed-by: Peter Xu -- Peter Xu

Re: [PATCH v2] mm: mprotect: check page dirty when change ptes

2018-09-27 Thread Peter Xu
On Fri, Sep 14, 2018 at 08:41:57PM -0400, Jerome Glisse wrote: > On Fri, Sep 14, 2018 at 03:16:11PM +0800, Peter Xu wrote: > > On Thu, Sep 13, 2018 at 08:42:39PM -0400, Jerome Glisse wrote: > > > On Thu, Sep 13, 2018 at 10:23:28AM -0400, Jerome Glisse wrote: > > > >

Re: [PATCH v2] mm: mprotect: check page dirty when change ptes

2018-09-27 Thread Peter Xu
On Thu, Sep 27, 2018 at 03:56:52AM -0400, Jerome Glisse wrote: > On Thu, Sep 27, 2018 at 03:43:38PM +0800, Peter Xu wrote: > > On Fri, Sep 14, 2018 at 08:41:57PM -0400, Jerome Glisse wrote: > > > On Fri, Sep 14, 2018 at 03:16:11PM +0800, Peter Xu wrote: > > > > On T

[PATCH 1/3] userfaultfd: selftest: cleanup help messages

2018-09-29 Thread Peter Xu
Firstly, the help in the comment region is obsolete, now we support three parameters. Since at it, change it and move it into the help message of the program. Also, the help messages dumped here and there is obsolete too. Use a single usage() helper. Signed-off-by: Peter Xu --- tools/testing

[PATCH 3/3] userfaultfd: selftest: recycle lock threads first

2018-09-29 Thread Peter Xu
s for each lock operation. Signed-off-by: Peter Xu --- tools/testing/selftests/vm/userfaultfd.c | 11 ++- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/tools/testing/selftests/vm/userfaultfd.c b/tools/testing/selftests/vm/userfaultfd.c index f79706f13ce7..a388675b15af 1

[PATCH 0/3] userfaultfd: selftests: cleanups and trivial fixes

2018-09-29 Thread Peter Xu
Recently I wrote some uffd write-protection test for the not-yet-published uffd-wp tree, and I picked these common patches out first for the selftest which even suite for master. Any feedback is welcomed. Please have a look, thanks. Peter Xu (3): userfaultfd: selftest: cleanup help messages

[PATCH 2/3] userfaultfd: selftest: generalize read and poll

2018-09-29 Thread Peter Xu
d not check EAGAIN case in read() mode - ignored BOUNCE_VERIFY check in read() mode Signed-off-by: Peter Xu --- tools/testing/selftests/vm/userfaultfd.c | 76 +--- 1 file changed, 42 insertions(+), 34 deletions(-) diff --git a/tools/testing/selftests/vm/userfaultfd.c b/

[PATCH RFC v3 0/4] mm: some enhancements to the page fault mechanism

2018-11-20 Thread Peter Xu
The series is only lightly tested. Before running more tests, I'd be really glad to see whether there's any feedback first. Looking forward to your comments. Thanks, [1] https://git.kernel.org/pub/scm/linux/kernel/git/andrea/aa.git/commit/?h=userfault&id=b245ecf6cf59156966f3da6e

[PATCH RFC v3 3/4] mm: allow VM_FAULT_RETRY for multiple times

2018-11-20 Thread Peter Xu
. It might also benefit other potential users who will have similar requirement like userfault write-protection. Please read the thread below for more information. [1] https://lkml.org/lkml/2017/11/2/833 Suggested-by: Linus Torvalds Suggested-by: Andrea Arcangeli Signed-off-by: Peter Xu ---

[PATCH RFC v3 4/4] mm: gup: allow VM_FAULT_RETRY for multiple times

2018-11-20 Thread Peter Xu
This is the gup counterpart of the change that allows the VM_FAULT_RETRY to happen for more than once. Signed-off-by: Peter Xu --- mm/gup.c | 17 + 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/mm/gup.c b/mm/gup.c index a40111c742ba..7c3b3ab6be88 100644 --- a/mm

[PATCH RFC v3 1/4] mm: gup: rename "nonblocking" to "locked" where proper

2018-11-20 Thread Peter Xu
ter suite the functionality of the variable. While at it, fixing up some of the comments accordingly. Signed-off-by: Peter Xu --- mm/gup.c | 44 +--- mm/hugetlb.c | 8 2 files changed, 25 insertions(+), 27 deletions(-) diff --git a/mm/gup.c

[PATCH RFC v3 2/4] mm: userfault: return VM_FAULT_RETRY on signals

2018-11-20 Thread Peter Xu
contains a potential fix for a double-free of mmap_sem on ARC architecture; please see https://lkml.org/lkml/2018/11/1/723 for more information) Suggested-by: Linus Torvalds Suggested-by: Andrea Arcangeli Signed-off-by: Peter Xu --- arch/alpha/mm/fault.c | 2 +- arch/arc/mm/fault.c

[PATCH] mm: thp: fix soft dirty for migration when split

2018-12-06 Thread Peter Xu
drew Morton CC: "Kirill A. Shutemov" CC: Matthew Wilcox CC: Michal Hocko CC: Dave Jiang CC: "Aneesh Kumar K.V" CC: Souptick Joarder CC: Konstantin Khlebnikov CC: linux...@kvack.org CC: linux-kernel@vger.kernel.org Signed-off-by: Peter Xu --- I noticed this during code reading.

Re: [PATCH] mm: thp: fix soft dirty for migration when split

2018-12-06 Thread Peter Xu
On Thu, Dec 06, 2018 at 04:46:04PM +0800, Peter Xu wrote: > When splitting a huge migrating PMD, we'll transfer the soft dirty bit > from the huge page to the small pages. However we're possibly using a > wrong data since when fetching the bit we're using pmd_soft_dirty()

Re: [PATCH 1/1] userfaultfd: check VM_MAYWRITE was set after verifying the uffd is registered

2018-12-06 Thread Peter Xu
is comment too some day: /* * Nothing to do: this vma is already registered into this * userfaultfd and with the right tracking mode too. */ But I don't think it's anything urgent since it's clear it means t

[PATCH] userfaultfd: clear flag if remap event not enabled

2018-12-09 Thread Peter Xu
@vger.kernel.org Signed-off-by: Peter Xu --- fs/userfaultfd.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fs/userfaultfd.c b/fs/userfaultfd.c index cd58939dc977..798ae8a438ff 100644 --- a/fs/userfaultfd.c +++ b/fs/userfaultfd.c @@ -740,6 +740,9 @@ void mremap_userfaultfd_prep(struct vm_area_struct

Re: [PATCH v4 9/9] iommu/vt-d: Remove the obsolete per iommu pasid tables

2018-07-10 Thread Peter Xu
void *data), void *data); > > #ifdef CONFIG_INTEL_IOMMU_SVM > -extern int intel_svm_alloc_pasid_tables(struct intel_iommu *iommu); > -extern int intel_svm_free_pasid_tables(struct intel_iommu *iommu); > +int intel_svm_init(struct intel_iommu *iommu); > +int intel_svm_exit(struct intel_iommu *iommu); > extern int intel_svm_enable_prq(struct intel_iommu *iommu); > extern int intel_svm_finish_prq(struct intel_iommu *iommu); > > -- > 2.7.4 > > ___ > iommu mailing list > io...@lists.linux-foundation.org > https://lists.linuxfoundation.org/mailman/listinfo/iommu -- Peter Xu

Re: [PATCH v4 6/9] iommu/vt-d: Per PCI device pasid table interfaces

2018-07-11 Thread Peter Xu
s function is called is in a single-thread context > (protected by a spinlock of device_domain_lock with local interrupt disabled). > > So we don't need an extra lock here. But anyway, I should put a comment > here. Yeah, that would be nice too! Or add a comment for both of the functions: /* Must be with device_domain_lock held */ Regards, -- Peter Xu

Re: [PATCH v2] mm: thp: fix flags for pmd migration when split

2018-12-11 Thread Peter Xu
On Tue, Dec 11, 2018 at 11:21:44AM +0300, Konstantin Khlebnikov wrote: > On 11.12.2018 8:12, Peter Xu wrote: > > When splitting a huge migrating PMD, we'll transfer all the existing > > PMD bits and apply them again onto the small PTEs. However we are > > fetching th

Re: [PATCH v2] mm: thp: fix flags for pmd migration when split

2018-12-12 Thread Peter Xu
On Wed, Dec 12, 2018 at 04:51:38PM +0300, Konstantin Khlebnikov wrote: > On Wed, Dec 12, 2018 at 8:15 AM Peter Xu wrote: > > > > On Tue, Dec 11, 2018 at 11:21:44AM +0300, Konstantin Khlebnikov wrote: > > > On 11.12.2018 8:12, Peter Xu wrote: > > > > When s

[PATCH v3] mm: thp: fix flags for pmd migration when split

2018-12-12 Thread Peter Xu
k Joarder CC: Konstantin Khlebnikov CC: Zi Yan CC: linux...@kvack.org CC: linux-kernel@vger.kernel.org Signed-off-by: Peter Xu --- v2: - fix it up for young/write/dirty bits too [Konstantin] v3: - fetch write correctly for migration entry; drop macro [Konstantin] --- mm/huge_memory.c | 20

Re: [PATCH v3] mm: thp: fix flags for pmd migration when split

2018-12-13 Thread Peter Xu
On Thu, Dec 13, 2018 at 12:59:42PM +0300, Kirill A. Shutemov wrote: > On Thu, Dec 13, 2018 at 01:15:10PM +0800, Peter Xu wrote: > > When splitting a huge migrating PMD, we'll transfer all the existing > > PMD bits and apply them again onto the small PTEs. However we are &

Re: [PATCH] mm: thp: fix soft dirty for migration when split

2018-12-10 Thread Peter Xu
On Mon, Dec 10, 2018 at 07:50:52PM +0300, Konstantin Khlebnikov wrote: > On Fri, Dec 7, 2018 at 6:34 AM Peter Xu wrote: > > > > On Thu, Dec 06, 2018 at 04:46:04PM +0800, Peter Xu wrote: > > > When splitting a huge migrating PMD, we'll transfer the soft dirty bit &g

[PATCH v2] mm: thp: fix flags for pmd migration when split

2018-12-10 Thread Peter Xu
bnikov CC: linux...@kvack.org CC: linux-kernel@vger.kernel.org Signed-off-by: Peter Xu --- v2: - fix it up for young/write/dirty bits too [Konstantin] --- mm/huge_memory.c | 15 ++- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/mm/huge_memory.c b/mm/huge_memory.c index

Re: [PATCH] userfaultfd: clear flag if remap event not enabled

2018-12-10 Thread Peter Xu
On Mon, Dec 10, 2018 at 03:09:25PM -0500, Andrea Arcangeli wrote: > Hello, > > On Mon, Dec 10, 2018 at 07:51:16PM +0200, Mike Rapoport wrote: > > On Mon, Dec 10, 2018 at 02:51:21PM +0800, Peter Xu wrote: > > > When the process being tracked do mremap() without > >

[PATCH v2] userfaultfd: clear flag if remap event not enabled

2018-12-10 Thread Peter Xu
@vger.kernel.org Acked-by: Mike Rapoport Reviewed-by: Andrea Arcangeli Signed-off-by: Peter Xu --- fs/userfaultfd.c | 10 +- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/fs/userfaultfd.c b/fs/userfaultfd.c index cd58939dc977..4567b5b6fd32 100644 --- a/fs/userfaultfd.c +++ b/fs

Re: Can VFIO pin only a specific region of guest mem when use pass through devices?

2018-10-29 Thread Peter Xu
y footprint, but of course > requires hardware support and lots of new code paths, many of which are > already being discussed for things like Scalable IOV and SVA. Thanks, Agree with Jason's and Alex's comments. One trivial additional: the whole guest RAM will possibly still be pinned for a very short period during guest system boot (e.g., when running guest BIOS) and before the guest kernel enables the vIOMMU for the assigned device since the bootup code like BIOS would still need to be able to access the whole guest memory. Thanks, -- Peter Xu

[PATCH RFC v2 0/4] mm: some enhancements to the page fault mechanism

2018-11-06 Thread Peter Xu
how to better test the work, etc... Looking forward to your comments. Thanks, [1] https://git.kernel.org/pub/scm/linux/kernel/git/andrea/aa.git/commit/?h=userfault&id=b245ecf6cf59156966f3da6e6b674f6695a5ffa5 Peter Xu (4): mm: gup: rename "nonblocking" to "locked"

[PATCH RFC v2 3/4] mm: allow VM_FAULT_RETRY for multiple times

2018-11-06 Thread Peter Xu
. It might also benefit other potential users who will have similar requirement like userfault write-protection. Please read the thread below for more information. [1] https://lkml.org/lkml/2017/11/2/833 Suggested-by: Linus Torvalds Suggested-by: Andrea Arcangeli Signed-off-by: Peter Xu ---

[PATCH RFC v2 4/4] mm: gup: allow VM_FAULT_RETRY for multiple times

2018-11-06 Thread Peter Xu
This is the gup counterpart of the change that allows the VM_FAULT_RETRY to happen for more than once. Signed-off-by: Peter Xu --- mm/gup.c | 17 + 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/mm/gup.c b/mm/gup.c index 6faff46cd409..8a0e7f9bd29a 100644 --- a/mm

[PATCH RFC v2 1/4] mm: gup: rename "nonblocking" to "locked" where proper

2018-11-06 Thread Peter Xu
ter suite the functionality of the variable. While at it, fixing up some of the comments accordingly. Signed-off-by: Peter Xu --- mm/gup.c | 44 +--- mm/hugetlb.c | 8 2 files changed, 25 insertions(+), 27 deletions(-) diff --git a/mm/gup.c

[PATCH RFC v2 2/4] mm: userfault: return VM_FAULT_RETRY on signals

2018-11-06 Thread Peter Xu
contains a potential fix for a double-free of mmap_sem on ARC architecture; please see https://lkml.org/lkml/2018/11/1/723 for more information) Suggested-by: Linus Torvalds Suggested-by: Andrea Arcangeli Signed-off-by: Peter Xu --- arch/alpha/mm/fault.c | 2 +- arch/arc/mm/fault.c

Re: [PATCH 1/4] KVM: delete .change_pte MMU notifier callback

2024-04-08 Thread Peter Xu
ked because I remember Andrea used to have a custom tree maintaining that part: https://github.com/aagit/aa/commit/c761078df7a77d13ddfaeebe56a0f4bc128b1968 Maybe it can't be enabled for some reason that I overlooked in the current tree, or we just decided to not to? Thanks, -- Peter Xu

Re: [PATCH 1/4] KVM: delete .change_pte MMU notifier callback

2024-04-11 Thread Peter Xu
On Thu, Apr 11, 2024 at 06:55:44PM +0200, Paolo Bonzini wrote: > On Mon, Apr 8, 2024 at 3:56 PM Peter Xu wrote: > > Paolo, > > > > I may miss a bunch of details here (as I still remember some change_pte > > patches previously on the list..), however not sure whether

Re: [PATCH v3 1/2] KVM: selftests: Sync data verify of dirty logging with guest sync

2021-04-20 Thread Peter Xu
On Tue, Apr 20, 2021 at 10:07:16AM +0200, Paolo Bonzini wrote: > On 18/04/21 14:43, Peter Xu wrote: > > 8<- > > diff --git a/tools/testing/selftests/kvm/dirty_log_test.c > > b/tools/testing/selftests/kvm/dirty_log_test.c > > index 25230e799bc4..d3050d1c2cd0

Re: [PATCH] KVM: selftests: Always run vCPU thread with blocked SIG_IPI

2021-04-20 Thread Peter Xu
_log_test could fail directly > on receiving a SIGUSR1 without a handler (when vcpu runs far slower than > main). > > Reported-by: Peter Xu > Cc: sta...@vger.kernel.org > Signed-off-by: Paolo Bonzini Yes, indeed better! :) Reviewed-by: Peter Xu -- Peter Xu

Re: [PATCH] KVM: selftests: Always run vCPU thread with blocked SIG_IPI

2021-04-20 Thread Peter Xu
On Tue, Apr 20, 2021 at 10:37:39AM -0400, Peter Xu wrote: > On Tue, Apr 20, 2021 at 04:16:14AM -0400, Paolo Bonzini wrote: > > The main thread could start to send SIG_IPI at any time, even before signal > > blocked on vcpu thread. Therefore, start the vcpu thread with the sig

[PATCH v4 0/2] KVM: selftests: fix races in dirty log test

2021-04-20 Thread Peter Xu
.kernel.org/kvm/20210420081614.684787-1-pbonz...@redhat.com/ Peter Xu (2): KVM: selftests: Sync data verify of dirty logging with guest sync KVM: selftests: Wait for vcpu thread before signal setup tools/testing/selftests/kvm/dirty_log_test.c | 70 +--- 1 file changed, 59 insertions(+

[PATCH v4 1/2] KVM: selftests: Sync data verify of dirty logging with guest sync

2021-04-20 Thread Peter Xu
.org/lkml/20210413213641.23742-1-pet...@redhat.com/ [2] https://lore.kernel.org/lkml/20210417140956.GV4440@xz-x1/ Cc: Paolo Bonzini Cc: Sean Christopherson Cc: Andrew Jones Signed-off-by: Peter Xu --- tools/testing/selftests/kvm/dirty_log_test.c | 62 1 file changed, 51 inse

[PATCH v4 2/2] KVM: selftests: Wait for vcpu thread before signal setup

2021-04-20 Thread Peter Xu
on receiving a SIG_USR1 without a handler (when vcpu runs far slower than main). Signed-off-by: Peter Xu --- tools/testing/selftests/kvm/dirty_log_test.c | 8 1 file changed, 8 insertions(+) diff --git a/tools/testing/selftests/kvm/dirty_log_test.c b/tools/testing/selftests/kvm

Re: [PATCH] KVM: selftests: Always run vCPU thread with blocked SIG_IPI

2021-04-20 Thread Peter Xu
On Tue, Apr 20, 2021 at 06:24:50PM +0200, Paolo Bonzini wrote: > On 20/04/21 17:32, Peter Xu wrote: > > On Tue, Apr 20, 2021 at 10:37:39AM -0400, Peter Xu wrote: > > > On Tue, Apr 20, 2021 at 04:16:14AM -0400, Paolo Bonzini wrote: > > > > The main thread could sta

Re: [PATCH v4 09/10] userfaultfd/shmem: modify shmem_mcopy_atomic_pte to use install_pte()

2021-04-20 Thread Peter Xu
ORMAL and _CONTINUE for both > shmem > + * and anon, and for both shared and private VMAs. > */ > -static int mcopy_atomic_install_pte(struct mm_struct *dst_mm, pmd_t *dst_pmd, > - struct vm_area_struct *dst_vma, > - unsigned long dst_addr, struct page *page, > - bool newly_allocated, bool wp_copy) > +int mcopy_atomic_install_pte(struct mm_struct *dst_mm, pmd_t *dst_pmd, > + struct vm_area_struct *dst_vma, > + unsigned long dst_addr, struct page *page, > + bool newly_allocated, bool wp_copy) > { > int ret; > pte_t _dst_pte, *dst_pte; > -- > 2.31.1.368.gbe11c130af-goog > -- Peter Xu

Re: [PATCH v2] vfio/type1: Use follow_pte()

2021-02-16 Thread Peter Xu
("vfio/type1: Fix VA->PA translation for PFNMAP VMAs in > vaddr_get_pfn()") > Reviewed-by: Jason Gunthorpe > Reviewed-by: Cornelia Huck > Signed-off-by: Alex Williamson Reviewed-by: Peter Xu -- Peter Xu

Re: [PATCH v2 23/26] userfaultfd: wp: don't wake up when doing write protect

2019-02-27 Thread Peter Xu
On Tue, Feb 26, 2019 at 10:00:29AM +0200, Mike Rapoport wrote: > On Tue, Feb 26, 2019 at 03:41:17PM +0800, Peter Xu wrote: > > On Tue, Feb 26, 2019 at 09:29:33AM +0200, Mike Rapoport wrote: > > > On Tue, Feb 26, 2019 at 02:24:52PM +0800, Peter Xu wrote: > > > > On M

Re: [PATCH v3 14/28] userfaultfd: wp: handle COW properly for uffd-wp

2019-04-24 Thread Peter Xu
On Tue, Apr 23, 2019 at 11:34:56AM -0400, Jerome Glisse wrote: > On Tue, Apr 23, 2019 at 11:00:30AM +0800, Peter Xu wrote: > > On Mon, Apr 22, 2019 at 10:54:02AM -0400, Jerome Glisse wrote: > > > On Mon, Apr 22, 2019 at 08:20:10PM +0800, Peter Xu wrote: > > > > On F

[PATCH v4 00/27] userfaultfd: write protection support

2019-04-25 Thread Peter Xu
eprotect API to userfaultfd ioctl Martin Cracauer (1): userfaultfd: wp: UFFDIO_REGISTER_MODE_WP documentation update Peter Xu (18): mm: gup: rename "nonblocking" to "locked" where proper mm: userfault: return VM_FAULT_RETRY on signals userfaultfd: don't retake mmap_

[PATCH v4 01/27] mm: gup: rename "nonblocking" to "locked" where proper

2019-04-25 Thread Peter Xu
ter suite the functionality of the variable. While at it, fixing up some of the comments accordingly. Reviewed-by: Mike Rapoport Reviewed-by: Jerome Glisse Signed-off-by: Peter Xu --- mm/gup.c | 44 +--- mm/hugetlb.c | 8 2 files changed, 25

[PATCH v4 03/27] userfaultfd: don't retake mmap_sem to emulate NOPAGE

2019-04-25 Thread Peter Xu
-by: Linus Torvalds Reviewed-by: Jerome Glisse Signed-off-by: Peter Xu --- fs/userfaultfd.c | 24 1 file changed, 24 deletions(-) diff --git a/fs/userfaultfd.c b/fs/userfaultfd.c index 89800fc7dc9d..b397bc3b954d 100644 --- a/fs/userfaultfd.c +++ b/fs/userfaultfd.c @@ -514

[PATCH v4 05/27] mm: gup: allow VM_FAULT_RETRY for multiple times

2019-04-25 Thread Peter Xu
This is the gup counterpart of the change that allows the VM_FAULT_RETRY to happen for more than once. Reviewed-by: Jerome Glisse Signed-off-by: Peter Xu --- mm/gup.c | 17 + mm/hugetlb.c | 6 -- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/mm/gup.c

[PATCH v4 04/27] mm: allow VM_FAULT_RETRY for multiple times

2019-04-25 Thread Peter Xu
Linus Torvalds Suggested-by: Andrea Arcangeli Reviewed-by: Jerome Glisse Signed-off-by: Peter Xu --- arch/alpha/mm/fault.c | 2 +- arch/arc/mm/fault.c | 1 - arch/arm/mm/fault.c | 3 --- arch/arm64/mm/fault.c | 5 arch/hexagon/mm/vm_faul

[PATCH v4 07/27] userfaultfd: wp: hook userfault handler to write protection fault

2019-04-25 Thread Peter Xu
t certainly worth to achieve it but in a later incremental patch. v3: Add hooking point for THP wrprotect faults. CC: Shaohua Li Signed-off-by: Andrea Arcangeli [peterx: don't conditionally drop FAULT_FLAG_WRITE in do_swap_page] Reviewed-by: Mike Rapoport Reviewed-by: Jerome Glisse Signed-

[PATCH v4 02/27] mm: userfault: return VM_FAULT_RETRY on signals

2019-04-25 Thread Peter Xu
to handle nonfatal signals faster than before. This patch is a preparation work for the next patch to finally remove the special code path mentioned above in handle_userfault(). Suggested-by: Linus Torvalds Suggested-by: Andrea Arcangeli Reviewed-by: Jerome Glisse Signed-off-by: Peter Xu ---

[PATCH v4 10/27] userfaultfd: wp: add UFFDIO_COPY_MODE_WP

2019-04-25 Thread Peter Xu
by: Jerome Glisse Reviewed-by: Mike Rapoport Signed-off-by: Peter Xu --- fs/userfaultfd.c | 5 +++-- include/linux/userfaultfd_k.h| 2 +- include/uapi/linux/userfaultfd.h | 11 +- mm/userfaultfd.c | 36 ++-- 4 files chang

[PATCH v4 09/27] userfaultfd: wp: userfaultfd_pte/huge_pmd_wp() helpers

2019-04-25 Thread Peter Xu
ome Glisse Reviewed-by: Mike Rapoport Signed-off-by: Peter Xu --- include/linux/userfaultfd_k.h | 27 +++ 1 file changed, 27 insertions(+) diff --git a/include/linux/userfaultfd_k.h b/include/linux/userfaultfd_k.h index 38f748e7186e..c6590c58ce28 100644 --- a/include/li

[PATCH v4 11/27] mm: merge parameters for change_protection()

2019-04-25 Thread Peter Xu
ameters to change_protection(). In the follow up patches, a new parameter for userfaultfd write protection will be introduced. No functional change at all. Reviewed-by: Jerome Glisse Signed-off-by: Peter Xu --- include/linux/huge_mm.h | 2 +- include/linux/mm.h | 14 +- mm/huge_memory.c

[PATCH v4 06/27] userfaultfd: wp: add helper for writeprotect check

2019-04-25 Thread Peter Xu
Glisse Reviewed-by: Mike Rapoport Signed-off-by: Peter Xu --- include/linux/userfaultfd_k.h | 10 ++ 1 file changed, 10 insertions(+) diff --git a/include/linux/userfaultfd_k.h b/include/linux/userfaultfd_k.h index 37c9eba75c98..38f748e7186e 100644 --- a/include/linux/userfaultfd_k.h +++ b

[PATCH v4 08/27] userfaultfd: wp: add WP pagetable tracking to x86

2019-04-25 Thread Peter Xu
ay on that, we'd need to stay on the safe side and generate false positive wp faults for every swapped out page. Signed-off-by: Andrea Arcangeli [peterx: append _PAGE_UFD_WP to _PAGE_CHG_MASK] Reviewed-by: Jerome Glisse Reviewed-by: Mike Rapoport Signed-off-by: Peter Xu --- arch/x

[PATCH v4 14/27] userfaultfd: wp: handle COW properly for uffd-wp

2019-04-25 Thread Peter Xu
t to resolve an uffd-wp page fault always. That matches what we do with general huge PMD write protections. In that way, we resolved the huge PMD copy-on-write issue into PTE copy-on-write. Signed-off-by: Peter Xu --- mm/memory.c | 5 - mm/

[PATCH v4 16/27] userfaultfd: wp: add pmd_swp_*uffd_wp() helpers

2019-04-25 Thread Peter Xu
Adding these missing helpers for uffd-wp operations with pmd swap/migration entries. Reviewed-by: Jerome Glisse Reviewed-by: Mike Rapoport Signed-off-by: Peter Xu --- arch/x86/include/asm/pgtable.h | 15 +++ include/asm-generic/pgtable_uffd.h | 15 +++ 2 files

[PATCH v4 12/27] userfaultfd: wp: apply _PAGE_UFFD_WP bit

2019-04-25 Thread Peter Xu
page faults in either do_wp_page() or wp_huge_pmd(). Reviewed-by: Jerome Glisse Reviewed-by: Mike Rapoport Signed-off-by: Peter Xu --- include/linux/mm.h | 5 + mm/huge_memory.c | 14 +- mm/memory.c| 4 ++-- mm/mprotect.c | 12 mm/userfaultfd.c | 8

[PATCH v4 20/27] userfaultfd: wp: support write protection for userfault vma range

2019-04-25 Thread Peter Xu
ngeli [peterx: - use the helper to find VMA; - return -ENOENT if not found to match mcopy case; - use the new MM_CP_UFFD_WP* flags for change_protection - check against mmap_changing for failures] Reviewed-by: Jerome Glisse Reviewed-by: Mike Rapoport Signed-off-by: Peter Xu --- include/

[PATCH v4 18/27] khugepaged: skip collapse if uffd-wp detected

2019-04-25 Thread Peter Xu
same thing needs to be considered for swap entries and migration entries. So do the check as well disregarding khugepaged_max_ptes_swap. Reviewed-by: Jerome Glisse Reviewed-by: Mike Rapoport Signed-off-by: Peter Xu --- include/trace/events/huge_memory.h | 1 + mm/khugepaged.c

[PATCH v4 17/27] userfaultfd: wp: support swap and page migration

2019-04-25 Thread Peter Xu
is a swap entry. That can lead to data mismatch if the page that we are going to write protect is swapped out when sending the UFFDIO_WRITEPROTECT. This patch also applies/removes the uffd-wp bit even for the swap entries. Signed-off-by: Peter Xu --- include/linux/swapops.h | 2 ++ mm/huge_memor

[PATCH v4 15/27] userfaultfd: wp: drop _PAGE_UFFD_WP properly when fork

2019-04-25 Thread Peter Xu
: Jerome Glisse Reviewed-by: Mike Rapoport Signed-off-by: Peter Xu --- mm/huge_memory.c | 8 mm/memory.c | 8 2 files changed, 16 insertions(+) diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 3885747d4901..cf8f11d6e6cd 100644 --- a/mm/huge_memory.c +++ b/mm

[PATCH v4 19/27] userfaultfd: introduce helper vma_find_uffd

2019-04-25 Thread Peter Xu
Mike Rapoport Signed-off-by: Peter Xu --- mm/userfaultfd.c | 54 +++- 1 file changed, 30 insertions(+), 24 deletions(-) diff --git a/mm/userfaultfd.c b/mm/userfaultfd.c index 240de2a8492d..2606409572b2 100644 --- a/mm/userfaultfd.c +++ b/mm/userfaul

[PATCH v4 13/27] mm: introduce do_wp_page_cont()

2019-04-25 Thread Peter Xu
somewhere else when resolving the userfault page fault. Signed-off-by: Peter Xu --- include/linux/mm.h | 2 ++ mm/memory.c| 8 2 files changed, 10 insertions(+) diff --git a/include/linux/mm.h b/include/linux/mm.h index a5ac81188523..a2911de04cdd 100644 --- a/include/linux/mm.h +++ b

[PATCH v4 24/27] userfaultfd: wp: UFFDIO_REGISTER_MODE_WP documentation update

2019-04-25 Thread Peter Xu
From: Martin Cracauer Adds documentation about the write protection support. Signed-off-by: Martin Cracauer Signed-off-by: Andrea Arcangeli [peterx: rewrite in rst format; fixups here and there] Reviewed-by: Jerome Glisse Reviewed-by: Mike Rapoport Signed-off-by: Peter Xu

[PATCH v4 21/27] userfaultfd: wp: add the writeprotect API to userfaultfd ioctl

2019-04-25 Thread Peter Xu
erome Glisse Signed-off-by: Peter Xu --- fs/userfaultfd.c | 82 +--- include/uapi/linux/userfaultfd.h | 23 + 2 files changed, 89 insertions(+), 16 deletions(-) diff --git a/fs/userfaultfd.c b/fs/userfaultfd.c index 3092885c9d2c..81962d62520c 1

[PATCH v4 22/27] userfaultfd: wp: enabled write protection in userfaultfd API

2019-04-25 Thread Peter Xu
ed-by: Jerome Glisse Reviewed-by: Mike Rapoport Signed-off-by: Peter Xu --- include/uapi/linux/userfaultfd.h | 6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/include/uapi/linux/userfaultfd.h b/include/uapi/linux/userfaultfd.h index 95c4a160e5f8..e7e98bde221f 100644 --- a/in

[PATCH v4 23/27] userfaultfd: wp: don't wake up when doing write protect

2019-04-25 Thread Peter Xu
It does not make sense to try to wake up any waiting thread when we're write-protecting a memory region. Only wake up when resolving a write protected page fault. Reviewed-by: Mike Rapoport Signed-off-by: Peter Xu --- fs/userfaultfd.c | 13 - 1 file changed, 8 insertions(

[PATCH v4 27/27] userfaultfd: selftests: add write-protect test

2019-04-25 Thread Peter Xu
ious tests but will do MISSING+WP for each page. For sigbus-mode test we'll need to provide standalone path to handle the write protection faults. For all tests, do statistics as well for uffd-wp pages. Signed-off-by: Peter Xu --- tools/testing/selftests/vm/user

[PATCH v4 25/27] userfaultfd: wp: declare _UFFDIO_WRITEPROTECT conditionally

2019-04-25 Thread Peter Xu
bit if the register mode has MODE_WP. Reviewed-by: Mike Rapoport Signed-off-by: Peter Xu --- fs/userfaultfd.c | 16 +--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/fs/userfaultfd.c b/fs/userfaultfd.c index f1f61a0278c2..7f87e9e4fb9b 100644 --- a/fs/userfaultfd.

[PATCH v4 26/27] userfaultfd: selftests: refactor statistics

2019-04-25 Thread Peter Xu
structure, it's very easy to introduce new statistics. Reviewed-by: Mike Rapoport Signed-off-by: Peter Xu --- tools/testing/selftests/vm/userfaultfd.c | 76 +++- 1 file changed, 49 insertions(+), 27 deletions(-) diff --git a/tools/testing/selftests/vm/userfaultfd.c b/

Re: [PATCH 1/3] userfaultfd/sysctl: introduce unprivileged_userfaultfd

2019-03-12 Thread Peter Xu
t this to "kvm" to restrict userfaultfd system call usage to users with ^ add " who have ptrace capability, or" -------+ > permissions to open "/dev/kvm". I think your version is better than mine, but I'd like to confirm about above two extra changes before I squash them into the patch. :) Thanks! -- Peter Xu

Re: [PATCH 0/3] userfaultfd: allow to forbid unprivileged users

2019-03-12 Thread Peter Xu
On Tue, Mar 12, 2019 at 09:01:47AM +0200, Mike Rapoport wrote: > Hi Peter, > > On Mon, Mar 11, 2019 at 05:36:58PM +0800, Peter Xu wrote: > > Hi, > > > > (The idea comes from Andrea, and following discussions with Mike and > > other people) > > > >

Re: [PATCH 0/3] userfaultfd: allow to forbid unprivileged users

2019-03-12 Thread Peter Xu
Hi, Kirill, On Tue, Mar 12, 2019 at 10:49:51AM +0300, Kirill A. Shutemov wrote: > On Mon, Mar 11, 2019 at 05:36:58PM +0800, Peter Xu wrote: > > Hi, > > > > (The idea comes from Andrea, and following discussions with Mike and > > other people) > > > > Thi

Re: [PATCH 0/3] userfaultfd: allow to forbid unprivileged users

2019-03-12 Thread Peter Xu
On Tue, Mar 12, 2019 at 12:59:34PM -0700, Mike Kravetz wrote: > On 3/11/19 2:36 AM, Peter Xu wrote: > > > > The "kvm" entry is a bit special here only to make sure that existing > > users like QEMU/KVM won't break by this newly introduced flag. What

Re: [PATCH 0/3] userfaultfd: allow to forbid unprivileged users

2019-03-15 Thread Peter Xu
On Wed, Mar 13, 2019 at 10:50:48AM -0700, Mike Kravetz wrote: > On 3/12/19 11:00 PM, Peter Xu wrote: > > On Tue, Mar 12, 2019 at 12:59:34PM -0700, Mike Kravetz wrote: > >> On 3/11/19 2:36 AM, Peter Xu wrote: > >>> > >>> The "kvm" entry i

Re: [PATCH] vfio/type1: Limit DMA mappings per container

2019-04-01 Thread Peter Xu
ed by simply using atomic_read() or even READ_ONCE() (I feel like we don't need atomic ops with dma_avail because we've had the mutex but it of course it doesn't hurt...) to replace atomic_add_unless() above to check against zero then we do +1/-1 in vfio_[un]link_dma() only.

Re: [PATCH] vfio/type1: Limit DMA mappings per container

2019-04-01 Thread Peter Xu
On Mon, Apr 01, 2019 at 10:34:13PM -0600, Alex Williamson wrote: > On Tue, 2 Apr 2019 10:41:15 +0800 > Peter Xu wrote: > > > On Mon, Apr 01, 2019 at 02:16:52PM -0600, Alex Williamson wrote: > > > > [...] > > > > > @@ -1081,8 +1088,14 @@ st

Re: [PATCH v2] vfio/type1: Limit DMA mappings per container

2019-04-02 Thread Peter Xu
pected to be well in excess of any reasonable use > case (a large virtual machine configuration would typically only make > use of tens of concurrent mappings). > > This fixes CVE-2019-3882. > > Signed-off-by: Alex Williamson Reviewed-by: Peter Xu Thanks, -- Peter Xu

Re: [PATCH v3 00/28] userfaultfd: write protection support

2019-04-08 Thread Peter Xu
On Wed, Mar 20, 2019 at 10:06:14AM +0800, Peter Xu wrote: > This series implements initial write protection support for > userfaultfd. Currently both shmem and hugetlbfs are not supported > yet, but only anonymous memory. This is the 3nd version of it. > > The latest code can a

Re: [PATCH v2 10/26] userfaultfd: wp: add UFFDIO_COPY_MODE_WP

2019-02-25 Thread Peter Xu
On Mon, Feb 25, 2019 at 05:58:37PM +0200, Mike Rapoport wrote: > On Tue, Feb 12, 2019 at 10:56:16AM +0800, Peter Xu wrote: > > From: Andrea Arcangeli > > > > This allows UFFDIO_COPY to map pages wrprotected. >write p

Re: [PATCH v2 20/26] userfaultfd: wp: support write protection for userfault vma range

2019-02-25 Thread Peter Xu
On Mon, Feb 25, 2019 at 10:52:34PM +0200, Mike Rapoport wrote: > On Tue, Feb 12, 2019 at 10:56:26AM +0800, Peter Xu wrote: > > From: Shaohua Li > > > > Add API to enable/disable writeprotect a vma range. Unlike mprotect, > > this doesn't split/merge vmas. >

Re: [PATCH v2 23/26] userfaultfd: wp: don't wake up when doing write protect

2019-02-25 Thread Peter Xu
On Mon, Feb 25, 2019 at 11:09:35PM +0200, Mike Rapoport wrote: > On Tue, Feb 12, 2019 at 10:56:29AM +0800, Peter Xu wrote: > > It does not make sense to try to wake up any waiting thread when we're > > write-protecting a memory region. Only wake up when resolving a write >

Re: [PATCH v2 21/26] userfaultfd: wp: add the writeprotect API to userfaultfd ioctl

2019-02-25 Thread Peter Xu
On Mon, Feb 25, 2019 at 11:03:51PM +0200, Mike Rapoport wrote: > On Tue, Feb 12, 2019 at 10:56:27AM +0800, Peter Xu wrote: > > From: Andrea Arcangeli > > > > v1: From: Shaohua Li > > > > v2: cleanups, remove a branch. > > > > [peterx writes up t

Re: [PATCH v2 24/26] userfaultfd: wp: UFFDIO_REGISTER_MODE_WP documentation update

2019-02-25 Thread Peter Xu
On Mon, Feb 25, 2019 at 11:19:32PM +0200, Mike Rapoport wrote: > On Tue, Feb 12, 2019 at 10:56:30AM +0800, Peter Xu wrote: > > From: Martin Cracauer > > > > Adds documentation about the write protection support. > > > > Signed-off-by: Andrea Arcangeli > >

Re: [PATCH v2 20/26] userfaultfd: wp: support write protection for userfault vma range

2019-02-25 Thread Peter Xu
On Tue, Feb 26, 2019 at 08:43:47AM +0200, Mike Rapoport wrote: > On Tue, Feb 26, 2019 at 02:06:27PM +0800, Peter Xu wrote: > > On Mon, Feb 25, 2019 at 10:52:34PM +0200, Mike Rapoport wrote: > > > On Tue, Feb 12, 2019 at 10:56:26AM +0800, Peter Xu wrote: > &

Re: [PATCH v2 23/26] userfaultfd: wp: don't wake up when doing write protect

2019-02-25 Thread Peter Xu
On Tue, Feb 26, 2019 at 09:29:33AM +0200, Mike Rapoport wrote: > On Tue, Feb 26, 2019 at 02:24:52PM +0800, Peter Xu wrote: > > On Mon, Feb 25, 2019 at 11:09:35PM +0200, Mike Rapoport wrote: > > > On Tue, Feb 12, 2019 at 10:56:29AM +0800, Peter Xu wrote: > > > > It

Re: [PATCH v2 24/26] userfaultfd: wp: UFFDIO_REGISTER_MODE_WP documentation update

2019-02-25 Thread Peter Xu
On Tue, Feb 26, 2019 at 09:04:25AM +0200, Mike Rapoport wrote: > On Tue, Feb 26, 2019 at 02:53:42PM +0800, Peter Xu wrote: > > On Mon, Feb 25, 2019 at 11:19:32PM +0200, Mike Rapoport wrote: > > > On Tue, Feb 12, 2019 at 10:56:30AM +0800, Peter Xu wrote: > > &

Re: [PATCH v2 26/26] userfaultfd: selftests: add write-protect test

2019-02-25 Thread Peter Xu
On Tue, Feb 26, 2019 at 08:58:36AM +0200, Mike Rapoport wrote: > On Tue, Feb 12, 2019 at 10:56:32AM +0800, Peter Xu wrote: > > This patch adds uffd tests for write protection. > > > > Instead of introducing new tests for it, let's simply squashing uffd-wp > > tests

Re: [PATCH v2 20/26] userfaultfd: wp: support write protection for userfault vma range

2019-02-25 Thread Peter Xu
which did validate_range() first, then > > in __mcopy_atomic() we've used BUG_ON()s. They make sense to me > > becauase userspace should never be able to trigger it. And if we > > really want to change the BUG_ON()s in this patch, IMHO we probably > > want to change the other BUG_ON()s as well, then that can be a > > standalone patch or patchset to address another issue... > > Yeah, we have quite a lot of them, so doing the replacement in a separate > patch makes perfect sense. > > > (and if we really want to use WARN_ON, I would prefer WARN_ON_ONCE, or > > directly return the errors to avoid DOS). > > Agree. > > > I'll see how you'd prefer to see how I should move on with this patch. > > Let's keep this patch as is and make the replacement on top of the WP > series. Feel free to add r-b. Great! I'll do. Thanks, -- Peter Xu

  1   2   3   4   5   6   7   8   9   10   >