File tree Expand file tree Collapse file tree 4 files changed +64
-1
lines changed Expand file tree Collapse file tree 4 files changed +64
-1
lines changed Original file line number Diff line number Diff line change 1
- obj-y := hv_init.o mmu.o
1
+ obj-y := hv_init.o mmu.o nested.o
2
2
obj-$(CONFIG_X86_64) += hv_apic.o
Original file line number Diff line number Diff line change
1
+ // SPDX-License-Identifier: GPL-2.0
2
+
3
+ /*
4
+ * Hyper-V nested virtualization code.
5
+ *
6
+ * Copyright (C) 2018, Microsoft, Inc.
7
+ *
8
+ * Author : Lan Tianyu <Tianyu.Lan@microsoft.com>
9
+ */
10
+
11
+
12
+ #include <linux/types.h>
13
+ #include <asm/hyperv-tlfs.h>
14
+ #include <asm/mshyperv.h>
15
+ #include <asm/tlbflush.h>
16
+
17
+ int hyperv_flush_guest_mapping (u64 as )
18
+ {
19
+ struct hv_guest_mapping_flush * * flush_pcpu ;
20
+ struct hv_guest_mapping_flush * flush ;
21
+ u64 status ;
22
+ unsigned long flags ;
23
+ int ret = - ENOTSUPP ;
24
+
25
+ if (!hv_hypercall_pg )
26
+ goto fault ;
27
+
28
+ local_irq_save (flags );
29
+
30
+ flush_pcpu = (struct hv_guest_mapping_flush * * )
31
+ this_cpu_ptr (hyperv_pcpu_input_arg );
32
+
33
+ flush = * flush_pcpu ;
34
+
35
+ if (unlikely (!flush )) {
36
+ local_irq_restore (flags );
37
+ goto fault ;
38
+ }
39
+
40
+ flush -> address_space = as ;
41
+ flush -> flags = 0 ;
42
+
43
+ status = hv_do_hypercall (HVCALL_FLUSH_GUEST_PHYSICAL_ADDRESS_SPACE ,
44
+ flush , NULL );
45
+ local_irq_restore (flags );
46
+
47
+ if (!(status & HV_HYPERCALL_RESULT_MASK ))
48
+ ret = 0 ;
49
+
50
+ fault :
51
+ return ret ;
52
+ }
53
+ EXPORT_SYMBOL_GPL (hyperv_flush_guest_mapping );
Original file line number Diff line number Diff line change @@ -309,6 +309,7 @@ struct ms_hyperv_tsc_page {
309
309
#define HV_X64_MSR_REENLIGHTENMENT_CONTROL 0x40000106
310
310
311
311
/* Nested features (CPUID 0x4000000A) EAX */
312
+ #define HV_X64_NESTED_GUEST_MAPPING_FLUSH BIT(18)
312
313
#define HV_X64_NESTED_MSR_BITMAP BIT(19)
313
314
314
315
struct hv_reenlightenment_control {
@@ -350,6 +351,7 @@ struct hv_tsc_emulation_status {
350
351
#define HVCALL_SEND_IPI_EX 0x0015
351
352
#define HVCALL_POST_MESSAGE 0x005c
352
353
#define HVCALL_SIGNAL_EVENT 0x005d
354
+ #define HVCALL_FLUSH_GUEST_PHYSICAL_ADDRESS_SPACE 0x00af
353
355
354
356
#define HV_X64_MSR_VP_ASSIST_PAGE_ENABLE 0x00000001
355
357
#define HV_X64_MSR_VP_ASSIST_PAGE_ADDRESS_SHIFT 12
@@ -741,6 +743,12 @@ struct ipi_arg_ex {
741
743
struct hv_vpset vp_set ;
742
744
};
743
745
746
+ /* HvFlushGuestPhysicalAddressSpace hypercalls */
747
+ struct hv_guest_mapping_flush {
748
+ u64 address_space ;
749
+ u64 flags ;
750
+ };
751
+
744
752
/* HvFlushVirtualAddressSpace, HvFlushVirtualAddressList hypercalls */
745
753
struct hv_tlb_flush {
746
754
u64 address_space ;
Original file line number Diff line number Diff line change @@ -305,6 +305,7 @@ void hyperv_reenlightenment_intr(struct pt_regs *regs);
305
305
void set_hv_tscchange_cb (void (* cb )(void ));
306
306
void clear_hv_tscchange_cb (void );
307
307
void hyperv_stop_tsc_emulation (void );
308
+ int hyperv_flush_guest_mapping (u64 as );
308
309
309
310
#ifdef CONFIG_X86_64
310
311
void hv_apic_init (void );
@@ -324,6 +325,7 @@ static inline struct hv_vp_assist_page *hv_get_vp_assist_page(unsigned int cpu)
324
325
{
325
326
return NULL ;
326
327
}
328
+ static inline int hyperv_flush_guest_mapping (u64 as ) { return -1 ; }
327
329
#endif /* CONFIG_HYPERV */
328
330
329
331
#ifdef CONFIG_HYPERV_TSCPAGE
You can’t perform that action at this time.
0 commit comments