From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 B87DAC77B73 for ; Wed, 31 May 2023 07:17:35 +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: Subject:Cc:To:From:Message-ID:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=+G+6aou5ilqFw6TLbblYTsfIgVhkWZOMzVLJQORABWI=; b=3p7Hm2O6mcXbWP 3EOgCNB8nV+19Bq3xaF44U3LvBU9ja+6mp3XN+rxgkd3ouZJOko3mPnHksLktVKxd6RV7Ysi6gt2u M+QE+VvQ8U6SoYWW1tFJgZ1ucucUXkcOL+hzpx6LP+u1D/DdnolYX3Qs2hRZ6UnqbTopXY1aCDw4V 1OECmOSDhya/4xYRoz+f6M4DxQsG1zvvzcNc6fFmIu9KbZxckDilKtHfJcSYnx9da439SO4hEZhdl EEP0SOtNfGkCNiDvwnfSzCptBCOih51Ou6pVNoaZnyy1mESWK8Z7HTRGDiUtMH+rlFALvpWa+zwgw BY1mCxQ1rhAepxW/hrYQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q4G52-00GPIJ-0h; Wed, 31 May 2023 07:17:12 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q4G4y-00GPHG-0U for linux-arm-kernel@lists.infradead.org; Wed, 31 May 2023 07:17:10 +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 dfw.source.kernel.org (Postfix) with ESMTPS id 83E9A61615; Wed, 31 May 2023 07:17:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E401BC433EF; Wed, 31 May 2023 07:17:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1685517427; bh=tmaVEwOR1njCj6VixWX3ZnHGosVCCTCzU+UjS4/vFTo=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=FdRKB1mEF4/guS6f6jz0w0VvNUuScegW5mPEVDLXczSM7Iyr4PJs8MX7XKUg1m1QK sAL1K48rJB7jcUselPRy35CB+Y+XCBaE5hH8oY/tXYq2Kc9ntCkjbzSyH6F9vjvB3c fPCKbDVI5z5NNQnu3yqwEx14spu5N9/fr4wbr9YjInlJtZ+mA/V7Lpywspdip+XY2I oLF8vklid0eL6fxXzppXuIlvXVcEB3/AP1QMi0I5ov91NJWICybxcbGylxNExgUeyV xkn9Ze/Onglt3fxOEtp5O0ydc8jpWIsd0SKJhaL9OPgzNVgJ3D6hkP7hY0AY0n+36u 3i2JLxEmwTNIg== Received: from sofa.misterjones.org ([185.219.108.64] helo=goblin-girl.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1q4G4u-001Xcj-MO; Wed, 31 May 2023 08:17:04 +0100 Date: Wed, 31 May 2023 08:17:04 +0100 Message-ID: <865y89c6mn.wl-maz@kernel.org> From: Marc Zyngier To: Oliver Upton Cc: kvmarm@lists.linux.dev, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, James Morse , Suzuki K Poulose , Zenghui Yu , Quentin Perret , Will Deacon , Fuad Tabba Subject: Re: [PATCH v2 02/17] arm64: Prevent the use of is_kernel_in_hyp_mode() in hypervisor code In-Reply-To: References: <20230526143348.4072074-1-maz@kernel.org> <20230526143348.4072074-3-maz@kernel.org> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/28.2 (aarch64-unknown-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: oliver.upton@linux.dev, kvmarm@lists.linux.dev, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, james.morse@arm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com, 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-20230531_001708_291227_70DE5CA8 X-CRM114-Status: GOOD ( 25.93 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Tue, 30 May 2023 20:54:51 +0100, Oliver Upton wrote: > > Hi Marc, > > On Fri, May 26, 2023 at 03:33:33PM +0100, Marc Zyngier wrote: > > 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 > > --- > > arch/arm64/include/asm/virt.h | 7 ++++++- > > 1 file changed, 6 insertions(+), 1 deletion(-) > > > > diff --git a/arch/arm64/include/asm/virt.h b/arch/arm64/include/asm/virt.h > > index 4eb601e7de50..91029709d133 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; > > } > > Would BUILD_BUG() work in this context, or have I missed something? Too obvious? :-) I'll fix that. Thanks, M. -- Without deviation from the norm, progress is not possible. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel