From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 191F83858C41 for ; Sat, 11 May 2024 10:08:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 191F83858C41 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 191F83858C41 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1715422135; cv=none; b=aqYC+0+TsTRYTqTJawmEQOh3Xq3b6tgNzstxMPpsbJd+ywOgP0MA7SSDbixwG6VoA2dMCnbzONVOfRy7U8e1PQuQ/JZ453ldZsdsoyj4O5U3nV7hX9INRAxJnJfUouHqSAJdaowAK45PGsGMO2mbDN+exTLvCLjg4dpRGj8OB/w= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1715422135; c=relaxed/simple; bh=5Y9PSUVforz4BLmMbTrrt8YKPD4as050r2cByA0tXIc=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=cwfWiBtx0gyzi++fCglV0BzwqSKd+FWevk+C248AjO7xDiLEGOv4zoFTCX0V2PUpbOo23zLCW+02qkQdMlYLtdJ8GzXjzeTg2zBQmc2tYblsb2582giXjZh07ViynHAC0WZIXtv/2bWHyMYatXNlY0JwU3hxd4nCyQdSFZCIC18= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1715422132; 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=hocNIUxR0fvxLrV49+tg7LKoOh/JA3kk9vmMDD5k8eo=; b=CzIGKJly67us9HY+jK/p/yhGAl6kF2IiKviOjJT2vsU4Lu/ozLJVAKtWFEAWOx3Qjb24It XOYv2IgkN1azZrEzCb79WTNYCbbWzBMQ32b3WLNI7AQ2b1uYsrQY9M61EHeeS6XX6WNzcw a878qD6HKkpSnURiVS49PzquUVkgWt8= Received: from mail-lf1-f71.google.com (mail-lf1-f71.google.com [209.85.167.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-371-JSXT1a_AM_u1xgyWqXSkFA-1; Sat, 11 May 2024 06:08:51 -0400 X-MC-Unique: JSXT1a_AM_u1xgyWqXSkFA-1 Received: by mail-lf1-f71.google.com with SMTP id 2adb3069b0e04-51fd3568b04so2548062e87.1 for ; Sat, 11 May 2024 03:08:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715422129; x=1716026929; 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=2lQ87tPQQIbOqF1OMYg2i/duuBDkXwFbOIKl0VMRBKY=; b=kWHe9lC50gDNeSdx+17QkvA0gxaGoic3Ibz3a2m/Kc26jS8tgTT3EbCxr97Q8518pN Y0HOXVg/PG7YdM0aKosiUT3jGKIHVnVMgYCfzDZjbydXBgPmOmFhcSQHhd+HI6OGS9fV sJZh0OAnaoMwM1IXeOGTZYADRBco+zpvRy4jNsqD1+jOq6BwFe48Qg96/I6ECa391Zc6 UvwgsrkmhRnN3eTtwMFa6flw9OyO0227IDhJmXYIAZ3nB7Hgt+j3euFNXzd2Yi4ci8bi fyUJx/+K/+F1WwqmXmw6zfVwHI3kePxjJbwV3PE61L9m7fcJMEEo7fkH7VX1DuIgJFwp MAGw== X-Gm-Message-State: AOJu0YxMke0hex7czQ4wsW/XJOkqF4joYutAkvyCPVaXFz2jQSa8FJyl 5iEnt/ujobLjQ25e2SsESAXRCbGszH1fpiertz/AUvffiTBfFWJ3vu+ESHRViqH2hzhmdP097NI 1A++/suzKYj2mOrwuXBmyPw/ImOjMOVjupn4DwYctFn5UfUq/t3LRF9yVFYLlrRSdazMdsCCoXl HiToKpsp6a6JX4CdF1Knpvu+a9T5Og4t5KI4JJpLDJj0U= X-Received: by 2002:a05:6512:290:b0:522:32c0:bb6e with SMTP id 2adb3069b0e04-52232c0bbf6mr1542458e87.23.1715422128730; Sat, 11 May 2024 03:08:48 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEm1N0f5cBxKiPE9tXBRByNBRub/TQRN5+DG4bkmVWQ6z/2yec+BwtfU6XMDidZg0y1P1y/GA== X-Received: by 2002:a05:6512:290:b0:522:32c0:bb6e with SMTP id 2adb3069b0e04-52232c0bbf6mr1542435e87.23.1715422128039; Sat, 11 May 2024 03:08:48 -0700 (PDT) Received: from localhost (92.40.185.101.threembb.co.uk. [92.40.185.101]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3502b8a791esm6608935f8f.64.2024.05.11.03.08.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 11 May 2024 03:08:46 -0700 (PDT) From: Andrew Burgess To: gdb-patches@sourceware.org Cc: Andrew Burgess , felix.willgerodt@intel.com, jhb@FreeBSD.org Subject: [PATCHv7 1/9] gdb/gdbserver: share I386_LINUX_XSAVE_XCR0_OFFSET definition Date: Sat, 11 May 2024 11:08:31 +0100 Message-Id: <8685cc8a396015661afd96b38cf5f68d41c05a8e.1715421687.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=-7.0 required=5.0 tests=BAYES_00,DKIM_INVALID,DKIM_SIGNED,GIT_PATCH_0,KAM_DMARC_NONE,KAM_DMARC_STATUS,RCVD_IN_ABUSEAT,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_NONE,TXREP 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: Share the definition of I386_LINUX_XSAVE_XCR0_OFFSET between GDB and gdbserver. This commit moves the definition into gdbsupport/x86-xstate.h, which allows the #define to be shared. There should be no user visible changes after this commit. Approved-By: Felix Willgerodt --- gdb/i386-linux-tdep.h | 20 -------------------- gdbserver/linux-x86-low.cc | 21 --------------------- gdbsupport/x86-xstate.h | 20 ++++++++++++++++++++ 3 files changed, 20 insertions(+), 41 deletions(-) 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/gdbserver/linux-x86-low.cc b/gdbserver/linux-x86-low.cc index 2603fb2ac5d..6de44aeb2d9 100644 --- a/gdbserver/linux-x86-low.cc +++ b/gdbserver/linux-x86-low.cc @@ -831,27 +831,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. */ diff --git a/gdbsupport/x86-xstate.h b/gdbsupport/x86-xstate.h index 89c1143fbe1..11b37544aa3 100644 --- a/gdbsupport/x86-xstate.h +++ b/gdbsupport/x86-xstate.h @@ -120,4 +120,24 @@ constexpr bool operator!= (const x86_xsave_layout &lhs, #define I387_MXCSR_INIT_VAL 0x1f80 +/* 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 + #endif /* COMMON_X86_XSTATE_H */ -- 2.25.4