Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp5404587pxb; Mon, 15 Feb 2021 19:34:54 -0800 (PST) X-Google-Smtp-Source: ABdhPJwpU7TG0c6wcxMORho+aXR+SkpJWM3AO9X43nBWYnb6gak23DynbLkwnew97impQtEOGrpy X-Received: by 2002:a17:906:17d5:: with SMTP id u21mr19023054eje.541.1613446494535; Mon, 15 Feb 2021 19:34:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613446494; cv=none; d=google.com; s=arc-20160816; b=CA9Zxyxm9W+RlZcEEkJih4Va3NUDzvVDZYDF/emjN2VXJyBT4L7mxZFbkSjFgwdita sS8wBI5Yjyv9+45etuwkHHV4nIulJCUoZ6OjlT6aIx5ZiZuU92CMpo7Rnm92jAdiS0XR 34ky8wfKvPfsKaf4O5GNGxv/02SsgLHlNM2UPxeF69H72KLByC1T2WkWtvxWFY+uVV/w 6cuthiIlCpT3QeBhy5mvJ0VLiEMP5+1/6G/gmqbIAk+Xu1G5QFgDsypkXgPIDW6Zdrqx 4dMQHXSIJbrlFUvta28U0Gj5jx4RvQKtZViEkwYiusEjgDepPRiGJc/cCux8kGZg2gEk l5SQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=/+DbxEtg6Xw2oT6KF8qdNjNz56Fdz+Hd0KuSf3S4/bs=; b=MaX+mLKkGAVkkzf4GS19cOog0vBYZ7AdtLlbVmT4Zwl0RzkowhTJ4TrdKRWIsDnG2q HaPzswCtAcTjJzP2p0WcmCwMgVIi0WkasnAIJ2rYJjbgVxNRkBfCdK3pRKo7WqW2gw6c e2+v+RpAg3M/uFOlOf0tZq/hsGhAX+gcx3S4/MzVBsbbXndduM2eET6RCYItyL7yl+Ay 3YofzX0KV68Jsao8jGGvmUhvN8uvuR1CFLCywEbSpTbr9ckDMbl0UP8FJbToLBRl2Lr8 ALM97C/qLXWb0wB5DinlRgUm9CM+8WZXBUlI1yrAoEbRSoFH9ET6JQtRNSoJIIs0S+oA dPsA== 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 dt22si13097801ejc.522.2021.02.15.19.34.31; Mon, 15 Feb 2021 19:34:54 -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 S230001AbhBPDcs (ORCPT + 99 others); Mon, 15 Feb 2021 22:32:48 -0500 Received: from out30-56.freemail.mail.aliyun.com ([115.124.30.56]:53430 "EHLO out30-56.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229894AbhBPDci (ORCPT ); Mon, 15 Feb 2021 22:32:38 -0500 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R211e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=alimailimapcm10staff010182156082;MF=tianjia.zhang@linux.alibaba.com;NM=1;PH=DS;RN=13;SR=0;TI=SMTPD_---0UOjzwRj_1613446294; Received: from localhost(mailfrom:tianjia.zhang@linux.alibaba.com fp:SMTPD_---0UOjzwRj_1613446294) by smtp.aliyun-inc.com(127.0.0.1); Tue, 16 Feb 2021 11:31:35 +0800 From: Tianjia Zhang To: Jarkko Sakkinen , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , Sean Christopherson , Shuah Khan , x86@kernel.org, linux-sgx@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Jia Zhang Cc: Tianjia Zhang Subject: [PATCH v5 2/3] x86/sgx: Allows ioctl PROVISION to execute before CREATE Date: Tue, 16 Feb 2021 11:31:32 +0800 Message-Id: <20210216033133.79543-3-tianjia.zhang@linux.alibaba.com> X-Mailer: git-send-email 2.19.1.3.ge56e4f7 In-Reply-To: <20210216033133.79543-1-tianjia.zhang@linux.alibaba.com> References: <20210216033133.79543-1-tianjia.zhang@linux.alibaba.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In the function sgx_create_enclave(), the direct assignment operation of attributes_mask determines that the ioctl PROVISION operation must be executed after the ioctl CREATE operation, which will limit the flexibility of SGX developers. This patch takes the assignment of attributes_mask from the function sgx_create_enclave() has been moved to the function sgx_open(), this will allow users to perform ioctl PROVISION operations before ioctl CREATE, increase the flexibility of the API and reduce restrictions. Signed-off-by: Tianjia Zhang --- arch/x86/kernel/cpu/sgx/driver.c | 1 + arch/x86/kernel/cpu/sgx/ioctl.c | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/kernel/cpu/sgx/driver.c b/arch/x86/kernel/cpu/sgx/driver.c index 8ce6d8371cfb..892e2a2a3221 100644 --- a/arch/x86/kernel/cpu/sgx/driver.c +++ b/arch/x86/kernel/cpu/sgx/driver.c @@ -36,6 +36,7 @@ static int sgx_open(struct inode *inode, struct file *file) return ret; } + encl->attributes_mask = SGX_ATTR_DEBUG | SGX_ATTR_MODE64BIT | SGX_ATTR_KSS; 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