AVB using OP-TEE
Subsystems (4)
v4 cover AVB using OP-TEE
Hi,
This adds support for storing AVB rollback indexes in the RPMB partition. The RPMB partition (content and key) is managed by OP-TEE
(https://www.op-tee.org/) which is a secure OS leveraging ARM TrustZone.
The Linux kernel can already support OP-TEE with reading and updating rollback indexes in the RPMB partition, the catch is that this is needed before the kernel has booted.
The design here is the same as what is in the Linux kernel, with the exception that the user space daemon tee-supplicant is integrated in the OP-TEE driver here (drivers/tee/optee/supplicant.c) instead. A new uclass (UCLASS_TEE) is introduced to provide an abstraction for interfacing with a Trusted Execution Environment (TEE). There's also the OP-TEE driver using UCLASS_TEE for registration.
A Trusted Application (TA) interface is added to be used by the AVB verify functions which are updated accordingly. The TA is managed by OP-TEE and is executed in a secure TrustZone protected environment.
The header files drivers/tee/optee/optee_{msg,msg_supplicant,smc}.h and include/tee/optee_ta_avb.h are copied from
https://github.com/OP-TEE/optee_os/tree/master more or less unmodified. They may need to be updated from time to time in order to support new features.
In MMC there's a new function, mmc_rpmb_route_frames(), which as the name suggests is used to route RPMB frames to/from the MMC. This saves OP-TEE from implementing an MMC driver which would need to share resources with its counterpart here in U-Boot.
This was tested on a Hikey (Kirin 620) board.
I've added myself as maintainer of the TEE stuff.
changes in v4:
* Addressed review comments from Simon Glass
* Rebased on v2018.09
* "avb_verify: bugfix avb_ops_free() skipping free" removed due to the rebase
* Commits "dt/bindings: add bindings for optee",
"sandbox: imply CONFIG_TEE (TEE uclass)",
"tee: add sandbox driver",
"avb_verify: support using OP-TEE TA AVB",
"test_avb: Update pymark.buildconfigspec information for the AVB tests", "Kconfig: sandbox: enable cmd_avb and dependencies",
* Added descriptions of additional structs and functions
* In commit "avb_verify: support sandbox configuration" avoid the #ifdef CONFIG_SANDBOX in get_sector_buf() as suggested by Simon.
changes in v3:
* Addressed review comments from Simon Glass
* A few new patches
- "avb_verify: bugfix avb_ops_free() skipping free"
- "tee: add sandbox driver"
- "test_avb: Update pymark.buildconfigspec information for the AVB tests"
- "avb_verify: support sandbox configuration"
- "Kconfig: sandbox: enable cmd_avb and dependencies"
* "sandbox: imply CONFIG_TEE (TEE uclass)", replacing
"configs: sandbox: enable CONFIG_TEE (TEE uclass)"
* Moved sandbox driver to drivers/tee and added code to emulate the AVB TA
* Enabled a few AVB tests (test/py/tests/test_avb.py) for sandbox
* Bugfix tee_find_device()
* Commits "dm: fdt: scan for devices under /firmware too", "cmd: avb read_rb: print rb_idx in hexadecimal",
"cmd: avb: print error message if command fails",
"Add UCLASS_TEE for Trusted Execution Environment",
"tee: add OP-TEE driver",
"Documentation: tee uclass and op-tee driver",
"test: tee: test TEE uclass",
"arm: dt: hikey: Add optee node" and
"sandbox: dt: add sandbox_tee node"
changes in v2:
* Added sandbox driver and a test in test/dm for the new TEE uclass:
Commit ("test: tee: test TEE uclass") and the enabling commits ("sandbox: dt: add sandbox_tee node") and
("configs: sandbox: enable CONFIG_TEE (TEE uclass)")
* Added descriptions of exported structs and functions
* Added documentation for the TEE uclass and the OP-TEE driver with the new commit ("Documentation: tee uclass and op-tee driver")
* Added documentation for the changes in avb_verify
* Addressed review comments from Simon Glass
* Added the commit ("cmd: avb: print error message if command fails")
* Made a few functions static in the OP-TEE driver
* Commit ("cmd: avb read_rb: print rb_idx in hexadecimal") and ("tee: optee: support AVB trusted application");
Thanks,
Jens
Jens Wiklander (19):
dm: fdt: scan for devices under /firmware too
cmd: avb read_rb: print rb_idx in hexadecimal
cmd: avb: print error message if command fails
mmc: rpmb: add mmc_rpmb_route_frames()
Add UCLASS_TEE for Trusted Execution Environment dt/bindings: add bindings for optee
tee: add OP-TEE driver
Documentation: tee uclass and op-tee driver
arm: dt: hikey: Add optee node
optee: support routing of rpmb data frames to mmc
tee: optee: support AVB trusted application
sandbox: dt: add sandbox_tee node
sandbox: imply CONFIG_TEE (TEE uclass)
tee: add sandbox driver
test: tee: test TEE uclass
avb_verify: support using OP-TEE TA AVB
test_avb: Update pymark.buildconfigspec information for the AVB tests
avb_verify: support sandbox configuration
Kconfig: sandbox: enable cmd_avb and dependencies
MAINTAINERS | 7 + arch/Kconfig | 5 + arch/arm/dts/hi6220-hikey.dts | 7 + arch/sandbox/dts/sandbox.dts | 4 + arch/sandbox/dts/sandbox64.dts | 4 + arch/sandbox/dts/test.dts | 4 + cmd/avb.c | 19 +- common/avb_verify.c | 118 +++- doc/README.avb2 | 13 + doc/README.tee | 112 +++ .../firmware/linaro,optee-tz.txt | 31 + drivers/Kconfig | 2 + drivers/Makefile | 1 + drivers/core/root.c | 15 +- drivers/fastboot/Kconfig | 2 + drivers/mmc/rpmb.c | 160 +++++ drivers/tee/Kconfig | 35 + drivers/tee/Makefile | 5 + drivers/tee/optee/Kconfig | 27 + drivers/tee/optee/Makefile | 5 + drivers/tee/optee/core.c | 662 ++++++++++++++++++ drivers/tee/optee/optee_msg.h | 425 +++++++++++ drivers/tee/optee/optee_msg_supplicant.h | 240 +++++++ drivers/tee/optee/optee_private.h | 65 ++ drivers/tee/optee/optee_smc.h | 450 ++++++++++++ drivers/tee/optee/rpmb.c | 181 +++++ drivers/tee/optee/supplicant.c | 96 +++ drivers/tee/sandbox.c | 308 ++++++++ drivers/tee/tee-uclass.c | 233 ++++++ include/avb_verify.h | 7 +- include/dm/uclass-id.h | 1 + include/mmc.h | 19 + include/sandboxtee.h | 21 + include/tee.h | 374 ++++++++++ include/tee/optee_ta_avb.h | 48 ++ test/dm/Makefile | 1 + test/dm/tee.c | 98 +++ test/py/tests/test_avb.py | 8 +- 38 files changed, 3802 insertions(+), 11 deletions(-) create mode 100644 doc/README.tee create mode 100644 doc/device-tree-bindings/firmware/linaro,optee-tz.txt create mode 100644 drivers/tee/Kconfig create mode 100644 drivers/tee/Makefile create mode 100644 drivers/tee/optee/Kconfig create mode 100644 drivers/tee/optee/Makefile create mode 100644 drivers/tee/optee/core.c create mode 100644 drivers/tee/optee/optee_msg.h create mode 100644 drivers/tee/optee/optee_msg_supplicant.h create mode 100644 drivers/tee/optee/optee_private.h create mode 100644 drivers/tee/optee/optee_smc.h create mode 100644 drivers/tee/optee/rpmb.c create mode 100644 drivers/tee/optee/supplicant.c create mode 100644 drivers/tee/sandbox.c create mode 100644 drivers/tee/tee-uclass.c create mode 100644 include/sandboxtee.h create mode 100644 include/tee.h create mode 100644 include/tee/optee_ta_avb.h create mode 100644 test/dm/tee.c
Signature · 1 line
2.17.1
PATCH v4 1/19 dm: fdt: scan for devices under /firmware too
Just as /chosen may contain devices /firmware may contain devices, scan for devices under /firmware too.
--- drivers/core/root.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-)
drivers/core/root.c +10 -5
@@ -265,9 +265,15 @@ static int dm_scan_fdt_node(struct udevice *parent, const void *blob,for (offset =fdt_first_subnode (blob, offset); offset >0 ; offset =fdt_next_subnode (blob, offset)) { -/* "chosen" node isn't a device itself but may contain some: */ -if (!strcmp (fdt_get_name (blob, offset,NULL ),"chosen" )) { -pr_debug ("parsing subnodes of \"chosen\"\n" ); +const char *node_name =fdt_get_name (blob, offset,NULL ); + +/* +* The "chosen" and "firmware" nodes aren't devices +* themselves but may contain some: +*/ +if (!strcmp (node_name,"chosen" ) || + !strcmp (node_name,"firmware" )) { +pr_debug ("parsing subnodes of \"%s\"\n" , node_name); err =dm_scan_fdt_node (parent, blob, offset, pre_reloc_only);
@@ -286,8 +292,7 @@ static int dm_scan_fdt_node(struct udevice *parent, const void *blob, err =lists_bind_fdt (parent,offset_to_ofnode (offset),NULL );if (err && !ret) { ret = err; -debug ("%s: ret=%d\n" ,fdt_get_name (blob, offset,NULL ), - ret); +debug ("%s: ret=%d\n" , node_name, ret); } }
Signature · 1 line
2.17.1
PATCH v4 1/19 dm: fdt: scan for devices under /firmware too
Quoted 5 lines · Jens Wiklander
Just as /chosen may contain devices /firmware may contain devices, scan for devices under /firmware too.
Reviewed-by Simon Glass <[email protected]>Signed-off-by Jens Wiklander <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: not available URL: <http://lists.denx.de/pipermail/u-boot/attachments/20181007/e4e53c80/attachment.sig>
PATCH v4 2/19 cmd: avb read_rb: print rb_idx in hexadecimal
In reply to Jens WiklanderPrior to this patch was do_avb_write_rb() reading supplied rb_idx as a hexadecimal number while do_avb_read_rb() printed the read out rb_idx as decimal number. For consistency change do_avb_read_rb() to print rb_idx as a hexadecimal number too.
--- cmd/avb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
cmd/avb.c +1 -1
@@ -158,7 +158,7 @@ int do_avb_read_rb(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])if (avb_ops->read_rollback_index (avb_ops, index, &rb_idx) ==AVB_IO_RESULT_OK ) { -printf ("Rollback index: %llu\n" , rb_idx); +printf ("Rollback index: %llx\n" , rb_idx);return CMD_RET_SUCCESS ; }return CMD_RET_FAILURE ;
Signature · 1 line
2.17.1
PATCH v4 2/19 cmd: avb read_rb: print rb_idx in hexadecimal
Quoted 8 lines · Jens Wiklander
Prior to this patch was
do_avb_write_rb()reading suppliedrb_idxas a hexadecimal number whiledo_avb_read_rb()printed the read outrb_idxas decimal number. For consistency changedo_avb_read_rb()to printrb_idxas a hexadecimal number too.Reviewed-by Simon Glass <[email protected]>Reviewed-by Igor Opaniuk <[email protected]>Signed-off-by Jens Wiklander <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: not available URL: <http://lists.denx.de/pipermail/u-boot/attachments/20181007/9d39c895/attachment.sig>
PATCH v4 3/19 cmd: avb: print error message if command fails
In reply to Jens Wiklander--- cmd/avb.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)
cmd/avb.c +17 -0
@@ -35,6 +35,8 @@ int do_avb_init(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])if (avb_ops)return CMD_RET_SUCCESS ; +printf ("Failed to initialize avb2\n" ); +return CMD_RET_FAILURE ; }
@@ -65,6 +67,8 @@ int do_avb_read_part(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])return CMD_RET_SUCCESS ; } +printf ("Failed to read from partition\n" ); +return CMD_RET_FAILURE ; }
@@ -108,6 +112,8 @@ int do_avb_read_part_hex(cmd_tbl_t *cmdtp, int flag, int argc,return CMD_RET_SUCCESS ; } +printf ("Failed to read from partition\n" ); +free (buffer);return CMD_RET_FAILURE ; }
@@ -138,6 +144,8 @@ int do_avb_write_part(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])return CMD_RET_SUCCESS ; } +printf ("Failed to write in partition\n" ); +return CMD_RET_FAILURE ; }
@@ -161,6 +169,9 @@ int do_avb_read_rb(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])printf ("Rollback index: %llx\n" , rb_idx);return CMD_RET_SUCCESS ; } + +printf ("Failed to read rollback index\n" ); +return CMD_RET_FAILURE ; }
@@ -184,6 +195,8 @@ int do_avb_write_rb(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) AVB_IO_RESULT_OK)return CMD_RET_SUCCESS ; +printf ("Failed to write rollback index\n" ); +return CMD_RET_FAILURE ; }
@@ -210,6 +223,8 @@ int do_avb_get_uuid(cmd_tbl_t *cmdtp, int flag,return CMD_RET_SUCCESS ; } +printf ("Failed to read UUID\n" ); +return CMD_RET_FAILURE ; }
@@ -320,6 +335,8 @@ int do_avb_is_unlocked(cmd_tbl_t *cmdtp, int flag,return CMD_RET_SUCCESS ; } +printf ("Can't determine device lock state.\n" ); +return CMD_RET_FAILURE ; }
Signature · 1 line
2.17.1
PATCH v4 3/19 cmd: avb: print error message if command fails
Quoted 2 lines · Jens Wiklander
Reviewed-by Simon Glass <[email protected]>Signed-off-by Jens Wiklander <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: not available URL: <http://lists.denx.de/pipermail/u-boot/attachments/20181007/716d5492/attachment.sig>
PATCH v4 4/19 mmc: rpmb: add mmc_rpmb_route_frames()
In reply to Jens WiklanderAdds mmc_rpmb_route_frames() to route RPMB data frames from/to an external entity.
--- drivers/mmc/rpmb.c | 160 +++++++++++++++++++++++++++++++++++++++++++++ include/mmc.h | 19 ++++++ 2 files changed, 179 insertions(+)
drivers/mmc/rpmb.c +160 -0
@@ -321,3 +321,163 @@ int mmc_rpmb_write(struct mmc *mmc, void *addr, unsigned short blk, }return i; } + +static int send_write_mult_block (struct mmc *mmc,const struct s_rpmb *frm, +unsigned short cnt) +{ +struct mmc_cmd cmd = { + .cmdidx =MMC_CMD_WRITE_MULTIPLE_BLOCK , + .resp_type = MMC_RSP_R1b, + }; +struct mmc_data data = { + .src = (const void *)frm, + .blocks = cnt, + .blocksize =sizeof (*frm), + .flags =MMC_DATA_WRITE , + }; + +return mmc_send_cmd (mmc, &cmd, &data); +} + +static int send_read_mult_block (struct mmc *mmc,struct s_rpmb *frm, +unsigned short cnt) +{ +struct mmc_cmd cmd = { + .cmdidx =MMC_CMD_READ_MULTIPLE_BLOCK , + .resp_type =MMC_RSP_R1 , + }; +struct mmc_data data = { + .dest = (void *)frm, + .blocks = cnt, + .blocksize =sizeof (*frm), + .flags =MMC_DATA_READ , + }; + +return mmc_send_cmd (mmc, &cmd, &data); +} + +static int rpmb_route_write_req (struct mmc *mmc,struct s_rpmb *req, +unsigned short req_cnt,struct s_rpmb *rsp, +unsigned short rsp_cnt) +{ +int ret; + +/* +* Send the write request. +*/ + ret =mmc_set_blockcount (mmc, req_cnt, true); +if (ret) +return ret; + + ret =send_write_mult_block (mmc, req, req_cnt); +if (ret) +return ret; + +/* +* Read the result of the request. +*/ + ret =mmc_set_blockcount (mmc,1 , false); +if (ret) +return ret; + +memset (rsp,0 ,sizeof (*rsp)); + rsp->request =cpu_to_be16 (RPMB_REQ_STATUS ); + ret =send_write_mult_block (mmc, rsp,1 ); +if (ret) +return ret; + + ret =mmc_set_blockcount (mmc,1 , false); +if (ret) +return ret; + +return send_read_mult_block (mmc, rsp,1 ); +} + +static int rpmb_route_read_req (struct mmc *mmc,struct s_rpmb *req, +unsigned short req_cnt,struct s_rpmb *rsp, +unsigned short rsp_cnt) +{ +int ret; + +/* +* Send the read request. +*/ + ret =mmc_set_blockcount (mmc,1 , false); +if (ret) +return ret; + + ret =send_write_mult_block (mmc, req,1 ); +if (ret) +return ret; + +/* +* Read the result of the request. +*/ + + ret =mmc_set_blockcount (mmc, rsp_cnt, false); +if (ret) +return ret; + +return send_read_mult_block (mmc, rsp, rsp_cnt); +} + +static int rpmb_route_frames (struct mmc *mmc,struct s_rpmb *req, +unsigned short req_cnt,struct s_rpmb *rsp, +unsigned short rsp_cnt) +{ +unsigned short n; + +/* +* If multiple request frames are provided, make sure that all are +* of the same type. +*/ +for (n =1 ; n < req_cnt; n++) +if (req[n].request != req->request) +return -EINVAL ; + +switch (be16_to_cpu (req->request)) { +case RPMB_REQ_KEY : +if (req_cnt !=1 || rsp_cnt !=1 ) +return -EINVAL ; +return rpmb_route_write_req (mmc, req, req_cnt, rsp, rsp_cnt); + +case RPMB_REQ_WRITE_DATA : +if (!req_cnt || rsp_cnt !=1 ) +return -EINVAL ; +return rpmb_route_write_req (mmc, req, req_cnt, rsp, rsp_cnt); + +case RPMB_REQ_WCOUNTER : +if (req_cnt !=1 || rsp_cnt !=1 ) +return -EINVAL ; +return rpmb_route_read_req (mmc, req, req_cnt, rsp, rsp_cnt); + +case RPMB_REQ_READ_DATA : +if (req_cnt !=1 || !req_cnt) +return -EINVAL ; +return rpmb_route_read_req (mmc, req, req_cnt, rsp, rsp_cnt); + +default : +debug ("Unsupported message type: %d\n" , +be16_to_cpu (req->request)); +return -EINVAL ; + } +} + +int mmc_rpmb_route_frames (struct mmc *mmc,void *req,unsigned long reqlen, +void *rsp,unsigned long rsplen) +{ +/* +* Whoever crafted the data supplied to this function knows how to +* format the PRMB frames and which response is expected. If +* there's some unexpected mismatch it's more helpful to report an +* error immediately than trying to guess what was the intention +* and possibly just delay an eventual error which will be harder +* to track down. +*/ + +if (reqlen %sizeof (struct s_rpmb ) || rsplen %sizeof (struct s_rpmb )) +return -EINVAL ; + +return rpmb_route_frames (mmc, req, reqlen /sizeof (struct s_rpmb ), + rsp, rsplen /sizeof (struct s_rpmb )); +}
include/mmc.h +19 -0
@@ -748,6 +748,25 @@ int mmc_rpmb_read(struct mmc *mmc, void *addr, unsigned short blk, unsigned short cnt, unsigned char *key);int mmc_rpmb_write (struct mmc *mmc,void *addr,unsigned short blk,unsigned short cnt,unsigned char *key); + +/** +* mmc_rpmb_route_frames() - route RPMB data frames +* @mmc Pointer to a MMC device struct +* @req Request data frames +* @reqlen Length of data frames in bytes +* @rsp Supplied buffer for response data frames +* @rsplen Length of supplied buffer for response data frames +* +* The RPMB data frames are routed to/from some external entity, for +* example a Trusted Exectuion Environment in an arm TrustZone protected +* secure world. It's expected that it's the external entity who is in +* control of the RPMB key. +* +* Returns 0 on success, < 0 on error. +*/ +int mmc_rpmb_route_frames (struct mmc *mmc,void *req,unsigned long reqlen, +void *rsp,unsigned long rsplen); +#ifdef CONFIG_CMD_BKOPS_ENABLE int mmc_set_bkops_enable (struct mmc *mmc);#endif
Signature · 1 line
2.17.1
PATCH v4 4/19 mmc: rpmb: add mmc_rpmb_route_frames()
Quoted 9 lines · Jens Wiklander
Adds
mmc_rpmb_route_frames()to route RPMB data frames from/to an external entity.Tested-by Igor Opaniuk <[email protected]>Signed-off-by Jens Wiklander <[email protected]>--- drivers/mmc/rpmb.c | 160 +++++++++++++++++++++++++++++++++++++++++++++ include/mmc.h | 19 ++++++ 2 files changed, 179 insertions(+)
PATCH v4 4/19 mmc: rpmb: add mmc_rpmb_route_frames()
In reply to Jens WiklanderQuoted 6 lines · Jens Wiklander
Adds
mmc_rpmb_route_frames()to route RPMB data frames from/to an external entity.Tested-by Igor Opaniuk <[email protected]>Signed-off-by Jens Wiklander <[email protected]>Reviewed-by Simon Glass <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: not available URL: <http://lists.denx.de/pipermail/u-boot/attachments/20181007/fb125fd5/attachment.sig>
PATCH v4 5/19 Add UCLASS_TEE for Trusted Execution Environment
In reply to Jens WiklanderAdds a uclass to interface with a TEE (Trusted Execution Environment).
A TEE driver is a driver that interfaces with a trusted OS running in some secure environment, for example, TrustZone on ARM cpus, or a separate secure co-processor etc.
The TEE subsystem can serve a TEE driver for a Global Platform compliant TEE, but it's not limited to only Global Platform TEEs.
The over all design is based on the TEE subsystem in the Linux kernel, tailored for U-Boot.
--- MAINTAINERS | 6 + drivers/Kconfig | 2 + drivers/Makefile | 1 + drivers/tee/Kconfig | 11 ++ drivers/tee/Makefile | 3 + drivers/tee/tee-uclass.c | 209 ++++++++++++++++++++++++ include/dm/uclass-id.h | 1 + include/tee.h | 336 +++++++++++++++++++++++++++++++++++++++ 8 files changed, 569 insertions(+) create mode 100644 drivers/tee/Kconfig create mode 100644 drivers/tee/Makefile create mode 100644 drivers/tee/tee-uclass.c create mode 100644 include/tee.h
MAINTAINERS +6 -0
@@ -585,6 +585,12 @@ TQ GROUP S: Orphaned (Since 2016-02) T: git git://git.denx.de/u-boot-tq-group.git +TEE +M: Jens Wiklander <[email protected]> +S: Maintained +F: drivers/tee/ +F: include/tee.h + UBI M: Kyungmin Park <[email protected]> M: Heiko Schocher <[email protected]>
drivers/Kconfig +2 -0
@@ -96,6 +96,8 @@ source "drivers/spmi/Kconfig" source "drivers/sysreset/Kconfig" +source "drivers/tee/Kconfig" + source "drivers/thermal/Kconfig" source "drivers/timer/Kconfig"
drivers/Makefile +1 -0
@@ -103,6 +103,7 @@ obj-y += smem/ obj-y += soc/ obj-$(CONFIG_REMOTEPROC) += remoteproc/ obj-y += thermal/ +obj-$(CONFIG_TEE) += tee/ obj-y += axi/ obj-$(CONFIG_MACH_PIC32) += ddr/microchip/
drivers/tee/Kconfig new file +11 -0
@@ -0,0 +1,11 @@ +# Generic Trusted Execution Environment Configuration +config TEE + bool "Trusted Execution Environment support" + depends on ARM && (ARM64 || CPU_V7A) + select ARM_SMCCC + help + This implements a generic interface towards a Trusted Execution + Environment (TEE). A TEE is a trusted OS running in some secure + environment, for example, TrustZone on ARM cpus, or a separate + secure co-processor etc. See also: + https://en.wikipedia.org/wiki/Trusted_execution_environment
drivers/tee/Makefile new file +3 -0
@@ -0,0 +1,3 @@ +# SPDX-License-Identifier: GPL-2.0+ + +obj-y += tee-uclass.o
drivers/tee/tee-uclass.c new file +209 -0
209 lines not on this page · raw message
include/dm/uclass-id.h +1 -0
@@ -83,6 +83,7 @@ enum uclass_id {UCLASS_SPI_GENERIC ,/* Generic SPI flash target */ UCLASS_SYSCON ,/* System configuration device */ UCLASS_SYSRESET ,/* System reset device */ +UCLASS_TEE ,/* Trusted Execution Environment device */ UCLASS_THERMAL ,/* Thermal sensor */ UCLASS_TIMER ,/* Timer device */ UCLASS_TPM, /* Trusted Platform Module TIS interface */
include/tee.h new file +336 -0
336 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH v4 5/19 Add UCLASS_TEE for Trusted Execution Environment
Quoted 9 lines · Jens Wiklander
Adds a uclass to interface with a TEE (Trusted Execution Environment).
A TEE driver is a driver that interfaces with a trusted OS running in some secure environment, for example, TrustZone on ARM cpus, or a separate secure co-processor etc.
The TEE subsystem can serve a TEE driver for a Global Platform compliant TEE, but it's not limited to only Global Platform TEEs.
Quoted 6 lines
The over all design is based on the TEE subsystem in the Linux kernel, tailored for U-Boot.
Reviewed-by Simon Glass <[email protected]>Tested-by Igor Opaniuk <[email protected]>Signed-off-by Jens Wiklander <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: not available URL: <http://lists.denx.de/pipermail/u-boot/attachments/20181007/7c0167c3/attachment.sig>
PATCH v4 6/19 dt/bindings: add bindings for optee
In reply to Jens WiklanderSync with c8bfafb15944 ("dt/bindings: add bindings for optee") from Linux kernel.
Introduces linaro prefix and adds bindings for ARM TrustZone based OP-TEE implementation.
--- .../firmware/linaro,optee-tz.txt | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 doc/device-tree-bindings/firmware/linaro,optee-tz.txt
doc/device-tree-bindings/firmware/linaro,optee-tz.txt new file +31 -0
@@ -0,0 +1,31 @@ +OP-TEE Device Tree Bindings + +OP-TEE is a piece of software using hardware features to provide a Trusted +Execution Environment. The security can be provided with ARM TrustZone, but +also by virtualization or a separate chip. + +We're using "linaro" as the first part of the compatible property for +the reference implementation maintained by Linaro. + +* OP-TEE based on ARM TrustZone required properties: + +- compatible : should contain "linaro,optee-tz" + +- method : The method of calling the OP-TEE Trusted OS. Permitted + values are: + + "smc" : SMC #0, with the register assignments specified + in drivers/tee/optee/optee_smc.h + + "hvc" : HVC #0, with the register assignments specified + in drivers/tee/optee/optee_smc.h + + + +Example: + firmware { + optee { + compatible = "linaro,optee-tz"; + method = "smc"; + }; + };
Signature · 1 line
2.17.1
PATCH v4 6/19 dt/bindings: add bindings for optee
Quoted 8 lines · Jens Wiklander
Sync with
c8bfafb15944("dt/bindings: add bindings for optee") from Linux kernel.Introduces linaro prefix and adds bindings for ARM TrustZone based OP-TEE implementation.
Reviewed-by Simon Glass <[email protected]>Signed-off-by Jens Wiklander <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: not available URL: <http://lists.denx.de/pipermail/u-boot/attachments/20181007/add331bc/attachment.sig>
PATCH v4 7/19 tee: add OP-TEE driver
In reply to Jens WiklanderAdds a OP-TEE driver.
* Targets ARM and ARM64
* Supports using any U-Boot memory as shared memory
* Probes OP-TEE version using SMCs
* Uses OPTEE message protocol version 2 to communicate with secure world
--- drivers/tee/Kconfig | 10 + drivers/tee/Makefile | 1 + drivers/tee/optee/Kconfig | 11 + drivers/tee/optee/Makefile | 4 + drivers/tee/optee/core.c | 654 +++++++++++++++++++++++ drivers/tee/optee/optee_msg.h | 425 +++++++++++++++ drivers/tee/optee/optee_msg_supplicant.h | 240 +++++++++ drivers/tee/optee/optee_private.h | 12 + drivers/tee/optee/optee_smc.h | 450 ++++++++++++++++ drivers/tee/optee/supplicant.c | 93 ++++ 10 files changed, 1900 insertions(+) create mode 100644 drivers/tee/optee/Kconfig create mode 100644 drivers/tee/optee/Makefile create mode 100644 drivers/tee/optee/core.c create mode 100644 drivers/tee/optee/optee_msg.h create mode 100644 drivers/tee/optee/optee_msg_supplicant.h create mode 100644 drivers/tee/optee/optee_private.h create mode 100644 drivers/tee/optee/optee_smc.h create mode 100644 drivers/tee/optee/supplicant.c
drivers/tee/Kconfig +10 -0
@@ -9,3 +9,13 @@ config TEE environment, for example, TrustZone on ARM cpus, or a separate secure co-processor etc. See also: https://en.wikipedia.org/wiki/Trusted_execution_environment + +if TEE + +menu "TEE drivers" + +source "drivers/tee/optee/Kconfig" + +endmenu + +endif
drivers/tee/Makefile +1 -0
@@ -1,3 +1,4 @@ # SPDX-License-Identifier: GPL-2.0+ obj-y += tee-uclass.o +obj-$(CONFIG_OPTEE) += optee/
drivers/tee/optee/Kconfig new file +11 -0
@@ -0,0 +1,11 @@ +# OP-TEE Trusted Execution Environment Configuration +config OPTEE + bool "OP-TEE" + depends on ARM_SMCCC + help + This implements the OP-TEE Trusted Execution Environment (TEE) + driver. OP-TEE is a Trusted OS designed primarily to rely on the + ARM TrustZone(R) technology as the underlying hardware isolation + mechanism. This driver can request services from OP-TEE, but also + handle Remote Procedure Calls (RPC) from OP-TEE needed to + execute a service. For more information see: https://www.op-tee.org
drivers/tee/optee/Makefile new file +4 -0
@@ -0,0 +1,4 @@ +# SPDX-License-Identifier: GPL-2.0+ + +obj-y += core.o +obj-y += supplicant.o
drivers/tee/optee/core.c new file +654 -0
654 lines not on this page · raw message
drivers/tee/optee/optee_msg.h new file +425 -0
425 lines not on this page · raw message
drivers/tee/optee/optee_msg_supplicant.h new file +240 -0
240 lines not on this page · raw message
drivers/tee/optee/optee_private.h new file +12 -0
@@ -0,0 +1,12 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* +* Copyright (c) 2018 Linaro Limited +*/ + +#ifndef __OPTEE_PRIVATE_H +#define __OPTEE_PRIVATE_H + +void *optee_alloc_and_init_page_list (void *buf,ulong len,u64 *phys_buf_ptr); +void optee_suppl_cmd (struct udevice *dev,void *shm,void **page_list); + +#endif /* __OPTEE_PRIVATE_H */
drivers/tee/optee/optee_smc.h new file +450 -0
450 lines not on this page · raw message
drivers/tee/optee/supplicant.c new file +93 -0
93 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH v4 7/19 tee: add OP-TEE driver
Quoted 10 lines · Jens Wiklander
Adds a OP-TEE driver.
* Targets ARM and ARM64
* Supports using any U-Boot memory as shared memory
* Probes OP-TEE version using SMCs
* Uses OPTEE message protocol version 2 to communicate with secure worldReviewed-by Simon Glass <[email protected]>Tested-by Igor Opaniuk <[email protected]>Signed-off-by Jens Wiklander <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: not available URL: <http://lists.denx.de/pipermail/u-boot/attachments/20181007/1eac93f7/attachment.sig>
PATCH v4 8/19 Documentation: tee uclass and op-tee driver
In reply to Jens Wiklander--- doc/README.tee | 112 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 112 insertions(+) create mode 100644 doc/README.tee
doc/README.tee new file +112 -0
@@ -0,0 +1,112 @@ +============= +TEE uclass +============= + +This document describes the TEE uclass in U-Boot + +A TEE (Trusted Execution Environment) is a trusted OS running in some +secure environment, for example, TrustZone on ARM CPUs, or a separate +secure co-processor etc. A TEE driver handles the details needed to +communicate with the TEE. + +This uclass deals with: + +- Registration of TEE drivers + +- Managing shared memory between U-Boot and the TEE + +- Providing a generic API to the TEE + +The TEE interface +================= + +include/tee.h defines the generic interface to a TEE. + +A client finds the TEE device via tee_find_device(). Other important functions +when interfacing with a TEE are: + +- tee_shm_alloc(), tee_shm_register() and tee_shm_free() to manage shared + memory objects often needed when communicating with the TEE. + +- tee_get_version() lets the client know which the capabilities of the TEE + device. + +- tee_open_session() opens a session to a Trusted Application + +- tee_invoke_func() invokes a function in a Trusted Application + +- tee_close_session() closes a session to a Trusted Application + +Much of the communication between clients and the TEE is opaque to the +driver. The main job for the driver is to receive requests from the +clients, forward them to the TEE and send back the results. + +OP-TEE driver +============= + +The OP-TEE driver handles OP-TEE [1] based TEEs. Currently it is only the ARM +TrustZone based OP-TEE solution that is supported. + +Lowest level of communication with OP-TEE builds on ARM SMC Calling +Convention (SMCCC) [2], which is the foundation for OP-TEE's SMC interface +[3] used internally by the driver. Stacked on top of that is OP-TEE Message +Protocol [4]. + +OP-TEE SMC interface provides the basic functions required by SMCCC and some +additional functions specific for OP-TEE. The most interesting functions are: + +- OPTEE_SMC_FUNCID_CALLS_UID (part of SMCCC) returns the version information + which is then returned by TEE_IOC_VERSION + +- OPTEE_SMC_CALL_GET_OS_UUID returns the particular OP-TEE implementation, used + to tell, for instance, a TrustZone OP-TEE apart from an OP-TEE running on a + separate secure co-processor. + +- OPTEE_SMC_CALL_WITH_ARG drives the OP-TEE message protocol + +- OPTEE_SMC_GET_SHM_CONFIG lets the driver and OP-TEE agree on which memory + range to used for shared memory between Linux and OP-TEE. + +The GlobalPlatform TEE Client API [5] is implemented on top of the generic +TEE API. + +Picture of the relationship between the different components in the +OP-TEE architecture: + + U-Boot Secure world + ~~~~~~ ~~~~~~~~~~~~ + +------------+ +-------------+ + | Client | | Trusted | + | | | Application | + +------------+ +-------------+ + /\ /\ + || || + \/ \/ + +------------+ +-------------+ + | TEE | | TEE Internal| + | uclass | | API | + +------------+ +-------------+ + | OP-TEE | | OP-TEE | + | driver | | Trusted OS | + +------------+-----------+-------------+ + | OP-TEE MSG | + | SMCCC (OPTEE_SMC_CALL_*) | + +--------------------------------------+ + +RPC (Remote Procedure Call) are requests from secure world to the driver. +An RPC is identified by a special range of SMCCC return values from +OPTEE_SMC_CALL_WITH_ARG. + +References +========== + +[1] https://github.com/OP-TEE/optee_os + +[2] http://infocenter.arm.com/help/topic/com.arm.doc.den0028a/index.html + +[3] drivers/tee/optee/optee_smc.h + +[4] drivers/tee/optee/optee_msg.h + +[5] http://www.globalplatform.org/specificationsdevice.asp look for + "TEE Client API Specification v1.0" and click download.
Signature · 1 line
2.17.1
PATCH v4 8/19 Documentation: tee uclass and op-tee driver
Quoted 2 lines · Jens Wiklander
Reviewed-by Simon Glass <[email protected]>Signed-off-by Jens Wiklander <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: not available URL: <http://lists.denx.de/pipermail/u-boot/attachments/20181007/4f3211ce/attachment.sig>
PATCH v4 9/19 arm: dt: hikey: Add optee node
In reply to Jens WiklanderSync with 14e21cb8f811 ("arm64: dt: hikey: Add optee node" from Linux kernel.
--- arch/arm/dts/hi6220-hikey.dts | 7 +++++++ 1 file changed, 7 insertions(+)
arch/arm/dts/hi6220-hikey.dts +7 -0
@@ -31,6 +31,13 @@ device_type = "memory"; reg = <0x0 0x0 0x0 0x40000000>; }; + + firmware { + optee { + compatible = "linaro,optee-tz"; + method = "smc"; + }; + }; }; &uart2 {
Signature · 1 line
2.17.1
PATCH v4 9/19 arm: dt: hikey: Add optee node
Quoted 5 lines · Jens Wiklander
Sync with
14e21cb8f811("arm64: dt: hikey: Add optee node" from Linux kernel.Reviewed-by Simon Glass <[email protected]>Signed-off-by Jens Wiklander <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: not available URL: <http://lists.denx.de/pipermail/u-boot/attachments/20181007/08436ed8/attachment.sig>
PATCH v4 10/19 optee: support routing of rpmb data frames to mmc
In reply to Jens WiklanderAdds support in optee supplicant to route signed (MACed) RPMB frames from OP-TEE Secure OS to MMC and vice versa to manipulate the RPMB partition.
--- drivers/tee/optee/Makefile | 1 + drivers/tee/optee/core.c | 8 ++ drivers/tee/optee/optee_private.h | 55 ++++++++- drivers/tee/optee/rpmb.c | 181 ++++++++++++++++++++++++++++++ drivers/tee/optee/supplicant.c | 3 + 5 files changed, 247 insertions(+), 1 deletion(-) create mode 100644 drivers/tee/optee/rpmb.c
drivers/tee/optee/Makefile +1 -0
@@ -2,3 +2,4 @@ obj-y += core.o obj-y += supplicant.o +obj-$(CONFIG_SUPPORT_EMMC_RPMB) += rpmb.o
drivers/tee/optee/core.c +8 -0
@@ -315,6 +315,13 @@ static u32 do_call_with_arg(struct udevice *dev, struct optee_msg_arg *arg) param.a3 = res.a3;handle_rpc (dev, ¶m, &page_list); }else { +/* +* In case we've accessed RPMB to serve an RPC +* request we need to restore the previously +* selected partition as the caller may expect it +* to remain unchanged. +*/ +optee_suppl_rpmb_release (dev);return call_err_to_res (res.a0); } }
@@ -651,4 +658,5 @@ U_BOOT_DRIVER(optee) = { .probe = optee_probe, .ops = &optee_ops, .platdata_auto_alloc_size = sizeof(struct optee_pdata), + .priv_auto_alloc_size = sizeof(struct optee_private), };
drivers/tee/optee/optee_private.h +54 -1
61 lines not on this page · raw message
drivers/tee/optee/rpmb.c new file +181 -0
181 lines not on this page · raw message
drivers/tee/optee/supplicant.c +3 -0
@@ -85,6 +85,9 @@ void optee_suppl_cmd(struct udevice *dev, struct tee_shm *shm_arg,debug ("OPTEE_MSG_RPC_CMD_FS not implemented\n" ); arg->ret =TEE_ERROR_NOT_IMPLEMENTED ;break ; +case OPTEE_MSG_RPC_CMD_RPMB : +optee_suppl_cmd_rpmb (dev, arg); +break ;default : arg->ret =TEE_ERROR_NOT_IMPLEMENTED ; }
Signature · 1 line
2.17.1
PATCH v4 10/19 optee: support routing of rpmb data frames to mmc
Quoted 6 lines · Jens Wiklander
Adds support in optee supplicant to route signed (MACed) RPMB frames from OP-TEE Secure OS to MMC and vice versa to manipulate the RPMB partition.
Tested-by Igor Opaniuk <[email protected]>Signed-off-by Jens Wiklander <[email protected]>
Quoted 8 lines
--- drivers/tee/optee/Makefile | 1 + drivers/tee/optee/core.c | 8 ++ drivers/tee/optee/optee_private.h | 55 ++++++++- drivers/tee/optee/rpmb.c | 181 ++++++++++++++++++++++++++++++ drivers/tee/optee/supplicant.c | 3 + 5 files changed, 247 insertions(+), 1 deletion(-) create mode 100644 drivers/tee/optee/rpmb.c
PATCH v4 10/19 optee: support routing of rpmb data frames to mmc
In reply to Jens WiklanderQuoted 7 lines · Jens Wiklander
Adds support in optee supplicant to route signed (MACed) RPMB frames from OP-TEE Secure OS to MMC and vice versa to manipulate the RPMB partition.
Tested-by Igor Opaniuk <[email protected]>Signed-off-by Jens Wiklander <[email protected]>Reviewed-by Simon Glass <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: not available URL: <http://lists.denx.de/pipermail/u-boot/attachments/20181007/5aa73dc3/attachment.sig>
PATCH v4 11/19 tee: optee: support AVB trusted application
In reply to Jens WiklanderAdds configuration option OPTEE_TA_AVB and a header file describing the interface to the Android Verified Boot 2.0 (AVB) trusted application provided by OP-TEE.
--- MAINTAINERS | 1 + drivers/tee/optee/Kconfig | 16 +++++++++++++ drivers/tee/tee-uclass.c | 24 +++++++++++++++++++ include/tee.h | 38 ++++++++++++++++++++++++++++++ include/tee/optee_ta_avb.h | 48 ++++++++++++++++++++++++++++++++++++++ 5 files changed, 127 insertions(+) create mode 100644 include/tee/optee_ta_avb.h
MAINTAINERS +1 -0
@@ -590,6 +590,7 @@ M: Jens Wiklander <[email protected]> S: Maintained F: drivers/tee/ F: include/tee.h +F: include/tee/ UBI M: Kyungmin Park <[email protected]>
drivers/tee/optee/Kconfig +16 -0
@@ -9,3 +9,19 @@ config OPTEE mechanism. This driver can request services from OP-TEE, but also handle Remote Procedure Calls (RPC) from OP-TEE needed to execute a service. For more information see: https://www.op-tee.org + +if OPTEE + +menu "OP-TEE options" + +config OPTEE_TA_AVB + bool "Support AVB TA" + default y + help + Enables support for the AVB Trusted Application (TA) in OP-TEE. + The TA can support the "avb" subcommands "read_rb", "write"rb" + and "is_unlocked". + +endmenu + +endif
drivers/tee/tee-uclass.c +24 -0
@@ -207,3 +207,27 @@ UCLASS_DRIVER(tee) = { .pre_probe = tee_pre_probe, .pre_remove = tee_pre_remove, }; + +void tee_optee_ta_uuid_from_octets (struct tee_optee_ta_uuid *d, +const u8 s[TEE_UUID_LEN ]) +{ + d->time_low = ((u32 )s[0 ] <<24 ) | ((u32 )s[1 ] <<16 ) | + ((u32 )s[2 ] <<8 ) | s[3 ], + d->time_mid = ((u32 )s[4 ] <<8 ) | s[5 ]; + d->time_hi_and_version = ((u32 )s[6 ] <<8 ) | s[7 ]; +memcpy (d->clock_seq_and_node, s +8 ,sizeof (d->clock_seq_and_node)); +} + +void tee_optee_ta_uuid_to_octets (u8 d[TEE_UUID_LEN ], +const struct tee_optee_ta_uuid *s) +{ + d[0 ] = s->time_low >>24 ; + d[1 ] = s->time_low >>16 ; + d[2 ] = s->time_low >>8 ; + d[3 ] = s->time_low; + d[4 ] = s->time_mid >>8 ; + d[5 ] = s->time_mid; + d[6 ] = s->time_hi_and_version >>8 ; + d[7 ] = s->time_hi_and_version; +memcpy (d +8 , s->clock_seq_and_node,sizeof (s->clock_seq_and_node)); +}
include/tee.h +38 -0
@@ -49,6 +49,22 @@#define TEE_ORIGIN_TRUSTED_APP 0x00000004struct udevice ; + +/** +* struct tee_optee_ta_uuid - OP-TEE Trusted Application (TA) UUID format +* +* Used to identify an OP-TEE TA and define suitable to initialize structs +* of this format is distributed with the interface of the TA. The +* individual fields of this struct doesn't have any special meaning in +* OP-TEE. See RFC4122 for details on the format. +*/ +struct tee_optee_ta_uuid { +u32 time_low; +u16 time_mid; +u16 time_hi_and_version; +u8 clock_seq_and_node[8 ]; +}; +/** * struct tee_shm - memory shared with the TEE * @dev: The TEE device
@@ -333,4 +349,26 @@ int tee_close_session(struct udevice *dev, u32 session);int tee_invoke_func (struct udevice *dev,struct tee_invoke_arg *arg,uint num_param,struct tee_param *param); +/** +* tee_optee_ta_uuid_from_octets() - Converts to struct tee_optee_ta_uuid +* @d: Destination struct +* @s: Source UUID octets +* +* Conversion to a struct tee_optee_ta_uuid represantion from binary octet +* representation. +*/ +void tee_optee_ta_uuid_from_octets (struct tee_optee_ta_uuid *d, +const u8 s[TEE_UUID_LEN ]); + +/** +* tee_optee_ta_uuid_to_octets() - Converts from struct tee_optee_ta_uuid +* @d: Destination UUID octets +* @s: Source struct +* +* Conversion from a struct tee_optee_ta_uuid represantion to binary octet +* representation. +*/ +void tee_optee_ta_uuid_to_octets (u8 d[TEE_UUID_LEN ], +const struct tee_optee_ta_uuid *s); +#endif /* __TEE_H */
include/tee/optee_ta_avb.h new file +48 -0
48 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH v4 11/19 tee: optee: support AVB trusted application
Quoted 7 lines · Jens Wiklander
Adds configuration option
OPTEE_TA_AVBand a header file describing the interface to the Android Verified Boot 2.0 (AVB) trusted application provided by OP-TEE.Tested-by Igor Opaniuk <[email protected]>Reviewed-by Igor Opaniuk <[email protected]>Signed-off-by Jens Wiklander <[email protected]>
Quoted 8 lines
--- MAINTAINERS | 1 + drivers/tee/optee/Kconfig | 16 +++++++++++++ drivers/tee/tee-uclass.c | 24 +++++++++++++++++++ include/tee.h | 38 ++++++++++++++++++++++++++++++ include/tee/optee_ta_avb.h | 48 ++++++++++++++++++++++++++++++++++++++ 5 files changed, 127 insertions(+) create mode 100644 include/tee/optee_ta_avb.h
PATCH v4 11/19 tee: optee: support AVB trusted application
In reply to Jens WiklanderQuoted 8 lines · Jens Wiklander
Adds configuration option
OPTEE_TA_AVBand a header file describing the interface to the Android Verified Boot 2.0 (AVB) trusted application provided by OP-TEE.Tested-by Igor Opaniuk <[email protected]>Reviewed-by Igor Opaniuk <[email protected]>Signed-off-by Jens Wiklander <[email protected]>Reviewed-by Simon Glass <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: not available URL: <http://lists.denx.de/pipermail/u-boot/attachments/20181007/450883ee/attachment.sig>
PATCH v4 12/19 sandbox: dt: add sandbox_tee node
In reply to Jens WiklanderAdds a sandbox_tee node to enable the sandbox tee driver in all the sandbox dts files.
--- arch/sandbox/dts/sandbox.dts | 4 ++++ arch/sandbox/dts/sandbox64.dts | 4 ++++ arch/sandbox/dts/test.dts | 4 ++++ 3 files changed, 12 insertions(+)
arch/sandbox/dts/sandbox.dts +4 -0
@@ -322,6 +322,10 @@ reg = <0x0 0x400>; }; }; + + sandbox_tee { + compatible = "sandbox,tee"; + }; }; #include "cros-ec-keyboard.dtsi"
arch/sandbox/dts/sandbox64.dts +4 -0
@@ -311,6 +311,10 @@ }; }; }; + + sandbox_tee { + compatible = "sandbox,tee"; + }; }; #include "cros-ec-keyboard.dtsi"
arch/sandbox/dts/test.dts +4 -0
@@ -630,6 +630,10 @@ }; }; }; + + sandbox_tee { + compatible = "sandbox,tee"; + }; }; #include "sandbox_pmic.dtsi"
Signature · 1 line
2.17.1
PATCH v4 12/19 sandbox: dt: add sandbox_tee node
Quoted 5 lines · Jens Wiklander
Adds a
sandbox_teenode to enable the sandbox tee driver in all the sandbox dts files.Reviewed-by Simon Glass <[email protected]>Signed-off-by Jens Wiklander <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: not available URL: <http://lists.denx.de/pipermail/u-boot/attachments/20181007/39aa3f18/attachment.sig>
PATCH v4 13/19 sandbox: imply CONFIG_TEE (TEE uclass)
In reply to Jens Wiklander--- arch/Kconfig | 1 + 1 file changed, 1 insertion(+)
arch/Kconfig +1 -0
@@ -91,6 +91,7 @@ config SANDBOX imply HASH_VERIFY imply LZMA imply SCSI + imply TEE config SH bool "SuperH architecture"
Signature · 1 line
2.17.1
PATCH v4 13/19 sandbox: imply CONFIG_TEE (TEE uclass)
Quoted 2 lines · Jens Wiklander
Reviewed-by Simon Glass <[email protected]>Signed-off-by Jens Wiklander <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: not available URL: <http://lists.denx.de/pipermail/u-boot/attachments/20181007/d9f0c55b/attachment.sig>
PATCH v4 14/19 tee: add sandbox driver
In reply to Jens WiklanderAdds a sandbox tee driver which emulates a generic TEE with the OP-TEE AVB TA.
--- drivers/tee/Kconfig | 18 ++- drivers/tee/Makefile | 1 + drivers/tee/optee/Kconfig | 2 +- drivers/tee/sandbox.c | 308 ++++++++++++++++++++++++++++++++++++++ include/sandboxtee.h | 21 +++ 5 files changed, 347 insertions(+), 3 deletions(-) create mode 100644 drivers/tee/sandbox.c create mode 100644 include/sandboxtee.h
drivers/tee/Kconfig +16 -2
@@ -1,8 +1,8 @@ # Generic Trusted Execution Environment Configuration config TEE bool "Trusted Execution Environment support" - depends on ARM && (ARM64 || CPU_V7A) - select ARM_SMCCC + depends on (ARM && (ARM64 || CPU_V7A)) || SANDBOX + select ARM_SMCCC if ARM help This implements a generic interface towards a Trusted Execution Environment (TEE). A TEE is a trusted OS running in some secure
@@ -14,6 +14,20 @@ if TEE menu "TEE drivers" +config SANDBOX_TEE + bool "Sandbox TEE emulator" + depends on SANDBOX + default y + help + This emulates a generic TEE needed for testing including the AVB + TA. The emulation provides all callbacks of a regular TEE and + supports session and shared memory management. The AVB TA is + emulated with rollback indexes and device lock-state, the state + of the TA is only kept in RAM and will be reset on each boot. + The emulation only supports one open session at a time. + Interaction from the U-Boot command line in possible via the + "avb" commands. + source "drivers/tee/optee/Kconfig" endmenu
drivers/tee/Makefile +1 -0
@@ -1,4 +1,5 @@ # SPDX-License-Identifier: GPL-2.0+ obj-y += tee-uclass.o +obj-$(CONFIG_SANDBOX) += sandbox.o obj-$(CONFIG_OPTEE) += optee/
drivers/tee/optee/Kconfig +1 -1
@@ -10,7 +10,7 @@ config OPTEE handle Remote Procedure Calls (RPC) from OP-TEE needed to execute a service. For more information see: https://www.op-tee.org -if OPTEE +if OPTEE || SANDBOX menu "OP-TEE options"
drivers/tee/sandbox.c new file +308 -0
308 lines not on this page · raw message
include/sandboxtee.h new file +21 -0
@@ -0,0 +1,21 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* +* Copyright (C) 2018 Linaro Limited +*/ + +#ifndef __SANDBOXTEE_H +#define __SANDBOXTEE_H + +/** +* struct sandbox_tee_state - internal state of the sandbox TEE +* @session: current open session +* @num_shms: number of registered shared memory objects +* @ta: Trusted Application of current session +*/ +struct sandbox_tee_state { +u32 session; +int num_shms; +void *ta; +}; + +#endif /*__SANDBOXTEE_H*/
Signature · 1 line
2.17.1
PATCH v4 14/19 tee: add sandbox driver
Quoted 5 lines · Jens Wiklander
Adds a sandbox tee driver which emulates a generic TEE with the OP-TEE AVB TA.
Reviewed-by Simon Glass <[email protected]>Signed-off-by Jens Wiklander <[email protected]>
Quoted 9 lines
--- drivers/tee/Kconfig | 18 ++- drivers/tee/Makefile | 1 + drivers/tee/optee/Kconfig | 2 +- drivers/tee/sandbox.c | 308 ++++++++++++++++++++++++++++++++++++++ include/sandboxtee.h | 21 +++ 5 files changed, 347 insertions(+), 3 deletions(-) create mode 100644 drivers/tee/sandbox.c create mode 100644 include/sandboxtee.h
PATCH v4 14/19 tee: add sandbox driver
In reply to Jens WiklanderQuoted 6 lines · Jens Wiklander
Adds a sandbox tee driver which emulates a generic TEE with the OP-TEE AVB TA.
Reviewed-by Simon Glass <[email protected]>Signed-off-by Jens Wiklander <[email protected]>Reviewed-by Simon Glass <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: not available URL: <http://lists.denx.de/pipermail/u-boot/attachments/20181007/20425b0c/attachment.sig>
PATCH v4 15/19 test: tee: test TEE uclass
In reply to Jens WiklanderTests the TEE uclass with a sandbox tee driver.
--- test/dm/Makefile | 1 + test/dm/tee.c | 98 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 99 insertions(+) create mode 100644 test/dm/tee.c
test/dm/Makefile +1 -0
@@ -46,4 +46,5 @@ obj-$(CONFIG_SPMI) += spmi.o obj-$(CONFIG_WDT) += wdt.o obj-$(CONFIG_AXI) += axi.o obj-$(CONFIG_MISC) += misc.o +obj-$(CONFIG_TEE) += tee.o endif
test/dm/tee.c new file +98 -0
98 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH v4 15/19 test: tee: test TEE uclass
Quoted 4 lines · Jens Wiklander
Tests the TEE uclass with a sandbox tee driver.
Reviewed-by Simon Glass <[email protected]>Signed-off-by Jens Wiklander <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: not available URL: <http://lists.denx.de/pipermail/u-boot/attachments/20181007/8bbe1ead/attachment.sig>
PATCH v4 16/19 avb_verify: support using OP-TEE TA AVB
In reply to Jens WiklanderWith CONFIG_OPTEE_TA_AVB use the trusted application AVB provided by OP-TEE to manage rollback indexes and device-lock status.
--- common/avb_verify.c | 118 ++++++++++++++++++++++++++++++++++++++++++- doc/README.avb2 | 13 +++++ include/avb_verify.h | 4 ++ 3 files changed, 134 insertions(+), 1 deletion(-)
common/avb_verify.c +117 -1
@@ -10,6 +10,8 @@#include <image.h> #include <malloc.h> #include <part.h> +#include <tee.h> +#include <tee/optee_ta_avb.h> static const unsigned char avb_root_pub[1032 ] = {0x0 ,0x0 ,0x10 ,0x0 ,0x55 ,0xd9 ,0x4 ,0xad ,0xd8 ,0x4 ,
@@ -600,6 +602,65 @@ static AvbIOResult validate_vbmeta_public_key(AvbOps *ops,return AVB_IO_RESULT_OK ; } +#ifdef CONFIG_OPTEE_TA_AVB +static int get_open_session (struct AvbOpsData *ops_data) +{ +struct udevice *tee =NULL ; + +while (!ops_data->tee) { +const struct tee_optee_ta_uuid uuid =TA_AVB_UUID ; +struct tee_open_session_arg arg; +int rc; + + tee =tee_find_device (tee,NULL ,NULL ,NULL ); +if (!tee) +return -ENODEV ; + +memset (&arg,0 ,sizeof (arg)); +tee_optee_ta_uuid_to_octets (arg.uuid, &uuid); + rc =tee_open_session (tee, &arg,0 ,NULL ); +if (!rc) { + ops_data->tee = tee; + ops_data->session = arg.session; + } + } + +return 0 ; +} + +static AvbIOResult invoke_func (struct AvbOpsData *ops_data,u32 func, +ulong num_param,struct tee_param *param) +{ +struct tee_invoke_arg arg; + +if (get_open_session (ops_data)) +return AVB_IO_RESULT_ERROR_IO ; + +memset (&arg,0 ,sizeof (arg)); + arg.func = func; + arg.session = ops_data->session; + +if (tee_invoke_func (ops_data->tee, &arg, num_param, param)) +return AVB_IO_RESULT_ERROR_IO ; +switch (arg.ret) { +case TEE_SUCCESS : +return AVB_IO_RESULT_OK ; +case TEE_ERROR_OUT_OF_MEMORY : +return AVB_IO_RESULT_ERROR_OOM ; +case TEE_ERROR_TARGET_DEAD : +/* +* The TA has paniced, close the session to reload the TA +* for the next request. +*/ +tee_close_session (ops_data->tee, ops_data->session); + ops_data->tee =NULL ; +return AVB_IO_RESULT_ERROR_IO ; +default : +return AVB_IO_RESULT_ERROR_IO ; + } +} +#endif +/** * read_rollback_index() - gets the rollback index corresponding to the * location of given by @out_rollback_index.
@@ -615,6 +676,7 @@ static AvbIOResult read_rollback_index(AvbOps *ops,size_t rollback_index_slot, u64 *out_rollback_index) { +#ifndef CONFIG_OPTEE_TA_AVB/* For now we always return 0 as the stored rollback index. */ printf("%s not supported yet\n", __func__);
@@ -622,6 +684,27 @@ static AvbIOResult read_rollback_index(AvbOps *ops, *out_rollback_index =0 ;return AVB_IO_RESULT_OK ; +#else +AvbIOResult rc; +struct tee_param param[2 ]; + +if (rollback_index_slot >=TA_AVB_MAX_ROLLBACK_LOCATIONS ) +return AVB_IO_RESULT_ERROR_NO_SUCH_VALUE ; + +memset (param,0 ,sizeof (param)); + param[0 ].attr =TEE_PARAM_ATTR_TYPE_VALUE_INPUT ; + param[0 ].u.value.a = rollback_index_slot; + param[1 ].attr =TEE_PARAM_ATTR_TYPE_VALUE_OUTPUT ; + + rc =invoke_func (ops->user_data,TA_AVB_CMD_READ_ROLLBACK_INDEX , +ARRAY_SIZE (param), param); +if (rc) +return rc; + + *out_rollback_index = (u64 )param[1 ].u.value.a <<32 | + (u32 )param[1 ].u.value.b; +return AVB_IO_RESULT_OK ; +#endif }/**
@@ -639,10 +722,27 @@ static AvbIOResult write_rollback_index(AvbOps *ops, size_t rollback_index_slot, u64 rollback_index) { +#ifndef CONFIG_OPTEE_TA_AVB /* For now this is a no-op. */ printf ("%s not supported yet\n" , __func__);return AVB_IO_RESULT_OK ; +#else +struct tee_param param[2 ]; + +if (rollback_index_slot >=TA_AVB_MAX_ROLLBACK_LOCATIONS ) +return AVB_IO_RESULT_ERROR_NO_SUCH_VALUE ; + +memset (param,0 ,sizeof (param)); + param[0 ].attr =TEE_PARAM_ATTR_TYPE_VALUE_INPUT ; + param[0 ].u.value.a = rollback_index_slot; + param[1 ].attr =TEE_PARAM_ATTR_TYPE_VALUE_INPUT ; + param[1 ].u.value.a = (u32)(rollback_index >>32 ); + param[1 ].u.value.b = (u32 )rollback_index; + +return invoke_func (ops->user_data,TA_AVB_CMD_WRITE_ROLLBACK_INDEX , +ARRAY_SIZE (param), param); +#endif }/**
@@ -658,6 +758,7 @@ static AvbIOResult write_rollback_index(AvbOps *ops,*/ static AvbIOResult read_is_device_unlocked (AvbOps *ops,bool *out_is_unlocked) { +#ifndef CONFIG_OPTEE_TA_AVB /* For now we always return that the device is unlocked. */ printf ("%s not supported yet\n" , __func__);
@@ -665,6 +766,16 @@ static AvbIOResult read_is_device_unlocked(AvbOps *ops, bool *out_is_unlocked) *out_is_unlocked = true;return AVB_IO_RESULT_OK ; +#else +AvbIOResult rc; +struct tee_param param = { .attr =TEE_PARAM_ATTR_TYPE_VALUE_OUTPUT }; + + rc =invoke_func (ops->user_data,TA_AVB_CMD_READ_LOCK_STATE ,1 , ¶m); +if (rc) +return rc; + *out_is_unlocked = !param.u.value.a; +return AVB_IO_RESULT_OK ; +#endif }/**
@@ -774,6 +885,11 @@ void avb_ops_free(AvbOps *ops) ops_data = ops->user_data; -if (ops_data) +if (ops_data) { +#ifdef CONFIG_OPTEE_TA_AVB +if (ops_data->tee) +tee_close_session (ops_data->tee, ops_data->session); +#endif avb_free (ops_data); + } }
doc/README.avb2 +13 -0
@@ -18,6 +18,13 @@ Integrity of the bootloader (U-boot BLOB and environment) is out of scope. For additional details check: https://android.googlesource.com/platform/external/avb/+/master/README.md +1.1. AVB using OP-TEE (optional) +--------------------------------- +If AVB is configured to use OP-TEE (see 4. below) rollback indexes and +device lock state are stored in RPMB. The RPMB partition is managed by +OP-TEE (https://www.op-tee.org/) which is a secure OS leveraging ARM +TrustZone. + 2. AVB 2.0 U-BOOT SHELL COMMANDS -----------------------------------
@@ -61,6 +68,12 @@ CONFIG_LIBAVB=y CONFIG_AVB_VERIFY=y CONFIG_CMD_AVB=y +In addtion optionally if storing rollback indexes in RPMB with help of +OP-TEE: +CONFIG_TEE=y +CONFIG_OPTEE=y +CONFIG_OPTEE_TA_AVB=y +CONFIG_SUPPORT_EMMC_RPMB=y Then add `avb verify` invocation to your android boot sequence of commands, e.g.:
include/avb_verify.h +4 -0
@@ -27,6 +27,10 @@ struct AvbOpsData {struct AvbOps ops;int mmc_dev;enum avb_boot_state boot_state; +#ifdef CONFIG_OPTEE_TA_AVB +struct udevice *tee; +u32 session; +#endif };struct mmc_part {
Signature · 1 line
2.17.1
PATCH v4 16/19 avb_verify: support using OP-TEE TA AVB
Quoted 5 lines · Jens Wiklander
With
CONFIG_OPTEE_TA_AVBuse the trusted application AVB provided by OP-TEE to manage rollback indexes and device-lock status.Reviewed-by Simon Glass <[email protected]>Signed-off-by Jens Wiklander <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: not available URL: <http://lists.denx.de/pipermail/u-boot/attachments/20181007/9d2f6ba7/attachment.sig>
PATCH v4 17/19 test_avb: Update pymark.buildconfigspec information for the AVB tests
In reply to Jens WiklanderUpdate the pymark.buildconfigspec to depend on 'cmd_mmc' in addition to 'cmd_avb' for those tests that needs more a more complete MMC implementation or the "mmc" command.
--- test/py/tests/test_avb.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
test/py/tests/test_avb.py +5 -3
@@ -23,7 +23,7 @@ mmc_dev = 1 temp_addr = 0x90000000 temp_addr2 = 0x90002000 - at pytest.mark.buildconfigspec('cmd_avb') + at pytest.mark.buildconfigspec('cmd_avb', 'cmd_mmc') def test_avb_verify(u_boot_console): """Run AVB 2.0 boot verification chain with avb subset of commands """
@@ -36,7 +36,7 @@ def test_avb_verify(u_boot_console): assert response.find(success_str) - at pytest.mark.buildconfigspec('cmd_avb') + at pytest.mark.buildconfigspec('cmd_avb', 'cmd_mmc') def test_avb_mmc_uuid(u_boot_console): """Check if 'avb get_uuid' works, compare results with 'part list mmc 1' output
@@ -78,6 +78,7 @@ def test_avb_read_rb(u_boot_console): assert response == '' response = u_boot_console.run_command('avb read_rb 1') + assert response == 'Rollback index: 0' @pytest.mark.buildconfigspec('cmd_avb')
@@ -89,9 +90,10 @@ def test_avb_is_unlocked(u_boot_console): assert response == '' response = u_boot_console.run_command('avb is_unlocked') + assert response == 'Unlocked = 1' - at pytest.mark.buildconfigspec('cmd_avb') + at pytest.mark.buildconfigspec('cmd_avb', 'cmd_mmc') def test_avb_mmc_read(u_boot_console): """Test mmc read operation """
Signature · 1 line
2.17.1
PATCH v4 17/19 test_avb: Update pymark.buildconfigspec information for the AVB tests
Quoted 6 lines · Jens Wiklander
Update the pymark.buildconfigspec to depend on '
cmd_mmc' in addition to 'cmd_avb' for those tests that needs more a more complete MMC implementation or the "mmc" command.Reviewed-by Simon Glass <[email protected]>Signed-off-by Jens Wiklander <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: not available URL: <http://lists.denx.de/pipermail/u-boot/attachments/20181007/600a85f7/attachment.sig>
PATCH v4 18/19 avb_verify: support sandbox configuration
In reply to Jens WiklanderChange get_sector_buf() to use map_sysmem() to get a pointer to the CONFIG_FASTBOOT_BUF_ADDR in memory.
--- include/avb_verify.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
include/avb_verify.h +2 -1
@@ -9,6 +9,7 @@#define _AVB_VERIFY_H#include <../lib/libavb/libavb.h> +#include <mapmem.h> #include <mmc.h> #define AVB_MAX_ARGS 1024
@@ -76,7 +77,7 @@ static inline size_t get_sector_buf_size(void)static inline void *get_sector_buf (void ) { -return (void *)CONFIG_FASTBOOT_BUF_ADDR ; +return map_sysmem (CONFIG_FASTBOOT_BUF_ADDR ,CONFIG_FASTBOOT_BUF_SIZE ); }static inline bool is_buf_unaligned (void *buffer)
Signature · 1 line
2.17.1
PATCH v4 18/19 avb_verify: support sandbox configuration
Quoted 7 lines · Jens Wiklander
Change
get_sector_buf()to usemap_sysmem()to get a pointer to theCONFIG_FASTBOOT_BUF_ADDRin memory.Signed-off-by Jens Wiklander <[email protected]>--- include/avb_verify.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
PATCH v4 18/19 avb_verify: support sandbox configuration
In reply to Jens WiklanderQuoted 5 lines · Jens Wiklander
Change
get_sector_buf()to usemap_sysmem()to get a pointer to theCONFIG_FASTBOOT_BUF_ADDRin memory.Signed-off-by Jens Wiklander <[email protected]>Reviewed-by Simon Glass <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: not available URL: <http://lists.denx.de/pipermail/u-boot/attachments/20181007/70167a41/attachment.sig>
PATCH v4 19/19 Kconfig: sandbox: enable cmd_avb and dependencies
In reply to Jens WiklanderEnables cmd_avb and its dependencies need to run the AVB tests.
--- arch/Kconfig | 4 ++++ drivers/fastboot/Kconfig | 2 ++ 2 files changed, 6 insertions(+)
arch/Kconfig +4 -0
@@ -92,6 +92,10 @@ config SANDBOX imply LZMA imply SCSI imply TEE + imply AVB_VERIFY + imply LIBAVB + imply CMD_AVB + imply UDP_FUNCTION_FASTBOOT config SH bool "SuperH architecture"
drivers/fastboot/Kconfig +2 -0
@@ -35,6 +35,7 @@ config FASTBOOT_BUF_ADDR ROCKCHIP_RK3399 default 0x280000 if ROCKCHIP_RK3368 default 0x100000 if ARCH_ZYNQMP + default 0 if SANDBOX help The fastboot protocol requires a large memory buffer for downloads. Define this to the starting RAM address to use for
@@ -45,6 +46,7 @@ config FASTBOOT_BUF_SIZE default 0x8000000 if ARCH_ROCKCHIP default 0x6000000 if ARCH_ZYNQMP default 0x2000000 if ARCH_SUNXI + default 0x8192 if SANDBOX default 0x7000000 help The fastboot protocol requires a large memory buffer for
Signature · 1 line
2.17.1
PATCH v4 19/19 Kconfig: sandbox: enable cmd_avb and dependencies
Quoted 4 lines · Jens Wiklander
Enables
cmd_avband its dependencies need to run the AVB tests.Reviewed-by Simon Glass <[email protected]>Signed-off-by Jens Wiklander <[email protected]>
Applied to u-boot/master.
But please note, some of the AVB Kconfig dependencies need to be tightened up as this was attempting to build on sandbox_noblk and failing on lack of MMC stuff (due to no CONFIG_BLK). I worked around it for the moment to move this forward by updating sandbox_noblk_defconfig to disable AVB but we should correct this in Kconfig dependency expressions, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: not available URL: <http://lists.denx.de/pipermail/u-boot/attachments/20181007/d2121707/attachment.sig>
v4 cover AVB using OP-TEE
In reply to Jens WiklanderHi Jen,
Quoted 46 lines · Jens Wiklander
Hi,
This adds support for storing AVB rollback indexes in the RPMB partition. The RPMB partition (content and key) is managed by OP-TEE
(https://www.op-tee.org/) which is a secure OS leveraging ARM TrustZone.The Linux kernel can already support OP-TEE with reading and updating rollback indexes in the RPMB partition, the catch is that this is needed before the kernel has booted.
The design here is the same as what is in the Linux kernel, with the exception that the user space daemon tee-supplicant is integrated in the OP-TEE driver here (
drivers/tee/optee/supplicant.c) instead. A new uclass (UCLASS_TEE) is introduced to provide an abstraction for interfacing with a Trusted Execution Environment (TEE). There's also the OP-TEE driver usingUCLASS_TEEfor registration.A Trusted Application (TA) interface is added to be used by the AVB verify functions which are updated accordingly. The TA is managed by OP-TEE and is executed in a secure TrustZone protected environment.
The header files
drivers/tee/optee/optee_{msg,msg_supplicant,smc}.handinclude/tee/optee_ta_avb.hare copied from
https://github.com/OP-TEE/optee_os/tree/master more or less unmodified. They may need to be updated from time to time in order to support new features.In MMC there's a new function,
mmc_rpmb_route_frames(), which as the name suggests is used to route RPMB frames to/from the MMC. This saves OP-TEE from implementing an MMC driver which would need to share resources with its counterpart here in U-Boot.This was tested on a Hikey (Kirin 620) board.
I've added myself as maintainer of the TEE stuff.
changes in v4:
* Addressed review comments from Simon Glass
* Rebased on v2018.09
* "avb_verify: bugfixavb_ops_free()skipping free" removed due to the rebase
* Commits "dt/bindings: add bindings for optee",
"sandbox: implyCONFIG_TEE(TEE uclass)",
"tee: add sandbox driver",
"avb_verify: support using OP-TEE TA AVB",
"test_avb: Update pymark.buildconfigspec information for the AVB tests", "Kconfig: sandbox: enablecmd_avband dependencies",
Quoted 4 lines
Reviewed-by Simon Glass <[email protected]>* Added descriptions of additional structs and functions
* In commit "avb_verify: support sandbox configuration" avoid the #ifdefCONFIG_SANDBOXinget_sector_buf()as suggested by Simon.
You might consider using patman, where you add the change log for each patch individually, and it produces the change log for the series automatically.
I find it harder to review patches which don't have their own individual change log.
Regards,
Simon
v4 cover AVB using OP-TEE
Hi Simon,
Quoted 54 lines · Simon Glass
Hi Jen,
Quoted 46 lines · Jens Wiklander
Hi,
This adds support for storing AVB rollback indexes in the RPMB partition. The RPMB partition (content and key) is managed by OP-TEE
(https://www.op-tee.org/) which is a secure OS leveraging ARM TrustZone.The Linux kernel can already support OP-TEE with reading and updating rollback indexes in the RPMB partition, the catch is that this is needed before the kernel has booted.
The design here is the same as what is in the Linux kernel, with the exception that the user space daemon tee-supplicant is integrated in the OP-TEE driver here (
drivers/tee/optee/supplicant.c) instead. A new uclass (UCLASS_TEE) is introduced to provide an abstraction for interfacing with a Trusted Execution Environment (TEE). There's also the OP-TEE driver usingUCLASS_TEEfor registration.A Trusted Application (TA) interface is added to be used by the AVB verify functions which are updated accordingly. The TA is managed by OP-TEE and is executed in a secure TrustZone protected environment.
The header files
drivers/tee/optee/optee_{msg,msg_supplicant,smc}.handinclude/tee/optee_ta_avb.hare copied from
https://github.com/OP-TEE/optee_os/tree/master more or less unmodified. They may need to be updated from time to time in order to support new features.In MMC there's a new function,
mmc_rpmb_route_frames(), which as the name suggests is used to route RPMB frames to/from the MMC. This saves OP-TEE from implementing an MMC driver which would need to share resources with its counterpart here in U-Boot.This was tested on a Hikey (Kirin 620) board.
I've added myself as maintainer of the TEE stuff.
changes in v4:
* Addressed review comments from Simon Glass
* Rebased on v2018.09
* "avb_verify: bugfixavb_ops_free()skipping free" removed due to the rebase
* Commits "dt/bindings: add bindings for optee",
"sandbox: implyCONFIG_TEE(TEE uclass)",
"tee: add sandbox driver",
"avb_verify: support using OP-TEE TA AVB",
"test_avb: Update patiensepymark.buildconfigspec information for the AVB tests", "Kconfig: sandbox: enablecmd_avband dependencies",Quoted 4 lines
Reviewed-by Simon Glass <[email protected]>* Added descriptions of additional structs and functions
* In commit "avb_verify: support sandbox configuration" avoid the #ifdefCONFIG_SANDBOXinget_sector_buf()as suggested by Simon.
Quoted 6 lines
You might consider using patman, where you add the change log for each patch individually, and it produces the change log for the series automatically.
I find it harder to review patches which don't have their own individual change log.
I'll try patman next time. A big thank you for reviewing this patch series.
--
Jens
v4 cover AVB using OP-TEE
Hi Jens,
Quoted 57 lines · Jens Wiklander
Hi Simon,
Quoted 54 lines · Simon Glass
Hi Jen,
Quoted 50 lines · Jens Wiklander
Hi,
This adds support for storing AVB rollback indexes in the RPMB partition. The RPMB partition (content and key) is managed by OP-TEE
(https://www.op-tee.org/) which is a secure OS leveraging ARM TrustZone.The Linux kernel can already support OP-TEE with reading and updating rollback indexes in the RPMB partition, the catch is that this is needed before the kernel has booted.
The design here is the same as what is in the Linux kernel, with the exception that the user space daemon tee-supplicant is integrated in the OP-TEE driver here (
drivers/tee/optee/supplicant.c) instead. A new uclass (UCLASS_TEE) is introduced to provide an abstraction for interfacing with a Trusted Execution Environment (TEE). There's also the OP-TEE driver usingUCLASS_TEEfor registration.A Trusted Application (TA) interface is added to be used by the AVB verify functions which are updated accordingly. The TA is managed by OP-TEE and is executed in a secure TrustZone protected environment.
The header files
drivers/tee/optee/optee_{msg,msg_supplicant,smc}.handinclude/tee/optee_ta_avb.hare copied from
https://github.com/OP-TEE/optee_os/tree/master more or less unmodified. They may need to be updated from time to time in order to support new features.In MMC there's a new function,
mmc_rpmb_route_frames(), which as the name suggests is used to route RPMB frames to/from the MMC. This saves OP-TEE from implementing an MMC driver which would need to share resources with its counterpart here in U-Boot.This was tested on a Hikey (Kirin 620) board.
I've added myself as maintainer of the TEE stuff.
changes in v4:
* Addressed review comments from Simon Glass
* Rebased on v2018.09
* "avb_verify: bugfixavb_ops_free()skipping free" removed due to the rebase
* Commits "dt/bindings: add bindings for optee",
"sandbox: implyCONFIG_TEE(TEE uclass)",
"tee: add sandbox driver",
"avb_verify: support using OP-TEE TA AVB",
"test_avb: Update patiensepymark.buildconfigspec information for the AVB tests", "Kconfig: sandbox: enablecmd_avband dependencies",Reviewed-by Simon Glass <[email protected]>* Added descriptions of additional structs and functions
* In commit "avb_verify: support sandbox configuration" avoid the #ifdefCONFIG_SANDBOXinget_sector_buf()as suggested by Simon.
Quoted 8 lines
Quoted 6 lines
You might consider using patman, where you add the change log for each patch individually, and it produces the change log for the series automatically.
I find it harder to review patches which don't have their own individual change log.
I'll try patman next time. A big thank you for reviewing this patch series.
You made it pretty easy :-) Thanks.
- Simon