mbox series

[00/31] passage: Define a standard for firmware data flow

Message ID 20211101011734.1614781-1-sjg@chromium.org
Headers show
Series passage: Define a standard for firmware data flow | expand

Message

Simon Glass Nov. 1, 2021, 1:17 a.m. UTC
This series adds a standard way of passing information between different
firmware phases. This already exists in U-Boot at a very basic level, in
the form of a bloblist containing an spl_handoff structure, but the intent
here is to define something useful across projects.

The need for this is growing as firmware fragments into multiple binaries
each with its own purpose. Without any run-time connection, we must rely
on build-time settings which are brittle and painful to keep in sync.

This feature is named 'standard passage' since the name is more unique
than many others that could be chosen, it is a passage in the sense that
information is flowing from one place to another and it is standard,
because that is what we want to create.

The implementation is simply a pointer to a bloblist in a register, with
an extra register to point to a devicetree, for more complex data, if one
is present in the bloblist. This should cover all cases (small memory
footprint as well as complex data flow) and be easy enough to implement on
all architectures.

The core bloblist code is relicensed to BSD-3-Clause in case it is useful
in non-GPL projects but there is no requirement to use the same code.

This series includes tweaks to the bloblist implementation in U-Boot to
make it more suitable for the task, including:

   - Allocate tags explicitly in the enum
   - Put the magic number first
   - Define a process for adding tags

The emphasis is on enabling open communcation between binaries, not
enabling passage of secret, undocumented data, although this is possible
in a private environment.

This series is built on the OF_BOARD series It is available at
u-boot-dm/pass-working or:

https://source.denx.de/u-boot/custodians/u-boot-dm/-/commit/073b5c156f222c69a98b8ebcaa563d1ff10eb217


Simon Glass (31):
  Makefile: Correct TPL rule for OF_REAL
  kconfig: Add support for conditional values
  dm: core: Allow getting some basic stats
  stddef: Avoid warning with clang with offsetof()
  fdt: Drop SPL_BUILD macro
  bloblist: Put the magic number first
  bloblist: Rename the SPL tag
  bloblist: Drop unused tags
  bloblist: Use explicit numbering for the tags
  bloblist: Support allocating the bloblist
  bloblist: Use LOG_CATEGORY to simply logging
  bloblist: Use 'phase' consistently for bloblists
  bloblist: Refactor Kconfig to support alloc or fixed
  arm: qemu: Add an SPL build
  bloblist: Add functions to obtain base address and size
  passage: Support an incoming passage
  passage: Support a control devicetree
  passage: arm: Accept a passage from the previous phase
  passage: spl: Support adding the dtb to the passage bloblist
  passage: spl: Support passing the passage to U-Boot
  passage: Record where the devicetree came from
  passage: Report the devicetree source
  passage: Add a qemu test for ARM
  bloblist: doc: Bring in the API documentation
  bloblist: Relicense to allow BSD-3-Clause
  sandbox: Add a way of checking structs for standard passage
  passage: Add documentation
  passage: Add docs for spl_handoff
  x86: Move Intel GNVS file into the common include directory
  passage: Add checks for pre-existing blobs
  WIP: RFC: Add a gitlab test

 .gitlab-ci.yml                                |   6 +
 MAINTAINERS                                   |  10 +
 Makefile                                      |   2 +-
 arch/arm/cpu/armv7/start.S                    |   7 +-
 arch/arm/dts/qemu-arm-u-boot.dtsi             |  22 ++
 arch/arm/lib/crt0.S                           |   4 +
 arch/arm/mach-qemu/Kconfig                    |   9 +
 arch/sandbox/cpu/spl.c                        |   2 +-
 arch/x86/cpu/apollolake/acpi.c                |   2 +-
 arch/x86/cpu/broadwell/cpu_from_spl.c         |   4 +-
 arch/x86/cpu/intel_common/acpi.c              |   2 +-
 .../include/asm/arch-apollolake/global_nvs.h  |   2 +-
 arch/x86/lib/spl.c                            |   2 +-
 arch/x86/lib/tpl.c                            |   2 +-
 board/emulation/qemu-arm/Kconfig              |  23 +-
 board/emulation/qemu-arm/MAINTAINERS          |   1 +
 board/emulation/qemu-arm/Makefile             |   1 +
 board/emulation/qemu-arm/spl.c                |  27 ++
 board/google/chromebook_coral/coral.c         |   2 +-
 board/sandbox/Makefile                        |   3 +-
 board/sandbox/stdpass_check.c                 | 107 ++++++
 cmd/bdinfo.c                                  |   2 +
 common/Kconfig                                | 161 ++++++++-
 common/bloblist.c                             | 124 +++++--
 common/board_f.c                              |  48 ++-
 common/board_r.c                              |  18 +
 common/spl/spl.c                              |  74 +++-
 configs/qemu_arm_spl_defconfig                |  78 +++++
 doc/board/emulation/qemu-arm.rst              |  38 +++
 doc/develop/bloblist.rst                      |  28 +-
 doc/develop/index.rst                         |   1 +
 doc/develop/std_passage.rst                   | 319 ++++++++++++++++++
 drivers/core/device.c                         |  11 +
 drivers/core/root.c                           |   7 +
 drivers/core/uclass.c                         |  13 +
 drivers/serial/serial-uclass.c                |   3 +-
 dts/Kconfig                                   |  12 +
 include/asm-generic/global_data.h             |  35 ++
 include/bloblist.h                            | 175 +++++++---
 include/dm/device.h                           |  11 +-
 include/dm/root.h                             |   8 +
 include/dm/uclass-internal.h                  |   7 +
 include/fdtdec.h                              |  40 ++-
 include/handoff.h                             |   8 +-
 .../x86/include/asm => include}/intel_gnvs.h  |   0
 include/linux/kconfig.h                       |  18 +
 include/linux/stddef.h                        |   8 +-
 include/spl.h                                 |  15 +
 include/stdpass/README                        |   4 +
 include/stdpass/tpm2_eventlog.h               |  42 +++
 include/stdpass/vboot_ctx.h                   | 267 +++++++++++++++
 lib/asm-offsets.c                             |   5 +
 lib/fdtdec.c                                  |  65 +++-
 scripts/config_whitelist.txt                  |   1 +
 test/bloblist.c                               |  21 +-
 test/dm/core.c                                |  41 +++
 test/py/tests/test_passage.py                 |  11 +
 57 files changed, 1798 insertions(+), 161 deletions(-)
 create mode 100644 arch/arm/dts/qemu-arm-u-boot.dtsi
 create mode 100644 board/emulation/qemu-arm/spl.c
 create mode 100644 board/sandbox/stdpass_check.c
 create mode 100644 configs/qemu_arm_spl_defconfig
 create mode 100644 doc/develop/std_passage.rst
 rename {arch/x86/include/asm => include}/intel_gnvs.h (100%)
 create mode 100644 include/stdpass/README
 create mode 100644 include/stdpass/tpm2_eventlog.h
 create mode 100644 include/stdpass/vboot_ctx.h
 create mode 100644 test/py/tests/test_passage.py

Comments

François Ozog Nov. 1, 2021, 8:53 a.m. UTC | #1
Hi Simon,

this seems a great endeavor. I'd like to better understand the scope of it.

Is it to be used as part of what could become a U-Boot entry ABI scheme? By
that I mean giving some fixed aspects
to U-Boot entry while letting boards to have flexibility (say for instance
that the first 5 architecture ABI
parameter registers are reserved for U-Boot), and the Passage is about
specifying either those reserved registers
or one of them?

Thinking entry ABI, here is what I observed on Arm:

Linux has two entry ABIs:
- plain: x0 = dtb;
          command line = dtb:/chosen/bootargs; initrd =
dtb:/chosen/linux,initrd-*
- EFI: x0=handle, x1=systemtable, x30=return address;
           dtb = EFI_UUID config table; initrd = efi:<loadfile2(INITRD
vendor media UUID); command line = efi: image_protocol::load_options

U-Boot (proper) has plenty of schemes:
- dtb is passed as either x0, x1, fixed memory area (Qemu which is bad in
itself), or other registers
- additional information passing: board specific register scheme, SMC calls
- U-Boot for RPI boards implement a Linux shaped entry ABI to be launched
by Videocore firmware

Based on all the above, I would tend to think that RPI scheme is a good
idea but also
shall not prevent additional schemes for the boards.

What about a U-Boot Arm entry ABI like:
- plain: x0=dtb, x1=<Passage defined>, x2-x5 = <reserved>, other registers
are per platform, SMC calls allowed too
- EFI: x0=handle, x1=systemtable, x30=return address;  (when U-Boot is
launched as an EFI app)
       dtb = EFI_UUID config table, + Passage = Passage UUID config table

We could further leverage Passage to pass Operating Systems parameters that
could be removed from device tree (migration of /chosen to Passage). Memory
inventory would still be in DT but allocations for CMA or GPUs would be in
Passage. This idea is to reach a point where  device tree is a "pristine"
hardware description.

Cheers

PS: as Ilias mentions, this patch set contains bug fixes, non immediately
related additional functions (DM stats). It would be great to carve those
out to fast path them and keep this one with the very core of your idea.

On Mon, 1 Nov 2021 at 02:17, Simon Glass <sjg@chromium.org> wrote:

>
> This series adds a standard way of passing information between different
> firmware phases. This already exists in U-Boot at a very basic level, in
> the form of a bloblist containing an spl_handoff structure, but the intent
> here is to define something useful across projects.
>
> The need for this is growing as firmware fragments into multiple binaries
> each with its own purpose. Without any run-time connection, we must rely
> on build-time settings which are brittle and painful to keep in sync.
>
> This feature is named 'standard passage' since the name is more unique
> than many others that could be chosen, it is a passage in the sense that
> information is flowing from one place to another and it is standard,
> because that is what we want to create.
>
> The implementation is simply a pointer to a bloblist in a register, with
> an extra register to point to a devicetree, for more complex data, if one
> is present in the bloblist. This should cover all cases (small memory
> footprint as well as complex data flow) and be easy enough to implement on
> all architectures.
>
> The core bloblist code is relicensed to BSD-3-Clause in case it is useful
> in non-GPL projects but there is no requirement to use the same code.
>
> This series includes tweaks to the bloblist implementation in U-Boot to
> make it more suitable for the task, including:
>
>    - Allocate tags explicitly in the enum
>    - Put the magic number first
>    - Define a process for adding tags
>
> The emphasis is on enabling open communcation between binaries, not
> enabling passage of secret, undocumented data, although this is possible
> in a private environment.
>
> This series is built on the OF_BOARD series It is available at
> u-boot-dm/pass-working or:
>
>
> https://source.denx.de/u-boot/custodians/u-boot-dm/-/commit/073b5c156f222c69a98b8ebcaa563d1ff10eb217
>
>
> Simon Glass (31):
>   Makefile: Correct TPL rule for OF_REAL
>   kconfig: Add support for conditional values
>   dm: core: Allow getting some basic stats
>   stddef: Avoid warning with clang with offsetof()
>   fdt: Drop SPL_BUILD macro
>   bloblist: Put the magic number first
>   bloblist: Rename the SPL tag
>   bloblist: Drop unused tags
>   bloblist: Use explicit numbering for the tags
>   bloblist: Support allocating the bloblist
>   bloblist: Use LOG_CATEGORY to simply logging
>   bloblist: Use 'phase' consistently for bloblists
>   bloblist: Refactor Kconfig to support alloc or fixed
>   arm: qemu: Add an SPL build
>   bloblist: Add functions to obtain base address and size
>   passage: Support an incoming passage
>   passage: Support a control devicetree
>   passage: arm: Accept a passage from the previous phase
>   passage: spl: Support adding the dtb to the passage bloblist
>   passage: spl: Support passing the passage to U-Boot
>   passage: Record where the devicetree came from
>   passage: Report the devicetree source
>   passage: Add a qemu test for ARM
>   bloblist: doc: Bring in the API documentation
>   bloblist: Relicense to allow BSD-3-Clause
>   sandbox: Add a way of checking structs for standard passage
>   passage: Add documentation
>   passage: Add docs for spl_handoff
>   x86: Move Intel GNVS file into the common include directory
>   passage: Add checks for pre-existing blobs
>   WIP: RFC: Add a gitlab test
>
>  .gitlab-ci.yml                                |   6 +
>  MAINTAINERS                                   |  10 +
>  Makefile                                      |   2 +-
>  arch/arm/cpu/armv7/start.S                    |   7 +-
>  arch/arm/dts/qemu-arm-u-boot.dtsi             |  22 ++
>  arch/arm/lib/crt0.S                           |   4 +
>  arch/arm/mach-qemu/Kconfig                    |   9 +
>  arch/sandbox/cpu/spl.c                        |   2 +-
>  arch/x86/cpu/apollolake/acpi.c                |   2 +-
>  arch/x86/cpu/broadwell/cpu_from_spl.c         |   4 +-
>  arch/x86/cpu/intel_common/acpi.c              |   2 +-
>  .../include/asm/arch-apollolake/global_nvs.h  |   2 +-
>  arch/x86/lib/spl.c                            |   2 +-
>  arch/x86/lib/tpl.c                            |   2 +-
>  board/emulation/qemu-arm/Kconfig              |  23 +-
>  board/emulation/qemu-arm/MAINTAINERS          |   1 +
>  board/emulation/qemu-arm/Makefile             |   1 +
>  board/emulation/qemu-arm/spl.c                |  27 ++
>  board/google/chromebook_coral/coral.c         |   2 +-
>  board/sandbox/Makefile                        |   3 +-
>  board/sandbox/stdpass_check.c                 | 107 ++++++
>  cmd/bdinfo.c                                  |   2 +
>  common/Kconfig                                | 161 ++++++++-
>  common/bloblist.c                             | 124 +++++--
>  common/board_f.c                              |  48 ++-
>  common/board_r.c                              |  18 +
>  common/spl/spl.c                              |  74 +++-
>  configs/qemu_arm_spl_defconfig                |  78 +++++
>  doc/board/emulation/qemu-arm.rst              |  38 +++
>  doc/develop/bloblist.rst                      |  28 +-
>  doc/develop/index.rst                         |   1 +
>  doc/develop/std_passage.rst                   | 319 ++++++++++++++++++
>  drivers/core/device.c                         |  11 +
>  drivers/core/root.c                           |   7 +
>  drivers/core/uclass.c                         |  13 +
>  drivers/serial/serial-uclass.c                |   3 +-
>  dts/Kconfig                                   |  12 +
>  include/asm-generic/global_data.h             |  35 ++
>  include/bloblist.h                            | 175 +++++++---
>  include/dm/device.h                           |  11 +-
>  include/dm/root.h                             |   8 +
>  include/dm/uclass-internal.h                  |   7 +
>  include/fdtdec.h                              |  40 ++-
>  include/handoff.h                             |   8 +-
>  .../x86/include/asm => include}/intel_gnvs.h  |   0
>  include/linux/kconfig.h                       |  18 +
>  include/linux/stddef.h                        |   8 +-
>  include/spl.h                                 |  15 +
>  include/stdpass/README                        |   4 +
>  include/stdpass/tpm2_eventlog.h               |  42 +++
>  include/stdpass/vboot_ctx.h                   | 267 +++++++++++++++
>  lib/asm-offsets.c                             |   5 +
>  lib/fdtdec.c                                  |  65 +++-
>  scripts/config_whitelist.txt                  |   1 +
>  test/bloblist.c                               |  21 +-
>  test/dm/core.c                                |  41 +++
>  test/py/tests/test_passage.py                 |  11 +
>  57 files changed, 1798 insertions(+), 161 deletions(-)
>  create mode 100644 arch/arm/dts/qemu-arm-u-boot.dtsi
>  create mode 100644 board/emulation/qemu-arm/spl.c
>  create mode 100644 board/sandbox/stdpass_check.c
>  create mode 100644 configs/qemu_arm_spl_defconfig
>  create mode 100644 doc/develop/std_passage.rst
>  rename {arch/x86/include/asm => include}/intel_gnvs.h (100%)
>  create mode 100644 include/stdpass/README
>  create mode 100644 include/stdpass/tpm2_eventlog.h
>  create mode 100644 include/stdpass/vboot_ctx.h
>  create mode 100644 test/py/tests/test_passage.py
>
> --
> 2.33.1.1089.g2158813163f-goog
>
>
Mark Kettenis Nov. 1, 2021, 6:19 p.m. UTC | #2
> From: François Ozog <francois.ozog@linaro.org>
> Date: Mon, 1 Nov 2021 09:53:40 +0100

[...]

> We could further leverage Passage to pass Operating Systems parameters that
> could be removed from device tree (migration of /chosen to Passage). Memory
> inventory would still be in DT but allocations for CMA or GPUs would be in
> Passage. This idea is to reach a point where  device tree is a "pristine"
> hardware description.

I wanted to react on something you said in an earlier thread, but this
discussion seems to be appropriate as well:

The notion that device trees only describe the hardware isn't really
correct.  Device trees have always been used to configure firmware
options (through the /options node) and between firmware and the OS
(through the /chosen node) and to describe firmware interfaces
(e.g. OpenFirmware calls, PSCI (on ARM), RTAS (on POWER)).  This was
the case on the original Open Firmware systems, and is still done on
PowerNV systems that use flattened device trees.

I don't see what the benefits are from using Passage instead.  It
would only fragment things even more.
François Ozog Nov. 1, 2021, 8:45 p.m. UTC | #3
Hi Mark,

Le lun. 1 nov. 2021 à 19:19, Mark Kettenis <mark.kettenis@xs4all.nl> a
écrit :

> > From: François Ozog <francois.ozog@linaro.org>
> > Date: Mon, 1 Nov 2021 09:53:40 +0100
>
> [...]
>
> > We could further leverage Passage to pass Operating Systems parameters
> that
> > could be removed from device tree (migration of /chosen to Passage).
> Memory
> > inventory would still be in DT but allocations for CMA or GPUs would be
> in
> > Passage. This idea is to reach a point where  device tree is a "pristine"
> > hardware description.
>
> I wanted to react on something you said in an earlier thread, but this
> discussion seems to be appropriate as well:
>
> The notion that device trees only describe the hardware isn't really
> correct.  Device trees have always been used to configure firmware
> options (through the /options node) and between firmware and the OS
> (through the /chosen node) and to describe firmware interfaces
> (e.g. OpenFirmware calls, PSCI (on ARM), RTAS (on POWER)).  This was
> the case on the original Open Firmware systems, and is still done on
> PowerNV systems that use flattened device trees.


