From: Thomas Huth <thuth@redhat.com>
To: Laurent Vivier <lvivier@redhat.com>,
kvm@vger.kernel.org, kvm-ppc@vger.kernel.org
Cc: drjones@redhat.com, dgibson@redhat.com, pbonzini@redhat.com
Subject: Re: [kvm-unit-tests PATCH v2 2/5] powerpc: add test to check invalid instruction trap
Date: Mon, 21 Mar 2016 14:57:04 +0000 [thread overview]
Message-ID: <56F00BC0.9000806@redhat.com> (raw)
In-Reply-To: <1458560014-28862-3-git-send-email-lvivier@redhat.com>
On 21.03.2016 12:33, Laurent Vivier wrote:
> Signed-off-by: Laurent Vivier <lvivier@redhat.com>
> ---
> v2:
> check program check type (invalid instruction)
> add "-v" parameter to display invalid instruction address
>
> powerpc/Makefile.common | 5 +++-
> powerpc/emulator.c | 65 +++++++++++++++++++++++++++++++++++++++++++++++++
> powerpc/unittests.cfg | 3 +++
> 3 files changed, 72 insertions(+), 1 deletion(-)
> create mode 100644 powerpc/emulator.c
>
> diff --git a/powerpc/Makefile.common b/powerpc/Makefile.common
> index ab2caf6..257e3fb 100644
> --- a/powerpc/Makefile.common
> +++ b/powerpc/Makefile.common
> @@ -7,7 +7,8 @@
> tests-common = \
> $(TEST_DIR)/selftest.elf \
> $(TEST_DIR)/spapr_hcall.elf \
> - $(TEST_DIR)/rtas.elf
> + $(TEST_DIR)/rtas.elf \
> + $(TEST_DIR)/emulator.elf
>
> all: $(TEST_DIR)/boot_rom.bin test_cases
>
> @@ -70,3 +71,5 @@ $(TEST_DIR)/selftest.elf: $(cstart.o) $(reloc.o) $(TEST_DIR)/selftest.o
> $(TEST_DIR)/spapr_hcall.elf: $(cstart.o) $(reloc.o) $(TEST_DIR)/spapr_hcall.o
>
> $(TEST_DIR)/rtas.elf: $(cstart.o) $(reloc.o) $(TEST_DIR)/rtas.o
> +
> +$(TEST_DIR)/emulator.elf: $(cstart.o) $(reloc.o) $(TEST_DIR)/emulator.o
> diff --git a/powerpc/emulator.c b/powerpc/emulator.c
> new file mode 100644
> index 0000000..1d4f164
> --- /dev/null
> +++ b/powerpc/emulator.c
> @@ -0,0 +1,65 @@
> +/*
> + * Test some powerpc instructions
> + */
> +
> +#include <libcflat.h>
> +#include <asm/processor.h>
> +
> +static int verbose;
> +static int volatile is_invalid;
> +
> +static void program_check_handler(struct pt_regs *regs, void *opaque)
> +{
> + int *data = opaque;
> +
> + if (verbose) {
> + printf("Detected invalid instruction 0x%016lx: %08x\n",
> + regs->nip, *(uint32_t*)regs->nip);
> + }
> +
> + /* the result is bit 16 to 19 of SRR1
> + * bit 0: SRR0 contains the address of the next instruction
> + * bit 1: Trap
> + * bit 2: Privileged instruction
> + * bit 3: Illegal instruction
> + * bit 4: FP enabled exception type
> + */
> +
> + *data = regs->msr >> 16;
> +
> + regs->nip += 4;
> +}
> +
> +static void test_illegal(void)
> +{
> + report_prefix_push("invalid");
> +
> + is_invalid = 0;
> +
> + asm volatile (".long 0");
> +
> + report("exception", is_invalid = 8); /* illegal instruction */
> +
> + report_prefix_pop();
> +}
> +
> +int main(int argc, char **argv)
> +{
> + int i;
> +
> + handle_exception(0x700, program_check_handler, (void *)&is_invalid);
> +
> + for (i = 0; i < argc; i++) {
> + if (strcmp(argv[i], "-v") = 0) {
> + verbose = 1;
> + }
> + }
> +
> + report_prefix_push("emulator");
> +
> + test_illegal();
> +
> + report_prefix_pop();
> +
> + return report_summary();
> +}
> diff --git a/powerpc/unittests.cfg b/powerpc/unittests.cfg
> index 02b21c7..ed4fdbe 100644
> --- a/powerpc/unittests.cfg
> +++ b/powerpc/unittests.cfg
> @@ -47,3 +47,6 @@ file = rtas.elf
> extra_params = -append "set-time-of-day"
> timeout = 5
> groups = rtas
> +
> +[emulator]
> +file = emulator.elf
>
Reviewed-by: Thomas Huth <thuth@redhat.com>
WARNING: multiple messages have this Message-ID (diff)
From: Thomas Huth <thuth@redhat.com>
To: Laurent Vivier <lvivier@redhat.com>,
kvm@vger.kernel.org, kvm-ppc@vger.kernel.org
Cc: drjones@redhat.com, dgibson@redhat.com, pbonzini@redhat.com
Subject: Re: [kvm-unit-tests PATCH v2 2/5] powerpc: add test to check invalid instruction trap
Date: Mon, 21 Mar 2016 15:57:04 +0100 [thread overview]
Message-ID: <56F00BC0.9000806@redhat.com> (raw)
In-Reply-To: <1458560014-28862-3-git-send-email-lvivier@redhat.com>
On 21.03.2016 12:33, Laurent Vivier wrote:
> Signed-off-by: Laurent Vivier <lvivier@redhat.com>
> ---
> v2:
> check program check type (invalid instruction)
> add "-v" parameter to display invalid instruction address
>
> powerpc/Makefile.common | 5 +++-
> powerpc/emulator.c | 65 +++++++++++++++++++++++++++++++++++++++++++++++++
> powerpc/unittests.cfg | 3 +++
> 3 files changed, 72 insertions(+), 1 deletion(-)
> create mode 100644 powerpc/emulator.c
>
> diff --git a/powerpc/Makefile.common b/powerpc/Makefile.common
> index ab2caf6..257e3fb 100644
> --- a/powerpc/Makefile.common
> +++ b/powerpc/Makefile.common
> @@ -7,7 +7,8 @@
> tests-common = \
> $(TEST_DIR)/selftest.elf \
> $(TEST_DIR)/spapr_hcall.elf \
> - $(TEST_DIR)/rtas.elf
> + $(TEST_DIR)/rtas.elf \
> + $(TEST_DIR)/emulator.elf
>
> all: $(TEST_DIR)/boot_rom.bin test_cases
>
> @@ -70,3 +71,5 @@ $(TEST_DIR)/selftest.elf: $(cstart.o) $(reloc.o) $(TEST_DIR)/selftest.o
> $(TEST_DIR)/spapr_hcall.elf: $(cstart.o) $(reloc.o) $(TEST_DIR)/spapr_hcall.o
>
> $(TEST_DIR)/rtas.elf: $(cstart.o) $(reloc.o) $(TEST_DIR)/rtas.o
> +
> +$(TEST_DIR)/emulator.elf: $(cstart.o) $(reloc.o) $(TEST_DIR)/emulator.o
> diff --git a/powerpc/emulator.c b/powerpc/emulator.c
> new file mode 100644
> index 0000000..1d4f164
> --- /dev/null
> +++ b/powerpc/emulator.c
> @@ -0,0 +1,65 @@
> +/*
> + * Test some powerpc instructions
> + */
> +
> +#include <libcflat.h>
> +#include <asm/processor.h>
> +
> +static int verbose;
> +static int volatile is_invalid;
> +
> +static void program_check_handler(struct pt_regs *regs, void *opaque)
> +{
> + int *data = opaque;
> +
> + if (verbose) {
> + printf("Detected invalid instruction 0x%016lx: %08x\n",
> + regs->nip, *(uint32_t*)regs->nip);
> + }
> +
> + /* the result is bit 16 to 19 of SRR1
> + * bit 0: SRR0 contains the address of the next instruction
> + * bit 1: Trap
> + * bit 2: Privileged instruction
> + * bit 3: Illegal instruction
> + * bit 4: FP enabled exception type
> + */
> +
> + *data = regs->msr >> 16;
> +
> + regs->nip += 4;
> +}
> +
> +static void test_illegal(void)
> +{
> + report_prefix_push("invalid");
> +
> + is_invalid = 0;
> +
> + asm volatile (".long 0");
> +
> + report("exception", is_invalid == 8); /* illegal instruction */
> +
> + report_prefix_pop();
> +}
> +
> +int main(int argc, char **argv)
> +{
> + int i;
> +
> + handle_exception(0x700, program_check_handler, (void *)&is_invalid);
> +
> + for (i = 0; i < argc; i++) {
> + if (strcmp(argv[i], "-v") == 0) {
> + verbose = 1;
> + }
> + }
> +
> + report_prefix_push("emulator");
> +
> + test_illegal();
> +
> + report_prefix_pop();
> +
> + return report_summary();
> +}
> diff --git a/powerpc/unittests.cfg b/powerpc/unittests.cfg
> index 02b21c7..ed4fdbe 100644
> --- a/powerpc/unittests.cfg
> +++ b/powerpc/unittests.cfg
> @@ -47,3 +47,6 @@ file = rtas.elf
> extra_params = -append "set-time-of-day"
> timeout = 5
> groups = rtas
> +
> +[emulator]
> +file = emulator.elf
>
Reviewed-by: Thomas Huth <thuth@redhat.com>
next prev parent reply other threads:[~2016-03-21 14:57 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-21 11:33 [kvm-unit-tests PATCH v2 0/5] Check emulation Laurent Vivier
2016-03-21 11:33 ` Laurent Vivier
2016-03-21 11:33 ` [kvm-unit-tests PATCH v2 1/5] powerpc: add exception handler Laurent Vivier
2016-03-21 11:33 ` Laurent Vivier
2016-03-21 23:47 ` David Gibson
2016-03-21 23:47 ` David Gibson
2016-03-21 11:33 ` [kvm-unit-tests PATCH v2 2/5] powerpc: add test to check invalid instruction trap Laurent Vivier
2016-03-21 11:33 ` Laurent Vivier
2016-03-21 14:57 ` Thomas Huth [this message]
2016-03-21 14:57 ` Thomas Huth
2016-03-21 23:49 ` David Gibson
2016-03-21 23:49 ` David Gibson
2016-03-21 11:33 ` [kvm-unit-tests PATCH v2 3/5] powerpc: check 64bit mode Laurent Vivier
2016-03-21 11:33 ` Laurent Vivier
2016-03-21 23:49 ` David Gibson
2016-03-21 23:49 ` David Gibson
2016-03-21 11:33 ` [kvm-unit-tests PATCH v2 4/5] powerpc: check lswx Laurent Vivier
2016-03-21 11:33 ` Laurent Vivier
2016-03-21 12:07 ` Thomas Huth
2016-03-21 12:07 ` Thomas Huth
2016-03-21 14:25 ` Paolo Bonzini
2016-03-21 14:25 ` Paolo Bonzini
2016-03-21 15:59 ` Laurent Vivier
2016-03-21 15:59 ` Laurent Vivier
2016-03-21 23:53 ` David Gibson
2016-03-21 23:53 ` David Gibson
2016-03-21 11:33 ` [kvm-unit-tests PATCH v2 5/5] powerpc: Check lswx in little-endian mode Laurent Vivier
2016-03-21 11:33 ` Laurent Vivier
2016-03-21 23:56 ` David Gibson
2016-03-21 23:56 ` David Gibson
2016-03-22 8:12 ` Thomas Huth
2016-03-22 8:12 ` Thomas Huth
2016-03-22 8:25 ` Laurent Vivier
2016-03-22 8:25 ` Laurent Vivier
2016-03-23 0:14 ` David Gibson
2016-03-23 0:14 ` David Gibson
2016-03-22 9:50 ` [kvm-unit-tests PATCH v2 0/5] Check emulation Paolo Bonzini
2016-03-22 9:50 ` Paolo Bonzini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=56F00BC0.9000806@redhat.com \
--to=thuth@redhat.com \
--cc=dgibson@redhat.com \
--cc=drjones@redhat.com \
--cc=kvm-ppc@vger.kernel.org \
--cc=kvm@vger.kernel.org \
--cc=lvivier@redhat.com \
--cc=pbonzini@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.