Skip to content

Commit edba407

Browse files
author
Marc Zyngier
committed
KVM: arm64: Add debugfs file dumping computed RESx values
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>
1 parent e8ef279 commit edba407

File tree

1 file changed

+68
-0
lines changed

1 file changed

+68
-0
lines changed

arch/arm64/kvm/sys_regs.c

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5090,12 +5090,80 @@ static const struct seq_operations idregs_debug_sops = {
50905090

50915091
DEFINE_SEQ_ATTRIBUTE(idregs_debug);
50925092

5093+
static const struct sys_reg_desc *sr_resx_find(struct kvm *kvm, loff_t pos)
5094+
{
5095+
unsigned long i, sr_idx = 0;
5096+
5097+
for (i = 0; i < ARRAY_SIZE(sys_reg_descs); i++) {
5098+
const struct sys_reg_desc *r = &sys_reg_descs[i];
5099+
5100+
if (r->reg < __SANITISED_REG_START__)
5101+
continue;
5102+
5103+
if (sr_idx++ == pos)
5104+
return r;
5105+
}
5106+
5107+
return NULL;
5108+
}
5109+
5110+
static void *sr_resx_start(struct seq_file *s, loff_t *pos)
5111+
{
5112+
struct kvm *kvm = s->private;
5113+
5114+
if (!kvm->arch.sysreg_masks)
5115+
return NULL;
5116+
5117+
return (void *)sr_resx_find(kvm, *pos);
5118+
}
5119+
5120+
static void *sr_resx_next(struct seq_file *s, void *v, loff_t *pos)
5121+
{
5122+
struct kvm *kvm = s->private;
5123+
5124+
(*pos)++;
5125+
5126+
return (void *)sr_resx_find(kvm, *pos);
5127+
}
5128+
5129+
static void sr_resx_stop(struct seq_file *s, void *v)
5130+
{
5131+
}
5132+
5133+
static int sr_resx_show(struct seq_file *s, void *v)
5134+
{
5135+
const struct sys_reg_desc *desc = v;
5136+
struct kvm *kvm = s->private;
5137+
struct resx resx;
5138+
5139+
if (!desc)
5140+
return 0;
5141+
5142+
resx = kvm_get_sysreg_resx(kvm, desc->reg);
5143+
5144+
seq_printf(s, "%20s:\tRES0:%016llx\tRES1:%016llx\n",
5145+
desc->name, resx.res0, resx.res1);
5146+
5147+
return 0;
5148+
}
5149+
5150+
static const struct seq_operations sr_resx_sops = {
5151+
.start = sr_resx_start,
5152+
.next = sr_resx_next,
5153+
.stop = sr_resx_stop,
5154+
.show = sr_resx_show,
5155+
};
5156+
5157+
DEFINE_SEQ_ATTRIBUTE(sr_resx);
5158+
50935159
void kvm_sys_regs_create_debugfs(struct kvm *kvm)
50945160
{
50955161
kvm->arch.idreg_debugfs_iter = ~0;
50965162

50975163
debugfs_create_file("idregs", 0444, kvm->debugfs_dentry, kvm,
50985164
&idregs_debug_fops);
5165+
debugfs_create_file("resx", 0444, kvm->debugfs_dentry, kvm,
5166+
&sr_resx_fops);
50995167
}
51005168

51015169
static void reset_vm_ftr_id_reg(struct kvm_vcpu *vcpu, const struct sys_reg_desc *reg)

0 commit comments

Comments
 (0)