> I understand and agree with the above.
Yet, PSCI is different from /options and /chosen: those are platform
services made available to the OS when the boot firmware code has been
unloaded/neutralized.

What I (not just myself but let’s simplify) am trying to decouple the
supply chain: loosely coupled platform provider (ODM), the firmware
provider, OS provider, application provider. So it is not to prevent
presence of those existing nodes, it is to be able introduce some
rationalization in their use:

Platform interfaces such as PSCI: The question is “who” injects them in the
DT (build time or runtime). There is no single good answer and you may want
the authoritative entity that implements the service to actually inject
itself in the DT passed to the OS. I know some platforms are using SMC
calls from U-Boot to know what to inject in the DT. I see those as the same
nature of DIMM sensing and injection in the DT.

/chosen:  a must have when you do not have UEFI but not necessary with UEFI.

/options: it should be possible for the end customer to make the decision
of integration: at build time or at runtime based on a separate flattened
device tree file.

This decoupling should result for instance, in the long run, in adjustable
memory layouts without headaches. changing the secure dram size is simple
from hardware perspective but a massive issue from a firmware perspective:
multiple firmware projects sources need to be adjusted, making manual
calculations on explicit constants or “hidden” ones. It should even be
possible to adjust it at runtime on the field (user selected firmware
parameter).


> I don't see what the benefits are from using Passage instead.  It
> would only fragment things even more.
>
Simon Glass Nov. 2, 2021, 2:58 p.m. UTC | #4
Hi François,

On Mon, 1 Nov 2021 at 02:53, François Ozog <francois.ozog@linaro.org> wrote:
>
> Hi Simon,
>
> this seems a great endeavor. I'd like to better understand the scope of it.
>
> Is it to be used as part of what could become a U-Boot entry ABI scheme? By that I mean giving some fixed aspects
> to U-Boot entry while letting boards to have flexibility (say for instance that the first 5 architecture ABI
> parameter registers are reserved for U-Boot), and the Passage is about specifying either those reserved registers
> or one of them?

The goal is to provide a standard entry scheme for all firmware
binaries. Whether it achieves that (or can with some mods) is up for
discussion.

Re the registers, do you think we need 5?

>
> Thinking entry ABI, here is what I observed on Arm:
>
> Linux has two entry ABIs:
> - plain: x0 = dtb;
>           command line = dtb:/chosen/bootargs; initrd = dtb:/chosen/linux,initrd-*
> - EFI: x0=handle, x1=systemtable, x30=return address;
>            dtb = EFI_UUID config table; initrd = efi:<loadfile2(INITRD vendor media UUID); command line = efi: image_protocol::load_options
>
> U-Boot (proper) has plenty of schemes:
> - dtb is passed as either x0, x1, fixed memory area (Qemu which is bad in itself), or other registers
> - additional information passing: board specific register scheme, SMC calls
> - U-Boot for RPI boards implement a Linux shaped entry ABI to be launched by Videocore firmware
>
> Based on all the above, I would tend to think that RPI scheme is a good idea but also
> shall not prevent additional schemes for the boards.

I was not actually considering Linux since I believe/assume its entry
scheme is fixed and not up for discussion.

I also did not think about the EFI case. As I understand it we cannot
touch it as it is used by UEFI today. Maybe it is even in the
standard?

Really I am hoping we can start afresh...?

>
> What about a U-Boot Arm entry ABI like:
> - plain: x0=dtb, x1=<Passage defined>, x2-x5 = <reserved>, other registers are per platform, SMC calls allowed too

Hmm we don't actually need the dtb as it is available in the bloblist.
But I added an offset to it as a convenience.

> - EFI: x0=handle, x1=systemtable, x30=return address;  (when U-Boot is launched as an EFI app)
>        dtb = EFI_UUID config table, + Passage = Passage UUID config table

I don't understand the last line. Where is the passage info /
bloblist? Do you mean it goes in the HOB list with a UUID? I suppose
that is the most EFI-compatible way.

What do you think about the idea of using an offset into the bloblist
for the dtb? Also, can we make the standard passage ABI a build-time
option, so it is deterministic?

>
> We could further leverage Passage to pass Operating Systems parameters that could be removed from device tree (migration of /chosen to Passage). Memory inventory would still be in DT but allocations for CMA or GPUs would be in Passage. This idea is to reach a point where  device tree is a "pristine" hardware description.

I'm worried about this becoming a substitute for devicetree. Really my
intent is to provide a way to pass simple info, whereas what you talk
about there seems like something that should be DT, just that it might
need suitable bindings.

As you know I have more expansive views about what should be in DT.

>
> Cheers
>
> PS: as Ilias mentions, this patch set contains bug fixes, non immediately related additional functions (DM stats). It would be great to carve those out to fast path them and keep this one with the very core of your idea.

The DM stats is used in 'passage: Report the devicetree source'. I
know it is sideways but I think it is better to make the output line
more useful than just reporting the devicetree source.

The first patch is indeed unrelated. I will pick it up so we can drop
it for the next rev.

Regards,
Simon


>
> On Mon, 1 Nov 2021 at 02:17, Simon Glass <sjg@chromium.org> wrote:
>>
>>
>> This series adds a standard way of passing information between different
>> firmware phases. This already exists in U-Boot at a very basic level, in
>> the form of a bloblist containing an spl_handoff structure, but the intent
>> here is to define something useful across projects.
>>
>> The need for this is growing as firmware fragments into multiple binaries
>> each with its own purpose. Without any run-time connection, we must rely
>> on build-time settings which are brittle and painful to keep in sync.
>>
>> This feature is named 'standard passage' since the name is more unique
>> than many others that could be chosen, it is a passage in the sense that
>> information is flowing from one place to another and it is standard,
>> because that is what we want to create.
>>
>> The implementation is simply a pointer to a bloblist in a register, with
>> an extra register to point to a devicetree, for more complex data, if one
>> is present in the bloblist. This should cover all cases (small memory
>> footprint as well as complex data flow) and be easy enough to implement on
>> all architectures.
>>
>> The core bloblist code is relicensed to BSD-3-Clause in case it is useful
>> in non-GPL projects but there is no requirement to use the same code.
>>
>> This series includes tweaks to the bloblist implementation in U-Boot to
>> make it more suitable for the task, including:
>>
>>    - Allocate tags explicitly in the enum
>>    - Put the magic number first
>>    - Define a process for adding tags
>>
>> The emphasis is on enabling open communcation between binaries, not
>> enabling passage of secret, undocumented data, although this is possible
>> in a private environment.
>>
>> This series is built on the OF_BOARD series It is available at
>> u-boot-dm/pass-working or:
>>
>> https://source.denx.de/u-boot/custodians/u-boot-dm/-/commit/073b5c156f222c69a98b8ebcaa563d1ff10eb217
>>
>>
>> Simon Glass (31):
>>   Makefile: Correct TPL rule for OF_REAL
>>   kconfig: Add support for conditional values
>>   dm: core: Allow getting some basic stats
>>   stddef: Avoid warning with clang with offsetof()
>>   fdt: Drop SPL_BUILD macro
>>   bloblist: Put the magic number first
>>   bloblist: Rename the SPL tag
>>   bloblist: Drop unused tags
>>   bloblist: Use explicit numbering for the tags
>>   bloblist: Support allocating the bloblist
>>   bloblist: Use LOG_CATEGORY to simply logging
>>   bloblist: Use 'phase' consistently for bloblists
>>   bloblist: Refactor Kconfig to support alloc or fixed
>>   arm: qemu: Add an SPL build
>>   bloblist: Add functions to obtain base address and size
>>   passage: Support an incoming passage
>>   passage: Support a control devicetree
>>   passage: arm: Accept a passage from the previous phase
>>   passage: spl: Support adding the dtb to the passage bloblist
>>   passage: spl: Support passing the passage to U-Boot
>>   passage: Record where the devicetree came from
>>   passage: Report the devicetree source
>>   passage: Add a qemu test for ARM
>>   bloblist: doc: Bring in the API documentation
>>   bloblist: Relicense to allow BSD-3-Clause
>>   sandbox: Add a way of checking structs for standard passage
>>   passage: Add documentation
>>   passage: Add docs for spl_handoff
>>   x86: Move Intel GNVS file into the common include directory
>>   passage: Add checks for pre-existing blobs
>>   WIP: RFC: Add a gitlab test
>>
>>  .gitlab-ci.yml                                |   6 +
>>  MAINTAINERS                                   |  10 +
>>  Makefile                                      |   2 +-
>>  arch/arm/cpu/armv7/start.S                    |   7 +-
>>  arch/arm/dts/qemu-arm-u-boot.dtsi             |  22 ++
>>  arch/arm/lib/crt0.S                           |   4 +
>>  arch/arm/mach-qemu/Kconfig                    |   9 +
>>  arch/sandbox/cpu/spl.c                        |   2 +-
>>  arch/x86/cpu/apollolake/acpi.c                |   2 +-
>>  arch/x86/cpu/broadwell/cpu_from_spl.c         |   4 +-
>>  arch/x86/cpu/intel_common/acpi.c              |   2 +-
>>  .../include/asm/arch-apollolake/global_nvs.h  |   2 +-
>>  arch/x86/lib/spl.c                            |   2 +-
>>  arch/x86/lib/tpl.c                            |   2 +-
>>  board/emulation/qemu-arm/Kconfig              |  23 +-
>>  board/emulation/qemu-arm/MAINTAINERS          |   1 +
>>  board/emulation/qemu-arm/Makefile             |   1 +
>>  board/emulation/qemu-arm/spl.c                |  27 ++
>>  board/google/chromebook_coral/coral.c         |   2 +-
>>  board/sandbox/Makefile                        |   3 +-
>>  board/sandbox/stdpass_check.c                 | 107 ++++++
>>  cmd/bdinfo.c                                  |   2 +
>>  common/Kconfig                                | 161 ++++++++-
>>  common/bloblist.c                             | 124 +++++--
>>  common/board_f.c                              |  48 ++-
>>  common/board_r.c                              |  18 +
>>  common/spl/spl.c                              |  74 +++-
>>  configs/qemu_arm_spl_defconfig                |  78 +++++
>>  doc/board/emulation/qemu-arm.rst              |  38 +++
>>  doc/develop/bloblist.rst                      |  28 +-
>>  doc/develop/index.rst                         |   1 +
>>  doc/develop/std_passage.rst                   | 319 ++++++++++++++++++
>>  drivers/core/device.c                         |  11 +
>>  drivers/core/root.c                           |   7 +
>>  drivers/core/uclass.c                         |  13 +
>>  drivers/serial/serial-uclass.c                |   3 +-
>>  dts/Kconfig                                   |  12 +
>>  include/asm-generic/global_data.h             |  35 ++
>>  include/bloblist.h                            | 175 +++++++---
>>  include/dm/device.h                           |  11 +-
>>  include/dm/root.h                             |   8 +
>>  include/dm/uclass-internal.h                  |   7 +
>>  include/fdtdec.h                              |  40 ++-
>>  include/handoff.h                             |   8 +-
>>  .../x86/include/asm => include}/intel_gnvs.h  |   0
>>  include/linux/kconfig.h                       |  18 +
>>  include/linux/stddef.h                        |   8 +-
>>  include/spl.h                                 |  15 +
>>  include/stdpass/README                        |   4 +
>>  include/stdpass/tpm2_eventlog.h               |  42 +++
>>  include/stdpass/vboot_ctx.h                   | 267 +++++++++++++++
>>  lib/asm-offsets.c                             |   5 +
>>  lib/fdtdec.c                                  |  65 +++-
>>  scripts/config_whitelist.txt                  |   1 +
>>  test/bloblist.c                               |  21 +-
>>  test/dm/core.c                                |  41 +++
>>  test/py/tests/test_passage.py                 |  11 +
>>  57 files changed, 1798 insertions(+), 161 deletions(-)
>>  create mode 100644 arch/arm/dts/qemu-arm-u-boot.dtsi
>>  create mode 100644 board/emulation/qemu-arm/spl.c
>>  create mode 100644 board/sandbox/stdpass_check.c
>>  create mode 100644 configs/qemu_arm_spl_defconfig
>>  create mode 100644 doc/develop/std_passage.rst
>>  rename {arch/x86/include/asm => include}/intel_gnvs.h (100%)
>>  create mode 100644 include/stdpass/README
>>  create mode 100644 include/stdpass/tpm2_eventlog.h
>>  create mode 100644 include/stdpass/vboot_ctx.h
>>  create mode 100644 test/py/tests/test_passage.py
>>
>> --
>> 2.33.1.1089.g2158813163f-goog
>>
>
>
> --
> François-Frédéric Ozog | Director Business Development
> T: +33.67221.6485
> francois.ozog@linaro.org | Skype: ffozog
>
François Ozog Nov. 2, 2021, 4:03 p.m. UTC | #5
Hi Simon,

On Tue, 2 Nov 2021 at 15:59, Simon Glass <sjg@chromium.org> wrote:

> Hi François,
>
> On Mon, 1 Nov 2021 at 02:53, François Ozog <francois.ozog@linaro.org>
> wrote:
> >
> > Hi Simon,
> >
> > this seems a great endeavor. I'd like to better understand the scope of
> it.
> >
> > Is it to be used as part of what could become a U-Boot entry ABI scheme?
> By that I mean giving some fixed aspects
> > to U-Boot entry while letting boards to have flexibility (say for
> instance that the first 5 architecture ABI
> > parameter registers are reserved for U-Boot), and the Passage is about
> specifying either those reserved registers
> > or one of them?
>
> The goal is to provide a standard entry scheme for all firmware
> binaries. Whether it achieves that (or can with some mods) is up for
> discussion.
>
> If you say
a) define a U-Boot entry ABI and providing a firmware-to-firmware
information passing facility which would be part of all firmware ABIs (as
the projects decide to define their own ABI) it looks good.
but If you say
b) define a standard entry scheme (register map, processor state, MMU
state, SMMU state, GIC state...) that does not look realistic.
I think you mean a) but just want to be sure.

> Re the registers, do you think we need 5?
>
> >
> > Thinking entry ABI, here is what I observed on Arm:
> >
> > Linux has two entry ABIs:
> > - plain: x0 = dtb;
> >           command line = dtb:/chosen/bootargs; initrd =
> dtb:/chosen/linux,initrd-*
> > - EFI: x0=handle, x1=systemtable, x30=return address;
> >            dtb = EFI_UUID config table; initrd = efi:<loadfile2(INITRD
> vendor media UUID); command line = efi: image_protocol::load_options
> >
> > U-Boot (proper) has plenty of schemes:
> > - dtb is passed as either x0, x1, fixed memory area (Qemu which is bad
> in itself), or other registers
> > - additional information passing: board specific register scheme, SMC
> calls
> > - U-Boot for RPI boards implement a Linux shaped entry ABI to be
> launched by Videocore firmware
> >
> > Based on all the above, I would tend to think that RPI scheme is a good
> idea but also
> > shall not prevent additional schemes for the boards.
>
> I was not actually considering Linux since I believe/assume its entry
> scheme is fixed and not up for discussion.
>
> I also did not think about the EFI case. As I understand it we cannot
> touch it as it is used by UEFI today. Maybe it is even in the
> standard?
>
It is in the spec and we are making it evolve, or its understanding evolve
(jurisprudence) for instance on initrd standard handling.

>
> Really I am hoping we can start afresh...?
>
> >
> > What about a U-Boot Arm entry ABI like:
> > - plain: x0=dtb, x1=<Passage defined>, x2-x5 = <reserved>, other
> registers are per platform, SMC calls allowed too
>
> Hmm we don't actually need the dtb as it is available in the bloblist.
>
If you don't have x0=dtb, then you will not be able to use U-Boot on RPI4.
Unless you want to redo everything the RPI firmware is doing.

> But I added an offset to it as a convenience.
>
> > - EFI: x0=handle, x1=systemtable, x30=return address;  (when U-Boot is
> launched as an EFI app)
> >        dtb = EFI_UUID config table, + Passage = Passage UUID config table
>
> I don't understand the last line. Where is the passage info /
> bloblist? Do you mean it goes in the HOB list with a UUID? I suppose
> that is the most EFI-compatible way.
>
The Passage config table  could just contain the "head" of the
bloblist/Passage information.

>
> What do you think about the idea of using an offset into the bloblist
> for the dtb?

It is possible but as I said, failing to mimic Linux entry ABI would miss
the opportunity to just boot without changes on RPI4.

> Also, can we make the standard passage ABI a build-time
> option, so it is deterministic?
>
> Looks good. I would look into stating that for SystemReady we would advise
to use that option and make it standard for Trusted Substrate (Linaro
recipes that we upstreaming to make SystemReady compliance easy and
consistent across platforms).

> >
> > We could further leverage Passage to pass Operating Systems parameters
> that could be removed from device tree (migration of /chosen to Passage).
> Memory inventory would still be in DT but allocations for CMA or GPUs would
> be in Passage. This idea is to reach a point where  device tree is a
> "pristine" hardware description.
>
> I'm worried about this becoming a substitute for devicetree. Really my
> intent is to provide a way to pass simple info, whereas what you talk
> about there seems like something that should be DT, just that it might
> need suitable bindings.
>
> I see your point and I agree It should not be a substitute.
here is an expanded version of what I had in mind when I wrote those lines.
cma, initrd and other Linux kernel parameters can be conveyed either
through command line or DT.
When using the non UEFI Linux entry ABI, you need to use the DT to pass
those parameters.
When using the UEFI Linux entry ABI, you *can* (not must) use the command
line to pass all information, leaving the DT passed to the OS without any
/chosen.
When introducing Passage, I was wondering if we could pass command line to
Linux and, same as UEFI, leave the DT free from /chosen.
I am not sure it is a good goal though. I may be too pushing for a DT free
from parameters.

> As you know I have more expansive views about what should be in DT.
>
I think both of us are huge supporters of DT format and self describing
capabilities.
I am inclined to put rules into what fits into what lands in the DT that is
passed to the OS.
I am a fan of having DT used more in ad-hoc files.

> >
> > Cheers
> >
> > PS: as Ilias mentions, this patch set contains bug fixes, non
> immediately related additional functions (DM stats). It would be great to
> carve those out to fast path them and keep this one with the very core of
> your idea.
>
> The DM stats is used in 'passage: Report the devicetree source'. I
> know it is sideways but I think it is better to make the output line
> more useful than just reporting the devicetree source.
>
> I believe the DM stats has merits in its own. You could upstream this
independently and then Passage would be yet another "customer" of the
feature.

