* [PATCH v3 1/3] boards: qemu-virt: apply overlay at postcore_initcall level
2023-03-13 14:42 [PATCH v3 0/3] boards: qemu-virt: support passing in FIT public key Ahmad Fatoum
@ 2023-03-13 14:42 ` Ahmad Fatoum
2023-03-13 14:42 ` [PATCH v3 2/3] boards: qemu-virt: compile overlay as such Ahmad Fatoum
` (4 subsequent siblings)
5 siblings, 0 replies; 8+ messages in thread
From: Ahmad Fatoum @ 2023-03-13 14:42 UTC (permalink / raw)
To: barebox; +Cc: Ahmad Fatoum, Michael Riesch
Qemu board driver fixups should be applied very early to be able to
influence core components, even if they are controlled directly by
initcalls. For this reason, let's move the early board code into
the earliest possible initcall level.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
common/boards/qemu-virt/board.c | 42 ++++++++++++++++++---------------
1 file changed, 23 insertions(+), 19 deletions(-)
diff --git a/common/boards/qemu-virt/board.c b/common/boards/qemu-virt/board.c
index d0f4412cdea5..7e0e63333c5c 100644
--- a/common/boards/qemu-virt/board.c
+++ b/common/boards/qemu-virt/board.c
@@ -36,33 +36,37 @@ static inline void arm_virt_init(void) {}
extern char __dtb_overlay_of_flash_start[];
-static int virt_probe(struct device *dev)
+static const struct of_device_id virt_of_match[] = {
+ { .compatible = "linux,dummy-virt", .data = arm_virt_init },
+ { .compatible = "riscv-virtio" },
+ { /* Sentinel */},
+};
+BAREBOX_DEEP_PROBE_ENABLE(virt_of_match);
+
+/*
+ * We don't have a dedicated qemu-virt device tree and instead rely
+ * on what Qemu passes us. To be able to get fundamental changes
+ * in very early, we forego having a board driver here and do this
+ * directly in the initcall.
+ */
+static int virt_board_driver_init(void)
{
+ struct device_node *root = of_get_root_node();
struct device_node *overlay;
+ const struct of_device_id *id;
void (*init)(void);
- init = device_get_match_data(dev);
- if (init)
+ id = of_match_node(virt_of_match, root);
+ if (id && id->data) {
+ init = id->data;
init();
+ }
overlay = of_unflatten_dtb(__dtb_overlay_of_flash_start, INT_MAX);
- of_overlay_apply_tree(dev->of_node, overlay);
+ of_overlay_apply_tree(root, overlay);
+
/* of_probe() will happen later at of_populate_initcall */
return 0;
}
-
-static const struct of_device_id virt_of_match[] = {
- { .compatible = "linux,dummy-virt", .data = arm_virt_init },
- { .compatible = "riscv-virtio" },
- { /* Sentinel */},
-};
-BAREBOX_DEEP_PROBE_ENABLE(virt_of_match);
-
-static struct driver virt_board_driver = {
- .name = "board-qemu-virt",
- .probe = virt_probe,
- .of_compatible = virt_of_match,
-};
-
-postcore_platform_driver(virt_board_driver);
+postcore_initcall(virt_board_driver_init);
--
2.30.2
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v3 2/3] boards: qemu-virt: compile overlay as such
2023-03-13 14:42 [PATCH v3 0/3] boards: qemu-virt: support passing in FIT public key Ahmad Fatoum
2023-03-13 14:42 ` [PATCH v3 1/3] boards: qemu-virt: apply overlay at postcore_initcall level Ahmad Fatoum
@ 2023-03-13 14:42 ` Ahmad Fatoum
2023-03-13 14:42 ` [PATCH v3 3/3] boards: qemu-virt: support passing in FIT public key Ahmad Fatoum
` (3 subsequent siblings)
5 siblings, 0 replies; 8+ messages in thread
From: Ahmad Fatoum @ 2023-03-13 14:42 UTC (permalink / raw)
To: barebox; +Cc: Michael Riesch
From: Ahmad Fatoum <ahmad@a3f.at>
Build system now differentiates between building normal device trees and
overlays; as the latter would be broken when CONFIG_EXTERNAL_DTS_FRAGMENTS
is in use. Switch over Qemu board support to build the overlay as such.
Signed-off-by: Ahmad Fatoum <ahmad@a3f.at>
---
common/boards/qemu-virt/Makefile | 2 +-
common/boards/qemu-virt/board.c | 4 ++--
common/boards/qemu-virt/{overlay-of-flash.dts => flash.dtso} | 0
3 files changed, 3 insertions(+), 3 deletions(-)
rename common/boards/qemu-virt/{overlay-of-flash.dts => flash.dtso} (100%)
diff --git a/common/boards/qemu-virt/Makefile b/common/boards/qemu-virt/Makefile
index 88184e9a7969..53f00d1b0c41 100644
--- a/common/boards/qemu-virt/Makefile
+++ b/common/boards/qemu-virt/Makefile
@@ -1,7 +1,7 @@
# SPDX-License-Identifier: GPL-2.0-only
obj-y += board.o
-obj-y += overlay-of-flash.dtb.o
+obj-y += flash.dtbo.o
ifeq ($(CONFIG_RISCV),y)
DTC_CPP_FLAGS_overlay-of-flash.dtb := -DRISCV_VIRT=1
endif
diff --git a/common/boards/qemu-virt/board.c b/common/boards/qemu-virt/board.c
index 7e0e63333c5c..89d103493179 100644
--- a/common/boards/qemu-virt/board.c
+++ b/common/boards/qemu-virt/board.c
@@ -34,7 +34,7 @@ static inline void arm_virt_init(void)
static inline void arm_virt_init(void) {}
#endif
-extern char __dtb_overlay_of_flash_start[];
+extern char __dtbo_flash_start[];
static const struct of_device_id virt_of_match[] = {
{ .compatible = "linux,dummy-virt", .data = arm_virt_init },
@@ -62,7 +62,7 @@ static int virt_board_driver_init(void)
init();
}
- overlay = of_unflatten_dtb(__dtb_overlay_of_flash_start, INT_MAX);
+ overlay = of_unflatten_dtb(__dtbo_flash_start, INT_MAX);
of_overlay_apply_tree(root, overlay);
/* of_probe() will happen later at of_populate_initcall */
diff --git a/common/boards/qemu-virt/overlay-of-flash.dts b/common/boards/qemu-virt/flash.dtso
similarity index 100%
rename from common/boards/qemu-virt/overlay-of-flash.dts
rename to common/boards/qemu-virt/flash.dtso
--
2.30.2
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v3 3/3] boards: qemu-virt: support passing in FIT public key
2023-03-13 14:42 [PATCH v3 0/3] boards: qemu-virt: support passing in FIT public key Ahmad Fatoum
2023-03-13 14:42 ` [PATCH v3 1/3] boards: qemu-virt: apply overlay at postcore_initcall level Ahmad Fatoum
2023-03-13 14:42 ` [PATCH v3 2/3] boards: qemu-virt: compile overlay as such Ahmad Fatoum
@ 2023-03-13 14:42 ` Ahmad Fatoum
2023-03-13 14:46 ` [PATCH v3 0/3] " Ahmad Fatoum
` (2 subsequent siblings)
5 siblings, 0 replies; 8+ messages in thread
From: Ahmad Fatoum @ 2023-03-13 14:42 UTC (permalink / raw)
To: barebox; +Cc: Ahmad Fatoum, Michael Riesch
FIT public key is usually passed in via board DT. Usual way to use
barebox with QEMU Virt however is to use DT supplied by Qemu and apply
overlay to it. mkimage doesn't generate overlay DTB though. To make
barbebox Qemu Virt behave like other boards, let's define a dummy DT
that includes CONFIG_BOOTM_FITIMAGE_PUBKEY, which is merged with the
barebox live device tree.
Suggested-by: Jan Lübbe <jlu@pengutronix.de>
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
common/boards/qemu-virt/Makefile | 2 +-
common/boards/qemu-virt/board.c | 6 +++++-
common/boards/qemu-virt/fitimage-pubkey.dts | 7 +++++++
3 files changed, 13 insertions(+), 2 deletions(-)
create mode 100644 common/boards/qemu-virt/fitimage-pubkey.dts
diff --git a/common/boards/qemu-virt/Makefile b/common/boards/qemu-virt/Makefile
index 53f00d1b0c41..d37bdced0e20 100644
--- a/common/boards/qemu-virt/Makefile
+++ b/common/boards/qemu-virt/Makefile
@@ -1,7 +1,7 @@
# SPDX-License-Identifier: GPL-2.0-only
obj-y += board.o
-obj-y += flash.dtbo.o
+obj-y += flash.dtbo.o fitimage-pubkey.dtb.o
ifeq ($(CONFIG_RISCV),y)
DTC_CPP_FLAGS_overlay-of-flash.dtb := -DRISCV_VIRT=1
endif
diff --git a/common/boards/qemu-virt/board.c b/common/boards/qemu-virt/board.c
index 89d103493179..c30a6c382ef4 100644
--- a/common/boards/qemu-virt/board.c
+++ b/common/boards/qemu-virt/board.c
@@ -35,6 +35,7 @@ static inline void arm_virt_init(void) {}
#endif
extern char __dtbo_flash_start[];
+extern char __dtb_fitimage_pubkey_start[];
static const struct of_device_id virt_of_match[] = {
{ .compatible = "linux,dummy-virt", .data = arm_virt_init },
@@ -52,7 +53,7 @@ BAREBOX_DEEP_PROBE_ENABLE(virt_of_match);
static int virt_board_driver_init(void)
{
struct device_node *root = of_get_root_node();
- struct device_node *overlay;
+ struct device_node *overlay, *pubkey;
const struct of_device_id *id;
void (*init)(void);
@@ -65,6 +66,9 @@ static int virt_board_driver_init(void)
overlay = of_unflatten_dtb(__dtbo_flash_start, INT_MAX);
of_overlay_apply_tree(root, overlay);
+ pubkey = of_unflatten_dtb(__dtb_fitimage_pubkey_start, INT_MAX);
+ of_merge_nodes(root, pubkey);
+
/* of_probe() will happen later at of_populate_initcall */
return 0;
diff --git a/common/boards/qemu-virt/fitimage-pubkey.dts b/common/boards/qemu-virt/fitimage-pubkey.dts
new file mode 100644
index 000000000000..497799fa4b60
--- /dev/null
+++ b/common/boards/qemu-virt/fitimage-pubkey.dts
@@ -0,0 +1,7 @@
+/dts-v1/;
+
+#ifdef CONFIG_BOOTM_FITIMAGE_PUBKEY
+#include CONFIG_BOOTM_FITIMAGE_PUBKEY
+#endif
+
+/{ };
--
2.30.2
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v3 0/3] boards: qemu-virt: support passing in FIT public key
2023-03-13 14:42 [PATCH v3 0/3] boards: qemu-virt: support passing in FIT public key Ahmad Fatoum
` (2 preceding siblings ...)
2023-03-13 14:42 ` [PATCH v3 3/3] boards: qemu-virt: support passing in FIT public key Ahmad Fatoum
@ 2023-03-13 14:46 ` Ahmad Fatoum
2023-03-14 8:05 ` Sascha Hauer
2023-04-11 10:00 ` Ahmad Fatoum
5 siblings, 0 replies; 8+ messages in thread
From: Ahmad Fatoum @ 2023-03-13 14:46 UTC (permalink / raw)
To: barebox; +Cc: Michael Riesch
On 13.03.23 15:42, Ahmad Fatoum wrote:
> FIT public key is usually passed in via board DT. Usual way to use
> barebox with QEMU Virt however is to use DT supplied by Qemu and apply
> overlay to it. mkimage doesn't generate overlay DTB though. To make
> barbebox Qemu Virt behave like other boards, let's define a dummy DT
> that includes CONFIG_BOOTM_FITIMAGE_PUBKEY, which is merged with the
> barebox live device tree.
>
> This replaces v2 of the series available in next and fixes the
> regressions I introduced for deep-probe systems that ensure probe in
> other devices.
Ah, not quite, the first patch in v2 is unchanged and I forgot to send it out.
@Sascha, let me know if you want me to resend (provided the series is ok now).
>
> I dropped Jan's Tested-by, because the differences warrant it, but
> I tested locally that a RSA key was registered as before.
>
> v2 was here:
> https://lore.barebox.org/barebox/20230210165353.3601175-1-a.fatoum@pengutronix.de/
>
> v2 -> v3:
> - drop "support of_ensure_probed for top-level machine device"
> - switch from board driver back to initcall
>
> v1 -> v2:
> - support of_ensure_probed for top-level machine device
> - ensure qemu board driver is probed at postcore
>
> Ahmad Fatoum (3):
> boards: qemu-virt: apply overlay at postcore_initcall level
> boards: qemu-virt: compile overlay as such
> boards: qemu-virt: support passing in FIT public key
>
> common/boards/qemu-virt/Makefile | 2 +-
> common/boards/qemu-virt/board.c | 52 +++++++++++--------
> common/boards/qemu-virt/fitimage-pubkey.dts | 7 +++
> .../{overlay-of-flash.dts => flash.dtso} | 0
> 4 files changed, 38 insertions(+), 23 deletions(-)
> create mode 100644 common/boards/qemu-virt/fitimage-pubkey.dts
> rename common/boards/qemu-virt/{overlay-of-flash.dts => flash.dtso} (100%)
>
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v3 0/3] boards: qemu-virt: support passing in FIT public key
2023-03-13 14:42 [PATCH v3 0/3] boards: qemu-virt: support passing in FIT public key Ahmad Fatoum
` (3 preceding siblings ...)
2023-03-13 14:46 ` [PATCH v3 0/3] " Ahmad Fatoum
@ 2023-03-14 8:05 ` Sascha Hauer
2023-04-11 10:00 ` Ahmad Fatoum
5 siblings, 0 replies; 8+ messages in thread
From: Sascha Hauer @ 2023-03-14 8:05 UTC (permalink / raw)
To: Ahmad Fatoum; +Cc: barebox, Michael Riesch
On Mon, Mar 13, 2023 at 03:42:17PM +0100, Ahmad Fatoum wrote:
> FIT public key is usually passed in via board DT. Usual way to use
> barebox with QEMU Virt however is to use DT supplied by Qemu and apply
> overlay to it. mkimage doesn't generate overlay DTB though. To make
> barbebox Qemu Virt behave like other boards, let's define a dummy DT
> that includes CONFIG_BOOTM_FITIMAGE_PUBKEY, which is merged with the
> barebox live device tree.
>
> This replaces v2 of the series available in next and fixes the
> regressions I introduced for deep-probe systems that ensure probe in
> other devices.
>
> I dropped Jan's Tested-by, because the differences warrant it, but
> I tested locally that a RSA key was registered as before.
>
> v2 was here:
> https://lore.barebox.org/barebox/20230210165353.3601175-1-a.fatoum@pengutronix.de/
>
> v2 -> v3:
> - drop "support of_ensure_probed for top-level machine device"
> - switch from board driver back to initcall
>
> v1 -> v2:
> - support of_ensure_probed for top-level machine device
> - ensure qemu board driver is probed at postcore
>
> Ahmad Fatoum (3):
> boards: qemu-virt: apply overlay at postcore_initcall level
> boards: qemu-virt: compile overlay as such
> boards: qemu-virt: support passing in FIT public key
Applied, thanks
Sascha
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v3 0/3] boards: qemu-virt: support passing in FIT public key
2023-03-13 14:42 [PATCH v3 0/3] boards: qemu-virt: support passing in FIT public key Ahmad Fatoum
` (4 preceding siblings ...)
2023-03-14 8:05 ` Sascha Hauer
@ 2023-04-11 10:00 ` Ahmad Fatoum
2023-04-11 12:35 ` Sascha Hauer
5 siblings, 1 reply; 8+ messages in thread
From: Ahmad Fatoum @ 2023-04-11 10:00 UTC (permalink / raw)
To: Sascha Hauer; +Cc: barebox
Hello Sascha,
please drop
a9d3244883d7 ("boards: qemu-virt: apply overlay at postcore_initcall level")
e664ca8f7c35 ("boards: qemu-virt: compile overlay as such")
224b5ef1da4c ("boards: qemu-virt: support passing in FIT public key")
again. I had been testing with ARM qemu_virt64_defconfig, but now that
I tested on RISC-V, I notice that non-qemu-virt platforms also execute
the initcall when they shouldn't and that DTC_CPP_FLAGS wasn't defined
for overlays leading to broken state there.
I'll send a revised version, but please drop the current one for now.
Thanks,
Ahmad
On 13.03.23 15:42, Ahmad Fatoum wrote:
> FIT public key is usually passed in via board DT. Usual way to use
> barebox with QEMU Virt however is to use DT supplied by Qemu and apply
> overlay to it. mkimage doesn't generate overlay DTB though. To make
> barbebox Qemu Virt behave like other boards, let's define a dummy DT
> that includes CONFIG_BOOTM_FITIMAGE_PUBKEY, which is merged with the
> barebox live device tree.
>
> This replaces v2 of the series available in next and fixes the
> regressions I introduced for deep-probe systems that ensure probe in
> other devices.
>
> I dropped Jan's Tested-by, because the differences warrant it, but
> I tested locally that a RSA key was registered as before.
>
> v2 was here:
> https://lore.barebox.org/barebox/20230210165353.3601175-1-a.fatoum@pengutronix.de/
>
> v2 -> v3:
> - drop "support of_ensure_probed for top-level machine device"
> - switch from board driver back to initcall
>
> v1 -> v2:
> - support of_ensure_probed for top-level machine device
> - ensure qemu board driver is probed at postcore
>
> Ahmad Fatoum (3):
> boards: qemu-virt: apply overlay at postcore_initcall level
> boards: qemu-virt: compile overlay as such
> boards: qemu-virt: support passing in FIT public key
>
> common/boards/qemu-virt/Makefile | 2 +-
> common/boards/qemu-virt/board.c | 52 +++++++++++--------
> common/boards/qemu-virt/fitimage-pubkey.dts | 7 +++
> .../{overlay-of-flash.dts => flash.dtso} | 0
> 4 files changed, 38 insertions(+), 23 deletions(-)
> create mode 100644 common/boards/qemu-virt/fitimage-pubkey.dts
> rename common/boards/qemu-virt/{overlay-of-flash.dts => flash.dtso} (100%)
>
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v3 0/3] boards: qemu-virt: support passing in FIT public key
2023-04-11 10:00 ` Ahmad Fatoum
@ 2023-04-11 12:35 ` Sascha Hauer
0 siblings, 0 replies; 8+ messages in thread
From: Sascha Hauer @ 2023-04-11 12:35 UTC (permalink / raw)
To: Ahmad Fatoum; +Cc: barebox
On Tue, Apr 11, 2023 at 12:00:18PM +0200, Ahmad Fatoum wrote:
> Hello Sascha,
>
> please drop
>
> a9d3244883d7 ("boards: qemu-virt: apply overlay at postcore_initcall level")
> e664ca8f7c35 ("boards: qemu-virt: compile overlay as such")
> 224b5ef1da4c ("boards: qemu-virt: support passing in FIT public key")
>
> again. I had been testing with ARM qemu_virt64_defconfig, but now that
> I tested on RISC-V, I notice that non-qemu-virt platforms also execute
> the initcall when they shouldn't and that DTC_CPP_FLAGS wasn't defined
> for overlays leading to broken state there.
>
> I'll send a revised version, but please drop the current one for now.
Ok, did that.
Sascha
>
> Thanks,
> Ahmad
>
> On 13.03.23 15:42, Ahmad Fatoum wrote:
> > FIT public key is usually passed in via board DT. Usual way to use
> > barebox with QEMU Virt however is to use DT supplied by Qemu and apply
> > overlay to it. mkimage doesn't generate overlay DTB though. To make
> > barbebox Qemu Virt behave like other boards, let's define a dummy DT
> > that includes CONFIG_BOOTM_FITIMAGE_PUBKEY, which is merged with the
> > barebox live device tree.
> >
> > This replaces v2 of the series available in next and fixes the
> > regressions I introduced for deep-probe systems that ensure probe in
> > other devices.
> >
> > I dropped Jan's Tested-by, because the differences warrant it, but
> > I tested locally that a RSA key was registered as before.
> >
> > v2 was here:
> > https://lore.barebox.org/barebox/20230210165353.3601175-1-a.fatoum@pengutronix.de/
> >
> > v2 -> v3:
> > - drop "support of_ensure_probed for top-level machine device"
> > - switch from board driver back to initcall
> >
> > v1 -> v2:
> > - support of_ensure_probed for top-level machine device
> > - ensure qemu board driver is probed at postcore
> >
> > Ahmad Fatoum (3):
> > boards: qemu-virt: apply overlay at postcore_initcall level
> > boards: qemu-virt: compile overlay as such
> > boards: qemu-virt: support passing in FIT public key
> >
> > common/boards/qemu-virt/Makefile | 2 +-
> > common/boards/qemu-virt/board.c | 52 +++++++++++--------
> > common/boards/qemu-virt/fitimage-pubkey.dts | 7 +++
> > .../{overlay-of-flash.dts => flash.dtso} | 0
> > 4 files changed, 38 insertions(+), 23 deletions(-)
> > create mode 100644 common/boards/qemu-virt/fitimage-pubkey.dts
> > rename common/boards/qemu-virt/{overlay-of-flash.dts => flash.dtso} (100%)
> >
>
> --
> Pengutronix e.K. | |
> Steuerwalder Str. 21 | http://www.pengutronix.de/ |
> 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
> Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
>
>
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
^ permalink raw reply [flat|nested] 8+ messages in thread