All of lore.kernel.org
 help / color / mirror / Atom feed
From: Suzuki.Poulose@arm.com (Suzuki K. Poulose)
To: linux-arm-kernel@lists.infradead.org
Subject: [RFC PATCH] arm64: Expose physical/virtual address bits through cpuinfo
Date: Thu, 17 Mar 2016 11:31:40 +0000	[thread overview]
Message-ID: <56EA959C.8080005@arm.com> (raw)
In-Reply-To: <1458209283-44999-1-git-send-email-wangkefeng.wang@huawei.com>

On 17/03/16 10:08, Kefeng Wang wrote:
> AArch64 support six types Physical Address range, permitted values
> in ID_AA64MMFR0_EL1 are:
> 0000  32 bits, 4GB.
> 0001  36 bits, 64GB.
> 0010  40 bits, 1TB.
> 0011  42 bits, 4TB.
> 0100  44 bits, 16TB.
> 0101  48 bits, 256TB.
> All other values are reserved.
>
> Meanwhile, AArch64 allows 36-bit, 39-bit, 42-bit, 47-bit and 48-bit
> virtual addresses.

See below..

>
> +static inline int id_aa64mmfr0_parange_bits(void)
> +{
> +	/*
> +	 * PARange[3:0] allows 0~5, other values are reserved,
> +	 * convert to physical address bits with a simple formula.
> +	 */
> +	u32 parange = read_system_reg(SYS_ID_AA64MMFR0_EL1) & 0xf;
> +
> +	return parange < 3 ? 32 + parange * 4 : 42 + (parange - 3) * (parange - 2);

This breaks for 52bit PA support added in ARMv8.2 [1]. It may be a good idea
to use an array here.

> +}
> +
>   #endif /* __ASSEMBLY__ */
>
>   #endif
> diff --git a/arch/arm64/kernel/cpuinfo.c b/arch/arm64/kernel/cpuinfo.c
> index 212ae63..f6b49db 100644
> --- a/arch/arm64/kernel/cpuinfo.c
> +++ b/arch/arm64/kernel/cpuinfo.c
> @@ -146,7 +146,9 @@ static int c_show(struct seq_file *m, void *v)
>   		seq_printf(m, "CPU architecture: 8\n");
>   		seq_printf(m, "CPU variant\t: 0x%x\n", MIDR_VARIANT(midr));
>   		seq_printf(m, "CPU part\t: 0x%03x\n", MIDR_PARTNUM(midr));
> -		seq_printf(m, "CPU revision\t: %d\n\n", MIDR_REVISION(midr));
> +		seq_printf(m, "CPU revision\t: %d\n", MIDR_REVISION(midr));
> +		seq_printf(m, "address sizes\t: %d bits physical, %d bits virtual\n\n",
> +			   id_aa64mmfr0_parange_bits(), VA_BITS);

VA_BITS is an attribute of your running kernel and doesn't have anything to do with what
the CPU can support. (e.g, it is 48bit on 8.0, 8.1, but could go upto 52 in 8.2)

[1] https://community.arm.com/groups/processors/blog/2016/01/05/armv8-a-architecture-evolution

Also, I am not sure if the change above would break userspace parsing the info. Ideally
it shouldn't , but...

Thanks
Suzuki

  reply	other threads:[~2016-03-17 11:31 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-17 10:08 [RFC PATCH] arm64: Expose physical/virtual address bits through cpuinfo Kefeng Wang
2016-03-17 11:31 ` Suzuki K. Poulose [this message]
2016-03-18  5:47   ` Kefeng Wang
2016-03-18 10:12     ` Suzuki K. Poulose
2016-03-18 12:13 ` Catalin Marinas
2016-03-21 11:58   ` Kefeng Wang

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=56EA959C.8080005@arm.com \
    --to=suzuki.poulose@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.