diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/arch/aarch64/arch_helpers.h | 14 | ||||
-rw-r--r-- | include/common/fdt_wrappers.h | 6 | ||||
-rw-r--r-- | include/drivers/arm/css/css_mhu_doorbell.h | 12 | ||||
-rw-r--r-- | include/drivers/arm/css/scmi.h | 4 | ||||
-rw-r--r-- | include/drivers/io/io_storage.h | 4 | ||||
-rw-r--r-- | include/lib/fconf/fconf.h | 61 | ||||
-rw-r--r-- | include/lib/fconf/fconf_dyn_cfg_getter.h | 24 | ||||
-rw-r--r-- | include/lib/fconf/fconf_tbbr_getter.h | 27 | ||||
-rw-r--r-- | include/plat/arm/common/arm_def.h | 36 | ||||
-rw-r--r-- | include/plat/arm/common/arm_dyn_cfg_helpers.h | 7 | ||||
-rw-r--r-- | include/plat/arm/common/arm_fconf_getter.h | 24 | ||||
-rw-r--r-- | include/plat/arm/common/arm_fconf_io_storage.h | 19 | ||||
-rw-r--r-- | include/plat/arm/common/plat_arm.h | 26 | ||||
-rw-r--r-- | include/plat/arm/css/common/css_def.h | 6 | ||||
-rw-r--r-- | include/plat/arm/css/common/css_pm.h | 13 | ||||
-rw-r--r-- | include/plat/common/platform.h | 11 | ||||
-rw-r--r-- | include/services/spci_svc.h | 139 | ||||
-rw-r--r-- | include/services/spm_core_manifest.h | 55 | ||||
-rw-r--r-- | include/services/spmd_svc.h | 25 | ||||
-rw-r--r-- | include/tools_share/sptool.h | 26 | ||||
-rw-r--r-- | include/tools_share/uuid.h | 7 |
21 files changed, 497 insertions, 49 deletions
diff --git a/include/arch/aarch64/arch_helpers.h b/include/arch/aarch64/arch_helpers.h index c60f2e8f7..240c1fbda 100644 --- a/include/arch/aarch64/arch_helpers.h +++ b/include/arch/aarch64/arch_helpers.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2019, ARM Limited and Contributors. All rights reserved. + * Copyright (c) 2013-2020, ARM Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ @@ -69,6 +69,13 @@ static inline void _op(void) \ __asm__ (#_op); \ } +/* Define function for system instruction with register parameter */ +#define DEFINE_SYSOP_PARAM_FUNC(_op) \ +static inline void _op(uint64_t v) \ +{ \ + __asm__ (#_op " %0" : : "r" (v)); \ +} + /* Define function for system instruction with type specifier */ #define DEFINE_SYSOP_TYPE_FUNC(_op, _type) \ static inline void _op ## _type(void) \ @@ -211,6 +218,11 @@ DEFINE_SYSOP_TYPE_PARAM_FUNC(at, s1e1r) DEFINE_SYSOP_TYPE_PARAM_FUNC(at, s1e2r) DEFINE_SYSOP_TYPE_PARAM_FUNC(at, s1e3r) +/******************************************************************************* + * Strip Pointer Authentication Code + ******************************************************************************/ +DEFINE_SYSOP_PARAM_FUNC(xpaci) + void flush_dcache_range(uintptr_t addr, size_t size); void clean_dcache_range(uintptr_t addr, size_t size); void inv_dcache_range(uintptr_t addr, size_t size); diff --git a/include/common/fdt_wrappers.h b/include/common/fdt_wrappers.h index 79d001d28..f467958b7 100644 --- a/include/common/fdt_wrappers.h +++ b/include/common/fdt_wrappers.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, ARM Limited and Contributors. All rights reserved. + * Copyright (c) 2018-2020, ARM Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ @@ -20,5 +20,9 @@ int fdtw_read_string(const void *dtb, int node, const char *prop, char *str, size_t size); int fdtw_write_inplace_cells(void *dtb, int node, const char *prop, unsigned int cells, void *value); +int fdtw_read_bytes(const void *dtb, int node, const char *prop, + unsigned int length, void *value); +int fdtw_write_inplace_bytes(void *dtb, int node, const char *prop, + unsigned int length, const void *data); #endif /* FDT_WRAPPERS_H */ diff --git a/include/drivers/arm/css/css_mhu_doorbell.h b/include/drivers/arm/css/css_mhu_doorbell.h index e6f7a1bd1..88302fd7b 100644 --- a/include/drivers/arm/css/css_mhu_doorbell.h +++ b/include/drivers/arm/css/css_mhu_doorbell.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014-2018, ARM Limited and Contributors. All rights reserved. + * Copyright (c) 2014-2020, ARM Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ @@ -11,13 +11,13 @@ #include <lib/mmio.h> -/* MHUv2 Base Address */ -#define MHUV2_BASE_ADDR PLAT_MHUV2_BASE +/* MHUv2 Frame Base Mask */ +#define MHU_V2_FRAME_BASE_MASK UL(~0xFFF) /* MHUv2 Control Registers Offsets */ -#define MHU_V2_MSG_NO_CAP_OFFSET 0xF80 -#define MHU_V2_ACCESS_REQ_OFFSET 0xF88 -#define MHU_V2_ACCESS_READY_OFFSET 0xF8C +#define MHU_V2_MSG_NO_CAP_OFFSET UL(0xF80) +#define MHU_V2_ACCESS_REQ_OFFSET UL(0xF88) +#define MHU_V2_ACCESS_READY_OFFSET UL(0xF8C) #define SENDER_REG_STAT(_channel) (0x20 * (_channel)) #define SENDER_REG_SET(_channel) ((0x20 * (_channel)) + 0xC) diff --git a/include/drivers/arm/css/scmi.h b/include/drivers/arm/css/scmi.h index 1f8dc6cce..e8a2863a9 100644 --- a/include/drivers/arm/css/scmi.h +++ b/include/drivers/arm/css/scmi.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2019, ARM Limited and Contributors. All rights reserved. + * Copyright (c) 2017-2020, ARM Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ @@ -162,7 +162,7 @@ int scmi_ap_core_set_reset_addr(void *p, uint64_t reset_addr, uint32_t attr); int scmi_ap_core_get_reset_addr(void *p, uint64_t *reset_addr, uint32_t *attr); /* API to get the platform specific SCMI channel information. */ -scmi_channel_plat_info_t *plat_css_get_scmi_info(void); +scmi_channel_plat_info_t *plat_css_get_scmi_info(int channel_id); /* API to override default PSCI callbacks for platforms that support SCMI. */ const plat_psci_ops_t *css_scmi_override_pm_ops(plat_psci_ops_t *ops); diff --git a/include/drivers/io/io_storage.h b/include/drivers/io/io_storage.h index 0e6ffd619..a301ad563 100644 --- a/include/drivers/io/io_storage.h +++ b/include/drivers/io/io_storage.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014-2019, ARM Limited and Contributors. All rights reserved. + * Copyright (c) 2014-2020, ARM Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ @@ -53,7 +53,7 @@ typedef struct io_file_spec { /* UUID specification - used to refer to data accessed using UUIDs (i.e. FIP * images) */ typedef struct io_uuid_spec { - const uuid_t uuid; + uuid_t uuid; } io_uuid_spec_t; /* Block specification - used to refer to data on a device supporting diff --git a/include/lib/fconf/fconf.h b/include/lib/fconf/fconf.h new file mode 100644 index 000000000..f58ff5710 --- /dev/null +++ b/include/lib/fconf/fconf.h @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2019-2020, ARM Limited. All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#ifndef FCONF_H +#define FCONF_H + +#include <stdint.h> + +/* Public API */ +#define FCONF_GET_PROPERTY(a, b, c) a##__##b##_getter(c) + +#define FCONF_REGISTER_POPULATOR(name, callback) \ + __attribute__((used, section(".fconf_populator"))) \ + const struct fconf_populator name##__populator = { \ + .info = #name, \ + .populate = callback \ + }; + +/* + * Populator callback + * + * This structure are used by the fconf_populate function and should only be + * defined by the FCONF_REGISTER_POPULATOR macro. + */ +struct fconf_populator { + /* Description of the data loaded by the callback */ + const char *info; + + /* Callback used by fconf_populate function with a provided config dtb. + * Return 0 on success, err_code < 0 otherwise. + */ + int (*populate)(uintptr_t config); +}; + +/* Load firmware configuration dtb */ +void fconf_load_config(void); + +/* Top level populate function + * + * This function takes a configuration dtb and calls all the registered + * populator callback with it. + * + * Panic on error. + */ +void fconf_populate(uintptr_t config); + +/* FCONF specific getter */ +#define fconf__dtb_getter(prop) fconf_dtb_info.prop + +/* Structure used to locally keep a reference to the config dtb. */ +struct fconf_dtb_info_t { + uintptr_t base_addr; + size_t size; +}; + +extern struct fconf_dtb_info_t fconf_dtb_info; + +#endif /* FCONF_H */ diff --git a/include/lib/fconf/fconf_dyn_cfg_getter.h b/include/lib/fconf/fconf_dyn_cfg_getter.h new file mode 100644 index 000000000..0fda8c9b2 --- /dev/null +++ b/include/lib/fconf/fconf_dyn_cfg_getter.h @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2019-2020, Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#ifndef FCONF_DYN_CFG_GETTER_H +#define FCONF_DYN_CFG_GETTER_H + +#include <lib/fconf/fconf.h> + +/* Dynamic configuration related getter */ +#define dyn_cfg__dtb_getter(id) dyn_cfg_dtb_info_getter(id) + +struct dyn_cfg_dtb_info_t { + uintptr_t config_addr; + size_t config_max_size; + unsigned int config_id; +}; + +struct dyn_cfg_dtb_info_t *dyn_cfg_dtb_info_getter(unsigned int config_id); +int fconf_populate_dtb_registry(uintptr_t config); + +#endif /* FCONF_DYN_CFG_GETTER_H */ diff --git a/include/lib/fconf/fconf_tbbr_getter.h b/include/lib/fconf/fconf_tbbr_getter.h new file mode 100644 index 000000000..eddc0c4b5 --- /dev/null +++ b/include/lib/fconf/fconf_tbbr_getter.h @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2019-2020, ARM Limited. All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#ifndef FCONF_TBBR_GETTER_H +#define FCONF_TBBR_GETTER_H + +#include <lib/fconf/fconf.h> + +/* TBBR related getter */ +#define tbbr__cot_getter(id) cot_desc_ptr[id] + +#define tbbr__dyn_config_getter(id) tbbr_dyn_config.id + +struct tbbr_dyn_config_t { + uint32_t disable_auth; + void *mbedtls_heap_addr; + size_t mbedtls_heap_size; +}; + +extern struct tbbr_dyn_config_t tbbr_dyn_config; + +int fconf_populate_tbbr_dyn_config(uintptr_t config); + +#endif /* FCONF_TBBR_GETTER_H */ diff --git a/include/plat/arm/common/arm_def.h b/include/plat/arm/common/arm_def.h index b419c853e..7df6b0d88 100644 --- a/include/plat/arm/common/arm_def.h +++ b/include/plat/arm/common/arm_def.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015-2019, ARM Limited and Contributors. All rights reserved. + * Copyright (c) 2015-2020, ARM Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ @@ -18,6 +18,12 @@ * Definitions common to all ARM standard platforms *****************************************************************************/ +/* + * Root of trust key hash lengths + */ +#define ARM_ROTPK_HEADER_LEN 19 +#define ARM_ROTPK_HASH_LEN 32 + /* Special value used to verify platform parameters from BL2 to BL31 */ #define ARM_BL31_PLAT_PARAM_VAL ULL(0x0f1e2d3c4b5a6978) @@ -223,6 +229,14 @@ ARM_EL3_TZC_DRAM1_SIZE, \ MT_MEMORY | MT_RW | MT_SECURE) +#if defined(SPD_spmd) +#define ARM_MAP_TRUSTED_DRAM MAP_REGION_FLAT( \ + PLAT_ARM_TRUSTED_DRAM_BASE, \ + PLAT_ARM_TRUSTED_DRAM_SIZE, \ + MT_MEMORY | MT_RW | MT_SECURE) +#endif + + /* * Mapping for the BL1 RW region. This mapping is needed by BL2 in order to * share the Mbed TLS heap. Since the heap is allocated inside BL1, it resides @@ -395,13 +409,21 @@ /******************************************************************************* * BL31 specific defines. ******************************************************************************/ -#if ARM_BL31_IN_DRAM +#if ARM_BL31_IN_DRAM || SEPARATE_NOBITS_REGION /* * Put BL31 at the bottom of TZC secured DRAM */ #define BL31_BASE ARM_AP_TZC_DRAM1_BASE #define BL31_LIMIT (ARM_AP_TZC_DRAM1_BASE + \ PLAT_ARM_MAX_BL31_SIZE) +/* + * For SEPARATE_NOBITS_REGION, BL31 PROGBITS are loaded in TZC secured DRAM. + * And BL31 NOBITS are loaded in Trusted SRAM such that BL2 is overwritten. + */ +#if SEPARATE_NOBITS_REGION +#define BL31_NOBITS_BASE BL2_BASE +#define BL31_NOBITS_LIMIT BL2_LIMIT +#endif /* SEPARATE_NOBITS_REGION */ #elif (RESET_TO_BL31) /* Ensure Position Independent support (PIE) is enabled for this config.*/ # if !ENABLE_PIE @@ -463,6 +485,12 @@ # define BL32_BASE (ARM_AP_TZC_DRAM1_BASE + ULL(0x200000)) # define BL32_LIMIT (ARM_AP_TZC_DRAM1_BASE + \ ARM_AP_TZC_DRAM1_SIZE) +# elif defined(SPD_spmd) +# define TSP_SEC_MEM_BASE (ARM_AP_TZC_DRAM1_BASE + ULL(0x200000)) +# define TSP_SEC_MEM_SIZE (ARM_AP_TZC_DRAM1_SIZE - ULL(0x200000)) +# define BL32_BASE PLAT_ARM_TRUSTED_DRAM_BASE +# define BL32_LIMIT (PLAT_ARM_TRUSTED_DRAM_BASE \ + + (UL(1) << 21)) # elif ARM_BL31_IN_DRAM # define TSP_SEC_MEM_BASE (ARM_AP_TZC_DRAM1_BASE + \ PLAT_ARM_MAX_BL31_SIZE) @@ -497,12 +525,12 @@ /* * BL32 is mandatory in AArch32. In AArch64, undefine BL32_BASE if there is no - * SPD and no SPM, as they are the only ones that can be used as BL32. + * SPD and no SPM-MM, as they are the only ones that can be used as BL32. */ #if defined(__aarch64__) && !JUNO_AARCH32_EL3_RUNTIME # if defined(SPD_none) && !SPM_MM # undef BL32_BASE -# endif /* defined(SPD_none) && !SPM_MM*/ +# endif /* defined(SPD_none) && !SPM_MM */ #endif /* defined(__aarch64__) && !JUNO_AARCH32_EL3_RUNTIME */ /******************************************************************************* diff --git a/include/plat/arm/common/arm_dyn_cfg_helpers.h b/include/plat/arm/common/arm_dyn_cfg_helpers.h index 3ad6d5468..2dc94abe3 100644 --- a/include/plat/arm/common/arm_dyn_cfg_helpers.h +++ b/include/plat/arm/common/arm_dyn_cfg_helpers.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, ARM Limited and Contributors. All rights reserved. + * Copyright (c) 2018-2020, ARM Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ @@ -10,12 +10,7 @@ #include <stdint.h> /* Function declarations */ -int arm_dyn_get_config_load_info(void *dtb, int node, unsigned int config_id, - uint64_t *config_addr, uint32_t *config_size); int arm_dyn_tb_fw_cfg_init(void *dtb, int *node); -int arm_dyn_get_disable_auth(void *dtb, int node, uint32_t *disable_auth); -int arm_get_dtb_mbedtls_heap_info(void *dtb, void **heap_addr, - size_t *heap_size); int arm_set_dtb_mbedtls_heap_info(void *dtb, void *heap_addr, size_t heap_size); diff --git a/include/plat/arm/common/arm_fconf_getter.h b/include/plat/arm/common/arm_fconf_getter.h new file mode 100644 index 000000000..28913a43f --- /dev/null +++ b/include/plat/arm/common/arm_fconf_getter.h @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2019-2020, ARM Limited. All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#ifndef ARM_FCONF_GETTER +#define ARM_FCONF_GETTER + +#include <lib/fconf/fconf.h> + +/* ARM io policies */ +#define arm__io_policies_getter(id) &policies[id] + +struct plat_io_policy { + uintptr_t *dev_handle; + uintptr_t image_spec; + int (*check)(const uintptr_t spec); +}; + +extern struct plat_io_policy policies[]; +int fconf_populate_arm_io_policies(uintptr_t config); + +#endif /* ARM_FCONF_GETTER */ diff --git a/include/plat/arm/common/arm_fconf_io_storage.h b/include/plat/arm/common/arm_fconf_io_storage.h new file mode 100644 index 000000000..02ee66c35 --- /dev/null +++ b/include/plat/arm/common/arm_fconf_io_storage.h @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2020, ARM Limited. All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ +#ifndef ARM_FCONF_IO_STORAGE_H +#define ARM_FCONF_IO_STORAGE_H + +#include <stdint.h> + +/* IO devices handle */ +extern uintptr_t memmap_dev_handle; +extern uintptr_t fip_dev_handle; + +/* Function declarations */ +int open_fip(const uintptr_t spec); +int open_memmap(const uintptr_t spec); + +#endif /* ARM_FCONF_IO_STORAGE_H */ diff --git a/include/plat/arm/common/plat_arm.h b/include/plat/arm/common/plat_arm.h index 02feec708..025a64fa2 100644 --- a/include/plat/arm/common/plat_arm.h +++ b/include/plat/arm/common/plat_arm.h @@ -1,11 +1,12 @@ /* - * Copyright (c) 2015-2019, ARM Limited and Contributors. All rights reserved. + * Copyright (c) 2015-2020, ARM Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ #ifndef PLAT_ARM_H #define PLAT_ARM_H +#include <stdbool.h> #include <stdint.h> #include <drivers/arm/tzc_common.h> @@ -142,8 +143,13 @@ void arm_setup_romlib(void); #define STATE_SW_E_PARAM (-2) #define STATE_SW_E_DENIED (-3) +/* plat_get_rotpk_info() flags */ +#define ARM_ROTPK_REGS_ID 1 +#define ARM_ROTPK_DEVEL_RSA_ID 2 +#define ARM_ROTPK_DEVEL_ECDSA_ID 3 + /* IO storage utility functions */ -void arm_io_setup(void); +int arm_io_setup(void); /* Security utility functions */ void arm_tzc400_setup(const arm_tzc_regions_info_t *tzc_regions); @@ -217,11 +223,9 @@ void arm_sp_min_early_platform_setup(void *from_bl2, uintptr_t tos_fw_config, void arm_sp_min_plat_runtime_setup(void); /* FIP TOC validity check */ -int arm_io_is_toc_valid(void); +bool arm_io_is_toc_valid(void); /* Utility functions for Dynamic Config */ -void arm_load_tb_fw_config(void); -void arm_bl2_set_tb_cfg_addr(void *dtb); void arm_bl2_dyn_cfg_init(void); void arm_bl1_set_mbedtls_heap(void); int arm_get_mbedtls_heap(void **heap_addr, size_t *heap_size); @@ -251,13 +255,21 @@ void plat_arm_interconnect_init(void); void plat_arm_interconnect_enter_coherency(void); void plat_arm_interconnect_exit_coherency(void); void plat_arm_program_trusted_mailbox(uintptr_t address); -int plat_arm_bl1_fwu_needed(void); +bool plat_arm_bl1_fwu_needed(void); __dead2 void plat_arm_error_handler(int err); /* - * Optional function in ARM standard platforms + * Optional functions in ARM standard platforms */ void plat_arm_override_gicr_frames(const uintptr_t *plat_gicr_frames); +int arm_get_rotpk_info(void **key_ptr, unsigned int *key_len, + unsigned int *flags); +int arm_get_rotpk_info_regs(void **key_ptr, unsigned int *key_len, + unsigned int *flags); +int arm_get_rotpk_info_cc(void **key_ptr, unsigned int *key_len, + unsigned int *flags); +int arm_get_rotpk_info_dev(void **key_ptr, unsigned int *key_len, + unsigned int *flags); #if ARM_PLAT_MT unsigned int plat_arm_get_cpu_pe_count(u_register_t mpidr); diff --git a/include/plat/arm/css/common/css_def.h b/include/plat/arm/css/common/css_def.h index 2adf11d66..7b6148445 100644 --- a/include/plat/arm/css/common/css_def.h +++ b/include/plat/arm/css/common/css_def.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015-2017, ARM Limited and Contributors. All rights reserved. + * Copyright (c) 2015-2020, ARM Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ @@ -29,6 +29,10 @@ #define SID_REG_BASE 0x2a4a0000 #define SID_SYSTEM_ID_OFFSET 0x40 #define SID_SYSTEM_CFG_OFFSET 0x70 +#define SID_NODE_ID_OFFSET 0x60 +#define SID_CHIP_ID_MASK 0xFF +#define SID_MULTI_CHIP_MODE_MASK 0x100 +#define SID_MULTI_CHIP_MODE_SHIFT 8 /* The slave_bootsecure controls access to GPU, DMC and CS. */ #define CSS_NIC400_SLAVE_BOOTSECURE 8 diff --git a/include/plat/arm/css/common/css_pm.h b/include/plat/arm/css/common/css_pm.h index 93f86162e..e5357f50b 100644 --- a/include/plat/arm/css/common/css_pm.h +++ b/include/plat/arm/css/common/css_pm.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015-2018, ARM Limited and Contributors. All rights reserved. + * Copyright (c) 2015-2020, ARM Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ @@ -44,4 +44,15 @@ int css_node_hw_state(u_register_t mpidr, unsigned int power_level); */ extern const uint32_t plat_css_core_pos_to_scmi_dmn_id_map[]; +#define SCMI_DOMAIN_ID_MASK U(0xFFFF) +#define SCMI_CHANNEL_ID_MASK U(0xFFFF) +#define SCMI_CHANNEL_ID_SHIFT U(16) + +#define SET_SCMI_CHANNEL_ID(n) (((n) & SCMI_CHANNEL_ID_MASK) << \ + SCMI_CHANNEL_ID_SHIFT) +#define SET_SCMI_DOMAIN_ID(n) ((n) & SCMI_DOMAIN_ID_MASK) +#define GET_SCMI_CHANNEL_ID(n) (((n) >> SCMI_CHANNEL_ID_SHIFT) & \ + SCMI_CHANNEL_ID_MASK) +#define GET_SCMI_DOMAIN_ID(n) ((n) & SCMI_DOMAIN_ID_MASK) + #endif /* CSS_PM_H */ diff --git a/include/plat/common/platform.h b/include/plat/common/platform.h index 332cfca8d..f5bd298c5 100644 --- a/include/plat/common/platform.h +++ b/include/plat/common/platform.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2019, ARM Limited and Contributors. All rights reserved. + * Copyright (c) 2013-2020, ARM Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ @@ -10,6 +10,9 @@ #include <stdint.h> #include <lib/psci/psci.h> +#if defined(SPD_spmd) + #include <services/spm_core_manifest.h> +#endif /******************************************************************************* * Forward declarations @@ -272,7 +275,11 @@ const struct spm_mm_boot_info *plat_get_secure_partition_boot_info( int plat_spm_sp_rd_load(struct sp_res_desc *rd, const void *ptr, size_t size); int plat_spm_sp_get_next_address(void **sp_base, size_t *sp_size, void **rd_base, size_t *rd_size); - +#if defined(SPD_spmd) +int plat_spm_core_manifest_load(spmc_manifest_sect_attribute_t *manifest, + const void *ptr, + size_t size); +#endif /******************************************************************************* * Mandatory BL image load functions(may be overridden). ******************************************************************************/ diff --git a/include/services/spci_svc.h b/include/services/spci_svc.h new file mode 100644 index 000000000..49ba40858 --- /dev/null +++ b/include/services/spci_svc.h @@ -0,0 +1,139 @@ +/* + * Copyright (c) 2019, Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#ifndef SPCI_SVC_H +#define SPCI_SVC_H + +#include <lib/smccc.h> +#include <lib/utils_def.h> +#include <tools_share/uuid.h> + +/* SPCI error codes. */ +#define SPCI_ERROR_NOT_SUPPORTED -1 +#define SPCI_ERROR_INVALID_PARAMETER -2 +#define SPCI_ERROR_NO_MEMORY -3 +#define SPCI_ERROR_BUSY -4 +#define SPCI_ERROR_INTERRUPTED -5 +#define SPCI_ERROR_DENIED -6 +#define SPCI_ERROR_RETRY -7 + +/* The macros below are used to identify SPCI calls from the SMC function ID */ +#define SPCI_FNUM_MIN_VALUE U(0x60) +#define SPCI_FNUM_MAX_VALUE U(0x7f) +#define is_spci_fid(fid) __extension__ ({ \ + __typeof__(fid) _fid = (fid); \ + ((GET_SMC_NUM(_fid) >= SPCI_FNUM_MIN_VALUE) && \ + (GET_SMC_NUM(_fid) <= SPCI_FNUM_MAX_VALUE)); }) + +/* SPCI_VERSION helpers */ +#define SPCI_VERSION_MAJOR U(0) +#define SPCI_VERSION_MAJOR_SHIFT 16 +#define SPCI_VERSION_MAJOR_MASK U(0x7FFF) +#define SPCI_VERSION_MINOR U(9) +#define SPCI_VERSION_MINOR_SHIFT 0 +#define SPCI_VERSION_MINOR_MASK U(0xFFFF) + +#define MAKE_SPCI_VERSION(major, minor) \ + ((((major) & SPCI_VERSION_MAJOR_MASK) << SPCI_VERSION_MAJOR_SHIFT) | \ + (((minor) & SPCI_VERSION_MINOR_MASK) << SPCI_VERSION_MINOR_SHIFT)) +#define SPCI_VERSION_COMPILED MAKE_SPCI_VERSION(SPCI_VERSION_MAJOR, \ + SPCI_VERSION_MINOR) + +/* SPCI_MSG_SEND helpers */ +#define SPCI_MSG_SEND_ATTRS_BLK_SHIFT U(0) +#define SPCI_MSG_SEND_ATTRS_BLK_MASK U(0x1) +#define SPCI_MSG_SEND_ATTRS_BLK U(0) +#define SPCI_MSG_SEND_ATTRS_BLK_NOT U(1) +#define SPCI_MSG_SEND_ATTRS(blk) \ + (((blk) & SPCI_MSG_SEND_ATTRS_BLK_MASK) \ + << SPCI_MSG_SEND_ATTRS_BLK_SHIFT) + +/* Get SPCI fastcall std FID from function number */ +#define SPCI_FID(smc_cc, func_num) \ + ((SMC_TYPE_FAST << FUNCID_TYPE_SHIFT) | \ + ((smc_cc) << FUNCID_CC_SHIFT) | \ + (OEN_STD_START << FUNCID_OEN_SHIFT) | \ + ((func_num) << FUNCID_NUM_SHIFT)) + +/* SPCI function numbers */ +#define SPCI_FNUM_ERROR U(0x60) +#define SPCI_FNUM_SUCCESS U(0x61) +#define SPCI_FNUM_INTERRUPT U(0x62) +#define SPCI_FNUM_VERSION U(0x63) +#define SPCI_FNUM_FEATURES U(0x64) +#define SPCI_FNUM_RX_RELEASE U(0x65) +#define SPCI_FNUM_RXTX_MAP U(0x66) +#define SPCI_FNUM_RXTX_UNMAP U(0x67) +#define SPCI_FNUM_PARTITION_INFO_GET U(0x68) +#define SPCI_FNUM_ID_GET U(0x69) +#define SPCI_FNUM_MSG_POLL U(0x6A) +#define SPCI_FNUM_MSG_WAIT U(0x6B) +#define SPCI_FNUM_MSG_YIELD U(0x6C) +#define SPCI_FNUM_MSG_RUN U(0x6D) +#define SPCI_FNUM_MSG_SEND U(0x6E) +#define SPCI_FNUM_MSG_SEND_DIRECT_REQ U(0x6F) +#define SPCI_FNUM_MSG_SEND_DIRECT_RESP U(0x70) +#define SPCI_FNUM_MEM_DONATE U(0x71) +#define SPCI_FNUM_MEM_LEND U(0x72) +#define SPCI_FNUM_MEM_SHARE U(0x73) +#define SPCI_FNUM_MEM_RETRIEVE_REQ U(0x74) +#define SPCI_FNUM_MEM_RETRIEVE_RESP U(0x75) +#define SPCI_FNUM_MEM_RELINQUISH U(0x76) +#define SPCI_FNUM_MEM_RECLAIM U(0x77) + +/* SPCI SMC32 FIDs */ +#define SPCI_ERROR SPCI_FID(SMC_32, SPCI_FNUM_ERROR) +#define SPCI_SUCCESS_SMC32 SPCI_FID(SMC_32, SPCI_FNUM_SUCCESS) +#define SPCI_INTERRUPT SPCI_FID(SMC_32, SPCI_FNUM_INTERRUPT) +#define SPCI_VERSION SPCI_FID(SMC_32, SPCI_FNUM_VERSION) +#define SPCI_FEATURES SPCI_FID(SMC_32, SPCI_FNUM_FEATURES) +#define SPCI_RX_RELEASE SPCI_FID(SMC_32, SPCI_FNUM_RX_RELEASE) +#define SPCI_RXTX_MAP_SMC32 SPCI_FID(SMC_32, SPCI_FNUM_RXTX_MAP) +#define SPCI_RXTX_UNMAP SPCI_FID(SMC_32, SPCI_FNUM_RXTX_UNMAP) +#define SPCI_PARTITION_INFO_GET SPCI_FID(SMC_32, SPCI_FNUM_PARTITION_INFO_GET) +#define SPCI_ID_GET SPCI_FID(SMC_32, SPCI_FNUM_ID_GET) +#define SPCI_MSG_POLL SPCI_FID(SMC_32, SPCI_FNUM_MSG_POLL) +#define SPCI_MSG_WAIT SPCI_FID(SMC_32, SPCI_FNUM_MSG_WAIT) +#define SPCI_MSG_YIELD SPCI_FID(SMC_32, SPCI_FNUM_MSG_YIELD) +#define SPCI_MSG_RUN SPCI_FID(SMC_32, SPCI_FNUM_MSG_RUN) +#define SPCI_MSG_SEND SPCI_FID(SMC_32, SPCI_FNUM_MSG_SEND) +#define SPCI_MSG_SEND_DIRECT_REQ_SMC32 \ + SPCI_FID(SMC_32, SPCI_FNUM_MSG_SEND_DIRECT_REQ) +#define SPCI_MSG_SEND_DIRECT_RESP_SMC32 \ + SPCI_FID(SMC_32, SPCI_FNUM_MSG_SEND_DIRECT_RESP) +#define SPCI_MEM_DONATE_SMC32 SPCI_FID(SMC_32, SPCI_FNUM_MEM_DONATE) +#define SPCI_MEM_LEND_SMC32 SPCI_FID(SMC_32, SPCI_FNUM_MEM_LEND) +#define SPCI_MEM_SHARE_SMC32 SPCI_FID(SMC_32, SPCI_FNUM_MEM_SHARE) +#define SPCI_MEM_RETRIEVE_REQ_SMC32 \ + SPCI_FID(SMC_32, SPCI_FNUM_MEM_RETRIEVE_REQ) +#define SPCI_MEM_RETRIEVE_RESP SPCI_FID(SMC_32, SPCI_FNUM_MEM_RETRIEVE_RESP) +#define SPCI_MEM_RELINQUISH SPCI_FID(SMC_32, SPCI_FNUM_MEM_RELINQUISH) +#define SPCI_MEM_RECLAIM SPCI_FID(SMC_32, SPCI_FNUM_MEM_RECLAIM) + +/* SPCI SMC64 FIDs */ +#define SPCI_SUCCESS_SMC64 SPCI_FID(SMC_64, SPCI_FNUM_SUCCESS) +#define SPCI_RXTX_MAP_SMC64 SPCI_FID(SMC_64, SPCI_FNUM_RXTX_MAP) +#define SPCI_MSG_SEND_DIRECT_REQ_SMC64 \ + SPCI_FID(SMC_64, SPCI_FNUM_MSG_SEND_DIRECT_REQ) +#define SPCI_MSG_SEND_DIRECT_RESP_SMC64 \ + SPCI_FID(SMC_64, SPCI_FNUM_MSG_SEND_DIRECT_RESP) +#define SPCI_MEM_DONATE_SMC64 SPCI_FID(SMC_64, SPCI_FNUM_MEM_DONATE) +#define SPCI_MEM_LEND_SMC64 SPCI_FID(SMC_64, SPCI_FNUM_MEM_LEND) +#define SPCI_MEM_SHARE_SMC64 SPCI_FID(SMC_64, SPCI_FNUM_MEM_SHARE) +#define SPCI_MEM_RETRIEVE_REQ_SMC64 \ + SPCI_FID(SMC_64, SPCI_FNUM_MEM_RETRIEVE_REQ) + +/* + * Reserve a special value for traffic targeted to the Hypervisor or SPM. + */ +#define SPCI_TARGET_INFO_MBZ U(0x0) + +/* + * Reserve a special value for MBZ parameters. + */ +#define SPCI_PARAM_MBZ U(0x0) + +#endif /* SPCI_SVC_H */ diff --git a/include/services/spm_core_manifest.h b/include/services/spm_core_manifest.h new file mode 100644 index 000000000..06ecc1391 --- /dev/null +++ b/include/services/spm_core_manifest.h @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2020, Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#ifndef SPMC_MANIFEST_H +#define SPMC_MANIFEST_H + +#include <stdint.h> + +/******************************************************************************* + * Attribute Section + ******************************************************************************/ + +typedef struct spm_core_manifest_sect_attribute { + /* + * SPCI version (mandatory). + */ + uint32_t major_version; + uint32_t minor_version; + + /* + * Run-Time Exception Level (mandatory): + * - 1: SEL1 + * - 2: SEL2 + */ + uint32_t runtime_el; + + /* + * Run-Time Execution state (optional): + * - 0: AArch64 (default) + * - 1: AArch32 + */ + uint32_t exec_state; + + /* + * Address of binary image containing SPM core in bytes (optional). + */ + uint64_t load_address; + + /* + * Offset from the base of the partition's binary image to the entry + * point of the partition. + */ + uint64_t entrypoint; + + /* + * Size of binary image containing SPM core in bytes (mandatory). + */ + uint32_t binary_size; + +} spmc_manifest_sect_attribute_t; + +#endif /* SPMC_MANIFEST_H */ diff --git a/include/services/spmd_svc.h b/include/services/spmd_svc.h new file mode 100644 index 000000000..6e4caf266 --- /dev/null +++ b/include/services/spmd_svc.h @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2020, ARM Limited and Contributors. All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#ifndef SPMD_SVC_H +#define SPMD_SVC_H + +#ifndef __ASSEMBLER__ +#include <services/spci_svc.h> +#include <stdint.h> + +int32_t spmd_setup(void); +uint64_t spmd_smc_handler(uint32_t smc_fid, + uint64_t x1, + uint64_t x2, + uint64_t x3, + uint64_t x4, + void *cookie, + void *handle, + uint64_t flags); +#endif /* __ASSEMBLER__ */ + +#endif /* SPMD_SVC_H */ diff --git a/include/tools_share/sptool.h b/include/tools_share/sptool.h index 67a2cf093..53668e09c 100644 --- a/include/tools_share/sptool.h +++ b/include/tools_share/sptool.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Arm Limited. All rights reserved. + * Copyright (c) 2018-2020, Arm Limited. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ @@ -9,21 +9,17 @@ #include <stdint.h> -/* Header for a secure partition package. There is one per package. */ -struct sp_pkg_header { - uint64_t version; - uint64_t number_of_sp; -}; +/* 4 Byte magic name "SPKG" */ +#define SECURE_PARTITION_MAGIC 0x474B5053 -/* - * Entry descriptor in a secure partition package. Each entry comprises a - * secure partition and its resource description. - */ -struct sp_pkg_entry { - uint64_t sp_offset; - uint64_t sp_size; - uint64_t rd_offset; - uint64_t rd_size; +/* Header for a secure partition package. */ +struct sp_pkg_header { + uint32_t magic; + uint32_t version; + uint32_t pm_offset; + uint32_t pm_size; + uint32_t img_offset; + uint32_t img_size; }; #endif /* SPTOOL_H */ diff --git a/include/tools_share/uuid.h b/include/tools_share/uuid.h index 7d0043206..36be9ed37 100644 --- a/include/tools_share/uuid.h +++ b/include/tools_share/uuid.h @@ -27,7 +27,7 @@ */ /* - * Portions copyright (c) 2014, ARM Limited and Contributors. + * Portions copyright (c) 2014-2020, ARM Limited and Contributors. * All rights reserved. */ @@ -56,6 +56,11 @@ struct uuid { uint8_t node[_UUID_NODE_LEN]; }; +union uuid_helper_t { + struct uuid uuid_struct; + uint32_t word[4]; +}; + /* XXX namespace pollution? */ typedef struct uuid uuid_t; |