Re: [RFC PATCH v4 2/4] x86/sgx: Implement support for MADV_WILLNEED

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Mar 20, 2023 at 09:36:14AM +0000, Huang, Kai wrote:
> On Sun, 2023-03-19 at 15:26 +0200, jarkko@xxxxxxxxxx wrote:
> > On Tue, Mar 14, 2023 at 09:54:30AM -0500, Haitao Huang wrote:
> > > On Thu, 09 Mar 2023 05:31:29 -0600, Huang, Kai <kai.huang@xxxxxxxxx> wrote:
> > > > > 
> > > > > Then in v29, PROT_NONE mapping was disallowed for encl_fd before pages
> > > > > EADDed so user space has to mmap anonymously to reserve the range.The
> > > > > intent was still not to allow mmap before pages EADDed (the !page check
> > > > > was still there up to v38)
> > > > 
> > > > Do you know the reason of disallowing PROT_NONE mapping against encl_fd?
> > > > 
> > > 
> > > I think it was to allow user space to do anonymous mapping to reserve
> > > address space for enclave.
> > > Before this point, you have to use PROT_NONE to reserve with encl_fd. There
> > > might be an issue with how #PF and EPC swapping was handled or the elegance
> > > of those flows that motivated the move but I can't remember. ABI was not
> > > fixed at that time so it was OK to change.
> > 
> > Yes, this was done because enclave naturally aligned base address.
> > 
> > 
> 
> Sorry for being ignorant, but you can also get the aligned base address via
> mmap() against encl_fd, correct?  What is the fundamental difference between
> mmap(MAP_ANONYMOUS) vs mmap(encl_fd)?

This is what we do atm:

static unsigned long sgx_get_unmapped_area(struct file *file,
                                           unsigned long addr,
                                           unsigned long len,
                                           unsigned long pgoff,
                                           unsigned long flags)
{
        if ((flags & MAP_TYPE) == MAP_PRIVATE)
                return -EINVAL;

        if (flags & MAP_FIXED)
                return addr;

        return current->mm->get_unmapped_area(file, addr, len, pgoff, flags);
}

BR, Jarkko



[Index of Archives]     [AMD Graphics]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux