From patchwork Tue Dec 17 05:29:56 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 22557 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-oa0-f71.google.com (mail-oa0-f71.google.com [209.85.219.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 93397202E2 for ; Tue, 17 Dec 2013 05:30:29 +0000 (UTC) Received: by mail-oa0-f71.google.com with SMTP id i4sf21606712oah.2 for ; Mon, 16 Dec 2013 21:30:29 -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=WDezFTtJiVy6AXhEidTA4aE2hA0oqTGHEsrk0ajb/0s=; b=d5nq/iQkREn9uY/gvWVabR744NfNeQcEo2iN8K3KR1ij2ByGxeEscoE+5AqafMFkZv l2vqEpGnAl0XkuS+cz03Q4fWU1j52kF6f6FUZcg+ktVdWvEPf8L6E/0s0fEKYJArXVrJ rTI3g1quK0C1QCkUu3fIJFECYGrRJqN0uxCI1gy1Lq11Ng86+eF0fSBzOJviPMbBSubq XOd/SW3qRl7p7ZpRcw99DiZ59pYq6uyy22EKCfGtRj9DDkxaE/Hv5Gnjqt6NI6kz0cT/ AdHLAcfLYkz41JA+KiQ29VEf8wKdk1pK6jeqTg7xFYn5pjdhyg1mik3tXvYm8HcwL4fW +r0A== X-Gm-Message-State: ALoCoQmFfmJ5E/OIWYAv8b9mIEP8tHDyLez5rGHVIzMry5y7x+H3k4CuTMb/jOpQgC5HggNY4K51 X-Received: by 10.43.100.129 with SMTP id cw1mr78902icc.30.1387258229164; Mon, 16 Dec 2013 21:30:29 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.71.237 with SMTP id y13ls2492145qeu.2.gmail; Mon, 16 Dec 2013 21:30:29 -0800 (PST) X-Received: by 10.52.165.131 with SMTP id yy3mr8441153vdb.25.1387258229008; Mon, 16 Dec 2013 21:30:29 -0800 (PST) Received: from mail-vc0-f173.google.com (mail-vc0-f173.google.com [209.85.220.173]) by mx.google.com with ESMTPS id s5si4571675vev.3.2013.12.16.21.30.28 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 16 Dec 2013 21:30:29 -0800 (PST) Received-SPF: neutral (google.com: 209.85.220.173 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.173; Received: by mail-vc0-f173.google.com with SMTP id ia6so3795452vcb.4 for ; Mon, 16 Dec 2013 21:30:28 -0800 (PST) X-Received: by 10.58.178.239 with SMTP id db15mr10048760vec.9.1387258228917; Mon, 16 Dec 2013 21:30:28 -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 u4csp44477vcz; Mon, 16 Dec 2013 21:30:28 -0800 (PST) X-Received: by 10.68.66.33 with SMTP id c1mr24625630pbt.73.1387258227941; Mon, 16 Dec 2013 21:30:27 -0800 (PST) Received: from mail-pa0-f51.google.com (mail-pa0-f51.google.com [209.85.220.51]) by mx.google.com with ESMTPS id e8si10769970pac.111.2013.12.16.21.30.27 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 16 Dec 2013 21:30:27 -0800 (PST) Received-SPF: neutral (google.com: 209.85.220.51 is neither permitted nor denied by best guess record for domain of christoffer.dall@linaro.org) client-ip=209.85.220.51; Received: by mail-pa0-f51.google.com with SMTP id fa1so3990407pad.10 for ; Mon, 16 Dec 2013 21:30:27 -0800 (PST) X-Received: by 10.68.189.101 with SMTP id gh5mr25162465pbc.39.1387258227501; Mon, 16 Dec 2013 21:30:27 -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 vn10sm30771688pbc.21.2013.12.16.21.30.23 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 16 Dec 2013 21:30:25 -0800 (PST) From: Christoffer Dall To: kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: linaro-kernel@lists.linaro.org, patches@linaro.org, Christoffer Dall Subject: [PATCH v5 05/10] KVM: arm-vgic: Make vgic mmio functions more generic Date: Mon, 16 Dec 2013 21:29:56 -0800 Message-Id: <1387258201-8738-6-git-send-email-christoffer.dall@linaro.org> X-Mailer: git-send-email 1.8.5 In-Reply-To: <1387258201-8738-1-git-send-email-christoffer.dall@linaro.org> References: <1387258201-8738-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.220.173 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. Acked-by: Marc Zyngier 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 45db48d..e2596f6 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);