Skip to content

Commit 2f96033

Browse files
committed
Merge tag 'efi-2024-10-rc1' of https://source.denx.de/u-boot/custodians/u-boot-efi into next
Pull request efi-2024-10-rc1 Documentation: Update requirements.txt to use current Python module versions Add a page describing debugging U-Boot with GDB FIT: describe data-size as a conditionally mandatory property Correct link to FIT specification in SPL code. Correct kaslrseed command long text description UEFI: Add unit test checking that don't have kaslr-seed when measuring boot Deduplicate code for measured boot. Other: Print size information in fwu command
2 parents 48641bf + 636480e commit 2f96033

File tree

18 files changed

+1386
-1079
lines changed

18 files changed

+1386
-1079
lines changed

boot/Kconfig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -734,6 +734,10 @@ config LEGACY_IMAGE_FORMAT
734734
config MEASURED_BOOT
735735
bool "Measure boot images and configuration when booting without EFI"
736736
depends on HASH && TPM_V2
737+
select SHA1
738+
select SHA256
739+
select SHA384
740+
select SHA512
737741
help
738742
This option enables measurement of the boot process when booting
739743
without UEFI . Measurement involves creating cryptographic hashes

boot/bootm.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include <asm/io.h>
2525
#include <linux/sizes.h>
2626
#include <tpm-v2.h>
27+
#include <tpm_tcg2.h>
2728
#if defined(CONFIG_CMD_USB)
2829
#include <usb.h>
2930
#endif

cmd/fwu_mdata.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ static void print_mdata(struct fwu_data *data)
2222
printf("\tFWU Metadata\n");
2323
printf("crc32: %#x\n", data->crc32);
2424
printf("version: %#x\n", data->version);
25+
printf("size: %#x\n", data->metadata_size);
2526
printf("active_index: %#x\n", data->active_index);
2627
printf("previous_active_index: %#x\n", data->previous_active_index);
2728

cmd/kaslrseed.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ static int do_kaslr_seed(struct cmd_tbl *cmdtp, int flag, int argc, char *const
3333
}
3434

3535
U_BOOT_LONGHELP(kaslrseed,
36-
"[n]\n"
36+
"\n"
3737
" - append random bytes to chosen kaslr-seed node\n");
3838

