From patchwork Fri Feb 16 00:21:13 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: 85851 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 04B15385841C for ; Fri, 16 Feb 2024 00:22:17 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-oa1-x29.google.com (mail-oa1-x29.google.com [IPv6:2001:4860:4864:20::29]) by sourceware.org (Postfix) with ESMTPS id 3D4E43858402 for ; Fri, 16 Feb 2024 00:21:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3D4E43858402 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 3D4E43858402 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2001:4860:4864:20::29 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708042888; cv=none; b=xzI417FsRWsYNTDbagS3HT9OrL8ni/g6KH2eRPBBRyEu+3H5arci9eNrFxUVaKBv3qCFzHqwNfWp1sG4fL6hCicFcMluuhJBNMnbmgzty7qKRy6bZ0mLlUOkEkw9pQCAg+tzZiIO1VSgd9VElzVPGkx3zPxOhoMbvhsFEDNTCLY= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708042888; c=relaxed/simple; bh=AmaP4NBSXAjWXAYjyDLvotKTsvmbnDa8aVZcFGCSD0g=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=muBhJ/9E5Tq1BHB8aVcXd163VV/cGhSsg2ged0zqXvljGqa8ah6GH/whN/VnHzhOok6yRfineWtagrvKqhe1GxPSuo+Ah3mFTbYx2lBIj1d1u4ate5s78yUqfcfTypewjXneFY8gR3pwgt7IH+PWi+jYMpvWki2ONdl3S05wPHM= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-oa1-x29.google.com with SMTP id 586e51a60fabf-219452bdf81so946688fac.2 for ; Thu, 15 Feb 2024 16:21:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708042876; x=1708647676; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=IFv6teZ6H/OJP5DU8POwM4h+WqkzO/3BTNGGL2IqGjo=; b=dgyDdleYvw33PUS1roweApyMhQG6qHQMT9AU+XfW40WDcYmgjh96aBqO2IkpdP2qN5 OL7touWr1kmgxy7OQoYGgR4uMnk3ax4Q0hEHLvNFqJwzCyfNFlCYbJqZFPosnhJJWig4 xPVgaHmd/HETUZWyi4jp/q50HJAq7p5IA1d0+d65BuZHLobYPJbaSMXoP7nGvqYJVDPR x9pr1sqS9aI01SK3I7934mcYQOj9nBOpz0XGKa92+DWCd5aJRsRLp11xDJyQoCvclGcj iGmpGludeINj5p62WnWmQXU+zcYxLI3E4bxK95eretm3AXpi+swxR1z9DLI9awIurunP 6H8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708042876; x=1708647676; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=IFv6teZ6H/OJP5DU8POwM4h+WqkzO/3BTNGGL2IqGjo=; b=PXzwJa0bkFcp1KRj+IyQC9SD81pHnAHwmEuvpMdM5EDcypXeX176BH8wghbRe5U77M hKgP2nqe6LP2ZpSGmznfNoC0iOBkDAdccxqcdynGMpiVXl9hic7PNrto6P3llB26Y3c6 Nk0oGtHvGZ1x6hDWZpPrG7RqNEucEPO4Gcj243DvJUMVcA8WSbDWBE+owtmvvWMpVgNc m53wB4MfxYg0foxPmuJcOhwU5F5uDlZkKhfYsMrATGEZb/ymyLmK/zfH0TfKVwbRCoSP tSicdNRlKbi0DyZ5CFxYN31gUnwfsMxa31EuFD7HLqPeWBGeFtwTSaIY6mGcWYHKqrrE yUaw== X-Gm-Message-State: AOJu0YxcCuj6/rzhan/i33/Fv4gRsJzvDxXpn0S8qykCSmVktIXrQRHB k9UCcbuGkh9MeXhwoD72OQm2IYz7ods+oqB50sAKnCE/R/I8yXhk X-Google-Smtp-Source: AGHT+IFohK/ipUtVrooNZlfYPjXPkgusI/+T3BmBvBNVo/w5DHWxIq6h+9xtjCkW02DciKzOTEiuUQ== X-Received: by 2002:a05:6870:1581:b0:219:36ad:bcd4 with SMTP id j1-20020a056870158100b0021936adbcd4mr3580475oab.38.1708042876172; Thu, 15 Feb 2024 16:21:16 -0800 (PST) Received: from gnu-cfl-3.localdomain ([172.58.89.72]) by smtp.gmail.com with ESMTPSA id cn6-20020a056a020a8600b005c6617b52e6sm1767863pgb.5.2024.02.15.16.21.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 16:21:15 -0800 (PST) Received: from gnu-cfl-3.. (localhost [IPv6:::1]) by gnu-cfl-3.localdomain (Postfix) with ESMTP id 9BEDD74064A; Thu, 15 Feb 2024 16:21:14 -0800 (PST) From: "H.J. Lu" To: libc-alpha@sourceware.org Cc: goldstein.w.n@gmail.com, fweimer@redhat.com, adhemerval.zanella@linaro.org Subject: [PATCH v7 1/2] x86-64: Save APX registers in ld.so trampoline Date: Thu, 15 Feb 2024 16:21:13 -0800 Message-ID: <20240216002114.2255406-2-hjl.tools@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240216002114.2255406-1-hjl.tools@gmail.com> References: <20240216002114.2255406-1-hjl.tools@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-3019.8 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 | 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)) +#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: */