Commit 8d17dd04 authored by David Daney's avatar David Daney Committed by Gleb Natapov

mips/kvm: Use ARRAY_SIZE() instead of hardcoded constants in kvm_arch_vcpu_ioctl_{s,g}et_regs

Also we cannot set special zero register, so force it to zero.
Signed-off-by: default avatarDavid Daney <david.daney@cavium.com>
Acked-by: default avatarSanjay Lal <sanjayl@kymasys.com>
Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
parent bf32ebf6
...@@ -677,9 +677,9 @@ int kvm_arch_vcpu_ioctl_set_regs(struct kvm_vcpu *vcpu, struct kvm_regs *regs) ...@@ -677,9 +677,9 @@ int kvm_arch_vcpu_ioctl_set_regs(struct kvm_vcpu *vcpu, struct kvm_regs *regs)
{ {
int i; 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[i] = regs->gpr[i];
vcpu->arch.gprs[0] = 0; /* zero is special, and cannot be set. */
vcpu->arch.hi = regs->hi; vcpu->arch.hi = regs->hi;
vcpu->arch.lo = regs->lo; vcpu->arch.lo = regs->lo;
vcpu->arch.pc = regs->pc; vcpu->arch.pc = regs->pc;
...@@ -691,7 +691,7 @@ int kvm_arch_vcpu_ioctl_get_regs(struct kvm_vcpu *vcpu, struct kvm_regs *regs) ...@@ -691,7 +691,7 @@ int kvm_arch_vcpu_ioctl_get_regs(struct kvm_vcpu *vcpu, struct kvm_regs *regs)
{ {
int i; 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->gpr[i] = vcpu->arch.gprs[i];
regs->hi = vcpu->arch.hi; regs->hi = vcpu->arch.hi;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment