Received: by 2002:a19:f614:0:0:0:0:0 with SMTP id x20csp37198lfe; Fri, 15 Apr 2022 18:16:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzTSyNvredLWahx/iEW+GFhahuHToPpXV0hHIVyYtqznxqZQkxSbyoiJ5VL1WTrjE4ILJKn X-Received: by 2002:a63:d149:0:b0:384:b288:8704 with SMTP id c9-20020a63d149000000b00384b2888704mr1239107pgj.112.1650071771813; Fri, 15 Apr 2022 18:16:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650071771; cv=none; d=google.com; s=arc-20160816; b=0WojW6loze7fGzze9sn4Rce6Q2TeYnUgDReVSrGQCMKiUlmXHXmtDm35fQC3s9xbE2 cjEgCzomMaPuVZMeI1KYFIB2kw1h14R05CXaNoX26I/3aP2+bx7IPgUmxupJUJr82cuA 3lccCoBaZHRYqnm62PvgAAVETTvp87yFlCh6jOyxuvgkVJJHjl+63ZLqAaNqEv11F2ss JGhegy+Nic/tHpf/yAtNijj4tC3rdi1XPV9JHj6fASsaQ/gcQpVE/EkHmFfdovqGwY0q bEAE2gyBqxb7hwuf3XTO0w16fCSL71ae4HiQszE8xg1qcKOnIvkR0ncF1Iaa4607M6NQ uS7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:message-id:organization :from:content-transfer-encoding:mime-version:date:references:subject :cc:to:dkim-signature; bh=mKnDPcylV7BmENLV7TvfkwvtaijBpIwhqdbRffv1W+c=; b=A0czbPvtu/9O5igxRmMwnVR2sEYQjiWe3QCEU0kzCczTEiRKBtsHBROVezan1WfeMs IKPvs3AfVkomMVPS4sfvR4Pt4upEEaqsc2b1fK/kk7gICm5nPPpY46KIAAo6n2UPLGtV tdr1looUoTEoec3or4LhudBoiRjIN3hQ4aWvvQu2is5FRGVZpHPfyjdqTC9Q8wSP2NhT T7e6CzVBmLcpxWvFLTmIYLVNFmxzyFJSTHHiPKMKAYqYL/Dk5OkHFJMTUSMSM2uSEydD 18xof28C5oaGr0UxXQxCVxFWsim3jOJoMZNCDpj+UsQDHC0Y1vin/N94FAvC6CFkBzf7 1ixw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=LjIollzP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id i62-20020a638741000000b003a0bfc020easi2797855pge.35.2022.04.15.18.16.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Apr 2022 18:16:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=LjIollzP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 5A647139ACD; Fri, 15 Apr 2022 17:52:41 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1354169AbiDON5y (ORCPT + 99 others); Fri, 15 Apr 2022 09:57:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34030 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1354196AbiDON5a (ORCPT ); Fri, 15 Apr 2022 09:57:30 -0400 Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 256305581; Fri, 15 Apr 2022 06:55:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1650030901; x=1681566901; h=to:cc:subject:references:date:mime-version: content-transfer-encoding:from:message-id:in-reply-to; bh=rnIvYvNkZSMlVf1curZVeeehjye1dFlSwJzy1pjQQ4A=; b=LjIollzPWpojXfctNvSRs6aV5pa/IfK37H8+wQunCeuBb3S3LNhHUNys Vb1V19gjb3qJuhMjht+TvRW1k+1W6ni+ozPPfv7MENW0VDTCzfOLGJ1XN 0c33Cgg8mp+a6baHdh+VvH8whbLybODaU0mpFRET/zXMtOks3ARkXKThp ZUbJNH0z92TgI6Hvizf+h7a7DfXht2kD9kcg05bdjZjLb0SwgTR76N8jY yPR8bodq0IqoX7D1dns3jcm+A/St50DMzX600LOyjAEbY5SA8X4A9EBQA aEpmP/GZo2zfhZa4DZw3ZJAMfnYo6i/54KY7Tjaf3iN8PDSVZxnioLsrY g==; X-IronPort-AV: E=McAfee;i="6400,9594,10317"; a="250454121" X-IronPort-AV: E=Sophos;i="5.90,262,1643702400"; d="scan'208";a="250454121" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Apr 2022 06:55:00 -0700 X-IronPort-AV: E=Sophos;i="5.90,262,1643702400"; d="scan'208";a="662093589" Received: from fkchan-mobl1.amr.corp.intel.com (HELO hhuan26-mobl1.mshome.net) ([10.212.59.147]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-SHA; 15 Apr 2022 06:54:58 -0700 Content-Type: text/plain; charset=iso-8859-15; format=flowed; delsp=yes To: "Jarkko Sakkinen" , dave.hansen@linux.intel.com, tglx@linutronix.de, bp@alien8.de, luto@kernel.org, mingo@redhat.com, linux-sgx@vger.kernel.org, x86@kernel.org, shuah@kernel.org, linux-kselftest@vger.kernel.org, "Reinette Chatre" Cc: seanjc@google.com, kai.huang@intel.com, cathy.zhang@intel.com, cedric.xing@intel.com, haitao.huang@intel.com, mark.shanahan@intel.com, vijay.dhanraj@intel.com, hpa@zytor.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH V4 14/31] x86/sgx: Support VA page allocation without reclaiming References: <0ab32196f5056b25c34fb89fcc4dc28a5d875d2e.1649878359.git.reinette.chatre@intel.com> <767b99c5-f28e-4b8f-5147-6e1d290ca5c6@intel.com> Date: Fri, 15 Apr 2022 08:54:53 -0500 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: "Haitao Huang" Organization: Intel Corp Message-ID: In-Reply-To: <767b99c5-f28e-4b8f-5147-6e1d290ca5c6@intel.com> User-Agent: Opera Mail/1.0 (Win32) X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 14 Apr 2022 11:30:34 -0500, Reinette Chatre wrote: > Hi Jarkko, > > On 4/14/2022 4:18 AM, Jarkko Sakkinen wrote: >> On Wed, 2022-04-13 at 14:10 -0700, Reinette Chatre wrote: >>> struct sgx_encl should be protected with the mutex >>> sgx_encl->lock. One exception is sgx_encl->page_cnt that >>> is incremented (in sgx_encl_grow()) when an enclave page >>> is added to the enclave. The reason the mutex is not held >>> is to allow the reclaimer to be called directly if there are >>> no EPC pages (in support of a new VA page) available at the time. >>> >>> Incrementing sgx_encl->page_cnt without sgc_encl->lock held >>> is currently (before SGX2) safe from concurrent updates because >>> all paths in which sgx_encl_grow() is called occur before >>> enclave initialization and are protected with an atomic >>> operation on SGX_ENCL_IOCTL. >>> >>> SGX2 includes support for dynamically adding pages after >>> enclave initialization where the protection of SGX_ENCL_IOCTL >>> is not available. >>> >>> Make direct reclaim of EPC pages optional when new VA pages >>> are added to the enclave. Essentially the existing "reclaim" >>> flag used when regular EPC pages are added to an enclave >>> becomes available to the caller when used to allocate VA pages >>> instead of always being "true". >>> >>> When adding pages without invoking the reclaimer it is possible >>> to do so with sgx_encl->lock held, gaining its protection against >>> concurrent updates to sgx_encl->page_cnt after enclave >>> initialization. >>> >>> No functional change. >>> >>> Reported-by: Haitao Huang >>> Tested-by: Haitao Huang >>> Signed-off-by: Reinette Chatre >> >> Reviewed-by: Jarkko Sakkinen > > Thank you. > >> >> Nit: I don't think tested-by is in the right patch here. Maybe >> Haitao's tested-by should be moved into patch that actually adds >> support for EAUG? Not something I would NAK this patch, just >> wondering... > > Yes, that is a good point. While this is the bulk of the fix where > the new API is introduced, the test is only applicable when this API > is used and that is in "x86/sgx: Support adding of pages to an > initialized enclave". I will move the "Tested-by" to that patch. > You can also add my Tested-by for patches adding the new IOCTLs. Our team and I have tested EAUG on #PF, modifying types and permissions with Intel SGX SDK/PSW. Thanks Haitao