lkml.org 
[lkml]   [2019]   [Aug]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v21 16/28] x86/sgx: Add the Linux SGX Enclave Driver
On Mon, Aug 05, 2019 at 09:16:44AM -0700, Sean Christopherson wrote:
> On Sat, Jul 13, 2019 at 08:07:52PM +0300, Jarkko Sakkinen wrote:
> > +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_PRIVATE)
> > + return -EINVAL;
> > +
> > + if (flags & MAP_FIXED)
> > + return addr;
> > +
> > + if (len < 2 * PAGE_SIZE || len & (len - 1))
> > + return -EINVAL;
> > +
> > + addr = current->mm->get_unmapped_area(file, addr, 2 * len, pgoff,
> > + flags);
> > + if (IS_ERR_VALUE(addr))
> > + return addr;
> > +
> > + addr = (addr + (len - 1)) & ~(len - 1);
> > +
> > + return addr;
> > +}
>
> Thinking about this more, I don't think the driver should verify or adjust
> @addr and @len during non-fixed mmap(). There is no requirement that
> userspace must map the full ELRANGE, or that an enclave's ELRANGE can
> *never* be mapped to non-EPC. The architectural requirement is that an
> access that hits ELRANGE must map to the EPC *if* the CPU is executing the
> associated enclave.

Yeah, well, these were done in a quite different "ecosystem" where range
was the enclave and not like now. Can be considered as cruft that we
have simply missed when moving the fd associated enclaves.

In the current framework of things it definitely makes sense to remove
these calculations.

So, I guess we will end up to:

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_PRIVATE)
return -EINVAL;

if (flags & MAP_FIXED)
return addr;

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

/Jarkko

\
 
 \ /
  Last update: 2019-08-05 23:40    [W:0.146 / U:0.548 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site