diff mbox series

[kvm-unit-tests,9/9] s390x: skrf: Fix tprot assembly

Message ID 20210922071811.1913-10-frankja@linux.ibm.com (mailing list archive)
State New, archived
Headers show
Series s390x: Cleanup and maintenance 2 | expand

Commit Message

Janosch Frank Sept. 22, 2021, 7:18 a.m. UTC
It's a base + displacement address so we need to address it via 0(%[addr]).

Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
---
 s390x/skrf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Claudio Imbrenda Sept. 22, 2021, 9:34 a.m. UTC | #1
On Wed, 22 Sep 2021 07:18:11 +0000
Janosch Frank <frankja@linux.ibm.com> wrote:

> It's a base + displacement address so we need to address it via 0(%[addr]).
> 
> Signed-off-by: Janosch Frank <frankja@linux.ibm.com>

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

but see comment below

> ---
>  s390x/skrf.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/s390x/skrf.c b/s390x/skrf.c
> index 8ca7588c..84fb762c 100644
> --- a/s390x/skrf.c
> +++ b/s390x/skrf.c
> @@ -103,7 +103,7 @@ static void test_tprot(void)
>  {
>  	report_prefix_push("tprot");
>  	expect_pgm_int();
> -	asm volatile("tprot	%[addr],0xf0(0)\n"
> +	asm volatile("tprot	0(%[addr]),0xf0(0)\n"

I think the displacement defaults to 0 if not specified?

did you get a warning, or why are you changing this now?

>  		     : : [addr] "a" (pagebuf) : );
>  	check_pgm_int_code(PGM_INT_CODE_SPECIAL_OPERATION);
>  	report_prefix_pop();
Janosch Frank Sept. 22, 2021, 11:47 a.m. UTC | #2
On 9/22/21 11:34 AM, Claudio Imbrenda wrote:
> On Wed, 22 Sep 2021 07:18:11 +0000
> Janosch Frank <frankja@linux.ibm.com> wrote:
> 
>> It's a base + displacement address so we need to address it via 0(%[addr]).
>>
>> Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
> 
> Reviewed-by: Claudio Imbrenda <imbrenda@linux.ibm.com>
> 
> but see comment below
> 
>> ---
>>  s390x/skrf.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/s390x/skrf.c b/s390x/skrf.c
>> index 8ca7588c..84fb762c 100644
>> --- a/s390x/skrf.c
>> +++ b/s390x/skrf.c
>> @@ -103,7 +103,7 @@ static void test_tprot(void)
>>  {
>>  	report_prefix_push("tprot");
>>  	expect_pgm_int();
>> -	asm volatile("tprot	%[addr],0xf0(0)\n"
>> +	asm volatile("tprot	0(%[addr]),0xf0(0)\n"
> 
> I think the displacement defaults to 0 if not specified?
> 
> did you get a warning, or why are you changing this now?

It fixes one of the ~18 clang warnings and making it explicit directly
tells you it's a B+D instruction i.e. it looks cleaner to me.

> 
>>  		     : : [addr] "a" (pagebuf) : );
>>  	check_pgm_int_code(PGM_INT_CODE_SPECIAL_OPERATION);
>>  	report_prefix_pop();
>
Janosch Frank Sept. 22, 2021, 1:53 p.m. UTC | #3
On 9/22/21 3:41 PM, Janis Schoetterl-Glausch wrote:
> On Wed, Sep 22, 2021 at 07:18:11AM +0000, Janosch Frank wrote:
>> It's a base + displacement address so we need to address it via 0(%[addr]).
>>
>> Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
>> ---
>>  s390x/skrf.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/s390x/skrf.c b/s390x/skrf.c
>> index 8ca7588c..84fb762c 100644
>> --- a/s390x/skrf.c
>> +++ b/s390x/skrf.c
>> @@ -103,7 +103,7 @@ static void test_tprot(void)
>>  {
>>  	report_prefix_push("tprot");
>>  	expect_pgm_int();
>> -	asm volatile("tprot	%[addr],0xf0(0)\n"
>> +	asm volatile("tprot	0(%[addr]),0xf0(0)\n"
>>  		     : : [addr] "a" (pagebuf) : );
>>  	check_pgm_int_code(PGM_INT_CODE_SPECIAL_OPERATION);
>>  	report_prefix_pop();
>> -- 
>> 2.30.2
>>
> 
> Let's add an argument to tprot instead.

Sure, LGTM

> -- >8 --
> Subject: [kvm-unit-tests PATCH] lib: s390x: Add access key argument to tprot
> 
> Currently there is only one callee passing a non zero key,
> but having the argument will be useful in the future.
> 
> Signed-off-by: Janis Schoetterl-Glausch <scgl@linux.ibm.com>
> ---
>  lib/s390x/asm/arch_def.h | 6 +++---
>  lib/s390x/sclp.c         | 2 +-
>  s390x/skrf.c             | 3 +--
>  3 files changed, 5 insertions(+), 6 deletions(-)
> 
> diff --git a/lib/s390x/asm/arch_def.h b/lib/s390x/asm/arch_def.h
> index 302ef1f..55f3124 100644
> --- a/lib/s390x/asm/arch_def.h
> +++ b/lib/s390x/asm/arch_def.h
> @@ -206,15 +206,15 @@ static inline unsigned short stap(void)
>  	return cpu_address;
>  }
>  
> -static inline int tprot(unsigned long addr)
> +static inline int tprot(unsigned long addr, char access_key)
>  {
>  	int cc;
>  
>  	asm volatile(
> -		"	tprot	0(%1),0\n"
> +		"	tprot	0(%1),0(%2)\n"
>  		"	ipm	%0\n"
>  		"	srl	%0,28\n"
> -		: "=d" (cc) : "a" (addr) : "cc");
> +		: "=d" (cc) : "a" (addr), "a" (access_key << 4) : "cc");
>  	return cc;
>  }
>  
> diff --git a/lib/s390x/sclp.c b/lib/s390x/sclp.c
> index 9502d16..0272249 100644
> --- a/lib/s390x/sclp.c
> +++ b/lib/s390x/sclp.c
> @@ -217,7 +217,7 @@ void sclp_memory_setup(void)
>  	/* probe for r/w memory up to max memory size */
>  	while (ram_size < max_ram_size) {
>  		expect_pgm_int();
> -		cc = tprot(ram_size + storage_increment_size - 1);
> +		cc = tprot(ram_size + storage_increment_size - 1, 0);
>  		/* stop once we receive an exception or have protected memory */
>  		if (clear_pgm_int() || cc != 0)
>  			break;
> diff --git a/s390x/skrf.c b/s390x/skrf.c
> index 9488c32..e0a1007 100644
> --- a/s390x/skrf.c
> +++ b/s390x/skrf.c
> @@ -102,8 +102,7 @@ static void test_tprot(void)
>  {
>  	report_prefix_push("tprot");
>  	expect_pgm_int();
> -	asm volatile("tprot	%[addr],0xf0(0)\n"
> -		     : : [addr] "a" (pagebuf) : );
> +	tprot((unsigned long)pagebuf, 0xf);
>  	check_pgm_int_code(PGM_INT_CODE_SPECIAL_OPERATION);
>  	report_prefix_pop();
>  }
>
diff mbox series

Patch

diff --git a/s390x/skrf.c b/s390x/skrf.c
index 8ca7588c..84fb762c 100644
--- a/s390x/skrf.c
+++ b/s390x/skrf.c
@@ -103,7 +103,7 @@  static void test_tprot(void)
 {
 	report_prefix_push("tprot");
 	expect_pgm_int();
-	asm volatile("tprot	%[addr],0xf0(0)\n"
+	asm volatile("tprot	0(%[addr]),0xf0(0)\n"
 		     : : [addr] "a" (pagebuf) : );
 	check_pgm_int_code(PGM_INT_CODE_SPECIAL_OPERATION);
 	report_prefix_pop();