Re: [kvm-unit-tests PATCH 6/6] s390x: SMP test

Janosch Frank
2019-09-03T08:45:00Z

[-- Attachment #1.1: Type: text/plain, Size: 1945 bytes --]

On 9/2/19 5:40 PM, Thomas Huth wrote:
> On 29/08/2019 14.14, Janosch Frank wrote:
>> Testing SIGP emulation for the following order codes:
>> * start
>> * stop
>> * restart
>> * set prefix
>> * store status
>> * stop and store status
>> * reset
>> * initial reset
>> * external call
>> * emegergency call
>>
>> restart and set prefix are part of the library and needed to start
>> other cpus.
>>
>> Signed-off-by: Janosch Frank <frankja@linux.ibm.com>
>> ---
[...]
>> +static void test_stop(void)
>> +{
>> + int i = 0;
>> +
>> + smp_cpu_stop(1);
>> + /*
>> + * The smp library waits for the CPU to shut down, but let's
>> + * also do it here, so we don't rely on the library
>> + * implementation
>> + */
>> + while (!smp_cpu_stopped(1)) {}
>> + t = 0;
>> + /* Let's leave some time for cpu #2 to change t */
>
> CPU #2 ? Where? Why?
>
>> + for (; i < 0x100000; i++) {}
>
> I'm pretty sure the compiler optimizes empty loops away.

Yeah, I removed all of that...

>
>> + report("stop", !t);
>> +}
>> +
>> +static void test_stop_store_status(void)
>> +{
>> + struct cpu *cpu = smp_cpu_from_addr(1);
>> + struct lowcore *lc = (void *)0x0;
>
> Do you want to erase the values in the save area before calling the
> "store_status"? ... just to be sure that we don't see old values there?

Well at least resetting the prefix and gr15 to 0

>
>> + smp_cpu_stop_store_status(1);
>> + mb();
>> + report("stop store status",
>> + lc->prefix_sa == (uint32_t)(uintptr_t)cpu->lowcore);
>
> That confused me. Why does the prefix_sa of the lowcore of CPU 0 match
> the prefix of CPU 1 ? I'd rather expect cpu->lowcore->prefix_sa to
> contain this value?

Store status saves at absolute 0, i.e. we get the status in cpu0's lowcore.

>
> Maybe you could also check that at least the stack pointer GPR is != 0
> in the save area?

Sure, I also fixed everything below

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]