Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1653149 > unrolled thread

[PATCH v5 04/10] x86/hyper-v: fast hypercall implementation

Started byVitaly Kuznetsov <vkuznets@redhat.com>
First post2017-05-30 13:40 +0200
Last post2017-05-30 18:40 +0200
Articles 2 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH v5 04/10] x86/hyper-v: fast hypercall implementation Vitaly Kuznetsov <vkuznets@redhat.com> - 2017-05-30 13:40 +0200
    Re: [PATCH v5 04/10] x86/hyper-v: fast hypercall implementation Andy Shevchenko <andy.shevchenko@gmail.com> - 2017-05-30 18:40 +0200

#1653149 — [PATCH v5 04/10] x86/hyper-v: fast hypercall implementation

FromVitaly Kuznetsov <vkuznets@redhat.com>
Date2017-05-30 13:40 +0200
Subject[PATCH v5 04/10] x86/hyper-v: fast hypercall implementation
Message-ID<tMNFg-6JG-27@gated-at.bofh.it>
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>
Acked-by: K. Y. Srinivasan <kys@microsoft.com>
---
Changes since v4:
- Avoid union aliasing, drop hv_hypercall_input definition [Andy Shevchenko]
- Use double register "A" in 32 bits asm [Jork Loeser]
---
 arch/x86/include/asm/mshyperv.h | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)

diff --git a/arch/x86/include/asm/mshyperv.h b/arch/x86/include/asm/mshyperv.h
index 282eaed..d587d1e 100644
--- a/arch/x86/include/asm/mshyperv.h
+++ b/arch/x86/include/asm/mshyperv.h
@@ -212,6 +212,38 @@ static inline u64 hv_do_hypercall(u64 control, void *input, void *output)
 	return hv_status;
 }
 
+/* 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 | BIT(16); /* 'fast' flag */
+	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);
-- 
2.9.4

[toc] | [next] | [standalone]


#1653373

FromAndy Shevchenko <andy.shevchenko@gmail.com>
Date2017-05-30 18:40 +0200
Message-ID<tMSlA-1h4-19@gated-at.bofh.it>
In reply to#1653149
On Tue, May 30, 2017 at 2:34 PM, Vitaly Kuznetsov <vkuznets@redhat.com> wrote:
> 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.

> +       u64 hv_status, control = (u64)code | BIT(16); /* 'fast' flag */

It might make sense to define magic with appropriate name.

-- 
With Best Regards,
Andy Shevchenko

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web