> The first patch is indeed unrelated. I will pick it up so we can drop
> it for the next rev.
>
> Regards,
> Simon
>
>
> >
> > On Mon, 1 Nov 2021 at 02:17, Simon Glass <sjg@chromium.org> wrote:
> >>
> >>
> >> This series adds a standard way of passing information between different
> >> firmware phases. This already exists in U-Boot at a very basic level, in
> >> the form of a bloblist containing an spl_handoff structure, but the
> intent
> >> here is to define something useful across projects.
> >>
> >> The need for this is growing as firmware fragments into multiple
> binaries
> >> each with its own purpose. Without any run-time connection, we must rely
> >> on build-time settings which are brittle and painful to keep in sync.
> >>
> >> This feature is named 'standard passage' since the name is more unique
> >> than many others that could be chosen, it is a passage in the sense that
> >> information is flowing from one place to another and it is standard,
> >> because that is what we want to create.
> >>
> >> The implementation is simply a pointer to a bloblist in a register, with
> >> an extra register to point to a devicetree, for more complex data, if
> one
> >> is present in the bloblist. This should cover all cases (small memory
> >> footprint as well as complex data flow) and be easy enough to implement
> on
> >> all architectures.
> >>
> >> The core bloblist code is relicensed to BSD-3-Clause in case it is
> useful
> >> in non-GPL projects but there is no requirement to use the same code.
> >>
> >> This series includes tweaks to the bloblist implementation in U-Boot to
> >> make it more suitable for the task, including:
> >>
> >>    - Allocate tags explicitly in the enum
> >>    - Put the magic number first
> >>    - Define a process for adding tags
> >>
> >> The emphasis is on enabling open communcation between binaries, not
> >> enabling passage of secret, undocumented data, although this is possible
> >> in a private environment.
> >>
> >> This series is built on the OF_BOARD series It is available at
> >> u-boot-dm/pass-working or:
> >>
> >>
> https://source.denx.de/u-boot/custodians/u-boot-dm/-/commit/073b5c156f222c69a98b8ebcaa563d1ff10eb217
> >>
> >>
> >> Simon Glass (31):
> >>   Makefile: Correct TPL rule for OF_REAL
> >>   kconfig: Add support for conditional values
> >>   dm: core: Allow getting some basic stats
> >>   stddef: Avoid warning with clang with offsetof()
> >>   fdt: Drop SPL_BUILD macro
> >>   bloblist: Put the magic number first
> >>   bloblist: Rename the SPL tag
> >>   bloblist: Drop unused tags
> >>   bloblist: Use explicit numbering for the tags
> >>   bloblist: Support allocating the bloblist
> >>   bloblist: Use LOG_CATEGORY to simply logging
> >>   bloblist: Use 'phase' consistently for bloblists
> >>   bloblist: Refactor Kconfig to support alloc or fixed
> >>   arm: qemu: Add an SPL build
> >>   bloblist: Add functions to obtain base address and size
> >>   passage: Support an incoming passage
> >>   passage: Support a control devicetree
> >>   passage: arm: Accept a passage from the previous phase
> >>   passage: spl: Support adding the dtb to the passage bloblist
> >>   passage: spl: Support passing the passage to U-Boot
> >>   passage: Record where the devicetree came from
> >>   passage: Report the devicetree source
> >>   passage: Add a qemu test for ARM
> >>   bloblist: doc: Bring in the API documentation
> >>   bloblist: Relicense to allow BSD-3-Clause
> >>   sandbox: Add a way of checking structs for standard passage
> >>   passage: Add documentation
> >>   passage: Add docs for spl_handoff
> >>   x86: Move Intel GNVS file into the common include directory
> >>   passage: Add checks for pre-existing blobs
> >>   WIP: RFC: Add a gitlab test
> >>
> >>  .gitlab-ci.yml                                |   6 +
> >>  MAINTAINERS                                   |  10 +
> >>  Makefile                                      |   2 +-
> >>  arch/arm/cpu/armv7/start.S                    |   7 +-
> >>  arch/arm/dts/qemu-arm-u-boot.dtsi             |  22 ++
> >>  arch/arm/lib/crt0.S                           |   4 +
> >>  arch/arm/mach-qemu/Kconfig                    |   9 +
> >>  arch/sandbox/cpu/spl.c                        |   2 +-
> >>  arch/x86/cpu/apollolake/acpi.c                |   2 +-
> >>  arch/x86/cpu/broadwell/cpu_from_spl.c         |   4 +-
> >>  arch/x86/cpu/intel_common/acpi.c              |   2 +-
> >>  .../include/asm/arch-apollolake/global_nvs.h  |   2 +-
> >>  arch/x86/lib/spl.c                            |   2 +-
> >>  arch/x86/lib/tpl.c                            |   2 +-
> >>  board/emulation/qemu-arm/Kconfig              |  23 +-
> >>  board/emulation/qemu-arm/MAINTAINERS          |   1 +
> >>  board/emulation/qemu-arm/Makefile             |   1 +
> >>  board/emulation/qemu-arm/spl.c                |  27 ++
> >>  board/google/chromebook_coral/coral.c         |   2 +-
> >>  board/sandbox/Makefile                        |   3 +-
> >>  board/sandbox/stdpass_check.c                 | 107 ++++++
> >>  cmd/bdinfo.c                                  |   2 +
> >>  common/Kconfig                                | 161 ++++++++-
> >>  common/bloblist.c                             | 124 +++++--
> >>  common/board_f.c                              |  48 ++-
> >>  common/board_r.c                              |  18 +
> >>  common/spl/spl.c                              |  74 +++-
> >>  configs/qemu_arm_spl_defconfig                |  78 +++++
> >>  doc/board/emulation/qemu-arm.rst              |  38 +++
> >>  doc/develop/bloblist.rst                      |  28 +-
> >>  doc/develop/index.rst                         |   1 +
> >>  doc/develop/std_passage.rst                   | 319 ++++++++++++++++++
> >>  drivers/core/device.c                         |  11 +
> >>  drivers/core/root.c                           |   7 +
> >>  drivers/core/uclass.c                         |  13 +
> >>  drivers/serial/serial-uclass.c                |   3 +-
> >>  dts/Kconfig                                   |  12 +
> >>  include/asm-generic/global_data.h             |  35 ++
> >>  include/bloblist.h                            | 175 +++++++---
> >>  include/dm/device.h                           |  11 +-
> >>  include/dm/root.h                             |   8 +
> >>  include/dm/uclass-internal.h                  |   7 +
> >>  include/fdtdec.h                              |  40 ++-
> >>  include/handoff.h                             |   8 +-
> >>  .../x86/include/asm => include}/intel_gnvs.h  |   0
> >>  include/linux/kconfig.h                       |  18 +
> >>  include/linux/stddef.h                        |   8 +-
> >>  include/spl.h                                 |  15 +
> >>  include/stdpass/README                        |   4 +
> >>  include/stdpass/tpm2_eventlog.h               |  42 +++
> >>  include/stdpass/vboot_ctx.h                   | 267 +++++++++++++++
> >>  lib/asm-offsets.c                             |   5 +
> >>  lib/fdtdec.c                                  |  65 +++-
> >>  scripts/config_whitelist.txt                  |   1 +
> >>  test/bloblist.c                               |  21 +-
> >>  test/dm/core.c                                |  41 +++
> >>  test/py/tests/test_passage.py                 |  11 +
> >>  57 files changed, 1798 insertions(+), 161 deletions(-)
> >>  create mode 100644 arch/arm/dts/qemu-arm-u-boot.dtsi
> >>  create mode 100644 board/emulation/qemu-arm/spl.c
> >>  create mode 100644 board/sandbox/stdpass_check.c
> >>  create mode 100644 configs/qemu_arm_spl_defconfig
> >>  create mode 100644 doc/develop/std_passage.rst
> >>  rename {arch/x86/include/asm => include}/intel_gnvs.h (100%)
> >>  create mode 100644 include/stdpass/README
> >>  create mode 100644 include/stdpass/tpm2_eventlog.h
> >>  create mode 100644 include/stdpass/vboot_ctx.h
> >>  create mode 100644 test/py/tests/test_passage.py
> >>
> >> --
> >> 2.33.1.1089.g2158813163f-goog
> >>
> >
> >
> > --
> > François-Frédéric Ozog | Director Business Development
> > T: +33.67221.6485
> > francois.ozog@linaro.org | Skype: ffozog
> >
>
Simon Glass Nov. 5, 2021, 2:02 a.m. UTC | #6
Hi François,

On Tue, 2 Nov 2021 at 10:03, François Ozog <francois.ozog@linaro.org> wrote:
>
> Hi Simon,
>
> On Tue, 2 Nov 2021 at 15:59, Simon Glass <sjg@chromium.org> wrote:
>>
>> Hi François,
>>
>> On Mon, 1 Nov 2021 at 02:53, François Ozog <francois.ozog@linaro.org> wrote:
>> >
>> > Hi Simon,
>> >
>> > this seems a great endeavor. I'd like to better understand the scope of it.
>> >
>> > Is it to be used as part of what could become a U-Boot entry ABI scheme? By that I mean giving some fixed aspects
>> > to U-Boot entry while letting boards to have flexibility (say for instance that the first 5 architecture ABI
>> > parameter registers are reserved for U-Boot), and the Passage is about specifying either those reserved registers
>> > or one of them?
>>
>> The goal is to provide a standard entry scheme for all firmware
>> binaries. Whether it achieves that (or can with some mods) is up for
>> discussion.
>>
> If you say
> a) define a U-Boot entry ABI and providing a firmware-to-firmware information passing facility which would be part of all firmware ABIs (as the projects decide to define their own ABI) it looks good.
> but If you say

It is an ABI to be adopted by U-Boot but also other firmware. For
example, if TF-A calls U-Boot it should use standard passage. If
U-Boot calls TF-A or Optee it should use standard passage.

> b) define a standard entry scheme (register map, processor state, MMU state, SMMU state, GIC state...) that does not look realistic.

No I don't mean that. This data structure could be used in any state,
so long as the two registers are set correctly.

> I think you mean a) but just want to be sure.

Yes I think so.

>>
>> Re the registers, do you think we need 5?
>>

I don't :-)

>> >
>> > Thinking entry ABI, here is what I observed on Arm:
>> >
>> > Linux has two entry ABIs:
>> > - plain: x0 = dtb;
>> >           command line = dtb:/chosen/bootargs; initrd = dtb:/chosen/linux,initrd-*
>> > - EFI: x0=handle, x1=systemtable, x30=return address;
>> >            dtb = EFI_UUID config table; initrd = efi:<loadfile2(INITRD vendor media UUID); command line = efi: image_protocol::load_options
>> >
>> > U-Boot (proper) has plenty of schemes:
>> > - dtb is passed as either x0, x1, fixed memory area (Qemu which is bad in itself), or other registers
>> > - additional information passing: board specific register scheme, SMC calls
>> > - U-Boot for RPI boards implement a Linux shaped entry ABI to be launched by Videocore firmware
>> >
>> > Based on all the above, I would tend to think that RPI scheme is a good idea but also
>> > shall not prevent additional schemes for the boards.
>>
>> I was not actually considering Linux since I believe/assume its entry
>> scheme is fixed and not up for discussion.
>>
>> I also did not think about the EFI case. As I understand it we cannot
>> touch it as it is used by UEFI today. Maybe it is even in the
>> standard?
>
> It is in the spec and we are making it evolve, or its understanding evolve (jurisprudence) for instance on initrd standard handling.

Well perhaps we could merge it with standard passage. But EFI is not
going to want to use a bloblist, it will want to use a HOB.

>>
>>
>> Really I am hoping we can start afresh...?
>>
>> >
>> > What about a U-Boot Arm entry ABI like:
>> > - plain: x0=dtb, x1=<Passage defined>, x2-x5 = <reserved>, other registers are per platform, SMC calls allowed too
>>
>> Hmm we don't actually need the dtb as it is available in the bloblist.
>
> If you don't have x0=dtb, then you will not be able to use U-Boot on RPI4.
> Unless you want to redo everything the RPI firmware is doing.

That's right, RPI cannot support standard passage. It is not
open-source firmware so it isn't really relevant to this discussion.
It will just do what it does and have limited functionality, with
work-arounds to deal with the pain, as one might expect.

>>
>> But I added an offset to it as a convenience.
>>
>> > - EFI: x0=handle, x1=systemtable, x30=return address;  (when U-Boot is launched as an EFI app)
>> >        dtb = EFI_UUID config table, + Passage = Passage UUID config table
>>
>> I don't understand the last line. Where is the passage info /
>> bloblist? Do you mean it goes in the HOB list with a UUID? I suppose
>> that is the most EFI-compatible way.
>
> The Passage config table  could just contain the "head" of the bloblist/Passage information.

If UEFI wants to deal with standard passage, that is...

>>
>>
>> What do you think about the idea of using an offset into the bloblist
>> for the dtb?
>
> It is possible but as I said, failing to mimic Linux entry ABI would miss the opportunity to just boot without changes on RPI4.

See above. Broadcom could look at open-sourcing their bootloader if they wish.

>>
>> Also, can we make the standard passage ABI a build-time
>> option, so it is deterministic?
>>
> Looks good. I would look into stating that for SystemReady we would advise to use that option and make it standard for Trusted Substrate (Linaro recipes that we upstreaming to make SystemReady compliance easy and consistent across platforms).

OK. I mean that if the option is enabled, then standard passage must
be provided / emitted or things won't work. If the option is disabled,
then standard passage is not used. In other words, we are looking for
magic values in registers, etc, just enabling/disabling it at
build-time.

>>
>> >
>> > We could further leverage Passage to pass Operating Systems parameters that could be removed from device tree (migration of /chosen to Passage). Memory inventory would still be in DT but allocations for CMA or GPUs would be in Passage. This idea is to reach a point where  device tree is a "pristine" hardware description.
>>
>> I'm worried about this becoming a substitute for devicetree. Really my
>> intent is to provide a way to pass simple info, whereas what you talk
>> about there seems like something that should be DT, just that it might
>> need suitable bindings.
>>
> I see your point and I agree It should not be a substitute.
> here is an expanded version of what I had in mind when I wrote those lines.
> cma, initrd and other Linux kernel parameters can be conveyed either through command line or DT.
> When using the non UEFI Linux entry ABI, you need to use the DT to pass those parameters.
> When using the UEFI Linux entry ABI, you *can* (not must) use the command line to pass all information, leaving the DT passed to the OS without any /chosen.
> When introducing Passage, I was wondering if we could pass command line to Linux and, same as UEFI, leave the DT free from /chosen.
> I am not sure it is a good goal though. I may be too pushing for a DT free from parameters.

We could. Are there benefits to that?

I doubt we would pass the standard passage to Linux as a bloblist. I
imagine something like this. The bloblist sits in memory with some
things in it, including a devicetree, perhaps an SMBIOS table and a
TPM log. But when U-Boot calls Linux it puts the address/size of those
individual things in the devicetree. They don't move and are still
contiguous in memory, but the bloblist around them is forgotten. Linux
doesn't know that the three separate things it is picking up are
actually part of a bloblist structure, since it doesn't care about
that. Even a console log could work the same way. That way we don't
end up trying to teach Linux about bloblist when it already has a
perfectly good means to accept these items.

For ACPI I see things a similar way. The ACPI tables can point to
things that *happen* to be in a bloblist, but without any knowledge of
that needed in Linux, grub, etc.

>>
>> As you know I have more expansive views about what should be in DT.
>
> I think both of us are huge supporters of DT format and self describing capabilities.
> I am inclined to put rules into what fits into what lands in the DT that is passed to the OS.
> I am a fan of having DT used more in ad-hoc files.

Me too.

>>
>> >
>> > Cheers
>> >
>> > PS: as Ilias mentions, this patch set contains bug fixes, non immediately related additional functions (DM stats). It would be great to carve those out to fast path them and keep this one with the very core of your idea.
>>
>> The DM stats is used in 'passage: Report the devicetree source'. I
>> know it is sideways but I think it is better to make the output line
>> more useful than just reporting the devicetree source.
>>
> I believe the DM stats has merits in its own. You could upstream this independently and then Passage would be yet another "customer" of the feature.

I could, but it would just be a debug feature so people might not
think it worth the code space. With the devicetree source it is more
compelling.

>>
>> The first patch is indeed unrelated. I will pick it up so we can drop
>> it for the next rev.
>>
[..]

Regards,
Simon
François Ozog Nov. 5, 2021, 8:26 a.m. UTC | #7
On Fri, 5 Nov 2021 at 03:02, Simon Glass <sjg@chromium.org> wrote:

