Skip to contentSkip to conversation

avb2.0: fix multiple compilation issues in sandbox

PATCH New Igor Opaniuk 3 participants 7 messages Jul 17, 2018 – Jul 26, 2018

lore
Share & tools
lore
#0 lore raw

v2 cover avb2.0: fix multiple compilation issues in sandbox

This series of two patches fixes compilation issues when AVB 2.0 is enabled for the 'sandbox' architecture:

1. Since libavb library alone is highly portable, it introduce dedicated Kconfig symbol for AVB compiler-dependent operations, so it's possible to build libavb separately.
2. Add CONFIG_FASTBOOT dependency, as fastboot buffer is re-used in partition verification operations.
3. Use blk_dread()/blk_dwrite() in mmc_read()/mmc_write() AVB operation implementations. This fixes compilation issues when CONFIG_BLK is enabled.

Changes for v2:
- Updated eb81cae89f ("avb2.0: add proper dependencies") commit message (added more details).
- Extended description of AVB_VERIFY Kconfig symbol.
- Replaced CONFIG_LIBAVB to CONFIG_AVB_VERIFY in common/Makefile.

Igor Opaniuk (2):
avb2.0: add proper dependencies
avb2.0: use block API in AVB ops

 cmd/Kconfig         |  2 +-
 common/Kconfig      | 10 ++++++++++
 common/Makefile     |  2 +-
 common/avb_verify.c |  9 +++++----
 doc/README.avb2     |  1 +
 5 files changed, 18 insertions(+), 6 deletions(-)

--
2.7.4

#1 lore raw

PATCH v2 1/2 avb2.0: add proper dependencies

1. Since libavb library alone is highly portable, introduce dedicated Kconfig symbol for AVB bootloader-dependent operations, so it's possible to build libavb separately. AVB bootloader-dependent operations include:
* Helpers to process strings in order to build OS bootargs.
* Helpers to access MMC, similar to drivers/fastboot/fb_mmc.c.
* Helpers to alloc/init/free avb ops.
2. Add CONFIG_FASTBOOT dependency, as fastboot buffer is re-used in partition verification operations.

---
 cmd/Kconfig     |  2 +-
 common/Kconfig  | 10 ++++++++++
 common/Makefile |  2 +-
 doc/README.avb2 |  1 +
 4 files changed, 13 insertions(+), 2 deletions(-)
cmd/Kconfig +1 -1
index aec2090..b3e030c 100644
@@ -1771,7 +1771,7 @@ config CMD_TRACE
 
 config CMD_AVB
 	bool "avb - Android Verified Boot 2.0 operations"
-	depends on LIBAVB
+	depends on AVB_VERIFY
 	default n
 	help
 	  Enables a "avb" command to perform verification of partitions using
common/Kconfig +10 -0
index 4c7a1a9..04fcb91 100644
@@ -631,6 +631,16 @@ config HASH
 	  and the algorithms it supports are defined in common/hash.c. See
 	  also CMD_HASH for command-line access.
 
+config AVB_VERIFY
+	bool "Build Android Verified Boot operations"
+	depends on LIBAVB && FASTBOOT
+	help
+	  This option enables compilation of bootloader-dependent operations,
+	  used by Android Verified Boot 2.0 library (libavb). Includes:
+	    * Helpers to process strings in order to build OS bootargs.
+	    * Helpers to access MMC, similar to drivers/fastboot/fb_mmc.c.
+	    * Helpers to alloc/init/free avb ops.
+
 endmenu
 
 menu "Update support"
common/Makefile +1 -1
index 66584f8..7100541 100644
@@ -121,4 +121,4 @@ obj-$(CONFIG_$(SPL_)LOG_CONSOLE) += log_console.o
 obj-y += s_record.o
 obj-y += xyzModem.o
 
-obj-$(CONFIG_LIBAVB) += avb_verify.o
+obj-$(CONFIG_AVB_VERIFY) += avb_verify.o
doc/README.avb2 +1 -0
index 67784b5..120279f 100644
@@ -58,6 +58,7 @@ Slot verification result: ERROR_IO
 -----------------------------------
 The following options must be enabled:
 CONFIG_LIBAVB=y
+CONFIG_AVB_VERIFY=y
 CONFIG_CMD_AVB=y
 
 
Signature · 1 line
2.7.4
#2 lore raw

PATCH v2 1/2 avb2.0: add proper dependencies

Hi Igor,

Quoted 9 lines · Igor Opaniuk

1. Since libavb library alone is highly portable, introduce dedicated Kconfig symbol for AVB bootloader-dependent operations, so it's possible to build libavb separately. AVB bootloader-dependent operations include:
* Helpers to process strings in order to build OS bootargs.
* Helpers to access MMC, similar to drivers/fastboot/fb_mmc.c.
* Helpers to alloc/init/free avb ops.
2. Add CONFIG_FASTBOOT dependency, as fastboot buffer is re-used in partition verification operations.

Quoted 8 lines
---
 cmd/Kconfig     |  2 +-
 common/Kconfig  | 10 ++++++++++
 common/Makefile |  2 +-
 doc/README.avb2 |  1 +
 4 files changed, 13 insertions(+), 2 deletions(-)

