Skip to contentSkip to conversation

Fix ABI incompatibility between Qemu-aarch64 and Linux Kernel in signal handling.

PATCH Maxim Ostapenko 2 participants 4 messages Feb 2, 2015 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

Sorry, missed ML.

-Maxim

Quoted 36 lines · Maxim Ostapenko

Hi,

this patch fixes https://bugs.launchpad.net/qemu/+bug/1416988.

There is a small ABI incompatibility between Qemu-aarch64 and Linux Kernel 3.19 caused by wrong size of struct target_siginfo in Qemu. This tiny patch fixes the issue.

-Maxim

From 1d662e325d004bce2d640cfea5b337c92c7feca2 Mon Sep 17 00:00:00 2001
From: Max Ostapenko <[email protected]>
Date: Mon, 2 Feb 2015 12:03:20 +0400
Subject: [PATCH] linux-user: wrong TARGET_SI_PAD_SIZE value for some targets.

Fix TARGET_SI_PAD_SIZE for S390X, SPARC, ALPHA and AARCH64 to correspond Linux Kernel 3.19 c59c961ca511dc7ee2f4f7e9c224d16f5c76ca6e revision.

---
 linux-user/syscall_defs.h | 5 +++++
 1 file changed, 5 insertions(+)
linux-user/syscall_defs.h +5 -0
index ebb3be1..b95a0b2 100644
@@ -655,7 +655,12 @@ typedef struct {
 #endif
 
 #define TARGET_SI_MAX_SIZE    128
+#if defined(TARGET_S390X) || defined(TARGET_SPARC) \
+   || defined(TARGET_ALPHA) || defined(TARGET_AARCH64)
+#define TARGET_SI_PAD_SIZE    ((TARGET_SI_MAX_SIZE/sizeof(int)) - 4)
+#else
 #define TARGET_SI_PAD_SIZE    ((TARGET_SI_MAX_SIZE/sizeof(int)) - 3)
+#endif
 
 typedef struct target_siginfo {
 #ifdef TARGET_MIPS
#2 lore raw
Quoted 1 line · Maxim Ostapenko

Sorry, missed ML.

You missed qemu-devel as well :-)

Quoted 12 lines · Maxim Ostapenko
Quoted 11 lines

Hi,

this patch fixes https://bugs.launchpad.net/qemu/+bug/1416988.

There is a small ABI incompatibility between Qemu-aarch64 and Linux Kernel 3.19 caused by wrong size of struct target_siginfo in Qemu. This tiny patch fixes the issue.

-Maxim

Quoted 8 lines
Quoted 8 lines

From 1d662e325d004bce2d640cfea5b337c92c7feca2 Mon Sep 17 00:00:00 2001
From: Max Ostapenko <[email protected]>
Date: Mon, 2 Feb 2015 12:03:20 +0400
Subject: [PATCH] linux-user: wrong TARGET_SI_PAD_SIZE value for some targets.

Fix TARGET_SI_PAD_SIZE for S390X, SPARC, ALPHA and AARCH64 to correspond Linux Kernel 3.19 c59c961ca511dc7ee2f4f7e9c224d16f5c76ca6e revision.

Thanks for this patch. I'm afraid that to apply it we need a
Signed-off-by: line from you that certifies that you're OK to contribute it. (This is the same as Linux kernel patches; see the "Patch emails must include a Signed-off-by: line" section in
http://wiki.qemu.org/Contribute/SubmitAPatch ).

Quoted 11 lines
Quoted 11 lines
---
 linux-user/syscall_defs.h | 5 +++++
 1 file changed, 5 insertions(+)
linux-user/syscall_defs.h +0 -0
index ebb3be1..b95a0b2 100644
@@ -655,7 +655,12 @@ typedef struct {
 #endif
 
Quoted 3 lines

linux-user/syscall_defs.h typedef struct { · line 659

Quoted 3 lines
linux-user/syscall_defs.h +2 -0
 #define TARGET_SI_MAX_SIZE    128
+#if defined(TARGET_S390X) || defined(TARGET_SPARC) \
+   || defined(TARGET_ALPHA) || defined(TARGET_AARCH64)

I don't think this ifdef is correct. For instance for sparc the kernel defines things differently for 32 and 64 bit.

In fact as far as I can tell for all architectures the kernel defines __ARCH_SI_PREAMBLE_SIZE to (4 * sizeof(int)) for 64 bit and (3 * sizeof(int)) for 32 bit.

Quoted 4 lines

linux-user/syscall_defs.h typedef struct { · line 663

Quoted 4 lines
linux-user/syscall_defs.h +3 -0
+#define TARGET_SI_PAD_SIZE    ((TARGET_SI_MAX_SIZE/sizeof(int)) - 4)
+#else
 #define TARGET_SI_PAD_SIZE    ((TARGET_SI_MAX_SIZE/sizeof(int)) - 3)
+#endif

So I would suggest

#if TARGET_ABI_BITS == 32
#define TARGET_SI_PREAMBLE_SIZE (3 * sizeof(int)) #else
#define TARGET_SI_PREAMBLE_SIZE (4 * sizeof(int)) #endif

#define TARGET_SI_PAD_SIZE ((TARGET_SI_MAX_SIZE - TARGET_SI_PREAMBLE_SIZE) / sizeof(int))

which should give us the correct answer for all archs and configurations (including I think the 32-bit-on-64-bit setups like sparc32plus). It also rephrases the calculation to match what the kernel uses.

thanks
-- PMM

#3 lore raw

Peter,

thank you for review and sorry for sign. I've updated the patch, is it ok now?

From 5b035df58f9f17e64b35311b6b5f55097c7f8ce1 Mon Sep 17 00:00:00 2001
From: Max Ostapenko <[email protected]>
Date: Mon, 2 Feb 2015 12:03:20 +0400
Subject: [PATCH] linux-user: wrong TARGET_SI_PAD_SIZE value for some targets.

Fix TARGET_SI_PAD_SIZE for S390X, SPARC, ALPHA and AARCH64 according to Linux Kernel 3.19 c59c961ca511dc7ee2f4f7e9c224d16f5c76ca6e revision.

---
 linux-user/syscall_defs.h | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
linux-user/syscall_defs.h +8 -1
index ebb3be1..9ed6de8 100644
@@ -655,7 +655,14 @@ typedef struct {
 #endif
 
 #define TARGET_SI_MAX_SIZE     128
-#define TARGET_SI_PAD_SIZE     ((TARGET_SI_MAX_SIZE/sizeof(int)) - 3)
+
+#if TARGET_ABI_BITS == 32
+#define TARGET_SI_PREAMBLE_SIZE (3 * sizeof(int))
+#else
+#define TARGET_SI_PREAMBLE_SIZE (4 * sizeof(int))
+#endif
+
+#define TARGET_SI_PAD_SIZE ((TARGET_SI_MAX_SIZE - TARGET_SI_PREAMBLE_SIZE) / sizeof(int))
 
 typedef struct target_siginfo {
 #ifdef TARGET_MIPS
Signature · 4 lines
Signed-off-by: Maxim Ostapenko <[email protected]>
1.8.5.2.2930.gf745acb

-Maxim
Quoted 74 lines · Peter Maydell
Quoted 1 line · Maxim Ostapenko

Sorry, missed ML.

You missed qemu-devel as well :-)

Quoted 11 lines · Maxim Ostapenko
Quoted 10 lines

Hi,

this patch fixes https://bugs.launchpad.net/qemu/+bug/1416988.

There is a small ABI incompatibility between Qemu-aarch64 and Linux Kernel 3.19 caused by wrong size of struct target_siginfo in Qemu. This tiny patch fixes the issue.

-Maxim

Quoted 8 lines
Quoted 8 lines

From 1d662e325d004bce2d640cfea5b337c92c7feca2 Mon Sep 17 00:00:00 2001
From: Max Ostapenko <[email protected]>
Date: Mon, 2 Feb 2015 12:03:20 +0400
Subject: [PATCH] linux-user: wrong TARGET_SI_PAD_SIZE value for some targets.

Fix TARGET_SI_PAD_SIZE for S390X, SPARC, ALPHA and AARCH64 to correspond Linux Kernel 3.19 c59c961ca511dc7ee2f4f7e9c224d16f5c76ca6e revision.

Thanks for this patch. I'm afraid that to apply it we need a
Signed-off-by: line from you that certifies that you're OK to contribute it. (This is the same as Linux kernel patches; see the "Patch emails must include a Signed-off-by: line" section in
http://wiki.qemu.org/Contribute/SubmitAPatch ).

Quoted 11 lines
Quoted 11 lines
---
  linux-user/syscall_defs.h | 5 +++++
  1 file changed, 5 insertions(+)
linux-user/syscall_defs.h +0 -0
index ebb3be1..b95a0b2 100644
@@ -655,7 +655,12 @@ typedef struct {
  #endif
 
Quoted 3 lines

linux-user/syscall_defs.h typedef struct { · line 659

Quoted 3 lines
linux-user/syscall_defs.h +2 -0
  #define TARGET_SI_MAX_SIZE    128
+#if defined(TARGET_S390X) || defined(TARGET_SPARC) \
+   || defined(TARGET_ALPHA) || defined(TARGET_AARCH64)

I don't think this ifdef is correct. For instance for sparc the kernel defines things differently for 32 and 64 bit.

In fact as far as I can tell for all architectures the kernel defines __ARCH_SI_PREAMBLE_SIZE to (4 * sizeof(int)) for 64 bit and (3 * sizeof(int)) for 32 bit.

Quoted 4 lines

linux-user/syscall_defs.h typedef struct { · line 663

Quoted 4 lines
linux-user/syscall_defs.h +3 -0
+#define TARGET_SI_PAD_SIZE    ((TARGET_SI_MAX_SIZE/sizeof(int)) - 4)
+#else
  #define TARGET_SI_PAD_SIZE    ((TARGET_SI_MAX_SIZE/sizeof(int)) - 3)
+#endif

So I would suggest

#if TARGET_ABI_BITS == 32
#define TARGET_SI_PREAMBLE_SIZE (3 * sizeof(int)) #else
#define TARGET_SI_PREAMBLE_SIZE (4 * sizeof(int)) #endif

#define TARGET_SI_PAD_SIZE ((TARGET_SI_MAX_SIZE - TARGET_SI_PREAMBLE_SIZE) / sizeof(int))

which should give us the correct answer for all archs and configurations (including I think the 32-bit-on-64-bit setups like sparc32plus). It also rephrases the calculation to match what the kernel uses.

thanks
-- PMM

#4 lore raw
Quoted 4 lines · Maxim Ostapenko

Peter,

thank you for review and sorry for sign. I've updated the patch, is it ok now?

The code looks ok, but...

Quoted 8 lines

From 5b035df58f9f17e64b35311b6b5f55097c7f8ce1 Mon Sep 17 00:00:00 2001
From: Max Ostapenko <[email protected]>
Date: Mon, 2 Feb 2015 12:03:20 +0400
Subject: [PATCH] linux-user: wrong TARGET_SI_PAD_SIZE value for some targets.

Fix TARGET_SI_PAD_SIZE for S390X, SPARC, ALPHA and AARCH64 according to Linux Kernel 3.19 c59c961ca511dc7ee2f4f7e9c224d16f5c76ca6e revision.

Your signed-off-by line should go here, in the commit message (one blank line, then the signoff; look at other commits in git to see how this should look).

Also that part about s390x/sparc/alpha/aarch64 in the commit message isn't accurate now the code has changed.

It's also best to send new versions of a patch as complete new emails, not as followups to the previous one. That way automated tools for tracking and downloading patches from the mailing list will function correctly.

thanks
-- PMM