From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-yw1-x1131.google.com (mail-yw1-x1131.google.com [IPv6:2607:f8b0:4864:20::1131]) by sourceware.org (Postfix) with ESMTPS id D9D813858D37 for ; Mon, 18 Mar 2024 12:33:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D9D813858D37 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 D9D813858D37 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::1131 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1710765192; cv=none; b=dQrbwo8vQDB1KUOKVPoLXwUjWxe4rNgAsjN1GixMvhXoC2x3+MCuGaUGeoumk870emB2pqEfhWY0EAKEVE0+Q5oT2NPOK0FRr9x1Y4r7kks83WPbLJSMdgpwB6MPLm8/MWSg4IcQm5o13dgVLJ+gsWCN8szbLAIq2MJrkYqGNEw= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1710765192; c=relaxed/simple; bh=5RDVSBFLwWALafI6g0UszI9DMyi9DEPKCvdhFQaoGyI=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=DjX1nHkvon4vEME3wRVBjhJliOO9osM30YN8fncu+/BDbz6vSz3J7DY0IsmVGA8hIXamMfG8jUlV+SHDyjruUW9guLK6ADPnfvPQQ529gFL1abyC12j6wkn1BGVaK4g9Gvwz4a4oY9QuzuEwzEf9Ln/4l/uMsNUlmnihSAkXmCY= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-yw1-x1131.google.com with SMTP id 00721157ae682-60cc4124a39so43926627b3.3 for ; Mon, 18 Mar 2024 05:33:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1710765181; x=1711369981; 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=UnguotiyI5vcZCDcZ7ecGisx2Zybkqe6Y4cJzKI9p2I=; b=XMESZNY8c92d8NjXNCmqkMN4/aeJUkn2Clb8veqkeUUIVhTiyBqFuiXzmBJxRtwF8r cAgJ9NsiPsqUsjruWGtF6xpoSzyohK8gnW5FJcy8WAEOa3eyc2KNM71ifqQXDvauCXD3 KKkhPQTwNOSkifKagWgQV7DPcfs0rgNL5QS7gryFfJ0Bx7GYldPY2oUdppcbgYuN4xo9 +PXcdSENfgALWxPTvd5PEkQbYSdDulrPT7nrpF0YqEMV4sw1cjdBs/uHpQkH5MbaYJeC 5n1l/NRpcb+ham1jG85iDHrzl+smjIMxX24gnvFx1JRZOFz9Y7UhGvsFGx+m5eG9/sfs nx1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710765181; x=1711369981; 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=UnguotiyI5vcZCDcZ7ecGisx2Zybkqe6Y4cJzKI9p2I=; b=H+0QzX11wplVd+es0qwuem0KLDe07ChwFDMMi/X68IA4Zyc0VqSGQwj3MMpywr1Fij QI0dNKPp0EVlk9w7qFscGW5H79BWYQcRPYB8nOcKH4t1K5vNBLX1eYv6F/cCYG7JNQLq v9aYO7RXT3K0+ZKfiVcg72GqYOehikuZBenEHxO8ke1TZRtxVFjpiR0zqyRXo/5YH7/G kcoyd1OVjcrt6v2vUktayG8nsqKf4J7f/vom1YZBLhvfQujXqeyMugGYBbS2GsWt9KmU OMeh0A8NZWGakXstfc2bZ+AAakLqqKFS4JvgX/pk5AV32JoL2ts03HwGIlmsGFpNiFmY AU3g== X-Gm-Message-State: AOJu0YxtxsbtkOomfUdmyKDaOW3D01E8iLuzYp3qbbwtecrbTrywIfxe XUveH1sBnwAOM7yFEZX8zRyDorX9dpsMvk5SROjwcOjU7puJJj9V4Tu8hCIFTHUgJ06A8WLOz+U ONFVUUJHXzwem2bUTaSGP9D2KX8vwaLBa1ZU= X-Google-Smtp-Source: AGHT+IH4JN3/1q5XVzHrzSxJLY+pjv3clxtFsJhPTlQjs7gJwNCbEq6Jr8xsQYvJtLbLAIAL/cdr1xfLf/klwHOO8FI= X-Received: by 2002:a0d:e046:0:b0:60a:851:63af with SMTP id j67-20020a0de046000000b0060a085163afmr11371417ywe.49.1710765179876; Mon, 18 Mar 2024 05:32:59 -0700 (PDT) MIME-Version: 1.0 References: <20240317125541.799962-1-hjl.tools@gmail.com> <875xxjvnyg.fsf@oldenburg3.str.redhat.com> In-Reply-To: <875xxjvnyg.fsf@oldenburg3.str.redhat.com> From: "H.J. Lu" Date: Mon, 18 Mar 2024 05:32:23 -0700 Message-ID: Subject: Re: [PATCH v4] 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=-3019.7 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,GIT_PATCH_0,KAM_SHORT,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 Mon, Mar 18, 2024 at 3:22=E2=80=AFAM Florian Weimer = wrote: > > * H. J. Lu: > > > _dl_tlsdesc_dynamic preserves RDI, RSI and RBX before realigning stack. > > After realigning stack, it saves RCX, RDX, R8, R9, R10 and R11. Define > > TLSDESC_CALL_REGISTER_SAVE_AREA to allocate space for RDI, RSI and RBX > > to avoid clobbering saved RDI, RSI and RBX values on stack by xsave to > > STATE_SAVE_OFFSET(%rsp). > > > > +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D+<- stack fra= me start aligned at 8 or 16 bytes > > It's 8-byte aligned only? If the caller uses the psABI convention, we > have %rsp =E2=89=A1 8 (mod 16). It is due to: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D58066 Do we need to support older compilers? > > > | |<- RDI > > | |<- RSI > > | |<- RBX > > I would add something like =E2=80=9Coriginally in the red zone=E2=80=9D h= ere. Fixed. > > | |<- paddings from stack realignment of 64 bytes > > |------------------|<- xsave buffer end aligned at 64 bytes > > > > | |<- > > | |<- > > | |<- > > |------------------|<- xsave buffer start at STATE_SAVE_OFFSET(%rsp) > > | |<- 8-byte padding > > Maybe add =E2=80=9Cto achieve 64-bit alignment=E2=80=9D. Fixed. > > | |<- 8-byte padding > > | |<- R11 > > | |<- R10 > > | |<- R9 > > | |<- R8 > > | |<- RDX > > | |<- RCX > > +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D+<- State buf= fer start aligned at 64 bytes > > Isn't this =E2=80=9C%rsp aligned at 64 bytes=E2=80=9D? Fixed. > Likewise for the comment in the sources below. Fixed. > > diff --git a/sysdeps/x86/sysdep.h b/sysdeps/x86/sysdep.h > > index db8e576e91..46fcd27345 100644 > > --- a/sysdeps/x86/sysdep.h > > +++ b/sysdeps/x86/sysdep.h > > @@ -46,6 +46,34 @@ > > red-zone into account. */ > > # define STATE_SAVE_OFFSET (8 * 7 + 8) > > The comment on STATE_SAVE_OFFSET needs updating, too. Fixed. > I would like to see comments from Noah or Sunil. You'll have to > maintain this, too. 8-) CCed Noah and Sunil. > I find the macro consts rather confusing, but maybe that's just me. Can you suggest a different name? The v5 patch is at https://patchwork.sourceware.org/project/glibc/list/?series=3D31992 Thanks. --=20 H.J.