* [igt-dev] [PATCH i-g-t v2] tools: Add tool to dump GuC/HuC CSS header
@ 2023-04-04 17:07 Lucas De Marchi
2023-04-04 18:15 ` [igt-dev] ✗ Fi.CI.BAT: failure for tools: Add tool to dump GuC/HuC CSS header (rev2) Patchwork
2023-04-11 16:19 ` [igt-dev] [Intel-xe] [PATCH i-g-t v2] tools: Add tool to dump GuC/HuC CSS header Lucas De Marchi
0 siblings, 2 replies; 3+ messages in thread
From: Lucas De Marchi @ 2023-04-04 17:07 UTC (permalink / raw)
To: igt-dev; +Cc: intel-gfx, Lucas De Marchi, intel-xe
Since we are now using unversioned GuC/HuC, it's useful to be able to
dump the firmware blob and get that information from the CSS header.
Add a tool that decodes that information and dumps the raw header.
Example output:
$ tools/intel-gfx-fw-info /lib/firmware/i915/tgl_guc_70.bin
version: 70.5.1
date: 2022-09-09
raw dump:
00000000 06 00 00 00 a1 00 00 00 00 00 01 00 00 00 00 00 ................
00000010 86 80 00 00 09 09 22 20 71 17 01 00 40 00 00 00 ......" q...@...
00000020 40 00 00 00 01 00 00 00 09 21 45 00 73 79 73 5f @........!E.sys_
00000030 67 62 73 62 50 43 2d 31 2e 30 2e 33 31 35 30 00 gbsbPC-1.0.3150.
00000040 01 05 46 00 00 00 00 00 00 00 00 00 00 00 00 00 ..F.............
00000050 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00000060 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00000070 00 00 00 00 00 00 00 00 00 10 80 00 00 01 40 00 ..............@.
struct uc_css_header:
- module_type: 0x6
- header_size_dw: 0xa1
- header_version: 0x10000
- module_id: 0x0
- module_vendor: 0x8086
- date: 0x20220909
- size_dw: 0x11771
- key_size_dw: 0x40
- modulus_size_dw: 0x40
- exponent_size_dw: 0x1
- time: 0x452109
- username: b'sys_gbsb'
- buildnumber: b'PC-1.0.3150\x00'
- sw_version: 0x460501
- vf_version: 0x0
- reserved0: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
- rsvd: <rsvd private_data_size=0x801000, reserved1=0x801000>
- header_info: 0x400100
v2:
- Comments in the struct don't need to be removed: the defines do.
Just comment them out with a "//" which should bring people's
attention to it since it's not an approved way for comments
according to kernel coding style
- Better logging handling, without an explicit logger object
- Catch ImportError for the dissect.cstruct dependency (Gustavo)
Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
Acked-by: Gustavo Sousa <gustavo.sousa@intel.com>
Acked-by: Kamil Konieczny <kamil.konieczny@linux.intel.com>
---
tools/intel-gfx-fw-info | 138 ++++++++++++++++++++++++++++++++++++++++
tools/meson.build | 2 +-
2 files changed, 139 insertions(+), 1 deletion(-)
create mode 100755 tools/intel-gfx-fw-info
diff --git a/tools/intel-gfx-fw-info b/tools/intel-gfx-fw-info
new file mode 100755
index 000000000..77903bbb7
--- /dev/null
+++ b/tools/intel-gfx-fw-info
@@ -0,0 +1,138 @@
+#!/usr/bin/env python3
+# pylint: disable=C0301
+# SPDX-License-Identifier: (GPL-2.0 OR MIT)
+#
+# Copyright (C) 2023 Intel Corporation
+
+import argparse
+import logging
+import sys
+import typing
+
+# struct definition below should match the one from i915
+# (drivers/gpu/drm/i915/gt/uc/intel_uc_fw_abi.h) and xe
+# (drivers/gpu/drm/xe/xe_uc_fw_abi.h).
+#
+# For compatibility reasons with dissect.cstruct python module, the following
+# things are changed from the original kernel definition:
+#
+# 1) #define in the middle of the struct removed: comment them out
+# 2) No anonymous union - not compatible with the
+# dumpstruct(): give it a name
+
+CDEF = """
+typedef uint32 u32;
+
+struct uc_css_header {
+ u32 module_type;
+ /*
+ * header_size includes all non-uCode bits, including css_header, rsa
+ * key, modulus key and exponent data.
+ */
+ u32 header_size_dw;
+ u32 header_version;
+ u32 module_id;
+ u32 module_vendor;
+ u32 date;
+// #define CSS_DATE_DAY (0xFF << 0)
+// #define CSS_DATE_MONTH (0xFF << 8)
+// #define CSS_DATE_YEAR (0xFFFF << 16)
+ u32 size_dw; /* uCode plus header_size_dw */
+ u32 key_size_dw;
+ u32 modulus_size_dw;
+ u32 exponent_size_dw;
+ u32 time;
+// #define CSS_TIME_HOUR (0xFF << 0)
+// #define CSS_DATE_MIN (0xFF << 8)
+// #define CSS_DATE_SEC (0xFFFF << 16)
+ char username[8];
+ char buildnumber[12];
+ u32 sw_version;
+// #define CSS_SW_VERSION_UC_MAJOR (0xFF << 16)
+// #define CSS_SW_VERSION_UC_MINOR (0xFF << 8)
+// #define CSS_SW_VERSION_UC_PATCH (0xFF << 0)
+ u32 vf_version;
+ u32 reserved0[12];
+ union {
+ u32 private_data_size; /* only applies to GuC */
+ u32 reserved1;
+ } rsvd;
+ u32 header_info;
+};
+"""
+
+logging.basicConfig(format="%(levelname)s: %(message)s")
+
+try:
+ from dissect import cstruct
+except:
+ logging.critical(
+ "Could not import dissect.cstruct module. See https://github.com/fox-it/dissect.cstruct for installation options"
+ )
+ raise SystemExit(1)
+
+
+def ffs(x: int) -> int:
+ """Returns the index, counting from 0, of the
+ least significant set bit in `x`.
+ """
+ return (x & -x).bit_length() - 1
+
+
+def FIELD_GET(mask: int, value: int) -> int:
+ return (value & mask) >> ffs(mask)
+
+
+def decode(fw) -> str:
+ data = []
+
+ CSS_SW_VERSION_UC_MAJOR = 0xFF << 16
+ CSS_SW_VERSION_UC_MINOR = 0xFF << 8
+ CSS_SW_VERSION_UC_PATCH = 0xFF
+ major = FIELD_GET(CSS_SW_VERSION_UC_MAJOR, fw.sw_version)
+ minor = FIELD_GET(CSS_SW_VERSION_UC_MINOR, fw.sw_version)
+ patch = FIELD_GET(CSS_SW_VERSION_UC_PATCH, fw.sw_version)
+ data += [f"version: {major}.{minor}.{patch}"]
+
+ CSS_DATE_DAY = 0xFF
+ CSS_DATE_MONTH = 0xFF << 8
+ CSS_DATE_YEAR = 0xFFFF << 16
+ day = FIELD_GET(CSS_DATE_DAY, fw.date)
+ month = FIELD_GET(CSS_DATE_MONTH, fw.date)
+ year = FIELD_GET(CSS_DATE_YEAR, fw.date)
+ data += [f"date: {year:02x}-{month:02x}-{day:02x}"]
+
+ return data
+
+
+def parse_args(argv: typing.List[str]) -> argparse.Namespace:
+ description = "Dump GuC/HuC firmware header"
+ parser = argparse.ArgumentParser(prog="intel-gfx-fw-info", description=description)
+
+ parser.add_argument("filename", help="GuC/HuC firmware file")
+
+ return parser.parse_args(argv)
+
+
+def main(argv: typing.List[str]) -> int:
+ args = parse_args(argv)
+
+ cparser = cstruct.cstruct()
+ cparser.load(CDEF)
+
+ try:
+ with open(args.filename, mode="rb") as f:
+ fw = cparser.uc_css_header(f)
+ except FileNotFoundError as e:
+ logging.fatal(e)
+ return 1
+
+ print(*decode(fw), sep="\n")
+ print("raw dump:", end="")
+ cstruct.dumpstruct(fw, color=sys.stdout.isatty())
+
+ return 0
+
+
+if __name__ == "__main__":
+ sys.exit(main(sys.argv[1:]))
diff --git a/tools/meson.build b/tools/meson.build
index 4c45f16b9..88c58adfe 100644
--- a/tools/meson.build
+++ b/tools/meson.build
@@ -81,7 +81,7 @@ executable('intel_reg', sources : intel_reg_src,
'-DIGT_DATADIR="@0@"'.format(join_paths(prefix, datadir)),
])
-install_data('intel_gpu_abrt', install_dir : bindir)
+install_data(['intel_gpu_abrt', 'intel-gfx-fw-info'], install_dir : bindir)
install_subdir('registers', install_dir : datadir)
--
2.39.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [igt-dev] ✗ Fi.CI.BAT: failure for tools: Add tool to dump GuC/HuC CSS header (rev2)
2023-04-04 17:07 [igt-dev] [PATCH i-g-t v2] tools: Add tool to dump GuC/HuC CSS header Lucas De Marchi
@ 2023-04-04 18:15 ` Patchwork
2023-04-11 16:19 ` [igt-dev] [Intel-xe] [PATCH i-g-t v2] tools: Add tool to dump GuC/HuC CSS header Lucas De Marchi
1 sibling, 0 replies; 3+ messages in thread
From: Patchwork @ 2023-04-04 18:15 UTC (permalink / raw)
To: Lucas De Marchi; +Cc: igt-dev
[-- Attachment #1: Type: text/plain, Size: 5054 bytes --]
== Series Details ==
Series: tools: Add tool to dump GuC/HuC CSS header (rev2)
URL : https://patchwork.freedesktop.org/series/116049/
State : failure
== Summary ==
CI Bug Log - changes from CI_DRM_12965 -> IGTPW_8752
====================================================
Summary
-------
**FAILURE**
Serious unknown changes coming with IGTPW_8752 absolutely need to be
verified manually.
If you think the reported changes have nothing to do with the changes
introduced in IGTPW_8752, please notify your bug team to allow them
to document this new failure mode, which will reduce false positives in CI.
External URL: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8752/index.html
Participating hosts (38 -> 36)
------------------------------
Missing (2): bat-adlp-9 fi-snb-2520m
Possible new issues
-------------------
Here are the unknown changes that may have been introduced in IGTPW_8752:
### IGT changes ###
#### Possible regressions ####
* igt@i915_pm_rpm@module-reload:
- fi-skl-6600u: [PASS][1] -> [FAIL][2]
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12965/fi-skl-6600u/igt@i915_pm_rpm@module-reload.html
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8752/fi-skl-6600u/igt@i915_pm_rpm@module-reload.html
Known issues
------------
Here are the changes found in IGTPW_8752 that come from known issues:
### IGT changes ###
#### Issues hit ####
* igt@gem_exec_suspend@basic-s3@smem:
- bat-rpls-1: NOTRUN -> [ABORT][3] ([i915#6687] / [i915#7978])
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8752/bat-rpls-1/igt@gem_exec_suspend@basic-s3@smem.html
* igt@i915_selftest@live@gt_lrc:
- bat-rpls-2: [PASS][4] -> [INCOMPLETE][5] ([i915#4983] / [i915#7913])
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12965/bat-rpls-2/igt@i915_selftest@live@gt_lrc.html
[5]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8752/bat-rpls-2/igt@i915_selftest@live@gt_lrc.html
* igt@i915_selftest@live@slpc:
- bat-rpls-1: NOTRUN -> [DMESG-FAIL][6] ([i915#6367] / [i915#7996])
[6]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8752/bat-rpls-1/igt@i915_selftest@live@slpc.html
* igt@kms_chamelium_hpd@common-hpd-after-suspend:
- bat-dg2-11: NOTRUN -> [SKIP][7] ([i915#7828])
[7]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8752/bat-dg2-11/igt@kms_chamelium_hpd@common-hpd-after-suspend.html
* igt@kms_pipe_crc_basic@nonblocking-crc-frame-sequence:
- bat-dg2-11: NOTRUN -> [SKIP][8] ([i915#5354])
[8]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8752/bat-dg2-11/igt@kms_pipe_crc_basic@nonblocking-crc-frame-sequence.html
#### Possible fixes ####
* igt@i915_selftest@live@gt_heartbeat:
- fi-apl-guc: [DMESG-FAIL][9] ([i915#5334]) -> [PASS][10]
[9]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12965/fi-apl-guc/igt@i915_selftest@live@gt_heartbeat.html
[10]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8752/fi-apl-guc/igt@i915_selftest@live@gt_heartbeat.html
* igt@i915_selftest@live@gt_lrc:
- bat-dg2-11: [INCOMPLETE][11] ([i915#7609] / [i915#7913]) -> [PASS][12]
[11]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12965/bat-dg2-11/igt@i915_selftest@live@gt_lrc.html
[12]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8752/bat-dg2-11/igt@i915_selftest@live@gt_lrc.html
* igt@i915_selftest@live@requests:
- bat-rpls-1: [ABORT][13] ([i915#4983] / [i915#7911]) -> [PASS][14]
[13]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12965/bat-rpls-1/igt@i915_selftest@live@requests.html
[14]: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8752/bat-rpls-1/igt@i915_selftest@live@requests.html
[i915#4983]: https://gitlab.freedesktop.org/drm/intel/issues/4983
[i915#5334]: https://gitlab.freedesktop.org/drm/intel/issues/5334
[i915#5354]: https://gitlab.freedesktop.org/drm/intel/issues/5354
[i915#6367]: https://gitlab.freedesktop.org/drm/intel/issues/6367
[i915#6687]: https://gitlab.freedesktop.org/drm/intel/issues/6687
[i915#7609]: https://gitlab.freedesktop.org/drm/intel/issues/7609
[i915#7828]: https://gitlab.freedesktop.org/drm/intel/issues/7828
[i915#7911]: https://gitlab.freedesktop.org/drm/intel/issues/7911
[i915#7913]: https://gitlab.freedesktop.org/drm/intel/issues/7913
[i915#7978]: https://gitlab.freedesktop.org/drm/intel/issues/7978
[i915#7996]: https://gitlab.freedesktop.org/drm/intel/issues/7996
Build changes
-------------
* CI: CI-20190529 -> None
* IGT: IGT_7236 -> IGTPW_8752
CI-20190529: 20190529
CI_DRM_12965: 53e37ca502cfe620396e498fae8430c293fb2c83 @ git://anongit.freedesktop.org/gfx-ci/linux
IGTPW_8752: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8752/index.html
IGT_7236: bac5a4cc31b3212a205219a6cbc45a173d30d04b @ https://gitlab.freedesktop.org/drm/igt-gpu-tools.git
Testlist changes
----------------
+++ 0 lines
--- 1009 lines
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_8752/index.html
[-- Attachment #2: Type: text/html, Size: 6008 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [igt-dev] [Intel-xe] [PATCH i-g-t v2] tools: Add tool to dump GuC/HuC CSS header
2023-04-04 17:07 [igt-dev] [PATCH i-g-t v2] tools: Add tool to dump GuC/HuC CSS header Lucas De Marchi
2023-04-04 18:15 ` [igt-dev] ✗ Fi.CI.BAT: failure for tools: Add tool to dump GuC/HuC CSS header (rev2) Patchwork
@ 2023-04-11 16:19 ` Lucas De Marchi
1 sibling, 0 replies; 3+ messages in thread
From: Lucas De Marchi @ 2023-04-11 16:19 UTC (permalink / raw)
To: igt-dev, Lucas De Marchi; +Cc: intel-gfx, intel-xe
On Tue, 04 Apr 2023 10:07:37 -0700, Lucas De Marchi wrote:
> Since we are now using unversioned GuC/HuC, it's useful to be able to
> dump the firmware blob and get that information from the CSS header.
> Add a tool that decodes that information and dumps the raw header.
>
> Example output:
>
> $ tools/intel-gfx-fw-info /lib/firmware/i915/tgl_guc_70.bin
> version: 70.5.1
> date: 2022-09-09
> raw dump:
> 00000000 06 00 00 00 a1 00 00 00 00 00 01 00 00 00 00 00 ................
> 00000010 86 80 00 00 09 09 22 20 71 17 01 00 40 00 00 00 ......" q...@...
> 00000020 40 00 00 00 01 00 00 00 09 21 45 00 73 79 73 5f @........!E.sys_
> 00000030 67 62 73 62 50 43 2d 31 2e 30 2e 33 31 35 30 00 gbsbPC-1.0.3150.
> 00000040 01 05 46 00 00 00 00 00 00 00 00 00 00 00 00 00 ..F.............
> 00000050 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
> 00000060 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
> 00000070 00 00 00 00 00 00 00 00 00 10 80 00 00 01 40 00 ..............@.
>
> [...]
Applied, thanks for the reviews.
[1/1] tools: Add tool to dump GuC/HuC CSS header
commit: 2da179d399d83a6859a89176d83b7ec1d71fe27a
Best regards,
--
Lucas De Marchi <lucas.demarchi@intel.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-04-11 16:19 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-04-04 17:07 [igt-dev] [PATCH i-g-t v2] tools: Add tool to dump GuC/HuC CSS header Lucas De Marchi
2023-04-04 18:15 ` [igt-dev] ✗ Fi.CI.BAT: failure for tools: Add tool to dump GuC/HuC CSS header (rev2) Patchwork
2023-04-11 16:19 ` [igt-dev] [Intel-xe] [PATCH i-g-t v2] tools: Add tool to dump GuC/HuC CSS header Lucas De Marchi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox