From: Laurent Vivier <laurent@vivier.eu>
To: Peter Maydell <peter.maydell@linaro.org>, qemu-devel@nongnu.org
Cc: Riku Voipio <riku.voipio@iki.fi>,
Icenowy Zheng <icenowy@aosc.xyz>,
patches@linaro.org
Subject: Re: [Qemu-devel] [PATCH] linux-user: Use correct alignment for long long on i386 guests
Date: Thu, 28 Jul 2016 22:36:19 +0200 [thread overview]
Message-ID: <d9cea7e1-74b7-0b09-1227-c6f079e8f956@vivier.eu> (raw)
In-Reply-To: <1469707079-9049-1-git-send-email-peter.maydell@linaro.org>
Le 28/07/2016 à 13:57, Peter Maydell a écrit :
> For i386, the ABI specifies that 'long long' (8 byte values)
> need only be 4 aligned, but we were requiring them to be
> 8-aligned. This meant we were laying out the target_epoll_event
> structure wrongly. Add a suitable ifdef to abitypes.h to
> specify the i386-specific alignment requirement.
gdb qemu-i386
(gdb) p &(((struct target_epoll_event *)0)->data)
$1 = (target_epoll_data_t *) 0x8
whereas:
gdb qemu-x86_64
(gdb) p &(((struct target_epoll_event *)0)->data)
$1 = (target_epoll_data_t *) 0x4
I've checked on real systems x86_64/i386:
-----
#include <sys/epoll.h>
int main(void)
{
volatile struct epoll_event e;
e.events = 0;
}
----
(gdb) p &(((struct epoll_event *)0)->data)
$1 = (epoll_data_t *) 0x4
but on ppc64, I have
(gdb) p &(((struct epoll_event *)0)->data)
$1 = (epoll_data_t *) 0x8
In fact, the structure should be packed in both cases, something like:
--- a/linux-user/syscall_defs.h
+++ b/linux-user/syscall_defs.h
@@ -2562,7 +2562,7 @@ struct target_mq_attr {
#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_I386)
#define TARGET_EPOLL_PACKED QEMU_PACKED
#else
#define TARGET_EPOLL_PACKED
on my Fedora systems x86_64/i386:
/usr/include/bits/epoll.h
#define __EPOLL_PACKED __attribute__ ((__packed__))
/usr/include/sys/epoll.h
struct epoll_event
{
uint32_t events; /* Epoll events */
epoll_data_t data; /* User data variable */
} __EPOLL_PACKED;
but I don't understand why in linux source tree we have
#ifdef __x86_64__
#define EPOLL_PACKED __attribute__((packed))
#else
#define EPOLL_PACKED
#endif
struct epoll_event {
__u32 events;
__u64 data;
} EPOLL_PACKED;
Laurent
next prev parent reply other threads:[~2016-07-28 20:36 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-28 11:57 [Qemu-devel] [PATCH] linux-user: Use correct alignment for long long on i386 guests Peter Maydell
2016-07-28 19:19 ` Laurent Vivier
2016-07-28 20:38 ` Peter Maydell
2016-07-28 20:36 ` Laurent Vivier [this message]
2016-07-28 20:43 ` Peter Maydell
2016-07-29 0:13 ` Laurent Vivier
2016-08-01 9:04 ` Riku Voipio
2016-08-01 10:02 ` Peter Maydell
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=d9cea7e1-74b7-0b09-1227-c6f079e8f956@vivier.eu \
--to=laurent@vivier.eu \
--cc=icenowy@aosc.xyz \
--cc=patches@linaro.org \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=riku.voipio@iki.fi \
/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.