From mboxrd@z Thu Jan 1 00:00:00 1970 From: Dave Martin Subject: Re: [PATCH 2/4] KVM: arm64: Allow implementations to be confined to using VHE Date: Thu, 8 Nov 2018 19:23:09 +0000 Message-ID: <20181108192309.GH3505@e103592.cambridge.arm.com> References: <20181105143617.120602-1-marc.zyngier@arm.com> <20181105143617.120602-3-marc.zyngier@arm.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Cc: Catalin Marinas , Will Deacon , kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, kvm@vger.kernel.org To: Marc Zyngier Return-path: Content-Disposition: inline In-Reply-To: <20181105143617.120602-3-marc.zyngier@arm.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kvmarm-bounces@lists.cs.columbia.edu Sender: kvmarm-bounces@lists.cs.columbia.edu List-Id: kvm.vger.kernel.org On Mon, Nov 05, 2018 at 02:36:14PM +0000, Marc Zyngier wrote: > Some implementations may be forced to use VHE to work around HW > errata, for example. Let's introduce a helper that checks for > these cases. > > Signed-off-by: Marc Zyngier > --- > arch/arm/include/asm/kvm_host.h | 1 + > arch/arm64/include/asm/kvm_host.h | 6 ++++++ > virt/kvm/arm/arm.c | 5 +++++ > 3 files changed, 12 insertions(+) > > diff --git a/arch/arm/include/asm/kvm_host.h b/arch/arm/include/asm/kvm_host.h > index c3469729f40c..0f2f782548cb 100644 > --- a/arch/arm/include/asm/kvm_host.h > +++ b/arch/arm/include/asm/kvm_host.h > @@ -286,6 +286,7 @@ void kvm_mmu_wp_memory_region(struct kvm *kvm, int slot); > struct kvm_vcpu *kvm_mpidr_to_vcpu(struct kvm *kvm, unsigned long mpidr); > > static inline bool kvm_arch_sve_requires_vhe(void) { return false; } > +static inline bool kvm_arch_impl_requires_vhe(void) { return false; } > static inline void kvm_arch_hardware_unsetup(void) {} > static inline void kvm_arch_sync_events(struct kvm *kvm) {} > static inline void kvm_arch_vcpu_uninit(struct kvm_vcpu *vcpu) {} > diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h > index ca1714148400..7d6e974d024a 100644 > --- a/arch/arm64/include/asm/kvm_host.h > +++ b/arch/arm64/include/asm/kvm_host.h > @@ -432,6 +432,12 @@ static inline bool kvm_arch_sve_requires_vhe(void) > return system_supports_sve(); > } > > +static inline bool kvm_arch_impl_requires_vhe(void) > +{ > + /* Some implementations have defects that confine them to VHE */ > + return false; > +} > + > static inline void kvm_arch_hardware_unsetup(void) {} > static inline void kvm_arch_sync_events(struct kvm *kvm) {} > static inline void kvm_arch_vcpu_uninit(struct kvm_vcpu *vcpu) {} > diff --git a/virt/kvm/arm/arm.c b/virt/kvm/arm/arm.c > index 66de2efddfca..bc90a1cdd27f 100644 > --- a/virt/kvm/arm/arm.c > +++ b/virt/kvm/arm/arm.c > @@ -1647,6 +1647,11 @@ int kvm_arch_init(void *opaque) > kvm_pr_unimpl("SVE system without VHE unsupported. Broken cpu?"); > return -ENODEV; > } > + > + if (kvm_arch_impl_requires_vhe()) { > + kvm_pr_unimpl("CPU requiring VHE in non-VHE mode"); ( Scratch my previous comment if unless you restructure the code so there's only one nested if() here. ) Also, minor nit: it sounds like "VHE in non-VHE mode" is the thing this CPU requires, which is somewhat confusing. Does it work to word this as "CPU requiring VHE was booted in non-VHE mode" ? Cheers ---Dave From mboxrd@z Thu Jan 1 00:00:00 1970 From: Dave.Martin@arm.com (Dave Martin) Date: Thu, 8 Nov 2018 19:23:09 +0000 Subject: [PATCH 2/4] KVM: arm64: Allow implementations to be confined to using VHE In-Reply-To: <20181105143617.120602-3-marc.zyngier@arm.com> References: <20181105143617.120602-1-marc.zyngier@arm.com> <20181105143617.120602-3-marc.zyngier@arm.com> Message-ID: <20181108192309.GH3505@e103592.cambridge.arm.com> To: linux-arm-kernel@lists.infradead.org List-Id: linux-arm-kernel.lists.infradead.org On Mon, Nov 05, 2018 at 02:36:14PM +0000, Marc Zyngier wrote: > Some implementations may be forced to use VHE to work around HW > errata, for example. Let's introduce a helper that checks for > these cases. > > Signed-off-by: Marc Zyngier > --- > arch/arm/include/asm/kvm_host.h | 1 + > arch/arm64/include/asm/kvm_host.h | 6 ++++++ > virt/kvm/arm/arm.c | 5 +++++ > 3 files changed, 12 insertions(+) > > diff --git a/arch/arm/include/asm/kvm_host.h b/arch/arm/include/asm/kvm_host.h > index c3469729f40c..0f2f782548cb 100644 > --- a/arch/arm/include/asm/kvm_host.h > +++ b/arch/arm/include/asm/kvm_host.h > @@ -286,6 +286,7 @@ void kvm_mmu_wp_memory_region(struct kvm *kvm, int slot); > struct kvm_vcpu *kvm_mpidr_to_vcpu(struct kvm *kvm, unsigned long mpidr); > > static inline bool kvm_arch_sve_requires_vhe(void) { return false; } > +static inline bool kvm_arch_impl_requires_vhe(void) { return false; } > static inline void kvm_arch_hardware_unsetup(void) {} > static inline void kvm_arch_sync_events(struct kvm *kvm) {} > static inline void kvm_arch_vcpu_uninit(struct kvm_vcpu *vcpu) {} > diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h > index ca1714148400..7d6e974d024a 100644 > --- a/arch/arm64/include/asm/kvm_host.h > +++ b/arch/arm64/include/asm/kvm_host.h > @@ -432,6 +432,12 @@ static inline bool kvm_arch_sve_requires_vhe(void) > return system_supports_sve(); > } > > +static inline bool kvm_arch_impl_requires_vhe(void) > +{ > + /* Some implementations have defects that confine them to VHE */ > + return false; > +} > + > static inline void kvm_arch_hardware_unsetup(void) {} > static inline void kvm_arch_sync_events(struct kvm *kvm) {} > static inline void kvm_arch_vcpu_uninit(struct kvm_vcpu *vcpu) {} > diff --git a/virt/kvm/arm/arm.c b/virt/kvm/arm/arm.c > index 66de2efddfca..bc90a1cdd27f 100644 > --- a/virt/kvm/arm/arm.c > +++ b/virt/kvm/arm/arm.c > @@ -1647,6 +1647,11 @@ int kvm_arch_init(void *opaque) > kvm_pr_unimpl("SVE system without VHE unsupported. Broken cpu?"); > return -ENODEV; > } > + > + if (kvm_arch_impl_requires_vhe()) { > + kvm_pr_unimpl("CPU requiring VHE in non-VHE mode"); ( Scratch my previous comment if unless you restructure the code so there's only one nested if() here. ) Also, minor nit: it sounds like "VHE in non-VHE mode" is the thing this CPU requires, which is somewhat confusing. Does it work to word this as "CPU requiring VHE was booted in non-VHE mode" ? Cheers ---Dave