From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Gibson Date: Mon, 21 Mar 2016 23:56:09 +0000 Subject: Re: [kvm-unit-tests PATCH v2 5/5] powerpc: Check lswx in little-endian mode. Message-Id: <20160322105609.1bed546e@voom.fritz.box> MIME-Version: 1 Content-Type: multipart/mixed; boundary="Sig_/dq1ceOkm3aU3KezA0sqvhoV" List-Id: References: <1458560014-28862-1-git-send-email-lvivier@redhat.com> <1458560014-28862-6-git-send-email-lvivier@redhat.com> In-Reply-To: <1458560014-28862-6-git-send-email-lvivier@redhat.com> To: Laurent Vivier Cc: kvm@vger.kernel.org, kvm-ppc@vger.kernel.org, drjones@redhat.com, thuth@redhat.com, pbonzini@redhat.com --Sig_/dq1ceOkm3aU3KezA0sqvhoV Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable On Mon, 21 Mar 2016 12:33:34 +0100 Laurent Vivier wrote: > For lswx in little-endian mode, an alignment interrupt occurs. >=20 > Signed-off-by: Laurent Vivier > Reviewed-by: Thomas Huth 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(+) >=20 > 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 @@ > =20 > static int verbose; > static int volatile is_invalid; > +static int volatile alignment; > =20 > 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 +=3D 4; > } > =20 > +static void alignment_handler(struct pt_regs *regs, void *opaque) > +{ > + int *data =3D opaque; > + > + printf("Detected alignment exception 0x%016lx: %08x\n", > + regs->nip, *(uint32_t*)regs->nip); > + > + *data =3D 1; > + > + regs->nip +=3D 4; > +} > + > static void test_illegal(void) > { > report_prefix_push("invalid"); > @@ -73,6 +86,8 @@ static void test_64bit(void) > * - RT <=3D RA or RB < RT + (n + 4) is invalid or result is undefined > * - RT =3D=3D RA =3D=3D 0 is invalid > * > + * For lswx in little-endian mode, an alignment interrupt always occurs. > + * > */ > =20 > static void test_lswx(void) > @@ -90,6 +105,7 @@ static void test_lswx(void) > =20 > /* check incomplete register filling */ > =20 > + alignment =3D 0; > asm volatile ("mtxer %[len];" > "li r12,-1;" > "mr r11, r12;" > @@ -103,7 +119,12 @@ static void test_lswx(void) > : > "xer", "r11", "r12", "memory"); > =20 > +#if __BYTE_ORDER__ =3D=3D __ORDER_LITTLE_ENDIAN__ > + report("alignment", alignment); > + return; > +#else > report("partial", regs[0] =3D=3D 0x01020300 && regs[1] =3D=3D (uint64_t= )-1); > +#endif > =20 > /* 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; > =20 > handle_exception(0x700, program_check_handler, (void *)&is_invalid); > + handle_exception(0x600, alignment_handler, (void *)&alignment); > =20 > for (i =3D 0; i < argc; i++) { > if (strcmp(argv[i], "-v") =3D=3D 0) { > --=20 > 2.5.0 >=20 --=20 David Gibson Senior Software Engineer, Virtualization, Red Hat --Sig_/dq1ceOkm3aU3KezA0sqvhoV Content-Type: application/pgp-signature Content-Description: OpenPGP digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAEBCAAGBQJW8IoZAAoJEGw4ysog2bOSpGIQAMsF9WwrbSZjnI5ipzM1Gz9N 3mYO7L0VjKEUpukiRH6rjG707iSc/XJw7BKuaPH200D64J3tazhP27A1ECnKCaDB BoJsJf5ykZaCuZOgSBZDQa3Oss610cm6fWZrf+BvQfb3H+fC9Fp5o1WKB5By2sXU CrJNJu0HWh83TkC1m7xwxxgTIOCJWabROF4yyT7iSLmbXP89r2xZklBQRlQYV3uc W+zTYyfkZmqwsOI87J7X0Espl0HloEebB7oJXJYaV2AWmr2cRFGLlJoS+5LukCcV P9eHoOU2MHuGcUrPyuAilYSj5PLgHrDZ6M4h41mUo9LPbFcZbojRkDoBs2noUTsq CX7PoKPNi7X6ULoa8DIlqh5seF9mYOaMzNnrHn1pT1cN1RuEFBqpIU1vyWINSjSw D5Pkqw6looB4SD6ufFu3Vg7Cyb2B2+Qbb4N3yNEN4Fkkcey28efX/XLg9OmtXcby 4bZIjtbX7N4BoNqVxD4dNeUDUA8mhveSwW2Yznk85ellpqakj2VoAoiDNEynsYeJ yRaLsjdpNXlzDRMhbVBXj6g2P0jLsBGEOcVrRcF+79//iSYEnvHibhlnfLCSu8om 4CCYknJCyJaEaxj5m9MYB9KyB9OKj5cCK6t5fz6SSvQwjKRKYDN0MJYfvDfjd4g6 UpsStmBCOLEmvVjbBv9p =6zez -----END PGP SIGNATURE----- --Sig_/dq1ceOkm3aU3KezA0sqvhoV-- From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Gibson 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 Message-ID: <20160322105609.1bed546e@voom.fritz.box> References: <1458560014-28862-1-git-send-email-lvivier@redhat.com> <1458560014-28862-6-git-send-email-lvivier@redhat.com> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; boundary="Sig_/dq1ceOkm3aU3KezA0sqvhoV"; protocol="application/pgp-signature" Cc: kvm@vger.kernel.org, kvm-ppc@vger.kernel.org, drjones@redhat.com, thuth@redhat.com, pbonzini@redhat.com To: Laurent Vivier Return-path: Received: from mx1.redhat.com ([209.132.183.28]:51153 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751111AbcCUXzD (ORCPT ); Mon, 21 Mar 2016 19:55:03 -0400 In-Reply-To: <1458560014-28862-6-git-send-email-lvivier@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: --Sig_/dq1ceOkm3aU3KezA0sqvhoV Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable On Mon, 21 Mar 2016 12:33:34 +0100 Laurent Vivier wrote: > For lswx in little-endian mode, an alignment interrupt occurs. >=20 > Signed-off-by: Laurent Vivier > Reviewed-by: Thomas Huth 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(+) >=20 > 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 @@ > =20 > static int verbose; > static int volatile is_invalid; > +static int volatile alignment; > =20 > 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 +=3D 4; > } > =20 > +static void alignment_handler(struct pt_regs *regs, void *opaque) > +{ > + int *data =3D opaque; > + > + printf("Detected alignment exception 0x%016lx: %08x\n", > + regs->nip, *(uint32_t*)regs->nip); > + > + *data =3D 1; > + > + regs->nip +=3D 4; > +} > + > static void test_illegal(void) > { > report_prefix_push("invalid"); > @@ -73,6 +86,8 @@ static void test_64bit(void) > * - RT <=3D RA or RB < RT + (n + 4) is invalid or result is undefined > * - RT =3D=3D RA =3D=3D 0 is invalid > * > + * For lswx in little-endian mode, an alignment interrupt always occurs. > + * > */ > =20 > static void test_lswx(void) > @@ -90,6 +105,7 @@ static void test_lswx(void) > =20 > /* check incomplete register filling */ > =20 > + alignment =3D 0; > asm volatile ("mtxer %[len];" > "li r12,-1;" > "mr r11, r12;" > @@ -103,7 +119,12 @@ static void test_lswx(void) > : > "xer", "r11", "r12", "memory"); > =20 > +#if __BYTE_ORDER__ =3D=3D __ORDER_LITTLE_ENDIAN__ > + report("alignment", alignment); > + return; > +#else > report("partial", regs[0] =3D=3D 0x01020300 && regs[1] =3D=3D (uint64_t= )-1); > +#endif > =20 > /* 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; > =20 > handle_exception(0x700, program_check_handler, (void *)&is_invalid); > + handle_exception(0x600, alignment_handler, (void *)&alignment); > =20 > for (i =3D 0; i < argc; i++) { > if (strcmp(argv[i], "-v") =3D=3D 0) { > --=20 > 2.5.0 >=20 --=20 David Gibson Senior Software Engineer, Virtualization, Red Hat --Sig_/dq1ceOkm3aU3KezA0sqvhoV Content-Type: application/pgp-signature Content-Description: OpenPGP digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAEBCAAGBQJW8IoZAAoJEGw4ysog2bOSpGIQAMsF9WwrbSZjnI5ipzM1Gz9N 3mYO7L0VjKEUpukiRH6rjG707iSc/XJw7BKuaPH200D64J3tazhP27A1ECnKCaDB BoJsJf5ykZaCuZOgSBZDQa3Oss610cm6fWZrf+BvQfb3H+fC9Fp5o1WKB5By2sXU CrJNJu0HWh83TkC1m7xwxxgTIOCJWabROF4yyT7iSLmbXP89r2xZklBQRlQYV3uc W+zTYyfkZmqwsOI87J7X0Espl0HloEebB7oJXJYaV2AWmr2cRFGLlJoS+5LukCcV P9eHoOU2MHuGcUrPyuAilYSj5PLgHrDZ6M4h41mUo9LPbFcZbojRkDoBs2noUTsq CX7PoKPNi7X6ULoa8DIlqh5seF9mYOaMzNnrHn1pT1cN1RuEFBqpIU1vyWINSjSw D5Pkqw6looB4SD6ufFu3Vg7Cyb2B2+Qbb4N3yNEN4Fkkcey28efX/XLg9OmtXcby 4bZIjtbX7N4BoNqVxD4dNeUDUA8mhveSwW2Yznk85ellpqakj2VoAoiDNEynsYeJ yRaLsjdpNXlzDRMhbVBXj6g2P0jLsBGEOcVrRcF+79//iSYEnvHibhlnfLCSu8om 4CCYknJCyJaEaxj5m9MYB9KyB9OKj5cCK6t5fz6SSvQwjKRKYDN0MJYfvDfjd4g6 UpsStmBCOLEmvVjbBv9p =6zez -----END PGP SIGNATURE----- --Sig_/dq1ceOkm3aU3KezA0sqvhoV--