]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
KVM: arm64: Add debugfs file dumping computed RESx values
authorMarc Zyngier <maz@kernel.org>
Mon, 2 Feb 2026 18:43:29 +0000 (18:43 +0000)
committerMarc Zyngier <maz@kernel.org>
Thu, 5 Feb 2026 09:02:13 +0000 (09:02 +0000)
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.

Co-developed-by: Fuad Tabba <tabba@google.com>
Signed-off-by: Fuad Tabba <tabba@google.com>
Tested-by: Fuad Tabba <tabba@google.com>
Link: https://patch.msgid.link/20260202184329.2724080-21-maz@kernel.org
Signed-off-by: Marc Zyngier <maz@kernel.org>
arch/arm64/kvm/sys_regs.c

index 88a57ca36d96c0675fbdaba680645f57cf06261c..d33c39ea8fadd000ad1280111701f612052e9a2f 100644 (file)
@@ -5090,12 +5090,80 @@ 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, loff_t 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;
+       }
+
+       return NULL;
+}
+
+static void *sr_resx_start(struct seq_file *s, loff_t *pos)
+{
+       struct kvm *kvm = s->private;
+
+       if (!kvm->arch.sysreg_masks)
+               return NULL;
+
+       return (void *)sr_resx_find(kvm, *pos);
+}
+
+static void *sr_resx_next(struct seq_file *s, void *v, loff_t *pos)
+{
+       struct kvm *kvm = s->private;
+
+       (*pos)++;
+
+       return (void *)sr_resx_find(kvm, *pos);
+}
+
+static void sr_resx_stop(struct seq_file *s, void *v)
+{
+}
+
+static int sr_resx_show(struct seq_file *s, void *v)
+{
+       const struct sys_reg_desc *desc = v;
+       struct kvm *kvm = s->private;
+       struct resx resx;
+
+       if (!desc)
+               return 0;
+
+       resx = kvm_get_sysreg_resx(kvm, desc->reg);
+
+       seq_printf(s, "%20s:\tRES0:%016llx\tRES1:%016llx\n",
+                  desc->name, resx.res0, resx.res1);
+
+       return 0;
+}
+
+static const struct seq_operations sr_resx_sops = {
+       .start  = sr_resx_start,
+       .next   = sr_resx_next,
+       .stop   = sr_resx_stop,
+       .show   = sr_resx_show,
+};
+
+DEFINE_SEQ_ATTRIBUTE(sr_resx);
+
 void kvm_sys_regs_create_debugfs(struct kvm *kvm)
 {
        kvm->arch.idreg_debugfs_iter = ~0;
 
        debugfs_create_file("idregs", 0444, kvm->debugfs_dentry, kvm,
                            &idregs_debug_fops);
+       debugfs_create_file("resx", 0444, kvm->debugfs_dentry, kvm,
+                           &sr_resx_fops);
 }
 
 static void reset_vm_ftr_id_reg(struct kvm_vcpu *vcpu, const struct sys_reg_desc *reg)