Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753375AbdHJQnY (ORCPT ); Thu, 10 Aug 2017 12:43:24 -0400 Received: from terminus.zytor.com ([65.50.211.136]:42715 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752840AbdHJQnV (ORCPT ); Thu, 10 Aug 2017 12:43:21 -0400 Date: Thu, 10 Aug 2017 09:38:41 -0700 From: tip-bot for Vitaly Kuznetsov Message-ID: Cc: rostedt@goodmis.org, peterz@infradead.org, vkuznets@redhat.com, luto@kernel.org, hpa@zytor.com, linux-kernel@vger.kernel.org, mingo@kernel.org, tglx@linutronix.de, Jork.Loeser@microsoft.com, torvalds@linux-foundation.org, andy.shevchenko@gmail.com, kys@microsoft.com, sixiao@microsoft.com, haiyangz@microsoft.com, sthemmin@microsoft.com Reply-To: linux-kernel@vger.kernel.org, tglx@linutronix.de, hpa@zytor.com, mingo@kernel.org, Jork.Loeser@microsoft.com, torvalds@linux-foundation.org, kys@microsoft.com, andy.shevchenko@gmail.com, sixiao@microsoft.com, haiyangz@microsoft.com, sthemmin@microsoft.com, rostedt@goodmis.org, peterz@infradead.org, vkuznets@redhat.com, luto@kernel.org In-Reply-To: <20170802160921.21791-6-vkuznets@redhat.com> References: <20170802160921.21791-6-vkuznets@redhat.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:x86/platform] x86/hyper-v: Implement rep hypercalls Git-Commit-ID: 806c89273bab0c8af0202a6fb6279f36042cb2e6 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3584 Lines: 101 Commit-ID: 806c89273bab0c8af0202a6fb6279f36042cb2e6 Gitweb: http://git.kernel.org/tip/806c89273bab0c8af0202a6fb6279f36042cb2e6 Author: Vitaly Kuznetsov AuthorDate: Wed, 2 Aug 2017 18:09:17 +0200 Committer: Ingo Molnar CommitDate: Thu, 10 Aug 2017 16:50:22 +0200 x86/hyper-v: Implement rep hypercalls Rep hypercalls are normal hypercalls which perform multiple actions at once. Hyper-V guarantees to return exectution to the caller in not more than 50us and the caller needs to use hypercall continuation. Touch NMI watchdog between hypercall invocations. This is going to be used for HvFlushVirtualAddressList hypercall for remote TLB flushing. Signed-off-by: Vitaly Kuznetsov Reviewed-by: Andy Shevchenko Reviewed-by: Stephen Hemminger Cc: Andy Lutomirski Cc: Haiyang Zhang Cc: Jork Loeser Cc: K. Y. Srinivasan Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Simon Xiao Cc: Steven Rostedt Cc: Thomas Gleixner Cc: devel@linuxdriverproject.org Link: http://lkml.kernel.org/r/20170802160921.21791-6-vkuznets@redhat.com Signed-off-by: Ingo Molnar --- arch/x86/include/asm/mshyperv.h | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/arch/x86/include/asm/mshyperv.h b/arch/x86/include/asm/mshyperv.h index e484255..efa1860 100644 --- a/arch/x86/include/asm/mshyperv.h +++ b/arch/x86/include/asm/mshyperv.h @@ -3,6 +3,7 @@ #include #include +#include #include #include @@ -209,7 +210,13 @@ static inline u64 hv_do_hypercall(u64 control, void *input, void *output) return hv_status; } +#define HV_HYPERCALL_RESULT_MASK GENMASK_ULL(15, 0) #define HV_HYPERCALL_FAST_BIT BIT(16) +#define HV_HYPERCALL_VARHEAD_OFFSET 17 +#define HV_HYPERCALL_REP_COMP_OFFSET 32 +#define HV_HYPERCALL_REP_COMP_MASK GENMASK_ULL(43, 32) +#define HV_HYPERCALL_REP_START_OFFSET 48 +#define HV_HYPERCALL_REP_START_MASK GENMASK_ULL(59, 48) /* Fast hypercall with 8 bytes of input and no output */ static inline u64 hv_do_fast_hypercall8(u16 code, u64 input1) @@ -243,6 +250,38 @@ static inline u64 hv_do_fast_hypercall8(u16 code, u64 input1) return hv_status; } +/* + * Rep hypercalls. Callers of this functions are supposed to ensure that + * rep_count and varhead_size comply with Hyper-V hypercall definition. + */ +static inline u64 hv_do_rep_hypercall(u16 code, u16 rep_count, u16 varhead_size, + void *input, void *output) +{ + u64 control = code; + u64 status; + u16 rep_comp; + + control |= (u64)varhead_size << HV_HYPERCALL_VARHEAD_OFFSET; + control |= (u64)rep_count << HV_HYPERCALL_REP_COMP_OFFSET; + + do { + status = hv_do_hypercall(control, input, output); + if ((status & HV_HYPERCALL_RESULT_MASK) != HV_STATUS_SUCCESS) + return status; + + /* Bits 32-43 of status have 'Reps completed' data. */ + rep_comp = (status & HV_HYPERCALL_REP_COMP_MASK) >> + HV_HYPERCALL_REP_COMP_OFFSET; + + control &= ~HV_HYPERCALL_REP_START_MASK; + control |= (u64)rep_comp << HV_HYPERCALL_REP_START_OFFSET; + + touch_nmi_watchdog(); + } while (rep_comp < rep_count); + + return status; +} + void hyperv_init(void); void hyperv_report_panic(struct pt_regs *regs); bool hv_is_hypercall_page_setup(void);