All of lore.kernel.org
 help / color / mirror / Atom feed
From: Michael Holzheu <holzheu@linux.vnet.ibm.com>
To: linux-s390@vger.kernel.org
Subject: [CRIU][PATCH 5/7] zdtm/static/sk-netlink: Fix endian issue
Date: Wed, 28 Jun 2017 16:12:03 +0000	[thread overview]
Message-ID: <20170628161205.37787-6-holzheu@linux.vnet.ibm.com> (raw)

On x86 sk->groups[1] contains the most significant bits. On s390 it
contains the least significant bits. Therefore on x86 for groups below 32
sk->groups[1] is zero and on s390 it contains 0x80000000 for the testcase.

As workaround swap sk->groups[0/1] for big-endian systems.

Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
---
 criu/sk-netlink.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/criu/sk-netlink.c b/criu/sk-netlink.c
index 44982a1..bfa6831 100644
--- a/criu/sk-netlink.c
+++ b/criu/sk-netlink.c
@@ -107,6 +107,22 @@ static int dump_one_netlink_fd(int lfd, u32 id, const struct fd_parms *p)
 		 * On 64-bit sk->gsize is multiple to 8 bytes (sizeof(long)),
 		 * so remove the last 4 bytes if they are empty.
 		 */
+#ifdef __ORDER_BIG_ENDIAN__
+		/*
+		 * Big endian swap: Ugly hack for zdtm/static/sk-netlink
+		 *
+		 * For big endian systems:
+		 *
+		 * - sk->groups[0] are bits 32-64
+		 * - sk->groups[1] are bits 0-32
+		 */
+		if (ne.n_groups == 2) {
+			uint32_t tmp = sk->groups[1];
+
+			sk->groups[1] = sk->groups[0];
+			sk->groups[0] = tmp;
+		}
+#endif
 		if (ne.n_groups && sk->groups[ne.n_groups - 1] == 0)
 			ne.n_groups -= 1;
 
-- 
2.7.4

                 reply	other threads:[~2017-06-28 16:12 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170628161205.37787-6-holzheu@linux.vnet.ibm.com \
    --to=holzheu@linux.vnet.ibm.com \
    --cc=linux-s390@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.