From d72c486b52dc654e4216d41dcc1b0f87bdbdf3e9 Mon Sep 17 00:00:00 2001 From: Lucian Paul-Trifu Date: Wed, 22 Jun 2022 18:45:30 +0100 Subject: [PATCH] feat(fvp): add platform hooks for DRTM DMA protection Added necessary platform hooks for DRTM DMA protection. These calls will be used by the subsequent DRTM implementation patches. DRTM platform API declarations have been listed down in a separate header file. Signed-off-by: Manish V Badarkhe Signed-off-by: Lucian Paul-Trifu Change-Id: Ib9726d1d3570800241bde702ee7006a64f1739ec --- include/plat/common/plat_drtm.h | 17 ++++++++ include/plat/common/platform.h | 5 ++- plat/arm/board/fvp/fvp_drtm_dma_prot.c | 60 ++++++++++++++++++++++++++ plat/arm/board/fvp/platform.mk | 4 ++ 4 files changed, 85 insertions(+), 1 deletion(-) create mode 100644 include/plat/common/plat_drtm.h create mode 100644 plat/arm/board/fvp/fvp_drtm_dma_prot.c diff --git a/include/plat/common/plat_drtm.h b/include/plat/common/plat_drtm.h new file mode 100644 index 000000000..3c4e3d536 --- /dev/null +++ b/include/plat/common/plat_drtm.h @@ -0,0 +1,17 @@ +/* + * Copyright (c) 2022, Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#ifndef PLAT_DRTM_H +#define PLAT_DRTM_H + +/* platform-specific DMA protection functions */ +bool plat_has_non_host_platforms(void); +bool plat_has_unmanaged_dma_peripherals(void); +unsigned int plat_get_total_smmus(void); +void plat_enumerate_smmus(const uintptr_t **smmus_out, + size_t *smmu_count_out); + +#endif /* PLAT_DRTM_H */ diff --git a/include/plat/common/platform.h b/include/plat/common/platform.h index da7462467..58e08d4aa 100644 --- a/include/plat/common/platform.h +++ b/include/plat/common/platform.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2022, ARM Limited and Contributors. All rights reserved. + * Copyright (c) 2013-2022, Arm Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ @@ -20,6 +20,9 @@ #include "plat_trng.h" #endif #include +#if DRTM_SUPPORT +#include "plat_drtm.h" +#endif /* DRTM_SUPPORT */ /******************************************************************************* * Forward declarations diff --git a/plat/arm/board/fvp/fvp_drtm_dma_prot.c b/plat/arm/board/fvp/fvp_drtm_dma_prot.c new file mode 100644 index 000000000..ec9cd7a2e --- /dev/null +++ b/plat/arm/board/fvp/fvp_drtm_dma_prot.c @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2022, Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#include +#include + +#include +#include +#include +#include + +#include + +/** + * Array mentioning number of SMMUs supported by FVP + */ +static const uintptr_t fvp_smmus[] = { + PLAT_FVP_SMMUV3_BASE, +}; + +bool plat_has_non_host_platforms(void) +{ + /* FVP base platforms typically have GPU, as per FVP Reference guide */ + return true; +} + +bool plat_has_unmanaged_dma_peripherals(void) +{ + /* + * FVP Reference guide does not show devices that are described as + * DMA-capable but not managed by an SMMU in the FVP documentation. + * However, the SMMU seems to have only been introduced in the RevC + * revision. + */ + return (arm_config.flags & ARM_CONFIG_FVP_HAS_SMMUV3) == 0; +} + +unsigned int plat_get_total_smmus(void) +{ + if ((arm_config.flags & ARM_CONFIG_FVP_HAS_SMMUV3) != 0U) { + return ARRAY_SIZE(fvp_smmus); + } else { + return 0; + } +} + +void plat_enumerate_smmus(const uintptr_t **smmus_out, + size_t *smmu_count_out) +{ + if ((arm_config.flags & ARM_CONFIG_FVP_HAS_SMMUV3) != 0U) { + *smmus_out = fvp_smmus; + *smmu_count_out = ARRAY_SIZE(fvp_smmus); + } else { + *smmus_out = NULL; + *smmu_count_out = 0; + } +} diff --git a/plat/arm/board/fvp/platform.mk b/plat/arm/board/fvp/platform.mk index a20343b35..811b2754b 100644 --- a/plat/arm/board/fvp/platform.mk +++ b/plat/arm/board/fvp/platform.mk @@ -413,6 +413,10 @@ endif endif +ifeq (${DRTM_SUPPORT}, 1) +BL31_SOURCES += plat/arm/board/fvp/fvp_drtm_dma_prot.c +endif + ifeq (${TRUSTED_BOARD_BOOT}, 1) BL1_SOURCES += plat/arm/board/fvp/fvp_trusted_boot.c BL2_SOURCES += plat/arm/board/fvp/fvp_trusted_boot.c -- 2.39.5