public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "dann frazier" <dann.frazier@canonical.com>
To: Ard Biesheuvel <ardb@kernel.org>
Cc: devel@edk2.groups.io
Subject: Re: [PATCH v2 2/2] ArmVirtPkg/ArmVirtQemu: Avoid early ID map on ThunderX
Date: Mon, 9 Jan 2023 17:08:36 -0700	[thread overview]
Message-ID: <Y7yshC6ZQNorwAwS@xps13.dannf> (raw)
In-Reply-To: <20230105162528.1430368-2-ardb@kernel.org>

On Thu, Jan 05, 2023 at 05:25:28PM +0100, Ard Biesheuvel wrote:
> The early ID map used by ArmVirtQemu uses ASID scoped non-global
> mappings, as this allows us to switch to the permanent ID map seamlessly
> without the need for explicit TLB maintenance.
> 
> However, this triggers a known erratum on ThunderX, which does not
> tolerate non-global mappings that are executable at EL1, as this appears
> to result in I-cache corruption. (Linux disables the KPTI based Meltdown
> mitigation on ThunderX for the same reason)
> 
> So work around this, by detecting the CPU implementor and part number,
> and proceeding without the early ID map if a ThunderX CPU is detected.
> 
> Note that this requires the C code to be built with strict alignment
> again, as we may end up executing it with the MMU and caches off.
> 
> Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
> ---
>  ArmVirtPkg/ArmVirtQemu.dsc                                        |  5 +++++
>  ArmVirtPkg/Library/ArmPlatformLibQemu/AArch64/ArmPlatformHelper.S | 15 +++++++++++++++
>  2 files changed, 20 insertions(+)

FTR, this v2 series also worked for me.

  -dann

> diff --git a/ArmVirtPkg/ArmVirtQemu.dsc b/ArmVirtPkg/ArmVirtQemu.dsc
> index f77443229e8e..5dd8b6104cca 100644
> --- a/ArmVirtPkg/ArmVirtQemu.dsc
> +++ b/ArmVirtPkg/ArmVirtQemu.dsc
> @@ -31,6 +31,7 @@ [Defines]
>    DEFINE SECURE_BOOT_ENABLE      = FALSE
>    DEFINE TPM2_ENABLE             = FALSE
>    DEFINE TPM2_CONFIG_ENABLE      = FALSE
> +  DEFINE CAVIUM_ERRATUM_27456    = FALSE
>  
>    #
>    # Network definition
> @@ -117,7 +118,11 @@ [LibraryClasses.common.UEFI_DRIVER]
>    UefiScsiLib|MdePkg/Library/UefiScsiLib/UefiScsiLib.inf
>  
>  [BuildOptions]
> +!if $(CAVIUM_ERRATUM_27456) == TRUE
> +  GCC:*_*_AARCH64_PP_FLAGS = -DCAVIUM_ERRATUM_27456
> +!else
>    GCC:*_*_AARCH64_CC_XIPFLAGS ==
> +!endif
>  
>  !include NetworkPkg/NetworkBuildOptions.dsc.inc
>  
> diff --git a/ArmVirtPkg/Library/ArmPlatformLibQemu/AArch64/ArmPlatformHelper.S b/ArmVirtPkg/Library/ArmPlatformLibQemu/AArch64/ArmPlatformHelper.S
> index 1787d52fbf51..5ac7c732f6ec 100644
> --- a/ArmVirtPkg/Library/ArmPlatformLibQemu/AArch64/ArmPlatformHelper.S
> +++ b/ArmVirtPkg/Library/ArmPlatformLibQemu/AArch64/ArmPlatformHelper.S
> @@ -42,6 +42,21 @@
>  
>  
>  ASM_FUNC(ArmPlatformPeiBootAction)
> +#ifdef CAVIUM_ERRATUM_27456
> +  /*
> +   * On Cavium ThunderX, using non-global mappings that are executable at EL1
> +   * results in I-cache corruption. So just avoid the early ID mapping there.
> +   *
> +   * MIDR implementor   0x43
> +   * MIDR part numbers  0xA1 0xA2 (but not 0xAF)
> +   */
> +  mrs    x0, midr_el1            // read the MIDR into X0
> +  ubfx   x1, x0, #24, #8         // grab implementor id
> +  ubfx   x0, x0, #7, #9          // grab part number bits [11:3]
> +  cmp    x1, #0x43               // compare implementor id
> +  ccmp   x0, #0xA0 >> 3, #0, eq  // compare part# bits [11:3]
> +  b.eq   0f
> +#endif
>    mrs    x0, CurrentEL           // check current exception level
>    tbnz   x0, #3, 0f              // omit early ID map if above EL1
>  

  reply	other threads:[~2023-01-10  0:08 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-05 16:25 [PATCH v2 1/2] ArmVirtPkg/ArmPlatformLibQemu: Ensure that VFP is on before running C code Ard Biesheuvel
2023-01-05 16:25 ` [PATCH v2 2/2] ArmVirtPkg/ArmVirtQemu: Avoid early ID map on ThunderX Ard Biesheuvel
2023-01-10  0:08   ` dann frazier [this message]
2023-01-17 12:47     ` [edk2-devel] " Oliver Steffen
2023-01-17 14:53       ` Ard Biesheuvel
2023-01-18  6:36         ` Oliver Steffen
2023-01-18  7:34           ` Ard Biesheuvel
2023-01-18  8:27             ` Oliver Steffen
2023-01-18  8:48               ` Ard Biesheuvel
2023-01-18  9:22                 ` Ard Biesheuvel
2023-01-19 11:03                   ` Oliver Steffen
2023-01-19 11:11                     ` Ard Biesheuvel
2023-01-19 11:25                       ` Oliver Steffen
2023-01-19 11:55                       ` Marc Zyngier
2023-01-19 12:21                         ` Ard Biesheuvel
2023-01-19 12:00                       ` Gerd Hoffmann
2023-01-19 12:55                         ` Oliver Steffen
2023-01-19 13:21                           ` Ard Biesheuvel
2023-01-26 12:01                             ` Gerd Hoffmann
2023-01-26 13:48                               ` Marc Zyngier
2023-01-26 14:46                                 ` Gerd Hoffmann
2023-01-26 15:08                                   ` Marc Zyngier
2023-02-01  9:13                             ` Oliver Steffen
2023-02-01 11:51                               ` Ard Biesheuvel
2023-02-01 12:58                                 ` Oliver Steffen
2023-02-01 13:29                                   ` Ard Biesheuvel
2023-02-02 11:09                                     ` Oliver Steffen
     [not found]                                     ` <173FFD60429C89C3.3213@groups.io>
2023-02-07 10:51                                       ` Oliver Steffen
2023-02-07 11:56                                         ` Ard Biesheuvel
2023-02-07 12:58                                           ` Oliver Steffen
2023-02-09 15:15                                             ` Ard Biesheuvel
2023-03-02 10:50                                               ` Ard Biesheuvel
2023-03-02 13:29                                                 ` Oliver Steffen
     [not found]                                                 ` <17489D498A098DB9.9697@groups.io>
2023-05-19 16:32                                                   ` Oliver Steffen
2023-05-19 21:36                                                     ` Ard Biesheuvel
2023-05-20  8:37                                                       ` Oliver Steffen
2023-05-20  9:20                                                         ` Ard Biesheuvel

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=Y7yshC6ZQNorwAwS@xps13.dannf \
    --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