From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 151E43563FE; Mon, 2 Feb 2026 09:14:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770023669; cv=none; b=Z36mv1YeXiwKW49qxRrA/EBO3tUwj0lFHg27/a1VaTwWnnpSryhJiWkfj0o3N5T5BNPIQXiQZOY59Vo7WUHbT0X3K9Pb2XeWRMHx7Cp0+gENvDLHUXdPKP7ZDykX1EED5h0hKOQVMi7ENnK7KLZzhqBZWiwPYnIMgje4ESQE21E= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770023669; c=relaxed/simple; bh=CdgeLmXVQi0CFJKfkUOWW2ZfhctpbwdNhykYHfA9aNo=; h=Date:Message-ID:From:To:Cc:Subject:In-Reply-To:References: MIME-Version:Content-Type; b=PjQcAIOQFNBfebWOaeJUlwaVvAe5TEtB0ysqGH1ZHWpCRtMqNpRLg5rWRnImYPJrNdxvznaS+wSrZuuqsohPbNLtmn6e7OTHBocejrkuILOQ9aZUUs7P6UgUNe8eTdlYA9eZGp5qujo6mwMClmdavKtyhpyQMAe+vzNGW8KspmQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=jNbXLeUg; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="jNbXLeUg" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9C189C116C6; Mon, 2 Feb 2026 09:14:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1770023668; bh=CdgeLmXVQi0CFJKfkUOWW2ZfhctpbwdNhykYHfA9aNo=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=jNbXLeUg92D7Ydkvq3UkgbqhWjQdwz4qm0OHxqAS3WSUe3ee2hRooMtkbug2asE5v +f6R/wwydBKrre8CF5tsDvt0T5h6FteO6sUhlarIPRi/zZvuJh5tY1ithcrP/A8Kb+ nMxC7OpZig2+xUNwunmh3y3FnW82RE5xt1sRlBsV4AN+e3fkhe+tqognGYRrKC04AI 5zTHI9f6qY+Q3Xz1yS3qyzYXCHklg73S9df23Hrk6rHBU7IBZP+fxZzc4shnh9w4PQ bOEPrpduAdSTTiSWi1+bphsme4BS1RaO98KLK/GZD30BolyGs5XQGGo4edhXnKmWuv G6wA7eigk56oA== 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.98.2) (envelope-from ) id 1vmq0n-00000007iNU-33Nc; Mon, 02 Feb 2026 09:14:25 +0000 Date: Mon, 02 Feb 2026 09:14:25 +0000 Message-ID: <86wm0va4ni.wl-maz@kernel.org> From: Marc Zyngier To: Fuad Tabba Cc: kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, kvm@vger.kernel.org, Joey Gouly , Suzuki K Poulose , Oliver Upton , Zenghui Yu , Will Deacon , Catalin Marinas Subject: Re: [PATCH 20/20] KVM: arm64: Add debugfs file dumping computed RESx values In-Reply-To: References: <20260126121655.1641736-1-maz@kernel.org> <20260126121655.1641736-21-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) Precedence: bulk X-Mailing-List: kvm@vger.kernel.org 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: tabba@google.com, kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, kvm@vger.kernel.org, joey.gouly@arm.com, suzuki.poulose@arm.com, oupton@kernel.org, yuzenghui@huawei.com, will@kernel.org, catalin.marinas@arm.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false On Mon, 02 Feb 2026 08:59:45 +0000, Fuad Tabba wrote: > > Hi Marc, > > On Mon, 26 Jan 2026 at 12:17, Marc Zyngier wrote: > > > > Computing RESx values is hard. Verifying that they are correct is > > harder. Add a debugfs file called "resx" that will dump all the RESx > > values for a given VM. > > > > I found it useful, maybe you will too. > > I'm sure I will :) > > > Signed-off-by: Marc Zyngier > > --- > > arch/arm64/include/asm/kvm_host.h | 1 + > > arch/arm64/kvm/sys_regs.c | 98 +++++++++++++++++++++++++++++++ > > 2 files changed, 99 insertions(+) > > > > diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h > > index c82b071ade2a5..54072f6ec9d4b 100644 > > --- a/arch/arm64/include/asm/kvm_host.h > > +++ b/arch/arm64/include/asm/kvm_host.h > > @@ -375,6 +375,7 @@ struct kvm_arch { > > > > /* Iterator for idreg debugfs */ > > u8 idreg_debugfs_iter; > > + u16 sr_resx_iter; > > Storing `sr_resx_iter` in `struct kvm_arch` effectively makes this > debugfs file exclusive (returning -EBUSY on contention). Standard > `seq_file` implementations should be stateless, using the `loff_t > *pos` argument to track the index. This allows multiple users to read > the file simultaneously without blocking each other. Yup, that's a good point. I guess I've lazily reimplemented a square wheel... > > > > > /* Hypercall features firmware registers' descriptor */ > > struct kvm_smccc_features smccc_feat; > > diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c > > index 88a57ca36d96c..f3f92b489b588 100644 > > --- a/arch/arm64/kvm/sys_regs.c > > +++ b/arch/arm64/kvm/sys_regs.c > > @@ -5090,12 +5090,110 @@ static const struct seq_operations idregs_debug_sops = { > > > > DEFINE_SEQ_ATTRIBUTE(idregs_debug); > > > > +static const struct sys_reg_desc *sr_resx_find(struct kvm *kvm, u16 pos) > > +{ > > + unsigned long i, sr_idx = 0; > > + > > + for (i = 0; i < ARRAY_SIZE(sys_reg_descs); i++) { > > + const struct sys_reg_desc *r = &sys_reg_descs[i]; > > + > > + if (r->reg < __SANITISED_REG_START__) > > + continue; > > + > > + if (sr_idx == pos) > > + return r; > > + > > + sr_idx++; > > + } > > + > > + return NULL; > > +} > > + > > +static void *sr_resx_start(struct seq_file *s, loff_t *pos) > > +{ > > + struct kvm *kvm = s->private; > > + u16 *iter; > > + > > + guard(mutex)(&kvm->arch.config_lock); > > My understanding of `guard()` is that it releases the lock as soon as > the current scope ends (i.e., when `sr_resx_start() `returns). If the > intention was to protect the iteration, it seems like `sr_resx_next()` > and `sr_resx_show()` would end up running unprotected. That said, > converting this to a standard `seq_file` implementation should remove > the need for locking altogether. > > I guess you based your code on the existing code for the idregs > debugfs. I had a look at that, and at vgic-debug, and I think they > both can be simplified and made more robust [1]. I also have a diff > that converts this to use `seq_file`. It's pretty similar to what I > have for idregs in the series I sent out [2]. Let me know if you'd > like me to share it. Yes please. We might as well do the right thing, and I can fold that into my current series with you as a co-author. Thanks, M. -- Without deviation from the norm, progress is not possible.