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 52F76CD8C88 for ; Sun, 7 Jun 2026 13:58:02 +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=J7GnilSwRfi66VVqN5+bysGT6o5bX4Vlpx4/8SB2poU=; b=zJEQPQA/IXwIQRPE11GolvZ1nk 4lfARLXlUehfPjbmVhLeB2kS23YaCpO+rzXcnbRIXlmMqFblf4V/aAYPBEwIA7/KE/2lZpExkNaq0 HhXKTOvSzldF8cLc1ld3q4SlxOGJj8JQctKtCYVmUPfAk+JoGUQ377dKwV0TA8jk7qgJHPBD93CH+ d3NFa/UswIBAeq2KKiixkuNlB5bO/sW6YVDT6bHsHG0Bns57hKsYoenaSw/5OwRVIVe8nsG0gM3rI FN4kjafQbvG9PpefyMGXVTitXZ+MhzImz8oJoR8kLmlWx+TdUEhscnHbJoyfzSyJopyBmPHEUrYWm bR6xy6dg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.99.1 #2 (Red Hat Linux)) id 1wWE0f-00000002HN9-39gf; Sun, 07 Jun 2026 13:57:53 +0000 Received: from tor.source.kernel.org ([2600:3c04:e001:324:0:1991:8:25]) by bombadil.infradead.org with esmtps (Exim 4.99.1 #2 (Red Hat Linux)) id 1wWE0d-00000002HN1-2cLh for linux-arm-kernel@lists.infradead.org; Sun, 07 Jun 2026 13:57:51 +0000 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by tor.source.kernel.org (Postfix) with ESMTP id 59A6F6001D; Sun, 7 Jun 2026 13:57:49 +0000 (UTC) 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) 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 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 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.