From patchwork Mon Aug 4 08:46:49 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 34800 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 BC38620F2E for ; Mon, 4 Aug 2014 08:56:57 +0000 (UTC) Received: by mail-oa0-f71.google.com with SMTP id g18sf38753741oah.2 for ; Mon, 04 Aug 2014 01:56:56 -0700 (PDT) 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=OLEGq9d+Gb628WETA2+dWEQrSfExsaDYMo4vfUxph+8=; b=M1NwFqJS7S34RpqwTBNdWWFCfVZHFcLXhZmAMiR2G04rUgV1pAtUS2ZnErU8ZjAMnM t17gxRWpDB0vT8szIfcIhDG4mDea7lW9KfVuOGVM1/dDtJgTlcqT6JNyxgCS+ApxfSLs 7UR7YHep/4z9flawIKCFRw/IERGuF79bJtaZGHMc/EatWj20dhYPU53m8qZXEmNwrCgA Rp06k7RqswAG02lpVg/OMI4Rk+X2SuwpW3MF0jaEGYAxJwbbieoQ3bqRuLwdgwTHie8G xkzxzjkAqNq2L3kCwLlAzGDNUH5wKwFSh0y0lv1nkwfWKkVasf8am1Lju7zc3i69ITvB eJbw== X-Gm-Message-State: ALoCoQlNsAHWFfbVpBP9K0dZbPpoa86UioO69GRH+AgJ+Juz/Q+3GoJudNtX5AfdiClwsyo8OyWz X-Received: by 10.182.213.105 with SMTP id nr9mr8814132obc.36.1407142616361; Mon, 04 Aug 2014 01:56:56 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.34.44 with SMTP id k41ls2202900qgk.78.gmail; Mon, 04 Aug 2014 01:56:56 -0700 (PDT) X-Received: by 10.52.243.10 with SMTP id wu10mr18556860vdc.45.1407142616221; Mon, 04 Aug 2014 01:56:56 -0700 (PDT) Received: from mail-vc0-f180.google.com (mail-vc0-f180.google.com [209.85.220.180]) by mx.google.com with ESMTPS id xc7si11556641vcb.32.2014.08.04.01.56.56 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 04 Aug 2014 01:56:56 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.180 as permitted sender) client-ip=209.85.220.180; Received: by mail-vc0-f180.google.com with SMTP id ij19so10522513vcb.11 for ; Mon, 04 Aug 2014 01:56:56 -0700 (PDT) X-Received: by 10.52.15.8 with SMTP id t8mr18683301vdc.18.1407142616121; Mon, 04 Aug 2014 01:56:56 -0700 (PDT) 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.221.37.5 with SMTP id tc5csp288560vcb; Mon, 4 Aug 2014 01:56:55 -0700 (PDT) X-Received: by 10.66.254.166 with SMTP id aj6mr22822769pad.11.1407142615207; Mon, 04 Aug 2014 01:56:55 -0700 (PDT) Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id gu1si469047pac.221.2014.08.04.01.56.54 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 04 Aug 2014 01:56:55 -0700 (PDT) Received-SPF: none (google.com: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org does not designate permitted sender hosts) client-ip=2001:1868:205::9; 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 1XEE3C-00005N-EJ; Mon, 04 Aug 2014 08:55:26 +0000 Received: from mail-lb0-f179.google.com ([209.85.217.179]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XEDwX-000253-BS for linux-arm-kernel@lists.infradead.org; Mon, 04 Aug 2014 08:48:33 +0000 Received: by mail-lb0-f179.google.com with SMTP id v6so5082501lbi.10 for ; Mon, 04 Aug 2014 01:48:11 -0700 (PDT) X-Received: by 10.112.167.67 with SMTP id zm3mr21115013lbb.27.1407142091109; Mon, 04 Aug 2014 01:48:11 -0700 (PDT) Received: from localhost.localdomain (188-178-240-98-static.dk.customer.tdc.net. [188.178.240.98]) by mx.google.com with ESMTPSA id px1sm26731207lbb.46.2014.08.04.01.48.09 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 04 Aug 2014 01:48:10 -0700 (PDT) From: Christoffer Dall To: Paolo Bonzini , Gleb Natapov Subject: [GIT PULL 32/51] ARM: KVM: MMIO support BE host running LE code Date: Mon, 4 Aug 2014 10:46:49 +0200 Message-Id: <1407142028-31105-33-git-send-email-christoffer.dall@linaro.org> X-Mailer: git-send-email 2.0.0 In-Reply-To: <1407142028-31105-1-git-send-email-christoffer.dall@linaro.org> References: <1407142028-31105-1-git-send-email-christoffer.dall@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140804_014833_578116_B8C66193 X-CRM114-Status: GOOD ( 11.60 ) X-Spam-Score: -0.7 (/) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-0.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.217.179 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [209.85.217.179 listed in wl.mailspike.net] -0.0 RCVD_IN_MSPIKE_WL Mailspike good senders Cc: Marc Zyngier , Victor Kamensky , kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, kvm@vger.kernel.org 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+patch=linaro.org@lists.infradead.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: christoffer.dall@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.180 as permitted sender) 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 From: Victor Kamensky 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 Reviewed-by: Christoffer Dall Reviewed-by: Marc Zyngier Signed-off-by: Marc Zyngier --- 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__ */