Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp963021pxb; Fri, 14 Jan 2022 22:31:10 -0800 (PST) X-Google-Smtp-Source: ABdhPJyk8Ki/KiTdqATjZz2h719PcliUrvnKIYMMCeDvj2iIekyZFzTGuU/eW72sxNeHObAdg172 X-Received: by 2002:a17:907:6e0b:: with SMTP id sd11mr10091432ejc.132.1642228270755; Fri, 14 Jan 2022 22:31:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642228270; cv=none; d=google.com; s=arc-20160816; b=NhiTnMWXY+JH+VvdwNKSmrUK0Wq3VxwdgDkGLxLTWUYLg86i2wCvSZ31Qg0jUtTgy0 98RDT7Z4c2PDps4qXJA0WFPioQq2njo1usgAhqXK1aTdZZJgZjf3P9SEgityg8I+4zqk s3o+RdZ7aBPNCq+OKfyUM0cXbf1m8WN6QHKsLFk0+s4CGQaIqD6hB261l2eMzVJDkQEG 6auFQGS0QIUkQ1qt/B/lQIyCXFfiDWZxxlhFsxLE8/7ArJtKXSIKiIPde7oqqJ7DzOIA AD7v8ThgwtscWryzFaM4yghOsKIZjWgzONpShPVEH/VEpS2D3alYh0clbEeZfFxnDjnu WTdA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=LYsw/IRY8Hu9fEObP3Va5wNU72VwkPuSeo7uCYlNOqk=; b=dEoaMUI4Na6R0qxLx04fDYK8cR6cWAcDAAuePjeECimtelxVR5QbUgzYq4H+p5z2LG yG/ixxZaahsPKajx+wHcUoIN7ccnmk6PDk7ZOcrn9gtBB5q0x41TfZezl/UcUK4CRirg SMqAoMCqw3M3ddW9PhT9Vu8aR5QtTlAImQLj3SRdfDnFjaDpCoMFBy3xEcwcg4uM+n1P 2oXBtj5x8IH2NIj9v3ndsfzuXGdH2d6g3xncp/lrgq3lVh/TJ4QLsE4O48qUYTS/vuzX 8T07zIoDWeChsBCYrFL3ExaUeXLYgv31IaNXqz7uNAM0dlwIyNNtrY+FZrKXXCRjE555 YL0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=DG5FenBp; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y8si4515079edw.210.2022.01.14.22.30.12; Fri, 14 Jan 2022 22:31:10 -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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=DG5FenBp; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231409AbiANX50 (ORCPT + 99 others); Fri, 14 Jan 2022 18:57:26 -0500 Received: from sin.source.kernel.org ([145.40.73.55]:53568 "EHLO sin.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229945AbiANX5Z (ORCPT ); Fri, 14 Jan 2022 18:57:25 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id 0F5EFCE2414; Fri, 14 Jan 2022 23:57:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A2ED0C36AE9; Fri, 14 Jan 2022 23:57:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1642204642; bh=oNGlXxyiCsXzWDaq7a+yH3K4XqiLgu/y4W7AI0O/+dY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=DG5FenBpLI1lzu0KabeAMW1/v+aCOqD2YH4opVRrmleCQURaVZX+2Ydhy6Ibz2S51 ilHisOaNAobT3whjWXg9U2IdjvxhdHlREyh8KwEV0y+y+SQB4pQGRzFawpuP9soT1e eyRkXxr17k4p/vpVVAGyamc9v06c8HuwziFe9oW6vygcbUkLbRNMxTttWzxqhwnK8k N7Uqt4Vt38DHPVPTwyLKOcBEyu7bpueLo+N/xWxpPlfMQUWBpim6YqIsvhRliyJLKq klD9XMYCXY7Y4RP7WQVliHoojObnU8MBOOuBvzAjibX/Ob1ENkYAiArGLsVidX/pO9 aaqG8u1OII68A== Date: Sat, 15 Jan 2022 01:57:09 +0200 From: Jarkko Sakkinen To: Dave Hansen Cc: Kristen Carlson Accardi , linux-sgx@vger.kernel.org, Dave Hansen , Thomas Gleixner , Ingo Molnar , Borislav Petkov , x86@kernel.org, "H. Peter Anvin" , linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 2/2] x86/sgx: account backing pages Message-ID: References: <20220107181618.6597-1-kristen@linux.intel.com> <20220107181618.6597-3-kristen@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jan 14, 2022 at 09:55:51AM -0800, Dave Hansen wrote: > On 1/14/22 9:51 AM, Kristen Carlson Accardi wrote: > >>> +int sgx_encl_lookup_backing(struct sgx_encl *encl, unsigned long > >>> page_index, > >>> + struct sgx_backing *backing) > >>> +{ > >>> + return sgx_encl_get_backing(encl, page_index, backing); > >>> +} > >> IMHO, sgx_encl_backing() should be open-coded here. > > I can understand your hesitation, but I agree with Dave here that > > wrapping the function makes the code more clear. I would prefer to keep > > this the way it is. > > I'd also like to see sgx_encl_lookup_backing() and > sgx_encl_alloc_backing() diverge more in the future. > > For instance, sgx_encl_alloc_backing() could ensure that the page does > not exist in the file before doing the sgx_encl_get_backing() call. > This would ensure that it truly *does* allocate a page and does not just > return a previously-allocated page. > > sgx_encl_lookup_backing() could ensure the opposite: that the page > *DOES* exist in the file before doing the sgx_encl_get_backing() call. > This would ensure that it does not allocate a page in a case where we > expected an old, existing page to be present. Would it be a too big tretch to add these and make the whole scheme fully legit? Does not sound like an extremely huge stretch and there is now a full cycle amount of time make it happen before 5.18 merge window. /Jarkko