linux-s390.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [kvm-unit-tests PATCH v1] s390x: spec_ex: Add test for misaligned load
@ 2023-03-01 13:26 Nina Schoetterl-Glausch
  2023-03-06 10:59 ` Claudio Imbrenda
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Nina Schoetterl-Glausch @ 2023-03-01 13:26 UTC (permalink / raw)
  To: Thomas Huth, Janosch Frank, Claudio Imbrenda
  Cc: Nina Schoetterl-Glausch, David Hildenbrand, kvm, linux-s390

The operand of LOAD RELATIVE LONG must be word aligned, otherwise a
specification exception occurs. Test that this exception occurs.

Signed-off-by: Nina Schoetterl-Glausch <nsg@linux.ibm.com>
---


Noticed while writing another test that TCG fails this requirement,
so thought it best do document this in the form of a test.


 s390x/spec_ex.c | 21 +++++++++++++++++++--
 1 file changed, 19 insertions(+), 2 deletions(-)

diff --git a/s390x/spec_ex.c b/s390x/spec_ex.c
index 42ecaed3..42e86070 100644
--- a/s390x/spec_ex.c
+++ b/s390x/spec_ex.c
@@ -136,7 +136,7 @@ static int short_psw_bit_12_is_0(void)
 	return 0;
 }
 
-static int bad_alignment(void)
+static int bad_alignment_lqp(void)
 {
 	uint32_t words[5] __attribute__((aligned(16)));
 	uint32_t (*bad_aligned)[4] = (uint32_t (*)[4])&words[1];
@@ -149,6 +149,22 @@ static int bad_alignment(void)
 	return 0;
 }
 
+static int bad_alignment_lrl(void)
+{
+	uint64_t r;
+
+	asm volatile ( ".pushsection .rodata\n"
+		"	.balign	4\n"
+		"	. = . + 2\n"
+		"0:	.fill	4\n"
+		"	.popsection\n"
+
+		"	lrl	%0,0b\n"
+		: "=d" (r)
+	);
+	return 0;
+}
+
 static int not_even(void)
 {
 	uint64_t quad[2] __attribute__((aligned(16))) = {0};
@@ -176,7 +192,8 @@ struct spec_ex_trigger {
 static const struct spec_ex_trigger spec_ex_triggers[] = {
 	{ "psw_bit_12_is_1", &psw_bit_12_is_1, false, &fixup_invalid_psw },
 	{ "short_psw_bit_12_is_0", &short_psw_bit_12_is_0, false, &fixup_invalid_psw },
-	{ "bad_alignment", &bad_alignment, true, NULL },
+	{ "bad_alignment_lqp", &bad_alignment_lqp, true, NULL },
+	{ "bad_alignment_lrl", &bad_alignment_lrl, true, NULL },
 	{ "not_even", &not_even, true, NULL },
 	{ NULL, NULL, false, NULL },
 };

base-commit: e3c5c3ef2524c58023073c0fadde2e8ae3c04ec6
-- 
2.36.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [kvm-unit-tests PATCH v1] s390x: spec_ex: Add test for misaligned load
  2023-03-01 13:26 [kvm-unit-tests PATCH v1] s390x: spec_ex: Add test for misaligned load Nina Schoetterl-Glausch
@ 2023-03-06 10:59 ` Claudio Imbrenda
  2023-03-06 11:31   ` Nina Schoetterl-Glausch
  2023-03-20 12:22 ` Claudio Imbrenda
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 6+ messages in thread
From: Claudio Imbrenda @ 2023-03-06 10:59 UTC (permalink / raw)
  To: Nina Schoetterl-Glausch
  Cc: Thomas Huth, Janosch Frank, David Hildenbrand, kvm, linux-s390

On Wed,  1 Mar 2023 14:26:38 +0100
Nina Schoetterl-Glausch <nsg@linux.ibm.com> wrote:

> The operand of LOAD RELATIVE LONG must be word aligned, otherwise a
> specification exception occurs. Test that this exception occurs.

