hv_common.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * Architecture neutral utility routines for interacting with
  4. * Hyper-V. This file is specifically for code that must be
  5. * built-in to the kernel image when CONFIG_HYPERV is set
  6. * (vs. being in a module) because it is called from architecture
  7. * specific code under arch/.
  8. *
  9. * Copyright (C) 2021, Microsoft, Inc.
  10. *
  11. * Author : Michael Kelley <mikelley@microsoft.com>
  12. */
  13. #include <linux/types.h>
  14. #include <linux/acpi.h>
  15. #include <linux/export.h>
  16. #include <linux/bitfield.h>
  17. #include <linux/cpumask.h>
  18. #include <linux/sched/task_stack.h>
  19. #include <linux/panic_notifier.h>
  20. #include <linux/ptrace.h>
  21. #include <linux/random.h>
  22. #include <linux/efi.h>
  23. #include <linux/kdebug.h>
  24. #include <linux/kmsg_dump.h>
  25. #include <linux/sizes.h>
  26. #include <linux/slab.h>
  27. #include <linux/dma-map-ops.h>
  28. #include <linux/set_memory.h>
  29. #include <asm/hyperv-tlfs.h>
  30. #include <asm/mshyperv.h>
  31. /*
  32. * hv_root_partition, ms_hyperv and hv_nested are defined here with other
  33. * Hyper-V specific globals so they are shared across all architectures and are
  34. * built only when CONFIG_HYPERV is defined. But on x86,
  35. * ms_hyperv_init_platform() is built even when CONFIG_HYPERV is not
  36. * defined, and it uses these three variables. So mark them as __weak
  37. * here, allowing for an overriding definition in the module containing
  38. * ms_hyperv_init_platform().
  39. */
  40. bool __weak hv_root_partition;
  41. EXPORT_SYMBOL_GPL(hv_root_partition);
  42. bool __weak hv_nested;
  43. EXPORT_SYMBOL_GPL(hv_nested);
  44. struct ms_hyperv_info __weak ms_hyperv;
  45. EXPORT_SYMBOL_GPL(ms_hyperv);
  46. u32 *hv_vp_index;
  47. EXPORT_SYMBOL_GPL(hv_vp_index);
  48. u32 hv_max_vp_index;
  49. EXPORT_SYMBOL_GPL(hv_max_vp_index);
  50. void * __percpu *hyperv_pcpu_input_arg;
  51. EXPORT_SYMBOL_GPL(hyperv_pcpu_input_arg);
  52. void * __percpu *hyperv_pcpu_output_arg;
  53. EXPORT_SYMBOL_GPL(hyperv_pcpu_output_arg);
  54. static void hv_kmsg_dump_unregister(void);
  55. static struct ctl_table_header *hv_ctl_table_hdr;
  56. /*
  57. * Hyper-V specific initialization and shutdown code that is
  58. * common across all architectures. Called from architecture
  59. * specific initialization functions.
  60. */
  61. void __init hv_common_free(void)
  62. {
  63. unregister_sysctl_table(hv_ctl_table_hdr);
  64. hv_ctl_table_hdr = NULL;
  65. if (ms_hyperv.misc_features & HV_FEATURE_GUEST_CRASH_MSR_AVAILABLE)
  66. hv_kmsg_dump_unregister();
  67. kfree(hv_vp_index);
  68. hv_vp_index = NULL;
  69. free_percpu(hyperv_pcpu_output_arg);
  70. hyperv_pcpu_output_arg = NULL;
  71. free_percpu(hyperv_pcpu_input_arg);
  72. hyperv_pcpu_input_arg = NULL;
  73. }
  74. /*
  75. * Functions for allocating and freeing memory with size and
  76. * alignment HV_HYP_PAGE_SIZE. These functions are needed because
  77. * the guest page size may not be the same as the Hyper-V page
  78. * size. We depend upon kmalloc() aligning power-of-two size
  79. * allocations to the allocation size boundary, so that the
  80. * allocated memory appears to Hyper-V as a page of the size
  81. * it expects.
  82. */
  83. void *hv_alloc_hyperv_page(void)
  84. {
  85. BUILD_BUG_ON(PAGE_SIZE < HV_HYP_PAGE_SIZE);
  86. if (PAGE_SIZE == HV_HYP_PAGE_SIZE)
  87. return (void *)__get_free_page(GFP_KERNEL);
  88. else
  89. return kmalloc(HV_HYP_PAGE_SIZE, GFP_KERNEL);
  90. }
  91. EXPORT_SYMBOL_GPL(hv_alloc_hyperv_page);
  92. void *hv_alloc_hyperv_zeroed_page(void)
  93. {
  94. if (PAGE_SIZE == HV_HYP_PAGE_SIZE)
  95. return (void *)__get_free_page(GFP_KERNEL | __GFP_ZERO);
  96. else
  97. return kzalloc(HV_HYP_PAGE_SIZE, GFP_KERNEL);
  98. }
  99. EXPORT_SYMBOL_GPL(hv_alloc_hyperv_zeroed_page);
  100. void hv_free_hyperv_page(void *addr)
  101. {
  102. if (PAGE_SIZE == HV_HYP_PAGE_SIZE)
  103. free_page((unsigned long)addr);
  104. else
  105. kfree(addr);
  106. }
  107. EXPORT_SYMBOL_GPL(hv_free_hyperv_page);
  108. static void *hv_panic_page;
  109. /*
  110. * Boolean to control whether to report panic messages over Hyper-V.
  111. *
  112. * It can be set via /proc/sys/kernel/hyperv_record_panic_msg
  113. */
  114. static int sysctl_record_panic_msg = 1;
  115. /*
  116. * sysctl option to allow the user to control whether kmsg data should be
  117. * reported to Hyper-V on panic.
  118. */
  119. static struct ctl_table hv_ctl_table[] = {
  120. {
  121. .procname = "hyperv_record_panic_msg",
  122. .data = &sysctl_record_panic_msg,
  123. .maxlen = sizeof(int),
  124. .mode = 0644,
  125. .proc_handler = proc_dointvec_minmax,
  126. .extra1 = SYSCTL_ZERO,
  127. .extra2 = SYSCTL_ONE
  128. },
  129. };
  130. static int hv_die_panic_notify_crash(struct notifier_block *self,
  131. unsigned long val, void *args);
  132. static struct notifier_block hyperv_die_report_block = {
  133. .notifier_call = hv_die_panic_notify_crash,
  134. };
  135. static struct notifier_block hyperv_panic_report_block = {
  136. .notifier_call = hv_die_panic_notify_crash,
  137. };
  138. /*
  139. * The following callback works both as die and panic notifier; its
  140. * goal is to provide panic information to the hypervisor unless the
  141. * kmsg dumper is used [see hv_kmsg_dump()], which provides more
  142. * information but isn't always available.
  143. *
  144. * Notice that both the panic/die report notifiers are registered only
  145. * if we have the capability HV_FEATURE_GUEST_CRASH_MSR_AVAILABLE set.
  146. */
  147. static int hv_die_panic_notify_crash(struct notifier_block *self,
  148. unsigned long val, void *args)
  149. {
  150. struct pt_regs *regs;
  151. bool is_die;
  152. /* Don't notify Hyper-V unless we have a die oops event or panic. */
  153. if (self == &hyperv_panic_report_block) {
  154. is_die = false;
  155. regs = current_pt_regs();
  156. } else { /* die event */
  157. if (val != DIE_OOPS)
  158. return NOTIFY_DONE;
  159. is_die = true;
  160. regs = ((struct die_args *)args)->regs;
  161. }
  162. /*
  163. * Hyper-V should be notified only once about a panic/die. If we will
  164. * be calling hv_kmsg_dump() later with kmsg data, don't do the
  165. * notification here.
  166. */
  167. if (!sysctl_record_panic_msg || !hv_panic_page)
  168. hyperv_report_panic(regs, val, is_die);
  169. return NOTIFY_DONE;
  170. }
  171. /*
  172. * Callback from kmsg_dump. Grab as much as possible from the end of the kmsg
  173. * buffer and call into Hyper-V to transfer the data.
  174. */
  175. static void hv_kmsg_dump(struct kmsg_dumper *dumper,
  176. struct kmsg_dump_detail *detail)
  177. {
  178. struct kmsg_dump_iter iter;
  179. size_t bytes_written;
  180. /* We are only interested in panics. */
  181. if (detail->reason != KMSG_DUMP_PANIC || !sysctl_record_panic_msg)
  182. return;
  183. /*
  184. * Write dump contents to the page. No need to synchronize; panic should
  185. * be single-threaded.
  186. */
  187. kmsg_dump_rewind(&iter);
  188. kmsg_dump_get_buffer(&iter, false, hv_panic_page, HV_HYP_PAGE_SIZE,
  189. &bytes_written);
  190. if (!bytes_written)
  191. return;
  192. /*
  193. * P3 to contain the physical address of the panic page & P4 to
  194. * contain the size of the panic data in that page. Rest of the
  195. * registers are no-op when the NOTIFY_MSG flag is set.
  196. */
  197. hv_set_msr(HV_MSR_CRASH_P0, 0);
  198. hv_set_msr(HV_MSR_CRASH_P1, 0);
  199. hv_set_msr(HV_MSR_CRASH_P2, 0);
  200. hv_set_msr(HV_MSR_CRASH_P3, virt_to_phys(hv_panic_page));
  201. hv_set_msr(HV_MSR_CRASH_P4, bytes_written);
  202. /*
  203. * Let Hyper-V know there is crash data available along with
  204. * the panic message.
  205. */
  206. hv_set_msr(HV_MSR_CRASH_CTL,
  207. (HV_CRASH_CTL_CRASH_NOTIFY |
  208. HV_CRASH_CTL_CRASH_NOTIFY_MSG));
  209. }
  210. static struct kmsg_dumper hv_kmsg_dumper = {
  211. .dump = hv_kmsg_dump,
  212. };
  213. static void hv_kmsg_dump_unregister(void)
  214. {
  215. kmsg_dump_unregister(&hv_kmsg_dumper);
  216. unregister_die_notifier(&hyperv_die_report_block);
  217. atomic_notifier_chain_unregister(&panic_notifier_list,
  218. &hyperv_panic_report_block);
  219. hv_free_hyperv_page(hv_panic_page);
  220. hv_panic_page = NULL;
  221. }
  222. static void hv_kmsg_dump_register(void)
  223. {
  224. int ret;
  225. hv_panic_page = hv_alloc_hyperv_zeroed_page();
  226. if (!hv_panic_page) {
  227. pr_err("Hyper-V: panic message page memory allocation failed\n");
  228. return;
  229. }
  230. ret = kmsg_dump_register(&hv_kmsg_dumper);
  231. if (ret) {
  232. pr_err("Hyper-V: kmsg dump register error 0x%x\n", ret);
  233. hv_free_hyperv_page(hv_panic_page);
  234. hv_panic_page = NULL;
  235. }
  236. }
  237. int __init hv_common_init(void)
  238. {
  239. int i;
  240. union hv_hypervisor_version_info version;
  241. /* Get information about the Hyper-V host version */
  242. if (!hv_get_hypervisor_version(&version))
  243. pr_info("Hyper-V: Host Build %d.%d.%d.%d-%d-%d\n",
  244. version.major_version, version.minor_version,
  245. version.build_number, version.service_number,
  246. version.service_pack, version.service_branch);
  247. if (hv_is_isolation_supported())
  248. sysctl_record_panic_msg = 0;
  249. /*
  250. * Hyper-V expects to get crash register data or kmsg when
  251. * crash enlightment is available and system crashes. Set
  252. * crash_kexec_post_notifiers to be true to make sure that
  253. * calling crash enlightment interface before running kdump
  254. * kernel.
  255. */
  256. if (ms_hyperv.misc_features & HV_FEATURE_GUEST_CRASH_MSR_AVAILABLE) {
  257. u64 hyperv_crash_ctl;
  258. crash_kexec_post_notifiers = true;
  259. pr_info("Hyper-V: enabling crash_kexec_post_notifiers\n");
  260. /*
  261. * Panic message recording (sysctl_record_panic_msg)
  262. * is enabled by default in non-isolated guests and
  263. * disabled by default in isolated guests; the panic
  264. * message recording won't be available in isolated
  265. * guests should the following registration fail.
  266. */
  267. hv_ctl_table_hdr = register_sysctl("kernel", hv_ctl_table);
  268. if (!hv_ctl_table_hdr)
  269. pr_err("Hyper-V: sysctl table register error");
  270. /*
  271. * Register for panic kmsg callback only if the right
  272. * capability is supported by the hypervisor.
  273. */
  274. hyperv_crash_ctl = hv_get_msr(HV_MSR_CRASH_CTL);
  275. if (hyperv_crash_ctl & HV_CRASH_CTL_CRASH_NOTIFY_MSG)
  276. hv_kmsg_dump_register();
  277. register_die_notifier(&hyperv_die_report_block);
  278. atomic_notifier_chain_register(&panic_notifier_list,
  279. &hyperv_panic_report_block);
  280. }
  281. /*
  282. * Allocate the per-CPU state for the hypercall input arg.
  283. * If this allocation fails, we will not be able to setup
  284. * (per-CPU) hypercall input page and thus this failure is
  285. * fatal on Hyper-V.
  286. */
  287. hyperv_pcpu_input_arg = alloc_percpu(void *);
  288. BUG_ON(!hyperv_pcpu_input_arg);
  289. /* Allocate the per-CPU state for output arg for root */
  290. if (hv_root_partition) {
  291. hyperv_pcpu_output_arg = alloc_percpu(void *);
  292. BUG_ON(!hyperv_pcpu_output_arg);
  293. }
  294. hv_vp_index = kmalloc_array(num_possible_cpus(), sizeof(*hv_vp_index),
  295. GFP_KERNEL);
  296. if (!hv_vp_index) {
  297. hv_common_free();
  298. return -ENOMEM;
  299. }
  300. for (i = 0; i < num_possible_cpus(); i++)
  301. hv_vp_index[i] = VP_INVAL;
  302. return 0;
  303. }
  304. void __init ms_hyperv_late_init(void)
  305. {
  306. struct acpi_table_header *header;
  307. acpi_status status;
  308. u8 *randomdata;
  309. u32 length, i;
  310. /*
  311. * Seed the Linux random number generator with entropy provided by
  312. * the Hyper-V host in ACPI table OEM0.
  313. */
  314. if (!IS_ENABLED(CONFIG_ACPI))
  315. return;
  316. status = acpi_get_table("OEM0", 0, &header);
  317. if (ACPI_FAILURE(status) || !header)
  318. return;
  319. /*
  320. * Since the "OEM0" table name is for OEM specific usage, verify
  321. * that what we're seeing purports to be from Microsoft.
  322. */
  323. if (strncmp(header->oem_table_id, "MICROSFT", 8))
  324. goto error;
  325. /*
  326. * Ensure the length is reasonable. Requiring at least 8 bytes and
  327. * no more than 4K bytes is somewhat arbitrary and just protects
  328. * against a malformed table. Hyper-V currently provides 64 bytes,
  329. * but allow for a change in a later version.
  330. */
  331. if (header->length < sizeof(*header) + 8 ||
  332. header->length > sizeof(*header) + SZ_4K)
  333. goto error;
  334. length = header->length - sizeof(*header);
  335. randomdata = (u8 *)(header + 1);
  336. pr_debug("Hyper-V: Seeding rng with %d random bytes from ACPI table OEM0\n",
  337. length);
  338. add_bootloader_randomness(randomdata, length);
  339. /*
  340. * To prevent the seed data from being visible in /sys/firmware/acpi,
  341. * zero out the random data in the ACPI table and fixup the checksum.
  342. * The zero'ing is done out of an abundance of caution in avoiding
  343. * potential security risks to the rng. Similarly, reset the table
  344. * length to just the header size so that a subsequent kexec doesn't
  345. * try to use the zero'ed out random data.
  346. */
  347. for (i = 0; i < length; i++) {
  348. header->checksum += randomdata[i];
  349. randomdata[i] = 0;
  350. }
  351. for (i = 0; i < sizeof(header->length); i++)
  352. header->checksum += ((u8 *)&header->length)[i];
  353. header->length = sizeof(*header);
  354. for (i = 0; i < sizeof(header->length); i++)
  355. header->checksum -= ((u8 *)&header->length)[i];
  356. error:
  357. acpi_put_table(header);
  358. }
  359. /*
  360. * Hyper-V specific initialization and die code for
  361. * individual CPUs that is common across all architectures.
  362. * Called by the CPU hotplug mechanism.
  363. */
  364. int hv_common_cpu_init(unsigned int cpu)
  365. {
  366. void **inputarg, **outputarg;
  367. u64 msr_vp_index;
  368. gfp_t flags;
  369. int pgcount = hv_root_partition ? 2 : 1;
  370. void *mem;
  371. int ret;
  372. /* hv_cpu_init() can be called with IRQs disabled from hv_resume() */
  373. flags = irqs_disabled() ? GFP_ATOMIC : GFP_KERNEL;
  374. inputarg = (void **)this_cpu_ptr(hyperv_pcpu_input_arg);
  375. /*
  376. * hyperv_pcpu_input_arg and hyperv_pcpu_output_arg memory is already
  377. * allocated if this CPU was previously online and then taken offline
  378. */
  379. if (!*inputarg) {
  380. mem = kmalloc(pgcount * HV_HYP_PAGE_SIZE, flags);
  381. if (!mem)
  382. return -ENOMEM;
  383. if (hv_root_partition) {
  384. outputarg = (void **)this_cpu_ptr(hyperv_pcpu_output_arg);
  385. *outputarg = (char *)mem + HV_HYP_PAGE_SIZE;
  386. }
  387. if (!ms_hyperv.paravisor_present &&
  388. (hv_isolation_type_snp() || hv_isolation_type_tdx())) {
  389. ret = set_memory_decrypted((unsigned long)mem, pgcount);
  390. if (ret) {
  391. /* It may be unsafe to free 'mem' */
  392. return ret;
  393. }
  394. memset(mem, 0x00, pgcount * HV_HYP_PAGE_SIZE);
  395. }
  396. /*
  397. * In a fully enlightened TDX/SNP VM with more than 64 VPs, if
  398. * hyperv_pcpu_input_arg is not NULL, set_memory_decrypted() ->
  399. * ... -> cpa_flush()-> ... -> __send_ipi_mask_ex() tries to
  400. * use hyperv_pcpu_input_arg as the hypercall input page, which
  401. * must be a decrypted page in such a VM, but the page is still
  402. * encrypted before set_memory_decrypted() returns. Fix this by
  403. * setting *inputarg after the above set_memory_decrypted(): if
  404. * hyperv_pcpu_input_arg is NULL, __send_ipi_mask_ex() returns
  405. * HV_STATUS_INVALID_PARAMETER immediately, and the function
  406. * hv_send_ipi_mask() falls back to orig_apic.send_IPI_mask(),
  407. * which may be slightly slower than the hypercall, but still
  408. * works correctly in such a VM.
  409. */
  410. *inputarg = mem;
  411. }
  412. msr_vp_index = hv_get_msr(HV_MSR_VP_INDEX);
  413. hv_vp_index[cpu] = msr_vp_index;
  414. if (msr_vp_index > hv_max_vp_index)
  415. hv_max_vp_index = msr_vp_index;
  416. return 0;
  417. }
  418. int hv_common_cpu_die(unsigned int cpu)
  419. {
  420. /*
  421. * The hyperv_pcpu_input_arg and hyperv_pcpu_output_arg memory
  422. * is not freed when the CPU goes offline as the hyperv_pcpu_input_arg
  423. * may be used by the Hyper-V vPCI driver in reassigning interrupts
  424. * as part of the offlining process. The interrupt reassignment
  425. * happens *after* the CPUHP_AP_HYPERV_ONLINE state has run and
  426. * called this function.
  427. *
  428. * If a previously offlined CPU is brought back online again, the
  429. * originally allocated memory is reused in hv_common_cpu_init().
  430. */
  431. return 0;
  432. }
  433. /* Bit mask of the extended capability to query: see HV_EXT_CAPABILITY_xxx */
  434. bool hv_query_ext_cap(u64 cap_query)
  435. {
  436. /*
  437. * The address of the 'hv_extended_cap' variable will be used as an
  438. * output parameter to the hypercall below and so it should be
  439. * compatible with 'virt_to_phys'. Which means, it's address should be
  440. * directly mapped. Use 'static' to keep it compatible; stack variables
  441. * can be virtually mapped, making them incompatible with
  442. * 'virt_to_phys'.
  443. * Hypercall input/output addresses should also be 8-byte aligned.
  444. */
  445. static u64 hv_extended_cap __aligned(8);
  446. static bool hv_extended_cap_queried;
  447. u64 status;
  448. /*
  449. * Querying extended capabilities is an extended hypercall. Check if the
  450. * partition supports extended hypercall, first.
  451. */
  452. if (!(ms_hyperv.priv_high & HV_ENABLE_EXTENDED_HYPERCALLS))
  453. return false;
  454. /* Extended capabilities do not change at runtime. */
  455. if (hv_extended_cap_queried)
  456. return hv_extended_cap & cap_query;
  457. status = hv_do_hypercall(HV_EXT_CALL_QUERY_CAPABILITIES, NULL,
  458. &hv_extended_cap);
  459. /*
  460. * The query extended capabilities hypercall should not fail under
  461. * any normal circumstances. Avoid repeatedly making the hypercall, on
  462. * error.
  463. */
  464. hv_extended_cap_queried = true;
  465. if (!hv_result_success(status)) {
  466. pr_err("Hyper-V: Extended query capabilities hypercall failed 0x%llx\n",
  467. status);
  468. return false;
  469. }
  470. return hv_extended_cap & cap_query;
  471. }
  472. EXPORT_SYMBOL_GPL(hv_query_ext_cap);
  473. void hv_setup_dma_ops(struct device *dev, bool coherent)
  474. {
  475. arch_setup_dma_ops(dev, coherent);
  476. }
  477. EXPORT_SYMBOL_GPL(hv_setup_dma_ops);
  478. bool hv_is_hibernation_supported(void)
  479. {
  480. return !hv_root_partition && acpi_sleep_state_supported(ACPI_STATE_S4);
  481. }
  482. EXPORT_SYMBOL_GPL(hv_is_hibernation_supported);
  483. /*
  484. * Default function to read the Hyper-V reference counter, independent
  485. * of whether Hyper-V enlightened clocks/timers are being used. But on
  486. * architectures where it is used, Hyper-V enlightenment code in
  487. * hyperv_timer.c may override this function.
  488. */
  489. static u64 __hv_read_ref_counter(void)
  490. {
  491. return hv_get_msr(HV_MSR_TIME_REF_COUNT);
  492. }
  493. u64 (*hv_read_reference_counter)(void) = __hv_read_ref_counter;
  494. EXPORT_SYMBOL_GPL(hv_read_reference_counter);
  495. /* These __weak functions provide default "no-op" behavior and
  496. * may be overridden by architecture specific versions. Architectures
  497. * for which the default "no-op" behavior is sufficient can leave
  498. * them unimplemented and not be cluttered with a bunch of stub
  499. * functions in arch-specific code.
  500. */
  501. bool __weak hv_is_isolation_supported(void)
  502. {
  503. return false;
  504. }
  505. EXPORT_SYMBOL_GPL(hv_is_isolation_supported);
  506. bool __weak hv_isolation_type_snp(void)
  507. {
  508. return false;
  509. }
  510. EXPORT_SYMBOL_GPL(hv_isolation_type_snp);
  511. bool __weak hv_isolation_type_tdx(void)
  512. {
  513. return false;
  514. }
  515. EXPORT_SYMBOL_GPL(hv_isolation_type_tdx);
  516. void __weak hv_setup_vmbus_handler(void (*handler)(void))
  517. {
  518. }
  519. EXPORT_SYMBOL_GPL(hv_setup_vmbus_handler);
  520. void __weak hv_remove_vmbus_handler(void)
  521. {
  522. }
  523. EXPORT_SYMBOL_GPL(hv_remove_vmbus_handler);
  524. void __weak hv_setup_kexec_handler(void (*handler)(void))
  525. {
  526. }
  527. EXPORT_SYMBOL_GPL(hv_setup_kexec_handler);
  528. void __weak hv_remove_kexec_handler(void)
  529. {
  530. }
  531. EXPORT_SYMBOL_GPL(hv_remove_kexec_handler);
  532. void __weak hv_setup_crash_handler(void (*handler)(struct pt_regs *regs))
  533. {
  534. }
  535. EXPORT_SYMBOL_GPL(hv_setup_crash_handler);
  536. void __weak hv_remove_crash_handler(void)
  537. {
  538. }
  539. EXPORT_SYMBOL_GPL(hv_remove_crash_handler);
  540. void __weak hyperv_cleanup(void)
  541. {
  542. }
  543. EXPORT_SYMBOL_GPL(hyperv_cleanup);
  544. u64 __weak hv_ghcb_hypercall(u64 control, void *input, void *output, u32 input_size)
  545. {
  546. return HV_STATUS_INVALID_PARAMETER;
  547. }
  548. EXPORT_SYMBOL_GPL(hv_ghcb_hypercall);
  549. u64 __weak hv_tdx_hypercall(u64 control, u64 param1, u64 param2)
  550. {
  551. return HV_STATUS_INVALID_PARAMETER;
  552. }
  553. EXPORT_SYMBOL_GPL(hv_tdx_hypercall);