[kvm-unit-tests,v3,8/9] s390x: smp: Test all CRs on initial reset
diff mbox series

Message ID 20200117104640.1983-9-frankja@linux.ibm.com
State New
Headers show
Series
  • s390x: smp: Improve smp code and reset checks
Related show

Commit Message

Janosch Frank Jan. 17, 2020, 10:46 a.m. UTC
All CRs are set to 0 and CRs 0 and 14 are set to pre-defined values,
so we also need to test 1-13 and 15 for 0.

And while we're at it, let's also set some values to cr 1, 7 and 13, so
we can actually be sure that they will be zeroed.

Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
---
 s390x/smp.c | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

Comments

Cornelia Huck Jan. 20, 2020, 11:44 a.m. UTC | #1
On Fri, 17 Jan 2020 05:46:39 -0500
Janosch Frank <frankja@linux.ibm.com> wrote:

> All CRs are set to 0 and CRs 0 and 14 are set to pre-defined values,
> so we also need to test 1-13 and 15 for 0.
> 
> And while we're at it, let's also set some values to cr 1, 7 and 13, so
> we can actually be sure that they will be zeroed.
> 
> Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
> ---
>  s390x/smp.c | 18 +++++++++++++++++-
>  1 file changed, 17 insertions(+), 1 deletion(-)

Reviewed-by: Cornelia Huck <cohuck@redhat.com>
David Hildenbrand Jan. 20, 2020, 12:10 p.m. UTC | #2
On 17.01.20 11:46, Janosch Frank wrote:
> All CRs are set to 0 and CRs 0 and 14 are set to pre-defined values,
> so we also need to test 1-13 and 15 for 0.
> 
> And while we're at it, let's also set some values to cr 1, 7 and 13, so
> we can actually be sure that they will be zeroed.
> 
> Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
> ---
>  s390x/smp.c | 18 +++++++++++++++++-
>  1 file changed, 17 insertions(+), 1 deletion(-)
> 
> diff --git a/s390x/smp.c b/s390x/smp.c
> index c12a3db..1385488 100644
> --- a/s390x/smp.c
> +++ b/s390x/smp.c
> @@ -169,16 +169,30 @@ static void test_emcall(void)
>  	report_prefix_pop();
>  }
>  
> +/* Used to dirty registers of cpu #1 before it is reset */
> +static void test_func_initial(void)
> +{
> +	lctlg(1, 0x42000UL);
> +	lctlg(7, 0x43000UL);
> +	lctlg(13, 0x44000UL);
> +	mb();
> +	testflag = 1;
> +}
> +
>  static void test_reset_initial(void)
>  {
>  	struct cpu_status *status = alloc_pages(0);
> +	uint64_t nullp[12] = {};
>  	struct psw psw;
>  
>  	psw.mask = extract_psw_mask();
> -	psw.addr = (unsigned long)test_func;
> +	psw.addr = (unsigned long)test_func_initial;
>  
>  	report_prefix_push("reset initial");
> +	testflag = 0;
> +	mb();

maybe use a  set_flag() function like

mb();
testflag = val;
mb();

and use it everywhere you set the flag? (e.g., in test_func_initial())

Apart from that

Reviewed-by: David Hildenbrand <david@redhat.com>

>  	smp_cpu_start(1, psw);
> +	wait_for_flag();
>  
>  	sigp_retry(1, SIGP_INITIAL_CPU_RESET, 0, NULL);
>  	sigp(1, SIGP_STORE_STATUS_AT_ADDRESS, (uintptr_t)status, NULL);
> @@ -189,6 +203,8 @@ static void test_reset_initial(void)
>  	report(!status->fpc, "fpc");
>  	report(!status->cputm, "cpu timer");
>  	report(!status->todpr, "todpr");
> +	report(!memcmp(&status->crs[1], nullp, sizeof(status->crs[1]) * 12), "cr1-13 == 0");
> +	report(status->crs[15] == 0, "cr15 == 0");
>  	report_prefix_pop();
>  
>  	report_prefix_push("initialized");
>
Janosch Frank Jan. 20, 2020, 2:49 p.m. UTC | #3
On 1/20/20 1:10 PM, David Hildenbrand wrote:
> On 17.01.20 11:46, Janosch Frank wrote:
>> All CRs are set to 0 and CRs 0 and 14 are set to pre-defined values,
>> so we also need to test 1-13 and 15 for 0.
>>
>> And while we're at it, let's also set some values to cr 1, 7 and 13, so
>> we can actually be sure that they will be zeroed.
>>
>> Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
>> ---
>>  s390x/smp.c | 18 +++++++++++++++++-
>>  1 file changed, 17 insertions(+), 1 deletion(-)
>>
>> diff --git a/s390x/smp.c b/s390x/smp.c
>> index c12a3db..1385488 100644
>> --- a/s390x/smp.c
>> +++ b/s390x/smp.c
>> @@ -169,16 +169,30 @@ static void test_emcall(void)
>>  	report_prefix_pop();
>>  }
>>  
>> +/* Used to dirty registers of cpu #1 before it is reset */
>> +static void test_func_initial(void)
>> +{
>> +	lctlg(1, 0x42000UL);
>> +	lctlg(7, 0x43000UL);
>> +	lctlg(13, 0x44000UL);
>> +	mb();
>> +	testflag = 1;
>> +}
>> +
>>  static void test_reset_initial(void)
>>  {
>>  	struct cpu_status *status = alloc_pages(0);
>> +	uint64_t nullp[12] = {};
>>  	struct psw psw;
>>  
>>  	psw.mask = extract_psw_mask();
>> -	psw.addr = (unsigned long)test_func;
>> +	psw.addr = (unsigned long)test_func_initial;
>>  
>>  	report_prefix_push("reset initial");
>> +	testflag = 0;
>> +	mb();
> 
> maybe use a  set_flag() function like
> 
> mb();
> testflag = val;
> mb();
> 
> and use it everywhere you set the flag? (e.g., in test_func_initial())

Hmm, so basically a set_test_flag() function in a new patch :)
Ok, I'll have a look.

