Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp4073285imm; Mon, 25 Jun 2018 09:15:43 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJrIW4xNSA8cLYBa51iyoFCCa8gIDQPc9aY7STRBT6FnqDlmdkwMHNqwSZIpI3CPRWyMHNd X-Received: by 2002:a63:65c2:: with SMTP id z185-v6mr11098507pgb.276.1529943343901; Mon, 25 Jun 2018 09:15:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529943343; cv=none; d=google.com; s=arc-20160816; b=PHkUc1PD1BoeIsSawn7R8Eb2vKRvmBYmwzqi+KjvabnvDCNqMDqDsAM0zJRDsgRiUJ hgGlaDGNLWrms1gMfp2E8lXwspQPxNWlG6nMcpvxdMrb+ekilUyyzNVkTi0GT+rccOfs jwsEt/hgjXFF4avLPBVU4mmGMPgQblm6TYGcf78OaboBkiNA0RyFN5DpnoX72Ym18hAe BEdqDPnDjPWIFXgaIGZtarOirWn11p3TUDcx2CC4/Ho8zOryxJOAyyOoSoyvLjBZvfRH CRDcqYAsd/5ewgV0IFtuGONEx7Mih2xO2oyZcKLGezZtWQzWHuTXPbu6heGlhvkt2mvi V+aA== 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=+YOD1qtvhnwHSWfc4TVzvkPY/jRAX6HoMNT/aeEZdfY=; b=zzEwUU0tCDAFRtom4GtAz4o0d4DXQxl06TJ8bKI1gim9jdB+ClrcTvLLtNaLj/ZB24 pH5kMMS622s9DEMuIqUzclZcYmajIE0FGNhsFhLq7ce1ol/Jp6mHgiVAdfXu0+sNzr2w uLU+F6RoigB6q0jn/Ek8bxdoAYUyepfVEGH/LSpDGTP32gr03+WjyX+0ZcXVicwyI5B5 RFQEdz+5yvKG/HOE5gURg8h+YV3YaRF7EVIPYLjcXD2dVSYpzhbtx3bs4VBayItFZarT PhlwcEm/bMjNV4CD4/BJS6aRqxI84BDUO2zc1Nb7bDg2D1vakjIpGX0YQ1NF3wIpwrmH 4F7g== 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=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m8-v6si14102380plt.29.2018.06.25.09.15.29; Mon, 25 Jun 2018 09:15:43 -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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933465AbeFYQOV (ORCPT + 99 others); Mon, 25 Jun 2018 12:14:21 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:50882 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752330AbeFYQOT (ORCPT ); Mon, 25 Jun 2018 12:14:19 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6044840711A9; Mon, 25 Jun 2018 16:14:18 +0000 (UTC) Received: from hmswarspite.think-freely.org (ovpn-121-117.rdu2.redhat.com [10.10.121.117]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0A6682026D5B; Mon, 25 Jun 2018 16:14:17 +0000 (UTC) Date: Mon, 25 Jun 2018 12:14:16 -0400 From: Neil Horman To: Jarkko Sakkinen Cc: Sean Christopherson , x86@kernel.org, platform-driver-x86@vger.kernel.org, dave.hansen@intel.com, npmccallum@redhat.com, Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , "open list:X86 ARCHITECTURE (32-BIT AND 64-BIT)" , "open list:INTEL SGX" Subject: Re: [PATCH v11 09/13] x86, sgx: basic routines for enclave page cache Message-ID: <20180625161416.GC18878@hmswarspite.think-freely.org> References: <20180608171216.26521-1-jarkko.sakkinen@linux.intel.com> <20180608171216.26521-10-jarkko.sakkinen@linux.intel.com> <1529500871.9779.58.camel@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.0 (2018-05-17) X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Mon, 25 Jun 2018 16:14:18 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.7]); Mon, 25 Jun 2018 16:14:18 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'nhorman@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jun 25, 2018 at 12:21:22PM +0300, Jarkko Sakkinen wrote: > On Wed, 2018-06-20 at 06:21 -0700, Sean Christopherson wrote: > > On Fri, 2018-06-08 at 19:09 +0200, Jarkko Sakkinen wrote: > > > SGX has a set of data structures to maintain information about the enclaves > > > and their security properties. BIOS reserves a fixed size region of > > > physical memory for these structures by setting Processor Reserved Memory > > > Range Registers (PRMRR). This memory area is called Enclave Page Cache > > > (EPC). > > > > > > This commit implements the basic routines to allocate and free pages from > > > different EPC banks. There is also a swapper thread ksgxswapd for EPC pages > > > that gets woken up by sgx_alloc_page() when we run below the low watermark. > > > The swapper thread continues swapping pages up until it reaches the high > > > watermark. > > > > > > Each subsystem that uses SGX must provide a set of callbacks for EPC > > > pages that are used to reclaim, block and write an EPC page. Kernel > > > takes the responsibility of maintaining LRU cache for them. > > > > > > Signed-off-by: Jarkko Sakkinen > > > --- > > > arch/x86/include/asm/sgx.h | 67 +++++ > > > arch/x86/include/asm/sgx_arch.h | 224 ++++++++++++++++ > > > arch/x86/kernel/cpu/intel_sgx.c | 443 +++++++++++++++++++++++++++++++- > > > 3 files changed, 732 insertions(+), 2 deletions(-) > > > create mode 100644 arch/x86/include/asm/sgx_arch.h > > > > ... > > > > > +struct sgx_pcmd { > > > + struct sgx_secinfo secinfo; > > > + uint64_t enclave_id; > > > + uint8_t reserved[40]; > > > + uint8_t mac[16]; > > > +}; > > > > sgx_pcmd has a 128-byte alignment requirement. I think it's > > worth specifying here as sgx_pcmd is small enough that it could > > be put on the stack, e.g. by KVM when trapping and executing > > ELD* on behalf of a guest VM. > > > > In fact, it probably makes sense to add alightment attributes > > to all SGX structs for self-documentation purposes, even though > > many of them will never be allocated statically or on the stack. > > I agree with this. It also documents stuff so that you don't have > to look it up from the SDM. > > Neil: this should also clear your concerns. > Agreed Neil > /Jarkko