Package: libnvme
Version: 1.2-1
Severity: serious
Tags: patch ftbfs
Justification: fails to build from source (but built successfully in the past)
User: ubuntu-de...@lists.ubuntu.com
Usertags: origin-ubuntu lunar ubuntu-patch
X-Debbugs-Cc: bdr...@debian.org

Dear Maintainer,

libnvme fails to build on big endian systems (e.g. s390x). I forwarded
the bug upstream and they fixed. Please apply the fix (see attachement).

Thanks for considering the patch.

-- 
Benjamin Drung
Debian & Ubuntu Developer
diff -Nru libnvme-1.2/debian/patches/mi-endian-fixes.patch 
libnvme-1.2/debian/patches/mi-endian-fixes.patch
--- libnvme-1.2/debian/patches/mi-endian-fixes.patch    1970-01-01 
01:00:00.000000000 +0100
+++ libnvme-1.2/debian/patches/mi-endian-fixes.patch    2022-11-10 
16:24:08.000000000 +0100
@@ -0,0 +1,61 @@
+From ac657355bc86b71e1d2d8dd6079d5d69332dedaa Mon Sep 17 00:00:00 2001
+From: Jeremy Kerr <j...@codeconstruct.com.au>
+Date: Thu, 10 Nov 2022 12:20:37 +0800
+Subject: [PATCH] mi: endian fixes
+
+We have a couple of endian issues in the mi code: one where we're not
+converting cdw0 for MI commands, and one where we're using the wrong
+byte length for an existing conversion. There is also an error in the
+test suite, where we should be converting the nsze field of a
+nvme_id_ns.
+
+This change fixes those, so that the test suite passes on a BE platform
+(ppc64 in my case).
+
+Fixes: https://github.com/linux-nvme/libnvme/issues/524
+Signed-off-by: Jeremy Kerr <j...@codeconstruct.com.au>
+Bug-Ubuntu: https://launchpad.net/bugs/1995935
+Origin: https://github.com/linux-nvme/libnvme/pull/529
+---
+ src/nvme/mi.c | 4 ++--
+ test/mi.c     | 2 +-
+ 2 files changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/src/nvme/mi.c b/src/nvme/mi.c
+index cd86e41..1a34208 100644
+--- a/src/nvme/mi.c
++++ b/src/nvme/mi.c
+@@ -139,7 +139,7 @@ int nvme_mi_scan_ep(nvme_mi_ep_t ep, bool force_rescan)
+               struct nvme_mi_ctrl *ctrl;
+               __u16 id;
+ 
+-              id = le32_to_cpu(list.identifier[i]);
++              id = le16_to_cpu(list.identifier[i]);
+               if (!id)
+                       continue;
+ 
+@@ -985,7 +985,7 @@ static int nvme_mi_read_data(nvme_mi_ep_t ep, __u32 cdw0,
+       req_hdr.hdr.nmp = (NVME_MI_ROR_REQ << 7) |
+               (NVME_MI_MT_MI << 3); /* we always use command slot 0 */
+       req_hdr.opcode = nvme_mi_mi_opcode_mi_data_read;
+-      req_hdr.cdw0 = cdw0;
++      req_hdr.cdw0 = cpu_to_le32(cdw0);
+ 
+       memset(&req, 0, sizeof(req));
+       req.hdr = &req_hdr.hdr;
+diff --git a/test/mi.c b/test/mi.c
+index 102cea9..4c7f1f2 100644
+--- a/test/mi.c
++++ b/test/mi.c
+@@ -1287,7 +1287,7 @@ static void test_admin_ns_mgmt_create(struct nvme_mi_ep 
*ep)
+       assert(!rc);
+       assert(ns == 0x01020304);
+ 
+-      nsid.nsze = 42;
++      nsid.nsze = cpu_to_le64(42);
+       rc = nvme_mi_admin_ns_mgmt_create(ctrl, &nsid, 0, &ns);
+       assert(rc);
+ }
+-- 
+2.37.2
+
diff -Nru libnvme-1.2/debian/patches/series libnvme-1.2/debian/patches/series
--- libnvme-1.2/debian/patches/series   1970-01-01 01:00:00.000000000 +0100
+++ libnvme-1.2/debian/patches/series   2022-11-10 16:20:16.000000000 +0100
@@ -0,0 +1 @@
+mi-endian-fixes.patch

Reply via email to