qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] Wrong unpacked structure for epoll_event on qemu-or1k (openr


From: Richard Henderson
Subject: Re: [PATCH] Wrong unpacked structure for epoll_event on qemu-or1k (openrisc user-space)
Date: Wed, 2 Aug 2023 13:03:50 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0

On 8/2/23 12:55, Thomas Huth wrote:
On 19/07/2023 14.38, Luca Bonissi wrote:
On 19/07/23 10:49, Laurent Vivier wrote:

According to linux/glibc sourced, epoll is only packed for x86_64.

And, in recent glibc, also for i386, even it seems not necessary: even if the __alignof__(long long) is 8, structures like epoll_event are only 12 bytes, maybe "packed" for historical reasons. Ancient i386 gcc[s] (<3.0.0) have 4 bytes for __alignof__(long long).

Perhaps the default alignment of long is not correctly defined in qemu for 
openrisc?

__alignof__(long long):
- 8 bytes: all 64 bit targets + arm, hppa, mips, ppc, sparc, xtensa, x86
- 4 bytes: microblaze, nios2, or1k, sh4
- 2 bytes: m68k
- 1 byte : cris

offsetof(struct epoll_event,data):
- 8: all 64 bit targets + arm, hppa, mips, ppc, sparc, xtensa
- 4: cris, m68k, microblaze, nios2, or1k, sh4, x86

So, epoll_event is "naturally" packed on the following targets (checked in linux-user container and/or with cross-compiler):
- cris, m68k, microblaze, nios2, or1k, sh4, x86 (32bit)

See include/exec/user/abitypes.h to update the value.

OK, abitypes.h should be updated with the following patch (discard the previous patch on syscall_defs.h):

Signed-off-by: Luca Bonissi <qemu@bonslack.org>
---

diff -up a/include/exec/user/abitypes.h b/include/exec/user/abitypes.h
--- a/include/exec/user/abitypes.h    2023-03-27 15:41:42.511916232 +0200
+++ b/include/exec/user/abitypes.h    2023-07-19 12:09:03.001687788 +0200
@@ -15,7 +15,15 @@
  #define ABI_LLONG_ALIGNMENT 2
  #endif

+#ifdef TARGET_CRIS
+#define ABI_SHORT_ALIGNMENT 1
+#define ABI_INT_ALIGNMENT 1
+#define ABI_LONG_ALIGNMENT 1
+#define ABI_LLONG_ALIGNMENT 1
+#endif
+
-#if (defined(TARGET_I386) && !defined(TARGET_X86_64)) || defined(TARGET_SH4)
+#if (defined(TARGET_I386) && !defined(TARGET_X86_64)) || defined(TARGET_SH4) 
|| \
+    defined(TARGET_OPENRISC) || defined(TARGET_NIOS2) || 
defined(TARGET_MICROBLAZE)
  #define ABI_LLONG_ALIGNMENT 4
  #endif

Hi! Thanks for the patch - but could you please send this as a new patch mail with a proper subject and patch description, so that it could be applied with "git am" ? Thanks!

The patch should be against master, because microblaze and nios2 are already 
fixed.


r~




reply via email to

[Prev in Thread] Current Thread [Next in Thread]