From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-oa1-x34.google.com (mail-oa1-x34.google.com [IPv6:2001:4860:4864:20::34]) by sourceware.org (Postfix) with ESMTPS id D22953858402; Sat, 9 Mar 2024 17:40:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D22953858402 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 D22953858402 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2001:4860:4864:20::34 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1710006003; cv=none; b=bvKfky+IJanNCnCrQnY4zumP+xF+2OmTn6+NqofmZIR/ShaxuqpiDVCF9zW7IHihS7UptbHiKi1Mx8MEyQT4iyjy3KLftfKzESSEQROantJd4/xQw2SXTvC45kaGP0LeYSwiZOC8ou+nbBOEx94AO+GqDplTNYqKOp9OVSOlvUU= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1710006003; c=relaxed/simple; bh=VFDjdDSMGx+TLVDcjtiBPJoRvoqDWLeyXgnyU8MaTUw=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=BobYRsMJqhyfomhVUZD5OKBp4Tc8dz44lwj+oaJgUl1cxAqSzyG7YCH027vUI3b2kgkgHJT1IGwibOLIcJa/g0ccONSRDMtTsHn8uS/GQi1EVFtAjfRqUW5CFC6t6TckTExFva+Hf0XVWUrvAPfKTvYsyK0NN/y+dR3s7zsOyJk= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-oa1-x34.google.com with SMTP id 586e51a60fabf-21fed501addso1588053fac.2; Sat, 09 Mar 2024 09:40:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1710005999; x=1710610799; 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=GZ9oW1a68FI8txjRtd5+Gm81zl9TNTPDLyBHtmXaJU8=; b=Ww2FaeVypgGhuPZX/qDchAUXLUUdK1UZciMf5RXf3MAawZkYQkar8H9T/kaBf1qnpn Aqr5LlrPfbG3jDSQNvBV/gD+GB0b+bR55ezwnBrQaWQnONu7FmeCtmF0+/6vzheSnnlx 2pRZIYA9nQuq+v8qx16U9b8kguBNStbyNGgejUTUKir1n2CnUu8zikzPExz0+hY6a+l+ sfzw0NIvl97n+y7RZizED5VzlUfOl2sA9vdvlBuo/vNNzbwHLnJST+TAg5aSETMd/QZY +/GpvEEhppXc1N2wDfiNwgaaT7RIefawvFgCQ4QsBnl/dVIRSoZutJy60iNa206E2cBW JLCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710005999; x=1710610799; 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=GZ9oW1a68FI8txjRtd5+Gm81zl9TNTPDLyBHtmXaJU8=; b=CRO8Hai49G+pbZz9cevA+JgQ0LI4Bw4hAAy3LjUTmhKkO20zAcMgTgG9Q1JsEzx8Gq yKpwMUodRNumt48vBQsuPgKiv6JKXrXBPcXpBjQkhLJTh2nfMfJ3Buai22ji1bdYz45+ d5x7I2no+C6V7rbzJZoUJClnI5e4RFzsvCW4xeyh8UJl2LFFLhp7AXLEJ74bgVUAoSi8 EiBikKzsAVa41Dle+LnK7SkEB8y5dBLSLDVKyarMb/hl47LN/0dGXtXR8hCfe6/VJDMH 4RrJYhgI1Dx/q3KqPMYUCgNxIa9a4YHzUmsSNP9+s+oKN6n/xy6wRma+BzTSYCGK3et+ jGDA== X-Forwarded-Encrypted: i=1; AJvYcCX1laKqV1MDjMEQGhUBreRWSvHgOx/31yZcNFZbXB0gglpjZndyt21CHdsSA+fFQyiDa4Gyu9gotEhEhNPZIvDXskyBd1iQn/2zGg== X-Gm-Message-State: AOJu0YzQ+LNhohxjlwrFHWZlnQrR+TEnbsBjp2Y8/XqFP3ixHA6ldcRd E5qdRtYaBmde2VloSi0ZJ263t4SMdFBneUopYSuh/7R7SMjCEFKA4u4N2eW1jE485jYYm+pFE9Z h+HAWQjcQ7n7LJ1GSXAXeVjPpXrFD+O/V X-Google-Smtp-Source: AGHT+IFp7QB6+OiRrlP5ln9fokIuPRJmwxY5+6u8Decb6iXhv0/DeMdl5hQYCwkqPbi6sjybWI0lTGPENkkqLsvlhPQ= X-Received: by 2002:a05:6870:ac0d:b0:21e:b2ee:75a4 with SMTP id kw13-20020a056870ac0d00b0021eb2ee75a4mr2412624oab.15.1710005999305; Sat, 09 Mar 2024 09:39:59 -0800 (PST) MIME-Version: 1.0 References: <20240216151711.2742988-1-hjl.tools@gmail.com> <20240216151711.2742988-2-hjl.tools@gmail.com> In-Reply-To: From: Noah Goldstein Date: Sat, 9 Mar 2024 11:39:48 -0600 Message-ID: Subject: Re: [PATCH v8 1/2] x86-64: Save APX registers in ld.so trampoline To: "H.J. Lu" Cc: GNU C Library , Florian Weimer , Adhemerval Zanella , Libc-stable Mailing List , Sunil K Pandey Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-9.4 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 Fri, Mar 8, 2024 at 2:09=E2=80=AFPM H.J. Lu wrote: > > On Sat, Feb 24, 2024 at 11:01=E2=80=AFAM Noah Goldstein wrote: > > > > On Fri, Feb 16, 2024 at 9:17=E2=80=AFAM H.J. Lu w= rote: > > > > > > Add APX registers to STATE_SAVE_MASK so that APX registers are saved = in > > > ld.so trampoline. This fixes BZ #31371. > > > > > > Also update STATE_SAVE_OFFSET and STATE_SAVE_MASK for i386 which will > > > be used by i386 _dl_tlsdesc_dynamic. > > > --- > > > sysdeps/x86/sysdep.h | 52 +++++++++++++++++++++++++++++++++++++++---= -- > > > 1 file changed, 46 insertions(+), 6 deletions(-) > > > > > > diff --git a/sysdeps/x86/sysdep.h b/sysdeps/x86/sysdep.h > > > index 85d0a8c943..837fd28734 100644 > > > --- a/sysdeps/x86/sysdep.h > > > +++ b/sysdeps/x86/sysdep.h > > > @@ -21,14 +21,54 @@ > > > > > > #include > > > > > > +/* The extended state feature IDs in the state component bitmap. */ > > > +#define X86_XSTATE_X87_ID 0 > > > +#define X86_XSTATE_SSE_ID 1 > > > +#define X86_XSTATE_AVX_ID 2 > > > +#define X86_XSTATE_BNDREGS_ID 3 > > > +#define X86_XSTATE_BNDCFG_ID 4 > > > +#define X86_XSTATE_K_ID 5 > > > +#define X86_XSTATE_ZMM_H_ID 6 > > > +#define X86_XSTATE_ZMM_ID 7 > > > +#define X86_XSTATE_PKRU_ID 9 > > > +#define X86_XSTATE_TILECFG_ID 17 > > > +#define X86_XSTATE_TILEDATA_ID 18 > > > +#define X86_XSTATE_APX_F_ID 19 > > > + > > > +#ifdef __x86_64__ > > > /* Offset for fxsave/xsave area used by _dl_runtime_resolve. Also n= eed > > > space to preserve RCX, RDX, RSI, RDI, R8, R9 and RAX. It must be > > > - aligned to 16 bytes for fxsave and 64 bytes for xsave. */ > > > -#define STATE_SAVE_OFFSET (8 * 7 + 8) > > > - > > > -/* Save SSE, AVX, AVX512, mask and bound registers. */ > > > -#define STATE_SAVE_MASK \ > > > - ((1 << 1) | (1 << 2) | (1 << 3) | (1 << 5) | (1 << 6) | (1 << 7)) > > > + aligned to 16 bytes for fxsave and 64 bytes for xsave. > > > + > > > + NB: Is is non-zero because of the 128-byte red-zone. Some regist= ers > > > + are saved on stack without adjusting stack pointer first. When w= e > > > + update stack pointer to allocate more space, we need to take the > > > + red-zone into account. */ > > > +# define STATE_SAVE_OFFSET (8 * 7 + 8) > > > + > > > +/* Save SSE, AVX, AVX512, mask, bound and APX registers. Bound and = APX > > > + registers are mutually exclusive. */ > > > +# define STATE_SAVE_MASK \ > > > + ((1 << X86_XSTATE_SSE_ID) \ > > > + | (1 << X86_XSTATE_AVX_ID) \ > > > + | (1 << X86_XSTATE_BNDREGS_ID) \ > > > + | (1 << X86_XSTATE_K_ID) \ > > > + | (1 << X86_XSTATE_ZMM_H_ID) \ > > > + | (1 << X86_XSTATE_ZMM_ID) \ > > > + | (1 << X86_XSTATE_APX_F_ID)) > > > +#else > > > +/* Offset for fxsave/xsave area used by _dl_tlsdesc_dynamic. Since = i386 > > > + doesn't have red-zone, use 0 here. */ > > > +# define STATE_SAVE_OFFSET 0 > > > + > > > +/* Save SSE, AVX, AXV512, mask and bound registers. */ > > > +# define STATE_SAVE_MASK \ > > > + ((1 << X86_XSTATE_SSE_ID) \ > > > + | (1 << X86_XSTATE_AVX_ID) \ > > > + | (1 << X86_XSTATE_BNDREGS_ID) \ > > > + | (1 << X86_XSTATE_K_ID) \ > > > + | (1 << X86_XSTATE_ZMM_H_ID)) > > > +#endif > > > > > > /* Constants for bits in __x86_string_control: */ > > > > > > -- > > > 2.43.0 > > > > > > > > > LGTM. > > Reviewed-by: Noah Goldstein > > OK to backport it to release branches? > > Thanks. Okay with it, but imo this type of system level change should have a bit longer of being tested in the realworld before backport. Maybe give it another week first?> > -- > H.J.