From patchwork Sun Nov 17 04:30: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: 21552 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pb0-f70.google.com (mail-pb0-f70.google.com [209.85.160.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 8AAC023FBB for ; Sun, 17 Nov 2013 04:29:23 +0000 (UTC) Received: by mail-pb0-f70.google.com with SMTP id rp16sf10279803pbb.1 for ; Sat, 16 Nov 2013 20:29:22 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version: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=3Ago4uT6oGUau39CuMFYKXQll4WWFpPXMfH3Xfl0/js=; b=jowPWhjc3AGq12KWdo6lhd05ZhZ4e6DTMTXEpO+1TbYixpJpa/iOc4jWG1LH1dP60T yBi4M63H7fmwa2kCfZ/8oFDNJ8b9O0/8uGxfdGPMTP6kEDfWojkiaoNt4KyXOEkHvbU9 irO6iiOIFoJKETyIfN5ueljZpdBOTCz3+jdWJSZ0SST4uzaTP98sHGQvHkhHZgWadRva H/hxbJfEwwLDdV9nK0zrv1WHwkufMFb896PM589Av8EdLKw5QSqz5nwlIOSGGBdHbeDW CTMi1R3mEKlbN4UA8q1oBXWOUOTiy57FNIsOWTf1cDxD9Z2EVrAERSEOc1vNjglElEwY YIQw== X-Gm-Message-State: ALoCoQmJkw9e5GQ3/bblvVP+1rPmpDjfL8Xd81hUG1V6ltDFzGnjfCT2bOLRgoMmZpOu22Vhs6C4 X-Received: by 10.66.118.37 with SMTP id kj5mr6244889pab.17.1384662562829; Sat, 16 Nov 2013 20:29:22 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.120.5 with SMTP id ky5ls497968qeb.26.gmail; Sat, 16 Nov 2013 20:29:22 -0800 (PST) X-Received: by 10.58.156.106 with SMTP id wd10mr9334665veb.7.1384662562697; Sat, 16 Nov 2013 20:29:22 -0800 (PST) Received: from mail-vb0-f51.google.com (mail-vb0-f51.google.com [209.85.212.51]) by mx.google.com with ESMTPS id hr2si5070015vdb.37.2013.11.16.20.29.22 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 16 Nov 2013 20:29:22 -0800 (PST) Received-SPF: neutral (google.com: 209.85.212.51 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.51; Received: by mail-vb0-f51.google.com with SMTP id w5so3799293vbf.38 for ; Sat, 16 Nov 2013 20:29:22 -0800 (PST) X-Received: by 10.52.243.138 with SMTP id wy10mr7835652vdc.2.1384662562597; Sat, 16 Nov 2013 20:29:22 -0800 (PST) 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 u4csp126854vcz; Sat, 16 Nov 2013 20:29:22 -0800 (PST) X-Received: by 10.66.164.136 with SMTP id yq8mr14397653pab.67.1384662561646; Sat, 16 Nov 2013 20:29:21 -0800 (PST) Received: from mail-pb0-f42.google.com (mail-pb0-f42.google.com [209.85.160.42]) by mx.google.com with ESMTPS id dj6si6212472pad.235.2013.11.16.20.29.21 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 16 Nov 2013 20:29:21 -0800 (PST) Received-SPF: neutral (google.com: 209.85.160.42 is neither permitted nor denied by best guess record for domain of christoffer.dall@linaro.org) client-ip=209.85.160.42; Received: by mail-pb0-f42.google.com with SMTP id uo5so5320740pbc.15 for ; Sat, 16 Nov 2013 20:29:21 -0800 (PST) X-Received: by 10.66.178.143 with SMTP id cy15mr14692129pac.105.1384662561246; Sat, 16 Nov 2013 20:29:21 -0800 (PST) Received: from localhost.localdomain (c-67-169-181-221.hsd1.ca.comcast.net. [67.169.181.221]) by mx.google.com with ESMTPSA id ho3sm14498530pbb.23.2013.11.16.20.29.19 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 16 Nov 2013 20:29:20 -0800 (PST) From: Christoffer Dall To: kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: patches@linaro.org, Christoffer Dall Subject: [PATCH v3 5/9] KVM: arm-vgic: Make vgic mmio functions more generic Date: Sat, 16 Nov 2013 20:30:16 -0800 Message-Id: <1384662620-13795-6-git-send-email-christoffer.dall@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1384662620-13795-1-git-send-email-christoffer.dall@linaro.org> References: <1384662620-13795-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.51 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 Acked-by: Marc Zyngier --- 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 edca754..9b9fa20 100644 --- a/virt/kvm/arm/vgic.c +++ b/virt/kvm/arm/vgic.c @@ -602,7 +602,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, @@ -669,14 +669,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++; } @@ -713,7 +712,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);