public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [kvm-unit-tests PATCH] s390x/intercept: Test invalid prefix argument to SET PREFIX
@ 2022-06-27 12:43 Janis Schoetterl-Glausch
  2022-06-27 12:52 ` Claudio Imbrenda
  0 siblings, 1 reply; 3+ messages in thread
From: Janis Schoetterl-Glausch @ 2022-06-27 12:43 UTC (permalink / raw)
  To: Thomas Huth, Janosch Frank, Claudio Imbrenda
  Cc: Janis Schoetterl-Glausch, David Hildenbrand, kvm, linux-s390

According to the architecture, SET PREFIX must try to access the new
prefix area and recognize an addressing exception if the area is not
accessible.
Test that the exception occurs when we try to set a prefix higher
than the available memory.

Signed-off-by: Janis Schoetterl-Glausch <scgl@linux.ibm.com>
---
 s390x/intercept.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/s390x/intercept.c b/s390x/intercept.c
index 86e57e11..0b90e588 100644
--- a/s390x/intercept.c
+++ b/s390x/intercept.c
@@ -74,6 +74,20 @@ static void test_spx(void)
 	expect_pgm_int();
 	asm volatile(" spx 0(%0) " : : "r"(-8L));
 	check_pgm_int_code(PGM_INT_CODE_ADDRESSING);
+
+	new_prefix = get_ram_size() & 0x7fffe000;
+	if (get_ram_size() - new_prefix < 2 * PAGE_SIZE) {
+		expect_pgm_int();
+		asm volatile("spx	%0 " : : "Q"(new_prefix));
+		check_pgm_int_code(PGM_INT_CODE_ADDRESSING);
+
+		/*
+		 * Cannot test inaccessibility of the second page the same way.
+		 * If we try to use the last page as first half of the prefix
+		 * area and our ram size is a multiple of 8k, after SPX aligns
+		 * the address to 8k we have a completely accessible area.
+		 */
+	}
 }
 
 /* Test the STORE CPU ADDRESS instruction */

base-commit: 110c69492b53f0070e1bbce986fb635e72a423b4
-- 
2.36.1


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

* Re: [kvm-unit-tests PATCH] s390x/intercept: Test invalid prefix argument to SET PREFIX
  2022-06-27 12:43 [kvm-unit-tests PATCH] s390x/intercept: Test invalid prefix argument to SET PREFIX Janis Schoetterl-Glausch
@ 2022-06-27 12:52 ` Claudio Imbrenda
  2022-06-27 12:58   ` Janis Schoetterl-Glausch
  0 siblings, 1 reply; 3+ messages in thread
From: Claudio Imbrenda @ 2022-06-27 12:52 UTC (permalink / raw)
  To: Janis Schoetterl-Glausch
  Cc: Thomas Huth, Janosch Frank, David Hildenbrand, kvm, linux-s390

On Mon, 27 Jun 2022 14:43:56 +0200
Janis Schoetterl-Glausch <scgl@linux.ibm.com> wrote:

> According to the architecture, SET PREFIX must try to access the new
> prefix area and recognize an addressing exception if the area is not
> accessible.
> Test that the exception occurs when we try to set a prefix higher
> than the available memory.
> 
> Signed-off-by: Janis Schoetterl-Glausch <scgl@linux.ibm.com>
> ---
>  s390x/intercept.c | 14 ++++++++++++++
>  1 file changed, 14 insertions(+)
> 
> diff --git a/s390x/intercept.c b/s390x/intercept.c
> index 86e57e11..0b90e588 100644
> --- a/s390x/intercept.c
> +++ b/s390x/intercept.c
> @@ -74,6 +74,20 @@ static void test_spx(void)
>  	expect_pgm_int();
>  	asm volatile(" spx 0(%0) " : : "r"(-8L));
>  	check_pgm_int_code(PGM_INT_CODE_ADDRESSING);
> +
> +	new_prefix = get_ram_size() & 0x7fffe000;
> +	if (get_ram_size() - new_prefix < 2 * PAGE_SIZE) {
> +		expect_pgm_int();
> +		asm volatile("spx	%0 " : : "Q"(new_prefix));
> +		check_pgm_int_code(PGM_INT_CODE_ADDRESSING);
> +
> +		/*
> +		 * Cannot test inaccessibility of the second page the same way.
> +		 * If we try to use the last page as first half of the prefix
> +		 * area and our ram size is a multiple of 8k, after SPX aligns
> +		 * the address to 8k we have a completely accessible area.
> +		 */
> +	}

please add something like:

else {
	report_skip("Inaccessible prefix");
}

>  }
>  
>  /* Test the STORE CPU ADDRESS instruction */
> 
> base-commit: 110c69492b53f0070e1bbce986fb635e72a423b4


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

* Re: [kvm-unit-tests PATCH] s390x/intercept: Test invalid prefix argument to SET PREFIX
  2022-06-27 12:52 ` Claudio Imbrenda
