x86/hyper-v: Introduce fast hypercall implementation
authorVitaly Kuznetsov <vkuznets@redhat.com>
Wed, 2 Aug 2017 16:09:15 +0000 (18:09 +0200)
committerIngo Molnar <mingo@kernel.org>
Thu, 10 Aug 2017 14:50:22 +0000 (16:50 +0200)
Hyper-V supports 'fast' hypercalls when all parameters are passed through
registers. Implement an inline version of a simpliest of these calls:
hypercall with one 8-byte input and no output.

Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Reviewed-by: Stephen Hemminger <sthemmin@microsoft.com>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Haiyang Zhang <haiyangz@microsoft.com>
Cc: Jork Loeser <Jork.Loeser@microsoft.com>
Cc: K. Y. Srinivasan <kys@microsoft.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Simon Xiao <sixiao@microsoft.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: devel@linuxdriverproject.org
Link: http://lkml.kernel.org/r/20170802160921.21791-4-vkuznets@redhat.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
arch/x86/include/asm/mshyperv.h

index 6fa5e342cc8687492ba4f0a41ce594966c6e68f5..e484255bd9defb1c75644282208c52c4998f6253 100644 (file)
@@ -209,6 +209,40 @@ static inline u64 hv_do_hypercall(u64 control, void *input, void *output)
        return hv_status;
 }
 
+#define HV_HYPERCALL_FAST_BIT          BIT(16)
+
+/* Fast hypercall with 8 bytes of input and no output */
+static inline u64 hv_do_fast_hypercall8(u16 code, u64 input1)
+{
+       u64 hv_status, control = (u64)code | HV_HYPERCALL_FAST_BIT;
+       register void *__sp asm(_ASM_SP);
+
+#ifdef CONFIG_X86_64
+       {
+               __asm__ __volatile__("call *%4"
+                                    : "=a" (hv_status), "+r" (__sp),
+                                      "+c" (control), "+d" (input1)
+                                    : "m" (hv_hypercall_pg)
+                                    : "cc", "r8", "r9", "r10", "r11");
+       }
+#else
+       {
+               u32 input1_hi = upper_32_bits(input1);
+               u32 input1_lo = lower_32_bits(input1);
+
+               __asm__ __volatile__ ("call *%5"
+                                     : "=A"(hv_status),
+                                       "+c"(input1_lo),
+                                       "+r"(__sp)
+                                     : "A" (control),
+                                       "b" (input1_hi),
+                                       "m" (hv_hypercall_pg)
+                                     : "cc", "edi", "esi");
+       }
+#endif
+               return hv_status;
+}
+
 void hyperv_init(void);
 void hyperv_report_panic(struct pt_regs *regs);
 bool hv_is_hypercall_page_setup(void);