Skip to content

Commit 2f4abd5

Browse files
committed
docs: update QEMU FSP targets documentation
1 parent 96654a3 commit 2f4abd5

File tree

1 file changed

+113
-51
lines changed

1 file changed

+113
-51
lines changed

docs/Targets.md

Lines changed: 113 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -2062,56 +2062,60 @@ The following variables must be set in your `.config` file when using this featu
20622062
- `WOLFBOOT_LOAD_BASE`: the address where wolfboot will be loaded in RAM after the first initialization phase
20632063

20642064
While Intel FSP aims to abstract away specific machine details, you still need
2065-
some machine-specific code. In the next section we show how to retrieve the
2066-
target-specific code for qemu. Refer to the Intel Integration Guide of the selected
2067-
silicon for more information.
2065+
some machine-specific code. Current supported targets are QEMU and the TigerLake based Kontron VX3060-S2 board.
2066+
Refer to the Intel Integration Guide of the selected silicon for more information.
20682067

20692068
Note:
20702069

20712070
- This feature requires `NASM` to be installed on the machine building wolfBoot.
20722071

20732072

2074-
### Running on 64-bit Qemu
2073+
### Running on 64-bit QEMU
20752074

2076-
An example configuration file is available in `config/examples/x86_fsp_qemu.config`.
2075+
Two example configuration files are available: `config/examples/x86_fsp_qemu.config` and `config/examples/x86_fsp_qemu_seal.config`.
2076+
Both will try to load a 64bit ELF/Multiboot2 payload from the emulated sata drive.
2077+
The second one is an example of configuration that also do measure boot and seal/unseal secrets using a TPM.
2078+
2079+
A test ELF/Multiboot2 image is provided as well. To test `config/examples/x86_fsp_qemu.config` use the following steps:
20772080

2078-
Assuming that you have compiled a linux kernel that can boot on qemu, you can verify
2079-
and stage it by running the following commands:
20802081

20812082
```
20822083
# Copy the example configuration for this target
20832084
cp config/examples/x86_fsp_qemu.config .config
20842085
20852086
# Create necessary Intel FSP binaries from edk2 repo
2086-
tools/x86_fsp/qemu/qemu_build_fsp.sh
2087+
./tools/x86_fsp/qemu/qemu_build_fsp.sh
20872088
20882089
# build wolfboot
20892090
make
20902091
2091-
# The next script needs to be run from wolboot root folder and assumes your
2092-
# kernel is in th root folder, named bzImage
2093-
# If this is not the case, change the path in the script accordingly
2094-
tools/x86_fsp/qemu/make_hd.sh
2092+
# make test-app
2093+
make test-app/image.elf
20952094
2096-
# Run wolfBoot + Linux in qemu
2097-
tools/scripts/qemu64/qemu64.sh
2095+
# make_hd.sh sign the image, creates a file-based hard disk image with GPT table and raw partitions and then copies the signed images into the partitions.
2096+
IMAGE=test-app/image.elf tools/x86_fsp/qemu/make_hd.sh
20982097
2098+
# run wolfBoot + test-image
2099+
./tools/x86_fsp/qemu/qemu.sh
20992100
```
21002101

