From c0ed4a68aecf0cf67d61c72c273fcd655682366f Mon Sep 17 00:00:00 2001 From: Ji Luo Date: Thu, 18 Jun 2020 10:52:37 +0800 Subject: [PATCH] MA-17390 Clean build warnings for android This commit eliminate the annoying build warning logs. Test: builds with buildman. Signed-off-by: Ji Luo Change-Id: Ia335dafe3f4c0eab08e011215b9de5d2974b8d0c (cherry picked from commit 85e0d429d19b8f9a62369a5f20e088644c488b1e) (cherry picked from commit 52471735760a8d3a410f88c144910a07a161028d) --- arch/arm/mach-imx/imx8/fdt.c | 4 ++-- board/freescale/imx8mp_evk/imx8mp_evk.c | 1 + common/spl/spl_mmc.c | 2 +- drivers/crypto/fsl_caam.c | 2 ++ drivers/fastboot/fb_fsl/bcb.c | 1 + .../fastboot/fb_fsl/fastboot_lock_unlock.c | 7 ++++-- drivers/fastboot/fb_fsl/fb_fsl_boot.c | 13 ++++++++--- drivers/fastboot/fb_fsl/fb_fsl_command.c | 2 +- include/trusty/keymaster.h | 22 +++++++++++++++++++ include/trusty/sysdeps.h | 1 + lib/avb/Makefile | 1 + lib/avb/fsl/fsl_avb_ab_flow.c | 1 + lib/avb/fsl/fsl_avbkey.c | 4 ++++ lib/avb/fsl/utils.c | 1 + lib/avb/libavb_atx/avb_atx_ops.h | 2 +- lib/avb/libavb_atx/avb_atx_types.h | 2 +- lib/avb/libavb_atx/libavb_atx.h | 2 +- lib/libavb/avb_slot_verify.c | 8 +++---- lib/trusty/ql-tipc/hwcrypto.c | 3 +++ lib/trusty/ql-tipc/libtipc.c | 2 ++ lib/trusty/ql-tipc/sysdeps/sysdeps_uboot.c | 2 ++ 21 files changed, 67 insertions(+), 16 deletions(-) diff --git a/arch/arm/mach-imx/imx8/fdt.c b/arch/arm/mach-imx/imx8/fdt.c index b331f7d6d5..551e00fd9e 100644 --- a/arch/arm/mach-imx/imx8/fdt.c +++ b/arch/arm/mach-imx/imx8/fdt.c @@ -155,7 +155,7 @@ static int fdt_edma_get_channel_id(u32 *regs, int index, struct edma_ch_map *edm return ch_id; } -static void update_fdt_edma_nodes(void *blob) +static __maybe_unused void update_fdt_edma_nodes(void *blob) { struct edma_ch_map edma_qm[] = { { SC_R_DMA_0_CH0, 0x5a200000, 32, "/dma-controller@5a1f0000"}, @@ -384,7 +384,7 @@ static void update_fdt_with_owned_resources_legacy(void *blob) } } -static void update_fdt_with_owned_resources(void *blob) +static __maybe_unused void update_fdt_with_owned_resources(void *blob) { /* * Traverses the fdt nodes, check its power domain and use diff --git a/board/freescale/imx8mp_evk/imx8mp_evk.c b/board/freescale/imx8mp_evk/imx8mp_evk.c index b4923b5be2..ef30784e0e 100644 --- a/board/freescale/imx8mp_evk/imx8mp_evk.c +++ b/board/freescale/imx8mp_evk/imx8mp_evk.c @@ -27,6 +27,7 @@ #include #include #include +#include DECLARE_GLOBAL_DATA_PTR; diff --git a/common/spl/spl_mmc.c b/common/spl/spl_mmc.c index 8a7fa01df9..d3ce1efc5f 100644 --- a/common/spl/spl_mmc.c +++ b/common/spl/spl_mmc.c @@ -61,7 +61,7 @@ static __maybe_unused unsigned long spl_mmc_raw_uboot_offset(int part) return 0; } -#if defined(CONFIG_IMX_TRUSTY_OS) +#if defined(CONFIG_DUAL_BOOTLOADER) int mmc_load_image_raw_sector_dual_uboot(struct spl_image_info *spl_image, struct mmc *mmc); #endif diff --git a/drivers/crypto/fsl_caam.c b/drivers/crypto/fsl_caam.c index fdb3004ad7..02cc82bf79 100644 --- a/drivers/crypto/fsl_caam.c +++ b/drivers/crypto/fsl_caam.c @@ -421,6 +421,7 @@ static void kick_trng(u32 ent_delay) /* * Descriptors to instantiate SH0, SH1, load the keys */ +#ifndef CONFIG_ARCH_IMX8 static const u32 rng_inst_sh0_desc[] = { /* Header, don't setup the size */ CAAM_HDR_CTYPE | CAAM_HDR_ONE | CAAM_HDR_START_INDEX(0), @@ -451,6 +452,7 @@ static const u32 rng_inst_load_keys[] = { /* Generate the Key */ CAAM_PROTOP_CTYPE | CAAM_C1_RNG | BM_ALGO_RNG_SK | ALGO_RNG_GENERATE, }; +#endif static void do_inst_desc(u32 *desc, u32 status) { diff --git a/drivers/fastboot/fb_fsl/bcb.c b/drivers/fastboot/fb_fsl/bcb.c index 58073219e5..a698ec8c99 100644 --- a/drivers/fastboot/fb_fsl/bcb.c +++ b/drivers/fastboot/fb_fsl/bcb.c @@ -11,6 +11,7 @@ #include #include #include "bcb.h" +#include "command.h" #define ALIGN_BYTES 64 /*armv7 cache line need 64 bytes aligned */ static ulong get_block_size(char *ifname, int dev) diff --git a/drivers/fastboot/fb_fsl/fastboot_lock_unlock.c b/drivers/fastboot/fb_fsl/fastboot_lock_unlock.c index 12c5c6b648..9c4102dc2e 100644 --- a/drivers/fastboot/fb_fsl/fastboot_lock_unlock.c +++ b/drivers/fastboot/fb_fsl/fastboot_lock_unlock.c @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include @@ -19,6 +20,8 @@ #include #endif +#include + #ifdef FASTBOOT_ENCRYPT_LOCK #include @@ -140,7 +143,7 @@ static int generate_salt(unsigned char* salt) { } -static FbLockState decrypt_lock_store(unsigned char *bdata) { +static __maybe_unused FbLockState decrypt_lock_store(unsigned char *bdata) { int p = 0, ret; ALLOC_CACHE_ALIGN_BUFFER(uint8_t, plain_data, ENDATA_LEN); @@ -188,7 +191,7 @@ static FbLockState decrypt_lock_store(unsigned char *bdata) { return plain_data[ENDATA_LEN-1]; } -static int encrypt_lock_store(FbLockState lock, unsigned char* bdata) { +static __maybe_unused int encrypt_lock_store(FbLockState lock, unsigned char* bdata) { unsigned int p = 0; int ret; int salt_len = generate_salt(bdata); diff --git a/drivers/fastboot/fb_fsl/fb_fsl_boot.c b/drivers/fastboot/fb_fsl/fb_fsl_boot.c index ca2c421177..a291b3efc8 100644 --- a/drivers/fastboot/fb_fsl/fb_fsl_boot.c +++ b/drivers/fastboot/fb_fsl/fb_fsl_boot.c @@ -40,6 +40,7 @@ #ifdef CONFIG_IMX_TRUSTY_OS #include "u-boot/sha256.h" #include +#include #endif #include "fb_fsl_common.h" @@ -439,8 +440,12 @@ fail: } #endif /* CONFIG_DUAL_BOOTLOADER && CONFIG_AVB_ATX */ -int trusty_setbootparameter(struct andr_img_hdr *hdr, AvbABFlowResult avb_result, - AvbSlotVerifyData *avb_out_data) { +#ifdef CONFIG_VENDOR_BOOT_SUPPORT +int trusty_setbootparameter(struct boot_img_hdr_v3 *hdr, +#else +int trusty_setbootparameter(struct andr_img_hdr *hdr, +#endif + AvbABFlowResult avb_result, AvbSlotVerifyData *avb_out_data) { #if defined(CONFIG_DUAL_BOOTLOADER) && defined(CONFIG_AVB_ATX) uint8_t vbh[AVB_SHA256_DIGEST_SIZE]; #endif @@ -492,7 +497,9 @@ int trusty_setbootparameter(struct andr_img_hdr *hdr, AvbABFlowResult avb_result NULL, 0); #endif +#if defined(CONFIG_DUAL_BOOTLOADER) && defined(CONFIG_AVB_ATX) fail: +#endif return ret; } #endif @@ -851,7 +858,7 @@ int do_boota(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { dt_entry = (struct dt_table_entry *)((ulong)dt_img + be32_to_cpu(dt_img->dt_entries_offset)); fdt_size = be32_to_cpu(dt_entry->dt_size); - memcpy((void *)fdt_addr, (void *)((ulong)dt_img + + memcpy((void *)(ulong)fdt_addr, (void *)((ulong)dt_img + be32_to_cpu(dt_entry->dt_offset)), fdt_size); #endif /*CONFIG_OF_LIBFDT*/ diff --git a/drivers/fastboot/fb_fsl/fb_fsl_command.c b/drivers/fastboot/fb_fsl/fb_fsl_command.c index 679757a0a6..301c776d77 100644 --- a/drivers/fastboot/fb_fsl/fb_fsl_command.c +++ b/drivers/fastboot/fb_fsl/fb_fsl_command.c @@ -402,7 +402,7 @@ static FbLockState do_fastboot_unlock(bool force) char *serial = get_serial(); status = trusty_verify_secure_unlock(fastboot_buf_addr, fastboot_bytes_received, - serial, 16); + (uint8_t *)serial, 16); if (status < 0) { printf("verify secure unlock credential fail due Trusty return %d\n", status); return FASTBOOT_LOCK_ERROR; diff --git a/include/trusty/keymaster.h b/include/trusty/keymaster.h index 3776dbc5a5..a44ae21987 100644 --- a/include/trusty/keymaster.h +++ b/include/trusty/keymaster.h @@ -85,6 +85,28 @@ int trusty_set_attestation_key(const uint8_t *key, uint32_t key_size, int trusty_append_attestation_cert_chain(const uint8_t *cert, uint32_t cert_size, keymaster_algorithm_t algorithm); +/* + * Set encrypted Keymaster attestation key. Returns one of trusty_err. + * + * @key: buffer containing encrypted key + * @key_size: size of key in bytes + * @algorithm: one of KM_ALGORITHM_RSA or KM_ALGORITHM_EC + */ +int trusty_set_attestation_key_enc(const uint8_t *key, + uint32_t key_size, + keymaster_algorithm_t algorithm); + +/* + * Append encrypted certificate to Keymaster attestation certificate chain. Returns + * one of trusty_err. + * + * @cert: buffer containing encrypted certificate + * @cert_size: size of certificate in bytes + * @algorithm: one of KM_ALGORITHM_RSA or KM_ALGORITHM_EC + */ +int trusty_append_attestation_cert_chain_enc(const uint8_t *cert, + uint32_t cert_size, + keymaster_algorithm_t algorithm); /* * Reads a CA Request from Keymaster. On success allocates a new CA Request * message at |*ca_request_p|, and the caller takes ownership. Returns one diff --git a/include/trusty/sysdeps.h b/include/trusty/sysdeps.h index 1f26bbd4c3..b21a29ca08 100644 --- a/include/trusty/sysdeps.h +++ b/include/trusty/sysdeps.h @@ -31,6 +31,7 @@ */ #include #include +#include /* * These attribute macros may need to be adjusted if not using gcc or clang. diff --git a/lib/avb/Makefile b/lib/avb/Makefile index 21af6a2029..0c5e2cf011 100644 --- a/lib/avb/Makefile +++ b/lib/avb/Makefile @@ -8,6 +8,7 @@ subdir-ccflags-y += -I./lib \ -Wno-type-limits \ -Wno-psabi \ -Wno-unused-parameter \ + -Wno-sign-compare \ -ffunction-sections \ -std=gnu99 diff --git a/lib/avb/fsl/fsl_avb_ab_flow.c b/lib/avb/fsl/fsl_avb_ab_flow.c index 4382e413c5..bf9ac53f2a 100644 --- a/lib/avb/fsl/fsl_avb_ab_flow.c +++ b/lib/avb/fsl/fsl_avb_ab_flow.c @@ -11,6 +11,7 @@ #include "utils.h" #include "fsl_caam.h" #include "fsl_avbkey.h" +#include "hang.h" #if defined(CONFIG_DUAL_BOOTLOADER) || !defined(CONFIG_SPL_BUILD) static const char* slot_suffixes[2] = {"_a", "_b"}; diff --git a/lib/avb/fsl/fsl_avbkey.c b/lib/avb/fsl/fsl_avbkey.c index 86082015dc..2ae7cccfec 100644 --- a/lib/avb/fsl/fsl_avbkey.c +++ b/lib/avb/fsl/fsl_avbkey.c @@ -13,6 +13,8 @@ #include #include #include +#include +#include #include #include "trusty/avb.h" @@ -792,7 +794,9 @@ int check_rpmb_blob(struct mmc *mmc) int ret = 0; char original_part; struct keyslot_package kp; +#if CONFIG_IS_ENABLED(BLK) struct blk_desc *dev_desc = NULL; +#endif read_keyslot_package(&kp); if (strcmp(kp.magic, KEYPACK_MAGIC)) { diff --git a/lib/avb/fsl/utils.c b/lib/avb/fsl/utils.c index 94a72e8e6a..3e70d576c8 100644 --- a/lib/avb/fsl/utils.c +++ b/lib/avb/fsl/utils.c @@ -6,6 +6,7 @@ + */ #include #include +#include #include "debug.h" #include "utils.h" diff --git a/lib/avb/libavb_atx/avb_atx_ops.h b/lib/avb/libavb_atx/avb_atx_ops.h index 53c898d623..e7bd686f3d 100644 --- a/lib/avb/libavb_atx/avb_atx_ops.h +++ b/lib/avb/libavb_atx/avb_atx_ops.h @@ -30,7 +30,7 @@ #ifndef AVB_ATX_OPS_H_ #define AVB_ATX_OPS_H_ -#include +#include <../lib/libavb/libavb.h> #include "avb_atx_types.h" diff --git a/lib/avb/libavb_atx/avb_atx_types.h b/lib/avb/libavb_atx/avb_atx_types.h index e78bbfa78c..a4563c0d08 100644 --- a/lib/avb/libavb_atx/avb_atx_types.h +++ b/lib/avb/libavb_atx/avb_atx_types.h @@ -30,7 +30,7 @@ #ifndef AVB_ATX_TYPES_H_ #define AVB_ATX_TYPES_H_ -#include +#include <../lib/libavb/libavb.h> #ifdef __cplusplus extern "C" { diff --git a/lib/avb/libavb_atx/libavb_atx.h b/lib/avb/libavb_atx/libavb_atx.h index 839c0afa98..3d830ac831 100644 --- a/lib/avb/libavb_atx/libavb_atx.h +++ b/lib/avb/libavb_atx/libavb_atx.h @@ -25,7 +25,7 @@ #ifndef LIBAVB_ATX_H_ #define LIBAVB_ATX_H_ -#include +#include <../lib/libavb/libavb.h> /* The AVB_INSIDE_LIBAVB_ATX_H preprocessor symbol is used to enforce * library users to include only this file. All public interfaces, and diff --git a/lib/libavb/avb_slot_verify.c b/lib/libavb/avb_slot_verify.c index 108cf29d64..436983771c 100644 --- a/lib/libavb/avb_slot_verify.c +++ b/lib/libavb/avb_slot_verify.c @@ -16,9 +16,9 @@ #include "avb_version.h" #include #include +#include #if defined(CONFIG_IMX_TRUSTY_OS) && !defined(CONFIG_AVB_ATX) #include "trusty/hwcrypto.h" -#include #endif /* Maximum number of partitions that can be loaded with avb_slot_verify(). */ @@ -295,7 +295,7 @@ static AvbSlotVerifyResult load_and_verify_hash_partition( bool image_preloaded = false; uint8_t* digest; size_t digest_len; - const char* found; + const char* found = NULL; uint64_t image_size; size_t expected_digest_len = 0; uint8_t expected_digest_buf[AVB_SHA512_DIGEST_SIZE]; @@ -395,7 +395,9 @@ static AvbSlotVerifyResult load_and_verify_hash_partition( // Although only one of the type might be used, we have to defined the // structure here so that they would live outside the 'if/else' scope to be // used later. +#if !defined(CONFIG_IMX_TRUSTY_OS) || defined(CONFIG_AVB_ATX) || defined(CONFIG_XEN) AvbSHA256Ctx sha256_ctx; +#endif AvbSHA512Ctx sha512_ctx; size_t image_size_to_hash = hash_desc.image_size; // If we allow verification error and the whole partition is smaller than @@ -412,8 +414,6 @@ static AvbSlotVerifyResult load_and_verify_hash_partition( ret = AVB_SLOT_VERIFY_RESULT_ERROR_OOM; goto out; } - uint32_t round_buf_size = ROUND(hash_desc.salt_len + image_size_to_hash, - ARCH_DMA_MINALIGN); hash_buf = (void *)CONFIG_FASTBOOT_BUF_ADDR; avb_memcpy(hash_buf, desc_salt, hash_desc.salt_len); diff --git a/lib/trusty/ql-tipc/hwcrypto.c b/lib/trusty/ql-tipc/hwcrypto.c index 051a505aa9..9de113a166 100644 --- a/lib/trusty/ql-tipc/hwcrypto.c +++ b/lib/trusty/ql-tipc/hwcrypto.c @@ -27,7 +27,10 @@ #include #include #include +#include #include "common.h" +#include +#include #define LOCAL_LOG 0 #define CAAM_KB_HEADER_LEN 48 diff --git a/lib/trusty/ql-tipc/libtipc.c b/lib/trusty/ql-tipc/libtipc.c index 30d4bbf854..92c842be2c 100644 --- a/lib/trusty/ql-tipc/libtipc.c +++ b/lib/trusty/ql-tipc/libtipc.c @@ -31,6 +31,8 @@ #include #include #include +#include +#include #define LOCAL_LOG 0 diff --git a/lib/trusty/ql-tipc/sysdeps/sysdeps_uboot.c b/lib/trusty/ql-tipc/sysdeps/sysdeps_uboot.c index b42cd20d4f..589e9e12ef 100644 --- a/lib/trusty/ql-tipc/sysdeps/sysdeps_uboot.c +++ b/lib/trusty/ql-tipc/sysdeps/sysdeps_uboot.c @@ -24,6 +24,8 @@ #include +#include +#include #include #include #include -- 2.17.1