From patchwork Wed Feb 12 05:41:33 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: vkamensky X-Patchwork-Id: 24512 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-oa0-f70.google.com (mail-oa0-f70.google.com [209.85.219.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 13B8A20567 for ; Wed, 12 Feb 2014 05:58:51 +0000 (UTC) Received: by mail-oa0-f70.google.com with SMTP id m1sf37280888oag.9 for ; Tue, 11 Feb 2014 21:58:51 -0800 (PST) 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=rkSkcNkiM5j5RF/O/F+JnctZVzneSIG0qrrWvIJqeV8=; b=IO7aK5VdZ/nQjN//4UpYRVPgScpYYqv8Yo5wBHFn6Ukw12fML8WCoM2DbCHhVhyZ0t VssgTtXeRRTVCOEd8siF8Ja3VpP3/1dKiXFrSRhOBsNBcRUS8VddN6I0zciv/ElKk4yy O+PHSPbID80EmkNoNNSLnsUb978rClCPJ4/1lxPdJA+J/EZkxxBz1KZydDzA2zS39ETI 5bR5EDM6D6ArMSCfPMqjroG/CRKTVNDEzTdkOhXmZUoMJ20w5ytpm2r3IowO9oNbNLiv eAmAObdvE/2lvtwOPOBNCaCis7Ih+AwYll/DRlXRThXtLnHrIlr6mP+ehbb86iI/qY8J KUMg== X-Gm-Message-State: ALoCoQnOI6XyZlSSM1k/pIO+p6ye6lyLLjzA1YZnWiKum0I+KjiBuIuZhyXDCcbXWAN0JT+CI0Sj X-Received: by 10.182.16.199 with SMTP id i7mr1062823obd.42.1392184731046; Tue, 11 Feb 2014 21:58:51 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.32.116 with SMTP id g107ls2958789qgg.49.gmail; Tue, 11 Feb 2014 21:58:50 -0800 (PST) X-Received: by 10.58.37.232 with SMTP id b8mr182710vek.27.1392184730923; Tue, 11 Feb 2014 21:58:50 -0800 (PST) Received: from mail-vc0-f175.google.com (mail-vc0-f175.google.com [209.85.220.175]) by mx.google.com with ESMTPS id vf1si4051504vcb.92.2014.02.11.21.58.50 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 11 Feb 2014 21:58:50 -0800 (PST) Received-SPF: neutral (google.com: 209.85.220.175 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.175; Received: by mail-vc0-f175.google.com with SMTP id ij19so6615522vcb.20 for ; Tue, 11 Feb 2014 21:58:50 -0800 (PST) X-Received: by 10.220.2.199 with SMTP id 7mr31459652vck.4.1392184730843; Tue, 11 Feb 2014 21:58:50 -0800 (PST) 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.220.174.196 with SMTP id u4csp11526vcz; Tue, 11 Feb 2014 21:58:50 -0800 (PST) X-Received: by 10.112.175.43 with SMTP id bx11mr198516lbc.51.1392184729638; Tue, 11 Feb 2014 21:58:49 -0800 (PST) Received: from casper.infradead.org (casper.infradead.org. [2001:770:15f::2]) by mx.google.com with ESMTPS id li1si11721461lab.77.2014.02.11.21.58.49 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 11 Feb 2014 21:58:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:770:15f::2 as permitted sender) client-ip=2001:770:15f::2; Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WDScN-00032m-Iy; Wed, 12 Feb 2014 05:44:20 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WDSbl-0006LR-3v; Wed, 12 Feb 2014 05:43:41 +0000 Received: from mail-pd0-f174.google.com ([209.85.192.174]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WDSap-0006DG-Gp for linux-arm-kernel@lists.infradead.org; Wed, 12 Feb 2014 05:42:45 +0000 Received: by mail-pd0-f174.google.com with SMTP id z10so8505084pdj.19 for ; Tue, 11 Feb 2014 21:42:22 -0800 (PST) X-Received: by 10.68.112.164 with SMTP id ir4mr20154352pbb.153.1392183741542; Tue, 11 Feb 2014 21:42:21 -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.19 for (version=TLSv1.2 cipher=AES128-GCM-SHA256 bits=128/128); Tue, 11 Feb 2014 21:42:21 -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 7/7] ARM: KVM: MMIO support BE host running LE code Date: Tue, 11 Feb 2014 21:41:33 -0800 Message-Id: <1392183693-21238-8-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_004243_685857_5152E968 X-CRM114-Status: GOOD ( 10.53 ) X-Spam-Score: 1.1 (+) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (1.1 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [209.85.192.174 listed in list.dnswl.org] 3.0 KHOP_BIG_TO_CC Sent to 10+ recipients instaed of Bcc or a list -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 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+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=neutral (google.com: 209.85.220.175 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 Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 In case of status register E bit is not set (LE mode) and host runs in BE mode we need byteswap data, so read/write is emulated correctly. Signed-off-by: Victor Kamensky --- arch/arm/include/asm/kvm_emulate.h | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/arch/arm/include/asm/kvm_emulate.h b/arch/arm/include/asm/kvm_emulate.h index 0fa90c9..69b7469 100644 --- a/arch/arm/include/asm/kvm_emulate.h +++ b/arch/arm/include/asm/kvm_emulate.h @@ -185,9 +185,16 @@ static inline unsigned long vcpu_data_guest_to_host(struct kvm_vcpu *vcpu, default: return be32_to_cpu(data); } + } else { + switch (len) { + case 1: + return data & 0xff; + case 2: + return le16_to_cpu(data & 0xffff); + default: + return le32_to_cpu(data); + } } - - return data; /* Leave LE untouched */ } static inline unsigned long vcpu_data_host_to_guest(struct kvm_vcpu *vcpu, @@ -203,9 +210,16 @@ static inline unsigned long vcpu_data_host_to_guest(struct kvm_vcpu *vcpu, default: return cpu_to_be32(data); } + } else { + switch (len) { + case 1: + return data & 0xff; + case 2: + return cpu_to_le16(data & 0xffff); + default: + return cpu_to_le32(data); + } } - - return data; /* Leave LE untouched */ } #endif /* __ARM_KVM_EMULATE_H__ */