All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ingo Molnar <mingo@kernel.org>
To: Dave Hansen <dave@sr71.net>
Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, x86@kernel.org,
	torvalds@linux-foundation.org, dave.hansen@linux.intel.com,
	srikar@linux.vnet.ibm.com, vbabka@suse.cz,
	akpm@linux-foundation.org, kirill.shutemov@linux.intel.com,
	aarcange@redhat.com, n-horiguchi@ah.jp.nec.com, jack@suse.cz
Subject: Re: [PATCH 01/31] mm, gup: introduce concept of "foreign" get_user_pages()
Date: Tue, 9 Feb 2016 13:46:49 +0100	[thread overview]
Message-ID: <20160209124649.GA20153@gmail.com> (raw)
In-Reply-To: <20160129181644.74134A5D@viggo.jf.intel.com>


* Dave Hansen <dave@sr71.net> wrote:

> 
> OK, so I've fixed up my build process to _actually_ build the
> nommu code.
> 
> One of Vlastimil's comments made me go dig back in to the uprobes
> code's use of get_user_pages().  I decided to change both of them
> to be "foreign" accesses.
> 
> This also fixes the nommu breakage that Vlastimil noted last time.
> 
> Srikar, I'd appreciate if you can have a look at the uprobes.c
> modifications, especially the comment.  I don't think this will
> change any behavior, but I want to make sure the comment is
> accurate.
> 
> ---
> 
> From: Dave Hansen <dave.hansen@linux.intel.com>
> 
> For protection keys, we need to understand whether protections
> should be enforced in software or not.  In general, we enforce
> protections when working on our own task, but not when on others.
> We call these "current" and "foreign" operations.
> 
> This patch introduces a new get_user_pages() variant:
> 
> 	get_user_pages_foreign()
> 
> We modify the vanilla get_user_pages() so it can no longer be
> used on mm/tasks other than 'current/current->mm', which is by
> far the most common way it is called.  Using it makes a few of
> the call sites look a bit nicer.
> 
> In other words, get_user_pages_foreign() is a replacement for
> when get_user_pages() is called on non-current tsk/mm.
> 
> This also switches get_user_pages_(un)locked() over to be like
> get_user_pages() and not take a tsk/mm.  There is no
> get_user_pages_foreign_(un)locked().  If someone wants that
> behavior they just have to use "__" variant and pass in
> FOLL_FOREIGN explicitly.
> 
> The uprobes is_trap_at_addr() location holds mmap_sem and
> calls get_user_pages(current->mm) on an instruction address.  This
> makes it a pretty unique gup caller.  Being an instruction access
> and also really originating from the kernel (vs. the app), I opted
> to consider this a 'foreign' access where protection keys will not
> be enforced.
> 
> Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com>
> Acked-by: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
> Acked-by: Vlastimil Babka <vbabka@suse.cz>
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
> Cc: Andrea Arcangeli <aarcange@redhat.com>
> Cc: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
> Cc: jack@suse.cz
> ---
> 
>  b/arch/cris/arch-v32/drivers/cryptocop.c        |    8 ---
>  b/arch/ia64/kernel/err_inject.c                 |    3 -
>  b/arch/mips/mm/gup.c                            |    3 -
>  b/arch/s390/mm/gup.c                            |    4 -
>  b/arch/sh/mm/gup.c                              |    2 
>  b/arch/sparc/mm/gup.c                           |    2 
>  b/arch/x86/mm/gup.c                             |    2 
>  b/arch/x86/mm/mpx.c                             |    4 -
>  b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c       |    3 -
>  b/drivers/gpu/drm/etnaviv/etnaviv_gem.c         |    2 
>  b/drivers/gpu/drm/i915/i915_gem_userptr.c       |    2 
>  b/drivers/gpu/drm/radeon/radeon_ttm.c           |    3 -
>  b/drivers/gpu/drm/via/via_dmablit.c             |    3 -
>  b/drivers/infiniband/core/umem.c                |    2 
>  b/drivers/infiniband/core/umem_odp.c            |    8 +--
>  b/drivers/infiniband/hw/mthca/mthca_memfree.c   |    3 -
>  b/drivers/infiniband/hw/qib/qib_user_pages.c    |    3 -
>  b/drivers/infiniband/hw/usnic/usnic_uiom.c      |    2 
>  b/drivers/media/pci/ivtv/ivtv-udma.c            |    4 -
>  b/drivers/media/pci/ivtv/ivtv-yuv.c             |   10 +---
>  b/drivers/media/v4l2-core/videobuf-dma-sg.c     |    3 -
>  b/drivers/misc/mic/scif/scif_rma.c              |    2 
>  b/drivers/misc/sgi-gru/grufault.c               |    3 -
>  b/drivers/scsi/st.c                             |    2 
>  b/drivers/staging/rdma/ipath/ipath_user_pages.c |    3 -
>  b/drivers/video/fbdev/pvr2fb.c                  |    4 -
>  b/drivers/virt/fsl_hypervisor.c                 |    5 --
>  b/fs/exec.c                                     |    8 ++-
>  b/include/linux/mm.h                            |   21 +++++----
>  b/kernel/events/uprobes.c                       |   10 +++-
>  b/mm/frame_vector.c                             |    2 
>  b/mm/gup.c                                      |   52 +++++++++++++++---------
>  b/mm/ksm.c                                      |    2 
>  b/mm/memory.c                                   |    2 
>  b/mm/mempolicy.c                                |    6 +-
>  b/mm/nommu.c                                    |   30 ++++++++-----
>  b/mm/process_vm_access.c                        |   11 +++--
>  b/mm/util.c                                     |    4 -
>  b/net/ceph/pagevec.c                            |    2 
>  b/security/tomoyo/domain.c                      |    9 +++-
>  b/virt/kvm/async_pf.c                           |    7 ++-
>  b/virt/kvm/kvm_main.c                           |   10 ++--
>  42 files changed, 148 insertions(+), 123 deletions(-)

