From patchwork Thu Dec 12 19:55:44 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 22306 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qe0-f70.google.com (mail-qe0-f70.google.com [209.85.128.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 9A39523FC9 for ; Thu, 12 Dec 2013 19:54:22 +0000 (UTC) Received: by mail-qe0-f70.google.com with SMTP id 6sf1789483qea.9 for ; Thu, 12 Dec 2013 11:54: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=vOiMO4B3AnR1dWIDyfuM10GeKQPPYP1qLsxz3OyIexE=; b=kHO9rESoc3bkVkwEJRub8+h+5JqVB3fleiBvOkof0tkDvipt9p0M2a7iGXU4U/ptiZ ZYqUr2SBlBfWjU++El6kJ7MrwQpc8rcZkG3vdZBsLR/qr3dPq25Dotv8COJq1WPWz+zO tNcKbTQK7xwk9JlFJOZ6yiaKo7n5pk9iihT1p94PCgiyxYI9Gz4Lth4n033khWQe+AWa YjndmbbaDHIEeR4CZS2hxZnb+6gTJF1BM/Yt5TQkAhQyATbnGUaRrqBPFBBBW18GNxPJ 8htUz1co/01wD5xoI7sdEuSSQ7bqA/jQUAa+dWXchXe7NrA3gg3h5NoxAuv115vPjbgR SbPg== X-Gm-Message-State: ALoCoQnLpQGTATPfs3Yf6JYHaC/ob5oe+GJGvTJ/V7MzBrKCOL3eWOtF4GyEXFV53eI0l4udF8Kf X-Received: by 10.236.8.6 with SMTP id 6mr3142611yhq.45.1386878062205; Thu, 12 Dec 2013 11:54:22 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.59.49 with SMTP id w17ls735045qeq.68.gmail; Thu, 12 Dec 2013 11:54:22 -0800 (PST) X-Received: by 10.58.156.106 with SMTP id wd10mr4602763veb.7.1386878062107; Thu, 12 Dec 2013 11:54:22 -0800 (PST) Received: from mail-ve0-f170.google.com (mail-ve0-f170.google.com [209.85.128.170]) by mx.google.com with ESMTPS id w7si8031569vcr.92.2013.12.12.11.54.22 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 12 Dec 2013 11:54:22 -0800 (PST) Received-SPF: neutral (google.com: 209.85.128.170 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.170; Received: by mail-ve0-f170.google.com with SMTP id oy12so688733veb.15 for ; Thu, 12 Dec 2013 11:54:22 -0800 (PST) X-Received: by 10.58.46.18 with SMTP id r18mr4716776vem.4.1386878062025; Thu, 12 Dec 2013 11:54: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 u4csp381988vcz; Thu, 12 Dec 2013 11:54:21 -0800 (PST) X-Received: by 10.68.220.72 with SMTP id pu8mr14979355pbc.83.1386878061148; Thu, 12 Dec 2013 11:54:21 -0800 (PST) Received: from mail-pb0-f44.google.com (mail-pb0-f44.google.com [209.85.160.44]) by mx.google.com with ESMTPS id yd9si17309084pab.263.2013.12.12.11.54.20 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 12 Dec 2013 11:54:21 -0800 (PST) Received-SPF: neutral (google.com: 209.85.160.44 is neither permitted nor denied by best guess record for domain of christoffer.dall@linaro.org) client-ip=209.85.160.44; Received: by mail-pb0-f44.google.com with SMTP id rq2so1103927pbb.31 for ; Thu, 12 Dec 2013 11:54:20 -0800 (PST) X-Received: by 10.68.194.71 with SMTP id hu7mr15234797pbc.68.1386878060765; Thu, 12 Dec 2013 11:54:20 -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 ql10sm4014884pbc.44.2013.12.12.11.54.18 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 12 Dec 2013 11:54:19 -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 05/10] KVM: arm-vgic: Make vgic mmio functions more generic Date: Thu, 12 Dec 2013 11:55:44 -0800 Message-Id: <1386878149-13397-6-git-send-email-christoffer.dall@linaro.org> X-Mailer: git-send-email 1.8.4.3 In-Reply-To: <1386878149-13397-1-git-send-email-christoffer.dall@linaro.org> References: <1386878149-13397-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.128.170 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);