From ae93cc2f872d0698b814bb0d1dbd3d728dece8c3 Mon Sep 17 00:00:00 2001 From: CyrIng Date: Tue, 30 Jan 2024 00:12:23 +0100 Subject: [PATCH] [AArch64] Guarded Control Stack (GCS) * Moved BTI under Security Features section --- aarch64/corefreq-cli-json.c | 2 ++ aarch64/corefreq-cli-rsc-en.h | 1 + aarch64/corefreq-cli-rsc-fr.h | 1 + aarch64/corefreq-cli-rsc.c | 1 + aarch64/corefreq-cli-rsc.h | 1 + aarch64/corefreq-cli.c | 26 +++++++++++++++++--------- aarch64/corefreqk.c | 9 +++++++++ aarch64/coretypes.h | 3 ++- 8 files changed, 34 insertions(+), 10 deletions(-) diff --git a/aarch64/corefreq-cli-json.c b/aarch64/corefreq-cli-json.c index 0336b63e..75c893cf 100644 --- a/aarch64/corefreq-cli-json.c +++ b/aarch64/corefreq-cli-json.c @@ -526,6 +526,8 @@ void JsonSysInfo(RO(SHM_STRUCT) *RO(Shm)) json_start_object(&s); json_key(&s, "BTI"); json_literal(&s, "%u", (unsigned) RO(Shm)->Proc.Features.BTI); + json_key(&s, "GCS"); + json_literal(&s, "%u", (unsigned) RO(Shm)->Proc.Features.GCS); json_key(&s, "MTE"); json_literal(&s, "%u", (unsigned) RO(Shm)->Proc.Features.MTE); json_key(&s, "NMI"); diff --git a/aarch64/corefreq-cli-rsc-en.h b/aarch64/corefreq-cli-rsc-en.h index 618e9fe6..1dda5e2b 100644 --- a/aarch64/corefreq-cli-rsc-en.h +++ b/aarch64/corefreq-cli-rsc-en.h @@ -809,6 +809,7 @@ #define RSC_FEATURES_BTI_CODE_EN "Branch Target Identification" #define RSC_FEATURES_EBEP_CODE_EN "Exception-based event profiling" #define RSC_FEATURES_DIT_CODE_EN "Data Independent Timing" +#define RSC_FEATURES_GCS_CODE_EN "Guarded Control Stack" #define RSC_FEATURES_GIC_CODE_EN "Generic Interrupt Controller" #define RSC_FEATURES_MPAM_CODE_EN "Memory Partitioning and Monitoring" #define RSC_FEATURES_MTE_CODE_EN "Memory Tagging Extension" diff --git a/aarch64/corefreq-cli-rsc-fr.h b/aarch64/corefreq-cli-rsc-fr.h index e2bc32c2..37687617 100644 --- a/aarch64/corefreq-cli-rsc-fr.h +++ b/aarch64/corefreq-cli-rsc-fr.h @@ -504,6 +504,7 @@ do echo -en "$h$l\t""\xc3""\x$h$l""\t"; done; done;echo "Profilage d'""\xa9""v""\xa9""nements en fonction des exceptions" #define RSC_FEATURES_DIT_CODE_FR RSC_FEATURES_DIT_CODE_EN +#define RSC_FEATURES_GCS_CODE_FR RSC_FEATURES_GCS_CODE_EN #define RSC_FEATURES_GIC_CODE_FR \ "Contr""\xb4""leur d'interruption g""\xa9""n""\xa9""rique" diff --git a/aarch64/corefreq-cli-rsc.c b/aarch64/corefreq-cli-rsc.c index 29fc8a8d..225e3d52 100644 --- a/aarch64/corefreq-cli-rsc.c +++ b/aarch64/corefreq-cli-rsc.c @@ -716,6 +716,7 @@ RESOURCE_ST Resource[] = { LDT(RSC_FEATURES_BTI), LDT(RSC_FEATURES_EBEP), LDT(RSC_FEATURES_DIT), + LDT(RSC_FEATURES_GCS), LDT(RSC_FEATURES_GIC), LDT(RSC_FEATURES_MPAM), LDT(RSC_FEATURES_MTE), diff --git a/aarch64/corefreq-cli-rsc.h b/aarch64/corefreq-cli-rsc.h index ebf28322..c086e6b7 100644 --- a/aarch64/corefreq-cli-rsc.h +++ b/aarch64/corefreq-cli-rsc.h @@ -539,6 +539,7 @@ enum { RSC_FEATURES_BTI, RSC_FEATURES_EBEP, RSC_FEATURES_DIT, + RSC_FEATURES_GCS, RSC_FEATURES_GIC, RSC_FEATURES_MPAM, RSC_FEATURES_MTE, diff --git a/aarch64/corefreq-cli.c b/aarch64/corefreq-cli.c index c0886292..6124524d 100644 --- a/aarch64/corefreq-cli.c +++ b/aarch64/corefreq-cli.c @@ -1598,14 +1598,6 @@ REASON_CODE SysInfoFeatures( Window *win, RSC(FEATURES_AMU).CODE(), width - 23 - RSZ(FEATURES_AMU), NULL }, - { - NULL, - RO(Shm)->Proc.Features.BTI == 1, - attr_Feat, - 2, "%s%.*sBTI [%7s]", RSC(FEATURES_BTI).CODE(), - width - 18 - RSZ(FEATURES_BTI), - NULL - }, { NULL, RO(Shm)->Proc.Features.EBEP == 1, @@ -1709,7 +1701,7 @@ REASON_CODE SysInfoFeatures( Window *win, }, { NULL, - RO(Shm)->Proc.Features.UAO, + RO(Shm)->Proc.Features.UAO == 1, attr_Feat, 2, "%s%.*sUAO [%9s]", RSC(FEATURES_UAO).CODE(), width - 18 - RSZ(FEATURES_UAO), @@ -1791,6 +1783,22 @@ REASON_CODE SysInfoFeatures( Window *win, 0, NULL }, + { + NULL, + RO(Shm)->Proc.Features.BTI == 1, + attr_Feat, + 2, "%s%.*sBTI [%7s]", RSC(FEATURES_BTI).CODE(), + width - 18 - RSZ(FEATURES_BTI), + NULL + }, + { + NULL, + RO(Shm)->Proc.Features.GCS == 1, + attr_Feat, + 2, "%s%.*sGCS [%7s]", RSC(FEATURES_GCS).CODE(), + width - 18 - RSZ(FEATURES_GCS), + NULL + }, { NULL, RO(Shm)->Proc.Features.RME == 1, diff --git a/aarch64/corefreqk.c b/aarch64/corefreqk.c index 3b27d117..f8652b4d 100644 --- a/aarch64/corefreqk.c +++ b/aarch64/corefreqk.c @@ -989,6 +989,15 @@ static void Query_Features(void *pArg) iArg->Features->NMI = 0; break; } + switch (pfr1.GCS) { + case 0b0001: + iArg->Features->GCS = 1; + break; + case 0b0000: + default: + iArg->Features->GCS = 0; + break; + } if (Experimental && (iArg->HypervisorID == HYPERV_NONE)) { /* Query the Cluster Configuration */ diff --git a/aarch64/coretypes.h b/aarch64/coretypes.h index 1e904221..5f49c5b3 100644 --- a/aarch64/coretypes.h +++ b/aarch64/coretypes.h @@ -817,7 +817,8 @@ typedef struct /* BSP features. */ AMU_frac : 20-19, RME : 21-20, MTE : 23-21, - _Unused2_ : 64-23; + GCS : 24-23, + _Unused2_ : 64-24; Bit64 InvariantTSC : 8-0, HyperThreading : 9-8,