From 6392262b68387299ee81d5d659cb5423a2ae1c9c Mon Sep 17 00:00:00 2001 From: Michal Kubecek Date: Mon, 26 Mar 2018 13:33:32 +0200 Subject: [PATCH 09/10] vmmon: fix indirect call with retpoline build Build against kernel with retpoline support issues warning objtool: Task_Switch()+0x425: indirect call found in RETPOLINE build This is because an indirect call in TaskSwitchToMonitor() is encoded using inline assembler so that it bypasses retpoline generation. For this purpose, macro CALL_NOSPEC exists since v4.15-rc8 (and has been backported into some distribution kernels with the rest of retpoline support). Use the macro if available and fallback to the original code if not. --- vmmon-only/common/task.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/vmmon-only/common/task.c b/vmmon-only/common/task.c index 98cc74a..400ebfe 100644 --- a/vmmon-only/common/task.c +++ b/vmmon-only/common/task.c @@ -2203,12 +2203,23 @@ TaskSwitchToMonitor(VMCrossPage *crosspage) { uint64 raxGetsWiped, rcxGetsWiped; +#ifdef CALL_NOSPEC + __asm__ __volatile__(CALL_NOSPEC + : "=a" (raxGetsWiped), + "=c" (rcxGetsWiped) + : "0" (codePtr), + "1" (crosspage), + THUNK_TARGET(codePtr) + : "rdx", "r8", "r9", "r10", "r11", "cc", "memory"); +#else __asm__ __volatile__("call *%%rax" : "=a" (raxGetsWiped), "=c" (rcxGetsWiped) : "0" (codePtr), "1" (crosspage) : "rdx", "r8", "r9", "r10", "r11", "cc", "memory"); +#endif + } #elif defined(_MSC_VER) /* -- 2.17.0