So this patch conflicts with recent upstream changes:

  patching file drivers/scsi/st.c
  can't find file to patch at input line 463

mind respinning it against v4.5-rc3 or so?

Also, please split this into three patches:

 - one patch adds the _foreign() GUP variant and applies it to code that uses it
   on remote tasks.

 - introduce the new get_user_pages() but also add macros so that both 8-parameter 
   and 7-parameter variants work without breaking the build. We can remove the 
   compatibility wrapping on v4.6 or so.

 - the third will be a large but trivial patch, which will change 8-parameter GUP 
   usage to 7-parameter usage.

... this should reduce the pain from the GUP interface change churn.

Agreed?

Thanks,

	Ingo

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

WARNING: multiple messages have this Message-ID (diff)
From: Ingo Molnar <mingo@kernel.org>
To: Dave Hansen <dave@sr71.net>
Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, x86@kernel.org,
	torvalds@linux-foundation.org, dave.hansen@linux.intel.com,
	srikar@linux.vnet.ibm.com, vbabka@suse.cz,
	akpm@linux-foundation.org, kirill.shutemov@linux.intel.com,
	aarcange@redhat.com, n-horiguchi@ah.jp.nec.com, jack@suse.cz
Subject: Re: [PATCH 01/31] mm, gup: introduce concept of "foreign" get_user_pages()
Date: Tue, 9 Feb 2016 13:46:49 +0100	[thread overview]
Message-ID: <20160209124649.GA20153@gmail.com> (raw)
In-Reply-To: <20160129181644.74134A5D@viggo.jf.intel.com>


* Dave Hansen <dave@sr71.net> wrote:

