hv.c 16 KB

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