From patchwork Wed Feb 12 05:41:32 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Victor Kamensky X-Patchwork-Id: 3634281 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 0EA469F334 for ; Wed, 12 Feb 2014 05:45:43 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0BB392015D for ; Wed, 12 Feb 2014 05:45:42 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (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 180EA20170 for ; Wed, 12 Feb 2014 05:45:41 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WDSbr-0002o7-VN; Wed, 12 Feb 2014 05:43:48 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WDSbR-0006KE-KW; Wed, 12 Feb 2014 05:43:21 +0000 Received: from mail-pa0-f48.google.com ([209.85.220.48]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WDSam-0006Cv-2Q for linux-arm-kernel@lists.infradead.org; Wed, 12 Feb 2014 05:42:43 +0000 Received: by mail-pa0-f48.google.com with SMTP id kx10so8733307pab.35 for ; Tue, 11 Feb 2014 21:42:18 -0800 (PST) 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=guKE+lWKJdxNLXbqNltF/PQCpX8EO9BbFGkhV4OjYuA=; b=XUpmCg9D9u+ucLzfuwa1p3AJgiCYqi6Y15D4Jes+JmIM56Ev3ZC02ZrJBaoJHP0NHF ipV8Ezid+FNTezs1QFOCRt630bnPN4jxf32cMdI1ZxDS7pYySC5K8+VduFF4bBWwmLoa c5sMLaTexiPDiXzoEoevSYQD9UCFOkRGyGsXCC52yjhDu7+luDadeA44n4uMEUhY18fm dTLErzNc80DHcsI80uJ3a5OrcU3/+Q/ay0KE9GR7lS7bV7LuiqAX4gGzCNy7QTrIeyGH B1J6iExlqoGz4P+GOPacVAiph0CpAav352AiO9l6leaj2vvY2AW1kNlddkjb7mZrtIBu cklw== X-Gm-Message-State: ALoCoQlgEGvslQkt7HTYeiCTEcO/HTZeCNNxiDUJ4uA4w38bVNYiB9EDydStpdCM0JFPsmmQHmVo X-Received: by 10.68.200.74 with SMTP id jq10mr1558764pbc.169.1392183738417; Tue, 11 Feb 2014 21:42:18 -0800 (PST) Received: from kamensky-w530.cisco.com (128-107-239-233.cisco.com. [128.107.239.233]) by mx.google.com with ESMTPSA id eo11sm152396678pac.0.2014.02.11.21.42.15 for (version=TLSv1.2 cipher=AES128-GCM-SHA256 bits=128/128); Tue, 11 Feb 2014 21:42:17 -0800 (PST) From: Victor Kamensky To: kvmarm@lists.cs.columbia.edu, christoffer.dall@linaro.org, marc.zyngier@arm.com, linux-arm-kernel@lists.infradead.org Subject: [PATCH v2 6/7] ARM: KVM: vgic mmio should hold data as LE bytes array in BE case Date: Tue, 11 Feb 2014 21:41:32 -0800 Message-Id: <1392183693-21238-7-git-send-email-victor.kamensky@linaro.org> X-Mailer: git-send-email 1.8.1.4 In-Reply-To: <1392183693-21238-1-git-send-email-victor.kamensky@linaro.org> References: <1392183693-21238-1-git-send-email-victor.kamensky@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140212_004240_264977_95D1698B X-CRM114-Status: GOOD ( 11.63 ) X-Spam-Score: 0.4 (/) Cc: linaro-kernel@lists.linaro.org, Victor Kamensky , taras.kondratiuk@linaro.org, will.deacon@arm.com, andre.przywara@linaro.org, ben.dooks@codethink.co.uk, Dave.Martin@arm.com, rmk@arm.linux.org.uk 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=-1.8 required=5.0 tests=BAYES_00,KHOP_BIG_TO_CC, RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,UNPARSEABLE_RELAY autolearn=ham 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 --- 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 685fc72..7e11458 100644 --- a/virt/kvm/arm/vgic.c +++ b/virt/kvm/arm/vgic.c @@ -236,12 +236,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; } /**