From patchwork Fri Dec 20 07:26:59 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: vkamensky X-Patchwork-Id: 22667 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pa0-f70.google.com (mail-pa0-f70.google.com [209.85.220.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 0B88F23FC0 for ; Fri, 20 Dec 2013 07:27:42 +0000 (UTC) Received: by mail-pa0-f70.google.com with SMTP id fa1sf5716927pad.1 for ; Thu, 19 Dec 2013 23:27:42 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=Bs/PfT7E8QvJMyBH0pvGizurV2C6YZvj5L+jWZuP+yA=; b=cO8bSBYRpXulAj+csQ4GmqLgfSXqeLMyu78aTaAqW056GNI78eshbQRnJwzNs+BoX/ yjJbtO8Iutjio+CvE7XHLIFfhekEWokRhySWPtCfynCy42beQUnTAtja5KEbA52xUJOL 7PmJrmkIlLkPnYEeQfrfd/2gKfF8bobS3You7NtAhkWdmZYWOpY+VjJXShf/U2pbNhvI 3zaGIavmt65rljI3vfpro0x2PlR28QRb0hnJNlj59zu+8UGZAL1eUaPUlv3UJn0CqmEn 02wzp8WhaJaxN5gxlRu6qndn21m+g6L3cMj+7XTHysBVmoZdlwIqFbkIXBsG2RnQZjfK na3w== X-Gm-Message-State: ALoCoQmgEjZkteKAEiTkaI0o9vSOe3MHy9ePR0SQlUvFxwZkt2+b6ToywPBJTO5036bDGqKMkP5A X-Received: by 10.66.66.163 with SMTP id g3mr2608682pat.3.1387524462234; Thu, 19 Dec 2013 23:27:42 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.25.196 with SMTP id e4ls633772qeg.6.gmail; Thu, 19 Dec 2013 23:27:42 -0800 (PST) X-Received: by 10.52.160.130 with SMTP id xk2mr392417vdb.24.1387524462108; Thu, 19 Dec 2013 23:27:42 -0800 (PST) Received: from mail-ve0-f171.google.com (mail-ve0-f171.google.com [209.85.128.171]) by mx.google.com with ESMTPS id xn8si1294204vdc.87.2013.12.19.23.27.42 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 19 Dec 2013 23:27:42 -0800 (PST) Received-SPF: neutral (google.com: 209.85.128.171 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.171; Received: by mail-ve0-f171.google.com with SMTP id pa12so1261401veb.2 for ; Thu, 19 Dec 2013 23:27:42 -0800 (PST) X-Received: by 10.52.135.201 with SMTP id pu9mr3413859vdb.13.1387524462017; Thu, 19 Dec 2013 23:27:42 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.59.13.131 with SMTP id ey3csp40816ved; Thu, 19 Dec 2013 23:27:41 -0800 (PST) X-Received: by 10.66.138.40 with SMTP id qn8mr6865401pab.154.1387524461210; Thu, 19 Dec 2013 23:27:41 -0800 (PST) Received: from mail-pa0-f50.google.com (mail-pa0-f50.google.com [209.85.220.50]) by mx.google.com with ESMTPS id vb7si4494784pbc.212.2013.12.19.23.27.40 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 19 Dec 2013 23:27:41 -0800 (PST) Received-SPF: neutral (google.com: 209.85.220.50 is neither permitted nor denied by best guess record for domain of victor.kamensky@linaro.org) client-ip=209.85.220.50; Received: by mail-pa0-f50.google.com with SMTP id kp14so397781pab.9 for ; Thu, 19 Dec 2013 23:27:40 -0800 (PST) X-Received: by 10.68.0.35 with SMTP id 3mr6809985pbb.52.1387524460819; Thu, 19 Dec 2013 23:27:40 -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 ic7sm12147339pbc.29.2013.12.19.23.27.39 for (version=TLSv1.2 cipher=AES128-GCM-SHA256 bits=128/128); Thu, 19 Dec 2013 23:27:40 -0800 (PST) From: Victor Kamensky To: linux-arm-kernel@lists.infradead.org, marc.zyngier@arm.com, christoffer.dall@linaro.org, ben.dooks@codethink.co.uk Cc: rmk@arm.linux.org.uk, will.deacon@arm.com, Dave.Martin@arm.com, andre.przywara@linaro.org, taras.kondratiuk@linaro.org, patches@linaro.org, linaro-kernel@lists.linaro.org, Victor Kamensky Subject: [PATCH 5/5] ARM: kvm MMIO support BE host running LE code Date: Thu, 19 Dec 2013 23:26:59 -0800 Message-Id: <1387524419-4216-6-git-send-email-victor.kamensky@linaro.org> X-Mailer: git-send-email 1.8.1.4 In-Reply-To: <1387524419-4216-1-git-send-email-victor.kamensky@linaro.org> References: <1387524419-4216-1-git-send-email-victor.kamensky@linaro.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.128.171 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 Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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__ */