From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-oa1-x2d.google.com (mail-oa1-x2d.google.com [IPv6:2001:4860:4864:20::2d]) by sourceware.org (Postfix) with ESMTPS id 022A03858D28 for ; Fri, 16 Feb 2024 07:39:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 022A03858D28 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 022A03858D28 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2001:4860:4864:20::2d ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708069191; cv=none; b=VueQ5gWh+VE3gFzOvG70nPNFiZpLxUj49MbftPYZxJCBkf5GuPDr/iH9I4+vAoPqBWPcebBd+1lKyZczQ8fXIByB1+XvyH4krd1IUDM/tyEPlnJBvEtBuRuY2/S7+2p7GHR46dkmn5w0ggwQv8UFfx+JW9HZFIJyOEkh5kjvnAM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708069191; c=relaxed/simple; bh=rP3Unxyx6uOl+/qhCgNztbbxF/R52LGOS7EYfVxCPmc=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=gpnEysWyzMeQLUv886Mjr1TYLKnGzK3nEPJ6y7CVlSYcRIr7dvk6e2/PlfwT1rkXVPk+FaBzPD3kOH99y2CDzKQZOQHdtRgo6VJAvv2vvKEPtx2AprLs0vCnlG4q13odjMjEWMry0bwBbI957RnQEC93ha/CXhevfSXZt7gAC0c= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-oa1-x2d.google.com with SMTP id 586e51a60fabf-21e45ece781so261482fac.0 for ; Thu, 15 Feb 2024 23:39:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708069189; x=1708673989; 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=Al9SumGniWnBiGIU3Jw839DX+Lauty6yP1OZFLOz5F4=; b=AZFqRBO8D5umhTE1B3xXm4ujuk6xZYZzN6Zx0xuczlEdUAUPv6FMEExUertFeJ5rGn 6S7BkHFyIgxdsHKRgzIvkfuncZE8CBPz651+LYTKLahIa6pjK3xSzVkjaQPq1eJWLFZU ahNzn3csF1YW5KY0aEofY/cvePi2mBoykscmNl1XELFTgSmCY6IsEGAbTsSUzUrIChtB JKKFh/SzYfah+N/vUg0u5pz85ZFtfQ10ql4JIv+F/OVYzdHAYzTwKmCMFUVqK0ptKot7 he1gWpgbOw8U9LbHQjRmuwFrHAzlShxXew2sXZBEvCJs9kdjiYxy8+tZruKEKZxFKvYF YeIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708069189; x=1708673989; 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=Al9SumGniWnBiGIU3Jw839DX+Lauty6yP1OZFLOz5F4=; b=Kc2wk0VbDuIllvqXHwG7pdELB2RNnnGvrdWAqcIUAOHaVn5ru/ZCkUTm0T0sNzAstj tRsxrvQNNjMlJ7pmpv9mSMAAfRtsvVcPAONs1GcqGVOKKLy0b4QTTWGtdqAA9dawVKla +EaQ+nclqpV6KvKvVtbnli9KZLckWwrdBOlTImOSaSQWJVhK/GWyYjsEWbMecwh5HBmZ Uen2tPC7XSOeYL9yAota/ESc+56P+Wah2b/jnqpFJkSl+U9tsMjs8KYUKmd2i0wnZoRM a1h6Fek26kjw2knzT20L1Av5gp9EFfwePZagl6Ido6Y73OZCdn5hmbPfb0u/bUvjwyVH xEyA== X-Gm-Message-State: AOJu0Yy17CIk7ExSmWjaP1+4n0UDO6ULIlbzdHZtDnZZUG9Y3C8LHF/X ewjkBWfYWL+zxqeirsz57Y8lszARguAqneo87ww13mAMG8/MiPlMMMFoCUFxN0IZR9fVZsTpsdH MTIXI/8q12H3GNETtuVGnVJ4GFD8= X-Google-Smtp-Source: AGHT+IFvj/VpFVXxJeU/cpGr7Td8mjRAmCzRg7QZ6GsOXopDOv6gH80cSrR9fpfiISfCm45w/F+H6DpoGnoHfFjCLg8= X-Received: by 2002:a05:6870:a54d:b0:219:44b3:c6b0 with SMTP id p13-20020a056870a54d00b0021944b3c6b0mr4488396oal.45.1708069189171; Thu, 15 Feb 2024 23:39:49 -0800 (PST) MIME-Version: 1.0 References: <20240216002114.2255406-1-hjl.tools@gmail.com> <20240216002114.2255406-2-hjl.tools@gmail.com> In-Reply-To: <20240216002114.2255406-2-hjl.tools@gmail.com> From: Noah Goldstein Date: Fri, 16 Feb 2024 07:39:38 +0000 Message-ID: Subject: Re: [PATCH v7 1/2] x86-64: Save APX registers in ld.so trampoline To: "H.J. Lu" Cc: libc-alpha@sourceware.org, fweimer@redhat.com, adhemerval.zanella@linaro.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-9.2 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, Feb 16, 2024 at 12:21=E2=80=AFAM H.J. Lu wrot= e: > > 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 need > 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 registers > + are saved on stack without adjusting stack pointer first. When we > + 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)) Need tile here? > +#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 >