All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot]  [PATCH 0/3] Add FIT loadable custom processing
@ 2016-11-21 20:14 Andrew F. Davis
  2016-11-21 20:14 ` [U-Boot] [PATCH 1/3] image: Add FIT image loadable section " Andrew F. Davis
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Andrew F. Davis @ 2016-11-21 20:14 UTC (permalink / raw)
  To: u-boot

Hello all,

To see the background on this see here[0].

As Simon suggested we are now using a linker list to keep any and all TEE
specific code out of common files as, unlike kernel, dtb, ramdisk, and
fpga image types, TEE images may not be used by needed by all users.

The last patch in this series is and example of how one can now add a
handler for an image type for their platform.

Thanks,
Andrew

[0] http://lists.denx.de/pipermail/u-boot/2016-November/272614.html

Andrew F. Davis (3):
  image: Add FIT image loadable section custom processing
  image: Add Trusted Execution Environment image type
  RFC: board: ti: dra7xx: add FIT image TEE processing

 board/ti/dra7xx/evm.c |  7 +++++++
 common/image.c        | 34 ++++++++++++++++++++++++++++++++++
 include/image.h       | 12 ++++++++++++
 3 files changed, 53 insertions(+)

-- 
2.10.2

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [U-Boot] [PATCH 1/3] image: Add FIT image loadable section custom processing
  2016-11-21 20:14 [U-Boot] [PATCH 0/3] Add FIT loadable custom processing Andrew F. Davis
@ 2016-11-21 20:14 ` Andrew F. Davis
  2016-11-24  2:20   ` Simon Glass
  2016-11-21 20:14 ` [U-Boot] [PATCH 2/3] image: Add Trusted Execution Environment image type Andrew F. Davis
  2016-11-21 20:14 ` [U-Boot] [PATCH 3/3] RFC: board: ti: dra7xx: add FIT image TEE processing Andrew F. Davis
  2 siblings, 1 reply; 8+ messages in thread
From: Andrew F. Davis @ 2016-11-21 20:14 UTC (permalink / raw)
  To: u-boot

To help automate the loading of custom image types we add the ability
to define custom handlers for the loadable section types. When we find
a compatible type while loading a "loadable" image from a FIT image we
run its associated handlers to perform any additional steps needed for
loading this image.

Signed-off-by: Andrew F. Davis <afd@ti.com>
---
 common/image.c  | 33 +++++++++++++++++++++++++++++++++
 include/image.h | 11 +++++++++++
 2 files changed, 44 insertions(+)

diff --git a/common/image.c b/common/image.c
index 7604494..2aac90d 100644
--- a/common/image.c
+++ b/common/image.c
@@ -1389,6 +1389,23 @@ int boot_get_fpga(int argc, char * const argv[], bootm_headers_t *images,
 }
 #endif
 
+static void fit_loadable_process(uint8_t img_type,
+				 ulong img_data,
+				 ulong img_len)
+{
+	int i;
+	const unsigned int count =
+			ll_entry_count(struct fit_loadable_tbl, fit_loadable);
+	struct fit_loadable_tbl *fit_loadable_handler =
+			ll_entry_start(struct fit_loadable_tbl, fit_loadable);
+	/* For each loadable handler */
+	for (i = 0; i < count; i++, fit_loadable_handler++)
+		/* matching this type */
+		if (fit_loadable_handler->type == img_type)
+			/* call that handler with this image data */
+			fit_loadable_handler->handler(img_data, img_len);
+}
+
 int boot_get_loadable(int argc, char * const argv[], bootm_headers_t *images,
 		uint8_t arch, const ulong *ld_start, ulong * const ld_len)
 {
@@ -1407,6 +1424,7 @@ int boot_get_loadable(int argc, char * const argv[], bootm_headers_t *images,
 	int conf_noffset;
 	int fit_img_result;
 	const char *uname;
+	uint8_t img_type;
 
 	/* Check to see if the images struct has a FIT configuration */
 	if (!genimg_has_config(images)) {
@@ -1447,6 +1465,21 @@ int boot_get_loadable(int argc, char * const argv[], bootm_headers_t *images,
 				/* Something went wrong! */
 				return fit_img_result;
 			}
+
+			fit_img_result = fit_image_get_node(buf, uname);
+			if (fit_img_result < 0) {
+				/* Something went wrong! */
+				return fit_img_result;
+			}
+			fit_img_result = fit_image_get_type(buf,
+							    fit_img_result,
+							    &img_type);
+			if (fit_img_result < 0) {
+				/* Something went wrong! */
+				return fit_img_result;
+			}
+
+			fit_loadable_process(img_type, img_data, img_len);
 		}
 		break;
 	default:
diff --git a/include/image.h b/include/image.h
index 2b1296c..a8b81b5 100644
--- a/include/image.h
+++ b/include/image.h
@@ -1263,4 +1263,15 @@ int board_fit_config_name_match(const char *name);
 void board_fit_image_post_process(void **p_image, size_t *p_size);
 #endif /* CONFIG_SPL_FIT_IMAGE_POST_PROCESS */
 
+struct fit_loadable_tbl {
+	int type;
+	void (*handler)(ulong data, size_t size);
+};
+
+#define U_BOOT_FIT_LOADABLE_HANDLER(_type, _handler) \
+	ll_entry_declare(struct fit_loadable_tbl, _function, fit_loadable) = { \
+		.type = _type, \
+		.handler = _handler, \
+	}
+
 #endif	/* __IMAGE_H__ */
-- 
2.10.2

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [U-Boot] [PATCH 2/3] image: Add Trusted Execution Environment image type
  2016-11-21 20:14 [U-Boot] [PATCH 0/3] Add FIT loadable custom processing Andrew F. Davis
  2016-11-21 20:14 ` [U-Boot] [PATCH 1/3] image: Add FIT image loadable section " Andrew F. Davis
