diff mbox series

[v2,15/15] target/ppc: Check cpu flags for prefixed insn support

Message ID 20210427171649.364699-16-luis.pires@eldorado.org.br
State New
Headers show
Series Base for adding PowerPC 64-bit instructions | expand

Commit Message

Luis Fernando Fujita Pires April 27, 2021, 5:16 p.m. UTC
Prefixed instructions were introduced in Power ISA 3.1

Signed-off-by: Luis Pires <luis.pires@eldorado.org.br>
---
 target/ppc/translate.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Comments

Richard Henderson April 28, 2021, 3:37 p.m. UTC | #1
On 4/27/21 10:16 AM, Luis Pires wrote:
> Prefixed instructions were introduced in Power ISA 3.1
> 
> Signed-off-by: Luis Pires <luis.pires@eldorado.org.br>
> ---
>   target/ppc/translate.c | 6 +++++-
>   1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/target/ppc/translate.c b/target/ppc/translate.c
> index 7422ea4e13..f4802a4f08 100644
> --- a/target/ppc/translate.c
> +++ b/target/ppc/translate.c
> @@ -7837,7 +7837,11 @@ static bool ppc_tr_breakpoint_check(DisasContextBase *dcbase, CPUState *cs,
>   
>   static bool is_prefix_insn(DisasContext *ctx, uint32_t insn)
>   {
> -    /* TODO: Check ctx->insns_flags* for whether prefixes are supported. */
> +    if (!(ctx->insns_flags2 & PPC2_ISA310)) {
> +        /* Prefixed instructions are not supported */
> +        return false;
> +    }

Patch 11 introduced REQUIRE_INSNS_FLAGS; this pattern calls for the 
introduction of REQUIRE_INSNS_FLAGS2, as you'll need it later.

Fold this back into patch 8, or move this to be patch 9, so that we don't have 
a range of patches which accept invalid instructions.


r~
diff mbox series

Patch

diff --git a/target/ppc/translate.c b/target/ppc/translate.c
index 7422ea4e13..f4802a4f08 100644
--- a/target/ppc/translate.c
+++ b/target/ppc/translate.c
@@ -7837,7 +7837,11 @@  static bool ppc_tr_breakpoint_check(DisasContextBase *dcbase, CPUState *cs,
 
 static bool is_prefix_insn(DisasContext *ctx, uint32_t insn)
 {
-    /* TODO: Check ctx->insns_flags* for whether prefixes are supported. */
+    if (!(ctx->insns_flags2 & PPC2_ISA310)) {
+        /* Prefixed instructions are not supported */
+        return false;
+    }
+
     return opc1(insn) == 1;
 }