Re: [PATCH v3 11/16] powerpc/pseries/svm: Export guest SVM status to user space via sysfs
From: Thiago Jung Bauermann
Date: Thu Aug 15 2019 - 20:50:07 EST
Michael Ellerman <mpe@xxxxxxxxxxxxxx> writes:
> Thiago Jung Bauermann <bauerman@xxxxxxxxxxxxx> writes:
>> 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.
>
> 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