From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-yw1-x1130.google.com (mail-yw1-x1130.google.com [IPv6:2607:f8b0:4864:20::1130]) by sourceware.org (Postfix) with ESMTPS id 04DC23858D37 for ; Sun, 17 Mar 2024 12:57:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 04DC23858D37 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 04DC23858D37 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::1130 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1710680276; cv=none; b=CMv4CGrUlSB0TuWNdvBYKkvmMRS19ZXtJEtxT9TATcMtvibTJpUw0NGdFDIwBdgR7IlG7m26Ozr8yeQj2BsAS4IROy6/B0A5BXM8v64sUKQHiVHO0xoyvxhtXfQ/CRZBu5L52v+9XwNIeJlGHj3N0nLQyKl6O1hB4VtukXtexMg= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1710680276; c=relaxed/simple; bh=8eCPBqH3XEX4ZmqUtSPqB1p4yYRdDAoJx+dHDV2dcas=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=OOKNstdtJ0K8ouPotfs58OdogSWrOtEvZ/QuSvGNB1gEZqJcL1bwdD5U8TP23UXPNrna83p2f8UzOGzHfLCi5y9n3B5+nj8IzhOA+h8WuDUeWTSG04lWV+v9V8G35yqkG6NGUC1ZukluKPjY5qUCq7InAMgWNK/RVLhjHE9iRrg= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-yw1-x1130.google.com with SMTP id 00721157ae682-609408d4b31so34116527b3.0 for ; Sun, 17 Mar 2024 05:57:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1710680273; x=1711285073; darn=sourceware.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=diKpZfGrqwXvyIiucl+NEHtsd8nPJiH8KQ32ZVFRhI0=; b=X4hndAfFn07nN6MeQ3m26CnlQlnM0MohBwcOz3gwYdRNbkUs1JokVdugqHRyBa2YQY m9Hca9jJF4NR83X5QZjt8M5l3UdbJxVlOgaMF1mjWWKOhKXMmrDGCQb6jmPypC2Xsmhd h0xNRqQxinXxkwWEue544asKuudxt5BMUoKOMNmOwMSHlRWZBxkqXvHstcbsPleSAWob /sUU7ieFYKU5wBHFwL0EYjZZb6kTeytx/VuZo0nlAHzw1HT5bxFVq18EbpXZOCx/Nfwg yvr1l3D8L0io3AXrdoS5ADw2PF51vqOOTVTJQjSDLmRye6x457/LfrVCT+IMsul23kQs UV6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710680273; x=1711285073; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=diKpZfGrqwXvyIiucl+NEHtsd8nPJiH8KQ32ZVFRhI0=; b=oVh3fBuCirET7ng0LyuS/AEKY7BtthcNy0Yg6W1OWZgNPpxsM7SwfadhhjahnwCaHO tDIryBzsB28HXH3yeKWQWIWBKXZ9uyAVtZV1CB4Jl6LF85QpFvqpO93BoDs1op17VFaL SsDvX8IUfeHZqh6j0TirP4N8I0rKn1m41BZVwL1JYkMHufjQGLeMbLVPfMAjT7Hh8iA/ poRCz8/cj9lm1TVLG4lA5ieeqrZ+oGFGfyWX/U0rGCWw969TNF22JUkQfywaFg6xx3/x SriNjtc/roD1nDUL78wnp0bZIY9e4fTJTWttRJs/3fYCRhYcLySmUb7e3H/O3Tp8vS/6 vSJw== X-Gm-Message-State: AOJu0Yxhj5u8RLmKU3qSeNmR8+soNsE2A9dgrBQEw/WTiMN5nNsbVNa4 LsTEIErifu2fJOI7dcGX6KRz1OnRCSJZqFsYyalFiUbvJ+98y8shwQZu1K9kf/EfuNj9THkqJyI xiCmC291OXkEaYTlVUdLLF+Ycykw= X-Google-Smtp-Source: AGHT+IFJx9kYnDytjBGDVOot7uhYN5csWVurapsfyLiMNo7jOqVSxkglHJIaoyAgOH4IfpbmVJC/PUS/JVfq6npIjTo= X-Received: by 2002:a81:9210:0:b0:609:87d8:4869 with SMTP id j16-20020a819210000000b0060987d84869mr7807786ywg.52.1710680273254; Sun, 17 Mar 2024 05:57:53 -0700 (PDT) MIME-Version: 1.0 References: <20240317031315.565195-1-hjl.tools@gmail.com> <878r2he02b.fsf@oldenburg.str.redhat.com> In-Reply-To: From: "H.J. Lu" Date: Sun, 17 Mar 2024 05:57:16 -0700 Message-ID: Subject: Re: [PATCH v2] x86-64: Allocate state buffer space for RDI, RSI and RBX To: Florian Weimer Cc: libc-alpha@sourceware.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-3020.3 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Sun, Mar 17, 2024 at 4:39=E2=80=AFAM H.J. Lu wrote= : > > On Sun, Mar 17, 2024 at 1:26=E2=80=AFAM Florian Weimer wrote: > > > > * H. J. Lu: > > > > > diff --git a/sysdeps/x86/sysdep.h b/sysdeps/x86/sysdep.h > > > index db8e576e91..262d4083e2 100644 > > > --- a/sysdeps/x86/sysdep.h > > > +++ b/sysdeps/x86/sysdep.h > > > @@ -46,6 +46,13 @@ > > > red-zone into account. */ > > > # define STATE_SAVE_OFFSET (8 * 7 + 8) > > > > > > +/* _dl_tlsdesc_dynamic preserves RDI, RSI and RBX before realigning > > > + stack. After realigning stack, it saves RCX, RDX, R8, R9, R10 an= d > > > + R11. Allocate space for all integer registers and round up the s= tate > > > + size to 64 bytes to avoid clobbering saved RDI, RSI and RBX value= s on > > > + stack by xsave on STATE_SAVE_OFFSET(%rsp). */ > > > +# define TLSDESC_CALL_STATE_SAVE_OFFSET (STATE_SAVE_OFFSET + 64) > > > > Why 64? The red zone is 128 bytes, and the three registers only need 2= 4 > > bytes. I think 24 has to be rounded up to 64 to preserve the XSAVE are= a > > alignment. > > I changed it to 24. > > > The macro is also misnamed because it is not an offset. The real offse= t > > depends on what the stack realignment did. > > > > I renamed it to TLSDESC_CALL_REGISTER_SAVE_AREA in the v3 patch: > > https://patchwork.sourceware.org/project/glibc/list/?series=3D31971 > No need to add a new test. Only sysdeps/x86_64/tst-gnu2-tls2mod1.S is need: https://patchwork.sourceware.org/project/glibc/list/?series=3D31975 --=20 H.J.