From patchwork Fri Aug 23 19:20:03 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 19504 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qc0-f198.google.com (mail-qc0-f198.google.com [209.85.216.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 7C75D248E6 for ; Fri, 23 Aug 2013 19:20:47 +0000 (UTC) Received: by mail-qc0-f198.google.com with SMTP id a11sf833045qcx.1 for ; Fri, 23 Aug 2013 12:20:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-gm-message-state:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=n2P9W93t4lU4kVuU9/m0TXN8Ks4ecdDtP6m0SR29ot8=; b=SJ0BraKQHeX4ibf4nke76jH3u/gto3IxQkGr27hLSWm+EZL8QRUII0XAMUvGm3wjW3 XoD5gbaXAEiyZ3pahxbKiUICA8DusCdUUJROhEJx1Z8YTnRROiidHDu+CYIO4dwYqecl 5cWbfFCrNv8O5wW/x+Vh21eEcWlZBCUDh62l0J5zPjT/2si4cGib+posZf/IaXwirX5G DVwzw4BbAqIOnaNwv/qovdljMK/dKjcrSn+XR3ktN821oIC54iXzHYzmu+gnzYlvM8+T LJVXUcjV1o1OIMXLbC3bKcc6Y4ub+hlnkT0BBYHtAdJmqjaHC5TFgXyW/YHfzWzdgj36 57DQ== X-Received: by 10.236.132.163 with SMTP id o23mr410913yhi.31.1377285647261; Fri, 23 Aug 2013 12:20:47 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.97.66 with SMTP id dy2ls1674931qeb.85.gmail; Fri, 23 Aug 2013 12:20:47 -0700 (PDT) X-Received: by 10.58.211.227 with SMTP id nf3mr806995vec.20.1377285647157; Fri, 23 Aug 2013 12:20:47 -0700 (PDT) Received: from mail-vb0-f47.google.com (mail-vb0-f47.google.com [209.85.212.47]) by mx.google.com with ESMTPS id 3si396014vco.85.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 23 Aug 2013 12:20:47 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.212.47 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.212.47; Received: by mail-vb0-f47.google.com with SMTP id h10so688954vbh.20 for ; Fri, 23 Aug 2013 12:20:47 -0700 (PDT) X-Gm-Message-State: ALoCoQndKJ0c0nRI/OYZpNFn0926JgPNQTsJdg7RkltKoX+ZrST5wcMyNU95YKu4f4tGCGmNONpt X-Received: by 10.58.215.15 with SMTP id oe15mr800994vec.25.1377285647062; Fri, 23 Aug 2013 12:20:47 -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.220.174.196 with SMTP id u4csp111073vcz; Fri, 23 Aug 2013 12:20:46 -0700 (PDT) X-Received: by 10.68.217.129 with SMTP id oy1mr1413803pbc.23.1377285645808; Fri, 23 Aug 2013 12:20:45 -0700 (PDT) Received: from mail-pa0-f50.google.com (mail-pa0-f50.google.com [209.85.220.50]) by mx.google.com with ESMTPS id rt3si664162pbc.203.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 23 Aug 2013 12:20:45 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.50 is neither permitted nor denied by best guess record for domain of christoffer.dall@linaro.org) client-ip=209.85.220.50; Received: by mail-pa0-f50.google.com with SMTP id fb10so1045618pad.9 for ; Fri, 23 Aug 2013 12:20:45 -0700 (PDT) X-Received: by 10.67.4.136 with SMTP id ce8mr476234pad.158.1377285645264; Fri, 23 Aug 2013 12:20:45 -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 qf7sm2746078pac.14.1969.12.31.16.00.00 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 23 Aug 2013 12:20:44 -0700 (PDT) From: Christoffer Dall To: kvmarm@lists.cs.columbia.edu Cc: linaro-kernel@lists.linaro.org, patches@linaro.org, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Christoffer Dall Subject: [PATCH 5/8] KVM: arm-vgic: Make vgic mmio functions more generic Date: Fri, 23 Aug 2013 12:20:03 -0700 Message-Id: <1377285606-15692-6-git-send-email-christoffer.dall@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1377285606-15692-1-git-send-email-christoffer.dall@linaro.org> References: <1377285606-15692-1-git-send-email-christoffer.dall@linaro.org> X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: christoffer.dall@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.212.47 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 a51efb8..629caeb 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);