2101-
#### Sample boot output
2102+
#### Sample boot output using config/examples/x86_fsp_qemu.config
21022103
```
21032104
Cache-as-RAM initialized
2105+
FSP-T:0.0.10 build 0
2106+
FSP-M:0.0.10 build 0
2107+
no microcode for QEMU target
21042108
calling FspMemInit...
21052109
21062110
============= FSP Spec v2.0 Header Revision v3 ($QEMFSP$ v0.0.10.0) =============
21072111
Fsp BootFirmwareVolumeBase - 0xFFE30000
21082112
Fsp BootFirmwareVolumeSize - 0x22000
21092113
Fsp TemporaryRamBase - 0x4
2110-
Fsp TemporaryRamSize - 0x20000
2114+
Fsp TemporaryRamSize - 0x50000
21112115
Fsp PeiTemporaryRamBase - 0x4
2112-
Fsp PeiTemporaryRamSize - 0x14CCC
2113-
Fsp StackBase - 0x14CD0
2114-
Fsp StackSize - 0xB334
2116+
Fsp PeiTemporaryRamSize - 0x34000
2117+
Fsp StackBase - 0x34004
2118+
Fsp StackSize - 0x1C000
21152119
Register PPI Notify: DCD0BE23-9586-40F4-B643-06522CED4EDE
21162120
Install PPI: 8C8CE578-8A3D-4F1C-9935-896185C32DD3
21172121
Install PPI: 5473C07A-3DCB-4DCA-BD6F-1E9689E7349A
@@ -2137,15 +2141,15 @@ Install PPI: 7408D748-FC8C-4EE6-9288-C4BEC092A410
21372141
Register PPI Notify: F894643D-C449-42D1-8EA8-85BDD8C65BDE
21382142
PeiInstallPeiMemory MemoryBegin 0x3EF00000, MemoryLength 0x100000
21392143
FspmInitPoint() - End
2140-
Temp Stack : BaseAddress=0x14CD0 Length=0xB334
2141-
Temp Heap : BaseAddress=0x4 Length=0x14CCC
2142-
Total temporary memory: 131072 bytes.
2144+
Temp Stack : BaseAddress=0x34004 Length=0x1C000
2145+
Temp Heap : BaseAddress=0x4 Length=0x34000
2146+
Total temporary memory: 327680 bytes.
21432147
temporary memory stack ever used: 3360 bytes.
21442148
temporary memory heap used for HobList: 2104 bytes.
21452149
temporary memory heap occupied by memory pages: 0 bytes.
2146-
Old Stack size 45876, New stack size 131072
2150+
Old Stack size 114688, New stack size 131072
21472151
Stack Hob: BaseAddress=0x3EF00000 Length=0x20000
2148-
Heap Offset = 0x3EF1FFFC Stack Offset = 0x3EEFFFFC
2152+
Heap Offset = 0x3EF1FFFC Stack Offset = 0x3EECFFFC
21492153
Loading PEIM 52C05B14-0B98-496C-BC3B-04B50211D680
21502154
Loading PEIM at 0x0003EFF5150 EntryPoint=0x0003EFFBBC6 PeiCore.efi
21512155
Reinstall PPI: 8C8CE578-8A3D-4F1C-9935-896185C32DD3
@@ -2155,19 +2159,34 @@ Install PPI: F894643D-C449-42D1-8EA8-85BDD8C65BDE
21552159
Notify: PPI Guid: F894643D-C449-42D1-8EA8-85BDD8C65BDE, Peim notify entry point: FFE40AB2
21562160
Memory Discovered Notify invoked ...
21572161
FSP TOLM = 0x3F000000
2158-
Migrate FSP-M UPD from 7F548 to 3EFF4000
2162+
Migrate FSP-M UPD from 7F540 to 3EFF4000
21592163
FspMemoryInitApi() - [Status: 0x00000000] - End
21602164
success
21612165
top reserved 0_3EF00000h
2166+
mem: [ 0x3EEF0000, 0x3EF00000 ] - stack (0x10000)
2167+
mem: [ 0x3EEEFFF4, 0x3EEF0000 ] - stage2 parameter (0xC)
21622168
hoblist@0x3EF20000
2169+
mem: [ 0x3EEE8000, 0x3EEEFFF4 ] - page tables (0x7FF4)
2170+
page table @ 0x3EEE8000 [length: 7000]
2171+
mem: [ 0x3EEE7FF8, 0x3EEE8000 ] - stage2 ptr holder (0x8)
2172+
TOLUM: 0x3EEE7FF8
21632173
TempRamExitApi() - Begin
21642174
Memory Discovered Notify completed ...
21652175
TempRamExitApi() - [Status: 0x00000000] - End
2176+
mem: [ 0x800000, 0x800084 ] - stage1 .data (0x84)
2177+
mem: [ 0x8000A0, 0x801A80 ] - stage1 .bss (0x19E0)
2178+
mem: [ 0xFED5E00, 0xFEEAF00 ] - FSPS (0x15100)
2179+
Authenticating FSP_S at FED5E00...
2180+
Image size 86016
2181+
verify_payload: image open successfully.
2182+
verify_payload: integrity OK. Checking signature.
2183+
FSP_S: verified OK.
2184+
FSP-S:0.0.10 build 0
21662185
call silicon...
21672186
SiliconInitApi() - Begin
21682187
Install PPI: 49EDB1C1-BF21-4761-BB12-EB0031AABB39
21692188
Notify: PPI Guid: 49EDB1C1-BF21-4761-BB12-EB0031AABB39, Peim notify entry point: FFE370A2
2170-
The 1th FV start address is 0x000FFED6000, size is 0x00015000, handle is 0xFFED6000
2189+
The 1th FV start address is 0x0000FED5F00, size is 0x00015000, handle is 0xFED5F00
21712190
DiscoverPeimsAndOrderWithApriori(): Found 0x4 PEI FFS files in the 1th FV
21722191
Loading PEIM 86D70125-BAA3-4296-A62F-602BEBBB9081
21732192
Loading PEIM at 0x0003EFEE150 EntryPoint=0x0003EFF15B9 DxeIpl.efi
@@ -2199,6 +2218,11 @@ FspInitEndOfPeiCallback--
21992218
FSP is waiting for NOTIFY
22002219
FspSiliconInitApi() - [Status: 0x00000000] - End
22012220
success
2221+
pcie retraining failed FFFFFFFF
2222+
cap a 0
2223+
ddt disabled 0
2224+
device enable: 0
2225+
device enable: 128
22022226
NotifyPhaseApi() - Begin [Phase: 00000020]
22032227
FSP Post PCI Enumeration ...
22042228
Install PPI: 30CFE3E7-3DE1-4586-BE20-DEABA1B3B793
@@ -2221,8 +2245,15 @@ FspEndOfFirmwareCallback++
22212245
FspEndOfFirmwareCallback--
22222246
NotifyPhaseApi() - End [Status: 0x00000000]
22232247
CPUID(0):D 68747541 444D4163
2224-
loading wolfboot at 2000000...
2248+
mem: [ 0x1FFFF00, 0x200CC70 ] - wolfboot (0xCD70)
2249+
mem: [ 0x200CC70, 0x222FA00 ] - wolfboot .bss (0x222D90)
22252250
load wolfboot end
2251+
Authenticating wolfboot at 2000000...
2252+
Image size 52336
2253+
verify_payload: image open successfully.
2254+
verify_payload: integrity OK. Checking signature.
2255+
wolfBoot: verified OK.
2256+
starting wolfboot 64bit
22262257
AHCI port 0: No disk detected
22272258
AHCI port 1: No disk detected
22282259
AHCI port 2: No disk detected
@@ -2245,44 +2276,75 @@ Total partitions on disk0: 2
22452276
Checking primary OS image in 0,0...
22462277
Checking secondary OS image in 0,1...
22472278
Versions, A:1 B:2
2279+
Load address 0x222FA00
22482280
Attempting boot from partition B
2249-
Image size 11982512
2250-
Firmware Valid
2251-
Booting at 5000100
2252-
linux payload
2281+
mem: [ 0x222FA00, 0x2241DC8 ] - ELF (0x123C8)
2282+
Loading image from disk...done.
2283+
Image size 74696
2284+
Checking image integrity...done.
2285+
Verifying image signature...done.
2286+
Firmware Valid.
2287+
Booting at 222FB00
2288+
mem: [ 0x100, 0x1E0 ] - MPTABLE (0xE0)
2289+
Loading elf at 0x222FB00
2290+
Found valid elf64 (little endian)
2291+
Program Headers 7 (size 56)
2292+
Load 504 bytes (offset 0x0) to 0x400000 (p 0x400000)
2293+
Load 3999 bytes (offset 0x1000) to 0x401000 (p 0x401000)
2294+
Load 1952 bytes (offset 0x2000) to 0x402000 (p 0x402000)
2295+
Load 32 bytes (offset 0x3000) to 0x403000 (p 0x403000)
2296+
Entry point 0x401000
2297+
Elf loaded (ret 0), entry 0x0_401000
2298+
mb2 header found at 2232B00
22532299
booting...
2254-
Linux version 5.17.15 (arch@wb-hg-2) (x86_64-linux-gcc.br_real (Buildroot toolchains.bootlin.com-2021.11-5) 11.2.0, GNU ld (GNU Binutils) 2.37) #24 PREEMPT Wed May 17 13:47:24 UTC 2023
2300+
wolfBoot QEMU x86 FSP test app
22552301
```
22562302

2257-
### Running on 64-bit Qemu with swtpm (TPM emulator)
2258-
2259-
The example configuration for this setup can be found in
2260-
`config/examples/x86_fsp_qemu_tpm.config`.
2303+
### Running on QEMU with swtpm (TPM emulator)
22612304

2262-
First step: [clone and install swtpm](https://github.com/stefanberger/swtpm), a TPM emulator that can be connected to qemu
2263-
guest VMs. This TPM emulator will create a memory-mapped I/O device.
2305+
First step: [clone and install swtpm](https://github.com/stefanberger/swtpm), a
2306+
TPM emulator that can be connected to qemu guest VMs. This TPM emulator will
2307+
create a memory-mapped I/O device.
22642308

2265-
The other steps to follow are:
2309+
A small note is that `config/examples/x86_fsp_qemu_seal.config` showcases two
2310+
different key ecc size of 384 and 256 of authentication for image verification
2311+
and TPM sealing respectively.
22662312

2313+
The correct steps to run the example:
22672314
```
2268-
# Copy the example configuration for this target
2269-
cp config/examples/x86_fsp_qemu_tpm.config .config
2315+
# copy the example configuration for this target
2316+
cp config/examples/x86_fsp_qemu_seal.config .config
22702317
2271-
# Create necessary Intel FSP binaries from edk2 repo
2318+
# create necessary Intel FSP binaries from edk2 repo
22722319
tools/x86_fsp/qemu/qemu_build_fsp.sh
22732320
2274-
# Compile wolfBoot and assemble the loader image
2275-
make
2321+
# make keytools and tpmtools
2322+
make keytools
2323+
make tpmtools
2324+
2325+
# create two keys, one for signing the images (ecc384) and one to seal/unseal secret into the TPM (ecc256)
2326+
./tools/keytools/keygen --force --ecc384 -g wolfboot_signing_private_key.der --ecc256 -g tpm_seal_key.key
2327+
2328+
# build wolfboot, manually add ECC256 for TPM
2329+
make CFLAGS_EXTRA="-DHAVE_ECC256"
2330+
2331+
# compute the value of PCR0 to sign with TPM key
2332+
PCR0=$(python ./tools/x86_fsp/compute_pcr.py --target qemu wolfboot_stage1.bin | tail -n 1)
2333+
2334+
# sign the policy
2335+
./tools/tpm/policy_sign -ecc256 -key=tpm_seal_key.key -pcr=0 -pcrdigest=$PCR0
2336+
2337+
# install the policy
2338+
./tools/x86_fsp/tpm_install_policy.sh policy.bin.sig
22762339
2277-
# The next script needs to be run from wolboot root folder and assumes your
2278-
# kernel is in wolfBoot's root folder. The file should be named `bzImage`.
2279-
# If this is not the case, change the path in the script accordingly
2340+
# make test-app
2341+
make test-app/image.elf
22802342
2281-
tools/x86_fsp/qemu/make_hd.sh
2343+
# make_hd.sh sign the image, creates a file-based hard disk image with GPT table and raw partitions and then copy the signed images into the partitions.
2344+
IMAGE=test-app/image.elf SIGN=--ecc384 tools/x86_fsp/qemu/make_hd.sh
22822345
2283-
# Run wolfBoot + linux in qemu, with swTPM connected to the guest machine.
2284-
# The script will start the TPM emulator before launching the VM.
2285-
tools/scripts/qemu64/qemu64-tpm.sh
2346+
# run wolfBoot + test-image, use -t to emulate a TPM (requires swtpm)
2347+
./tools/x86_fsp/qemu/qemu.sh -t
22862348
```
22872349

22882350
For more advanced uses of TPM, please check [TPM.md](TPM.md) to configure wolfBoot

0 commit comments

Comments
 (0)