From patchwork Tue May 13 16:14:01 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: vkamensky X-Patchwork-Id: 30102 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ob0-f199.google.com (mail-ob0-f199.google.com [209.85.214.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id B91E820446 for ; Tue, 13 May 2014 16:18:11 +0000 (UTC) Received: by mail-ob0-f199.google.com with SMTP id wm4sf2486101obc.10 for ; Tue, 13 May 2014 09:18:11 -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=FNXTdCt7iqPxdq0jrmAp7lbmmY4oRni8yYQk5+eKIeI=; b=KDtl+GJ1NYzyAusZtdTowPOSetT2soGxYBH9Dr1mSz3k1f5TgCaGchYZwmN2Qa7s9J ARAeFnG6kUNOIJjc5F71sqk+kSkw2c8Auo4xpPNW1f/J18sEpQp4VG/lD8h/VO80oElk tWoTOdiXBzRA76bM5nLcBRAW6w//VjsRT9yu1/uxHtgZPQikZs8SEfRjp25JnwOKzPRq rqOL/VD5NBy4iBXrxnZ34mCTZxOXH9QT+jJMH27a95UkPgiS6IZU41C9106q+7L0wjxs f24bvY8rKmEq2XeSGnCQKNgl1BPlIFcvO5TQlaccAv3YgsM0MxxSeziUMPvRqKOp5hGY 9MqQ== X-Gm-Message-State: ALoCoQl+WFb2XTHUaSqD6s5WLXEKorG9r4EUR2W0IZXtsOboEB4wGDd1FZRM1hBB7tOhIoMLmyJV X-Received: by 10.182.128.234 with SMTP id nr10mr17673126obb.0.1399997891362; Tue, 13 May 2014 09:18:11 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.101.247 with SMTP id u110ls1942330qge.79.gmail; Tue, 13 May 2014 09:18:11 -0700 (PDT) X-Received: by 10.52.244.194 with SMTP id xi2mr97109vdc.91.1399997891268; Tue, 13 May 2014 09:18:11 -0700 (PDT) Received: from mail-vc0-f175.google.com (mail-vc0-f175.google.com [209.85.220.175]) by mx.google.com with ESMTPS id v2si2726730vet.142.2014.05.13.09.18.11 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 13 May 2014 09:18:11 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.175 as permitted sender) client-ip=209.85.220.175; Received: by mail-vc0-f175.google.com with SMTP id hu19so757283vcb.20 for ; Tue, 13 May 2014 09:18:11 -0700 (PDT) X-Received: by 10.52.227.138 with SMTP id sa10mr25044134vdc.25.1399997891202; Tue, 13 May 2014 09:18:11 -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.220.221.72 with SMTP id ib8csp164190vcb; Tue, 13 May 2014 09:18:10 -0700 (PDT) X-Received: by 10.140.49.208 with SMTP id q74mr38152192qga.103.1399997890721; Tue, 13 May 2014 09:18:10 -0700 (PDT) Received: from bombadil.infradead.org (bombadil.infradead.org. [198.137.202.9]) by mx.google.com with ESMTPS id m6si8000896qcg.70.2014.05.13.09.18.10 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 13 May 2014 09:18:10 -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=198.137.202.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 1WkFNr-0003U7-Bl; Tue, 13 May 2014 16:16:51 +0000 Received: from mail-pa0-f42.google.com ([209.85.220.42]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WkFMU-0002Nj-RJ for linux-arm-kernel@lists.infradead.org; Tue, 13 May 2014 16:15:27 +0000 Received: by mail-pa0-f42.google.com with SMTP id rd3so465387pab.1 for ; Tue, 13 May 2014 09:15:05 -0700 (PDT) X-Received: by 10.68.163.197 with SMTP id yk5mr6335624pbb.57.1399997705823; Tue, 13 May 2014 09:15:05 -0700 (PDT) Received: from kamensky-w530.hsd1.ca.comcast.net (c-24-6-79-41.hsd1.ca.comcast.net. [24.6.79.41]) by mx.google.com with ESMTPSA id dd5sm28958360pbc.85.2014.05.13.09.15.04 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 13 May 2014 09:15:05 -0700 (PDT) From: Victor Kamensky To: kvmarm@lists.cs.columbia.edu, christoffer.dall@linaro.org, marc.zyngier@arm.com, agraf@suse.de Subject: [PATCH v3 09/14] ARM64: KVM: MMIO support BE host running LE code Date: Tue, 13 May 2014 09:14:01 -0700 Message-Id: <1399997646-4716-10-git-send-email-victor.kamensky@linaro.org> X-Mailer: git-send-email 1.8.1.4 In-Reply-To: <1399997646-4716-1-git-send-email-victor.kamensky@linaro.org> References: <1399997646-4716-1-git-send-email-victor.kamensky@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140513_091526_942698_FAFFCD98 X-CRM114-Status: UNSURE ( 9.93 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -0.7 (/) X-Spam-Report: SpamAssassin version 3.3.2 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.42 listed in list.dnswl.org] -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.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=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.175 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 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 Reviewed-by: Christoffer Dall Reviewed-by: Marc Zyngier --- 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 */