Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp51608imm; Tue, 3 Jul 2018 13:45:37 -0700 (PDT) X-Google-Smtp-Source: AAOMgpe4PuLJXzpEiuYPtTct4fiZ6XfmJUht3jTWeBRZiHaK7ukrrY11OOqzjHsqWo2xeB+o5YTm X-Received: by 2002:aa7:80cf:: with SMTP id a15-v6mr31060409pfn.19.1530650737514; Tue, 03 Jul 2018 13:45:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530650737; cv=none; d=google.com; s=arc-20160816; b=ND6TgcSGik0or3j46y8CKo6I9kR8LC8hw5ncUA4ygWaAuZTVc+0pd+HcLDGGhgHiuQ vv3lK1PP9P6uQ4SrM3TE8BLBTJLcZ2UPNMLahJ/9BhQgs3Vgiiz+2idM5hqJ5ms/nXis t7uLjLbHuvQs+0cG272EdF+zEKUrjZwLSWiafTV0j/Ba0QBv0YwfyPX3ScWG9cXNx+xM WCQ0jn61xW5kH4enyHuV6wktSdbsi7i/6z3A/HY8hUXOtSW8Dqj2eFoDDyr4n79uXshk rrZRiQ19rMtLSQlHxRs4PkhdY6NzsSP5vDL3FSHm4Lkd3ABkNw7x85YhtesPXC1QPHLv 5TpQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date :arc-authentication-results; bh=KfhCKC+KHwk99ZRCr8rdSyzyaKk39HDs1k9jtxWd9H0=; b=hu5HN6D85Zn1HVy4F9mWgDovNM7XU6SMu0uJdjDg6OttsPS2c70stru9DGCwqlG+gP iCTXs4Om7IuDTwA0TelPsDBbWMxvz1xgx3aLR20lY6ATXJGYFhDAlb1aZOYqEBcxIGwe InjucokAaFe9N5fsw9iTq8ineR8w/Gx8a1jJ3tT1w3wl8OCE9IkVQhgEV3/Tvag0sJM5 SIfZDNEso8ZLoEgFAnVNVYWIWlIi1ft7iawlGPL1Y455uphRzXVLjXxoeQo9bOiuugCS yaLtLk2X9x/+e7gJoNWV9fCDNzNiZ3s0HSU7bWbH3yNh81u+td9MdkoYmyLCVsVRkgZ/ 8rdQ== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b76-v6si1963014pfl.223.2018.07.03.13.45.22; Tue, 03 Jul 2018 13:45:37 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752768AbeGCUok (ORCPT + 99 others); Tue, 3 Jul 2018 16:44:40 -0400 Received: from Galois.linutronix.de ([146.0.238.70]:45442 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752399AbeGCUoj (ORCPT ); Tue, 3 Jul 2018 16:44:39 -0400 Received: from p4fea482e.dip0.t-ipconnect.de ([79.234.72.46] helo=nanos) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1faS9w-0002Uy-N7; Tue, 03 Jul 2018 22:44:24 +0200 Date: Tue, 3 Jul 2018 22:44:24 +0200 (CEST) From: Thomas Gleixner To: Randy Dunlap cc: Jarkko Sakkinen , 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)" Subject: Re: [PATCH v12 07/13] x86/sgx: data structures for tracking available EPC pages In-Reply-To: <00ca61d5-5a1d-5c83-3b49-62c899a87041@infradead.org> Message-ID: References: <20180703182118.15024-1-jarkko.sakkinen@linux.intel.com> <20180703182118.15024-8-jarkko.sakkinen@linux.intel.com> <00ca61d5-5a1d-5c83-3b49-62c899a87041@infradead.org> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 3 Jul 2018, Randy Dunlap wrote: > 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. It's a short sentence decribing the function and sentences start usually with uppercase letters, right? > I happen to disagree with it. Then we have to agree that we disagree. > >> +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'? Makes is more readable IMO, but I'm not religious about that. Thanks, tglx