[PATCH v3 0/8] Hexagon (target/hexagon) Check opcodes versions

Taylor Simpson posted 8 patches 1 month, 3 weeks ago
Failed in applying to current master (apply log)
Maintainers: Brian Cain <brian.cain@oss.qualcomm.com>, Laurent Vivier <laurent@vivier.eu>, Pierrick Bouvier <pierrick.bouvier@linaro.org>
target/hexagon/cpu-qom.h             |  27 ++
target/hexagon/cpu.h                 |   2 +
target/hexagon/cpu_bits.h            |   4 +-
target/hexagon/decode.h              |   2 +
target/hexagon/printinsn.h           |   4 +-
target/hexagon/translate.h           |   1 +
disas/hexagon.c                      |   3 +-
linux-user/hexagon/elfload.c         |  43 +-
target/hexagon/cpu.c                 |  48 ++-
target/hexagon/decode.c              |  52 ++-
target/hexagon/printinsn.c           |  40 +-
target/hexagon/translate.c           |   1 +
tests/tcg/hexagon/check_rev_gating.c | 141 ++++++
target/hexagon/tag_rev_info.c.inc    | 613 +++++++++++++++++++++++++++
tests/tcg/hexagon/Makefile.target    |   6 +
15 files changed, 911 insertions(+), 76 deletions(-)
create mode 100644 tests/tcg/hexagon/check_rev_gating.c
create mode 100644 target/hexagon/tag_rev_info.c.inc
[PATCH v3 0/8] Hexagon (target/hexagon) Check opcodes versions
Posted by Taylor Simpson 1 month, 3 weeks ago
Currently, all versions of Hexagon CPU are treated the same, and all
opcodes are able to run on any version.  This series changes the behavior
such that only the opcodes available on the currently executing Hexagon
CPU version can execute.

Changes include:
Mark which Hexagon CPU version is currently executing
Check that each opcode is supported in the Hexagon CPU version
If not, generate INVALID_PACKET opcode, which is converted to SIGILL
Properly handle disassembly (-d in_asm)
Test case added

Co-authored-by: Matheus Tavares Bernardino <matheus.bernardino@oss.qualcomm.com>
Co-authored-by: Brian Cain <brian.cain@oss.qualcomm.com>

Changes in v2:
- Rebase with Brian Cain's "Handle some invalid encodings" series
- Add older opcodes to tag_rev_info.c.inc
- Change tag_rev_info to use HexagonVersion
      Suggested by Richard Henderson <richard.henderson@linaro.org>
- Disassembly includes valid opcodes inside packet with invalid opcodes
- Remove unused function - snpring_a_pkt_debug

Changes in v3:
- Use a struct to hold Hexagon definition rather than a simple enum
      Suggested by Anton Johansson <anjo@rev.ng>

Brian Cain (1):
  tests/tcg/hexagon: Add test for revision-gated instruction decoding

Matheus Tavares Bernardino (1):
  Hexagon (target/hexagon) Introduce tag_rev_info.c.inc

Taylor Simpson (6):
  Hexagon (target/hexagon) Properly handle Hexagon CPU version
  Hexagon (linux-user/hexagon) Identify Hexagon version in ELF file
  Hexagon (target/hexagon) Add Hexagon definition field to DisasContext
  Hexagon (target/hexagon) Check each opcode against current CPU
    definition
  Hexagon (target/hexagon) Disassembly of invalid packets
  Hexagon (target/hexagon) Remove snprint_a_pkt_debug

 target/hexagon/cpu-qom.h             |  27 ++
 target/hexagon/cpu.h                 |   2 +
 target/hexagon/cpu_bits.h            |   4 +-
 target/hexagon/decode.h              |   2 +
 target/hexagon/printinsn.h           |   4 +-
 target/hexagon/translate.h           |   1 +
 disas/hexagon.c                      |   3 +-
 linux-user/hexagon/elfload.c         |  43 +-
 target/hexagon/cpu.c                 |  48 ++-
 target/hexagon/decode.c              |  52 ++-
 target/hexagon/printinsn.c           |  40 +-
 target/hexagon/translate.c           |   1 +
 tests/tcg/hexagon/check_rev_gating.c | 141 ++++++
 target/hexagon/tag_rev_info.c.inc    | 613 +++++++++++++++++++++++++++
 tests/tcg/hexagon/Makefile.target    |   6 +
 15 files changed, 911 insertions(+), 76 deletions(-)
 create mode 100644 tests/tcg/hexagon/check_rev_gating.c
 create mode 100644 target/hexagon/tag_rev_info.c.inc

