Re: [RFC PATCH v2 4/4] arm64: Export id_aar64fpr0 via sysfs

Marc Zyngier
2020-10-21T11:11:35Z

On 2020-10-21 11:46, Qais Yousef wrote:
> So that userspace can detect if the cpu has aarch32 support at EL0.
>
> CPUREGS_ATTR_RO() was renamed to CPUREGS_RAW_ATTR_RO() to better
> reflect
> what it does. And fixed to accept both u64 and u32 without causing the
> printf to print out a warning about mismatched type. This was caught
> while testing to check the new CPUREGS_USER_ATTR_RO().
>
> The new CPUREGS_USER_ATTR_RO() exports a Sanitised or RAW sys_reg based
> on a @cond to user space. The exported fields match the definition in
> arm64_ftr_reg so that the content of a register exported via MRS and
> sysfs are kept cohesive.
>
> The @cond in our case is that the system is asymmetric aarch32 and the
> controlling sysctl.enable_asym_32bit is enabled.
>
> Update Documentation/arm64/cpu-feature-registers.rst to reflect the
> newly visible EL0 field in ID_AA64FPR0_EL1.
>
> Note that the MRS interface will still return the sanitized content
> _only_.
>
> Signed-off-by: Qais Yousef <qais.yousef@arm.com>
> ---
>
> Example output. I was surprised that the 2nd field (bits[7:4]) is
> printed out
> although it's set as FTR_HIDDEN.
>
> # cat /sys/devices/system/cpu/cpu*/regs/identification/id_aa64pfr0
> 0x0000000000000011
> 0x0000000000000011
> 0x0000000000000011
> 0x0000000000000011
> 0x0000000000000011
> 0x0000000000000011
>
> # echo 1 > /proc/sys/kernel/enable_asym_32bit
>
> # cat /sys/devices/system/cpu/cpu*/regs/identification/id_aa64pfr0
> 0x0000000000000011
> 0x0000000000000011
> 0x0000000000000012
> 0x0000000000000012
> 0x0000000000000011
> 0x0000000000000011

This looks like a terrible userspace interface. It exposes unrelated
features,
and doesn't expose the single useful information that the kernel has:
the cpumask describing the CPUs supporting AArch32 at EL0. Why not
expose
this synthetic piece of information which requires very little effort
from
userspace and doesn't spit out unrelated stuff? Not to mention the
discrepancy
with what userspace gets while reading the same register via the MRS
emulation.

Granted, the cpumask doesn't fit the cpu*/regs/identification hierarchy,
but I don't think this fits either.

M.
--
Jazz is not dead. It just smells funny...