]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
arm64/sysreg: Add definitions for architected GCS caps
authorMark Brown <broonie@kernel.org>
Tue, 1 Oct 2024 22:58:47 +0000 (23:58 +0100)
committerCatalin Marinas <catalin.marinas@arm.com>
Fri, 4 Oct 2024 11:04:34 +0000 (12:04 +0100)
The architecture defines a format for guarded control stack caps, used
to mark the top of an unused GCS in order to limit the potential for
exploitation via stack switching. Add definitions associated with these.

Reviewed-by: Thiago Jung Bauermann <thiago.bauermann@linaro.org>
Acked-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
Link: https://lore.kernel.org/r/20241001-arm64-gcs-v13-8-222b78d87eee@kernel.org
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
arch/arm64/include/asm/sysreg.h

index 9ea97dddefc4054889ce42da828b5d87b51cc992..9c98ff448bd9e824cdc94422cf56e46997076a55 100644 (file)
 /* Initial value for Permission Overlay Extension for EL0 */
 #define POR_EL0_INIT   POE_RXW
 
+/*
+ * Definitions for Guarded Control Stack
+ */
+
+#define GCS_CAP_ADDR_MASK              GENMASK(63, 12)
+#define GCS_CAP_ADDR_SHIFT             12
+#define GCS_CAP_ADDR_WIDTH             52
+#define GCS_CAP_ADDR(x)                        FIELD_GET(GCS_CAP_ADDR_MASK, x)
+
+#define GCS_CAP_TOKEN_MASK             GENMASK(11, 0)
+#define GCS_CAP_TOKEN_SHIFT            0
+#define GCS_CAP_TOKEN_WIDTH            12
+#define GCS_CAP_TOKEN(x)               FIELD_GET(GCS_CAP_TOKEN_MASK, x)
+
+#define GCS_CAP_VALID_TOKEN            0x1
+#define GCS_CAP_IN_PROGRESS_TOKEN      0x5
+
+#define GCS_CAP(x)     ((((unsigned long)x) & GCS_CAP_ADDR_MASK) | \
+                                              GCS_CAP_VALID_TOKEN)
+
 #define ARM64_FEATURE_FIELD_BITS       4
 
 /* Defined for compatibility only, do not add new users. */