From nobody Sun Nov 24 14:02:26 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1722437094; cv=none; d=zohomail.com; s=zohoarc; b=d1t5M5gg5Vjtw5sK11Fh+OE8aMJEiCX3pQzICn1uV0Blbd0OREwv2dt2/lIC5NjdVYfV3kBs6weGgdyh61YCClmlo/41ajYhs1TRCcP/VuMNr0Ll5dv82t5xnuCpkHi+T0St1USdA0M2vl5krfx6Li3lwAwvyG9L50O4yJR4u3U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1722437094; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=ZPipbue8XEOy1ZXs7JMbjuMc+ayUzxlT8wDjLkWGgPg=; b=hFUxjLXmjVdRL4uyQBRghXmC9FKa3mbuUklDHCpfJeVgc0UyEeKkNzVrO0+OHeWQFOYpACP+2pwQwQI0aFJ58QhGM7DZyZwmogtgqm3VtswhfndaG5IjC/vKl4vFWMLdiidlY5r2KZKyRZ3BsUxlTAINiJt+kSPxqL8Kids1En4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1722437094058289.39517294391385; Wed, 31 Jul 2024 07:44:54 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sZAZJ-0007OL-Mp; Wed, 31 Jul 2024 10:44:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sZAZG-00078K-4q for qemu-devel@nongnu.org; Wed, 31 Jul 2024 10:44:42 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sZAZE-0004b8-Ly for qemu-devel@nongnu.org; Wed, 31 Jul 2024 10:44:41 -0400 Received: from pps.filterd (m0353724.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 46VCh7j9023626; Wed, 31 Jul 2024 14:44:36 GMT Received: from ppma13.dal12v.mail.ibm.com (dd.9e.1632.ip4.static.sl-reverse.com [50.22.158.221]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 40qnbygf4p-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 31 Jul 2024 14:44:36 +0000 (GMT) Received: from pps.filterd (ppma13.dal12v.mail.ibm.com [127.0.0.1]) by ppma13.dal12v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 46VDIckn003773; Wed, 31 Jul 2024 14:44:35 GMT Received: from smtprelay06.fra02v.mail.ibm.com ([9.218.2.230]) by ppma13.dal12v.mail.ibm.com (PPS) with ESMTPS id 40ndemkvp2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 31 Jul 2024 14:44:35 +0000 Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay06.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 46VEiVp29634160 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 31 Jul 2024 14:44:33 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A61E02004E; Wed, 31 Jul 2024 14:44:31 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 421C92004B; Wed, 31 Jul 2024 14:44:31 +0000 (GMT) Received: from heavy.ibm.com (unknown [9.171.57.89]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Wed, 31 Jul 2024 14:44:31 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from :to:cc:subject:date:message-id:mime-version :content-transfer-encoding; s=pp1; bh=ZPipbue8XEOy1ZXs7JMbjuMc+a yUzxlT8wDjLkWGgPg=; b=EXQ/ndaJiTpWCjU3jjpsqIV09kagtwAdqoC9ASD4eG 9urtBlYHSjv7hnyB5LtRyV2TJtjQUeR3y/Hu/8iwQAUXZkIum1J8b3v9QHQirvzV Z3wkm70SSgEvKv08Ct3B88GFu7I9gPah7LCxaa6eeWkVp43ijXodR9b67NNmY2DO Z+2jubSMs1u2bkFDZ3FsMR7HC4cxIFKUDIUMenzQBLK+VA/Jt+H16roAbkeYwHXr U8haQLeowCB4ubbzvcPmkWW7GN4okSZhN9Hkmdgp+eu2cgydRi1O6zIAE/6Yl39g XveDBI6dqW/Oqc015a7WKp1knwCuGb9GpHfKfrpQF0DA== From: Ilya Leoshkevich To: Warner Losh , Kyle Evans , Richard Henderson Cc: qemu-devel@nongnu.org, Ilya Leoshkevich Subject: [PATCH] bsd-user/x86_64/target_arch_thread.h: Align stack Date: Wed, 31 Jul 2024 16:44:12 +0200 Message-ID: <20240731144428.5882-1-iii@linux.ibm.com> X-Mailer: git-send-email 2.45.2 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-GUID: Eu_dkaGhKDGPWp_JnrwbXXm1rHnl7J2X X-Proofpoint-ORIG-GUID: Eu_dkaGhKDGPWp_JnrwbXXm1rHnl7J2X X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-07-31_09,2024-07-31_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 phishscore=0 impostorscore=0 bulkscore=0 priorityscore=1501 mlxlogscore=958 malwarescore=0 clxscore=1011 adultscore=0 mlxscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2407110000 definitions=main-2407310103 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=148.163.158.5; envelope-from=iii@linux.ibm.com; helo=mx0b-001b2d01.pphosted.com X-Spam_score_int: -19 X-Spam_score: -2.0 X-Spam_bar: -- X-Spam_report: (-2.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @ibm.com) X-ZM-MESSAGEID: 1722437095958116600 Content-Type: text/plain; charset="utf-8" bsd-user qemu-x86_64 almost immediately dies with: qemu: 0x4002201a68: unhandled CPU exception 0xd - aborting on FreeBSD 14.1-RELEASE. This is an instruction that requires alignment: (gdb) x/i 0x4002201a68 0x4002201a68: movaps %xmm0,-0x40(%rbp) and the argument is not aligned: (gdb) p/x env->regs[5] $1 =3D 0x822443b58 A quick experiment shows that the userspace entry point expects misaligned rsp: (gdb) starti (gdb) p/x $rsp $1 =3D 0x7fffffffeaa8 Emulate this behavior in bsd-user. Signed-off-by: Ilya Leoshkevich Reviewed-by: Richard Henderson Reviewed-by: Warner Losh --- bsd-user/x86_64/target_arch_thread.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bsd-user/x86_64/target_arch_thread.h b/bsd-user/x86_64/target_= arch_thread.h index 52c28906d6d..25233443c14 100644 --- a/bsd-user/x86_64/target_arch_thread.h +++ b/bsd-user/x86_64/target_arch_thread.h @@ -31,7 +31,7 @@ static inline void target_thread_init(struct target_pt_re= gs *regs, struct image_info *infop) { regs->rax =3D 0; - regs->rsp =3D infop->start_stack; + regs->rsp =3D (infop->start_stack & ~0xfUL) - 8; regs->rip =3D infop->entry; regs->rdi =3D infop->start_stack; } --=20 2.45.2