@ 2016-11-21 20:14 ` Andrew F. Davis
  2016-11-24  2:20   ` Simon Glass
  2016-11-21 20:14 ` [U-Boot] [PATCH 3/3] RFC: board: ti: dra7xx: add FIT image TEE processing Andrew F. Davis
  2 siblings, 1 reply; 8+ messages in thread
From: Andrew F. Davis @ 2016-11-21 20:14 UTC (permalink / raw)
  To: u-boot

Add a new image type representing Trusted Execution Environment (TEE)
image types. For example, an OP-TEE OS binary image.

Signed-off-by: Andrew F. Davis <afd@ti.com>
---
 common/image.c  | 1 +
 include/image.h | 1 +
 2 files changed, 2 insertions(+)

diff --git a/common/image.c b/common/image.c
index 2aac90d..bd07e86 100644
--- a/common/image.c
+++ b/common/image.c
@@ -165,6 +165,7 @@ static const table_entry_t uimage_type[] = {
 	{	IH_TYPE_ZYNQIMAGE,  "zynqimage",  "Xilinx Zynq Boot Image" },
 	{	IH_TYPE_ZYNQMPIMAGE, "zynqmpimage", "Xilinx ZynqMP Boot Image" },
 	{	IH_TYPE_FPGA,       "fpga",       "FPGA Image" },
+	{       IH_TYPE_TEE,        "tee",        "Trusted Execution Environment Image",},
 	{	-1,		    "",		  "",			},
 };
 
diff --git a/include/image.h b/include/image.h
index a8b81b5..12f52d7 100644
--- a/include/image.h
+++ b/include/image.h
@@ -279,6 +279,7 @@ enum {
 	IH_TYPE_ZYNQMPIMAGE,		/* Xilinx ZynqMP Boot Image */
 	IH_TYPE_FPGA,			/* FPGA Image */
 	IH_TYPE_VYBRIDIMAGE,	/* VYBRID .vyb Image */
+	IH_TYPE_TEE,            /* Trusted Execution Environment OS Image */
 
 	IH_TYPE_COUNT,			/* Number of image types */
 };
-- 
2.10.2

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [U-Boot] [PATCH 3/3] RFC: board: ti: dra7xx: add FIT image TEE processing
  2016-11-21 20:14 [U-Boot] [PATCH 0/3] Add FIT loadable custom processing Andrew F. Davis
  2016-11-21 20:14 ` [U-Boot] [PATCH 1/3] image: Add FIT image loadable section " Andrew F. Davis
  2016-11-21 20:14 ` [U-Boot] [PATCH 2/3] image: Add Trusted Execution Environment image type Andrew F. Davis
@ 2016-11-21 20:14 ` Andrew F. Davis
  2016-11-24  2:20   ` Simon Glass
  2 siblings, 1 reply; 8+ messages in thread
From: Andrew F. Davis @ 2016-11-21 20:14 UTC (permalink / raw)
  To: u-boot

Populate the corresponding TEE image processing call to be
performed during FIT loadable processing.

Signed-off-by: Andrew F. Davis <afd@ti.com>
---
 board/ti/dra7xx/evm.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/board/ti/dra7xx/evm.c b/board/ti/dra7xx/evm.c
index 3c16846..3bb895c 100644
--- a/board/ti/dra7xx/evm.c
+++ b/board/ti/dra7xx/evm.c
@@ -848,4 +848,11 @@ void board_fit_image_post_process(void **p_image, size_t *p_size)
 {
 	secure_boot_verify_image(p_image, p_size);
 }
+
+void board_tee_image_process(ulong tee_image, size_t tee_size)
+{
+	secure_tee_install((u32)tee_image);
+}
+
+U_BOOT_FIT_LOADABLE_HANDLER(IH_TYPE_TEE, board_tee_image_process);
 #endif
-- 
2.10.2

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [U-Boot] [PATCH 1/3] image: Add FIT image loadable section custom processing
  2016-11-21 20:14 ` [U-Boot] [PATCH 1/3] image: Add FIT image loadable section " Andrew F. Davis
@ 2016-11-24  2:20   ` Simon Glass
  2016-11-29 16:51     ` Andrew F. Davis
  0 siblings, 1 reply; 8+ messages in thread
