hv.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627
  1. /*
  2. * Copyright (c) 2009, Microsoft Corporation.
  3. *
  4. * This program is free software; you can redistribute it and/or modify it
  5. * under the terms and conditions of the GNU General Public License,
  6. * version 2, as published by the Free Software Foundation.
  7. *
  8. * This program is distributed in the hope it will be useful, but WITHOUT
  9. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  10. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  11. * more details.
  12. *
  13. * You should have received a copy of the GNU General Public License along with
  14. * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
  15. * Place - Suite 330, Boston, MA 02111-1307 USA.
  16. *
  17. * Authors:
  18. * Haiyang Zhang <haiyangz@microsoft.com>
  19. * Hank Janssen <hjanssen@microsoft.com>
  20. *
  21. */
  22. #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
  23. #include <linux/kernel.h>
  24. #include <linux/mm.h>
  25. #include <linux/slab.h>
  26. #include <linux/vmalloc.h>
  27. #include <linux/hyperv.h>
  28. #include <linux/version.h>
  29. #include <linux/interrupt.h>
  30. #include <linux/clockchips.h>
  31. #include <asm/hyperv.h>
  32. #include <asm/mshyperv.h>
  33. #include "hyperv_vmbus.h"
  34. /* The one and only */
  35. struct hv_context hv_context = {
  36. .synic_initialized = false,
  37. .hypercall_page = NULL,
  38. };
  39. #define HV_TIMER_FREQUENCY (10 * 1000 * 1000) /* 100ns period */
  40. #define HV_MAX_MAX_DELTA_TICKS 0xffffffff
  41. #define HV_MIN_DELTA_TICKS 1
  42. /*
  43. * query_hypervisor_info - Get version info of the windows hypervisor
  44. */
  45. unsigned int host_info_eax;
  46. unsigned int host_info_ebx;
  47. unsigned int host_info_ecx;
  48. unsigned int host_info_edx;
  49. static int query_hypervisor_info(void)
  50. {
  51. unsigned int eax;
  52. unsigned int ebx;
  53. unsigned int ecx;
  54. unsigned int edx;
  55. unsigned int max_leaf;
  56. unsigned int op;
  57. /*
  58. * Its assumed that this is called after confirming that Viridian
  59. * is present. Query id and revision.
  60. */
  61. eax = 0;
  62. ebx = 0;
  63. ecx = 0;
  64. edx = 0;
  65. op = HVCPUID_VENDOR_MAXFUNCTION;
  66. cpuid(op, &eax, &ebx, &ecx, &edx);
  67. max_leaf = eax;
  68. if (max_leaf >= HVCPUID_VERSION) {
  69. eax = 0;
  70. ebx = 0;
  71. ecx = 0;
  72. edx = 0;
  73. op = HVCPUID_VERSION;
  74. cpuid(op, &eax, &ebx, &ecx, &edx);
  75. host_info_eax = eax;
  76. host_info_ebx = ebx;
  77. host_info_ecx = ecx;
  78. host_info_edx = edx;
  79. }
  80. return max_leaf;
  81. }
  82. /*
  83. * hv_do_hypercall- Invoke the specified hypercall
  84. */
  85. u64 hv_do_hypercall(u64 control, void *input, void *output)
  86. {
  87. u64 input_address = (input) ? virt_to_phys(input) : 0;
  88. u64 output_address = (output) ? virt_to_phys(output) : 0;
  89. void *hypercall_page = hv_context.hypercall_page;
  90. #ifdef CONFIG_X86_64
  91. u64 hv_status = 0;
  92. if (!hypercall_page)
  93. return (u64)ULLONG_MAX;
  94. __asm__ __volatile__("mov %0, %%r8" : : "r" (output_address) : "r8");
  95. __asm__ __volatile__("call *%3" : "=a" (hv_status) :
  96. "c" (control), "d" (input_address),
  97. "m" (hypercall_page));
  98. return hv_status;
  99. #else
  100. u32 control_hi = control >> 32;
  101. u32 control_lo = control & 0xFFFFFFFF;
  102. u32 hv_status_hi = 1;
  103. u32 hv_status_lo = 1;
  104. u32 input_address_hi = input_address >> 32;
  105. u32 input_address_lo = input_address & 0xFFFFFFFF;
  106. u32 output_address_hi = output_address >> 32;
  107. u32 output_address_lo = output_address & 0xFFFFFFFF;
  108. if (!hypercall_page)
  109. return (u64)ULLONG_MAX;
  110. __asm__ __volatile__ ("call *%8" : "=d"(hv_status_hi),
  111. "=a"(hv_status_lo) : "d" (control_hi),
  112. "a" (control_lo), "b" (input_address_hi),
  113. "c" (input_address_lo), "D"(output_address_hi),
  114. "S"(output_address_lo), "m" (hypercall_page));
  115. return hv_status_lo | ((u64)hv_status_hi << 32);
  116. #endif /* !x86_64 */
  117. }
  118. EXPORT_SYMBOL_GPL(hv_do_hypercall);
  119. #ifdef CONFIG_X86_64
  120. static u64 read_hv_clock_tsc(struct clocksource *arg)
  121. {
  122. u64 current_tick;
  123. struct ms_hyperv_tsc_page *tsc_pg = hv_context.tsc_page;
  124. if (tsc_pg->tsc_sequence != 0) {
  125. /*
  126. * Use the tsc page to compute the value.
  127. */
  128. while (1) {
  129. u64 tmp;
  130. u32 sequence = tsc_pg->tsc_sequence;
  131. u64 cur_tsc;
  132. u64 scale = tsc_pg->tsc_scale;
  133. s64 offset = tsc_pg->tsc_offset;
  134. rdtscll(cur_tsc);
  135. /* current_tick = ((cur_tsc *scale) >> 64) + offset */
  136. asm("mulq %3"
  137. : "=d" (current_tick), "=a" (tmp)
  138. : "a" (cur_tsc), "r" (scale));
  139. current_tick += offset;
  140. if (tsc_pg->tsc_sequence == sequence)
  141. return current_tick;
  142. if (tsc_pg->tsc_sequence != 0)
  143. continue;
  144. /*
  145. * Fallback using MSR method.
  146. */
  147. break;
  148. }
  149. }
  150. rdmsrl(HV_X64_MSR_TIME_REF_COUNT, current_tick);
  151. return current_tick;
  152. }
  153. static struct clocksource hyperv_cs_tsc = {
  154. .name = "hyperv_clocksource_tsc_page",
  155. .rating = 425,
  156. .read = read_hv_clock_tsc,
  157. .mask = CLOCKSOURCE_MASK(64),
  158. .flags = CLOCK_SOURCE_IS_CONTINUOUS,
  159. };
  160. #endif
  161. /*
  162. * hv_init - Main initialization routine.
  163. *
  164. * This routine must be called before any other routines in here are called
  165. */
  166. int hv_init(void)
  167. {
  168. int max_leaf;
  169. union hv_x64_msr_hypercall_contents hypercall_msr;
  170. void *virtaddr = NULL;
  171. memset(hv_context.synic_event_page, 0, sizeof(void *) * NR_CPUS);
  172. memset(hv_context.synic_message_page, 0,
  173. sizeof(void *) * NR_CPUS);
  174. memset(hv_context.post_msg_page, 0,
  175. sizeof(void *) * NR_CPUS);
  176. memset(hv_context.vp_index, 0,
  177. sizeof(int) * NR_CPUS);
  178. memset(hv_context.event_dpc, 0,
  179. sizeof(void *) * NR_CPUS);
  180. memset(hv_context.msg_dpc, 0,
  181. sizeof(void *) * NR_CPUS);
  182. memset(hv_context.clk_evt, 0,
  183. sizeof(void *) * NR_CPUS);
  184. max_leaf = query_hypervisor_info();
  185. /*
  186. * Write our OS ID.
  187. */
  188. hv_context.guestid = generate_guest_id(0, LINUX_VERSION_CODE, 0);
  189. wrmsrl(HV_X64_MSR_GUEST_OS_ID, hv_context.guestid);
  190. /* See if the hypercall page is already set */
  191. rdmsrl(HV_X64_MSR_HYPERCALL, hypercall_msr.as_uint64);
  192. virtaddr = __vmalloc(PAGE_SIZE, GFP_KERNEL, PAGE_KERNEL_EXEC);
  193. if (!virtaddr)
  194. goto cleanup;
  195. hypercall_msr.enable = 1;
  196. hypercall_msr.guest_physical_address = vmalloc_to_pfn(virtaddr);
  197. wrmsrl(HV_X64_MSR_HYPERCALL, hypercall_msr.as_uint64);
  198. /* Confirm that hypercall page did get setup. */
  199. hypercall_msr.as_uint64 = 0;
  200. rdmsrl(HV_X64_MSR_HYPERCALL, hypercall_msr.as_uint64);
  201. if (!hypercall_msr.enable)
  202. goto cleanup;
  203. hv_context.hypercall_page = virtaddr;
  204. #ifdef CONFIG_X86_64
  205. if (ms_hyperv.features & HV_X64_MSR_REFERENCE_TSC_AVAILABLE) {
  206. union hv_x64_msr_hypercall_contents tsc_msr;
  207. void *va_tsc;
  208. va_tsc = __vmalloc(PAGE_SIZE, GFP_KERNEL, PAGE_KERNEL);
  209. if (!va_tsc)
  210. goto cleanup;
  211. hv_context.tsc_page = va_tsc;
  212. rdmsrl(HV_X64_MSR_REFERENCE_TSC, tsc_msr.as_uint64);
  213. tsc_msr.enable = 1;
  214. tsc_msr.guest_physical_address = vmalloc_to_pfn(va_tsc);
  215. wrmsrl(HV_X64_MSR_REFERENCE_TSC, tsc_msr.as_uint64);
  216. clocksource_register_hz(&hyperv_cs_tsc, NSEC_PER_SEC/100);
  217. }
  218. #endif
  219. return 0;
  220. cleanup:
  221. if (virtaddr) {
  222. if (hypercall_msr.enable) {
  223. hypercall_msr.as_uint64 = 0;
  224. wrmsrl(HV_X64_MSR_HYPERCALL, hypercall_msr.as_uint64);
  225. }
  226. vfree(virtaddr);
  227. }
  228. return -ENOTSUPP;
  229. }
  230. /*
  231. * hv_cleanup - Cleanup routine.
  232. *
  233. * This routine is called normally during driver unloading or exiting.
  234. */
  235. void hv_cleanup(bool crash)
  236. {
  237. union hv_x64_msr_hypercall_contents hypercall_msr;
  238. /* Reset our OS id */
  239. wrmsrl(HV_X64_MSR_GUEST_OS_ID, 0);
  240. if (hv_context.hypercall_page) {
  241. hypercall_msr.as_uint64 = 0;
  242. wrmsrl(HV_X64_MSR_HYPERCALL, hypercall_msr.as_uint64);
  243. if (!crash)
  244. vfree(hv_context.hypercall_page);
  245. hv_context.hypercall_page = NULL;
  246. }
  247. #ifdef CONFIG_X86_64
  248. /*
  249. * Cleanup the TSC page based CS.
  250. */
  251. if (ms_hyperv.features & HV_X64_MSR_REFERENCE_TSC_AVAILABLE) {
  252. /*
  253. * Crash can happen in an interrupt context and unregistering
  254. * a clocksource is impossible and redundant in this case.
  255. */
  256. if (!oops_in_progress) {
  257. clocksource_change_rating(&hyperv_cs_tsc, 10);
  258. clocksource_unregister(&hyperv_cs_tsc);
  259. }
  260. hypercall_msr.as_uint64 = 0;
  261. wrmsrl(HV_X64_MSR_REFERENCE_TSC, hypercall_msr.as_uint64);
  262. if (!crash)
  263. vfree(hv_context.tsc_page);
  264. hv_context.tsc_page = NULL;
  265. }
  266. #endif
  267. }
  268. /*
  269. * hv_post_message - Post a message using the hypervisor message IPC.
  270. *
  271. * This involves a hypercall.
  272. */
  273. int hv_post_message(union hv_connection_id connection_id,
  274. enum hv_message_type message_type,
  275. void *payload, size_t payload_size)
  276. {
  277. struct hv_input_post_message *aligned_msg;
  278. u64 status;
  279. if (payload_size > HV_MESSAGE_PAYLOAD_BYTE_COUNT)
  280. return -EMSGSIZE;
  281. aligned_msg = (struct hv_input_post_message *)
  282. hv_context.post_msg_page[get_cpu()];
  283. aligned_msg->connectionid = connection_id;
  284. aligned_msg->reserved = 0;
  285. aligned_msg->message_type = message_type;
  286. aligned_msg->payload_size = payload_size;
  287. memcpy((void *)aligned_msg->payload, payload, payload_size);
  288. status = hv_do_hypercall(HVCALL_POST_MESSAGE, aligned_msg, NULL);
  289. put_cpu();
  290. return status & 0xFFFF;
  291. }
  292. static int hv_ce_set_next_event(unsigned long delta,
  293. struct clock_event_device *evt)
  294. {
  295. u64 current_tick;
  296. WARN_ON(!clockevent_state_oneshot(evt));
  297. rdmsrl(HV_X64_MSR_TIME_REF_COUNT, current_tick);
  298. current_tick += delta;
  299. wrmsrl(HV_X64_MSR_STIMER0_COUNT, current_tick);
  300. return 0;
  301. }
  302. static int hv_ce_shutdown(struct clock_event_device *evt)
  303. {
  304. wrmsrl(HV_X64_MSR_STIMER0_COUNT, 0);
  305. wrmsrl(HV_X64_MSR_STIMER0_CONFIG, 0);
  306. return 0;
  307. }
  308. static int hv_ce_set_oneshot(struct clock_event_device *evt)
  309. {
  310. union hv_timer_config timer_cfg;
  311. timer_cfg.enable = 1;
  312. timer_cfg.auto_enable = 1;
  313. timer_cfg.sintx = VMBUS_MESSAGE_SINT;
  314. wrmsrl(HV_X64_MSR_STIMER0_CONFIG, timer_cfg.as_uint64);
  315. return 0;
  316. }
  317. static void hv_init_clockevent_device(struct clock_event_device *dev, int cpu)
  318. {
  319. dev->name = "Hyper-V clockevent";
  320. dev->features = CLOCK_EVT_FEAT_ONESHOT;
  321. dev->cpumask = cpumask_of(cpu);
  322. dev->rating = 1000;
  323. /*
  324. * Avoid settint dev->owner = THIS_MODULE deliberately as doing so will
  325. * result in clockevents_config_and_register() taking additional
  326. * references to the hv_vmbus module making it impossible to unload.
  327. */
  328. dev->set_state_shutdown = hv_ce_shutdown;
  329. dev->set_state_oneshot = hv_ce_set_oneshot;
  330. dev->set_next_event = hv_ce_set_next_event;
  331. }
  332. int hv_synic_alloc(void)
  333. {
  334. size_t size = sizeof(struct tasklet_struct);
  335. size_t ced_size = sizeof(struct clock_event_device);
  336. int cpu;
  337. hv_context.hv_numa_map = kzalloc(sizeof(struct cpumask) * nr_node_ids,
  338. GFP_ATOMIC);
  339. if (hv_context.hv_numa_map == NULL) {
  340. pr_err("Unable to allocate NUMA map\n");
  341. goto err;
  342. }
  343. for_each_online_cpu(cpu) {
  344. hv_context.event_dpc[cpu] = kmalloc(size, GFP_ATOMIC);
  345. if (hv_context.event_dpc[cpu] == NULL) {
  346. pr_err("Unable to allocate event dpc\n");
  347. goto err;
  348. }
  349. tasklet_init(hv_context.event_dpc[cpu], vmbus_on_event, cpu);
  350. hv_context.msg_dpc[cpu] = kmalloc(size, GFP_ATOMIC);
  351. if (hv_context.msg_dpc[cpu] == NULL) {
  352. pr_err("Unable to allocate event dpc\n");
  353. goto err;
  354. }
  355. tasklet_init(hv_context.msg_dpc[cpu], vmbus_on_msg_dpc, cpu);
  356. hv_context.clk_evt[cpu] = kzalloc(ced_size, GFP_ATOMIC);
  357. if (hv_context.clk_evt[cpu] == NULL) {
  358. pr_err("Unable to allocate clock event device\n");
  359. goto err;
  360. }
  361. hv_init_clockevent_device(hv_context.clk_evt[cpu], cpu);
  362. hv_context.synic_message_page[cpu] =
  363. (void *)get_zeroed_page(GFP_ATOMIC);
  364. if (hv_context.synic_message_page[cpu] == NULL) {
  365. pr_err("Unable to allocate SYNIC message page\n");
  366. goto err;
  367. }
  368. hv_context.synic_event_page[cpu] =
  369. (void *)get_zeroed_page(GFP_ATOMIC);
  370. if (hv_context.synic_event_page[cpu] == NULL) {
  371. pr_err("Unable to allocate SYNIC event page\n");
  372. goto err;
  373. }
  374. hv_context.post_msg_page[cpu] =
  375. (void *)get_zeroed_page(GFP_ATOMIC);
  376. if (hv_context.post_msg_page[cpu] == NULL) {
  377. pr_err("Unable to allocate post msg page\n");
  378. goto err;
  379. }
  380. }
  381. return 0;
  382. err:
  383. return -ENOMEM;
  384. }
  385. static void hv_synic_free_cpu(int cpu)
  386. {
  387. kfree(hv_context.event_dpc[cpu]);
  388. kfree(hv_context.msg_dpc[cpu]);
  389. kfree(hv_context.clk_evt[cpu]);
  390. if (hv_context.synic_event_page[cpu])
  391. free_page((unsigned long)hv_context.synic_event_page[cpu]);
  392. if (hv_context.synic_message_page[cpu])
  393. free_page((unsigned long)hv_context.synic_message_page[cpu]);
  394. if (hv_context.post_msg_page[cpu])
  395. free_page((unsigned long)hv_context.post_msg_page[cpu]);
  396. }
  397. void hv_synic_free(void)
  398. {
  399. int cpu;
  400. kfree(hv_context.hv_numa_map);
  401. for_each_online_cpu(cpu)
  402. hv_synic_free_cpu(cpu);
  403. }
  404. /*
  405. * hv_synic_init - Initialize the Synthethic Interrupt Controller.
  406. *
  407. * If it is already initialized by another entity (ie x2v shim), we need to
  408. * retrieve the initialized message and event pages. Otherwise, we create and
  409. * initialize the message and event pages.
  410. */
  411. void hv_synic_init(void *arg)
  412. {
  413. u64 version;
  414. union hv_synic_simp simp;
  415. union hv_synic_siefp siefp;
  416. union hv_synic_sint shared_sint;
  417. union hv_synic_scontrol sctrl;
  418. u64 vp_index;
  419. int cpu = smp_processor_id();
  420. if (!hv_context.hypercall_page)
  421. return;
  422. /* Check the version */
  423. rdmsrl(HV_X64_MSR_SVERSION, version);
  424. /* Setup the Synic's message page */
  425. rdmsrl(HV_X64_MSR_SIMP, simp.as_uint64);
  426. simp.simp_enabled = 1;
  427. simp.base_simp_gpa = virt_to_phys(hv_context.synic_message_page[cpu])
  428. >> PAGE_SHIFT;
  429. wrmsrl(HV_X64_MSR_SIMP, simp.as_uint64);
  430. /* Setup the Synic's event page */
  431. rdmsrl(HV_X64_MSR_SIEFP, siefp.as_uint64);
  432. siefp.siefp_enabled = 1;
  433. siefp.base_siefp_gpa = virt_to_phys(hv_context.synic_event_page[cpu])
  434. >> PAGE_SHIFT;
  435. wrmsrl(HV_X64_MSR_SIEFP, siefp.as_uint64);
  436. /* Setup the shared SINT. */
  437. rdmsrl(HV_X64_MSR_SINT0 + VMBUS_MESSAGE_SINT, shared_sint.as_uint64);
  438. shared_sint.as_uint64 = 0;
  439. shared_sint.vector = HYPERVISOR_CALLBACK_VECTOR;
  440. shared_sint.masked = false;
  441. shared_sint.auto_eoi = true;
  442. wrmsrl(HV_X64_MSR_SINT0 + VMBUS_MESSAGE_SINT, shared_sint.as_uint64);
  443. /* Enable the global synic bit */
  444. rdmsrl(HV_X64_MSR_SCONTROL, sctrl.as_uint64);
  445. sctrl.enable = 1;
  446. wrmsrl(HV_X64_MSR_SCONTROL, sctrl.as_uint64);
  447. hv_context.synic_initialized = true;
  448. /*
  449. * Setup the mapping between Hyper-V's notion
  450. * of cpuid and Linux' notion of cpuid.
  451. * This array will be indexed using Linux cpuid.
  452. */
  453. rdmsrl(HV_X64_MSR_VP_INDEX, vp_index);
  454. hv_context.vp_index[cpu] = (u32)vp_index;
  455. INIT_LIST_HEAD(&hv_context.percpu_list[cpu]);
  456. /*
  457. * Register the per-cpu clockevent source.
  458. */
  459. if (ms_hyperv.features & HV_X64_MSR_SYNTIMER_AVAILABLE)
  460. clockevents_config_and_register(hv_context.clk_evt[cpu],
  461. HV_TIMER_FREQUENCY,
  462. HV_MIN_DELTA_TICKS,
  463. HV_MAX_MAX_DELTA_TICKS);
  464. return;
  465. }
  466. /*
  467. * hv_synic_clockevents_cleanup - Cleanup clockevent devices
  468. */
  469. void hv_synic_clockevents_cleanup(void)
  470. {
  471. int cpu;
  472. if (!(ms_hyperv.features & HV_X64_MSR_SYNTIMER_AVAILABLE))
  473. return;
  474. for_each_present_cpu(cpu)
  475. clockevents_unbind_device(hv_context.clk_evt[cpu], cpu);
  476. }
  477. /*
  478. * hv_synic_cleanup - Cleanup routine for hv_synic_init().
  479. */
  480. void hv_synic_cleanup(void *arg)
  481. {
  482. union hv_synic_sint shared_sint;
  483. union hv_synic_simp simp;
  484. union hv_synic_siefp siefp;
  485. union hv_synic_scontrol sctrl;
  486. int cpu = smp_processor_id();
  487. if (!hv_context.synic_initialized)
  488. return;
  489. /* Turn off clockevent device */
  490. if (ms_hyperv.features & HV_X64_MSR_SYNTIMER_AVAILABLE) {
  491. clockevents_unbind_device(hv_context.clk_evt[cpu], cpu);
  492. hv_ce_shutdown(hv_context.clk_evt[cpu]);
  493. }
  494. rdmsrl(HV_X64_MSR_SINT0 + VMBUS_MESSAGE_SINT, shared_sint.as_uint64);
  495. shared_sint.masked = 1;
  496. /* Need to correctly cleanup in the case of SMP!!! */
  497. /* Disable the interrupt */
  498. wrmsrl(HV_X64_MSR_SINT0 + VMBUS_MESSAGE_SINT, shared_sint.as_uint64);
  499. rdmsrl(HV_X64_MSR_SIMP, simp.as_uint64);
  500. simp.simp_enabled = 0;
  501. simp.base_simp_gpa = 0;
  502. wrmsrl(HV_X64_MSR_SIMP, simp.as_uint64);
  503. rdmsrl(HV_X64_MSR_SIEFP, siefp.as_uint64);
  504. siefp.siefp_enabled = 0;
  505. siefp.base_siefp_gpa = 0;
  506. wrmsrl(HV_X64_MSR_SIEFP, siefp.as_uint64);
  507. /* Disable the global synic bit */
  508. rdmsrl(HV_X64_MSR_SCONTROL, sctrl.as_uint64);
  509. sctrl.enable = 0;
  510. wrmsrl(HV_X64_MSR_SCONTROL, sctrl.as_uint64);
  511. }