From nobody Wed Oct 29 20:26:42 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1525986088037248.28578000602522; Thu, 10 May 2018 14:01:28 -0700 (PDT) Received: from localhost ([::1]:35621 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fGsgg-0006BS-Mf for importer@patchew.org; Thu, 10 May 2018 17:01:18 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60870) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fGsfn-0005q6-Cc for qemu-devel@nongnu.org; Thu, 10 May 2018 17:00:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fGsfk-0005sV-BY for qemu-devel@nongnu.org; Thu, 10 May 2018 17:00:23 -0400 Received: from mout.kundenserver.de ([212.227.126.133]:41899) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fGsfk-0005sH-2W for qemu-devel@nongnu.org; Thu, 10 May 2018 17:00:20 -0400 Received: from localhost.localdomain ([78.238.229.36]) by mrelayeu.kundenserver.de (mreue006 [212.227.15.167]) with ESMTPSA (Nemesis) id 0LthuT-1eGMT106WD-011A9R; Thu, 10 May 2018 23:00:10 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Date: Thu, 10 May 2018 22:59:49 +0200 Message-Id: <20180510205949.26455-1-laurent@vivier.eu> X-Mailer: git-send-email 2.14.3 X-Provags-ID: V03:K1:IVsYEFIoPpLAqvebO5bNAj/+MbR6m4aLxtSdO4VKSn/OhFO/2ol GoF3tkVlx/D0mqZWpaAyJRPjZ52JBVQIhEzGKDAJt+HNwmNlIVI4iqHifhUJqXD23kSk+US XiHYI4l8o3t624gb97FvN9KnsnES2XzhlJJN23FlO9yfk+u6YS10FboB1g2WpbkLEcxKM+b w9/4FPmWsldgeXvnHqjvg== X-UI-Out-Filterresults: notjunk:1;V01:K0:zBNs9CaLwJk=:TI3a/YC+Q9nPdlFXyRpGTw ycMBA9mdXJHK7aA3d39DVpMmtObZYW9ofJztjXN+8ZuZmC9BWROGom2CjaWuTZ7Eijc1EZupq QEgcn1X53IxhAduujvYMI0Hd13zemtXEKeqWQ/Y6mcnKRyb28AgZy2EhlcM3niv2POk8K6ib5 LgJx8Qg5QPnJ9NZyevg9PcYOuNzc5Xc/ZQwGAjjEDRBTFziA+TNZt/KJzlsGGMyNKTB1GRHih 5B1eN06bQVkX39oc7WyaVQO5AOQd88XoH8UG1hdu/fNB64RlMpRvgQSdCmDYdIZc69h91TqX5 3lByB4jS1p0ApsXliiZUhEKglt4wnaMRbyILy36cmJQWvhLfMZmECy2pICduYCub80upIOEDG brjfjXqvHpHac2lrJIWbIyalj9VDg/fkFHvvnXULfZqo7jadNZCFKVQjW799x0FuP59ZuDtoW 4zER1DfH+3NGKHuDa0pOxwtnYGrWAKh97NA0Xa7Fyl8PX7lkBvufh8fOhmqjThz8ufEJIZYVb /2KA/NmN8gvGcbFh0BVel5U+EpbdxT+OOFzCF4bv81J17IUIfDUqs2nBGUD/cAvU8si6Yv4am /P+HIXrrFwrSP/wvpDoi/GAxMEg8e5XP8Rx97D/GZuZAn37dtar8+iwyWTVLaBPWZKyg1ixr8 H70tsUoWp5JF50xIB0ggZp2iL1sIYkkgBASRtdztRc8HXfjANnrsBEQZzLy37x17AtsI= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 212.227.126.133 Subject: [Qemu-devel] [PATCH] linux-user: correctly align types in thunking code X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Riku Voipio , Laurent Vivier Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This is a follow up of patch: commit c2e3dee6e03527baf8698698cce76b1a3174969a Author: Laurent Vivier Date: Sun Feb 13 23:37:34 2011 +0100 linux-user: Define target alignment size In my case m68k aligns "int" on 2 not 4. You can check this with the following program: int main(void) { struct rtentry rt; printf("rt_pad1 %ld %zd\n", offsetof(struct rtentry, rt_pad1), sizeof(rt.rt_pad1)); printf("rt_dst %ld %zd\n", offsetof(struct rtentry, rt_dst), sizeof(rt.rt_dst)); printf("rt_gateway %ld %zd\n", offsetof(struct rtentry, rt_gateway), sizeof(rt.rt_gateway)); printf("rt_genmask %ld %zd\n", offsetof(struct rtentry, rt_genmask), sizeof(rt.rt_genmask)); printf("rt_flags %ld %zd\n", offsetof(struct rtentry, rt_flags), sizeof(rt.rt_flags)); printf("rt_pad2 %ld %zd\n", offsetof(struct rtentry, rt_pad2), sizeof(rt.rt_pad2)); printf("rt_pad3 %ld %zd\n", offsetof(struct rtentry, rt_pad3), sizeof(rt.rt_pad3)); printf("rt_pad4 %ld %zd\n", offsetof(struct rtentry, rt_pad4), sizeof(rt.rt_pad4)); printf("rt_metric %ld %zd\n", offsetof(struct rtentry, rt_metric), sizeof(rt.rt_metric)); printf("rt_dev %ld %zd\n", offsetof(struct rtentry, rt_dev), sizeof(rt.rt_dev)); printf("rt_mtu %ld %zd\n", offsetof(struct rtentry, rt_mtu), sizeof(rt.rt_mtu)); printf("rt_window %ld %zd\n", offsetof(struct rtentry, rt_window), sizeof(rt.rt_window)); printf("rt_irtt %ld %zd\n", offsetof(struct rtentry, rt_irtt), sizeof(rt.rt_irtt)); } And result is : i386 rt_pad1 0 4 rt_dst 4 16 rt_gateway 20 16 rt_genmask 36 16 rt_flags 52 2 rt_pad2 54 2 rt_pad3 56 4 rt_pad4 62 2 rt_metric 64 2 rt_dev 68 4 rt_mtu 72 4 rt_window 76 4 rt_irtt 80 2 m68k rt_pad1 0 4 rt_dst 4 16 rt_gateway 20 16 rt_genmask 36 16 rt_flags 52 2 rt_pad2 54 2 rt_pad3 56 4 rt_pad4 62 2 rt_metric 64 2 rt_dev 66 4 rt_mtu 70 4 rt_window 74 4 rt_irtt 78 2 This affects the "route" command : WITHOUT this patch: $ sudo route add -net default gw 10.0.3.1 window 1024 irtt 2 eth0 $ netstat -nr Kernel IP routing table Destination Gateway Genmask Flags MSS Window irtt If= ace 0.0.0.0 10.0.3.1 0.0.0.0 UG 0 67108866 32768= eth0 10.0.3.0 0.0.0.0 255.255.255.0 U 0 0 0 et= h0 WITH this patch: $ sudo route add -net default gw 10.0.3.1 window 1024 irtt 2 eth0 $ netstat -nr Kernel IP routing table Destination Gateway Genmask Flags MSS Window irtt If= ace 0.0.0.0 10.0.3.1 0.0.0.0 UG 0 1024 2 et= h0 10.0.3.0 0.0.0.0 255.255.255.0 U 0 0 0 et= h0 Signed-off-by: Laurent Vivier Reviewed-by: Peter Maydell --- include/exec/user/thunk.h | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/include/exec/user/thunk.h b/include/exec/user/thunk.h index f19ef4b230..8f55b233b3 100644 --- a/include/exec/user/thunk.h +++ b/include/exec/user/thunk.h @@ -149,20 +149,32 @@ static inline int thunk_type_align(const argtype *typ= e_ptr, int is_host) case TYPE_CHAR: return 1; case TYPE_SHORT: - return 2; + if (is_host) { + return __alignof__(short); + } else { + return ABI_SHORT_ALIGNMENT; + } case TYPE_INT: - return 4; + if (is_host) { + return __alignof__(int); + } else { + return ABI_INT_ALIGNMENT; + } case TYPE_LONGLONG: case TYPE_ULONGLONG: - return 8; + if (is_host) { + return __alignof__(long long); + } else { + return ABI_LLONG_ALIGNMENT; + } case TYPE_LONG: case TYPE_ULONG: case TYPE_PTRVOID: case TYPE_PTR: if (is_host) { - return sizeof(void *); + return __alignof__(long); } else { - return TARGET_ABI_BITS / 8; + return ABI_LONG_ALIGNMENT; } break; case TYPE_OLDDEVT: --=20 2.14.3