From patchwork Thu Jun 12 16:30:04 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Victor Kamensky X-Patchwork-Id: 4343501 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 13726BEEAA for ; Thu, 12 Jun 2014 16:34:05 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 520A72034C for ; Thu, 12 Jun 2014 16:34:04 +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 7AF0F202FF for ; Thu, 12 Jun 2014 16:34:03 +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 1Wv7uq-0008B4-NQ; Thu, 12 Jun 2014 16:31:52 +0000 Received: from mail-pa0-f50.google.com ([209.85.220.50]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Wv7tz-0007sE-Ni for linux-arm-kernel@lists.infradead.org; Thu, 12 Jun 2014 16:31:03 +0000 Received: by mail-pa0-f50.google.com with SMTP id fb1so1188835pad.9 for ; Thu, 12 Jun 2014 09:30:38 -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=J+gUUEJtWBSKjeiZ/zpVBQGttkFdCL6OglMBDQ4TlLc=; b=M77fXHTjFxn+I1vYgYuNdI8F7ZK5HyZIM+dlNbG3EHgNj0druVxiY2T8DHvxPfjpqJ L8fMBz1KUaS7gHgPuV9GGvThFTukbyHk8b2UE1IxmQg2M3IygqBpLul37r6aqR7W3kNG PrYLoQui6s5nlDKAqyxZl9pvBi4lw80hqnl2J37DeJkXFMX8kky6VLhuxYaH5UzXv+iA DrW/w9SFNNj5LoMAxvo0Qz04DP4ZHdrw47mZD1OBrJwSRrR0t1+pH6NkrHwiIDbVpywW 7/Vk1ixgYbgjjBi1O+vb7XsWIkWjdXgH98MCq1gPwGZeeurePGCAlaKEalm/X2qsAXHS truw== X-Gm-Message-State: ALoCoQnf9+/YUCHRDMU2us9hAPEKgH0Z1eQHuwBLcehn+9jGi2qf8Sm6jx7pPU7BEM471Z7aqQh6 X-Received: by 10.68.221.42 with SMTP id qb10mr13975225pbc.65.1402590638913; Thu, 12 Jun 2014 09:30:38 -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.37 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 12 Jun 2014 09:30:38 -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 05/14] ARM: KVM: vgic mmio should hold data as LE bytes array in BE case Date: Thu, 12 Jun 2014 09:30:04 -0700 Message-Id: <1402590613-3341-6-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_093059_814063_D67E7A7A X-CRM114-Status: GOOD ( 11.65 ) 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.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+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 According to recent clarifications of mmio.data array meaning - the mmio.data array should hold bytes as they would appear in memory. Vgic is little endian device. And in case of BE image kernel side that emulates vgic, holds data in BE form. So we need to byteswap cpu<->le32 vgic registers when we read/write them from mmio.data[]. Change has no effect in LE case because cpu already runs in le32. Signed-off-by: Victor Kamensky Reviewed-by: Christoffer Dall Acked-by: Marc Zyngier --- virt/kvm/arm/vgic.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/virt/kvm/arm/vgic.c b/virt/kvm/arm/vgic.c index 56ff9be..529c336 100644 --- a/virt/kvm/arm/vgic.c +++ b/virt/kvm/arm/vgic.c @@ -241,12 +241,12 @@ static void vgic_cpu_irq_clear(struct kvm_vcpu *vcpu, int irq) static u32 mmio_data_read(struct kvm_exit_mmio *mmio, u32 mask) { - return *((u32 *)mmio->data) & mask; + return le32_to_cpu(*((u32 *)mmio->data)) & mask; } static void mmio_data_write(struct kvm_exit_mmio *mmio, u32 mask, u32 value) { - *((u32 *)mmio->data) = value & mask; + *((u32 *)mmio->data) = cpu_to_le32(value) & mask; } /**