Skip to contentSkip to conversation

kernel-fitimage: uboot-sign: Check UBOOT_DTB_BINARY before adding deps

PATCH In review Alex Kiernan 3 participants 9 messages Jun 12, 2019 – Jun 13, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 kernel-fitimage: uboot-sign: Check UBOOT_DTB_BINARY before adding deps

Since UBOOT_DTB_BINARY empty means we don't need to inject signatures into the U-Boot DTB, we can remove the dependencies between consumers of these two classes and resolve a circular dependency between u-boot and kernel.

---

 meta/classes/kernel-fitimage.bbclass | 2 +-
 meta/classes/uboot-sign.bbclass      | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
meta/classes/kernel-fitimage.bbclass +1 -1
index 2820ff968940..9e224daf057e 100644
@@ -42,7 +42,7 @@ python __anonymous () {
         # Verified boot will sign the fitImage and append the public key to
         # U-Boot dtb. We ensure the U-Boot dtb is deployed before assembling
         # the fitImage:
-        if d.getVar('UBOOT_SIGN_ENABLE') == "1":
+        if d.getVar('UBOOT_SIGN_ENABLE') == "1" and d.getVar('UBOOT_DTB_BINARY'):
             uboot_pn = d.getVar('PREFERRED_PROVIDER_u-boot') or 'u-boot'
             d.appendVarFlag('do_assemble_fitimage', 'depends', ' %s:do_populate_sysroot' % uboot_pn)
 }
meta/classes/uboot-sign.bbclass +1 -1
index 8beafff7c03e..de81ad1b389c 100644
@@ -116,7 +116,7 @@ do_install_append() {
 }
 
 python () {
-    if d.getVar('UBOOT_SIGN_ENABLE') == '1' and d.getVar('PN') == d.getVar('UBOOT_PN'):
+    if d.getVar('UBOOT_SIGN_ENABLE') == '1' and d.getVar('PN') == d.getVar('UBOOT_PN') and d.getVar('UBOOT_DTB_BINARY'):
         kernel_pn = d.getVar('PREFERRED_PROVIDER_virtual/kernel')
 
         # Make "bitbake u-boot -cdeploy" deploys the signed u-boot.dtb
Signature · 1 line
2.17.1
#1 lore raw
Quoted 7 lines · Alex Kiernan

Since UBOOT_DTB_BINARY empty means we don't need to inject signatures into the U-Boot DTB, we can remove the dependencies between consumers of
these two classes and resolve a circular dependency between u-boot and
kernel.

Quoted 6 lines

---

 meta/classes/kernel-fitimage.bbclass | 2 +-
 meta/classes/uboot-sign.bbclass      | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

Really wish we had tests and documentation for these classes...

Cheers,

Richard

#2 lore raw
Quoted 9 lines · Richard Purdie
Quoted 7 lines · Alex Kiernan

Since UBOOT_DTB_BINARY empty means we don't need to inject signatures into the U-Boot DTB, we can remove the dependencies between consumers of
these two classes and resolve a circular dependency between u-boot and
kernel.

Quoted 9 lines
Quoted 6 lines

---

 meta/classes/kernel-fitimage.bbclass | 2 +-
 meta/classes/uboot-sign.bbclass      | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

Really wish we had tests and documentation for these classes...

I know... I have a dread anytime anyone touches it, me included... I sat on this change for a couple of weeks too.

The truth is the pair of them are fragile and hopelessly intertwined, but without tests they're never going to get rewritten, so I might try and take some of that on (or get someone here to do it) as I still have multiple issues with them - signing doesn't really work the way I want, I still have a circular dependency I've not tracked down, doubtless other things I can't immediately bring to mind.

If we were to add some tests around it, what would you pull out as the simplest thing that it could do which would be valuable?

Signature · 1 line
Alex Kiernan
#3 lore raw

Hi Richard,

Quoted 28 lines · Alex Kiernan
Quoted 8 lines · Richard Purdie
Quoted 7 lines · Alex Kiernan

Since UBOOT_DTB_BINARY empty means we don't need to inject signatures into the U-Boot DTB, we can remove the dependencies between consumers of
these two classes and resolve a circular dependency between u-boot and
kernel.

Quoted 8 lines
Quoted 6 lines

---

  meta/classes/kernel-fitimage.bbclass | 2 +-
  meta/classes/uboot-sign.bbclass      | 2 +-
  2 files changed, 2 insertions(+), 2 deletions(-)

Really wish we had tests and documentation for these classes...

I know... I have a dread anytime anyone touches it, me included... I sat on this change for a couple of weeks too.

The truth is the pair of them are fragile and hopelessly intertwined, but without tests they're never going to get rewritten, so I might try and take some of that on (or get someone here to do it) as I still have multiple issues with them - signing doesn't really work the way I want, I still have a circular dependency I've not tracked down, doubtless other things I can't immediately bring to mind.

Quoted 2 lines

If we were to add some tests around it, what would you pull out as the simplest thing that it could do which would be valuable?

Actually, you can ignore this patch.  We debugged the actual race condition contributing to the confusion, and that developer will submit a new patch with that fix.  We can review if that patch makes more sense (even without tests).

The test would need to follow:

1) Is there a pub key in the u-boot.dtb (symlinked file) in the deploy directory and is it the same as what is generated by mkimage when pointing at the fitImage in the deploy directory.
2) The race condition affects the build when there is a cached step built incorrectly.   The cached build step injects the u-boot.dtb prior to it being signed.

Hopefully that makes sense,

- Mike

