[U-Boot] [RFC 4/9] arm: omap-common: add secure rom call API for secure devices

Lokesh Vutla lokeshvutla at ti.com
Fri Jun 17 06:18:05 CEST 2016



On Thursday 16 June 2016 12:56 AM, Andreas Dannenberg wrote:
> From: Daniel Allred <d-allred at ti.com>
> 
> Adds a generic C-callable API for making secure ROM calls on OMAP and
> OMAP-compatible devices. This API provides the important function of
> flushing the ROM call arguments to memory from the cache, so that the
> secure world will have a coherent view of those arguments. Then is
> simply calls the omap_smc_sec routine.
> 
> Signed-off-by: Daniel Allred <d-allred at ti.com>
> Signed-off-by: Andreas Dannenberg <dannenberg at ti.com>
> ---
>  arch/arm/cpu/armv7/omap-common/Makefile     |  4 +++
>  arch/arm/cpu/armv7/omap-common/sec_bridge.c | 47 +++++++++++++++++++++++++++++
>  arch/arm/include/asm/omap_common.h          |  4 +++
>  3 files changed, 55 insertions(+)
>  create mode 100644 arch/arm/cpu/armv7/omap-common/sec_bridge.c
> 
> diff --git a/arch/arm/cpu/armv7/omap-common/Makefile b/arch/arm/cpu/armv7/omap-common/Makefile
> index 87a7ac0..4fc3926 100644
> --- a/arch/arm/cpu/armv7/omap-common/Makefile
> +++ b/arch/arm/cpu/armv7/omap-common/Makefile
> @@ -28,6 +28,10 @@ obj-y	+= pipe3-phy.o
>  obj-$(CONFIG_SCSI_AHCI_PLAT) += sata.o
>  endif
>  
> +ifneq ($(CONFIG_TI_SECURE_DEVICE),)
> +obj-y   += sec_bridge.o
> +endif

can we use: obj-$(CONFIG_TI_SECURE_DEVICE) += sec_bridge.o ?

> +
>  ifeq ($(CONFIG_SYS_DCACHE_OFF),)
>  obj-y	+= omap-cache.o
>  endif
> diff --git a/arch/arm/cpu/armv7/omap-common/sec_bridge.c b/arch/arm/cpu/armv7/omap-common/sec_bridge.c
> new file mode 100644
> index 0000000..4eaba8e
> --- /dev/null
> +++ b/arch/arm/cpu/armv7/omap-common/sec_bridge.c
> @@ -0,0 +1,47 @@
> +/*
> + *
> + * Common bridge function to make OMAP secure ROM calls
> + *
> + * (C) Copyright 2016
> + * Texas Instruments, <www.ti.com>
> + *
> + * Daniel Allred    <d-allred at ti.com>
> + *
> + * SPDX-License-Identifier: GPL-2.0+
> + */
> +
> +#include <common.h>
> +#include <stdarg.h>
> +
> +#include <asm/arch/sys_proto.h>
> +#include <asm/omap_common.h>
> +
> +static uint32_t secure_rom_call_args[5] __aligned(ARCH_DMA_MINALIGN);
> +
> +u32 secure_rom_call(u32 service, u32 proc_id, u32 flag, ...)
> +{
> +	int i;
> +	u32 num_args;
> +	va_list ap;
> +
> +	va_start(ap, flag);
> +
> +	num_args = va_arg(ap, u32);
> +

Is there a cap on the num_args? can you add a check for that?

> +	/* Copy args to aligned args structure */
> +	for (i = 0; i < num_args; i++)
> +		secure_rom_call_args[i + 1] = va_arg(ap, u32);
> +
> +	secure_rom_call_args[0] = num_args;
> +
> +	va_end(ap);
> +
> +	/* if data cache is enabled, flush the aligned args structure */
> +#ifndef CONFIG_SYS_DCACHE_OFF
> +	flush_dcache_range(
> +		(unsigned int)&secure_rom_call_args[0],
> +		(unsigned int)&secure_rom_call_args[0] +
> +		roundup(sizeof(secure_rom_call_args), ARCH_DMA_MINALIGN));
> +#endif

I guess you do not need #ifndef here. Patch 2 should take care of it.

Thanks and regards,
Lokesh


> +	return omap_smc_sec(service, proc_id, flag, secure_rom_call_args);
> +}
> diff --git a/arch/arm/include/asm/omap_common.h b/arch/arm/include/asm/omap_common.h
> index 5943e6f..cb02c88 100644
> --- a/arch/arm/include/asm/omap_common.h
> +++ b/arch/arm/include/asm/omap_common.h
> @@ -629,6 +629,10 @@ void omap_smc1(u32 service, u32 val);
>  
>  u32 omap_smc_sec(u32 service, u32 proc_id, u32 flag, u32 *params);
>  
> +#ifdef CONFIG_TI_SECURE_DEVICE
> +u32 secure_rom_call(u32 service, u32 proc_id, u32 flag, ...);
> +#endif
> +
>  void enable_edma3_clocks(void);
>  void disable_edma3_clocks(void);
>  
> 


More information about the U-Boot mailing list