target/microblaze: Switch to transaction_failed hook
RFC 1/1 target/microblaze: Switch to transaction_failed hook
Switch the microblaze target from the old unassigned_access hook to the transaction_failed hook.
The notable difference is that rather than it being called for all physical memory accesses which fail (including those made by DMA devices or by the gdbstub), it is only called for those made by the CPU via its MMU. For microblaze this makes no difference because none of the target CPU code needs to make loads or stores by physical address.
---
A straightforward conversion, but tagged RFC because I don't have any microblaze test images and have tested only with "make check".
target/microblaze/cpu.h | 7 ++++--- target/microblaze/cpu.c | 2 +- target/microblaze/op_helper.c | 20 ++++++++++---------- 3 files changed, 15 insertions(+), 14 deletions(-)
target/microblaze/cpu.h +4 -3
@@ -388,9 +388,10 @@ static inline void cpu_get_tb_cpu_state(CPUMBState *env, target_ulong *pc, }#if !defined(CONFIG_USER_ONLY ) -void mb_cpu_unassigned_access (CPUState *cpu,hwaddr addr, -bool is_write,bool is_exec,int is_asi, -unsigned size); +void mb_cpu_transaction_failed (CPUState *cs,hwaddr physaddr,vaddr addr, +unsigned size,MMUAccessType access_type, +int mmu_idx,MemTxAttrs attrs, +MemTxResult response,uintptr_t retaddr);#endif #endif
target/microblaze/cpu.c +1 -1
@@ -297,7 +297,7 @@ static void mb_cpu_class_init(ObjectClass *oc, void *data)#ifdef CONFIG_USER_ONLY cc->handle_mmu_fault = mb_cpu_handle_mmu_fault;#else - cc->do_unassigned_access = mb_cpu_unassigned_access; + cc->do_transaction_failed = mb_cpu_transaction_failed; cc->get_phys_page_debug = mb_cpu_get_phys_page_debug;#endif dc->vmsd = &vmstate_mb_cpu;
target/microblaze/op_helper.c +10 -10
@@ -486,18 +486,18 @@ void helper_mmu_write(CPUMBState *env, uint32_t ext, uint32_t rn, uint32_t v)mmu_write (env, ext, rn, v); } -void mb_cpu_unassigned_access (CPUState *cs,hwaddr addr, -bool is_write,bool is_exec,int is_asi, -unsigned size) +void mb_cpu_transaction_failed (CPUState *cs,hwaddr physaddr,vaddr addr, +unsigned size,MMUAccessType access_type, +int mmu_idx,MemTxAttrs attrs, +MemTxResult response,uintptr_t retaddr) {MicroBlazeCPU *cpu;CPUMBState *env; - -qemu_log_mask (CPU_LOG_INT ,"Unassigned " TARGET_FMT_plx" wr=%d exe=%d\n" , - addr, is_write ?1 :0 , is_exec ?1 :0 ); -if (cs ==NULL ) { -return ; - } +qemu_log_mask (CPU_LOG_INT ,"Transaction failed: vaddr 0x%" VADDR_PRIx +" physaddr 0x" TARGET_FMT_plx"size %d access type %s\n" , + addr, physaddr, size, + access_type ==MMU_INST_FETCH ?"INST_FETCH" : + (access_type ==MMU_DATA_LOAD ?"DATA_LOAD" :"DATA_STORE" )); cpu =MICROBLAZE_CPU (cs); env = &cpu->env;if (!(env->sregs[SR_MSR ] &MSR_EE )) {
@@ -505,7 +505,7 @@ void mb_cpu_unassigned_access(CPUState *cs, hwaddr addr, } env->sregs[SR_EAR ] = addr; -if (is_exec) { +if (access_type ==MMU_INST_FETCH ) {if ((env->pvr.regs[2 ] &PVR2_IOPB_BUS_EXC_MASK )) { env->sregs[SR_ESR ] =ESR_EC_INSN_BUS ;helper_raise_exception (env,EXCP_HW_EXCP );
Signature · 1 line
2.19.2
Quoted 98 lines · Peter Maydell
Switch the microblaze target from the old
unassigned_accesshook to thetransaction_failedhook.The notable difference is that rather than it being called for all physical memory accesses which fail (including those made by DMA devices or by the gdbstub), it is only called for those made by the CPU via its MMU. For microblaze this makes no difference because none of the target CPU code needs to make loads or stores by physical address.
Signed-off-by Peter Maydell <[email protected]>---
A straightforward conversion, but tagged RFC because I don't have any microblaze test images and have tested only with "make check".target/microblaze/cpu.h | 7 ++++--- target/microblaze/cpu.c | 2 +- target/microblaze/op_helper.c | 20 ++++++++++---------- 3 files changed, 15 insertions(+), 14 deletions(-)target/microblaze/cpu.h +4
-3@@ -388,9 +388,10 @@ static inline void cpu_get_tb_cpu_state(CPUMBState *env, target_ulong *pc, }#if !defined(CONFIG_USER_ONLY ) -void mb_cpu_unassigned_access (CPUState *cpu,hwaddr addr, -bool is_write,bool is_exec,int is_asi, -unsigned size); +void mb_cpu_transaction_failed (CPUState *cs,hwaddr physaddr,vaddr addr, +unsigned size,MMUAccessType access_type, +int mmu_idx,MemTxAttrs attrs, +MemTxResult response,uintptr_t retaddr);#endif #endif target/microblaze/cpu.c +1
-1@@ -297,7 +297,7 @@ static void mb_cpu_class_init(ObjectClass *oc, void *data)#ifdef CONFIG_USER_ONLY cc->handle_mmu_fault = mb_cpu_handle_mmu_fault;#else - cc->do_unassigned_access = mb_cpu_unassigned_access; + cc->do_transaction_failed = mb_cpu_transaction_failed; cc->get_phys_page_debug = mb_cpu_get_phys_page_debug;#endif dc->vmsd = &vmstate_mb_cpu;target/microblaze/op_helper.c +10
-11@@ -486,18 +486,18 @@ void helper_mmu_write(CPUMBState *env, uint32_t ext, uint32_t rn, uint32_t v)mmu_write (env, ext, rn, v); } -void mb_cpu_unassigned_access (CPUState *cs,hwaddr addr, -bool is_write,bool is_exec,int is_asi, -unsigned size) +void mb_cpu_transaction_failed (CPUState *cs,hwaddr physaddr,vaddr addr, +unsigned size,MMUAccessType access_type, +int mmu_idx,MemTxAttrs attrs, +MemTxResult response,uintptr_t retaddr) {MicroBlazeCPU *cpu;CPUMBState *env; - -qemu_log_mask (CPU_LOG_INT ,"Unassigned " TARGET_FMT_plx" wr=%d exe=%d\n" , - addr, is_write ?1 :0 , is_exec ?1 :0 ); -if (cs ==NULL ) { -return ; - } +qemu_log_mask (CPU_LOG_INT ,"Transaction failed: vaddr 0x%" VADDR_PRIx +" physaddr 0x" TARGET_FMT_plx"size %d access type %s\n" , + addr, physaddr, size, + access_type ==MMU_INST_FETCH ?"INST_FETCH" : + (access_type ==MMU_DATA_LOAD ?"DATA_LOAD" :"DATA_STORE" )); cpu =MICROBLAZE_CPU (cs); env = &cpu->env;if (!(env->sregs[SR_MSR ] &MSR_EE )) {@@ -505,7 +505,7 @@ void mb_cpu_unassigned_access(CPUState *cs, hwaddr addr, } env->sregs[SR_EAR ] = addr; -if (is_exec) { +if (access_type ==MMU_INST_FETCH ) {if ((env->pvr.regs[2 ] &PVR2_IOPB_BUS_EXC_MASK )) { env->sregs[SR_ESR ] =ESR_EC_INSN_BUS ;helper_raise_exception (env,EXCP_HW_EXCP ); --2.19.2
Signature · 2 lines
12345678901234567890123456789012345678901234567890123456789012345678901234567890
1 2 3 4 5 6 7 8Quoted 78 lines · Peter Maydell
Quoted 76 lines · Peter Maydell
Switch the microblaze target from the old
unassigned_accesshook to thetransaction_failedhook.The notable difference is that rather than it being called for all physical memory accesses which fail (including those made by DMA devices or by the gdbstub), it is only called for those made by the CPU via its MMU. For microblaze this makes no difference because none of the target CPU code needs to make loads or stores by physical address.
Signed-off-by Peter Maydell <[email protected]>---
A straightforward conversion, but tagged RFC because I don't have any microblaze test images and have tested only with "make check".target/microblaze/cpu.h | 7 ++++--- target/microblaze/cpu.c | 2 +- target/microblaze/op_helper.c | 20 ++++++++++---------- 3 files changed, 15 insertions(+), 14 deletions(-)target/microblaze/cpu.h +4
-3@@ -388,9 +388,10 @@ static inline void cpu_get_tb_cpu_state(CPUMBState *env, target_ulong *pc, }#if !defined(CONFIG_USER_ONLY ) -void mb_cpu_unassigned_access (CPUState *cpu,hwaddr addr, -bool is_write,bool is_exec,int is_asi, -unsigned size); +void mb_cpu_transaction_failed (CPUState *cs,hwaddr physaddr,vaddr addr, +unsigned size,MMUAccessType access_type, +int mmu_idx,MemTxAttrs attrs, +MemTxResult response,uintptr_t retaddr);#endif #endif target/microblaze/cpu.c +1
-1@@ -297,7 +297,7 @@ static void mb_cpu_class_init(ObjectClass *oc, void *data)#ifdef CONFIG_USER_ONLY cc->handle_mmu_fault = mb_cpu_handle_mmu_fault;#else - cc->do_unassigned_access = mb_cpu_unassigned_access; + cc->do_transaction_failed = mb_cpu_transaction_failed; cc->get_phys_page_debug = mb_cpu_get_phys_page_debug;#endif dc->vmsd = &vmstate_mb_cpu;target/microblaze/op_helper.c +4
-8@@ -486,18 +486,18 @@ void helper_mmu_write(CPUMBState *env, uint32_t ext, uint32_t rn, uint32_t v)mmu_write (env, ext, rn, v); } -void mb_cpu_unassigned_access (CPUState *cs,hwaddr addr, -bool is_write,bool is_exec,int is_asi, -unsigned size) +void mb_cpu_transaction_failed (CPUState *cs,hwaddr physaddr,vaddr addr, +unsigned size,MMUAccessType access_type, +int mmu_idx,MemTxAttrs attrs, +MemTxResult response,uintptr_t retaddr) {MicroBlazeCPU *cpu;CPUMBState *env; - -qemu_log_mask (CPU_LOG_INT ,"Unassigned " TARGET_FMT_plx" wr=%d exe=%d\n" , - addr, is_write ?1 :0 , is_exec ?1 :0 ); -if (cs ==NULL ) { -return ;
Quoted 8 lines
target/microblaze/op_helper.c void helper_mmu_write(CPUMBState *env, uint32_t ext, uint32_t rn, uint32_t v) · line 502
Quoted 8 lines
target/microblaze/op_helper.c +5
-1- } +qemu_log_mask (CPU_LOG_INT ,"Transaction failed: vaddr 0x%" VADDR_PRIx +" physaddr 0x" TARGET_FMT_plx"size %d access type %s\n" , + addr, physaddr, size, + access_type ==MMU_INST_FETCH ?"INST_FETCH" : + (access_type ==MMU_DATA_LOAD ?"DATA_LOAD" :"DATA_STORE" )); cpu =MICROBLAZE_CPU (cs); env = &cpu->env;
Oops. Here there should be
cpu_restore_state(cs, retaddr, true);
Quoted 4 lines
Quoted 4 lines
target/microblaze/op_helper.c +0
-0if (!(env->sregs[SR_MSR ] &MSR_EE )) {@@ -505,7 +505,7 @@ void mb_cpu_unassigned_access(CPUState *cs, hwaddr addr, }
Quoted 8 lines
Quoted 8 lines
target/microblaze/op_helper.c +1
-2env->sregs[SR_EAR ] = addr; -if (is_exec) { +if (access_type ==MMU_INST_FETCH ) {if ((env->pvr.regs[2 ] &PVR2_IOPB_BUS_EXC_MASK )) { env->sregs[SR_ESR ] =ESR_EC_INSN_BUS ;helper_raise_exception (env,EXCP_HW_EXCP ); --2.19.2
thanks
-- PMM
Quoted 7 lines · Peter Maydell
Quoted 6 lines · Peter Maydell
Quoted 4 lines · Peter Maydell
Switch the microblaze target from the old
unassigned_accesshook to thetransaction_failedhook.
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
The notable difference is that rather than it being called for all physical memory accesses which fail (including those made by DMA devices or by the gdbstub), it is only called for those made by the CPU via its MMU. For microblaze this makes no difference because none of the target CPU code needs to make loads or stores by physical address.
Thanks Peter, this looks good.
Actually, upstream QEMU is lacking the necessary CPU cfg properties to enable CPU exceptions for transaction errors. I'll post patches to add those. On boards without those props enabled, the logging happens but the error gets ignored by the core.
Cheers,
Edgar
Quoted 93 lines
Quoted 65 lines
Quoted 65 lines
Signed-off-by Peter Maydell <[email protected]>---
A straightforward conversion, but tagged RFC because I don't have any microblaze test images and have tested only with "make check".target/microblaze/cpu.h | 7 ++++--- target/microblaze/cpu.c | 2 +- target/microblaze/op_helper.c | 20 ++++++++++---------- 3 files changed, 15 insertions(+), 14 deletions(-)target/microblaze/cpu.h +4
-3@@ -388,9 +388,10 @@ static inline void cpu_get_tb_cpu_state(CPUMBState *env, target_ulong *pc, }#if !defined(CONFIG_USER_ONLY ) -void mb_cpu_unassigned_access (CPUState *cpu,hwaddr addr, -bool is_write,bool is_exec,int is_asi, -unsigned size); +void mb_cpu_transaction_failed (CPUState *cs,hwaddr physaddr,vaddr addr, +unsigned size,MMUAccessType access_type, +int mmu_idx,MemTxAttrs attrs, +MemTxResult response,uintptr_t retaddr);#endif #endif target/microblaze/cpu.c +1
-1@@ -297,7 +297,7 @@ static void mb_cpu_class_init(ObjectClass *oc, void *data)#ifdef CONFIG_USER_ONLY cc->handle_mmu_fault = mb_cpu_handle_mmu_fault;#else - cc->do_unassigned_access = mb_cpu_unassigned_access; + cc->do_transaction_failed = mb_cpu_transaction_failed; cc->get_phys_page_debug = mb_cpu_get_phys_page_debug;#endif dc->vmsd = &vmstate_mb_cpu;target/microblaze/op_helper.c +4
-8@@ -486,18 +486,18 @@ void helper_mmu_write(CPUMBState *env, uint32_t ext, uint32_t rn, uint32_t v)mmu_write (env, ext, rn, v); } -void mb_cpu_unassigned_access (CPUState *cs,hwaddr addr, -bool is_write,bool is_exec,int is_asi, -unsigned size) +void mb_cpu_transaction_failed (CPUState *cs,hwaddr physaddr,vaddr addr, +unsigned size,MMUAccessType access_type, +int mmu_idx,MemTxAttrs attrs, +MemTxResult response,uintptr_t retaddr) {MicroBlazeCPU *cpu;CPUMBState *env; - -qemu_log_mask (CPU_LOG_INT ,"Unassigned " TARGET_FMT_plx" wr=%d exe=%d\n" , - addr, is_write ?1 :0 , is_exec ?1 :0 ); -if (cs ==NULL ) { -return ;Quoted 8 lines
target/microblaze/op_helper.c void helper_mmu_write(CPUMBState *env, uint32_t ext, uint32_t rn, uint32_t v) · line 502
Quoted 8 lines
target/microblaze/op_helper.c +5
-1- } +qemu_log_mask (CPU_LOG_INT ,"Transaction failed: vaddr 0x%" VADDR_PRIx +" physaddr 0x" TARGET_FMT_plx"size %d access type %s\n" , + addr, physaddr, size, + access_type ==MMU_INST_FETCH ?"INST_FETCH" : + (access_type ==MMU_DATA_LOAD ?"DATA_LOAD" :"DATA_STORE" )); cpu =MICROBLAZE_CPU (cs); env = &cpu->env;Oops. Here there should be
cpu_restore_state(cs, retaddr, true);Quoted 4 lines
Quoted 4 lines
target/microblaze/op_helper.c +0
-0if (!(env->sregs[SR_MSR ] &MSR_EE )) {@@ -505,7 +505,7 @@ void mb_cpu_unassigned_access(CPUState *cs, hwaddr addr, }Quoted 8 lines
Quoted 8 lines
target/microblaze/op_helper.c +1
-2env->sregs[SR_EAR ] = addr; -if (is_exec) { +if (access_type ==MMU_INST_FETCH ) {if ((env->pvr.regs[2 ] &PVR2_IOPB_BUS_EXC_MASK )) { env->sregs[SR_ESR ] =ESR_EC_INSN_BUS ;helper_raise_exception (env,EXCP_HW_EXCP ); --2.19.2
thanks
-- PMM
Quoted 7 lines · Peter Maydell
Quoted 6 lines · Peter Maydell
Quoted 4 lines · Peter Maydell
Switch the microblaze target from the old
unassigned_accesshook to thetransaction_failedhook.
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
The notable difference is that rather than it being called for all physical memory accesses which fail (including those made by DMA devices or by the gdbstub), it is only called for those made by the CPU via its MMU. For microblaze this makes no difference because none of the target CPU code needs to make loads or stores by physical address.
Hi again,
I just noticed a small typo
Quoted 60 lines
Quoted 60 lines
Quoted 60 lines
Signed-off-by Peter Maydell <[email protected]>---
A straightforward conversion, but tagged RFC because I don't have any microblaze test images and have tested only with "make check".target/microblaze/cpu.h | 7 ++++--- target/microblaze/cpu.c | 2 +- target/microblaze/op_helper.c | 20 ++++++++++---------- 3 files changed, 15 insertions(+), 14 deletions(-)target/microblaze/cpu.h +4
-3@@ -388,9 +388,10 @@ static inline void cpu_get_tb_cpu_state(CPUMBState *env, target_ulong *pc, }#if !defined(CONFIG_USER_ONLY ) -void mb_cpu_unassigned_access (CPUState *cpu,hwaddr addr, -bool is_write,bool is_exec,int is_asi, -unsigned size); +void mb_cpu_transaction_failed (CPUState *cs,hwaddr physaddr,vaddr addr, +unsigned size,MMUAccessType access_type, +int mmu_idx,MemTxAttrs attrs, +MemTxResult response,uintptr_t retaddr);#endif #endif target/microblaze/cpu.c +1
-1@@ -297,7 +297,7 @@ static void mb_cpu_class_init(ObjectClass *oc, void *data)#ifdef CONFIG_USER_ONLY cc->handle_mmu_fault = mb_cpu_handle_mmu_fault;#else - cc->do_unassigned_access = mb_cpu_unassigned_access; + cc->do_transaction_failed = mb_cpu_transaction_failed; cc->get_phys_page_debug = mb_cpu_get_phys_page_debug;#endif dc->vmsd = &vmstate_mb_cpu;target/microblaze/op_helper.c +4
-3@@ -486,18 +486,18 @@ void helper_mmu_write(CPUMBState *env, uint32_t ext, uint32_t rn, uint32_t v)mmu_write (env, ext, rn, v); } -void mb_cpu_unassigned_access (CPUState *cs,hwaddr addr, -bool is_write,bool is_exec,int is_asi, -unsigned size) +void mb_cpu_transaction_failed (CPUState *cs,hwaddr physaddr,vaddr addr, +unsigned size,MMUAccessType access_type, +int mmu_idx,MemTxAttrs attrs, +MemTxResult response,uintptr_t retaddr) {MicroBlazeCPU *cpu;CPUMBState *env;
Quoted 8 lines
Quoted 8 lines
target/microblaze/op_helper.c void helper_mmu_write(CPUMBState *env, uint32_t ext, uint32_t rn, uint32_t v) · line 497
Quoted 8 lines
target/microblaze/op_helper.c +2
-6- -qemu_log_mask (CPU_LOG_INT ,"Unassigned " TARGET_FMT_plx" wr=%d exe=%d\n" , - addr, is_write ?1 :0 , is_exec ?1 :0 ); -if (cs ==NULL ) { -return ; - } + qemu_log_mask(CPU_LOG_INT, "Transaction failed: vaddr 0x%" VADDR_PRIx + " physaddr 0x" TARGET_FMT_plx "size %d access type %s\n",
^^^
We'd want a space before size here.
Cheers,
Edgar
Quoted 25 lines
Quoted 5 lines
target/microblaze/op_helper.c void helper_mmu_write(CPUMBState *env, uint32_t ext, uint32_t rn, uint32_t v) · line 502
Quoted 5 lines
target/microblaze/op_helper.c +3
-0+ addr, physaddr, size, + access_type ==MMU_INST_FETCH ?"INST_FETCH" : + (access_type == MMU_DATA_LOAD ? "DATA_LOAD" : "DATA_STORE")); cpu =MICROBLAZE_CPU (cs); env = &cpu->env;Oops. Here there should be
cpu_restore_state(cs, retaddr, true);Quoted 4 lines
Quoted 4 lines
target/microblaze/op_helper.c +0
-0if (!(env->sregs[SR_MSR ] &MSR_EE )) {@@ -505,7 +505,7 @@ void mb_cpu_unassigned_access(CPUState *cs, hwaddr addr, }Quoted 8 lines
Quoted 8 lines
target/microblaze/op_helper.c +1
-2env->sregs[SR_EAR ] = addr; -if (is_exec) { +if (access_type ==MMU_INST_FETCH ) {if ((env->pvr.regs[2 ] &PVR2_IOPB_BUS_EXC_MASK )) { env->sregs[SR_ESR ] =ESR_EC_INSN_BUS ;helper_raise_exception (env,EXCP_HW_EXCP ); --2.19.2
thanks
-- PMM