1 /* 2 * Copyright (c) 2021-2025, Arm Limited and Contributors. All rights reserved. 3 * 4 * SPDX-License-Identifier: BSD-3-Clause 5 */ 6 7 #ifndef RMMD_PRIVATE_H 8 #define RMMD_PRIVATE_H 9 10 #include <context.h> 11 #include <services/rmmd_svc.h> 12 13 /******************************************************************************* 14 * Constants that allow assembler code to preserve callee-saved registers of the 15 * C runtime context while performing a security state switch. 16 ******************************************************************************/ 17 #define RMMD_C_RT_CTX_X19 0x0 18 #define RMMD_C_RT_CTX_X20 0x8 19 #define RMMD_C_RT_CTX_X21 0x10 20 #define RMMD_C_RT_CTX_X22 0x18 21 #define RMMD_C_RT_CTX_X23 0x20 22 #define RMMD_C_RT_CTX_X24 0x28 23 #define RMMD_C_RT_CTX_X25 0x30 24 #define RMMD_C_RT_CTX_X26 0x38 25 #define RMMD_C_RT_CTX_X27 0x40 26 #define RMMD_C_RT_CTX_X28 0x48 27 #define RMMD_C_RT_CTX_X29 0x50 28 #define RMMD_C_RT_CTX_X30 0x58 29 30 #define RMMD_C_RT_CTX_SIZE 0x60 31 #define RMMD_C_RT_CTX_ENTRIES (RMMD_C_RT_CTX_SIZE >> DWORD_SHIFT) 32 33 #ifndef __ASSEMBLER__ 34 #include <stdint.h> 35 36 /* 37 * Data structure used by the RMM dispatcher (RMMD) in EL3 to track context of 38 * the RMM at R-EL2. 39 */ 40 typedef struct rmmd_rmm_context { 41 uint64_t c_rt_ctx; 42 uint64_t activation_token; 43 cpu_context_t cpu_ctx; 44 } rmmd_rmm_context_t; 45 46 /* Functions used to enter/exit the RMM synchronously */ 47 uint64_t rmmd_rmm_sync_entry(rmmd_rmm_context_t *ctx); 48 __dead2 void rmmd_rmm_sync_exit(uint64_t rc); 49 50 /* Functions implementing attestation utilities for RMM */ 51 int rmmd_attest_get_platform_token(uint64_t buf_pa, uint64_t *buf_size, 52 uint64_t c_size, 53 uint64_t *remaining_len); 54 int rmmd_attest_get_signing_key(uint64_t buf_pa, uint64_t *buf_size, 55 uint64_t ecc_curve); 56 uint64_t rmmd_el3_token_sign(void *handle, uint64_t x1, uint64_t x2, 57 uint64_t x3, uint64_t x4); 58 59 /* Functions implementing IDE KM programming */ 60 int rmmd_el3_ide_key_program(uint64_t ecam_address, uint64_t rp_id, 61 uint64_t ide_stream_info, rp_ide_key_info_t *ide_key_info_ptr, 62 uint64_t request_id, uint64_t cookie); 63 int rmmd_el3_ide_key_set_go(uint64_t ecam_address, uint64_t rp_id, uint64_t ide_stream_info, 64 uint64_t request_id, uint64_t cookie); 65 int rmmd_el3_ide_key_set_stop(uint64_t ecam_address, uint64_t rp_id, uint64_t ide_stream_info, 66 uint64_t request_id, uint64_t cookie); 67 int rmmd_el3_ide_km_pull_response(uint64_t ecam_address, uint64_t rp_id, uint64_t *req_resp, 68 uint64_t *request_id, uint64_t *cookie_ptr); 69 70 /* Memory reservation for RMM */ 71 int rmmd_reserve_memory(size_t size, uint64_t *arg); 72 73 /* Assembly helpers */ 74 uint64_t rmmd_rmm_enter(uint64_t *c_rt_ctx); 75 void __dead2 rmmd_rmm_exit(uint64_t c_rt_ctx, uint64_t ret); 76 77 /* Reference to PM ops for the RMMD */ 78 extern const spd_pm_ops_t rmmd_pm; 79 80 #endif /* __ASSEMBLER__ */ 81 82 #endif /* RMMD_PRIVATE_H */ 83