Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932579AbcKOQd6 (ORCPT ); Tue, 15 Nov 2016 11:33:58 -0500 Received: from mail.skyhub.de ([78.46.96.112]:59163 "EHLO mail.skyhub.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752376AbcKOQdz (ORCPT ); Tue, 15 Nov 2016 11:33:55 -0500 Date: Tue, 15 Nov 2016 17:33:50 +0100 From: Borislav Petkov To: Tom Lendacky Cc: Joerg Roedel , 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 , 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: <20161115163350.jal7sd6ghbmk5sqc@pd.tnic> References: <20161110003426.3280.2999.stgit@tlendack-t1.amdoffice.net> <20161110003513.3280.12104.stgit@tlendack-t1.amdoffice.net> <20161115121035.GD24857@8bytes.org> <20161115121456.f4slpk4i2jl3e2ke@pd.tnic> <20161115153338.a2cxmatnpqcgiaiy@pd.tnic> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20161014 (1.7.1) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2045 Lines: 62 On Tue, Nov 15, 2016 at 10:06:16AM -0600, Tom Lendacky wrote: > Yes, but that doesn't relate to the physical address space reduction. > > Once the SYS_CFG MSR bit for SME is set, even if the encryption bit is > never used, there is a physical reduction of the address space. So when > checking whether to adjust the physical address bits I can't rely on the > sme_me_mask, I have to look at the MSR. > > But when I'm looking to decide whether to encrypt or decrypt something, > I use the sme_me_mask to decide if that is needed. If the sme_me_mask > is not set then the encrypt/decrypt op shouldn't be performed. > > I might not be grasping the point you're trying to make... Ok, let me try to summarize how I see it. There are a couple of states: * CPUID bit in 0x8000001f - that's SME supported * Reduction of address space - MSR bit. That could be called "SME BIOS-eenabled". * SME active. That's both of the above and is sme_me_mask != 0. Right? So you said previously "The feature may be present and enabled even if it is not currently active." But then you say "active" below > > And in patch 12 you have: > > > > + /* > > + * If memory encryption is active, the trampoline area will need to > > + * be in un-encrypted memory in order to bring up other processors > > + * successfully. > > + */ > > + sme_early_mem_dec(__pa(base), size); > > + sme_set_mem_unenc(base, size); and test sme_me_mask. Which makes sense now after having explained which hw setting controls what. So can we agree on the nomenclature for all the different SME states first and use those throughout the code? And hold those states down in Documentation/x86/amd-memory-encryption.txt so that it is perfectly clear to people looking at the code. Also, if we need to check those states more than once, we should add inline helpers: sme_supported() sme_bios_enabled() sme_active() How does that sound? -- Regards/Gruss, Boris. Good mailing practices for 400: avoid top-posting and trim the reply.