public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Auger Eric <eric.auger@redhat.com>
To: Ard Biesheuvel <ard.biesheuvel@linaro.org>, edk2-devel@lists.01.org
Cc: Laszlo Ersek <lersek@redhat.com>,
	Leif Lindholm <leif.lindholm@linaro.org>,
	Andrew Jones <drjones@redhat.com>,
	Philippe Mathieu-Daude <philmd@redhat.com>,
	Julien Grall <julien.grall@linaro.org>
Subject: Re: [PATCH v2 01/13] ArmPkg/ArmLib: add support for reading the max physical address space size
Date: Tue, 27 Nov 2018 15:51:24 +0100	[thread overview]
Message-ID: <01a3ac7b-14c7-4c7c-6a5b-68a012f81feb@redhat.com> (raw)
In-Reply-To: <20181126223801.17121-2-ard.biesheuvel@linaro.org>

Hi,

On 11/26/18 11:37 PM, Ard Biesheuvel wrote:
> Add a helper function that returns the maximum physical address space
> size as supported by the current CPU.
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> ---
>  ArmPkg/Include/Library/ArmLib.h               | 17 +++++++++++++++++
>  ArmPkg/Library/ArmLib/AArch64/ArmLibSupport.S | 16 ++++++++++++++++
>  ArmPkg/Library/ArmLib/Arm/ArmLibSupport.S     |  8 ++++++++
>  3 files changed, 41 insertions(+)
> 
> diff --git a/ArmPkg/Include/Library/ArmLib.h b/ArmPkg/Include/Library/ArmLib.h
> index ffda50e9d767..b22879fe6e94 100644
> --- a/ArmPkg/Include/Library/ArmLib.h
> +++ b/ArmPkg/Include/Library/ArmLib.h
> @@ -29,6 +29,17 @@
>  #define EFI_MEMORY_CACHETYPE_MASK   (EFI_MEMORY_UC | EFI_MEMORY_WC | \
>                                       EFI_MEMORY_WT | EFI_MEMORY_WB | \
>                                       EFI_MEMORY_UCE)
> +//
> +// ARM_MMU_IDMAP_RANGE defines the maximum size of the identity mapping
> +// that covers the entire address space when running in UEFI. This is
> +// limited to what can architecturally be mapped using a 4 KB granule,
> +// even if the hardware is capable of mapping more using larger pages.
> +//
> +#ifdef MDE_CPU_ARM
> +#define ARM_MMU_IDMAP_RANGE     (1ULL << 32)
> +#else
> +#define ARM_MMU_IDMAP_RANGE     (1ULL << 48)
> +#endif
>  
>  /**
>   * The UEFI firmware must not use the ARM_MEMORY_REGION_ATTRIBUTE_NONSECURE_* attributes.
> @@ -733,4 +744,10 @@ ArmWriteCntvOff (
>    UINT64   Val
>    );
>  
> +UINTN
> +EFIAPI
> +ArmGetPhysicalAddressBits (
> +  VOID
> +  );
> +
>  #endif // __ARM_LIB__
> diff --git a/ArmPkg/Library/ArmLib/AArch64/ArmLibSupport.S b/ArmPkg/Library/ArmLib/AArch64/ArmLibSupport.S
> index 1ef2f61f5979..7332601241aa 100644
> --- a/ArmPkg/Library/ArmLib/AArch64/ArmLibSupport.S
> +++ b/ArmPkg/Library/ArmLib/AArch64/ArmLibSupport.S
> @@ -196,4 +196,20 @@ ASM_FUNC(ArmWriteSctlr)
>  3:msr   sctlr_el3, x0
>  4:ret
>  
> +ASM_FUNC(ArmGetPhysicalAddressBits)
> +  mrs   x0, id_aa64mmfr0_el1
> +  adr   x1, .LPARanges
> +  and   x0, x0, #7
> +  ldrb  w0, [x1, x0]
> +  ret
> +
> +//
> +// Bits 0..2 of the AA64MFR0_EL1 system register encode the size of the
> +// physical address space support on this CPU:
> +// 0 == 32 bits, 1 == 36 bits, etc etc
> +// 6 and 7 are reserved
> +//
> +.LPARanges:
> +  .byte 32, 36, 40, 42, 44, 48, 52, -1
> +
>  ASM_FUNCTION_REMOVE_IF_UNREFERENCED
> diff --git a/ArmPkg/Library/ArmLib/Arm/ArmLibSupport.S b/ArmPkg/Library/ArmLib/Arm/ArmLibSupport.S
> index f2a517671f0a..f2f3c9a25991 100644
> --- a/ArmPkg/Library/ArmLib/Arm/ArmLibSupport.S
> +++ b/ArmPkg/Library/ArmLib/Arm/ArmLibSupport.S
> @@ -165,4 +165,12 @@ ASM_FUNC(ArmWriteCpuActlr)
>    isb
>    bx      lr
>  
> +ASM_FUNC (ArmGetPhysicalAddressBits)
> +  mrc     p15, 0, r0, c0, c1, 4   // MMFR0
> +  and     r0, r0, #0xf            // VMSA [3:0]
> +  cmp     r0, #5                  // >5 implies LPAE support
nit: >= 5 in the comment

Thanks

Eric
> +  movlt   r0, #32                 // 32 bits if no LPAE
> +  movge   r0, #40                 // 40 bits if LPAE
> +  bx      lr
> +
>  ASM_FUNCTION_REMOVE_IF_UNREFERENCED
> 


  parent reply	other threads:[~2018-11-27 14:51 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-26 22:37 [PATCH v2 00/13] ArmPkg, ArmVirtPkg: lift 40-bit IPA space limit Ard Biesheuvel
2018-11-26 22:37 ` [PATCH v2 01/13] ArmPkg/ArmLib: add support for reading the max physical address space size Ard Biesheuvel
2018-11-26 22:43   ` Philippe Mathieu-Daudé
2018-11-26 23:02     ` Philippe Mathieu-Daudé
2018-11-26 23:03       ` Ard Biesheuvel
2018-11-27 12:26   ` Ard Biesheuvel
2018-11-27 14:51   ` Auger Eric [this message]
2018-11-26 22:37 ` [PATCH v2 02/13] ArmVirtPkg: refactor reading of the " Ard Biesheuvel
2018-11-26 22:37 ` [PATCH v2 03/13] ArmPkg/ArmMmuLib: take the CPU supported maximum PA space into account Ard Biesheuvel
2018-11-26 22:37 ` [PATCH v2 04/13] ArmPkg/CpuPei: base GCD memory space size on CPU's PA range Ard Biesheuvel
2018-11-26 22:37 ` [PATCH v2 05/13] ArmPlatformPkg/PrePi: " Ard Biesheuvel
2018-11-26 22:37 ` [PATCH v2 06/13] ArmVirtPkg/PrePi: " Ard Biesheuvel
2018-11-26 22:37 ` [PATCH v2 07/13] BeagleBoardPkg/PrePi: " Ard Biesheuvel
2018-11-26 22:37 ` [PATCH v2 08/13] EmbeddedPkg/PrePiHobLib: " Ard Biesheuvel
2018-11-26 22:37 ` [PATCH v2 09/13] ArmPlatformPkg/PlatformPei: drop unused PCD references Ard Biesheuvel
2018-11-26 22:37 ` [PATCH v2 10/13] EmbeddedPkg/PrePiLib: drop unused PCD reference Ard Biesheuvel
2018-11-26 22:37 ` [PATCH v2 11/13] ArmVirtPkg/QemuVirtMemInfoLib: ignore PcdPrePiCpuMemorySize Ard Biesheuvel
2018-11-26 22:38 ` [PATCH v2 12/13] ArmVirtPkg: drop PcdPrePiCpuMemorySize assignments from all platforms Ard Biesheuvel
2018-11-26 22:38 ` [PATCH v2 13/13] EmbeddedPkg/EmbeddedPkg.dec: drop PcdPrePiCpuMemorySize declarations Ard Biesheuvel
2018-11-27 12:11 ` [PATCH v2 00/13] ArmPkg, ArmVirtPkg: lift 40-bit IPA space limit Laszlo Ersek
2018-11-27 12:13   ` Ard Biesheuvel
2018-11-27 14:35     ` Laszlo Ersek

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-list 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=01a3ac7b-14c7-4c7c-6a5b-68a012f81feb@redhat.com \
    --to=devel@edk2.groups.io \
    /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