3939
U_BOOT_CMD(

common/spl/spl_fit.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -587,7 +587,7 @@ __weak void *spl_load_simple_fit_fix_load(const void *fit)
587587
static void warn_deprecated(const char *msg)
588588
{
589589
printf("DEPRECATED: %s\n", msg);
590-
printf("\tSee doc/uImage.FIT/source_file_format.txt\n");
590+
printf("\tSee https://fitspec.osfw.foundation/\n");
591591
}
592592

593593
static int spl_fit_upload_fpga(struct spl_fit_info *ctx, int node,

doc/develop/gdb.rst

Lines changed: 171 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
1+
.. SPDX-License-Identifier: GPL-2.0+
2+
.. Copyright (c) 2024 Alexander Dahl
3+
4+
Debugging U-Boot with GDB
5+
=========================
6+
7+
Using a JTAG adapter it is possible to debug a running U-Boot with GDB.
8+
A common way is to connect a debug adapter to the JTAG connector of your
9+
board, run a GDB server, connect GDB to the GDB server, and use GDB as usual.
10+
11+
Similarly QEMU can provide a GDB server.
12+
13+
Preparing build
14+
---------------
15+
16+
Building U-Boot with with reduced optimization (-Og) and without link time
17+
optimization is recommended for easier debugging::
18+
19+
CONFIG_CC_OPTIMIZE_FOR_DEBUG=y
20+
CONFIG_LTO=n
21+
22+
Otherwise build, install, and run U-Boot as usual.
23+
24+
Using OpenOCD as GDB server
25+
---------------------------
26+
27+
`OpenOCD <https://openocd.org/>`_ is an open source tool supporting hardware
28+
debug probes, and providing a GDB server. It is readily available in major Linux
29+
distributions or you can build it from source.
30+
31+
Here is example of starting OpenOCD on Debian using a J-Link adapter and a
32+
board with an AT91 SAMA5D2 SoC:
33+
34+
.. code-block:: console
35+
36+
$ openocd -f interface/jlink.cfg -f target/at91sama5d2.cfg -c 'adapter speed 4000'
37+
Open On-Chip Debugger 0.12.0
38+
Licensed under GNU GPL v2
39+
For bug reports, read
40+
http://openocd.org/doc/doxygen/bugs.html
41+
Info : auto-selecting first available session transport "jtag". To override use 'transport select <transport>'.
42+
adapter speed: 4000 kHz
43+
44+
Info : Listening on port 6666 for tcl connections
45+
Info : Listening on port 4444 for telnet connections
46+
Info : J-Link V10 compiled Jan 30 2023 11:28:07
47+
Info : Hardware version: 10.10
48+
Info : VTarget = 3.244 V
49+
Info : clock speed 4000 kHz
50+
Info : JTAG tap: at91sama5d2.cpu tap/device found: 0x5ba00477 (mfg: 0x23b (ARM Ltd), part: 0xba00, ver: 0x5)
51+
Info : at91sama5d2.cpu_a5.0: hardware has 3 breakpoints, 2 watchpoints
52+
Info : at91sama5d2.cpu_a5.0: MPIDR level2 0, cluster 0, core 0, mono core, no SMT
53+
Info : starting gdb server for at91sama5d2.cpu_a5.0 on 3333
54+
Info : Listening on port 3333 for gdb connections
55+
56+
Notice that OpenOCD is listening on port 3333 for GDB connections.
57+
58+
Using QEMU as GDB server
59+
------------------------
60+
61+
When running U-Boot on QEMU you can used the '-gdb' parameter to provide a
62+
GDB server:
63+
64+
qemu-system-riscv64 -M virt -nographic -gdb tcp::3333 -kernel u-boot
65+
66+
Running a GDB session
67+
----------------------
68+
69+
You need a GDB suited for your target. This can be the GDB coming with your
70+
toolchain or *gdb-multiarch* available in your Linux distribution.
71+
72+
.. prompt:: bash $
73+
74+
gdb-multiarch u-boot
75+
76+
In the above command-line *u-boot* is the U-boot binary in your build
77+
directory. You may need to adjust the path when calling GDB.
78+
79+
Connect to the GDB server like this:
80+
81+
.. code-block:: console
82+
83+
(gdb) target extended-remote :3333
84+
Remote debugging using :3333
85+
0x27fa9ac6 in ?? ()
86+
(gdb)
87+
88+
This is fine for debugging before U-Boot relocates itself.
89+
90+
For debugging U-Boot after relocation you need to indicate the relocation
91+
address to GDB. You can retrieve the relocation address from the U-Boot shell
92+
with the command *bdinfo*:
93+
94+
.. code-block:: console
95+
96+
U-Boot> bdinfo
97+
boot_params = 0x20000100
98+
DRAM bank = 0x00000000
99+
-> start = 0x20000000
100+
-> size = 0x08000000
101+
flashstart = 0x00000000
102+
flashsize = 0x00000000
103+
flashoffset = 0x00000000
104+
baudrate = 115200 bps
105+
relocaddr = 0x27f7a000
106+
reloc off = 0x0607a000
107+
Build = 32-bit
108+
current eth = ethernet@f8008000
109+
ethaddr = 00:50:c2:31:58:d4
110+
IP addr = <NULL>
111+
fdt_blob = 0x27b36060
112+
new_fdt = 0x27b36060
113+
fdt_size = 0x00003e40
114+
lmb_dump_all:
115+
memory.cnt = 0x1 / max = 0x10
116+
memory[0] [0x20000000-0x27ffffff], 0x08000000 bytes flags: 0
117+
reserved.cnt = 0x1 / max = 0x10
118+
reserved[0] [0x27b31d00-0x27ffffff], 0x004ce300 bytes flags: 0
119+
devicetree = separate
120+
arch_number = 0x00000000
121+
TLB addr = 0x27ff0000
122+
irq_sp = 0x27b36050
123+
sp start = 0x27b36040
124+
Early malloc usage: cd8 / 2000
125+
126+
Look out for the line starting with *relocaddr* which has the address
127+
you need, ``0x27f7a000`` in this case.
128+
129+
On most architectures (not sandbox, x86, Xtensa) the global data pointer is
130+
stored in a fixed register:
131+
132+
============ ========
133+
Architecture Register
134+
============ ========
135+
arc r25
136+
arm r9
137+
arm64 x18
138+
m68k d7
139+
microblaze r31
140+
mips k0
141+
nios2 gp
142+
powerpc r2
143+
riscv gp
144+
sh r13
145+
============ ========
146+
147+
On these architecture the relocation address cat be determined by
148+
dereferencing the global data pointer stored in register, *r9* in the example:
149+
150+
.. code-block:: console
151+
152+
(gdb) p/x (*(struct global_data*)$r9)->relocaddr
153+
$1 = 0x27f7a000
154+
155+
In the GDB shell discard the previously loaded symbol file and add it once
156+
again with the relocation address like this:
157+
158+
.. code-block:: console
159+
160+
(gdb) symbol-file
161+
Discard symbol table from `/home/adahl/build/u-boot/v2024.04.x/u-boot'? (y or n) y
162+
No symbol file now.
163+
(gdb) add-symbol-file u-boot 0x27f7a000
164+
add symbol table from file "u-boot" at
165+
.text_addr = 0x27f7a000
166+
(y or n) y
167+
Reading symbols from u-boot...
168+
(gdb)
169+
170+
You can now use GDB as usual, setting breakpoints, printing backtraces,
171+
inspecting variables, stepping through the code, etc.

doc/develop/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ Debugging
6060
:maxdepth: 1
6161

6262
crash_dumps
63+
gdb
6364
trace
6465

6566
Packaging

doc/sphinx/requirements.txt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
alabaster==0.7.16
2-
Babel==2.14.0
3-
certifi==2023.11.17
2+
Babel==2.15.0
3+
certifi==2024.6.2
44
charset-normalizer==3.3.2
55
docutils==0.20.1
66
idna==3.7
77
imagesize==1.4.1
88
Jinja2==3.1.4
9-
MarkupSafe==2.1.3
10-
packaging==23.2
11-
Pygments==2.17.2
12-
requests==2.32.2
9+
MarkupSafe==2.1.5
10+
packaging==24.1
11+
Pygments==2.18.0
12+
requests==2.32.3
1313
six==1.16.0
1414
snowballstemmer==2.2.0
15-
Sphinx==7.2.6
15+
Sphinx==7.3.7
1616
sphinx-prompt==1.8.0
1717
sphinx-rtd-theme==2.0.0
1818
sphinxcontrib-applehelp==1.0.8
@@ -22,4 +22,4 @@ sphinxcontrib-jquery==4.1
2222
sphinxcontrib-jsmath==1.0.1
2323
sphinxcontrib-qthelp==1.0.7
2424
sphinxcontrib-serializinghtml==1.1.10
25-
urllib3==2.1.0
25+
urllib3==2.2.1

doc/usage/fit/source_file_format.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -254,9 +254,6 @@ compression
254254
zstd zstd compressed
255255
==================== ==================
256256

257-
data-size
258-
size of the data in bytes
259-
260257

261258
Conditionally mandatory property
262259
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -276,6 +273,9 @@ data-position
276273
not relative to the loading of the FIT. This is mandatory if external data
277274
used with a fixed address.
278275

276+
data-size
277+
Size of the data in bytes. This is mandatory if external data is used.
278+
279279
os
280280
OS name, mandatory for types "kernel". Valid OS names are:
281281

include/efi_tcg2.h

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,14 @@
1818

1919
#include <efi_api.h>
2020
#include <tpm-v2.h>
21+
#include <tpm_tcg2.h>
2122

2223
/* TPMV2 only */
2324
#define TCG2_EVENT_LOG_FORMAT_TCG_2 0x00000002
2425
#define EFI_TCG2_EXTEND_ONLY 0x0000000000000001
2526
#define PE_COFF_IMAGE 0x0000000000000010
2627

2728
#define EFI_TCG2_MAX_PCR_INDEX 23
28-
29-
/* Algorithm Registry */
30-
#define EFI_TCG2_BOOT_HASH_ALG_SHA1 0x00000001
31-
#define EFI_TCG2_BOOT_HASH_ALG_SHA256 0x00000002
32-
#define EFI_TCG2_BOOT_HASH_ALG_SHA384 0x00000004
33-
#define EFI_TCG2_BOOT_HASH_ALG_SHA512 0x00000008
34-
#define EFI_TCG2_BOOT_HASH_ALG_SM3_256 0x00000010
35-
3629
#define EFI_TCG2_FINAL_EVENTS_TABLE_VERSION 1
3730

3831
#define TPM2_EVENT_LOG_SIZE CONFIG_EFI_TCG2_PROTOCOL_EVENTLOG_SIZE

0 commit comments

Comments
 (0)