linux-sgx.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
To: Sean Christopherson <sean.j.christopherson@intel.com>
Cc: linux-sgx@vger.kernel.org, luto@kernel.org,
	Haitao Huang <haitao.huang@linux.intel.com>
Subject: Re: [PATCH] x86/sgx: Remove PROT_NONE branch from sgx_encl_may_map().
Date: Tue, 21 Apr 2020 00:51:10 +0300	[thread overview]
Message-ID: <20200420215110.GB14637@linux.intel.com> (raw)
In-Reply-To: <20200418043749.GH15609@linux.intel.com>

On Fri, Apr 17, 2020 at 09:37:49PM -0700, Sean Christopherson wrote:
> On Tue, Mar 31, 2020 at 12:13:36AM +0300, Jarkko Sakkinen wrote:
> > On Mon, Mar 30, 2020 at 09:54:52PM +0300, Jarkko Sakkinen wrote:
> > > sgx_encl_may_map() always succeeding when PROT_NONE is given is not that
> > > useful behaviour as one can just well as do an anonymous mapping as
> > > demonstrated by the change in this patch to the test program. As a
> > > consequence, remove the special case.
> > > 
> > > Pratically any possible way to make sure that you don't overwrite anything
> > > useful in the memory, should be fine. MAP_FIXED does not care what's
> > > underneath (if you want't it to care you ought to use
> > > MAP_FIXED_NO_REPLACE).
> > > 
> > > After this change, the selftest run called sgx_mmap() only three times
> > > (TCS, text, data) instead of four.
> > > 
> > >         test_sgx-1811  [002] ....   586.907585: sgx_mmap <-mmap_region
> > >         test_sgx-1811  [002] ....   586.911752: sgx_mmap <-mmap_region
> > >         test_sgx-1811  [002] ....   586.911756: sgx_mmap <-mmap_region
> > > 
> > > This also gives more angles to segregate enclave building and mapping as
> > > the mmap()'s need to be applied only when the enclave is fully built:
> > > 
> > > Cc: luto@kernel.org
> > > Cc: Haitao Huang <haitao.huang@linux.intel.com>
> > > Cc: Sean Christopherson <sean.j.christopherson@intel.com>
> > > Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
> > 
> > Sean, would be cool if you can try this out soonish because I'm
> > building on top of this.
> 
> Two and a half weeks is soonish, right?
> 
> Anyways, finally tested this, no issues.  Just to be different than the
> selftest, I used MAP_PRIVATE instead of MAP_SHARED along with MAP_ANONYMOUS
> in my test code.

Ah, MAP_SHARED was not intentional. Not gonna change it tho because both
should equally work (or basically anything to guarante the availability
of the address space).

/Jarkko

      reply	other threads:[~2020-04-20 21:51 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-30 18:54 [PATCH] x86/sgx: Remove PROT_NONE branch from sgx_encl_may_map() Jarkko Sakkinen
2020-03-30 21:13 ` Jarkko Sakkinen
2020-04-18  4:37   ` Sean Christopherson
2020-04-20 21:51     ` Jarkko Sakkinen [this message]

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=20200420215110.GB14637@linux.intel.com \
    --to=jarkko.sakkinen@linux.intel.com \
    --cc=haitao.huang@linux.intel.com \
    --cc=linux-sgx@vger.kernel.org \
    --cc=luto@kernel.org \
    --cc=sean.j.christopherson@intel.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).