Re: [PATCH v8 1/8] mm/memfd: Introduce userspace inaccessible memfd

2022-11-03 Thread Vishal Annapurve
On Mon, Oct 24, 2022 at 8:30 PM Kirill A . Shutemov wrote: > > On Fri, Oct 21, 2022 at 04:18:14PM +, Sean Christopherson wrote: > > On Fri, Oct 21, 2022, Chao Peng wrote: > > > > > > > > In the context of userspace inaccessible memfd, what would be a > > > > suggested way to enforce NUMA

Re: [PATCH v8 1/8] mm/memfd: Introduce userspace inaccessible memfd

2022-10-24 Thread David Hildenbrand
On 24.10.22 16:59, Kirill A . Shutemov wrote: On Fri, Oct 21, 2022 at 04:18:14PM +, Sean Christopherson wrote: On Fri, Oct 21, 2022, Chao Peng wrote: In the context of userspace inaccessible memfd, what would be a suggested way to enforce NUMA memory policy for physical memory allocation?

Re: [PATCH v8 1/8] mm/memfd: Introduce userspace inaccessible memfd

2022-10-24 Thread Kirill A . Shutemov
On Fri, Oct 21, 2022 at 04:18:14PM +, Sean Christopherson wrote: > On Fri, Oct 21, 2022, Chao Peng wrote: > > > > > > In the context of userspace inaccessible memfd, what would be a > > > suggested way to enforce NUMA memory policy for physical memory > > > allocation? mbind[1] won't work

Re: [PATCH v8 1/8] mm/memfd: Introduce userspace inaccessible memfd

2022-10-21 Thread Sean Christopherson
On Fri, Oct 21, 2022, Chao Peng wrote: > On Thu, Oct 20, 2022 at 04:20:58PM +0530, Vishal Annapurve wrote: > > On Wed, Oct 19, 2022 at 9:02 PM Kirill A . Shutemov > > wrote: > > > > > > On Tue, Oct 18, 2022 at 07:12:10PM +0530, Vishal Annapurve wrote: > > > > I think moving this

Re: [PATCH v8 1/8] mm/memfd: Introduce userspace inaccessible memfd

2022-10-21 Thread Sean Christopherson
On Fri, Oct 21, 2022, Chao Peng wrote: > > > > In the context of userspace inaccessible memfd, what would be a > > suggested way to enforce NUMA memory policy for physical memory > > allocation? mbind[1] won't work here in absence of virtual address > > range. > > How about set_mempolicy(): >

Re: [PATCH v8 1/8] mm/memfd: Introduce userspace inaccessible memfd

2022-10-21 Thread Chao Peng
On Thu, Oct 20, 2022 at 04:20:58PM +0530, Vishal Annapurve wrote: > On Wed, Oct 19, 2022 at 9:02 PM Kirill A . Shutemov > wrote: > > > > On Tue, Oct 18, 2022 at 07:12:10PM +0530, Vishal Annapurve wrote: > > > On Tue, Oct 18, 2022 at 3:27 AM Kirill A . Shutemov > > > wrote: > > > > > > > > On

Re: [PATCH v8 1/8] mm/memfd: Introduce userspace inaccessible memfd

2022-10-21 Thread Chao Peng
> > In the context of userspace inaccessible memfd, what would be a > suggested way to enforce NUMA memory policy for physical memory > allocation? mbind[1] won't work here in absence of virtual address > range. How about set_mempolicy():

Re: [PATCH v8 1/8] mm/memfd: Introduce userspace inaccessible memfd

2022-10-20 Thread Vishal Annapurve
On Wed, Oct 19, 2022 at 9:02 PM Kirill A . Shutemov wrote: > > On Tue, Oct 18, 2022 at 07:12:10PM +0530, Vishal Annapurve wrote: > > On Tue, Oct 18, 2022 at 3:27 AM Kirill A . Shutemov > > wrote: > > > > > > On Mon, Oct 17, 2022 at 06:39:06PM +0200, Gupta, Pankaj wrote: > > > > On 10/17/2022

Re: [PATCH v8 1/8] mm/memfd: Introduce userspace inaccessible memfd

