From patchwork Thu Jun 12 16:30:10 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: vkamensky X-Patchwork-Id: 31846 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pa0-f72.google.com (mail-pa0-f72.google.com [209.85.220.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 74D4E20AE6 for ; Thu, 12 Jun 2014 16:34:37 +0000 (UTC) Received: by mail-pa0-f72.google.com with SMTP id rd3sf2360316pab.11 for ; Thu, 12 Jun 2014 09:34:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:subject:date:message-id :in-reply-to:references:cc:precedence:list-id:list-unsubscribe :list-archive:list-post:list-help:list-subscribe:mime-version:sender :errors-to:x-original-sender:x-original-authentication-results :mailing-list:content-type:content-transfer-encoding; bh=9oTGKk+ABZ4GEpze7MJC5jfQjw8ltTrgkQ15olJ7/d8=; b=CsmSOeiRYQj5QS6FfPvpyfpViZ119OFW7GTerQ5d0BZ5qF/6dRau4ACUmmJw4jZRpC 2mIH6F9hpgXjvwgUQ8UpnDg0aLl6ic2h3atdyRP5yd08ElT1XZ5sQ4T3Q/NO7JszxKkC CXV5/lZ1OtdwWMC8aiHVNqKw5tAdWQAzS64a4GXlK7eUzNsuZf1285yp11u/Z83ykgud zZjkaax+Y+8UjE0Zn5gtZ9VcBm1SQuLIx98YEAzXL/+yDikGQiitDwtw/X9TcQydKM7S yHWHCj5RYOaHLl2O36FtxjtKsObUXEvK/O6HchFLpjk0QO4O8vYo/4sXamFw+PXi+yez c1DA== X-Gm-Message-State: ALoCoQkpt/3l/P5GSj7/+KevYmNVeli18S1cB3QfQZ8JfcpDMabY6KRcp44HkG8mgHQP9SyjmwZa X-Received: by 10.68.253.66 with SMTP id zy2mr3798799pbc.1.1402590876763; Thu, 12 Jun 2014 09:34:36 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.19.83 with SMTP id 77ls3051519qgg.28.gmail; Thu, 12 Jun 2014 09:34:36 -0700 (PDT) X-Received: by 10.220.98.143 with SMTP id q15mr1041530vcn.38.1402590876530; Thu, 12 Jun 2014 09:34:36 -0700 (PDT) Received: from mail-vc0-f177.google.com (mail-vc0-f177.google.com [209.85.220.177]) by mx.google.com with ESMTPS id v15si484874vei.0.2014.06.12.09.34.36 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 12 Jun 2014 09:34:36 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.177 as permitted sender) client-ip=209.85.220.177; Received: by mail-vc0-f177.google.com with SMTP id ij19so1067539vcb.36 for ; Thu, 12 Jun 2014 09:34:36 -0700 (PDT) X-Received: by 10.52.190.138 with SMTP id gq10mr1232556vdc.47.1402590876460; Thu, 12 Jun 2014 09:34:36 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.221.54.6 with SMTP id vs6csp417081vcb; Thu, 12 Jun 2014 09:34:36 -0700 (PDT) X-Received: by 10.224.138.9 with SMTP id y9mr4051394qat.1.1402590875972; Thu, 12 Jun 2014 09:34:35 -0700 (PDT) Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id s5si1691903qas.87.2014.06.12.09.34.35 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 12 Jun 2014 09:34:35 -0700 (PDT) Received-SPF: none (google.com: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org does not designate permitted sender hosts) client-ip=2001:1868:205::9; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1Wv7vy-0000VQ-8v; Thu, 12 Jun 2014 16:33:02 +0000 Received: from mail-pd0-f182.google.com ([209.85.192.182]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Wv7u8-0007sq-9o for linux-arm-kernel@lists.infradead.org; Thu, 12 Jun 2014 16:31:09 +0000 Received: by mail-pd0-f182.google.com with SMTP id y13so1121052pdi.41 for ; Thu, 12 Jun 2014 09:30:48 -0700 (PDT) X-Received: by 10.68.103.66 with SMTP id fu2mr13778302pbb.133.1402590648837; Thu, 12 Jun 2014 09:30:48 -0700 (PDT) Received: from kamensky-w530.cisco.com (128-107-239-235.cisco.com. [128.107.239.235]) by mx.google.com with ESMTPSA id nh8sm81278030pbc.25.2014.06.12.09.30.47 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 12 Jun 2014 09:30:48 -0700 (PDT) From: Victor Kamensky To: kvmarm@lists.cs.columbia.edu, christoffer.dall@linaro.org, marc.zyngier@arm.com, agraf@suse.de Subject: [PATCH v4 11/14] ARM64: KVM: fix vgic_bitmap_get_reg function for BE 64bit case Date: Thu, 12 Jun 2014 09:30:10 -0700 Message-Id: <1402590613-3341-12-git-send-email-victor.kamensky@linaro.org> X-Mailer: git-send-email 1.8.1.4 In-Reply-To: <1402590613-3341-1-git-send-email-victor.kamensky@linaro.org> References: <1402590613-3341-1-git-send-email-victor.kamensky@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140612_093108_415190_AF646BFE X-CRM114-Status: GOOD ( 11.90 ) X-Spam-Score: -0.0 (/) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [209.85.192.182 listed in wl.mailspike.net] -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [209.85.192.182 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record Cc: taras.kondratiuk@linaro.org, linaro-kernel@lists.linaro.org, linux-arm-kernel@lists.infradead.org, Victor Kamensky X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: victor.kamensky@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.177 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 Fix vgic_bitmap_get_reg function to return 'right' word address of 'unsigned long' bitmap value in case of BE 64bit image. Signed-off-by: Victor Kamensky Reviewed-by: Christoffer Dall --- virt/kvm/arm/vgic.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/virt/kvm/arm/vgic.c b/virt/kvm/arm/vgic.c index 529c336..b4ffd82 100644 --- a/virt/kvm/arm/vgic.c +++ b/virt/kvm/arm/vgic.c @@ -101,14 +101,34 @@ static u32 vgic_nr_lr; static unsigned int vgic_maint_irq; +/* + * struct vgic_bitmap contains unions that provide two views of + * the same data. In one case it is an array of registers of + * u32's, and in the other case it is a bitmap of unsigned + * longs. + * + * This does not work on 64-bit BE systems, because the bitmap access + * will store two consecutive 32-bit words with the higher-addressed + * register's bits at the lower index and the lower-addressed register's + * bits at the higher index. + * + * Therefore, swizzle the register index when accessing the 32-bit word + * registers to access the right register's value. + */ +#if defined(CONFIG_CPU_BIG_ENDIAN) && BITS_PER_LONG == 64 +#define REG_OFFSET_SWIZZLE 1 +#else +#define REG_OFFSET_SWIZZLE 0 +#endif + static u32 *vgic_bitmap_get_reg(struct vgic_bitmap *x, int cpuid, u32 offset) { offset >>= 2; if (!offset) - return x->percpu[cpuid].reg; + return x->percpu[cpuid].reg + (offset ^ REG_OFFSET_SWIZZLE); else - return x->shared.reg + offset - 1; + return x->shared.reg + ((offset - 1) ^ REG_OFFSET_SWIZZLE); } static int vgic_bitmap_get_irq_val(struct vgic_bitmap *x,