* [Qemu-devel] [PATCH][SPARC] Fix handling of conditional branches in delay slot of a conditional branch @ 2011-08-06 15:01 Artyom Tarasenko 2011-08-06 20:14 ` Blue Swirl 0 siblings, 1 reply; 4+ messages in thread From: Artyom Tarasenko @ 2011-08-06 15:01 UTC (permalink / raw) To: qemu-devel; +Cc: blauwirbel, Artyom Tarasenko Check whether dc->npc is dynamic before using its value for branch. Signed-off-by: Artyom Tarasenko <atar4qemu@gmail.com> --- Particaluary the patch fixes handling of the constructions like 0x13e26c0: brz,pn %o0, 0x13e26e4 0x13e26c4: brlez,pn %o1, 0x13e26e4 present in NetBSD-5.1 target-sparc/translate.c | 30 +++++++++++++++++++++--------- 1 files changed, 21 insertions(+), 9 deletions(-) diff --git a/target-sparc/translate.c b/target-sparc/translate.c index 958fbc5..dee67b3 100644 --- a/target-sparc/translate.c +++ b/target-sparc/translate.c @@ -1286,7 +1286,6 @@ static inline void gen_cond_reg(TCGv r_dst, int cond, TCGv r_src) } #endif -/* XXX: potentially incorrect if dynamic npc */ static void do_branch(DisasContext *dc, int32_t offset, uint32_t insn, int cc, TCGv r_cond) { @@ -1321,13 +1320,17 @@ static void do_branch(DisasContext *dc, int32_t offset, uint32_t insn, int cc, } else { dc->pc = dc->npc; dc->jump_pc[0] = target; - dc->jump_pc[1] = dc->npc + 4; - dc->npc = JUMP_PC; + if (unlikely(dc->npc == DYNAMIC_PC)) { + dc->jump_pc[1] = DYNAMIC_PC; + tcg_gen_addi_tl(cpu_pc, cpu_npc, 4); + } else { + dc->jump_pc[1] = dc->npc + 4; + dc->npc = JUMP_PC; + } } } } -/* XXX: potentially incorrect if dynamic npc */ static void do_fbranch(DisasContext *dc, int32_t offset, uint32_t insn, int cc, TCGv r_cond) { @@ -1362,14 +1365,18 @@ static void do_fbranch(DisasContext *dc, int32_t offset, uint32_t insn, int cc, } else { dc->pc = dc->npc; dc->jump_pc[0] = target; - dc->jump_pc[1] = dc->npc + 4; - dc->npc = JUMP_PC; + if (unlikely(dc->npc == DYNAMIC_PC)) { + dc->jump_pc[1] = DYNAMIC_PC; + tcg_gen_addi_tl(cpu_pc, cpu_npc, 4); + } else { + dc->jump_pc[1] = dc->npc + 4; + dc->npc = JUMP_PC; + } } } } #ifdef TARGET_SPARC64 -/* XXX: potentially incorrect if dynamic npc */ static void do_branch_reg(DisasContext *dc, int32_t offset, uint32_t insn, TCGv r_cond, TCGv r_reg) { @@ -1384,8 +1391,13 @@ static void do_branch_reg(DisasContext *dc, int32_t offset, uint32_t insn, } else { dc->pc = dc->npc; dc->jump_pc[0] = target; - dc->jump_pc[1] = dc->npc + 4; - dc->npc = JUMP_PC; + if (unlikely(dc->npc == DYNAMIC_PC)) { + dc->jump_pc[1] = DYNAMIC_PC; + tcg_gen_addi_tl(cpu_pc, cpu_npc, 4); + } else { + dc->jump_pc[1] = dc->npc + 4; + dc->npc = JUMP_PC; + } } } -- 1.7.3.4 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH][SPARC] Fix handling of conditional branches in delay slot of a conditional branch 2011-08-06 15:01 [Qemu-devel] [PATCH][SPARC] Fix handling of conditional branches in delay slot of a conditional branch Artyom Tarasenko @ 2011-08-06 20:14 ` Blue Swirl 2011-08-06 21:33 ` Artyom Tarasenko 0 siblings, 1 reply; 4+ messages in thread From: Blue Swirl @ 2011-08-06 20:14 UTC (permalink / raw) To: Artyom Tarasenko; +Cc: qemu-devel Thanks, applied. On Sat, Aug 6, 2011 at 3:01 PM, Artyom Tarasenko <atar4qemu@gmail.com> wrote: > Check whether dc->npc is dynamic before using its value for branch. > > Signed-off-by: Artyom Tarasenko <atar4qemu@gmail.com> > --- > Particaluary the patch fixes handling of the constructions like > > 0x13e26c0: brz,pn %o0, 0x13e26e4 > 0x13e26c4: brlez,pn %o1, 0x13e26e4 > > present in NetBSD-5.1 > > target-sparc/translate.c | 30 +++++++++++++++++++++--------- > 1 files changed, 21 insertions(+), 9 deletions(-) > > diff --git a/target-sparc/translate.c b/target-sparc/translate.c > index 958fbc5..dee67b3 100644 > --- a/target-sparc/translate.c > +++ b/target-sparc/translate.c > @@ -1286,7 +1286,6 @@ static inline void gen_cond_reg(TCGv r_dst, int cond, TCGv r_src) > } > #endif > > -/* XXX: potentially incorrect if dynamic npc */ > static void do_branch(DisasContext *dc, int32_t offset, uint32_t insn, int cc, > TCGv r_cond) > { > @@ -1321,13 +1320,17 @@ static void do_branch(DisasContext *dc, int32_t offset, uint32_t insn, int cc, > } else { > dc->pc = dc->npc; > dc->jump_pc[0] = target; > - dc->jump_pc[1] = dc->npc + 4; > - dc->npc = JUMP_PC; > + if (unlikely(dc->npc == DYNAMIC_PC)) { > + dc->jump_pc[1] = DYNAMIC_PC; > + tcg_gen_addi_tl(cpu_pc, cpu_npc, 4); > + } else { > + dc->jump_pc[1] = dc->npc + 4; > + dc->npc = JUMP_PC; > + } > } > } > } > > -/* XXX: potentially incorrect if dynamic npc */ > static void do_fbranch(DisasContext *dc, int32_t offset, uint32_t insn, int cc, > TCGv r_cond) > { > @@ -1362,14 +1365,18 @@ static void do_fbranch(DisasContext *dc, int32_t offset, uint32_t insn, int cc, > } else { > dc->pc = dc->npc; > dc->jump_pc[0] = target; > - dc->jump_pc[1] = dc->npc + 4; > - dc->npc = JUMP_PC; > + if (unlikely(dc->npc == DYNAMIC_PC)) { > + dc->jump_pc[1] = DYNAMIC_PC; > + tcg_gen_addi_tl(cpu_pc, cpu_npc, 4); > + } else { > + dc->jump_pc[1] = dc->npc + 4; > + dc->npc = JUMP_PC; > + } > } > } > } > > #ifdef TARGET_SPARC64 > -/* XXX: potentially incorrect if dynamic npc */ > static void do_branch_reg(DisasContext *dc, int32_t offset, uint32_t insn, > TCGv r_cond, TCGv r_reg) > { > @@ -1384,8 +1391,13 @@ static void do_branch_reg(DisasContext *dc, int32_t offset, uint32_t insn, > } else { > dc->pc = dc->npc; > dc->jump_pc[0] = target; > - dc->jump_pc[1] = dc->npc + 4; > - dc->npc = JUMP_PC; > + if (unlikely(dc->npc == DYNAMIC_PC)) { > + dc->jump_pc[1] = DYNAMIC_PC; > + tcg_gen_addi_tl(cpu_pc, cpu_npc, 4); > + } else { > + dc->jump_pc[1] = dc->npc + 4; > + dc->npc = JUMP_PC; > + } > } > } > > -- > 1.7.3.4 > > ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH][SPARC] Fix handling of conditional branches in delay slot of a conditional branch 2011-08-06 20:14 ` Blue Swirl @ 2011-08-06 21:33 ` Artyom Tarasenko 2011-08-07 9:25 ` Blue Swirl 0 siblings, 1 reply; 4+ messages in thread From: Artyom Tarasenko @ 2011-08-06 21:33 UTC (permalink / raw) To: Blue Swirl; +Cc: qemu-devel Since it's a pure bug fix, do you think can it be applied to 0.15 as well? On Sat, Aug 6, 2011 at 10:14 PM, Blue Swirl <blauwirbel@gmail.com> wrote: > Thanks, applied. > > On Sat, Aug 6, 2011 at 3:01 PM, Artyom Tarasenko <atar4qemu@gmail.com> wrote: >> Check whether dc->npc is dynamic before using its value for branch. >> >> Signed-off-by: Artyom Tarasenko <atar4qemu@gmail.com> >> --- >> Particaluary the patch fixes handling of the constructions like >> >> 0x13e26c0: brz,pn %o0, 0x13e26e4 >> 0x13e26c4: brlez,pn %o1, 0x13e26e4 >> >> present in NetBSD-5.1 >> >> target-sparc/translate.c | 30 +++++++++++++++++++++--------- >> 1 files changed, 21 insertions(+), 9 deletions(-) >> >> diff --git a/target-sparc/translate.c b/target-sparc/translate.c >> index 958fbc5..dee67b3 100644 >> --- a/target-sparc/translate.c >> +++ b/target-sparc/translate.c >> @@ -1286,7 +1286,6 @@ static inline void gen_cond_reg(TCGv r_dst, int cond, TCGv r_src) >> } >> #endif >> >> -/* XXX: potentially incorrect if dynamic npc */ >> static void do_branch(DisasContext *dc, int32_t offset, uint32_t insn, int cc, >> TCGv r_cond) >> { >> @@ -1321,13 +1320,17 @@ static void do_branch(DisasContext *dc, int32_t offset, uint32_t insn, int cc, >> } else { >> dc->pc = dc->npc; >> dc->jump_pc[0] = target; >> - dc->jump_pc[1] = dc->npc + 4; >> - dc->npc = JUMP_PC; >> + if (unlikely(dc->npc == DYNAMIC_PC)) { >> + dc->jump_pc[1] = DYNAMIC_PC; >> + tcg_gen_addi_tl(cpu_pc, cpu_npc, 4); >> + } else { >> + dc->jump_pc[1] = dc->npc + 4; >> + dc->npc = JUMP_PC; >> + } >> } >> } >> } >> >> -/* XXX: potentially incorrect if dynamic npc */ >> static void do_fbranch(DisasContext *dc, int32_t offset, uint32_t insn, int cc, >> TCGv r_cond) >> { >> @@ -1362,14 +1365,18 @@ static void do_fbranch(DisasContext *dc, int32_t offset, uint32_t insn, int cc, >> } else { >> dc->pc = dc->npc; >> dc->jump_pc[0] = target; >> - dc->jump_pc[1] = dc->npc + 4; >> - dc->npc = JUMP_PC; >> + if (unlikely(dc->npc == DYNAMIC_PC)) { >> + dc->jump_pc[1] = DYNAMIC_PC; >> + tcg_gen_addi_tl(cpu_pc, cpu_npc, 4); >> + } else { >> + dc->jump_pc[1] = dc->npc + 4; >> + dc->npc = JUMP_PC; >> + } >> } >> } >> } >> >> #ifdef TARGET_SPARC64 >> -/* XXX: potentially incorrect if dynamic npc */ >> static void do_branch_reg(DisasContext *dc, int32_t offset, uint32_t insn, >> TCGv r_cond, TCGv r_reg) >> { >> @@ -1384,8 +1391,13 @@ static void do_branch_reg(DisasContext *dc, int32_t offset, uint32_t insn, >> } else { >> dc->pc = dc->npc; >> dc->jump_pc[0] = target; >> - dc->jump_pc[1] = dc->npc + 4; >> - dc->npc = JUMP_PC; >> + if (unlikely(dc->npc == DYNAMIC_PC)) { >> + dc->jump_pc[1] = DYNAMIC_PC; >> + tcg_gen_addi_tl(cpu_pc, cpu_npc, 4); >> + } else { >> + dc->jump_pc[1] = dc->npc + 4; >> + dc->npc = JUMP_PC; >> + } >> } >> } >> >> -- >> 1.7.3.4 >> >> > -- Regards, Artyom Tarasenko solaris/sparc under qemu blog: http://tyom.blogspot.com/ ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH][SPARC] Fix handling of conditional branches in delay slot of a conditional branch 2011-08-06 21:33 ` Artyom Tarasenko @ 2011-08-07 9:25 ` Blue Swirl 0 siblings, 0 replies; 4+ messages in thread From: Blue Swirl @ 2011-08-07 9:25 UTC (permalink / raw) To: Artyom Tarasenko, Anthony Liguori, Jordan Justen; +Cc: qemu-devel On Sat, Aug 6, 2011 at 9:33 PM, Artyom Tarasenko <atar4qemu@gmail.com> wrote: > Since it's a pure bug fix, do you think can it be applied to 0.15 as well? Maybe. Anthony/Jordan, please consider applying these to stable: 548f66d Fix handling of conditional branches in delay slot of a conditional branch 6749432 Sparc: fix non-faulting unassigned memory accesses ccb57e0 SPARC64: fix fnor* and fnand* > On Sat, Aug 6, 2011 at 10:14 PM, Blue Swirl <blauwirbel@gmail.com> wrote: >> Thanks, applied. >> >> On Sat, Aug 6, 2011 at 3:01 PM, Artyom Tarasenko <atar4qemu@gmail.com> wrote: >>> Check whether dc->npc is dynamic before using its value for branch. >>> >>> Signed-off-by: Artyom Tarasenko <atar4qemu@gmail.com> >>> --- >>> Particaluary the patch fixes handling of the constructions like >>> >>> 0x13e26c0: brz,pn %o0, 0x13e26e4 >>> 0x13e26c4: brlez,pn %o1, 0x13e26e4 >>> >>> present in NetBSD-5.1 >>> >>> target-sparc/translate.c | 30 +++++++++++++++++++++--------- >>> 1 files changed, 21 insertions(+), 9 deletions(-) >>> >>> diff --git a/target-sparc/translate.c b/target-sparc/translate.c >>> index 958fbc5..dee67b3 100644 >>> --- a/target-sparc/translate.c >>> +++ b/target-sparc/translate.c >>> @@ -1286,7 +1286,6 @@ static inline void gen_cond_reg(TCGv r_dst, int cond, TCGv r_src) >>> } >>> #endif >>> >>> -/* XXX: potentially incorrect if dynamic npc */ >>> static void do_branch(DisasContext *dc, int32_t offset, uint32_t insn, int cc, >>> TCGv r_cond) >>> { >>> @@ -1321,13 +1320,17 @@ static void do_branch(DisasContext *dc, int32_t offset, uint32_t insn, int cc, >>> } else { >>> dc->pc = dc->npc; >>> dc->jump_pc[0] = target; >>> - dc->jump_pc[1] = dc->npc + 4; >>> - dc->npc = JUMP_PC; >>> + if (unlikely(dc->npc == DYNAMIC_PC)) { >>> + dc->jump_pc[1] = DYNAMIC_PC; >>> + tcg_gen_addi_tl(cpu_pc, cpu_npc, 4); >>> + } else { >>> + dc->jump_pc[1] = dc->npc + 4; >>> + dc->npc = JUMP_PC; >>> + } >>> } >>> } >>> } >>> >>> -/* XXX: potentially incorrect if dynamic npc */ >>> static void do_fbranch(DisasContext *dc, int32_t offset, uint32_t insn, int cc, >>> TCGv r_cond) >>> { >>> @@ -1362,14 +1365,18 @@ static void do_fbranch(DisasContext *dc, int32_t offset, uint32_t insn, int cc, >>> } else { >>> dc->pc = dc->npc; >>> dc->jump_pc[0] = target; >>> - dc->jump_pc[1] = dc->npc + 4; >>> - dc->npc = JUMP_PC; >>> + if (unlikely(dc->npc == DYNAMIC_PC)) { >>> + dc->jump_pc[1] = DYNAMIC_PC; >>> + tcg_gen_addi_tl(cpu_pc, cpu_npc, 4); >>> + } else { >>> + dc->jump_pc[1] = dc->npc + 4; >>> + dc->npc = JUMP_PC; >>> + } >>> } >>> } >>> } >>> >>> #ifdef TARGET_SPARC64 >>> -/* XXX: potentially incorrect if dynamic npc */ >>> static void do_branch_reg(DisasContext *dc, int32_t offset, uint32_t insn, >>> TCGv r_cond, TCGv r_reg) >>> { >>> @@ -1384,8 +1391,13 @@ static void do_branch_reg(DisasContext *dc, int32_t offset, uint32_t insn, >>> } else { >>> dc->pc = dc->npc; >>> dc->jump_pc[0] = target; >>> - dc->jump_pc[1] = dc->npc + 4; >>> - dc->npc = JUMP_PC; >>> + if (unlikely(dc->npc == DYNAMIC_PC)) { >>> + dc->jump_pc[1] = DYNAMIC_PC; >>> + tcg_gen_addi_tl(cpu_pc, cpu_npc, 4); >>> + } else { >>> + dc->jump_pc[1] = dc->npc + 4; >>> + dc->npc = JUMP_PC; >>> + } >>> } >>> } >>> >>> -- >>> 1.7.3.4 >>> >>> >> > > > > -- > Regards, > Artyom Tarasenko > > solaris/sparc under qemu blog: http://tyom.blogspot.com/ > ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2011-08-07 9:25 UTC | newest] Thread overview: 4+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2011-08-06 15:01 [Qemu-devel] [PATCH][SPARC] Fix handling of conditional branches in delay slot of a conditional branch Artyom Tarasenko 2011-08-06 20:14 ` Blue Swirl 2011-08-06 21:33 ` Artyom Tarasenko 2011-08-07 9:25 ` Blue Swirl
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).