* Wrong unpacked structure for epoll_event on qemu-or1k (openrisc user-space)
@ 2023-07-18 13:03 Luca Bonissi
2023-07-18 14:40 ` Peter Maydell
0 siblings, 1 reply; 7+ messages in thread
From: Luca Bonissi @ 2023-07-18 13:03 UTC (permalink / raw)
To: qemu-devel
The or1k epoll_event structure - unlike other architectures - is packed,
so we need to define it as packed in qemu-user, otherwise it leads to
infinite loop due to missing file descriptor in the returned data:
--- qemu-20230327/linux-user/syscall_defs.h.orig 2023-03-27
15:41:42.000000000 +0200
+++ qemu-20230327/linux-user/syscall_defs.h 2023-06-30
17:29:39.034322213 +0200
@@ -2714,7 +2709,7 @@
#define FUTEX_CMD_MASK ~(FUTEX_PRIVATE_FLAG |
FUTEX_CLOCK_REALTIME)
#ifdef CONFIG_EPOLL
-#if defined(TARGET_X86_64)
+#if defined(TARGET_X86_64) || defined(TARGET_OPENRISC)
#define TARGET_EPOLL_PACKED QEMU_PACKED
#else
#define TARGET_EPOLL_PACKED
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Wrong unpacked structure for epoll_event on qemu-or1k (openrisc user-space)
2023-07-18 13:03 Wrong unpacked structure for epoll_event on qemu-or1k (openrisc user-space) Luca Bonissi
@ 2023-07-18 14:40 ` Peter Maydell
2023-07-18 15:06 ` [PATCH] " Luca Bonissi
0 siblings, 1 reply; 7+ messages in thread
From: Peter Maydell @ 2023-07-18 14:40 UTC (permalink / raw)
To: Luca Bonissi; +Cc: qemu-devel
On Tue, 18 Jul 2023 at 14:03, Luca Bonissi <qemu@bonslack.org> wrote:
>
> The or1k epoll_event structure - unlike other architectures - is packed,
> so we need to define it as packed in qemu-user, otherwise it leads to
> infinite loop due to missing file descriptor in the returned data:
Hi; thanks for this patch. Unfortunately we need patches
to include a Signed-off-by: line that says you're legally
OK with it being contributed to QEMU, or we can't take them.
More info here:
https://www.qemu.org/docs/master/devel/submitting-a-patch.html
thanks
-- PMM
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] Wrong unpacked structure for epoll_event on qemu-or1k (openrisc user-space)
2023-07-18 14:40 ` Peter Maydell
@ 2023-07-18 15:06 ` Luca Bonissi
2023-07-19 8:49 ` Laurent Vivier
0 siblings, 1 reply; 7+ messages in thread
From: Luca Bonissi @ 2023-07-18 15:06 UTC (permalink / raw)
To: Peter Maydell; +Cc: qemu-devel, Laurent Vivier
On 18/07/23 16:40, Peter Maydell wrote:
> Hi; thanks for this patch. Unfortunately we need patches
> to include a Signed-off-by: line that says you're legally
> OK with it being contributed to QEMU, or we can't take them.
Sorry for the missing "signed-off-by" line, adding it just now:
==============
The or1k epoll_event structure - unlike other architectures - is packed,
so we need to define it as packed in qemu-user, otherwise it leads to
infinite loop due to missing file descriptor in the returned data:
Signed-off-by: Luca Bonissi <qemu@bonslack.org>
---
diff -up a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h
--- a/linux-user/syscall_defs.h 2023-03-27 15:41:42.000000000 +0200
+++ b/linux-user/syscall_defs.h 2023-06-30 17:29:39.034322213 +0200
@@ -2714,7 +2709,7 @@
#define FUTEX_CMD_MASK ~(FUTEX_PRIVATE_FLAG |
FUTEX_CLOCK_REALTIME)
#ifdef CONFIG_EPOLL
-#if defined(TARGET_X86_64)
+#if defined(TARGET_X86_64) || defined(TARGET_OPENRISC)
#define TARGET_EPOLL_PACKED QEMU_PACKED
#else
#define TARGET_EPOLL_PACKED
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] Wrong unpacked structure for epoll_event on qemu-or1k (openrisc user-space)
2023-07-18 15:06 ` [PATCH] " Luca Bonissi
@ 2023-07-19 8:49 ` Laurent Vivier
2023-07-19 12:38 ` Luca Bonissi
0 siblings, 1 reply; 7+ messages in thread
From: Laurent Vivier @ 2023-07-19 8:49 UTC (permalink / raw)
To: Luca Bonissi, Peter Maydell; +Cc: qemu-devel
Le 18/07/2023 à 17:06, Luca Bonissi a écrit :
> On 18/07/23 16:40, Peter Maydell wrote:
>> Hi; thanks for this patch. Unfortunately we need patches
>> to include a Signed-off-by: line that says you're legally
>> OK with it being contributed to QEMU, or we can't take them.
>
> Sorry for the missing "signed-off-by" line, adding it just now:
>
> ==============
> The or1k epoll_event structure - unlike other architectures - is packed, so we need to define it as
> packed in qemu-user, otherwise it leads to infinite loop due to missing file descriptor in the
> returned data:
>
>
> Signed-off-by: Luca Bonissi <qemu@bonslack.org>
> ---
>
> diff -up a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h
> --- a/linux-user/syscall_defs.h 2023-03-27 15:41:42.000000000 +0200
> +++ b/linux-user/syscall_defs.h 2023-06-30 17:29:39.034322213 +0200
> @@ -2714,7 +2709,7 @@
> #define FUTEX_CMD_MASK ~(FUTEX_PRIVATE_FLAG | FUTEX_CLOCK_REALTIME)
>
> #ifdef CONFIG_EPOLL
> -#if defined(TARGET_X86_64)
> +#if defined(TARGET_X86_64) || defined(TARGET_OPENRISC)
> #define TARGET_EPOLL_PACKED QEMU_PACKED
> #else
> #define TARGET_EPOLL_PACKED
According to linux/glibc sourced, epoll is only packed for x86_64.
Did you try to check the alignment of the structure with gdb of a C program using offsetof() in an
openrisc VM or linux-user container?
Perhaps the default alignment of long is not correctly defined in qemu for openrisc?
You can check with:
int main(void)
{
printf("alignof(short) %ld\n", __alignof__(short));
printf("alignof(int) %ld\n", __alignof__(int));
printf("alignof(long) %ld\n", __alignof__(long));
printf("alignof(long long) %ld\n", __alignof__(long long));
}
See include/exec/user/abitypes.h to update the value.
Thanks,
Laurent
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] Wrong unpacked structure for epoll_event on qemu-or1k (openrisc user-space)
2023-07-19 8:49 ` Laurent Vivier
@ 2023-07-19 12:38 ` Luca Bonissi
2023-08-02 19:55 ` Thomas Huth
0 siblings, 1 reply; 7+ messages in thread
From: Luca Bonissi @ 2023-07-19 12:38 UTC (permalink / raw)
To: Laurent Vivier; +Cc: qemu-devel, Peter Maydell
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
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] Wrong unpacked structure for epoll_event on qemu-or1k (openrisc user-space)
2023-07-19 12:38 ` Luca Bonissi
@ 2023-08-02 19:55 ` Thomas Huth
2023-08-02 20:03 ` Richard Henderson
0 siblings, 1 reply; 7+ messages in thread
From: Thomas Huth @ 2023-08-02 19:55 UTC (permalink / raw)
To: Luca Bonissi, Laurent Vivier; +Cc: qemu-devel, Peter Maydell, Richard Henderson
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!
Thomas
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] Wrong unpacked structure for epoll_event on qemu-or1k (openrisc user-space)
2023-08-02 19:55 ` Thomas Huth
@ 2023-08-02 20:03 ` Richard Henderson
0 siblings, 0 replies; 7+ messages in thread
From: Richard Henderson @ 2023-08-02 20:03 UTC (permalink / raw)
To: Thomas Huth, Luca Bonissi, Laurent Vivier; +Cc: qemu-devel, Peter Maydell
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~
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2023-08-02 20:04 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-18 13:03 Wrong unpacked structure for epoll_event on qemu-or1k (openrisc user-space) Luca Bonissi
2023-07-18 14:40 ` Peter Maydell
2023-07-18 15:06 ` [PATCH] " Luca Bonissi
2023-07-19 8:49 ` Laurent Vivier
2023-07-19 12:38 ` Luca Bonissi
2023-08-02 19:55 ` Thomas Huth
2023-08-02 20:03 ` Richard Henderson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).