From mboxrd@z Thu Jan 1 00:00:00 1970 From: Mario Smarduch Subject: Re: [PATCH v6 1/6] arm/arm64: KVM: Introduce armv7 fp/simd vcpu fields and helpers Date: Wed, 13 Jan 2016 19:03:04 -0800 Message-ID: <56970FE8.4020805@samsung.com> References: <1451166900-3711-1-git-send-email-m.smarduch@samsung.com> <1451166900-3711-2-git-send-email-m.smarduch@samsung.com> <20160110163204.GD30867@cbox> <56943D29.3000002@samsung.com> <20160112141207.GF15554@cbox> <5695A0EB.5020609@samsung.com> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Cc: marc.zyngier@arm.com, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Russell King - ARM Linux To: Christoffer Dall Return-path: Received: from mailout1.w2.samsung.com ([211.189.100.11]:19297 "EHLO usmailout1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751182AbcANDDJ (ORCPT ); Wed, 13 Jan 2016 22:03:09 -0500 Received: from uscpsbgex3.samsung.com (u124.gpu85.samsung.co.kr [203.254.195.124]) by mailout1.w2.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0O0X005289T8HH80@mailout1.w2.samsung.com> for kvm@vger.kernel.org; Wed, 13 Jan 2016 22:03:08 -0500 (EST) In-reply-to: <5695A0EB.5020609@samsung.com> Sender: kvm-owner@vger.kernel.org List-ID: On 1/12/2016 4:57 PM, Mario Smarduch wrote: > > > On 1/12/2016 6:12 AM, Christoffer Dall wrote: >> On Mon, Jan 11, 2016 at 03:39:21PM -0800, Mario Smarduch wrote: >>> >>> >>> On 1/10/2016 8:32 AM, Christoffer Dall wrote: >>>> Hi Mario, >>>> >>>> I spotted one more potential issue... >>>> >>>> On Sat, Dec 26, 2015 at 01:54:55PM -0800, Mario Smarduch wrote: >>>>> Add helper functions to enable access to fp/smid on guest entry and save host >>>>> fpexc on vcpu put, check if fp/simd registers are dirty and add new vcpu >>>>> fields. >>>>> >>>>> Signed-off-by: Mario Smarduch >>>>> --- >>>>> arch/arm/include/asm/kvm_emulate.h | 42 ++++++++++++++++++++++++++++++++++++ >>>>> arch/arm/include/asm/kvm_host.h | 6 ++++++ >>>>> arch/arm64/include/asm/kvm_emulate.h | 8 +++++++ >>>>> 3 files changed, 56 insertions(+) >>>>> >>>>> diff --git a/arch/arm/include/asm/kvm_emulate.h b/arch/arm/include/asm/kvm_emulate.h >>>>> index 3095df0..d4d9da1 100644 >>>>> --- a/arch/arm/include/asm/kvm_emulate.h >>>>> +++ b/arch/arm/include/asm/kvm_emulate.h >>>>> @@ -24,6 +24,8 @@ >>>>> #include >>>>> #include >>>>> #include >>>>> +#include >>>>> +#include "../vfp/vfpinstr.h" >>>>> >>>>> unsigned long *vcpu_reg(struct kvm_vcpu *vcpu, u8 reg_num); >>>>> unsigned long *vcpu_spsr(struct kvm_vcpu *vcpu); >>>>> @@ -255,4 +257,44 @@ static inline unsigned long vcpu_data_host_to_guest(struct kvm_vcpu *vcpu, >>>>> } >>>>> } >>>>> >>>>> +#ifdef CONFIG_VFPv3 >>>>> +/* Called from vcpu_load - save fpexc and enable guest access to fp/simd unit */ >>>>> +static inline void vcpu_trap_vfp_enable(struct kvm_vcpu *vcpu) >>>>> +{ >>>>> + u32 fpexc; >>>>> + >>>>> + /* Save host fpexc, and enable guest access to fp unit */ >>>>> + fpexc = fmrx(FPEXC); >>>>> + vcpu->arch.host_fpexc = fpexc; >>>>> + fpexc |= FPEXC_EN; >>>>> + fmxr(FPEXC, fpexc); >>>>> + >>>>> + /* Configure HCPTR to trap on tracing and fp/simd access */ >>>>> + vcpu->arch.hcptr = HCPTR_TTA | HCPTR_TCP(10) | HCPTR_TCP(11); >>>>> +} >>>>> + >>>>> +/* Called from vcpu_put - restore host fpexc */ >>>>> +static inline void vcpu_restore_host_fpexc(struct kvm_vcpu *vcpu) >>>>> +{ >>>>> + fmxr(FPEXC, vcpu->arch.host_fpexc); >>>>> +} >>>>> + >>>>> +/* If trap bits are reset then fp/simd registers are dirty */ >>>>> +static inline bool vcpu_vfp_isdirty(struct kvm_vcpu *vcpu) >>>>> +{ >>>>> + return !(vcpu->arch.hcptr & (HCPTR_TCP(10) | HCPTR_TCP(11))); >>>>> +} >>>>> +#else >>>>> +static inline void vcpu_trap_vfp_enable(struct kvm_vcpu *vcpu) >>>>> +{ >>>>> + vcpu->arch.hcptr = HCPTR_TTA; >>>> >>>> Is it correct not to trap VFP registers when the host kernel does not >>>> have CONFIG_VFPv3? I think this is a change in functionality compared >>>> to the current kernels is it not? >>> >>> With CPU_V7 VFPv3 gets selected, without it fp should be emulated, >>> with exceptions taken in guest kernel. I don't see a reason why >>> fp hcptr access should be enabled in that case. >>> >> >> If you have to guests with CONFIG_VFPV3 but your host doesn't have >> CONFIG_VFPV3, you will never context-switch the VFP registers between >> the two VMs, and mayhem will ensue. >> >> Unless I'm missing something very obvious? Did more testing on this enabling OABI_COMPAT and selecting NWFPE/FastFPE breaks the boot. So far can't find a way to boot host without VFP/VFPv3 enabled on ARMv7. CPU_V7 defaults to VFPv3 selection. I'm wondering if !VFPv3 path should be removed from the patches? - Mario > > Hi Christoffer, > - on host I disabled VFP/VFPv3 and got a lot of Illegal instructions > and many other problems. Perhaps disabling for armv7 this option may need > re-evaluation. > - Enabling VFPv3 on host and running guest with no vfpv3 appears > to work with few glitches. > - and vpfv3 host/guest works just fine. > > Appears disabling vfpv3 on armv7 requires another investigation (atleast > on my end). > > BTW this is on fast models. > > - Mario > >> >> -Christoffer >> > _______________________________________________ > kvmarm mailing list > kvmarm@lists.cs.columbia.edu > https://lists.cs.columbia.edu/mailman/listinfo/kvmarm > From mboxrd@z Thu Jan 1 00:00:00 1970 From: m.smarduch@samsung.com (Mario Smarduch) Date: Wed, 13 Jan 2016 19:03:04 -0800 Subject: [PATCH v6 1/6] arm/arm64: KVM: Introduce armv7 fp/simd vcpu fields and helpers In-Reply-To: <5695A0EB.5020609@samsung.com> References: <1451166900-3711-1-git-send-email-m.smarduch@samsung.com> <1451166900-3711-2-git-send-email-m.smarduch@samsung.com> <20160110163204.GD30867@cbox> <56943D29.3000002@samsung.com> <20160112141207.GF15554@cbox> <5695A0EB.5020609@samsung.com> Message-ID: <56970FE8.4020805@samsung.com> To: linux-arm-kernel@lists.infradead.org List-Id: linux-arm-kernel.lists.infradead.org On 1/12/2016 4:57 PM, Mario Smarduch wrote: > > > On 1/12/2016 6:12 AM, Christoffer Dall wrote: >> On Mon, Jan 11, 2016 at 03:39:21PM -0800, Mario Smarduch wrote: >>> >>> >>> On 1/10/2016 8:32 AM, Christoffer Dall wrote: >>>> Hi Mario, >>>> >>>> I spotted one more potential issue... >>>> >>>> On Sat, Dec 26, 2015 at 01:54:55PM -0800, Mario Smarduch wrote: >>>>> Add helper functions to enable access to fp/smid on guest entry and save host >>>>> fpexc on vcpu put, check if fp/simd registers are dirty and add new vcpu >>>>> fields. >>>>> >>>>> Signed-off-by: Mario Smarduch >>>>> --- >>>>> arch/arm/include/asm/kvm_emulate.h | 42 ++++++++++++++++++++++++++++++++++++ >>>>> arch/arm/include/asm/kvm_host.h | 6 ++++++ >>>>> arch/arm64/include/asm/kvm_emulate.h | 8 +++++++ >>>>> 3 files changed, 56 insertions(+) >>>>> >>>>> diff --git a/arch/arm/include/asm/kvm_emulate.h b/arch/arm/include/asm/kvm_emulate.h >>>>> index 3095df0..d4d9da1 100644 >>>>> --- a/arch/arm/include/asm/kvm_emulate.h >>>>> +++ b/arch/arm/include/asm/kvm_emulate.h >>>>> @@ -24,6 +24,8 @@ >>>>> #include >>>>> #include >>>>> #include >>>>> +#include >>>>> +#include "../vfp/vfpinstr.h" >>>>> >>>>> unsigned long *vcpu_reg(struct kvm_vcpu *vcpu, u8 reg_num); >>>>> unsigned long *vcpu_spsr(struct kvm_vcpu *vcpu); >>>>> @@ -255,4 +257,44 @@ static inline unsigned long vcpu_data_host_to_guest(struct kvm_vcpu *vcpu, >>>>> } >>>>> } >>>>> >>>>> +#ifdef CONFIG_VFPv3 >>>>> +/* Called from vcpu_load - save fpexc and enable guest access to fp/simd unit */ >>>>> +static inline void vcpu_trap_vfp_enable(struct kvm_vcpu *vcpu) >>>>> +{ >>>>> + u32 fpexc; >>>>> + >>>>> + /* Save host fpexc, and enable guest access to fp unit */ >>>>> + fpexc = fmrx(FPEXC); >>>>> + vcpu->arch.host_fpexc = fpexc; >>>>> + fpexc |= FPEXC_EN; >>>>> + fmxr(FPEXC, fpexc); >>>>> + >>>>> + /* Configure HCPTR to trap on tracing and fp/simd access */ >>>>> + vcpu->arch.hcptr = HCPTR_TTA | HCPTR_TCP(10) | HCPTR_TCP(11); >>>>> +} >>>>> + >>>>> +/* Called from vcpu_put - restore host fpexc */ >>>>> +static inline void vcpu_restore_host_fpexc(struct kvm_vcpu *vcpu) >>>>> +{ >>>>> + fmxr(FPEXC, vcpu->arch.host_fpexc); >>>>> +} >>>>> + >>>>> +/* If trap bits are reset then fp/simd registers are dirty */ >>>>> +static inline bool vcpu_vfp_isdirty(struct kvm_vcpu *vcpu) >>>>> +{ >>>>> + return !(vcpu->arch.hcptr & (HCPTR_TCP(10) | HCPTR_TCP(11))); >>>>> +} >>>>> +#else >>>>> +static inline void vcpu_trap_vfp_enable(struct kvm_vcpu *vcpu) >>>>> +{ >>>>> + vcpu->arch.hcptr = HCPTR_TTA; >>>> >>>> Is it correct not to trap VFP registers when the host kernel does not >>>> have CONFIG_VFPv3? I think this is a change in functionality compared >>>> to the current kernels is it not? >>> >>> With CPU_V7 VFPv3 gets selected, without it fp should be emulated, >>> with exceptions taken in guest kernel. I don't see a reason why >>> fp hcptr access should be enabled in that case. >>> >> >> If you have to guests with CONFIG_VFPV3 but your host doesn't have >> CONFIG_VFPV3, you will never context-switch the VFP registers between >> the two VMs, and mayhem will ensue. >> >> Unless I'm missing something very obvious? Did more testing on this enabling OABI_COMPAT and selecting NWFPE/FastFPE breaks the boot. So far can't find a way to boot host without VFP/VFPv3 enabled on ARMv7. CPU_V7 defaults to VFPv3 selection. I'm wondering if !VFPv3 path should be removed from the patches? - Mario > > Hi Christoffer, > - on host I disabled VFP/VFPv3 and got a lot of Illegal instructions > and many other problems. Perhaps disabling for armv7 this option may need > re-evaluation. > - Enabling VFPv3 on host and running guest with no vfpv3 appears > to work with few glitches. > - and vpfv3 host/guest works just fine. > > Appears disabling vfpv3 on armv7 requires another investigation (atleast > on my end). > > BTW this is on fast models. > > - Mario > >> >> -Christoffer >> > _______________________________________________ > kvmarm mailing list > kvmarm at lists.cs.columbia.edu > https://lists.cs.columbia.edu/mailman/listinfo/kvmarm >