From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751770AbdE3Lfo (ORCPT ); Tue, 30 May 2017 07:35:44 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44368 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751612AbdE3Lew (ORCPT ); Tue, 30 May 2017 07:34:52 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 1A36E80B52 Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=vkuznets@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 1A36E80B52 From: Vitaly Kuznetsov To: x86@kernel.org, devel@linuxdriverproject.org Cc: linux-kernel@vger.kernel.org, "K. Y. Srinivasan" , Haiyang Zhang , Stephen Hemminger , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , Steven Rostedt , Jork Loeser , Simon Xiao , Andy Lutomirski , Andy Shevchenko Subject: [PATCH v5 06/10] x86/hyper-v: implement rep hypercalls Date: Tue, 30 May 2017 13:34:20 +0200 Message-Id: <20170530113424.15687-7-vkuznets@redhat.com> In-Reply-To: <20170530113424.15687-1-vkuznets@redhat.com> References: <20170530113424.15687-1-vkuznets@redhat.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Tue, 30 May 2017 11:34:47 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Acked-by: K. Y. Srinivasan --- Changes since v4: - Avoid union aliasing [Andy Shevchenko] --- arch/x86/include/asm/mshyperv.h | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/arch/x86/include/asm/mshyperv.h b/arch/x86/include/asm/mshyperv.h index d587d1e..7c79a17 100644 --- a/arch/x86/include/asm/mshyperv.h +++ b/arch/x86/include/asm/mshyperv.h @@ -4,6 +4,7 @@ #include #include #include +#include #include /* @@ -244,6 +245,41 @@ 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 << 17; /* Variable header size */ + control |= (u64)rep_count << 32; /* Rep Count */ + + do { + status = hv_do_hypercall(control, input, output); + if ((status & 0xffff) != HV_STATUS_SUCCESS) + return status; + + /* Bits 32-43 of status have 'Reps completed' data. */ + rep_comp = upper_32_bits(status) & 0xfff; + + /* + * Set Rep Start Index (bits 48-59) for continuation. Upper 4 + * bits are reserved and should be set to 0. + */ + control &= U64_MAX >> 16; + control |= (u64)rep_comp << 48; + + 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); -- 2.9.4