[RFC PATCH 4/5] selftest/x86: Fix sysret_rip with ENDBR

From: Yu-cheng Yu
Date: Thu May 21 2020 - 17:17:45 EST


Insert endbr64 to assembly code of sysret_rip.

Signed-off-by: Yu-cheng Yu <yu-cheng.yu@xxxxxxxxx>
---
tools/testing/selftests/x86/sysret_rip.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/tools/testing/selftests/x86/sysret_rip.c b/tools/testing/selftests/x86/sysret_rip.c
index 84d74be1d902..027682a0f377 100644
--- a/tools/testing/selftests/x86/sysret_rip.c
+++ b/tools/testing/selftests/x86/sysret_rip.c
@@ -27,8 +27,9 @@ asm (
".pushsection \".text\", \"ax\"\n\t"
".balign 4096\n\t"
"test_page: .globl test_page\n\t"
- ".fill 4094,1,0xcc\n\t"
+ ".fill 4090,1,0xcc\n\t"
"test_syscall_insn:\n\t"
+ "endbr64\n\t"
"syscall\n\t"
".ifne . - test_page - 4096\n\t"
".error \"test page is not one page long\"\n\t"
@@ -151,7 +152,7 @@ static void test_syscall_fallthrough_to(unsigned long ip)

if (sigsetjmp(jmpbuf, 1) == 0) {
asm volatile ("call *%[syscall_insn]" :: "a" (SYS_getpid),
- [syscall_insn] "rm" (ip - 2));
+ [syscall_insn] "rm" (ip - 6));
errx(1, "[FAIL]\tSyscall trampoline returned");
}

--
2.21.0