1 /* 2 * SPDX-License-Identifier: BSD-3-Clause 3 * SPDX-FileCopyrightText: Copyright TF-RMM Contributors. 4 */ 5 6 #ifndef RSI_HANDLER_H 7 #define RSI_HANDLER_H 8 9 #include <rsi-walk.h> 10 #include <smc.h> 11 12 struct rec; 13 struct rmi_rec_exit; 14 15 /* 16 * If set, update REC registers to values provided by the handler. 17 */ 18 #define FLAG_UPDATE_REC 1U 19 20 /* 21 * If set, exit to Host. Otherwise, return to Realm. 22 */ 23 #define FLAG_EXIT_TO_HOST 2U 24 25 /* 26 * If set, present emulated Stage 2 abort to Host. 27 */ 28 #define FLAG_STAGE_2_ABORT 4U 29 30 enum rsi_action { 31 /* 32 * Update REC registers to values provided by the handler, 33 * and return to Realm. 34 */ 35 UPDATE_REC_RETURN_TO_REALM = FLAG_UPDATE_REC, 36 37 /* 38 * Leave REC registers unchanged, and exit to Host, 39 * with rec_exit fields populated by the handler. 40 */ 41 EXIT_TO_HOST = FLAG_EXIT_TO_HOST, 42 43 /* 44 * Update REC registers to values provided by the handler, 45 * with rec_exit fields and exit to Host, with rec_exit 46 * fields populated by the handler. 47 */ 48 UPDATE_REC_EXIT_TO_HOST = FLAG_UPDATE_REC | 49 FLAG_EXIT_TO_HOST, 50 51 /* 52 * Exit to Host, indicating a Stage 2 translation fault 53 * encountered by the handler. 54 */ 55 STAGE_2_TRANSLATION_FAULT = FLAG_EXIT_TO_HOST | 56 FLAG_STAGE_2_ABORT 57 }; 58 59 /* 60 * Result of RSI command handler 61 */ 62 struct rsi_result { 63 /* 64 * Action which should be taken following execution of the handler. 65 */ 66 enum rsi_action action; 67 68 /* 69 * If the handler performed an RTT walk, 70 * @rtt_level is the level at which the walk terminated. 71 */ 72 unsigned long rtt_level; 73 74 /* 75 * If @action is RETURN_TO_REALM, 76 * @smc_result contains GPR values to be returned to the Realm. 77 */ 78 struct smc_result smc_res; 79 }; 80 81 void handle_rsi_version(struct rec *rec, struct rsi_result *res); 82 void handle_rsi_features(struct rec *rec, struct rsi_result *res); 83 void handle_rsi_realm_config(struct rec *rec, struct rsi_result *res); 84 void handle_rsi_host_call(struct rec *rec, struct rmi_rec_exit *rec_exit, 85 struct rsi_result *res); 86 void handle_rsi_ipa_state_set(struct rec *rec, struct rmi_rec_exit *rec_exit, 87 struct rsi_result *res); 88 void handle_rsi_ipa_state_get(struct rec *rec, struct rsi_result *res); 89 void handle_rsi_measurement_read(struct rec *rec, struct rsi_result *res); 90 void handle_rsi_measurement_extend(struct rec *rec, struct rsi_result *res); 91 void handle_rsi_attest_token_init(struct rec *rec, struct rsi_result *res); 92 void handle_rsi_attest_token_continue(struct rec *rec, 93 struct rmi_rec_exit *rec_exit, 94 struct rsi_result *res); 95 void handle_psci(struct rec *rec, struct rmi_rec_exit *rec_exit, 96 struct rsi_result *res); 97 98 #endif /* RSI_HANDLER_H */ 99