From nobody Sun May 5 04:06:48 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 154291126830067.28579278549114; Thu, 22 Nov 2018 10:27:48 -0800 (PST) Received: from localhost ([::1]:48829 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gPtha-0003gV-RR for importer@patchew.org; Thu, 22 Nov 2018 13:27:46 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51535) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gPtfe-0002az-A7 for qemu-devel@nongnu.org; Thu, 22 Nov 2018 13:25:49 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gPtdd-0007J4-2b for qemu-devel@nongnu.org; Thu, 22 Nov 2018 13:23:44 -0500 Received: from mx1.redhat.com ([209.132.183.28]:45374) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gPtdc-0007Hh-S0 for qemu-devel@nongnu.org; Thu, 22 Nov 2018 13:23:40 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DC714307D860; Thu, 22 Nov 2018 18:23:37 +0000 (UTC) Received: from donizetti.redhat.com (ovpn-112-67.ams2.redhat.com [10.36.112.67]) by smtp.corp.redhat.com (Postfix) with ESMTP id B670817250; Thu, 22 Nov 2018 18:23:36 +0000 (UTC) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 22 Nov 2018 19:23:35 +0100 Message-Id: <20181122182335.9038-1-pbonzini@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Thu, 22 Nov 2018 18:23:38 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH] nvme: fix CMB endianness confusion 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: kwolf@redhat.com, peter.maydell@linaro.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" The CMB is marked as DEVICE_LITTLE_ENDIAN, so the data must be read/written as if it was little-endian output (in the case of big endian, we get two swaps, one in the memory core and one in nvme.c). Signed-off-by: Paolo Bonzini Tested-by: Peter Maydell --- hw/block/nvme.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/hw/block/nvme.c b/hw/block/nvme.c index 5d92794ef7..8a12fba24f 100644 --- a/hw/block/nvme.c +++ b/hw/block/nvme.c @@ -1175,16 +1175,13 @@ static void nvme_cmb_write(void *opaque, hwaddr add= r, uint64_t data, unsigned size) { NvmeCtrl *n =3D (NvmeCtrl *)opaque; - memcpy(&n->cmbuf[addr], &data, size); + stn_le_p(&n->cmbuf[addr], size, data); } =20 static uint64_t nvme_cmb_read(void *opaque, hwaddr addr, unsigned size) { - uint64_t val; NvmeCtrl *n =3D (NvmeCtrl *)opaque; - - memcpy(&val, &n->cmbuf[addr], size); - return val; + return ldn_le_p(&n->cmbuf[addr], size); } =20 static const MemoryRegionOps nvme_cmb_ops =3D { --=20 2.19.1