diff options
| author | Michael Biebl <biebl@debian.org> | 2020-10-08 11:30:00 +0200 |
|---|---|---|
| committer | Michael Biebl <biebl@debian.org> | 2020-10-08 11:30:14 +0200 |
| commit | 33cdf7346d8934377fe45441b54f0ff6d8635d8d (patch) | |
| tree | e19eb87f6fea8c949b39b8f2e2091b9618d2b5f8 | |
| parent | 94990fefa3430d3ec0487f18ec71f2c6527a9def (diff) | |
Cherry-pick a couple of upstream patches
Hopefully fixes the build and test-suite failures on some of the more exotic architectures.
6 files changed, 277 insertions, 0 deletions
diff --git a/debian/patches/c-rbtree-reduce-alignment-constraints.patch b/debian/patches/c-rbtree-reduce-alignment-constraints.patch new file mode 100644 index 00000000..787e3097 --- /dev/null +++ b/debian/patches/c-rbtree-reduce-alignment-constraints.patch @@ -0,0 +1,92 @@ +From: David Rheinsberg <david.rheinsberg@gmail.com> +Date: Wed, 7 Oct 2020 15:54:15 +0200 +Subject: c-rbtree: reduce alignment constraints + +There are some Debian-supported architectures where `max_align_t` is +only aligned to 4-bytes. This is unfortunate and breaks our assumptions. +While glibc-malloc still guarantees 8 / 16 bytes alignment, this is not +necessarily guaranteed by the C standard (and alternative allocators +will deviate (see jemalloc, for instance)). + +Fortunately, we only need 2 flags, so a 4-byte alignment is more than +enough. + +Reported-by: Thomas Haller +Signed-off-by: David Rheinsberg <david.rheinsberg@gmail.com> + +https://github.com/c-util/c-rbtree/pull/4 +(cherry picked from commit 1554936e33718c1a4deea590217e2c19ea6f80de) +(cherry picked from commit 282fac4afbe2ebdf95a9f0210aa8bd745061e8d2) +--- + shared/c-rbtree/src/c-rbtree.c | 14 ++++++++------ + shared/c-rbtree/src/c-rbtree.h | 8 +++----- + 2 files changed, 11 insertions(+), 11 deletions(-) + +diff --git a/shared/c-rbtree/src/c-rbtree.c b/shared/c-rbtree/src/c-rbtree.c +index aacdcc2..2f0e608 100644 +--- a/shared/c-rbtree/src/c-rbtree.c ++++ b/shared/c-rbtree/src/c-rbtree.c +@@ -31,15 +31,17 @@ + #include "c-rbtree-private.h" + + /* +- * We use alignas(8) to enforce 64bit alignment of structure fields. This is +- * according to ISO-C11, so we rely on the compiler to implement this. However, +- * at the same time we don't want to exceed native malloc() alignment on target +- * platforms. Hence, we also verify against max_align_t. ++ * We use the lower 2 bits of CRBNode pointers to store flags. Make sure ++ * CRBNode is 4-byte aligned, so the lower 2 bits are actually unused. We also ++ * sometimes store a pointer to the root-node, so make sure this one is also 4 ++ * byte aligned. ++ * Note that there are actually some architectures where `max_align_t` is 4, so ++ * we do not have much wiggle-room to extend this flag-set. + */ + static_assert(alignof(CRBNode) <= alignof(max_align_t), "Invalid RBNode alignment"); +-static_assert(alignof(CRBNode) >= 8, "Invalid CRBNode alignment"); ++static_assert(alignof(CRBNode) >= 4, "Invalid CRBNode alignment"); + static_assert(alignof(CRBTree) <= alignof(max_align_t), "Invalid RBTree alignment"); +-static_assert(alignof(CRBTree) >= 8, "Invalid CRBTree alignment"); ++static_assert(alignof(CRBTree) >= 4, "Invalid CRBTree alignment"); + + /** + * c_rbnode_leftmost() - return leftmost child +diff --git a/shared/c-rbtree/src/c-rbtree.h b/shared/c-rbtree/src/c-rbtree.h +index cb33fcf..a9bbce5 100644 +--- a/shared/c-rbtree/src/c-rbtree.h ++++ b/shared/c-rbtree/src/c-rbtree.h +@@ -27,7 +27,6 @@ extern "C" { + #endif + + #include <assert.h> +-#include <stdalign.h> + #include <stddef.h> + + typedef struct CRBNode CRBNode; +@@ -36,8 +35,7 @@ typedef struct CRBTree CRBTree; + /* implementation detail */ + #define C_RBNODE_RED (0x1UL) + #define C_RBNODE_ROOT (0x2UL) +-#define C_RBNODE_UNUSED3 (0x4UL) +-#define C_RBNODE_FLAG_MASK (0x7UL) ++#define C_RBNODE_FLAG_MASK (0x3UL) + + /** + * struct CRBNode - Node of a Red-Black Tree +@@ -60,7 +58,7 @@ typedef struct CRBTree CRBTree; + * C_RBNODE_INIT. + */ + struct CRBNode { +- alignas(8) unsigned long __parent_and_flags; ++ unsigned long __parent_and_flags; + CRBNode *left; + CRBNode *right; + }; +@@ -90,7 +88,7 @@ void c_rbnode_unlink_stale(CRBNode *n); + * To initialize an RB-Tree, set it to NULL / all zero. + */ + struct CRBTree { +- alignas(8) CRBNode *root; ++ CRBNode *root; + }; + + #define C_RBTREE_INIT {} diff --git a/debian/patches/platform-tests-adjust-regeneration-of-test-code-for-test_.patch b/debian/patches/platform-tests-adjust-regeneration-of-test-code-for-test_.patch new file mode 100644 index 00000000..941204a3 --- /dev/null +++ b/debian/patches/platform-tests-adjust-regeneration-of-test-code-for-test_.patch @@ -0,0 +1,39 @@ +From: Thomas Haller <thaller@redhat.com> +Date: Wed, 7 Oct 2020 08:39:56 +0200 +Subject: platform/tests: adjust regeneration of test code for + test_platform_ip_address_pretty_sort_cmp() + +Since re-formatting our source code, the generated output no longer +matched the required formatting. Adjust it. + +(cherry picked from commit 4fc79734985f661c7c28c56a558f00a795b9abf3) +(cherry picked from commit 07868a535f2454a7bdc7d1af9b96d8686d9f7dca) +--- + src/platform/tests/test-platform-general.c | 10 ++++++---- + 1 file changed, 6 insertions(+), 4 deletions(-) + +diff --git a/src/platform/tests/test-platform-general.c b/src/platform/tests/test-platform-general.c +index f98f84c..aca4413 100644 +--- a/src/platform/tests/test-platform-general.c ++++ b/src/platform/tests/test-platform-general.c +@@ -692,14 +692,16 @@ test_platform_ip_address_pretty_sort_cmp(gconstpointer test_data) + } + + if (PRINT_RESULT) { +- g_print("\n\n\t\t[%d] = (\n", TEST_DATA_I); ++ g_print("\n [%d] = (", TEST_DATA_I); + for (i = 0; i < ELM_SIZE * N_ADDRESSES;) { +- g_print("\t\t\t\""); ++ if (i > 0) ++ g_print("\n "); ++ g_print("\""); + for (j = 0; j < 40 && i < ELM_SIZE * N_ADDRESSES; j++, i++) + g_print("%02x", addresses[i]); +- g_print("\"\n"); ++ g_print("\""); + } +- g_print("\t\t),\n\n"); ++ g_print("),\n"); + return; + } + diff --git a/debian/patches/platform-tests-print-details-about-test-failure-for-test_.patch b/debian/patches/platform-tests-print-details-about-test-failure-for-test_.patch new file mode 100644 index 00000000..63a980be --- /dev/null +++ b/debian/patches/platform-tests-print-details-about-test-failure-for-test_.patch @@ -0,0 +1,38 @@ +From: Thomas Haller <thaller@redhat.com> +Date: Wed, 7 Oct 2020 09:00:41 +0200 +Subject: platform/tests: print details about test failure for + test_platform_ip_address_pretty_sort_cmp() + +When the test is about to fail, print the wrong data to help debugging +the test failure. + +(cherry picked from commit 3576f541003106fb4ba7b41138a57f8e4a6e7d18) +(cherry picked from commit 36ccbcc550a981688eee6a83bfc55324cdd0c874) +--- + src/platform/tests/test-platform-general.c | 13 +++++++++++++ + 1 file changed, 13 insertions(+) + +diff --git a/src/platform/tests/test-platform-general.c b/src/platform/tests/test-platform-general.c +index aca4413..ee1e247 100644 +--- a/src/platform/tests/test-platform-general.c ++++ b/src/platform/tests/test-platform-general.c +@@ -715,6 +715,19 @@ test_platform_ip_address_pretty_sort_cmp(gconstpointer test_data) + NULL, + 0, + &bin_len); ++ ++ if (bin_len != ELM_SIZE * N_ADDRESSES || memcmp(addresses, bin_arr, bin_len) != 0) { ++ char *addresses_str = nm_utils_bin2hexstr(addresses, ELM_SIZE * N_ADDRESSES, -1); ++ ++ g_error(">>> test_platform_ip_address_pretty_sort_cmp() will fail:\n" ++ ">>> addresses[%zu]: %s\n" ++ ">>> expected [%zu]: %s\n", ++ ELM_SIZE * N_ADDRESSES, ++ addresses_str, ++ bin_len, ++ EXPECTED_BUFFER[TEST_DATA_I]); ++ } ++ + g_assert_cmpmem(addresses, ELM_SIZE * N_ADDRESSES, bin_arr, bin_len); + } + } diff --git a/debian/patches/platform-tests-skip-test_platform_ip_address_pretty_sort_.patch b/debian/patches/platform-tests-skip-test_platform_ip_address_pretty_sort_.patch new file mode 100644 index 00000000..71376190 --- /dev/null +++ b/debian/patches/platform-tests-skip-test_platform_ip_address_pretty_sort_.patch @@ -0,0 +1,40 @@ +From: Thomas Haller <thaller@redhat.com> +Date: Wed, 7 Oct 2020 09:08:57 +0200 +Subject: platform/tests: skip test_platform_ip_address_pretty_sort_cmp() on + non-amd64 archs + +The test only works on amd64, because it relies on the memory layout of +the structures. + +https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/546 +(cherry picked from commit 6cf7c6739f670bb8ae2e1b8cbc56c789a0b0ae0d) +(cherry picked from commit b569687f5f363fa83f2518c97d51abce5a518b64) +--- + src/platform/tests/test-platform-general.c | 14 ++++++++++++++ + 1 file changed, 14 insertions(+) + +diff --git a/src/platform/tests/test-platform-general.c b/src/platform/tests/test-platform-general.c +index ee1e247..703c886 100644 +--- a/src/platform/tests/test-platform-general.c ++++ b/src/platform/tests/test-platform-general.c +@@ -555,6 +555,20 @@ test_platform_ip_address_pretty_sort_cmp(gconstpointer test_data) + gs_free guint64 *rand_map = NULL; + gsize i, j; + ++#if !defined(__amd64__) ++ /* The test generates a random array of NMPlatformIPXAddress (by crudely randomizing the memory, ++ * not the structures themself) and then compares the sorted result with the expected output. ++ * The sole purpose is to ensure that the sorting order stays stable. ++ * ++ * This only works on an architecture for which the test was made, otherwise ++ * the expected data does not match (due to different layout of the structures ++ * in memory). ++ * ++ * That's fine. Skip the test. */ ++ g_test_skip("skip test on non-amd64 architecture"); ++ return; ++#endif ++ + /* + * First we create a list of addresses filled with (stable) random bytes. + * We tweak some fields explicitly (stable randomly), so that we cover all diff --git a/debian/patches/series b/debian/patches/series index a2d7e06d..117a27db 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -1 +1,6 @@ Force-online-state-with-unmanaged-devices.patch +platform-tests-adjust-regeneration-of-test-code-for-test_.patch +platform-tests-print-details-about-test-failure-for-test_.patch +platform-tests-skip-test_platform_ip_address_pretty_sort_.patch +c-rbtree-reduce-alignment-constraints.patch +systemd-basic-missing_syscall-fix-syscall-numbers-for-mip.patch diff --git a/debian/patches/systemd-basic-missing_syscall-fix-syscall-numbers-for-mip.patch b/debian/patches/systemd-basic-missing_syscall-fix-syscall-numbers-for-mip.patch new file mode 100644 index 00000000..6acf5aa2 --- /dev/null +++ b/debian/patches/systemd-basic-missing_syscall-fix-syscall-numbers-for-mip.patch @@ -0,0 +1,63 @@ +From: Michael Biebl <biebl@debian.org> +Date: Wed, 7 Oct 2020 17:44:05 +0200 +Subject: systemd: basic/missing_syscall: fix syscall numbers for mips* + +Thanks Christian Brauner @brauner + +https://github.com/systemd/systemd/commit/cd2065989163a5b6f71c8f1e4a8d73f1be63a52b + +https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/545 +(cherry picked from commit e9c6561ffade614e9341769b5e37a9d0436e693b) +(cherry picked from commit dfd54b7f2eb65f9d4909d501c1ec9ff5333e170e) +--- + shared/systemd/src/basic/missing_syscall.h | 28 ++++++++++++++++++++++++++-- + 1 file changed, 26 insertions(+), 2 deletions(-) + +diff --git a/shared/systemd/src/basic/missing_syscall.h b/shared/systemd/src/basic/missing_syscall.h +index 4aed6e7..d11a77d 100644 +--- a/shared/systemd/src/basic/missing_syscall.h ++++ b/shared/systemd/src/basic/missing_syscall.h +@@ -632,8 +632,20 @@ static inline long missing_get_mempolicy(int *mode, unsigned long *nodemask, + /* ======================================================================= */ + + /* should be always defined, see kernel 39036cd2727395c3369b1051005da74059a85317 */ +-#if defined(__alpha__) ++#if defined __alpha__ + # define systemd_NR_pidfd_send_signal 534 ++#elif defined _MIPS_SIM ++# if _MIPS_SIM == _MIPS_SIM_ABI32 /* o32 */ ++# define systemd_NR_pidfd_send_signal (424 + 4000) ++# endif ++# if _MIPS_SIM == _MIPS_SIM_NABI32 /* n32 */ ++# define systemd_NR_pidfd_send_signal (424 + 6000) ++# endif ++# if _MIPS_SIM == _MIPS_SIM_ABI64 /* n64 */ ++# define systemd_NR_pidfd_send_signal (424 + 5000) ++# endif ++#elif defined __ia64__ ++# define systemd_NR_pidfd_send_signal (424 + 1024) + #else + # define systemd_NR_pidfd_send_signal 424 + #endif +@@ -664,8 +676,20 @@ static inline int missing_pidfd_send_signal(int fd, int sig, siginfo_t *info, un + #endif + + /* should be always defined, see kernel 7615d9e1780e26e0178c93c55b73309a5dc093d7 */ +-#if defined(__alpha__) ++#if defined __alpha__ + # define systemd_NR_pidfd_open 544 ++#elif defined _MIPS_SIM ++# if _MIPS_SIM == _MIPS_SIM_ABI32 /* o32 */ ++# define systemd_NR_pidfd_open (434 + 4000) ++# endif ++# if _MIPS_SIM == _MIPS_SIM_NABI32 /* n32 */ ++# define systemd_NR_pidfd_open (434 + 6000) ++# endif ++# if _MIPS_SIM == _MIPS_SIM_ABI64 /* n64 */ ++# define systemd_NR_pidfd_open (434 + 5000) ++# endif ++#elif defined __ia64__ ++# define systemd_NR_pidfd_open (434 + 1024) + #else + # define systemd_NR_pidfd_open 434 + #endif |