Commit b2af8d60551f0474014a91ac03d109e1fc40a52e
1 parent
54781b897c
Exists in
smarc_8mq-imx_v2020.04_5.4.24_2.1.0
and in
1 other branch
MA-16877 Skip kernel hab authentication for android
Android use AVB to verify the kernel, hab authentication is not necessary for boot image. For imx8m, don't authenticate the kernel image when AVB (CONFIG_AVB_SUPPORT) is enabled. For imx8q, as android uses different 'CONFIG_EXTRA_ENV_SETTINGS' and 'CONFIG_BOOTCOMMAND' with linux bsp, so it won't try to do kernel hab authentication. by default. Test: boot imx8mp with "CONFIG_IMX_HAB" and imx8qxp with 'CONFIG_AHAB_BOOT'. Change-Id: I1b2087ce7d8f9795422a053b6b68a694c86f0b3d Signed-off-by: Ji Luo <ji.luo@nxp.com> (cherry picked from commit f907e4ac090e960ba5110b8039cccc4296841595)
Showing 1 changed file with 1 additions and 1 deletions Inline Diff
cmd/booti.c
1 | // SPDX-License-Identifier: GPL-2.0+ | 1 | // SPDX-License-Identifier: GPL-2.0+ |
2 | /* | 2 | /* |
3 | * (C) Copyright 2000-2009 | 3 | * (C) Copyright 2000-2009 |
4 | * Wolfgang Denk, DENX Software Engineering, wd@denx.de. | 4 | * Wolfgang Denk, DENX Software Engineering, wd@denx.de. |
5 | */ | 5 | */ |
6 | 6 | ||
7 | #include <common.h> | 7 | #include <common.h> |
8 | #include <bootm.h> | 8 | #include <bootm.h> |
9 | #include <command.h> | 9 | #include <command.h> |
10 | #include <image.h> | 10 | #include <image.h> |
11 | #include <irq_func.h> | 11 | #include <irq_func.h> |
12 | #include <lmb.h> | 12 | #include <lmb.h> |
13 | #include <mapmem.h> | 13 | #include <mapmem.h> |
14 | #include <linux/kernel.h> | 14 | #include <linux/kernel.h> |
15 | #include <linux/sizes.h> | 15 | #include <linux/sizes.h> |
16 | 16 | ||
17 | /* | 17 | /* |
18 | * Image booting support | 18 | * Image booting support |
19 | */ | 19 | */ |
20 | static int booti_start(cmd_tbl_t *cmdtp, int flag, int argc, | 20 | static int booti_start(cmd_tbl_t *cmdtp, int flag, int argc, |
21 | char * const argv[], bootm_headers_t *images) | 21 | char * const argv[], bootm_headers_t *images) |
22 | { | 22 | { |
23 | int ret; | 23 | int ret; |
24 | ulong ld; | 24 | ulong ld; |
25 | ulong relocated_addr; | 25 | ulong relocated_addr; |
26 | ulong image_size; | 26 | ulong image_size; |
27 | 27 | ||
28 | ret = do_bootm_states(cmdtp, flag, argc, argv, BOOTM_STATE_START, | 28 | ret = do_bootm_states(cmdtp, flag, argc, argv, BOOTM_STATE_START, |
29 | images, 1); | 29 | images, 1); |
30 | 30 | ||
31 | /* Setup Linux kernel Image entry point */ | 31 | /* Setup Linux kernel Image entry point */ |
32 | if (!argc) { | 32 | if (!argc) { |
33 | ld = image_load_addr; | 33 | ld = image_load_addr; |
34 | debug("* kernel: default image load address = 0x%08lx\n", | 34 | debug("* kernel: default image load address = 0x%08lx\n", |
35 | image_load_addr); | 35 | image_load_addr); |
36 | } else { | 36 | } else { |
37 | ld = simple_strtoul(argv[0], NULL, 16); | 37 | ld = simple_strtoul(argv[0], NULL, 16); |
38 | debug("* kernel: cmdline image address = 0x%08lx\n", ld); | 38 | debug("* kernel: cmdline image address = 0x%08lx\n", ld); |
39 | } | 39 | } |
40 | 40 | ||
41 | ret = booti_setup(ld, &relocated_addr, &image_size, false); | 41 | ret = booti_setup(ld, &relocated_addr, &image_size, false); |
42 | if (ret != 0) | 42 | if (ret != 0) |
43 | return 1; | 43 | return 1; |
44 | 44 | ||
45 | #ifdef CONFIG_IMX_HAB | 45 | #if defined(CONFIG_IMX_HAB) && !defined(CONFIG_AVB_SUPPORT) |
46 | extern int authenticate_image( | 46 | extern int authenticate_image( |
47 | uint32_t ddr_start, uint32_t raw_image_size); | 47 | uint32_t ddr_start, uint32_t raw_image_size); |
48 | if (authenticate_image(ld, image_size) != 0) { | 48 | if (authenticate_image(ld, image_size) != 0) { |
49 | printf("Authenticate Image Fail, Please check\n"); | 49 | printf("Authenticate Image Fail, Please check\n"); |
50 | return 1; | 50 | return 1; |
51 | } | 51 | } |
52 | 52 | ||
53 | #endif | 53 | #endif |
54 | 54 | ||
55 | /* Handle BOOTM_STATE_LOADOS */ | 55 | /* Handle BOOTM_STATE_LOADOS */ |
56 | if (relocated_addr != ld) { | 56 | if (relocated_addr != ld) { |
57 | debug("Moving Image from 0x%lx to 0x%lx\n", ld, relocated_addr); | 57 | debug("Moving Image from 0x%lx to 0x%lx\n", ld, relocated_addr); |
58 | memmove((void *)relocated_addr, (void *)ld, image_size); | 58 | memmove((void *)relocated_addr, (void *)ld, image_size); |
59 | } | 59 | } |
60 | 60 | ||
61 | images->ep = relocated_addr; | 61 | images->ep = relocated_addr; |
62 | images->os.start = relocated_addr; | 62 | images->os.start = relocated_addr; |
63 | images->os.end = relocated_addr + image_size; | 63 | images->os.end = relocated_addr + image_size; |
64 | 64 | ||
65 | lmb_reserve(&images->lmb, images->ep, le32_to_cpu(image_size)); | 65 | lmb_reserve(&images->lmb, images->ep, le32_to_cpu(image_size)); |
66 | 66 | ||
67 | /* | 67 | /* |
68 | * Handle the BOOTM_STATE_FINDOTHER state ourselves as we do not | 68 | * Handle the BOOTM_STATE_FINDOTHER state ourselves as we do not |
69 | * have a header that provide this informaiton. | 69 | * have a header that provide this informaiton. |
70 | */ | 70 | */ |
71 | if (bootm_find_images(flag, argc, argv)) | 71 | if (bootm_find_images(flag, argc, argv)) |
72 | return 1; | 72 | return 1; |
73 | 73 | ||
74 | return 0; | 74 | return 0; |
75 | } | 75 | } |
76 | 76 | ||
77 | int do_booti(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) | 77 | int do_booti(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
78 | { | 78 | { |
79 | int ret; | 79 | int ret; |
80 | 80 | ||
81 | /* Consume 'booti' */ | 81 | /* Consume 'booti' */ |
82 | argc--; argv++; | 82 | argc--; argv++; |
83 | 83 | ||
84 | if (booti_start(cmdtp, flag, argc, argv, &images)) | 84 | if (booti_start(cmdtp, flag, argc, argv, &images)) |
85 | return 1; | 85 | return 1; |
86 | 86 | ||
87 | /* | 87 | /* |
88 | * We are doing the BOOTM_STATE_LOADOS state ourselves, so must | 88 | * We are doing the BOOTM_STATE_LOADOS state ourselves, so must |
89 | * disable interrupts ourselves | 89 | * disable interrupts ourselves |
90 | */ | 90 | */ |
91 | bootm_disable_interrupts(); | 91 | bootm_disable_interrupts(); |
92 | 92 | ||
93 | images.os.os = IH_OS_LINUX; | 93 | images.os.os = IH_OS_LINUX; |
94 | #ifdef CONFIG_RISCV_SMODE | 94 | #ifdef CONFIG_RISCV_SMODE |
95 | images.os.arch = IH_ARCH_RISCV; | 95 | images.os.arch = IH_ARCH_RISCV; |
96 | #elif CONFIG_ARM64 | 96 | #elif CONFIG_ARM64 |
97 | images.os.arch = IH_ARCH_ARM64; | 97 | images.os.arch = IH_ARCH_ARM64; |
98 | #endif | 98 | #endif |
99 | ret = do_bootm_states(cmdtp, flag, argc, argv, | 99 | ret = do_bootm_states(cmdtp, flag, argc, argv, |
100 | #ifdef CONFIG_SYS_BOOT_RAMDISK_HIGH | 100 | #ifdef CONFIG_SYS_BOOT_RAMDISK_HIGH |
101 | BOOTM_STATE_RAMDISK | | 101 | BOOTM_STATE_RAMDISK | |
102 | #endif | 102 | #endif |
103 | BOOTM_STATE_OS_PREP | BOOTM_STATE_OS_FAKE_GO | | 103 | BOOTM_STATE_OS_PREP | BOOTM_STATE_OS_FAKE_GO | |
104 | BOOTM_STATE_OS_GO, | 104 | BOOTM_STATE_OS_GO, |
105 | &images, 1); | 105 | &images, 1); |
106 | 106 | ||
107 | return ret; | 107 | return ret; |
108 | } | 108 | } |
109 | 109 | ||
110 | #ifdef CONFIG_SYS_LONGHELP | 110 | #ifdef CONFIG_SYS_LONGHELP |
111 | static char booti_help_text[] = | 111 | static char booti_help_text[] = |
112 | "[addr [initrd[:size]] [fdt]]\n" | 112 | "[addr [initrd[:size]] [fdt]]\n" |
113 | " - boot Linux 'Image' stored at 'addr'\n" | 113 | " - boot Linux 'Image' stored at 'addr'\n" |
114 | "\tThe argument 'initrd' is optional and specifies the address\n" | 114 | "\tThe argument 'initrd' is optional and specifies the address\n" |
115 | "\tof an initrd in memory. The optional parameter ':size' allows\n" | 115 | "\tof an initrd in memory. The optional parameter ':size' allows\n" |
116 | "\tspecifying the size of a RAW initrd.\n" | 116 | "\tspecifying the size of a RAW initrd.\n" |
117 | #if defined(CONFIG_OF_LIBFDT) | 117 | #if defined(CONFIG_OF_LIBFDT) |
118 | "\tSince booting a Linux kernel requires a flat device-tree, a\n" | 118 | "\tSince booting a Linux kernel requires a flat device-tree, a\n" |
119 | "\tthird argument providing the address of the device-tree blob\n" | 119 | "\tthird argument providing the address of the device-tree blob\n" |
120 | "\tis required. To boot a kernel with a device-tree blob but\n" | 120 | "\tis required. To boot a kernel with a device-tree blob but\n" |
121 | "\twithout an initrd image, use a '-' for the initrd argument.\n" | 121 | "\twithout an initrd image, use a '-' for the initrd argument.\n" |
122 | #endif | 122 | #endif |
123 | ""; | 123 | ""; |
124 | #endif | 124 | #endif |
125 | 125 | ||
126 | U_BOOT_CMD( | 126 | U_BOOT_CMD( |
127 | booti, CONFIG_SYS_MAXARGS, 1, do_booti, | 127 | booti, CONFIG_SYS_MAXARGS, 1, do_booti, |
128 | "boot Linux kernel 'Image' format from memory", booti_help_text | 128 | "boot Linux kernel 'Image' format from memory", booti_help_text |
129 | ); | 129 | ); |
130 | 130 |