From 500da4306bd0130848f7d4d1929242eafa2e92dc Mon Sep 17 00:00:00 2001 From: Hoa Nguyen Date: Mon, 17 Jun 2024 12:44:05 -0700 Subject: [PATCH] arch: Mark FailUnimplemented instructions as Invalid instructions (#1247) This is a follow-up on the discussion here [1]. The IsInvalid flag was previously defined as an instruction that does not appear in the ISA. However, a micro-architecture can choose to not recognize an instruction in and raise illegal instruction fault even if the instruction is in the ISA. This change modifies the definition of a Invalid instruction such that, if a StaticInst instruction is marked as IsInvalid, it means the instruction is not recognized by the decoder. This means that any instruction recognized by the decoder are not invalid, even if the instruction is not in the official ISA spec; e.g., m5 pseudo-instructions. Note that instructions that are recognized by the decoder but are chosen to act as a nop are not invalid. This applies to WarnUnimplemented instructions, e.g. hint instructions. [1] https://github.com/gem5/gem5/pull/1071 Change-Id: I1371b222d8b06793d47f434d0f148c5571672068 Signed-off-by: Hoa Nguyen --- src/arch/arm/insts/pseudo.cc | 2 ++ src/arch/mips/isa/formats/unimp.isa | 1 + src/arch/power/isa/formats/unimp.isa | 1 + src/arch/sparc/insts/unimp.hh | 4 +++- src/arch/x86/isa/formats/unimp.isa | 1 + 5 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/arch/arm/insts/pseudo.cc b/src/arch/arm/insts/pseudo.cc index 3d017c1857..0402071255 100644 --- a/src/arch/arm/insts/pseudo.cc +++ b/src/arch/arm/insts/pseudo.cc @@ -116,6 +116,7 @@ FailUnimplemented::FailUnimplemented(const char *_mnemonic, // don't call execute() (which panics) if we're on a // speculative path flags[IsNonSpeculative] = true; + flags[IsInvalid] = true; } FailUnimplemented::FailUnimplemented(const char *_mnemonic, @@ -127,6 +128,7 @@ FailUnimplemented::FailUnimplemented(const char *_mnemonic, // don't call execute() (which panics) if we're on a // speculative path flags[IsNonSpeculative] = true; + flags[IsInvalid] = true; } Fault diff --git a/src/arch/mips/isa/formats/unimp.isa b/src/arch/mips/isa/formats/unimp.isa index 198e20b820..776698f291 100644 --- a/src/arch/mips/isa/formats/unimp.isa +++ b/src/arch/mips/isa/formats/unimp.isa @@ -49,6 +49,7 @@ output header {{ // don't call execute() (which panics) if we're on a // speculative path flags[IsNonSpeculative] = true; + flags[IsInvalid] = true; } Fault execute(ExecContext *, trace::InstRecord *) const override; diff --git a/src/arch/power/isa/formats/unimp.isa b/src/arch/power/isa/formats/unimp.isa index 9e1e46051b..5e9579fa5e 100644 --- a/src/arch/power/isa/formats/unimp.isa +++ b/src/arch/power/isa/formats/unimp.isa @@ -51,6 +51,7 @@ output header {{ // don't call execute() (which panics) if we're on a // speculative path flags[IsNonSpeculative] = true; + flags[IsInvalid] = true; } Fault execute(ExecContext *, trace::InstRecord *) const override; diff --git a/src/arch/sparc/insts/unimp.hh b/src/arch/sparc/insts/unimp.hh index 9eda012182..8609823382 100644 --- a/src/arch/sparc/insts/unimp.hh +++ b/src/arch/sparc/insts/unimp.hh @@ -59,7 +59,9 @@ class FailUnimplemented : public SparcStaticInst /// Constructor FailUnimplemented(const char *_mnemonic, ExtMachInst _machInst) : SparcStaticInst(_mnemonic, _machInst, No_OpClass) - {} + { + flags[IsInvalid] = true; + } Fault execute(ExecContext *xc, trace::InstRecord *traceData) const override diff --git a/src/arch/x86/isa/formats/unimp.isa b/src/arch/x86/isa/formats/unimp.isa index 2950f55891..e43ed00764 100644 --- a/src/arch/x86/isa/formats/unimp.isa +++ b/src/arch/x86/isa/formats/unimp.isa @@ -58,6 +58,7 @@ output header {{ // don't call execute() (which panics) if we're on a // speculative path flags[IsNonSpeculative] = true; + flags[IsInvalid] = true; } Fault execute(ExecContext *, trace::InstRecord *) const override;