x86/traps: Rework write_stub_trampoline() to not hardcode the jmp
authorAndrew Cooper <andrew.cooper3@citrix.com>
Mon, 1 Nov 2021 12:36:33 +0000 (12:36 +0000)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Wed, 23 Feb 2022 15:33:43 +0000 (15:33 +0000)
commit809beac3e7fdfd20000386453c64a1e2a3d93075
tree44c8ebf3c95ebbcea0766df9b7d46f2889629b63
parent48cdc15a424f9fadad7f9aed00e7dc8ef16a2196
x86/traps: Rework write_stub_trampoline() to not hardcode the jmp

For CET-IBT, we will need to optionally insert an endbr64 instruction at the
start of the stub.  Don't hardcode the jmp displacement assuming that it
starts at byte 24 of the stub.

Also add extra comments describing what is going on.  The mix of %rax and %rsp
is far from trivial to follow.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
xen/arch/x86/x86_64/traps.c