@samitouri / QOSamiQemu / commits / a646f41996

target/arm: migrate fault syndromes to registerfields

Migrate syn_insn_abort and syn_data_abort_* to the registerfields API. Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Signed-off-by: Alex Bennée <alex.bennee@linaro.org> Tested-by: Philippe Mathieu-Daudé <philmd@linaro.org> Message-id: 20260422125250.1303100-11-alex.bennee@linaro.org Signed-off-by: Peter Maydell <peter.maydell@linaro.org>

Alex Bennée committed Apr 22, 2026 at 13:52 UTC a646f41996b580e620883880bb2faf31a3ddd6df
1 file changed +74 -13
target/arm/syndrome.h
+74 -13
@@ -494,20 +494,64 @@ static inline uint32_t syn_gpc(int s2ptw, int ind, int gpcsc, int vncr,
494 return res;
495 }
496
497 +/*
498 + * ISS encoding for an exception from an Instruction Abort
499 + *
500 + * (aka instruction abort)
501 + */
502 +FIELD(IABORT_ISS, IFSC, 0, 6)
503 +FIELD(IABORT_ISS, S1PTW, 7, 1)
504 +FIELD(IABORT_ISS, EA, 9, 1)
505 +FIELD(IABORT_ISS, FnV, 10, 1) /* FAR not Valid */
506 +FIELD(IABORT_ISS, SET, 11, 2)
507 +FIELD(IABORT_ISS, PFV, 14, 1)
508 +FIELD(IABORT_ISS, TopLevel, 21, 1) /* FEAT_THE */
509 +
510 static inline uint32_t syn_insn_abort(int same_el, int ea, int s1ptw, int fsc)
511 {
499 - return (EC_INSNABORT << ARM_EL_EC_SHIFT) | (same_el << ARM_EL_EC_SHIFT)
500 - | ARM_EL_IL | (ea << 9) | (s1ptw << 7) | fsc;
512 + uint32_t res = syn_set_ec(0, EC_INSNABORT + same_el);
513 + res = FIELD_DP32(res, SYNDROME, IL, 1);
514 +
515 + res = FIELD_DP32(res, IABORT_ISS, EA, ea);
516 + res = FIELD_DP32(res, IABORT_ISS, S1PTW, s1ptw);
517 + res = FIELD_DP32(res, IABORT_ISS, IFSC, fsc);
518 +
519 + return res;
520 }
521
522 +/*
523 + * ISS encoding for an exception from a Data Abort
524 + */
525 +FIELD(DABORT_ISS, DFSC, 0, 6)
526 +FIELD(DABORT_ISS, WNR, 6, 1)
527 +FIELD(DABORT_ISS, S1PTW, 7, 1)
528 +FIELD(DABORT_ISS, CM, 8, 1)
529 +FIELD(DABORT_ISS, EA, 9, 1)
530 +FIELD(DABORT_ISS, FnV, 10, 1)
531 +FIELD(DABORT_ISS, LST, 11, 2)
532 +FIELD(DABORT_ISS, VNCR, 13, 1)
533 +FIELD(DABORT_ISS, AR, 14, 1)
534 +FIELD(DABORT_ISS, SF, 15, 1)
535 +FIELD(DABORT_ISS, SRT, 16, 5)
536 +FIELD(DABORT_ISS, SSE, 21, 1)
537 +FIELD(DABORT_ISS, SAS, 22, 2)
538 +FIELD(DABORT_ISS, ISV, 24, 1)
539 +
540 static inline uint32_t syn_data_abort_no_iss(int same_el, int fnv,
541 int ea, int cm, int s1ptw,
542 int wnr, int fsc)
543 {
507 - return (EC_DATAABORT << ARM_EL_EC_SHIFT) | (same_el << ARM_EL_EC_SHIFT)
508 - | ARM_EL_IL
509 - | (fnv << 10) | (ea << 9) | (cm << 8) | (s1ptw << 7)
510 - | (wnr << 6) | fsc;
544 + uint32_t res = syn_set_ec(0, EC_DATAABORT + same_el);
545 + res = FIELD_DP32(res, SYNDROME, IL, 1);
546 +
547 + res = FIELD_DP32(res, DABORT_ISS, FnV, fnv);
548 + res = FIELD_DP32(res, DABORT_ISS, EA, ea);
549 + res = FIELD_DP32(res, DABORT_ISS, CM, cm);
550 + res = FIELD_DP32(res, DABORT_ISS, S1PTW, s1ptw);
551 + res = FIELD_DP32(res, DABORT_ISS, WNR, wnr);
552 + res = FIELD_DP32(res, DABORT_ISS, DFSC, fsc);
553 +
554 + return res;
555 }
556
557 static inline uint32_t syn_data_abort_with_iss(int same_el,
@@ -517,11 +561,22 @@ static inline uint32_t syn_data_abort_with_iss(int same_el,
561 int wnr, int fsc,
562 bool is_16bit)
563 {
520 - return (EC_DATAABORT << ARM_EL_EC_SHIFT) | (same_el << ARM_EL_EC_SHIFT)
521 - | (is_16bit ? 0 : ARM_EL_IL)
522 - | ARM_EL_ISV | (sas << 22) | (sse << 21) | (srt << 16)
523 - | (sf << 15) | (ar << 14)
524 - | (ea << 9) | (cm << 8) | (s1ptw << 7) | (wnr << 6) | fsc;
564 + uint32_t res = syn_set_ec(0, EC_DATAABORT + same_el);
565 + res = FIELD_DP32(res, SYNDROME, IL, !is_16bit);
566 +
567 + res = FIELD_DP32(res, DABORT_ISS, ISV, 1);
568 + res = FIELD_DP32(res, DABORT_ISS, SAS, sas);
569 + res = FIELD_DP32(res, DABORT_ISS, SSE, sse);
570 + res = FIELD_DP32(res, DABORT_ISS, SRT, srt);
571 + res = FIELD_DP32(res, DABORT_ISS, SF, sf);
572 + res = FIELD_DP32(res, DABORT_ISS, AR, ar);
573 + res = FIELD_DP32(res, DABORT_ISS, EA, ea);
574 + res = FIELD_DP32(res, DABORT_ISS, CM, cm);
575 + res = FIELD_DP32(res, DABORT_ISS, S1PTW, s1ptw);
576 + res = FIELD_DP32(res, DABORT_ISS, WNR, wnr);
577 + res = FIELD_DP32(res, DABORT_ISS, DFSC, fsc);
578 +
579 + return res;
580 }
581
582 /*
@@ -530,8 +585,14 @@ static inline uint32_t syn_data_abort_with_iss(int same_el,
585 */
586 static inline uint32_t syn_data_abort_vncr(int ea, int wnr, int fsc)
587 {
533 - return (EC_DATAABORT << ARM_EL_EC_SHIFT) | (1 << ARM_EL_EC_SHIFT)
534 - | ARM_EL_IL | ARM_EL_VNCR | (wnr << 6) | fsc;
588 + uint32_t res = syn_set_ec(0, EC_DATAABORT_SAME_EL);
589 + res = FIELD_DP32(res, SYNDROME, IL, 1);
590 +
591 + res = FIELD_DP32(res, DABORT_ISS, VNCR, 1);
592 + res = FIELD_DP32(res, DABORT_ISS, WNR, wnr);
593 + res = FIELD_DP32(res, DABORT_ISS, DFSC, fsc);
594 +
595 + return res;
596 }
597
598 static inline uint32_t syn_swstep(int same_el, int isv, int ex)