blob: b16fc5a41e8dcfaab6aa4a7f1c4543a7faa9e03f [file] [log] [blame]
Soby Mathewb4c6df42022-11-09 11:13:29 +00001/*
2 * SPDX-License-Identifier: BSD-3-Clause
3 *
4 * SPDX-FileCopyrightText: Copyright TF-RMM Contributors.
5 */
6
7#include <arch.h>
8#include <arch_helpers.h>
9#include <attestation_token.h>
10#include <buffer.h>
11#include <esr.h>
12#include <exit.h>
13#include <fpu_helpers.h>
14#include <gic.h>
15#include <granule.h>
16#include <inject_exp.h>
17#include <memory_alloc.h>
18#include <psci.h>
19#include <realm.h>
20#include <realm_attest.h>
21#include <rec.h>
22#include <rsi-config.h>
23#include <rsi-handler.h>
24#include <rsi-host-call.h>
25#include <rsi-logger.h>
26#include <rsi-memory.h>
27#include <rsi-walk.h>
28#include <smc-rmi.h>
29#include <smc-rsi.h>
30#include <status.h>
31#include <sve.h>
32#include <sysreg_traps.h>
33#include <table.h>
34
35void save_fpu_state(struct fpu_state *fpu);
36void restore_fpu_state(struct fpu_state *fpu);
37
38static void system_abort(void)
39{
40 /*
41 * TODO: report the abort to the EL3.
42 * We need to establish the exact EL3 API first.
43 */
44 assert(false);
45}
46
47static bool fixup_aarch32_data_abort(struct rec *rec, unsigned long *esr)
48{
49 unsigned long spsr = read_spsr_el2();
50
51 if ((spsr & SPSR_EL2_nRW_AARCH32) != 0UL) {
52 /*
53 * mmio emulation of AArch32 reads/writes is not supported.
54 */
55 *esr &= ~ESR_EL2_ABORT_ISV_BIT;
56 return true;
57 }
58 return false;
59}
60
61static unsigned long get_dabt_write_value(struct rec *rec, unsigned long esr)
62{
63 unsigned int rt = esr_srt(esr);
64
65 /* Handle xzr */
66 if (rt == 31U) {
67 return 0UL;
68 }
69 return rec->regs[rt] & access_mask(esr);
70}
71
72/*
73 * Returns 'true' if access from @rec to @addr is within the Protected IPA space.
74 */
75static bool access_in_rec_par(struct rec *rec, unsigned long addr)
76{
77 /*
78 * It is OK to check only the base address of the access because:
79 * - The Protected IPA space starts at address zero.
80 * - The IPA width is below 64 bits, therefore the access cannot
81 * wrap around.
82 */
83 return addr_in_rec_par(rec, addr);
84}
85
86/*
87 * Returns 'true' if the @ipa is in PAR and its RIPAS is 'empty'.
88 *
89 * @ipa must be aligned to the granule size.
90 */
91static bool ipa_is_empty(unsigned long ipa, struct rec *rec)
92{
93 unsigned long s2tte, *ll_table;
94 struct rtt_walk wi;
95 enum ripas ripas;
96 bool ret;
97
98 assert(GRANULE_ALIGNED(ipa));
99
100 if (!addr_in_rec_par(rec, ipa)) {
101 return false;
102 }
103 granule_lock(rec->realm_info.g_rtt, GRANULE_STATE_RTT);
104
105 rtt_walk_lock_unlock(rec->realm_info.g_rtt,
106 rec->realm_info.s2_starting_level,
107 rec->realm_info.ipa_bits,
108 ipa, RTT_PAGE_LEVEL, &wi);
109
110 ll_table = granule_map(wi.g_llt, SLOT_RTT);
111 s2tte = s2tte_read(&ll_table[wi.index]);
112
113 if (s2tte_is_destroyed(s2tte)) {
114 ret = false;
115 goto out_unmap_ll_table;
116 }
117 ripas = s2tte_get_ripas(s2tte);
118 ret = (ripas == RMI_EMPTY);
119
120out_unmap_ll_table:
121 buffer_unmap(ll_table);
122 granule_unlock(wi.g_llt);
123 return ret;
124}
125
126static bool fsc_is_external_abort(unsigned long fsc)
127{
128 if (fsc == ESR_EL2_ABORT_FSC_SEA) {
129 return true;
130 }
131
132 if ((fsc >= ESR_EL2_ABORT_FSC_SEA_TTW_START) &&
133 (fsc <= ESR_EL2_ABORT_FSC_SEA_TTW_END)) {
134 return true;
135 }
136
137 return false;
138}
139
140/*
141 * Handles Data/Instruction Aborts at a lower EL with External Abort fault
142 * status code (D/IFSC).
143 * Returns 'true' if the exception is the external abort and the `rec_exit`
144 * structure is populated, 'false' otherwise.
145 */
146static bool handle_sync_external_abort(struct rec *rec,
147 struct rmi_rec_exit *rec_exit,
148 unsigned long esr)
149{
150 unsigned long fsc = esr & ESR_EL2_ABORT_FSC_MASK;
151 unsigned long set = esr & ESR_EL2_ABORT_SET_MASK;
152
153 if (!fsc_is_external_abort(fsc)) {
154 return false;
155 }
156
157 switch (set) {
158 case ESR_EL2_ABORT_SET_UER:
159 /*
160 * The recoverable SEA.
161 * Inject the sync. abort into the Realm.
162 * Report the exception to the host.
163 */
164 inject_sync_idabort(ESR_EL2_ABORT_FSC_SEA);
165 /*
166 * Fall through.
167 */
168 case ESR_EL2_ABORT_SET_UEO:
169 /*
170 * The restartable SEA.
171 * Report the exception to the host.
172 * The REC restarts the same instruction.
173 */
174 rec_exit->esr = esr & ESR_NONEMULATED_ABORT_MASK;
175
176 /*
177 * The value of the HPFAR_EL2 is not provided to the host as
178 * it is undefined for external aborts.
179 *
180 * We also don't provide the content of FAR_EL2 because it
181 * has no practical value to the host without the HPFAR_EL2.
182 */
183 break;
184 case ESR_EL2_ABORT_SET_UC:
185 /*
186 * The uncontainable SEA.
187 * Fatal to the system.
188 */
189 system_abort();
190 break;
191 default:
192 assert(false);
193 }
194
195 return true;
196}
197
198void emulate_stage2_data_abort(struct rec *rec,
199 struct rmi_rec_exit *rec_exit,
200 unsigned long rtt_level)
201{
202 unsigned long fipa = rec->regs[1];
203
204 assert(rtt_level <= RTT_PAGE_LEVEL);
205
206 /*
207 * Setup Exception Syndrom Register to emulate a real data abort
208 * and return to NS host to handle it.
209 */
210 rec_exit->esr = (ESR_EL2_EC_DATA_ABORT |
211 (ESR_EL2_ABORT_FSC_TRANSLATION_FAULT_L0 + rtt_level));
212 rec_exit->far = 0UL;
213 rec_exit->hpfar = fipa >> HPFAR_EL2_FIPA_OFFSET;
214 rec_exit->exit_reason = RMI_EXIT_SYNC;
215}
216
217/*
218 * Returns 'true' if the abort is handled and the RMM should return to the Realm,
219 * and returns 'false' if the exception should be reported to the HS host.
220 */
221static bool handle_data_abort(struct rec *rec, struct rmi_rec_exit *rec_exit,
222 unsigned long esr)
223{
224 unsigned long far = 0UL;
225 unsigned long hpfar = read_hpfar_el2();
226 unsigned long fipa = (hpfar & HPFAR_EL2_FIPA_MASK) << HPFAR_EL2_FIPA_OFFSET;
227 unsigned long write_val = 0UL;
228
229 if (handle_sync_external_abort(rec, rec_exit, esr)) {
230 /*
231 * All external aborts are immediately reported to the host.
232 */
233 return false;
234 }
235
236 /*
237 * The memory access that crosses a page boundary may cause two aborts
238 * with `hpfar_el2` values referring to two consecutive pages.
239 *
240 * Insert the SEA and return to the Realm if the granule's RIPAS is EMPTY.
241 */
242 if (ipa_is_empty(fipa, rec)) {
243 inject_sync_idabort(ESR_EL2_ABORT_FSC_SEA);
244 return true;
245 }
246
247 if (fixup_aarch32_data_abort(rec, &esr) ||
248 access_in_rec_par(rec, fipa)) {
249 esr &= ESR_NONEMULATED_ABORT_MASK;
250 goto end;
251 }
252
253 if (esr_is_write(esr)) {
254 write_val = get_dabt_write_value(rec, esr);
255 }
256
257 far = read_far_el2() & ~GRANULE_MASK;
258 esr &= ESR_EMULATED_ABORT_MASK;
259
260end:
261 rec_exit->esr = esr;
262 rec_exit->far = far;
263 rec_exit->hpfar = hpfar;
264 rec_exit->gprs[0] = write_val;
265
266 return false;
267}
268
269/*
270 * Returns 'true' if the abort is handled and the RMM should return to the Realm,
271 * and returns 'false' if the exception should be reported to the NS host.
272 */
273static bool handle_instruction_abort(struct rec *rec, struct rmi_rec_exit *rec_exit,
274 unsigned long esr)
275{
276 unsigned long fsc = esr & ESR_EL2_ABORT_FSC_MASK;
277 unsigned long fsc_type = fsc & ~ESR_EL2_ABORT_FSC_LEVEL_MASK;
278 unsigned long hpfar = read_hpfar_el2();
279 unsigned long fipa = (hpfar & HPFAR_EL2_FIPA_MASK) << HPFAR_EL2_FIPA_OFFSET;
280
281 if (handle_sync_external_abort(rec, rec_exit, esr)) {
282 /*
283 * All external aborts are immediately reported to the host.
284 */
285 return false;
286 }
287
288 /*
289 * Insert the SEA and return to the Realm if:
290 * - The instruction abort is at an Unprotected IPA, or
291 * - The granule's RIPAS is EMPTY
292 */
293 if (!access_in_rec_par(rec, fipa) || ipa_is_empty(fipa, rec)) {
294 inject_sync_idabort(ESR_EL2_ABORT_FSC_SEA);
295 return true;
296 }
297
298 if (fsc_type != ESR_EL2_ABORT_FSC_TRANSLATION_FAULT) {
299 unsigned long far = read_far_el2();
300
301 /*
302 * TODO: Should this ever happen, or is it an indication of an
303 * internal consistency failure in the RMM which should lead
304 * to a panic instead?
305 */
306
307 ERROR("Unhandled instruction abort:\n");
308 ERROR(" FSC: %12s0x%02lx\n", " ", fsc);
309 ERROR(" FAR: %16lx\n", far);
310 ERROR(" HPFAR: %16lx\n", hpfar);
311 return false;
312 }
313
314 rec_exit->hpfar = hpfar;
315 rec_exit->esr = esr & ESR_NONEMULATED_ABORT_MASK;
316
317 return false;
318}
319
320/*
321 * Return 'false' if no IRQ is pending,
322 * return 'true' if there is an IRQ pending, and need to return to host.
323 */
324static bool check_pending_irq(void)
325{
326 unsigned long pending_irq;
327
328 pending_irq = read_isr_el1();
329
330 return (pending_irq != 0UL);
331}
332
333static void advance_pc(void)
334{
335 unsigned long pc = read_elr_el2();
336
337 write_elr_el2(pc + 4UL);
338}
339
340static void return_result_to_realm(struct rec *rec, struct smc_result result)
341{
342 rec->regs[0] = result.x[0];
343 rec->regs[1] = result.x[1];
344 rec->regs[2] = result.x[2];
345 rec->regs[3] = result.x[3];
346}
347
348/*
349 * Return 'true' if execution should continue in the REC, otherwise return
350 * 'false' to go back to the NS caller of REC.Enter.
351 */
352static bool handle_realm_rsi(struct rec *rec, struct rmi_rec_exit *rec_exit)
353{
354 bool ret_to_rec = true; /* Return to Realm */
355 unsigned int function_id = rec->regs[0];
356
357 RSI_LOG_SET(rec->regs[1], rec->regs[2],
358 rec->regs[3], rec->regs[4], rec->regs[5]);
359
360 if (!IS_SMC32_PSCI_FID(function_id) && !IS_SMC64_PSCI_FID(function_id)
361 && !IS_SMC64_RSI_FID(function_id)) {
362
363 ERROR("Invalid RSI function_id = %x\n", function_id);
364 rec->regs[0] = SMC_UNKNOWN;
365 return true;
366 }
367
368 switch (function_id) {
369 case SMCCC_VERSION:
370 rec->regs[0] = SMCCC_VERSION_NUMBER;
371 break;
372 case SMC_RSI_ABI_VERSION:
373 rec->regs[0] = system_rsi_abi_version();
374 break;
375 case SMC32_PSCI_FID_MIN ... SMC32_PSCI_FID_MAX:
376 case SMC64_PSCI_FID_MIN ... SMC64_PSCI_FID_MAX: {
377 struct psci_result res;
378
379 res = psci_rsi(rec,
380 function_id,
381 rec->regs[1],
382 rec->regs[2],
383 rec->regs[3]);
384
385 if (!rec->psci_info.pending) {
386 rec->regs[0] = res.smc_res.x[0];
387 rec->regs[1] = res.smc_res.x[1];
388 rec->regs[2] = res.smc_res.x[2];
389 rec->regs[3] = res.smc_res.x[3];
390 }
391
392 if (res.hvc_forward.forward_psci_call) {
393 unsigned int i;
394
395 rec_exit->exit_reason = RMI_EXIT_PSCI;
396 rec_exit->gprs[0] = function_id;
397 rec_exit->gprs[1] = res.hvc_forward.x1;
398 rec_exit->gprs[2] = res.hvc_forward.x2;
399 rec_exit->gprs[3] = res.hvc_forward.x3;
400
401 for (i = 4U; i < REC_EXIT_NR_GPRS; i++) {
402 rec_exit->gprs[i] = 0UL;
403 }
404
405 advance_pc();
406 ret_to_rec = false;
407 }
408 break;
409 }
410 case SMC_RSI_ATTEST_TOKEN_INIT:
411 rec->regs[0] = handle_rsi_attest_token_init(rec);
412 break;
413 case SMC_RSI_ATTEST_TOKEN_CONTINUE: {
414 struct attest_result res;
415 attest_realm_token_sign_continue_start();
416 while (true) {
417 /*
418 * Possible outcomes:
419 * if res.incomplete is true
420 * if IRQ pending
421 * check for pending IRQ and return to host
422 * else try a new iteration
423 * else
424 * if RTT table walk has failed,
425 * emulate data abort back to host
426 * otherwise
427 * return to realm because the token
428 * creation is complete or input parameter
429 * validation failed.
430 */
431 handle_rsi_attest_token_continue(rec, &res);
432
433 if (res.incomplete) {
434 if (check_pending_irq()) {
435 rec_exit->exit_reason = RMI_EXIT_IRQ;
436 /* Return to NS host to handle IRQ. */
437 ret_to_rec = false;
438 break;
439 }
440 } else {
441 if (res.walk_result.abort) {
442 emulate_stage2_data_abort(
443 rec, rec_exit,
444 res.walk_result.rtt_level);
445 ret_to_rec = false; /* Exit to Host */
446 break;
447 }
448
449 /* Return to Realm */
450 return_result_to_realm(rec, res.smc_res);
451 break;
452 }
453 }
454 attest_realm_token_sign_continue_finish();
455 break;
456 }
457 case SMC_RSI_MEASUREMENT_READ:
458 rec->regs[0] = handle_rsi_read_measurement(rec);
459 break;
460 case SMC_RSI_MEASUREMENT_EXTEND:
461 rec->regs[0] = handle_rsi_extend_measurement(rec);
462 break;
463 case SMC_RSI_REALM_CONFIG: {
464 struct rsi_config_result res;
465
466 res = handle_rsi_realm_config(rec);
467 if (res.walk_result.abort) {
468 emulate_stage2_data_abort(rec, rec_exit,
469 res.walk_result.rtt_level);
470 ret_to_rec = false; /* Exit to Host */
471 } else {
472 /* Return to Realm */
473 return_result_to_realm(rec, res.smc_res);
474 }
475 break;
476 }
477 case SMC_RSI_IPA_STATE_SET:
478 if (handle_rsi_ipa_state_set(rec, rec_exit)) {
479 rec->regs[0] = RSI_ERROR_INPUT;
480 } else {
481 advance_pc();
482 ret_to_rec = false; /* Return to Host */
483 }
484 break;
485 case SMC_RSI_IPA_STATE_GET: {
486 enum ripas ripas;
487
488 rec->regs[0] = handle_rsi_ipa_state_get(rec, rec->regs[1],
489 &ripas);
490 if (rec->regs[0] == RSI_SUCCESS) {
491 rec->regs[1] = ripas;
492 }
493 break;
494 }
495 case SMC_RSI_HOST_CALL: {
496 struct rsi_host_call_result res;
497
498 res = handle_rsi_host_call(rec, rec_exit);
499
500 if (res.walk_result.abort) {
501 emulate_stage2_data_abort(rec, rec_exit,
502 res.walk_result.rtt_level);
503 } else {
504 rec->regs[0] = res.smc_result;
505
506 /*
507 * Return to Realm in case of error,
508 * parent function calls advance_pc()
509 */
510 if (rec->regs[0] == RSI_SUCCESS) {
511 advance_pc();
512
513 /* Exit to Host */
514 rec->host_call = true;
515 rec_exit->exit_reason = RMI_EXIT_HOST_CALL;
516 ret_to_rec = false;
517 }
518 }
519 break;
520 }
521
522 default:
523 rec->regs[0] = SMC_UNKNOWN;
524 break;
525 }
526
527 /* Log RSI call */
528 RSI_LOG_EXIT(function_id, rec->regs[0], ret_to_rec);
529 return ret_to_rec;
530}
531
532/*
533 * Return 'true' if the RMM handled the exception,
534 * 'false' to return to the Non-secure host.
535 */
536static bool handle_exception_sync(struct rec *rec, struct rmi_rec_exit *rec_exit)
537{
538 const unsigned long esr = read_esr_el2();
539
540 switch (esr & ESR_EL2_EC_MASK) {
541 case ESR_EL2_EC_WFX:
542 rec_exit->esr = esr & (ESR_EL2_EC_MASK | ESR_EL2_WFx_TI_BIT);
543 advance_pc();
544 return false;
545 case ESR_EL2_EC_HVC:
546 realm_inject_undef_abort();
547 return true;
548 case ESR_EL2_EC_SMC:
549 if (!handle_realm_rsi(rec, rec_exit)) {
550 return false;
551 }
552 /*
553 * Advance PC.
554 * HCR_EL2.TSC traps execution of the SMC instruction.
555 * It is not a routing control for the SMC exception.
556 * Trap exceptions and SMC exceptions have different
557 * preferred return addresses.
558 */
559 advance_pc();
560 return true;
561 case ESR_EL2_EC_SYSREG: {
562 bool ret = handle_sysreg_access_trap(rec, rec_exit, esr);
563
564 advance_pc();
565 return ret;
566 }
567 case ESR_EL2_EC_INST_ABORT:
568 return handle_instruction_abort(rec, rec_exit, esr);
569 case ESR_EL2_EC_DATA_ABORT:
570 return handle_data_abort(rec, rec_exit, esr);
571 case ESR_EL2_EC_FPU: {
572 unsigned long cptr;
573
574 /*
575 * Realm has requested FPU/SIMD access, so save NS state and
576 * load realm state. Start by disabling traps so we can save
577 * the NS state and load the realm state.
578 */
579 cptr = read_cptr_el2();
580 cptr &= ~(CPTR_EL2_FPEN_MASK << CPTR_EL2_FPEN_SHIFT);
581 cptr |= (CPTR_EL2_FPEN_NO_TRAP_11 << CPTR_EL2_FPEN_SHIFT);
582 cptr &= ~(CPTR_EL2_ZEN_MASK << CPTR_EL2_ZEN_SHIFT);
583 cptr |= (CPTR_EL2_ZEN_NO_TRAP_11 << CPTR_EL2_ZEN_SHIFT);
584 write_cptr_el2(cptr);
585
586 /*
587 * Save NS state, restore realm state, and set flag indicating
588 * realm has used FPU so we know to save and restore NS state at
589 * realm exit.
590 */
591 if (rec->ns->sve != NULL) {
592 save_sve_state(rec->ns->sve);
593 } else {
594 assert(rec->ns->fpu != NULL);
595 fpu_save_state(rec->ns->fpu);
596 }
597 fpu_restore_state(&rec->fpu_ctx.fpu);
598 rec->fpu_ctx.used = true;
599
600 /*
601 * Disable SVE for now, until per rec save/restore is
602 * implemented
603 */
604 cptr = read_cptr_el2();
605 cptr &= ~(CPTR_EL2_ZEN_MASK << CPTR_EL2_ZEN_SHIFT);
606 cptr |= (CPTR_EL2_ZEN_TRAP_ALL_00 << CPTR_EL2_ZEN_SHIFT);
607 write_cptr_el2(cptr);
608
609 /*
610 * Return 'true' indicating that this exception
611 * has been handled and execution can continue.
612 */
613 return true;
614 }
615 default:
616 /*
617 * TODO: Check if there are other exit reasons we could
618 * encounter here and handle them appropriately
619 */
620 break;
621 }
622
623 VERBOSE("Unhandled sync exit ESR: %08lx (EC: %lx ISS: %lx)\n",
624 esr,
625 (esr & ESR_EL2_EC_MASK) >> ESR_EL2_EC_SHIFT,
626 (esr & ESR_EL2_ISS_MASK) >> ESR_EL2_ISS_SHIFT);
627
628 /*
629 * Zero values in esr, far & hpfar of 'rec_exit' structure
630 * will be returned to the NS host.
631 * The only information that may leak is when there was
632 * some unhandled/unknown reason for the exception.
633 */
634 return false;
635}
636
637/*
638 * Return 'true' if the RMM handled the exception, 'false' to return to the
639 * Non-secure host.
640 */
641static bool handle_exception_serror_lel(struct rec *rec, struct rmi_rec_exit *rec_exit)
642{
643 const unsigned long esr = read_esr_el2();
644
645 if (esr & ESR_EL2_SERROR_IDS_BIT) {
646 /*
647 * Implementation defined content of the esr.
648 */
649 system_abort();
650 }
651
652 if ((esr & ESR_EL2_SERROR_DFSC_MASK) != ESR_EL2_SERROR_DFSC_ASYNC) {
653 /*
654 * Either Uncategorized or Reserved fault status code.
655 */
656 system_abort();
657 }
658
659 switch (esr & ESR_EL2_SERROR_AET_MASK) {
660 case ESR_EL2_SERROR_AET_UEU: /* Unrecoverable RAS Error */
661 case ESR_EL2_SERROR_AET_UER: /* Recoverable RAS Error */
662 /*
663 * The abort is fatal to the current S/W. Inject the SError into
664 * the Realm so it can e.g. shut down gracefully or localize the
665 * problem at the specific EL0 application.
666 *
667 * Note: Consider shutting down the Realm here to avoid
668 * the host's attack on unstable Realms.
669 */
670 inject_serror(rec, esr);
671 /*
672 * Fall through.
673 */
674 case ESR_EL2_SERROR_AET_CE: /* Corrected RAS Error */
675 case ESR_EL2_SERROR_AET_UEO: /* Restartable RAS Error */
676 /*
677 * Report the exception to the host.
678 */
679 rec_exit->esr = esr & ESR_SERROR_MASK;
680 break;
681 case ESR_EL2_SERROR_AET_UC: /* Uncontainable RAS Error */
682 system_abort();
683 break;
684 default:
685 /*
686 * Unrecognized Asynchronous Error Type
687 */
688 assert(false);
689 }
690
691 return false;
692}
693
694static bool handle_exception_irq_lel(struct rec *rec, struct rmi_rec_exit *rec_exit)
695{
696 (void)rec;
697
698 rec_exit->exit_reason = RMI_EXIT_IRQ;
699
700 /*
701 * With GIC all virtual interrupt programming
702 * must go via the NS hypervisor.
703 */
704 return false;
705}
706
707/* Returns 'true' when returning to Realm (S) and false when to NS */
708bool handle_realm_exit(struct rec *rec, struct rmi_rec_exit *rec_exit, int exception)
709{
710 switch (exception) {
711 case ARM_EXCEPTION_SYNC_LEL: {
712 bool ret;
713
714 /*
715 * TODO: Sanitize ESR to ensure it doesn't leak sensitive
716 * information.
717 */
718 rec_exit->exit_reason = RMI_EXIT_SYNC;
719 ret = handle_exception_sync(rec, rec_exit);
720 if (!ret) {
721 rec->last_run_info.esr = read_esr_el2();
722 rec->last_run_info.far = read_far_el2();
723 rec->last_run_info.hpfar = read_hpfar_el2();
724 }
725 return ret;
726
727 /*
728 * TODO: Much more detailed handling of exit reasons.
729 */
730 }
731 case ARM_EXCEPTION_IRQ_LEL:
732 return handle_exception_irq_lel(rec, rec_exit);
733 case ARM_EXCEPTION_FIQ_LEL:
734 rec_exit->exit_reason = RMI_EXIT_FIQ;
735 break;
736 case ARM_EXCEPTION_SERROR_LEL: {
737 const unsigned long esr = read_esr_el2();
738 bool ret;
739
740 /*
741 * TODO: Sanitize ESR to ensure it doesn't leak sensitive
742 * information.
743 */
744 rec_exit->exit_reason = RMI_EXIT_SERROR;
745 ret = handle_exception_serror_lel(rec, rec_exit);
746 if (!ret) {
747 rec->last_run_info.esr = esr;
748 rec->last_run_info.far = read_far_el2();
749 rec->last_run_info.hpfar = read_hpfar_el2();
750 }
751 return ret;
752 }
753 default:
754 INFO("Unrecognized exit reason: %d\n", exception);
755 break;
756 };
757
758 return false;
759}