From patchwork Mon Nov 5 14:36:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marc Zyngier X-Patchwork-Id: 10668361 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6342515A6 for ; Mon, 5 Nov 2018 14:36:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 537FE29906 for ; Mon, 5 Nov 2018 14:36:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 47CB22990A; Mon, 5 Nov 2018 14:36:54 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D67A629906 for ; Mon, 5 Nov 2018 14:36:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730032AbeKEX4x (ORCPT ); Mon, 5 Nov 2018 18:56:53 -0500 Received: from foss.arm.com ([217.140.101.70]:44908 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730026AbeKEX4w (ORCPT ); Mon, 5 Nov 2018 18:56:52 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 6840415AD; Mon, 5 Nov 2018 06:36:52 -0800 (PST) Received: from filthy-habits.cambridge.arm.com (filthy-habits.cambridge.arm.com [10.1.196.62]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id E46BC3F7B4; Mon, 5 Nov 2018 06:36:50 -0800 (PST) From: Marc Zyngier To: linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org Cc: Will Deacon , Catalin Marinas , Christoffer Dall , Mark Rutland , Suzuki K Poulose Subject: [PATCH 2/4] KVM: arm64: Allow implementations to be confined to using VHE Date: Mon, 5 Nov 2018 14:36:14 +0000 Message-Id: <20181105143617.120602-3-marc.zyngier@arm.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181105143617.120602-1-marc.zyngier@arm.com> References: <20181105143617.120602-1-marc.zyngier@arm.com> MIME-Version: 1.0 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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"); + return -ENODEV; + } } for_each_online_cpu(cpu) {