From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id gFjzOI+5u2XcfA8AWB0awg (envelope-from ) for ; Thu, 01 Feb 2024 10:32:31 -0500 Authentication-Results: simark.ca; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=LnkUJ2gQ; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id E36291E0D0; Thu, 1 Feb 2024 10:32:31 -0500 (EST) Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id CC0671E092 for ; Thu, 1 Feb 2024 10:32:29 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 446343860765 for ; Thu, 1 Feb 2024 15:32:29 +0000 (GMT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id D32393857BAB for ; Thu, 1 Feb 2024 15:28:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D32393857BAB Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org D32393857BAB Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1706801335; cv=none; b=t8E+7QiGGenO80/3lHBOnMnsX7xID2rIjwoqUs+bzc8VbjOhhbfYZvnXEvMmxFOvqHahyeKWnqguRWYcVgDltwaCeTS816z4iBsLw6SnEkOyYqR7XNr1W6hy5AcrpVD/9+MqgpfuTU88dA+Qz2ekK14H37h3RI2/INQPC5OtYQw= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1706801335; c=relaxed/simple; bh=r8aKnFPvjMfySKtPOQUl4o1CDFHdSvTDWRGCsBc3bEQ=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=hSU8vgpATHABCnn+3fFxgy0vwURw+g/iDT/V7KrQ31h2cs3qWz3ARHUQM4ENHPlOWOOE0EJs2PHEkqQCBOcJ8ZvIpO7p1+18cYgno22v8nTp7zc/Vv9NToQn8A6PyOfO7Yx7wEeCoVXPFzDkWbRfKa1kOjpJ0ps9xTqLoMNSyCc= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1706801327; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=PpdS64XSgIzTslXk38Lx34afdAewAItZ2Y2fhUfhd4w=; b=LnkUJ2gQMD5uahbYAxjIC8logXjmj4M9t0bnQV+eWKV61ixh2DzDVvtjFlUtFvQIsiuR7Q iSDmdXE/YpV7x2bw9L0LLavw2WZEGgjtDJjvKNsiIDx3YWWushDk3OfDHnfyAnCUgzNMh2 lNCkSexlBZ3cg6OMDAa9u0/LIMcwIOw= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-156-ky4wpbrbO3eYFJtNYwsDYg-1; Thu, 01 Feb 2024 10:28:46 -0500 X-MC-Unique: ky4wpbrbO3eYFJtNYwsDYg-1 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-40e4478a3afso4533065e9.1 for ; Thu, 01 Feb 2024 07:28:45 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706801324; x=1707406124; 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=/RzWi/6+iiUg0Ib6btw8S5tv2SrGNcYqtHYFoEFcTUc=; b=AyIQRRv0OYvl/v2Crn29/cwdFK6ZBNRkgCrEzn/UFjwHIaYEXzjE20AzM8o08GSOG/ jUhvdMjEEUZZDLv/f7HeayXqKnxXcT0dQDYwnZaZ2Q4o1/9oXzkVej/QsgVVaWF//fcB BJyLm+yNVa34V8qtKuOp3KZ9yl9b4Yty3B3iRQF5hI7X0YlYj1LdxFfQi+tVGxKjGLpi KfmUHORGA6z8HtYZ7UWs+P0PqHdHtk0Hq5yYSvrE2+tey6/zjlisv8CRgC6vz1vwD40R eRSjRMlgxQRBmZqTnaWHuEIAfqq/RNVXlqVijvKk11orqA3aMmmjp4161AGlOqKv1Aq5 YJcg== X-Gm-Message-State: AOJu0YyYihBsLGZAxh2+c3m3sy0EheV2kLpDHTWUBxBaDJZvKv//kF/4 OznEIpOHuDXTb9NNyj3qXgL29ly4GZVZLqLHWFVckooXTXxPz4XvBOjGe0EnixILgVEe+JO+Uky ipnRGChHxRzPIVsLisxoVMaw5ho6oNizUNKgYKQwss0J2TnZvD8UqzU8mmwfKJcMMKAPCzVXvNw lcE7GKcrMYUherbGvsPhivUOMe8sF8gAEZz8Y/CVvcZ9c= X-Received: by 2002:a05:600c:1d97:b0:40d:62c4:3ea with SMTP id p23-20020a05600c1d9700b0040d62c403eamr4841362wms.6.1706801324618; Thu, 01 Feb 2024 07:28:44 -0800 (PST) X-Google-Smtp-Source: AGHT+IGYRxNjiEHbPO3rO3n7qsGFm15HR1PYwqPrxeJ8De41rx14uSnTxlcJKzvVZxro3RrJe4UPIw== X-Received: by 2002:a05:600c:1d97:b0:40d:62c4:3ea with SMTP id p23-20020a05600c1d9700b0040d62c403eamr4841346wms.6.1706801324285; Thu, 01 Feb 2024 07:28:44 -0800 (PST) Received: from localhost (185.223.159.143.dyn.plus.net. [143.159.223.185]) by smtp.gmail.com with ESMTPSA id u7-20020a05600c19c700b0040fbe0ad3efsm1613681wmq.45.2024.02.01.07.28.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Feb 2024 07:28:43 -0800 (PST) From: Andrew Burgess To: gdb-patches@sourceware.org Cc: Andrew Burgess Subject: [PATCH 4/7] gdb/gdbserver: share I386_LINUX_XSAVE_XCR0_OFFSET definition Date: Thu, 1 Feb 2024 15:28:31 +0000 Message-Id: <220d6fbce7f3515fced151314b88b1d2e49beb2d.1706801009.git.aburgess@redhat.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: References: MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true X-Spam-Status: No, score=-11.8 required=5.0 tests=BAYES_00, DKIM_INVALID, DKIM_SIGNED, GIT_PATCH_0, KAM_DMARC_NONE, KAM_DMARC_STATUS, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, 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: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Share the definition of I386_LINUX_XSAVE_XCR0_OFFSET between GDB and gdbserver. This commit is part of a series that aims to share more of the x86 target description creation code between GDB and gdbserver. The I386_LINUX_XSAVE_XCR0_OFFSET #define is used as part of the target description creation, and I noticed that this constant is defined separately for GDB and gdbserver. This commit moves the definition into gdb/nat/x86-linux.h, which allows the #define to be shared. There should be no user visible changes after this commit. --- gdb/amd64-linux-tdep.c | 1 + gdb/i386-linux-tdep.c | 1 + gdb/i386-linux-tdep.h | 20 -------------------- gdb/nat/x86-linux.h | 20 ++++++++++++++++++++ gdbserver/linux-x86-low.cc | 22 +--------------------- 5 files changed, 23 insertions(+), 41 deletions(-) diff --git a/gdb/amd64-linux-tdep.c b/gdb/amd64-linux-tdep.c index fe7f5d4a259..051c3f74eda 100644 --- a/gdb/amd64-linux-tdep.c +++ b/gdb/amd64-linux-tdep.c @@ -42,6 +42,7 @@ #include "arch/amd64.h" #include "target-descriptions.h" #include "expop.h" +#include "nat/x86-linux.h" /* The syscall's XML filename for i386. */ #define XML_SYSCALL_FILENAME_AMD64 "syscalls/amd64-linux.xml" diff --git a/gdb/i386-linux-tdep.c b/gdb/i386-linux-tdep.c index 27aea18c436..43cb2961e28 100644 --- a/gdb/i386-linux-tdep.c +++ b/gdb/i386-linux-tdep.c @@ -40,6 +40,7 @@ #include "i387-tdep.h" #include "gdbsupport/x86-xstate.h" +#include "nat/x86-linux.h" /* The syscall's XML filename for i386. */ #define XML_SYSCALL_FILENAME_I386 "syscalls/i386-linux.xml" diff --git a/gdb/i386-linux-tdep.h b/gdb/i386-linux-tdep.h index 5891747572b..07593c6a8ec 100644 --- a/gdb/i386-linux-tdep.h +++ b/gdb/i386-linux-tdep.h @@ -58,26 +58,6 @@ extern void i386_linux_report_signal_info (struct gdbarch *gdbarch, /* Return the target description according to XCR0. */ extern const struct target_desc *i386_linux_read_description (uint64_t xcr0); -/* Format of XSAVE extended state is: - struct - { - fxsave_bytes[0..463] - sw_usable_bytes[464..511] - xstate_hdr_bytes[512..575] - extended state regions (AVX, MPX, AVX512, PKRU, etc.) - }; - - Same memory layout will be used for the coredump NT_X86_XSTATE - representing the XSAVE extended state registers. - - The first 8 bytes of the sw_usable_bytes[464..467] is the OS enabled - extended state mask, which is the same as the extended control register - 0 (the XFEATURE_ENABLED_MASK register), XCR0. We can use this mask - together with the mask saved in the xstate_hdr_bytes to determine what - states the processor/OS supports and what state, used or initialized, - the process/thread is in. */ -#define I386_LINUX_XSAVE_XCR0_OFFSET 464 - extern int i386_linux_gregset_reg_offset[]; /* Return x86 siginfo type. */ diff --git a/gdb/nat/x86-linux.h b/gdb/nat/x86-linux.h index 15153ea277e..855a8d14f91 100644 --- a/gdb/nat/x86-linux.h +++ b/gdb/nat/x86-linux.h @@ -22,6 +22,26 @@ #include "nat/linux-nat.h" +/* Format of XSAVE extended state is: + struct + { + fxsave_bytes[0..463] + sw_usable_bytes[464..511] + xstate_hdr_bytes[512..575] + extended state regions (AVX, MPX, AVX512, PKRU, etc.) + }; + + Same memory layout will be used for the coredump NT_X86_XSTATE + representing the XSAVE extended state registers. + + The first 8 bytes of the sw_usable_bytes[464..467] is the OS enabled + extended state mask, which is the same as the extended control register + 0 (the XFEATURE_ENABLED_MASK register), XCR0. We can use this mask + together with the mask saved in the xstate_hdr_bytes to determine what + states the processor/OS supports and what state, used or initialized, + the process/thread is in. */ +#define I386_LINUX_XSAVE_XCR0_OFFSET 464 + /* Set whether our local mirror of LWP's debug registers has been changed since the values were last written to the thread. Nonzero indicates that a change has been made, zero indicates no change. */ diff --git a/gdbserver/linux-x86-low.cc b/gdbserver/linux-x86-low.cc index ec80bfe905c..7bade8b3cbf 100644 --- a/gdbserver/linux-x86-low.cc +++ b/gdbserver/linux-x86-low.cc @@ -27,6 +27,7 @@ #include "gdbsupport/x86-xstate.h" #include "nat/x86-xstate.h" #include "nat/gdb_ptrace.h" +#include "nat/x86-linux.h" #ifdef __x86_64__ #include "nat/amd64-linux-siginfo.h" @@ -832,27 +833,6 @@ x86_target::low_siginfo_fixup (siginfo_t *ptrace, gdb_byte *inf, int direction) static int use_xml; -/* Format of XSAVE extended state is: - struct - { - fxsave_bytes[0..463] - sw_usable_bytes[464..511] - xstate_hdr_bytes[512..575] - avx_bytes[576..831] - future_state etc - }; - - Same memory layout will be used for the coredump NT_X86_XSTATE - representing the XSAVE extended state registers. - - The first 8 bytes of the sw_usable_bytes[464..467] is the OS enabled - extended state mask, which is the same as the extended control register - 0 (the XFEATURE_ENABLED_MASK register), XCR0. We can use this mask - together with the mask saved in the xstate_hdr_bytes to determine what - states the processor/OS supports and what state, used or initialized, - the process/thread is in. */ -#define I386_LINUX_XSAVE_XCR0_OFFSET 464 - /* Does the current host support the GETFPXREGS request? The header file may or may not define it, and even if it is defined, the kernel will return EIO if it's running on a pre-SSE processor. */ -- 2.25.4