[kvm-unit-tests PATCH v3 08/17] x86: cet: Validate writing unaligned values to SSP MSR causes #GP

Sean Christopherson
2025-11-14T00:13:15Z

From: Chao Gao <chao.gao@intel.com>

Validate that writing invalid values to SSP MSRs triggers a #GP exception.
This verifies that necessary validity checks are performed by the hardware
or the underlying VMM.

Signed-off-by: Chao Gao <chao.gao@intel.com>
Signed-off-by: Mathias Krause <minipli@grsecurity.net>
Signed-off-by: Sean Christopherson <seanjc@google.com>
---
x86/cet.c | 5 +++++
1 file changed, 5 insertions(+)

diff --git a/x86/cet.c b/x86/cet.c
index 8c2cf8c6..80864fb1 100644
--- a/x86/cet.c
+++ b/x86/cet.c
@@ -56,6 +56,7 @@ int main(int ac, char **av)
char *shstk_virt;
unsigned long shstk_phys;
pteval_t pte = 0;
+ u8 vector;
bool rvc;

if (!this_cpu_has(X86_FEATURE_SHSTK)) {
@@ -105,5 +106,9 @@ int main(int ac, char **av)
write_cr4(read_cr4() & ~X86_CR4_CET);
wrmsr(MSR_IA32_U_CET, 0);

+ /* SSP should be 4-Byte aligned */
+ vector = wrmsr_safe(MSR_IA32_PL3_SSP, 0x1);
+ report(vector == GP_VECTOR, "MSR_IA32_PL3_SSP alignment test.");
+
return report_summary();
}
--
2.52.0.rc1.455.g30608eb744-goog