return false;
}
-static const struct sys_reg_desc *idregs_debug_find(struct kvm *kvm, u8 pos)
+static const struct sys_reg_desc *idregs_debug_find(struct kvm *kvm, loff_t pos)
{
unsigned long i, idreg_idx = 0;
if (!is_vm_ftr_id_reg(reg_to_encoding(r)))
continue;
- if (idreg_idx == pos)
+ if (idreg_idx++ == pos)
return r;
-
- idreg_idx++;
}
return NULL;
static void *idregs_debug_start(struct seq_file *s, loff_t *pos)
{
struct kvm *kvm = s->private;
- u8 *iter;
-
- mutex_lock(&kvm->arch.config_lock);
-
- iter = &kvm->arch.idreg_debugfs_iter;
- if (test_bit(KVM_ARCH_FLAG_ID_REGS_INITIALIZED, &kvm->arch.flags) &&
- *iter == (u8)~0) {
- *iter = *pos;
- if (!idregs_debug_find(kvm, *iter))
- iter = NULL;
- } else {
- iter = ERR_PTR(-EBUSY);
- }
- mutex_unlock(&kvm->arch.config_lock);
+ if (!test_bit(KVM_ARCH_FLAG_ID_REGS_INITIALIZED, &kvm->arch.flags))
+ return NULL;
- return iter;
+ return (void *)idregs_debug_find(kvm, *pos);
}
static void *idregs_debug_next(struct seq_file *s, void *v, loff_t *pos)
(*pos)++;
- if (idregs_debug_find(kvm, kvm->arch.idreg_debugfs_iter + 1)) {
- kvm->arch.idreg_debugfs_iter++;
-
- return &kvm->arch.idreg_debugfs_iter;
- }
-
- return NULL;
+ return (void *)idregs_debug_find(kvm, *pos);
}
static void idregs_debug_stop(struct seq_file *s, void *v)
{
- struct kvm *kvm = s->private;
-
- if (IS_ERR(v))
- return;
-
- mutex_lock(&kvm->arch.config_lock);
-
- kvm->arch.idreg_debugfs_iter = ~0;
-
- mutex_unlock(&kvm->arch.config_lock);
}
static int idregs_debug_show(struct seq_file *s, void *v)
{
- const struct sys_reg_desc *desc;
+ const struct sys_reg_desc *desc = v;
struct kvm *kvm = s->private;
- desc = idregs_debug_find(kvm, kvm->arch.idreg_debugfs_iter);
-
- if (!desc->name)
+ if (!desc)
return 0;
seq_printf(s, "%20s:\t%016llx\n",
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);
}