All of lore.kernel.org
 help / color / mirror / Atom feed
From: will.deacon@arm.com (Will Deacon)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 1/3] arm64: add MIDR_EL1 field accessors
Date: Mon, 12 May 2014 16:05:14 +0100	[thread overview]
Message-ID: <20140512150514.GD18960@arm.com> (raw)
In-Reply-To: <1399905470-26500-2-git-send-email-mark.rutland@arm.com>

On Mon, May 12, 2014 at 03:37:48PM +0100, Mark Rutland wrote:
> The MIDR_EL1 register is composed of a number of bitfields, and uses of
> the fields has so far involved open-coding of the shifts and masks
> required.
> 
> This patch adds shifts and masks for each of the MIDR_EL1 subfields, and
> also provides accessors built atop of these. Existing uses within
> cputype.h are updated to use these accessors.
> 
> Signed-off-by: Mark Rutland <mark.rutland@arm.com>
> ---
>  arch/arm64/include/asm/cputype.h | 27 +++++++++++++++++++++++++--
>  1 file changed, 25 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/arm64/include/asm/cputype.h b/arch/arm64/include/asm/cputype.h
> index c404fb0..541b829 100644
> --- a/arch/arm64/include/asm/cputype.h
> +++ b/arch/arm64/include/asm/cputype.h
> @@ -36,6 +36,25 @@
>  	__val;								\
>  })
>  
> +#define MIDR_REVISION_MASK	0xf
> +#define MIDR_REVISION(midr)	((midr) & MIDR_REVISION_MASK)
> +#define MIDR_PARTNUM_SHIFT	4
> +#define MIDR_PARTNUM_MASK	(0xfff << MIDR_PARTNUM_SHIFT)
> +#define MIDR_PARTNUM(midr)	\
> +	(((midr) & MIDR_PARTNUM_MASK) >> MIDR_PARTNUM_SHIFT)
> +#define MIDR_ARCHITECTURE_SHIFT	16
> +#define MIDR_ARCHITECTURE_MASK	(0xf << MIDR_ARCHITECTURE_SHIFT)
> +#define MIDR_ARCHITECTURE(midr)	\
> +	(((midr) & MIDR_ARCHITECTURE_MASK) >> MIDR_ARCHITECTURE_SHIFT)
> +#define MIDR_VARIANT_SHIFT	20
> +#define MIDR_VARIANT_MASK	(0xf << MIDR_VARIANT_SHIFT)
> +#define MIDR_VARIANT(midr)	\
> +	(((midr) & MIDR_VARIANT_MASK) >> MIDR_VARIANT_SHIFT)
> +#define MIDR_IMPLEMENTOR_SHIFT	24
> +#define MIDR_IMPLEMENTOR_MASK	(0xff << MIDR_IMPLEMENTOR_SHIFT)
> +#define MIDR_IMPLEMENTOR(midr)	\
> +	(((midr) & MIDR_IMPLEMENTOR_MASK) >> MIDR_IMPLEMENTOR_SHIFT)
> +
>  #define ARM_CPU_IMP_ARM		0x41
>  #define ARM_CPU_IMP_APM		0x50
>  
> @@ -64,12 +83,16 @@ static inline u64 __attribute_const__ read_cpuid_mpidr(void)
>  
>  static inline unsigned int __attribute_const__ read_cpuid_implementor(void)
>  {
> -	return (read_cpuid_id() & 0xFF000000) >> 24;
> +	return MIDR_IMPLEMENTOR(read_cpuid_id());
>  }
>  
>  static inline unsigned int __attribute_const__ read_cpuid_part_number(void)
>  {
> -	return (read_cpuid_id() & 0xFFF0);
> +	/*
> +	 * The part number field is used in-place as a userspace ABI, so we
> +	 * cannot use MIDR_PARTNUM() here.
> +	 */
> +	return (read_cpuid_id() & MIDR_PARTNUM_MASK);

Where is this used as ABI? c_show is open-coded and kvm_target_cpu could
just add a shift left.

Will

  reply	other threads:[~2014-05-12 15:05 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-12 14:37 [PATCH 0/3] arm64: extend/fix /proc/cpuinfo + runtime sanity checks Mark Rutland
2014-05-12 14:37 ` [PATCH 1/3] arm64: add MIDR_EL1 field accessors Mark Rutland
2014-05-12 15:05   ` Will Deacon [this message]
2014-05-12 15:22     ` Mark Rutland
2014-05-12 14:37 ` [PATCH 2/3] arm64: cpuinfo: print info for all CPUs Mark Rutland
2014-05-12 14:54   ` Ard Biesheuvel
2014-05-12 15:17     ` Mark Rutland
2014-05-12 14:37 ` [PATCH 3/3] arm64: add runtime system sanity checks Mark Rutland
2014-05-12 15:11   ` Will Deacon
2014-05-12 15:41     ` Mark Rutland

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=20140512150514.GD18960@arm.com \
    --to=will.deacon@arm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.