Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp2704382rwb; Fri, 2 Dec 2022 13:50:34 -0800 (PST) X-Google-Smtp-Source: AA0mqf7eLUtpGGEz3wFZ1S4NzgbxBCA8LAXrYYFrhLAY+6se4Xp6nNWTtLS6X+zpPSW8zzfWROn0 X-Received: by 2002:a17:906:e090:b0:7c0:cb34:f936 with SMTP id gh16-20020a170906e09000b007c0cb34f936mr2895033ejb.631.1670017833980; Fri, 02 Dec 2022 13:50:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670017833; cv=none; d=google.com; s=arc-20160816; b=VuUhtIMvgQYda9wwzWOe/wwYgJNz/3EjRSITzp0Xc3r3nSa1b+1NxjeB9FjSsQCFbd AJKlsn4yHRvqpkFVECJ9DpTPsJlM8I5y/1uKFnBUUHElCCP3ogVOirKmB9YtoYgKqddJ 2RJujDgyfaugsyZwukBBZ/Ep4yLWxrhhkhzWm7X455dim2BNWITT68niQQsf9B2/nU2F D9YxaCKLI6MMtEHwNDjTXFnseFbdhcGwAHzrGf2r4WdckJl+Zd+vDjAuQtnOgHZHG3Jw 0a5D9+IxhCLx3+f9tEk64M25xA+6/d2OoHXS3MiivDCmDVxjVrMpYK5x7dOUERn+inQ2 24fQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent :content-transfer-encoding:references:in-reply-to:date:cc:to:from :subject:message-id:dkim-signature; bh=NuDVEcz+ZwrxpvyK1gNkgUCJxIW8h0yVGClVY+eE7s8=; b=w5wIgBJmgKGCI/4EPo5fOTuRX1JGM4fHJNZFa7rxzWxGrXn6mz3NaJg7ObdNBu8HWZ WbB9QpKZjLZ3wKt1u8kWR6yLmJfv8dRHrpprs7OIn81oaz8T433Pa9QFXZNbY0z4F54U JPVyFz55CZ1OiZy+cNT+ymt+didI9EToz1vspuuUyODvwAUIIIjufguQltDQOlVje22B IO/oyE84Y/DuDfVr7fn/SRKoYKA2t7zsU3Fcy8hQ6Ra85TaG+CnQCCBPouQPgKPB1TlK 15z541Ss1+CM6LPL91oXaVXFnmZZWw9LDWLRIBTLJkKvyjY1b0fctBzPduKjYR6uKGYI 4plQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=T8Kd0PqA; 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 qw22-20020a1709066a1600b007c0a5799e70si7282374ejc.534.2022.12.02.13.50.14; Fri, 02 Dec 2022 13:50:33 -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=T8Kd0PqA; 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 S234635AbiLBVkc (ORCPT + 82 others); Fri, 2 Dec 2022 16:40:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55288 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233541AbiLBVka (ORCPT ); Fri, 2 Dec 2022 16:40:30 -0500 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3522AE5A8B; Fri, 2 Dec 2022 13:40:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1670017230; x=1701553230; h=message-id:subject:from:to:cc:date:in-reply-to: references:content-transfer-encoding:mime-version; bh=NuDVEcz+ZwrxpvyK1gNkgUCJxIW8h0yVGClVY+eE7s8=; b=T8Kd0PqA/x5Ex0q76P7Dk4IGJsKrWS0chB9dPU2MzD03rr0xga3o6/jX +il7IaGjLQ0aGSBMMhPsK3WFw8e9mUa7pU56knff+3227LhdcR8pKJ4M7 yw+axMA6JMJsgSaBfN06+yp+/JQw8bWDF+SZD0l1BmBtLKL/BCr+gI5yN P3dq18srfRSnvsAov1IxYh7hSjD1Mn+CQrIc9L7ywHzPjrehpigcg6Yhy aPlmOs+eWCRV1CyT4jgnG0impu+yNf1jIKJNAdciFxhw1HDidxQ/Dna4m bFD9GszPkQWizhLrOxR06D1DtPS4kZp4jv/Qq/EPKb0vc+bSCXM2d8WCy Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10549"; a="317196856" X-IronPort-AV: E=Sophos;i="5.96,213,1665471600"; d="scan'208";a="317196856" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Dec 2022 13:40:28 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10549"; a="595586009" X-IronPort-AV: E=Sophos;i="5.96,213,1665471600"; d="scan'208";a="595586009" Received: from kcaskeyx-mobl1.amr.corp.intel.com (HELO [10.251.1.207]) ([10.251.1.207]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Dec 2022 13:40:27 -0800 Message-ID: Subject: Re: [PATCH v2 02/18] x86/sgx: Store struct sgx_encl when allocating new VA pages From: Kristen Carlson Accardi To: Dave Hansen , 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 Date: Fri, 02 Dec 2022 13:40:26 -0800 In-Reply-To: <3a789b1c-4c70-158b-d764-daec141a5816@intel.com> References: <20221202183655.3767674-1-kristen@linux.intel.com> <20221202183655.3767674-3-kristen@linux.intel.com> <3a789b1c-4c70-158b-d764-daec141a5816@intel.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.44.4 (3.44.4-2.fc36) MIME-Version: 1.0 X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,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 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. >=20 > What does this have to do with the 'encl' that is being passed, > though? >=20 > 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.