2022-10-19 Thread Kirill A . Shutemov
On Tue, Oct 18, 2022 at 07:12:10PM +0530, Vishal Annapurve wrote: > On Tue, Oct 18, 2022 at 3:27 AM Kirill A . Shutemov > wrote: > > > > On Mon, Oct 17, 2022 at 06:39:06PM +0200, Gupta, Pankaj wrote: > > > On 10/17/2022 6:19 PM, Kirill A . Shutemov wrote: > > > > On Mon, Oct 17, 2022 at

Re: [PATCH v8 1/8] mm/memfd: Introduce userspace inaccessible memfd

2022-10-19 Thread Fuad Tabba
Hi, On Tue, Oct 18, 2022 at 1:34 AM Sean Christopherson wrote: > > On Fri, Sep 30, 2022, Fuad Tabba wrote: > > > > > > pKVM would also need a way to make an fd accessible again > > > > > > when shared back, which I think isn't possible with this patch. > > > > > > > > > > But does pKVM really

Re: [PATCH v8 1/8] mm/memfd: Introduce userspace inaccessible memfd

2022-10-19 Thread Chao Peng
On Mon, Oct 17, 2022 at 08:05:10PM +0100, Fuad Tabba wrote: > Hi, > > > > > Using both private_fd and userspace_addr is only needed in TDX and other > > > > confidential computing scenarios, pKVM may only use private_fd if the fd > > > > can also be mmaped as a whole to userspace as Sean

Re: [PATCH v8 1/8] mm/memfd: Introduce userspace inaccessible memfd

2022-10-19 Thread Vishal Annapurve
On Thu, Sep 15, 2022 at 8:04 PM Chao Peng wrote: > > From: "Kirill A. Shutemov" > > KVM can use memfd-provided memory for guest memory. For normal userspace > accessible memory, KVM userspace (e.g. QEMU) mmaps the memfd into its > virtual address space and then tells KVM to use the virtual

Re: [PATCH v8 1/8] mm/memfd: Introduce userspace inaccessible memfd

2022-10-18 Thread Vishal Annapurve
On Tue, Oct 18, 2022 at 3:27 AM Kirill A . Shutemov wrote: > > On Mon, Oct 17, 2022 at 06:39:06PM +0200, Gupta, Pankaj wrote: > > On 10/17/2022 6:19 PM, Kirill A . Shutemov wrote: > > > On Mon, Oct 17, 2022 at 03:00:21PM +0200, Vlastimil Babka wrote: > > > > On 9/15/22 16:29, Chao Peng wrote: > >

Re: [PATCH v8 1/8] mm/memfd: Introduce userspace inaccessible memfd

2022-10-17 Thread Sean Christopherson
On Fri, Sep 30, 2022, Fuad Tabba wrote: > > > > > pKVM would also need a way to make an fd accessible again > > > > > when shared back, which I think isn't possible with this patch. > > > > > > > > But does pKVM really want to mmap/munmap a new region at the page-level, > > > > that can cause VMA

Re: [PATCH v8 1/8] mm/memfd: Introduce userspace inaccessible memfd

2022-10-17 Thread Kirill A . Shutemov
On Mon, Oct 17, 2022 at 06:39:06PM +0200, Gupta, Pankaj wrote: > On 10/17/2022 6:19 PM, Kirill A . Shutemov wrote: > > On Mon, Oct 17, 2022 at 03:00:21PM +0200, Vlastimil Babka wrote: > > > On 9/15/22 16:29, Chao Peng wrote: > > > > From: "Kirill A. Shutemov" > > > > > > > > KVM can use

Re: [PATCH v8 1/8] mm/memfd: Introduce userspace inaccessible memfd

2022-10-17 Thread Fuad Tabba
Hi, > > > Using both private_fd and userspace_addr is only needed in TDX and other > > > confidential computing scenarios, pKVM may only use private_fd if the fd > > > can also be mmaped as a whole to userspace as Sean suggested. > > > > That does work in practice, for now at least, and is what I

Re: [PATCH v8 1/8] mm/memfd: Introduce userspace inaccessible memfd

