selftests/powerpc: Fix prefixes in alignment_handler signal handler

The signal handler in the alignment handler self test has the ability
to jump over the instruction that triggered the signal. It does this
by incrementing the PT_NIP in the user context by 4. If it were a
prefixed instruction this will mean that the suffix is then executed
which is incorrect. Instead check if the major opcode indicates a
prefixed instruction (e.g. it is 1) and if so increment PT_NIP by 8.

If ISA v3.1 is not available treat it as a word instruction even if
the major opcode is 1.

Fixes: 620a6473df ("selftests/powerpc: Add prefixed loads/stores to alignment_handler test")
Signed-off-by: Jordan Niethe <jniethe5@gmail.com>
[mpe: Fix 32-bit build, rename haveprefixes to prefixes_enabled]
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20200824131231.14008-1-jniethe5@gmail.com
This commit is contained in:
Jordan Niethe 2020-08-24 23:12:31 +10:00 committed by Michael Ellerman
parent 364b236a0b
commit db96221a68

View File

@ -62,6 +62,7 @@ int bufsize;
int debug;
int testing;
volatile int gotsig;
bool prefixes_enabled;
char *cipath = "/dev/fb0";
long cioffset;
@ -75,7 +76,12 @@ void sighandler(int sig, siginfo_t *info, void *ctx)
}
gotsig = sig;
#ifdef __powerpc64__
ucp->uc_mcontext.gp_regs[PT_NIP] += 4;
if (prefixes_enabled) {
u32 inst = *(u32 *)ucp->uc_mcontext.gp_regs[PT_NIP];
ucp->uc_mcontext.gp_regs[PT_NIP] += ((inst >> 26 == 1) ? 8 : 4);
} else {
ucp->uc_mcontext.gp_regs[PT_NIP] += 4;
}
#else
ucp->uc_mcontext.uc_regs->gregs[PT_NIP] += 4;
#endif
@ -646,6 +652,8 @@ int main(int argc, char *argv[])
exit(1);
}
prefixes_enabled = have_hwcap2(PPC_FEATURE2_ARCH_3_1);
rc |= test_harness(test_alignment_handler_vsx_206,
"test_alignment_handler_vsx_206");
rc |= test_harness(test_alignment_handler_vsx_207,