@ 2022-06-27 12:58   ` Janis Schoetterl-Glausch
  0 siblings, 0 replies; 3+ messages in thread
From: Janis Schoetterl-Glausch @ 2022-06-27 12:58 UTC (permalink / raw)
  To: Claudio Imbrenda
  Cc: Thomas Huth, Janosch Frank, David Hildenbrand, kvm, linux-s390

On 6/27/22 14:52, Claudio Imbrenda wrote:
> On Mon, 27 Jun 2022 14:43:56 +0200
> Janis Schoetterl-Glausch <scgl@linux.ibm.com> wrote:
> 
>> According to the architecture, SET PREFIX must try to access the new
>> prefix area and recognize an addressing exception if the area is not
>> accessible.
>> Test that the exception occurs when we try to set a prefix higher
>> than the available memory.
>>
>> Signed-off-by: Janis Schoetterl-Glausch <scgl@linux.ibm.com>
>> ---
>>  s390x/intercept.c | 14 ++++++++++++++
>>  1 file changed, 14 insertions(+)
>>
>> diff --git a/s390x/intercept.c b/s390x/intercept.c
>> index 86e57e11..0b90e588 100644
>> --- a/s390x/intercept.c
>> +++ b/s390x/intercept.c
>> @@ -74,6 +74,20 @@ static void test_spx(void)
>>  	expect_pgm_int();
>>  	asm volatile(" spx 0(%0) " : : "r"(-8L));
>>  	check_pgm_int_code(PGM_INT_CODE_ADDRESSING);
>> +
>> +	new_prefix = get_ram_size() & 0x7fffe000;
>> +	if (get_ram_size() - new_prefix < 2 * PAGE_SIZE) {
>> +		expect_pgm_int();
>> +		asm volatile("spx	%0 " : : "Q"(new_prefix));
>> +		check_pgm_int_code(PGM_INT_CODE_ADDRESSING);
>> +
>> +		/*
>> +		 * Cannot test inaccessibility of the second page the same way.
>> +		 * If we try to use the last page as first half of the prefix
>> +		 * area and our ram size is a multiple of 8k, after SPX aligns
>> +		 * the address to 8k we have a completely accessible area.
>> +		 */
>> +	}
> 
> please add something like:
> 
> else {
> 	report_skip("Inaccessible prefix");
> }
> 

Yeah, good idea.

Is there any low effort way of generating an invalid prefix other than > ram_size ?
That might then allow for testing the second page also.

>>  }
>>  
>>  /* Test the STORE CPU ADDRESS instruction */
>>
>> base-commit: 110c69492b53f0070e1bbce986fb635e72a423b4
> 


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

end of thread, other threads:[~2022-06-27 12:59 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-06-27 12:43 [kvm-unit-tests PATCH] s390x/intercept: Test invalid prefix argument to SET PREFIX Janis Schoetterl-Glausch
2022-06-27 12:52 ` Claudio Imbrenda
2022-06-27 12:58   ` Janis Schoetterl-Glausch

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox