Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp38234imm; Tue, 3 Jul 2018 13:28:02 -0700 (PDT) X-Google-Smtp-Source: AAOMgpciJpWYQFAmSqEmC6CZSdcqbP0VgoWvnnehvtiFpN+DzAN+DPBWX+mYbPQlxiqNlTiwZpvT X-Received: by 2002:a62:5e06:: with SMTP id s6-v6mr31118823pfb.253.1530649682827; Tue, 03 Jul 2018 13:28:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530649682; cv=none; d=google.com; s=arc-20160816; b=ixLRR0YZyl8FZFPgg/EHi84NE+q9lhusbWVIjnnSQVxbWSGC7Ok//0CSIEIcG12pOM A/XLFXyqc+38IwHzvbcOlYD+WIxeF/Qgue+Dsr79hUjmHhZhg5+N3f/dvj8pgK09jiGL 6rFOZYbztSXuIiVzWVv4lZbdgjR/AhqYyQtE4L/O2mbJZEb6JOJitcQpHeX1Y4jhk2Ty Id27nsdmtKgAjT2nLTXptHN9ky9Xx0HgVA33+t0tdJR0eO5VtVP3amogpFQV40olxLGf FpimhIopCBQKl3ZeP6SePUPe7i3ip+blQqWTrH4mW67G5ooinOmf2wzd4+S3U+3/XF2l dF5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature :arc-authentication-results; bh=vobmshzvhyVr3X2oUlxY2PRL4/kmtAnQaJ5589PlVUg=; b=xEPOGvngh5iIxaTIjAH8gPvR9rx+QXByxZSOEgDHjVCU/u1PU2iip0STgh+WfyE6/5 uVKVG66ef/0e0eSfsMJCfe4YQSfvUAwku727et5MPlscdXYOlsq1sxOZKQyN88ndCFlf eUMKv0h2QR4RpPfiDRTxCQ4uzx9tDw9ey0j6zJjlMCdEXIXS36ZrIOiDfdV6baupEQV5 zc0VrXh9k+nsW9OqS2hrd70HHD3RClDpjbKrAz0ImlhedhKRBW5/iPVx7yKQlRPr63nY lbJRVoksB3gTvLnjMaVekK0VxOT973bgarQCSwnSJQMbYD6AQi5DSI7dPkVbE4Ad9l1s ZDBQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=oDKxY+nD; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 33-v6si1792978plq.348.2018.07.03.13.27.48; Tue, 03 Jul 2018 13:28:02 -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; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=oDKxY+nD; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753001AbeGCU0P (ORCPT + 99 others); Tue, 3 Jul 2018 16:26:15 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:43232 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752237AbeGCU0O (ORCPT ); Tue, 3 Jul 2018 16:26:14 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: Content-Type:In-Reply-To:MIME-Version:Date:Message-ID:From:References:Cc:To: Subject:Sender:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=vobmshzvhyVr3X2oUlxY2PRL4/kmtAnQaJ5589PlVUg=; b=oDKxY+nDPjgvV9FmvKJHjFfwy 7t3AIOGKlUhGaB+Rd9yACbjP9uHr4UIooegIghd+TWptUz5BTS3jzV4P19U0W+PosSy5RSpqVFi8R cci5cSaOUztHptYmig2+bwHKDJOXMHiDWx/fxrdWt8YcK1gSjaRD3J2+dI7p+iWtmmbwsKzKaOVEO NWUtm/SUm4rghDyHZ52QbGn4dJfRsASIeBn78+TNqCbFB6F2PlKLPeKaZ84IC9rxnHdbYdKlV+WVd YiH8hQTgFdWLi9XypHH0Hkce4zzwOZYjwuBzRGWVJ4G1fJg+Uu+sjsrHtS7EbvbIEIl7U++1KHq9I bk/b2q+DQ==; Received: from static-50-53-52-16.bvtn.or.frontiernet.net ([50.53.52.16] helo=midway.dunlab) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1faRsL-00026s-Ad; Tue, 03 Jul 2018 20:26:13 +0000 Subject: Re: [PATCH v12 07/13] x86/sgx: data structures for tracking available EPC pages To: Thomas Gleixner , Jarkko Sakkinen Cc: x86@kernel.org, platform-driver-x86@vger.kernel.org, dave.hansen@intel.com, sean.j.christopherson@intel.com, nhorman@redhat.com, npmccallum@redhat.com, linux-sgx@vger.kernel.org, Ingo Molnar , "H. Peter Anvin" , "open list:X86 ARCHITECTURE (32-BIT AND 64-BIT)" References: <20180703182118.15024-1-jarkko.sakkinen@linux.intel.com> <20180703182118.15024-8-jarkko.sakkinen@linux.intel.com> From: Randy Dunlap Message-ID: <00ca61d5-5a1d-5c83-3b49-62c899a87041@infradead.org> Date: Tue, 3 Jul 2018 13:26:11 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 07/03/18 12:46, Thomas Gleixner wrote: > On Tue, 3 Jul 2018, 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 adds a database of EPC banks for kernel to easily access the what kind of database? How does one query it? >> diff --git a/arch/x86/include/asm/sgx.h b/arch/x86/include/asm/sgx.h >> index 2130e639ab49..77b2294fcfb0 100644 >> --- a/arch/x86/include/asm/sgx.h >> +++ b/arch/x86/include/asm/sgx.h >> +/** >> + * sgx_get_page - pin an EPC page > > Description starts with an uppercase letter. How would someone know that? It's not documented anywhere. I happen to disagree with it. >> +static __init int sgx_page_cache_init(void) >> +{ >> + unsigned long size; >> + unsigned int eax; >> + unsigned int ebx; >> + unsigned int ecx; >> + unsigned int edx; >> + unsigned long pa; >> + int i; >> + int ret; > > Please aggregate the declarations of the same type. No point in wasting all > the screen space. And please use 'u32' for ea-dx > >> + >> + for (i = 0; i < SGX_MAX_EPC_BANKS; i++) { >> + cpuid_count(SGX_CPUID, i + SGX_CPUID_EPC_BANKS, &eax, &ebx, >> + &ecx, &edx); >> + if (!(eax & 0xf)) >> + break; >> + >> + pa = ((u64)(ebx & 0xfffff) << 32) + (u64)(eax & 0xfffff000); >> + size = ((u64)(edx & 0xfffff) << 32) + (u64)(ecx & 0xfffff000); > > These magic constants should be 'U', using uppercase 'F' and defines. Plus > this wants a comment how pa and size are cobbled together from the cpuid > regs. Why the uppercase 'F'? thnx, -- ~Randy