Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933530AbcKOMKw (ORCPT ); Tue, 15 Nov 2016 07:10:52 -0500 Received: from 8bytes.org ([81.169.241.247]:35331 "EHLO theia.8bytes.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932810AbcKOMKs (ORCPT ); Tue, 15 Nov 2016 07:10:48 -0500 Date: Tue, 15 Nov 2016 13:10:35 +0100 From: Joerg Roedel To: Tom Lendacky Cc: linux-arch@vger.kernel.org, linux-efi@vger.kernel.org, kvm@vger.kernel.org, linux-doc@vger.kernel.org, x86@kernel.org, linux-kernel@vger.kernel.org, kasan-dev@googlegroups.com, linux-mm@kvack.org, iommu@lists.linux-foundation.org, Rik van Riel , Radim =?utf-8?B?S3LEjW3DocWZ?= , Arnd Bergmann , Jonathan Corbet , Matt Fleming , Konrad Rzeszutek Wilk , Paolo Bonzini , Larry Woodman , Ingo Molnar , Borislav Petkov , Andy Lutomirski , "H. Peter Anvin" , Andrey Ryabinin , Alexander Potapenko , Thomas Gleixner , Dmitry Vyukov Subject: Re: [RFC PATCH v3 04/20] x86: Handle reduction in physical address size with SME Message-ID: <20161115121035.GD24857@8bytes.org> References: <20161110003426.3280.2999.stgit@tlendack-t1.amdoffice.net> <20161110003513.3280.12104.stgit@tlendack-t1.amdoffice.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20161110003513.3280.12104.stgit@tlendack-t1.amdoffice.net> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 809 Lines: 27 On Wed, Nov 09, 2016 at 06:35:13PM -0600, Tom Lendacky wrote: > +/* > + * AMD Secure Memory Encryption (SME) can reduce the size of the physical > + * address space if it is enabled, even if memory encryption is not active. > + * Adjust x86_phys_bits if SME is enabled. > + */ > +static void phys_bits_adjust(struct cpuinfo_x86 *c) > +{ Better call this function amd_sme_phys_bits_adjust(). This name makes it clear at the call-site why it is there and what it does. > + u32 eax, ebx, ecx, edx; > + u64 msr; > + > + if (c->x86_vendor != X86_VENDOR_AMD) > + return; > + > + if (c->extended_cpuid_level < 0x8000001f) > + return; > + > + /* Check for SME feature */ > + cpuid(0x8000001f, &eax, &ebx, &ecx, &edx); > + if (!(eax & 0x01)) > + return; Maybe add a comment here why you can't use cpu_has (yet).