stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: stable@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	patches@lists.linux.dev, Ard Biesheuvel <ardb@kernel.org>,
	James Morse <james.morse@arm.com>, Will Deacon <will@kernel.org>,
	Florian Fainelli <f.fainelli@gmail.com>
Subject: [PATCH 5.4 35/53] arm64: errata: Remove AES hwcap for COMPAT tasks
Date: Thu, 27 Oct 2022 18:56:23 +0200	[thread overview]
Message-ID: <20221027165051.139646777@linuxfoundation.org> (raw)
In-Reply-To: <20221027165049.817124510@linuxfoundation.org>

From: James Morse <james.morse@arm.com>

commit 44b3834b2eed595af07021b1c64e6f9bc396398b upstream.

Cortex-A57 and Cortex-A72 have an erratum where an interrupt that
occurs between a pair of AES instructions in aarch32 mode may corrupt
the ELR. The task will subsequently produce the wrong AES result.

The AES instructions are part of the cryptographic extensions, which are
optional. User-space software will detect the support for these
instructions from the hwcaps. If the platform doesn't support these
instructions a software implementation should be used.

Remove the hwcap bits on affected parts to indicate user-space should
not use the AES instructions.

Acked-by: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: James Morse <james.morse@arm.com>
Link: https://lore.kernel.org/r/20220714161523.279570-3-james.morse@arm.com
Signed-off-by: Will Deacon <will@kernel.org>
[florian: resolved conflicts in arch/arm64/tools/cpucaps and cpu_errata.c]
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 Documentation/arm64/silicon-errata.rst |    4 ++++
 arch/arm64/Kconfig                     |   16 ++++++++++++++++
 arch/arm64/include/asm/cpucaps.h       |    3 ++-
 arch/arm64/kernel/cpu_errata.c         |   16 ++++++++++++++++
 arch/arm64/kernel/cpufeature.c         |   13 ++++++++++++-
 5 files changed, 50 insertions(+), 2 deletions(-)

--- a/Documentation/arm64/silicon-errata.rst
+++ b/Documentation/arm64/silicon-errata.rst
@@ -70,8 +70,12 @@ stable kernels.
 +----------------+-----------------+-----------------+-----------------------------+
 | ARM            | Cortex-A57      | #834220         | ARM64_ERRATUM_834220        |
 +----------------+-----------------+-----------------+-----------------------------+
+| ARM            | Cortex-A57      | #1742098        | ARM64_ERRATUM_1742098       |
++----------------+-----------------+-----------------+-----------------------------+
 | ARM            | Cortex-A72      | #853709         | N/A                         |
 +----------------+-----------------+-----------------+-----------------------------+
+| ARM            | Cortex-A72      | #1655431        | ARM64_ERRATUM_1742098       |
++----------------+-----------------+-----------------+-----------------------------+
 | ARM            | Cortex-A73      | #858921         | ARM64_ERRATUM_858921        |
 +----------------+-----------------+-----------------+-----------------------------+
 | ARM            | Cortex-A55      | #1024718        | ARM64_ERRATUM_1024718       |
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -574,6 +574,22 @@ config ARM64_ERRATUM_1542419
 
 	  If unsure, say Y.
 
+config ARM64_ERRATUM_1742098
+	bool "Cortex-A57/A72: 1742098: ELR recorded incorrectly on interrupt taken between cryptographic instructions in a sequence"
+	depends on COMPAT
+	default y
+	help
+	  This option removes the AES hwcap for aarch32 user-space to
+	  workaround erratum 1742098 on Cortex-A57 and Cortex-A72.
+
+	  Affected parts may corrupt the AES state if an interrupt is
+	  taken between a pair of AES instructions. These instructions
+	  are only present if the cryptography extensions are present.
+	  All software should have a fallback implementation for CPUs
+	  that don't implement the cryptography extensions.
+
+	  If unsure, say Y.
+
 config CAVIUM_ERRATUM_22375
 	bool "Cavium erratum 22375, 24313"
 	default y