-- 
2.43.0
Re: [PATCH v3 0/8] Hexagon (target/hexagon) Check opcodes versions
Posted by Brian Cain 2 days, 11 hours ago
On Tue, Feb 17, 2026 at 3:22 PM Taylor Simpson <ltaylorsimpson@gmail.com> wrote:
>
> Currently, all versions of Hexagon CPU are treated the same, and all
> opcodes are able to run on any version.  This series changes the behavior
> such that only the opcodes available on the currently executing Hexagon
> CPU version can execute.
>
> Changes include:
> Mark which Hexagon CPU version is currently executing
> Check that each opcode is supported in the Hexagon CPU version
> If not, generate INVALID_PACKET opcode, which is converted to SIGILL
> Properly handle disassembly (-d in_asm)
> Test case added

Thanks for the patches Taylor - this is queued on my hex-next-express
tree for post-11 inclusion.

> Co-authored-by: Matheus Tavares Bernardino <matheus.bernardino@oss.qualcomm.com>
> Co-authored-by: Brian Cain <brian.cain@oss.qualcomm.com>
>
> Changes in v2:
> - Rebase with Brian Cain's "Handle some invalid encodings" series
> - Add older opcodes to tag_rev_info.c.inc
> - Change tag_rev_info to use HexagonVersion
>       Suggested by Richard Henderson <richard.henderson@linaro.org>
> - Disassembly includes valid opcodes inside packet with invalid opcodes
> - Remove unused function - snpring_a_pkt_debug
>
> Changes in v3:
> - Use a struct to hold Hexagon definition rather than a simple enum
>       Suggested by Anton Johansson <anjo@rev.ng>
>
> Brian Cain (1):
>   tests/tcg/hexagon: Add test for revision-gated instruction decoding
>
> Matheus Tavares Bernardino (1):
>   Hexagon (target/hexagon) Introduce tag_rev_info.c.inc
>
> Taylor Simpson (6):
>   Hexagon (target/hexagon) Properly handle Hexagon CPU version
>   Hexagon (linux-user/hexagon) Identify Hexagon version in ELF file
>   Hexagon (target/hexagon) Add Hexagon definition field to DisasContext
>   Hexagon (target/hexagon) Check each opcode against current CPU
>     definition
>   Hexagon (target/hexagon) Disassembly of invalid packets
>   Hexagon (target/hexagon) Remove snprint_a_pkt_debug
>
>  target/hexagon/cpu-qom.h             |  27 ++
>  target/hexagon/cpu.h                 |   2 +
>  target/hexagon/cpu_bits.h            |   4 +-
>  target/hexagon/decode.h              |   2 +
>  target/hexagon/printinsn.h           |   4 +-
>  target/hexagon/translate.h           |   1 +
>  disas/hexagon.c                      |   3 +-
>  linux-user/hexagon/elfload.c         |  43 +-
>  target/hexagon/cpu.c                 |  48 ++-
>  target/hexagon/decode.c              |  52 ++-
>  target/hexagon/printinsn.c           |  40 +-
>  target/hexagon/translate.c           |   1 +
>  tests/tcg/hexagon/check_rev_gating.c | 141 ++++++
>  target/hexagon/tag_rev_info.c.inc    | 613 +++++++++++++++++++++++++++
>  tests/tcg/hexagon/Makefile.target    |   6 +
>  15 files changed, 911 insertions(+), 76 deletions(-)
>  create mode 100644 tests/tcg/hexagon/check_rev_gating.c
>  create mode 100644 target/hexagon/tag_rev_info.c.inc
>
> --
> 2.43.0
>