Quoted 1 line
Signature · 5 lines
Michael Scott
Embedded Software Engineer at Foundries.io
"microPlatforms™ for Connected Products"
E: [email protected]
W: https://www.foundries.io
#4 lore raw
Quoted 4 lines · Michael Scott

Actually, you can ignore this patch. We debugged the actual race condition contributing to the confusion, and that developer will submit a new patch with that fix. We can review if that patch makes more sense (even without tests).

Well, this patch merged earlier this evening as tested passed. Is that a problem?

Quoted 9 lines

The test would need to follow:

1) Is there a pub key in the u-boot.dtb (symlinked file) in the deploy
directory and is it the same as what is generated by mkimage when pointing at the fitImage in the deploy directory.
2) The race condition affects the build when there is a cached step
built incorrectly. The cached build step injects the u-boot.dtb
prior to it being signed.

That does help explain the problem you were seeing and does some like something we could/should be testing for.

Cheers,

Richard

#5 lore raw
Quoted 7 lines · On 6/12/19 3:21 PM, [email protected] wrote:
Quoted 4 lines · Michael Scott

Actually, you can ignore this patch. We debugged the actual race condition contributing to the confusion, and that developer will submit a new patch with that fix. We can review if that patch makes more sense (even without tests).

Well, this patch merged earlier this evening as tested passed. Is that a problem?

Not a problem at all.  I believe we also kept this change when we debugged the actual race condition.

Quoted 10 lines
Quoted 10 lines

The test would need to follow:

1) Is there a pub key in the u-boot.dtb (symlinked file) in the deploy
directory and is it the same as what is generated by mkimage when pointing at the fitImage in the deploy directory.
2) The race condition affects the build when there is a cached step
built incorrectly. The cached build step injects the u-boot.dtb
prior to it being signed.

Quoted 2 lines

That does help explain the problem you were seeing and does some like something we could/should be testing for.

Yes if possible the test should run #1 above - 3 ways: 1) clean cache for kernel/u-boot/u-boot tools, 2) cached run for kernel/u-boot/u-boot tools and 3) cached for kernel/u-boot tools, but changed u-boot (invalidate cache?)

- Mike

Quoted 5 lines

Cheers,

Richard

Signature · 5 lines
Michael Scott
Embedded Software Engineer at Foundries.io
"microPlatforms™ for Connected Products"
E: [email protected]
W: https://www.foundries.io
#6 lore raw

Hi Mike

Quoted 8 lines · Michael Scott
Quoted 5 lines · On 6/12/19 3:21 PM, [email protected] wrote:
Quoted 4 lines · Michael Scott

Actually, you can ignore this patch. We debugged the actual race condition contributing to the confusion, and that developer will submit a new patch with that fix. We can review if that patch makes more sense (even without tests).

Quoted 6 lines
Quoted 2 lines

Well, this patch merged earlier this evening as tested passed. Is that a problem?

Not a problem at all. I believe we also kept this change when we debugged the actual race condition.

Wrong patch you're pointing to here? I'm guessing you meant
https://patchwork.openembedded.org/patch/161440/

Signature · 1 line
Alex Kiernan
#7 lore raw

Hi Alex and Richard,

Quoted 14 lines · Alex Kiernan

Hi Mike

Quoted 11 lines · Michael Scott
Quoted 7 lines · On 6/12/19 3:21 PM, [email protected] wrote:
Quoted 4 lines · Michael Scott

Actually, you can ignore this patch. We debugged the actual race condition contributing to the confusion, and that developer will submit a new patch with that fix. We can review if that patch makes more sense (even without tests).

Well, this patch merged earlier this evening as tested passed. Is that a problem?

Quoted 6 lines
Quoted 3 lines

Not a problem at all. I believe we also kept this change when we debugged the actual race condition.

Wrong patch you're pointing to here? I'm guessing you meant
https://patchwork.openembedded.org/patch/161440/

You are 100% correct. I was checking email on the phone and it trimmed the subject line.

Please ignore my comments with regard to this patch.

Richard: You are still correct in that the u-boot signing process needs tests.

My apologies,

- Mike

Quoted 5 lines

--
Alex Kiernan

#8 lore raw
In reply to Alex Kiernan
Quoted 20 lines · Alex Kiernan
Quoted 18 lines · Richard Purdie
Quoted 16 lines · Alex Kiernan

Since UBOOT_DTB_BINARY empty means we don't need to inject signatures
into the U-Boot DTB, we can remove the dependencies between consumers
of
these two classes and resolve a circular dependency between u- boot
and
kernel.

---

 meta/classes/kernel-fitimage.bbclass | 2 +-
 meta/classes/uboot-sign.bbclass      | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
Quoted 5 lines
Quoted 2 lines

Really wish we had tests and documentation for these classes...

I know... I have a dread anytime anyone touches it, me included... I sat on this change for a couple of weeks too.

I also have little idea what to do with the patches, I just don't have enough information to make any informed decision here :/.

Quoted 9 lines

The truth is the pair of them are fragile and hopelessly intertwined, but without tests they're never going to get rewritten, so I might try and take some of that on (or get someone here to do it) as I still have multiple issues with them - signing doesn't really work the way I want, I still have a circular dependency I've not tracked down, doubtless other things I can't immediately bring to mind.

If we were to add some tests around it, what would you pull out as the simplest thing that it could do which would be valuable?

I don't know enough about what its doing or how people are using it to make a useful comment on that.

I'd suggest whoever writes the tests gets to document and test the way they use it. They can then modify and improve the code such that the tests keep working. If other untested usecases break, that would be unfortunate and we'd want to add testcases if they got fixed.

I'd be quite happy to work to such a policy (within reason).

Cheers,

Richard