Message ID | 20221020090727.3669908-5-maz@kernel.org (mailing list archive) |
---|---|
State | New, archived |
Headers | show
Return-Path: <linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org> X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2277DC4332F for <linux-arm-kernel@archiver.kernel.org>; Thu, 20 Oct 2022 09:09:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=nsX09iEXn8NX3NBkSPE730UpllwVFmJuTbKTnZ9fr7c=; b=wk/I3pR2mgdCC5 FvsJKWZF8ak66wZD5ZVLzEZgK0tXwffui7aDujWEX5cRK8+TadAdWlQTE0oid6T2s8kr9mUo9VKq5 VKgCLQ+8JyPDyel6kSSH3lKxcYDQOGcBtZPD77pSkPmcuhchINwRo+FcbpozbK7d6F8/L949waHnR WGRw4/Li8TO00c9X67hxd+18OkOrZz4FUzQnBLulufSjgNcLfVApiYc5RHbuwrT7tV9mvc+OG9apB RMYKEWeDJYOPQyp73NYT/v3A3VxqjfxTdeCF8kRrf/vfsO5+BrraeBmec7hUWsWZGvhuHpzIScWnl 1dVimMAN2p34t5qIHAug==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1olRXL-00CijJ-D3; Thu, 20 Oct 2022 09:08:23 +0000 Received: from ams.source.kernel.org ([145.40.68.75]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1olRWe-00CiGn-7O for linux-arm-kernel@lists.infradead.org; Thu, 20 Oct 2022 09:07:42 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id E3180B826AF; Thu, 20 Oct 2022 09:07:38 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 89FABC43140; Thu, 20 Oct 2022 09:07:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1666256857; bh=L1c/+tFZZRhijg30lPPqIBaHqiyb70GwjjA7yQE8RbU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kdHjbnJxE1vsadwz99+FDtf+3bDvjYIypzkkG++XKlx5pC2sCEgLZWVGpRaO+deYE rDw2gXsPIO8OXFey6/zSQOejSCNiPwJ274Olia2ILnPtQrx5d8F76hAJSTs2W+pynX W/fCe+UDInZhlj/JnXY5oVDVtv3rPMv8lU128yqTn5DqxqF+8y/PCItcN9mG49MrNl aCH+r4AGlo1cPKUof1+CeExDOlUAJR47D/5QHHzkjpd1Epx18yhDTMVdH0xuUNRQut nt1Xl0+/tVdaedjuNmV9uBWxjr7Dy9cv9bZhD/exzmF+zv5l9HtZCe58h0IEjyHgeN 17JzpXPpLoMow== Received: from sofa.misterjones.org ([185.219.108.64] helo=valley-girl.lan) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from <maz@kernel.org>) id 1olRWZ-000Buf-Id; Thu, 20 Oct 2022 10:07:35 +0100 From: Marc Zyngier <maz@kernel.org> To: <kvmarm@lists.cs.columbia.edu>, <kvmarm@lists.linux.dev>, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: James Morse <james.morse@arm.com>, Suzuki K Poulose <suzuki.poulose@arm.com>, Alexandru Elisei <alexandru.elisei@arm.com>, Oliver Upton <oliver.upton@linux.dev>, Quentin Perret <qperret@google.com>, Will Deacon <will@kernel.org>, Fuad Tabba <tabba@google.com> Subject: [PATCH 04/17] arm64: Prevent the use of is_kernel_in_hyp_mode() in hypervisor code Date: Thu, 20 Oct 2022 10:07:14 +0100 Message-Id: <20221020090727.3669908-5-maz@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221020090727.3669908-1-maz@kernel.org> References: <20221020090727.3669908-1-maz@kernel.org> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: kvmarm@lists.cs.columbia.edu, kvmarm@lists.linux.dev, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, james.morse@arm.com, suzuki.poulose@arm.com, alexandru.elisei@arm.com, oliver.upton@linux.dev, qperret@google.com, will@kernel.org, tabba@google.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221020_020740_424798_FCA0483C X-CRM114-Status: GOOD ( 13.23 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: <linux-arm-kernel.lists.infradead.org> List-Unsubscribe: <http://lists.infradead.org/mailman/options/linux-arm-kernel>, <mailto:linux-arm-kernel-request@lists.infradead.org?subject=unsubscribe> List-Archive: <http://lists.infradead.org/pipermail/linux-arm-kernel/> List-Post: <mailto:linux-arm-kernel@lists.infradead.org> List-Help: <mailto:linux-arm-kernel-request@lists.infradead.org?subject=help> List-Subscribe: <http://lists.infradead.org/mailman/listinfo/linux-arm-kernel>, <mailto:linux-arm-kernel-request@lists.infradead.org?subject=subscribe> Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" <linux-arm-kernel-bounces@lists.infradead.org> Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org |
Series |
KVM: arm64: Allow using VHE in the nVHE hypervisor
|
expand
|
diff --git a/arch/arm64/include/asm/virt.h b/arch/arm64/include/asm/virt.h index b11a1c8c8b36..5f84a87a6a2d 100644 --- a/arch/arm64/include/asm/virt.h +++ b/arch/arm64/include/asm/virt.h @@ -110,8 +110,13 @@ static inline bool is_hyp_mode_mismatched(void) return __boot_cpu_mode[0] != __boot_cpu_mode[1]; } -static inline bool is_kernel_in_hyp_mode(void) +extern void gotcha_is_kernel_in_hyp_mode(void); + +static __always_inline bool is_kernel_in_hyp_mode(void) { +#if defined(__KVM_NVHE_HYPERVISOR__) || defined(__KVM_VHE_HYPERVISOR__) + gotcha_is_kernel_in_hyp_mode(); +#endif return read_sysreg(CurrentEL) == CurrentEL_EL2; }
Using is_kernel_in_hyp_mode() in hypervisor code is a pretty bad mistake. This helper only checks for CurrentEL being EL2, which is always true. Make the link fail if using the helper in hypervisor context by referencing a non-existent function. Whilst we're at it, flag the helper as __always_inline, which it really should be. Signed-off-by: Marc Zyngier <maz@kernel.org> --- arch/arm64/include/asm/virt.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)