> Hi François,
>
> On Tue, 2 Nov 2021 at 10:03, François Ozog <francois.ozog@linaro.org>
> wrote:
> >
> > Hi Simon,
> >
> > On Tue, 2 Nov 2021 at 15:59, Simon Glass <sjg@chromium.org> wrote:
> >>
> >> Hi François,
> >>
> >> On Mon, 1 Nov 2021 at 02:53, François Ozog <francois.ozog@linaro.org>
> wrote:
> >> >
> >> > Hi Simon,
> >> >
> >> > this seems a great endeavor. I'd like to better understand the scope
> of it.
> >> >
> >> > Is it to be used as part of what could become a U-Boot entry ABI
> scheme? By that I mean giving some fixed aspects
> >> > to U-Boot entry while letting boards to have flexibility (say for
> instance that the first 5 architecture ABI
> >> > parameter registers are reserved for U-Boot), and the Passage is
> about specifying either those reserved registers
> >> > or one of them?
> >>
> >> The goal is to provide a standard entry scheme for all firmware
> >> binaries. Whether it achieves that (or can with some mods) is up for
> >> discussion.
> >>
> > If you say
> > a) define a U-Boot entry ABI and providing a firmware-to-firmware
> information passing facility which would be part of all firmware ABIs (as
> the projects decide to define their own ABI) it looks good.
> > but If you say
>
> It is an ABI to be adopted by U-Boot but also other firmware. For
> example, if TF-A calls U-Boot it should use standard passage. If
> U-Boot calls TF-A or Optee it should use standard passage.
>
> > b) define a standard entry scheme (register map, processor state, MMU
> state, SMMU state, GIC state...) that does not look realistic.
>
> No I don't mean that. This data structure could be used in any state,
> so long as the two registers are set correctly.
>
> > I think you mean a) but just want to be sure.
>
> Yes I think so.
>
> >>
> >> Re the registers, do you think we need 5?
> >>
>
> I don't :-)
>
> >> >
> >> > Thinking entry ABI, here is what I observed on Arm:
> >> >
> >> > Linux has two entry ABIs:
> >> > - plain: x0 = dtb;
> >> >           command line = dtb:/chosen/bootargs; initrd =
> dtb:/chosen/linux,initrd-*
> >> > - EFI: x0=handle, x1=systemtable, x30=return address;
> >> >            dtb = EFI_UUID config table; initrd =
> efi:<loadfile2(INITRD vendor media UUID); command line = efi:
> image_protocol::load_options
> >> >
> >> > U-Boot (proper) has plenty of schemes:
> >> > - dtb is passed as either x0, x1, fixed memory area (Qemu which is
> bad in itself), or other registers
> >> > - additional information passing: board specific register scheme, SMC
> calls
> >> > - U-Boot for RPI boards implement a Linux shaped entry ABI to be
> launched by Videocore firmware
> >> >
> >> > Based on all the above, I would tend to think that RPI scheme is a
> good idea but also
> >> > shall not prevent additional schemes for the boards.
> >>
> >> I was not actually considering Linux since I believe/assume its entry
> >> scheme is fixed and not up for discussion.
> >>
> >> I also did not think about the EFI case. As I understand it we cannot
> >> touch it as it is used by UEFI today. Maybe it is even in the
> >> standard?
> >
> > It is in the spec and we are making it evolve, or its understanding
> evolve (jurisprudence) for instance on initrd standard handling.
>
> Well perhaps we could merge it with standard passage. But EFI is not
> going to want to use a bloblist, it will want to use a HOB.
>
> >>
> >>
> >> Really I am hoping we can start afresh...?
> >>
> >> >
> >> > What about a U-Boot Arm entry ABI like:
> >> > - plain: x0=dtb, x1=<Passage defined>, x2-x5 = <reserved>, other
> registers are per platform, SMC calls allowed too
> >>
> >> Hmm we don't actually need the dtb as it is available in the bloblist.
> >
> > If you don't have x0=dtb, then you will not be able to use U-Boot on
> RPI4.
> > Unless you want to redo everything the RPI firmware is doing.
>
> That's right, RPI cannot support standard passage. It is not
> open-source firmware so it isn't really relevant to this discussion.
> It will just do what it does and have limited functionality, with
> work-arounds to deal with the pain, as one might expect.
>
> So you are seeing two "all-or-nothing" options:
<specific>: U-Boot entry is board specific as it is today
<purepassage>: A new form where the only parameter is a head of bloblist,
one of those blobs contain a DT
 You propose to mandate a DT for all boards make sense in that environment.
For RPI4, you just ignore everything the prior boot loader does because it
is not <passage> compliant.

This reinforces my opposition to the mandatory DT proposal.

a third option is I think way more attractive:
<optpassage>: shaped after the architecture Linux entry (ie. first
parameter is dtb) [+ passage head (i.e. second parameter is pointer to
passage head)]

This way, you make U-Boot entry clean in RPI4, Apple M1, Qemu, SystemReady
contexts
and get a well deserved standardized information passing between prior
loaders and U-Boot.

The three options are possible though, you could select a U-Boot entry
CONFIG option for:
<specific>
<optpassage>
<purepassage>

But despite it would be technically feasible, I don't think it is goes in
the right direction.

>>
> >> But I added an offset to it as a convenience.
> >>
> >> > - EFI: x0=handle, x1=systemtable, x30=return address;  (when U-Boot
> is launched as an EFI app)
> >> >        dtb = EFI_UUID config table, + Passage = Passage UUID config
> table
> >>
> >> I don't understand the last line. Where is the passage info /
> >> bloblist? Do you mean it goes in the HOB list with a UUID? I suppose
> >> that is the most EFI-compatible way.
> >
> > The Passage config table  could just contain the "head" of the
> bloblist/Passage information.
>
> If UEFI wants to deal with standard passage, that is...
>
> >>
> >>
> >> What do you think about the idea of using an offset into the bloblist
> >> for the dtb?
> >
> > It is possible but as I said, failing to mimic Linux entry ABI would
> miss the opportunity to just boot without changes on RPI4.
>
> See above. Broadcom could look at open-sourcing their bootloader if they
> wish.
>
> >>
> >> Also, can we make the standard passage ABI a build-time
> >> option, so it is deterministic?
> >>
> > Looks good. I would look into stating that for SystemReady we would
> advise to use that option and make it standard for Trusted Substrate
> (Linaro recipes that we upstreaming to make SystemReady compliance easy and
> consistent across platforms).
>
> OK. I mean that if the option is enabled, then standard passage must
> be provided / emitted or things won't work. If the option is disabled,
> then standard passage is not used. In other words, we are looking for
> magic values in registers, etc, just enabling/disabling it at
> build-time.
>
> >>
> >> >
> >> > We could further leverage Passage to pass Operating Systems
> parameters that could be removed from device tree (migration of /chosen to
> Passage). Memory inventory would still be in DT but allocations for CMA or
> GPUs would be in Passage. This idea is to reach a point where  device tree
> is a "pristine" hardware description.
> >>
> >> I'm worried about this becoming a substitute for devicetree. Really my
> >> intent is to provide a way to pass simple info, whereas what you talk
> >> about there seems like something that should be DT, just that it might
> >> need suitable bindings.
> >>
> > I see your point and I agree It should not be a substitute.
> > here is an expanded version of what I had in mind when I wrote those
> lines.
> > cma, initrd and other Linux kernel parameters can be conveyed either
> through command line or DT.
> > When using the non UEFI Linux entry ABI, you need to use the DT to pass
> those parameters.
> > When using the UEFI Linux entry ABI, you *can* (not must) use the
> command line to pass all information, leaving the DT passed to the OS
> without any /chosen.
> > When introducing Passage, I was wondering if we could pass command line
> to Linux and, same as UEFI, leave the DT free from /chosen.
> > I am not sure it is a good goal though. I may be too pushing for a DT
> free from parameters.
>
> We could. Are there benefits to that?
>
> I doubt we would pass the standard passage to Linux as a bloblist. I
> imagine something like this. The bloblist sits in memory with some
> things in it, including a devicetree, perhaps an SMBIOS table and a
> TPM log. But when U-Boot calls Linux it puts the address/size of those
> individual things in the devicetree. They don't move and are still
> contiguous in memory, but the bloblist around them is forgotten. Linux
> doesn't know that the three separate things it is picking up are
> actually part of a bloblist structure, since it doesn't care about
> that. Even a console log could work the same way. That way we don't
> end up trying to teach Linux about bloblist when it already has a
> perfectly good means to accept these items.
>
> For ACPI I see things a similar way. The ACPI tables can point to
> things that *happen* to be in a bloblist, but without any knowledge of
> that needed in Linux, grub, etc.
>
> >>
> >> As you know I have more expansive views about what should be in DT.
> >
> > I think both of us are huge supporters of DT format and self describing
> capabilities.
> > I am inclined to put rules into what fits into what lands in the DT that
> is passed to the OS.
> > I am a fan of having DT used more in ad-hoc files.
>
> Me too.
>
> >>
> >> >
> >> > Cheers
> >> >
> >> > PS: as Ilias mentions, this patch set contains bug fixes, non
> immediately related additional functions (DM stats). It would be great to
> carve those out to fast path them and keep this one with the very core of
> your idea.
> >>
> >> The DM stats is used in 'passage: Report the devicetree source'. I
> >> know it is sideways but I think it is better to make the output line
> >> more useful than just reporting the devicetree source.
> >>
> > I believe the DM stats has merits in its own. You could upstream this
> independently and then Passage would be yet another "customer" of the
> feature.
>
> I could, but it would just be a debug feature so people might not
> think it worth the code space. With the devicetree source it is more
> compelling.
>
> >>
> >> The first patch is indeed unrelated. I will pick it up so we can drop
> >> it for the next rev.
> >>
> [..]
>
> Regards,
> Simon
>
Simon Glass Nov. 5, 2021, 4:12 p.m. UTC | #8
Hi François,

On Fri, 5 Nov 2021 at 02:27, François Ozog <francois.ozog@linaro.org> wrote:
>
>
>
> On Fri, 5 Nov 2021 at 03:02, Simon Glass <sjg@chromium.org> wrote:
>>
>> Hi François,
>>
>> On Tue, 2 Nov 2021 at 10:03, François Ozog <francois.ozog@linaro.org> wrote:
>> >
>> > Hi Simon,
>> >
>> > On Tue, 2 Nov 2021 at 15:59, Simon Glass <sjg@chromium.org> wrote:
>> >>
>> >> Hi François,
>> >>
>> >> On Mon, 1 Nov 2021 at 02:53, François Ozog <francois.ozog@linaro.org> wrote:
>> >> >
>> >> > Hi Simon,
>> >> >
>> >> > this seems a great endeavor. I'd like to better understand the scope of it.
>> >> >
>> >> > Is it to be used as part of what could become a U-Boot entry ABI scheme? By that I mean giving some fixed aspects
>> >> > to U-Boot entry while letting boards to have flexibility (say for instance that the first 5 architecture ABI
>> >> > parameter registers are reserved for U-Boot), and the Passage is about specifying either those reserved registers
>> >> > or one of them?
>> >>
>> >> The goal is to provide a standard entry scheme for all firmware
>> >> binaries. Whether it achieves that (or can with some mods) is up for
>> >> discussion.
>> >>
>> > If you say
>> > a) define a U-Boot entry ABI and providing a firmware-to-firmware information passing facility which would be part of all firmware ABIs (as the projects decide to define their own ABI) it looks good.
>> > but If you say
>>
>> It is an ABI to be adopted by U-Boot but also other firmware. For
>> example, if TF-A calls U-Boot it should use standard passage. If
>> U-Boot calls TF-A or Optee it should use standard passage.
>>
>> > b) define a standard entry scheme (register map, processor state, MMU state, SMMU state, GIC state...) that does not look realistic.
>>
>> No I don't mean that. This data structure could be used in any state,
>> so long as the two registers are set correctly.
>>
>> > I think you mean a) but just want to be sure.
>>
>> Yes I think so.
>>
>> >>
>> >> Re the registers, do you think we need 5?
>> >>
>>
>> I don't :-)
>>
>> >> >
>> >> > Thinking entry ABI, here is what I observed on Arm:
>> >> >
>> >> > Linux has two entry ABIs:
>> >> > - plain: x0 = dtb;
>> >> >           command line = dtb:/chosen/bootargs; initrd = dtb:/chosen/linux,initrd-*
>> >> > - EFI: x0=handle, x1=systemtable, x30=return address;
>> >> >            dtb = EFI_UUID config table; initrd = efi:<loadfile2(INITRD vendor media UUID); command line = efi: image_protocol::load_options
>> >> >
>> >> > U-Boot (proper) has plenty of schemes:
>> >> > - dtb is passed as either x0, x1, fixed memory area (Qemu which is bad in itself), or other registers
>> >> > - additional information passing: board specific register scheme, SMC calls
>> >> > - U-Boot for RPI boards implement a Linux shaped entry ABI to be launched by Videocore firmware
>> >> >
>> >> > Based on all the above, I would tend to think that RPI scheme is a good idea but also
>> >> > shall not prevent additional schemes for the boards.
>> >>
>> >> I was not actually considering Linux since I believe/assume its entry
>> >> scheme is fixed and not up for discussion.
>> >>
>> >> I also did not think about the EFI case. As I understand it we cannot
>> >> touch it as it is used by UEFI today. Maybe it is even in the
>> >> standard?
>> >
>> > It is in the spec and we are making it evolve, or its understanding evolve (jurisprudence) for instance on initrd standard handling.
>>
>> Well perhaps we could merge it with standard passage. But EFI is not
>> going to want to use a bloblist, it will want to use a HOB.
>>
>> >>
>> >>
>> >> Really I am hoping we can start afresh...?
>> >>
>> >> >
>> >> > What about a U-Boot Arm entry ABI like:
>> >> > - plain: x0=dtb, x1=<Passage defined>, x2-x5 = <reserved>, other registers are per platform, SMC calls allowed too
>> >>
>> >> Hmm we don't actually need the dtb as it is available in the bloblist.
>> >
>> > If you don't have x0=dtb, then you will not be able to use U-Boot on RPI4.
>> > Unless you want to redo everything the RPI firmware is doing.
>>
>> That's right, RPI cannot support standard passage. It is not
>> open-source firmware so it isn't really relevant to this discussion.
>> It will just do what it does and have limited functionality, with
>> work-arounds to deal with the pain, as one might expect.
>>
> So you are seeing two "all-or-nothing" options:
> <specific>: U-Boot entry is board specific as it is today
> <purepassage>: A new form where the only parameter is a head of bloblist, one of those blobs contain a DT
>  You propose to mandate a DT for all boards make sense in that environment.
> For RPI4, you just ignore everything the prior boot loader does because it is not <passage> compliant.

It's not that. It's just that it is closed-source, so not relevant to
the discussion here. They could open-source it and then we could
consider it, but it has been closed-source for years now, so why would
we think that would happen?

>
> This reinforces my opposition to the mandatory DT proposal.
>
> a third option is I think way more attractive:
> <optpassage>: shaped after the architecture Linux entry (ie. first parameter is dtb) [+ passage head (i.e. second parameter is pointer to passage head)]
>
> This way, you make U-Boot entry clean in RPI4, Apple M1, Qemu, SystemReady contexts
> and get a well deserved standardized information passing between prior loaders and U-Boot.
>
> The three options are possible though, you could select a U-Boot entry CONFIG option for:
> <specific>
> <optpassage>
> <purepassage>
>
> But despite it would be technically feasible, I don't think it is goes in the right direction.

OK. Do you think we need a separate devicetree pointer, rather than
forcing it to be inside the created bloblist?

I'd like to understand what problem you are solving with this. I am
trying to figure out a firmware-to-firmware mini-ABI (just a few
register values) that can be used in open-source projects. The ABI is
not intended to be used with Linux (I am unsure of the benefit it
would give and whether it is feasible to change the current one).

You are talking about the Linux entry mechanism. What relevance does
that have for firmware?

I understand that some projects already implement the Linux mechanism,
but that is because they expect to jump straight to Linux, not have
U-Boot in the path. So IMO standard passage offers no benefit to them.

To address them in turn:
- rpi4 - closed source, who cares?
- Apple M1 - we could probably expand it to pass a bloblist, but it
would be confusing unless we share registers, as you suggest
- Qemu - I already tried to update that and got pushback...do you
really think those guys are going to want to add a bloblist? So again,
who cares?
- SystemReady - not sure what this means in practice, but it would be
good if SystemReady could use standard passage

So let's say we have an optional standard-passage thing and we use
registers such that it is similar to Linux and EFI and just expands on
them.

The first problem is that Linux and EFI seem to be completely
incompatible. Can that be changed, perhaps on the EFI side? If not,
we need two separate protocols.

I'll ignore EFI for now. So we might have:

r0 = 0
r1 = machine number (0?)
r2 = dtb pointer
r3 = bloblist pointer, 0 if missing
r14 = return address

or

x0 = dtb
x1 = bloblist pointer, 0 if missing
x30 = return address

For EFI, we could add a blob to the bloblist containing the system
table and handle, perhaps? Otherwise:

x2 - efi handle
x3 - system table

Is that along the lines of what you are thinking?

But still, please respond above so I can understand what problem you
are worried about.

Regards,
Simon


>
>> >>
>> >> But I added an offset to it as a convenience.
>> >>
>> >> > - EFI: x0=handle, x1=systemtable, x30=return address;  (when U-Boot is launched as an EFI app)
>> >> >        dtb = EFI_UUID config table, + Passage = Passage UUID config table
>> >>
>> >> I don't understand the last line. Where is the passage info /
>> >> bloblist? Do you mean it goes in the HOB list with a UUID? I suppose
>> >> that is the most EFI-compatible way.
>> >
>> > The Passage config table  could just contain the "head" of the bloblist/Passage information.
>>
>> If UEFI wants to deal with standard passage, that is...
>>
>> >>
>> >>
>> >> What do you think about the idea of using an offset into the bloblist
>> >> for the dtb?
>> >
>> > It is possible but as I said, failing to mimic Linux entry ABI would miss the opportunity to just boot without changes on RPI4.
>>
>> See above. Broadcom could look at open-sourcing their bootloader if they wish.
>>
>> >>
>> >> Also, can we make the standard passage ABI a build-time
>> >> option, so it is deterministic?
>> >>
>> > Looks good. I would look into stating that for SystemReady we would advise to use that option and make it standard for Trusted Substrate (Linaro recipes that we upstreaming to make SystemReady compliance easy and consistent across platforms).
>>
>> OK. I mean that if the option is enabled, then standard passage must
>> be provided / emitted or things won't work. If the option is disabled,
>> then standard passage is not used. In other words, we are looking for
>> magic values in registers, etc, just enabling/disabling it at
>> build-time.
>>
>> >>
>> >> >
>> >> > We could further leverage Passage to pass Operating Systems parameters that could be removed from device tree (migration of /chosen to Passage). Memory inventory would still be in DT but allocations for CMA or GPUs would be in Passage. This idea is to reach a point where  device tree is a "pristine" hardware description.
>> >>
>> >> I'm worried about this becoming a substitute for devicetree. Really my
>> >> intent is to provide a way to pass simple info, whereas what you talk
>> >> about there seems like something that should be DT, just that it might
>> >> need suitable bindings.
>> >>
>> > I see your point and I agree It should not be a substitute.
>> > here is an expanded version of what I had in mind when I wrote those lines.
>> > cma, initrd and other Linux kernel parameters can be conveyed either through command line or DT.
>> > When using the non UEFI Linux entry ABI, you need to use the DT to pass those parameters.
>> > When using the UEFI Linux entry ABI, you *can* (not must) use the command line to pass all information, leaving the DT passed to the OS without any /chosen.
>> > When introducing Passage, I was wondering if we could pass command line to Linux and, same as UEFI, leave the DT free from /chosen.
>> > I am not sure it is a good goal though. I may be too pushing for a DT free from parameters.
>>
>> We could. Are there benefits to that?
>>
>> I doubt we would pass the standard passage to Linux as a bloblist. I
>> imagine something like this. The bloblist sits in memory with some
>> things in it, including a devicetree, perhaps an SMBIOS table and a
>> TPM log. But when U-Boot calls Linux it puts the address/size of those
>> individual things in the devicetree. They don't move and are still
>> contiguous in memory, but the bloblist around them is forgotten. Linux
>> doesn't know that the three separate things it is picking up are
>> actually part of a bloblist structure, since it doesn't care about
>> that. Even a console log could work the same way. That way we don't
>> end up trying to teach Linux about bloblist when it already has a
>> perfectly good means to accept these items.
>>
>> For ACPI I see things a similar way. The ACPI tables can point to
>> things that *happen* to be in a bloblist, but without any knowledge of
>> that needed in Linux, grub, etc.
>>
>> >>
>> >> As you know I have more expansive views about what should be in DT.
>> >
>> > I think both of us are huge supporters of DT format and self describing capabilities.
>> > I am inclined to put rules into what fits into what lands in the DT that is passed to the OS.
>> > I am a fan of having DT used more in ad-hoc files.
>>
>> Me too.
>>
>> >>
>> >> >
>> >> > Cheers
>> >> >
>> >> > PS: as Ilias mentions, this patch set contains bug fixes, non immediately related additional functions (DM stats). It would be great to carve those out to fast path them and keep this one with the very core of your idea.
>> >>
>> >> The DM stats is used in 'passage: Report the devicetree source'. I
>> >> know it is sideways but I think it is better to make the output line
>> >> more useful than just reporting the devicetree source.
>> >>
>> > I believe the DM stats has merits in its own. You could upstream this independently and then Passage would be yet another "customer" of the feature.
>>
>> I could, but it would just be a debug feature so people might not
>> think it worth the code space. With the devicetree source it is more
>> compelling.
>>
>> >>
>> >> The first patch is indeed unrelated. I will pick it up so we can drop
>> >> it for the next rev.
>> >>
>> [..]
>>
>> Regards,
>> Simon
>
>
>
> --
> François-Frédéric Ozog | Director Business Development
> T: +33.67221.6485
> francois.ozog@linaro.org | Skype: ffozog
>
François Ozog Nov. 5, 2021, 4:31 p.m. UTC | #9
Hi Simon,

