x86/entry/64: Use JMP instead of JMPQ [Linux 3.16.72]

This Linux kernel change "x86/entry/64: Use JMP instead of JMPQ" is included in the Linux 3.16.72 release. This change is authored by Josh Poimboeuf <jpoimboe [at] redhat.com> on Mon Jul 15 11:51:39 2019 -0500. The commit for this change in Linux stable tree is e191f51 (patch) which is from upstream commit 64dbc12. The same Linux upstream change may have been applied to various maintained Linux releases and you can find all Linux releases containing changes from upstream 64dbc12.

x86/entry/64: Use JMP instead of JMPQ

commit 64dbc122b20f75183d8822618c24f85144a5a94d upstream.

Somehow the swapgs mitigation entry code patch ended up with a JMPQ
instruction instead of JMP, where only the short jump is needed.  Some
assembler versions apparently fail to optimize JMPQ into a two-byte JMP
when possible, instead always using a 7-byte JMP with relocation.  For
some reason that makes the entry code explode with a #GP during boot.

Change it back to "JMP" as originally intended.

Fixes: 18ec54fdd6d1 ("x86/speculation: Prepare entry code for Spectre v1 swapgs mitigations")
Signed-off-by: Josh Poimboeuf <[email protected]>
Signed-off-by: Thomas Gleixner <[email protected]>
[bwh: Backported to 3.16: adjust filename, context]
Signed-off-by: Ben Hutchings <[email protected]>

There are 2 lines of Linux source code added/deleted in this change. Code changes to Linux kernel are as follows.

 arch/x86/kernel/entry_64.S | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S
index b4274d9..467069f 100644
--- a/arch/x86/kernel/entry_64.S
+++ b/arch/x86/kernel/entry_64.S
@@ -267,7 +267,7 @@ ENDPROC(native_usergs_sysret64)
    SWAPGS
    FENCE_SWAPGS_USER_ENTRY
    SWITCH_KERNEL_CR3
-   jmpq    2f
+   jmp 2f
 1:
    FENCE_SWAPGS_KERNEL_ENTRY
 2:

Leave a Reply

Your email address will not be published. Required fields are marked *