From mboxrd@z Thu Jan 1 00:00:00 1970 From: Brijesh Singh Subject: Re: [PATCH] x86/CPU/AMD, mm: Extend with mem_encrypt=sme option Date: Mon, 2 Oct 2017 10:07:33 -0500 Message-ID: <715846be-0f2e-07ee-63a0-ba1794d1bcbd@amd.com> References: <20171001171617.uzwfzps7sxowfram@pd.tnic> <20171001194509.4187-1-brijesh.singh@amd.com> <20171001220216.nhwc5momrn7wq3kj@pd.tnic> <6de5cc08-0a0d-cb45-9518-e5b30fd7e276@amd.com> <20171002124107.rwn5ww3wkynxwmsa@pd.tnic> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Cc: brijesh.singh@amd.com, Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , Paolo Bonzini , =?UTF-8?B?UmFkaW0gS3LEjW3DocWZ?= , kvm@vger.kernel.org, x86@kernel.org, linux-kernel@vger.kernel.org To: Borislav Petkov Return-path: In-Reply-To: <20171002124107.rwn5ww3wkynxwmsa@pd.tnic> Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org List-Id: kvm.vger.kernel.org On 10/02/2017 07:41 AM, Borislav Petkov wrote: > On Mon, Oct 02, 2017 at 06:32:18AM -0500, Brijesh Singh wrote: >> Because sev_enabled will always be 'false' when we are booting on bare >> metal. Whereas when we are running under hypervisor then this variable >> will be true for the SEV guest, please see [1]. > > Ok, then. This needs absolutely to be documented. Please add a comment > over sev_enabled's definition. > >> Both sev_active() and sme_active() make use of this variable >> hence we will not be able to set the sev_enabled variable on bare >> metal. Basically none of the SEV cases will be executed on bare >> metal -- only thing which we need to take care of is clearing the >> X86_FEATURE_SEV flag so that hypervisor will never launch SEV guest >> when mem_encrypt=sme option is provided. > > In that case, you want to disable SEV at the guest loading point, > i.e., sev_guest_init() AFAICT is the earliest time we start prepping > a SEV guest. You can add a __setup() early param which parses > "mem_encrypt=sme", to arch/x86/kernel/cpu/amd.c and which sets a > sev_host_enabled bool or so. sev_guest_init() can then check that > variable before going any further. No need for any of that early parsing > changes. Yep, that will work just fine. There are couple of ways we can limit hypervisor from creating the SEV guest 1) clear the X86_FEATURE_SEV bit when mem_encrypt=sme is passed or 2) parse the mem_encrypt=xxx in kvm-amd.ko and fail the KVM_SEV_INIT when mem_encrpt=sme or mem_encrypt=off. I was not sure which way to go. We can go with #2 and kvm folks have any concern then we can go back to #1. I will update KVM_SEV_INIT patch and send you v4.1. -Brijesh