From nobody Mon Nov 17 09:46:54 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1603814655; cv=none; d=zohomail.com; s=zohoarc; b=RC/WXIcKXodE32l/n3uu1ZtBJdqLSCJ3fQETbVMrbFvb5XuNaPIGTXSBY5TvBdexZxrxba2qVRh/TsPz6YTYAWuQcAfMMJrWrB3zHbcNmtj1gTL3XxARqxvsPWxjYcVAt4WLfpVCPDjzNO+3LI1lifCYvdTl33PM+B9B4AVo8nc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603814655; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:MIME-Version:Message-ID:Subject:To; bh=fxbpQEAHbX0or96GM6hC5X/mct/rAasK8lB74c4iv5g=; b=Wykm3LBmbKc6KuOWgiG4KqZXQAK6VNBJ3GxVPsGIzJ3VtScY2LmrFPVprmtBDmIbHHTrw5WHReBph6pjs57xinNbGkIf6LeVpoc0omwLrXKDfjtwChROmbH02SUAfsQ6hDfViNtb6kqkBkFIAYH0wGS7hiPO8rzfTgBaKq1vswY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 160381465499755.87063325195868; Tue, 27 Oct 2020 09:04:14 -0700 (PDT) Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-232-L3n8suv1MS-n1ifs3hc_oQ-1; Tue, 27 Oct 2020 12:04:11 -0400 Received: by mail-ej1-f70.google.com with SMTP id p19so1050859ejy.11 for ; Tue, 27 Oct 2020 09:04:11 -0700 (PDT) Return-Path: Return-Path: Received: from x1w.redhat.com (237.red-88-18-140.staticip.rima-tde.net. [88.18.140.237]) by smtp.gmail.com with ESMTPSA id u2sm1261486edr.70.2020.10.27.09.04.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Oct 2020 09:04:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603814653; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=fxbpQEAHbX0or96GM6hC5X/mct/rAasK8lB74c4iv5g=; b=EVXvaw2+ntEsqVzAMMPaER6drU9XMDq2ogdedktlI5gRGbLXZWz7byywg0U0nMmnhLa14y Nfz+W27/6MTGhCxVrZBrGQjomuL0RIRh9uRF5+vtPxhM1TDO3CVyjblduSLqbV0pL0hX+5 1tHjNJlPhWZYHq0JO/OIJhiRycNCzkU= X-MC-Unique: L3n8suv1MS-n1ifs3hc_oQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=fxbpQEAHbX0or96GM6hC5X/mct/rAasK8lB74c4iv5g=; b=kKoqPeXPT8rcSrWWtK/0eOo/3f8O6KTfXdK3/VAIgAtPkvaEQvbU5WKZDmdi7qEUv/ Sd3LPYgIQVvXV6QUqTjpkSZ8xLkgAPNjoQbbMeVV/iKlJohOlcxaE0Cb8h7oyVbtsmBb MqNa1whPAWmfw+BgL+pWkBn+cidxidiJWzfaHEgV9trNaNVaoQWVgmSLUESDp1GKPbtE n8MVTUtOE1tX2qq5okGyaedxHmdjsoTjAtFYTicIIPZ/VXh/Kbm8Da7Was0DvlQ0hvyb oL4ZmWPWL8FCm1wrV47mrKVgALlQXWK2x5kfg/vHotklYInrj+PIOIs7AhRvVojT8EL9 grwQ== X-Gm-Message-State: AOAM531jmU67EWQfyp36TuzF1JPaDru9fpNc6GgQCAt8pmgKEfW7Nssr FA4K5zMQRdVXEYw3wRJ4QlTJdeOMoKu9mOMae2n4CXr9djR2SY0vQ0xXObzBUjoeV6LZeG7y889 GR0Dv/wx3/aqdyg== X-Received: by 2002:a17:906:715a:: with SMTP id z26mr3104411ejj.300.1603814650068; Tue, 27 Oct 2020 09:04:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyCpWNAoohzquAZWXz2B+4CFzZ4g/AL9GzaiTeQwT58v/d+X/sdCVtZJKxpc52fg0lZAxrEqA== X-Received: by 2002:a17:906:715a:: with SMTP id z26mr3104396ejj.300.1603814649868; Tue, 27 Oct 2020 09:04:09 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Stefan Hajnoczi , Max Reitz , Eric Auger , Klaus Jensen , Kevin Wolf , Fam Zheng , qemu-block@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Keith Busch Subject: [PATCH-for-5.2] block/nvme: Fix nvme_submit_command() on big-endian host Date: Tue, 27 Oct 2020 17:04:07 +0100 Message-Id: <20201027160407.418423-1-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) The Completion Queue Command Identifier is a 16-bit value, so nvme_submit_command() is unlikely to work on big-endian hosts, as the relevant bits are truncated. The "Completion Queue Entry: DW 2" describes it as: This identifier is assigned by host software when the command is submitted to the Submission As the is just an opaque cookie, it is pointless to byte-swap it. Fixes: bdd6a90a9e5 ("block: Add VFIO based NVMe driver") Reported-by: Keith Busch Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- Based-on: <20201027135547.374946-1-philmd@redhat.com> --- block/nvme.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/block/nvme.c b/block/nvme.c index ff645eefe6a..d9b2245db40 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -343,7 +343,7 @@ static inline int nvme_translate_error(const NvmeCqe *c) trace_nvme_error(le32_to_cpu(c->result), le16_to_cpu(c->sq_head), le16_to_cpu(c->sq_id), - le16_to_cpu(c->cid), + c->cid, le16_to_cpu(status)); } switch (status) { @@ -400,7 +400,7 @@ static bool nvme_process_completion(NVMeQueuePair *q) if (!q->cq.head) { q->cq_phase =3D !q->cq_phase; } - cid =3D le16_to_cpu(c->cid); + cid =3D c->cid; if (cid =3D=3D 0 || cid > NVME_QUEUE_SIZE) { warn_report("NVMe: Unexpected CID in completion queue: %"PRIu3= 2", " "queue size: %u", cid, NVME_QUEUE_SIZE); @@ -468,7 +468,7 @@ static void nvme_submit_command(NVMeQueuePair *q, NVMeR= equest *req, assert(!req->cb); req->cb =3D cb; req->opaque =3D opaque; - cmd->cid =3D cpu_to_le32(req->cid); + cmd->cid =3D req->cid; =20 trace_nvme_submit_command(q->s, q->index, req->cid); nvme_trace_command(cmd); --=20 2.26.2