From patchwork Thu Jun 12 16:30:05 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: vkamensky X-Patchwork-Id: 31841 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qc0-f197.google.com (mail-qc0-f197.google.com [209.85.216.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 62D1020AE6 for ; Thu, 12 Jun 2014 16:33:28 +0000 (UTC) Received: by mail-qc0-f197.google.com with SMTP id i8sf5333686qcq.4 for ; Thu, 12 Jun 2014 09:33:28 -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=fQsMXcaAr+RWlXsDf/ZsYwfP7pEFsmCKz0gxsnKALtY=; b=T3xa2Q2RXXseSZJoHyq6Shna0MW3iw9TalKJ+r6gMdTeecce+VZhqo0JzbfnFk3HGT jUVSUhN4dgO7+s4jHim+rdy2ZHcsGeDbry0Wp3u07V6u4A+pjTeQPO/drvvL7YQ2BeUb rlada93TldRN58VE5KfznzaIFCXgwt3+QGZ4sgkcQtOW6yhiaomEnBsfVp0dEhtkHjho zJfXN4XN3yhF4n3PR7WA5BtQuQ0Ex8VrH9U8dNofbVjZsezlCw1s6Vk4YaH+vrDurZAk 6C8wKcUAoktTGV5fcVEY3OBcQifMBo1HMU7uw9MdZYLPuL65OnpsaBT7rOlpXbJcbLIk T/rw== X-Gm-Message-State: ALoCoQnP6KKrjb1Yk4w5GozS6TaryqCyjpe5oWsx9ZLW/2J6xSN7AFcjxGHR3q9yUUSJVAcFi6Gt X-Received: by 10.236.124.100 with SMTP id w64mr692297yhh.57.1402590808237; Thu, 12 Jun 2014 09:33:28 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.22.145 with SMTP id 17ls3115173qgn.21.gmail; Thu, 12 Jun 2014 09:33:28 -0700 (PDT) X-Received: by 10.58.22.164 with SMTP id e4mr165497vef.71.1402590808076; Thu, 12 Jun 2014 09:33:28 -0700 (PDT) Received: from mail-ve0-f170.google.com (mail-ve0-f170.google.com [209.85.128.170]) by mx.google.com with ESMTPS id qk6si475164vdb.68.2014.06.12.09.33.28 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 12 Jun 2014 09:33:28 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.128.170 as permitted sender) client-ip=209.85.128.170; Received: by mail-ve0-f170.google.com with SMTP id oz11so2062527veb.29 for ; Thu, 12 Jun 2014 09:33:28 -0700 (PDT) X-Received: by 10.52.35.69 with SMTP id f5mr838390vdj.83.1402590807988; Thu, 12 Jun 2014 09:33:27 -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.54.6 with SMTP id vs6csp417001vcb; Thu, 12 Jun 2014 09:33:27 -0700 (PDT) X-Received: by 10.224.55.202 with SMTP id v10mr4899039qag.10.1402590807382; Thu, 12 Jun 2014 09:33:27 -0700 (PDT) Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id q10si1678530qak.116.2014.06.12.09.33.27 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 12 Jun 2014 09:33:27 -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 1Wv7uz-0008ED-8S; Thu, 12 Jun 2014 16:32:01 +0000 Received: from mail-pa0-f44.google.com ([209.85.220.44]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Wv7u1-0007sF-4H for linux-arm-kernel@lists.infradead.org; Thu, 12 Jun 2014 16:31:04 +0000 Received: by mail-pa0-f44.google.com with SMTP id bj1so1190456pad.3 for ; Thu, 12 Jun 2014 09:30:40 -0700 (PDT) X-Received: by 10.68.225.105 with SMTP id rj9mr14002864pbc.108.1402590640366; Thu, 12 Jun 2014 09:30:40 -0700 (PDT) Received: from kamensky-w530.cisco.com (128-107-239-235.cisco.com. [128.107.239.235]) by mx.google.com with ESMTPSA id nh8sm81278030pbc.25.2014.06.12.09.30.38 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 12 Jun 2014 09:30:39 -0700 (PDT) From: Victor Kamensky To: kvmarm@lists.cs.columbia.edu, christoffer.dall@linaro.org, marc.zyngier@arm.com, agraf@suse.de Subject: [PATCH v4 06/14] ARM: KVM: MMIO support BE host running LE code Date: Thu, 12 Jun 2014 09:30:05 -0700 Message-Id: <1402590613-3341-7-git-send-email-victor.kamensky@linaro.org> X-Mailer: git-send-email 1.8.1.4 In-Reply-To: <1402590613-3341-1-git-send-email-victor.kamensky@linaro.org> References: <1402590613-3341-1-git-send-email-victor.kamensky@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140612_093101_194264_214FAD6A X-CRM114-Status: GOOD ( 11.02 ) 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.220.44 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [209.85.220.44 listed in wl.mailspike.net] -0.0 SPF_PASS SPF: sender matches SPF record Cc: taras.kondratiuk@linaro.org, linaro-kernel@lists.linaro.org, linux-arm-kernel@lists.infradead.org, Victor Kamensky 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: victor.kamensky@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.128.170 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 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 --- 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__ */