target/ppc: Fix BookE debug interrupt generation
PATCH v2 1/1 target/ppc: Fix BookE debug interrupt generation
From: Bin Meng <[email protected]>
Per E500 core reference manual [1], chapter 8.4.4 "Branch Taken Debug Event" and chapter 8.4.5 "Instruction Complete Debug Event":
"A branch taken debug event occurs if both MSR[DE] and DBCR0[BRT] are set ... Branch taken debug events are not recognized if MSR[DE] is cleared when the branch instruction executes."
"An instruction complete debug event occurs when any instruction completes execution so long as MSR[DE] and DBCR0[ICMP] are both set ... Instruction complete debug events are not recognized if MSR[DE] is cleared at the time of the instruction execution."
Current codes do not check MSR.DE bit before setting HFLAGS_SE and HFLAGS_BE flag, which would cause the immediate debug interrupt to be generated, e.g.: when DBCR0.ICMP bit is set by guest software and MSR.DE is not set.
[1] https://www.nxp.com/docs/en/reference-manual/E500CORERM.pdf
---
Changes in v2:
- update commit message to use E500CORERM instead of PowerISA 2.07
target/ppc/helper_regs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
target/ppc/helper_regs.c +2 -2
@@ -63,10 +63,10 @@ static uint32_t hreg_compute_hflags_value(CPUPPCState *env)if (ppc_flags &POWERPC_FLAG_DE ) {target_ulong dbcr0 = env->spr[SPR_BOOKE_DBCR0 ]; -if (dbcr0 &DBCR0_ICMP ) { +if ((dbcr0 &DBCR0_ICMP ) && msr_de) { hflags |=1 <<HFLAGS_SE ; } -if (dbcr0 &DBCR0_BRT ) { +if ((dbcr0 &DBCR0_BRT ) && msr_de) { hflags |=1 <<HFLAGS_BE ; } }else {
Signature · 1 line
2.25.1
Quoted 14 lines · Bin Meng
From: Bin Meng <[email protected]>
Per E500 core reference manual [1], chapter 8.4.4 "Branch Taken Debug Event" and chapter 8.4.5 "Instruction Complete Debug Event":
"A branch taken debug event occurs if both MSR[DE] and DBCR0[BRT] are set ... Branch taken debug events are not recognized if MSR[DE] is cleared when the branch instruction executes."
"An instruction complete debug event occurs when any instruction completes execution so long as MSR[DE] and DBCR0[ICMP] are both set ... Instruction complete debug events are not recognized if MSR[DE] is cleared at the time of the instruction execution."
Quoted 8 lines
Current codes do not check MSR.DE bit before setting
HFLAGS_SEandHFLAGS_BEflag, which would cause the immediate debug interrupt to be generated, e.g.: when DBCR0.ICMP bit is set by guest software and MSR.DE is not set.[1] https://www.nxp.com/docs/en/reference-manual/E500CORERM.pdf
Signed-off-by Bin Meng <[email protected]>
Thanks,
C.
Quoted 25 lines
---
Changes in v2:
- update commit message to use E500CORERM instead of PowerISA 2.07target/ppc/helper_regs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)target/ppc/helper_regs.c +2
-2@@ -63,10 +63,10 @@ static uint32_t hreg_compute_hflags_value(CPUPPCState *env)if (ppc_flags &POWERPC_FLAG_DE ) {target_ulong dbcr0 = env->spr[SPR_BOOKE_DBCR0 ]; -if (dbcr0 &DBCR0_ICMP ) { +if ((dbcr0 &DBCR0_ICMP ) && msr_de) { hflags |=1 <<HFLAGS_SE ; } -if (dbcr0 &DBCR0_BRT ) { +if ((dbcr0 &DBCR0_BRT ) && msr_de) { hflags |=1 <<HFLAGS_BE ; } }else {
Quoted 14 lines · Bin Meng
From: Bin Meng <[email protected]>
Per E500 core reference manual [1], chapter 8.4.4 "Branch Taken Debug Event" and chapter 8.4.5 "Instruction Complete Debug Event":
"A branch taken debug event occurs if both MSR[DE] and DBCR0[BRT] are set ... Branch taken debug events are not recognized if MSR[DE] is cleared when the branch instruction executes."
"An instruction complete debug event occurs when any instruction completes execution so long as MSR[DE] and DBCR0[ICMP] are both set ... Instruction complete debug events are not recognized if MSR[DE] is cleared at the time of the instruction execution."
Quoted 8 lines
Current codes do not check MSR.DE bit before setting
HFLAGS_SEandHFLAGS_BEflag, which would cause the immediate debug interrupt to be generated, e.g.: when DBCR0.ICMP bit is set by guest software and MSR.DE is not set.[1] https://www.nxp.com/docs/en/reference-manual/E500CORERM.pdf
Signed-off-by Bin Meng <[email protected]>
Quoted 35 lines · Bin Meng
From: Bin Meng<[email protected]>
Per E500 core reference manual [1], chapter 8.4.4 "Branch Taken Debug Event" and chapter 8.4.5 "Instruction Complete Debug Event":
"A branch taken debug event occurs if both MSR[DE] and DBCR0[BRT] are set ... Branch taken debug events are not recognized if MSR[DE] is cleared when the branch instruction executes."
"An instruction complete debug event occurs when any instruction completes execution so long as MSR[DE] and DBCR0[ICMP] are both set ... Instruction complete debug events are not recognized if MSR[DE] is cleared at the time of the instruction execution."
Current codes do not check MSR.DE bit before setting
HFLAGS_SEandHFLAGS_BEflag, which would cause the immediate debug interrupt to be generated, e.g.: when DBCR0.ICMP bit is set by guest software and MSR.DE is not set.[1]https://www.nxp.com/docs/en/reference-manual/E500CORERM.pdf
Signed-off-by Bin Meng<[email protected]>---
Changes in v2:
- update commit message to use E500CORERM instead of PowerISA 2.07target/ppc/helper_regs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)target/ppc/helper_regs.c +0
-0
target/ppc/helper_regs.c static uint32_t hreg_compute_hflags_value(CPUPPCState *env) · line 66
Quoted 5 lines
target/ppc/helper_regs.c +1
-1@@ -63,10 +63,10 @@ static uint32_t hreg_compute_hflags_value(CPUPPCState *env)if (ppc_flags &POWERPC_FLAG_DE ) {target_ulong dbcr0 = env->spr[SPR_BOOKE_DBCR0 ]; -if (dbcr0 &DBCR0_ICMP ) { +if ((dbcr0 &DBCR0_ICMP ) && msr_de) {
There was a discussion some time ago that was better to avoid hidden uses of *env, so it may be better to change msr_de to ((env->msr >> MSR_DE) & 1) or to (env->msr & BIT_ULL(MSR_DE))
target/ppc/helper_regs.c static uint32_t hreg_compute_hflags_value(CPUPPCState *env) · line 69
Quoted 4 lines
target/ppc/helper_regs.c +1
-1hflags |=1 <<HFLAGS_SE ; } -if (dbcr0 &DBCR0_BRT ) { +if ((dbcr0 &DBCR0_BRT ) && msr_de) {
Here as well
Quoted 7 lines
target/ppc/helper_regs.c +0
-1hflags |=1 <<HFLAGS_BE ; } }else { --2.25.1
Apart from that,
Signature · 5 lines
Lucas Mateus M. Araujo e Castro Instituto de Pesquisas ELDORADO <https://www.eldorado.org.br/?utm_campaign=assinatura_de_e-mail&utm_medium=email&utm_source=RD+Station> Departamento Computação Embarcada Analista de Software Trainee Aviso Legal - Disclaimer <https://www.eldorado.org.br/disclaimer.html>
Quoted 38 lines · Lucas Mateus Martins Araujo e Castro
Quoted 36 lines · Bin Meng
From: Bin Meng<[email protected]>
Per E500 core reference manual [1], chapter 8.4.4 "Branch Taken Debug Event" and chapter 8.4.5 "Instruction Complete Debug Event":
"A branch taken debug event occurs if both MSR[DE] and DBCR0[BRT] are set ... Branch taken debug events are not recognized if MSR[DE] is cleared when the branch instruction executes."
"An instruction complete debug event occurs when any instruction completes execution so long as MSR[DE] and DBCR0[ICMP] are both set ... Instruction complete debug events are not recognized if MSR[DE] is cleared at the time of the instruction execution."
Current codes do not check MSR.DE bit before setting
HFLAGS_SEandHFLAGS_BEflag, which would cause the immediate debug interrupt to be generated, e.g.: when DBCR0.ICMP bit is set by guest software and MSR.DE is not set.[1]https://www.nxp.com/docs/en/reference-manual/E500CORERM.pdf
Signed-off-by Bin Meng<[email protected]>---
Changes in v2:
- update commit message to use E500CORERM instead of PowerISA 2.07target/ppc/helper_regs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)target/ppc/helper_regs.c +0
-0@@ -63,10 +63,10 @@ static uint32_t hreg_compute_hflags_value(CPUPPCState *env)
Quoted 5 lines
target/ppc/helper_regs.c static uint32_t hreg_compute_hflags_value(CPUPPCState *env) · line 66
Quoted 4 lines
target/ppc/helper_regs.c +1
-1if (ppc_flags &POWERPC_FLAG_DE ) {target_ulong dbcr0 = env->spr[SPR_BOOKE_DBCR0 ]; -if (dbcr0 &DBCR0_ICMP ) { +if ((dbcr0 &DBCR0_ICMP ) && msr_de) {There was a discussion some time ago that was better to avoid hidden uses of *env, so it may be better to change
msr_deto ((env->msr>>MSR_DE) & 1) or to (env->msr&BIT_ULL(MSR_DE))
I think the "target/ppc: Remove hidden usages of *env" patchset :
https://patchwork.ozlabs.org/project/qemu-ppc/list/?series=296440
will take some time to merge and there will certainly be followups.
This patch can go first.
Thanks,
C.
Quoted 20 lines
target/ppc/helper_regs.c static uint32_t hreg_compute_hflags_value(CPUPPCState *env) · line 69
Quoted 4 lines
target/ppc/helper_regs.c +1
-1hflags |=1 <<HFLAGS_SE ; } -if (dbcr0 &DBCR0_BRT ) { +if ((dbcr0 &DBCR0_BRT ) && msr_de) {Here as well
Quoted 7 lines
target/ppc/helper_regs.c +0
-1hflags |=1 <<HFLAGS_BE ; } }else { --2.25.1
Apart from that,
Reviewed-by Lucas Mateus Castro <[email protected]>Signature · 5 lines
Lucas Mateus M. Araujo e Castro Instituto de Pesquisas ELDORADO <https://www.eldorado.org.br/?utm_campaign=assinatura_de_e-mail&utm_medium=email&utm_source=RD+Station> Departamento Computação Embarcada Analista de Software Trainee Aviso Legal - Disclaimer <https://www.eldorado.org.br/disclaimer.html>
Daniel Henrique Barboza
AppliedQueued in gitlab.com/danielhb/qemu/tree/ppc-next. Thanks,
Daniel
Quoted 47 lines · Bin Meng
From: Bin Meng <[email protected]>
Per E500 core reference manual [1], chapter 8.4.4 "Branch Taken Debug Event" and chapter 8.4.5 "Instruction Complete Debug Event":
"A branch taken debug event occurs if both MSR[DE] and DBCR0[BRT] are set ... Branch taken debug events are not recognized if MSR[DE] is cleared when the branch instruction executes."
"An instruction complete debug event occurs when any instruction completes execution so long as MSR[DE] and DBCR0[ICMP] are both set ... Instruction complete debug events are not recognized if MSR[DE] is cleared at the time of the instruction execution."
Current codes do not check MSR.DE bit before setting
HFLAGS_SEandHFLAGS_BEflag, which would cause the immediate debug interrupt to be generated, e.g.: when DBCR0.ICMP bit is set by guest software and MSR.DE is not set.[1] https://www.nxp.com/docs/en/reference-manual/E500CORERM.pdf
Signed-off-by Bin Meng <[email protected]>---
Changes in v2:
- update commit message to use E500CORERM instead of PowerISA 2.07target/ppc/helper_regs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)target/ppc/helper_regs.c +2
-2@@ -63,10 +63,10 @@ static uint32_t hreg_compute_hflags_value(CPUPPCState *env)if (ppc_flags &POWERPC_FLAG_DE ) {target_ulong dbcr0 = env->spr[SPR_BOOKE_DBCR0 ]; -if (dbcr0 &DBCR0_ICMP ) { +if ((dbcr0 &DBCR0_ICMP ) && msr_de) { hflags |=1 <<HFLAGS_SE ; } -if (dbcr0 &DBCR0_BRT ) { +if ((dbcr0 &DBCR0_BRT ) && msr_de) { hflags |=1 <<HFLAGS_BE ; } }else {