--- a/arch/arm64/include/asm/cpucaps.h
+++ b/arch/arm64/include/asm/cpucaps.h
@@ -56,7 +56,8 @@
 #define ARM64_WORKAROUND_CAVIUM_TX2_219_PRFM	46
 #define ARM64_WORKAROUND_1542419		47
 #define ARM64_SPECTRE_BHB			48
+#define ARM64_WORKAROUND_1742098		49
 
-#define ARM64_NCAPS				49
+#define ARM64_NCAPS				50
 
 #endif /* __ASM_CPUCAPS_H */
--- a/arch/arm64/kernel/cpu_errata.c
+++ b/arch/arm64/kernel/cpu_errata.c
@@ -817,6 +817,14 @@ static const struct arm64_cpu_capabiliti
 };
 #endif
 
+#ifdef CONFIG_ARM64_ERRATUM_1742098
+static struct midr_range broken_aarch32_aes[] = {
+	MIDR_RANGE(MIDR_CORTEX_A57, 0, 1, 0xf, 0xf),
+	MIDR_ALL_VERSIONS(MIDR_CORTEX_A72),
+	{},
+};
+#endif
+
 const struct arm64_cpu_capabilities arm64_errata[] = {
 #ifdef CONFIG_ARM64_WORKAROUND_CLEAN_CACHE
 	{
@@ -998,6 +1006,14 @@ const struct arm64_cpu_capabilities arm6
 		.cpu_enable = cpu_enable_trap_ctr_access,
 	},
 #endif
+#ifdef CONFIG_ARM64_ERRATUM_1742098
+	{
+		.desc = "ARM erratum 1742098",
+		.capability = ARM64_WORKAROUND_1742098,
+		CAP_MIDR_RANGE_LIST(broken_aarch32_aes),
+		.type = ARM64_CPUCAP_LOCAL_CPU_ERRATUM,
+	},
+#endif
 	{
 	}
 };
--- a/arch/arm64/kernel/cpufeature.c
+++ b/arch/arm64/kernel/cpufeature.c
@@ -21,6 +21,7 @@
 #include <asm/cpufeature.h>
 #include <asm/cpu_ops.h>
 #include <asm/fpsimd.h>
+#include <asm/hwcap.h>
 #include <asm/mmu_context.h>
 #include <asm/processor.h>
 #include <asm/sysreg.h>
@@ -1280,6 +1281,14 @@ static bool can_use_gic_priorities(const
 }
 #endif
 
