From patchwork Fri Dec 20 16:48:45 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: vkamensky X-Patchwork-Id: 22687 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pa0-f71.google.com (mail-pa0-f71.google.com [209.85.220.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 9C65A202AE for ; Fri, 20 Dec 2013 16:49:26 +0000 (UTC) Received: by mail-pa0-f71.google.com with SMTP id kp14sf2373367pab.10 for ; Fri, 20 Dec 2013 08:49:25 -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=YHyn7AYpxfxFvNmfI/DRNt/7C5X3cIxIwPcaYHzUPYtJ8CE9o71VGnE15NIREDb1uA xHZD2i65GXOPb5LdBA9BNjMFaz4bNLgfAnyWZhuVqjAORGdxhPjgWe6105AHeyvZwzHu 0gmYMxfdJ+r3CgnxkcDAOTEA9fOFtnp3xg8q1yWZkB6+S00lym1YUb6t3cVxkxEfyuiz fWiJ90MiT6h5Rwo/tzyBCfLkrd/mLgzJgQw69loSfqQQKjwR0FrYz/wxAMllhW9ekgs9 pnJDoppRu11MHlf7NE/6flaJmCi9qQ4aKxntQvWT3vQwk7aN7h+RWa8tHpO9cfV8AINz 9YVQ== X-Gm-Message-State: ALoCoQlQdXRfWUp3rErSAXwVekRdTncgQDT4wFfV489btBBY3Q+m5GAMZ4QPBEkMJNrgiomAi62A X-Received: by 10.66.220.163 with SMTP id px3mr4227295pac.38.1387558165916; Fri, 20 Dec 2013 08:49:25 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.76.72 with SMTP id i8ls787769qew.59.gmail; Fri, 20 Dec 2013 08:49:25 -0800 (PST) X-Received: by 10.58.67.9 with SMTP id j9mr5487524vet.3.1387558165765; Fri, 20 Dec 2013 08:49:25 -0800 (PST) Received: from mail-vb0-f49.google.com (mail-vb0-f49.google.com [209.85.212.49]) by mx.google.com with ESMTPS id at4si1620272ved.151.2013.12.20.08.49.25 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 20 Dec 2013 08:49:25 -0800 (PST) Received-SPF: neutral (google.com: 209.85.212.49 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.212.49; Received: by mail-vb0-f49.google.com with SMTP id x11so1496676vbb.22 for ; Fri, 20 Dec 2013 08:49:25 -0800 (PST) X-Received: by 10.220.106.84 with SMTP id w20mr1916769vco.18.1387558165694; Fri, 20 Dec 2013 08:49:25 -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 ey3csp75256ved; Fri, 20 Dec 2013 08:49:25 -0800 (PST) X-Received: by 10.69.19.225 with SMTP id gx1mr9889753pbd.62.1387558164619; Fri, 20 Dec 2013 08:49:24 -0800 (PST) Received: from mail-pd0-f181.google.com (mail-pd0-f181.google.com [209.85.192.181]) by mx.google.com with ESMTPS id nu5si5673524pbc.88.2013.12.20.08.49.24 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 20 Dec 2013 08:49:24 -0800 (PST) Received-SPF: neutral (google.com: 209.85.192.181 is neither permitted nor denied by best guess record for domain of victor.kamensky@linaro.org) client-ip=209.85.192.181; Received: by mail-pd0-f181.google.com with SMTP id p10so2736443pdj.40 for ; Fri, 20 Dec 2013 08:49:24 -0800 (PST) X-Received: by 10.68.228.138 with SMTP id si10mr9788881pbc.13.1387558164178; Fri, 20 Dec 2013 08:49:24 -0800 (PST) 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 nw11sm20120833pab.13.2013.12.20.08.49.22 for (version=TLSv1.2 cipher=AES128-GCM-SHA256 bits=128/128); Fri, 20 Dec 2013 08:49:23 -0800 (PST) From: Victor Kamensky To: linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, 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 REPOST 5/5] ARM: kvm MMIO support BE host running LE code Date: Fri, 20 Dec 2013 08:48:45 -0800 Message-Id: <1387558125-3460-6-git-send-email-victor.kamensky@linaro.org> X-Mailer: git-send-email 1.8.1.4 In-Reply-To: <1387558125-3460-1-git-send-email-victor.kamensky@linaro.org> References: <1387558125-3460-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.212.49 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__ */