2022-10-17 Thread Gupta, Pankaj
On 10/17/2022 6:19 PM, Kirill A . Shutemov wrote: On Mon, Oct 17, 2022 at 03:00:21PM +0200, Vlastimil Babka wrote: On 9/15/22 16:29, Chao Peng wrote: From: "Kirill A. Shutemov" KVM can use memfd-provided memory for guest memory. For normal userspace accessible memory, KVM userspace (e.g.

Re: [PATCH v8 1/8] mm/memfd: Introduce userspace inaccessible memfd

2022-10-17 Thread Kirill A . Shutemov
On Mon, Oct 17, 2022 at 03:00:21PM +0200, Vlastimil Babka wrote: > On 9/15/22 16:29, Chao Peng wrote: > > From: "Kirill A. Shutemov" > > > > KVM can use memfd-provided memory for guest memory. For normal userspace > > accessible memory, KVM userspace (e.g. QEMU) mmaps the memfd into its > >

Re: [PATCH v8 1/8] mm/memfd: Introduce userspace inaccessible memfd

2022-10-17 Thread Chao Peng
On Mon, Oct 17, 2022 at 11:31:19AM +0100, Fuad Tabba wrote: > Hi, > > > > > > > Actually, for pKVM, there is no need for the guest memory to be > > > GUP'able at all if we use the new inaccessible_get_pfn(). > > > > If pKVM can use inaccessible_get_pfn() to get pfn and can avoid GUP (I > > think

Re: [PATCH v8 1/8] mm/memfd: Introduce userspace inaccessible memfd

2022-10-17 Thread Vlastimil Babka
On 9/15/22 16:29, Chao Peng wrote: > From: "Kirill A. Shutemov" > > KVM can use memfd-provided memory for guest memory. For normal userspace > accessible memory, KVM userspace (e.g. QEMU) mmaps the memfd into its > virtual address space and then tells KVM to use the virtual address to > setup

Re: [PATCH v8 1/8] mm/memfd: Introduce userspace inaccessible memfd

2022-10-17 Thread Fuad Tabba
Hi, > > > > Actually, for pKVM, there is no need for the guest memory to be > > GUP'able at all if we use the new inaccessible_get_pfn(). > > If pKVM can use inaccessible_get_pfn() to get pfn and can avoid GUP (I > think that is the major concern?), do you see any other gap from > existing API?

Re: [PATCH v8 1/8] mm/memfd: Introduce userspace inaccessible memfd

2022-10-13 Thread Chao Peng
On Fri, Sep 30, 2022 at 05:19:00PM +0100, Fuad Tabba wrote: > Hi, > > On Tue, Sep 27, 2022 at 11:47 PM Sean Christopherson > wrote: > > > > On Mon, Sep 26, 2022, Fuad Tabba wrote: > > > Hi, > > > > > > On Mon, Sep 26, 2022 at 3:28 PM Chao Peng > > > wrote: > > > > > > > > On Fri, Sep 23, 2022

Re: [PATCH v8 1/8] mm/memfd: Introduce userspace inaccessible memfd

2022-10-06 Thread Kirill A. Shutemov
On Thu, Oct 06, 2022 at 09:50:28AM +0100, Fuad Tabba wrote: > Hi, > > <...> > > > > diff --git a/mm/memfd_inaccessible.c b/mm/memfd_inaccessible.c > > new file mode 100644 > > index ..2d33cbdd9282 > > --- /dev/null > > +++ b/mm/memfd_inaccessible.c > > <...> > > > +struct file

Re: [PATCH v8 1/8] mm/memfd: Introduce userspace inaccessible memfd

2022-10-06 Thread Fuad Tabba
Hi, <...> > diff --git a/mm/memfd_inaccessible.c b/mm/memfd_inaccessible.c > new file mode 100644 > index ..2d33cbdd9282 > --- /dev/null > +++ b/mm/memfd_inaccessible.c <...> > +struct file *memfd_mkinaccessible(struct file *memfd) > +{ > + struct inaccessible_data *data; >

Re: [PATCH v8 1/8] mm/memfd: Introduce userspace inaccessible memfd

2022-10-04 Thread Fuad Tabba
Hi, On Mon, Oct 3, 2022 at 12:01 PM Kirill A. Shutemov wrote: > > On Mon, Oct 03, 2022 at 08:33:13AM +0100, Fuad Tabba wrote: > > > I think it is "don't do that" category. inaccessible_register_notifier() > > > caller has to know what file it operates on, no? > > > > The thing is, you could oops

Re: [PATCH v8 1/8] mm/memfd: Introduce userspace inaccessible memfd

2022-10-03 Thread Kirill A. Shutemov
On Mon, Oct 03, 2022 at 08:33:13AM +0100, Fuad Tabba wrote: > > I think it is "don't do that" category. inaccessible_register_notifier() > > caller has to know what file it operates on, no? > > The thing is, you could oops the kernel from userspace. For that, all > you have to do is a

Re: [PATCH v8 1/8] mm/memfd: Introduce userspace inaccessible memfd

2022-10-03 Thread Fuad Tabba
Hi On Fri, Sep 30, 2022 at 5:23 PM Kirill A . Shutemov wrote: > > On Fri, Sep 30, 2022 at 05:14:00PM +0100, Fuad Tabba wrote: > > Hi, > > > > <...> > > > > > diff --git a/mm/memfd_inaccessible.c b/mm/memfd_inaccessible.c > > > new file mode 100644 > > > index ..2d33cbdd9282 > > > ---

Re: [PATCH v8 1/8] mm/memfd: Introduce userspace inaccessible memfd

2022-09-30 Thread Fuad Tabba
Hi, On Tue, Sep 27, 2022 at 11:47 PM Sean Christopherson wrote: > > On Mon, Sep 26, 2022, Fuad Tabba wrote: > > Hi, > > > > On Mon, Sep 26, 2022 at 3:28 PM Chao Peng > > wrote: > > > > > > On Fri, Sep 23, 2022 at 04:19:46PM +0100, Fuad Tabba wrote: > > > > > Then on the KVM side, its

Re: [PATCH v8 1/8] mm/memfd: Introduce userspace inaccessible memfd

2022-09-30 Thread Kirill A . Shutemov
On Fri, Sep 30, 2022 at 05:14:00PM +0100, Fuad Tabba wrote: > Hi, > > <...> > > > diff --git a/mm/memfd_inaccessible.c b/mm/memfd_inaccessible.c > > new file mode 100644 > > index ..2d33cbdd9282 > > --- /dev/null > > +++ b/mm/memfd_inaccessible.c > > @@ -0,0 +1,219 @@ > > +//

Re: [PATCH v8 1/8] mm/memfd: Introduce userspace inaccessible memfd

2022-09-30 Thread Fuad Tabba
Hi, <...> > diff --git a/mm/memfd_inaccessible.c b/mm/memfd_inaccessible.c > new file mode 100644 > index ..2d33cbdd9282 > --- /dev/null > +++ b/mm/memfd_inaccessible.c > @@ -0,0 +1,219 @@ > +// SPDX-License-Identifier: GPL-2.0 > +#include "linux/sbitmap.h" > +#include > +#include

Re: [PATCH v8 1/8] mm/memfd: Introduce userspace inaccessible memfd

2022-09-28 Thread Kirill A. Shutemov
On Tue, Sep 27, 2022 at 11:23:24PM +, Sean Christopherson wrote: > On Mon, Sep 26, 2022, David Hildenbrand wrote: > > On 26.09.22 16:48, Kirill A. Shutemov wrote: > > > On Mon, Sep 26, 2022 at 12:35:34PM +0200, David Hildenbrand wrote: > > > > When using DAX, what happens with the shared

Re: [PATCH v8 1/8] mm/memfd: Introduce userspace inaccessible memfd

2022-09-27 Thread Sean Christopherson
On Mon, Sep 26, 2022, David Hildenbrand wrote: > On 26.09.22 16:48, Kirill A. Shutemov wrote: > > On Mon, Sep 26, 2022 at 12:35:34PM +0200, David Hildenbrand wrote: > > > When using DAX, what happens with the shared <->private conversion? Which > > > "type" is supposed to use dax, which not? > > >

Re: [PATCH v8 1/8] mm/memfd: Introduce userspace inaccessible memfd

2022-09-27 Thread Sean Christopherson
On Mon, Sep 26, 2022, Fuad Tabba wrote: > Hi, > > On Mon, Sep 26, 2022 at 3:28 PM Chao Peng wrote: > > > > On Fri, Sep 23, 2022 at 04:19:46PM +0100, Fuad Tabba wrote: > > > > Then on the KVM side, its mmap_start() + mmap_end() sequence would: > > > > > > > > 1. Not be supported for TDX or

Re: [PATCH v8 1/8] mm/memfd: Introduce userspace inaccessible memfd

2022-09-26 Thread Fuad Tabba
Hi, On Mon, Sep 26, 2022 at 3:28 PM Chao Peng wrote: > > On Fri, Sep 23, 2022 at 04:19:46PM +0100, Fuad Tabba wrote: > > > Regarding pKVM's use case, with the shim approach I believe this can be > > > done by > > > allowing userspace mmap() the "hidden" memfd, but with a ton of > > >

Re: [PATCH v8 1/8] mm/memfd: Introduce userspace inaccessible memfd

2022-09-26 Thread David Hildenbrand
On 26.09.22 16:48, Kirill A. Shutemov wrote: On Mon, Sep 26, 2022 at 12:35:34PM +0200, David Hildenbrand wrote: On 23.09.22 02:58, Kirill A . Shutemov wrote: On Mon, Sep 19, 2022 at 11:12:46AM +0200, David Hildenbrand wrote: diff --git a/include/uapi/linux/magic.h b/include/uapi/linux/magic.h

Re: [PATCH v8 1/8] mm/memfd: Introduce userspace inaccessible memfd

2022-09-26 Thread Chao Peng
On Fri, Sep 23, 2022 at 04:19:46PM +0100, Fuad Tabba wrote: > > Regarding pKVM's use case, with the shim approach I believe this can be > > done by > > allowing userspace mmap() the "hidden" memfd, but with a ton of restrictions > > piled on top. > > > > My first thought was to make the uAPI a

Re: [PATCH v8 1/8] mm/memfd: Introduce userspace inaccessible memfd

2022-09-26 Thread Kirill A. Shutemov
On Mon, Sep 26, 2022 at 12:35:34PM +0200, David Hildenbrand wrote: > On 23.09.22 02:58, Kirill A . Shutemov wrote: > > On Mon, Sep 19, 2022 at 11:12:46AM +0200, David Hildenbrand wrote: > > > > diff --git a/include/uapi/linux/magic.h b/include/uapi/linux/magic.h > > > > index

Re: [PATCH v8 1/8] mm/memfd: Introduce userspace inaccessible memfd

2022-09-26 Thread David Hildenbrand
On 23.09.22 02:58, Kirill A . Shutemov wrote: On Mon, Sep 19, 2022 at 11:12:46AM +0200, David Hildenbrand wrote: diff --git a/include/uapi/linux/magic.h b/include/uapi/linux/magic.h index 6325d1d0e90f..9d066be3d7e8 100644 --- a/include/uapi/linux/magic.h +++ b/include/uapi/linux/magic.h @@

Re: [PATCH v8 1/8] mm/memfd: Introduce userspace inaccessible memfd

2022-09-23 Thread Fuad Tabba
Hi, On Fri, Sep 23, 2022 at 1:53 AM Kirill A . Shutemov wrote: > > On Thu, Sep 22, 2022 at 07:49:18PM +, Sean Christopherson wrote: > > On Thu, Sep 22, 2022, Wang, Wei W wrote: > > > On Thursday, September 15, 2022 10:29 PM, Chao Peng wrote: > > > > +int inaccessible_get_pfn(struct file

Re: [PATCH v8 1/8] mm/memfd: Introduce userspace inaccessible memfd

2022-09-23 Thread Fuad Tabba
Hi, <...> > > Regarding pKVM's use case, with the shim approach I believe this can be > > done by > > allowing userspace mmap() the "hidden" memfd, but with a ton of restrictions > > piled on top. > > > > My first thought was to make the uAPI a set of KVM ioctls so that KVM > > could tightly >

Re: [PATCH v8 1/8] mm/memfd: Introduce userspace inaccessible memfd

2022-09-23 Thread Fuad Tabba
Hi, On Mon, Sep 19, 2022 at 8:10 PM Sean Christopherson wrote: > > +Will, Marc and Fuad (apologies if I missed other pKVM folks) > > On Mon, Sep 19, 2022, David Hildenbrand wrote: > > On 15.09.22 16:29, Chao Peng wrote: > > > From: "Kirill A. Shutemov" > > > > > > KVM can use memfd-provided

Re: [PATCH v8 1/8] mm/memfd: Introduce userspace inaccessible memfd

2022-09-22 Thread Kirill A . Shutemov
On Mon, Sep 19, 2022 at 11:12:46AM +0200, David Hildenbrand wrote: > > diff --git a/include/uapi/linux/magic.h b/include/uapi/linux/magic.h > > index 6325d1d0e90f..9d066be3d7e8 100644 > > --- a/include/uapi/linux/magic.h > > +++ b/include/uapi/linux/magic.h > > @@ -101,5 +101,6 @@ > > #define

Re: [PATCH v8 1/8] mm/memfd: Introduce userspace inaccessible memfd

2022-09-22 Thread Kirill A . Shutemov
On Thu, Sep 22, 2022 at 07:49:18PM +, Sean Christopherson wrote: > On Thu, Sep 22, 2022, Wang, Wei W wrote: > > On Thursday, September 15, 2022 10:29 PM, Chao Peng wrote: > > > +int inaccessible_get_pfn(struct file *file, pgoff_t offset, pfn_t *pfn, > > > + int *order) > > >

Re: [PATCH v8 1/8] mm/memfd: Introduce userspace inaccessible memfd

2022-09-22 Thread Sean Christopherson
On Thu, Sep 22, 2022, Wang, Wei W wrote: > On Thursday, September 15, 2022 10:29 PM, Chao Peng wrote: > > +int inaccessible_get_pfn(struct file *file, pgoff_t offset, pfn_t *pfn, > > +int *order) > > Better to remove "order" from this interface? Hard 'no'. > Some callers

RE: [PATCH v8 1/8] mm/memfd: Introduce userspace inaccessible memfd

2022-09-22 Thread Wang, Wei W
On Thursday, September 15, 2022 10:29 PM, Chao Peng wrote: > +int inaccessible_get_pfn(struct file *file, pgoff_t offset, pfn_t *pfn, > + int *order) Better to remove "order" from this interface? Some callers only need to get pfn, and no need to bother with defining and

RE: [PATCH v8 1/8] mm/memfd: Introduce userspace inaccessible memfd

2022-09-22 Thread Wang, Wei W
Perret ; Michael Roth ; > Hocko, Michal ; Muchun Song > ; Wang, Wei W ; > Will Deacon ; Marc Zyngier ; Fuad Tabba > > Subject: Re: [PATCH v8 1/8] mm/memfd: Introduce userspace inaccessible > memfd > > (please excuse any formatting disasters. my internet went out as I was &g

Re: [PATCH v8 1/8] mm/memfd: Introduce userspace inaccessible memfd

2022-09-21 Thread Andy Lutomirski
(please excuse any formatting disasters. my internet went out as I was composing this, and i did my best to rescue it.) On Mon, Sep 19, 2022, at 12:10 PM, Sean Christopherson wrote: > +Will, Marc and Fuad (apologies if I missed other pKVM folks) > > On Mon, Sep 19, 2022, David Hildenbrand

Re: [PATCH v8 1/8] mm/memfd: Introduce userspace inaccessible memfd

2022-09-19 Thread Sean Christopherson
+Will, Marc and Fuad (apologies if I missed other pKVM folks) On Mon, Sep 19, 2022, David Hildenbrand wrote: > On 15.09.22 16:29, Chao Peng wrote: > > From: "Kirill A. Shutemov" > > > > KVM can use memfd-provided memory for guest memory. For normal userspace > > accessible memory, KVM userspace

Re: [PATCH v8 1/8] mm/memfd: Introduce userspace inaccessible memfd

2022-09-19 Thread David Hildenbrand
On 15.09.22 16:29, Chao Peng wrote: From: "Kirill A. Shutemov" KVM can use memfd-provided memory for guest memory. For normal userspace accessible memory, KVM userspace (e.g. QEMU) mmaps the memfd into its virtual address space and then tells KVM to use the virtual address to setup the mapping