From patchwork Wed Feb 12 05:57:19 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: vkamensky X-Patchwork-Id: 24513 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-oa0-f71.google.com (mail-oa0-f71.google.com [209.85.219.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 2909D20567 for ; Wed, 12 Feb 2014 05:59:38 +0000 (UTC) Received: by mail-oa0-f71.google.com with SMTP id g12sf37232154oah.10 for ; Tue, 11 Feb 2014 21:59:37 -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=BGNWsl1mr5nk7GxGFj9u9PC6MdeB7vEgLaGmLpND+b8=; b=QJL/t1DAuz+WMKLBShRdstCMbZm5GPn/N2tDXSavO89zdrTrw2+j4JKMV6p2yI4Hij m0jVtMfS9lnrRTAEW3thrY5UHqLNWny1AHTHajs+4RoHCPEsKV3t6XLWp6wFQ6OUDoZx hVkqoFwfrvvJB0yBqXmxaUU8N7wTHPfCYd+HudhVoFR5C948aIb2b/qXWH97RWN6Kfrb 3rJUPAYj66fZbDGEN7BtsLAqXqOWFZ7HWvNqQ4pYF9czFGbKCRrR/5Zzfj9d3olAC1dn oR1XtsdNbb5GP9Fff0glQSfiw5XPE58+isvbR3U21jN6z40DCz9fpe1XpDeRKMvJRpHi bMGw== X-Gm-Message-State: ALoCoQnTaTBvKHzbiUHkXzVCMosswVoHIPHul+PH5lmXmu2recr4howS1etQr02WICCI4633l6I7 X-Received: by 10.182.28.36 with SMTP id y4mr1052350obg.46.1392184777195; Tue, 11 Feb 2014 21:59:37 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.44.102 with SMTP id f93ls2713746qga.75.gmail; Tue, 11 Feb 2014 21:59:37 -0800 (PST) X-Received: by 10.58.37.232 with SMTP id b8mr184897vek.27.1392184777097; Tue, 11 Feb 2014 21:59:37 -0800 (PST) Received: from mail-vb0-f42.google.com (mail-vb0-f42.google.com [209.85.212.42]) by mx.google.com with ESMTPS id n17si6942524vcq.60.2014.02.11.21.59.37 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 11 Feb 2014 21:59:37 -0800 (PST) Received-SPF: neutral (google.com: 209.85.212.42 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.212.42; Received: by mail-vb0-f42.google.com with SMTP id i11so3536093vbh.15 for ; Tue, 11 Feb 2014 21:59:37 -0800 (PST) X-Received: by 10.58.170.69 with SMTP id ak5mr181907vec.28.1392184777017; Tue, 11 Feb 2014 21:59:37 -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 u4csp11559vcz; Tue, 11 Feb 2014 21:59:36 -0800 (PST) X-Received: by 10.112.160.161 with SMTP id xl1mr173780lbb.71.1392184775426; Tue, 11 Feb 2014 21:59:35 -0800 (PST) Received: from casper.infradead.org (casper.infradead.org. [2001:770:15f::2]) by mx.google.com with ESMTPS id t10si11735382lat.12.2014.02.11.21.59.34 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 11 Feb 2014 21:59:35 -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 1WDSq8-0005pX-Ek; Wed, 12 Feb 2014 05:58:32 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WDSq0-0006bP-3u; Wed, 12 Feb 2014 05:58:24 +0000 Received: from mail-ob0-f174.google.com ([209.85.214.174]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WDSpw-0006ZL-2R for linux-arm-kernel@lists.infradead.org; Wed, 12 Feb 2014 05:58:21 +0000 Received: by mail-ob0-f174.google.com with SMTP id uy5so10092253obc.33 for ; Tue, 11 Feb 2014 21:57:59 -0800 (PST) X-Received: by 10.182.113.195 with SMTP id ja3mr10750779obb.46.1392184678940; Tue, 11 Feb 2014 21:57:58 -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 tr7sm63581349oec.0.2014.02.11.21.57.51 for (version=TLSv1.2 cipher=AES128-GCM-SHA256 bits=128/128); Tue, 11 Feb 2014 21:57:58 -0800 (PST) From: Victor Kamensky To: kvmarm@lists.cs.columbia.edu, marc.zyngier@arm.com, christoffer.dall@linaro.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH 1/5] ARM64: KVM: MMIO support BE host running LE code Date: Tue, 11 Feb 2014 21:57:19 -0800 Message-Id: <1392184643-6108-2-git-send-email-victor.kamensky@linaro.org> X-Mailer: git-send-email 1.8.1.4 In-Reply-To: <1392184643-6108-1-git-send-email-victor.kamensky@linaro.org> References: <1392184643-6108-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_005820_210304_D33CE11C X-CRM114-Status: UNSURE ( 9.47 ) X-CRM114-Notice: Please train this message. X-Spam-Score: 0.4 (/) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (0.4 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.214.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.212.42 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 guest CPU running in LE mode and host runs in BE mode we need byteswap data, so read/write is emulated correctly. Signed-off-by: Victor Kamensky --- arch/arm64/include/asm/kvm_emulate.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/arch/arm64/include/asm/kvm_emulate.h b/arch/arm64/include/asm/kvm_emulate.h index dd8ecfc..fdc3e21 100644 --- a/arch/arm64/include/asm/kvm_emulate.h +++ b/arch/arm64/include/asm/kvm_emulate.h @@ -213,6 +213,17 @@ static inline unsigned long vcpu_data_guest_to_host(struct kvm_vcpu *vcpu, default: return be64_to_cpu(data); } + } else { + switch (len) { + case 1: + return data & 0xff; + case 2: + return le16_to_cpu(data & 0xffff); + case 4: + return le32_to_cpu(data & 0xffffffff); + default: + return le64_to_cpu(data); + } } return data; /* Leave LE untouched */ @@ -233,6 +244,17 @@ static inline unsigned long vcpu_data_host_to_guest(struct kvm_vcpu *vcpu, default: return cpu_to_be64(data); } + } else { + switch (len) { + case 1: + return data & 0xff; + case 2: + return cpu_to_le16(data & 0xffff); + case 4: + return cpu_to_le32(data & 0xffffffff); + default: + return cpu_to_le64(data); + } } return data; /* Leave LE untouched */