> 
> OK, so I've fixed up my build process to _actually_ build the
> nommu code.
> 
> One of Vlastimil's comments made me go dig back in to the uprobes
> code's use of get_user_pages().  I decided to change both of them
> to be "foreign" accesses.
> 
> This also fixes the nommu breakage that Vlastimil noted last time.
> 
> Srikar, I'd appreciate if you can have a look at the uprobes.c
> modifications, especially the comment.  I don't think this will
> change any behavior, but I want to make sure the comment is
> accurate.
> 
> ---
> 
> From: Dave Hansen <dave.hansen@linux.intel.com>
> 
> For protection keys, we need to understand whether protections
> should be enforced in software or not.  In general, we enforce
> protections when working on our own task, but not when on others.
> We call these "current" and "foreign" operations.
> 
> This patch introduces a new get_user_pages() variant:
> 
> 	get_user_pages_foreign()
> 
> We modify the vanilla get_user_pages() so it can no longer be
> used on mm/tasks other than 'current/current->mm', which is by
> far the most common way it is called.  Using it makes a few of
> the call sites look a bit nicer.
> 
> In other words, get_user_pages_foreign() is a replacement for
> when get_user_pages() is called on non-current tsk/mm.
> 
> This also switches get_user_pages_(un)locked() over to be like
> get_user_pages() and not take a tsk/mm.  There is no
> get_user_pages_foreign_(un)locked().  If someone wants that
> behavior they just have to use "__" variant and pass in
> FOLL_FOREIGN explicitly.
> 
> The uprobes is_trap_at_addr() location holds mmap_sem and
> calls get_user_pages(current->mm) on an instruction address.  This
> makes it a pretty unique gup caller.  Being an instruction access
> and also really originating from the kernel (vs. the app), I opted
> to consider this a 'foreign' access where protection keys will not
> be enforced.
> 
> Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com>
> Acked-by: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
> Acked-by: Vlastimil Babka <vbabka@suse.cz>
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
> Cc: Andrea Arcangeli <aarcange@redhat.com>
> Cc: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
> Cc: jack@suse.cz
> ---
> 
>  b/arch/cris/arch-v32/drivers/cryptocop.c        |    8 ---
>  b/arch/ia64/kernel/err_inject.c                 |    3 -
>  b/arch/mips/mm/gup.c                            |    3 -
>  b/arch/s390/mm/gup.c                            |    4 -
>  b/arch/sh/mm/gup.c                              |    2 
>  b/arch/sparc/mm/gup.c                           |    2 
>  b/arch/x86/mm/gup.c                             |    2 
>  b/arch/x86/mm/mpx.c                             |    4 -
>  b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c       |    3 -
>  b/drivers/gpu/drm/etnaviv/etnaviv_gem.c         |    2 
>  b/drivers/gpu/drm/i915/i915_gem_userptr.c       |    2 
>  b/drivers/gpu/drm/radeon/radeon_ttm.c           |    3 -
>  b/drivers/gpu/drm/via/via_dmablit.c             |    3 -
>  b/drivers/infiniband/core/umem.c                |    2 
>  b/drivers/infiniband/core/umem_odp.c            |    8 +--
>  b/drivers/infiniband/hw/mthca/mthca_memfree.c   |    3 -
>  b/drivers/infiniband/hw/qib/qib_user_pages.c    |    3 -
>  b/drivers/infiniband/hw/usnic/usnic_uiom.c      |    2 
>  b/drivers/media/pci/ivtv/ivtv-udma.c            |    4 -
>  b/drivers/media/pci/ivtv/ivtv-yuv.c             |   10 +---
>  b/drivers/media/v4l2-core/videobuf-dma-sg.c     |    3 -
>  b/drivers/misc/mic/scif/scif_rma.c              |    2 
>  b/drivers/misc/sgi-gru/grufault.c               |    3 -
>  b/drivers/scsi/st.c                             |    2 
>  b/drivers/staging/rdma/ipath/ipath_user_pages.c |    3 -
>  b/drivers/video/fbdev/pvr2fb.c                  |    4 -
>  b/drivers/virt/fsl_hypervisor.c                 |    5 --
>  b/fs/exec.c                                     |    8 ++-
>  b/include/linux/mm.h                            |   21 +++++----
>  b/kernel/events/uprobes.c                       |   10 +++-
>  b/mm/frame_vector.c                             |    2 
>  b/mm/gup.c                                      |   52 +++++++++++++++---------
>  b/mm/ksm.c                                      |    2 
>  b/mm/memory.c                                   |    2 
>  b/mm/mempolicy.c                                |    6 +-
>  b/mm/nommu.c                                    |   30 ++++++++-----
>  b/mm/process_vm_access.c                        |   11 +++--
>  b/mm/util.c                                     |    4 -
>  b/net/ceph/pagevec.c                            |    2 
>  b/security/tomoyo/domain.c                      |    9 +++-
>  b/virt/kvm/async_pf.c                           |    7 ++-
>  b/virt/kvm/kvm_main.c                           |   10 ++--
>  42 files changed, 148 insertions(+), 123 deletions(-)

