From adf056292cdb9ae810fc64127aa9638abf072f3e Mon Sep 17 00:00:00 2001 From: zhang sanshan Date: Mon, 30 Oct 2017 17:19:45 +0800 Subject: [PATCH] MA-10552-10 [Android] enable A/B system in android CAAM do not work in imx8. disable FASTBOOT_ENCRYPT_LOCK for lock&unlock and return 0 for fsl avb call back on imx8 device. Change-Id: I79e2de2571a922ae22c2a52f0beb661762e11dd5 Signed-off-by: zhang sanshan --- drivers/usb/gadget/fastboot_lock_unlock.h | 2 ++ lib/avb/Makefile | 1 + lib/avb/fsl/fsl_avb.c | 1 - lib/avb/fsl/fsl_avbkey.c | 39 +++++++++++++++++++++++ 4 files changed, 42 insertions(+), 1 deletion(-) diff --git a/drivers/usb/gadget/fastboot_lock_unlock.h b/drivers/usb/gadget/fastboot_lock_unlock.h index 380be1aa6e..f08ab269bb 100644 --- a/drivers/usb/gadget/fastboot_lock_unlock.h +++ b/drivers/usb/gadget/fastboot_lock_unlock.h @@ -34,7 +34,9 @@ #define ALIGN_BYTES 64 /*armv7 cache line need 64 bytes aligned */ //#define FASTBOOT_LOCK_DEBUG +#ifdef CONFIG_FSL_CAAM_KB #define FASTBOOT_ENCRYPT_LOCK +#endif #ifdef FASTBOOT_LOCK_DEBUG #define FB_DEBUG(format, ...) printf(format, ##__VA_ARGS__) diff --git a/lib/avb/Makefile b/lib/avb/Makefile index a80a17e298..ea0fd22d38 100644 --- a/lib/avb/Makefile +++ b/lib/avb/Makefile @@ -5,6 +5,7 @@ subdir-ccflags-y += -D_FILE_OFFSET_BITS=64 \ -Wall \ -Wextra \ -Wformat=2 \ + -Wno-type-limits \ -Wno-psabi \ -Wno-unused-parameter \ -ffunction-sections \ diff --git a/lib/avb/fsl/fsl_avb.c b/lib/avb/fsl/fsl_avb.c index d4c4d72d6c..59c7c0af96 100644 --- a/lib/avb/fsl/fsl_avb.c +++ b/lib/avb/fsl/fsl_avb.c @@ -9,7 +9,6 @@ #include #include -#include #include "../../../drivers/usb/gadget/fastboot_lock_unlock.h" #include diff --git a/lib/avb/fsl/fsl_avbkey.c b/lib/avb/fsl/fsl_avbkey.c index ff55a3a169..0d99e8c684 100644 --- a/lib/avb/fsl/fsl_avbkey.c +++ b/lib/avb/fsl/fsl_avbkey.c @@ -7,7 +7,9 @@ #include #include +#ifdef CONFIG_FSL_CAAM_KB #include +#endif #include #include #include @@ -40,6 +42,42 @@ #define RESULT_ERROR -1 #define RESULT_OK 0 +#ifndef CONFIG_FSL_CAAM_KB +/* ARM64 won't avbkey and rollback index in this stage directly. */ +int avbkey_init(uint8_t *plainkey, uint32_t keylen) { + return 0; +} + +int rbkidx_erase(void) { + return 0; +} + +/* + * In no security enhanced ARM64, we cannot protect public key. + * So that we choose to trust the key from vbmeta image + */ +AvbIOResult fsl_validate_vbmeta_public_key_rpmb(AvbOps* ops, + const uint8_t* public_key_data, + size_t public_key_length, + const uint8_t* public_key_metadata, + size_t public_key_metadata_length, + bool* out_is_trusted) { + *out_is_trusted = true; + return AVB_IO_RESULT_OK; +} + +/* In no security enhanced ARM64, rollback index has no protection so no use it */ +AvbIOResult fsl_write_rollback_index_rpmb(AvbOps* ops, size_t rollback_index_slot, + uint64_t rollback_index) { + return AVB_IO_RESULT_OK; + +} +AvbIOResult fsl_read_rollback_index_rpmb(AvbOps* ops, size_t rollback_index_slot, + uint64_t* out_rollback_index) { + *out_rollback_index = 0; + return AVB_IO_RESULT_OK; +} +#else static int mmc_dev_no = -1; static struct mmc *get_mmc(void) { @@ -1074,6 +1112,7 @@ fail: free(plain_idx); return ret; } +#endif /* CONFIG_FSL_CAAM_KB */ #if defined(AVB_RPMB) && defined(CONFIG_AVB_ATX) /* Reads permanent |attributes| data. There are no restrictions on where this -- 2.17.1