[0/3] Introduce version array structure: sgx_va
mbox series

Message ID 20210224222049.240754-1-jarkko@kernel.org
Headers show
Series
  • Introduce version array structure: sgx_va
Related show

Message

Jarkko Sakkinen Feb. 24, 2021, 10:20 p.m. UTC
Introduce an xarray based version array (VA) structure: struct sgx_va.

The use of sgx_va can be later on extended to the following use cases:

- A global VA for reclaimed SECS pages.
- A global VA for reclaimed VA pages.

Testing done while developing the patch:

- With NUC7PJYH: https://www.intel.com/content/www/us/en/products/boards-kits/nuc/kits/nuc7pjyh.html
- seq 10000 | xargs -I {} -P10000 ./test_sgx > /dev/null
- The EPC size was set from BIOS to 32 MB.

Jarkko Sakkinen (3):
  x86/sgx: Move struct sgx_va_page creation to sgx_alloc_va_page()
  x86/sgx: Add a version array (VA) structure
  x86/sgx: Use sgx_va for the enclave's version array

 arch/x86/kernel/cpu/sgx/driver.c |   3 +-
 arch/x86/kernel/cpu/sgx/encl.c   | 180 ++++++++++++++++++++++---------
 arch/x86/kernel/cpu/sgx/encl.h   |  36 ++++---
 arch/x86/kernel/cpu/sgx/ioctl.c  |  77 +++++--------
 arch/x86/kernel/cpu/sgx/main.c   |  19 +---
 5 files changed, 184 insertions(+), 131 deletions(-)

Comments

Dave Hansen Feb. 24, 2021, 11:48 p.m. UTC | #1
On 2/24/21 2:20 PM, Jarkko Sakkinen wrote:
> The use of sgx_va can be later on extended to the following use cases:
> 
> - A global VA for reclaimed SECS pages.
> - A global VA for reclaimed VA pages.
...
>  arch/x86/kernel/cpu/sgx/driver.c |   3 +-
>  arch/x86/kernel/cpu/sgx/encl.c   | 180 ++++++++++++++++++++++---------
>  arch/x86/kernel/cpu/sgx/encl.h   |  36 ++++---
>  arch/x86/kernel/cpu/sgx/ioctl.c  |  77 +++++--------
>  arch/x86/kernel/cpu/sgx/main.c   |  19 +---
>  5 files changed, 184 insertions(+), 131 deletions(-)

It looks interesting.

Were you planning on keeping this on the back burner until we need it
more acutely?  Or, were you thinking it should be merged immediately?
Jarkko Sakkinen Feb. 25, 2021, 1:01 a.m. UTC | #2
On Wed, Feb 24, 2021 at 03:48:50PM -0800, Dave Hansen wrote:
> On 2/24/21 2:20 PM, Jarkko Sakkinen wrote:
> > The use of sgx_va can be later on extended to the following use cases:
> > 
> > - A global VA for reclaimed SECS pages.
> > - A global VA for reclaimed VA pages.
> ...
> >  arch/x86/kernel/cpu/sgx/driver.c |   3 +-
> >  arch/x86/kernel/cpu/sgx/encl.c   | 180 ++++++++++++++++++++++---------
> >  arch/x86/kernel/cpu/sgx/encl.h   |  36 ++++---
> >  arch/x86/kernel/cpu/sgx/ioctl.c  |  77 +++++--------
> >  arch/x86/kernel/cpu/sgx/main.c   |  19 +---
> >  5 files changed, 184 insertions(+), 131 deletions(-)
> 
> It looks interesting.
> 
> Were you planning on keeping this on the back burner until we need it
> more acutely?  Or, were you thinking it should be merged immediately?

I think this can wait. Perhaps, this could be picked to some other patch
set, such as EDMM.

Let's just say that this should be part of anything that touches the page
reclaimer.

IDA might look odd. Mapping through IDA allocated ID's is for conserving
the amount of used EPC pages for the version array.

Alternative would be to linearly map enclave page offset to the VA page
index but that would introduce a sloppy allocation of EPC.

The selected approach, on the other hand, no matter how sparsely you create
enclave pages, that does not add to the amount of EPC VA page usage.

BTW, encl_page->va_page could be removed, and use sgx_va_get() to locate
the VA page, when needed. I'm open for opinions with this one: it's space
vs the cost of access question.

/Jarkko
Jarkko Sakkinen Feb. 25, 2021, 7:34 a.m. UTC | #3
On Thu, Feb 25, 2021 at 12:20:46AM +0200, Jarkko Sakkinen wrote:
> Introduce an xarray based version array (VA) structure: struct sgx_va.
> 
> The use of sgx_va can be later on extended to the following use cases:
> 
> - A global VA for reclaimed SECS pages.
> - A global VA for reclaimed VA pages.
> 
> Testing done while developing the patch:
> 
> - With NUC7PJYH: https://www.intel.com/content/www/us/en/products/boards-kits/nuc/kits/nuc7pjyh.html
> - seq 10000 | xargs -I {} -P10000 ./test_sgx > /dev/null
> - The EPC size was set from BIOS to 32 MB.

In [1], 'va' branch is tip/master with the patch set on top.

[1] https://git.kernel.org/pub/scm/linux/kernel/git/jarkko/linux-sgx.git:

/Jarkko