From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on gnuweeb.org X-Spam-Level: X-Spam-Status: No, score=-1.2 required=5.0 tests=ALL_TRUSTED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,URIBL_BLOCKED, URIBL_DBL_BLOCKED_OPENDNS autolearn=ham autolearn_force=no version=3.4.6 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1693059411; bh=jG4wfsNEpwe3we+Lpb64W15qznopGnPznQ18oTfIcV8=; h=From:To:Cc:Subject:Date; b=CYflKv9p31Oesd2yyBQjJw5VisVsqEiG2hUs8osfJopCG+4LUnkw7br314qqssdha pHskgP2Z5/Lgw3hgLFs4qCyDr24lB3ts8Tn32IrxPAU7yCEmCeYi9UFDOIk0jvIWI0 eUjGQe/CYn2hAgQqeY4ZYPpcTm88W2TEEf1vC14FuP8Z6IzxzE2yAuHcO4pwlk2o78 RtlAqKnjM4deMDyAidU5qVll5UQAJMUshb9j09m+KuQpmy+jTA57Qbyf+Od9T88mTZ l3NGswBa3ZbDx3zznULq/itDG+Sl9NQXDGY8RhX4Kqkx/z5Rn6IcUofXZk2ATL36Z3 GErk3quI8NVUQ== Received: from localhost.localdomain (unknown [182.253.126.208]) by gnuweeb.org (Postfix) with ESMTPSA id 2196B24B1BC; Sat, 26 Aug 2023 21:16:47 +0700 (WIB) From: Ammar Faizi To: Willy Tarreau , =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= Cc: Ammar Faizi , Zhangjin Wu , Nicholas Rosenberg , GNU/Weeb Mailing List , Michael William Jonathan , Linux Kernel Mailing List Subject: [PATCH v1 0/1] Fix a stack misalign bug on _start Date: Sat, 26 Aug 2023 21:16:31 +0700 Message-Id: <20230826141632.1488740-1-ammarfaizi2@gnuweeb.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit List-Id: Hi Willy, Just a single quick fix. The ABI mandates that the %esp register must be a multiple of 16 when executing a call instruction. Commit 2ab446336b17 simplified the _start function, but it didn't take care of the %esp alignment, causing SIGSEGV on SSE and AVX programs that use aligned move instruction (e.g., movdqa, movaps, and vmovdqa). $eax : 0x56559000 → 0x00003f90 $ebx : 0x56559000 → 0x00003f90 $ecx : 0x1 $edx : 0xf7fcaaa0 → endbr32 $esp : 0xffffcdbc → 0x00000001 $ebp : 0x0 $esi : 0xffffce7c → 0xffffd096 $edi : 0x56556060 → <_start+0> xor %ebp, %ebp $eip : 0x56556489 → movaps %xmm0, 0x30(%esp) pop %eax add $0x2b85, %eax movups -0x1fd0(%eax), %xmm0 → movaps %xmm0, 0x30(%esp) <== trapping instruction movups -0x1fe0(%eax), %xmm1 movaps %xmm1, 0x20(%esp) movups -0x1ff0(%eax), %xmm2 movaps %xmm2, 0x10(%esp) movups -0x2000(%eax), %xmm3 [#0] Id 1, Name: "test", stopped 0x56556489 in sse_pq_add (), reason: SIGSEGV (gdb) bt #0 0x56556489 in sse_pq_add () #1 0x5655608e in main () Ensure the %esp is a multiple of 16 when executing the call instruction. Signed-off-by: Ammar Faizi --- Ammar Faizi (1): tools/nolibc: i386: Fix a stack misalign bug on _start tools/include/nolibc/arch-i386.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) base-commit: 6269320850097903b30be8f07a5c61d9f7592393 -- Ammar Faizi