Linux-Sgx Archive on lore.kernel.org
 help / color / Atom feed
From: "Ayoun, Serge" <serge.ayoun@intel.com>
To: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>,
	"linux-sgx@vger.kernel.org" <linux-sgx@vger.kernel.org>
Cc: "Christopherson, Sean J" <sean.j.christopherson@intel.com>,
	"Katz-zamir, Shay" <shay.katz-zamir@intel.com>
Subject: RE: [PATCH 1/4] x86/sgx: Replace @is_secs_child with @pt in sgx_encl_ewb()
Date: Mon, 26 Aug 2019 14:31:54 +0000
Message-ID: <88B7642769729B409B4A93D7C5E0C5E7C6624865@hasmsx108.ger.corp.intel.com> (raw)
In-Reply-To: <20190823161616.27644-2-jarkko.sakkinen@linux.intel.com>

> On Behalf Of Jarkko Sakkinen
> Sent: Friday, August 23, 2019 19:16
> To: linux-sgx@vger.kernel.org
> Cc: Christopherson, Sean J <sean.j.christopherson@intel.com>; Ayoun,
> Serge <serge.ayoun@intel.com>; Katz-zamir, Shay <shay.katz-
> zamir@intel.com>; Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
> Subject: [PATCH 1/4] x86/sgx: Replace @is_secs_child with @pt in
> sgx_encl_ewb()
> 
> Sean complained about boolean parameters so I though that maybe it would
> be good to rework the EWB flow in a way that it operates by a page type and
> here is the result. The contract is and will be that as long as you give the
> correct page type, you will get what you want. That is why I set REG and TCS
> appropriately even though they are treated the same way at this point of
> time.
> 
> Cc: Sean Christopherson <sean.j.christopherson@intel.com>
> Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
> ---
>  arch/x86/kernel/cpu/sgx/reclaim.c | 43 +++++++++++++++++++------------
>  1 file changed, 27 insertions(+), 16 deletions(-)
> 
> diff --git a/arch/x86/kernel/cpu/sgx/reclaim.c
> b/arch/x86/kernel/cpu/sgx/reclaim.c
> index 00f596c64a2d..3f10a8ff00b7 100644
> --- a/arch/x86/kernel/cpu/sgx/reclaim.c
> +++ b/arch/x86/kernel/cpu/sgx/reclaim.c
> @@ -221,7 +221,7 @@ static void sgx_reclaimer_block(struct sgx_epc_page
> *epc_page)
> 
>  static int __sgx_encl_ewb(struct sgx_encl *encl, struct sgx_epc_page
> *epc_page,
>  			  struct sgx_va_page *va_page, unsigned int
> va_offset,
> -			  bool is_secs_child)
> +			  unsigned int pt)
>  {
>  	struct sgx_encl_page *encl_page = epc_page->owner;
>  	struct sgx_pageinfo pginfo;
> @@ -232,10 +232,14 @@ static int __sgx_encl_ewb(struct sgx_encl *encl,
> struct sgx_epc_page *epc_page,
>  	struct page *pcmd;
>  	int ret;
> 
> -	if (is_secs_child)
> -		page_index = SGX_ENCL_PAGE_INDEX(encl_page);
> -	else
> +	if (pt != SGX_SECINFO_SECS && pt != SGX_SECINFO_TCS &&
> +	    pt != SGX_SECINFO_REG)
> +		return -EINVAL;

Not sure about this one since this 'if' should never happen, unless there is a bug
Not clear if the caller (sgx_encl_ewb) will handle -EINVAL properly.
Maybe would be better to issue some warning message or BUG_ON

---------------------------------------------------------------------
Intel Israel (74) Limited

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.


  reply index

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-23 16:16 [PATCH 0/4] Remaining updates for v22 Jarkko Sakkinen
2019-08-23 16:16 ` [PATCH 1/4] x86/sgx: Replace @is_secs_child with @pt in sgx_encl_ewb() Jarkko Sakkinen
2019-08-26 14:31   ` Ayoun, Serge [this message]
2019-08-26 16:25     ` Jarkko Sakkinen
2019-08-23 16:16 ` [PATCH 2/4] x86/sgx: Validate TCS permssions in sgx_validate_secinfo() Jarkko Sakkinen
2019-08-23 16:16 ` [PATCH 3/4] x86/sgx: Remove a deperecated enum Jarkko Sakkinen
2019-08-23 16:16 ` [PATCH 4/4] x86/sgx: Move VM prot bits calculation to sgx_encl_page_alloc() Jarkko Sakkinen
2019-08-23 21:53 ` [PATCH 0/4] Remaining updates for v22 Sean Christopherson
2019-08-26  5:39   ` Jarkko Sakkinen

Reply instructions:

You may reply publically 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=88B7642769729B409B4A93D7C5E0C5E7C6624865@hasmsx108.ger.corp.intel.com \
    --to=serge.ayoun@intel.com \
    --cc=jarkko.sakkinen@linux.intel.com \
    --cc=linux-sgx@vger.kernel.org \
    --cc=sean.j.christopherson@intel.com \
    --cc=shay.katz-zamir@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

Linux-Sgx Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-sgx/0 linux-sgx/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-sgx linux-sgx/ https://lore.kernel.org/linux-sgx \
		linux-sgx@vger.kernel.org
	public-inbox-index linux-sgx

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-sgx


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git