hugetlb: introduce generic version of hugetlb_free_pgd_range
[linux/fpc-iii.git] / arch / x86 / hyperv / nested.c
blobb8e60cc504616b8c238aaaa35c1f724584b0c3db
1 // SPDX-License-Identifier: GPL-2.0
3 /*
4 * Hyper-V nested virtualization code.
6 * Copyright (C) 2018, Microsoft, Inc.
8 * Author : Lan Tianyu <Tianyu.Lan@microsoft.com>
9 */
12 #include <linux/types.h>
13 #include <asm/hyperv-tlfs.h>
14 #include <asm/mshyperv.h>
15 #include <asm/tlbflush.h>
17 #include <asm/trace/hyperv.h>
19 int hyperv_flush_guest_mapping(u64 as)
21 struct hv_guest_mapping_flush **flush_pcpu;
22 struct hv_guest_mapping_flush *flush;
23 u64 status;
24 unsigned long flags;
25 int ret = -ENOTSUPP;
27 if (!hv_hypercall_pg)
28 goto fault;
30 local_irq_save(flags);
32 flush_pcpu = (struct hv_guest_mapping_flush **)
33 this_cpu_ptr(hyperv_pcpu_input_arg);
35 flush = *flush_pcpu;
37 if (unlikely(!flush)) {
38 local_irq_restore(flags);
39 goto fault;
42 flush->address_space = as;
43 flush->flags = 0;
45 status = hv_do_hypercall(HVCALL_FLUSH_GUEST_PHYSICAL_ADDRESS_SPACE,
46 flush, NULL);
47 local_irq_restore(flags);
49 if (!(status & HV_HYPERCALL_RESULT_MASK))
50 ret = 0;
52 fault:
53 trace_hyperv_nested_flush_guest_mapping(as, ret);
54 return ret;
56 EXPORT_SYMBOL_GPL(hyperv_flush_guest_mapping);