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: 10668373 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 2F5CD175A for ; Mon, 5 Nov 2018 14:41:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 17173298F4 for ; Mon, 5 Nov 2018 14:41:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0B33F2990E; Mon, 5 Nov 2018 14:41:09 +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=-3.6 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_LOW autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 378B6298F4 for ; Mon, 5 Nov 2018 14:41:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=p+ykAYR6YcCl/i0lURU6uR/JMQ/klaZvy9DYTw0v9Lw=; b=r4gjAOcUc/2y8c bftOFpC0hAWB41LEY/hKVhLiy54m4Bq2Nd0B9a9KRh2X0FJ++zagxvi32TruC0AckIsGh0OEeBL0A K3HeDbkNO9Ybv9jqKFSa13Ca+QCk4s/cu/wFqgUDEHBPDoihqQoWBs08LklJEtejS/jkdKUvs54Aa +/qOOlxktyoQuJA2pNjUxtinoIUbsqlw2OxZhsub7bo9+5q1JO7IplHudEuAY7Tj9nzOtTKhGgn87 LmMB3GGi1h7uNAGHV+sNJqcAQ6ntSiyqmjqy2mx1DTijz18N0C1qPP7pG2S0S+U4ECWcz3/RReB/u 4QhKj75zpKtfM82JzDQA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gJg3o-0003tS-Oq; Mon, 05 Nov 2018 14:41:00 +0000 Received: from foss.arm.com ([217.140.101.70]) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gJfzw-0001Bh-EG for linux-arm-kernel@lists.infradead.org; Mon, 05 Nov 2018 14:37:03 +0000 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 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181105_063700_539807_D20F58BD X-CRM114-Status: GOOD ( 11.96 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , Catalin Marinas , Will Deacon , Christoffer Dall , Suzuki K Poulose Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.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) {