Fuad Tabba | 5c73843 | 2019-12-02 11:02:42 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2019 The Hafnium Authors. |
| 3 | * |
Andrew Walbran | e959ec1 | 2020-06-17 15:01:09 +0100 | [diff] [blame] | 4 | * Use of this source code is governed by a BSD-style |
| 5 | * license that can be found in the LICENSE file or at |
| 6 | * https://opensource.org/licenses/BSD-3-Clause. |
Fuad Tabba | 5c73843 | 2019-12-02 11:02:42 +0000 | [diff] [blame] | 7 | */ |
| 8 | |
| 9 | #pragma once |
| 10 | |
Olivier Deprez | c5203fb | 2022-09-29 13:49:24 +0200 | [diff] [blame] | 11 | #include "hf/arch/types.h" |
| 12 | |
Fuad Tabba | 5c73843 | 2019-12-02 11:02:42 +0000 | [diff] [blame] | 13 | #include "hf/addr.h" |
Daniel Boulby | 801f8ef | 2022-06-27 14:21:01 +0100 | [diff] [blame] | 14 | #include "hf/interrupt_desc.h" |
J-Alves | 67f5ba3 | 2024-09-27 18:07:11 +0100 | [diff] [blame] | 15 | #include "hf/list.h" |
Karl Meakin | 07a69ab | 2025-02-07 14:53:19 +0000 | [diff] [blame] | 16 | #include "hf/mm.h" |
Fuad Tabba | 5c73843 | 2019-12-02 11:02:42 +0000 | [diff] [blame] | 17 | #include "hf/spinlock.h" |
| 18 | |
Andrew Walbran | b5ab43c | 2020-04-30 11:32:54 +0100 | [diff] [blame] | 19 | #include "vmapi/hf/ffa.h" |
Fuad Tabba | 5c73843 | 2019-12-02 11:02:42 +0000 | [diff] [blame] | 20 | |
Madhukar Pappireddy | 8415405 | 2022-06-21 18:30:25 -0500 | [diff] [blame] | 21 | /** Action for non secure interrupt by SPMC. */ |
| 22 | #define NS_ACTION_QUEUED 0 |
| 23 | #define NS_ACTION_ME 1 |
| 24 | #define NS_ACTION_SIGNALED 2 |
Madhukar Pappireddy | 8415405 | 2022-06-21 18:30:25 -0500 | [diff] [blame] | 25 | |
Madhukar Pappireddy | 32913cb | 2024-07-19 13:04:05 -0500 | [diff] [blame] | 26 | /** Maximum number of pending virtual interrupts in the queue per vCPU. */ |
J-Alves | a835bdc | 2025-02-28 18:38:43 +0000 | [diff] [blame] | 27 | #define VINT_QUEUE_MAX 10 |
Madhukar Pappireddy | 32913cb | 2024-07-19 13:04:05 -0500 | [diff] [blame] | 28 | |
Madhukar Pappireddy | d6c055d | 2025-05-08 15:35:46 -0500 | [diff] [blame] | 29 | /** |
| 30 | * Refer section 7.2 of the FF-A v1.3 ALP2 specification. |
| 31 | */ |
Fuad Tabba | 5c73843 | 2019-12-02 11:02:42 +0000 | [diff] [blame] | 32 | enum vcpu_state { |
Fuad Tabba | b0ef2a4 | 2019-12-19 11:19:25 +0000 | [diff] [blame] | 33 | /** The vCPU is switched off. */ |
Fuad Tabba | 5c73843 | 2019-12-02 11:02:42 +0000 | [diff] [blame] | 34 | VCPU_STATE_OFF, |
| 35 | |
Fuad Tabba | b0ef2a4 | 2019-12-19 11:19:25 +0000 | [diff] [blame] | 36 | /** The vCPU is currently running. */ |
Fuad Tabba | 5c73843 | 2019-12-02 11:02:42 +0000 | [diff] [blame] | 37 | VCPU_STATE_RUNNING, |
| 38 | |
Madhukar Pappireddy | b11e0d1 | 2021-08-02 19:44:35 -0500 | [diff] [blame] | 39 | /** The vCPU is waiting to be allocated CPU cycles to do work. */ |
| 40 | VCPU_STATE_WAITING, |
| 41 | |
| 42 | /** |
| 43 | * The vCPU is blocked and waiting for some work to complete on |
| 44 | * its behalf. |
| 45 | */ |
| 46 | VCPU_STATE_BLOCKED, |
| 47 | |
| 48 | /** The vCPU has been preempted by an interrupt. */ |
| 49 | VCPU_STATE_PREEMPTED, |
Fuad Tabba | 5c73843 | 2019-12-02 11:02:42 +0000 | [diff] [blame] | 50 | |
Fuad Tabba | b0ef2a4 | 2019-12-19 11:19:25 +0000 | [diff] [blame] | 51 | /** The vCPU is waiting for an interrupt. */ |
Fuad Tabba | 5c73843 | 2019-12-02 11:02:42 +0000 | [diff] [blame] | 52 | VCPU_STATE_BLOCKED_INTERRUPT, |
| 53 | |
Fuad Tabba | b0ef2a4 | 2019-12-19 11:19:25 +0000 | [diff] [blame] | 54 | /** The vCPU has aborted. */ |
Fuad Tabba | 5c73843 | 2019-12-02 11:02:42 +0000 | [diff] [blame] | 55 | VCPU_STATE_ABORTED, |
Madhukar Pappireddy | d6c055d | 2025-05-08 15:35:46 -0500 | [diff] [blame] | 56 | |
| 57 | /** The vCPU is in NULL state. */ |
| 58 | VCPU_STATE_NULL, |
| 59 | |
| 60 | /** The vCPU has been stopped by partition manager. */ |
| 61 | VCPU_STATE_STOPPED, |
| 62 | |
| 63 | /** |
| 64 | * The partition manager has allocated all required resources to |
| 65 | * initialize the vCPU. |
| 66 | */ |
| 67 | VCPU_STATE_CREATED, |
| 68 | |
| 69 | /** The vCPU has been allocated CPU cycles to initialize itself. */ |
| 70 | VCPU_STATE_STARTING, |
| 71 | |
| 72 | /** The vCPU is currently executing to stop itself. */ |
| 73 | VCPU_STATE_STOPPING, |
Fuad Tabba | 5c73843 | 2019-12-02 11:02:42 +0000 | [diff] [blame] | 74 | }; |
| 75 | |
Madhukar Pappireddy | fe297a3 | 2022-06-21 16:42:13 -0500 | [diff] [blame] | 76 | /** Refer to section 7 of the FF-A v1.1 EAC0 spec. */ |
| 77 | enum partition_runtime_model { |
| 78 | RTM_NONE, |
| 79 | /** Runtime model for FFA_RUN. */ |
| 80 | RTM_FFA_RUN, |
| 81 | /** Runtime model for FFA_MSG_SEND_DIRECT_REQUEST. */ |
| 82 | RTM_FFA_DIR_REQ, |
| 83 | /** Runtime model for Secure Interrupt handling. */ |
| 84 | RTM_SEC_INTERRUPT, |
| 85 | /** Runtime model for SP Initialization. */ |
| 86 | RTM_SP_INIT, |
| 87 | }; |
| 88 | |
Madhukar Pappireddy | 5992fbc | 2022-06-21 17:15:16 -0500 | [diff] [blame] | 89 | /** Refer to section 8.2.3 of the FF-A EAC0 spec. */ |
| 90 | enum schedule_mode { |
| 91 | NONE, |
| 92 | /** Normal world scheduled mode. */ |
| 93 | NWD_MODE, |
| 94 | /** SPMC scheduled mode. */ |
| 95 | SPMC_MODE, |
| 96 | }; |
| 97 | |
Madhukar Pappireddy | 5388dd9 | 2025-02-10 11:24:19 -0600 | [diff] [blame] | 98 | enum power_mgmt_operation { |
| 99 | PWR_MGMT_NONE = 0, |
| 100 | /** Power off the CPU. */ |
| 101 | PWR_MGMT_CPU_OFF, |
| 102 | /** No other operations are supported at the moment. */ |
| 103 | }; |
| 104 | |
Madhukar Pappireddy | 32913cb | 2024-07-19 13:04:05 -0500 | [diff] [blame] | 105 | /* |
| 106 | * This queue is implemented as a circular buffer. The entries are managed on |
| 107 | * a First In First Out basis. |
| 108 | */ |
| 109 | struct interrupt_queue { |
| 110 | uint32_t vint_buffer[VINT_QUEUE_MAX]; |
| 111 | uint16_t head; |
| 112 | uint16_t tail; |
J-Alves | 23a7303 | 2025-03-04 16:20:54 +0000 | [diff] [blame] | 113 | size_t queued_vint_count; |
Madhukar Pappireddy | 32913cb | 2024-07-19 13:04:05 -0500 | [diff] [blame] | 114 | }; |
| 115 | |
Fuad Tabba | 5c73843 | 2019-12-02 11:02:42 +0000 | [diff] [blame] | 116 | struct interrupts { |
| 117 | /** Bitfield keeping track of which interrupts are enabled. */ |
Daniel Boulby | 4ca50f0 | 2022-07-29 18:29:34 +0100 | [diff] [blame] | 118 | struct interrupt_bitmap interrupt_enabled; |
Fuad Tabba | 5c73843 | 2019-12-02 11:02:42 +0000 | [diff] [blame] | 119 | /** Bitfield keeping track of which interrupts are pending. */ |
Daniel Boulby | 4ca50f0 | 2022-07-29 18:29:34 +0100 | [diff] [blame] | 120 | struct interrupt_bitmap interrupt_pending; |
Manish Pandey | 35e452f | 2021-02-18 21:36:34 +0000 | [diff] [blame] | 121 | /** Bitfield recording the interrupt pin configuration. */ |
Daniel Boulby | 4ca50f0 | 2022-07-29 18:29:34 +0100 | [diff] [blame] | 122 | struct interrupt_bitmap interrupt_type; |
Fuad Tabba | 5c73843 | 2019-12-02 11:02:42 +0000 | [diff] [blame] | 123 | /** |
| 124 | * The number of interrupts which are currently both enabled and |
Manish Pandey | 35e452f | 2021-02-18 21:36:34 +0000 | [diff] [blame] | 125 | * pending. Count independently virtual IRQ and FIQ interrupt types |
| 126 | * i.e. the sum of the two counters is the number of bits set in |
| 127 | * interrupt_enable & interrupt_pending. |
Fuad Tabba | 5c73843 | 2019-12-02 11:02:42 +0000 | [diff] [blame] | 128 | */ |
Manish Pandey | 35e452f | 2021-02-18 21:36:34 +0000 | [diff] [blame] | 129 | uint32_t enabled_and_pending_irq_count; |
| 130 | uint32_t enabled_and_pending_fiq_count; |
Madhukar Pappireddy | 32913cb | 2024-07-19 13:04:05 -0500 | [diff] [blame] | 131 | |
| 132 | /** |
| 133 | * Partition Manager maintains a queue of pending virtual interrupts. |
| 134 | */ |
| 135 | struct interrupt_queue vint_q; |
Fuad Tabba | 5c73843 | 2019-12-02 11:02:42 +0000 | [diff] [blame] | 136 | }; |
| 137 | |
| 138 | struct vcpu_fault_info { |
| 139 | ipaddr_t ipaddr; |
| 140 | vaddr_t vaddr; |
| 141 | vaddr_t pc; |
Karl Meakin | 07a69ab | 2025-02-07 14:53:19 +0000 | [diff] [blame] | 142 | mm_mode_t mode; |
Fuad Tabba | 5c73843 | 2019-12-02 11:02:42 +0000 | [diff] [blame] | 143 | }; |
| 144 | |
Madhukar Pappireddy | 5992fbc | 2022-06-21 17:15:16 -0500 | [diff] [blame] | 145 | struct call_chain { |
| 146 | /** Previous node in the SP call chain. */ |
| 147 | struct vcpu *prev_node; |
| 148 | |
| 149 | /** Next node in the SP call chain. */ |
| 150 | struct vcpu *next_node; |
| 151 | }; |
| 152 | |
Karl Meakin | c5cebbc | 2024-06-17 11:30:27 +0100 | [diff] [blame] | 153 | #define LOG_BUFFER_SIZE 256 |
| 154 | |
| 155 | struct log_buffer { |
| 156 | char chars[LOG_BUFFER_SIZE]; |
| 157 | uint16_t len; |
| 158 | }; |
| 159 | |
Fuad Tabba | 5c73843 | 2019-12-02 11:02:42 +0000 | [diff] [blame] | 160 | struct vcpu { |
| 161 | struct spinlock lock; |
| 162 | |
| 163 | /* |
| 164 | * The state is only changed in the context of the vCPU being run. This |
| 165 | * ensures the scheduler can easily keep track of the vCPU state as |
| 166 | * transitions are indicated by the return code from the run call. |
| 167 | */ |
| 168 | enum vcpu_state state; |
| 169 | |
| 170 | struct cpu *cpu; |
| 171 | struct vm *vm; |
| 172 | struct arch_regs regs; |
| 173 | struct interrupts interrupts; |
| 174 | |
Karl Meakin | c5cebbc | 2024-06-17 11:30:27 +0100 | [diff] [blame] | 175 | struct log_buffer log_buffer; |
| 176 | |
Fuad Tabba | 5c73843 | 2019-12-02 11:02:42 +0000 | [diff] [blame] | 177 | /* |
| 178 | * Determine whether the 'regs' field is available for use. This is set |
| 179 | * to false when a vCPU is about to run on a physical CPU, and is set |
Olivier Deprez | 3caed1c | 2021-02-05 12:07:36 +0100 | [diff] [blame] | 180 | * back to true when it is descheduled. This is not relevant for the |
| 181 | * primary VM vCPUs in the normal world (or the "other world VM" vCPUs |
| 182 | * in the secure world) as they are pinned to physical CPUs and there |
| 183 | * is no contention to take care of. |
Fuad Tabba | 5c73843 | 2019-12-02 11:02:42 +0000 | [diff] [blame] | 184 | */ |
| 185 | bool regs_available; |
Olivier Deprez | ee9d6a9 | 2019-11-26 09:14:11 +0000 | [diff] [blame] | 186 | |
| 187 | /* |
| 188 | * If the current vCPU is executing as a consequence of a |
Kathleen Capella | e468c11 | 2023-12-13 17:56:28 -0500 | [diff] [blame] | 189 | * direct request invocation, then this member holds the |
Olivier Deprez | ee9d6a9 | 2019-11-26 09:14:11 +0000 | [diff] [blame] | 190 | * originating VM ID from which the call originated. |
| 191 | * The value HF_INVALID_VM_ID implies the vCPU is not executing as |
Kathleen Capella | e468c11 | 2023-12-13 17:56:28 -0500 | [diff] [blame] | 192 | * a result of a prior direct request invocation. |
Olivier Deprez | ee9d6a9 | 2019-11-26 09:14:11 +0000 | [diff] [blame] | 193 | */ |
Kathleen Capella | e468c11 | 2023-12-13 17:56:28 -0500 | [diff] [blame] | 194 | struct { |
Kathleen Capella | e468c11 | 2023-12-13 17:56:28 -0500 | [diff] [blame] | 195 | ffa_id_t vm_id; |
Karl Meakin | 06e8b73 | 2024-09-20 18:26:49 +0100 | [diff] [blame] | 196 | /** Indicate whether request is via FFA_MSG_SEND_DIRECT_REQ2. */ |
| 197 | bool is_ffa_req2; |
| 198 | /** Indicate whether request is a framework message. */ |
| 199 | bool is_framework; |
Kathleen Capella | e468c11 | 2023-12-13 17:56:28 -0500 | [diff] [blame] | 200 | } direct_request_origin; |
Manish Pandey | a5f39fb | 2020-09-11 09:47:11 +0100 | [diff] [blame] | 201 | |
Madhukar Pappireddy | b11e0d1 | 2021-08-02 19:44:35 -0500 | [diff] [blame] | 202 | /** Determine whether partition is currently handling managed exit. */ |
Manish Pandey | a5f39fb | 2020-09-11 09:47:11 +0100 | [diff] [blame] | 203 | bool processing_managed_exit; |
Madhukar Pappireddy | f675bb6 | 2021-08-03 12:57:10 -0500 | [diff] [blame] | 204 | |
| 205 | /** |
Madhukar Pappireddy | f675bb6 | 2021-08-03 12:57:10 -0500 | [diff] [blame] | 206 | * Track current vCPU which got pre-empted when secure interrupt |
| 207 | * triggered. |
| 208 | */ |
| 209 | struct vcpu *preempted_vcpu; |
Madhukar Pappireddy | dd6fdfb | 2021-12-14 12:30:36 -0600 | [diff] [blame] | 210 | |
Madhukar Pappireddy | 5992fbc | 2022-06-21 17:15:16 -0500 | [diff] [blame] | 211 | /** SP call chain. */ |
| 212 | struct call_chain call_chain; |
| 213 | |
| 214 | /** |
J-Alves | 0cbd7a3 | 2025-02-10 17:29:15 +0000 | [diff] [blame] | 215 | * Track if pending interrupts have been retrieved by |
Daniel Boulby | 1f2babf | 2024-08-29 16:39:47 +0100 | [diff] [blame] | 216 | * FFA_NOTIFICATION_INFO_GET. |
| 217 | */ |
J-Alves | 0cbd7a3 | 2025-02-10 17:29:15 +0000 | [diff] [blame] | 218 | bool interrupts_info_get_retrieved; |
Daniel Boulby | 1f2babf | 2024-08-29 16:39:47 +0100 | [diff] [blame] | 219 | |
| 220 | /** |
Madhukar Pappireddy | 5992fbc | 2022-06-21 17:15:16 -0500 | [diff] [blame] | 221 | * Indicates if the current vCPU is running in SPMC scheduled |
| 222 | * mode or Normal World scheduled mode. |
| 223 | */ |
| 224 | enum schedule_mode scheduling_mode; |
| 225 | |
Madhukar Pappireddy | 8415405 | 2022-06-21 18:30:25 -0500 | [diff] [blame] | 226 | /** |
Madhukar Pappireddy | 94da32d | 2023-02-22 16:04:10 -0600 | [diff] [blame] | 227 | * If the action in response to a non-secure or other-secure interrupt |
| 228 | * is to queue it, this field is used to save and restore the current |
| 229 | * priority mask. |
Madhukar Pappireddy | 8415405 | 2022-06-21 18:30:25 -0500 | [diff] [blame] | 230 | */ |
Madhukar Pappireddy | 94da32d | 2023-02-22 16:04:10 -0600 | [diff] [blame] | 231 | uint8_t prev_interrupt_priority; |
Madhukar Pappireddy | c40f55f | 2022-06-22 11:00:41 -0500 | [diff] [blame] | 232 | |
Madhukar Pappireddy | fe297a3 | 2022-06-21 16:42:13 -0500 | [diff] [blame] | 233 | /** Partition Runtime Model. */ |
| 234 | enum partition_runtime_model rt_model; |
Madhukar Pappireddy | 2f76e49 | 2022-09-06 15:21:59 -0500 | [diff] [blame] | 235 | |
Madhukar Pappireddy | eed861e | 2024-09-25 13:50:54 -0500 | [diff] [blame] | 236 | /** |
| 237 | * An entry in a list maintained by Hafnium for pending arch timers. |
| 238 | * It exists in the list on behalf of its parent vCPU. The `prev` and |
| 239 | * `next` fields point to the adjacent entries in the list. The list |
| 240 | * itself is protected by a spinlock therefore timer entry is |
| 241 | * safeguarded from concurrent accesses. |
| 242 | */ |
| 243 | struct list_entry timer_node; |
Daniel Boulby | 7011b5a | 2024-10-15 18:27:26 +0100 | [diff] [blame] | 244 | |
| 245 | /* |
| 246 | * List entry pointing to the next vcpu with an IPI pending on the |
| 247 | * same pinned CPU. |
| 248 | */ |
| 249 | struct list_entry ipi_list_node; |
Madhukar Pappireddy | 5388dd9 | 2025-02-10 11:24:19 -0600 | [diff] [blame] | 250 | |
| 251 | /* |
| 252 | * Denotes which power management operation message is being currently |
| 253 | * handled by this vCPU. |
| 254 | */ |
| 255 | enum power_mgmt_operation pwr_mgmt_op; |
Fuad Tabba | 5c73843 | 2019-12-02 11:02:42 +0000 | [diff] [blame] | 256 | }; |
| 257 | |
| 258 | /** Encapsulates a vCPU whose lock is held. */ |
| 259 | struct vcpu_locked { |
| 260 | struct vcpu *vcpu; |
| 261 | }; |
| 262 | |
Olivier Deprez | 0b6f10a | 2020-08-05 18:21:33 +0200 | [diff] [blame] | 263 | /** Container for two vcpu_locked structures. */ |
| 264 | struct two_vcpu_locked { |
| 265 | struct vcpu_locked vcpu1; |
| 266 | struct vcpu_locked vcpu2; |
| 267 | }; |
| 268 | |
Fuad Tabba | 5c73843 | 2019-12-02 11:02:42 +0000 | [diff] [blame] | 269 | struct vcpu_locked vcpu_lock(struct vcpu *vcpu); |
Olivier Deprez | 0b6f10a | 2020-08-05 18:21:33 +0200 | [diff] [blame] | 270 | struct two_vcpu_locked vcpu_lock_both(struct vcpu *vcpu1, struct vcpu *vcpu2); |
Fuad Tabba | 5c73843 | 2019-12-02 11:02:42 +0000 | [diff] [blame] | 271 | void vcpu_unlock(struct vcpu_locked *locked); |
| 272 | void vcpu_init(struct vcpu *vcpu, struct vm *vm); |
Madhukar Pappireddy | 98ab38b | 2025-05-08 15:46:31 -0500 | [diff] [blame^] | 273 | void vcpu_prepare(struct vcpu_locked vcpu, ipaddr_t entry, uintreg_t arg); |
Andrew Walbran | b5ab43c | 2020-04-30 11:32:54 +0100 | [diff] [blame] | 274 | ffa_vcpu_index_t vcpu_index(const struct vcpu *vcpu); |
Fuad Tabba | 5c73843 | 2019-12-02 11:02:42 +0000 | [diff] [blame] | 275 | bool vcpu_is_off(struct vcpu_locked vcpu); |
Max Shvetsov | 40108e7 | 2020-08-27 12:39:50 +0100 | [diff] [blame] | 276 | bool vcpu_secondary_reset_and_start(struct vcpu_locked vcpu_locked, |
| 277 | ipaddr_t entry, uintreg_t arg); |
Fuad Tabba | 5c73843 | 2019-12-02 11:02:42 +0000 | [diff] [blame] | 278 | |
| 279 | bool vcpu_handle_page_fault(const struct vcpu *current, |
| 280 | struct vcpu_fault_info *f); |
Olivier Deprez | 2ebae3a | 2020-06-11 16:34:30 +0200 | [diff] [blame] | 281 | |
J-Alves | 7ac4905 | 2022-02-08 17:20:53 +0000 | [diff] [blame] | 282 | void vcpu_set_phys_core_idx(struct vcpu *vcpu); |
Olivier Deprez | 632249e | 2022-09-26 09:18:31 +0200 | [diff] [blame] | 283 | void vcpu_set_boot_info_gp_reg(struct vcpu *vcpu); |
| 284 | |
Madhukar Pappireddy | bd10e57 | 2023-03-06 16:39:49 -0600 | [diff] [blame] | 285 | static inline void vcpu_call_chain_extend(struct vcpu_locked vcpu1_locked, |
| 286 | struct vcpu_locked vcpu2_locked) |
Madhukar Pappireddy | 5992fbc | 2022-06-21 17:15:16 -0500 | [diff] [blame] | 287 | { |
Madhukar Pappireddy | bd10e57 | 2023-03-06 16:39:49 -0600 | [diff] [blame] | 288 | vcpu1_locked.vcpu->call_chain.next_node = vcpu2_locked.vcpu; |
| 289 | vcpu2_locked.vcpu->call_chain.prev_node = vcpu1_locked.vcpu; |
Madhukar Pappireddy | 5992fbc | 2022-06-21 17:15:16 -0500 | [diff] [blame] | 290 | } |
| 291 | |
Madhukar Pappireddy | bd10e57 | 2023-03-06 16:39:49 -0600 | [diff] [blame] | 292 | static inline void vcpu_call_chain_remove_node(struct vcpu_locked vcpu1_locked, |
| 293 | struct vcpu_locked vcpu2_locked) |
Madhukar Pappireddy | 5992fbc | 2022-06-21 17:15:16 -0500 | [diff] [blame] | 294 | { |
Madhukar Pappireddy | bd10e57 | 2023-03-06 16:39:49 -0600 | [diff] [blame] | 295 | vcpu1_locked.vcpu->call_chain.prev_node = NULL; |
| 296 | vcpu2_locked.vcpu->call_chain.next_node = NULL; |
Madhukar Pappireddy | 5992fbc | 2022-06-21 17:15:16 -0500 | [diff] [blame] | 297 | } |
J-Alves | 12cedae | 2023-08-04 14:37:37 +0100 | [diff] [blame] | 298 | |
J-Alves | 478faac | 2024-10-23 10:35:57 +0100 | [diff] [blame] | 299 | void vcpu_set_running(struct vcpu_locked target_locked, |
| 300 | const struct ffa_value *args); |
Daniel Boulby | 1f2babf | 2024-08-29 16:39:47 +0100 | [diff] [blame] | 301 | |
J-Alves | 12cedae | 2023-08-04 14:37:37 +0100 | [diff] [blame] | 302 | void vcpu_save_interrupt_priority(struct vcpu_locked vcpu_locked, |
| 303 | uint8_t priority); |
J-Alves | 3b31f09 | 2024-08-07 13:26:29 +0100 | [diff] [blame] | 304 | |
Daniel Boulby | d21e9b3 | 2025-02-13 15:53:21 +0000 | [diff] [blame] | 305 | void vcpu_enter_secure_interrupt_rtm(struct vcpu_locked vcpu_locked); |
| 306 | |
| 307 | void vcpu_secure_interrupt_complete(struct vcpu_locked vcpu_locked); |
| 308 | |
Daniel Boulby | d21e9b3 | 2025-02-13 15:53:21 +0000 | [diff] [blame] | 309 | static inline bool vcpu_is_virt_interrupt_pending(struct interrupts *interrupts, |
| 310 | uint32_t intid) |
| 311 | { |
| 312 | return interrupt_bitmap_get_value(&interrupts->interrupt_pending, |
| 313 | intid) == 1U; |
| 314 | } |
| 315 | |
| 316 | static inline enum interrupt_type vcpu_virt_interrupt_get_type( |
| 317 | struct interrupts *interrupts, uint32_t intid) |
| 318 | { |
| 319 | return (enum interrupt_type)interrupt_bitmap_get_value( |
| 320 | &interrupts->interrupt_type, intid); |
| 321 | } |
| 322 | |
| 323 | static inline void vcpu_virt_interrupt_set_type(struct interrupts *interrupts, |
| 324 | uint32_t intid, |
| 325 | enum interrupt_type type) |
| 326 | { |
| 327 | if (type == INTERRUPT_TYPE_IRQ) { |
| 328 | interrupt_bitmap_clear_value(&interrupts->interrupt_type, |
| 329 | intid); |
| 330 | } else { |
| 331 | interrupt_bitmap_set_value(&interrupts->interrupt_type, intid); |
| 332 | } |
| 333 | } |
| 334 | |
| 335 | uint32_t vcpu_virt_interrupt_irq_count_get(struct vcpu_locked vcpu_locked); |
| 336 | uint32_t vcpu_virt_interrupt_fiq_count_get(struct vcpu_locked vcpu_locked); |
| 337 | uint32_t vcpu_virt_interrupt_count_get(struct vcpu_locked vcpu_locked); |
| 338 | |
| 339 | void vcpu_virt_interrupt_enable(struct vcpu_locked vcpu_locked, |
| 340 | uint32_t vint_id, bool enable); |
| 341 | |
Daniel Boulby | 3c1506b | 2025-02-25 10:49:51 +0000 | [diff] [blame] | 342 | uint32_t vcpu_virt_interrupt_peek_pending_and_enabled( |
| 343 | struct vcpu_locked vcpu_locked); |
| 344 | uint32_t vcpu_virt_interrupt_get_pending_and_enabled( |
| 345 | struct vcpu_locked vcpu_locked); |
| 346 | void vcpu_virt_interrupt_inject(struct vcpu_locked vcpu_locked, |
Madhukar Pappireddy | 32913cb | 2024-07-19 13:04:05 -0500 | [diff] [blame] | 347 | uint32_t vint_id); |
Daniel Boulby | d799223 | 2025-03-06 17:09:49 +0000 | [diff] [blame] | 348 | void vcpu_virt_interrupt_clear(struct vcpu_locked vcpu_locked, |
| 349 | uint32_t vint_id); |
Madhukar Pappireddy | 5388dd9 | 2025-02-10 11:24:19 -0600 | [diff] [blame] | 350 | |
| 351 | void vcpu_dir_req_set_state(struct vcpu_locked target_locked, bool is_ffa_req2, |
| 352 | ffa_id_t sender_vm_id, struct ffa_value args); |
| 353 | |
| 354 | void vcpu_dir_req_reset_state(struct vcpu_locked vcpu_locked); |