From: David Gibson <dgibson@redhat.com>
To: Laurent Vivier <lvivier@redhat.com>
Cc: kvm@vger.kernel.org, kvm-ppc@vger.kernel.org, drjones@redhat.com,
thuth@redhat.com, pbonzini@redhat.com
Subject: Re: [kvm-unit-tests PATCH v2 5/5] powerpc: Check lswx in little-endian mode.
Date: Mon, 21 Mar 2016 23:56:09 +0000 [thread overview]
Message-ID: <20160322105609.1bed546e@voom.fritz.box> (raw)
In-Reply-To: <1458560014-28862-6-git-send-email-lvivier@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 2875 bytes --]
On Mon, 21 Mar 2016 12:33:34 +0100
Laurent Vivier <lvivier@redhat.com> wrote:
> For lswx in little-endian mode, an alignment interrupt occurs.
>
> Signed-off-by: Laurent Vivier <lvivier@redhat.com>
> Reviewed-by: Thomas Huth <thuth@redhat.com>
I'm not entirely clear here; will the test fail if the alignment
exception doesn't occur in little endian mode?
The general trend in Power has been for less and less things to trigger
alignment exceptions, so failing to cause an alignment exception
shouldn't cause a test failure (as long as the unaligned case is
correctly processed, of course).
> ---
> powerpc/emulator.c | 22 ++++++++++++++++++++++
> 1 file changed, 22 insertions(+)
>
> diff --git a/powerpc/emulator.c b/powerpc/emulator.c
> index 8d0dde2..87ef4a9 100644
> --- a/powerpc/emulator.c
> +++ b/powerpc/emulator.c
> @@ -7,6 +7,7 @@
>
> static int verbose;
> static int volatile is_invalid;
> +static int volatile alignment;
>
> static void program_check_handler(struct pt_regs *regs, void *opaque)
> {
> @@ -30,6 +31,18 @@ static void program_check_handler(struct pt_regs *regs, void *opaque)
> regs->nip += 4;
> }
>
> +static void alignment_handler(struct pt_regs *regs, void *opaque)
> +{
> + int *data = opaque;
> +
> + printf("Detected alignment exception 0x%016lx: %08x\n",
> + regs->nip, *(uint32_t*)regs->nip);
> +
> + *data = 1;
> +
> + regs->nip += 4;
> +}
> +
> static void test_illegal(void)
> {
> report_prefix_push("invalid");
> @@ -73,6 +86,8 @@ static void test_64bit(void)
> * - RT <= RA or RB < RT + (n + 4) is invalid or result is undefined
> * - RT == RA == 0 is invalid
> *
> + * For lswx in little-endian mode, an alignment interrupt always occurs.
> + *
> */
>
> static void test_lswx(void)
> @@ -90,6 +105,7 @@ static void test_lswx(void)
>
> /* check incomplete register filling */
>
> + alignment = 0;
> asm volatile ("mtxer %[len];"
> "li r12,-1;"
> "mr r11, r12;"
> @@ -103,7 +119,12 @@ static void test_lswx(void)
> :
> "xer", "r11", "r12", "memory");
>
> +#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
> + report("alignment", alignment);
> + return;
> +#else
> report("partial", regs[0] == 0x01020300 && regs[1] == (uint64_t)-1);
> +#endif
>
> /* check an old know bug: the number of bytes is used as
> * the number of registers, so try 32 bytes.
> @@ -200,6 +221,7 @@ int main(int argc, char **argv)
> int i;
>
> handle_exception(0x700, program_check_handler, (void *)&is_invalid);
> + handle_exception(0x600, alignment_handler, (void *)&alignment);
>
> for (i = 0; i < argc; i++) {
> if (strcmp(argv[i], "-v") == 0) {
> --
> 2.5.0
>
--
David Gibson <dgibson@redhat.com>
Senior Software Engineer, Virtualization, Red Hat
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
WARNING: multiple messages have this Message-ID (diff)
From: David Gibson <dgibson@redhat.com>
To: Laurent Vivier <lvivier@redhat.com>
Cc: kvm@vger.kernel.org, kvm-ppc@vger.kernel.org, drjones@redhat.com,
thuth@redhat.com, pbonzini@redhat.com
Subject: Re: [kvm-unit-tests PATCH v2 5/5] powerpc: Check lswx in little-endian mode.
Date: Tue, 22 Mar 2016 10:56:09 +1100 [thread overview]
Message-ID: <20160322105609.1bed546e@voom.fritz.box> (raw)
In-Reply-To: <1458560014-28862-6-git-send-email-lvivier@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 2875 bytes --]
On Mon, 21 Mar 2016 12:33:34 +0100
Laurent Vivier <lvivier@redhat.com> wrote:
> For lswx in little-endian mode, an alignment interrupt occurs.
>
> Signed-off-by: Laurent Vivier <lvivier@redhat.com>
> Reviewed-by: Thomas Huth <thuth@redhat.com>
I'm not entirely clear here; will the test fail if the alignment
exception doesn't occur in little endian mode?
The general trend in Power has been for less and less things to trigger
alignment exceptions, so failing to cause an alignment exception
shouldn't cause a test failure (as long as the unaligned case is
correctly processed, of course).
> ---
> powerpc/emulator.c | 22 ++++++++++++++++++++++
> 1 file changed, 22 insertions(+)
>
> diff --git a/powerpc/emulator.c b/powerpc/emulator.c
> index 8d0dde2..87ef4a9 100644
> --- a/powerpc/emulator.c
> +++ b/powerpc/emulator.c
> @@ -7,6 +7,7 @@
>
> static int verbose;
> static int volatile is_invalid;
> +static int volatile alignment;
>
> static void program_check_handler(struct pt_regs *regs, void *opaque)
> {
> @@ -30,6 +31,18 @@ static void program_check_handler(struct pt_regs *regs, void *opaque)
> regs->nip += 4;
> }
>
> +static void alignment_handler(struct pt_regs *regs, void *opaque)
> +{
> + int *data = opaque;
> +
> + printf("Detected alignment exception 0x%016lx: %08x\n",
> + regs->nip, *(uint32_t*)regs->nip);
> +
> + *data = 1;
> +
> + regs->nip += 4;
> +}
> +
> static void test_illegal(void)
> {
> report_prefix_push("invalid");
> @@ -73,6 +86,8 @@ static void test_64bit(void)
> * - RT <= RA or RB < RT + (n + 4) is invalid or result is undefined
> * - RT == RA == 0 is invalid
> *
> + * For lswx in little-endian mode, an alignment interrupt always occurs.
> + *
> */
>
> static void test_lswx(void)
> @@ -90,6 +105,7 @@ static void test_lswx(void)
>
> /* check incomplete register filling */
>
> + alignment = 0;
> asm volatile ("mtxer %[len];"
> "li r12,-1;"
> "mr r11, r12;"
> @@ -103,7 +119,12 @@ static void test_lswx(void)
> :
> "xer", "r11", "r12", "memory");
>
> +#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
> + report("alignment", alignment);
> + return;
> +#else
> report("partial", regs[0] == 0x01020300 && regs[1] == (uint64_t)-1);
> +#endif
>
> /* check an old know bug: the number of bytes is used as
> * the number of registers, so try 32 bytes.
> @@ -200,6 +221,7 @@ int main(int argc, char **argv)
> int i;
>
> handle_exception(0x700, program_check_handler, (void *)&is_invalid);
> + handle_exception(0x600, alignment_handler, (void *)&alignment);
>
> for (i = 0; i < argc; i++) {
> if (strcmp(argv[i], "-v") == 0) {
> --
> 2.5.0
>
--
David Gibson <dgibson@redhat.com>
Senior Software Engineer, Virtualization, Red Hat
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
next prev parent reply other threads:[~2016-03-21 23:56 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
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 [this message]
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=20160322105609.1bed546e@voom.fritz.box \
--to=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 \
--cc=thuth@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.