Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

+68
+68
arch/arm64/kvm/sys_regs.c
··· 5090 5090 5091 5091 DEFINE_SEQ_ATTRIBUTE(idregs_debug); 5092 5092 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 + 5093 5159 void kvm_sys_regs_create_debugfs(struct kvm *kvm) 5094 5160 { 5095 5161 kvm->arch.idreg_debugfs_iter = ~0; 5096 5162 5097 5163 debugfs_create_file("idregs", 0444, kvm->debugfs_dentry, kvm, 5098 5164 &idregs_debug_fops); 5165 + debugfs_create_file("resx", 0444, kvm->debugfs_dentry, kvm, 5166 + &sr_resx_fops); 5099 5167 } 5100 5168 5101 5169 static void reset_vm_ftr_id_reg(struct kvm_vcpu *vcpu, const struct sys_reg_desc *reg)