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