From patchwork Thu May 23 16:49:08 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Daney X-Patchwork-Id: 2608271 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id A541A40077 for ; Thu, 23 May 2013 16:50:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759881Ab3EWQt6 (ORCPT ); Thu, 23 May 2013 12:49:58 -0400 Received: from mail-pd0-f176.google.com ([209.85.192.176]:44456 "EHLO mail-pd0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759830Ab3EWQtU (ORCPT ); Thu, 23 May 2013 12:49:20 -0400 Received: by mail-pd0-f176.google.com with SMTP id r11so3080339pdi.7 for ; Thu, 23 May 2013 09:49:20 -0700 (PDT) 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=5Hg5/wh82XV2iuYYkJCDDyjN8KNUnedAkxyJfJPluj0=; b=0HUpaEcm8rEREpH7jK5DiY55JxWirDWQ5uRprTZzOIPXPhsQDC6fmJ46TLBlxnH9oo x4xaAG0bzIgKlDp/r9CbzciSauXMedYxP64SR7KMC2BAOuniXDTaj5apUg4TPKjXZHYh 38uyNP0bM7y+8x5UnCqFdqJ2a9fQNzAHUJRP/Ekl4jeWLcjMgZhULlDMyJRuSMx/5d7S hdpB6eg8bavziXMRwQP7twRjjfYMRFGdVYxTU9vCDBp2gK3JRFxJK9jpNPhb83HnKJgw HCLQnkD7pHHtc2kPzSwjv4c7KTOVL+IhTl1vYj0wfvyENRkkzfNjLC6i7qO2XvffqK+x zCDg== X-Received: by 10.68.99.163 with SMTP id er3mr14025973pbb.36.1369327760471; Thu, 23 May 2013 09:49:20 -0700 (PDT) Received: from dl.caveonetworks.com (64.2.3.195.ptr.us.xo.net. [64.2.3.195]) by mx.google.com with ESMTPSA id aj2sm12419645pbc.1.2013.05.23.09.49.16 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 23 May 2013 09:49:17 -0700 (PDT) Received: from dl.caveonetworks.com (localhost.localdomain [127.0.0.1]) by dl.caveonetworks.com (8.14.5/8.14.5) with ESMTP id r4NGnFQV028635; Thu, 23 May 2013 09:49:15 -0700 Received: (from ddaney@localhost) by dl.caveonetworks.com (8.14.5/8.14.5/Submit) id r4NGnFYV028634; Thu, 23 May 2013 09:49:15 -0700 From: David Daney To: linux-mips@linux-mips.org, ralf@linux-mips.org, kvm@vger.kernel.org, Sanjay Lal , Gleb Natapov Cc: linux-kernel@vger.kernel.org, David Daney Subject: [PATCH v6 4/6] mips/kvm: Use ARRAY_SIZE() instead of hardcoded constants in kvm_arch_vcpu_ioctl_{s, g}et_regs Date: Thu, 23 May 2013 09:49:08 -0700 Message-Id: <1369327750-28580-5-git-send-email-ddaney.cavm@gmail.com> X-Mailer: git-send-email 1.7.11.7 In-Reply-To: <1369327750-28580-1-git-send-email-ddaney.cavm@gmail.com> References: <1369327750-28580-1-git-send-email-ddaney.cavm@gmail.com> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: David Daney Also we cannot set special zero register, so force it to zero. Signed-off-by: David Daney Acked-by: Sanjay Lal --- 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;