mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
To: "Christopherson, Sean J" <sean.j.christopherson@intel.com>
Cc: "intel-sgx-kernel-dev@lists.01.org" 
	<intel-sgx-kernel-dev@lists.01.org>,
	"platform-driver-x86@vger.kernel.org" 
	<platform-driver-x86@vger.kernel.org>,
	"x86@kernel.org" <x86@kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Ingo Molnar <mingo@redhat.com>, "H. Peter Anvin" <hpa@zytor.com>,
	Darren Hart <dvhart@infradead.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Andy Shevchenko <andy@infradead.org>
Subject: Re: [intel-sgx-kernel-dev] [PATCH v7 4/8] intel_sgx: driver for Intel Software Guard Extensions
Date: Fri, 15 Dec 2017 17:02:39 +0200	[thread overview]
Message-ID: <20171215150239.7n2q4yb4ka3ruzcw@linux.intel.com> (raw)
In-Reply-To: <37306EFA9975BE469F115FDE982C075BC6B3BD95@ORSMSX108.amr.corp.intel.com>

On Thu, Dec 14, 2017 at 09:36:05PM +0000, Christopherson, Sean J wrote:
> On Thu, Dec 14, 2017 at 03:10:06PM +0200, Jarkko Sakkinen wrote:
> > On Tue, Dec 12, 2017 at 01:46:48PM -0800, Sean Christopherson wrote:
> > > So it looks like you avoid the described case by moving B to the head of
> > > the list in sgx_eldu.  The bug I am seeing is still straightforward to
> > > theorize:
> > >
> > >     1. Three VA pages.  List = A->B->C
> > >     2. Fill A and B, use one entry in C.  List = C->B->A
> > >     3. ELDU, freeing a slot in B.  List = B->C->A
> > >     4. EWB, consuming the last slot in B.  List = B->C->A
> > >     5. ELDU, freeing a slot in A.  List = A->B->C
> > >     6. EWB, consuming the last slot in A.  List = A->B->C
> > >     7. ELDU, but both A and B are full
> > >     8. Explode
> >
> > I see. It is easy to fix by moving back to of the list immediately after
> > last allocation. Thanks for pointing this out.
> 
> Why not keep it simple and iterate over all VA pages?  You can still
> move full pages to the back of the list to reduce the number of times
> full pages are queried.  IMO, juggling the pages on every EWB/ELDU
> adds complexity for little to no gain; there's no guarantee that the
> cache/TLB benefits of reusing a VA slot justifies the potential for
> thrashing the list, e.g. moving a previously-full VA page to the head
> of the list on ELDU will cause that page to get bounced back to the
> end of the list on the next EWB.  Besides, whatever performance might
> be gained is a drop in the bucket compared to the performance hit of
> evicting enough EPC pages to fill multiple VA pages.
> 
> e.g.
> 
> 	list_for_each_entry_safe(va_page, tmp, &encl->va_pages, list) {
> 		va_offset = sgx_alloc_va_slot(va_page);
> 		if (va_offset < PAGE_SIZE)
> 			break;
> 
> 		list_move_tail(&va_page->list, &full_pages);
> 	}
> 	list_splice_tail(&full_pages, &va_page->list);

It is easy to just to check whether VA page is full and move it back
of the list if it is.

/Jarkko

  reply	other threads:[~2017-12-15 15:02 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-07  1:54 [PATCH v7 0/8] Intel SGX Driver Jarkko Sakkinen
2017-12-07  1:54 ` [PATCH v7 1/8] intel_sgx: updated MAINTAINERS Jarkko Sakkinen
2017-12-07  1:54 ` [PATCH v7 2/8] x86: add SGX definitions to cpufeature Jarkko Sakkinen
2017-12-07  1:54 ` [PATCH v7 3/8] x86: add SGX definitions to msr-index.h Jarkko Sakkinen
2017-12-07  1:54 ` [PATCH v7 4/8] intel_sgx: driver for Intel Software Guard Extensions Jarkko Sakkinen
2017-12-07 14:46   ` [intel-sgx-kernel-dev] " Christopherson, Sean J
2017-12-07 16:05     ` Jarkko Sakkinen
2017-12-07 16:12       ` Jarkko Sakkinen
2017-12-08 15:31       ` Christopherson, Sean J
2017-12-14 12:42         ` Jarkko Sakkinen
2017-12-12 21:32       ` Sean Christopherson
2017-12-14 13:03         ` Jarkko Sakkinen
     [not found]       ` <37306EFA9975BE469F115FDE982C075BC6B39E1D@ORSMSX108.amr.corp.intel.com>
2017-12-12 21:46         ` Sean Christopherson
2017-12-14 13:10           ` Jarkko Sakkinen
2017-12-14 21:36             ` Christopherson, Sean J
2017-12-15 15:02               ` Jarkko Sakkinen [this message]
2017-12-12  7:42   ` Ayoun, Serge
2017-12-07  1:54 ` [PATCH v7 5/8] intel_sgx: ptrace() support Jarkko Sakkinen
2017-12-07  1:54 ` [PATCH v7 6/8] intel_sgx: driver documentation Jarkko Sakkinen
2017-12-07  1:54 ` [PATCH v7 7/8] fs/pipe.c: export create_pipe_files() Jarkko Sakkinen
2017-12-07  1:54 ` [PATCH v7 8/8] intel_sgx: in-kernel launch enclave Jarkko Sakkinen

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=20171215150239.7n2q4yb4ka3ruzcw@linux.intel.com \
    --to=jarkko.sakkinen@linux.intel.com \
    --cc=andy@infradead.org \
    --cc=dvhart@infradead.org \
    --cc=hpa@zytor.com \
    --cc=intel-sgx-kernel-dev@lists.01.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=platform-driver-x86@vger.kernel.org \
    --cc=sean.j.christopherson@intel.com \
    --cc=tglx@linutronix.de \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome