Patchwork target-xtensa: raise an exception for invalid and reserved opcodes

login
register
mail settings
Submitter Max Filippov
Date Oct. 25, 2011, 4:44 p.m.
Message ID <1319561060-6472-1-git-send-email-jcmvbkbc@gmail.com>
Download mbox | patch
Permalink /patch/121748/
State New
Headers show

Comments

Max Filippov - Oct. 25, 2011, 4:44 p.m.
This includes opcodes from disabled features and those marked reserved in the ISA.

Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
---
 target-xtensa/translate.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
Peter Maydell - Oct. 25, 2011, 4:51 p.m.
On 25 October 2011 17:44, Max Filippov <jcmvbkbc@gmail.com> wrote:
> This includes opcodes from disabled features and those marked reserved in the ISA.
>
> Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
> ---
>  target-xtensa/translate.c |    1 +
>  1 files changed, 1 insertions(+), 0 deletions(-)
>
> diff --git a/target-xtensa/translate.c b/target-xtensa/translate.c
> index 1688bb2..792eff1 100644
> --- a/target-xtensa/translate.c
> +++ b/target-xtensa/translate.c
> @@ -2378,6 +2378,7 @@ static void disas_xtensa_insn(DisasContext *dc)
>
>  invalid_opcode:
>     qemu_log("INVALID(pc = %08x)\n", dc->pc);
> +    gen_exception_cause(dc, ILLEGAL_INSTRUCTION_CAUSE);
>     dc->pc = dc->next_pc;
>  #undef HAS_OPTION
>  }

Don't you need to do something to end the TB as well?
gen_exception_cause() doesn't seem to do it for you.

-- PMM
Max Filippov - Oct. 25, 2011, 5:24 p.m.
> > This includes opcodes from disabled features and those marked reserved in the ISA.
> >
> > Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
> > ---
> >  target-xtensa/translate.c |    1 +
> >  1 files changed, 1 insertions(+), 0 deletions(-)
> >
> > diff --git a/target-xtensa/translate.c b/target-xtensa/translate.c
> > index 1688bb2..792eff1 100644
> > --- a/target-xtensa/translate.c
> > +++ b/target-xtensa/translate.c
> > @@ -2378,6 +2378,7 @@ static void disas_xtensa_insn(DisasContext *dc)
> >
> >  invalid_opcode:
> >     qemu_log("INVALID(pc = %08x)\n", dc->pc);
> > +    gen_exception_cause(dc, ILLEGAL_INSTRUCTION_CAUSE);
> >     dc->pc = dc->next_pc;
> >  #undef HAS_OPTION
> >  }
> 
> Don't you need to do something to end the TB as well?
> gen_exception_cause() doesn't seem to do it for you.

Do you mean that I have to end the TB on every instruction that will definitely raise an exception?
Or on every instruction that potentially raises an exception?
I didn't do any of the above anywhere.

Thanks.
-- Max
Richard Henderson - Oct. 25, 2011, 5:41 p.m.
On 10/25/2011 10:24 AM, Max Filippov wrote:
> Do you mean that I have to end the TB on every instruction that will definitely raise an exception?
> Or on every instruction that potentially raises an exception?
> I didn't do any of the above anywhere.

Normally we do end the TB on every instruction that will definitely
raise an exception.  There's little point to continue translation,
since we know for a fact that control will transfer out of the cpu loop.


r~

Patch

diff --git a/target-xtensa/translate.c b/target-xtensa/translate.c
index 1688bb2..792eff1 100644
--- a/target-xtensa/translate.c
+++ b/target-xtensa/translate.c
@@ -2378,6 +2378,7 @@  static void disas_xtensa_insn(DisasContext *dc)
 
 invalid_opcode:
     qemu_log("INVALID(pc = %08x)\n", dc->pc);
+    gen_exception_cause(dc, ILLEGAL_INSTRUCTION_CAUSE);
     dc->pc = dc->next_pc;
 #undef HAS_OPTION
 }