e902126cae
Add a number of small test that check whether accessing unaligned addresses in various ways leads to a specification exception. Run these test both in softmmu and user configurations; expect a PGM in one case and SIGILL in the other. Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com> Reviewed-by: Thomas Huth <thuth@redhat.com> Message-Id: <20230316164428.275147-13-iii@linux.ibm.com> [thuth: Added -Wl,--build-id=none to LDFLAGS] Signed-off-by: Thomas Huth <thuth@redhat.com>
38 lines
722 B
C
38 lines
722 B
C
/*
|
|
* Common user code for specification exception testing.
|
|
*
|
|
* SPDX-License-Identifier: GPL-2.0-or-later
|
|
*/
|
|
#include <assert.h>
|
|
#include <signal.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <unistd.h>
|
|
|
|
extern void test(void);
|
|
extern long expected_old_psw[2];
|
|
|
|
static void handle_sigill(int sig, siginfo_t *info, void *ucontext)
|
|
{
|
|
if ((long)info->si_addr != expected_old_psw[1]) {
|
|
_exit(EXIT_FAILURE);
|
|
}
|
|
_exit(EXIT_SUCCESS);
|
|
}
|
|
|
|
int main(void)
|
|
{
|
|
struct sigaction act;
|
|
int err;
|
|
|
|
memset(&act, 0, sizeof(act));
|
|
act.sa_sigaction = handle_sigill;
|
|
act.sa_flags = SA_SIGINFO;
|
|
err = sigaction(SIGILL, &act, NULL);
|
|
assert(err == 0);
|
|
|
|
test();
|
|
|
|
return EXIT_FAILURE;
|
|
}
|