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


Groups > linux.kernel > #1647435

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

Path csiph.com!eternal-september.org!feeder.eternal-september.org!aioe.org!bofh.it!news.nic.it!robomod
From Andy Lutomirski <luto@kernel.org>
Newsgroups linux.kernel
Subject Re: [PATCH v3 04/10] x86/hyper-v: fast hypercall implementation
Date Tue, 23 May 2017 00:10:02 +0200
Message-ID <tK3Gy-2Wa-9@gated-at.bofh.it> (permalink)
References <tIQV3-3mw-3@gated-at.bofh.it> <tIQV4-3mw-15@gated-at.bofh.it> <tJpzr-21p-1@gated-at.bofh.it> <tJT4u-4AD-19@gated-at.bofh.it>
X-Original-To Vitaly Kuznetsov <vkuznets@redhat.com>
Dmarc-Filter OpenDMARC Filter v1.3.2 mail.kernel.org 0EED4239E5
Authentication-Results mail.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.org
Authentication-Results mail.kernel.org; spf=none smtp.mailfrom=luto@kernel.org
X-Gm-Message-State AODbwcCrpWA+tKXVfz6z/0w0u8Qf1KNOWHoH8IQoD5lYbBNbaZyVFz42 Z2VGU9/k2+EIu95Jk5As4YUzQ8yH9xgG
X-Received by 10.31.161.213 with SMTP id k204mr8318970vke.57.1495490668126; Mon, 22 May 2017 15:04:28 -0700 (PDT)
MIME-Version 1.0
X-Gmail-Original-Message-ID <CALCETrV0d+r3E_c7SRYkGp=WGZu6MEtCwgshUHjgT8H8_aXC6A@mail.gmail.com>
Content-Type text/plain; charset="UTF-8"
Sender robomod@news.nic.it
List-ID <linux-kernel.vger.kernel.org>
X-Mailing-List linux-kernel@vger.kernel.org
Approved robomod@news.nic.it
Lines 83
Organization linux.* mail to news gateway
X-Original-Cc Andy Lutomirski <luto@kernel.org>, devel@linuxdriverproject.org, Stephen Hemminger <sthemmin@microsoft.com>, Jork Loeser <Jork.Loeser@microsoft.com>, Haiyang Zhang <haiyangz@microsoft.com>, X86 ML <x86@kernel.org>, "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>, Steven Rostedt <rostedt@goodmis.org>, Ingo Molnar <mingo@redhat.com>, "H. Peter Anvin" <hpa@zytor.com>, Thomas Gleixner <tglx@linutronix.de>
X-Original-Date Mon, 22 May 2017 15:04:07 -0700
X-Original-Message-ID <CALCETrV0d+r3E_c7SRYkGp=WGZu6MEtCwgshUHjgT8H8_aXC6A@mail.gmail.com>
X-Original-References <20170519140953.1167-1-vkuznets@redhat.com> <20170519140953.1167-5-vkuznets@redhat.com> <1fa6d42d-0f2d-2db6-47ad-d1ae06e13f02@kernel.org> <87y3tptbm5.fsf@vitty.brq.redhat.com>
X-Original-Sender linux-kernel-owner@vger.kernel.org
Xref csiph.com linux.kernel:1647435

Show key headers only | View raw


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.

Back to linux.kernel | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

[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

csiph-web