From patchwork Wed Feb 28 20:08:02 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: 56741 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 1958F3858431 for ; Wed, 28 Feb 2024 20:08:34 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pl1-x636.google.com (mail-pl1-x636.google.com [IPv6:2607:f8b0:4864:20::636]) by sourceware.org (Postfix) with ESMTPS id A1C0E3858D39 for ; Wed, 28 Feb 2024 20:08:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A1C0E3858D39 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 A1C0E3858D39 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::636 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1709150888; cv=none; b=OEYJtZol0YT6BVn8Fm9bkq1QmMDjrhhkgXkHxIg+Kd5BuPuLReWllS2zOILZTb8uwn4OlIj5/duewag/ftFV5RcyLpPF8unLhCkSGFh+d1M8iEXZHhCSxADSJLjiqrpwAUsOTZJviDK1mlVDZBvJDUy9Hvm6ouwVpuTrZgSd454= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1709150888; c=relaxed/simple; bh=w/7LVPWN1FlYfJgZMAvCEfn319Bz4fEcGziCxmRgfds=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=kD1PqOw0iCls5TFmjtr6y2xomgO8xAyP3LjAAizoZFGHu3ee+blicustI6i9kkkpJnQW0Nn5i9BVJMg5S+9LEddZemdfqHtkJy6XlDYnDgjhlkGwxq2RRi3kpdzIz9AzV649qPpewCjgbhwzzF5CCb4LNVIodVp0R/sN46SkBHA= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pl1-x636.google.com with SMTP id d9443c01a7336-1dbae7b8ff2so1695265ad.3 for ; Wed, 28 Feb 2024 12:08:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709150885; x=1709755685; darn=sourceware.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=GLzyf9vpCarkgzEsEFuCrWAWL3B7U9pe8JutwJ7uK+s=; b=bBWCsIv0TcQH/nTNZcIWOR1nEYVUyyCKh8bREJ0RNZXR1+F1xwqXM66F43k3MMTM1R 2xgA5azPLoQCc5LK0XfXoURX/JJleSrXMo9z+LIPFXIkRWmBb1LyLo2B2Othx8FWE2k0 v+GyKP0TsCN6lg+lu+Y2wQ2jMZ9yMWgKxHYfLk2e3swAe0HkWtUvJrF8Yh6QY7Az1Y3h 11cn7A+V6vo9nsCD5oVNRkD6DBFUTNFslM/+hv2FTZDJjWkuNOLkrqwRoxburRYAI7ch 54KiZLFRiygE8tX0QRf7lk/FHGjIUx7QyIaygOhSw3wGWRB60GKLib3EUx+FK+1kHO8M IWNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709150885; x=1709755685; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=GLzyf9vpCarkgzEsEFuCrWAWL3B7U9pe8JutwJ7uK+s=; b=NpboYjCJSAdocmoeuldnDTCS+mp4o734+nBWfBr44emKMEVX6SG2RVhAEHcUC8/LNo kua9mO16HCZw/KDuD2/sLLsnD2QFRGlH1wDGaw2V1JpXawwd3bqyoTpT6PZixkStLaWq Gm5zuNaZLiTRHuaHSzvZf1KhL5LE7oytTgPSFumI09rsP6B0pNe4zmkV2Oed9rOJx+CU eDgL+DfUmX4LM8i6w6pv+4vsGL90u7U1OWIo2QoFMbOZrChWu8zhhTQqMGW7e1b6QWUk 3ou0+Ei0DepaT6/XuP1lwn9eutCPDIKJQlsuMWbCKaYkVvDXrqH+KKpqxJH4MjQgL5On 8Zlw== X-Gm-Message-State: AOJu0YytS73UWFaMy2Zd0oF3bYZmwYU31fICMuNt9G3RDpLZs3Nrc53T XXnOTRh06h7QMYWTAzb52tMh0gcaZ5Fu+v1mJIkyRjvae4ROEpgvLYHwqwT5 X-Google-Smtp-Source: AGHT+IEi1kuCqyrD0q77JrApvb+g+V2vvnSkf4VFwhY3aHbf0mGUwNmNrzseskidDZ2B1Qt+fHKphA== X-Received: by 2002:a17:903:50b:b0:1dc:d642:aacd with SMTP id jn11-20020a170903050b00b001dcd642aacdmr142185plb.67.1709150885511; Wed, 28 Feb 2024 12:08:05 -0800 (PST) Received: from gnu-cfl-3.localdomain ([172.58.89.72]) by smtp.gmail.com with ESMTPSA id kl14-20020a170903074e00b001dc95e7e191sm3664394plb.298.2024.02.28.12.08.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Feb 2024 12:08:05 -0800 (PST) Received: from gnu-cfl-3.. (localhost [IPv6:::1]) by gnu-cfl-3.localdomain (Postfix) with ESMTP id 14D0F740093; Wed, 28 Feb 2024 12:08:04 -0800 (PST) From: "H.J. Lu" To: libc-alpha@sourceware.org Cc: goldstein.w.n@gmail.com, skpgkp2@gmail.com Subject: [PATCH v2 0/1] x86-64: Update _dl_tlsdesc_dynamic to preserve AMX registers Date: Wed, 28 Feb 2024 12:08:02 -0800 Message-ID: <20240228200804.2328362-1-hjl.tools@gmail.com> X-Mailer: git-send-email 2.43.2 MIME-Version: 1.0 X-Spam-Status: No, score=-3013.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, KAM_SHORT, RCVD_IN_DNSWL_NONE, RCVD_IN_SBL_CSS, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=no 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 Changes in v2: 1. Unroll the first loop in init_tile_config in AMX test. --- _dl_tlsdesc_dynamic should also preserve AMX registers which are caller-saved. Add X86_XSTATE_TILECFG_ID and X86_XSTATE_TILEDATA_ID to x86-64 TLSDESC_CALL_STATE_SAVE_MASK. Compute the AMX state size and save it in xsave_state_full_size which is only used by _dl_tlsdesc_dynamic_xsave and _dl_tlsdesc_dynamic_xsavec. This fixes the AMX part of BZ #31372. Tested on AMX processor. AMX test is enabled only for compilers with the fix for https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114098 GCC 14 and GCC 11/12/13 branches have the bug fix. --- H.J. Lu (1): x86-64: Update _dl_tlsdesc_dynamic to preserve AMX registers sysdeps/unix/sysv/linux/x86_64/Makefile | 27 ++++++ .../sysv/linux/x86_64/include/asm/prctl.h | 5 ++ .../linux/x86_64/tst-gnu2-tls2-amx-mod0.c | 2 + .../linux/x86_64/tst-gnu2-tls2-amx-mod1.c | 2 + .../linux/x86_64/tst-gnu2-tls2-amx-mod2.c | 2 + .../sysv/linux/x86_64/tst-gnu2-tls2-amx.c | 83 +++++++++++++++++++ .../sysv/linux/x86_64/tst-gnu2-tls2-amx.h | 63 ++++++++++++++ sysdeps/x86/cpu-features-offsets.sym | 1 + sysdeps/x86/cpu-features.c | 55 +++++++++++- sysdeps/x86/include/cpu-features.h | 2 + sysdeps/x86/sysdep.h | 18 +++- sysdeps/x86_64/configure | 28 +++++++ sysdeps/x86_64/configure.ac | 15 ++++ sysdeps/x86_64/dl-tlsdesc-dynamic.h | 2 +- 14 files changed, 299 insertions(+), 6 deletions(-) create mode 100644 sysdeps/unix/sysv/linux/x86_64/tst-gnu2-tls2-amx-mod0.c create mode 100644 sysdeps/unix/sysv/linux/x86_64/tst-gnu2-tls2-amx-mod1.c create mode 100644 sysdeps/unix/sysv/linux/x86_64/tst-gnu2-tls2-amx-mod2.c create mode 100644 sysdeps/unix/sysv/linux/x86_64/tst-gnu2-tls2-amx.c create mode 100644 sysdeps/unix/sysv/linux/x86_64/tst-gnu2-tls2-amx.h