From patchwork Thu Jun 12 16:30:08 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: vkamensky X-Patchwork-Id: 31845 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ie0-f198.google.com (mail-ie0-f198.google.com [209.85.223.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 620F520AE6 for ; Thu, 12 Jun 2014 16:34:24 +0000 (UTC) Received: by mail-ie0-f198.google.com with SMTP id y20sf7185130ier.9 for ; Thu, 12 Jun 2014 09:34:23 -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=lKjCWmzYFTk/fDaF75U6jmFJQQLPloGf1NbJC47LYFk=; b=XUSKIIUjKC6xuL2xkeS2sC0/2HEYcglGebjMw32ZnaDSQvrrpDGjDJnRY8ivtZhzIy xFwdIy6afKRq+0TBRBjwN355J2LwVhjbYE6PTerkrCWJFQ1OpiMtkMtJ3+7nVaS8x2lc hZguNq4v5AmSR+1Fce5TdbkHc8ougrq/zWSxP9N3UWVwqyIEMim9W+0HCU/hzRpgxges QTznp8EzZulUl+fWDIgZX3uTbBjysTkna5f2GtktKg3OIjXi4EFXVfVH11FoLBW4iEoO K4Pk7CY1mBwwEIaQiaLTLHntRlRnU9yQUdbjLgIlyYX9s/xrrmyD0L929ymeepv73hN9 48ZQ== X-Gm-Message-State: ALoCoQkETEIFmDU0OgAa7yqUxHWforroCGDcQ85nQtWGpoYUNlBRFK9ZvvAfLs16r9z5uCVbaENI X-Received: by 10.182.250.229 with SMTP id zf5mr1373416obc.4.1402590863582; Thu, 12 Jun 2014 09:34:23 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.42.111 with SMTP id b102ls3160746qga.31.gmail; Thu, 12 Jun 2014 09:34:23 -0700 (PDT) X-Received: by 10.58.127.101 with SMTP id nf5mr1177296veb.50.1402590863440; Thu, 12 Jun 2014 09:34:23 -0700 (PDT) Received: from mail-vc0-f173.google.com (mail-vc0-f173.google.com [209.85.220.173]) by mx.google.com with ESMTPS id og7si482754vcb.23.2014.06.12.09.34.23 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 12 Jun 2014 09:34:23 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.173 as permitted sender) client-ip=209.85.220.173; Received: by mail-vc0-f173.google.com with SMTP id lf12so1067465vcb.4 for ; Thu, 12 Jun 2014 09:34:23 -0700 (PDT) X-Received: by 10.52.27.209 with SMTP id v17mr8761213vdg.23.1402590863377; Thu, 12 Jun 2014 09:34:23 -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 vs6csp417065vcb; Thu, 12 Jun 2014 09:34:23 -0700 (PDT) X-Received: by 10.224.114.81 with SMTP id d17mr62502635qaq.33.1402590862952; Thu, 12 Jun 2014 09:34:22 -0700 (PDT) Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id g3si1647403qch.17.2014.06.12.09.34.22 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 12 Jun 2014 09:34:22 -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 1Wv7vf-0000Fd-96; Thu, 12 Jun 2014 16:32:43 +0000 Received: from mail-pb0-f43.google.com ([209.85.160.43]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Wv7u6-0007se-Qd for linux-arm-kernel@lists.infradead.org; Thu, 12 Jun 2014 16:31:08 +0000 Received: by mail-pb0-f43.google.com with SMTP id up15so1171147pbc.30 for ; Thu, 12 Jun 2014 09:30:45 -0700 (PDT) X-Received: by 10.66.97.4 with SMTP id dw4mr22070590pab.55.1402590645746; Thu, 12 Jun 2014 09:30:45 -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.44 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 12 Jun 2014 09:30:45 -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 09/14] ARM64: KVM: MMIO support BE host running LE code Date: Thu, 12 Jun 2014 09:30:08 -0700 Message-Id: <1402590613-3341-10-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_093106_906047_8FF3B416 X-CRM114-Status: GOOD ( 10.10 ) 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.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [209.85.160.43 listed in wl.mailspike.net] -0.0 SPF_PASS SPF: sender matches SPF record -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.160.43 listed in list.dnswl.org] 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.220.173 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 */