mirror of
https://github.com/yuzu-emu/unicorn.git
synced 2025-01-11 13:05:36 +00:00
target/arm: Report correct syndrome for FP/SIMD traps to Hyp mode
For traps of FP/SIMD instructions to AArch32 Hyp mode, the syndrome provided in HSR has more information than is reported to AArch64. Specifically, there are extra fields TA and coproc which indicate whether the trapped instruction was FP or SIMD. Add this extra information to the syndromes we construct, and mask it out when taking the exception to AArch64. Backports commit 4be42f4013fa1a9df47b48aae5148767bed8e80c from qemu
This commit is contained in:
parent
075bac4d57
commit
d60fe610bb
|
@ -7741,6 +7741,15 @@ static void arm_cpu_do_interrupt_aarch64_(CPUState *cs)
|
||||||
case EXCP_HVC:
|
case EXCP_HVC:
|
||||||
case EXCP_HYP_TRAP:
|
case EXCP_HYP_TRAP:
|
||||||
case EXCP_SMC:
|
case EXCP_SMC:
|
||||||
|
if (syn_get_ec(env->exception.syndrome) == EC_ADVSIMDFPACCESSTRAP) {
|
||||||
|
/*
|
||||||
|
* QEMU internal FP/SIMD syndromes from AArch32 include the
|
||||||
|
* TA and coproc fields which are only exposed if the exception
|
||||||
|
* is taken to AArch32 Hyp mode. Mask them out to get a valid
|
||||||
|
* AArch64 format syndrome.
|
||||||
|
*/
|
||||||
|
env->exception.syndrome &= ~MAKE_64BIT_MASK(0, 20);
|
||||||
|
}
|
||||||
env->cp15.esr_el[new_el] = env->exception.syndrome;
|
env->cp15.esr_el[new_el] = env->exception.syndrome;
|
||||||
break;
|
break;
|
||||||
case EXCP_IRQ:
|
case EXCP_IRQ:
|
||||||
|
|
|
@ -290,6 +290,9 @@ static inline uint32_t syn_get_ec(uint32_t syn)
|
||||||
* few cases the value in HSR for exceptions taken to AArch32 Hyp
|
* few cases the value in HSR for exceptions taken to AArch32 Hyp
|
||||||
* mode differs slightly, and we fix this up when populating HSR in
|
* mode differs slightly, and we fix this up when populating HSR in
|
||||||
* arm_cpu_do_interrupt_aarch32_hyp().
|
* arm_cpu_do_interrupt_aarch32_hyp().
|
||||||
|
* The exception is FP/SIMD access traps -- these report extra information
|
||||||
|
* when taking an exception to AArch32. For those we include the extra coproc
|
||||||
|
* and TA fields, and mask them out when taking the exception to AArch64.
|
||||||
*/
|
*/
|
||||||
static inline uint32_t syn_uncategorized(void)
|
static inline uint32_t syn_uncategorized(void)
|
||||||
{
|
{
|
||||||
|
@ -389,9 +392,18 @@ static inline uint32_t syn_cp15_rrt_trap(int cv, int cond, int opc1, int crm,
|
||||||
|
|
||||||
static inline uint32_t syn_fp_access_trap(int cv, int cond, bool is_16bit)
|
static inline uint32_t syn_fp_access_trap(int cv, int cond, bool is_16bit)
|
||||||
{
|
{
|
||||||
|
/* AArch32 FP trap or any AArch64 FP/SIMD trap: TA == 0 coproc == 0xa */
|
||||||
return (EC_ADVSIMDFPACCESSTRAP << ARM_EL_EC_SHIFT)
|
return (EC_ADVSIMDFPACCESSTRAP << ARM_EL_EC_SHIFT)
|
||||||
| (is_16bit ? 0 : ARM_EL_IL)
|
| (is_16bit ? 0 : ARM_EL_IL)
|
||||||
| (cv << 24) | (cond << 20);
|
| (cv << 24) | (cond << 20) | 0xa;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline uint32_t syn_simd_access_trap(int cv, int cond, bool is_16bit)
|
||||||
|
{
|
||||||
|
/* AArch32 SIMD trap: TA == 1 coproc == 0 */
|
||||||
|
return (EC_ADVSIMDFPACCESSTRAP << ARM_EL_EC_SHIFT)
|
||||||
|
| (is_16bit ? 0 : ARM_EL_IL)
|
||||||
|
| (cv << 24) | (cond << 20) | (1 << 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline uint32_t syn_sve_access_trap(void)
|
static inline uint32_t syn_sve_access_trap(void)
|
||||||
|
|
|
@ -5096,7 +5096,7 @@ static int disas_neon_ls_insn(DisasContext *s, uint32_t insn)
|
||||||
*/
|
*/
|
||||||
if (s->fp_excp_el) {
|
if (s->fp_excp_el) {
|
||||||
gen_exception_insn(s, 4, EXCP_UDEF,
|
gen_exception_insn(s, 4, EXCP_UDEF,
|
||||||
syn_fp_access_trap(1, 0xe, false), s->fp_excp_el);
|
syn_simd_access_trap(1, 0xe, false), s->fp_excp_el);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5892,7 +5892,7 @@ static int disas_neon_data_insn(DisasContext *s, uint32_t insn)
|
||||||
*/
|
*/
|
||||||
if (s->fp_excp_el) {
|
if (s->fp_excp_el) {
|
||||||
gen_exception_insn(s, 4, EXCP_UDEF,
|
gen_exception_insn(s, 4, EXCP_UDEF,
|
||||||
syn_fp_access_trap(1, 0xe, false), s->fp_excp_el);
|
syn_simd_access_trap(1, 0xe, false), s->fp_excp_el);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8005,7 +8005,7 @@ static int disas_neon_insn_3same_ext(DisasContext *s, uint32_t insn)
|
||||||
|
|
||||||
if (s->fp_excp_el) {
|
if (s->fp_excp_el) {
|
||||||
gen_exception_insn(s, 4, EXCP_UDEF,
|
gen_exception_insn(s, 4, EXCP_UDEF,
|
||||||
syn_fp_access_trap(1, 0xe, false), s->fp_excp_el);
|
syn_simd_access_trap(1, 0xe, false), s->fp_excp_el);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (!s->vfp_enabled) {
|
if (!s->vfp_enabled) {
|
||||||
|
@ -8092,7 +8092,7 @@ static int disas_neon_insn_2reg_scalar_ext(DisasContext *s, uint32_t insn)
|
||||||
|
|
||||||
if (s->fp_excp_el) {
|
if (s->fp_excp_el) {
|
||||||
gen_exception_insn(s, 4, EXCP_UDEF,
|
gen_exception_insn(s, 4, EXCP_UDEF,
|
||||||
syn_fp_access_trap(1, 0xe, false), s->fp_excp_el);
|
syn_simd_access_trap(1, 0xe, false), s->fp_excp_el);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (!s->vfp_enabled) {
|
if (!s->vfp_enabled) {
|
||||||
|
|
Loading…
Reference in a new issue