From: Brijesh Singh Subject: Re: SEV guest regression in 4.18 Date: Tue, 21 Aug 2018 11:07:38 -0500 Message-ID: <92e2b80c-0dcc-94be-8d3a-5e11e5cf2370@amd.com> References: <20ad6cd5-394c-d3ae-d99c-b656d7ef8293@amd.com> <20180821083911.GF24940@nazgul.tnic> <3d46f44c-dd78-8fa9-02ac-8206676ffde9@amd.com> <20180821151938.GA31212@nazgul.tnic> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Cc: brijesh.singh@amd.com, "x86@kernel.org" , "linux-kernel@vger.kernel.org" , "kvm@vger.kernel.org" , "Lendacky, Thomas" , Thomas Gleixner , Paolo Bonzini , Pavel Tatashin To: Borislav Petkov Return-path: In-Reply-To: <20180821151938.GA31212@nazgul.tnic> Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org List-Id: kvm.vger.kernel.org On 08/21/2018 10:19 AM, Borislav Petkov wrote: > On Tue, Aug 21, 2018 at 09:37:56AM -0500, Brijesh Singh wrote: >> Those variables are accessed immediately by the tsc calibration code >> path hence we will not able to delay the allocation. > > If you mean, check_tsc_sync_source/_target(), those are called pretty > late, AFAICT. > > And I see a setup_arch() -> init_mem_mapping -> ... -> > kernel_physical_mapping_init() call which happens much earlier. > > Again, AFAICT. You probably should try it though, to make sure. > Here is a typical flow: setup_arch() .... init_hypervisor_platform() kvmclock_init() kvm_register_clock("primary cpu clock") /* this shares the physical address of variable with HV. * Ideally you want C-bit to be cleared before we give * the address to HV because HV may start using the * variable as soon as we issue wrmsrl(MSR_KVM_SYSTEM_TIME). * * we may able to relax rules that variable should be mapped * with C=0 before making the wrmsrl(). Since HV will anyways * write the data with C=0. The important thing is when guest * tries to read it must map the address as C=0. */ Later part of kvmclock_init provides a hooks for tsc calibration tsc_early_init() determine_cpu_tsc_frequencies() /* this will call tsc calibration hooks registered by the * kvmclock_init. The hooks basically reads those variables. * These variable must be mapped with C=0 otherwise we will * not be able to get the data written by the hypervisor. */ ... ... ... ... trim_low_memory_range init_mem_mapping() ... The tsc_early_init() is called before setup_arch() -> init_mem_mapping. -Brijesh