From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5FEE217A309 for ; Sun, 7 Jun 2026 13:57:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780840670; cv=none; b=bb1n+JmZwumPsKuNwxzFj7RYloFIfPQobInYCKbsyEM02RrSPtfjru6vQXU0cGFTXDY4a5T94CuDK7OjH92gE3V9FwcY5XadRqrvj46YJDJULlExczriFxuc4MV8jWYoJDd4957lEB4yOk1TKkrSCHrKWrllwOPoqcOirBcG5hg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780840670; c=relaxed/simple; bh=1ENHuFDR6S5WNQQy4lZW55U1X5K9oNzNXVox9sKV3Ys=; h=Date:Message-ID:From:To:Cc:Subject:In-Reply-To:References: MIME-Version:Content-Type; b=JDEHQiqxTeAwzKe10c8zt2pqzy3WzIAdjVzEiV1WPUi8BDQ9H4K6Psx+uQ5uZfCMWV39wNuZTGs2FmFQCWuPYAi94GrJadrMQVTQJj54j2mZVrQli8ZbeDryn0xE5DAeQa1C8qIHCdfg6DsJJ8yduoEuTeT54KjED0RBr5lBFDI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=mVhK984x; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="mVhK984x" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 067931F00893; Sun, 7 Jun 2026 13:57:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1780840669; bh=J7GnilSwRfi66VVqN5+bysGT6o5bX4Vlpx4/8SB2poU=; h=Date:From:To:Cc:Subject:In-Reply-To:References; b=mVhK984xJhTtClRveStLHONb0f3rYZwW1fMV2ZHzEuE/Av/RsGjcrR8t4SyDAp/gE mVmmSWb8DSMfbT1FtIY9nGcHlkQbn+qNN72Kc8esF4Xh34h74FaWWTv3Wc9pSnciBF JzWobWRtW7L7OCcHWuI9IqPRzW/UAnI0NHlJyt2vzLys6tAqpBoP3HOWFZcy+yvlZz CnANzB9fXSByDiplR8HxEAiqShGfATbbQ6hVMi/3GWAqW3jibGDA9MNQldUekq9q67 OKnq78XZ4xoy+0cbBpfgtbJJawoiZcTALPqYlR4huwYx1ud0wHPhCJZ4wqCVNkpWK1 MTfzEWo0kslCQ== 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 1wWE0X-0000000ACY9-1vhZ; Sun, 07 Jun 2026 13:57:46 +0000 Date: Sun, 07 Jun 2026 15:01:03 +0100 Message-ID: <87zf168n6o.wl-maz@kernel.org> From: Marc Zyngier To: Will Deacon Cc: Vincent Donnefort , oliver.upton@linux.dev, joey.gouly@arm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com, catalin.marinas@arm.com, linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, kernel-team@android.com, tabba@google.com Subject: Re: [PATCH] KVM: arm64: Set a linux errno on SMCCC error in kvm_call_hyp_nvhe() In-Reply-To: References: <20260603110312.2909844-1-vdonnefort@google.com> 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) Precedence: bulk X-Mailing-List: kvmarm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: 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: will@kernel.org, vdonnefort@google.com, oliver.upton@linux.dev, joey.gouly@arm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com, catalin.marinas@arm.com, linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, kernel-team@android.com, 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 On Fri, 05 Jun 2026 12:23:40 +0100, Will Deacon wrote: > > On Wed, Jun 03, 2026 at 12:03:12PM +0100, Vincent Donnefort wrote: > > If the HVC called in kvm_call_hyp_nvhe() fails with an SMCCC error code, > > we WARN. However, the returned value isn't initialized and the caller > > might get garbage or 0 which is likely to be interpreted as success. > > > > Set a default -EPERM error value, ensuring all callers get the message > > when SMCCC calls fail. > > > > Signed-off-by: Vincent Donnefort > > > > --- > > > > I have encountered this issue while working on a follow-up contribution to the > > hypervisor tracing. In that case it completely crashed the kernel because > > IS_ERR() failed on that res.a1 value. > > > > Now, if it makes that function more robust, I do not believe it is fixing any > > existing bug which is why I haven't added a "Fixes:" tag. > > > > In case we want to stick one, here it is: > > > > Fixes: 054698316d87 ("KVM: arm64: nVHE: Migrate hyp interface to SMCCC") > > > > diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h > > index a49042bfa801..6b8fd494792c 100644 > > --- a/arch/arm64/include/asm/kvm_host.h > > +++ b/arch/arm64/include/asm/kvm_host.h > > @@ -1273,13 +1273,14 @@ void kvm_arm_resume_guest(struct kvm *kvm); > > #define vcpu_has_run_once(vcpu) (!!READ_ONCE((vcpu)->pid)) > > > > #ifndef __KVM_NVHE_HYPERVISOR__ > > -#define kvm_call_hyp_nvhe(f, ...) \ > > +#define kvm_call_hyp_nvhe(f, ...) \ > > ({ \ > > struct arm_smccc_res res; \ > > \ > > arm_smccc_1_1_hvc(KVM_HOST_SMCCC_FUNC(f), \ > > ##__VA_ARGS__, &res); \ > > - WARN_ON(res.a0 != SMCCC_RET_SUCCESS); \ > > + if (WARN_ON(res.a0 != SMCCC_RET_SUCCESS)) \ > > + res.a1 = -EPERM; \ > > \ > > res.a1; \ > > }) > > Looks like the only error code we return to the host is > SMCCC_RET_NOT_SUPPORTED, so maybe -EOPNOTSUPP would be more appropriate? Yes, this is better. I've hacked the patch to reflect this upon applying it. Thanks, M. -- Jazz isn't dead. It just smells funny.