Hi,
I thought perhaps it might be worth starting a thread on this, as
despite Grant and Heinrich kinding spending a bit of time talking
about this, I am still very much in the dark about how 'embedded' and
distro/other boot flows are going to come together with EBBR. Of
course this would be easier f2f.
Case 1:
Firmware loads the kernel to a particular address, selects DT and
boots it. The kernel may require EFI boot services, or may not, but in
the general case the firmware provides them.
Case 2:
Firmware loads EFI app and provides EFI boot services to it. How the
system actually boots is under control of the app.
I feel that a lot of the confusion about verified boot, DT selections,
boot menus, etc. is coming from the introduction of an EFI app which
has no specification (it can be grub, shim or something else, as I
understand it). Certainly this is very flexible and future-proof, but
it is also arbitrarily complex, unpredictable and hard to secure.
I am wondering if we can come up with a way to deterministically
specify how a system will boot and how to make it boot a different way
(i.e. with a different kernel, initrd, DT).
Heinrich mentioned EFI variables as a way of selecting
kernel/initrd/DT. Then the problem becomes just a case of being able
to change those variables from Linux userspace. Is that right?
We are talking about having a 'secure' part of EBBR, which allows for
secure boot. Should we have a 'defined boot' part of EBBR, that
defines how the kernel/DT/initrd are selected, based on EFI variables?
Unfortunately I just don't know enough about all the different boot
flows used by the different distros. It seems like crazy town. Does
anyone have some pointers so I can do some study?
Regards,
SImon
Hello Atish,
the UEFI spec has this sentence:
"When UEFI firmware handoff control to OS, the RISC-V is operated in
machine-mode privilege." (M-mode is the equivalent to EL3 in ARM).
This does not make any sense to me when using a secure execution
environement (SEE) like OpenSBI.
The hand-off should occur in S-Mode if the CPU supports it and only in
M-Mode when the CPU only supports M-mode.
We should prescribe this in the EBBR and somehow get the UEFI spec fixed
afterwards.
An other issue is the calling convention. Chapter "2.3.7.3 Detailed
Calling Convention" does not describe which registers are saved by the
UEFI payload's entry point and restored by the payload before calling
the UEFI API or returning to the UEFI payload. This concerns especially
registers gp (x3) and tp (x4).
Into the EBBR or UEFI spec we should put a link to the "RISC-V ELF psABI
specification"
https://github.com/riscv/riscv-elf-psabi-doc/blob/master/riscv-elf.md
which is referenced by "The RISC-V Instruction Set Manual".
>From the "RISC-V ELF psABI specification" one might conclude that the
UEFI payload should not be allowed to change gp and tp before calling
ExitBootServices() or SetVirtualAddressMap() whichever occurs last.
Due to this missing clarification U-Boot is currently saving gp before
calling the entry point of the payload and restores it on reentry or on
entry of an API call. Nothing is done for tp.
Best regards
Heinrich
Reminder: the next EBBR regular meeting is later today at
16:00BST/08:00PDT. Draft agenda below. Right now the agenda is very
light. I'll keep the meeting short if we don't have anything to discuss.
Agenda
- Report on DT reserved-memory discussion
- issue & PR review
Send me an email if you want to add an item to the agenda, or add an
issue to the github page. Also email me if you want me to send you a
calendar invite for the meeting series.
https://github.com/arm-software/ebbr/issues
g.
----
Time: Every second Monday starting 31 Aug at 16:00BST, 08:00PST
Join Zoom Meeting
https://armltd.zoom.us/j/92081365511?pwd=SFZpRitXUEp3Zy9GM0h3UUZ1b1pnUT09
Meeting ID: 920 8136 5511
Password: 490324
One tap mobile
+14086380968,,92081365511#,,#,490324# US (San Jose)
+16465189805,,92081365511#,,#,490324# US (New York)
Dial by your location
+1 408 638 0968 US (San Jose)
+1 646 518 9805 US (New York)
+1 346 248 7799 US (Houston)
Meeting ID: 920 8136 5511
Password: 490324
Find your local number: https://armltd.zoom.us/u/adYiWaDyys
IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.
Hi
As we are organizing Linaro Connect and many people are involved or
attending it has been difficult to settle an agenda.
I propose we have an open floor to discuss any topic.
Cordially
François Frédéric
--
François-Frédéric Ozog | *Director Linaro Edge & Fog Computing Group*
T: +33.67221.6485
francois.ozog(a)linaro.org | Skype: ffozog
Please find below the meeting minutes for the last call.
(all project documentation, meeting notes and slides, reference material
can be found on the DTE portal <https://collaborate.linaro.org/display/DTE>)
-
François-Frédéric Ozog (Linaro)
-
Joakim Bech (Linaro)
-
Atish Patra (Western Digital)
-
Loic Pallardy (ST)
-
Matthias Brugger
-
Ilias Apalodimas (Linaro)
-
Don (Harbin?)
-
CVS
-
Simon Glass (Google)
-
Bill Mills (Linaro)
-
Mark Brown (Arm)
-
Mike Holmes (Linaro)
-
Poonam (NXP)
-
Ruchika Gupta (Linaro)
-
Etienne Carriere (ST)
-
Stefano Stabellini (Xilinx)
Notes:
-
Linaro slides
<https://docs.google.com/presentation/d/1iCi8i7zAfYrXEXmQ0DfGB8DT3nPksX7zFJ7…>
for 9th September meeting
-
Atish presentation on Risc-V boot process
-
SBI - Supervisor Binary Interface
-
Side note:
-
Privilege level defines what the running software can do during
its execution. Common usage of each privilege level is as follows:
-
U-mode: user processes
-
S-mode: kernel (including kernel modules and device drivers),
hypervisor
-
M-mode: bootloader, firmware
-
SBI call looks like SMC call
-
Actually SMC or HVC ?
-
OpenSBI: Open source implementation of the RISC-V SBI specification
(BSD-2 clause).
-
RISC-V Boot flow
-
-
OpenSBI here is equivalent to TF-A in the Arm world, however, there
is no security implemented at this point.
-
The Linux kernel is booted by a single hardware thread identified by
HART ID (HART = HARdware Thread)
-
Then Linux can bring up other cores with HART SBI State Management (~
PSCI)
-
-
DT stuff
-
Generate DT from RTL
-
HART ID of boot core needs to be in chosen node
-
Reuses topology DT node as defined by Arm64
-
Still work to do on standard IRQ controllers
-
Platform level interrupt controller PLIC is SiFive specific
-
Core Level Interrupt Controller (CLINT)
-
Future
-
Grub support
-
EBBR compliance
-
LinuxBoot support (was discussed last year but no more activity)
-
SecureBoot (still drafting)
--
François-Frédéric Ozog | *Director Linaro Edge & Fog Computing Group*
T: +33.67221.6485
francois.ozog(a)linaro.org | Skype: ffozog
Hi Atish,
Is the HARTID in DT used to *define* which thread should used as the
booted payload (Linux) or is it used to *inform* Linux that it was
started on this particular HARTID?
If we assume two DTs are used: one for OpenSBI and one for Linux,
which one (or both) is used to contain the HARTID?
Cheers
FF
Imported from linux kernel source:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Doc…
Very minor editorial changes made while importing, with one exception.
Added clause that the 'no-map' and 'reusable' properties are mutually
exclusive.
Signed-off-by: Grant Likely <grant.likely(a)arm.com>
Cc: Rob Herring <robh(a)kernel.org>
Cc: Heinrich Schuchardt <xypron.glpk(a)gmx.de>
Cc: Ard Biesheuvel <ardb(a)kernel.org>
---
source/chapter3-devicenodes.rst | 199 ++++++++++++++++++++++++++++++++
1 file changed, 199 insertions(+)
diff --git a/source/chapter3-devicenodes.rst b/source/chapter3-devicenodes.rst
index 3aa4650..1c1149a 100644
--- a/source/chapter3-devicenodes.rst
+++ b/source/chapter3-devicenodes.rst
@@ -200,6 +200,205 @@ memory ranges. The 2 GB I/O region is skipped. Note that the
value of 2, which means that two 32-bit cells are required to define the
address and length for the ``reg`` property of the memory node.
+``/reserved-memory`` Node
+-------------------------
+
+Reserved memory is specified as a node under the ``/reserved-memory`` node.
+The operating system shall exclude reserved memory from normal usage
+one can create child nodes describing particular reserved (excluded from
+normal use) memory regions.
+Such memory regions are usually designed for the special usage by various
+device drivers.
+
+Parameters for each memory region can be encoded into the device tree
+with the following nodes:
+
+/reserved-memory parent node
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. tabularcolumns:: | p{4cm} p{0.75cm} p{4cm} p{6.5cm} |
+.. table:: /reserved-memory Parent Node Properties
+
+ =================== ===== ================= ===============================================
+ Property Name Usage Value Type Definition
+ =================== ===== ================= ===============================================
+ ``#address-cells`` R ``<u32>`` Specifies the number of ``<u32>`` cells to
+ represent the address in the ``reg`` property in
+ children of root.
+ ``#size-cells`` R ``<u32>`` Specifies the number of ``<u32>`` cells to
+ represent the size in the ``reg`` property in
+ children of root.
+ ``ranges`` R ``<prop encoded This property represents the mapping between
+ array>`` parent address to child address spaces (see
+ section :ref:`sect-standard-properties-ranges`,
+ ranges).
+ Usage legend: R=Required, O=Optional, OR=Optional but Recommended, SD=See Definition
+ ===========================================================================================
+
+``#address-cells`` and ``#size-cells`` should use the same values as for the root node,
+and ``ranges`` should be empty so that address translation logic works correctly.
+
+/reserved-memory/ child nodes
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Each child of the reserved-memory node specifies one or more regions of
+reserved memory. Each child node may either use a ``reg`` property to
+specify a specific range of reserved memory, or a ``size`` property with
+optional constraints to request a dynamically allocated block of memory.
+
+Following the generic-names recommended practice, node names should
+reflect the purpose of the node (ie. "*framebuffer*" or "*dma-pool*").
+Unit address (``@<address>``) should be appended to the name if the node
+is a static allocation.
+
+A reserved memory node requires either a ``reg`` property for static
+allocations, or a ``size`` property for dynamics allocations.
+Dynamic allocations may use ``alignment`` and ``alloc-ranges`` properties
+to constrain where the memory is allocated from.
+If both ``reg`` and ``size`` are present, then the region is treated as a
+static allocation with the ``reg`` property taking precedence and ``size``
+is ignored.
+
+.. tabularcolumns:: | p{4cm} p{0.75cm} p{4cm} p{6.5cm} |
+.. table:: ``/reserved-memory/`` Child Node Properties
+
+ ======================= ===== ========================= ===============================================
+ Property Name Usage Value Type Definition
+ ======================= ===== ========================= ===============================================
+ ``reg`` O ``<prop-encoded-array>`` Consists of an arbitrary number of address and
+ size pairs that specify the physical address
+ and size of the memory ranges.
+ ``size`` O ``<prop-encoded-array>`` Size in bytes of memory to reserve for
+ dynamically allocated regions.
+ Size of this property is based on parent node's
+ ``#size-cells`` property.
+ ``alignment`` O ``<prop-encoded-array>`` Address boundary for alignment of allocation.
+ Size of this property is based on parent node's
+ ``#size-cells`` property.
+ ``alloc-ranges`` O ``<prop-encoded-array>`` Specifies regions of memory that are acceptable
+ to allocate from.
+ Format is (address, length pairs) tuples in
+ same format as for ``reg`` properties.
+ ``compatible`` O ``<stringlist>`` May contain the following strings:
+
+ - ``shared-dma-pool``: This indicates a region of
+ memory meant to be used as a shared pool of DMA
+ buffers for a set of devices.
+ It can be used by an operating system to
+ instantiate the necessary pool management
+ subsystem if necessary.
+
+ - vendor specific string in the form
+ ``<vendor>,[<device>-]<usage>``
+ ``no-map`` O ``<empty>`` If present, indicates the operating system must
+ not create a virtual mapping of the region as
+ part of its standard mapping of system memory,
+ nor permit speculative access to it under any
+ circumstances other than under the control of
+ the device driver using the region.
+ ``reusable`` O ``<empty>`` The operating system can use the memory in this
+ region with the limitation that the device
+ driver(s) owning the region need to be able to
+ reclaim it back.
+ Typically that means that the operating system
+ can use that region to store volatile or cached
+ data that can be otherwise regenerated or
+ migrated elsewhere.
+ Usage legend: R=Required, O=Optional, OR=Optional but Recommended, SD=See Definition
+ =======================================================================================================
+
+.. note:: All other standard properties (section
+ :ref:`sect-standard-properties`) are allowed but are optional.
+
+The ``no-map`` and ``reusable`` properties are mutually exclusive and both must
+not be used together in the same node.
+
+Linux implementation notes:
+
+- If a ``linux,cma-default`` property is present, then Linux will use the
+ region for the default pool of the contiguous memory allocator.
+
+- If a ``linux,dma-default`` property is present, then Linux will use the
+ region for the default pool of the consistent DMA allocator.
+
+Device node references to reserved memory
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Regions in the ``/reserved-memory`` node may be referenced by other device
+nodes by adding a ``memory-region`` property to the device node.
+
+.. tabularcolumns:: | p{4cm} p{0.75cm} p{4cm} p{6.5cm} |
+.. table:: ``Properties for referencing reserved-memory regions
+
+ ======================= ===== ========================= ===============================================
+ Property Name Usage Value Type Definition
+ ======================= ===== ========================= ===============================================
+ ``memory-region`` O ``<prop-encoded-array>`` phandle, specifier pairs to children of
+ ``/reserved-memory``
+ ``memory-region-names`` O ``<stringlist>>`` A list of names, one for each corresponding
+ entry in the ``memory-region`` property
+ =======================================================================================================
+
+Example
+~~~~~~~
+
+This example defines 3 contiguous regions are defined for Linux kernel:
+one default of all device drivers (named ``linux,cma@72000000`` and 64MiB in size),
+one dedicated to the framebuffer device (named ``framebuffer@78000000``, 8MiB), and
+one for multimedia processing (named ``multimedia-memory@77000000``, 64MiB).
+
+.. code-block:: dts
+
+ / {
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ memory {
+ reg = <0x40000000 0x40000000>;
+ };
+
+ reserved-memory {
+ #address-cells = <1>;
+ #size-cells = <1>;
+ ranges;
+
+ /* global autoconfigured region for contiguous allocations */
+ linux,cma {
+ compatible = "shared-dma-pool";
+ reusable;
+ size = <0x4000000>;
+ alignment = <0x2000>;
+ linux,cma-default;
+ };
+
+ display_reserved: framebuffer@78000000 {
+ reg = <0x78000000 0x800000>;
+ };
+
+ multimedia_reserved: multimedia@77000000 {
+ compatible = "acme,multimedia-memory";
+ reg = <0x77000000 0x4000000>;
+ };
+ };
+
+ /* ... */
+
+ fb0: video@12300000 {
+ memory-region = <&display_reserved>;
+ /* ... */
+ };
+
+ scaler: scaler@12500000 {
+ memory-region = <&multimedia_reserved>;
+ /* ... */
+ };
+
+ codec: codec@12600000 {
+ memory-region = <&multimedia_reserved>;
+ /* ... */
+ };
+ };
+
``/chosen`` Node
----------------
--
2.20.1
IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.
Closes: #52
The no-map property of the /reserved-memory device tree nodes is used to
signal that a memory region shall not be accessed by the operating system,
even not via speculative access.
/reserved-memory nodes without the no-map property describe memory that
have special usage by the operating system.
This difference has to be reflected in the memory map returned by
GetMemoryMap().
Signed-off-by: Heinrich Schuchardt <xypron.glpk(a)gmx.de>
---
source/chapter2-uefi.rst | 13 +++++++++++++
source/references.rst | 4 ++++
2 files changed, 17 insertions(+)
diff --git a/source/chapter2-uefi.rst b/source/chapter2-uefi.rst
index 74ef70e..f410c57 100644
--- a/source/chapter2-uefi.rst
+++ b/source/chapter2-uefi.rst
@@ -74,6 +74,19 @@ that virtual addresses must equal physical addresses.
The default RAM allocated attribute must be EFI_MEMORY_WB.
+In the device tree reserved memory in modelled as a /reserved-memory nodes
+[RESMEM]_. The reserved-memory node MAY carry either the no-map or the resue
+property. It MUST NOT carry both properties as this would be contradictary.
+
+A 'no-map' reserved memory node describes memory that the UEFI payload MUST NOT
+access. It MUST be modelled as a EfiReservedMemoryType entry in the memory map.
+
+A reserved memory without the 'no-map' describes memory that MAY be used by the
+UEFI payload after ExitBootServices(). It MUST be modelled as a memory map entry
+that can only be used by the UEFI payload after ExitBootServices(). It
+is recommended to use EfiBootServicesData. The node MUST NOT be modelled as
+EfiReservedMemoryType and NOT as EfiConventionalMemory.
+
Configuration Tables
--------------------
diff --git a/source/references.rst b/source/references.rst
index 1eb0509..2434137 100644
--- a/source/references.rst
+++ b/source/references.rst
@@ -16,6 +16,10 @@
<https://static.docs.arm.com/den0022/c/DEN0022C_Power_State_Coordination_Int…>`_
30 January 2015, `Arm Limited <http://arm.com>`_
+.. [RESMEM] `Reserved memory regions
+ <https://www.kernel.org/doc/Documentation/devicetree/bindings/reserved-memor…>`_,
+ 21 July 2020, Linux kernel
+
.. [SBBR] `Arm Server Base Boot Requirements specification Issue B (v1.0)
<https://static.docs.arm.com/den0044/b/DEN0044B_Server_Base_Boot_Requirement…>`_
8 March 2016, `Arm Limited <http://arm.com>`_
--
2.28.0
The existing language around how firmware and an OS can share a storage
device doesn't go into sufficient detail on how the firmware should
protect firmware data on the device. Add language for both the GPT and
MBR partitioning schemes on how firmware images should be described in
the partition table.
Signed-off-by: Grant Likely <grant.likely(a)arm.com>
---
I posted this patch before the v1.0.1 release, but didn't merge it at
that time because it needs a little more due diligence than can be give
on a minor point release. Posting it now for proper review.
source/chapter4-firmware-media.rst | 67 +++++++++++++++++++++++-------
1 file changed, 51 insertions(+), 16 deletions(-)
diff --git a/source/chapter4-firmware-media.rst b/source/chapter4-firmware-media.rst
index fc71274..65da603 100644
--- a/source/chapter4-firmware-media.rst
+++ b/source/chapter4-firmware-media.rst
@@ -47,13 +47,19 @@ conflict with normal usage of the media by an OS.
Partitioning of Shared Storage
==============================
-A shared storage device shall use GPT partitioning unless it is incompatible
-with the platform boot sequence.
-In which case, MBR partitioning shall be used. [#MBRReqExample]_
-
-.. [#MBRReqExample] For example, if the boot ROM doesn't understand GPT
- partitioning, and will only work with an MBR, then the storage must be
- partitioned using an MBR.
+The shared storage device must use the GUID Partition Table (GPT) disk
+layout as defined in [UEFI]_ § 5.3, unless the platform boot sequence is
+fundamentally incompatible with the GPT disk layout.
+In which case, a legacy Master Boot Recored (MBR) must be used.
+[#MBRReqExample]_
+
+.. [#MBRReqExample] For example, if the SoC boot ROM requires an MBR to
+ find the next stage firmware image, then it is incompatible with
+ the GPT boot layout.
+ Similarly, if the boot ROM expects the next stage firmware to be located
+ at LBA1 (the location of the GPT Header), then it is incompatible with
+ the GPT disk layout.
+ In both cases the shared storage device must use legacy MBR partitioning.
.. warning::
@@ -71,15 +77,14 @@ the partition(s) containing firmware.
However, some SoCs load firmware from a fixed offset into the storage media.
In this case, to protect against partitioning tools overwriting firmware, the
-firmware image shall either reside entirely within the first 1MiB of storage,
-or should be covered by a protective partition entry in the partition table as
+partition table must be formed in a way to protect the firmware image(s) as
described in sections :ref:`section-gpt-parts` and :ref:`section-mbr-parts`.
-Automatic partitioning tools (e.g. an OS installer) must not create
-partitions within the first 1MiB of storage, or delete, move, or modify
-protective partition entries.
+Automatic partitioning tools (e.g. an OS installer) must not
+delete the protective information in the partition table, or
+delete, move, or modify protective partition entries.
Manual partitioning tools should provide warnings when modifying
-protective partitions or creating partitions within the first 1MiB.
+protective partitions.
.. warning::
@@ -95,19 +100,49 @@ GPT partitioning
----------------
The partition table must strictly conform to the UEFI specification and include
-a protective MBR authored exactly as described in [UEFI]_ § 5 (hybrid
+a protective MBR authored exactly as described in [UEFI]_ § 5.3 (hybrid
partitioning schemes are not permitted).
-Protective partitions must have the Platform Required Attribute Flag set.
+Fixed-location firmware images must be protected by creating protective
+partition entries, or by placing GPT data structures away from the LBAs
+occupied by firmware,
+
+Protective partitions are entries in the partition table that cover the
+LBA region occupied by firmware and have the 'Required Partition' attribute
+set.
+A protective partition must use a `PartitionTypeGUID` that identifies it
+as a firmware protective partition. (e.g., don't reuse a GUID used by
+non-protective partitions).
+There are no requirements on the contents or layout of the firmware
+protective partition.
+
+Placing GPT data structures away from firmware images can be accomplished by
+adjusting the GUID Partition Entry array location
+(adjusting the values of `PartitionEntryLBA` and `NumberOfPartitionEntries`,
+and `SizeOfPartitionEntry`),
+or by specifying the usable LBAs (Choosing `FirstUsableLBA`/`LastUsableLBA`
+to not overlap the fixed firmware location).
+See [UEFI]_ § 5.3.2.
+
+Given the choice, platforms should use protective partitions over
+adjusting the placement of GPT data structures because protective partitions
+provide explicit information about the protected region.
.. _section-mbr-parts:
MBR partitioning
^^^^^^^^^^^^^^^^
-Protective partitions should have a partition type of 0xF8 unless some
+If firmware is at a fixed location entirely within the first 1MiB of
+storage (<= LBA2047) then no protective partitions are required.
+If firmware resides in a fixed location outside the first 1MiB,
+then a protective partition must be used to cover the firmware LBAs.
+Protective partitions should have a partition type of 0xF8 unless an
immutable feature of the platform makes this impossible.
+OS partitioning tools must not create partitions in the first 1MiB
+of the storage device, and must not remove protective partitions.
+
.. _section-fw-partition-fs:
Firmware Partition Filesystem
--
2.20.1
Define the meanings of "MUST" and similar language for clarity.
Fixes: #46
Signed-off-by: Daniel Thompson <daniel.thompson(a)linaro.org>
---
source/chapter1-about.rst | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/source/chapter1-about.rst b/source/chapter1-about.rst
index 3744d8a14086..3b5339a9c202 100644
--- a/source/chapter1-about.rst
+++ b/source/chapter1-about.rst
@@ -171,6 +171,10 @@ UEFI § 6.1 - Reference to the UEFI specification [UEFI]_ section 6.1
Terms and abbreviations
=======================
+The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
+SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this
+document are to be interpreted as described in :rfc:`2119`.
+
This document uses the following terms and abbreviations.
.. glossary::
--
2.25.4