From patchwork Tue Feb 21 06:46:55 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yongji Xie X-Patchwork-Id: 9583923 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 11E6E600C1 for ; Tue, 21 Feb 2017 06:47:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DEB2828574 for ; Tue, 21 Feb 2017 06:47:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D252F288E4; Tue, 21 Feb 2017 06:47:28 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 48A7628574 for ; Tue, 21 Feb 2017 06:47:27 +0000 (UTC) Received: from localhost ([::1]:42585 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cg4EP-00030k-LS for patchwork-qemu-devel@patchwork.kernel.org; Tue, 21 Feb 2017 01:47:25 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54679) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cg4EA-00030U-0X for qemu-devel@nongnu.org; Tue, 21 Feb 2017 01:47:11 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cg4E5-0001jj-3E for qemu-devel@nongnu.org; Tue, 21 Feb 2017 01:47:10 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:59603) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cg4E4-0001jd-Q9 for qemu-devel@nongnu.org; Tue, 21 Feb 2017 01:47:05 -0500 Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v1L6dQWW053512 for ; Tue, 21 Feb 2017 01:47:02 -0500 Received: from e31.co.us.ibm.com (e31.co.us.ibm.com [32.97.110.149]) by mx0a-001b2d01.pphosted.com with ESMTP id 28r120bh8e-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Tue, 21 Feb 2017 01:47:01 -0500 Received: from localhost by e31.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 20 Feb 2017 23:47:01 -0700 Received: from d03dlp02.boulder.ibm.com (9.17.202.178) by e31.co.us.ibm.com (192.168.1.131) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 20 Feb 2017 23:46:58 -0700 Received: from b03cxnp08026.gho.boulder.ibm.com (b03cxnp08026.gho.boulder.ibm.com [9.17.130.18]) by d03dlp02.boulder.ibm.com (Postfix) with ESMTP id A95E03E40052; Mon, 20 Feb 2017 23:46:57 -0700 (MST) Received: from b03ledav005.gho.boulder.ibm.com (b03ledav005.gho.boulder.ibm.com [9.17.130.236]) by b03cxnp08026.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v1L6kvf78782258; Mon, 20 Feb 2017 23:46:57 -0700 Received: from b03ledav005.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 84AA2BE038; Mon, 20 Feb 2017 23:46:57 -0700 (MST) Received: from localhost (unknown [9.186.9.18]) by b03ledav005.gho.boulder.ibm.com (Postfix) with ESMTP id 43B00BE03B; Mon, 20 Feb 2017 23:46:57 -0700 (MST) From: Yongji Xie To: pbonzini@redhat.com Date: Tue, 21 Feb 2017 14:46:55 +0800 X-Mailer: git-send-email 1.7.1 X-TM-AS-GCONF: 00 X-Content-Scanned: Fidelis XPS MAILER x-cbid: 17022106-8235-0000-0000-00000B0395BE X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00006655; HX=3.00000240; KW=3.00000007; PH=3.00000004; SC=3.00000204; SDB=6.00824891; UDB=6.00403844; IPR=6.00602346; BA=6.00005160; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00014368; XFM=3.00000011; UTC=2017-02-21 06:46:59 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17022106-8236-0000-0000-000039C536EE Message-Id: <1487659615-15820-1-git-send-email-xyjxie@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-02-21_05:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1612050000 definitions=main-1702210069 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.156.1 Subject: [Qemu-devel] [PATCH] memory: make ram device read/write endian sensitive X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: aik@ozlabs.ru, alex.williamson@redhat.com, xyjxie@linux.vnet.ibm.com, qemu-devel@nongnu.org, zhong@linux.vnet.ibm.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP At the moment ram device's memory regions are NATIVE_ENDIAN. This does not work on PPC64 because VFIO PCI device is little endian but PPC64 always defines static macro TARGET_WORDS_BIGENDIAN. This fixes endianness for ram device the same way as it is done for VFIO region in commit 6758008e2c4e79fb6bd04fe8e7a41665fa583965. Signed-off-by: Yongji Xie --- memory.c | 14 +++++++------- 1 files changed, 7 insertions(+), 7 deletions(-) diff --git a/memory.c b/memory.c index 6c58373..1ccb99f 100644 --- a/memory.c +++ b/memory.c @@ -1139,13 +1139,13 @@ static uint64_t memory_region_ram_device_read(void *opaque, data = *(uint8_t *)(mr->ram_block->host + addr); break; case 2: - data = *(uint16_t *)(mr->ram_block->host + addr); + data = le16_to_cpu(*(uint16_t *)(mr->ram_block->host + addr)); break; case 4: - data = *(uint32_t *)(mr->ram_block->host + addr); + data = le32_to_cpu(*(uint32_t *)(mr->ram_block->host + addr)); break; case 8: - data = *(uint64_t *)(mr->ram_block->host + addr); + data = le64_to_cpu(*(uint64_t *)(mr->ram_block->host + addr)); break; } @@ -1166,13 +1166,13 @@ static void memory_region_ram_device_write(void *opaque, hwaddr addr, *(uint8_t *)(mr->ram_block->host + addr) = (uint8_t)data; break; case 2: - *(uint16_t *)(mr->ram_block->host + addr) = (uint16_t)data; + *(uint16_t *)(mr->ram_block->host + addr) = cpu_to_le16((uint16_t)data); break; case 4: - *(uint32_t *)(mr->ram_block->host + addr) = (uint32_t)data; + *(uint32_t *)(mr->ram_block->host + addr) = cpu_to_le32((uint32_t)data); break; case 8: - *(uint64_t *)(mr->ram_block->host + addr) = data; + *(uint64_t *)(mr->ram_block->host + addr) = cpu_to_le64(data); break; } } @@ -1180,7 +1180,7 @@ static void memory_region_ram_device_write(void *opaque, hwaddr addr, static const MemoryRegionOps ram_device_mem_ops = { .read = memory_region_ram_device_read, .write = memory_region_ram_device_write, - .endianness = DEVICE_NATIVE_ENDIAN, + .endianness = DEVICE_LITTLE_ENDIAN, .valid = { .min_access_size = 1, .max_access_size = 8,