So this patch conflicts with recent upstream changes:

  patching file drivers/scsi/st.c
  can't find file to patch at input line 463

mind respinning it against v4.5-rc3 or so?

Also, please split this into three patches:

 - one patch adds the _foreign() GUP variant and applies it to code that uses it
   on remote tasks.

 - introduce the new get_user_pages() but also add macros so that both 8-parameter 
   and 7-parameter variants work without breaking the build. We can remove the 
   compatibility wrapping on v4.6 or so.

 - the third will be a large but trivial patch, which will change 8-parameter GUP 
   usage to 7-parameter usage.

... this should reduce the pain from the GUP interface change churn.

Agreed?

Thanks,

	Ingo

  reply	other threads:[~2016-02-09 12:46 UTC|newest]

Thread overview: 80+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-29 18:16 [PATCH 00/31] x86: Memory Protection Keys (v9) Dave Hansen
2016-01-29 18:16 ` Dave Hansen
2016-01-29 18:16 ` [PATCH 01/31] mm, gup: introduce concept of "foreign" get_user_pages() Dave Hansen
2016-01-29 18:16   ` Dave Hansen
2016-02-09 12:46   ` Ingo Molnar [this message]
2016-02-09 12:46     ` Ingo Molnar
2016-02-09 13:06     ` Ingo Molnar
2016-02-09 13:06       ` Ingo Molnar
2016-02-09 15:15     ` Dave Hansen
2016-02-09 15:15       ` Dave Hansen
2016-01-29 18:16 ` [PATCH 02/31] x86, fpu: add placeholder for Processor Trace XSAVE state Dave Hansen
2016-01-29 18:16   ` Dave Hansen
2016-01-29 18:16 ` [PATCH 03/31] x86, pkeys: Add Kconfig option Dave Hansen
2016-01-29 18:16   ` Dave Hansen
2016-01-29 18:16 ` [PATCH 04/31] x86, pkeys: cpuid bit definition Dave Hansen
2016-01-29 18:16   ` Dave Hansen
2016-01-29 18:16 ` [PATCH 05/31] x86, pkeys: define new CR4 bit Dave Hansen
2016-01-29 18:16   ` Dave Hansen
2016-01-29 18:16 ` [PATCH 06/31] x86, pkeys: add PKRU xsave fields and data structure(s) Dave Hansen
2016-01-29 18:16   ` Dave Hansen
2016-01-29 18:16 ` [PATCH 07/31] x86, pkeys: PTE bits for storing protection key Dave Hansen
2016-01-29 18:16   ` Dave Hansen
2016-01-29 18:16 ` [PATCH 08/31] x86, pkeys: new page fault error code bit: PF_PK Dave Hansen
2016-01-29 18:16   ` Dave Hansen
2016-01-29 18:16 ` [PATCH 09/31] x86, pkeys: store protection in high VMA flags Dave Hansen
2016-01-29 18:16   ` Dave Hansen
2016-01-29 18:16 ` [PATCH 10/31] x86, pkeys: arch-specific protection bits Dave Hansen
2016-01-29 18:16   ` Dave Hansen
2016-01-29 18:16 ` [PATCH 11/31] x86, pkeys: pass VMA down in to fault signal generation code Dave Hansen
2016-01-29 18:16   ` Dave Hansen
2016-01-29 18:16 ` [PATCH 12/31] signals, pkeys: notify userspace about protection key faults Dave Hansen
2016-01-29 18:16   ` Dave Hansen
2016-01-29 18:17 ` [PATCH 13/31] x86, pkeys: fill in pkey field in siginfo Dave Hansen
2016-01-29 18:17   ` Dave Hansen
2016-01-29 18:17 ` [PATCH 14/31] x86, pkeys: add functions to fetch PKRU Dave Hansen
2016-01-29 18:17   ` Dave Hansen
2016-01-29 18:17 ` [PATCH 15/31] mm: factor out VMA fault permission checking Dave Hansen
2016-01-29 18:17   ` Dave Hansen
2016-01-29 18:17 ` [PATCH 16/31] x86, mm: simplify get_user_pages() PTE bit handling Dave Hansen
2016-01-29 18:17   ` Dave Hansen
2016-01-29 18:17 ` [PATCH 17/31] x86, pkeys: check VMAs and PTEs for protection keys Dave Hansen
2016-01-29 18:17   ` Dave Hansen
2016-01-29 18:17 ` [PATCH 18/31] mm: do not enforce PKEY permissions on "foreign" mm access Dave Hansen
2016-01-29 18:17   ` Dave Hansen
2016-01-29 18:17 ` [PATCH 19/31] x86, pkeys: optimize fault handling in access_error() Dave Hansen
2016-01-29 18:17   ` Dave Hansen
2016-01-29 18:17 ` [PATCH 20/31] x86, pkeys: differentiate instruction fetches Dave Hansen
2016-01-29 18:17   ` Dave Hansen
2016-01-29 18:17 ` [PATCH 21/31] x86, pkeys: dump PKRU with other kernel registers Dave Hansen
2016-01-29 18:17   ` Dave Hansen
2016-01-29 18:17 ` [PATCH 22/31] x86, pkeys: dump pkey from VMA in /proc/pid/smaps Dave Hansen
2016-01-29 18:17   ` Dave Hansen
2016-02-02 16:11   ` Vlastimil Babka
2016-02-02 16:11     ` Vlastimil Babka
2016-02-02 19:04     ` Dave Hansen
2016-02-02 19:04       ` Dave Hansen
2016-01-29 18:17 ` [PATCH 23/31] x86, pkeys: add Kconfig prompt to existing config option Dave Hansen
2016-01-29 18:17   ` Dave Hansen
2016-01-29 18:17 ` [PATCH 24/31] x86, pkeys: actually enable Memory Protection Keys in CPU Dave Hansen
2016-01-29 18:17   ` Dave Hansen
2016-01-29 18:17 ` [PATCH 25/31] mm, multi-arch: pass a protection key in to calc_vm_flag_bits() Dave Hansen
2016-01-29 18:17   ` Dave Hansen
2016-01-29 18:17 ` [PATCH 26/31] x86, pkeys: add arch_validate_pkey() Dave Hansen
2016-01-29 18:17   ` Dave Hansen
2016-01-29 18:17 ` [PATCH 27/31] x86: separate out LDT init from context init Dave Hansen
2016-01-29 18:17   ` Dave Hansen
2016-01-29 18:17 ` [PATCH 28/31] x86, fpu: allow setting of XSAVE state Dave Hansen
2016-01-29 18:17   ` Dave Hansen
2016-01-29 18:17 ` [PATCH 29/31] x86, pkeys: allow kernel to modify user pkey rights register Dave Hansen
2016-01-29 18:17   ` Dave Hansen
2016-01-29 18:17 ` [PATCH 30/31] x86, pkeys: create an x86 arch_calc_vm_prot_bits() for VMA flags Dave Hansen
2016-01-29 18:17   ` Dave Hansen
2016-01-29 18:17 ` [PATCH 31/31] x86, pkeys: execute-only support Dave Hansen
2016-01-29 18:17   ` Dave Hansen
  -- strict thread matches above, loose matches on Subject: below --
2016-01-07  0:01 [PATCH 00/31] x86: Memory Protection Keys (v8) Dave Hansen
2016-01-07  0:01 ` [PATCH 01/31] mm, gup: introduce concept of "foreign" get_user_pages() Dave Hansen
2016-01-07  0:01   ` Dave Hansen
2016-01-13 19:00   ` Vlastimil Babka
2016-01-13 19:00     ` Vlastimil Babka
2016-01-13 19:16     ` Dave Hansen
2016-01-13 19:16       ` Dave Hansen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160209124649.GA20153@gmail.com \
    --to=mingo@kernel.org \
    --cc=aarcange@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=dave.hansen@linux.intel.com \
    --cc=dave@sr71.net \
    --cc=jack@suse.cz \
    --cc=kirill.shutemov@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=n-horiguchi@ah.jp.nec.com \
    --cc=srikar@linux.vnet.ibm.com \
    --cc=torvalds@linux-foundation.org \
    --cc=vbabka@suse.cz \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.