From: Marc Zyngier <maz@kernel.org>
To: Fuad Tabba <tabba@google.com>
Cc: kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org,
kvm@vger.kernel.org, Joey Gouly <joey.gouly@arm.com>,
Suzuki K Poulose <suzuki.poulose@arm.com>,
Oliver Upton <oupton@kernel.org>,
Zenghui Yu <yuzenghui@huawei.com>, Will Deacon <will@kernel.org>,
Catalin Marinas <catalin.marinas@arm.com>
Subject: Re: [PATCH 20/20] KVM: arm64: Add debugfs file dumping computed RESx values
Date: Mon, 02 Feb 2026 09:14:25 +0000 [thread overview]
Message-ID: <86wm0va4ni.wl-maz@kernel.org> (raw)
In-Reply-To: <CA+EHjTxAEah7N1myCgc-XRDjSFLiQcYHQtNjLWt=Ns_Rag6vPw@mail.gmail.com>
On Mon, 02 Feb 2026 08:59:45 +0000,
Fuad Tabba <tabba@google.com> wrote:
>
> Hi Marc,
>
> On Mon, 26 Jan 2026 at 12:17, Marc Zyngier <maz@kernel.org> 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 <maz@kernel.org>
> > ---
> > 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.
next prev parent reply other threads:[~2026-02-02 9:14 UTC|newest]
Thread overview: 53+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-26 12:16 [PATCH 00/20] KVM: arm64: Generalise RESx handling Marc Zyngier
2026-01-26 12:16 ` [PATCH 01/20] arm64: Convert SCTLR_EL2 to sysreg infrastructure Marc Zyngier
2026-01-26 17:53 ` Fuad Tabba
2026-01-26 12:16 ` [PATCH 02/20] KVM: arm64: Remove duplicate configuration for SCTLR_EL1.{EE,E0E} Marc Zyngier
2026-01-26 18:04 ` Fuad Tabba
2026-01-26 12:16 ` [PATCH 03/20] KVM: arm64: Introduce standalone FGU computing primitive Marc Zyngier
2026-01-26 18:35 ` Fuad Tabba
2026-01-26 12:16 ` [PATCH 04/20] KVM: arm64: Introduce data structure tracking both RES0 and RES1 bits Marc Zyngier
2026-01-26 18:54 ` Fuad Tabba
2026-01-26 12:16 ` [PATCH 05/20] KVM: arm64: Extend unified RESx handling to runtime sanitisation Marc Zyngier
2026-01-26 19:15 ` Fuad Tabba
2026-01-27 10:52 ` Marc Zyngier
2026-01-26 12:16 ` [PATCH 06/20] KVM: arm64: Inherit RESx bits from FGT register descriptors Marc Zyngier
2026-01-27 15:21 ` Joey Gouly
2026-01-27 17:58 ` Fuad Tabba
2026-01-26 12:16 ` [PATCH 07/20] KVM: arm64: Allow RES1 bits to be inferred from configuration Marc Zyngier
2026-01-27 15:26 ` Joey Gouly
2026-01-27 17:58 ` Fuad Tabba
2026-01-26 12:16 ` [PATCH 08/20] KVM: arm64: Correctly handle SCTLR_EL1 RES1 bits for unsupported features Marc Zyngier
2026-01-27 18:06 ` Fuad Tabba
2026-01-26 12:16 ` [PATCH 09/20] KVM: arm64: Convert HCR_EL2.RW to AS_RES1 Marc Zyngier
2026-01-27 18:09 ` Fuad Tabba
2026-01-26 12:16 ` [PATCH 10/20] KVM: arm64: Simplify FIXED_VALUE handling Marc Zyngier
2026-01-27 18:20 ` Fuad Tabba
2026-01-26 12:16 ` [PATCH 11/20] KVM: arm64: Add REQUIRES_E2H1 constraint as configuration flags Marc Zyngier
2026-01-27 18:28 ` Fuad Tabba
2026-01-26 12:16 ` [PATCH 12/20] KVM: arm64: Add RESx_WHEN_E2Hx constraints " Marc Zyngier
2026-01-28 17:43 ` Fuad Tabba
2026-01-29 10:14 ` Marc Zyngier
2026-01-29 10:30 ` Fuad Tabba
2026-01-26 12:16 ` [PATCH 13/20] KVM: arm64: Move RESx into individual register descriptors Marc Zyngier
2026-01-29 16:29 ` Fuad Tabba
2026-01-29 17:19 ` Marc Zyngier
2026-01-29 17:39 ` Fuad Tabba
2026-01-29 18:07 ` Marc Zyngier
2026-01-29 18:13 ` Fuad Tabba
2026-01-30 9:06 ` Marc Zyngier
2026-01-26 12:16 ` [PATCH 14/20] KVM: arm64: Simplify handling of HCR_EL2.E2H RESx Marc Zyngier
2026-01-29 16:41 ` Fuad Tabba
2026-01-26 12:16 ` [PATCH 15/20] KVM: arm64: Get rid of FIXED_VALUE altogether Marc Zyngier
2026-01-29 16:54 ` Fuad Tabba
2026-01-26 12:16 ` [PATCH 16/20] KVM: arm64: Simplify handling of full register invalid constraint Marc Zyngier
2026-01-29 17:34 ` Fuad Tabba
2026-01-26 12:16 ` [PATCH 17/20] KVM: arm64: Remove all traces of FEAT_TME Marc Zyngier
2026-01-29 17:43 ` Fuad Tabba
2026-01-26 12:16 ` [PATCH 18/20] KVM: arm64: Remove all traces of HCR_EL2.MIOCNCE Marc Zyngier
2026-01-29 17:51 ` Fuad Tabba
2026-01-26 12:16 ` [PATCH 19/20] KVM: arm64: Add sanitisation to SCTLR_EL2 Marc Zyngier
2026-01-29 18:11 ` Fuad Tabba
2026-01-26 12:16 ` [PATCH 20/20] KVM: arm64: Add debugfs file dumping computed RESx values Marc Zyngier
2026-02-02 8:59 ` Fuad Tabba
2026-02-02 9:14 ` Marc Zyngier [this message]
2026-02-02 9:57 ` Fuad Tabba
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=86wm0va4ni.wl-maz@kernel.org \
--to=maz@kernel.org \
--cc=catalin.marinas@arm.com \
--cc=joey.gouly@arm.com \
--cc=kvm@vger.kernel.org \
--cc=kvmarm@lists.linux.dev \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=oupton@kernel.org \
--cc=suzuki.poulose@arm.com \
--cc=tabba@google.com \
--cc=will@kernel.org \
--cc=yuzenghui@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox