blob: f7af60579da0d8ce6391cab30d2476d91a6f931b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
|
# smmstoretool
Offline SMMSTORE variable modification tool.
## Operation
### Storage initialization
If SMMSTORE presence isn't detected and an update operation is requested, the
store spanning the whole file is created automatically. Size of the store file
must be a multiple of 64 KiB (block size in version 2 of SMMSTORE protocol),
the variable storage itself will be 64 KiB in size. That's the way EDK2 makes
use of it.
Unlike online editing which mostly appends new variable entries each storage
update with this tool drops all deleted or incomplete entries.
### Unicode
There is no actual support for it. ASCII bytes (or UTF-8 bytes if that was
passed in) is just extended to 16 bits. And Unicode chars that are larger than
8 bit are turned into `?`. Need UTF-8 to/from UTF-16 conversion functions for
proper support.
## Help
Start with:
```
$ smmstoretool -h
Usage: smmstoretool smm-store-file sub-command
smmstoretool -h|--help
Sub-commands:
* get - display current value of a variable
* guids - show GUID to alias mapping
* help - provide built-in help
* list - list variables present in the store
* remove - remove a variable from the store
* set - add or updates a variable in the store
```
Then run `smmstoretool rom help sub-command-name` to get more details.
## Data types
EFI variables in the storage don't have an associated data type and it needs to
be specified on reading/writing variables. Several basic types that correspond
to typical configuration values are supported:
* `bool` (`true`, `false`)
* `uint8` (0-255)
* `uint16` (0-65535)
* `uint32` (0-4294967295)
* `ascii` (NUL-terminated)
* `unicode` (widened and NUL-terminated)
* `raw` (output only; raw bytes on output)
## Examples
`SMMSTORE` is the name of a file containing SMMSTORE data.
### Variable listing
```
$ smmstoretool SMMSTORE list
dasharo :NetworkBoot (1 byte)
c076ec0c-7028-4399-a07271ee5c448b9f:CustomMode (1 byte)
d9bee56e-75dc-49d9-b4d7b534210f637a:certdb (4 bytes)
9073e4e0-60ec-4b6e-99034c223c260f3c:VendorKeysNv (1 byte)
6339d487-26ba-424b-9a5d687e25d740bc:TCG2_DEVICE_DETECTION (1 byte)
6339d487-26ba-424b-9a5d687e25d740bc:TCG2_CONFIGURATION (1 byte)
6339d487-26ba-424b-9a5d687e25d740bc:TCG2_VERSION (16 bytes)
global :Boot0000 (66 bytes)
global :Timeout (2 bytes)
global :PlatformLang (3 bytes)
global :Lang (4 bytes)
global :Key0000 (14 bytes)
global :Boot0001 (102 bytes)
global :Key0001 (14 bytes)
04b37fe8-f6ae-480b-bdd537d98c5e89aa:VarErrorFlag (1 byte)
dasharo :Type1UUID (16 bytes)
dasharo :Type2SN (10 bytes)
global :Boot0002 (90 bytes)
global :BootOrder (8 bytes)
global :Boot0003 (76 bytes)
...
```
### Variable reading
```
$ smmstoretool SMMSTORE get -g dasharo -n UsbDriverStack -t bool
false
```
### Variable writing
```
$ smmstoretool SMMSTORE set -g dasharo -n UsbDriverStack -t bool -v true
```
### Variable deletion
```
$ smmstoretool SMMSTORE remove -g dasharo -n NetworkBoot
```
### Real-world usage
If one edits a newly generated Dasharo `coreboot.rom`:
```bash
cbfstool coreboot.rom read -r SMMSTORE -f SMMSTORE
smmstoretool SMMSTORE set -g dasharo -n NetworkBoot -t bool -v true
cbfstool coreboot.rom write -r SMMSTORE -f SMMSTORE
```
On the first boot, "Network Boot" setting will already be enabled.
Can also read SMMSTORE from a flash and examine some of its contents for
debugging purposes without adding new logging code or powering on the hardware:
```bash
smmstoretool SMMSTORE get -g global -n BootOrder -t raw | hexdump -C
```
|