Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp9411imm; Tue, 28 Aug 2018 14:54:25 -0700 (PDT) X-Google-Smtp-Source: ANB0VdbEY/LNKDJ4vnTqisnNUkc0Q7Ky5cXQdNGEksv7njoRgN/tNseOGLw702CBNTRco0y5cdV+ X-Received: by 2002:a17:902:145:: with SMTP id 63-v6mr3261437plb.103.1535493265673; Tue, 28 Aug 2018 14:54:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535493265; cv=none; d=google.com; s=arc-20160816; b=Wh9vUE1z3UvXQA5oU6Ct9XriBHAmef7VuPOkgp/ynEQnuhcotEvxZmMx9JxWsCyOCZ umxX1upw0g4AJGO/NPAoV4mdyCvWZS9hIQ7h2CvVOx/qUFujuM6kBsElQ5XeDrvXV6c8 dHQ9BqqFsbWgObtbd0XVOSRlMF87cUKSdGpkrWce2qbKhhChibZcELVsqP/1s/NBT85e 6Nz/XLFdTuBSJ8hLJSFYGUSoBMljp5Kt9NFRf40XXTlJ0x4FIuaJ636SFA2PV1EriRiZ LFGehFbTz+VhzCFlZxTqZFsk9Jdf/D0db9aIXTrpUjpUzMK1dTnoyAGJDCLrAEeIPnjo G7Kw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=0RoRbXKN11ozhn/YOUbynp07gghhM4F03mJn5Jm4qQQ=; b=hZnCZwwD5Ax85TqLeGBxuE9pBddr31tK4Z4jcMJXH8cxLDCR9aPmi1vn6N1s4A0605 UA3MSZ37AyzlAK0RL7hM0yYhuQb5FIae6gR0vfm7G6m0WREFpjIiDANIGLRwYAtSfQrS yW1bJSOOLdxsnI+lSahZn3peUtRcI7msDELm2GkvbE07irtjq+gKPjqxRIzWe0ncEhjo k/wP4G27bMpy3yTnxCUNdInnUsraXUL/2GcmFil5ljVyuUe9hJPZHX9+ZKgA1yXzDN0O WG4TQzay6W9fYxYTim0GKt780328WIKpkQROCfnWgDqPaybZSzTbSPsoX+FE/IKy+KUc 5n9Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o18-v6si1935512pll.344.2018.08.28.14.54.10; Tue, 28 Aug 2018 14:54:25 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727397AbeH2Bqc (ORCPT + 99 others); Tue, 28 Aug 2018 21:46:32 -0400 Received: from mga14.intel.com ([192.55.52.115]:6038 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727216AbeH2Bqb (ORCPT ); Tue, 28 Aug 2018 21:46:31 -0400 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 28 Aug 2018 14:52:54 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.53,300,1531810800"; d="scan'208";a="258843158" Received: from sjchrist-coffee.jf.intel.com (HELO linux.intel.com) ([10.54.74.9]) by fmsmga006.fm.intel.com with ESMTP; 28 Aug 2018 14:52:40 -0700 Date: Tue, 28 Aug 2018 14:52:40 -0700 From: Sean Christopherson To: Dave Hansen Cc: Jarkko Sakkinen , x86@kernel.org, platform-driver-x86@vger.kernel.org, nhorman@redhat.com, npmccallum@redhat.com, linux-sgx@vger.kernel.org, Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , Suresh Siddha , Serge Ayoun , "open list:X86 ARCHITECTURE (32-BIT AND 64-BIT)" Subject: Re: [PATCH v13 09/13] x86/sgx: Enclave Page Cache (EPC) memory manager Message-ID: <20180828215240.GA29684@linux.intel.com> References: <20180827185507.17087-1-jarkko.sakkinen@linux.intel.com> <20180827185507.17087-10-jarkko.sakkinen@linux.intel.com> <7c5df14e-3028-46b3-fe93-aa6ba8352317@intel.com> <20180828083540.GH15508@linux.intel.com> <132d309d-77e2-52ed-7251-abb2c80cdf49@intel.com> <20180828212244.GA29488@linux.intel.com> <81adf7e1-b9c2-e906-95a3-c6e08cbcc52a@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <81adf7e1-b9c2-e906-95a3-c6e08cbcc52a@intel.com> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Aug 28, 2018 at 02:26:36PM -0700, Dave Hansen wrote: > On 08/28/2018 02:22 PM, Sean Christopherson wrote: > > On Tue, Aug 28, 2018 at 07:07:33AM -0700, Dave Hansen wrote: > >> On 08/28/2018 01:35 AM, Jarkko Sakkinen wrote: > >>> On Mon, Aug 27, 2018 at 02:15:34PM -0700, Dave Hansen wrote: > >>>> On 08/27/2018 11:53 AM, Jarkko Sakkinen wrote: > >>>>> +struct sgx_epc_page_ops { > >>>>> + bool (*get)(struct sgx_epc_page *epc_page); > >>>>> + void (*put)(struct sgx_epc_page *epc_page); > >>>>> + bool (*reclaim)(struct sgx_epc_page *epc_page); > >>>>> + void (*block)(struct sgx_epc_page *epc_page); > >>>>> + void (*write)(struct sgx_epc_page *epc_page); > >>>>> +}; > >>>> Why do we need a fancy, slow (retpoline'd) set of function pointers when > >>>> we only have one user of these (the SGX driver)? > >>> KVM has its own implementation for these operations. > >> > >> That belongs in the changelog. > >> > >> Also, where is the implementation? How can we assess this code that was > >> built to create an abstraction without both of the users? > > > > I can provide an early preview of the KVM reclaim code, but honestly > > I think that would do more harm than good. The VMX architecture for > > EPC reclaim is complex, even for SGX standards. Opening that can of > > worms would likely derail this discussion. That being said, this > > abstraction isn't exactly what KVM will need, but it's pretty close > > and gives us something to build on. > > Please remove the abstraction code. We don't introduce infrastructure > which no one will use. The infrastructure is used in the sense that it allows us to split the userspace-facing code, i.e. the driver, into a separate module. This in turn allows virtualization of SGX without having to load the driver or building it in the first place, e.g. to virtualize SGX on a system that doesn't meet the driver's requirements. We could eliminate the abstraction by moving the EPC management code into the driver, but that would directly conflict with past feedback and would need to be completely undone to enable KVM. The abstraction could be dumbed down to a single function, but as mentioned earlier, that comes with its own costs. I can dive into exactly what we lose with a single function approach if this is a sticking point.