+static void elf_hwcap_fixup(void)
+{
+#ifdef CONFIG_ARM64_ERRATUM_1742098
+	if (cpus_have_const_cap(ARM64_WORKAROUND_1742098))
+		compat_elf_hwcap2 &= ~COMPAT_HWCAP2_AES;
+#endif /* ARM64_ERRATUM_1742098 */
+}
+
 static const struct arm64_cpu_capabilities arm64_features[] = {
 	{
 		.desc = "GIC system register CPU interface",
@@ -2103,8 +2112,10 @@ void __init setup_cpu_features(void)
 	mark_const_caps_ready();
 	setup_elf_hwcaps(arm64_elf_hwcaps);
 
-	if (system_supports_32bit_el0())
+	if (system_supports_32bit_el0()) {
 		setup_elf_hwcaps(compat_elf_hwcaps);
+		elf_hwcap_fixup();
+	}
 
 	if (system_uses_ttbr0_pan())
 		pr_info("emulated: Privileged Access Never (PAN) using TTBR0_EL1 switching\n");



  parent reply	other threads:[~2022-10-27 17:09 UTC|newest]

Thread overview: 58+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-27 16:55 [PATCH 5.4 00/53] 5.4.221-rc1 review Greg Kroah-Hartman
2022-10-27 16:55 ` [PATCH 5.4 01/53] xfs: open code insert range extent split helper Greg Kroah-Hartman
2022-10-27 16:55 ` [PATCH 5.4 02/53] xfs: rework insert range into an atomic operation Greg Kroah-Hartman
2022-10-27 16:55 ` [PATCH 5.4 03/53] xfs: rework collapse " Greg Kroah-Hartman
2022-10-27 16:55 ` [PATCH 5.4 04/53] xfs: add a function to deal with corrupt buffers post-verifiers Greg Kroah-Hartman
2022-10-27 16:55 ` [PATCH 5.4 05/53] xfs: xfs_buf_corruption_error should take __this_address Greg Kroah-Hartman
2022-10-27 16:55 ` [PATCH 5.4 06/53] xfs: fix buffer corruption reporting when xfs_dir3_free_header_check fails Greg Kroah-Hartman
2022-10-27 16:55 ` [PATCH 5.4 07/53] xfs: check owner of dir3 data blocks Greg Kroah-Hartman
2022-10-27 16:55 ` [PATCH 5.4 08/53] xfs: check owner of dir3 blocks Greg Kroah-Hartman
2022-10-27 16:55 ` [PATCH 5.4 09/53] xfs: Use scnprintf() for avoiding potential buffer overflow Greg Kroah-Hartman
2022-10-27 16:55 ` [PATCH 5.4 10/53] xfs: remove the xfs_disk_dquot_t and xfs_dquot_t Greg Kroah-Hartman
2022-10-27 16:55 ` [PATCH 5.4 11/53] xfs: remove the xfs_dq_logitem_t typedef Greg Kroah-Hartman
2022-10-27 16:56 ` [PATCH 5.4 12/53] xfs: remove the xfs_qoff_logitem_t typedef Greg Kroah-Hartman
2022-10-27 16:56 ` [PATCH 5.4 13/53] xfs: Replace function declaration by actual definition Greg Kroah-Hartman
2022-10-27 16:56 ` [PATCH 5.4 14/53] xfs: factor out quotaoff intent AIL removal and memory free Greg Kroah-Hartman
2022-10-27 16:56 ` [PATCH 5.4 15/53] xfs: fix unmount hang and memory leak on shutdown during quotaoff Greg Kroah-Hartman
2022-10-27 16:56 ` [PATCH 5.4 16/53] xfs: preserve default grace interval during quotacheck Greg Kroah-Hartman
2022-10-27 16:56 ` [PATCH 5.4 17/53] xfs: Lower CIL flush limit for large logs Greg Kroah-Hartman
2022-10-27 16:56 ` [PATCH 5.4 18/53] xfs: Throttle commits on delayed background CIL push Greg Kroah-Hartman
2022-10-27 16:56 ` [PATCH 5.4 19/53] xfs: factor common AIL item deletion code Greg Kroah-Hartman
2022-10-27 16:56 ` [PATCH 5.4 20/53] xfs: tail updates only need to occur when LSN changes Greg Kroah-Hartman
2022-10-27 16:56 ` [PATCH 5.4 21/53] xfs: dont write a corrupt unmount record to force summary counter recalc Greg Kroah-Hartman
2022-10-27 16:56 ` [PATCH 5.4 22/53] xfs: trylock underlying buffer on dquot flush Greg Kroah-Hartman
2022-10-27 16:56 ` [PATCH 5.4 23/53] xfs: factor out a new xfs_log_force_inode helper Greg Kroah-Hartman
2022-10-27 16:56 ` [PATCH 5.4 24/53] xfs: reflink should force the log out if mounted with wsync Greg Kroah-Hartman
2022-10-27 16:56 ` [PATCH 5.4 25/53] xfs: move inode flush to the sync workqueue Greg Kroah-Hartman
2022-10-27 16:56 ` [PATCH 5.4 26/53] xfs: fix use-after-free on CIL context on shutdown Greg Kroah-Hartman
2022-10-27 16:56 ` [PATCH 5.4 27/53] ocfs2: clear dinode links count in case of error Greg Kroah-Hartman
2022-10-27 16:56 ` [PATCH 5.4 28/53] ocfs2: fix BUG when iput after ocfs2_mknod fails Greg Kroah-Hartman
2022-10-27 16:56 ` [PATCH 5.4 29/53] x86/microcode/AMD: Apply the patch early on every logical thread Greg Kroah-Hartman
2022-10-27 16:56 ` [PATCH 5.4 30/53] hwmon/coretemp: Handle large core ID value Greg Kroah-Hartman
2022-10-27 16:56 ` [PATCH 5.4 31/53] ata: ahci-imx: Fix MODULE_ALIAS Greg Kroah-Hartman
2022-10-27 16:56 ` [PATCH 5.4 32/53] ata: ahci: Match EM_MAX_SLOTS with SATA_PMP_MAX_PORTS Greg Kroah-Hartman
2022-10-27 16:56 ` [PATCH 5.4 33/53] KVM: arm64: vgic: Fix exit condition in scan_its_table() Greg Kroah-Hartman
2022-10-27 16:56 ` [PATCH 5.4 34/53] media: venus: dec: Handle the case where find_format fails Greg Kroah-Hartman
2022-10-27 16:56 ` Greg Kroah-Hartman [this message]
2022-10-27 16:56 ` [PATCH 5.4 36/53] r8152: add PID for the Lenovo OneLink+ Dock Greg Kroah-Hartman
2022-10-27 16:56 ` [PATCH 5.4 37/53] btrfs: fix processing of delayed data refs during backref walking Greg Kroah-Hartman
2022-10-27 16:56 ` [PATCH 5.4 38/53] btrfs: fix processing of delayed tree block " Greg Kroah-Hartman
2022-10-27 16:56 ` [PATCH 5.4 39/53] ACPI: extlog: Handle multiple records Greg Kroah-Hartman
2022-10-27 16:56 ` [PATCH 5.4 40/53] tipc: Fix recognition of trial period Greg Kroah-Hartman
2022-10-27 16:56 ` [PATCH 5.4 41/53] tipc: fix an information leak in tipc_topsrv_kern_subscr Greg Kroah-Hartman
2022-10-27 16:56 ` [PATCH 5.4 42/53] HID: magicmouse: Do not set BTN_MOUSE on double report Greg Kroah-Hartman
2022-10-27 16:56 ` [PATCH 5.4 43/53] net/atm: fix proc_mpc_write incorrect return value Greg Kroah-Hartman
2022-10-27 16:56 ` [PATCH 5.4 44/53] net: phy: dp83867: Extend RX strap quirk for SGMII mode Greg Kroah-Hartman
2022-10-27 16:56 ` [PATCH 5.4 45/53] net: sched: cake: fix null pointer access issue when cake_init() fails Greg Kroah-Hartman
2022-10-27 16:56 ` [PATCH 5.4 46/53] net: hns: fix possible memory leak in hnae_ae_register() Greg Kroah-Hartman
2022-10-27 16:56 ` [PATCH 5.4 47/53] iommu/vt-d: Clean up si_domain in the init_dmars() error path Greg Kroah-Hartman
2022-10-27 16:56 ` [PATCH 5.4 48/53] arm64: topology: move store_cpu_topology() to shared code Greg Kroah-Hartman
2022-10-27 16:56 ` [PATCH 5.4 49/53] riscv: topology: fix default topology reporting Greg Kroah-Hartman
2022-10-27 16:56 ` [PATCH 5.4 50/53] [PATCH v3] ACPI: video: Force backlight native for more TongFang devices Greg Kroah-Hartman
2022-10-27 16:56 ` [PATCH 5.4 51/53] Makefile.debug: re-enable debug info for .S files Greg Kroah-Hartman
2022-10-27 16:56 ` [PATCH 5.4 52/53] hv_netvsc: Fix race between VF offering and VF association message from host Greg Kroah-Hartman
2022-10-27 16:56 ` [PATCH 5.4 53/53] mm: /proc/pid/smaps_rollup: fix no vmas null-deref Greg Kroah-Hartman
2022-10-28 10:49 ` [PATCH 5.4 00/53] 5.4.221-rc1 review Sudip Mukherjee (Codethink)
2022-10-28 14:01 ` Naresh Kamboju
2022-10-28 20:06 ` Florian Fainelli
2022-10-29  3:35 ` Guenter Roeck

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=20221027165051.139646777@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=ardb@kernel.org \
    --cc=f.fainelli@gmail.com \
    --cc=james.morse@arm.com \
    --cc=patches@lists.linux.dev \
    --cc=stable@vger.kernel.org \
    --cc=will@kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).