From patchwork Thu Sep 26 19:01:34 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 20641 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 D76F623A4E for ; Thu, 26 Sep 2013 19:02:16 +0000 (UTC) Received: by mail-ve0-f197.google.com with SMTP id jy13sf1446089veb.0 for ; Thu, 26 Sep 2013 12:02:16 -0700 (PDT) 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=MgfjUKjBDg6TIOE/rBr5UYbGDpTtvTHT5D6M9UEVpFM=; b=fPKMBIRIbd9Z/HwFrirG/rDCEU/rKdx3PbBkTbpHLez2PxriGMFtLr7WqM0+zGr2aS JDcmDy4+FK1Hp+/9XWFsP8CsPe+f+4N5qAqwsW/dyv+h1lvUYv+YRqnMkhjup2pSXvYM EGnB90tbBxGsgE7fukN/xUnocygRP2pQ840vjieqA3wosKYE/PQ6sYAiIFjOBi2beyOi KMNWDsxWG4jJcEaC1Wl8uaS5n6NxFoJx8YvmPxZP6K8n1fJb9PJuTGi565ioq5Karzlw jB0aLPuOV9ZO8Y68GjqwSn3AGNc9kkyDDsMKMvvAfPGDp0DuaI27absNCOvUuja4Zdlg OkBw== X-Gm-Message-State: ALoCoQmhayGDWa3xL9E5JXd+Ssoq+7mriXXa+SffsiB3TxThVuW9t2la3gBnz4fUB2DqdWr2Sak9 X-Received: by 10.236.167.138 with SMTP id i10mr596347yhl.9.1380222136468; Thu, 26 Sep 2013 12:02:16 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.37.170 with SMTP id z10ls1023179qej.32.gmail; Thu, 26 Sep 2013 12:02:16 -0700 (PDT) X-Received: by 10.52.74.100 with SMTP id s4mr1660210vdv.35.1380222136368; Thu, 26 Sep 2013 12:02:16 -0700 (PDT) Received: from mail-vb0-f53.google.com (mail-vb0-f53.google.com [209.85.212.53]) by mx.google.com with ESMTPS id gq10si763446vdc.95.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 26 Sep 2013 12:02:16 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.212.53 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.53; Received: by mail-vb0-f53.google.com with SMTP id i3so1155912vbh.40 for ; Thu, 26 Sep 2013 12:01:46 -0700 (PDT) X-Received: by 10.58.196.148 with SMTP id im20mr1988505vec.28.1380222106267; Thu, 26 Sep 2013 12:01:46 -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 u4csp383693vcz; Thu, 26 Sep 2013 12:01:45 -0700 (PDT) X-Received: by 10.68.59.38 with SMTP id w6mr2756876pbq.135.1380222105084; Thu, 26 Sep 2013 12:01:45 -0700 (PDT) Received: from mail-pa0-f52.google.com (mail-pa0-f52.google.com [209.85.220.52]) by mx.google.com with ESMTPS id k10si2140372pak.334.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 26 Sep 2013 12:01:45 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.52 is neither permitted nor denied by best guess record for domain of christoffer.dall@linaro.org) client-ip=209.85.220.52; Received: by mail-pa0-f52.google.com with SMTP id kl14so1699526pab.39 for ; Thu, 26 Sep 2013 12:01:44 -0700 (PDT) X-Received: by 10.68.171.193 with SMTP id aw1mr2826248pbc.131.1380222104652; Thu, 26 Sep 2013 12:01:44 -0700 (PDT) Received: from localhost.localdomain (c-67-169-181-221.hsd1.ca.comcast.net. [67.169.181.221]) by mx.google.com with ESMTPSA id k4sm3870767pbd.11.1969.12.31.16.00.00 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 26 Sep 2013 12:01:43 -0700 (PDT) From: Christoffer Dall To: kvmarm@lists.cs.columbia.edu Cc: kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linaro-kernel@lists.linaro.org, patches@linaro.org, Christoffer Dall Subject: [PATCH v2 5/8] KVM: arm-vgic: Make vgic mmio functions more generic Date: Thu, 26 Sep 2013 12:01:34 -0700 Message-Id: <1380222097-20251-6-git-send-email-christoffer.dall@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1380222097-20251-1-git-send-email-christoffer.dall@linaro.org> References: <1380222097-20251-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.53 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 Reviewed-by: Alexander Graf --- 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 d9c0fc5..1148a2e 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);