Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752019AbdFYRJY (ORCPT ); Sun, 25 Jun 2017 13:09:24 -0400 Received: from a2nlsmtp01-05.prod.iad2.secureserver.net ([198.71.225.49]:43984 "EHLO a2nlsmtp01-05.prod.iad2.secureserver.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751339AbdFYRHw (ORCPT ); Sun, 25 Jun 2017 13:07:52 -0400 x-originating-ip: 107.180.71.197 From: kys@exchange.microsoft.com To: gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, devel@linuxdriverproject.org, olaf@aepfle.de, apw@canonical.com, vkuznets@redhat.com, jasowang@redhat.com, leann.ogasawara@canonical.com, marcelo.cerri@canonical.com, sthemmin@microsoft.com Cc: "K. Y. Srinivasan" Subject: [PATCH 04/10] x86/hyper-v: fast hypercall implementation Date: Sun, 25 Jun 2017 10:06:43 -0700 Message-Id: <1498410409-30997-4-git-send-email-kys@exchange.microsoft.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1498410380-30955-1-git-send-email-kys@exchange.microsoft.com> References: <1498410380-30955-1-git-send-email-kys@exchange.microsoft.com> Reply-To: kys@microsoft.com X-CMAE-Envelope: MS4wfNofXgILmdOw5GAXVPnaX8pagFoN5df7oeAI1WRHeQIjiG0Fda16lyWK+loohweKXpXzISTNBO2efLkIYtdhSFNfDaCoGg9vFsVc8zCc9gJuGTZJqM+7 OaxkN6avEp7cVALi2fAZnmIVgZvf0TmP67FhJhks6zjXsNXWnnCLzB5iV9bu5z0aPieJdPf2UWe5dvIVDB4RwALJ0clw1L8szJrKTM6dilbjEl9y5wHhJhCo dlHGTtbfUu8jXF+M4GdtUs95o24tpB2d27oVF0V006Or52FtP6izZIre8n3W72q6Dq+7e6kMfELWl3slagugU1bA3GwNBoobzrjQtaDbhsyQlOkeaZClwNIQ xtLDjFQB+WAfLgH7yzQQ43NKt1LEbbCGyuOkFBAidja1a/TEXjecRVV/z+dLRZlfyyuDqyDpoqZC/BJLCms5ig0c9sWmYQ37fV2X+WM3H73TWmwPa4ET6SAg BnvfleEvdjPnbKpjXibId1vEvPEDPCKd98pyLCV8gWw6SG7fghilod2xSUsUnqr6MZviOZB+x5dw8pp8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1810 Lines: 60 From: Vitaly Kuznetsov 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 Reviewed-by: Andy Shevchenko Signed-off-by: K. Y. Srinivasan --- arch/x86/include/asm/mshyperv.h | 34 ++++++++++++++++++++++++++++++++++ 1 files changed, 34 insertions(+), 0 deletions(-) diff --git a/arch/x86/include/asm/mshyperv.h b/arch/x86/include/asm/mshyperv.h index a004b3b..f3bedb4 100644 --- a/arch/x86/include/asm/mshyperv.h +++ b/arch/x86/include/asm/mshyperv.h @@ -211,6 +211,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); -- 1.7.1