* [PATCH v2] emulation: fdt: Allow using U-Boot's device tree with QEMU
@ 2025-04-05 19:07 Simon Glass
2025-04-14 22:53 ` Tom Rini
2025-04-16 5:33 ` Heinrich Schuchardt
0 siblings, 2 replies; 10+ messages in thread
From: Simon Glass @ 2025-04-05 19:07 UTC (permalink / raw)
To: U-Boot Mailing List
Cc: Peter Maydell, Ilias Apalodimas, Tom Rini, Andrew Phelps,
Simon Glass, Alexander Graf, Bin Meng, Caleb Connolly, Jan Kiszka,
Jerry Van Baren, Jiaxun Yang, Lukas Funke, Marek Vasut,
Max Filippov, Michal Simek, Oliver Gaskell, Patrick Rudolph,
Rayagonda Kokatanur, Robert Marko, Sumit Garg,
This contributor prefers not to receive mails, Tuomas Tynkkynen
At present it is impossible to change the qemu_arm64 defconfig to
obtain a devicetree from the U-Boot build.
This is necessary for FIT validation, for example, where the signature
node must be compiled into U-Boot.
A proposed change to QEMU to allow device tree additions has been
blocked for several years. The only known workaround is to use QEMU's
dumpdtb option, merge in the signature node manually, disable
OF_HAS_PRIOR_STAGE and then start QEMU with special arguments. This is
complicated enough that it is documented in U-Boot[1].
Unfortunately the only way to disable OF_HAS_PRIOR_STAGE at present is
to hack the Kconfig.
Add a new QEMU_MANUAL_DTB Kconfig option which makes OF_HAS_PRIOR_STAGE
optional, thus avoiding needing to patch U-Boot to get this working.
This seems a clearer solution than just making OF_HAS_PRIOR_STAGE
visible, since that symbol is intended to be set automatically by each
platform.
[1] https://docs.u-boot.org/en/latest/develop/devicetree/dt_qemu.html
Link: https://patchwork.kernel.org/project/qemu-devel/patch/20210926183410.256484-1-sjg@chromium.org/#24481799
Signed-off-by: Simon Glass <sjg@chromium.org>
Suggested-by: Tom Rini <trini@konsulko.com>
---
Changes in v2:
- Add a new QEMU-specific Kconfig instead
arch/arm/Kconfig | 2 +-
board/emulation/common/Kconfig | 12 ++++++++++++
doc/develop/devicetree/dt_qemu.rst | 5 +++++
dts/Kconfig | 9 +++++++--
4 files changed, 25 insertions(+), 3 deletions(-)
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index db8758e6dfe..b55ed61894a 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -1055,7 +1055,7 @@ config ARCH_QEMU
imply DM_RNG
imply DM_RTC
imply RTC_PL031
- imply OF_HAS_PRIOR_STAGE if !TARGET_QEMU_ARM_SBSA
+ imply OF_HAS_PRIOR_STAGE if !TARGET_QEMU_ARM_SBSA && !QEMU_MANUAL_DTB
imply VIDEO
imply VIDEO_BOCHS
imply SYS_WHITE_ON_BLACK
diff --git a/board/emulation/common/Kconfig b/board/emulation/common/Kconfig
index 4c15c8bcb89..3f9a6ea578f 100644
--- a/board/emulation/common/Kconfig
+++ b/board/emulation/common/Kconfig
@@ -13,3 +13,15 @@ config MTDPARTS_NOR1
help
This define the partition of nor1 used to build mtparts dynamically
for the u-boot env stored on nor1.
+
+config QEMU_MANUAL_DTB
+ bool "Manually provide a device tree to QEMU"
+ help
+ For some use cases, such as FIT validation where a public key must be
+ placed in U-Boot's device tree, we need to override the device tree
+ that QEMU would normally provide to us.
+
+ Note: this work-around is necessary since Linaro has blocked
+ addition of a feature to support additions to the QEMU devicetree:
+
+ Link: https://patchwork.kernel.org/project/qemu-devel/patch/20210926183410.256484-1-sjg@chromium.org/#24481799
diff --git a/doc/develop/devicetree/dt_qemu.rst b/doc/develop/devicetree/dt_qemu.rst
index 8ba2b225590..c693b49d3d4 100644
--- a/doc/develop/devicetree/dt_qemu.rst
+++ b/doc/develop/devicetree/dt_qemu.rst
@@ -46,3 +46,8 @@ You can then run qemu with the merged devicetree, e.g.::
Note that there seems to be a bug in some versions of qemu where the output of
dumpdtb does not quite match what is provided to U-Boot.
+
+See also the
+`rejected QEMU patch <https://patchwork.kernel.org/project/qemu-devel/patch/20231117021840.117874-1-sjg@chromium.org>`_
+and
+`discussion <https://patchwork.kernel.org/project/qemu-devel/patch/20210926183410.256484-1-sjg@chromium.org>`_.
diff --git a/dts/Kconfig b/dts/Kconfig
index 2e88d210bb8..53f7e246a80 100644
--- a/dts/Kconfig
+++ b/dts/Kconfig
@@ -205,8 +205,13 @@ config OF_HAS_PRIOR_STAGE
development purposes, but it is not recommended, and likely will not
even work, for production systems.
- Note: This option must be set in Kconfig and cannot be enabled or
- disabled in the board's defconfig file.
+ Note: This option can be disabled for QEMU usiing QEMU_MANUAL_DTB thus
+ allowing QEMU to support FIT validation, where the devicetree must
+ include a public key.
+
+ See also this for context:
+
+ https://patchwork.kernel.org/project/qemu-devel/patch/20210926183410.256484-1-sjg@chromium.org/#24481799
config OF_OMIT_DTB
bool "Omit the device tree output when building"
--
2.43.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH v2] emulation: fdt: Allow using U-Boot's device tree with QEMU
2025-04-05 19:07 [PATCH v2] emulation: fdt: Allow using U-Boot's device tree with QEMU Simon Glass
@ 2025-04-14 22:53 ` Tom Rini
2025-04-15 7:22 ` Ilias Apalodimas
2025-04-17 21:39 ` Simon Glass
2025-04-16 5:33 ` Heinrich Schuchardt
1 sibling, 2 replies; 10+ messages in thread
From: Tom Rini @ 2025-04-14 22:53 UTC (permalink / raw)
To: Simon Glass
Cc: U-Boot Mailing List, Peter Maydell, Ilias Apalodimas,
Andrew Phelps, Alexander Graf, Bin Meng, Caleb Connolly,
Jan Kiszka, Jerry Van Baren, Jiaxun Yang, Lukas Funke,
Marek Vasut, Max Filippov, Michal Simek, Oliver Gaskell,
Patrick Rudolph, Rayagonda Kokatanur, Robert Marko, Sumit Garg,
This contributor prefers not to receive mails, Tuomas Tynkkynen
[-- Attachment #1: Type: text/plain, Size: 1730 bytes --]
On Sun, Apr 06, 2025 at 07:07:04AM +1200, Simon Glass wrote:
> At present it is impossible to change the qemu_arm64 defconfig to
> obtain a devicetree from the U-Boot build.
>
> This is necessary for FIT validation, for example, where the signature
> node must be compiled into U-Boot.
>
> A proposed change to QEMU to allow device tree additions has been
> blocked for several years. The only known workaround is to use QEMU's
> dumpdtb option, merge in the signature node manually, disable
> OF_HAS_PRIOR_STAGE and then start QEMU with special arguments. This is
> complicated enough that it is documented in U-Boot[1].
This paragraph and then
[snip]
> + Note: this work-around is necessary since Linaro has blocked
> + addition of a feature to support additions to the QEMU devicetree:
This part of the help are overly antagonistic.
[snip]
> diff --git a/dts/Kconfig b/dts/Kconfig
> index 2e88d210bb8..53f7e246a80 100644
> --- a/dts/Kconfig
> +++ b/dts/Kconfig
> @@ -205,8 +205,13 @@ config OF_HAS_PRIOR_STAGE
> development purposes, but it is not recommended, and likely will not
> even work, for production systems.
>
> - Note: This option must be set in Kconfig and cannot be enabled or
> - disabled in the board's defconfig file.
> + Note: This option can be disabled for QEMU usiing QEMU_MANUAL_DTB thus
> + allowing QEMU to support FIT validation, where the devicetree must
> + include a public key.
> +
> + See also this for context:
> +
> + https://patchwork.kernel.org/project/qemu-devel/patch/20210926183410.256484-1-sjg@chromium.org/#24481799
And we don't need more wording here. The QEMU_MANUAL_DTB option itself
is enough.
--
Tom
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v2] emulation: fdt: Allow using U-Boot's device tree with QEMU
2025-04-14 22:53 ` Tom Rini
@ 2025-04-15 7:22 ` Ilias Apalodimas
2025-04-15 14:12 ` Tom Rini
2025-04-17 21:39 ` Simon Glass
1 sibling, 1 reply; 10+ messages in thread
From: Ilias Apalodimas @ 2025-04-15 7:22 UTC (permalink / raw)
To: Tom Rini
Cc: Simon Glass, U-Boot Mailing List, Peter Maydell, Andrew Phelps,
Alexander Graf, Bin Meng, Caleb Connolly, Jan Kiszka,
Jerry Van Baren, Jiaxun Yang, Lukas Funke, Marek Vasut,
Max Filippov, Michal Simek, Oliver Gaskell, Patrick Rudolph,
Rayagonda Kokatanur, Robert Marko, Sumit Garg,
This contributor prefers not to receive mails, Tuomas Tynkkynen
Hi Tom
Thanks for roping me in.
On Tue, 15 Apr 2025 at 01:53, Tom Rini <trini@konsulko.com> wrote:
>
> On Sun, Apr 06, 2025 at 07:07:04AM +1200, Simon Glass wrote:
>
> > At present it is impossible to change the qemu_arm64 defconfig to
> > obtain a devicetree from the U-Boot build.
> >
> > This is necessary for FIT validation, for example, where the signature
> > node must be compiled into U-Boot.
I'll repeat once more, that using the DT to store whatever random data
you invent makes little sense.
No one is obliged to follow internal U-Boot ABIs. Instead, it would
make much more sense to store the data in the U-Boot binary somewhere
and retrieve them. On top of that we now have proper memory
permissions at least for arm64 and you can place certificates in
.rodata.
> >
> > A proposed change to QEMU to allow device tree additions has been
> > blocked for several years.
It hasn't been blocked, it has been rejected.
> The only known workaround is to use QEMU's
> > dumpdtb option, merge in the signature node manually, disable
> > OF_HAS_PRIOR_STAGE and then start QEMU with special arguments. This is
> > complicated enough that it is documented in U-Boot[1].
>
> This paragraph and then
>
> [snip]
> > + Note: this work-around is necessary since Linaro has blocked
Linaro hasn't blocked anything. The QEMU maintainers NAK'ed the patch
multiple times for a very good reason.
FWIW apart from the commit message being misleading once again, the
overall architecture is just unnecessarily complicated.
Cheers
/Ilias
> > + addition of a feature to support additions to the QEMU devicetree:
>
> This part of the help are overly antagonistic.
>
> [snip]
> > diff --git a/dts/Kconfig b/dts/Kconfig
> > index 2e88d210bb8..53f7e246a80 100644
> > --- a/dts/Kconfig
> > +++ b/dts/Kconfig
> > @@ -205,8 +205,13 @@ config OF_HAS_PRIOR_STAGE
> > development purposes, but it is not recommended, and likely will not
> > even work, for production systems.
> >
> > - Note: This option must be set in Kconfig and cannot be enabled or
> > - disabled in the board's defconfig file.
> > + Note: This option can be disabled for QEMU usiing QEMU_MANUAL_DTB thus
> > + allowing QEMU to support FIT validation, where the devicetree must
> > + include a public key.
> > +
> > + See also this for context:
> > +
> > + https://patchwork.kernel.org/project/qemu-devel/patch/20210926183410.256484-1-sjg@chromium.org/#24481799
>
> And we don't need more wording here. The QEMU_MANUAL_DTB option itself
> is enough.
>
> --
> Tom
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v2] emulation: fdt: Allow using U-Boot's device tree with QEMU
2025-04-15 7:22 ` Ilias Apalodimas
@ 2025-04-15 14:12 ` Tom Rini
2025-04-15 18:45 ` Ilias Apalodimas
0 siblings, 1 reply; 10+ messages in thread
From: Tom Rini @ 2025-04-15 14:12 UTC (permalink / raw)
To: Ilias Apalodimas
Cc: Simon Glass, U-Boot Mailing List, Peter Maydell, Andrew Phelps,
Alexander Graf, Bin Meng, Caleb Connolly, Jan Kiszka,
Jerry Van Baren, Jiaxun Yang, Lukas Funke, Marek Vasut,
Max Filippov, Michal Simek, Oliver Gaskell, Patrick Rudolph,
Rayagonda Kokatanur, Robert Marko, Sumit Garg,
This contributor prefers not to receive mails, Tuomas Tynkkynen
[-- Attachment #1: Type: text/plain, Size: 1374 bytes --]
On Tue, Apr 15, 2025 at 10:22:50AM +0300, Ilias Apalodimas wrote:
> Hi Tom
>
> Thanks for roping me in.
You were cc'd on the original, fwiw.
>
> On Tue, 15 Apr 2025 at 01:53, Tom Rini <trini@konsulko.com> wrote:
> >
> > On Sun, Apr 06, 2025 at 07:07:04AM +1200, Simon Glass wrote:
> >
> > > At present it is impossible to change the qemu_arm64 defconfig to
> > > obtain a devicetree from the U-Boot build.
> > >
> > > This is necessary for FIT validation, for example, where the signature
> > > node must be compiled into U-Boot.
>
> I'll repeat once more, that using the DT to store whatever random data
> you invent makes little sense.
> No one is obliged to follow internal U-Boot ABIs. Instead, it would
> make much more sense to store the data in the U-Boot binary somewhere
> and retrieve them. On top of that we now have proper memory
> permissions at least for arm64 and you can place certificates in
> .rodata.
I don't see the high level difference really between blob with a
signature attached somewhere being good (signed EFI files where the
signature isn't an external file) vs blob with a signature attached
somewhere being bad (what Simon is doing with FIT here). So as long as
we can drop the antagonism (and don't break other use cases) I'm fine
with letting this alternate way of securing a system proceed.
--
Tom
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v2] emulation: fdt: Allow using U-Boot's device tree with QEMU
2025-04-15 14:12 ` Tom Rini
@ 2025-04-15 18:45 ` Ilias Apalodimas
0 siblings, 0 replies; 10+ messages in thread
From: Ilias Apalodimas @ 2025-04-15 18:45 UTC (permalink / raw)
To: Tom Rini
Cc: Simon Glass, U-Boot Mailing List, Peter Maydell, Andrew Phelps,
Alexander Graf, Bin Meng, Caleb Connolly, Jan Kiszka,
Jerry Van Baren, Jiaxun Yang, Lukas Funke, Marek Vasut,
Max Filippov, Michal Simek, Oliver Gaskell, Patrick Rudolph,
Rayagonda Kokatanur, Robert Marko, Sumit Garg,
This contributor prefers not to receive mails, Tuomas Tynkkynen
On Tue, 15 Apr 2025 at 17:12, Tom Rini <trini@konsulko.com> wrote:
>
> On Tue, Apr 15, 2025 at 10:22:50AM +0300, Ilias Apalodimas wrote:
> > Hi Tom
> >
> > Thanks for roping me in.
>
> You were cc'd on the original, FWIW.
I completely missed that and only noticed it with your reply. Thanks!
>
> >
> > On Tue, 15 Apr 2025 at 01:53, Tom Rini <trini@konsulko.com> wrote:
> > >
> > > On Sun, Apr 06, 2025 at 07:07:04AM +1200, Simon Glass wrote:
> > >
> > > > At present it is impossible to change the qemu_arm64 defconfig to
> > > > obtain a devicetree from the U-Boot build.
> > > >
> > > > This is necessary for FIT validation, for example, where the signature
> > > > node must be compiled into U-Boot.
> >
> > I'll repeat once more, that using the DT to store whatever random data
> > you invent makes little sense.
> > No one is obliged to follow internal U-Boot ABIs. Instead, it would
> > make much more sense to store the data in the U-Boot binary somewhere
> > and retrieve them. On top of that we now have proper memory
> > permissions at least for arm64 and you can place certificates in
> > .rodata.
>
> I don't see the high level difference really between blob with a
> signature attached somewhere being good (signed EFI files where the
> signature isn't an external file) vs blob with a signature attached
> somewhere being bad (what Simon is doing with FIT here).
There really isn't a technical one. The only thing that makes our
lives a lot easier is that DT is governed by a spec and adding u-boot
signatures in there feels a bit weird. It also *requires* us to do
things like the current patchset, while using the binary itself
doesn't.
> So as long as
> we can drop the antagonism (and don't break other use cases) I'm fine
> with letting this alternate way of securing a system proceed.
>
Thanks
/Ilias
> --
> Tom
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v2] emulation: fdt: Allow using U-Boot's device tree with QEMU
2025-04-14 22:53 ` Tom Rini
2025-04-15 7:22 ` Ilias Apalodimas
@ 2025-04-17 21:39 ` Simon Glass
2025-04-17 22:04 ` Tom Rini
1 sibling, 1 reply; 10+ messages in thread
From: Simon Glass @ 2025-04-17 21:39 UTC (permalink / raw)
To: Tom Rini
Cc: U-Boot Mailing List, Peter Maydell, Ilias Apalodimas,
Andrew Phelps, Alexander Graf, Bin Meng, Caleb Connolly,
Jan Kiszka, Jerry Van Baren, Jiaxun Yang, Lukas Funke,
Marek Vasut, Max Filippov, Michal Simek, Oliver Gaskell,
Patrick Rudolph, Rayagonda Kokatanur, Robert Marko, Sumit Garg,
This contributor prefers not to receive mails, Tuomas Tynkkynen
Hi Tom,
On Mon, 14 Apr 2025 at 16:53, Tom Rini <trini@konsulko.com> wrote:
>
> On Sun, Apr 06, 2025 at 07:07:04AM +1200, Simon Glass wrote:
>
> > At present it is impossible to change the qemu_arm64 defconfig to
> > obtain a devicetree from the U-Boot build.
> >
> > This is necessary for FIT validation, for example, where the signature
> > node must be compiled into U-Boot.
> >
> > A proposed change to QEMU to allow device tree additions has been
> > blocked for several years. The only known workaround is to use QEMU's
> > dumpdtb option, merge in the signature node manually, disable
> > OF_HAS_PRIOR_STAGE and then start QEMU with special arguments. This is
> > complicated enough that it is documented in U-Boot[1].
>
> This paragraph and then
>
> [snip]
> > + Note: this work-around is necessary since Linaro has blocked
> > + addition of a feature to support additions to the QEMU devicetree:
>
> This part of the help are overly antagonistic.
>
> [snip]
> > diff --git a/dts/Kconfig b/dts/Kconfig
> > index 2e88d210bb8..53f7e246a80 100644
> > --- a/dts/Kconfig
> > +++ b/dts/Kconfig
> > @@ -205,8 +205,13 @@ config OF_HAS_PRIOR_STAGE
> > development purposes, but it is not recommended, and likely will not
> > even work, for production systems.
> >
> > - Note: This option must be set in Kconfig and cannot be enabled or
> > - disabled in the board's defconfig file.
> > + Note: This option can be disabled for QEMU usiing QEMU_MANUAL_DTB thus
> > + allowing QEMU to support FIT validation, where the devicetree must
> > + include a public key.
> > +
> > + See also this for context:
> > +
> > + https://patchwork.kernel.org/project/qemu-devel/patch/20210926183410.256484-1-sjg@chromium.org/#24481799
>
> And we don't need more wording here. The QEMU_MANUAL_DTB option itself
> is enough.
I believe what I said is true, Ilias' comments to the contrary
notwithstanding. If I were trying to be antagonistic I would perhaps
express my views in a different manner.
Perhaps we should discuss whether Linaro should have maintainship on
these important projects? U-Boot depends on QEMU and for it to block
that patch is really not that good. It just makes things hard for
open-source firmware.
As you've seen, I've added this patch into my standard-passage series,
which was dropped several years ago.
Regards,
Simon
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v2] emulation: fdt: Allow using U-Boot's device tree with QEMU
2025-04-17 21:39 ` Simon Glass
@ 2025-04-17 22:04 ` Tom Rini
0 siblings, 0 replies; 10+ messages in thread
From: Tom Rini @ 2025-04-17 22:04 UTC (permalink / raw)
To: Simon Glass
Cc: U-Boot Mailing List, Peter Maydell, Ilias Apalodimas,
Andrew Phelps, Alexander Graf, Bin Meng, Caleb Connolly,
Jan Kiszka, Jerry Van Baren, Jiaxun Yang, Lukas Funke,
Marek Vasut, Max Filippov, Michal Simek, Oliver Gaskell,
Patrick Rudolph, Rayagonda Kokatanur, Robert Marko, Sumit Garg,
This contributor prefers not to receive mails, Tuomas Tynkkynen
[-- Attachment #1: Type: text/plain, Size: 2986 bytes --]
On Thu, Apr 17, 2025 at 03:39:57PM -0600, Simon Glass wrote:
> Hi Tom,
>
> On Mon, 14 Apr 2025 at 16:53, Tom Rini <trini@konsulko.com> wrote:
> >
> > On Sun, Apr 06, 2025 at 07:07:04AM +1200, Simon Glass wrote:
> >
> > > At present it is impossible to change the qemu_arm64 defconfig to
> > > obtain a devicetree from the U-Boot build.
> > >
> > > This is necessary for FIT validation, for example, where the signature
> > > node must be compiled into U-Boot.
> > >
> > > A proposed change to QEMU to allow device tree additions has been
> > > blocked for several years. The only known workaround is to use QEMU's
> > > dumpdtb option, merge in the signature node manually, disable
> > > OF_HAS_PRIOR_STAGE and then start QEMU with special arguments. This is
> > > complicated enough that it is documented in U-Boot[1].
> >
> > This paragraph and then
> >
> > [snip]
> > > + Note: this work-around is necessary since Linaro has blocked
> > > + addition of a feature to support additions to the QEMU devicetree:
> >
> > This part of the help are overly antagonistic.
> >
> > [snip]
> > > diff --git a/dts/Kconfig b/dts/Kconfig
> > > index 2e88d210bb8..53f7e246a80 100644
> > > --- a/dts/Kconfig
> > > +++ b/dts/Kconfig
> > > @@ -205,8 +205,13 @@ config OF_HAS_PRIOR_STAGE
> > > development purposes, but it is not recommended, and likely will not
> > > even work, for production systems.
> > >
> > > - Note: This option must be set in Kconfig and cannot be enabled or
> > > - disabled in the board's defconfig file.
> > > + Note: This option can be disabled for QEMU usiing QEMU_MANUAL_DTB thus
> > > + allowing QEMU to support FIT validation, where the devicetree must
> > > + include a public key.
> > > +
> > > + See also this for context:
> > > +
> > > + https://patchwork.kernel.org/project/qemu-devel/patch/20210926183410.256484-1-sjg@chromium.org/#24481799
> >
> > And we don't need more wording here. The QEMU_MANUAL_DTB option itself
> > is enough.
>
> I believe what I said is true, Ilias' comments to the contrary
> notwithstanding. If I were trying to be antagonistic I would perhaps
> express my views in a different manner.
>
> Perhaps we should discuss whether Linaro should have maintainship on
> these important projects? U-Boot depends on QEMU and for it to block
> that patch is really not that good. It just makes things hard for
> open-source firmware.
If you wish to argue that Linaro as an organization has undue influence
in the open source community, this project is not the right forum to
raise that concern on. You should submit an op-ed to any of the
OSS-focused new sites or something perhaps, I don't know. Because QEMU
is a member of the Software Freedom Conservancy project, which is also
where I am trying to steer us to, and they take the idea of keeping
community projects as community run seriously.
--
Tom
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v2] emulation: fdt: Allow using U-Boot's device tree with QEMU
2025-04-05 19:07 [PATCH v2] emulation: fdt: Allow using U-Boot's device tree with QEMU Simon Glass
2025-04-14 22:53 ` Tom Rini
@ 2025-04-16 5:33 ` Heinrich Schuchardt
2025-04-16 13:50 ` Tom Rini
2025-04-17 21:35 ` Simon Glass
1 sibling, 2 replies; 10+ messages in thread
From: Heinrich Schuchardt @ 2025-04-16 5:33 UTC (permalink / raw)
To: Simon Glass
Cc: Peter Maydell, Ilias Apalodimas, Tom Rini, Andrew Phelps,
Alexander Graf, Bin Meng, Caleb Connolly, Jan Kiszka,
Jerry Van Baren, Jiaxun Yang, Lukas Funke, Marek Vasut,
Max Filippov, Michal Simek, Oliver Gaskell, Patrick Rudolph,
Rayagonda Kokatanur, Robert Marko, Sumit Garg, Tuomas Tynkkynen,
U-Boot Mailing List
On 4/5/25 21:07, Simon Glass wrote:
> At present it is impossible to change the qemu_arm64 defconfig to
> obtain a devicetree from the U-Boot build.
>
> This is necessary for FIT validation, for example, where the signature
> node must be compiled into U-Boot.
This description looks wrong:
Signatures are in FIT images.
Only public keys to validate the signatures should be compiled into U-Boot.
>
> A proposed change to QEMU to allow device tree additions has been
> blocked for several years. The only known workaround is to use QEMU's
> dumpdtb option, merge in the signature node manually, disable
> OF_HAS_PRIOR_STAGE and then start QEMU with special arguments. This is
> complicated enough that it is documented in U-Boot[1].
This seems to relate to
[PATCH] hw/arm/virt: Allow additions to the generated device tree
https://lore.kernel.org/qemu-devel/20210926183410.256484-1-sjg@chromium.org/
As your describe in [1] QEMU already provides a -dtb parameter if you
want a crafted device-tree. Your proposed change is confounding boot
stages and and would not provide value to the QEMU project. It was
therefore rejected for good.
It remains unclear why you would disable OF_HAS_PRIOR_STAGE if you were
using QEMU's -dtb parameter.
What would be the benefit of compiling the DT into U-Boot instead of
providing it via the -dtb parameter?
>
> Unfortunately the only way to disable OF_HAS_PRIOR_STAGE at present is
> to hack the Kconfig.
>
> Add a new QEMU_MANUAL_DTB Kconfig option which makes OF_HAS_PRIOR_STAGE
> optional, thus avoiding needing to patch U-Boot to get this working.
>
> This seems a clearer solution than just making OF_HAS_PRIOR_STAGE
> visible, since that symbol is intended to be set automatically by each
> platform.
To me the new parameter is harder to use than simply making
CONFIG_OF_HAS_PRIOR_STAGE always editable.
>
> [1] https://docs.u-boot.org/en/latest/develop/devicetree/dt_qemu.html
The instructions that you provide in [1] are incorrect.
"qemu-system-arm -machine virt -machine dumpdtb=qemu.dtb"
The second machine statement overrides the first one. And the second one
will use the default machine which for instance on riscv64 is not virt.
The correct invocation to download the device-tree would be:
qemu-system-arm -M virt,dumpdtb=qemudtb
> Link: https://patchwork.kernel.org/project/qemu-devel/patch/20210926183410.256484-1-sjg@chromium.org/#24481799
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> Suggested-by: Tom Rini <trini@konsulko.com>
> ---
>
> Changes in v2:
> - Add a new QEMU-specific Kconfig instead
>
> arch/arm/Kconfig | 2 +-
> board/emulation/common/Kconfig | 12 ++++++++++++
> doc/develop/devicetree/dt_qemu.rst | 5 +++++
> dts/Kconfig | 9 +++++++--
This patch lacks proper documentation in doc/
> 4 files changed, 25 insertions(+), 3 deletions(-)
>
> diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
> index db8758e6dfe..b55ed61894a 100644
> --- a/arch/arm/Kconfig
> +++ b/arch/arm/Kconfig
> @@ -1055,7 +1055,7 @@ config ARCH_QEMU
> imply DM_RNG
> imply DM_RTC
> imply RTC_PL031
> - imply OF_HAS_PRIOR_STAGE if !TARGET_QEMU_ARM_SBSA
> + imply OF_HAS_PRIOR_STAGE if !TARGET_QEMU_ARM_SBSA && !QEMU_MANUAL_DTB
> imply VIDEO
> imply VIDEO_BOCHS
> imply SYS_WHITE_ON_BLACK
> diff --git a/board/emulation/common/Kconfig b/board/emulation/common/Kconfig
> index 4c15c8bcb89..3f9a6ea578f 100644
> --- a/board/emulation/common/Kconfig
> +++ b/board/emulation/common/Kconfig
> @@ -13,3 +13,15 @@ config MTDPARTS_NOR1
> help
> This define the partition of nor1 used to build mtparts dynamically
> for the u-boot env stored on nor1.
> +
> +config QEMU_MANUAL_DTB
> + bool "Manually provide a device tree to QEMU"
> + help
> + For some use cases, such as FIT validation where a public key must be
> + placed in U-Boot's device tree, we need to override the device tree
> + that QEMU would normally provide to us.
> +
> + Note: this work-around is necessary since Linaro has blocked
> + addition of a feature to support additions to the QEMU devicetree:
> +
> + Link: https://patchwork.kernel.org/project/qemu-devel/patch/20210926183410.256484-1-sjg@chromium.org/#24481799
> diff --git a/doc/develop/devicetree/dt_qemu.rst b/doc/develop/devicetree/dt_qemu.rst
> index 8ba2b225590..c693b49d3d4 100644
> --- a/doc/develop/devicetree/dt_qemu.rst
> +++ b/doc/develop/devicetree/dt_qemu.rst
> @@ -46,3 +46,8 @@ You can then run qemu with the merged devicetree, e.g.::
>
> Note that there seems to be a bug in some versions of qemu where the output of
> dumpdtb does not quite match what is provided to U-Boot.
> +
> +See also the
> +`rejected QEMU patch <https://patchwork.kernel.org/project/qemu-devel/patch/20231117021840.117874-1-sjg@chromium.org>`_
> +and
> +`discussion <https://patchwork.kernel.org/project/qemu-devel/patch/20210926183410.256484-1-sjg@chromium.org>`_.
> diff --git a/dts/Kconfig b/dts/Kconfig
> index 2e88d210bb8..53f7e246a80 100644
> --- a/dts/Kconfig
> +++ b/dts/Kconfig
> @@ -205,8 +205,13 @@ config OF_HAS_PRIOR_STAGE
> development purposes, but it is not recommended, and likely will not
> even work, for production systems.
>
> - Note: This option must be set in Kconfig and cannot be enabled or
> - disabled in the board's defconfig file.
> + Note: This option can be disabled for QEMU usiing QEMU_MANUAL_DTB thus
%s/usiing/using/
Best regards
Heinrich
> + allowing QEMU to support FIT validation, where the devicetree must
> + include a public key.
> +
> + See also this for context:
> +
> + https://patchwork.kernel.org/project/qemu-devel/patch/20210926183410.256484-1-sjg@chromium.org/#24481799
>
> config OF_OMIT_DTB
> bool "Omit the device tree output when building"
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v2] emulation: fdt: Allow using U-Boot's device tree with QEMU
2025-04-16 5:33 ` Heinrich Schuchardt
@ 2025-04-16 13:50 ` Tom Rini
2025-04-17 21:35 ` Simon Glass
1 sibling, 0 replies; 10+ messages in thread
From: Tom Rini @ 2025-04-16 13:50 UTC (permalink / raw)
To: Heinrich Schuchardt
Cc: Simon Glass, Peter Maydell, Ilias Apalodimas, Andrew Phelps,
Alexander Graf, Bin Meng, Caleb Connolly, Jan Kiszka,
Jerry Van Baren, Jiaxun Yang, Lukas Funke, Marek Vasut,
Max Filippov, Michal Simek, Oliver Gaskell, Patrick Rudolph,
Rayagonda Kokatanur, Robert Marko, Sumit Garg, Tuomas Tynkkynen,
U-Boot Mailing List
[-- Attachment #1: Type: text/plain, Size: 2529 bytes --]
On Wed, Apr 16, 2025 at 07:33:51AM +0200, Heinrich Schuchardt wrote:
> On 4/5/25 21:07, Simon Glass wrote:
> > At present it is impossible to change the qemu_arm64 defconfig to
> > obtain a devicetree from the U-Boot build.
> >
> > This is necessary for FIT validation, for example, where the signature
> > node must be compiled into U-Boot.
>
> This description looks wrong:
>
> Signatures are in FIT images.
>
> Only public keys to validate the signatures should be compiled into U-Boot.
>
> >
> > A proposed change to QEMU to allow device tree additions has been
> > blocked for several years. The only known workaround is to use QEMU's
> > dumpdtb option, merge in the signature node manually, disable
> > OF_HAS_PRIOR_STAGE and then start QEMU with special arguments. This is
> > complicated enough that it is documented in U-Boot[1].
>
> This seems to relate to
> [PATCH] hw/arm/virt: Allow additions to the generated device tree
> https://lore.kernel.org/qemu-devel/20210926183410.256484-1-sjg@chromium.org/
>
> As your describe in [1] QEMU already provides a -dtb parameter if you want a
> crafted device-tree. Your proposed change is confounding boot stages and and
> would not provide value to the QEMU project. It was therefore rejected for
> good.
>
> It remains unclear why you would disable OF_HAS_PRIOR_STAGE if you were
> using QEMU's -dtb parameter.
>
> What would be the benefit of compiling the DT into U-Boot instead of
> providing it via the -dtb parameter?
>
> >
> > Unfortunately the only way to disable OF_HAS_PRIOR_STAGE at present is
> > to hack the Kconfig.
> >
> > Add a new QEMU_MANUAL_DTB Kconfig option which makes OF_HAS_PRIOR_STAGE
> > optional, thus avoiding needing to patch U-Boot to get this working.
> >
> > This seems a clearer solution than just making OF_HAS_PRIOR_STAGE
> > visible, since that symbol is intended to be set automatically by each
> > platform.
>
> To me the new parameter is harder to use than simply making
> CONFIG_OF_HAS_PRIOR_STAGE always editable.
I don't want OF_HAS_PRIOR_STAGE to be editable. Ideally, we shouldn't
ever be asking the user/developer to put this in the config, it's a
feature of the board. But as part of Simon's whole "Why don't [I] try
saying yes?" request, I'm trying to accommodate the design he has in
mind. And so, for QEMU, we need something here, because on real hardware
implementing the scheme, everything required would already be in the
provided tree.
--
Tom
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v2] emulation: fdt: Allow using U-Boot's device tree with QEMU
2025-04-16 5:33 ` Heinrich Schuchardt
2025-04-16 13:50 ` Tom Rini
@ 2025-04-17 21:35 ` Simon Glass
1 sibling, 0 replies; 10+ messages in thread
From: Simon Glass @ 2025-04-17 21:35 UTC (permalink / raw)
To: Heinrich Schuchardt
Cc: Peter Maydell, Ilias Apalodimas, Tom Rini, Andrew Phelps,
Alexander Graf, Bin Meng, Caleb Connolly, Jan Kiszka,
Jerry Van Baren, Jiaxun Yang, Lukas Funke, Marek Vasut,
Max Filippov, Michal Simek, Oliver Gaskell, Patrick Rudolph,
Rayagonda Kokatanur, Robert Marko, Sumit Garg, Tuomas Tynkkynen,
U-Boot Mailing List
Hi Heinrich,
On Tue, 15 Apr 2025 at 23:33, Heinrich Schuchardt <xypron.glpk@gmx.de> wrote:
>
> On 4/5/25 21:07, Simon Glass wrote:
> > At present it is impossible to change the qemu_arm64 defconfig to
> > obtain a devicetree from the U-Boot build.
> >
> > This is necessary for FIT validation, for example, where the signature
> > node must be compiled into U-Boot.
>
> This description looks wrong:
>
> Signatures are in FIT images.
>
> Only public keys to validate the signatures should be compiled into U-Boot.
>
> >
> > A proposed change to QEMU to allow device tree additions has been
> > blocked for several years. The only known workaround is to use QEMU's
> > dumpdtb option, merge in the signature node manually, disable
> > OF_HAS_PRIOR_STAGE and then start QEMU with special arguments. This is
> > complicated enough that it is documented in U-Boot[1].
>
> This seems to relate to
> [PATCH] hw/arm/virt: Allow additions to the generated device tree
> https://lore.kernel.org/qemu-devel/20210926183410.256484-1-sjg@chromium.org/
>
> As your describe in [1] QEMU already provides a -dtb parameter if you
> want a crafted device-tree. Your proposed change is confounding boot
> stages and and would not provide value to the QEMU project. It was
> therefore rejected for good.
>
> It remains unclear why you would disable OF_HAS_PRIOR_STAGE if you were
> using QEMU's -dtb parameter.
>
> What would be the benefit of compiling the DT into U-Boot instead of
> providing it via the -dtb parameter?
It is helpful when testing things in U-Boot, e.g. FIT validation.
>
> >
> > Unfortunately the only way to disable OF_HAS_PRIOR_STAGE at present is
> > to hack the Kconfig.
> >
> > Add a new QEMU_MANUAL_DTB Kconfig option which makes OF_HAS_PRIOR_STAGE
> > optional, thus avoiding needing to patch U-Boot to get this working.
> >
> > This seems a clearer solution than just making OF_HAS_PRIOR_STAGE
> > visible, since that symbol is intended to be set automatically by each
> > platform.
>
> To me the new parameter is harder to use than simply making
> CONFIG_OF_HAS_PRIOR_STAGE always editable.
>
> >
> > [1] https://docs.u-boot.org/en/latest/develop/devicetree/dt_qemu.html
>
> The instructions that you provide in [1] are incorrect.
>
> "qemu-system-arm -machine virt -machine dumpdtb=qemu.dtb"
>
> The second machine statement overrides the first one. And the second one
> will use the default machine which for instance on riscv64 is not virt.
>
> The correct invocation to download the device-tree would be:
>
> qemu-system-arm -M virt,dumpdtb=qemudtb
I didn't actually send that code in this patch, but please do a patch
if you have time.
>
>
> > Link: https://patchwork.kernel.org/project/qemu-devel/patch/20210926183410.256484-1-sjg@chromium.org/#24481799
> >
> > Signed-off-by: Simon Glass <sjg@chromium.org>
> > Suggested-by: Tom Rini <trini@konsulko.com>
> > ---
> >
> > Changes in v2:
> > - Add a new QEMU-specific Kconfig instead
> >
> > arch/arm/Kconfig | 2 +-
> > board/emulation/common/Kconfig | 12 ++++++++++++
> > doc/develop/devicetree/dt_qemu.rst | 5 +++++
> > dts/Kconfig | 9 +++++++--
>
> This patch lacks proper documentation in doc/
OK I'll add something.
>
> > 4 files changed, 25 insertions(+), 3 deletions(-)
> >
> > diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
> > index db8758e6dfe..b55ed61894a 100644
> > --- a/arch/arm/Kconfig
> > +++ b/arch/arm/Kconfig
> > @@ -1055,7 +1055,7 @@ config ARCH_QEMU
> > imply DM_RNG
> > imply DM_RTC
> > imply RTC_PL031
> > - imply OF_HAS_PRIOR_STAGE if !TARGET_QEMU_ARM_SBSA
> > + imply OF_HAS_PRIOR_STAGE if !TARGET_QEMU_ARM_SBSA && !QEMU_MANUAL_DTB
> > imply VIDEO
> > imply VIDEO_BOCHS
> > imply SYS_WHITE_ON_BLACK
> > diff --git a/board/emulation/common/Kconfig b/board/emulation/common/Kconfig
> > index 4c15c8bcb89..3f9a6ea578f 100644
> > --- a/board/emulation/common/Kconfig
> > +++ b/board/emulation/common/Kconfig
> > @@ -13,3 +13,15 @@ config MTDPARTS_NOR1
> > help
> > This define the partition of nor1 used to build mtparts dynamically
> > for the u-boot env stored on nor1.
> > +
> > +config QEMU_MANUAL_DTB
> > + bool "Manually provide a device tree to QEMU"
> > + help
> > + For some use cases, such as FIT validation where a public key must be
> > + placed in U-Boot's device tree, we need to override the device tree
> > + that QEMU would normally provide to us.
> > +
> > + Note: this work-around is necessary since Linaro has blocked
> > + addition of a feature to support additions to the QEMU devicetree:
> > +
> > + Link: https://patchwork.kernel.org/project/qemu-devel/patch/20210926183410.256484-1-sjg@chromium.org/#24481799
> > diff --git a/doc/develop/devicetree/dt_qemu.rst b/doc/develop/devicetree/dt_qemu.rst
> > index 8ba2b225590..c693b49d3d4 100644
> > --- a/doc/develop/devicetree/dt_qemu.rst
> > +++ b/doc/develop/devicetree/dt_qemu.rst
> > @@ -46,3 +46,8 @@ You can then run qemu with the merged devicetree, e.g.::
> >
> > Note that there seems to be a bug in some versions of qemu where the output of
> > dumpdtb does not quite match what is provided to U-Boot.
> > +
> > +See also the
> > +`rejected QEMU patch <https://patchwork.kernel.org/project/qemu-devel/patch/20231117021840.117874-1-sjg@chromium.org>`_
> > +and
> > +`discussion <https://patchwork.kernel.org/project/qemu-devel/patch/20210926183410.256484-1-sjg@chromium.org>`_.
> > diff --git a/dts/Kconfig b/dts/Kconfig
> > index 2e88d210bb8..53f7e246a80 100644
> > --- a/dts/Kconfig
> > +++ b/dts/Kconfig
> > @@ -205,8 +205,13 @@ config OF_HAS_PRIOR_STAGE
> > development purposes, but it is not recommended, and likely will not
> > even work, for production systems.
> >
> > - Note: This option must be set in Kconfig and cannot be enabled or
> > - disabled in the board's defconfig file.
> > + Note: This option can be disabled for QEMU usiing QEMU_MANUAL_DTB thus
>
> %s/usiing/using/
Will fix.
>
> Best regards
>
> Heinrich
>
> > + allowing QEMU to support FIT validation, where the devicetree must
> > + include a public key.
> > +
> > + See also this for context:
> > +
> > + https://patchwork.kernel.org/project/qemu-devel/patch/20210926183410.256484-1-sjg@chromium.org/#24481799
> >
> > config OF_OMIT_DTB
> > bool "Omit the device tree output when building"
>
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2025-04-17 22:04 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-05 19:07 [PATCH v2] emulation: fdt: Allow using U-Boot's device tree with QEMU Simon Glass
2025-04-14 22:53 ` Tom Rini
2025-04-15 7:22 ` Ilias Apalodimas
2025-04-15 14:12 ` Tom Rini
2025-04-15 18:45 ` Ilias Apalodimas
2025-04-17 21:39 ` Simon Glass
2025-04-17 22:04 ` Tom Rini
2025-04-16 5:33 ` Heinrich Schuchardt
2025-04-16 13:50 ` Tom Rini
2025-04-17 21:35 ` Simon Glass
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.