hv.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625
  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 cycle_t read_hv_clock_tsc(struct clocksource *arg)
  121. {
  122. cycle_t 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. cycle_t 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_RX);
  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. }
  267. #endif
  268. }
  269. /*
  270. * hv_post_message - Post a message using the hypervisor message IPC.
  271. *
  272. * This involves a hypercall.
  273. */
  274. int hv_post_message(union hv_connection_id connection_id,
  275. enum hv_message_type message_type,
  276. void *payload, size_t payload_size)
  277. {
  278. struct hv_input_post_message *aligned_msg;
  279. u64 status;
  280. if (payload_size > HV_MESSAGE_PAYLOAD_BYTE_COUNT)
  281. return -EMSGSIZE;
  282. aligned_msg = (struct hv_input_post_message *)
  283. hv_context.post_msg_page[get_cpu()];
  284. aligned_msg->connectionid = connection_id;
  285. aligned_msg->reserved = 0;
  286. aligned_msg->message_type = message_type;
  287. aligned_msg->payload_size = payload_size;
  288. memcpy((void *)aligned_msg->payload, payload, payload_size);
  289. status = hv_do_hypercall(HVCALL_POST_MESSAGE, aligned_msg, NULL);
  290. put_cpu();
  291. return status & 0xFFFF;
  292. }
  293. static int hv_ce_set_next_event(unsigned long delta,
  294. struct clock_event_device *evt)
  295. {
  296. cycle_t current_tick;
  297. WARN_ON(!clockevent_state_oneshot(evt));
  298. rdmsrl(HV_X64_MSR_TIME_REF_COUNT, current_tick);
  299. current_tick += delta;
  300. wrmsrl(HV_X64_MSR_STIMER0_COUNT, current_tick);
  301. return 0;
  302. }
  303. static int hv_ce_shutdown(struct clock_event_device *evt)
  304. {
  305. wrmsrl(HV_X64_MSR_STIMER0_COUNT, 0);
  306. wrmsrl(HV_X64_MSR_STIMER0_CONFIG, 0);
  307. return 0;
  308. }
  309. static int hv_ce_set_oneshot(struct clock_event_device *evt)
  310. {
  311. union hv_timer_config timer_cfg;
  312. timer_cfg.enable = 1;
  313. timer_cfg.auto_enable = 1;
  314. timer_cfg.sintx = VMBUS_MESSAGE_SINT;
  315. wrmsrl(HV_X64_MSR_STIMER0_CONFIG, timer_cfg.as_uint64);
  316. return 0;
  317. }
  318. static void hv_init_clockevent_device(struct clock_event_device *dev, int cpu)
  319. {
  320. dev->name = "Hyper-V clockevent";
  321. dev->features = CLOCK_EVT_FEAT_ONESHOT;
  322. dev->cpumask = cpumask_of(cpu);
  323. dev->rating = 1000;
  324. /*
  325. * Avoid settint dev->owner = THIS_MODULE deliberately as doing so will
  326. * result in clockevents_config_and_register() taking additional
  327. * references to the hv_vmbus module making it impossible to unload.
  328. */
  329. dev->set_state_shutdown = hv_ce_shutdown;
  330. dev->set_state_oneshot = hv_ce_set_oneshot;
  331. dev->set_next_event = hv_ce_set_next_event;
  332. }
  333. int hv_synic_alloc(void)
  334. {
  335. size_t size = sizeof(struct tasklet_struct);
  336. size_t ced_size = sizeof(struct clock_event_device);
  337. int cpu;
  338. hv_context.hv_numa_map = kzalloc(sizeof(struct cpumask) * nr_node_ids,
  339. GFP_ATOMIC);
  340. if (hv_context.hv_numa_map == NULL) {
  341. pr_err("Unable to allocate NUMA map\n");
  342. goto err;
  343. }
  344. for_each_present_cpu(cpu) {
  345. hv_context.event_dpc[cpu] = kmalloc(size, GFP_ATOMIC);
  346. if (hv_context.event_dpc[cpu] == NULL) {
  347. pr_err("Unable to allocate event dpc\n");
  348. goto err;
  349. }
  350. tasklet_init(hv_context.event_dpc[cpu], vmbus_on_event, cpu);
  351. hv_context.msg_dpc[cpu] = kmalloc(size, GFP_ATOMIC);
  352. if (hv_context.msg_dpc[cpu] == NULL) {
  353. pr_err("Unable to allocate event dpc\n");
  354. goto err;
  355. }
  356. tasklet_init(hv_context.msg_dpc[cpu], vmbus_on_msg_dpc, cpu);
  357. hv_context.clk_evt[cpu] = kzalloc(ced_size, GFP_ATOMIC);
  358. if (hv_context.clk_evt[cpu] == NULL) {
  359. pr_err("Unable to allocate clock event device\n");
  360. goto err;
  361. }
  362. hv_init_clockevent_device(hv_context.clk_evt[cpu], cpu);
  363. hv_context.synic_message_page[cpu] =
  364. (void *)get_zeroed_page(GFP_ATOMIC);
  365. if (hv_context.synic_message_page[cpu] == NULL) {
  366. pr_err("Unable to allocate SYNIC message page\n");
  367. goto err;
  368. }
  369. hv_context.synic_event_page[cpu] =
  370. (void *)get_zeroed_page(GFP_ATOMIC);
  371. if (hv_context.synic_event_page[cpu] == NULL) {
  372. pr_err("Unable to allocate SYNIC event page\n");
  373. goto err;
  374. }
  375. hv_context.post_msg_page[cpu] =
  376. (void *)get_zeroed_page(GFP_ATOMIC);
  377. if (hv_context.post_msg_page[cpu] == NULL) {
  378. pr_err("Unable to allocate post msg page\n");
  379. goto err;
  380. }
  381. INIT_LIST_HEAD(&hv_context.percpu_list[cpu]);
  382. }
  383. return 0;
  384. err:
  385. return -ENOMEM;
  386. }
  387. static void hv_synic_free_cpu(int cpu)
  388. {
  389. kfree(hv_context.event_dpc[cpu]);
  390. kfree(hv_context.msg_dpc[cpu]);
  391. kfree(hv_context.clk_evt[cpu]);
  392. if (hv_context.synic_event_page[cpu])
  393. free_page((unsigned long)hv_context.synic_event_page[cpu]);
  394. if (hv_context.synic_message_page[cpu])
  395. free_page((unsigned long)hv_context.synic_message_page[cpu]);
  396. if (hv_context.post_msg_page[cpu])
  397. free_page((unsigned long)hv_context.post_msg_page[cpu]);
  398. }
  399. void hv_synic_free(void)
  400. {
  401. int cpu;
  402. kfree(hv_context.hv_numa_map);
  403. for_each_present_cpu(cpu)
  404. hv_synic_free_cpu(cpu);
  405. }
  406. /*
  407. * hv_synic_init - Initialize the Synthethic Interrupt Controller.
  408. *
  409. * If it is already initialized by another entity (ie x2v shim), we need to
  410. * retrieve the initialized message and event pages. Otherwise, we create and
  411. * initialize the message and event pages.
  412. */
  413. void hv_synic_init(void *arg)
  414. {
  415. u64 version;
  416. union hv_synic_simp simp;
  417. union hv_synic_siefp siefp;
  418. union hv_synic_sint shared_sint;
  419. union hv_synic_scontrol sctrl;
  420. u64 vp_index;
  421. int cpu = smp_processor_id();
  422. if (!hv_context.hypercall_page)
  423. return;
  424. /* Check the version */
  425. rdmsrl(HV_X64_MSR_SVERSION, version);
  426. /* Setup the Synic's message page */
  427. rdmsrl(HV_X64_MSR_SIMP, simp.as_uint64);
  428. simp.simp_enabled = 1;
  429. simp.base_simp_gpa = virt_to_phys(hv_context.synic_message_page[cpu])
  430. >> PAGE_SHIFT;
  431. wrmsrl(HV_X64_MSR_SIMP, simp.as_uint64);
  432. /* Setup the Synic's event page */
  433. rdmsrl(HV_X64_MSR_SIEFP, siefp.as_uint64);
  434. siefp.siefp_enabled = 1;
  435. siefp.base_siefp_gpa = virt_to_phys(hv_context.synic_event_page[cpu])
  436. >> PAGE_SHIFT;
  437. wrmsrl(HV_X64_MSR_SIEFP, siefp.as_uint64);
  438. /* Setup the shared SINT. */
  439. rdmsrl(HV_X64_MSR_SINT0 + VMBUS_MESSAGE_SINT, shared_sint.as_uint64);
  440. shared_sint.as_uint64 = 0;
  441. shared_sint.vector = HYPERVISOR_CALLBACK_VECTOR;
  442. shared_sint.masked = false;
  443. shared_sint.auto_eoi = true;
  444. wrmsrl(HV_X64_MSR_SINT0 + VMBUS_MESSAGE_SINT, shared_sint.as_uint64);
  445. /* Enable the global synic bit */
  446. rdmsrl(HV_X64_MSR_SCONTROL, sctrl.as_uint64);
  447. sctrl.enable = 1;
  448. wrmsrl(HV_X64_MSR_SCONTROL, sctrl.as_uint64);
  449. hv_context.synic_initialized = true;
  450. /*
  451. * Setup the mapping between Hyper-V's notion
  452. * of cpuid and Linux' notion of cpuid.
  453. * This array will be indexed using Linux cpuid.
  454. */
  455. rdmsrl(HV_X64_MSR_VP_INDEX, vp_index);
  456. hv_context.vp_index[cpu] = (u32)vp_index;
  457. /*
  458. * Register the per-cpu clockevent source.
  459. */
  460. if (ms_hyperv.features & HV_X64_MSR_SYNTIMER_AVAILABLE)
  461. clockevents_config_and_register(hv_context.clk_evt[cpu],
  462. HV_TIMER_FREQUENCY,
  463. HV_MIN_DELTA_TICKS,
  464. HV_MAX_MAX_DELTA_TICKS);
  465. return;
  466. }
  467. /*
  468. * hv_synic_clockevents_cleanup - Cleanup clockevent devices
  469. */
  470. void hv_synic_clockevents_cleanup(void)
  471. {
  472. int cpu;
  473. if (!(ms_hyperv.features & HV_X64_MSR_SYNTIMER_AVAILABLE))
  474. return;
  475. for_each_online_cpu(cpu)
  476. clockevents_unbind_device(hv_context.clk_evt[cpu], cpu);
  477. }
  478. /*
  479. * hv_synic_cleanup - Cleanup routine for hv_synic_init().
  480. */
  481. void hv_synic_cleanup(void *arg)
  482. {
  483. union hv_synic_sint shared_sint;
  484. union hv_synic_simp simp;
  485. union hv_synic_siefp siefp;
  486. union hv_synic_scontrol sctrl;
  487. int cpu = smp_processor_id();
  488. if (!hv_context.synic_initialized)
  489. return;
  490. /* Turn off clockevent device */
  491. if (ms_hyperv.features & HV_X64_MSR_SYNTIMER_AVAILABLE)
  492. hv_ce_shutdown(hv_context.clk_evt[cpu]);
  493. rdmsrl(HV_X64_MSR_SINT0 + VMBUS_MESSAGE_SINT, shared_sint.as_uint64);
  494. shared_sint.masked = 1;
  495. /* Need to correctly cleanup in the case of SMP!!! */
  496. /* Disable the interrupt */
  497. wrmsrl(HV_X64_MSR_SINT0 + VMBUS_MESSAGE_SINT, shared_sint.as_uint64);
  498. rdmsrl(HV_X64_MSR_SIMP, simp.as_uint64);
  499. simp.simp_enabled = 0;
  500. simp.base_simp_gpa = 0;
  501. wrmsrl(HV_X64_MSR_SIMP, simp.as_uint64);
  502. rdmsrl(HV_X64_MSR_SIEFP, siefp.as_uint64);
  503. siefp.siefp_enabled = 0;
  504. siefp.base_siefp_gpa = 0;
  505. wrmsrl(HV_X64_MSR_SIEFP, siefp.as_uint64);
  506. /* Disable the global synic bit */
  507. rdmsrl(HV_X64_MSR_SCONTROL, sctrl.as_uint64);
  508. sctrl.enable = 0;
  509. wrmsrl(HV_X64_MSR_SCONTROL, sctrl.as_uint64);
  510. }