[kvm-unit-tests PATCH v3 07/17] x86: cet: Drop unnecessary casting

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

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

cet_shstk_func() and cet_ibt_func() have the same type as usermode_func.
So, remove the unnecessary casting.

Signed-off-by: Chao Gao <chao.gao@intel.com>
[mks: make the types really equal by using uint64_t]
Signed-off-by: Mathias Krause <minipli@grsecurity.net>
Signed-off-by: Sean Christopherson <seanjc@google.com>
---
x86/cet.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/x86/cet.c b/x86/cet.c
index d6ca5dd8..8c2cf8c6 100644
--- a/x86/cet.c
+++ b/x86/cet.c
@@ -8,7 +8,7 @@
#include "alloc_page.h"
#include "fault_test.h"

-static u64 cet_shstk_func(void)
+static uint64_t cet_shstk_func(void)
{
unsigned long *ret_addr, *ssp;

@@ -31,7 +31,7 @@ static u64 cet_shstk_func(void)
return 0;
}

-static u64 cet_ibt_func(void)
+static uint64_t cet_ibt_func(void)
{
/*
* In below assembly code, the first instruction at label 2 is not
@@ -93,13 +93,13 @@ int main(int ac, char **av)
write_cr4(read_cr4() | X86_CR4_CET);

printf("Unit test for CET user mode...\n");
- run_in_user((usermode_func)cet_shstk_func, CP_VECTOR, 0, 0, 0, 0, &rvc);
+ run_in_user(cet_shstk_func, CP_VECTOR, 0, 0, 0, 0, &rvc);
report(rvc && exception_error_code() == 1, "Shadow-stack protection test.");

/* Enable indirect-branch tracking */
wrmsr(MSR_IA32_U_CET, ENABLE_IBT_BIT);

- run_in_user((usermode_func)cet_ibt_func, CP_VECTOR, 0, 0, 0, 0, &rvc);
+ run_in_user(cet_ibt_func, CP_VECTOR, 0, 0, 0, 0, &rvc);
report(rvc && exception_error_code() == 3, "Indirect-branch tracking test.");

write_cr4(read_cr4() & ~X86_CR4_CET);
--
2.52.0.rc1.455.g30608eb744-goog