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>
Fri, 25 Mar 2022 17:06:38 +0000 (17:06 +0000)
commitf18d3a07a84d1c9c06e2cbf10da2f6f15d55431a
treef1dd4327d878684c12805e25214cf081372c4756
parent9c8a0179039e523cee6de194073c7e3731b952e9
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>
(cherry picked from commit 809beac3e7fdfd20000386453c64a1e2a3d93075)
xen/arch/x86/x86_64/traps.c