diff options
author | Jim Quigley <jim.quigley@arm.com> | 2020-06-16 16:08:59 +0100 |
---|---|---|
committer | Chris Kay <chris@cjkay.com> | 2020-07-16 10:13:30 +0100 |
commit | 99cfb2eb6d8d6024d0a206584bbe676e5e4e7ed2 (patch) | |
tree | 402190be9bf497c97f805bef126b301acbc70cbf /product/sgm775 | |
parent | 52ff1203f94d53943778b7d3269fe9373caaab5d (diff) |
SCMI: Clock Protocol Permissions
This patch adds the SCMI Clock Protocol Resource Permissions
management.
Change-Id: Ie636c4317e65f17b53f5ba3f5ba7eba2c405a203
Signed-off-by: Jim Quigley <jim.quigley@arm.com>
Diffstat (limited to 'product/sgm775')
-rw-r--r-- | product/sgm775/scp_ramfw/config_resource_perms.c | 79 | ||||
-rw-r--r-- | product/sgm775/scp_ramfw/config_scmi_clock.c | 16 | ||||
-rw-r--r-- | product/sgm775/scp_ramfw/firmware.mk | 9 |
3 files changed, 88 insertions, 16 deletions
diff --git a/product/sgm775/scp_ramfw/config_resource_perms.c b/product/sgm775/scp_ramfw/config_resource_perms.c new file mode 100644 index 00000000..1618e989 --- /dev/null +++ b/product/sgm775/scp_ramfw/config_resource_perms.c @@ -0,0 +1,79 @@ +/* + * Arm SCP/MCP Software + * Copyright (c) 2019-2020, Arm Limited and Contributors. All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#include "sgm775_scmi.h" + +#include <mod_resource_perms.h> +#include <mod_scmi_std.h> + +#include <fwk_element.h> +#include <fwk_id.h> +#include <fwk_macros.h> +#include <fwk_module.h> +#include <fwk_module_idx.h> + +/*! + * If the agent wants to modify permissions at run-time these tables + * must be allocated in writable memory. + */ + +#define AGENT_IDX(agent_id) (agent_id - 1) + +static struct mod_res_agent_protocol_permissions + agent_protocol_permissions[] = { + [AGENT_IDX(SCMI_AGENT_ID_OSPM)] = { + .protocols = MOD_RES_PERMS_SCMI_ALL_PROTOCOLS_ALLOWED, + }, + + /* PSCI agent has no access to clock protocol */ + [AGENT_IDX(SCMI_AGENT_ID_PSCI)] = { + .protocols = MOD_RES_PERMS_SCMI_CLOCK_PROTOCOL_DENIED, + }, +}; + +/* + * Messages have an index offset from 0x3 as all agents can access + * the VERSION/ATTRIBUTES/MSG_ATTRIBUTES messages for all + * protocols, hence message 0x3 maps to bit[0], message 0x4 maps + * to bit[1], etc. + */ +static struct mod_res_agent_msg_permissions agent_msg_permissions[] = { + [AGENT_IDX(SCMI_AGENT_ID_OSPM)] = { + /* Example, Base, disable unused msg 12 */ + .messages[MOD_RES_PERMS_SCMI_BASE_MESSAGE_IDX] = 0x0, + /* Power Domain */ + .messages[MOD_RES_PERMS_SCMI_POWER_DOMAIN_MESSAGE_IDX] = 0x0, + /* System Power Domain */ + .messages[MOD_RES_PERMS_SCMI_SYS_POWER_MESSAGE_IDX] = 0x0, + /* Performance */ + .messages[MOD_RES_PERMS_SCMI_PERF_MESSAGE_IDX] = 0x0, + /* + * sgm775 denies access to CONFIG_SET + */ + .messages[MOD_RES_PERMS_SCMI_CLOCK_MESSAGE_IDX] = + MOD_RES_PERMS_ACCESS_DENIED << + (MOD_SCMI_CLOCK_CONFIG_SET - MOD_SCMI_CLOCK_ATTRIBUTES), + /* Sensors */ + .messages[MOD_RES_PERMS_SCMI_SENSOR_MESSAGE_IDX] = 0x0, + /* Reset Domains */ + .messages[MOD_RES_PERMS_SCMI_RESET_DOMAIN_MESSAGE_IDX] = 0x0, + }, +}; + +static struct mod_res_agent_permission agent_permissions = { + .agent_protocol_permissions = agent_protocol_permissions, + .agent_msg_permissions = agent_msg_permissions, +}; + +struct fwk_module_config config_resource_perms = { + .data = + &(struct mod_res_resource_perms_config){ + .agent_permissions = (uintptr_t)&agent_permissions, + .agent_count = SCMI_AGENT_ID_COUNT, + .protocol_count = 6, + }, +}; diff --git a/product/sgm775/scp_ramfw/config_scmi_clock.c b/product/sgm775/scp_ramfw/config_scmi_clock.c index 62f7b887..91829ffa 100644 --- a/product/sgm775/scp_ramfw/config_scmi_clock.c +++ b/product/sgm775/scp_ramfw/config_scmi_clock.c @@ -20,37 +20,21 @@ static const struct mod_scmi_clock_device agent_device_table_ospm[] = { /* VPU */ .element_id = FWK_ID_ELEMENT_INIT(FWK_MODULE_IDX_CLOCK, CLOCK_DEV_IDX_VPU), - .permissions = MOD_SCMI_CLOCK_PERM_ATTRIBUTES | - MOD_SCMI_CLOCK_PERM_DESCRIBE_RATES | - MOD_SCMI_CLOCK_PERM_GET_RATE | - MOD_SCMI_CLOCK_PERM_SET_RATE, }, { /* DPU */ .element_id = FWK_ID_ELEMENT_INIT(FWK_MODULE_IDX_CLOCK, CLOCK_DEV_IDX_DPU), - .permissions = MOD_SCMI_CLOCK_PERM_ATTRIBUTES | - MOD_SCMI_CLOCK_PERM_DESCRIBE_RATES | - MOD_SCMI_CLOCK_PERM_GET_RATE | - MOD_SCMI_CLOCK_PERM_SET_RATE, }, { /* PIXEL_0 */ .element_id = FWK_ID_ELEMENT_INIT(FWK_MODULE_IDX_CLOCK, CLOCK_DEV_IDX_PIXEL_0), - .permissions = MOD_SCMI_CLOCK_PERM_ATTRIBUTES | - MOD_SCMI_CLOCK_PERM_DESCRIBE_RATES | - MOD_SCMI_CLOCK_PERM_GET_RATE | - MOD_SCMI_CLOCK_PERM_SET_RATE, }, { /* PIXEL_1 */ .element_id = FWK_ID_ELEMENT_INIT(FWK_MODULE_IDX_CLOCK, CLOCK_DEV_IDX_PIXEL_1), - .permissions = MOD_SCMI_CLOCK_PERM_ATTRIBUTES | - MOD_SCMI_CLOCK_PERM_DESCRIBE_RATES | - MOD_SCMI_CLOCK_PERM_GET_RATE | - MOD_SCMI_CLOCK_PERM_SET_RATE, }, }; diff --git a/product/sgm775/scp_ramfw/firmware.mk b/product/sgm775/scp_ramfw/firmware.mk index 6bf37cb8..73911814 100644 --- a/product/sgm775/scp_ramfw/firmware.mk +++ b/product/sgm775/scp_ramfw/firmware.mk @@ -11,6 +11,7 @@ BS_FIRMWARE_CPU := cortex-m3 BS_FIRMWARE_HAS_MULTITHREADING := yes BS_FIRMWARE_HAS_NOTIFICATION := yes +BS_FIRMWARE_HAS_RESOURCE_PERMISSIONS := yes BS_FIRMWARE_MODULES := \ sid \ @@ -47,6 +48,10 @@ BS_FIRMWARE_MODULES := \ scmi_apcore \ sds +ifeq ($(BS_FIRMWARE_HAS_RESOURCE_PERMISSIONS),yes) + BS_FIRMWARE_MODULES += resource_perms +endif + BS_FIRMWARE_SOURCES := \ rtx_config.c \ sgm775_core.c \ @@ -83,4 +88,8 @@ ifeq ($(BUILD_HAS_DEBUGGER),yes) BS_FIRMWARE_SOURCES += config_debugger_cli.c endif +ifeq ($(BS_FIRMWARE_HAS_RESOURCE_PERMISSIONS),yes) + BS_FIRMWARE_SOURCES += config_resource_perms.c +endif + include $(BS_DIR)/firmware.mk |