nested.c 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * Hyper-V nested virtualization code.
  4. *
  5. * Copyright (C) 2018, Microsoft, Inc.
  6. *
  7. * Author : Lan Tianyu <Tianyu.Lan@microsoft.com>
  8. */
  9. #include <linux/types.h>
  10. #include <asm/hyperv-tlfs.h>
  11. #include <asm/mshyperv.h>
  12. #include <asm/tlbflush.h>
  13. #include <asm/trace/hyperv.h>
  14. int hyperv_flush_guest_mapping(u64 as)
  15. {
  16. struct hv_guest_mapping_flush **flush_pcpu;
  17. struct hv_guest_mapping_flush *flush;
  18. u64 status;
  19. unsigned long flags;
  20. int ret = -ENOTSUPP;
  21. if (!hv_hypercall_pg)
  22. goto fault;
  23. local_irq_save(flags);
  24. flush_pcpu = (struct hv_guest_mapping_flush **)
  25. this_cpu_ptr(hyperv_pcpu_input_arg);
  26. flush = *flush_pcpu;
  27. if (unlikely(!flush)) {
  28. local_irq_restore(flags);
  29. goto fault;
  30. }
  31. flush->address_space = as;
  32. flush->flags = 0;
  33. status = hv_do_hypercall(HVCALL_FLUSH_GUEST_PHYSICAL_ADDRESS_SPACE,
  34. flush, NULL);
  35. local_irq_restore(flags);
  36. if (!(status & HV_HYPERCALL_RESULT_MASK))
  37. ret = 0;
  38. fault:
  39. trace_hyperv_nested_flush_guest_mapping(as, ret);
  40. return ret;
  41. }
  42. EXPORT_SYMBOL_GPL(hyperv_flush_guest_mapping);