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 269E210FCAC9 for ; Wed, 1 Apr 2026 18:28:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:MIME-Version: References:In-Reply-To:Subject:Cc:To:From:Message-ID:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=TB6tAOT03NPkINDMfIbxI681ixMV9NgdrkZqK1RyW0o=; b=NLMAO1azW0rCI2ON1O7yJTk3jY cfl5GYtnryYo/DfW0cd0QBXMFkr3rX5Ds2xZf+/o4hM/IdcQwlC7DQoqmfI/y8UtpUVM90cnkrZnR 3ZR6g14mcKzQ0zDMJ/dMjU0vN8duNNqB+388xXW28LsTxy9ul6yeRZ6pdcbeWDtec4Osc//d8NOry OdySRVTIYan5IzyHga4ho9bybdtFP/I5YQNfibtyrGPOAmskpvJOfiBX0n9p0mu6b7LO59pDw/7t2 fGjUqcj3uTdPozM9PJ1pF1ulYkEbtAd9gdfWMFw9bSmNAN8kfjLXIsl2y480k1JyeZItmtzAbFBfA 7Sm+LsTg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1w80Is-0000000FxWG-2zLV; Wed, 01 Apr 2026 18:28:34 +0000 Received: from tor.source.kernel.org ([2600:3c04:e001:324:0:1991:8:25]) by bombadil.infradead.org with esmtps (Exim 4.98.2 #2 (Red Hat Linux)) id 1w80Ir-0000000FxVc-0XTu for linux-arm-kernel@lists.infradead.org; Wed, 01 Apr 2026 18:28:33 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by tor.source.kernel.org (Postfix) with ESMTP id DA94560120; Wed, 1 Apr 2026 18:28:31 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8855DC19423; Wed, 1 Apr 2026 18:28:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1775068111; bh=cnuQKE7lR20BabjHW0Z1mMe+3X8ukWTNhbfSYIsBuuM=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=Z7opBMyFzdVQ8jvFFedCtygTsIf7j1jyf4+hCklIJQ0bdCnG9Y/uDQxFFyo56eVir Ua4oVf3U1nBNsckbdGch4EPq1/4tqcuqs/i8SB9YPT+ICLlXxz0m1cqy6bNa6yK9hI MRU5hK6YS7IDdKEl6oqqCYQSy78qT2K4rcmxpP6sAI8SFZDLkFzJ4PzmgcRtXIG2FS meSMCffkkUcT7x+1G9PsQI+MyULqK8UniFAyF0Mj68iVjqFuYEA+dMFsFzszyfIC28 yxoIHhiykdq0CMKlytlQQfCeklKDqJWk3aaFLJ72jT1qrtZAbWw2e8BG8eAQPzF9D5 XD+hbcg9i3nLQ== Received: from sofa.misterjones.org ([185.219.108.64] helo=lobster-girl.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1w80In-00000007ywO-15Gd; Wed, 01 Apr 2026 18:28:29 +0000 Date: Wed, 01 Apr 2026 19:28:28 +0100 Message-ID: <877bqqcz77.wl-maz@kernel.org> From: Marc Zyngier To: Sebastian Ene Cc: catalin.marinas@arm.com, kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, android-kvm@google.com, joey.gouly@arm.com, korneld@google.com, mrigendra.chaubey@gmail.com, oupton@kernel.org, perlarsen@google.com, suzuki.poulose@arm.com, will@kernel.org, yuzenghui@huawei.com Subject: Re: [PATCH] KVM: arm64: Pass a 64bit function-id in the SMC handlers In-Reply-To: References: <20260401123201.389906-1-sebastianene@google.com> <86341e4to0.wl-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/30.1 (aarch64-unknown-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: sebastianene@google.com, catalin.marinas@arm.com, kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, android-kvm@google.com, joey.gouly@arm.com, korneld@google.com, mrigendra.chaubey@gmail.com, oupton@kernel.org, perlarsen@google.com, suzuki.poulose@arm.com, will@kernel.org, yuzenghui@huawei.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Wed, 01 Apr 2026 18:21:58 +0100, Sebastian Ene wrote: > > On Wed, Apr 01, 2026 at 03:55:11PM +0100, Marc Zyngier wrote: > > On Wed, 01 Apr 2026 13:32:01 +0100, > > Sebastian Ene wrote: > > > > > > Make the SMC handlers accept a 64bit value for the function-id to keep > > > it uniform with the rest of the code and prevent a u64 -> u32 -> u64 > > > conversion as it currently happens when we handle PSCI. > > > > That seems overly creative. The spec says (2.5, from ARM DEN 0028 1.6 > > G): > > I'm not plannig to be *overly creative*. Thanks for pointing out the ARM > spec. > > > > > "The Function Identifier is passed on W0 on every SMC and HVC > > call. Its 32-bit integer value indicates which function is being > > requested by the caller. It is always passed as the first argument to > > every SMC or HVC call in R0 or W0." > > > > which indicates that it is *always* a 32bit value. > > > > So if you have a 64bit value somewhere, *that* should be fixed, not > > propagated arbitrarily. > > If you have a non SMCCC call that happen to have the first 32-bits of > the function-id matching either PSCI or FF-A you will end up handling > them instead of forwarding it to Trustzone because func_id is declared as: > > DECLARE_REG(u64, func_id, host_ctxt, 0); Again, the correct approach to prevent the propagation of something that is known to be wrong. Something like this: diff --git a/arch/arm64/kvm/hyp/nvhe/hyp-main.c b/arch/arm64/kvm/hyp/nvhe/hyp-main.c index 007fc993f2319..dae993a1d081b 100644 --- a/arch/arm64/kvm/hyp/nvhe/hyp-main.c +++ b/arch/arm64/kvm/hyp/nvhe/hyp-main.c @@ -694,6 +694,11 @@ static void handle_host_smc(struct kvm_cpu_context *host_ctxt) DECLARE_REG(u64, func_id, host_ctxt, 0); bool handled; + if (upper_32_bits(func_id)) { + cpu_reg(host_ctxt, 0) = SMCCC_RET_NOT_SUPPORTED; + kvm_skip_host_instr(); + } + func_id &= ~ARM_SMCCC_CALL_HINTS; handled = kvm_host_psci_handler(host_ctxt, func_id); Because forwarding something that is blatantly illegal to the secure side is not something we should accept at all (just like we now refuse non-zero SMC immediate values). Thanks, M. -- Jazz isn't dead. It just smells funny.