Recommonmark has been deprecated since 2021 [1] and the last release was over 3 years ago [2]. As per their announcement, Markedly Structured Text (MyST) Parser [3] is the recommended replacement. For the most part, the existing documentation is compatible with MyST, as both parsers are built around the CommonMark flavor of Markdown. The main difference that affects coreboot is how the Sphinx toctree is generated. Recommonmark has a feature called auto_toc_tree, which converts single level lists of references into a toctree: * [Part 1: Starting from scratch](part1.md) * [Part 2: Submitting a patch to coreboot.org](part2.md) * [Part 3: Writing unit tests](part3.md) * [Managing local additions](managing_local_additions.md) * [Flashing firmware](flashing_firmware/index.md) MyST Parser does not provide a replacement for this feature, meaning the toctree must be defined manually. This is done using MyST's syntax for Sphinx directives: ```{toctree} :maxdepth: 1 Part 1: Starting from scratch <part1.md> Part 2: Submitting a patch to coreboot.org <part2.md> Part 3: Writing unit tests <part3.md> Managing local additions <managing_local_additions.md> Flashing firmware <flashing_firmware/index.md> ``` Internally, auto_toc_tree essentially converts lists of references into the Sphinx toctree structure that the MyST syntax above more directly represents. The toctrees were converted to the MyST syntax using the following command and Python script: `find ./ -iname "*.md" | xargs -n 1 python conv_toctree.py` ``` import re import sys in_list = False f = open(sys.argv[1]) lines = f.readlines() f.close() with open(sys.argv[1], "w") as f: for line in lines: match = re.match(r"^[-*+] \[(.*)\]\((.*)\)$", line) if match is not None: if not in_list: in_list = True f.write("```{toctree}\n") f.write(":maxdepth: 1\n\n") f.write(match.group(1) + " <" + match.group(2) + ">\n") else: if in_list: f.write("```\n") f.write(line) in_list = False if in_list: f.write("```\n") ``` While this does add a little more work for creating the toctree, this does give more control over exactly what goes into the toctree. For instance, lists of links to external resources currently end up in the toctree, but we may want to limit it to pages within coreboot. This change does break rendering and navigation of the documentation in applications that can render Markdown, such as Okular, Gitiles, or the GitHub mirror. Assuming the docs are mainly intended to be viewed after being rendered to doc.coreboot.org, this is probably not an issue in practice. Another difference is that MyST natively supports Markdown tables, whereas with Recommonmark, tables had to be written in embedded rST [4]. However, MyST also supports embedded rST, so the existing tables can be easily converted as the syntax is nearly identical. These were converted using `find ./ -iname "*.md" | xargs -n 1 sed -i "s/eval_rst/{eval-rst}/"` Makefile.sphinx and conf.py were regenerated from scratch by running `sphinx-quickstart` using the updated version of Sphinx, which removes a lot of old commented out boilerplate. Any relevant changes coreboot had made on top of the previous autogenerated versions of these files were ported over to the newly generated file. From some initial testing the generated webpages appear and function identically to the existing documentation built with Recommonmark. TEST: `make -C util/docker docker-build-docs` builds the documentation successfully and the generated output renders properly when viewed in a web browser. [1] https://github.com/readthedocs/recommonmark/issues/221 [2] https://pypi.org/project/recommonmark/ [3] https://myst-parser.readthedocs.io/en/latest/ [4] https://doc.coreboot.org/getting_started/writing_documentation.html Change-Id: I0837c1722fa56d25c9441ea218e943d8f3d9b804 Signed-off-by: Nicholas Chin <nic.c3.14@gmail.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/73158 Reviewed-by: Matt DeVillier <matt.devillier@gmail.com> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
139 lines
4.2 KiB
Markdown
139 lines
4.2 KiB
Markdown
# SMM based flash storage driver
|
|
|
|
This documents the API exposed by the x86 system management based
|
|
storage driver.
|
|
|
|
## SMMSTORE
|
|
|
|
SMMSTORE is a [SMM] mediated driver to read from, write to and erase a
|
|
predefined region in flash. It can be enabled by setting
|
|
`CONFIG_SMMSTORE=y` in menuconfig.
|
|
|
|
This can be used by the OS or the payload to implement persistent
|
|
storage to hold for instance configuration data, without needing
|
|
to implement a (platform specific) storage driver in the payload
|
|
itself.
|
|
|
|
The API provides append-only semantics for key/value pairs.
|
|
|
|
## API
|
|
|
|
### Storage region
|
|
|
|
By default SMMSTORE will operate on a separate FMAP region called
|
|
`SMMSTORE`. The default generated FMAP will include such a region.
|
|
On systems with a locked FMAP, e.g. in an existing vboot setup
|
|
with a locked RO region, the option exists to add a cbfsfile
|
|
called `smm_store` in the `RW_LEGACY` (if CHROMEOS) or in the
|
|
`COREBOOT` FMAP regions. It is recommended for new builds using
|
|
a handcrafted FMD that intend to make use of SMMSTORE to include a
|
|
sufficiently large `SMMSTORE` FMAP region. It is recommended to
|
|
align the `SMMSTORE` region to 64KiB for the largest flash erase
|
|
op compatibility.
|
|
|
|
When a default generated FMAP is used the size of the FMAP region
|
|
is equal to `CONFIG_SMMSTORE_SIZE`. UEFI payloads expect at least
|
|
64KiB. Given that the current implementation lacks a way to rewrite
|
|
key-value pairs at least a multiple of this is recommended.
|
|
|
|
### generating the SMI
|
|
|
|
SMMSTORE is called via an SMI, which is generated via a write to the
|
|
IO port defined in the smi_cmd entry of the FADT ACPI table. `%al`
|
|
contains `APM_CNT_SMMSTORE=0xed` and is written to the smi_cmd IO
|
|
port. `%ah` contains the SMMSTORE command. `%ebx` contains the
|
|
parameter buffer to the SMMSTORE command.
|
|
|
|
### Return values
|
|
|
|
If a command succeeds, SMMSTORE will return with
|
|
`SMMSTORE_RET_SUCCESS=0` on `%eax`. On failure SMMSTORE will return
|
|
`SMMSTORE_RET_FAILURE=1`. For unsupported SMMSTORE commands
|
|
`SMMSTORE_REG_UNSUPPORTED=2` is returned.
|
|
|
|
**NOTE1**: The caller **must** check the return value and should make
|
|
no assumption on the returned data if `%eax` does not contain
|
|
`SMMSTORE_RET_SUCCESS`.
|
|
|
|
**NOTE2**: If the SMI returns without changing `%ax` assume that the
|
|
SMMSTORE feature is not installed.
|
|
|
|
### Calling arguments
|
|
|
|
SMMSTORE supports 3 subcommands that are passed via `%ah`, the additional
|
|
calling arguments are passed via `%ebx`.
|
|
|
|
**NOTE**: The size of the struct entries are in the native word size of
|
|
smihandler. This means 32 bits in almost all cases.
|
|
|
|
|
|
#### - SMMSTORE_CMD_CLEAR = 1
|
|
|
|
This clears the `SMMSTORE` storage region. The argument in `%ebx` is
|
|
unused.
|
|
|
|
#### - SMMSTORE_CMD_READ = 2
|
|
|
|
The additional parameter buffer `%ebx` contains a pointer to
|
|
the following struct:
|
|
|
|
```C
|
|
struct smmstore_params_read {
|
|
void *buf;
|
|
ssize_t bufsize;
|
|
};
|
|
```
|
|
|
|
INPUT:
|
|
- `buf`: is a pointer to where the data needs to be read
|
|
- `bufsize`: is the size of the buffer
|
|
|
|
OUTPUT:
|
|
- `buf`
|
|
- `bufsize`: returns the amount of data that has actually been read.
|
|
|
|
#### - SMMSTORE_CMD_APPEND = 3
|
|
|
|
SMMSTORE takes a key-value approach to appending data. key-value pairs
|
|
are never updated, they are always appended. It is up to the caller to
|
|
walk through the key-value pairs after reading SMMSTORE to find the
|
|
latest one.
|
|
|
|
The additional parameter buffer `%ebx` contains a pointer to
|
|
the following struct:
|
|
|
|
```C
|
|
struct smmstore_params_append {
|
|
void *key;
|
|
size_t keysize;
|
|
void *val;
|
|
size_t valsize;
|
|
};
|
|
```
|
|
|
|
INPUT:
|
|
- `key`: pointer to the key data
|
|
- `keysize`: size of the key data
|
|
- `val`: pointer to the value data
|
|
- `valsize`: size of the value data
|
|
|
|
#### Security
|
|
|
|
Pointers provided by the payload or OS are checked to not overlap with the SMM.
|
|
That protects the SMM handler from being manipulated.
|
|
|
|
*However there's no validation done on the source or destination pointing to
|
|
DRAM. A malicious application that is able to issue SMIs could extract arbitrary
|
|
data or modify the currently running kernel.*
|
|
|
|
## External links
|
|
|
|
```{toctree}
|
|
:maxdepth: 1
|
|
|
|
A Tour Beyond BIOS Implementing UEFI Authenticated Variables in SMM with EDKI <https://software.intel.com/sites/default/files/managed/cf/ea/a_tour_beyond_bios_implementing_uefi_authenticated_variables_in_smm_with_edkii.pdf>
|
|
```
|
|
Note, this differs significantly from coreboot's implementation.
|
|
|
|
[SMM]: ../security/smm.md
|