[kvm-unit-tests PATCH v5 22/29] powerpc: Fix emulator illegal instruction test for powernv
Nicholas Piggin
npiggin at gmail.com
Sun Dec 17 00:42:49 AEDT 2023
Illegal instructions cause 0xe40 (HEAI) interrupts rather
than program interrupts.
Signed-off-by: Nicholas Piggin <npiggin at gmail.com>
---
powerpc/emulator.c | 19 ++++++++++++++++++-
1 file changed, 18 insertions(+), 1 deletion(-)
diff --git a/powerpc/emulator.c b/powerpc/emulator.c
index 39dd5964..035a903c 100644
--- a/powerpc/emulator.c
+++ b/powerpc/emulator.c
@@ -31,6 +31,20 @@ static void program_check_handler(struct pt_regs *regs, void *opaque)
regs->nip += 4;
}
+static void heai_handler(struct pt_regs *regs, void *opaque)
+{
+ int *data = opaque;
+
+ if (verbose) {
+ printf("Detected invalid instruction %#018lx: %08x\n",
+ regs->nip, *(uint32_t*)regs->nip);
+ }
+
+ *data = 8; /* Illegal instruction */
+
+ regs->nip += 4;
+}
+
static void alignment_handler(struct pt_regs *regs, void *opaque)
{
int *data = opaque;
@@ -362,7 +376,10 @@ int main(int argc, char **argv)
{
int i;
- handle_exception(0x700, program_check_handler, (void *)&is_invalid);
+ if (machine_is_powernv())
+ handle_exception(0xe40, heai_handler, (void *)&is_invalid);
+ else
+ handle_exception(0x700, program_check_handler, (void *)&is_invalid);
handle_exception(0x600, alignment_handler, (void *)&alignment);
for (i = 1; i < argc; i++) {
--
2.42.0
More information about the Linuxppc-dev
mailing list