Le ven. 5 nov. 2021 à 17:12, Simon Glass <sjg@chromium.org> a écrit :

> Hi François,
>
> On Fri, 5 Nov 2021 at 02:27, François Ozog <francois.ozog@linaro.org>
> wrote:
> >
> >
> >
> > On Fri, 5 Nov 2021 at 03:02, Simon Glass <sjg@chromium.org> wrote:
> >>
> >> Hi François,
> >>
> >> On Tue, 2 Nov 2021 at 10:03, François Ozog <francois.ozog@linaro.org>
> wrote:
> >> >
> >> > Hi Simon,
> >> >
> >> > On Tue, 2 Nov 2021 at 15:59, Simon Glass <sjg@chromium.org> wrote:
> >> >>
> >> >> Hi François,
> >> >>
> >> >> On Mon, 1 Nov 2021 at 02:53, François Ozog <francois.ozog@linaro.org>
> wrote:
> >> >> >
> >> >> > Hi Simon,
> >> >> >
> >> >> > this seems a great endeavor. I'd like to better understand the
> scope of it.
> >> >> >
> >> >> > Is it to be used as part of what could become a U-Boot entry ABI
> scheme? By that I mean giving some fixed aspects
> >> >> > to U-Boot entry while letting boards to have flexibility (say for
> instance that the first 5 architecture ABI
> >> >> > parameter registers are reserved for U-Boot), and the Passage is
> about specifying either those reserved registers
> >> >> > or one of them?
> >> >>
> >> >> The goal is to provide a standard entry scheme for all firmware
> >> >> binaries. Whether it achieves that (or can with some mods) is up for
> >> >> discussion.
> >> >>
> >> > If you say
> >> > a) define a U-Boot entry ABI and providing a firmware-to-firmware
> information passing facility which would be part of all firmware ABIs (as
> the projects decide to define their own ABI) it looks good.
> >> > but If you say
> >>
> >> It is an ABI to be adopted by U-Boot but also other firmware. For
> >> example, if TF-A calls U-Boot it should use standard passage. If
> >> U-Boot calls TF-A or Optee it should use standard passage.
> >>
> >> > b) define a standard entry scheme (register map, processor state, MMU
> state, SMMU state, GIC state...) that does not look realistic.
> >>
> >> No I don't mean that. This data structure could be used in any state,
> >> so long as the two registers are set correctly.
> >>
> >> > I think you mean a) but just want to be sure.
> >>
> >> Yes I think so.
> >>
> >> >>
> >> >> Re the registers, do you think we need 5?
> >> >>
> >>
> >> I don't :-)
> >>
> >> >> >
> >> >> > Thinking entry ABI, here is what I observed on Arm:
> >> >> >
> >> >> > Linux has two entry ABIs:
> >> >> > - plain: x0 = dtb;
> >> >> >           command line = dtb:/chosen/bootargs; initrd =
> dtb:/chosen/linux,initrd-*
> >> >> > - EFI: x0=handle, x1=systemtable, x30=return address;
> >> >> >            dtb = EFI_UUID config table; initrd =
> efi:<loadfile2(INITRD vendor media UUID); command line = efi:
> image_protocol::load_options
> >> >> >
> >> >> > U-Boot (proper) has plenty of schemes:
> >> >> > - dtb is passed as either x0, x1, fixed memory area (Qemu which is
> bad in itself), or other registers
> >> >> > - additional information passing: board specific register scheme,
> SMC calls
> >> >> > - U-Boot for RPI boards implement a Linux shaped entry ABI to be
> launched by Videocore firmware
> >> >> >
> >> >> > Based on all the above, I would tend to think that RPI scheme is a
> good idea but also
> >> >> > shall not prevent additional schemes for the boards.
> >> >>
> >> >> I was not actually considering Linux since I believe/assume its entry
> >> >> scheme is fixed and not up for discussion.
> >> >>
> >> >> I also did not think about the EFI case. As I understand it we cannot
> >> >> touch it as it is used by UEFI today. Maybe it is even in the
> >> >> standard?
> >> >
> >> > It is in the spec and we are making it evolve, or its understanding
> evolve (jurisprudence) for instance on initrd standard handling.
> >>
> >> Well perhaps we could merge it with standard passage. But EFI is not
> >> going to want to use a bloblist, it will want to use a HOB.
> >>
> >> >>
> >> >>
> >> >> Really I am hoping we can start afresh...?
> >> >>
> >> >> >
> >> >> > What about a U-Boot Arm entry ABI like:
> >> >> > - plain: x0=dtb, x1=<Passage defined>, x2-x5 = <reserved>, other
> registers are per platform, SMC calls allowed too
> >> >>
> >> >> Hmm we don't actually need the dtb as it is available in the
> bloblist.
> >> >
> >> > If you don't have x0=dtb, then you will not be able to use U-Boot on
> RPI4.
> >> > Unless you want to redo everything the RPI firmware is doing.
> >>
> >> That's right, RPI cannot support standard passage. It is not
> >> open-source firmware so it isn't really relevant to this discussion.
> >> It will just do what it does and have limited functionality, with
> >> work-arounds to deal with the pain, as one might expect.
> >>
> > So you are seeing two "all-or-nothing" options:
> > <specific>: U-Boot entry is board specific as it is today
> > <purepassage>: A new form where the only parameter is a head of
> bloblist, one of those blobs contain a DT
> >  You propose to mandate a DT for all boards make sense in that
> environment.
> > For RPI4, you just ignore everything the prior boot loader does because
> it is not <passage> compliant.
>
> It's not that. It's just that it is closed-source, so not relevant to
> the discussion here. They could open-source it and then we could
> consider it, but it has been closed-source for years now, so why would
> we think that would happen?
>
> >
> > This reinforces my opposition to the mandatory DT proposal.
> >
> > a third option is I think way more attractive:
> > <optpassage>: shaped after the architecture Linux entry (ie. first
> parameter is dtb) [+ passage head (i.e. second parameter is pointer to
> passage head)]
> >
> > This way, you make U-Boot entry clean in RPI4, Apple M1, Qemu,
> SystemReady contexts
> > and get a well deserved standardized information passing between prior
> loaders and U-Boot.
> >
> > The three options are possible though, you could select a U-Boot entry
> CONFIG option for:
> > <specific>
> > <optpassage>
> > <purepassage>
> >
> > But despite it would be technically feasible, I don't think it is goes
> in the right direction.
>
> OK. Do you think we need a separate devicetree pointer, rather than
> forcing it to be inside the created bloblist?
>
> I'd like to understand what problem you are solving with this. I am
> trying to figure out a firmware-to-firmware mini-ABI (just a few
> register values) that can be used in open-source projects. The ABI is
> not intended to be used with Linux (I am unsure of the benefit it
> would give and whether it is feasible to change the current one).
>
> You are talking about the Linux entry mechanism. What relevance does
> that have for firmware?
>
> I understand that some projects already implement the Linux mechanism,
> but that is because they expect to jump straight to Linux, not have
> U-Boot in the path. So IMO standard passage offers no benefit to them.
>
> To address them in turn:
> - rpi4 - closed source, who cares?
> - Apple M1 - we could probably expand it to pass a bloblist, but it
> would be confusing unless we share registers, as you suggest
> - Qemu - I already tried to update that and got pushback...do you
> really think those guys are going to want to add a bloblist? So again,
> who cares?
> - SystemReady - not sure what this means in practice, but it would be
> good if SystemReady could use standard passage
>
> So let's say we have an optional standard-passage thing and we use
> registers such that it is similar to Linux and EFI and just expands on
> them.
>
> The first problem is that Linux and EFI seem to be completely
> incompatible. Can that be changed, perhaps on the EFI side? If not,
> we need two separate protocols.
>
> I'll ignore EFI for now. So we might have:
>
> r0 = 0
> r1 = machine number (0?)
> r2 = dtb pointer
> r3 = bloblist pointer, 0 if missing
> r14 = return address
>
> or
>
> x0 = dtb
> x1 = bloblist pointer, 0 if missing
> x30 = return address
>
That’s essentially what I proposed!
you do not force the DTB to be found in the bloblist, and shape the U-Boot
entry after the Linux entry ABI. Good !
I was saving a few registers for future ABI evolution so that boards can be
guaranteed to have their board specific registers properly protected. The 5
registers, leaving 3 undefined was just « why not ». We could also have a
cookie in x1: high 48 bits magic low 16 ABI version, x2=bloblist pointer.


> For EFI, we could add a blob to the bloblist containing the system
> table and handle, perhaps? Otherwise:
>
> x2 - efi handle
> x3 - system table
>
> Is that along the lines of what you are thinking?
>
No, efi entry is only x0=efi handle, x1=system table . I was trying to find
a way to have passage when U-Boot is loaded as a UEFI app (your other patch
set to make U-Boot a more integrated UEFi app). Let’s say that a U-Boot
aware DXE driver/protocol actually populate such a table, it could be a
communication channel between that driver and U-Boot.

>
> But still, please respond above so I can understand what problem you
> are worried about.
>
> Regards,
> Simon
>
>
> >
> >> >>
> >> >> But I added an offset to it as a convenience.
> >> >>
> >> >> > - EFI: x0=handle, x1=systemtable, x30=return address;  (when
> U-Boot is launched as an EFI app)
> >> >> >        dtb = EFI_UUID config table, + Passage = Passage UUID
> config table
> >> >>
> >> >> I don't understand the last line. Where is the passage info /
> >> >> bloblist? Do you mean it goes in the HOB list with a UUID? I suppose
> >> >> that is the most EFI-compatible way.
> >> >
> >> > The Passage config table  could just contain the "head" of the
> bloblist/Passage information.
> >>
> >> If UEFI wants to deal with standard passage, that is...
> >>
> >> >>
> >> >>
> >> >> What do you think about the idea of using an offset into the bloblist
> >> >> for the dtb?
> >> >
> >> > It is possible but as I said, failing to mimic Linux entry ABI would
> miss the opportunity to just boot without changes on RPI4.
> >>
> >> See above. Broadcom could look at open-sourcing their bootloader if
> they wish.
> >>
> >> >>
> >> >> Also, can we make the standard passage ABI a build-time
> >> >> option, so it is deterministic?
> >> >>
> >> > Looks good. I would look into stating that for SystemReady we would
> advise to use that option and make it standard for Trusted Substrate
> (Linaro recipes that we upstreaming to make SystemReady compliance easy and
> consistent across platforms).
> >>
> >> OK. I mean that if the option is enabled, then standard passage must
> >> be provided / emitted or things won't work. If the option is disabled,
> >> then standard passage is not used. In other words, we are looking for
> >> magic values in registers, etc, just enabling/disabling it at
> >> build-time.
> >>
> >> >>
> >> >> >
> >> >> > We could further leverage Passage to pass Operating Systems
> parameters that could be removed from device tree (migration of /chosen to
> Passage). Memory inventory would still be in DT but allocations for CMA or
> GPUs would be in Passage. This idea is to reach a point where  device tree
> is a "pristine" hardware description.
> >> >>
> >> >> I'm worried about this becoming a substitute for devicetree. Really
> my
> >> >> intent is to provide a way to pass simple info, whereas what you talk
> >> >> about there seems like something that should be DT, just that it
> might
> >> >> need suitable bindings.
> >> >>
> >> > I see your point and I agree It should not be a substitute.
> >> > here is an expanded version of what I had in mind when I wrote those
> lines.
> >> > cma, initrd and other Linux kernel parameters can be conveyed either
> through command line or DT.
> >> > When using the non UEFI Linux entry ABI, you need to use the DT to
> pass those parameters.
> >> > When using the UEFI Linux entry ABI, you *can* (not must) use the
> command line to pass all information, leaving the DT passed to the OS
> without any /chosen.
> >> > When introducing Passage, I was wondering if we could pass command
> line to Linux and, same as UEFI, leave the DT free from /chosen.
> >> > I am not sure it is a good goal though. I may be too pushing for a DT
> free from parameters.
> >>
> >> We could. Are there benefits to that?
> >>
> >> I doubt we would pass the standard passage to Linux as a bloblist. I
> >> imagine something like this. The bloblist sits in memory with some
> >> things in it, including a devicetree, perhaps an SMBIOS table and a
> >> TPM log. But when U-Boot calls Linux it puts the address/size of those
> >> individual things in the devicetree. They don't move and are still
> >> contiguous in memory, but the bloblist around them is forgotten. Linux
> >> doesn't know that the three separate things it is picking up are
> >> actually part of a bloblist structure, since it doesn't care about
> >> that. Even a console log could work the same way. That way we don't
> >> end up trying to teach Linux about bloblist when it already has a
> >> perfectly good means to accept these items.
> >>
> >> For ACPI I see things a similar way. The ACPI tables can point to
> >> things that *happen* to be in a bloblist, but without any knowledge of
> >> that needed in Linux, grub, etc.
> >>
> >> >>
> >> >> As you know I have more expansive views about what should be in DT.
> >> >
> >> > I think both of us are huge supporters of DT format and self
> describing capabilities.
> >> > I am inclined to put rules into what fits into what lands in the DT
> that is passed to the OS.
> >> > I am a fan of having DT used more in ad-hoc files.
> >>
> >> Me too.
> >>
> >> >>
> >> >> >
> >> >> > Cheers
> >> >> >
> >> >> > PS: as Ilias mentions, this patch set contains bug fixes, non
> immediately related additional functions (DM stats). It would be great to
> carve those out to fast path them and keep this one with the very core of
> your idea.
> >> >>
> >> >> The DM stats is used in 'passage: Report the devicetree source'. I
> >> >> know it is sideways but I think it is better to make the output line
> >> >> more useful than just reporting the devicetree source.
> >> >>
> >> > I believe the DM stats has merits in its own. You could upstream this
> independently and then Passage would be yet another "customer" of the
> feature.
> >>
> >> I could, but it would just be a debug feature so people might not
> >> think it worth the code space. With the devicetree source it is more
> >> compelling.
> >>
> >> >>
> >> >> The first patch is indeed unrelated. I will pick it up so we can drop
> >> >> it for the next rev.
> >> >>
> >> [..]
> >>
> >> Regards,
> >> Simon
> >
> >
> >
> > --
> > François-Frédéric Ozog | Director Business Development
> > T: +33.67221.6485
> > francois.ozog@linaro.org | Skype: ffozog
> >
>
Simon Glass Nov. 5, 2021, 5:16 p.m. UTC | #10
) to signal Hi François,

