Re: [PATCH v3 11/16] powerpc/pseries/svm: Export guest SVM status to user space via sysfs

From: Thiago Jung Bauermann
Date: Mon Aug 12 2019 - 19:22:34 EST



Michael Ellerman <mpe@xxxxxxxxxxxxxx> writes:

> Thiago Jung Bauermann <bauerman@xxxxxxxxxxxxx> writes:
>> From: Ryan Grimm <grimm@xxxxxxxxxxxxxxxxxx>
>>
>> User space might want to know it's running in a secure VM. It can't do
>> a mfmsr because mfmsr is a privileged instruction.
>>
>> The solution here is to create a cpu attribute:
>>
>> /sys/devices/system/cpu/svm
>>
>> which will read 0 or 1 based on the S bit of the guest's CPU 0.
>
> Why CPU 0?
>
> If we have different CPUs running with different MSR_S then something
> has gone badly wrong, no?

Yes, that would be very bad.

> So can't we just read the MSR on whatever CPU the sysfs code happens to
> run on.

Good point. I made the change in the patch below.

--
Thiago Jung Bauermann
IBM Linux Technology Center