aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVitaly Kuznetsov <vkuznets@redhat.com>2017-08-02 12:09:17 -0400
committerIngo Molnar <mingo@kernel.org>2017-08-10 10:50:22 -0400
commit806c89273bab0c8af0202a6fb6279f36042cb2e6 (patch)
tree7f7a213ef0316f30c32bbe9bbb994a35f0dbc6e8
parent057841713cfff62b4485cdd2b245f05b7ea3ba16 (diff)
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 <vkuznets@redhat.com> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Reviewed-by: Stephen Hemminger <sthemmin@microsoft.com> Cc: Andy Lutomirski <luto@kernel.org> Cc: Haiyang Zhang <haiyangz@microsoft.com> Cc: Jork Loeser <Jork.Loeser@microsoft.com> Cc: K. Y. Srinivasan <kys@microsoft.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Simon Xiao <sixiao@microsoft.com> Cc: Steven Rostedt <rostedt@goodmis.org> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: devel@linuxdriverproject.org Link: http://lkml.kernel.org/r/20170802160921.21791-6-vkuznets@redhat.com Signed-off-by: Ingo Molnar <mingo@kernel.org>
-rw-r--r--arch/x86/include/asm/mshyperv.h39
1 files changed, 39 insertions, 0 deletions
diff --git a/arch/x86/include/asm/mshyperv.h b/arch/x86/include/asm/mshyperv.h
index e484255bd9de..efa1860276b5 100644
--- a/arch/x86/include/asm/mshyperv.h
+++ b/arch/x86/include/asm/mshyperv.h
@@ -3,6 +3,7 @@
3 3
4#include <linux/types.h> 4#include <linux/types.h>
5#include <linux/atomic.h> 5#include <linux/atomic.h>
6#include <linux/nmi.h>
6#include <asm/io.h> 7#include <asm/io.h>
7#include <asm/hyperv.h> 8#include <asm/hyperv.h>
8 9
@@ -209,7 +210,13 @@ static inline u64 hv_do_hypercall(u64 control, void *input, void *output)
209 return hv_status; 210 return hv_status;
210} 211}
211 212
213#define HV_HYPERCALL_RESULT_MASK GENMASK_ULL(15, 0)
212#define HV_HYPERCALL_FAST_BIT BIT(16) 214#define HV_HYPERCALL_FAST_BIT BIT(16)
215#define HV_HYPERCALL_VARHEAD_OFFSET 17
216#define HV_HYPERCALL_REP_COMP_OFFSET 32
217#define HV_HYPERCALL_REP_COMP_MASK GENMASK_ULL(43, 32)
218#define HV_HYPERCALL_REP_START_OFFSET 48
219#define HV_HYPERCALL_REP_START_MASK GENMASK_ULL(59, 48)
213 220
214/* Fast hypercall with 8 bytes of input and no output */ 221/* Fast hypercall with 8 bytes of input and no output */
215static inline u64 hv_do_fast_hypercall8(u16 code, u64 input1) 222static 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)
243 return hv_status; 250 return hv_status;
244} 251}
245 252
253/*
254 * Rep hypercalls. Callers of this functions are supposed to ensure that
255 * rep_count and varhead_size comply with Hyper-V hypercall definition.
256 */
257static inline u64 hv_do_rep_hypercall(u16 code, u16 rep_count, u16 varhead_size,
258 void *input, void *output)
259{
260 u64 control = code;
261 u64 status;
262 u16 rep_comp;
263
264 control |= (u64)varhead_size << HV_HYPERCALL_VARHEAD_OFFSET;
265 control |= (u64)rep_count << HV_HYPERCALL_REP_COMP_OFFSET;
266
267 do {
268 status = hv_do_hypercall(control, input, output);
269 if ((status & HV_HYPERCALL_RESULT_MASK) != HV_STATUS_SUCCESS)
270 return status;
271
272 /* Bits 32-43 of status have 'Reps completed' data. */
273 rep_comp = (status & HV_HYPERCALL_REP_COMP_MASK) >>
274 HV_HYPERCALL_REP_COMP_OFFSET;
275
276 control &= ~HV_HYPERCALL_REP_START_MASK;
277 control |= (u64)rep_comp << HV_HYPERCALL_REP_START_OFFSET;
278
279 touch_nmi_watchdog();
280 } while (rep_comp < rep_count);
281
282 return status;
283}
284
246void hyperv_init(void); 285void hyperv_init(void);
247void hyperv_report_panic(struct pt_regs *regs); 286void hyperv_report_panic(struct pt_regs *regs);
248bool hv_is_hypercall_page_setup(void); 287bool hv_is_hypercall_page_setup(void);