On Fri, 5 Nov 2021 at 10:31, François Ozog <francois.ozog@linaro.org> wrote:
>
> Hi Simon,
>
> Le ven. 5 nov. 2021 à 17:12, Simon Glass <sjg@chromium.org> a écrit :
>>
>> Hi François,
>>
>> On Fri, 5 Nov 2021 at 02:27, François Ozog <francois.ozog@linaro.org> wrote:
>> >
>> >
>> >
>> > On Fri, 5 Nov 2021 at 03:02, Simon Glass <sjg@chromium.org> wrote:
>> >>
>> >> Hi François,
>> >>
>> >> On Tue, 2 Nov 2021 at 10:03, François Ozog <francois.ozog@linaro.org> wrote:
>> >> >
>> >> > Hi Simon,
>> >> >
>> >> > On Tue, 2 Nov 2021 at 15:59, Simon Glass <sjg@chromium.org> wrote:
>> >> >>
>> >> >> Hi François,
>> >> >>
>> >> >> On Mon, 1 Nov 2021 at 02:53, François Ozog <francois.ozog@linaro.org> wrote:
>> >> >> >
>> >> >> > Hi Simon,
>> >> >> >
>> >> >> > this seems a great endeavor. I'd like to better understand the scope of it.
>> >> >> >
>> >> >> > Is it to be used as part of what could become a U-Boot entry ABI scheme? By that I mean giving some fixed aspects
>> >> >> > to U-Boot entry while letting boards to have flexibility (say for instance that the first 5 architecture ABI
>> >> >> > parameter registers are reserved for U-Boot), and the Passage is about specifying either those reserved registers
>> >> >> > or one of them?
>> >> >>
>> >> >> The goal is to provide a standard entry scheme for all firmware
>> >> >> binaries. Whether it achieves that (or can with some mods) is up for
>> >> >> discussion.
>> >> >>
>> >> > If you say
>> >> > a) define a U-Boot entry ABI and providing a firmware-to-firmware information passing facility which would be part of all firmware ABIs (as the projects decide to define their own ABI) it looks good.
>> >> > but If you say
>> >>
>> >> It is an ABI to be adopted by U-Boot but also other firmware. For
>> >> example, if TF-A calls U-Boot it should use standard passage. If
>> >> U-Boot calls TF-A or Optee it should use standard passage.
>> >>
>> >> > b) define a standard entry scheme (register map, processor state, MMU state, SMMU state, GIC state...) that does not look realistic.
>> >>
>> >> No I don't mean that. This data structure could be used in any state,
>> >> so long as the two registers are set correctly.
>> >>
>> >> > I think you mean a) but just want to be sure.
>> >>
>> >> Yes I think so.
>> >>
>> >> >>
>> >> >> Re the registers, do you think we need 5?
>> >> >>
>> >>
>> >> I don't :-)
>> >>
>> >> >> >
>> >> >> > Thinking entry ABI, here is what I observed on Arm:
>> >> >> >
>> >> >> > Linux has two entry ABIs:
>> >> >> > - plain: x0 = dtb;
>> >> >> >           command line = dtb:/chosen/bootargs; initrd = dtb:/chosen/linux,initrd-*
>> >> >> > - EFI: x0=handle, x1=systemtable, x30=return address;
>> >> >> >            dtb = EFI_UUID config table; initrd = efi:<loadfile2(INITRD vendor media UUID); command line = efi: image_protocol::load_options
>> >> >> >
>> >> >> > U-Boot (proper) has plenty of schemes:
>> >> >> > - dtb is passed as either x0, x1, fixed memory area (Qemu which is bad in itself), or other registers
>> >> >> > - additional information passing: board specific register scheme, SMC calls
>> >> >> > - U-Boot for RPI boards implement a Linux shaped entry ABI to be launched by Videocore firmware
>> >> >> >
>> >> >> > Based on all the above, I would tend to think that RPI scheme is a good idea but also
>> >> >> > shall not prevent additional schemes for the boards.
>> >> >>
>> >> >> I was not actually considering Linux since I believe/assume its entry
>> >> >> scheme is fixed and not up for discussion.
>> >> >>
>> >> >> I also did not think about the EFI case. As I understand it we cannot
>> >> >> touch it as it is used by UEFI today. Maybe it is even in the
>> >> >> standard?
>> >> >
>> >> > It is in the spec and we are making it evolve, or its understanding evolve (jurisprudence) for instance on initrd standard handling.
>> >>
>> >> Well perhaps we could merge it with standard passage. But EFI is not
>> >> going to want to use a bloblist, it will want to use a HOB.
>> >>
>> >> >>
>> >> >>
>> >> >> Really I am hoping we can start afresh...?
>> >> >>
>> >> >> >
>> >> >> > What about a U-Boot Arm entry ABI like:
>> >> >> > - plain: x0=dtb, x1=<Passage defined>, x2-x5 = <reserved>, other registers are per platform, SMC calls allowed too
>> >> >>
>> >> >> Hmm we don't actually need the dtb as it is available in the bloblist.
>> >> >
>> >> > If you don't have x0=dtb, then you will not be able to use U-Boot on RPI4.
>> >> > Unless you want to redo everything the RPI firmware is doing.
>> >>
>> >> That's right, RPI cannot support standard passage. It is not
>> >> open-source firmware so it isn't really relevant to this discussion.
>> >> It will just do what it does and have limited functionality, with
>> >> work-arounds to deal with the pain, as one might expect.
>> >>
>> > So you are seeing two "all-or-nothing" options:
>> > <specific>: U-Boot entry is board specific as it is today
>> > <purepassage>: A new form where the only parameter is a head of bloblist, one of those blobs contain a DT
>> >  You propose to mandate a DT for all boards make sense in that environment.
>> > For RPI4, you just ignore everything the prior boot loader does because it is not <passage> compliant.
>>
>> It's not that. It's just that it is closed-source, so not relevant to
>> the discussion here. They could open-source it and then we could
>> consider it, but it has been closed-source for years now, so why would
>> we think that would happen?
>>
>> >
>> > This reinforces my opposition to the mandatory DT proposal.
>> >
>> > a third option is I think way more attractive:
>> > <optpassage>: shaped after the architecture Linux entry (ie. first parameter is dtb) [+ passage head (i.e. second parameter is pointer to passage head)]
>> >
>> > This way, you make U-Boot entry clean in RPI4, Apple M1, Qemu, SystemReady contexts
>> > and get a well deserved standardized information passing between prior loaders and U-Boot.
>> >
>> > The three options are possible though, you could select a U-Boot entry CONFIG option for:
>> > <specific>
>> > <optpassage>
>> > <purepassage>
>> >
>> > But despite it would be technically feasible, I don't think it is goes in the right direction.
>>
>> OK. Do you think we need a separate devicetree pointer, rather than
>> forcing it to be inside the created bloblist?
>>
>> I'd like to understand what problem you are solving with this. I am
>> trying to figure out a firmware-to-firmware mini-ABI (just a few
>> register values) that can be used in open-source projects. The ABI is
>> not intended to be used with Linux (I am unsure of the benefit it
>> would give and whether it is feasible to change the current one).
>>
>> You are talking about the Linux entry mechanism. What relevance does
>> that have for firmware?
>>
>> I understand that some projects already implement the Linux mechanism,
>> but that is because they expect to jump straight to Linux, not have
>> U-Boot in the path. So IMO standard passage offers no benefit to them.
>>
>> To address them in turn:
>> - rpi4 - closed source, who cares?
>> - Apple M1 - we could probably expand it to pass a bloblist, but it
>> would be confusing unless we share registers, as you suggest
>> - Qemu - I already tried to update that and got pushback...do you
>> really think those guys are going to want to add a bloblist? So again,
>> who cares?
>> - SystemReady - not sure what this means in practice, but it would be
>> good if SystemReady could use standard passage
>>
>> So let's say we have an optional standard-passage thing and we use
>> registers such that it is similar to Linux and EFI and just expands on
>> them.
>>
>> The first problem is that Linux and EFI seem to be completely
>> incompatible. Can that be changed, perhaps on the EFI side? If not,
>> we need two separate protocols.
>>
>> I'll ignore EFI for now. So we might have:
>>
>> r0 = 0
>> r1 = machine number (0?)
>> r2 = dtb pointer
>> r3 = bloblist pointer, 0 if missing
>> r14 = return address
>>
>> or
>>
>> x0 = dtb
>> x1 = bloblist pointer, 0 if missing
>> x30 = return address
>
> That’s essentially what I proposed!
> you do not force the DTB to be found in the bloblist, and shape the U-Boot entry after the Linux entry ABI. Good !
> I was saving a few registers for future ABI evolution so that boards can be guaranteed to have their board specific registers properly protected. The 5 registers, leaving 3 undefined was just « why not ». We could also have a cookie in x1: high 48 bits magic low 16 ABI version, x2=bloblist pointer.

Isn't 32 bits enough for a magic value?

Also x3 might be nicer, to match ARM 32-bit, so:

x0 = dtb
x1 = ABI indicator bits 63:32 0xb00757a3, bits 31:1 = 0, bit 0 = 1
(version 1) ? We don't need to decide how many bits for the version
right now. Perhaps 8 is plenty
x2 = 0
x3 = bloblist pointer, 0 if missing
x4 = 0
x30 = return address

For ARM:

r0 = 0
r1 = machine number (0xb00757xx to signal standard passage where xx is
the ABI version?)*
r2 = dtb pointer
r3 = bloblist pointer (if r1 is 0xb00757xx), else 0
r4 = 0
r14 = return address

* might be safe, looking at
https://elixir.bootlin.com/linux/latest/source/arch/arm/kernel/setup.c#L1094

>
>>
>> For EFI, we could add a blob to the bloblist containing the system
>> table and handle, perhaps? Otherwise:
>>
>> x2 - efi handle
>> x3 - system table
>>
>> Is that along the lines of what you are thinking?
>
> No, efi entry is only x0=efi handle, x1=system table . I was trying to find a way to have passage when U-Boot is loaded as a UEFI app (your other patch set to make U-Boot a more integrated UEFi app). Let’s say that a U-Boot aware DXE driver/protocol actually populate such a table, it could be a communication channel between that driver and U-Boot.

OK, I figured, so how about, for EFI on 64-bit:

x0 = handle
x1 = systable
x2 = ABI indicator bits 63:32 0xb00757a3, bits 31:1 = 0, bit 0 = 1 (version 1)
x3 = bloblist pointer
x4 = 0
x30 = return address

EFI 32-bit:

r0 = handle
r1 = systable
r2 = 0xb00757a3
r3 = bloblist pointer
r4 = 0
r14 = return address

Regards,
Simon

>>
>>
>> But still, please respond above so I can understand what problem you
>> are worried about.
>>
>> Regards,
>> Simon
>>
>>
>> >
>> >> >>
>> >> >> But I added an offset to it as a convenience.
>> >> >>
>> >> >> > - EFI: x0=handle, x1=systemtable, x30=return address;  (when U-Boot is launched as an EFI app)
>> >> >> >        dtb = EFI_UUID config table, + Passage = Passage UUID config table
>> >> >>
>> >> >> I don't understand the last line. Where is the passage info /
>> >> >> bloblist? Do you mean it goes in the HOB list with a UUID? I suppose
>> >> >> that is the most EFI-compatible way.
>> >> >
>> >> > The Passage config table  could just contain the "head" of the bloblist/Passage information.
>> >>
>> >> If UEFI wants to deal with standard passage, that is...
>> >>
>> >> >>
>> >> >>
>> >> >> What do you think about the idea of using an offset into the bloblist
>> >> >> for the dtb?
>> >> >
>> >> > It is possible but as I said, failing to mimic Linux entry ABI would miss the opportunity to just boot without changes on RPI4.
>> >>
>> >> See above. Broadcom could look at open-sourcing their bootloader if they wish.
>> >>
>> >> >>
>> >> >> Also, can we make the standard passage ABI a build-time
>> >> >> option, so it is deterministic?
>> >> >>
>> >> > Looks good. I would look into stating that for SystemReady we would advise to use that option and make it standard for Trusted Substrate (Linaro recipes that we upstreaming to make SystemReady compliance easy and consistent across platforms).
>> >>
>> >> OK. I mean that if the option is enabled, then standard passage must
>> >> be provided / emitted or things won't work. If the option is disabled,
>> >> then standard passage is not used. In other words, we are looking for
>> >> magic values in registers, etc, just enabling/disabling it at
>> >> build-time.
>> >>
>> >> >>
>> >> >> >
>> >> >> > We could further leverage Passage to pass Operating Systems parameters that could be removed from device tree (migration of /chosen to Passage). Memory inventory would still be in DT but allocations for CMA or GPUs would be in Passage. This idea is to reach a point where  device tree is a "pristine" hardware description.
>> >> >>
>> >> >> I'm worried about this becoming a substitute for devicetree. Really my
>> >> >> intent is to provide a way to pass simple info, whereas what you talk
>> >> >> about there seems like something that should be DT, just that it might
>> >> >> need suitable bindings.
>> >> >>
>> >> > I see your point and I agree It should not be a substitute.
>> >> > here is an expanded version of what I had in mind when I wrote those lines.
>> >> > cma, initrd and other Linux kernel parameters can be conveyed either through command line or DT.
>> >> > When using the non UEFI Linux entry ABI, you need to use the DT to pass those parameters.
>> >> > When using the UEFI Linux entry ABI, you *can* (not must) use the command line to pass all information, leaving the DT passed to the OS without any /chosen.
>> >> > When introducing Passage, I was wondering if we could pass command line to Linux and, same as UEFI, leave the DT free from /chosen.
>> >> > I am not sure it is a good goal though. I may be too pushing for a DT free from parameters.
>> >>
>> >> We could. Are there benefits to that?
>> >>
>> >> I doubt we would pass the standard passage to Linux as a bloblist. I
>> >> imagine something like this. The bloblist sits in memory with some
>> >> things in it, including a devicetree, perhaps an SMBIOS table and a
>> >> TPM log. But when U-Boot calls Linux it puts the address/size of those
>> >> individual things in the devicetree. They don't move and are still
>> >> contiguous in memory, but the bloblist around them is forgotten. Linux
>> >> doesn't know that the three separate things it is picking up are
>> >> actually part of a bloblist structure, since it doesn't care about
>> >> that. Even a console log could work the same way. That way we don't
>> >> end up trying to teach Linux about bloblist when it already has a
>> >> perfectly good means to accept these items.
>> >>
>> >> For ACPI I see things a similar way. The ACPI tables can point to
>> >> things that *happen* to be in a bloblist, but without any knowledge of
>> >> that needed in Linux, grub, etc.
>> >>
>> >> >>
>> >> >> As you know I have more expansive views about what should be in DT.
>> >> >
>> >> > I think both of us are huge supporters of DT format and self describing capabilities.
>> >> > I am inclined to put rules into what fits into what lands in the DT that is passed to the OS.
>> >> > I am a fan of having DT used more in ad-hoc files.
>> >>
>> >> Me too.
>> >>
>> >> >>
>> >> >> >
>> >> >> > Cheers
>> >> >> >
>> >> >> > PS: as Ilias mentions, this patch set contains bug fixes, non immediately related additional functions (DM stats). It would be great to carve those out to fast path them and keep this one with the very core of your idea.
>> >> >>
>> >> >> The DM stats is used in 'passage: Report the devicetree source'. I
>> >> >> know it is sideways but I think it is better to make the output line
>> >> >> more useful than just reporting the devicetree source.
>> >> >>
>> >> > I believe the DM stats has merits in its own. You could upstream this independently and then Passage would be yet another "customer" of the feature.
>> >>
>> >> I could, but it would just be a debug feature so people might not
>> >> think it worth the code space. With the devicetree source it is more
>> >> compelling.
>> >>
>> >> >>
>> >> >> The first patch is indeed unrelated. I will pick it up so we can drop
>> >> >> it for the next rev.
>> >> >>
>> >> [..]
>> >>
>> >> Regards,
>> >> Simon
>> >
>> >
>> >
>> > --
>> > François-Frédéric Ozog | Director Business Development
>> > T: +33.67221.6485
>> > francois.ozog@linaro.org | Skype: ffozog
>> >
>
> --
> François-Frédéric Ozog | Director Business Development
> T: +33.67221.6485
> francois.ozog@linaro.org | Skype: ffozog
>
François Ozog Nov. 8, 2021, 4:20 p.m. UTC | #11
On Fri, 5 Nov 2021 at 18:17, Simon Glass <sjg@chromium.org> wrote:

