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 B41283845BE1 for ; Wed, 8 May 2024 16:46:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B41283845BE1 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 B41283845BE1 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=1715186815; cv=none; b=jRs6IHEI9wBhhJQexWhxOBSkjo52B1VN8rH4H7cQs1LrBGWQKrct0JAPzJAhr+xzq1WunYyd8Ym5993kZFkbywjJsL7PcqJcOM1+Cg+8lWxoM4bsOd5WJLEMHJRV/jSyxymeFf8cTM014cgBcA+bFNhDcGPpx8f12qQIUXedufw= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1715186815; c=relaxed/simple; bh=5Y9PSUVforz4BLmMbTrrt8YKPD4as050r2cByA0tXIc=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=Pl2zdxcjS6uxmbftGKNG8guptkf9uBWQaVbYHCzZufQClgYYCvGnrVXZEgyxXc5N85rhv4VX5luk1GoPL73nagOynFjvUcfoME9u7PCI//FjFuZet2Hf4Htn108e2sVpt8e7jvpbPCqbzs5pJLr8lwvwjFvjuFjqJlimbFuaK28= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1715186812; 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=aBhR/AR8IBG1mIQ4sbSOfdSuHWG+CDAk1IlU6wKnkuYVYKzrXmwORyWuTwdxfr/lfn55u1 u3JQGLbOIcZIAd6f4Qntj5hP93kDpvsaLu8oB2z6MnIuzc1JJl5jXEyEbdFfdtzGbhfTqx fPYC3KNgihdAepnffNF2My9IzQI3pO4= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-173-SiRuONPeNUq7qXMP-HPi8g-1; Wed, 08 May 2024 12:46:50 -0400 X-MC-Unique: SiRuONPeNUq7qXMP-HPi8g-1 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-34cca3de393so1912074f8f.3 for ; Wed, 08 May 2024 09:46:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715186809; x=1715791609; 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=B8eUwScckUub2F1H8Xt4RUKWNxuAAGyiFQlvrIvo1tWA7lYrpv5nS/+FMiuWbZCbop e6kFIk0yXaf+bIKmXkLa+4xaDpRelvRG7niLUvR08Tx/TDw6ym/ry3RLGJaD9nsUQ1tZ FPX7T4k0G77UXiWatOETvm7XYnSv2y6pH7Ox8BAoD75H2PvDHmatZbSNnFQV1XzmfMB1 VSKO6c5eE0NAaqtC38HUFH0aAHsIFX0DHpPnvlzxmzlQyLWp6yeeZnttA1sbzK2JyIzT whunSJ3T7VbX/LnGei2VHw6W3iHlL07ESfi8oxz0pIcPET3auSo7pt7bRQr+RZWPW0Pb zb2A== X-Gm-Message-State: AOJu0YxvFxgQOkR6256cfHd5v5/y6Z4t/JKAbdR4IybawYsQmp6s4Jur C2WRn6QXCx8KAiFiIXbc7RghAgZMt3OdJc4e4XXoCPCOGAARuj0OM6AZtYYU1KkPt8fbbsfhbrm fRzs4O446KHFyiBH2/6+A1Jw13k9cBJAbkfWKPqXfpW6LNmQ3IeQ/bOV26SU8yWfF1hZZI52axm ePfqYCYEhRv+T6v9MX499RL09JpXnWYwl2uvGjI1rwNbo= X-Received: by 2002:adf:e787:0:b0:34c:c1c:8413 with SMTP id ffacd0b85a97d-34fca80d3dbmr2346192f8f.58.1715186808689; Wed, 08 May 2024 09:46:48 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGSha2BWnh2VHDkanQtaif5UgjT1D5Qxc0gjgUCUOA6uA+kvj0pklK1Uxv8qdpqK/XQ2SMJEg== X-Received: by 2002:adf:e787:0:b0:34c:c1c:8413 with SMTP id ffacd0b85a97d-34fca80d3dbmr2346174f8f.58.1715186808180; Wed, 08 May 2024 09:46:48 -0700 (PDT) Received: from localhost ([31.111.84.240]) by smtp.gmail.com with ESMTPSA id g18-20020a5d5412000000b00346bda84bf9sm15785101wrv.78.2024.05.08.09.46.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 May 2024 09:46:47 -0700 (PDT) From: Andrew Burgess To: gdb-patches@sourceware.org Cc: Andrew Burgess , felix.willgerodt@intel.com, jhb@FreeBSD.org Subject: [PATCHv6 1/9] gdb/gdbserver: share I386_LINUX_XSAVE_XCR0_OFFSET definition Date: Wed, 8 May 2024 17:46:37 +0100 Message-Id: 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.5 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_H4,RCVD_IN_MSPIKE_WL,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