Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp3284166pxb; Tue, 19 Jan 2021 20:00:01 -0800 (PST) X-Google-Smtp-Source: ABdhPJwk8jnjjly7gKWaFZFo4rjpl81IzrZNyv4D45/XR5wjcv0VbqPbHTR9tSnCGEdIVtPJiIcT X-Received: by 2002:a17:906:4151:: with SMTP id l17mr5148185ejk.54.1611115201470; Tue, 19 Jan 2021 20:00:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611115201; cv=none; d=google.com; s=arc-20160816; b=hcjzVi1oe+HF30P12U/5wQ/Aw0Q19N5XL0Qtn8Vn4VDy4qNcUdLVopqUhj/g6Aaf2Z Dex7YkSZachcIokk22KBWIr2kxlsjPc9c/+FFG4zuhhWmw65RSEmkhZI/Y/fPFPg9at4 2NctxLRmcK/D3Ib7+uUhG2ABQkam2mrPcr+BDMa7QK/uz80Fzy235jsEhXjYRuXTO10A 4dq97JBGNFfSRlAGySoN+tsTbrSr7a/+5n+uEy0I4WQc5Ewgw3lYrLwIdgdXvzlEWzx3 zhIWRBEIlWHgi6LUXWIs4BVRI4iUGGA/8ljhFtkoGYBynlwzqO6oGy2b4qHQ8EYoZwsw zQUQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=FmV9SzIZ8+8zzIqAItAMq9tBUhGOp54tCtOOuwvWSqU=; b=Ftxe30W1IuveFUUlD86/gGCVOyvD3BBkoqorjZJJSRh/Anefj4iinRmmiWTReIhadH N9FznrrsPMd96AVaK22NAbtSj5vKcnbB+cd/HxeyM04htuQBHFOO6umO0Goq5ETz514q ypT32fuR8Po3ajV5SF0vkxW1IIiPxdO06vpkkgbWAlS2jJPQuD8Bb2AOSA43HaEfpAiW LhIJnZCREFvrWJEViJzEpHTU1l5hQAae7iqvBnz1NbM5SrG2hfgcFJyNayga7F/CUT4i aHIvxONVNFKYkf/VTSk1c0+LYFN5OpwwCwb3wxMTDUBOKHMUXHwz326flMGEdTtlytwW D1tg== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id mj8si244815ejb.586.2021.01.19.19.59.36; Tue, 19 Jan 2021 20:00:01 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728573AbhATD6x (ORCPT + 99 others); Tue, 19 Jan 2021 22:58:53 -0500 Received: from out30-42.freemail.mail.aliyun.com ([115.124.30.42]:45449 "EHLO out30-42.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731757AbhATD6H (ORCPT ); Tue, 19 Jan 2021 22:58:07 -0500 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R141e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04357;MF=tianjia.zhang@linux.alibaba.com;NM=1;PH=DS;RN=16;SR=0;TI=SMTPD_---0UMI0fsI_1611115039; Received: from 30.25.183.227(mailfrom:tianjia.zhang@linux.alibaba.com fp:SMTPD_---0UMI0fsI_1611115039) by smtp.aliyun-inc.com(127.0.0.1); Wed, 20 Jan 2021 11:57:20 +0800 Subject: Re: [PATCH] x86/sgx: Allows ioctl PROVISION to execute before CREATE To: Sean Christopherson Cc: Jarkko Sakkinen , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , Andrew Morton , Shuah Khan , haitao.huang@intel.com, Kai Huang , x86@kernel.org, linux-sgx@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-kselftest@vger.kernel.org, Jia Zhang References: <20210118133335.98907-1-tianjia.zhang@linux.alibaba.com> From: Tianjia Zhang Message-ID: <5037ee56-0211-f16c-3ea0-86cf8146b7f8@linux.alibaba.com> Date: Wed, 20 Jan 2021 11:57:18 +0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.6.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On 1/20/21 4:05 AM, Sean Christopherson wrote: > On Mon, Jan 18, 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 change this assignment statement to >> or operation, the PROVISION command can be executed earlier and >> more flexibly. >> >> Reported-by: Jia Zhang >> Signed-off-by: Tianjia Zhang >> --- >> arch/x86/kernel/cpu/sgx/ioctl.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/arch/x86/kernel/cpu/sgx/ioctl.c b/arch/x86/kernel/cpu/sgx/ioctl.c >> index f45957c05f69..0ca3fc238bc2 100644 >> --- a/arch/x86/kernel/cpu/sgx/ioctl.c >> +++ b/arch/x86/kernel/cpu/sgx/ioctl.c >> @@ -108,7 +108,7 @@ 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; >> + encl->attributes_mask |= SGX_ATTR_DEBUG | SGX_ATTR_MODE64BIT | SGX_ATTR_KSS; > > Alternatively, move the existing code to sgx_open()? Initializing the field > when the encl object is allocated feels more correct. > This seems like a good idea. Thanks for your suggestion. I have sent v2 patch, include the next two patches. Best regards, Tianjia