> ) to signal Hi François,
>
> On Fri, 5 Nov 2021 at 10:31, François Ozog <francois.ozog@linaro.org>
> wrote:
> >
> > Hi Simon,
> >
> > Le ven. 5 nov. 2021 à 17:12, Simon Glass <sjg@chromium.org> a écrit :
> >>
> >> Hi François,
> >>
> >> On Fri, 5 Nov 2021 at 02:27, François Ozog <francois.ozog@linaro.org>
> wrote:
> >> >
> >> >
> >> >
> >> > On Fri, 5 Nov 2021 at 03:02, Simon Glass <sjg@chromium.org> wrote:
> >> >>
> >> >> Hi François,
> >> >>
> >> >> On Tue, 2 Nov 2021 at 10:03, François Ozog <francois.ozog@linaro.org>
> wrote:
> >> >> >
> >> >> > Hi Simon,
> >> >> >
> >> >> > On Tue, 2 Nov 2021 at 15:59, Simon Glass <sjg@chromium.org> wrote:
> >> >> >>
> >> >> >> Hi François,
> >> >> >>
> >> >> >> On Mon, 1 Nov 2021 at 02:53, François Ozog <
> francois.ozog@linaro.org> wrote:
> >> >> >> >
> >> >> >> > Hi Simon,
> >> >> >> >
> >> >> >> > this seems a great endeavor. I'd like to better understand the
> scope of it.
> >> >> >> >
> >> >> >> > Is it to be used as part of what could become a U-Boot entry
> ABI scheme? By that I mean giving some fixed aspects
> >> >> >> > to U-Boot entry while letting boards to have flexibility (say
> for instance that the first 5 architecture ABI
> >> >> >> > parameter registers are reserved for U-Boot), and the Passage
> is about specifying either those reserved registers
> >> >> >> > or one of them?
> >> >> >>
> >> >> >> The goal is to provide a standard entry scheme for all firmware
> >> >> >> binaries. Whether it achieves that (or can with some mods) is up
> for
> >> >> >> discussion.
> >> >> >>
> >> >> > If you say
> >> >> > a) define a U-Boot entry ABI and providing a firmware-to-firmware
> information passing facility which would be part of all firmware ABIs (as
> the projects decide to define their own ABI) it looks good.
> >> >> > but If you say
> >> >>
> >> >> It is an ABI to be adopted by U-Boot but also other firmware. For
> >> >> example, if TF-A calls U-Boot it should use standard passage. If
> >> >> U-Boot calls TF-A or Optee it should use standard passage.
> >> >>
> >> >> > b) define a standard entry scheme (register map, processor state,
> MMU state, SMMU state, GIC state...) that does not look realistic.
> >> >>
> >> >> No I don't mean that. This data structure could be used in any state,
> >> >> so long as the two registers are set correctly.
> >> >>
> >> >> > I think you mean a) but just want to be sure.
> >> >>
> >> >> Yes I think so.
> >> >>
> >> >> >>
> >> >> >> Re the registers, do you think we need 5?
> >> >> >>
> >> >>
> >> >> I don't :-)
> >> >>
> >> >> >> >
> >> >> >> > Thinking entry ABI, here is what I observed on Arm:
> >> >> >> >
> >> >> >> > Linux has two entry ABIs:
> >> >> >> > - plain: x0 = dtb;
> >> >> >> >           command line = dtb:/chosen/bootargs; initrd =
> dtb:/chosen/linux,initrd-*
> >> >> >> > - EFI: x0=handle, x1=systemtable, x30=return address;
> >> >> >> >            dtb = EFI_UUID config table; initrd =
> efi:<loadfile2(INITRD vendor media UUID); command line = efi:
> image_protocol::load_options
> >> >> >> >
> >> >> >> > U-Boot (proper) has plenty of schemes:
> >> >> >> > - dtb is passed as either x0, x1, fixed memory area (Qemu which
> is bad in itself), or other registers
> >> >> >> > - additional information passing: board specific register
> scheme, SMC calls
> >> >> >> > - U-Boot for RPI boards implement a Linux shaped entry ABI to
> be launched by Videocore firmware
> >> >> >> >
> >> >> >> > Based on all the above, I would tend to think that RPI scheme
> is a good idea but also
> >> >> >> > shall not prevent additional schemes for the boards.
> >> >> >>
> >> >> >> I was not actually considering Linux since I believe/assume its
> entry
> >> >> >> scheme is fixed and not up for discussion.
> >> >> >>
> >> >> >> I also did not think about the EFI case. As I understand it we
> cannot
> >> >> >> touch it as it is used by UEFI today. Maybe it is even in the
> >> >> >> standard?
> >> >> >
> >> >> > It is in the spec and we are making it evolve, or its
> understanding evolve (jurisprudence) for instance on initrd standard
> handling.
> >> >>
> >> >> Well perhaps we could merge it with standard passage. But EFI is not
> >> >> going to want to use a bloblist, it will want to use a HOB.
> >> >>
> >> >> >>
> >> >> >>
> >> >> >> Really I am hoping we can start afresh...?
> >> >> >>
> >> >> >> >
> >> >> >> > What about a U-Boot Arm entry ABI like:
> >> >> >> > - plain: x0=dtb, x1=<Passage defined>, x2-x5 = <reserved>,
> other registers are per platform, SMC calls allowed too
> >> >> >>
> >> >> >> Hmm we don't actually need the dtb as it is available in the
> bloblist.
> >> >> >
> >> >> > If you don't have x0=dtb, then you will not be able to use U-Boot
> on RPI4.
> >> >> > Unless you want to redo everything the RPI firmware is doing.
> >> >>
> >> >> That's right, RPI cannot support standard passage. It is not
> >> >> open-source firmware so it isn't really relevant to this discussion.
> >> >> It will just do what it does and have limited functionality, with
> >> >> work-arounds to deal with the pain, as one might expect.
> >> >>
> >> > So you are seeing two "all-or-nothing" options:
> >> > <specific>: U-Boot entry is board specific as it is today
> >> > <purepassage>: A new form where the only parameter is a head of
> bloblist, one of those blobs contain a DT
> >> >  You propose to mandate a DT for all boards make sense in that
> environment.
> >> > For RPI4, you just ignore everything the prior boot loader does
> because it is not <passage> compliant.
> >>
> >> It's not that. It's just that it is closed-source, so not relevant to
> >> the discussion here. They could open-source it and then we could
> >> consider it, but it has been closed-source for years now, so why would
> >> we think that would happen?
> >>
> >> >
> >> > This reinforces my opposition to the mandatory DT proposal.
> >> >
> >> > a third option is I think way more attractive:
> >> > <optpassage>: shaped after the architecture Linux entry (ie. first
> parameter is dtb) [+ passage head (i.e. second parameter is pointer to
> passage head)]
> >> >
> >> > This way, you make U-Boot entry clean in RPI4, Apple M1, Qemu,
> SystemReady contexts
> >> > and get a well deserved standardized information passing between
> prior loaders and U-Boot.
> >> >
> >> > The three options are possible though, you could select a U-Boot
> entry CONFIG option for:
> >> > <specific>
> >> > <optpassage>
> >> > <purepassage>
> >> >
> >> > But despite it would be technically feasible, I don't think it is
> goes in the right direction.
> >>
> >> OK. Do you think we need a separate devicetree pointer, rather than
> >> forcing it to be inside the created bloblist?
> >>
> >> I'd like to understand what problem you are solving with this. I am
> >> trying to figure out a firmware-to-firmware mini-ABI (just a few
> >> register values) that can be used in open-source projects. The ABI is
> >> not intended to be used with Linux (I am unsure of the benefit it
> >> would give and whether it is feasible to change the current one).
> >>
> >> You are talking about the Linux entry mechanism. What relevance does
> >> that have for firmware?
> >>
> >> I understand that some projects already implement the Linux mechanism,
> >> but that is because they expect to jump straight to Linux, not have
> >> U-Boot in the path. So IMO standard passage offers no benefit to them.
> >>
> >> To address them in turn:
> >> - rpi4 - closed source, who cares?
> >> - Apple M1 - we could probably expand it to pass a bloblist, but it
> >> would be confusing unless we share registers, as you suggest
> >> - Qemu - I already tried to update that and got pushback...do you
> >> really think those guys are going to want to add a bloblist? So again,
> >> who cares?
> >> - SystemReady - not sure what this means in practice, but it would be
> >> good if SystemReady could use standard passage
> >>
> >> So let's say we have an optional standard-passage thing and we use
> >> registers such that it is similar to Linux and EFI and just expands on
> >> them.
> >>
> >> The first problem is that Linux and EFI seem to be completely
> >> incompatible. Can that be changed, perhaps on the EFI side? If not,
> >> we need two separate protocols.
> >>
> >> I'll ignore EFI for now. So we might have:
> >>
> >> r0 = 0
> >> r1 = machine number (0?)
> >> r2 = dtb pointer
> >> r3 = bloblist pointer, 0 if missing
> >> r14 = return address
> >>
> >> or
> >>
> >> x0 = dtb
> >> x1 = bloblist pointer, 0 if missing
> >> x30 = return address
> >
> > That’s essentially what I proposed!
> > you do not force the DTB to be found in the bloblist, and shape the
> U-Boot entry after the Linux entry ABI. Good !
> > I was saving a few registers for future ABI evolution so that boards can
> be guaranteed to have their board specific registers properly protected.
> The 5 registers, leaving 3 undefined was just « why not ». We could also
> have a cookie in x1: high 48 bits magic low 16 ABI version, x2=bloblist
> pointer.
>
> Isn't 32 bits enough for a magic value?
>
> Also x3 might be nicer, to match ARM 32-bit, so:
>
> x0 = dtb
> x1 = ABI indicator bits 63:32 0xb00757a3, bits 31:1 = 0, bit 0 = 1
> (version 1) ? We don't need to decide how many bits for the version
> right now. Perhaps 8 is plenty
> x2 = 0
> x3 = bloblist pointer, 0 if missing
> x4 = 0
> x30 = return address
>
> sounds usable. Need more comments on this.


> For ARM:
>
> r0 = 0
> r1 = machine number (0xb00757xx to signal standard passage where xx is
> the ABI version?)*
> r2 = dtb pointer
> r3 = bloblist pointer (if r1 is 0xb00757xx), else 0
> r4 = 0
> r14 = return address
>
> * might be safe, looking at
>
> https://elixir.bootlin.com/linux/latest/source/arch/arm/kernel/setup.c#L1094
>
> Indeed. Need more comments on this.



> >
> >>
> >> For EFI, we could add a blob to the bloblist containing the system
> >> table and handle, perhaps? Otherwise:
> >>
> >> x2 - efi handle
> >> x3 - system table
> >>
> >> Is that along the lines of what you are thinking?
> >
> > No, efi entry is only x0=efi handle, x1=system table . I was trying to
> find a way to have passage when U-Boot is loaded as a UEFI app (your other
> patch set to make U-Boot a more integrated UEFi app). Let’s say that a
> U-Boot aware DXE driver/protocol actually populate such a table, it could
> be a communication channel between that driver and U-Boot.
>
> OK, I figured, so how about, for EFI on 64-bit:
>
> x0 = handle
> x1 = systable
> x2 = ABI indicator bits 63:32 0xb00757a3, bits 31:1 = 0, bit 0 = 1
> (version 1)
> x3 = bloblist pointer
> x4 = 0
> x30 = return address
>
> EFI 32-bit:
>
> r0 = handle
> r1 = systable
> r2 = 0xb00757a3
> r3 = bloblist pointer
> r4 = 0
> r14 = return address
>
> Let's be clear that this is for an existing UEFI implementation to boot
U-Boot.
If the implementation cannot be changed to add the information, a UEFI
driver or protocol may be used.
Could SPL may be tweaked to craft the bloblist based on whatever
information I that case?

(side comment: LinuxBoot has developed techniques to replace most of an
EDK2 implementation by Linux.
This entry ABI does not apply in this use case as it is defined by EDK2.)

Now on the how.

EFI API has already defined extension mechanism, so that may be difficult
to add.

let's put the bloblist pointer in a <configtable>:

 typedef struct {
1936  ///
1937  /// The 128-bit GUID value that uniquely identifies the system
configuration table.
1938  ///
1939
<https://dox.ipxe.org/structEFI__CONFIGURATION__TABLE.html#a50a67cc76cea0a08e7fcfc868ea8a02f>
  EFI_GUID <https://dox.ipxe.org/structGUID.html> VendorGuid
<https://dox.ipxe.org/structEFI__CONFIGURATION__TABLE.html#a50a67cc76cea0a08e7fcfc868ea8a02f>;
/* set to BLOB_LIST_GUID */
1940  ///
1941  /// A pointer to the table associated with VendorGuid.
1942  ///
1943
<https://dox.ipxe.org/structEFI__CONFIGURATION__TABLE.html#a1acfe9c046bb4d3a1e7d0e3c7c06f11b>
  VOID <https://dox.ipxe.org/Base_8h.html#a7f319bfc2492a2136964194204e7a8cf>
*VendorTable
<https://dox.ipxe.org/structEFI__CONFIGURATION__TABLE.html#a1acfe9c046bb4d3a1e7d0e3c7c06f11b>;
/* bloblist pointer */
1944 } EFI_CONFIGURATION_TABLE
<https://dox.ipxe.org/structEFI__CONFIGURATION__TABLE.html>;

U-Boot or a driver or a protocol can set the VendorTable to bloblist
pointer and add this to the list of configuration tables via
https://edk2-docs.gitbook.io/edk-ii-uefi-driver-writer-s-guide/5_uefi_services/readme.2/5210_installconfigurationtable

The blobs should be already accounted for in the memory map as they were
pre-allocated before U-Boot entry. But that may be a topic to be checked.


Regards,
> Simon
>
> >>
> >>
> >> But still, please respond above so I can understand what problem you
> >> are worried about.
> >>
> >> Regards,
> >> Simon
> >>
> >>
> >> >
> >> >> >>
> >> >> >> But I added an offset to it as a convenience.
> >> >> >>
> >> >> >> > - EFI: x0=handle, x1=systemtable, x30=return address;  (when
> U-Boot is launched as an EFI app)
> >> >> >> >        dtb = EFI_UUID config table, + Passage = Passage UUID
> config table
> >> >> >>
> >> >> >> I don't understand the last line. Where is the passage info /
> >> >> >> bloblist? Do you mean it goes in the HOB list with a UUID? I
> suppose
> >> >> >> that is the most EFI-compatible way.
> >> >> >
> >> >> > The Passage config table  could just contain the "head" of the
> bloblist/Passage information.
> >> >>
> >> >> If UEFI wants to deal with standard passage, that is...
> >> >>
> >> >> >>
> >> >> >>
> >> >> >> What do you think about the idea of using an offset into the
> bloblist
> >> >> >> for the dtb?
> >> >> >
> >> >> > It is possible but as I said, failing to mimic Linux entry ABI
> would miss the opportunity to just boot without changes on RPI4.
> >> >>
> >> >> See above. Broadcom could look at open-sourcing their bootloader if
> they wish.
> >> >>
> >> >> >>
> >> >> >> Also, can we make the standard passage ABI a build-time
> >> >> >> option, so it is deterministic?
> >> >> >>
> >> >> > Looks good. I would look into stating that for SystemReady we
> would advise to use that option and make it standard for Trusted Substrate
> (Linaro recipes that we upstreaming to make SystemReady compliance easy and
> consistent across platforms).
> >> >>
> >> >> OK. I mean that if the option is enabled, then standard passage must
> >> >> be provided / emitted or things won't work. If the option is
> disabled,
> >> >> then standard passage is not used. In other words, we are looking for
> >> >> magic values in registers, etc, just enabling/disabling it at
> >> >> build-time.
> >> >>
> >> >> >>
> >> >> >> >
> >> >> >> > We could further leverage Passage to pass Operating Systems
> parameters that could be removed from device tree (migration of /chosen to
> Passage). Memory inventory would still be in DT but allocations for CMA or
> GPUs would be in Passage. This idea is to reach a point where  device tree
> is a "pristine" hardware description.
> >> >> >>
> >> >> >> I'm worried about this becoming a substitute for devicetree.
> Really my
> >> >> >> intent is to provide a way to pass simple info, whereas what you
> talk
> >> >> >> about there seems like something that should be DT, just that it
> might
> >> >> >> need suitable bindings.
> >> >> >>
> >> >> > I see your point and I agree It should not be a substitute.
> >> >> > here is an expanded version of what I had in mind when I wrote
> those lines.
> >> >> > cma, initrd and other Linux kernel parameters can be conveyed
> either through command line or DT.
> >> >> > When using the non UEFI Linux entry ABI, you need to use the DT to
> pass those parameters.
> >> >> > When using the UEFI Linux entry ABI, you *can* (not must) use the
> command line to pass all information, leaving the DT passed to the OS
> without any /chosen.
> >> >> > When introducing Passage, I was wondering if we could pass command
> line to Linux and, same as UEFI, leave the DT free from /chosen.
> >> >> > I am not sure it is a good goal though. I may be too pushing for a
> DT free from parameters.
> >> >>
> >> >> We could. Are there benefits to that?
> >> >>
> >> >> I doubt we would pass the standard passage to Linux as a bloblist. I
> >> >> imagine something like this. The bloblist sits in memory with some
> >> >> things in it, including a devicetree, perhaps an SMBIOS table and a
> >> >> TPM log. But when U-Boot calls Linux it puts the address/size of
> those
> >> >> individual things in the devicetree. They don't move and are still
> >> >> contiguous in memory, but the bloblist around them is forgotten.
> Linux
> >> >> doesn't know that the three separate things it is picking up are
> >> >> actually part of a bloblist structure, since it doesn't care about
> >> >> that. Even a console log could work the same way. That way we don't
> >> >> end up trying to teach Linux about bloblist when it already has a
> >> >> perfectly good means to accept these items.
> >> >>
> >> >> For ACPI I see things a similar way. The ACPI tables can point to
> >> >> things that *happen* to be in a bloblist, but without any knowledge
> of
> >> >> that needed in Linux, grub, etc.
> >> >>
> >> >> >>
> >> >> >> As you know I have more expansive views about what should be in
> DT.
> >> >> >
> >> >> > I think both of us are huge supporters of DT format and self
> describing capabilities.
> >> >> > I am inclined to put rules into what fits into what lands in the
> DT that is passed to the OS.
> >> >> > I am a fan of having DT used more in ad-hoc files.
> >> >>
> >> >> Me too.
> >> >>
> >> >> >>
> >> >> >> >
> >> >> >> > Cheers
> >> >> >> >
> >> >> >> > PS: as Ilias mentions, this patch set contains bug fixes, non
> immediately related additional functions (DM stats). It would be great to
> carve those out to fast path them and keep this one with the very core of
> your idea.
> >> >> >>
> >> >> >> The DM stats is used in 'passage: Report the devicetree source'. I
> >> >> >> know it is sideways but I think it is better to make the output
> line
> >> >> >> more useful than just reporting the devicetree source.
> >> >> >>
> >> >> > I believe the DM stats has merits in its own. You could upstream
> this independently and then Passage would be yet another "customer" of the
> feature.
> >> >>
> >> >> I could, but it would just be a debug feature so people might not
> >> >> think it worth the code space. With the devicetree source it is more
> >> >> compelling.
> >> >>
> >> >> >>
> >> >> >> The first patch is indeed unrelated. I will pick it up so we can
> drop
> >> >> >> it for the next rev.
> >> >> >>
> >> >> [..]
> >> >>
> >> >> Regards,
> >> >> Simon
> >> >
> >> >
> >> >
> >> > --
> >> > François-Frédéric Ozog | Director Business Development
> >> > T: +33.67221.6485
> >> > francois.ozog@linaro.org | Skype: ffozog
> >> >
> >
> > --
> > François-Frédéric Ozog | Director Business Development
> > T: +33.67221.6485
> > francois.ozog@linaro.org | Skype: ffozog
> >
>
Simon Glass Nov. 10, 2021, 7:37 p.m. UTC | #12
Hi François,