From: Simon Glass @ 2016-11-24  2:20 UTC (permalink / raw)
  To: u-boot

Hi Andrew,

On 21 November 2016 at 13:14, Andrew F. Davis <afd@ti.com> wrote:
> To help automate the loading of custom image types we add the ability
> to define custom handlers for the loadable section types. When we find
> a compatible type while loading a "loadable" image from a FIT image we
> run its associated handlers to perform any additional steps needed for
> loading this image.
>
> Signed-off-by: Andrew F. Davis <afd@ti.com>
> ---
>  common/image.c  | 33 +++++++++++++++++++++++++++++++++
>  include/image.h | 11 +++++++++++
>  2 files changed, 44 insertions(+)

Reviewed-by: Simon Glass <sjg@chromium.org>

But please comment U_BOOT_FIT_LOADABLE_HANDLER and its associated struct.

Also can you add some documentation somewhere? Perhaps to
source_file_format.txt?

Regards,
Simon

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [U-Boot] [PATCH 2/3] image: Add Trusted Execution Environment image type
  2016-11-21 20:14 ` [U-Boot] [PATCH 2/3] image: Add Trusted Execution Environment image type Andrew F. Davis
@ 2016-11-24  2:20   ` Simon Glass
  0 siblings, 0 replies; 8+ messages in thread
From: Simon Glass @ 2016-11-24  2:20 UTC (permalink / raw)
  To: u-boot

On 21 November 2016 at 13:14, Andrew F. Davis <afd@ti.com> wrote:
> Add a new image type representing Trusted Execution Environment (TEE)
> image types. For example, an OP-TEE OS binary image.
>
> Signed-off-by: Andrew F. Davis <afd@ti.com>
> ---
>  common/image.c  | 1 +
>  include/image.h | 1 +
>  2 files changed, 2 insertions(+)

Reviewed-by: Simon Glass <sjg@chromium.org>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [U-Boot] [PATCH 3/3] RFC: board: ti: dra7xx: add FIT image TEE processing
  2016-11-21 20:14 ` [U-Boot] [PATCH 3/3] RFC: board: ti: dra7xx: add FIT image TEE processing Andrew F. Davis
@ 2016-11-24  2:20   ` Simon Glass
  0 siblings, 0 replies; 8+ messages in thread
From: Simon Glass @ 2016-11-24  2:20 UTC (permalink / raw)
  To: u-boot

On 21 November 2016 at 13:14, Andrew F. Davis <afd@ti.com> wrote:
> Populate the corresponding TEE image processing call to be
> performed during FIT loadable processing.
>
> Signed-off-by: Andrew F. Davis <afd@ti.com>
> ---
>  board/ti/dra7xx/evm.c | 7 +++++++
>  1 file changed, 7 insertions(+)

Reviewed-by: Simon Glass <sjg@chromium.org>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [U-Boot] [PATCH 1/3] image: Add FIT image loadable section custom processing
  2016-11-24  2:20   ` Simon Glass
@ 2016-11-29 16:51     ` Andrew F. Davis
  0 siblings, 0 replies; 8+ messages in thread
From: Andrew F. Davis @ 2016-11-29 16:51 UTC (permalink / raw)
  To: u-boot

On 11/23/2016 08:20 PM, Simon Glass wrote:
> Hi Andrew,
> 
> On 21 November 2016 at 13:14, Andrew F. Davis <afd@ti.com> wrote:
>> To help automate the loading of custom image types we add the ability
>> to define custom handlers for the loadable section types. When we find
>> a compatible type while loading a "loadable" image from a FIT image we
>> run its associated handlers to perform any additional steps needed for
>> loading this image.
>>
>> Signed-off-by: Andrew F. Davis <afd@ti.com>
>> ---
>>  common/image.c  | 33 +++++++++++++++++++++++++++++++++
>>  include/image.h | 11 +++++++++++
>>  2 files changed, 44 insertions(+)
> 
> Reviewed-by: Simon Glass <sjg@chromium.org>
> 
> But please comment U_BOOT_FIT_LOADABLE_HANDLER and its associated struct.
> 
> Also can you add some documentation somewhere? Perhaps to
> source_file_format.txt?
> 

Works for me, will add for v2.

Thanks,
Andrew

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2016-11-29 16:51 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-11-21 20:14 [U-Boot] [PATCH 0/3] Add FIT loadable custom processing Andrew F. Davis
2016-11-21 20:14 ` [U-Boot] [PATCH 1/3] image: Add FIT image loadable section " Andrew F. Davis
2016-11-24  2:20   ` Simon Glass
2016-11-29 16:51     ` Andrew F. Davis
2016-11-21 20:14 ` [U-Boot] [PATCH 2/3] image: Add Trusted Execution Environment image type Andrew F. Davis
2016-11-24  2:20   ` Simon Glass
2016-11-21 20:14 ` [U-Boot] [PATCH 3/3] RFC: board: ti: dra7xx: add FIT image TEE processing Andrew F. Davis
2016-11-24  2:20   ` Simon Glass

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.