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

Thiago Jung Bauermann bauerman at linux.ibm.com
Fri Aug 16 10:49:26 AEST 2019


Michael Ellerman <mpe at ellerman.id.au> writes:

> Thiago Jung Bauermann <bauerman at linux.ibm.com> writes:
>> Michael Ellerman <mpe at ellerman.id.au> writes:
>>> Thiago Jung Bauermann <bauerman at linux.ibm.com> writes:
>>>> From: Ryan Grimm <grimm at linux.vnet.ibm.com>
>>>> 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.
>
> The patch looks good. Although, it raises the question of whether it
> should be an attribute of the CPU at all.
>
> I guess there's not obviously anywhere better for it.

Ok. TBH this patch is not as urgent as the others. It was added so that
tests have an easy way to tell if they're in an SVM. I can leave it out
for now to figure out if there's a better place for this information.

> Still you should document the attribute in Documentation/ABI/testing/sysfs-devices-system-cpu

Indedd, will do that.

--
Thiago Jung Bauermann
IBM Linux Technology Center


More information about the Linuxppc-dev mailing list