diff --git a/cmd/efidebug.c b/cmd/efidebug.c index 6e36575a94..0bf7b8856c 100644 --- a/cmd/efidebug.c +++ b/cmd/efidebug.c @@ -341,27 +341,27 @@ static int do_efi_capsule(struct cmd_tbl *cmdtp, int flag, #endif /* CONFIG_EFI_HAVE_CAPSULE_SUPPORT */ /** - * efi_get_device_handle_info() - get information of UEFI device + * efi_get_device_path_text() - get device path text * - * @handle: Handle of UEFI device - * @dev_path_text: Pointer to text of device path - * Return: 0 on success, -1 on failure + * Return the text representation of the device path of a handle. * - * Currently return a formatted text of device path. + * @handle: handle of UEFI device + * Return: + * Pointer to the device path text or NULL. + * The caller is responsible for calling FreePool(). */ -static int efi_get_device_handle_info(efi_handle_t handle, u16 **dev_path_text) +static u16 *efi_get_device_path_text(efi_handle_t handle) { - struct efi_device_path *dp; + struct efi_handler *handler; efi_status_t ret; - ret = EFI_CALL(BS->open_protocol(handle, &efi_guid_device_path, - (void **)&dp, NULL /* FIXME */, NULL, - EFI_OPEN_PROTOCOL_GET_PROTOCOL)); - if (ret == EFI_SUCCESS) { - *dev_path_text = efi_dp_str(dp); - return 0; + ret = efi_search_protocol(handle, &efi_guid_device_path, &handler); + if (ret == EFI_SUCCESS && handler->protocol_interface) { + struct efi_device_path *dp = handler->protocol_interface; + + return efi_dp_str(dp); } else { - return -1; + return NULL; } } @@ -401,7 +401,8 @@ static int do_efi_show_devices(struct cmd_tbl *cmdtp, int flag, printf("Device%.*s Device Path\n", EFI_HANDLE_WIDTH - 6, spc); printf("%.*s ====================\n", EFI_HANDLE_WIDTH, sep); for (i = 0; i < num; i++) { - if (!efi_get_device_handle_info(handles[i], &dev_path_text)) { + dev_path_text = efi_get_device_path_text(handles[i]); + if (dev_path_text) { printf("%p %ls\n", handles[i], dev_path_text); efi_free_pool(dev_path_text); } diff --git a/doc/develop/uefi/uefi.rst b/doc/develop/uefi/uefi.rst index b3494c22e0..4f2b8b036d 100644 --- a/doc/develop/uefi/uefi.rst +++ b/doc/develop/uefi/uefi.rst @@ -180,6 +180,12 @@ Set up boot parameters on your board:: efidebug boot add -b 1 HELLO mmc 0:1 /helloworld.efi.signed "" +Since kernel 5.7 there's an alternative way of loading an initrd using +LoadFile2 protocol if CONFIG_EFI_LOAD_FILE2_INITRD is enabled. +The initrd path can be specified with:: + + efidebug boot add -b ABE0 'kernel' mmc 0:1 Image -i mmc 0:1 initrd + Now your board can run the signed image via the boot manager (see below). You can also try this sequence by running Pytest, test_efi_secboot, on the sandbox @@ -213,7 +219,63 @@ non-volatile variables. When calling the variable services via the OP-TEE API U-Boot's OP-TEE supplicant relays calls to the RPMB driver which has to be enabled via CONFIG_SUPPORT_EMMC_RPMB=y. -[1] https://optee.readthedocs.io/ - OP-TEE documentation +EDK2 Build instructions +*********************** + +.. code-block:: bash + + $ git clone https://github.com/tianocore/edk2.git + $ git clone https://github.com/tianocore/edk2-platforms.git + $ cd edk2 + $ git submodule init && git submodule update --init --recursive + $ cd .. + $ export WORKSPACE=$(pwd) + $ export PACKAGES_PATH=$WORKSPACE/edk2:$WORKSPACE/edk2-platforms + $ export ACTIVE_PLATFORM="Platform/StandaloneMm/PlatformStandaloneMmPkg/PlatformStandaloneMmRpmb.dsc" + $ export GCC5_AARCH64_PREFIX=aarch64-linux-gnu- + $ source edk2/edksetup.sh + $ make -C edk2/BaseTools + $ build -p $ACTIVE_PLATFORM -b RELEASE -a AARCH64 -t GCC5 -n `nproc` + +OP-TEE Build instructions +************************* + +.. code-block:: bash + + $ git clone https://github.com/OP-TEE/optee_os.git + $ cd optee_os + $ ln -s ../Build/MmStandaloneRpmb/RELEASE_GCC5/FV/BL32_AP_MM.fd + $ export ARCH=arm + $ CROSS_COMPILE32=arm-linux-gnueabihf- make -j32 CFG_ARM64_core=y \ + PLATFORM= CFG_STMM_PATH=BL32_AP_MM.fd CFG_RPMB_FS=y \ + CFG_RPMB_FS_DEV_ID=0 CFG_CORE_HEAP_SIZE=524288 CFG_RPMB_WRITE_KEY=1 \ + CFG_CORE_HEAP_SIZE=524288 CFG_CORE_DYN_SHM=y CFG_RPMB_TESTKEY=y \ + CFG_REE_FS=n CFG_CORE_ARM64_PA_BITS=48 CFG_TEE_CORE_LOG_LEVEL=1 \ + CFG_TEE_TA_LOG_LEVEL=1 CFG_SCTLR_ALIGNMENT_CHECK=n + +U-Boot Build instructions +************************* + +Although the StandAloneMM binary comes from EDK2, using and storing the +variables is currently available in U-Boot only. + +.. code-block:: bash + + $ git clone https://github.com/u-boot/u-boot.git + $ cd u-boot + $ export CROSS_COMPILE=aarch64-linux-gnu- + $ export ARCH= + $ make _defconfig + $ make menuconfig + +Enable ``CONFIG_OPTEE``, ``CONFIG_CMD_OPTEE_RPMB`` and ``CONFIG_EFI_MM_COMM_TEE`` + +.. warning:: + + - Your OP-TEE platform port must support Dynamic shared memory, since that's + the only kind of memory U-Boot supports for now. + +[1] https://optee.readthedocs.io/en/latest/building/efi_vars/stmm.html Executing the boot manager ~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -484,7 +546,21 @@ The load file 2 protocol can be used by the Linux kernel to load the initial RAM disk. U-Boot can be configured to provide an implementation with:: EFI_LOAD_FILE2_INITRD=y - EFI_INITRD_FILESPEC=interface dev:part path_to_initrd + +When the option is enabled the user can add the initrd path with the efidebug +command. + +Load options Boot#### have a FilePathList[] member. The first element of +the array (FilePathList[0]) is the EFI binary to execute. When an initrd +is specified the Device Path for the initrd is denoted by a VenMedia node +with the EFI_INITRD_MEDIA_GUID. Each entry of the array is terminated by the +'end of entire device path' subtype (0xff). If a user wants to define multiple +initrds, those must by separated by the 'end of this instance' identifier of +the end node (0x01). + +So our final format of the FilePathList[] is:: + + Loaded image - end node (0xff) - VenMedia - initrd_1 - [end node (0x01) - initrd_n ...] - end node (0xff) Links ----- diff --git a/doc/usage/index.rst b/doc/usage/index.rst index 5faf279f43..d330b14a17 100644 --- a/doc/usage/index.rst +++ b/doc/usage/index.rst @@ -32,6 +32,7 @@ Shell commands load loady mbr + mmc md pstore qfw diff --git a/doc/usage/mmc.rst b/doc/usage/mmc.rst new file mode 100644 index 0000000000..57284ed674 --- /dev/null +++ b/doc/usage/mmc.rst @@ -0,0 +1,212 @@ +.. SPDX-License-Identifier: GPL-2.0+: + +mmc command +============ + +Synopsis +-------- + +:: + + mmc info + mmc read addr blk# cnt + mmc write addr blk# cnt + mmc erase blk# cnt + mmc rescan + mmc part + mmc dev [dev] [part] + mmc list + mmc wp + mmc bootbus + mmc bootpart-resize + mmc partconf [boot_ack boot_partition partition_access] + mmc rst-function + +Description +----------- + +The mmc command is used to control MMC(eMMC/SD) device. + +The 'mmc info' command displays information (Manufacturer ID, OEM, Name, Bus Speed, Mode, ...) of MMC device. + +The 'mmc read' command reads raw data to memory address from MMC device with block offset and count. + +The 'mmc write' command writes raw data to MMC device from memory address with block offset and count. + + addr + memory address + blk# + start block offset + cnt + block count + +The 'mmc erase' command erases MMC device from block offset until count. + + blk# + start block offset + cnt + block count + +The 'mmc rescan' command scans the available MMC device. + +The 'mmc part' command displays the list available partition on current mmc device. + +The 'mmc dev' command shows or set current mmc device. + + dev + device number to change + part + partition number to change + +The 'mmc list' command displays the list available devices. + +The 'mmc wp' command enables "power on write protect" function for boot partitions. + +The 'mmc bootbus' command sets the BOOT_BUS_WIDTH field. (*Refer to eMMC specification*) + + boot_bus_width + 0x0 + x1 (sdr) or x4(ddr) buswidth in boot operation mode (default) + 0x1 + x4 (sdr/ddr) buswidth in boot operation mode + 0x2 + x8 (sdr/ddr) buswidth in boot operation mode + 0x3 + Reserved + + reset_boot_bus_width + 0x0 + Reset buswidth to x1, Single data reate and backward compatible timing after boot operation (default) + 0x1 + Retain BOOT_BUS_WIDTH and BOOT_MODE value after boot operation. This is relevant to Push-pull mode operation only + + boot_mode + 0x0 + Use single data rate + backward compatible timing in boot operation (default) + 0x1 + Use single data rate + High Speed timing in boot operation mode + 0x2 + Use dual data rate in boot operation + 0x3 + Reserved + +The 'mmc partconf' command shows or changes PARTITION_CONFIG field. + + boot_ack + boot acknowledge value + boot_partition + boot partition to enable for boot + 0x0 + Device not boot enabled(default) + 0x1 + Boot partition1 enabled for boot + 0x2 + Boot partition2 enabled for boot + 0x7 + User area enabled for boot + others + Reserved + partition_access + partitions to access + +The 'mmc bootpart-resize' command changes sizes of boot and RPMB partitions. + dev + device number + boot part size MB + target size of boot partition + RPMB part size MB + target size of RPMB partition + +The 'mmc rst-function' command changes the RST_n_FUNCTION field. +**WARNING** : This is a write-once field. (*Refer to eMMC specification*) + + value + 0x0 + RST_n signal is temporarily disabled (default) + 0x1 + RST_n signal is permanently enabled + 0x2 + RST_n signal is permanently disabled + 0x3 + Reserved + + +Examples +-------- + +The 'mmc info' command displays device's capabilities: +:: + + => mmc info + Device: EXYNOS DWMMC + Manufacturer ID: 45 + OEM: 100 + Name: SDW16 + Bus Speed: 52000000 + Mode: MMC DDR52 (52MHz) + Rd Block Len: 512 + MMC version 5.0 + High Capacity: Yes + Capacity: 14.7 GiB + Bus Width: 8-bit DDR + Erase Group Size: 512 KiB + HC WP Group Size: 8 MiB + User Capacity: 14.7 GiB WRREL + Boot Capacity: 4 MiB ENH + RPMB Capacity: 4 MiB ENH + Boot area 0 is not write protected + Boot area 1 is not write protected + +The raw data can be read/written via 'mmc read/write' command: +:: + + => mmc read 0x40000000 0x5000 0x100 + MMC read: dev # 0, block # 20480, count 256 ... 256 blocks read: OK + + => mmc write 0x40000000 0x5000 0x10 + MMC write: dev # 0, block # 20480, count 256 ... 256 blocks written: OK + +The partition list can be shown via 'mmc part' command: +:: + + => mmc part + Partition Map for MMC device 0 -- Partition Type: DOS + + Part Start Sector Num Sectors UUID Type + 1 8192 131072 dff8751a-01 0e Boot + 2 139264 6291456 dff8751a-02 83 + 3 6430720 1048576 dff8751a-03 83 + 4 7479296 23298048 dff8751a-04 05 Extd + 5 7481344 307200 dff8751a-05 83 + 6 7790592 65536 dff8751a-06 83 + 7 7858176 16384 dff8751a-07 83 + 8 7876608 22900736 dff8751a-08 83 + +The current device can be shown or set via 'mmc dev' command: +:: + + => mmc dev + switch to partitions #0, OK + mmc0(part0) is current device + => mmc dev 2 0 + switch to partitions #0, OK + mmc2 is current device + +The list of available devices can be shown via 'mmc list' command: +:: + + => mmc list + mmc list + EXYNOS DWMMC: 0 (eMMC) + EXYNOS DWMMC: 2 (SD) + +Configuration +------------- + +The mmc command is only available if CONFIG_CMD_MMC=y. +Some commands need to enable more configuration. + +write, erase + CONFIG_MMC_WRITE +bootbus, bootpart-resize, partconf, rst-function + CONFIG_SUPPORT_EMMC_BOOT=y diff --git a/fs/fat/fat.c b/fs/fat/fat.c index ccba268f61..c561d82b35 100644 --- a/fs/fat/fat.c +++ b/fs/fat/fat.c @@ -1147,42 +1147,12 @@ int file_fat_detectfs(void) return 1; } -#if defined(CONFIG_IDE) || \ - defined(CONFIG_SATA) || \ - defined(CONFIG_SCSI) || \ - defined(CONFIG_CMD_USB) || \ - defined(CONFIG_MMC) - printf("Interface: "); - switch (cur_dev->if_type) { - case IF_TYPE_IDE: - printf("IDE"); - break; - case IF_TYPE_SATA: - printf("SATA"); - break; - case IF_TYPE_SCSI: - printf("SCSI"); - break; - case IF_TYPE_ATAPI: - printf("ATAPI"); - break; - case IF_TYPE_USB: - printf("USB"); - break; - case IF_TYPE_DOC: - printf("DOC"); - break; - case IF_TYPE_MMC: - printf("MMC"); - break; - default: - printf("Unknown"); + if (IS_ENABLED(CONFIG_HAVE_BLOCK_DEVICE)) { + printf("Interface: %s\n", blk_get_if_type_name(cur_dev->if_type)); + printf(" Device %d: ", cur_dev->devnum); + dev_print(cur_dev); } - printf("\n Device %d: ", cur_dev->devnum); - dev_print(cur_dev); -#endif - if (read_bootsectandvi(&bs, &volinfo, &fatsize)) { printf("\nNo valid FAT fs found\n"); return 1; diff --git a/include/charset.h b/include/charset.h index a911160f19..b93d023092 100644 --- a/include/charset.h +++ b/include/charset.h @@ -13,7 +13,7 @@ #define MAX_UTF8_PER_UTF16 3 -/** +/* * codepage_437 - Unicode to codepage 437 translation table */ extern const u16 codepage_437[128]; diff --git a/include/efi.h b/include/efi.h index 503fbf060b..6417a9b8c5 100644 --- a/include/efi.h +++ b/include/efi.h @@ -180,9 +180,13 @@ enum efi_mem_type { */ EFI_PAL_CODE, /* - * Non-volatile memory. + * Byte addressable non-volatile memory. */ EFI_PERSISTENT_MEMORY_TYPE, + /* + * Unaccepted memory must be accepted by boot target before usage. + */ + EFI_UNACCEPTED_MEMORY_TYPE, EFI_MAX_MEMORY_TYPE, }; @@ -201,6 +205,7 @@ enum efi_mem_type { ((u64)0x0000000000010000ULL) /* higher reliability */ #define EFI_MEMORY_RO ((u64)0x0000000000020000ULL) /* read-only */ #define EFI_MEMORY_SP ((u64)0x0000000000040000ULL) /* specific-purpose memory (SPM) */ +#define EFI_MEMORY_CPU_CRYPTO ((u64)0x0000000000080000ULL) /* cryptographically protectable */ #define EFI_MEMORY_RUNTIME ((u64)0x8000000000000000ULL) /* range requires runtime mapping */ #define EFI_MEM_DESC_VERSION 1 diff --git a/include/efi_selftest.h b/include/efi_selftest.h index 07b619901c..94ceb14733 100644 --- a/include/efi_selftest.h +++ b/include/efi_selftest.h @@ -53,21 +53,25 @@ */ enum efi_test_phase { /** - * @EFI_EXECUTE_BEFORE_BOOTTIME_EXIT: - execute before ExitBootServices + * @EFI_EXECUTE_BEFORE_BOOTTIME_EXIT: * * Setup, execute, and teardown are executed before ExitBootServices(). */ EFI_EXECUTE_BEFORE_BOOTTIME_EXIT = 1, /** - * @EFI_SETUP_BEFORE_BOOTTIME_EXIT: - setup before ExitBootServices + * @EFI_SETUP_BEFORE_BOOTTIME_EXIT: * * Setup is executed before ExitBootServices() while execute, and * teardown are executed after ExitBootServices(). */ EFI_SETUP_BEFORE_BOOTTIME_EXIT, /** - * @EFI_SETTING_VIRTUAL_ADDRESS_MAP - calls SetVirtualAddressMap() - * Execute calls SetVirtualAddressMap(). + * @EFI_SETTING_VIRTUAL_ADDRESS_MAP: + * + * Execute calls SetVirtualAddressMap(). Setup is executed before + * ExitBootServices() while execute is executed after + * ExitBootServices(), and after the execute of tests marked as + * @EFI_SETUP_BEFORE_BOOTTIME_EXIT. Teardown is executed thereafter. */ EFI_SETTING_VIRTUAL_ADDRESS_MAP, }; diff --git a/include/linker_lists.h b/include/linker_lists.h index 81a280a884..2fea54c834 100644 --- a/include/linker_lists.h +++ b/include/linker_lists.h @@ -219,6 +219,10 @@ * * This is like ll_entry_get(), but without the extra code, so it is suitable * for putting into data structures. + * + * @_type: C type of the list entry, e.g. 'struct foo' + * @_name: name of the entry + * @_list: name of the list */ #define ll_entry_ref(_type, _name, _list) \ ((_type *)&_u_boot_list_2_##_list##_2_##_name) diff --git a/lib/efi_loader/Kconfig b/lib/efi_loader/Kconfig index e44f004f3f..0b99d7c774 100644 --- a/lib/efi_loader/Kconfig +++ b/lib/efi_loader/Kconfig @@ -173,6 +173,7 @@ config EFI_CAPSULE_AUTHENTICATE select X509_CERTIFICATE_PARSER select PKCS7_MESSAGE_PARSER select PKCS7_VERIFY + select IMAGE_SIGN_INFO default n help Select this option if you want to enable capsule diff --git a/lib/efi_loader/efi_bootmgr.c b/lib/efi_loader/efi_bootmgr.c index 46c8011344..1fe19237f9 100644 --- a/lib/efi_loader/efi_bootmgr.c +++ b/lib/efi_loader/efi_bootmgr.c @@ -30,38 +30,6 @@ static const struct efi_runtime_services *rs; * should do normal or recovery boot. */ -/** - * get_var() - get UEFI variable - * - * It is the caller's duty to free the returned buffer. - * - * @name: name of variable - * @vendor: vendor GUID of variable - * @size: size of allocated buffer - * Return: buffer with variable data or NULL - */ -static void *get_var(u16 *name, const efi_guid_t *vendor, - efi_uintn_t *size) -{ - efi_status_t ret; - void *buf = NULL; - - *size = 0; - ret = efi_get_variable_int(name, vendor, NULL, size, buf, NULL); - if (ret == EFI_BUFFER_TOO_SMALL) { - buf = malloc(*size); - ret = efi_get_variable_int(name, vendor, NULL, size, buf, NULL); - } - - if (ret != EFI_SUCCESS) { - free(buf); - *size = 0; - return NULL; - } - - return buf; -} - /** * try_load_entry() - try to load image for boot option * @@ -89,7 +57,7 @@ static efi_status_t try_load_entry(u16 n, efi_handle_t *handle, varname[6] = hexmap[(n & 0x00f0) >> 4]; varname[7] = hexmap[(n & 0x000f) >> 0]; - load_option = get_var(varname, &efi_global_variable_guid, &size); + load_option = efi_get_var(varname, &efi_global_variable_guid, &size); if (!load_option) return EFI_LOAD_ERROR; @@ -210,7 +178,7 @@ efi_status_t efi_bootmgr_load(efi_handle_t *handle, void **load_options) } /* BootOrder */ - bootorder = get_var(L"BootOrder", &efi_global_variable_guid, &size); + bootorder = efi_get_var(L"BootOrder", &efi_global_variable_guid, &size); if (!bootorder) { log_info("BootOrder not defined\n"); ret = EFI_NOT_FOUND; diff --git a/lib/efi_loader/efi_esrt.c b/lib/efi_loader/efi_esrt.c index 947bdb5e95..40f53260e4 100644 --- a/lib/efi_loader/efi_esrt.c +++ b/lib/efi_loader/efi_esrt.c @@ -120,8 +120,8 @@ efi_status_t efi_esrt_allocate_install(u32 num_entries) (void **)&new_esrt); if (ret != EFI_SUCCESS) { - EFI_PRINT("ESRT cannot allocate memory for %d entries (%d bytes)\n", - num_entries, efi_esrt_entries_to_size(num_entries)); + EFI_PRINT("ESRT cannot allocate memory for %u entries (%u bytes)\n", + num_entries, size); return ret; } @@ -180,7 +180,7 @@ struct efi_system_resource_entry *esrt_find_entry(efi_guid_t *img_fw_class) /* Check if the image with img_fw_class is already in the ESRT. */ for (u32 idx = 0; idx < filled_entries; idx++) { if (!guidcmp(&entry[idx].fw_class, img_fw_class)) { - EFI_PRINT("ESRT found entry for image %pUl at index %d\n", + EFI_PRINT("ESRT found entry for image %pUl at index %u\n", img_fw_class, idx); return &entry[idx]; } @@ -202,7 +202,7 @@ struct efi_system_resource_entry *esrt_find_entry(efi_guid_t *img_fw_class) */ esrt->fw_resource_count++; entry[filled_entries].fw_class = *img_fw_class; - EFI_PRINT("ESRT allocated new entry for image %pUl at index %d\n", + EFI_PRINT("ESRT allocated new entry for image %pUl at index %u\n", img_fw_class, filled_entries); return &entry[filled_entries]; @@ -316,7 +316,7 @@ efi_status_t efi_esrt_populate(void) { efi_handle_t *base_handle = NULL; efi_handle_t *it_handle; - size_t no_handles = 0; + efi_uintn_t no_handles = 0; struct efi_firmware_management_protocol *fmp; efi_status_t ret; u32 num_entries = 0; @@ -341,7 +341,7 @@ efi_status_t efi_esrt_populate(void) return EFI_SUCCESS; } - EFI_PRINT("ESRT populate esrt from (%ld) available FMP handles\n", + EFI_PRINT("ESRT populate esrt from (%zd) available FMP handles\n", no_handles); /* @@ -363,7 +363,7 @@ efi_status_t efi_esrt_populate(void) &handler); if (ret != EFI_SUCCESS) { - EFI_PRINT("ESRT Unable to find FMP handle (%d)\n", + EFI_PRINT("ESRT Unable to find FMP handle (%u)\n", idx); goto out; } @@ -414,7 +414,7 @@ efi_status_t efi_esrt_populate(void) EFI_CALL(efi_free_pool(img_info)); } - EFI_PRINT("ESRT create table with %d entries\n", num_entries); + EFI_PRINT("ESRT create table with %u entries\n", num_entries); /* * Allocate an ESRT with the sufficient number of entries to accommodate * all the FMPs in the system. @@ -435,7 +435,7 @@ efi_status_t efi_esrt_populate(void) &handler)); if (ret != EFI_SUCCESS) { - EFI_PRINT("ESRT unable to find FMP handle (%d)\n", + EFI_PRINT("ESRT unable to find FMP handle (%u)\n", idx); break; } diff --git a/lib/efi_loader/efi_tcg2.c b/lib/efi_loader/efi_tcg2.c index 09046844c7..ed86a220fb 100644 --- a/lib/efi_loader/efi_tcg2.c +++ b/lib/efi_loader/efi_tcg2.c @@ -176,13 +176,14 @@ static efi_status_t tcg2_agile_log_append(u32 pcr_index, u32 event_type, struct tpml_digest_values *digest_list, u32 size, u8 event[]) { - void *log = event_log.buffer + event_log.pos; + void *log = (void *)((uintptr_t)event_log.buffer + event_log.pos); size_t pos; int i; u32 event_size; if (event_log.get_event_called) - log = event_log.final_buffer + event_log.final_pos; + log = (void *)((uintptr_t)event_log.final_buffer + + event_log.final_pos); /* * size refers to the length of event[] only, we need to check against @@ -197,24 +198,24 @@ static efi_status_t tcg2_agile_log_append(u32 pcr_index, u32 event_type, put_unaligned_le32(pcr_index, log); pos = offsetof(struct tcg_pcr_event2, event_type); - put_unaligned_le32(event_type, log + pos); + put_unaligned_le32(event_type, (void *)((uintptr_t)log + pos)); pos = offsetof(struct tcg_pcr_event2, digests); /* count */ - put_unaligned_le32(digest_list->count, log + pos); + put_unaligned_le32(digest_list->count, (void *)((uintptr_t)log + pos)); pos += offsetof(struct tpml_digest_values, digests); for (i = 0; i < digest_list->count; i++) { u16 hash_alg = digest_list->digests[i].hash_alg; u8 *digest = (u8 *)&digest_list->digests[i].digest; - put_unaligned_le16(hash_alg, log + pos); + put_unaligned_le16(hash_alg, (void *)((uintptr_t)log + pos)); pos += offsetof(struct tpmt_ha, digest); - memcpy(log + pos, digest, alg_to_len(hash_alg)); + memcpy((void *)((uintptr_t)log + pos), digest, alg_to_len(hash_alg)); pos += alg_to_len(hash_alg); } - put_unaligned_le32(size, log + pos); + put_unaligned_le32(size, (void *)((uintptr_t)log + pos)); pos += sizeof(u32); /* tcg_pcr_event2 event_size*/ - memcpy(log + pos, event, size); + memcpy((void *)((uintptr_t)log + pos), event, size); pos += size; /* make sure the calculated buffer is what we checked against */ @@ -1046,7 +1047,7 @@ static efi_status_t efi_init_event_log(void) put_unaligned_le32(0, &event_header->pcr_index); put_unaligned_le32(EV_NO_ACTION, &event_header->event_type); memset(&event_header->digest, 0, sizeof(event_header->digest)); - ret = create_specid_event(dev, event_log.buffer + sizeof(*event_header), + ret = create_specid_event(dev, (void *)((uintptr_t)event_log.buffer + sizeof(*event_header)), &spec_event_size); if (ret != EFI_SUCCESS) goto out; diff --git a/tools/mkeficapsule.c b/tools/mkeficapsule.c index f272512451..de0a628988 100644 --- a/tools/mkeficapsule.c +++ b/tools/mkeficapsule.c @@ -64,14 +64,14 @@ static void print_usage(void) printf("Usage: %s [options] \n" "Options:\n" - "\t--fit new FIT image file\n" - "\t--raw new raw image file\n" - "\t--index update image index\n" - "\t--instance update hardware instance\n" - "\t--public-key public key esl file\n" - "\t--dtb dtb file\n" - "\t--overlay the dtb file is an overlay\n" - "\t--help print a help message\n", + "\t-f, --fit new FIT image file\n" + "\t-r, --raw new raw image file\n" + "\t-i, --index update image index\n" + "\t-I, --instance update hardware instance\n" + "\t-K, --public-key public key esl file\n" + "\t-D, --dtb dtb file\n" + "\t-O, --overlay the dtb file is an overlay\n" + "\t-h, --help print a help message\n", tool_name); }