Date: Tue, 14 Apr 2026 10:36:08 -0700
On Tuesday, 14 April 2026 02:42:20 Pacific Daylight Time Frederick Virchanza
Gotham via Std-Proposals wrote:
> Firstly, here's how you'd write an interceptor:
>
> [[interceptor]] void Logger(void)
> {
> puts("Function called");
The first thing anyone is going to ask is to get access to the arguments of the
call, so they can be logged.
The second is going to be to change the arguments.
> Some x86_64 processors only have SSE, some have AVX-256, and some have
> AVX-512, so at runtime I need to execute the CPUID instruction to find out.
Or you can use IFUNC and make a call instead. Push the target address onto the
stack and JMP to the saver-redirector-restorer.
> kmovq %k0, 520(%rsp)
> kmovq %k1, 528(%rsp)
> kmovq %k2, 536(%rsp)
> kmovq %k3, 544(%rsp)
> kmovq %k4, 552(%rsp)
> kmovq %k5, 560(%rsp)
> kmovq %k6, 568(%rsp)
> kmovq %k7, 576(%rsp)
> jmp .Lpush_done\@
Why are you saving the k regs? They are all scratch registers, aren't they?
Gotham via Std-Proposals wrote:
> Firstly, here's how you'd write an interceptor:
>
> [[interceptor]] void Logger(void)
> {
> puts("Function called");
The first thing anyone is going to ask is to get access to the arguments of the
call, so they can be logged.
The second is going to be to change the arguments.
> Some x86_64 processors only have SSE, some have AVX-256, and some have
> AVX-512, so at runtime I need to execute the CPUID instruction to find out.
Or you can use IFUNC and make a call instead. Push the target address onto the
stack and JMP to the saver-redirector-restorer.
> kmovq %k0, 520(%rsp)
> kmovq %k1, 528(%rsp)
> kmovq %k2, 536(%rsp)
> kmovq %k3, 544(%rsp)
> kmovq %k4, 552(%rsp)
> kmovq %k5, 560(%rsp)
> kmovq %k6, 568(%rsp)
> kmovq %k7, 576(%rsp)
> jmp .Lpush_done\@
Why are you saving the k regs? They are all scratch registers, aren't they?
-- Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org Principal Engineer - Intel Data Center - Platform & Sys. Eng.
Received on 2026-04-14 17:36:17
