Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752164AbdIFIRs (ORCPT ); Wed, 6 Sep 2017 04:17:48 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:47370 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750832AbdIFIRp (ORCPT ); Wed, 6 Sep 2017 04:17:45 -0400 Subject: Re: [PATCH] arm64: KVM: VHE: save and restore some PSTATE bits To: gengdongjiu , "christoffer.dall@linaro.org" , "pbonzini@redhat.com" , "rkrcmar@redhat.com" , "vladimir.murzin@arm.com" , "linux-arm-kernel@lists.infradead.org" , "kvmarm@lists.cs.columbia.edu" , "kvm@vger.kernel.org" , "linux-kernel@vger.kernel.org" References: <0184EA26B2509940AA629AE1405DD7F2015DF717@DGGEMA503-MBX.china.huawei.com> Cc: James Morse From: Marc Zyngier Organization: ARM Ltd Message-ID: <2a5d4299-2523-aef5-7db1-f351ca66b562@arm.com> Date: Wed, 6 Sep 2017 09:17:41 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: <0184EA26B2509940AA629AE1405DD7F2015DF717@DGGEMA503-MBX.china.huawei.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-GB Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1607 Lines: 46 On 05/09/17 19:58, gengdongjiu wrote: > when exit from guest, some host PSTATE bits may be lost, such as > PSTATE.PAN or PSTATE.UAO. It is because host and hypervisor all run > in the EL2, host PSTATE value cannot be saved and restored via > SPSR_EL2. So if guest has changed the PSTATE, host continues with > a wrong value guest has set. > > Signed-off-by: Dongjiu Geng > Signed-off-by: Haibin Zhang > --- > arch/arm64/include/asm/kvm_host.h | 8 +++++++ > arch/arm64/include/asm/kvm_hyp.h | 2 ++ > arch/arm64/include/asm/sysreg.h | 23 +++++++++++++++++++ > arch/arm64/kvm/hyp/entry.S | 2 -- > arch/arm64/kvm/hyp/switch.c | 24 ++++++++++++++++++-- > arch/arm64/kvm/hyp/sysreg-sr.c | 48 ++++++++++++++++++++++++++++++++++++--- > 6 files changed, 100 insertions(+), 7 deletions(-) > > diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h > index e923b58..cba7d3e 100644 > --- a/arch/arm64/include/asm/kvm_host.h > +++ b/arch/arm64/include/asm/kvm_host.h > @@ -193,6 +193,12 @@ struct kvm_cpu_context { > }; > }; > > +struct kvm_cpu_host_pstate { > + u64 daif; > + u64 uao; > + u64 pan; > +}; I love it. This is the most expensive way of saving/restoring a single 32bit value. More seriously, please see the discussion between James and Christoffer there[1]. I expect James to address the PAN/UAO states together with the debug state in the next iteration of his patch. Thanks, M. [1] https://www.spinics.net/lists/arm-kernel/msg599798.html -- Jazz is not dead. It just smells funny...