mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Catalin Marinas <catalin.marinas@arm.com>
To: Suzuki K Poulose <suzuki.poulose@arm.com>
Cc: linux-arm-kernel@lists.infradead.org, mark.rutland@arm.com,
	ryan.arnold@linaro.org, sid@reserved-bit.com, aph@redhat.com,
	will.deacon@arm.com, linux-kernel@vger.kernel.org,
	marc.zyngier@arm.com, adhemerval.zanella@linaro.org,
	dave.martin@arm.com
Subject: Re: [PATCH 9/9] arm64: Documentation - Expose CPU feature registers
Date: Thu, 24 Nov 2016 18:44:37 +0000	[thread overview]
Message-ID: <20161124184436.GG7452@e104818-lin.cambridge.arm.com> (raw)
In-Reply-To: <1479994809-9081-10-git-send-email-suzuki.poulose@arm.com>

Hi Suzuki,

On Thu, Nov 24, 2016 at 01:40:09PM +0000, Suzuki K. Poulose wrote:
> --- /dev/null
> +++ b/Documentation/arm64/cpu-feature-registers.txt
> @@ -0,0 +1,198 @@
> +		ARM64 CPU Feature Registers
> +		===========================
> +
> +Author: Suzuki K Poulose <suzuki.poulose@arm.com>
> +
> +
> +This file describes the API for exporting the AArch64 CPU ID/feature
> +registers to userspace. The availability of this API is advertised
> +via the HWCAP_CPUID in HWCAPs.

s/API/ABI/ maybe?

> +
> +1. Motivation
> +---------------
> +
> +The ARM architecture defines a set of feature registers, which describe
> +the capabilities of the CPU/system. Access to these system registers is
> +restricted from EL0 and there is no reliable way for an application to
> +extract this information to make better decisions at runtime. There is
> +limited information available to the application via HWCAPs, however
> +there are some issues with their usage.
> +
> + a) Any change to the HWCAPs requires an update to userspace (e.g libc)
> +    to detect the new changes, which can take a long time to appear in
> +    distributions. Exposing the registers allows applications to get the
> +    information without requiring updates to the toolchains.
> +
> + b) Access to HWCAPs is sometimes limited (e.g prior to libc, or
> +    when ld is initialised at startup time).
> +
> + c) HWCAPs cannot represent non-boolean information effectively. The
> +    architecture defines a canonical format for representing features
> +    in the ID registers; this is well defined and is capable of
> +    representing all valid architecture variations. Exposing the ID
> +    registers avoids having to come up with HWCAP representations and
> +    parsing code.

For point (c) above, we don't (yet?) have an actual case on AArch64
where HWCAP needs more than a boolean value.

And just to clarify my position: I consider that we should continue to
expose HWCAP for new features (e.g. SVE) in parallel with the CPUID
access emulation. There are different use-cases for them (i.e. dynamic
loader uses HWCAP for the ifunc resolver).

> +3. Implementation
> +--------------------
> +
> +The infrastructure is built on the emulation of the 'MRS' instruction.
> +Accessing a restricted system register from an application generates an
> +exception and ends up in SIGILL being delivered to the process.
> +The infrastructure hooks into the exception handler and emulates the
> +operation if the source belongs to the supported system register space.
> +
> +The infrastructure emulates only the following system register space:
> +	Op0=3, Op1=0, CRn=0
> +
> +(See Table C5-6 'System instruction encodings for non-Debug System
> +register accesses' in ARMv8 ARM DDI 0487A.h, for the list of
> +registers).
> +
> +
> +The following rules are applied to the value returned by the
> +infrastructure:
> +
> + a) The value of an 'IMPLEMENTATION DEFINED' field is set to 0.
> + b) The value of a reserved field is populated with the reserved
> +    value as defined by the architecture.
> + c) The value of a field marked as not 'visible', is set to indicate
> +    the feature is missing (as defined by the architecture).

I don't understand point (c) above. If it is marked as not 'visible', it
is always reported to user as 0. The above could be misinterpreted as
reporting missing architecture features.

[...]
> diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c
> index 94c188f..fb331de 100644
> --- a/arch/arm64/kernel/cpufeature.c
> +++ b/arch/arm64/kernel/cpufeature.c
> @@ -81,6 +81,10 @@ static bool __maybe_unused
>  cpufeature_pan_not_uao(const struct arm64_cpu_capabilities *entry, int __unused);
>  
>  
> +/*
> + * NOTE: Any changes to the visibility of features should be kept in
> + * sync with the documentation of the CPU feature register API.

s/API/ABI/

-- 
Catalin

  reply	other threads:[~2016-11-24 18:44 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-24 13:40 [PATCH 0/9] arm64: Expose CPUID registers via emulation Suzuki K Poulose
2016-11-24 13:40 ` [PATCH 1/9] arm64: cpufeature: treat unknown fields as RES0 Suzuki K Poulose
2016-11-24 13:40 ` [PATCH 2/9] arm64: cpufeature: remove explicit RAZ fields Suzuki K Poulose
2016-11-24 13:40 ` [PATCH 3/9] arm64: cpufeature: Cleanup feature bit tables Suzuki K Poulose
2016-11-24 13:40 ` [PATCH 4/9] arm64: cpufeature: Document the rules of safe value for features Suzuki K Poulose
2016-11-24 13:40 ` [PATCH 5/9] arm64: cpufeature: Define helpers for sys_reg id Suzuki K Poulose
2016-11-30 11:04   ` Will Deacon
2016-11-30 14:16     ` Suzuki K Poulose
2016-11-24 13:40 ` [PATCH 6/9] arm64: Add helper to decode register from instruction Suzuki K Poulose
2016-11-24 13:40 ` [PATCH 7/9] arm64: cpufeature: Track user visible fields Suzuki K Poulose
2016-11-24 13:40 ` [PATCH 8/9] arm64: cpufeature: Expose CPUID registers by emulation Suzuki K Poulose
2016-11-24 13:40 ` [PATCH 9/9] arm64: Documentation - Expose CPU feature registers Suzuki K Poulose
2016-11-24 18:44   ` Catalin Marinas [this message]
2016-11-30 11:41     ` Suzuki K Poulose
2016-11-30 11:14   ` Siddhesh Poyarekar
2016-11-30 11:30     ` Suzuki K Poulose
2016-11-30 11:33       ` Siddhesh Poyarekar
2016-11-30 11:31     ` Catalin Marinas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20161124184436.GG7452@e104818-lin.cambridge.arm.com \
    --to=catalin.marinas@arm.com \
    --cc=adhemerval.zanella@linaro.org \
    --cc=aph@redhat.com \
    --cc=dave.martin@arm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marc.zyngier@arm.com \
    --cc=mark.rutland@arm.com \
    --cc=ryan.arnold@linaro.org \
    --cc=sid@reserved-bit.com \
    --cc=suzuki.poulose@arm.com \
    --cc=will.deacon@arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome