From patchwork Tue Jun 11 04:51:16 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 17779 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ve0-f197.google.com (mail-ve0-f197.google.com [209.85.128.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 112852397B for ; Tue, 11 Jun 2013 04:51:59 +0000 (UTC) Received: by mail-ve0-f197.google.com with SMTP id d10sf8030034vea.0 for ; Mon, 10 Jun 2013 21:51:58 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-beenthere:x-forwarded-to:x-forwarded-for :delivered-to:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references:x-gm-message-state:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-google-group-id:list-post:list-help:list-archive:list-unsubscribe; bh=YsYOmkveH/PRWPVt0/Z6HgpzfYyKEyBniJdTzp9obn8=; b=C1lUSVIIxKjTZvZ8OAhRe5WFPtm2tUeke16Xlfeuty/lFa33xygFaU/hNhxWiqagvx fk/7Toad16/tPBOPKFP/5snfn4QuyEJMMn3sh4aQ1IsORB7z/fmI8HXecBUv5LtmqOOy soIoL+qQvcCIf39zjgZhjN2yUz15QL0ZISDcMtoERUDcabiq5knluExote0tK61fLmSM gCPy0RhWQoG+SI7rR0Cux+BF6nH+/6tYQWeGcbrDOQhNmmbho3vzpTMjR93LjELQ3PBW 9HZNuzUG9btwGICrCFl00i+i8pRdvTh+2+2LmYuzP4sbNVB43ahDssApv4b8J3k2fTjL 4Hog== X-Received: by 10.236.170.74 with SMTP id o50mr7651291yhl.8.1370926318806; Mon, 10 Jun 2013 21:51:58 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.5.8 with SMTP id o8ls3025282qeo.24.gmail; Mon, 10 Jun 2013 21:51:58 -0700 (PDT) X-Received: by 10.52.156.65 with SMTP id wc1mr6405090vdb.10.1370926318581; Mon, 10 Jun 2013 21:51:58 -0700 (PDT) Received: from mail-vc0-f172.google.com (mail-vc0-f172.google.com [209.85.220.172]) by mx.google.com with ESMTPS id r12si6359949vcv.58.2013.06.10.21.51.58 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 10 Jun 2013 21:51:58 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.172 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.172; Received: by mail-vc0-f172.google.com with SMTP id ib11so5131596vcb.3 for ; Mon, 10 Jun 2013 21:51:58 -0700 (PDT) X-Received: by 10.58.173.36 with SMTP id bh4mr7488117vec.9.1370926318456; Mon, 10 Jun 2013 21:51:58 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.221.10.206 with SMTP id pb14csp94467vcb; Mon, 10 Jun 2013 21:51:57 -0700 (PDT) X-Received: by 10.68.233.98 with SMTP id tv2mr12677972pbc.146.1370926317227; Mon, 10 Jun 2013 21:51:57 -0700 (PDT) Received: from mail-pd0-f170.google.com (mail-pd0-f170.google.com [209.85.192.170]) by mx.google.com with ESMTPS id x3si8287208paa.227.2013.06.10.21.51.56 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 10 Jun 2013 21:51:57 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.192.170 is neither permitted nor denied by best guess record for domain of christoffer.dall@linaro.org) client-ip=209.85.192.170; Received: by mail-pd0-f170.google.com with SMTP id x11so2438121pdj.15 for ; Mon, 10 Jun 2013 21:51:56 -0700 (PDT) X-Received: by 10.66.5.168 with SMTP id t8mr16809416pat.196.1370926316726; Mon, 10 Jun 2013 21:51:56 -0700 (PDT) Received: from localhost.localdomain (c-67-169-183-77.hsd1.ca.comcast.net. [67.169.183.77]) by mx.google.com with ESMTPSA id i16sm18268008pag.18.2013.06.10.21.51.55 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 10 Jun 2013 21:51:56 -0700 (PDT) From: Christoffer Dall To: linux-arm-kernel@lists.infradead.org, kvm@vger.kernel.org, kvmarm@lists.cs.columbia.edu Cc: patches@linaro.org, linaro-kernel@lists.linaro.org, Christoffer Dall Subject: [PATCH 4/7] KVM: arm-vgic: Make vgic mmio functions more generic Date: Mon, 10 Jun 2013 21:51:16 -0700 Message-Id: <1370926279-32532-5-git-send-email-christoffer.dall@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1370926279-32532-1-git-send-email-christoffer.dall@linaro.org> References: <1370926279-32532-1-git-send-email-christoffer.dall@linaro.org> X-Gm-Message-State: ALoCoQmxAUfDVc13JacpTZxNM/8V/o2bZa0o+idJhoQigZDa1jL64kl1wXbMFZDSCaaGIWEgEwlK X-Original-Sender: christoffer.dall@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.172 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Rename the vgic_ranges array to vgic_dist_ranges to be more specific and to prepare for handling CPU interface register access as well (for save/restore of VGIC state). Pass offset from distributor or interface MMIO base to find_matching_range function instead of the physical address of the access in the VM memory map. This allows other callers unaware of the VM specifics, but with generic VGIC knowledge to reuse the function. Signed-off-by: Christoffer Dall --- virt/kvm/arm/vgic.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/virt/kvm/arm/vgic.c b/virt/kvm/arm/vgic.c index 8e915b7..bfb9985 100644 --- a/virt/kvm/arm/vgic.c +++ b/virt/kvm/arm/vgic.c @@ -604,7 +604,7 @@ struct mmio_range { phys_addr_t offset); }; -static const struct mmio_range vgic_ranges[] = { +static const struct mmio_range vgic_dist_ranges[] = { { .base = GIC_DIST_CTRL, .len = 12, @@ -671,14 +671,13 @@ static const struct mmio_range vgic_ranges[] = { static const struct mmio_range *find_matching_range(const struct mmio_range *ranges, struct kvm_exit_mmio *mmio, - phys_addr_t base) + phys_addr_t offset) { const struct mmio_range *r = ranges; - phys_addr_t addr = mmio->phys_addr - base; while (r->len) { - if (addr >= r->base && - (addr + mmio->len) <= (r->base + r->len)) + if (offset >= r->base && + (offset + mmio->len) <= (r->base + r->len)) return r; r++; } @@ -715,7 +714,8 @@ bool vgic_handle_mmio(struct kvm_vcpu *vcpu, struct kvm_run *run, return true; } - range = find_matching_range(vgic_ranges, mmio, base); + offset = mmio->phys_addr - base; + range = find_matching_range(vgic_dist_ranges, mmio, offset); if (unlikely(!range || !range->handle_mmio)) { pr_warn("Unhandled access %d %08llx %d\n", mmio->is_write, mmio->phys_addr, mmio->len);