Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp348719pxb; Wed, 20 Jan 2021 08:24:51 -0800 (PST) X-Google-Smtp-Source: ABdhPJyccv+g8Es2MTOqjQFAmyc3cT+i4KzxgxP5+JCw/3wsLefe5o9I1bD4BbD5lWNpf1y6x+mQ X-Received: by 2002:a05:6402:139a:: with SMTP id b26mr8036267edv.47.1611159890947; Wed, 20 Jan 2021 08:24:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611159890; cv=none; d=google.com; s=arc-20160816; b=gM6eb0MhBfB6BsYoMlWJasVhSe/q8pgPM4ybBmkG8p3P/54BN424gOl9SnV4sIWzc9 IHuZjLGqdGeEf3koK5wbnFtxAy7TR8v+PbA0lyF25fAGc74VUzYLXPzm30EbIG6TpQF1 1kPHRyYCmMx7XQmyhYPh6FRSLZMs+34o/DyiTkeHAoEStxBHJJtxMvTHhgM3EY1qkNs8 RCSVyehMx+vGk9xSOvDCVTr+Y38gHudHE1q5B8eWOKgwWJ8FsPLo9RK2pFE+zDCGsGBp LC4qQO4kmepkCXHwnJpoNjeUA8LGMEiid+6PMYWZPqUjdxgWipyVQJbrKyxwQG1gPT2o EkCQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=MBqThV9Olupan+r++p/11MWGguLV0PkDywP+wSQi6Ys=; b=YabagghMkrFIHESk4HKEFfmJMcGh46O7fUvs7XFHnbpV/Y5UyuEfLVGxZLSz7Hh5ha VkPU/2Sm3MCP6Ca5MIsh8coegyxEC1eKvFxALLrAtX7fpxmAIiRUFPZ7DDQ8TBCoIZJR EySl37p/ZFsJlU+6RbPSxd+ot8ZSJlHe/1eKKp/bebg5kTgKIgfZYnKcwoF2K+IfeSqL AG0A1j7EZ56PDr9CRKDmVW08XosqWoDAZgt61niv/eHEnsm8VuqZxa6aBC5kX9s21WWu rvr6M9btxynZjgn6h0kO2H3Snj+Hu5v7sJlAkz57M4tB1WNzBXHkS3MvU14PcpdgA9mW RZug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=uHr2OtDy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b13si1037166eds.375.2021.01.20.08.24.26; Wed, 20 Jan 2021 08:24:50 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=uHr2OtDy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2403995AbhATQWd (ORCPT + 99 others); Wed, 20 Jan 2021 11:22:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48870 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2403869AbhATQVN (ORCPT ); Wed, 20 Jan 2021 11:21:13 -0500 Received: from mail-pf1-x430.google.com (mail-pf1-x430.google.com [IPv6:2607:f8b0:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6CBE9C0613C1 for ; Wed, 20 Jan 2021 08:20:33 -0800 (PST) Received: by mail-pf1-x430.google.com with SMTP id o20so6383542pfu.0 for ; Wed, 20 Jan 2021 08:20:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=MBqThV9Olupan+r++p/11MWGguLV0PkDywP+wSQi6Ys=; b=uHr2OtDySDWynGYYVHmG0ZLx5k0Xy3+cFC6x79NNNa1TrWBKQOCABpQ2bdlD2NfWMi +/GIjyJLmUCsaXB/23nUzfp1zu2SliNMi8A6LgxHad+C/2ZVK5kZFAW+jOYUu/xSZk1z EeUJsxPMVvRK6t87oEbGkUYD9HUWh+/eZHJk0qPLpKgo5PyjgsRk7/fUTcvhL2CkJFXs KqzPtAqvrzSyUY9ug0lU74cZsa3LZPrDUIO4XYFHc92PGnpclqfTtS9yQcUmZyxRCM/d IMe3GOyNJNRshNj9B5TpSjLH3tG7KBOic6wfjWmCytNxziT4f9tJX+9TY7otjNedyENs zVHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=MBqThV9Olupan+r++p/11MWGguLV0PkDywP+wSQi6Ys=; b=mLvH02fGYrRYBtQC8pJDFx2ihgFoVDyzgtX+riXOZ3bPk/fUvelcqstf4YZPGxJXJs cEeB16gg9gII2OMp3XXL7HVH+cuANs9o2MqiB1k6c572fAGGMDbIuIjXyj83VYEBeH7c O1wjatDyZQT1+huMhYhGF7TjScOlih1qzpBMjqyaMOzdb8JsZ+fMwlDRLMezo6IRwHrT sT4/Oqg6U77LhV/wSBQDz1zNsOJH3CIFuiWodvajqTG+M7foELmqO1dqSFwbV5Xk618L LGwBpTFqgdtd8xOtU4pCooZWOrdx9juYUNITS1zRkWLEDknIbLpwu4lv6QpcP8goP/Jj op8w== X-Gm-Message-State: AOAM533z2c/ArFUF0c96S+vrBVn6fefHftnD6ZIaHX09Is8+Rjw9dWty zpEwFrKw4vSveY6Z1WfA+zogQA== X-Received: by 2002:a63:e40e:: with SMTP id a14mr10073281pgi.345.1611159632434; Wed, 20 Jan 2021 08:20:32 -0800 (PST) Received: from google.com ([2620:15c:f:10:1ea0:b8ff:fe73:50f5]) by smtp.gmail.com with ESMTPSA id h6sm3049073pfr.47.2021.01.20.08.20.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Jan 2021 08:20:31 -0800 (PST) Date: Wed, 20 Jan 2021 08:20:25 -0800 From: Sean Christopherson To: Tianjia Zhang Cc: Jarkko Sakkinen , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , x86@kernel.org, linux-sgx@vger.kernel.org, linux-kernel@vger.kernel.org, Jia Zhang Subject: Re: [PATCH v2] x86/sgx: Allows ioctl PROVISION to execute before CREATE Message-ID: References: <20210120035309.19545-1-tianjia.zhang@linux.alibaba.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210120035309.19545-1-tianjia.zhang@linux.alibaba.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jan 20, 2021, Tianjia Zhang wrote: > In function sgx_encl_create(), the logic of directly assigning > value to attributes_mask determines that the call to > SGX_IOC_ENCLAVE_PROVISION must be after the command of > SGX_IOC_ENCLAVE_CREATE. If move this assignment statement to > function sgx_open(), the PROVISION command can be executed > earlier and more flexibly. Use imperative mood to describe what you're doing, e.g. the "if" leaves the reader wonder whether it's a suggestion or what the patch is actually doing. E.g. something like Move the initialization of an enclave's allowed attributes_mask to sgx_open() to allow the ENCLAVE_PROVISION ioctl() to be invoked before ENCLAVE_CREATE. > Reported-by: Jia Zhang > Suggested-by: Sean Christopherson > Signed-off-by: Tianjia Zhang > --- > arch/x86/kernel/cpu/sgx/driver.c | 3 +++ > arch/x86/kernel/cpu/sgx/ioctl.c | 1 - > 2 files changed, 3 insertions(+), 1 deletion(-) > > diff --git a/arch/x86/kernel/cpu/sgx/driver.c b/arch/x86/kernel/cpu/sgx/driver.c > index f2eac41bb4ff..8766580194ae 100644 > --- a/arch/x86/kernel/cpu/sgx/driver.c > +++ b/arch/x86/kernel/cpu/sgx/driver.c > @@ -36,6 +36,9 @@ static int sgx_open(struct inode *inode, struct file *file) > return ret; > } > > + encl->attributes_mask = SGX_ATTR_DEBUG | SGX_ATTR_MODE64BIT | > + SGX_ATTR_KSS; Probably don't need a newline before SGX_ATTR_KSS. In fact, I wouldn't be surprised if Boris explicitly requested letting the original code go past 80 chars to improve readability. Either way, with a cleaned up changelog: Reviewed-by: Sean Christopherson > + > file->private_data = encl; > > return 0; > diff --git a/arch/x86/kernel/cpu/sgx/ioctl.c b/arch/x86/kernel/cpu/sgx/ioctl.c > index 90a5caf76939..1c6ecf9fbeff 100644 > --- a/arch/x86/kernel/cpu/sgx/ioctl.c > +++ b/arch/x86/kernel/cpu/sgx/ioctl.c > @@ -109,7 +109,6 @@ static int sgx_encl_create(struct sgx_encl *encl, struct sgx_secs *secs) > encl->base = secs->base; > encl->size = secs->size; > encl->attributes = secs->attributes; > - encl->attributes_mask = SGX_ATTR_DEBUG | SGX_ATTR_MODE64BIT | SGX_ATTR_KSS; > > /* Set only after completion, as encl->lock has not been taken. */ > set_bit(SGX_ENCL_CREATED, &encl->flags); > -- > 2.19.1.3.ge56e4f7 >