From patchwork Tue May 13 16:14:03 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Victor Kamensky X-Patchwork-Id: 4169551 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id F29C0BFF02 for ; Tue, 13 May 2014 16:20:11 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2C95820221 for ; Tue, 13 May 2014 16:20:11 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 36E302020A for ; Tue, 13 May 2014 16:20:10 +0000 (UTC) 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 1WkFOG-0003uD-ON; Tue, 13 May 2014 16:17:16 +0000 Received: from mail-pa0-f54.google.com ([209.85.220.54]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WkFMY-0002a1-8v for linux-arm-kernel@lists.infradead.org; Tue, 13 May 2014 16:15:31 +0000 Received: by mail-pa0-f54.google.com with SMTP id bj1so450764pad.41 for ; Tue, 13 May 2014 09:15:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=45hyzfoLfW4vbETEMT09z3MW9PhZrgKgVb+VDXgFG6w=; b=eC4SHhb4RWySSIiv1bV4eObdHqVdgnuZCd0AMnb/6QNOzPE9xa91FIO88spOjD9dHS KzFLgO53vycenJQVvbxe99SoE2aUvQN7cWnMTpxulz7L0WrXzrktPBL6r42NIxV5DNdF WMtmGORIN5vEAXvGmcQldsLOYh85PYCZiYwSHahW2yFIFSbokjg12WaBOrKozLQKPLNX KHyrOkV4x8yj1zCF+CgrjOXVLTqM8I1ZbCfjjPO1N8yEYfaVPl4mpdqYU3zXr4YBockH XBNIvvB7O5r83dasnmH7Kk9Wzf0sA4QOxPMUePGd64SU83uRIs7ij76bKxo7GCBkjIpr Eqeg== X-Gm-Message-State: ALoCoQkWvBF7k7WesBSVykrEMjDTVIhoo9EBQgGRO8HV5kzdjypjLPzFTurkBXI5Pj4QglCvLebK X-Received: by 10.66.65.204 with SMTP id z12mr65401880pas.60.1399997709311; Tue, 13 May 2014 09:15:09 -0700 (PDT) Received: from kamensky-w530.hsd1.ca.comcast.net (c-24-6-79-41.hsd1.ca.comcast.net. [24.6.79.41]) by mx.google.com with ESMTPSA id dd5sm28958360pbc.85.2014.05.13.09.15.07 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 13 May 2014 09:15:08 -0700 (PDT) From: Victor Kamensky To: kvmarm@lists.cs.columbia.edu, christoffer.dall@linaro.org, marc.zyngier@arm.com, agraf@suse.de Subject: [PATCH v3 11/14] ARM64: KVM: fix vgic_bitmap_get_reg function for BE 64bit case Date: Tue, 13 May 2014 09:14:03 -0700 Message-Id: <1399997646-4716-12-git-send-email-victor.kamensky@linaro.org> X-Mailer: git-send-email 1.8.1.4 In-Reply-To: <1399997646-4716-1-git-send-email-victor.kamensky@linaro.org> References: <1399997646-4716-1-git-send-email-victor.kamensky@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140513_091530_383236_45A2BDC0 X-CRM114-Status: GOOD ( 10.66 ) X-Spam-Score: -0.7 (/) 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.15 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+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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..d0a1a24 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 union that provides two view of + * the same data. In one case it is an array of registers of + * u32 type (.reg), and in the other case it is a bitmape, which is + * an array of 'unsgined long' (.reg_ul). It all works well in + * case of 32-bit (u32 and 'unsigned long' have the same size). + * It alos works well in 64-bit LE, but breaks on 64-bit BE. + * In this case word sized register of even index actually resides + * in least significant word of 'unsigned long' which has address + * at offset plus 4 bytes. And word sized register of odd index + * resides at most significant of 'unsigned long' which has offset + * minus 4 bytes. Define REG_OFFSET_SWIZZLE that would help to + * change offset of register in case of BE 64bit system. + */ +#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,