Skip to content

Commit 1cd5f05

Browse files
author
Peter Zijlstra
committed
x86,static_call: Fix __static_call_return0 for i386
Paolo reported that the instruction sequence that is used to replace: call __static_call_return0 namely: 66 66 48 31 c0 data16 data16 xor %rax,%rax decodes to something else on i386, namely: 66 66 48 data16 dec %ax 31 c0 xor %eax,%eax Which is a nonsensical sequence that happens to have the same outcome. *However* an important distinction is that it consists of 2 instructions which is a problem when the thing needs to be overwriten with a regular call instruction again. As such, replace the instruction with something that decodes the same on both i386 and x86_64. Fixes: 3f2a8fc ("static_call/x86: Add __static_call_return0()") Reported-by: Paolo Bonzini <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
1 parent 3123109 commit 1cd5f05

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

arch/x86/kernel/static_call.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,9 @@ enum insn_type {
1212
};
1313

1414
/*
15-
* data16 data16 xorq %rax, %rax - a single 5 byte instruction that clears %rax
16-
* The REX.W cancels the effect of any data16.
15+
* cs cs cs xorl %eax, %eax - a single 5 byte instruction that clears %[er]ax
1716
*/
18-
static const u8 xor5rax[] = { 0x66, 0x66, 0x48, 0x31, 0xc0 };
17+
static const u8 xor5rax[] = { 0x2e, 0x2e, 0x2e, 0x31, 0xc0 };
1918

2019
static const u8 retinsn[] = { RET_INSN_OPCODE, 0xcc, 0xcc, 0xcc, 0xcc };
2120

0 commit comments

Comments
 (0)