Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1645634 > unrolled thread
| Started by | Vitaly Kuznetsov <vkuznets@redhat.com> |
|---|---|
| First post | 2017-05-19 16:20 +0200 |
| Last post | 2017-05-23 00:10 +0200 |
| Articles | 4 — 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.
[PATCH v3 04/10] x86/hyper-v: fast hypercall implementation Vitaly Kuznetsov <vkuznets@redhat.com> - 2017-05-19 16:20 +0200
Re: [PATCH v3 04/10] x86/hyper-v: fast hypercall implementation Andy Lutomirski <luto@kernel.org> - 2017-05-21 05:20 +0200
Re: [PATCH v3 04/10] x86/hyper-v: fast hypercall implementation Vitaly Kuznetsov <vkuznets@redhat.com> - 2017-05-22 12:50 +0200
Re: [PATCH v3 04/10] x86/hyper-v: fast hypercall implementation Andy Lutomirski <luto@kernel.org> - 2017-05-23 00:10 +0200
| From | Vitaly Kuznetsov <vkuznets@redhat.com> |
|---|---|
| Date | 2017-05-19 16:20 +0200 |
| Subject | [PATCH v3 04/10] x86/hyper-v: fast hypercall implementation |
| Message-ID | <tIQV4-3mw-15@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.
Proper hypercall input interface (struct hv_hypercall_input) definition is
added as well.
Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Acked-by: K. Y. Srinivasan <kys@microsoft.com>
Tested-by: Simon Xiao <sixiao@microsoft.com>
Tested-by: Srikanth Myakam <v-srm@microsoft.com>
---
arch/x86/include/asm/mshyperv.h | 39 ++++++++++++++++++++++++++++++++++++++
arch/x86/include/uapi/asm/hyperv.h | 19 +++++++++++++++++++
2 files changed, 58 insertions(+)
diff --git a/arch/x86/include/asm/mshyperv.h b/arch/x86/include/asm/mshyperv.h
index e293937..028e29b 100644
--- a/arch/x86/include/asm/mshyperv.h
+++ b/arch/x86/include/asm/mshyperv.h
@@ -216,6 +216,45 @@ static inline u64 hv_do_hypercall(u64 control, void *input, void *output)
#endif /* !x86_64 */
}
+/* Fast hypercall with 8 bytes of input and no output */
+static inline u64 hv_do_fast_hypercall8(u16 code, u64 input1)
+{
+ union hv_hypercall_input control = {0};
+
+ control.code = code;
+ control.fast = 1;
+#ifdef CONFIG_X86_64
+ {
+ u64 hv_status;
+
+ __asm__ __volatile__("call *%3"
+ : "=a" (hv_status),
+ "+c" (control.as_uint64), "+d" (input1)
+ : "m" (hv_hypercall_pg)
+ : "cc", "r8", "r9", "r10", "r11");
+ return hv_status;
+ }
+#else
+ {
+ u32 hv_status_hi, hv_status_lo;
+ u32 input1_hi = (u32)(input1 >> 32);
+ u32 input1_lo = (u32)input1;
+
+ __asm__ __volatile__ ("call *%6"
+ : "=d"(hv_status_hi),
+ "=a"(hv_status_lo),
+ "+c"(input1_lo)
+ : "d" (control.as_uint32_hi),
+ "a" (control.as_uint32_lo),
+ "b" (input1_hi),
+ "m" (hv_hypercall_pg)
+ : "cc", "edi", "esi");
+
+ return hv_status_lo | ((u64)hv_status_hi << 32);
+ }
+#endif
+}
+
void hyperv_init(void);
void hyperv_report_panic(struct pt_regs *regs);
bool hv_is_hypercall_page_setup(void);
diff --git a/arch/x86/include/uapi/asm/hyperv.h b/arch/x86/include/uapi/asm/hyperv.h
index 432df4b..c87e900 100644
--- a/arch/x86/include/uapi/asm/hyperv.h
+++ b/arch/x86/include/uapi/asm/hyperv.h
@@ -256,6 +256,25 @@
#define HV_PROCESSOR_POWER_STATE_C2 2
#define HV_PROCESSOR_POWER_STATE_C3 3
+/* Hypercall interface */
+union hv_hypercall_input {
+ u64 as_uint64;
+ struct {
+ __u32 as_uint32_lo;
+ __u32 as_uint32_hi;
+ };
+ struct {
+ __u64 code:16;
+ __u64 fast:1;
+ __u64 varhead_size:10;
+ __u64 reserved1:5;
+ __u64 rep_count:12;
+ __u64 reserved2:4;
+ __u64 rep_start:12;
+ __u64 reserved3:4;
+ };
+};
+
/* hypercall status code */
#define HV_STATUS_SUCCESS 0
#define HV_STATUS_INVALID_HYPERCALL_CODE 2
--
2.9.3
[toc] | [next] | [standalone]
| From | Andy Lutomirski <luto@kernel.org> |
|---|---|
| Date | 2017-05-21 05:20 +0200 |
| Message-ID | <tJpzr-21p-1@gated-at.bofh.it> |
| In reply to | #1645634 |
On 05/19/2017 07:09 AM, Vitaly Kuznetsov 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.
>
> Proper hypercall input interface (struct hv_hypercall_input) definition is
> added as well.
>
> Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
> Acked-by: K. Y. Srinivasan <kys@microsoft.com>
> Tested-by: Simon Xiao <sixiao@microsoft.com>
> Tested-by: Srikanth Myakam <v-srm@microsoft.com>
> ---
> arch/x86/include/asm/mshyperv.h | 39 ++++++++++++++++++++++++++++++++++++++
> arch/x86/include/uapi/asm/hyperv.h | 19 +++++++++++++++++++
> 2 files changed, 58 insertions(+)
>
> diff --git a/arch/x86/include/asm/mshyperv.h b/arch/x86/include/asm/mshyperv.h
> index e293937..028e29b 100644
> --- a/arch/x86/include/asm/mshyperv.h
> +++ b/arch/x86/include/asm/mshyperv.h
> @@ -216,6 +216,45 @@ static inline u64 hv_do_hypercall(u64 control, void *input, void *output)
> #endif /* !x86_64 */
> }
>
> +/* Fast hypercall with 8 bytes of input and no output */
> +static inline u64 hv_do_fast_hypercall8(u16 code, u64 input1)
> +{
> + union hv_hypercall_input control = {0};
> +
> + control.code = code;
> + control.fast = 1;
> +#ifdef CONFIG_X86_64
> + {
> + u64 hv_status;
> +
> + __asm__ __volatile__("call *%3"
> + : "=a" (hv_status),
> + "+c" (control.as_uint64), "+d" (input1)
> + : "m" (hv_hypercall_pg)
> + : "cc", "r8", "r9", "r10", "r11");
> + return hv_status;
> + }
> +#else
> + {
> + u32 hv_status_hi, hv_status_lo;
> + u32 input1_hi = (u32)(input1 >> 32);
> + u32 input1_lo = (u32)input1;
> +
> + __asm__ __volatile__ ("call *%6"
> + : "=d"(hv_status_hi),
> + "=a"(hv_status_lo),
> + "+c"(input1_lo)
> + : "d" (control.as_uint32_hi),
> + "a" (control.as_uint32_lo),
> + "b" (input1_hi),
> + "m" (hv_hypercall_pg)
> + : "cc", "edi", "esi");
> +
> + return hv_status_lo | ((u64)hv_status_hi << 32);
> + }
> +#endif
This is going to need an explicit "sp" annotation to force a stack
frame, I think. Otherwise objtool is likely to get mad in a
frame-pointer-omitted build.
[toc] | [prev] | [next] | [standalone]
| From | Vitaly Kuznetsov <vkuznets@redhat.com> |
|---|---|
| Date | 2017-05-22 12:50 +0200 |
| Message-ID | <tJT4u-4AD-19@gated-at.bofh.it> |
| In reply to | #1646239 |
Andy Lutomirski <luto@kernel.org> writes:
> On 05/19/2017 07:09 AM, Vitaly Kuznetsov 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.
>>
>> Proper hypercall input interface (struct hv_hypercall_input) definition is
>> added as well.
>>
>> Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
>> Acked-by: K. Y. Srinivasan <kys@microsoft.com>
>> Tested-by: Simon Xiao <sixiao@microsoft.com>
>> Tested-by: Srikanth Myakam <v-srm@microsoft.com>
>> ---
>> arch/x86/include/asm/mshyperv.h | 39 ++++++++++++++++++++++++++++++++++++++
>> arch/x86/include/uapi/asm/hyperv.h | 19 +++++++++++++++++++
>> 2 files changed, 58 insertions(+)
>>
>> diff --git a/arch/x86/include/asm/mshyperv.h b/arch/x86/include/asm/mshyperv.h
>> index e293937..028e29b 100644
>> --- a/arch/x86/include/asm/mshyperv.h
>> +++ b/arch/x86/include/asm/mshyperv.h
>> @@ -216,6 +216,45 @@ static inline u64 hv_do_hypercall(u64 control, void *input, void *output)
>> #endif /* !x86_64 */
>> }
>> +/* Fast hypercall with 8 bytes of input and no output */
>> +static inline u64 hv_do_fast_hypercall8(u16 code, u64 input1)
>> +{
>> + union hv_hypercall_input control = {0};
>> +
>> + control.code = code;
>> + control.fast = 1;
>> +#ifdef CONFIG_X86_64
>> + {
>> + u64 hv_status;
>> +
>> + __asm__ __volatile__("call *%3"
>> + : "=a" (hv_status),
>> + "+c" (control.as_uint64), "+d" (input1)
>> + : "m" (hv_hypercall_pg)
>> + : "cc", "r8", "r9", "r10", "r11");
>> + return hv_status;
>> + }
>> +#else
>> + {
>> + u32 hv_status_hi, hv_status_lo;
>> + u32 input1_hi = (u32)(input1 >> 32);
>> + u32 input1_lo = (u32)input1;
>> +
>> + __asm__ __volatile__ ("call *%6"
>> + : "=d"(hv_status_hi),
>> + "=a"(hv_status_lo),
>> + "+c"(input1_lo)
>> + : "d" (control.as_uint32_hi),
>> + "a" (control.as_uint32_lo),
>> + "b" (input1_hi),
>> + "m" (hv_hypercall_pg)
>> + : "cc", "edi", "esi");
>> +
>> + return hv_status_lo | ((u64)hv_status_hi << 32);
>> + }
>> +#endif
>
> This is going to need an explicit "sp" annotation to force a stack
> frame, I think. Otherwise objtool is likely to get mad in a
> frame-pointer-omitted build.
>
You mean I should do something like
diff --git a/arch/x86/include/asm/mshyperv.h b/arch/x86/include/asm/mshyperv.h
index 359967f..f86c4ae 100644
--- a/arch/x86/include/asm/mshyperv.h
+++ b/arch/x86/include/asm/mshyperv.h
@@ -221,6 +221,7 @@ static inline u64 hv_do_hypercall(u64 control, void *input, void *output)
static inline u64 hv_do_fast_hypercall8(u16 code, u64 input1)
{
union hv_hypercall_input control = {0};
+ register void *__sp asm(_ASM_SP);
control.code = code;
control.fast = 1;
@@ -228,8 +229,8 @@ static inline u64 hv_do_fast_hypercall8(u16 code, u64 input1)
{
u64 hv_status;
- __asm__ __volatile__("call *%3"
- : "=a" (hv_status),
+ __asm__ __volatile__("call *%4"
+ : "=a" (hv_status), "+r" (__sp),
"+c" (control.as_uint64), "+d" (input1)
: "m" (hv_hypercall_pg)
: "cc", "r8", "r9", "r10", "r11");
@@ -241,10 +242,11 @@ static inline u64 hv_do_fast_hypercall8(u16 code, u64 input1)
u32 input1_hi = (u32)(input1 >> 32);
u32 input1_lo = (u32)input1;
- __asm__ __volatile__ ("call *%6"
+ __asm__ __volatile__ ("call *%7"
: "=d"(hv_status_hi),
"=a"(hv_status_lo),
- "+c"(input1_lo)
+ "+c"(input1_lo),
+ "+r"(__sp)
: "d" (control.as_uint32_hi),
"a" (control.as_uint32_lo),
"b" (input1_hi),
(stollen from 0e8e2238)? hv_do_hypercall() will need this adjustment
too, I think.
--
Vitaly
[toc] | [prev] | [next] | [standalone]
| From | Andy Lutomirski <luto@kernel.org> |
|---|---|
| Date | 2017-05-23 00:10 +0200 |
| Message-ID | <tK3Gy-2Wa-9@gated-at.bofh.it> |
| In reply to | #1646726 |
On Mon, May 22, 2017 at 3:44 AM, Vitaly Kuznetsov <vkuznets@redhat.com> wrote:
> Andy Lutomirski <luto@kernel.org> writes:
>
>> On 05/19/2017 07:09 AM, Vitaly Kuznetsov 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.
>>>
>>> Proper hypercall input interface (struct hv_hypercall_input) definition is
>>> added as well.
>>>
>>> Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
>>> Acked-by: K. Y. Srinivasan <kys@microsoft.com>
>>> Tested-by: Simon Xiao <sixiao@microsoft.com>
>>> Tested-by: Srikanth Myakam <v-srm@microsoft.com>
>>> ---
>>> arch/x86/include/asm/mshyperv.h | 39 ++++++++++++++++++++++++++++++++++++++
>>> arch/x86/include/uapi/asm/hyperv.h | 19 +++++++++++++++++++
>>> 2 files changed, 58 insertions(+)
>>>
>>> diff --git a/arch/x86/include/asm/mshyperv.h b/arch/x86/include/asm/mshyperv.h
>>> index e293937..028e29b 100644
>>> --- a/arch/x86/include/asm/mshyperv.h
>>> +++ b/arch/x86/include/asm/mshyperv.h
>>> @@ -216,6 +216,45 @@ static inline u64 hv_do_hypercall(u64 control, void *input, void *output)
>>> #endif /* !x86_64 */
>>> }
>>> +/* Fast hypercall with 8 bytes of input and no output */
>>> +static inline u64 hv_do_fast_hypercall8(u16 code, u64 input1)
>>> +{
>>> + union hv_hypercall_input control = {0};
>>> +
>>> + control.code = code;
>>> + control.fast = 1;
>>> +#ifdef CONFIG_X86_64
>>> + {
>>> + u64 hv_status;
>>> +
>>> + __asm__ __volatile__("call *%3"
>>> + : "=a" (hv_status),
>>> + "+c" (control.as_uint64), "+d" (input1)
>>> + : "m" (hv_hypercall_pg)
>>> + : "cc", "r8", "r9", "r10", "r11");
>>> + return hv_status;
>>> + }
>>> +#else
>>> + {
>>> + u32 hv_status_hi, hv_status_lo;
>>> + u32 input1_hi = (u32)(input1 >> 32);
>>> + u32 input1_lo = (u32)input1;
>>> +
>>> + __asm__ __volatile__ ("call *%6"
>>> + : "=d"(hv_status_hi),
>>> + "=a"(hv_status_lo),
>>> + "+c"(input1_lo)
>>> + : "d" (control.as_uint32_hi),
>>> + "a" (control.as_uint32_lo),
>>> + "b" (input1_hi),
>>> + "m" (hv_hypercall_pg)
>>> + : "cc", "edi", "esi");
>>> +
>>> + return hv_status_lo | ((u64)hv_status_hi << 32);
>>> + }
>>> +#endif
>>
>> This is going to need an explicit "sp" annotation to force a stack
>> frame, I think. Otherwise objtool is likely to get mad in a
>> frame-pointer-omitted build.
>>
>
> You mean I should do something like
>
> diff --git a/arch/x86/include/asm/mshyperv.h b/arch/x86/include/asm/mshyperv.h
> index 359967f..f86c4ae 100644
> --- a/arch/x86/include/asm/mshyperv.h
> +++ b/arch/x86/include/asm/mshyperv.h
> @@ -221,6 +221,7 @@ static inline u64 hv_do_hypercall(u64 control, void *input, void *output)
> static inline u64 hv_do_fast_hypercall8(u16 code, u64 input1)
> {
> union hv_hypercall_input control = {0};
> + register void *__sp asm(_ASM_SP);
Exactly.
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web