From patchwork Tue Feb 13 04:15:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "H.J. Lu" X-Patchwork-Id: 85643 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D76193858419 for ; Tue, 13 Feb 2024 04:15:34 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pl1-x634.google.com (mail-pl1-x634.google.com [IPv6:2607:f8b0:4864:20::634]) by sourceware.org (Postfix) with ESMTPS id C9D043858C2C for ; Tue, 13 Feb 2024 04:15:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C9D043858C2C 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 C9D043858C2C Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::634 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1707797706; cv=none; b=Tlv6vY/0BAjU1qGiQwSEj5KJ0TAF3tM7DS6Dd2KVErisWjioIRhXY5zzFYJZCEM2Ng2qHFBm8W79iSFPHnzPpCxKijo2PjdHdcw3OOHqh3WCV7mNW9W/jTrnOWkecQFJxXbOKfYOt8v2beE9AnNYFs/+bpCNyD3NaiQT3MnQZBA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1707797706; c=relaxed/simple; bh=bTcKb7D7h6nZzzANXLvWdj8SR9uew8//AcmxfxS0vmw=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=n2wAfLzRwfseJHcxwjqXzuCHV2Ekx71cS9+iYbxR12LEjGd12Rz3ElTrZH2fqglrGuBtUO9PQUK68pPTFkKsg+3IWgzo9xfTT6f6oCIh5aQfZVKemljCN9A4an94sI6mPEI8MtFj30EiDVX77C4P5euDhhk3npde8K8ndMsOtPA= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pl1-x634.google.com with SMTP id d9443c01a7336-1da0cd9c0e5so27928235ad.0 for ; Mon, 12 Feb 2024 20:15:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707797703; x=1708402503; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=JDFMZbN2eSG0GaRA2C1J+IkWL0jrdNGLAnhsqocTMxs=; b=BjTbk9/BcuI0sXFI2IVZYB47+YHPRRwNagchnrizNPWeLvq/ols994nMzEKRjAp3C0 Z1PWitB3etShTLeZyto5FkkUB7XjSQZtYnD7+3Q7qk/GfdkmnxKdXxcQXl+J++SnYBdf 8zyPHErY3YVvcvGuuyi3FenAeCBQjmPWXEKLngdukjLDSCluObJmo5LO3tBTcMYtS411 CFMvg6Zl1TtqUXSPPOtTZ873T2vnIJJ2AToG9qrcs51jrzu9k28CP4+Q5bVJp6C6B78B BErcFgZNRHn34+D2RRczmGomxCoFjgkUdYivg00gs4LjtTk9oRayybg7RxFbDf4fxBl1 /wuA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707797703; x=1708402503; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=JDFMZbN2eSG0GaRA2C1J+IkWL0jrdNGLAnhsqocTMxs=; b=YB8RQTvXSdiUwtrUCrUUI1oT/r01XhgkWwclrXt2uPJwL7+0siOipfnNT3DCqr5++g k24G/ICU5o5CklVHdWBBMPU89M1IQnlg5YmQycDEatKHO7cVDaQNR160Guf7zR8tWll0 +BmkLjiNG99l9/T+lg162b1BRh+QJZ0gMPBEdKpqvVIkQQ9fi27Ij1qYTV13s3kO7/M0 VBxglJ/E48b9ED6BLFrsfcdA1NkrVv4HA51u2tEUELZ2YMkq9uC+rUbpoTi1h8ZDpWkm XH/epxQDPcEzhIxz1IkvbyuzYdSzdnHNyvuwfv+Xqv0LTGp8t2p7dtlZ7y29YqvkiTxj fYRA== X-Gm-Message-State: AOJu0Yxkh9iBt5OfZHAdIGCYRVU0n7CjE/iOZjyn1/b27JsjOMsUc64p ouU+TEA/kzA+aB30oMxx+N9GwJpgfXlkXl16qOWe1bjcvVWvbP3I+Wh1ga2K X-Google-Smtp-Source: AGHT+IHLGX0vYn78yOwsQWZhoUsZPXZxu7ydhVQgsxYKW5pOa5J1YlXJC5DITC7GFW4JzAijTH74iQ== X-Received: by 2002:a17:90a:9b04:b0:298:9d78:b2c9 with SMTP id f4-20020a17090a9b0400b002989d78b2c9mr1783481pjp.8.1707797703183; Mon, 12 Feb 2024 20:15:03 -0800 (PST) Received: from gnu-cfl-3.localdomain ([172.56.168.224]) by smtp.gmail.com with ESMTPSA id sz13-20020a17090b2d4d00b0029552a03219sm1374549pjb.29.2024.02.12.20.15.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Feb 2024 20:15:02 -0800 (PST) Received: from gnu-cfl-3.. (localhost [IPv6:::1]) by gnu-cfl-3.localdomain (Postfix) with ESMTP id 797AF7402CA for ; Mon, 12 Feb 2024 20:15:01 -0800 (PST) From: "H.J. Lu" To: libc-alpha@sourceware.org Subject: [PATCH v4 1/2] x86-64: Save APX registers in ld.so trampoline Date: Mon, 12 Feb 2024 20:15:00 -0800 Message-ID: <20240213041501.2494232-2-hjl.tools@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240213041501.2494232-1-hjl.tools@gmail.com> References: <20240213041501.2494232-1-hjl.tools@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-3020.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_ABUSEAT, RCVD_IN_DNSWL_NONE, RCVD_IN_SBL_CSS, 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 X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org 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 | 50 ++++++++++++++++++++++++++++++++++++++------ 1 file changed, 44 insertions(+), 6 deletions(-) diff --git a/sysdeps/x86/sysdep.h b/sysdeps/x86/sysdep.h index 85d0a8c943..5c1f0bcf53 100644 --- a/sysdeps/x86/sysdep.h +++ b/sysdeps/x86/sysdep.h @@ -21,14 +21,52 @@ #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_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)) +#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: */