Skip to content

Commit e91b6aa

Browse files
JasonChenCJjren1
authored andcommitted
retpoline: replace indirect jmp in switch_to function
Signed-off-by: Jason Chen CJ <jason.cj.chen@intel.com>
1 parent d14a7db commit e91b6aa

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

hypervisor/common/schedule.c

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,14 +199,26 @@ static void switch_to(struct vcpu *curr)
199199
if (curr == NULL) {
200200
asm volatile ("movq %1, %%rsp\n"
201201
"movq $0, %%rdi\n"
202-
"jmp *%0\n"
202+
"call 22f\n"
203+
"11: \n"
204+
"pause\n"
205+
"jmp 11b\n"
206+
"22:\n"
207+
"mov %0, (%%rsp)\n"
208+
"ret\n"
203209
:
204210
: "a"(default_idle), "r"(cur_sp)
205211
: "memory");
206212
} else {
207213
asm volatile ("movq %2, %%rsp\n"
208214
"movq %0, %%rdi\n"
209-
"jmp *%1\n"
215+
"call 44f\n"
216+
"33: \n"
217+
"pause\n"
218+
"jmp 33b\n"
219+
"44:\n"
220+
"mov %1, (%%rsp)\n"
221+
"ret\n"
210222
:
211223
: "c"(curr), "a"(vcpu_thread), "r"(cur_sp)
212224
: "memory");

0 commit comments

Comments
 (0)