With this patch I am now able to compile libavb natively for x86_64, as well as cross-compile it for arm and aarch64, w/o the avb_verify wrapper. Thanks for the improvements in the patch/Kconfig description.

#3 lore raw

PATCH v2 1/2 avb2.0: add proper dependencies

In reply to Igor Opaniuk
Quoted 9 lines · Igor Opaniuk

1. Since libavb library alone is highly portable, introduce dedicated Kconfig symbol for AVB bootloader-dependent operations, so it's possible to build libavb separately. AVB bootloader-dependent operations include:
* Helpers to process strings in order to build OS bootargs.
* Helpers to access MMC, similar to drivers/fastboot/fb_mmc.c.
* Helpers to alloc/init/free avb ops.
2. Add CONFIG_FASTBOOT dependency, as fastboot buffer is re-used in partition verification operations.

Quoted 4 lines

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180726/18e32950/attachment.sig>
#4 lore raw

PATCH v2 2/2 avb2.0: use block API in AVB ops

In reply to Igor Opaniuk

Use blk_dread()/blk_dwrite() in mmc_read()/mmc_write() AVB operation implementations. This fixes compilation issues when CONFIG_BLK is enabled.

---
 common/avb_verify.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
common/avb_verify.c +5 -4
index f9a00f8..20e35ad 100644
@@ -5,6 +5,7 @@
  */
 
 #include <avb_verify.h>
+#include <blk.h>
 #include <fastboot.h>
 #include <image.h>
 #include <malloc.h>
@@ -288,8 +289,8 @@ static unsigned long mmc_read_and_flush(struct mmc_part *part,
 		tmp_buf = buffer;
 	}
 
-	blks = part->mmc->block_dev.block_read(part->mmc_blk,
-				start, sectors, tmp_buf);
+	blks = blk_dread(part->mmc_blk,
+			 start, sectors, tmp_buf);
 	/* flush cache after read */
 	flush_cache((ulong)tmp_buf, sectors * part->info.blksz);
 
@@ -327,8 +328,8 @@ static unsigned long mmc_write(struct mmc_part *part, lbaint_t start,
 		tmp_buf = buffer;
 	}
 
-	return part->mmc->block_dev.block_write(part->mmc_blk,
-				start, sectors, tmp_buf);
+	return blk_dwrite(part->mmc_blk,
+			  start, sectors, tmp_buf);
 }
 
 static struct mmc_part *get_partition(AvbOps *ops, const char *partition)
Signature · 1 line
2.7.4
#5 lore raw

PATCH v2 2/2 avb2.0: use block API in AVB ops

Quoted 46 lines · Igor Opaniuk

Use blk_dread()/blk_dwrite() in mmc_read()/mmc_write() AVB operation implementations. This fixes compilation issues when CONFIG_BLK is enabled.

---
 common/avb_verify.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
common/avb_verify.c +5 -4
index f9a00f8..20e35ad 100644
@@ -5,6 +5,7 @@
  */
 
 #include <avb_verify.h>
+#include <blk.h>
 #include <fastboot.h>
 #include <image.h>
 #include <malloc.h>
@@ -288,8 +289,8 @@ static unsigned long mmc_read_and_flush(struct mmc_part *part,
 		tmp_buf = buffer;
 	}
 
-	blks = part->mmc->block_dev.block_read(part->mmc_blk,
-				start, sectors, tmp_buf);
+	blks = blk_dread(part->mmc_blk,
+			 start, sectors, tmp_buf);
 	/* flush cache after read */
 	flush_cache((ulong)tmp_buf, sectors * part->info.blksz);
 
@@ -327,8 +328,8 @@ static unsigned long mmc_write(struct mmc_part *part, lbaint_t start,
 		tmp_buf = buffer;
 	}
 
-	return part->mmc->block_dev.block_write(part->mmc_blk,
-				start, sectors, tmp_buf);
+	return blk_dwrite(part->mmc_blk,
+			  start, sectors, tmp_buf);
 }
 
 static struct mmc_part *get_partition(AvbOps *ops, const char *partition)
Signature · 1 line
2.7.4

I confirm this patch fixes below compilation failure on sandbox (LIBAVB=y, AVB_VERIFY=y, FASTBOOT=y, BLK=y):

common/avb_verify.c: In function ‘mmc_read_and_flush’:
common/avb_verify.c:291:18: error: ‘struct mmc’ has no member named ‘block_dev’
blks = part->mmc->block_dev.block_read(part->mmc_blk,

                  ^~

common/avb_verify.c: In function ‘mmc_write’:
common/avb_verify.c:330:18: error: ‘struct mmc’ has no member named ‘block_dev’
return part->mmc->block_dev.block_write(part->mmc_blk,

With this patch, avb_verify compiles equally well with BLK=y and BLK=n.

Thanks,
Eugeniu.

#6 lore raw

PATCH v2 2/2 avb2.0: use block API in AVB ops

In reply to Igor Opaniuk
Quoted 6 lines · Igor Opaniuk

Use blk_dread()/blk_dwrite() in mmc_read()/mmc_write() AVB operation implementations. This fixes compilation issues when CONFIG_BLK is enabled.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180726/029e4f7b/attachment.sig>