amd-ucode-patch 1.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- amd_ucode_patch-1.0.0/.github/dependabot.yml +16 -0
- amd_ucode_patch-1.0.0/.github/workflows/build.yml +61 -0
- amd_ucode_patch-1.0.0/.github/workflows/codeql.yml +91 -0
- amd_ucode_patch-1.0.0/.github/workflows/scorecard.yml +43 -0
- amd_ucode_patch-1.0.0/.gitignore +2 -0
- amd_ucode_patch-1.0.0/LICENSE.md +360 -0
- amd_ucode_patch-1.0.0/PKG-INFO +79 -0
- amd_ucode_patch-1.0.0/README.md +51 -0
- amd_ucode_patch-1.0.0/pyproject.toml +48 -0
- amd_ucode_patch-1.0.0/src/amd_ucode_patch/banner.py +16 -0
- amd_ucode_patch-1.0.0/src/amd_ucode_patch/cli_info.py +82 -0
- amd_ucode_patch-1.0.0/src/amd_ucode_patch/naming.py +15 -0
- amd_ucode_patch-1.0.0/src/amd_ucode_patch/parse.py +9 -0
- amd_ucode_patch-1.0.0/src/amd_ucode_patch/structures/ucode_patch.py +29 -0
- amd_ucode_patch-1.0.0/src/amd_ucode_patch/structures/ucode_patch_header.py +126 -0
- amd_ucode_patch-1.0.0/src/amd_ucode_patch/structures/verified_header.py +42 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# To get started with Dependabot version updates, you'll need to specify which
|
|
2
|
+
# package ecosystems to update and where the package manifests are located.
|
|
3
|
+
# Please see the documentation for all configuration options:
|
|
4
|
+
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
|
|
5
|
+
|
|
6
|
+
version: 2
|
|
7
|
+
updates:
|
|
8
|
+
- package-ecosystem: "github-actions" # See documentation for possible values
|
|
9
|
+
directory: "/" # Location of package manifests
|
|
10
|
+
schedule:
|
|
11
|
+
interval: "weekly"
|
|
12
|
+
|
|
13
|
+
- package-ecosystem: "pip" # See documentation for possible values
|
|
14
|
+
directory: "/" # Location of package manifests
|
|
15
|
+
schedule:
|
|
16
|
+
interval: "weekly"
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
name: Build
|
|
2
|
+
on: [push, pull_request]
|
|
3
|
+
permissions:
|
|
4
|
+
contents: read
|
|
5
|
+
|
|
6
|
+
jobs:
|
|
7
|
+
build:
|
|
8
|
+
runs-on: ubuntu-latest
|
|
9
|
+
strategy:
|
|
10
|
+
matrix:
|
|
11
|
+
python-version:
|
|
12
|
+
- "pypy3.11"
|
|
13
|
+
- "3.10"
|
|
14
|
+
- "3.11"
|
|
15
|
+
- "3.12"
|
|
16
|
+
- "3.13"
|
|
17
|
+
- "3.14"
|
|
18
|
+
|
|
19
|
+
steps:
|
|
20
|
+
- name: Checkout repository
|
|
21
|
+
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7
|
|
22
|
+
|
|
23
|
+
- name: Set up Python ${{ matrix.python-version }}
|
|
24
|
+
uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6
|
|
25
|
+
with:
|
|
26
|
+
python-version: ${{ matrix.python-version }}
|
|
27
|
+
|
|
28
|
+
- name: Install dependencies
|
|
29
|
+
run: |
|
|
30
|
+
python -m pip install --upgrade pip
|
|
31
|
+
pip install hatch
|
|
32
|
+
|
|
33
|
+
- name: Build
|
|
34
|
+
run: hatch build
|
|
35
|
+
|
|
36
|
+
- name: Upload artifacts
|
|
37
|
+
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
|
|
38
|
+
with:
|
|
39
|
+
name: python_${{ matrix.python-version }}
|
|
40
|
+
path: dist/
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
publish_pypi:
|
|
44
|
+
name: Publish to PyPi
|
|
45
|
+
needs: [build]
|
|
46
|
+
if: contains(github.ref, 'refs/tags/v')
|
|
47
|
+
runs-on: ubuntu-latest
|
|
48
|
+
environment:
|
|
49
|
+
name: pypi
|
|
50
|
+
url: https://pypi.org/p/amd-ucode-patch
|
|
51
|
+
permissions:
|
|
52
|
+
id-token: write
|
|
53
|
+
steps:
|
|
54
|
+
- name: Download artifacts
|
|
55
|
+
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
|
|
56
|
+
with:
|
|
57
|
+
name: python_3.13
|
|
58
|
+
path: dist/
|
|
59
|
+
|
|
60
|
+
- name: Publish distribution to PyPI
|
|
61
|
+
uses: pypa/gh-action-pypi-publish@cef221092ed1bacb1cc03d23a2d87d1d172e277b # release/v1
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
name: "CodeQL"
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [ "main" ]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [ "main" ]
|
|
8
|
+
schedule:
|
|
9
|
+
- cron: '27 22 * * 0'
|
|
10
|
+
|
|
11
|
+
permissions: read-all
|
|
12
|
+
|
|
13
|
+
jobs:
|
|
14
|
+
analyze:
|
|
15
|
+
name: Analyze (${{ matrix.language }})
|
|
16
|
+
# Runner size impacts CodeQL analysis time. To learn more, please see:
|
|
17
|
+
# - https://gh.io/recommended-hardware-resources-for-running-codeql
|
|
18
|
+
# - https://gh.io/supported-runners-and-hardware-resources
|
|
19
|
+
# - https://gh.io/using-larger-runners (GitHub.com only)
|
|
20
|
+
# Consider using larger runners or machines with greater resources for possible analysis time improvements.
|
|
21
|
+
runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }}
|
|
22
|
+
permissions:
|
|
23
|
+
# required for all workflows
|
|
24
|
+
security-events: write
|
|
25
|
+
|
|
26
|
+
# required to fetch internal or private CodeQL packs
|
|
27
|
+
packages: read
|
|
28
|
+
|
|
29
|
+
# only required for workflows in private repositories
|
|
30
|
+
actions: read
|
|
31
|
+
contents: read
|
|
32
|
+
|
|
33
|
+
strategy:
|
|
34
|
+
fail-fast: false
|
|
35
|
+
matrix:
|
|
36
|
+
include:
|
|
37
|
+
- language: actions
|
|
38
|
+
build-mode: none
|
|
39
|
+
- language: python
|
|
40
|
+
build-mode: none
|
|
41
|
+
# CodeQL supports the following values keywords for 'language': 'actions', 'c-cpp', 'csharp', 'go', 'java-kotlin', 'javascript-typescript', 'python', 'ruby', 'rust', 'swift'
|
|
42
|
+
# Use `c-cpp` to analyze code written in C, C++ or both
|
|
43
|
+
# Use 'java-kotlin' to analyze code written in Java, Kotlin or both
|
|
44
|
+
# Use 'javascript-typescript' to analyze code written in JavaScript, TypeScript or both
|
|
45
|
+
# To learn more about changing the languages that are analyzed or customizing the build mode for your analysis,
|
|
46
|
+
# see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/customizing-your-advanced-setup-for-code-scanning.
|
|
47
|
+
# If you are analyzing a compiled language, you can modify the 'build-mode' for that language to customize how
|
|
48
|
+
# your codebase is analyzed, see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/codeql-code-scanning-for-compiled-languages
|
|
49
|
+
steps:
|
|
50
|
+
- name: Checkout repository
|
|
51
|
+
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7
|
|
52
|
+
|
|
53
|
+
# Add any setup steps before running the `github/codeql-action/init` action.
|
|
54
|
+
# This includes steps like installing compilers or runtimes (`actions/setup-node`
|
|
55
|
+
# or others). This is typically only required for manual builds.
|
|
56
|
+
# - name: Setup runtime (example)
|
|
57
|
+
# uses: actions/setup-example@v1
|
|
58
|
+
|
|
59
|
+
# Initializes the CodeQL tools for scanning.
|
|
60
|
+
- name: Initialize CodeQL
|
|
61
|
+
uses: github/codeql-action/init@8aad20d150bbac5944a9f9d289da16a4b0d87c1e # v4
|
|
62
|
+
with:
|
|
63
|
+
languages: ${{ matrix.language }}
|
|
64
|
+
build-mode: ${{ matrix.build-mode }}
|
|
65
|
+
# If you wish to specify custom queries, you can do so here or in a config file.
|
|
66
|
+
# By default, queries listed here will override any specified in a config file.
|
|
67
|
+
# Prefix the list here with "+" to use these queries and those in the config file.
|
|
68
|
+
|
|
69
|
+
# For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
|
|
70
|
+
# queries: security-extended,security-and-quality
|
|
71
|
+
|
|
72
|
+
# If the analyze step fails for one of the languages you are analyzing with
|
|
73
|
+
# "We were unable to automatically build your code", modify the matrix above
|
|
74
|
+
# to set the build mode to "manual" for that language. Then modify this step
|
|
75
|
+
# to build your code.
|
|
76
|
+
# ℹ️ Command-line programs to run using the OS shell.
|
|
77
|
+
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
|
|
78
|
+
- if: matrix.build-mode == 'manual'
|
|
79
|
+
shell: bash
|
|
80
|
+
run: |
|
|
81
|
+
echo 'If you are using a "manual" build mode for one or more of the' \
|
|
82
|
+
'languages you are analyzing, replace this with the commands to build' \
|
|
83
|
+
'your code, for example:'
|
|
84
|
+
echo ' make bootstrap'
|
|
85
|
+
echo ' make release'
|
|
86
|
+
exit 1
|
|
87
|
+
|
|
88
|
+
- name: Perform CodeQL Analysis
|
|
89
|
+
uses: github/codeql-action/analyze@8aad20d150bbac5944a9f9d289da16a4b0d87c1e # v4
|
|
90
|
+
with:
|
|
91
|
+
category: "/language:${{matrix.language}}"
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
name: Scorecard
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
branch_protection_rule:
|
|
5
|
+
schedule:
|
|
6
|
+
- cron: '27 22 * * 0'
|
|
7
|
+
push:
|
|
8
|
+
branches: [ "main" ]
|
|
9
|
+
|
|
10
|
+
permissions: read-all
|
|
11
|
+
|
|
12
|
+
jobs:
|
|
13
|
+
analysis:
|
|
14
|
+
name: Scorecard analysis
|
|
15
|
+
runs-on: ubuntu-latest
|
|
16
|
+
permissions:
|
|
17
|
+
security-events: write
|
|
18
|
+
id-token: write
|
|
19
|
+
|
|
20
|
+
steps:
|
|
21
|
+
- name: Checkout repository
|
|
22
|
+
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
|
23
|
+
with:
|
|
24
|
+
persist-credentials: false
|
|
25
|
+
|
|
26
|
+
- name: Run analysis
|
|
27
|
+
uses: ossf/scorecard-action@4eaacf0543bb3f2c246792bd56e8cdeffafb205a # v2.4.3
|
|
28
|
+
with:
|
|
29
|
+
results_file: results.sarif
|
|
30
|
+
results_format: sarif
|
|
31
|
+
publish_results: true
|
|
32
|
+
|
|
33
|
+
- name: Upload artifact
|
|
34
|
+
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
|
|
35
|
+
with:
|
|
36
|
+
name: SARIF file
|
|
37
|
+
path: results.sarif
|
|
38
|
+
retention-days: 5
|
|
39
|
+
|
|
40
|
+
- name: Upload to code-scanning
|
|
41
|
+
uses: github/codeql-action/upload-sarif@8aad20d150bbac5944a9f9d289da16a4b0d87c1e # v4.36.2
|
|
42
|
+
with:
|
|
43
|
+
sarif_file: results.sarif
|
|
@@ -0,0 +1,360 @@
|
|
|
1
|
+
# GNU GENERAL PUBLIC LICENSE
|
|
2
|
+
|
|
3
|
+
Version 2, June 1991
|
|
4
|
+
|
|
5
|
+
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
|
|
6
|
+
<https://fsf.org/>
|
|
7
|
+
|
|
8
|
+
Everyone is permitted to copy and distribute verbatim copies
|
|
9
|
+
of this license document, but changing it is not allowed.
|
|
10
|
+
|
|
11
|
+
## Preamble
|
|
12
|
+
|
|
13
|
+
The licenses for most software are designed to take away your freedom
|
|
14
|
+
to share and change it. By contrast, the GNU General Public License is
|
|
15
|
+
intended to guarantee your freedom to share and change free
|
|
16
|
+
software--to make sure the software is free for all its users. This
|
|
17
|
+
General Public License applies to most of the Free Software
|
|
18
|
+
Foundation's software and to any other program whose authors commit to
|
|
19
|
+
using it. (Some other Free Software Foundation software is covered by
|
|
20
|
+
the GNU Lesser General Public License instead.) You can apply it to
|
|
21
|
+
your programs, too.
|
|
22
|
+
|
|
23
|
+
When we speak of free software, we are referring to freedom, not
|
|
24
|
+
price. Our General Public Licenses are designed to make sure that you
|
|
25
|
+
have the freedom to distribute copies of free software (and charge for
|
|
26
|
+
this service if you wish), that you receive source code or can get it
|
|
27
|
+
if you want it, that you can change the software or use pieces of it
|
|
28
|
+
in new free programs; and that you know you can do these things.
|
|
29
|
+
|
|
30
|
+
To protect your rights, we need to make restrictions that forbid
|
|
31
|
+
anyone to deny you these rights or to ask you to surrender the rights.
|
|
32
|
+
These restrictions translate to certain responsibilities for you if
|
|
33
|
+
you distribute copies of the software, or if you modify it.
|
|
34
|
+
|
|
35
|
+
For example, if you distribute copies of such a program, whether
|
|
36
|
+
gratis or for a fee, you must give the recipients all the rights that
|
|
37
|
+
you have. You must make sure that they, too, receive or can get the
|
|
38
|
+
source code. And you must show them these terms so they know their
|
|
39
|
+
rights.
|
|
40
|
+
|
|
41
|
+
We protect your rights with two steps: (1) copyright the software, and
|
|
42
|
+
(2) offer you this license which gives you legal permission to copy,
|
|
43
|
+
distribute and/or modify the software.
|
|
44
|
+
|
|
45
|
+
Also, for each author's protection and ours, we want to make certain
|
|
46
|
+
that everyone understands that there is no warranty for this free
|
|
47
|
+
software. If the software is modified by someone else and passed on,
|
|
48
|
+
we want its recipients to know that what they have is not the
|
|
49
|
+
original, so that any problems introduced by others will not reflect
|
|
50
|
+
on the original authors' reputations.
|
|
51
|
+
|
|
52
|
+
Finally, any free program is threatened constantly by software
|
|
53
|
+
patents. We wish to avoid the danger that redistributors of a free
|
|
54
|
+
program will individually obtain patent licenses, in effect making the
|
|
55
|
+
program proprietary. To prevent this, we have made it clear that any
|
|
56
|
+
patent must be licensed for everyone's free use or not licensed at
|
|
57
|
+
all.
|
|
58
|
+
|
|
59
|
+
The precise terms and conditions for copying, distribution and
|
|
60
|
+
modification follow.
|
|
61
|
+
|
|
62
|
+
## TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
|
63
|
+
|
|
64
|
+
**0.** This License applies to any program or other work which
|
|
65
|
+
contains a notice placed by the copyright holder saying it may be
|
|
66
|
+
distributed under the terms of this General Public License. The
|
|
67
|
+
"Program", below, refers to any such program or work, and a "work
|
|
68
|
+
based on the Program" means either the Program or any derivative work
|
|
69
|
+
under copyright law: that is to say, a work containing the Program or
|
|
70
|
+
a portion of it, either verbatim or with modifications and/or
|
|
71
|
+
translated into another language. (Hereinafter, translation is
|
|
72
|
+
included without limitation in the term "modification".) Each licensee
|
|
73
|
+
is addressed as "you".
|
|
74
|
+
|
|
75
|
+
Activities other than copying, distribution and modification are not
|
|
76
|
+
covered by this License; they are outside its scope. The act of
|
|
77
|
+
running the Program is not restricted, and the output from the Program
|
|
78
|
+
is covered only if its contents constitute a work based on the Program
|
|
79
|
+
(independent of having been made by running the Program). Whether that
|
|
80
|
+
is true depends on what the Program does.
|
|
81
|
+
|
|
82
|
+
**1.** You may copy and distribute verbatim copies of the Program's
|
|
83
|
+
source code as you receive it, in any medium, provided that you
|
|
84
|
+
conspicuously and appropriately publish on each copy an appropriate
|
|
85
|
+
copyright notice and disclaimer of warranty; keep intact all the
|
|
86
|
+
notices that refer to this License and to the absence of any warranty;
|
|
87
|
+
and give any other recipients of the Program a copy of this License
|
|
88
|
+
along with the Program.
|
|
89
|
+
|
|
90
|
+
You may charge a fee for the physical act of transferring a copy, and
|
|
91
|
+
you may at your option offer warranty protection in exchange for a
|
|
92
|
+
fee.
|
|
93
|
+
|
|
94
|
+
**2.** You may modify your copy or copies of the Program or any
|
|
95
|
+
portion of it, thus forming a work based on the Program, and copy and
|
|
96
|
+
distribute such modifications or work under the terms of Section 1
|
|
97
|
+
above, provided that you also meet all of these conditions:
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
**a)** You must cause the modified files to carry prominent notices
|
|
101
|
+
stating that you changed the files and the date of any change.
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
**b)** You must cause any work that you distribute or publish, that in
|
|
105
|
+
whole or in part contains or is derived from the Program or any part
|
|
106
|
+
thereof, to be licensed as a whole at no charge to all third parties
|
|
107
|
+
under the terms of this License.
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
**c)** If the modified program normally reads commands interactively
|
|
111
|
+
when run, you must cause it, when started running for such interactive
|
|
112
|
+
use in the most ordinary way, to print or display an announcement
|
|
113
|
+
including an appropriate copyright notice and a notice that there is
|
|
114
|
+
no warranty (or else, saying that you provide a warranty) and that
|
|
115
|
+
users may redistribute the program under these conditions, and telling
|
|
116
|
+
the user how to view a copy of this License. (Exception: if the
|
|
117
|
+
Program itself is interactive but does not normally print such an
|
|
118
|
+
announcement, your work based on the Program is not required to print
|
|
119
|
+
an announcement.)
|
|
120
|
+
|
|
121
|
+
These requirements apply to the modified work as a whole. If
|
|
122
|
+
identifiable sections of that work are not derived from the Program,
|
|
123
|
+
and can be reasonably considered independent and separate works in
|
|
124
|
+
themselves, then this License, and its terms, do not apply to those
|
|
125
|
+
sections when you distribute them as separate works. But when you
|
|
126
|
+
distribute the same sections as part of a whole which is a work based
|
|
127
|
+
on the Program, the distribution of the whole must be on the terms of
|
|
128
|
+
this License, whose permissions for other licensees extend to the
|
|
129
|
+
entire whole, and thus to each and every part regardless of who wrote
|
|
130
|
+
it.
|
|
131
|
+
|
|
132
|
+
Thus, it is not the intent of this section to claim rights or contest
|
|
133
|
+
your rights to work written entirely by you; rather, the intent is to
|
|
134
|
+
exercise the right to control the distribution of derivative or
|
|
135
|
+
collective works based on the Program.
|
|
136
|
+
|
|
137
|
+
In addition, mere aggregation of another work not based on the Program
|
|
138
|
+
with the Program (or with a work based on the Program) on a volume of
|
|
139
|
+
a storage or distribution medium does not bring the other work under
|
|
140
|
+
the scope of this License.
|
|
141
|
+
|
|
142
|
+
**3.** You may copy and distribute the Program (or a work based on it,
|
|
143
|
+
under Section 2) in object code or executable form under the terms of
|
|
144
|
+
Sections 1 and 2 above provided that you also do one of the following:
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
**a)** Accompany it with the complete corresponding machine-readable
|
|
148
|
+
source code, which must be distributed under the terms of Sections 1
|
|
149
|
+
and 2 above on a medium customarily used for software interchange; or,
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
**b)** Accompany it with a written offer, valid for at least three
|
|
153
|
+
years, to give any third party, for a charge no more than your cost of
|
|
154
|
+
physically performing source distribution, a complete machine-readable
|
|
155
|
+
copy of the corresponding source code, to be distributed under the
|
|
156
|
+
terms of Sections 1 and 2 above on a medium customarily used for
|
|
157
|
+
software interchange; or,
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
**c)** Accompany it with the information you received as to the offer
|
|
161
|
+
to distribute corresponding source code. (This alternative is allowed
|
|
162
|
+
only for noncommercial distribution and only if you received the
|
|
163
|
+
program in object code or executable form with such an offer, in
|
|
164
|
+
accord with Subsection b above.)
|
|
165
|
+
|
|
166
|
+
The source code for a work means the preferred form of the work for
|
|
167
|
+
making modifications to it. For an executable work, complete source
|
|
168
|
+
code means all the source code for all modules it contains, plus any
|
|
169
|
+
associated interface definition files, plus the scripts used to
|
|
170
|
+
control compilation and installation of the executable. However, as a
|
|
171
|
+
special exception, the source code distributed need not include
|
|
172
|
+
anything that is normally distributed (in either source or binary
|
|
173
|
+
form) with the major components (compiler, kernel, and so on) of the
|
|
174
|
+
operating system on which the executable runs, unless that component
|
|
175
|
+
itself accompanies the executable.
|
|
176
|
+
|
|
177
|
+
If distribution of executable or object code is made by offering
|
|
178
|
+
access to copy from a designated place, then offering equivalent
|
|
179
|
+
access to copy the source code from the same place counts as
|
|
180
|
+
distribution of the source code, even though third parties are not
|
|
181
|
+
compelled to copy the source along with the object code.
|
|
182
|
+
|
|
183
|
+
**4.** You may not copy, modify, sublicense, or distribute the Program
|
|
184
|
+
except as expressly provided under this License. Any attempt otherwise
|
|
185
|
+
to copy, modify, sublicense or distribute the Program is void, and
|
|
186
|
+
will automatically terminate your rights under this License. However,
|
|
187
|
+
parties who have received copies, or rights, from you under this
|
|
188
|
+
License will not have their licenses terminated so long as such
|
|
189
|
+
parties remain in full compliance.
|
|
190
|
+
|
|
191
|
+
**5.** You are not required to accept this License, since you have not
|
|
192
|
+
signed it. However, nothing else grants you permission to modify or
|
|
193
|
+
distribute the Program or its derivative works. These actions are
|
|
194
|
+
prohibited by law if you do not accept this License. Therefore, by
|
|
195
|
+
modifying or distributing the Program (or any work based on the
|
|
196
|
+
Program), you indicate your acceptance of this License to do so, and
|
|
197
|
+
all its terms and conditions for copying, distributing or modifying
|
|
198
|
+
the Program or works based on it.
|
|
199
|
+
|
|
200
|
+
**6.** Each time you redistribute the Program (or any work based on
|
|
201
|
+
the Program), the recipient automatically receives a license from the
|
|
202
|
+
original licensor to copy, distribute or modify the Program subject to
|
|
203
|
+
these terms and conditions. You may not impose any further
|
|
204
|
+
restrictions on the recipients' exercise of the rights granted herein.
|
|
205
|
+
You are not responsible for enforcing compliance by third parties to
|
|
206
|
+
this License.
|
|
207
|
+
|
|
208
|
+
**7.** If, as a consequence of a court judgment or allegation of
|
|
209
|
+
patent infringement or for any other reason (not limited to patent
|
|
210
|
+
issues), conditions are imposed on you (whether by court order,
|
|
211
|
+
agreement or otherwise) that contradict the conditions of this
|
|
212
|
+
License, they do not excuse you from the conditions of this License.
|
|
213
|
+
If you cannot distribute so as to satisfy simultaneously your
|
|
214
|
+
obligations under this License and any other pertinent obligations,
|
|
215
|
+
then as a consequence you may not distribute the Program at all. For
|
|
216
|
+
example, if a patent license would not permit royalty-free
|
|
217
|
+
redistribution of the Program by all those who receive copies directly
|
|
218
|
+
or indirectly through you, then the only way you could satisfy both it
|
|
219
|
+
and this License would be to refrain entirely from distribution of the
|
|
220
|
+
Program.
|
|
221
|
+
|
|
222
|
+
If any portion of this section is held invalid or unenforceable under
|
|
223
|
+
any particular circumstance, the balance of the section is intended to
|
|
224
|
+
apply and the section as a whole is intended to apply in other
|
|
225
|
+
circumstances.
|
|
226
|
+
|
|
227
|
+
It is not the purpose of this section to induce you to infringe any
|
|
228
|
+
patents or other property right claims or to contest validity of any
|
|
229
|
+
such claims; this section has the sole purpose of protecting the
|
|
230
|
+
integrity of the free software distribution system, which is
|
|
231
|
+
implemented by public license practices. Many people have made
|
|
232
|
+
generous contributions to the wide range of software distributed
|
|
233
|
+
through that system in reliance on consistent application of that
|
|
234
|
+
system; it is up to the author/donor to decide if he or she is willing
|
|
235
|
+
to distribute software through any other system and a licensee cannot
|
|
236
|
+
impose that choice.
|
|
237
|
+
|
|
238
|
+
This section is intended to make thoroughly clear what is believed to
|
|
239
|
+
be a consequence of the rest of this License.
|
|
240
|
+
|
|
241
|
+
**8.** If the distribution and/or use of the Program is restricted in
|
|
242
|
+
certain countries either by patents or by copyrighted interfaces, the
|
|
243
|
+
original copyright holder who places the Program under this License
|
|
244
|
+
may add an explicit geographical distribution limitation excluding
|
|
245
|
+
those countries, so that distribution is permitted only in or among
|
|
246
|
+
countries not thus excluded. In such case, this License incorporates
|
|
247
|
+
the limitation as if written in the body of this License.
|
|
248
|
+
|
|
249
|
+
**9.** The Free Software Foundation may publish revised and/or new
|
|
250
|
+
versions of the General Public License from time to time. Such new
|
|
251
|
+
versions will be similar in spirit to the present version, but may
|
|
252
|
+
differ in detail to address new problems or concerns.
|
|
253
|
+
|
|
254
|
+
Each version is given a distinguishing version number. If the Program
|
|
255
|
+
specifies a version number of this License which applies to it and
|
|
256
|
+
"any later version", you have the option of following the terms and
|
|
257
|
+
conditions either of that version or of any later version published by
|
|
258
|
+
the Free Software Foundation. If the Program does not specify a
|
|
259
|
+
version number of this License, you may choose any version ever
|
|
260
|
+
published by the Free Software Foundation.
|
|
261
|
+
|
|
262
|
+
**10.** If you wish to incorporate parts of the Program into other
|
|
263
|
+
free programs whose distribution conditions are different, write to
|
|
264
|
+
the author to ask for permission. For software which is copyrighted by
|
|
265
|
+
the Free Software Foundation, write to the Free Software Foundation;
|
|
266
|
+
we sometimes make exceptions for this. Our decision will be guided by
|
|
267
|
+
the two goals of preserving the free status of all derivatives of our
|
|
268
|
+
free software and of promoting the sharing and reuse of software
|
|
269
|
+
generally.
|
|
270
|
+
|
|
271
|
+
**NO WARRANTY**
|
|
272
|
+
|
|
273
|
+
**11.** BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO
|
|
274
|
+
WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
|
|
275
|
+
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
|
|
276
|
+
OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY
|
|
277
|
+
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
|
|
278
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
279
|
+
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
|
|
280
|
+
PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME
|
|
281
|
+
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
|
282
|
+
|
|
283
|
+
**12.** IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
|
|
284
|
+
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
|
|
285
|
+
AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU
|
|
286
|
+
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
|
|
287
|
+
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
|
|
288
|
+
PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
|
|
289
|
+
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
|
|
290
|
+
FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF
|
|
291
|
+
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
|
|
292
|
+
DAMAGES.
|
|
293
|
+
|
|
294
|
+
END OF TERMS AND CONDITIONS
|
|
295
|
+
|
|
296
|
+
## How to Apply These Terms to Your New Programs
|
|
297
|
+
|
|
298
|
+
If you develop a new program, and you want it to be of the greatest
|
|
299
|
+
possible use to the public, the best way to achieve this is to make it
|
|
300
|
+
free software which everyone can redistribute and change under these
|
|
301
|
+
terms.
|
|
302
|
+
|
|
303
|
+
To do so, attach the following notices to the program. It is safest to
|
|
304
|
+
attach them to the start of each source file to most effectively
|
|
305
|
+
convey the exclusion of warranty; and each file should have at least
|
|
306
|
+
the "copyright" line and a pointer to where the full notice is found.
|
|
307
|
+
|
|
308
|
+
one line to give the program's name and an idea of what it does.
|
|
309
|
+
Copyright (C) yyyy name of author
|
|
310
|
+
|
|
311
|
+
This program is free software; you can redistribute it and/or
|
|
312
|
+
modify it under the terms of the GNU General Public License
|
|
313
|
+
as published by the Free Software Foundation; either version 2
|
|
314
|
+
of the License, or (at your option) any later version.
|
|
315
|
+
|
|
316
|
+
This program is distributed in the hope that it will be useful,
|
|
317
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
318
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
319
|
+
GNU General Public License for more details.
|
|
320
|
+
|
|
321
|
+
You should have received a copy of the GNU General Public License
|
|
322
|
+
along with this program; if not, see <https://www.gnu.org/licenses/>.
|
|
323
|
+
|
|
324
|
+
Also add information on how to contact you by electronic and paper
|
|
325
|
+
mail.
|
|
326
|
+
|
|
327
|
+
If the program is interactive, make it output a short notice like this
|
|
328
|
+
when it starts in an interactive mode:
|
|
329
|
+
|
|
330
|
+
Gnomovision version 69, Copyright (C) year name of author
|
|
331
|
+
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details
|
|
332
|
+
type `show w'. This is free software, and you are welcome
|
|
333
|
+
to redistribute it under certain conditions; type `show c'
|
|
334
|
+
for details.
|
|
335
|
+
|
|
336
|
+
The hypothetical commands \`show w' and \`show c' should show the
|
|
337
|
+
appropriate parts of the General Public License. Of course, the
|
|
338
|
+
commands you use may be called something other than \`show w' and
|
|
339
|
+
\`show c'; they could even be mouse-clicks or menu items--whatever
|
|
340
|
+
suits your program.
|
|
341
|
+
|
|
342
|
+
You should also get your employer (if you work as a programmer) or
|
|
343
|
+
your school, if any, to sign a "copyright disclaimer" for the program,
|
|
344
|
+
if necessary. Here is a sample; alter the names:
|
|
345
|
+
|
|
346
|
+
Yoyodyne, Inc., hereby disclaims all copyright
|
|
347
|
+
interest in the program `Gnomovision'
|
|
348
|
+
(which makes passes at compilers) written
|
|
349
|
+
by James Hacker.
|
|
350
|
+
|
|
351
|
+
signature of Moe Ghoul, 1 April 1989
|
|
352
|
+
Moe Ghoul, President of Vice
|
|
353
|
+
|
|
354
|
+
This General Public License does not permit incorporating your program
|
|
355
|
+
into proprietary programs. If your program is a subroutine library,
|
|
356
|
+
you may consider it more useful to permit linking proprietary
|
|
357
|
+
applications with the library. If this is what you want to do, use the
|
|
358
|
+
[GNU Lesser General Public
|
|
359
|
+
License](https://www.gnu.org/licenses/lgpl.html) instead of this
|
|
360
|
+
License.
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: amd-ucode-patch
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: A Python library for parsing and interpreting AMD microcode patch files
|
|
5
|
+
Project-URL: Homepage, https://github.com/amd-zenith/amd-ucode-patch
|
|
6
|
+
Project-URL: Repository, https://github.com/amd-zenith/amd-ucode-patch
|
|
7
|
+
Project-URL: Issues, https://github.com/amd-zenith/amd-ucode-patch/issues
|
|
8
|
+
Author: Kaya Erchiran
|
|
9
|
+
Author-email: Antonio Vázquez Blanco <antoniovazquezblanco@gmail.com>
|
|
10
|
+
License-Expression: GPL-2.0-or-later
|
|
11
|
+
License-File: LICENSE.md
|
|
12
|
+
Keywords: amd,microcode,parser,patch,ucode,x86
|
|
13
|
+
Classifier: Development Status :: 4 - Beta
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: Operating System :: OS Independent
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
22
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
23
|
+
Classifier: Topic :: System :: Hardware
|
|
24
|
+
Classifier: Topic :: Utilities
|
|
25
|
+
Requires-Python: >=3.10
|
|
26
|
+
Requires-Dist: rich
|
|
27
|
+
Description-Content-Type: text/markdown
|
|
28
|
+
|
|
29
|
+
# AMD Microcode Patch
|
|
30
|
+
|
|
31
|
+
[](https://github.com/amd-zenith/amd-ucode-patch/actions/workflows/build.yml)
|
|
32
|
+
[](https://github.com/amd-zenith/amd-ucode-patch/actions/workflows/codeql.yml)
|
|
33
|
+
[](https://pypi.org/project/amd-ucode-patch/)
|
|
34
|
+
[](https://pypi.org/project/amd-ucode-patch/)
|
|
35
|
+
[](https://snyk.io/advisor/python/amd-ucode-patch)
|
|
36
|
+
[](https://scorecard.dev/viewer/?uri=github.com/amd-zenith/amd-ucode-patch)
|
|
37
|
+
|
|
38
|
+
A Python library for parsing and interpreting AMD microcode patch files.
|
|
39
|
+
|
|
40
|
+
## Installation
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
pip install amd-ucode-patch
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Command line tools
|
|
47
|
+
|
|
48
|
+
Installing the package provides the following command line tools.
|
|
49
|
+
|
|
50
|
+
### `amd_ucode_patch_info`
|
|
51
|
+
|
|
52
|
+
Inspect one or more AMD microcode patch files and print their header
|
|
53
|
+
information as a table.
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
amd_ucode_patch_info <files...> [-f {text,md,csv}]
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Arguments:
|
|
60
|
+
|
|
61
|
+
- `files`: One or more patch files to inspect. Glob patterns (e.g. `*.bin` or `**/*.bin`) are expanded automatically.
|
|
62
|
+
- `-f`, `--format`: Output format. One of:
|
|
63
|
+
- `text` (default): A table rendered for the terminal.
|
|
64
|
+
- `md`: A Markdown table.
|
|
65
|
+
- `csv`: Comma separated values.
|
|
66
|
+
|
|
67
|
+
For every patch file the following fields are reported: file name, date, update revision, loader ID, processor revision, CPUID, family, model, stepping, autorun, encrypted and body size.
|
|
68
|
+
|
|
69
|
+
## Library usage
|
|
70
|
+
|
|
71
|
+
The package can also be used programmatically:
|
|
72
|
+
|
|
73
|
+
```python
|
|
74
|
+
from amd_ucode_patch.parse import ucode_patch_parse
|
|
75
|
+
|
|
76
|
+
patch = ucode_patch_parse("firmware.bin")
|
|
77
|
+
print(patch.header.cpuid_str)
|
|
78
|
+
print(patch.header.update_revision)
|
|
79
|
+
```
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# AMD Microcode Patch
|
|
2
|
+
|
|
3
|
+
[](https://github.com/amd-zenith/amd-ucode-patch/actions/workflows/build.yml)
|
|
4
|
+
[](https://github.com/amd-zenith/amd-ucode-patch/actions/workflows/codeql.yml)
|
|
5
|
+
[](https://pypi.org/project/amd-ucode-patch/)
|
|
6
|
+
[](https://pypi.org/project/amd-ucode-patch/)
|
|
7
|
+
[](https://snyk.io/advisor/python/amd-ucode-patch)
|
|
8
|
+
[](https://scorecard.dev/viewer/?uri=github.com/amd-zenith/amd-ucode-patch)
|
|
9
|
+
|
|
10
|
+
A Python library for parsing and interpreting AMD microcode patch files.
|
|
11
|
+
|
|
12
|
+
## Installation
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
pip install amd-ucode-patch
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Command line tools
|
|
19
|
+
|
|
20
|
+
Installing the package provides the following command line tools.
|
|
21
|
+
|
|
22
|
+
### `amd_ucode_patch_info`
|
|
23
|
+
|
|
24
|
+
Inspect one or more AMD microcode patch files and print their header
|
|
25
|
+
information as a table.
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
amd_ucode_patch_info <files...> [-f {text,md,csv}]
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Arguments:
|
|
32
|
+
|
|
33
|
+
- `files`: One or more patch files to inspect. Glob patterns (e.g. `*.bin` or `**/*.bin`) are expanded automatically.
|
|
34
|
+
- `-f`, `--format`: Output format. One of:
|
|
35
|
+
- `text` (default): A table rendered for the terminal.
|
|
36
|
+
- `md`: A Markdown table.
|
|
37
|
+
- `csv`: Comma separated values.
|
|
38
|
+
|
|
39
|
+
For every patch file the following fields are reported: file name, date, update revision, loader ID, processor revision, CPUID, family, model, stepping, autorun, encrypted and body size.
|
|
40
|
+
|
|
41
|
+
## Library usage
|
|
42
|
+
|
|
43
|
+
The package can also be used programmatically:
|
|
44
|
+
|
|
45
|
+
```python
|
|
46
|
+
from amd_ucode_patch.parse import ucode_patch_parse
|
|
47
|
+
|
|
48
|
+
patch = ucode_patch_parse("firmware.bin")
|
|
49
|
+
print(patch.header.cpuid_str)
|
|
50
|
+
print(patch.header.update_revision)
|
|
51
|
+
```
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling", "hatch-vcs"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "amd-ucode-patch"
|
|
7
|
+
dynamic = ["version"]
|
|
8
|
+
authors = [
|
|
9
|
+
{ name="Antonio Vázquez Blanco", email="antoniovazquezblanco@gmail.com" },
|
|
10
|
+
{ name="Kaya Erchiran" },
|
|
11
|
+
]
|
|
12
|
+
description = "A Python library for parsing and interpreting AMD microcode patch files"
|
|
13
|
+
readme = "README.md"
|
|
14
|
+
requires-python = ">=3.10"
|
|
15
|
+
license = "GPL-2.0-or-later"
|
|
16
|
+
license-files = ["LICENSE.md"]
|
|
17
|
+
keywords = ["amd", "microcode", "ucode", "patch", "parser", "x86"]
|
|
18
|
+
classifiers = [
|
|
19
|
+
"Development Status :: 4 - Beta",
|
|
20
|
+
"Intended Audience :: Developers",
|
|
21
|
+
"Programming Language :: Python :: 3",
|
|
22
|
+
"Programming Language :: Python :: 3.10",
|
|
23
|
+
"Programming Language :: Python :: 3.11",
|
|
24
|
+
"Programming Language :: Python :: 3.12",
|
|
25
|
+
"Programming Language :: Python :: 3.13",
|
|
26
|
+
"Programming Language :: Python :: 3.14",
|
|
27
|
+
"Operating System :: OS Independent",
|
|
28
|
+
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
29
|
+
"Topic :: System :: Hardware",
|
|
30
|
+
"Topic :: Utilities",
|
|
31
|
+
]
|
|
32
|
+
dependencies = [
|
|
33
|
+
"rich",
|
|
34
|
+
]
|
|
35
|
+
|
|
36
|
+
[project.urls]
|
|
37
|
+
Homepage = "https://github.com/amd-zenith/amd-ucode-patch"
|
|
38
|
+
Repository = "https://github.com/amd-zenith/amd-ucode-patch"
|
|
39
|
+
Issues = "https://github.com/amd-zenith/amd-ucode-patch/issues"
|
|
40
|
+
|
|
41
|
+
[project.scripts]
|
|
42
|
+
amd_ucode_patch_info = "amd_ucode_patch.cli_info:main"
|
|
43
|
+
|
|
44
|
+
[tool.hatch.version]
|
|
45
|
+
source = "vcs"
|
|
46
|
+
|
|
47
|
+
[tool.hatch.build.targets.wheel]
|
|
48
|
+
packages = ["src/amd_ucode_patch"]
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
# SPDX-License-Identifier: GPL-2.0-or-later
|
|
3
|
+
'''
|
|
4
|
+
Banner for the CLI tools.
|
|
5
|
+
'''
|
|
6
|
+
|
|
7
|
+
BANNER = r'''
|
|
8
|
+
_____ _____ ____ _____ _
|
|
9
|
+
| _ | | \ _ _| |___ _| |___
|
|
10
|
+
| | | | | | | | | | --| . | . | -_|
|
|
11
|
+
|__|__|_|_|_|____/ |___|_____|___|___|___|
|
|
12
|
+
_____ _ _
|
|
13
|
+
| _ |___| |_ ___| |_
|
|
14
|
+
| __| .'| _| _| |
|
|
15
|
+
|__| |__,|_| |___|_|_|
|
|
16
|
+
'''
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
# SPDX-License-Identifier: GPL-2.0-or-later
|
|
3
|
+
'''
|
|
4
|
+
A command line tool to print information about AMD uCode patch files.
|
|
5
|
+
'''
|
|
6
|
+
|
|
7
|
+
import glob
|
|
8
|
+
import argparse
|
|
9
|
+
from pathlib import Path
|
|
10
|
+
from rich import box
|
|
11
|
+
from rich.console import Console
|
|
12
|
+
from rich.table import Table
|
|
13
|
+
from .banner import BANNER
|
|
14
|
+
from .parse import ucode_patch_parse
|
|
15
|
+
|
|
16
|
+
COLS = ["File", "Date", "Upd. Rev", "Loader ID", "Proc. Rev", "CPUID", "Family", "Model", "Stepping", "Autorun", "Encrypted", "Body size"]
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def expand_paths(patterns):
|
|
20
|
+
for pattern in patterns:
|
|
21
|
+
matches = sorted(glob.glob(pattern, recursive=True))
|
|
22
|
+
if not matches:
|
|
23
|
+
yield Path(pattern)
|
|
24
|
+
continue
|
|
25
|
+
for match in matches:
|
|
26
|
+
yield Path(match)
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def _row_fields(path, patch):
|
|
30
|
+
return (
|
|
31
|
+
str(path),
|
|
32
|
+
f"{patch.header.year:04d}-{patch.header.month:02d}-{patch.header.day:02d}",
|
|
33
|
+
f"{patch.header.update_revision:08x}",
|
|
34
|
+
f"{patch.header.loader_id:04x}",
|
|
35
|
+
f"{patch.header.processor_rev_id:04x}",
|
|
36
|
+
patch.header.cpuid_str,
|
|
37
|
+
f"0x{patch.header.cpu_family:02x}",
|
|
38
|
+
f"0x{patch.header.cpu_model:02x}",
|
|
39
|
+
f"0x{patch.header.cpu_stepping:02x}",
|
|
40
|
+
f"{patch.verified_header.autorun if patch.verified_header is not None else ''}",
|
|
41
|
+
f"{patch.verified_header.encrypted if patch.verified_header is not None else ''}",
|
|
42
|
+
f"{len(patch.body)}",
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
def print_table(console: Console, paths, format):
|
|
46
|
+
table = Table(*COLS, box=format)
|
|
47
|
+
for path in paths:
|
|
48
|
+
try:
|
|
49
|
+
patch = ucode_patch_parse(path)
|
|
50
|
+
table.add_row(*_row_fields(path, patch))
|
|
51
|
+
except Exception as e:
|
|
52
|
+
console.log(f"Error parsing {path}: {e}")
|
|
53
|
+
console.print(table)
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
def print_csv(console: Console, paths):
|
|
57
|
+
console.print(",".join(COLS))
|
|
58
|
+
for path in paths:
|
|
59
|
+
patch = ucode_patch_parse(path)
|
|
60
|
+
console.print(",".join(_row_fields(path, patch)))
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
def main():
|
|
64
|
+
console = Console()
|
|
65
|
+
console.print(BANNER, highlight=False)
|
|
66
|
+
|
|
67
|
+
parser = argparse.ArgumentParser(description="Inspect AMD microcode patch files.")
|
|
68
|
+
parser.add_argument("files", nargs="+", help="Patch files to inspect")
|
|
69
|
+
parser.add_argument("-f", "--format", choices=["text", "md", "csv"], default="text")
|
|
70
|
+
args = parser.parse_args()
|
|
71
|
+
|
|
72
|
+
paths = expand_paths(args.files)
|
|
73
|
+
if args.format == "text":
|
|
74
|
+
print_table(console, paths, box.HEAVY_HEAD)
|
|
75
|
+
elif args.format == "md":
|
|
76
|
+
print_table(console, paths, box.MARKDOWN)
|
|
77
|
+
elif args.format == "csv":
|
|
78
|
+
print_csv(console, paths)
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
if __name__ == "__main__":
|
|
82
|
+
main()
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
# SPDX-License-Identifier: GPL-2.0-or-later
|
|
3
|
+
|
|
4
|
+
from .structures.ucode_patch import UcodePatch
|
|
5
|
+
|
|
6
|
+
def ucode_patch_name(patch: UcodePatch, enc_override=None) -> str:
|
|
7
|
+
# Format should be:
|
|
8
|
+
# family<family>_cpuid<cpuid>_rev<revision>_date<yyyymmdd>_enc<ee>.bin
|
|
9
|
+
# The _enc<ee> suffix is only present when a verified header exists.
|
|
10
|
+
name = f"family{patch.header.cpu_family:02x}_cpuid{patch.header.cpuid_str}_rev{patch.header.update_revision:08x}_date{patch.header.year:04}{patch.header.month:02}{patch.header.day:02}"
|
|
11
|
+
if patch.verified_header is not None:
|
|
12
|
+
enc = patch.verified_header.encrypted if enc_override is None else enc_override
|
|
13
|
+
name += f"_enc{enc:02}"
|
|
14
|
+
name += ".bin"
|
|
15
|
+
return name
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
# SPDX-License-Identifier: GPL-2.0-or-later
|
|
3
|
+
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
from .structures.ucode_patch import UcodePatch
|
|
6
|
+
|
|
7
|
+
def ucode_patch_parse(file: Path) -> UcodePatch:
|
|
8
|
+
with file.open("rb") as f:
|
|
9
|
+
return UcodePatch.from_bytes(f.read())
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
# SPDX-License-Identifier: GPL-2.0-or-later
|
|
3
|
+
|
|
4
|
+
from dataclasses import dataclass
|
|
5
|
+
from .ucode_patch_header import UcodePatchHeader
|
|
6
|
+
from .verified_header import VerifiedHeader
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
@dataclass
|
|
10
|
+
class UcodePatch:
|
|
11
|
+
header: UcodePatchHeader
|
|
12
|
+
signature: bytes
|
|
13
|
+
public_key: bytes
|
|
14
|
+
verified_header: VerifiedHeader | None
|
|
15
|
+
body: bytes
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
@staticmethod
|
|
19
|
+
def from_bytes(buf: bytes) -> "UcodePatch":
|
|
20
|
+
header = UcodePatchHeader.from_bytes(buf)
|
|
21
|
+
verified_header = None if header.cpu_family < 0x16 else VerifiedHeader.from_bytes(buf[800::])
|
|
22
|
+
body_start_pos = UcodePatchHeader.SIZE + 256 + 512 + (0 if verified_header is None else VerifiedHeader.SIZE)
|
|
23
|
+
return UcodePatch(
|
|
24
|
+
header=header,
|
|
25
|
+
signature=buf[UcodePatchHeader.SIZE:UcodePatchHeader.SIZE+256],
|
|
26
|
+
public_key=buf[UcodePatchHeader.SIZE+256:UcodePatchHeader.SIZE+256+512],
|
|
27
|
+
verified_header=verified_header,
|
|
28
|
+
body=buf[body_start_pos::]
|
|
29
|
+
)
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
# SPDX-License-Identifier: GPL-2.0-or-later
|
|
3
|
+
|
|
4
|
+
import struct
|
|
5
|
+
from dataclasses import dataclass
|
|
6
|
+
|
|
7
|
+
def _weird_hex_as_dec(x: int) -> int:
|
|
8
|
+
return int(f"{x:x}", 10)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def _dec_as_weird_hex(x: int) -> int:
|
|
12
|
+
return int(str(x), 16)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
@dataclass
|
|
16
|
+
class UcodePatchHeader:
|
|
17
|
+
'''
|
|
18
|
+
https://github.com/torvalds/linux/blob/3544d5ce36f403db6e5c994f526101c870ffe9fe/arch/x86/kernel/cpu/microcode/amd.c#L70
|
|
19
|
+
|
|
20
|
+
Original structure:
|
|
21
|
+
struct microcode_header_amd {
|
|
22
|
+
u32 data_code;
|
|
23
|
+
u32 patch_id;
|
|
24
|
+
u16 mc_patch_data_id;
|
|
25
|
+
u8 mc_patch_data_len;
|
|
26
|
+
u8 init_flag;
|
|
27
|
+
u32 mc_patch_data_checksum;
|
|
28
|
+
u32 nb_dev_id;
|
|
29
|
+
u32 sb_dev_id;
|
|
30
|
+
u16 processor_rev_id;
|
|
31
|
+
u8 nb_rev_id;
|
|
32
|
+
u8 sb_rev_id;
|
|
33
|
+
u8 bios_api_rev;
|
|
34
|
+
u8 reserved1[3];
|
|
35
|
+
u32 match_reg[8];
|
|
36
|
+
} __packed;
|
|
37
|
+
|
|
38
|
+
data_code is in reality a date. We split that into u16, u8, u8.
|
|
39
|
+
patch_id is referred to as revision in many other places.
|
|
40
|
+
'''
|
|
41
|
+
FMT = "<HBB I HBB I II H BBBBBB"
|
|
42
|
+
SIZE = struct.calcsize(FMT)
|
|
43
|
+
|
|
44
|
+
year: int
|
|
45
|
+
day: int
|
|
46
|
+
month: int
|
|
47
|
+
update_revision: int
|
|
48
|
+
loader_id: int
|
|
49
|
+
unk0: int
|
|
50
|
+
unk1: int
|
|
51
|
+
unk2: int
|
|
52
|
+
unk3: int
|
|
53
|
+
unk4: int
|
|
54
|
+
processor_rev_id: int
|
|
55
|
+
unk5: int
|
|
56
|
+
unk6: int
|
|
57
|
+
unk7: int
|
|
58
|
+
unk8: int
|
|
59
|
+
unk9: int
|
|
60
|
+
unk10: int
|
|
61
|
+
|
|
62
|
+
@property
|
|
63
|
+
def cpu_family(self) -> int:
|
|
64
|
+
return 0xf + (self.processor_rev_id >> 12)
|
|
65
|
+
|
|
66
|
+
@property
|
|
67
|
+
def cpu_model(self) -> int:
|
|
68
|
+
return (self.processor_rev_id >> 4) & 0xf
|
|
69
|
+
|
|
70
|
+
@property
|
|
71
|
+
def cpu_stepping(self) -> int:
|
|
72
|
+
return self.processor_rev_id & 0xf
|
|
73
|
+
|
|
74
|
+
@property
|
|
75
|
+
def cpuid_str(self) -> str:
|
|
76
|
+
hi = (self.processor_rev_id >> 8) & 0xFF
|
|
77
|
+
lo = self.processor_rev_id & 0xFF
|
|
78
|
+
return f"00{hi:02X}0F{lo:02X}"
|
|
79
|
+
|
|
80
|
+
@staticmethod
|
|
81
|
+
def from_bytes(buf: bytes) -> "UcodePatchHeader":
|
|
82
|
+
if len(buf) < UcodePatchHeader.SIZE:
|
|
83
|
+
raise ValueError("not enough bytes for AMD header")
|
|
84
|
+
chunk = buf[0:UcodePatchHeader.SIZE]
|
|
85
|
+
vals = struct.unpack(UcodePatchHeader.FMT, chunk)
|
|
86
|
+
return UcodePatchHeader(
|
|
87
|
+
year=_weird_hex_as_dec(vals[0]),
|
|
88
|
+
day=_weird_hex_as_dec(vals[1]),
|
|
89
|
+
month=_weird_hex_as_dec(vals[2]),
|
|
90
|
+
update_revision=vals[3],
|
|
91
|
+
loader_id=vals[4],
|
|
92
|
+
unk0=vals[5],
|
|
93
|
+
unk1=vals[6],
|
|
94
|
+
unk2=vals[7],
|
|
95
|
+
unk3=vals[8],
|
|
96
|
+
unk4=vals[9],
|
|
97
|
+
processor_rev_id=vals[10],
|
|
98
|
+
unk5=vals[11],
|
|
99
|
+
unk6=vals[12],
|
|
100
|
+
unk7=vals[13],
|
|
101
|
+
unk8=vals[14],
|
|
102
|
+
unk9=vals[15],
|
|
103
|
+
unk10=vals[16],
|
|
104
|
+
)
|
|
105
|
+
|
|
106
|
+
def to_bytes(self) -> bytes:
|
|
107
|
+
return struct.pack(
|
|
108
|
+
UcodePatchHeader.FMT,
|
|
109
|
+
_dec_as_weird_hex(self.year),
|
|
110
|
+
_dec_as_weird_hex(self.day),
|
|
111
|
+
_dec_as_weird_hex(self.month),
|
|
112
|
+
self.update_revision,
|
|
113
|
+
self.loader_id,
|
|
114
|
+
self.unk0,
|
|
115
|
+
self.unk1,
|
|
116
|
+
self.unk2,
|
|
117
|
+
self.unk3,
|
|
118
|
+
self.unk4,
|
|
119
|
+
self.processor_rev_id,
|
|
120
|
+
self.unk5,
|
|
121
|
+
self.unk6,
|
|
122
|
+
self.unk7,
|
|
123
|
+
self.unk8,
|
|
124
|
+
self.unk9,
|
|
125
|
+
self.unk10,
|
|
126
|
+
)
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
# SPDX-License-Identifier: GPL-2.0-or-later
|
|
3
|
+
|
|
4
|
+
import struct
|
|
5
|
+
from dataclasses import dataclass
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
@dataclass
|
|
10
|
+
class VerifiedHeader:
|
|
11
|
+
FMT = "<BB BB I"
|
|
12
|
+
SIZE = struct.calcsize(FMT)
|
|
13
|
+
|
|
14
|
+
autorun: int
|
|
15
|
+
encrypted: int
|
|
16
|
+
unk0: int
|
|
17
|
+
unk1: int
|
|
18
|
+
update_revision: int
|
|
19
|
+
|
|
20
|
+
@staticmethod
|
|
21
|
+
def from_bytes(buf: bytes) -> "VerifiedHeader":
|
|
22
|
+
if len(buf) < VerifiedHeader.SIZE:
|
|
23
|
+
raise ValueError("not enough bytes for AMD verified header")
|
|
24
|
+
chunk = buf[0:VerifiedHeader.SIZE]
|
|
25
|
+
vals = struct.unpack(VerifiedHeader.FMT, chunk)
|
|
26
|
+
return VerifiedHeader(
|
|
27
|
+
autorun=vals[0],
|
|
28
|
+
encrypted=vals[1],
|
|
29
|
+
unk0=vals[2],
|
|
30
|
+
unk1=vals[3],
|
|
31
|
+
update_revision=vals[4],
|
|
32
|
+
)
|
|
33
|
+
|
|
34
|
+
def to_bytes(self) -> bytes:
|
|
35
|
+
return struct.pack(
|
|
36
|
+
VerifiedHeader.FMT,
|
|
37
|
+
self.autorun,
|
|
38
|
+
self.encrypted,
|
|
39
|
+
self.unk0,
|
|
40
|
+
self.unk1,
|
|
41
|
+
self.update_revision,
|
|
42
|
+
)
|