Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp2738647rwb; Fri, 2 Dec 2022 14:25:24 -0800 (PST) X-Google-Smtp-Source: AA0mqf4IoLP2XAYyBOpAkXSy+rLE+DyOVADo3Pdc5dABPHA/T6XZy0iPZX+6X1fOr6DPJXsAMpx1 X-Received: by 2002:a05:6402:134c:b0:46a:1d7:c94d with SMTP id y12-20020a056402134c00b0046a01d7c94dmr28367994edw.327.1670019924476; Fri, 02 Dec 2022 14:25:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670019924; cv=none; d=google.com; s=arc-20160816; b=ngqnlGPO5NDmEjfLIQJMXQDsNeuZeUyi1ueaxa2chEQSbcYpXobJcu4bhREnMmINlJ KIj4PriyZpYIArvA51+UlGwm4ZnVaJ+G1Xqp6Mvrq7f10wKKlTP2+cPJ5pkjBXYWxilx wxR1BIMkBHg/ObnE4Njf9UvlntPFzmHIRqv34Tlt5NtA9LJsx7ZfxzMJFfLNoLLzgkxD yjDh4wrbz9vGwLE9HYRXoRQ0nqmA6enbDMZE5Am+yNDIM/SDLEZhVvXWcTMusCR2FRDt oxb4tZG4EgEo8VkBmCLtevYXvlze4C/kPRa3gy+qFHaMTmjem5rEZGB7y5jzVLbnJrUi B4Qw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=EDfBXWfAHYVtwU57hMCKCO16uMM3c78FeY5S9PDvlJ4=; b=atm7VnQcZLNCYDkE7oflJrasZ5LoyKZ7HZJiBrOEIWMhLG1HVg7FewzCIxteEuESew TzQ5g5cbgxeFQLEocGVjyHTO1WoX5O1nR1ZRlI2C0WRwR2M370ROTl76+BParxluUsSd +i1wLWF3b4q393eXH6JtIqn/ajkB2RBf8OQJdpk6+2GBiu3lhhoIFuxCqj4NKq4iL+5r kMsFLUpasj5FSc/UljCMmQTNP/mP04ULNAgQjJcRvMAUb25kaNLFIDI/4kP7CU5EztFy q1NHR6AxldF/6/yUx60Ap1WWmgh8t0XRXymbDhoJo/rml/CLXsQgZMz/xh/Af76LuHCr OMpQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=nBHCTjZN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ji4-20020a170907980400b007c0ce254c43si1405822ejc.687.2022.12.02.14.25.04; Fri, 02 Dec 2022 14:25:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=nBHCTjZN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234551AbiLBVsh (ORCPT + 82 others); Fri, 2 Dec 2022 16:48:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36476 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234290AbiLBVsf (ORCPT ); Fri, 2 Dec 2022 16:48:35 -0500 Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 676BDEC089; Fri, 2 Dec 2022 13:48:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1670017714; x=1701553714; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=EDfBXWfAHYVtwU57hMCKCO16uMM3c78FeY5S9PDvlJ4=; b=nBHCTjZNwGgHAkuxZ7mFZGwruzY4bIZl2iBPjmSh77HsBpNSaoJPIV0u 6D6U4Z8Sftjq7a1BySK7s9PfoPIEv7uzcQLLRyzUWel7s+rX1vJSG2fQE GqiYY1Ltrag1onaq1uZc2nuwhpQFOzcClnyDOAPEDyXegpq0U7LHmcPrc HmGUpijWhlcCmFZUD5bT1kdexPsBsnKJ6DGztXv/kyMrD2g6r2LLlzvuM Du32wsJssbjV/y7Z+IQasE9irR5RyvR+M9+Jh03KzNCDM6uP3YT1VmdrU ZyItSACFsJSaw4ZQMPsRnhrFh64/l3cUYQs/FbJZEd9GU076BfSC5bVsj g==; X-IronPort-AV: E=McAfee;i="6500,9779,10549"; a="303663264" X-IronPort-AV: E=Sophos;i="5.96,213,1665471600"; d="scan'208";a="303663264" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Dec 2022 13:48:33 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10549"; a="638885159" X-IronPort-AV: E=Sophos;i="5.96,213,1665471600"; d="scan'208";a="638885159" Received: from rsnyder-mobl.amr.corp.intel.com (HELO [10.209.68.71]) ([10.209.68.71]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Dec 2022 13:48:33 -0800 Message-ID: <2015ae96-5459-1f82-596b-f46af08ef766@intel.com> Date: Fri, 2 Dec 2022 13:48:32 -0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.2.2 Subject: Re: [PATCH v2 02/18] x86/sgx: Store struct sgx_encl when allocating new VA pages Content-Language: en-US To: Kristen Carlson Accardi , jarkko@kernel.org, dave.hansen@linux.intel.com, tj@kernel.org, linux-kernel@vger.kernel.org, linux-sgx@vger.kernel.org, cgroups@vger.kernel.org, Thomas Gleixner , Ingo Molnar , Borislav Petkov , x86@kernel.org, "H. Peter Anvin" Cc: zhiquan1.li@intel.com, Sean Christopherson References: <20221202183655.3767674-1-kristen@linux.intel.com> <20221202183655.3767674-3-kristen@linux.intel.com> <3a789b1c-4c70-158b-d764-daec141a5816@intel.com> From: Dave Hansen In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE, SPF_NONE autolearn=ham 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 12/2/22 13:40, Kristen Carlson Accardi wrote: > On Fri, 2022-12-02 at 13:35 -0800, Dave Hansen wrote: >> On 12/2/22 10:36, Kristen Carlson Accardi wrote: >>> When allocating new Version Array (VA) pages, pass the struct >>> sgx_encl >>> of the enclave that is allocating the page. sgx_alloc_epc_page() >>> will >>> store this value in the encl_owner field of the struct >>> sgx_epc_page. In >>> a later patch, VA pages will be placed in an unreclaimable queue, >>> and then when the cgroup max limit is reached and there are no more >>> reclaimable pages and the enclave must be oom killed, all the >>> VA pages associated with that enclave can be uncharged and freed. >> What does this have to do with the 'encl' that is being passed, >> though? >> >> In other words, why is this new sgx_epc_page-to-encl mapping needed >> for >> VA pages now, but it wasn't before? > When we OOM kill an enclave, we want to get rid of all the associated > VA pages too. Prior to this patch, there wasn't a way to easily get the > VA pages associated with an enclave. Given an enclave, we have encl->va_pages to look up all the VA pages. Also, this patch's code allows you to go from a va page to an enclave. That seems like it's going the other direction from what an OOM-kill would need to do.