you're only testing halfword misalignment; would it make sense to test
all possible misalignments? (it's only 3 of them after all)

> 
> Signed-off-by: Nina Schoetterl-Glausch <nsg@linux.ibm.com>
> ---
> 
> 
> Noticed while writing another test that TCG fails this requirement,
> so thought it best do document this in the form of a test.
> 
> 
>  s390x/spec_ex.c | 21 +++++++++++++++++++--
>  1 file changed, 19 insertions(+), 2 deletions(-)
> 
> diff --git a/s390x/spec_ex.c b/s390x/spec_ex.c
> index 42ecaed3..42e86070 100644
> --- a/s390x/spec_ex.c
> +++ b/s390x/spec_ex.c
> @@ -136,7 +136,7 @@ static int short_psw_bit_12_is_0(void)
>  	return 0;
>  }
>  
> -static int bad_alignment(void)
> +static int bad_alignment_lqp(void)
>  {
>  	uint32_t words[5] __attribute__((aligned(16)));
>  	uint32_t (*bad_aligned)[4] = (uint32_t (*)[4])&words[1];
> @@ -149,6 +149,22 @@ static int bad_alignment(void)
>  	return 0;
>  }
>  
> +static int bad_alignment_lrl(void)
> +{
> +	uint64_t r;
> +
> +	asm volatile ( ".pushsection .rodata\n"

why not declare this as a local array?

uint8_t stuff[8] __attribute__((aligned(8)));

> +		"	.balign	4\n"
> +		"	. = . + 2\n"
> +		"0:	.fill	4\n"
> +		"	.popsection\n"
> +
> +		"	lrl	%0,0b\n"
> +		: "=d" (r)

and here pass stuff + 1 or something like that?

less asm = more readable

> +	);
> +	return 0;
> +}
> +
>  static int not_even(void)
>  {
>  	uint64_t quad[2] __attribute__((aligned(16))) = {0};
> @@ -176,7 +192,8 @@ struct spec_ex_trigger {
>  static const struct spec_ex_trigger spec_ex_triggers[] = {
>  	{ "psw_bit_12_is_1", &psw_bit_12_is_1, false, &fixup_invalid_psw },
>  	{ "short_psw_bit_12_is_0", &short_psw_bit_12_is_0, false, &fixup_invalid_psw },
> -	{ "bad_alignment", &bad_alignment, true, NULL },
> +	{ "bad_alignment_lqp", &bad_alignment_lqp, true, NULL },
> +	{ "bad_alignment_lrl", &bad_alignment_lrl, true, NULL },
>  	{ "not_even", &not_even, true, NULL },
>  	{ NULL, NULL, false, NULL },
>  };
> 
> base-commit: e3c5c3ef2524c58023073c0fadde2e8ae3c04ec6


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [kvm-unit-tests PATCH v1] s390x: spec_ex: Add test for misaligned load
  2023-03-06 10:59 ` Claudio Imbrenda
@ 2023-03-06 11:31   ` Nina Schoetterl-Glausch
  0 siblings, 0 replies; 6+ messages in thread
From: Nina Schoetterl-Glausch @ 2023-03-06 11:31 UTC (permalink / raw)
  To: Claudio Imbrenda
  Cc: Thomas Huth, Janosch Frank, David Hildenbrand, kvm, linux-s390

On Mon, 2023-03-06 at 11:59 +0100, Claudio Imbrenda wrote:
> On Wed,  1 Mar 2023 14:26:38 +0100
> Nina Schoetterl-Glausch <nsg@linux.ibm.com> wrote:
> 
> > The operand of LOAD RELATIVE LONG must be word aligned, otherwise a
> > specification exception occurs. Test that this exception occurs.
> 
> you're only testing halfword misalignment; would it make sense to test
> all possible misalignments? (it's only 3 of them after all)

No, that's not possible, the address calculation is:
insn_addr + immediate * 2

So for LRL there is only one possible misalignment.
For LGRL there are multiple, tho.

> 
> > 
> > Signed-off-by: Nina Schoetterl-Glausch <nsg@linux.ibm.com>
> > ---
> > 
> > 
> > Noticed while writing another test that TCG fails this requirement,
> > so thought it best do document this in the form of a test.
> > 
> > 
> >  s390x/spec_ex.c | 21 +++++++++++++++++++--
> >  1 file changed, 19 insertions(+), 2 deletions(-)
> > 
> > diff --git a/s390x/spec_ex.c b/s390x/spec_ex.c
> > index 42ecaed3..42e86070 100644
> > --- a/s390x/spec_ex.c
> > +++ b/s390x/spec_ex.c
> > @@ -136,7 +136,7 @@ static int short_psw_bit_12_is_0(void)
> >  	return 0;
> >  }
> >  
> > -static int bad_alignment(void)
> > +static int bad_alignment_lqp(void)
> >  {
> >  	uint32_t words[5] __attribute__((aligned(16)));
> >  	uint32_t (*bad_aligned)[4] = (uint32_t (*)[4])&words[1];
> > @@ -149,6 +149,22 @@ static int bad_alignment(void)
> >  	return 0;
> >  }
> >  
> > +static int bad_alignment_lrl(void)
> > +{
> > +	uint64_t r;
> > +
> > +	asm volatile ( ".pushsection .rodata\n"
> 
> why not declare this as a local array?

I cannot put it on the stack, since I need a relative offset.
I guess I could use a global symbol, but that also makes the
test less self-contained.

> 
> uint8_t stuff[8] __attribute__((aligned(8)));
> 
> > +		"	.balign	4\n"
> > +		"	. = . + 2\n"
> > +		"0:	.fill	4\n"
> > +		"	.popsection\n"
> > +
> > +		"	lrl	%0,0b\n"
> > +		: "=d" (r)
> 
> and here pass stuff + 1 or something like that?
> 
> less asm = more readable
> 
> > +	);
> > +	return 0;
> > +}
> > +
> >  static int not_even(void)
> >  {
> >  	uint64_t quad[2] __attribute__((aligned(16))) = {0};
> > @@ -176,7 +192,8 @@ struct spec_ex_trigger {
> >  static const struct spec_ex_trigger spec_ex_triggers[] = {
> >  	{ "psw_bit_12_is_1", &psw_bit_12_is_1, false, &fixup_invalid_psw },
> >  	{ "short_psw_bit_12_is_0", &short_psw_bit_12_is_0, false, &fixup_invalid_psw },
> > -	{ "bad_alignment", &bad_alignment, true, NULL },
> > +	{ "bad_alignment_lqp", &bad_alignment_lqp, true, NULL },
> > +	{ "bad_alignment_lrl", &bad_alignment_lrl, true, NULL },
> >  	{ "not_even", &not_even, true, NULL },
> >  	{ NULL, NULL, false, NULL },
> >  };
> > 
> > base-commit: e3c5c3ef2524c58023073c0fadde2e8ae3c04ec6
> 


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [kvm-unit-tests PATCH v1] s390x: spec_ex: Add test for misaligned load
  2023-03-01 13:26 [kvm-unit-tests PATCH v1] s390x: spec_ex: Add test for misaligned load Nina Schoetterl-Glausch
  2023-03-06 10:59 ` Claudio Imbrenda
@ 2023-03-20 12:22 ` Claudio Imbrenda
  2023-03-22 14:55 ` Nico Boehr
  2023-03-23 12:42 ` Nico Boehr
  3 siblings, 0 replies; 6+ messages in thread
From: Claudio Imbrenda @ 2023-03-20 12:22 UTC (permalink / raw)
  To: Nina Schoetterl-Glausch
  Cc: Thomas Huth, Janosch Frank, David Hildenbrand, kvm, linux-s390

On Wed,  1 Mar 2023 14:26:38 +0100
Nina Schoetterl-Glausch <nsg@linux.ibm.com> wrote:

> The operand of LOAD RELATIVE LONG must be word aligned, otherwise a
> specification exception occurs. Test that this exception occurs.
> 
> Signed-off-by: Nina Schoetterl-Glausch <nsg@linux.ibm.com>

Reviewed-by: Claudio Imbrenda <imbrenda@linux.ibm.com>

> ---
> 
> 
> Noticed while writing another test that TCG fails this requirement,
> so thought it best do document this in the form of a test.
> 
> 
>  s390x/spec_ex.c | 21 +++++++++++++++++++--
>  1 file changed, 19 insertions(+), 2 deletions(-)
> 
> diff --git a/s390x/spec_ex.c b/s390x/spec_ex.c
> index 42ecaed3..42e86070 100644
> --- a/s390x/spec_ex.c
> +++ b/s390x/spec_ex.c
> @@ -136,7 +136,7 @@ static int short_psw_bit_12_is_0(void)
>  	return 0;
>  }
>  
> -static int bad_alignment(void)
> +static int bad_alignment_lqp(void)
>  {
>  	uint32_t words[5] __attribute__((aligned(16)));
>  	uint32_t (*bad_aligned)[4] = (uint32_t (*)[4])&words[1];
> @@ -149,6 +149,22 @@ static int bad_alignment(void)
>  	return 0;
>  }
>  
> +static int bad_alignment_lrl(void)
> +{
> +	uint64_t r;
> +
> +	asm volatile ( ".pushsection .rodata\n"
> +		"	.balign	4\n"
> +		"	. = . + 2\n"
> +		"0:	.fill	4\n"
> +		"	.popsection\n"
> +
> +		"	lrl	%0,0b\n"
> +		: "=d" (r)
> +	);
> +	return 0;
> +}
> +
>  static int not_even(void)
>  {
>  	uint64_t quad[2] __attribute__((aligned(16))) = {0};
> @@ -176,7 +192,8 @@ struct spec_ex_trigger {
>  static const struct spec_ex_trigger spec_ex_triggers[] = {
>  	{ "psw_bit_12_is_1", &psw_bit_12_is_1, false, &fixup_invalid_psw },
>  	{ "short_psw_bit_12_is_0", &short_psw_bit_12_is_0, false, &fixup_invalid_psw },
> -	{ "bad_alignment", &bad_alignment, true, NULL },
> +	{ "bad_alignment_lqp", &bad_alignment_lqp, true, NULL },
> +	{ "bad_alignment_lrl", &bad_alignment_lrl, true, NULL },
>  	{ "not_even", &not_even, true, NULL },
>  	{ NULL, NULL, false, NULL },
>  };
> 
> base-commit: e3c5c3ef2524c58023073c0fadde2e8ae3c04ec6


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [kvm-unit-tests PATCH v1] s390x: spec_ex: Add test for misaligned load
  2023-03-01 13:26 [kvm-unit-tests PATCH v1] s390x: spec_ex: Add test for misaligned load Nina Schoetterl-Glausch
  2023-03-06 10:59 ` Claudio Imbrenda
  2023-03-20 12:22 ` Claudio Imbrenda
@ 2023-03-22 14:55 ` Nico Boehr
  2023-03-23 12:42 ` Nico Boehr
  3 siblings, 0 replies; 6+ messages in thread
From: Nico Boehr @ 2023-03-22 14:55 UTC (permalink / raw)
  To: Claudio Imbrenda, Janosch Frank, Nina Schoetterl-Glausch, Thomas Huth
  Cc: Nina Schoetterl-Glausch, David Hildenbrand, kvm, linux-s390

Quoting Nina Schoetterl-Glausch (2023-03-01 14:26:38)
> The operand of LOAD RELATIVE LONG must be word aligned, otherwise a
> specification exception occurs. Test that this exception occurs.
> 
> Signed-off-by: Nina Schoetterl-Glausch <nsg@linux.ibm.com>

Reviewed-by: Nico Boehr <nrb@linux.ibm.com>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [kvm-unit-tests PATCH v1] s390x: spec_ex: Add test for misaligned load
  2023-03-01 13:26 [kvm-unit-tests PATCH v1] s390x: spec_ex: Add test for misaligned load Nina Schoetterl-Glausch
                   ` (2 preceding siblings ...)
  2023-03-22 14:55 ` Nico Boehr
@ 2023-03-23 12:42 ` Nico Boehr
  3 siblings, 0 replies; 6+ messages in thread
From: Nico Boehr @ 2023-03-23 12:42 UTC (permalink / raw)
  To: Claudio Imbrenda, Janosch Frank, Nina Schoetterl-Glausch, Thomas Huth
  Cc: Nina Schoetterl-Glausch, David Hildenbrand, kvm, linux-s390

Quoting Nina Schoetterl-Glausch (2023-03-01 14:26:38)
> The operand of LOAD RELATIVE LONG must be word aligned, otherwise a
> specification exception occurs. Test that this exception occurs.
> 
> Signed-off-by: Nina Schoetterl-Glausch <nsg@linux.ibm.com>

queued, thanks.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-03-23 12:43 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-01 13:26 [kvm-unit-tests PATCH v1] s390x: spec_ex: Add test for misaligned load Nina Schoetterl-Glausch
2023-03-06 10:59 ` Claudio Imbrenda
2023-03-06 11:31   ` Nina Schoetterl-Glausch
2023-03-20 12:22 ` Claudio Imbrenda
2023-03-22 14:55 ` Nico Boehr
2023-03-23 12:42 ` Nico Boehr

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).