linux-mips
[Top] [All Lists]

[PATCH v5 4/6] mips/kvm: Use ARRAY_SIZE() instead of hardcoded constants

To: linux-mips@linux-mips.org, ralf@linux-mips.org, kvm@vger.kernel.org, Sanjay Lal <sanjayl@kymasys.com>, Gleb Natapov <gleb@redhat.com>
Subject: [PATCH v5 4/6] mips/kvm: Use ARRAY_SIZE() instead of hardcoded constants in kvm_arch_vcpu_ioctl_{s,g}et_regs
From: David Daney <ddaney.cavm@gmail.com>
Date: Wed, 22 May 2013 11:43:54 -0700
Cc: linux-kernel@vger.kernel.org, David Daney <david.daney@cavium.com>
Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=c9BSCB1NujibP7eUFGiq2gccKrGQoppYXygvsMvfjNA=; b=OynWpIcv8wl5LtZllWP8fAdU9A9CIz+PAD/2R4vT4uI3kOCqNe+TfR9EnQ1ESzfRqI P+YBH31d+uhkP/thNEwUE72iYg6nN+duRXHyuoDL/2Ngfu0PLK/eq3T7zAr5eu2BSwdc ftxdycwC7YEjB0N9u9lzNShlySYHocdjpZ4t4Lhd4++Wix0QTXD0vyvetUOTgMOweu3T mLGuD/9/szrgOddkz3nmNjXq06E2fqjFwy0i3GeZHEbVP5VfhqBw3pOWIBgGay2KKfM6 G7pdkv6mz+dhkywNrUd+dI0C1SLefyuAuzs0uNYXqgAUBY8HjQkIVtba5LHaWf6I4zuv r4KQ==
In-reply-to: <1369248236-27237-1-git-send-email-ddaney.cavm@gmail.com>
List-archive: <http://www.linux-mips.org/archives/linux-mips/>
List-help: <mailto:ecartis@linux-mips.org?Subject=help>
List-id: linux-mips <linux-mips.eddie.linux-mips.org>
List-owner: <mailto:ralf@linux-mips.org>
List-post: <mailto:linux-mips@linux-mips.org>
List-software: Ecartis version 1.0.0
List-subscribe: <mailto:ecartis@linux-mips.org?subject=subscribe%20linux-mips>
List-unsubscribe: <mailto:ecartis@linux-mips.org?subject=unsubscribe%20linux-mips>
Original-recipient: rfc822;linux-mips@linux-mips.org
References: <1369248236-27237-1-git-send-email-ddaney.cavm@gmail.com>
Sender: linux-mips-bounce@linux-mips.org
From: David Daney <david.daney@cavium.com>

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

Signed-off-by: David Daney <david.daney@cavium.com>
---
 arch/mips/kvm/kvm_mips.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/mips/kvm/kvm_mips.c b/arch/mips/kvm/kvm_mips.c
index 93da750..71a1fc1 100644
--- a/arch/mips/kvm/kvm_mips.c
+++ b/arch/mips/kvm/kvm_mips.c
@@ -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;
@@ -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;
-- 
1.7.11.7


<Prev in Thread] Current Thread [Next in Thread>