git: ea6865bb78c5 - main - arm64: Update how we handle SpecSEI

From: Andrew Turner <andrew_at_FreeBSD.org>
Date: Mon, 21 Oct 2024 12:24:23 UTC
The branch main has been updated by andrew:

URL: https://cgit.FreeBSD.org/src/commit/?id=ea6865bb78c5ac007a50f3d06a8e745052f745a0

commit ea6865bb78c5ac007a50f3d06a8e745052f745a0
Author:     Andrew Turner <andrew@FreeBSD.org>
AuthorDate: 2024-10-18 09:17:22 +0000
Commit:     Andrew Turner <andrew@FreeBSD.org>
CommitDate: 2024-10-21 12:23:16 +0000

    arm64: Update how we handle SpecSEI
    
    The ID_AA64MMFR1_EL0.SpecSEI field needs to use MRS_HIGHER to get the
    largest value from all CPUs. This is because it indicates when an
    exception might happen when it's non-zero and can't happen when zero.
    As indicating something that might happen even when it can't is safer
    use MRS_HIGHER to handle this field.
    
    Reviewed by:    imp
    Sponsored by:   Arm Ltd
    Differential Revision:  https://reviews.freebsd.org/D47126
---
 sys/arm64/arm64/identcpu.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/sys/arm64/arm64/identcpu.c b/sys/arm64/arm64/identcpu.c
index 834b0c5493b4..f4d297e7d9bc 100644
--- a/sys/arm64/arm64/identcpu.c
+++ b/sys/arm64/arm64/identcpu.c
@@ -1283,7 +1283,14 @@ static const struct mrs_field id_aa64mmfr1_fields[] = {
 	MRS_FIELD(ID_AA64MMFR1, ETS, false, MRS_LOWER, 0, id_aa64mmfr1_ets),
 	MRS_FIELD(ID_AA64MMFR1, TWED, false, MRS_LOWER, 0, id_aa64mmfr1_twed),
 	MRS_FIELD(ID_AA64MMFR1, XNX, false, MRS_LOWER, 0, id_aa64mmfr1_xnx),
-	MRS_FIELD(ID_AA64MMFR1, SpecSEI, false, MRS_LOWER, 0,
+	/*
+	 * SpecSEI != 0 indicates the CPU might generate an external abort
+	 * under speculation, while 0 indicates it can't happen. It's safer
+	 * to incorrectly indicate it might happen when it can't rather than
+	 * say it can't happen when it could. As such use the largest value
+	 * found in the system.
+	 */
+	MRS_FIELD(ID_AA64MMFR1, SpecSEI, false, MRS_HIGHER, 0,
 	    id_aa64mmfr1_specsei),
 	MRS_FIELD(ID_AA64MMFR1, PAN, false, MRS_LOWER, 0, id_aa64mmfr1_pan),
 	MRS_FIELD(ID_AA64MMFR1, LO, false, MRS_LOWER, 0, id_aa64mmfr1_lo),