From 48d733ced792bbbc114c3530be32f0460c99a74e Mon Sep 17 00:00:00 2001 From: CyrIng Date: Tue, 30 Jan 2024 00:44:55 +0100 Subject: [PATCH] [AArch64] Translation Hardening Extension (THE) --- aarch64/corefreq-cli-json.c | 2 ++ aarch64/corefreq-cli-rsc-en.h | 2 +- aarch64/corefreq-cli-rsc-fr.h | 1 + aarch64/corefreq-cli-rsc.c | 1 + aarch64/corefreq-cli-rsc.h | 1 + aarch64/corefreq-cli.c | 8 ++++++++ aarch64/corefreqk.c | 9 +++++++++ aarch64/coretypes.h | 3 ++- 8 files changed, 25 insertions(+), 2 deletions(-) diff --git a/aarch64/corefreq-cli-json.c b/aarch64/corefreq-cli-json.c index 75c893cf..fd467d82 100644 --- a/aarch64/corefreq-cli-json.c +++ b/aarch64/corefreq-cli-json.c @@ -538,6 +538,8 @@ void JsonSysInfo(RO(SHM_STRUCT) *RO(Shm)) json_literal(&s, "%u", (unsigned) RO(Shm)->Proc.Features.RAS_frac); json_key(&s, "MPAM_frac"); json_literal(&s, "%u", (unsigned) RO(Shm)->Proc.Features.MPAM_frac); + json_key(&s, "THE"); + json_literal(&s, "%u", (unsigned) RO(Shm)->Proc.Features.THE); json_end_object(&s); } json_key(&s, "MISC"); diff --git a/aarch64/corefreq-cli-rsc-en.h b/aarch64/corefreq-cli-rsc-en.h index 1dda5e2b..97779d4a 100644 --- a/aarch64/corefreq-cli-rsc-en.h +++ b/aarch64/corefreq-cli-rsc-en.h @@ -817,7 +817,7 @@ #define RSC_FEATURES_PAN_CODE_EN "Privileged Access Never" #define RSC_FEATURES_RAS_CODE_EN "Reliability Availability & Serviceability" #define RSC_FEATURES_RME_CODE_EN "Realm Management Extension" - +#define RSC_FEATURES_THE_CODE_EN "Translation Hardening Extension" #define RSC_FEATURES_TLB_CODE_EN "TLB maintenance instructions" #define RSC_FEATURES_TME_CODE_EN "Transactional Memory Extension" #define RSC_FEATURES_TSC_CODE_EN "Time Stamp Counter" diff --git a/aarch64/corefreq-cli-rsc-fr.h b/aarch64/corefreq-cli-rsc-fr.h index 37687617..77475f56 100644 --- a/aarch64/corefreq-cli-rsc-fr.h +++ b/aarch64/corefreq-cli-rsc-fr.h @@ -518,6 +518,7 @@ do echo -en "$h$l\t""\xc3""\x$h$l""\t"; done; done;echo "Fiabilit""\xa9"" Disponibilit""\xa9"" et Durabilit""\xa9" #define RSC_FEATURES_RME_CODE_FR RSC_FEATURES_RME_CODE_EN +#define RSC_FEATURES_THE_CODE_FR RSC_FEATURES_THE_CODE_EN #define RSC_FEATURES_TLB_CODE_FR "Instructions de gestion TLB" #define RSC_FEATURES_TME_CODE_FR "Extension de m""\xa9""moire transactionnelle" #define RSC_FEATURES_TSC_CODE_FR "Compteur d'horodatage" diff --git a/aarch64/corefreq-cli-rsc.c b/aarch64/corefreq-cli-rsc.c index 225e3d52..8ddd7b1b 100644 --- a/aarch64/corefreq-cli-rsc.c +++ b/aarch64/corefreq-cli-rsc.c @@ -724,6 +724,7 @@ RESOURCE_ST Resource[] = { LDT(RSC_FEATURES_PAN), LDT(RSC_FEATURES_RAS), LDT(RSC_FEATURES_RME), + LDT(RSC_FEATURES_THE), LDT(RSC_FEATURES_TLB), LDT(RSC_FEATURES_TME), LDT(RSC_FEATURES_TSC), diff --git a/aarch64/corefreq-cli-rsc.h b/aarch64/corefreq-cli-rsc.h index c086e6b7..8f23afd6 100644 --- a/aarch64/corefreq-cli-rsc.h +++ b/aarch64/corefreq-cli-rsc.h @@ -547,6 +547,7 @@ enum { RSC_FEATURES_PAN, RSC_FEATURES_RAS, RSC_FEATURES_RME, + RSC_FEATURES_THE, RSC_FEATURES_TLB, RSC_FEATURES_TME, RSC_FEATURES_TSC, diff --git a/aarch64/corefreq-cli.c b/aarch64/corefreq-cli.c index 6124524d..e0fc9186 100644 --- a/aarch64/corefreq-cli.c +++ b/aarch64/corefreq-cli.c @@ -1807,6 +1807,14 @@ REASON_CODE SysInfoFeatures( Window *win, width - 18 - RSZ(FEATURES_RME), NULL }, + { + NULL, + RO(Shm)->Proc.Features.THE == 1, + attr_Feat, + 2, "%s%.*sTHE [%7s]", RSC(FEATURES_THE).CODE(), + width - 18 - RSZ(FEATURES_THE), + NULL + }, }; size_t idx; for (idx = 0; idx < sizeof(FEAT) / sizeof(struct FEAT_ST); idx++) diff --git a/aarch64/corefreqk.c b/aarch64/corefreqk.c index f8652b4d..bfa05ba2 100644 --- a/aarch64/corefreqk.c +++ b/aarch64/corefreqk.c @@ -998,6 +998,15 @@ static void Query_Features(void *pArg) iArg->Features->GCS = 0; break; } + switch (pfr1.THE) { + case 0b0001: + iArg->Features->THE = 1; + break; + case 0b0000: + default: + iArg->Features->THE = 0; + break; + } if (Experimental && (iArg->HypervisorID == HYPERV_NONE)) { /* Query the Cluster Configuration */ diff --git a/aarch64/coretypes.h b/aarch64/coretypes.h index 5f49c5b3..29153eeb 100644 --- a/aarch64/coretypes.h +++ b/aarch64/coretypes.h @@ -818,7 +818,8 @@ typedef struct /* BSP features. */ RME : 21-20, MTE : 23-21, GCS : 24-23, - _Unused2_ : 64-24; + THE : 25-24, + _Unused2_ : 64-25; Bit64 InvariantTSC : 8-0, HyperThreading : 9-8,