Skip to content

Commit e70e589

Browse files
dwmw2KAGA-KOKO
authored andcommitted
x86/retpoline/hyperv: Convert assembler indirect jumps
Convert all indirect jumps in hyperv inline asm code to use non-speculative sequences when CONFIG_RETPOLINE is enabled. Signed-off-by: David Woodhouse <dwmw@amazon.co.uk> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Acked-by: Arjan van de Ven <arjan@linux.intel.com> Acked-by: Ingo Molnar <mingo@kernel.org> Cc: gnomes@lxorguk.ukuu.org.uk Cc: Rik van Riel <riel@redhat.com> Cc: Andi Kleen <ak@linux.intel.com> Cc: Josh Poimboeuf <jpoimboe@redhat.com> Cc: thomas.lendacky@amd.com Cc: Peter Zijlstra <peterz@infradead.org> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Jiri Kosina <jikos@kernel.org> Cc: Andy Lutomirski <luto@amacapital.net> Cc: Dave Hansen <dave.hansen@intel.com> Cc: Kees Cook <keescook@google.com> Cc: Tim Chen <tim.c.chen@linux.intel.com> Cc: Greg Kroah-Hartman <gregkh@linux-foundation.org> Cc: Paul Turner <pjt@google.com> Link: https://lkml.kernel.org/r/1515707194-20531-9-git-send-email-dwmw@amazon.co.uk
1 parent 9351803 commit e70e589

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

arch/x86/include/asm/mshyperv.h

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include <linux/nmi.h>
88
#include <asm/io.h>
99
#include <asm/hyperv.h>
10+
#include <asm/nospec-branch.h>
1011

1112
/*
1213
* The below CPUID leaves are present if VersionAndFeatures.HypervisorPresent
@@ -186,10 +187,11 @@ static inline u64 hv_do_hypercall(u64 control, void *input, void *output)
186187
return U64_MAX;
187188

188189
__asm__ __volatile__("mov %4, %%r8\n"
189-
"call *%5"
190+
CALL_NOSPEC
190191
: "=a" (hv_status), ASM_CALL_CONSTRAINT,
191192
"+c" (control), "+d" (input_address)
192-
: "r" (output_address), "m" (hv_hypercall_pg)
193+
: "r" (output_address),
194+
THUNK_TARGET(hv_hypercall_pg)
193195
: "cc", "memory", "r8", "r9", "r10", "r11");
194196
#else
195197
u32 input_address_hi = upper_32_bits(input_address);
@@ -200,13 +202,13 @@ static inline u64 hv_do_hypercall(u64 control, void *input, void *output)
200202
if (!hv_hypercall_pg)
201203
return U64_MAX;
202204

203-
__asm__ __volatile__("call *%7"
205+
__asm__ __volatile__(CALL_NOSPEC
204206
: "=A" (hv_status),
205207
"+c" (input_address_lo), ASM_CALL_CONSTRAINT
206208
: "A" (control),
207209
"b" (input_address_hi),
208210
"D"(output_address_hi), "S"(output_address_lo),
209-
"m" (hv_hypercall_pg)
211+
THUNK_TARGET(hv_hypercall_pg)
210212
: "cc", "memory");
211213
#endif /* !x86_64 */
212214
return hv_status;
@@ -227,24 +229,24 @@ static inline u64 hv_do_fast_hypercall8(u16 code, u64 input1)
227229

228230
#ifdef CONFIG_X86_64
229231
{
230-
__asm__ __volatile__("call *%4"
232+
__asm__ __volatile__(CALL_NOSPEC
231233
: "=a" (hv_status), ASM_CALL_CONSTRAINT,
232234
"+c" (control), "+d" (input1)
233-
: "m" (hv_hypercall_pg)
235+
: THUNK_TARGET(hv_hypercall_pg)
234236
: "cc", "r8", "r9", "r10", "r11");
235237
}
236238
#else
237239
{
238240
u32 input1_hi = upper_32_bits(input1);
239241
u32 input1_lo = lower_32_bits(input1);
240242

241-
__asm__ __volatile__ ("call *%5"
243+
__asm__ __volatile__ (CALL_NOSPEC
242244
: "=A"(hv_status),
243245
"+c"(input1_lo),
244246
ASM_CALL_CONSTRAINT
245247
: "A" (control),
246248
"b" (input1_hi),
247-
"m" (hv_hypercall_pg)
249+
THUNK_TARGET(hv_hypercall_pg)
248250
: "cc", "edi", "esi");
249251
}
250252
#endif

0 commit comments

Comments
 (0)