Skip to content

Commit

Permalink
mips/kvm: Use ARRAY_SIZE() instead of hardcoded constants in kvm_arch…
Browse files Browse the repository at this point in the history
…_vcpu_ioctl_{s,g}et_regs

Also we cannot set special zero register, so force it to zero.

Signed-off-by: David Daney <david.daney@cavium.com>
Acked-by: Sanjay Lal <sanjayl@kymasys.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
  • Loading branch information
David Daney authored and Gleb Natapov committed Jun 3, 2013
1 parent bf32ebf commit 8d17dd0
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions arch/mips/kvm/kvm_mips.c
Original file line number Diff line number Diff line change
Expand Up @@ -677,9 +677,9 @@ int kvm_arch_vcpu_ioctl_set_regs(struct kvm_vcpu *vcpu, struct kvm_regs *regs)
{
int i;

for (i = 0; i < 32; i++)
for (i = 1; i < ARRAY_SIZE(vcpu->arch.gprs); i++)
vcpu->arch.gprs[i] = regs->gpr[i];

vcpu->arch.gprs[0] = 0; /* zero is special, and cannot be set. */
vcpu->arch.hi = regs->hi;
vcpu->arch.lo = regs->lo;
vcpu->arch.pc = regs->pc;
Expand All @@ -691,7 +691,7 @@ int kvm_arch_vcpu_ioctl_get_regs(struct kvm_vcpu *vcpu, struct kvm_regs *regs)
{
int i;

for (i = 0; i < 32; i++)
for (i = 0; i < ARRAY_SIZE(vcpu->arch.gprs); i++)
regs->gpr[i] = vcpu->arch.gprs[i];

regs->hi = vcpu->arch.hi;
Expand Down

0 comments on commit 8d17dd0

Please sign in to comment.