> 
> Apart from that
> 
> Reviewed-by: David Hildenbrand <david@redhat.com>
> 
>>  	smp_cpu_start(1, psw);
>> +	wait_for_flag();
>>  
>>  	sigp_retry(1, SIGP_INITIAL_CPU_RESET, 0, NULL);
>>  	sigp(1, SIGP_STORE_STATUS_AT_ADDRESS, (uintptr_t)status, NULL);
>> @@ -189,6 +203,8 @@ static void test_reset_initial(void)
>>  	report(!status->fpc, "fpc");
>>  	report(!status->cputm, "cpu timer");
>>  	report(!status->todpr, "todpr");
>> +	report(!memcmp(&status->crs[1], nullp, sizeof(status->crs[1]) * 12), "cr1-13 == 0");
>> +	report(status->crs[15] == 0, "cr15 == 0");
>>  	report_prefix_pop();
>>  
>>  	report_prefix_push("initialized");
>>
> 
>
David Hildenbrand Jan. 20, 2020, 2:53 p.m. UTC | #4
On 20.01.20 15:49, Janosch Frank wrote:
> On 1/20/20 1:10 PM, David Hildenbrand wrote:
>> On 17.01.20 11:46, Janosch Frank wrote:
>>> All CRs are set to 0 and CRs 0 and 14 are set to pre-defined values,
>>> so we also need to test 1-13 and 15 for 0.
>>>
>>> And while we're at it, let's also set some values to cr 1, 7 and 13, so
>>> we can actually be sure that they will be zeroed.
>>>
>>> Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
>>> ---
>>>  s390x/smp.c | 18 +++++++++++++++++-
>>>  1 file changed, 17 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/s390x/smp.c b/s390x/smp.c
>>> index c12a3db..1385488 100644
>>> --- a/s390x/smp.c
>>> +++ b/s390x/smp.c
>>> @@ -169,16 +169,30 @@ static void test_emcall(void)
>>>  	report_prefix_pop();
>>>  }
>>>  
>>> +/* Used to dirty registers of cpu #1 before it is reset */
>>> +static void test_func_initial(void)
>>> +{
>>> +	lctlg(1, 0x42000UL);
>>> +	lctlg(7, 0x43000UL);
>>> +	lctlg(13, 0x44000UL);
>>> +	mb();
>>> +	testflag = 1;
>>> +}
>>> +
>>>  static void test_reset_initial(void)
>>>  {
>>>  	struct cpu_status *status = alloc_pages(0);
>>> +	uint64_t nullp[12] = {};
>>>  	struct psw psw;
>>>  
>>>  	psw.mask = extract_psw_mask();
>>> -	psw.addr = (unsigned long)test_func;
>>> +	psw.addr = (unsigned long)test_func_initial;
>>>  
>>>  	report_prefix_push("reset initial");
>>> +	testflag = 0;
>>> +	mb();
>>
>> maybe use a  set_flag() function like
>>
>> mb();
>> testflag = val;
>> mb();
>>
>> and use it everywhere you set the flag? (e.g., in test_func_initial())
> 
> Hmm, so basically a set_test_flag() function in a new patch :)
> Ok, I'll have a look.

Sorry that this patch set keeps exploding :)

Patch
diff mbox series

diff --git a/s390x/smp.c b/s390x/smp.c
index c12a3db..1385488 100644
--- a/s390x/smp.c
+++ b/s390x/smp.c
@@ -169,16 +169,30 @@  static void test_emcall(void)
 	report_prefix_pop();
 }
 
+/* Used to dirty registers of cpu #1 before it is reset */
+static void test_func_initial(void)
+{
+	lctlg(1, 0x42000UL);
+	lctlg(7, 0x43000UL);
+	lctlg(13, 0x44000UL);
+	mb();
+	testflag = 1;
+}
+
 static void test_reset_initial(void)
 {
 	struct cpu_status *status = alloc_pages(0);
+	uint64_t nullp[12] = {};
 	struct psw psw;
 
 	psw.mask = extract_psw_mask();
-	psw.addr = (unsigned long)test_func;
+	psw.addr = (unsigned long)test_func_initial;
 
 	report_prefix_push("reset initial");
+	testflag = 0;
+	mb();
 	smp_cpu_start(1, psw);
+	wait_for_flag();
 
 	sigp_retry(1, SIGP_INITIAL_CPU_RESET, 0, NULL);
 	sigp(1, SIGP_STORE_STATUS_AT_ADDRESS, (uintptr_t)status, NULL);
@@ -189,6 +203,8 @@  static void test_reset_initial(void)
 	report(!status->fpc, "fpc");
 	report(!status->cputm, "cpu timer");
 	report(!status->todpr, "todpr");
+	report(!memcmp(&status->crs[1], nullp, sizeof(status->crs[1]) * 12), "cr1-13 == 0");
+	report(status->crs[15] == 0, "cr15 == 0");
 	report_prefix_pop();
 
 	report_prefix_push("initialized");