Skip to content

Commit 44cbe80

Browse files
ouptonMarc Zyngier
authored andcommitted
KVM: arm64: Reset VM feature ID regs from kvm_reset_sys_regs()
A subsequent change to KVM will expand the range of feature ID registers that get special treatment at reset. Fold the existing ones back in to kvm_reset_sys_regs() to avoid the need for an additional table walk. Signed-off-by: Oliver Upton <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Marc Zyngier <[email protected]>
1 parent 592efc6 commit 44cbe80

File tree

1 file changed

+10
-17
lines changed

1 file changed

+10
-17
lines changed

arch/arm64/kvm/sys_regs.c

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3510,26 +3510,16 @@ void kvm_sys_regs_create_debugfs(struct kvm *kvm)
35103510
&idregs_debug_fops);
35113511
}
35123512

3513-
static void kvm_reset_id_regs(struct kvm_vcpu *vcpu)
3513+
static void reset_vm_ftr_id_reg(struct kvm_vcpu *vcpu, const struct sys_reg_desc *reg)
35143514
{
3515-
const struct sys_reg_desc *idreg = first_idreg;
3516-
u32 id = reg_to_encoding(idreg);
3515+
u32 id = reg_to_encoding(reg);
35173516
struct kvm *kvm = vcpu->kvm;
35183517

35193518
if (test_bit(KVM_ARCH_FLAG_ID_REGS_INITIALIZED, &kvm->arch.flags))
35203519
return;
35213520

35223521
lockdep_assert_held(&kvm->arch.config_lock);
3523-
3524-
/* Initialize all idregs */
3525-
while (is_vm_ftr_id_reg(id)) {
3526-
IDREG(kvm, id) = idreg->reset(vcpu, idreg);
3527-
3528-
idreg++;
3529-
id = reg_to_encoding(idreg);
3530-
}
3531-
3532-
set_bit(KVM_ARCH_FLAG_ID_REGS_INITIALIZED, &kvm->arch.flags);
3522+
IDREG(kvm, id) = reg->reset(vcpu, reg);
35333523
}
35343524

35353525
/**
@@ -3541,19 +3531,22 @@ static void kvm_reset_id_regs(struct kvm_vcpu *vcpu)
35413531
*/
35423532
void kvm_reset_sys_regs(struct kvm_vcpu *vcpu)
35433533
{
3534+
struct kvm *kvm = vcpu->kvm;
35443535
unsigned long i;
35453536

3546-
kvm_reset_id_regs(vcpu);
3547-
35483537
for (i = 0; i < ARRAY_SIZE(sys_reg_descs); i++) {
35493538
const struct sys_reg_desc *r = &sys_reg_descs[i];
35503539

3551-
if (is_vm_ftr_id_reg(reg_to_encoding(r)))
3540+
if (!r->reset)
35523541
continue;
35533542

3554-
if (r->reset)
3543+
if (is_vm_ftr_id_reg(reg_to_encoding(r)))
3544+
reset_vm_ftr_id_reg(vcpu, r);
3545+
else
35553546
r->reset(vcpu, r);
35563547
}
3548+
3549+
set_bit(KVM_ARCH_FLAG_ID_REGS_INITIALIZED, &kvm->arch.flags);
35573550
}
35583551

35593552
/**

0 commit comments

Comments
 (0)