[PATCH] KVM: arm64: Pass a 64bit function-id in the SMC handlers

Marc Zyngier maz at kernel.org
Wed Apr 1 11:34:23 PDT 2026


On Wed, 01 Apr 2026 19:28:28 +0100,
Marc Zyngier <maz at kernel.org> wrote:
> 
> On Wed, 01 Apr 2026 18:21:58 +0100,
> Sebastian Ene <sebastianene at google.com> 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 <sebastianene at google.com> 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();

Plus the obviously missing:

+		return;

> +	}
> +

	M.

-- 
Jazz isn't dead. It just smells funny.



More information about the linux-arm-kernel mailing list