On Mon, 8 Nov 2021 at 09:20, François Ozog <francois.ozog@linaro.org> wrote:
>
>
>
> On Fri, 5 Nov 2021 at 18:17, Simon Glass <sjg@chromium.org> wrote:
>>
>> ) to signal Hi François,
>>
>> On Fri, 5 Nov 2021 at 10:31, François Ozog <francois.ozog@linaro.org> wrote:
>> >
>> > Hi Simon,
>> >
>> > Le ven. 5 nov. 2021 à 17:12, Simon Glass <sjg@chromium.org> a écrit :
>> >>
>> >> Hi François,
>> >>
>> >> On Fri, 5 Nov 2021 at 02:27, François Ozog <francois.ozog@linaro.org> wrote:
>> >> >
>> >> >
>> >> >
>> >> > On Fri, 5 Nov 2021 at 03:02, Simon Glass <sjg@chromium.org> wrote:
>> >> >>
>> >> >> Hi François,
>> >> >>
>> >> >> On Tue, 2 Nov 2021 at 10:03, François Ozog <francois.ozog@linaro.org> wrote:
>> >> >> >
>> >> >> > Hi Simon,
>> >> >> >
>> >> >> > On Tue, 2 Nov 2021 at 15:59, Simon Glass <sjg@chromium.org> wrote:
>> >> >> >>
>> >> >> >> Hi François,
>> >> >> >>
>> >> >> >> On Mon, 1 Nov 2021 at 02:53, François Ozog <francois.ozog@linaro.org> wrote:
>> >> >> >> >
>> >> >> >> > Hi Simon,
>> >> >> >> >
>> >> >> >> > this seems a great endeavor. I'd like to better understand the scope of it.
>> >> >> >> >
>> >> >> >> > Is it to be used as part of what could become a U-Boot entry ABI scheme? By that I mean giving some fixed aspects
>> >> >> >> > to U-Boot entry while letting boards to have flexibility (say for instance that the first 5 architecture ABI
>> >> >> >> > parameter registers are reserved for U-Boot), and the Passage is about specifying either those reserved registers
>> >> >> >> > or one of them?
>> >> >> >>
>> >> >> >> The goal is to provide a standard entry scheme for all firmware
>> >> >> >> binaries. Whether it achieves that (or can with some mods) is up for
>> >> >> >> discussion.
>> >> >> >>
>> >> >> > If you say
>> >> >> > a) define a U-Boot entry ABI and providing a firmware-to-firmware information passing facility which would be part of all firmware ABIs (as the projects decide to define their own ABI) it looks good.
>> >> >> > but If you say
>> >> >>
>> >> >> It is an ABI to be adopted by U-Boot but also other firmware. For
>> >> >> example, if TF-A calls U-Boot it should use standard passage. If
>> >> >> U-Boot calls TF-A or Optee it should use standard passage.
>> >> >>
>> >> >> > b) define a standard entry scheme (register map, processor state, MMU state, SMMU state, GIC state...) that does not look realistic.
>> >> >>
>> >> >> No I don't mean that. This data structure could be used in any state,
>> >> >> so long as the two registers are set correctly.
>> >> >>
>> >> >> > I think you mean a) but just want to be sure.
>> >> >>
>> >> >> Yes I think so.
>> >> >>
>> >> >> >>
>> >> >> >> Re the registers, do you think we need 5?
>> >> >> >>
>> >> >>
>> >> >> I don't :-)
>> >> >>
>> >> >> >> >
>> >> >> >> > Thinking entry ABI, here is what I observed on Arm:
>> >> >> >> >
>> >> >> >> > Linux has two entry ABIs:
>> >> >> >> > - plain: x0 = dtb;
>> >> >> >> >           command line = dtb:/chosen/bootargs; initrd = dtb:/chosen/linux,initrd-*
>> >> >> >> > - EFI: x0=handle, x1=systemtable, x30=return address;
>> >> >> >> >            dtb = EFI_UUID config table; initrd = efi:<loadfile2(INITRD vendor media UUID); command line = efi: image_protocol::load_options
>> >> >> >> >
>> >> >> >> > U-Boot (proper) has plenty of schemes:
>> >> >> >> > - dtb is passed as either x0, x1, fixed memory area (Qemu which is bad in itself), or other registers
>> >> >> >> > - additional information passing: board specific register scheme, SMC calls
>> >> >> >> > - U-Boot for RPI boards implement a Linux shaped entry ABI to be launched by Videocore firmware
>> >> >> >> >
>> >> >> >> > Based on all the above, I would tend to think that RPI scheme is a good idea but also
>> >> >> >> > shall not prevent additional schemes for the boards.
>> >> >> >>
>> >> >> >> I was not actually considering Linux since I believe/assume its entry
>> >> >> >> scheme is fixed and not up for discussion.
>> >> >> >>
>> >> >> >> I also did not think about the EFI case. As I understand it we cannot
>> >> >> >> touch it as it is used by UEFI today. Maybe it is even in the
>> >> >> >> standard?
>> >> >> >
>> >> >> > It is in the spec and we are making it evolve, or its understanding evolve (jurisprudence) for instance on initrd standard handling.
>> >> >>
>> >> >> Well perhaps we could merge it with standard passage. But EFI is not
>> >> >> going to want to use a bloblist, it will want to use a HOB.
>> >> >>
>> >> >> >>
>> >> >> >>
>> >> >> >> Really I am hoping we can start afresh...?
>> >> >> >>
>> >> >> >> >
>> >> >> >> > What about a U-Boot Arm entry ABI like:
>> >> >> >> > - plain: x0=dtb, x1=<Passage defined>, x2-x5 = <reserved>, other registers are per platform, SMC calls allowed too
>> >> >> >>
>> >> >> >> Hmm we don't actually need the dtb as it is available in the bloblist.
>> >> >> >
>> >> >> > If you don't have x0=dtb, then you will not be able to use U-Boot on RPI4.
>> >> >> > Unless you want to redo everything the RPI firmware is doing.
>> >> >>
>> >> >> That's right, RPI cannot support standard passage. It is not
>> >> >> open-source firmware so it isn't really relevant to this discussion.
>> >> >> It will just do what it does and have limited functionality, with
>> >> >> work-arounds to deal with the pain, as one might expect.
>> >> >>
>> >> > So you are seeing two "all-or-nothing" options:
>> >> > <specific>: U-Boot entry is board specific as it is today
>> >> > <purepassage>: A new form where the only parameter is a head of bloblist, one of those blobs contain a DT
>> >> >  You propose to mandate a DT for all boards make sense in that environment.
>> >> > For RPI4, you just ignore everything the prior boot loader does because it is not <passage> compliant.
>> >>
>> >> It's not that. It's just that it is closed-source, so not relevant to
>> >> the discussion here. They could open-source it and then we could
>> >> consider it, but it has been closed-source for years now, so why would
>> >> we think that would happen?
>> >>
>> >> >
>> >> > This reinforces my opposition to the mandatory DT proposal.
>> >> >
>> >> > a third option is I think way more attractive:
>> >> > <optpassage>: shaped after the architecture Linux entry (ie. first parameter is dtb) [+ passage head (i.e. second parameter is pointer to passage head)]
>> >> >
>> >> > This way, you make U-Boot entry clean in RPI4, Apple M1, Qemu, SystemReady contexts
>> >> > and get a well deserved standardized information passing between prior loaders and U-Boot.
>> >> >
>> >> > The three options are possible though, you could select a U-Boot entry CONFIG option for:
>> >> > <specific>
>> >> > <optpassage>
>> >> > <purepassage>
>> >> >
>> >> > But despite it would be technically feasible, I don't think it is goes in the right direction.
>> >>
>> >> OK. Do you think we need a separate devicetree pointer, rather than
>> >> forcing it to be inside the created bloblist?
>> >>
>> >> I'd like to understand what problem you are solving with this. I am
>> >> trying to figure out a firmware-to-firmware mini-ABI (just a few
>> >> register values) that can be used in open-source projects. The ABI is
>> >> not intended to be used with Linux (I am unsure of the benefit it
>> >> would give and whether it is feasible to change the current one).
>> >>
>> >> You are talking about the Linux entry mechanism. What relevance does
>> >> that have for firmware?
>> >>
>> >> I understand that some projects already implement the Linux mechanism,
>> >> but that is because they expect to jump straight to Linux, not have
>> >> U-Boot in the path. So IMO standard passage offers no benefit to them.
>> >>
>> >> To address them in turn:
>> >> - rpi4 - closed source, who cares?
>> >> - Apple M1 - we could probably expand it to pass a bloblist, but it
>> >> would be confusing unless we share registers, as you suggest
>> >> - Qemu - I already tried to update that and got pushback...do you
>> >> really think those guys are going to want to add a bloblist? So again,
>> >> who cares?
>> >> - SystemReady - not sure what this means in practice, but it would be
>> >> good if SystemReady could use standard passage
>> >>
>> >> So let's say we have an optional standard-passage thing and we use
>> >> registers such that it is similar to Linux and EFI and just expands on
>> >> them.
>> >>
>> >> The first problem is that Linux and EFI seem to be completely
>> >> incompatible. Can that be changed, perhaps on the EFI side? If not,
>> >> we need two separate protocols.
>> >>
>> >> I'll ignore EFI for now. So we might have:
>> >>
>> >> r0 = 0
>> >> r1 = machine number (0?)
>> >> r2 = dtb pointer
>> >> r3 = bloblist pointer, 0 if missing
>> >> r14 = return address
>> >>
>> >> or
>> >>
>> >> x0 = dtb
>> >> x1 = bloblist pointer, 0 if missing
>> >> x30 = return address
>> >
>> > That’s essentially what I proposed!
>> > you do not force the DTB to be found in the bloblist, and shape the U-Boot entry after the Linux entry ABI. Good !
>> > I was saving a few registers for future ABI evolution so that boards can be guaranteed to have their board specific registers properly protected. The 5 registers, leaving 3 undefined was just « why not ». We could also have a cookie in x1: high 48 bits magic low 16 ABI version, x2=bloblist pointer.
>>
>> Isn't 32 bits enough for a magic value?
>>
>> Also x3 might be nicer, to match ARM 32-bit, so:
>>
>> x0 = dtb
>> x1 = ABI indicator bits 63:32 0xb00757a3, bits 31:1 = 0, bit 0 = 1
>> (version 1) ? We don't need to decide how many bits for the version
>> right now. Perhaps 8 is plenty
>> x2 = 0
>> x3 = bloblist pointer, 0 if missing
>> x4 = 0
>> x30 = return address
>>
> sounds usable. Need more comments on this.
>
>>
>> For ARM:
>>
>> r0 = 0
>> r1 = machine number (0xb00757xx to signal standard passage where xx is
>> the ABI version?)*
>> r2 = dtb pointer
>> r3 = bloblist pointer (if r1 is 0xb00757xx), else 0
>> r4 = 0
>> r14 = return address
>>
>> * might be safe, looking at
>> https://elixir.bootlin.com/linux/latest/source/arch/arm/kernel/setup.c#L1094
>>
> Indeed. Need more comments on this.
>
>
>>
>> >
>> >>
>> >> For EFI, we could add a blob to the bloblist containing the system
>> >> table and handle, perhaps? Otherwise:
>> >>
>> >> x2 - efi handle
>> >> x3 - system table
>> >>
>> >> Is that along the lines of what you are thinking?
>> >
>> > No, efi entry is only x0=efi handle, x1=system table . I was trying to find a way to have passage when U-Boot is loaded as a UEFI app (your other patch set to make U-Boot a more integrated UEFi app). Let’s say that a U-Boot aware DXE driver/protocol actually populate such a table, it could be a communication channel between that driver and U-Boot.
>>
>> OK, I figured, so how about, for EFI on 64-bit:
>>
>> x0 = handle
>> x1 = systable
>> x2 = ABI indicator bits 63:32 0xb00757a3, bits 31:1 = 0, bit 0 = 1 (version 1)
>> x3 = bloblist pointer
>> x4 = 0
>> x30 = return address
>>
>> EFI 32-bit:
>>
>> r0 = handle
>> r1 = systable
>> r2 = 0xb00757a3
>> r3 = bloblist pointer
>> r4 = 0
>> r14 = return address
>>
> Let's be clear that this is for an existing UEFI implementation to boot U-Boot.
> If the implementation cannot be changed to add the information, a UEFI driver or protocol may be used.
> Could SPL may be tweaked to craft the bloblist based on whatever information I that case?

Yes that is easy enough, but then how does SPL load U-Boot? UEFI
requires an efl file and we don't want to put the EFI app into SPL, I
think.

>
> (side comment: LinuxBoot has developed techniques to replace most of an EDK2 implementation by Linux.
> This entry ABI does not apply in this use case as it is defined by EDK2.)
>
> Now on the how.
>
> EFI API has already defined extension mechanism, so that may be difficult to add.
>
> let's put the bloblist pointer in a <configtable>:
>
>  typedef struct {
> 1936  ///
> 1937  /// The 128-bit GUID value that uniquely identifies the system configuration table.
> 1938  ///
> 1939  EFI_GUID VendorGuid; /* set to BLOB_LIST_GUID */
> 1940  ///
> 1941  /// A pointer to the table associated with VendorGuid.
> 1942  ///
> 1943  VOID *VendorTable; /* bloblist pointer */
> 1944 } EFI_CONFIGURATION_TABLE;
>
> U-Boot or a driver or a protocol can set the VendorTable to bloblist pointer and add this to the list of configuration tables via
> https://edk2-docs.gitbook.io/edk-ii-uefi-driver-writer-s-guide/5_uefi_services/readme.2/5210_installconfigurationtable
>
> The blobs should be already accounted for in the memory map as they were pre-allocated before U-Boot entry. But that may be a topic to be checked.

OK, well in that case I suppose we don't need to define it here? Or
are you saying that we should define this as an alternative way to get
the bloblist?

Everything we define, we need tests for, so I want to make sure only
useful cases are included.

Regards,
Simon


>
>
>> Regards,
>> Simon
>>
>> >>
>> >>
>> >> But still, please respond above so I can understand what problem you
>> >> are worried about.
>> >>
>> >> Regards,
>> >> Simon
>> >>
>> >>
>> >> >
>> >> >> >>
>> >> >> >> But I added an offset to it as a convenience.
>> >> >> >>
>> >> >> >> > - EFI: x0=handle, x1=systemtable, x30=return address;  (when U-Boot is launched as an EFI app)
>> >> >> >> >        dtb = EFI_UUID config table, + Passage = Passage UUID config table
>> >> >> >>
>> >> >> >> I don't understand the last line. Where is the passage info /
>> >> >> >> bloblist? Do you mean it goes in the HOB list with a UUID? I suppose
>> >> >> >> that is the most EFI-compatible way.
>> >> >> >
>> >> >> > The Passage config table  could just contain the "head" of the bloblist/Passage information.
>> >> >>
>> >> >> If UEFI wants to deal with standard passage, that is...
>> >> >>
>> >> >> >>
>> >> >> >>
>> >> >> >> What do you think about the idea of using an offset into the bloblist
>> >> >> >> for the dtb?
>> >> >> >
>> >> >> > It is possible but as I said, failing to mimic Linux entry ABI would miss the opportunity to just boot without changes on RPI4.
>> >> >>
>> >> >> See above. Broadcom could look at open-sourcing their bootloader if they wish.
>> >> >>
>> >> >> >>
>> >> >> >> Also, can we make the standard passage ABI a build-time
>> >> >> >> option, so it is deterministic?
>> >> >> >>
>> >> >> > Looks good. I would look into stating that for SystemReady we would advise to use that option and make it standard for Trusted Substrate (Linaro recipes that we upstreaming to make SystemReady compliance easy and consistent across platforms).
>> >> >>
>> >> >> OK. I mean that if the option is enabled, then standard passage must
>> >> >> be provided / emitted or things won't work. If the option is disabled,
>> >> >> then standard passage is not used. In other words, we are looking for
>> >> >> magic values in registers, etc, just enabling/disabling it at
>> >> >> build-time.
>> >> >>
>> >> >> >>
>> >> >> >> >
>> >> >> >> > We could further leverage Passage to pass Operating Systems parameters that could be removed from device tree (migration of /chosen to Passage). Memory inventory would still be in DT but allocations for CMA or GPUs would be in Passage. This idea is to reach a point where  device tree is a "pristine" hardware description.
>> >> >> >>
>> >> >> >> I'm worried about this becoming a substitute for devicetree. Really my
>> >> >> >> intent is to provide a way to pass simple info, whereas what you talk
>> >> >> >> about there seems like something that should be DT, just that it might
>> >> >> >> need suitable bindings.
>> >> >> >>
>> >> >> > I see your point and I agree It should not be a substitute.
>> >> >> > here is an expanded version of what I had in mind when I wrote those lines.
>> >> >> > cma, initrd and other Linux kernel parameters can be conveyed either through command line or DT.
>> >> >> > When using the non UEFI Linux entry ABI, you need to use the DT to pass those parameters.
>> >> >> > When using the UEFI Linux entry ABI, you *can* (not must) use the command line to pass all information, leaving the DT passed to the OS without any /chosen.
>> >> >> > When introducing Passage, I was wondering if we could pass command line to Linux and, same as UEFI, leave the DT free from /chosen.
>> >> >> > I am not sure it is a good goal though. I may be too pushing for a DT free from parameters.
>> >> >>
>> >> >> We could. Are there benefits to that?
>> >> >>
>> >> >> I doubt we would pass the standard passage to Linux as a bloblist. I
>> >> >> imagine something like this. The bloblist sits in memory with some
>> >> >> things in it, including a devicetree, perhaps an SMBIOS table and a
>> >> >> TPM log. But when U-Boot calls Linux it puts the address/size of those
>> >> >> individual things in the devicetree. They don't move and are still
>> >> >> contiguous in memory, but the bloblist around them is forgotten. Linux
>> >> >> doesn't know that the three separate things it is picking up are
>> >> >> actually part of a bloblist structure, since it doesn't care about
>> >> >> that. Even a console log could work the same way. That way we don't
>> >> >> end up trying to teach Linux about bloblist when it already has a
>> >> >> perfectly good means to accept these items.
>> >> >>
>> >> >> For ACPI I see things a similar way. The ACPI tables can point to
>> >> >> things that *happen* to be in a bloblist, but without any knowledge of
>> >> >> that needed in Linux, grub, etc.
>> >> >>
>> >> >> >>
>> >> >> >> As you know I have more expansive views about what should be in DT.
>> >> >> >
>> >> >> > I think both of us are huge supporters of DT format and self describing capabilities.
>> >> >> > I am inclined to put rules into what fits into what lands in the DT that is passed to the OS.
>> >> >> > I am a fan of having DT used more in ad-hoc files.
>> >> >>
>> >> >> Me too.
>> >> >>
>> >> >> >>
>> >> >> >> >
>> >> >> >> > Cheers
>> >> >> >> >
>> >> >> >> > PS: as Ilias mentions, this patch set contains bug fixes, non immediately related additional functions (DM stats). It would be great to carve those out to fast path them and keep this one with the very core of your idea.
>> >> >> >>
>> >> >> >> The DM stats is used in 'passage: Report the devicetree source'. I
>> >> >> >> know it is sideways but I think it is better to make the output line
>> >> >> >> more useful than just reporting the devicetree source.
>> >> >> >>
>> >> >> > I believe the DM stats has merits in its own. You could upstream this independently and then Passage would be yet another "customer" of the feature.
>> >> >>
>> >> >> I could, but it would just be a debug feature so people might not
>> >> >> think it worth the code space. With the devicetree source it is more
>> >> >> compelling.
>> >> >>
>> >> >> >>
>> >> >> >> The first patch is indeed unrelated. I will pick it up so we can drop
>> >> >> >> it for the next rev.
>> >> >> >>
>> >> >> [..]
>> >> >>
>> >> >> Regards,
>> >> >> Simon
>> >> >
>> >> >
>> >> >
>> >> > --
>> >> > François-Frédéric Ozog | Director Business Development
>> >> > T: +33.67221.6485
>> >> > francois.ozog@linaro.org | Skype: ffozog
>> >> >
>> >
>> > --
>> > François-Frédéric Ozog | Director Business Development
>> > T: +33.67221.6485
>> > francois.ozog@linaro.org | Skype: ffozog
>> >
>
>
>
> --
> François-Frédéric Ozog | Director Business Development
> T: +33.67221.6485
> francois.ozog@linaro.org | Skype: ffozog
>