All of lore.kernel.org
 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
Subject: Re: [PATCH] x86/sgx: Fix ELDU MAC failures
Date: Fri, 23 Aug 2019 16:35:07 +0300	[thread overview]
Message-ID: <39b3936327dfda8fe36ee8ea103d1d5e7779bd3d.camel@linux.intel.com> (raw)
In-Reply-To: <20190823020002.25550-1-sean.j.christopherson@intel.com>

On Thu, 2019-08-22 at 19:00 -0700, Sean Christopherson wrote:
> Revert a change that directly propagates the page type from SECINFO into
> encl_page->desc.  encl_page->desc is a packed value, jamming the SECINFO
> page_type sets bits that are intended for other uses.
> 
> Specifically, bits 11:3 are used to store the VA offset when a page is
> swapped out and are available for other uses when the page is resident
> in the EPC.  To allow overloading bits 11:3, the VA offset is cleared at
> ELDU and so is not explicitly cleared at EWB, e.g. the VA offset is OR'd
> into encl_page->desc.  As a result, a subsequent ELDU gets a MAC failure
> due to loading the wrong VA offset.
> 
> Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com>
> ---
>  arch/x86/kernel/cpu/sgx/driver/ioctl.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/x86/kernel/cpu/sgx/driver/ioctl.c b/arch/x86/kernel/cpu/sgx/driver/ioctl.c
> index 85e36e530baf..355ce967a77f 100644
> --- a/arch/x86/kernel/cpu/sgx/driver/ioctl.c
> +++ b/arch/x86/kernel/cpu/sgx/driver/ioctl.c
> @@ -140,7 +140,8 @@ static struct sgx_encl_page *sgx_encl_page_alloc(struct sgx_encl *encl,
>  		return ERR_PTR(-ENOMEM);
>  
>  	encl_page->desc = addr;
> -	encl_page->desc |= page_type;
> +	if (page_type == SGX_SECINFO_TCS)
> +		encl_page->desc |= SGX_ENCL_PAGE_TCS;
>  	encl_page->encl = encl;

Oops. How embrassing from my side. Please also ignore my original review
comment about unreadability. The parameter type was right and everything
was right. I was just blind for a while.

This is exactly how it should be e.g. no boolean parameter. I think with
most of this kind of APIs we should follow a patttern the API takes PT
and the function does whatever encoding we have.

/Jarkko


  reply	other threads:[~2019-08-23 13:36 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-23  2:00 [PATCH] x86/sgx: Fix ELDU MAC failures Sean Christopherson
2019-08-23 13:35 ` Jarkko Sakkinen [this message]
2019-08-23 13:39   ` Jarkko Sakkinen
2019-08-23 13:54     ` 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=39b3936327dfda8fe36ee8ea103d1d5e7779bd3d.camel@linux.intel.com \
    --to=jarkko.sakkinen@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.