x86/cet: Simplify IBT test
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH 6/8 x86/cet: Simplify IBT test
[resend with kvm@ on cc]
Quoted 14 lines · Chao Gao
Quoted 13 lines · Mathias Krause
static
uint64_tcet_ibt_func(void)
{(quoted diff) +1
-0+ unsigned long tmp;/* * In below assembly code, the first instruction at label 2 is not * endbr64, it'll trigger #CP with error code 0x3, and the execution * is terminated when HW detects the violation. */ printf("No endbr64 instruction at jmp target, this triggers #CP...\n");(quoted diff) +0
-4- asm volatile ("movq $2, %rcx\n" - "dec %rcx\n" - "leaq 2f(%rip), %rax\n" - "jmp *%rax \n"
Quoted 9 lines
Review
Quoted 6 lines
(quoted diff) +4
-2- "2:\n" - "dec %rcx\n"); + asm volatile ("leaq 2f(%%rip), %0\n\t" + "jmpq *%0\n\t" + "2:" + : "=r"(tmp));@tmp isn't needed. We can still use "rax" and list it as clobbered.
I still prefer letting the compiler choose a fitting register. This also makes it easier to enable this code to be 32-bit ready. So 'tmp' may seem unnecessary, but it's a vehicle to allow the compiler to choose an unused register. RAX needs to be set to zero, after all.
Thanks,
Mathias
Quoted 3 lines
Quoted 3 lines
return 0; }