kvm_host.h 30 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111
  1. #ifndef __KVM_HOST_H
  2. #define __KVM_HOST_H
  3. /*
  4. * This work is licensed under the terms of the GNU GPL, version 2. See
  5. * the COPYING file in the top-level directory.
  6. */
  7. #include <linux/types.h>
  8. #include <linux/hardirq.h>
  9. #include <linux/list.h>
  10. #include <linux/mutex.h>
  11. #include <linux/spinlock.h>
  12. #include <linux/signal.h>
  13. #include <linux/sched.h>
  14. #include <linux/bug.h>
  15. #include <linux/mm.h>
  16. #include <linux/mmu_notifier.h>
  17. #include <linux/preempt.h>
  18. #include <linux/msi.h>
  19. #include <linux/slab.h>
  20. #include <linux/rcupdate.h>
  21. #include <linux/ratelimit.h>
  22. #include <linux/err.h>
  23. #include <linux/irqflags.h>
  24. #include <linux/context_tracking.h>
  25. #include <asm/signal.h>
  26. #include <linux/kvm.h>
  27. #include <linux/kvm_para.h>
  28. #include <linux/kvm_types.h>
  29. #include <asm/kvm_host.h>
  30. #ifndef KVM_MMIO_SIZE
  31. #define KVM_MMIO_SIZE 8
  32. #endif
  33. /*
  34. * The bit 16 ~ bit 31 of kvm_memory_region::flags are internally used
  35. * in kvm, other bits are visible for userspace which are defined in
  36. * include/linux/kvm_h.
  37. */
  38. #define KVM_MEMSLOT_INVALID (1UL << 16)
  39. #define KVM_MEMSLOT_INCOHERENT (1UL << 17)
  40. /* Two fragments for cross MMIO pages. */
  41. #define KVM_MAX_MMIO_FRAGMENTS 2
  42. /*
  43. * For the normal pfn, the highest 12 bits should be zero,
  44. * so we can mask bit 62 ~ bit 52 to indicate the error pfn,
  45. * mask bit 63 to indicate the noslot pfn.
  46. */
  47. #define KVM_PFN_ERR_MASK (0x7ffULL << 52)
  48. #define KVM_PFN_ERR_NOSLOT_MASK (0xfffULL << 52)
  49. #define KVM_PFN_NOSLOT (0x1ULL << 63)
  50. #define KVM_PFN_ERR_FAULT (KVM_PFN_ERR_MASK)
  51. #define KVM_PFN_ERR_HWPOISON (KVM_PFN_ERR_MASK + 1)
  52. #define KVM_PFN_ERR_RO_FAULT (KVM_PFN_ERR_MASK + 2)
  53. /*
  54. * error pfns indicate that the gfn is in slot but faild to
  55. * translate it to pfn on host.
  56. */
  57. static inline bool is_error_pfn(pfn_t pfn)
  58. {
  59. return !!(pfn & KVM_PFN_ERR_MASK);
  60. }
  61. /*
  62. * error_noslot pfns indicate that the gfn can not be
  63. * translated to pfn - it is not in slot or failed to
  64. * translate it to pfn.
  65. */
  66. static inline bool is_error_noslot_pfn(pfn_t pfn)
  67. {
  68. return !!(pfn & KVM_PFN_ERR_NOSLOT_MASK);
  69. }
  70. /* noslot pfn indicates that the gfn is not in slot. */
  71. static inline bool is_noslot_pfn(pfn_t pfn)
  72. {
  73. return pfn == KVM_PFN_NOSLOT;
  74. }
  75. /*
  76. * architectures with KVM_HVA_ERR_BAD other than PAGE_OFFSET (e.g. s390)
  77. * provide own defines and kvm_is_error_hva
  78. */
  79. #ifndef KVM_HVA_ERR_BAD
  80. #define KVM_HVA_ERR_BAD (PAGE_OFFSET)
  81. #define KVM_HVA_ERR_RO_BAD (PAGE_OFFSET + PAGE_SIZE)
  82. static inline bool kvm_is_error_hva(unsigned long addr)
  83. {
  84. return addr >= PAGE_OFFSET;
  85. }
  86. #endif
  87. #define KVM_ERR_PTR_BAD_PAGE (ERR_PTR(-ENOENT))
  88. static inline bool is_error_page(struct page *page)
  89. {
  90. return IS_ERR(page);
  91. }
  92. /*
  93. * vcpu->requests bit members
  94. */
  95. #define KVM_REQ_TLB_FLUSH 0
  96. #define KVM_REQ_MIGRATE_TIMER 1
  97. #define KVM_REQ_REPORT_TPR_ACCESS 2
  98. #define KVM_REQ_MMU_RELOAD 3
  99. #define KVM_REQ_TRIPLE_FAULT 4
  100. #define KVM_REQ_PENDING_TIMER 5
  101. #define KVM_REQ_UNHALT 6
  102. #define KVM_REQ_MMU_SYNC 7
  103. #define KVM_REQ_CLOCK_UPDATE 8
  104. #define KVM_REQ_KICK 9
  105. #define KVM_REQ_DEACTIVATE_FPU 10
  106. #define KVM_REQ_EVENT 11
  107. #define KVM_REQ_APF_HALT 12
  108. #define KVM_REQ_STEAL_UPDATE 13
  109. #define KVM_REQ_NMI 14
  110. #define KVM_REQ_PMU 15
  111. #define KVM_REQ_PMI 16
  112. #define KVM_REQ_WATCHDOG 17
  113. #define KVM_REQ_MASTERCLOCK_UPDATE 18
  114. #define KVM_REQ_MCLOCK_INPROGRESS 19
  115. #define KVM_REQ_EPR_EXIT 20
  116. #define KVM_REQ_SCAN_IOAPIC 21
  117. #define KVM_REQ_GLOBAL_CLOCK_UPDATE 22
  118. #define KVM_REQ_ENABLE_IBS 23
  119. #define KVM_REQ_DISABLE_IBS 24
  120. #define KVM_REQ_APIC_PAGE_RELOAD 25
  121. #define KVM_USERSPACE_IRQ_SOURCE_ID 0
  122. #define KVM_IRQFD_RESAMPLE_IRQ_SOURCE_ID 1
  123. extern struct kmem_cache *kvm_vcpu_cache;
  124. extern spinlock_t kvm_lock;
  125. extern struct list_head vm_list;
  126. struct kvm_io_range {
  127. gpa_t addr;
  128. int len;
  129. struct kvm_io_device *dev;
  130. };
  131. #define NR_IOBUS_DEVS 1000
  132. struct kvm_io_bus {
  133. int dev_count;
  134. int ioeventfd_count;
  135. struct kvm_io_range range[];
  136. };
  137. enum kvm_bus {
  138. KVM_MMIO_BUS,
  139. KVM_PIO_BUS,
  140. KVM_VIRTIO_CCW_NOTIFY_BUS,
  141. KVM_FAST_MMIO_BUS,
  142. KVM_NR_BUSES
  143. };
  144. int kvm_io_bus_write(struct kvm *kvm, enum kvm_bus bus_idx, gpa_t addr,
  145. int len, const void *val);
  146. int kvm_io_bus_write_cookie(struct kvm *kvm, enum kvm_bus bus_idx, gpa_t addr,
  147. int len, const void *val, long cookie);
  148. int kvm_io_bus_read(struct kvm *kvm, enum kvm_bus bus_idx, gpa_t addr, int len,
  149. void *val);
  150. int kvm_io_bus_register_dev(struct kvm *kvm, enum kvm_bus bus_idx, gpa_t addr,
  151. int len, struct kvm_io_device *dev);
  152. int kvm_io_bus_unregister_dev(struct kvm *kvm, enum kvm_bus bus_idx,
  153. struct kvm_io_device *dev);
  154. #ifdef CONFIG_KVM_ASYNC_PF
  155. struct kvm_async_pf {
  156. struct work_struct work;
  157. struct list_head link;
  158. struct list_head queue;
  159. struct kvm_vcpu *vcpu;
  160. struct mm_struct *mm;
  161. gva_t gva;
  162. unsigned long addr;
  163. struct kvm_arch_async_pf arch;
  164. bool wakeup_all;
  165. };
  166. void kvm_clear_async_pf_completion_queue(struct kvm_vcpu *vcpu);
  167. void kvm_check_async_pf_completion(struct kvm_vcpu *vcpu);
  168. int kvm_setup_async_pf(struct kvm_vcpu *vcpu, gva_t gva, unsigned long hva,
  169. struct kvm_arch_async_pf *arch);
  170. int kvm_async_pf_wakeup_all(struct kvm_vcpu *vcpu);
  171. #endif
  172. /*
  173. * Carry out a gup that requires IO. Allow the mm to relinquish the mmap
  174. * semaphore if the filemap/swap has to wait on a page lock. pagep == NULL
  175. * controls whether we retry the gup one more time to completion in that case.
  176. * Typically this is called after a FAULT_FLAG_RETRY_NOWAIT in the main tdp
  177. * handler.
  178. */
  179. int kvm_get_user_page_io(struct task_struct *tsk, struct mm_struct *mm,
  180. unsigned long addr, bool write_fault,
  181. struct page **pagep);
  182. enum {
  183. OUTSIDE_GUEST_MODE,
  184. IN_GUEST_MODE,
  185. EXITING_GUEST_MODE,
  186. READING_SHADOW_PAGE_TABLES,
  187. };
  188. /*
  189. * Sometimes a large or cross-page mmio needs to be broken up into separate
  190. * exits for userspace servicing.
  191. */
  192. struct kvm_mmio_fragment {
  193. gpa_t gpa;
  194. void *data;
  195. unsigned len;
  196. };
  197. struct kvm_vcpu {
  198. struct kvm *kvm;
  199. #ifdef CONFIG_PREEMPT_NOTIFIERS
  200. struct preempt_notifier preempt_notifier;
  201. #endif
  202. int cpu;
  203. int vcpu_id;
  204. int srcu_idx;
  205. int mode;
  206. unsigned long requests;
  207. unsigned long guest_debug;
  208. struct mutex mutex;
  209. struct kvm_run *run;
  210. int fpu_active;
  211. int guest_fpu_loaded, guest_xcr0_loaded;
  212. wait_queue_head_t wq;
  213. struct pid *pid;
  214. int sigset_active;
  215. sigset_t sigset;
  216. struct kvm_vcpu_stat stat;
  217. #ifdef CONFIG_HAS_IOMEM
  218. int mmio_needed;
  219. int mmio_read_completed;
  220. int mmio_is_write;
  221. int mmio_cur_fragment;
  222. int mmio_nr_fragments;
  223. struct kvm_mmio_fragment mmio_fragments[KVM_MAX_MMIO_FRAGMENTS];
  224. #endif
  225. #ifdef CONFIG_KVM_ASYNC_PF
  226. struct {
  227. u32 queued;
  228. struct list_head queue;
  229. struct list_head done;
  230. spinlock_t lock;
  231. } async_pf;
  232. #endif
  233. #ifdef CONFIG_HAVE_KVM_CPU_RELAX_INTERCEPT
  234. /*
  235. * Cpu relax intercept or pause loop exit optimization
  236. * in_spin_loop: set when a vcpu does a pause loop exit
  237. * or cpu relax intercepted.
  238. * dy_eligible: indicates whether vcpu is eligible for directed yield.
  239. */
  240. struct {
  241. bool in_spin_loop;
  242. bool dy_eligible;
  243. } spin_loop;
  244. #endif
  245. bool preempted;
  246. struct kvm_vcpu_arch arch;
  247. };
  248. static inline int kvm_vcpu_exiting_guest_mode(struct kvm_vcpu *vcpu)
  249. {
  250. return cmpxchg(&vcpu->mode, IN_GUEST_MODE, EXITING_GUEST_MODE);
  251. }
  252. /*
  253. * Some of the bitops functions do not support too long bitmaps.
  254. * This number must be determined not to exceed such limits.
  255. */
  256. #define KVM_MEM_MAX_NR_PAGES ((1UL << 31) - 1)
  257. struct kvm_memory_slot {
  258. gfn_t base_gfn;
  259. unsigned long npages;
  260. unsigned long *dirty_bitmap;
  261. struct kvm_arch_memory_slot arch;
  262. unsigned long userspace_addr;
  263. u32 flags;
  264. short id;
  265. };
  266. static inline unsigned long kvm_dirty_bitmap_bytes(struct kvm_memory_slot *memslot)
  267. {
  268. return ALIGN(memslot->npages, BITS_PER_LONG) / 8;
  269. }
  270. struct kvm_s390_adapter_int {
  271. u64 ind_addr;
  272. u64 summary_addr;
  273. u64 ind_offset;
  274. u32 summary_offset;
  275. u32 adapter_id;
  276. };
  277. struct kvm_kernel_irq_routing_entry {
  278. u32 gsi;
  279. u32 type;
  280. int (*set)(struct kvm_kernel_irq_routing_entry *e,
  281. struct kvm *kvm, int irq_source_id, int level,
  282. bool line_status);
  283. union {
  284. struct {
  285. unsigned irqchip;
  286. unsigned pin;
  287. } irqchip;
  288. struct msi_msg msi;
  289. struct kvm_s390_adapter_int adapter;
  290. };
  291. struct hlist_node link;
  292. };
  293. #ifndef KVM_PRIVATE_MEM_SLOTS
  294. #define KVM_PRIVATE_MEM_SLOTS 0
  295. #endif
  296. #ifndef KVM_MEM_SLOTS_NUM
  297. #define KVM_MEM_SLOTS_NUM (KVM_USER_MEM_SLOTS + KVM_PRIVATE_MEM_SLOTS)
  298. #endif
  299. /*
  300. * Note:
  301. * memslots are not sorted by id anymore, please use id_to_memslot()
  302. * to get the memslot by its id.
  303. */
  304. struct kvm_memslots {
  305. u64 generation;
  306. struct kvm_memory_slot memslots[KVM_MEM_SLOTS_NUM];
  307. /* The mapping table from slot id to the index in memslots[]. */
  308. short id_to_index[KVM_MEM_SLOTS_NUM];
  309. };
  310. struct kvm {
  311. spinlock_t mmu_lock;
  312. struct mutex slots_lock;
  313. struct mm_struct *mm; /* userspace tied to this vm */
  314. struct kvm_memslots *memslots;
  315. struct srcu_struct srcu;
  316. struct srcu_struct irq_srcu;
  317. #ifdef CONFIG_KVM_APIC_ARCHITECTURE
  318. u32 bsp_vcpu_id;
  319. #endif
  320. struct kvm_vcpu *vcpus[KVM_MAX_VCPUS];
  321. atomic_t online_vcpus;
  322. int last_boosted_vcpu;
  323. struct list_head vm_list;
  324. struct mutex lock;
  325. struct kvm_io_bus *buses[KVM_NR_BUSES];
  326. #ifdef CONFIG_HAVE_KVM_EVENTFD
  327. struct {
  328. spinlock_t lock;
  329. struct list_head items;
  330. struct list_head resampler_list;
  331. struct mutex resampler_lock;
  332. } irqfds;
  333. struct list_head ioeventfds;
  334. #endif
  335. struct kvm_vm_stat stat;
  336. struct kvm_arch arch;
  337. atomic_t users_count;
  338. #ifdef KVM_COALESCED_MMIO_PAGE_OFFSET
  339. struct kvm_coalesced_mmio_ring *coalesced_mmio_ring;
  340. spinlock_t ring_lock;
  341. struct list_head coalesced_zones;
  342. #endif
  343. struct mutex irq_lock;
  344. #ifdef CONFIG_HAVE_KVM_IRQCHIP
  345. /*
  346. * Update side is protected by irq_lock.
  347. */
  348. struct kvm_irq_routing_table __rcu *irq_routing;
  349. struct hlist_head mask_notifier_list;
  350. #endif
  351. #ifdef CONFIG_HAVE_KVM_IRQFD
  352. struct hlist_head irq_ack_notifier_list;
  353. #endif
  354. #if defined(CONFIG_MMU_NOTIFIER) && defined(KVM_ARCH_WANT_MMU_NOTIFIER)
  355. struct mmu_notifier mmu_notifier;
  356. unsigned long mmu_notifier_seq;
  357. long mmu_notifier_count;
  358. #endif
  359. long tlbs_dirty;
  360. struct list_head devices;
  361. };
  362. #define kvm_err(fmt, ...) \
  363. pr_err("kvm [%i]: " fmt, task_pid_nr(current), ## __VA_ARGS__)
  364. #define kvm_info(fmt, ...) \
  365. pr_info("kvm [%i]: " fmt, task_pid_nr(current), ## __VA_ARGS__)
  366. #define kvm_debug(fmt, ...) \
  367. pr_debug("kvm [%i]: " fmt, task_pid_nr(current), ## __VA_ARGS__)
  368. #define kvm_pr_unimpl(fmt, ...) \
  369. pr_err_ratelimited("kvm [%i]: " fmt, \
  370. task_tgid_nr(current), ## __VA_ARGS__)
  371. /* The guest did something we don't support. */
  372. #define vcpu_unimpl(vcpu, fmt, ...) \
  373. kvm_pr_unimpl("vcpu%i " fmt, (vcpu)->vcpu_id, ## __VA_ARGS__)
  374. static inline struct kvm_vcpu *kvm_get_vcpu(struct kvm *kvm, int i)
  375. {
  376. smp_rmb();
  377. return kvm->vcpus[i];
  378. }
  379. #define kvm_for_each_vcpu(idx, vcpup, kvm) \
  380. for (idx = 0; \
  381. idx < atomic_read(&kvm->online_vcpus) && \
  382. (vcpup = kvm_get_vcpu(kvm, idx)) != NULL; \
  383. idx++)
  384. #define kvm_for_each_memslot(memslot, slots) \
  385. for (memslot = &slots->memslots[0]; \
  386. memslot < slots->memslots + KVM_MEM_SLOTS_NUM && memslot->npages;\
  387. memslot++)
  388. int kvm_vcpu_init(struct kvm_vcpu *vcpu, struct kvm *kvm, unsigned id);
  389. void kvm_vcpu_uninit(struct kvm_vcpu *vcpu);
  390. int __must_check vcpu_load(struct kvm_vcpu *vcpu);
  391. void vcpu_put(struct kvm_vcpu *vcpu);
  392. #ifdef CONFIG_HAVE_KVM_IRQFD
  393. int kvm_irqfd_init(void);
  394. void kvm_irqfd_exit(void);
  395. #else
  396. static inline int kvm_irqfd_init(void)
  397. {
  398. return 0;
  399. }
  400. static inline void kvm_irqfd_exit(void)
  401. {
  402. }
  403. #endif
  404. int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
  405. struct module *module);
  406. void kvm_exit(void);
  407. void kvm_get_kvm(struct kvm *kvm);
  408. void kvm_put_kvm(struct kvm *kvm);
  409. static inline struct kvm_memslots *kvm_memslots(struct kvm *kvm)
  410. {
  411. return rcu_dereference_check(kvm->memslots,
  412. srcu_read_lock_held(&kvm->srcu)
  413. || lockdep_is_held(&kvm->slots_lock));
  414. }
  415. static inline struct kvm_memory_slot *
  416. id_to_memslot(struct kvm_memslots *slots, int id)
  417. {
  418. int index = slots->id_to_index[id];
  419. struct kvm_memory_slot *slot;
  420. slot = &slots->memslots[index];
  421. WARN_ON(slot->id != id);
  422. return slot;
  423. }
  424. /*
  425. * KVM_SET_USER_MEMORY_REGION ioctl allows the following operations:
  426. * - create a new memory slot
  427. * - delete an existing memory slot
  428. * - modify an existing memory slot
  429. * -- move it in the guest physical memory space
  430. * -- just change its flags
  431. *
  432. * Since flags can be changed by some of these operations, the following
  433. * differentiation is the best we can do for __kvm_set_memory_region():
  434. */
  435. enum kvm_mr_change {
  436. KVM_MR_CREATE,
  437. KVM_MR_DELETE,
  438. KVM_MR_MOVE,
  439. KVM_MR_FLAGS_ONLY,
  440. };
  441. int kvm_set_memory_region(struct kvm *kvm,
  442. struct kvm_userspace_memory_region *mem);
  443. int __kvm_set_memory_region(struct kvm *kvm,
  444. struct kvm_userspace_memory_region *mem);
  445. void kvm_arch_free_memslot(struct kvm *kvm, struct kvm_memory_slot *free,
  446. struct kvm_memory_slot *dont);
  447. int kvm_arch_create_memslot(struct kvm *kvm, struct kvm_memory_slot *slot,
  448. unsigned long npages);
  449. void kvm_arch_memslots_updated(struct kvm *kvm);
  450. int kvm_arch_prepare_memory_region(struct kvm *kvm,
  451. struct kvm_memory_slot *memslot,
  452. struct kvm_userspace_memory_region *mem,
  453. enum kvm_mr_change change);
  454. void kvm_arch_commit_memory_region(struct kvm *kvm,
  455. struct kvm_userspace_memory_region *mem,
  456. const struct kvm_memory_slot *old,
  457. enum kvm_mr_change change);
  458. bool kvm_largepages_enabled(void);
  459. void kvm_disable_largepages(void);
  460. /* flush all memory translations */
  461. void kvm_arch_flush_shadow_all(struct kvm *kvm);
  462. /* flush memory translations pointing to 'slot' */
  463. void kvm_arch_flush_shadow_memslot(struct kvm *kvm,
  464. struct kvm_memory_slot *slot);
  465. int gfn_to_page_many_atomic(struct kvm *kvm, gfn_t gfn, struct page **pages,
  466. int nr_pages);
  467. struct page *gfn_to_page(struct kvm *kvm, gfn_t gfn);
  468. unsigned long gfn_to_hva(struct kvm *kvm, gfn_t gfn);
  469. unsigned long gfn_to_hva_prot(struct kvm *kvm, gfn_t gfn, bool *writable);
  470. unsigned long gfn_to_hva_memslot(struct kvm_memory_slot *slot, gfn_t gfn);
  471. unsigned long gfn_to_hva_memslot_prot(struct kvm_memory_slot *slot, gfn_t gfn,
  472. bool *writable);
  473. void kvm_release_page_clean(struct page *page);
  474. void kvm_release_page_dirty(struct page *page);
  475. void kvm_set_page_accessed(struct page *page);
  476. pfn_t gfn_to_pfn_atomic(struct kvm *kvm, gfn_t gfn);
  477. pfn_t gfn_to_pfn_async(struct kvm *kvm, gfn_t gfn, bool *async,
  478. bool write_fault, bool *writable);
  479. pfn_t gfn_to_pfn(struct kvm *kvm, gfn_t gfn);
  480. pfn_t gfn_to_pfn_prot(struct kvm *kvm, gfn_t gfn, bool write_fault,
  481. bool *writable);
  482. pfn_t gfn_to_pfn_memslot(struct kvm_memory_slot *slot, gfn_t gfn);
  483. pfn_t gfn_to_pfn_memslot_atomic(struct kvm_memory_slot *slot, gfn_t gfn);
  484. void kvm_release_pfn_clean(pfn_t pfn);
  485. void kvm_set_pfn_dirty(pfn_t pfn);
  486. void kvm_set_pfn_accessed(pfn_t pfn);
  487. void kvm_get_pfn(pfn_t pfn);
  488. int kvm_read_guest_page(struct kvm *kvm, gfn_t gfn, void *data, int offset,
  489. int len);
  490. int kvm_read_guest_atomic(struct kvm *kvm, gpa_t gpa, void *data,
  491. unsigned long len);
  492. int kvm_read_guest(struct kvm *kvm, gpa_t gpa, void *data, unsigned long len);
  493. int kvm_read_guest_cached(struct kvm *kvm, struct gfn_to_hva_cache *ghc,
  494. void *data, unsigned long len);
  495. int kvm_write_guest_page(struct kvm *kvm, gfn_t gfn, const void *data,
  496. int offset, int len);
  497. int kvm_write_guest(struct kvm *kvm, gpa_t gpa, const void *data,
  498. unsigned long len);
  499. int kvm_write_guest_cached(struct kvm *kvm, struct gfn_to_hva_cache *ghc,
  500. void *data, unsigned long len);
  501. int kvm_gfn_to_hva_cache_init(struct kvm *kvm, struct gfn_to_hva_cache *ghc,
  502. gpa_t gpa, unsigned long len);
  503. int kvm_clear_guest_page(struct kvm *kvm, gfn_t gfn, int offset, int len);
  504. int kvm_clear_guest(struct kvm *kvm, gpa_t gpa, unsigned long len);
  505. struct kvm_memory_slot *gfn_to_memslot(struct kvm *kvm, gfn_t gfn);
  506. int kvm_is_visible_gfn(struct kvm *kvm, gfn_t gfn);
  507. unsigned long kvm_host_page_size(struct kvm *kvm, gfn_t gfn);
  508. void mark_page_dirty(struct kvm *kvm, gfn_t gfn);
  509. void kvm_vcpu_block(struct kvm_vcpu *vcpu);
  510. void kvm_vcpu_kick(struct kvm_vcpu *vcpu);
  511. int kvm_vcpu_yield_to(struct kvm_vcpu *target);
  512. void kvm_vcpu_on_spin(struct kvm_vcpu *vcpu);
  513. void kvm_load_guest_fpu(struct kvm_vcpu *vcpu);
  514. void kvm_put_guest_fpu(struct kvm_vcpu *vcpu);
  515. void kvm_flush_remote_tlbs(struct kvm *kvm);
  516. void kvm_reload_remote_mmus(struct kvm *kvm);
  517. void kvm_make_mclock_inprogress_request(struct kvm *kvm);
  518. void kvm_make_scan_ioapic_request(struct kvm *kvm);
  519. bool kvm_make_all_cpus_request(struct kvm *kvm, unsigned int req);
  520. long kvm_arch_dev_ioctl(struct file *filp,
  521. unsigned int ioctl, unsigned long arg);
  522. long kvm_arch_vcpu_ioctl(struct file *filp,
  523. unsigned int ioctl, unsigned long arg);
  524. int kvm_arch_vcpu_fault(struct kvm_vcpu *vcpu, struct vm_fault *vmf);
  525. int kvm_vm_ioctl_check_extension(struct kvm *kvm, long ext);
  526. int kvm_get_dirty_log(struct kvm *kvm,
  527. struct kvm_dirty_log *log, int *is_dirty);
  528. int kvm_vm_ioctl_get_dirty_log(struct kvm *kvm,
  529. struct kvm_dirty_log *log);
  530. int kvm_vm_ioctl_irq_line(struct kvm *kvm, struct kvm_irq_level *irq_level,
  531. bool line_status);
  532. long kvm_arch_vm_ioctl(struct file *filp,
  533. unsigned int ioctl, unsigned long arg);
  534. int kvm_arch_vcpu_ioctl_get_fpu(struct kvm_vcpu *vcpu, struct kvm_fpu *fpu);
  535. int kvm_arch_vcpu_ioctl_set_fpu(struct kvm_vcpu *vcpu, struct kvm_fpu *fpu);
  536. int kvm_arch_vcpu_ioctl_translate(struct kvm_vcpu *vcpu,
  537. struct kvm_translation *tr);
  538. int kvm_arch_vcpu_ioctl_get_regs(struct kvm_vcpu *vcpu, struct kvm_regs *regs);
  539. int kvm_arch_vcpu_ioctl_set_regs(struct kvm_vcpu *vcpu, struct kvm_regs *regs);
  540. int kvm_arch_vcpu_ioctl_get_sregs(struct kvm_vcpu *vcpu,
  541. struct kvm_sregs *sregs);
  542. int kvm_arch_vcpu_ioctl_set_sregs(struct kvm_vcpu *vcpu,
  543. struct kvm_sregs *sregs);
  544. int kvm_arch_vcpu_ioctl_get_mpstate(struct kvm_vcpu *vcpu,
  545. struct kvm_mp_state *mp_state);
  546. int kvm_arch_vcpu_ioctl_set_mpstate(struct kvm_vcpu *vcpu,
  547. struct kvm_mp_state *mp_state);
  548. int kvm_arch_vcpu_ioctl_set_guest_debug(struct kvm_vcpu *vcpu,
  549. struct kvm_guest_debug *dbg);
  550. int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run);
  551. int kvm_arch_init(void *opaque);
  552. void kvm_arch_exit(void);
  553. int kvm_arch_vcpu_init(struct kvm_vcpu *vcpu);
  554. void kvm_arch_vcpu_uninit(struct kvm_vcpu *vcpu);
  555. void kvm_arch_sched_in(struct kvm_vcpu *vcpu, int cpu);
  556. void kvm_arch_vcpu_free(struct kvm_vcpu *vcpu);
  557. void kvm_arch_vcpu_load(struct kvm_vcpu *vcpu, int cpu);
  558. void kvm_arch_vcpu_put(struct kvm_vcpu *vcpu);
  559. struct kvm_vcpu *kvm_arch_vcpu_create(struct kvm *kvm, unsigned int id);
  560. int kvm_arch_vcpu_setup(struct kvm_vcpu *vcpu);
  561. int kvm_arch_vcpu_postcreate(struct kvm_vcpu *vcpu);
  562. void kvm_arch_vcpu_destroy(struct kvm_vcpu *vcpu);
  563. int kvm_arch_hardware_enable(void);
  564. void kvm_arch_hardware_disable(void);
  565. int kvm_arch_hardware_setup(void);
  566. void kvm_arch_hardware_unsetup(void);
  567. void kvm_arch_check_processor_compat(void *rtn);
  568. int kvm_arch_vcpu_runnable(struct kvm_vcpu *vcpu);
  569. int kvm_arch_vcpu_should_kick(struct kvm_vcpu *vcpu);
  570. void *kvm_kvzalloc(unsigned long size);
  571. void kvm_kvfree(const void *addr);
  572. #ifndef __KVM_HAVE_ARCH_VM_ALLOC
  573. static inline struct kvm *kvm_arch_alloc_vm(void)
  574. {
  575. return kzalloc(sizeof(struct kvm), GFP_KERNEL);
  576. }
  577. static inline void kvm_arch_free_vm(struct kvm *kvm)
  578. {
  579. kfree(kvm);
  580. }
  581. #endif
  582. #ifdef __KVM_HAVE_ARCH_NONCOHERENT_DMA
  583. void kvm_arch_register_noncoherent_dma(struct kvm *kvm);
  584. void kvm_arch_unregister_noncoherent_dma(struct kvm *kvm);
  585. bool kvm_arch_has_noncoherent_dma(struct kvm *kvm);
  586. #else
  587. static inline void kvm_arch_register_noncoherent_dma(struct kvm *kvm)
  588. {
  589. }
  590. static inline void kvm_arch_unregister_noncoherent_dma(struct kvm *kvm)
  591. {
  592. }
  593. static inline bool kvm_arch_has_noncoherent_dma(struct kvm *kvm)
  594. {
  595. return false;
  596. }
  597. #endif
  598. static inline wait_queue_head_t *kvm_arch_vcpu_wq(struct kvm_vcpu *vcpu)
  599. {
  600. #ifdef __KVM_HAVE_ARCH_WQP
  601. return vcpu->arch.wqp;
  602. #else
  603. return &vcpu->wq;
  604. #endif
  605. }
  606. int kvm_arch_init_vm(struct kvm *kvm, unsigned long type);
  607. void kvm_arch_destroy_vm(struct kvm *kvm);
  608. void kvm_arch_sync_events(struct kvm *kvm);
  609. int kvm_cpu_has_pending_timer(struct kvm_vcpu *vcpu);
  610. void kvm_vcpu_kick(struct kvm_vcpu *vcpu);
  611. bool kvm_is_reserved_pfn(pfn_t pfn);
  612. struct kvm_irq_ack_notifier {
  613. struct hlist_node link;
  614. unsigned gsi;
  615. void (*irq_acked)(struct kvm_irq_ack_notifier *kian);
  616. };
  617. struct kvm_assigned_dev_kernel {
  618. struct kvm_irq_ack_notifier ack_notifier;
  619. struct list_head list;
  620. int assigned_dev_id;
  621. int host_segnr;
  622. int host_busnr;
  623. int host_devfn;
  624. unsigned int entries_nr;
  625. int host_irq;
  626. bool host_irq_disabled;
  627. bool pci_2_3;
  628. struct msix_entry *host_msix_entries;
  629. int guest_irq;
  630. struct msix_entry *guest_msix_entries;
  631. unsigned long irq_requested_type;
  632. int irq_source_id;
  633. int flags;
  634. struct pci_dev *dev;
  635. struct kvm *kvm;
  636. spinlock_t intx_lock;
  637. spinlock_t intx_mask_lock;
  638. char irq_name[32];
  639. struct pci_saved_state *pci_saved_state;
  640. };
  641. struct kvm_irq_mask_notifier {
  642. void (*func)(struct kvm_irq_mask_notifier *kimn, bool masked);
  643. int irq;
  644. struct hlist_node link;
  645. };
  646. void kvm_register_irq_mask_notifier(struct kvm *kvm, int irq,
  647. struct kvm_irq_mask_notifier *kimn);
  648. void kvm_unregister_irq_mask_notifier(struct kvm *kvm, int irq,
  649. struct kvm_irq_mask_notifier *kimn);
  650. void kvm_fire_mask_notifiers(struct kvm *kvm, unsigned irqchip, unsigned pin,
  651. bool mask);
  652. int kvm_irq_map_gsi(struct kvm *kvm,
  653. struct kvm_kernel_irq_routing_entry *entries, int gsi);
  654. int kvm_irq_map_chip_pin(struct kvm *kvm, unsigned irqchip, unsigned pin);
  655. int kvm_set_irq(struct kvm *kvm, int irq_source_id, u32 irq, int level,
  656. bool line_status);
  657. int kvm_set_irq_inatomic(struct kvm *kvm, int irq_source_id, u32 irq, int level);
  658. int kvm_set_msi(struct kvm_kernel_irq_routing_entry *irq_entry, struct kvm *kvm,
  659. int irq_source_id, int level, bool line_status);
  660. bool kvm_irq_has_notifier(struct kvm *kvm, unsigned irqchip, unsigned pin);
  661. void kvm_notify_acked_irq(struct kvm *kvm, unsigned irqchip, unsigned pin);
  662. void kvm_register_irq_ack_notifier(struct kvm *kvm,
  663. struct kvm_irq_ack_notifier *kian);
  664. void kvm_unregister_irq_ack_notifier(struct kvm *kvm,
  665. struct kvm_irq_ack_notifier *kian);
  666. int kvm_request_irq_source_id(struct kvm *kvm);
  667. void kvm_free_irq_source_id(struct kvm *kvm, int irq_source_id);
  668. #ifdef CONFIG_KVM_DEVICE_ASSIGNMENT
  669. int kvm_iommu_map_pages(struct kvm *kvm, struct kvm_memory_slot *slot);
  670. void kvm_iommu_unmap_pages(struct kvm *kvm, struct kvm_memory_slot *slot);
  671. int kvm_iommu_map_guest(struct kvm *kvm);
  672. int kvm_iommu_unmap_guest(struct kvm *kvm);
  673. int kvm_assign_device(struct kvm *kvm,
  674. struct kvm_assigned_dev_kernel *assigned_dev);
  675. int kvm_deassign_device(struct kvm *kvm,
  676. struct kvm_assigned_dev_kernel *assigned_dev);
  677. #else
  678. static inline int kvm_iommu_map_pages(struct kvm *kvm,
  679. struct kvm_memory_slot *slot)
  680. {
  681. return 0;
  682. }
  683. static inline void kvm_iommu_unmap_pages(struct kvm *kvm,
  684. struct kvm_memory_slot *slot)
  685. {
  686. }
  687. static inline int kvm_iommu_unmap_guest(struct kvm *kvm)
  688. {
  689. return 0;
  690. }
  691. #endif
  692. static inline void kvm_guest_enter(void)
  693. {
  694. unsigned long flags;
  695. BUG_ON(preemptible());
  696. local_irq_save(flags);
  697. guest_enter();
  698. local_irq_restore(flags);
  699. /* KVM does not hold any references to rcu protected data when it
  700. * switches CPU into a guest mode. In fact switching to a guest mode
  701. * is very similar to exiting to userspace from rcu point of view. In
  702. * addition CPU may stay in a guest mode for quite a long time (up to
  703. * one time slice). Lets treat guest mode as quiescent state, just like
  704. * we do with user-mode execution.
  705. */
  706. rcu_virt_note_context_switch(smp_processor_id());
  707. }
  708. static inline void kvm_guest_exit(void)
  709. {
  710. unsigned long flags;
  711. local_irq_save(flags);
  712. guest_exit();
  713. local_irq_restore(flags);
  714. }
  715. /*
  716. * search_memslots() and __gfn_to_memslot() are here because they are
  717. * used in non-modular code in arch/powerpc/kvm/book3s_hv_rm_mmu.c.
  718. * gfn_to_memslot() itself isn't here as an inline because that would
  719. * bloat other code too much.
  720. */
  721. static inline struct kvm_memory_slot *
  722. search_memslots(struct kvm_memslots *slots, gfn_t gfn)
  723. {
  724. struct kvm_memory_slot *memslot;
  725. kvm_for_each_memslot(memslot, slots)
  726. if (gfn >= memslot->base_gfn &&
  727. gfn < memslot->base_gfn + memslot->npages)
  728. return memslot;
  729. return NULL;
  730. }
  731. static inline struct kvm_memory_slot *
  732. __gfn_to_memslot(struct kvm_memslots *slots, gfn_t gfn)
  733. {
  734. return search_memslots(slots, gfn);
  735. }
  736. static inline unsigned long
  737. __gfn_to_hva_memslot(struct kvm_memory_slot *slot, gfn_t gfn)
  738. {
  739. return slot->userspace_addr + (gfn - slot->base_gfn) * PAGE_SIZE;
  740. }
  741. static inline int memslot_id(struct kvm *kvm, gfn_t gfn)
  742. {
  743. return gfn_to_memslot(kvm, gfn)->id;
  744. }
  745. static inline gfn_t
  746. hva_to_gfn_memslot(unsigned long hva, struct kvm_memory_slot *slot)
  747. {
  748. gfn_t gfn_offset = (hva - slot->userspace_addr) >> PAGE_SHIFT;
  749. return slot->base_gfn + gfn_offset;
  750. }
  751. static inline gpa_t gfn_to_gpa(gfn_t gfn)
  752. {
  753. return (gpa_t)gfn << PAGE_SHIFT;
  754. }
  755. static inline gfn_t gpa_to_gfn(gpa_t gpa)
  756. {
  757. return (gfn_t)(gpa >> PAGE_SHIFT);
  758. }
  759. static inline hpa_t pfn_to_hpa(pfn_t pfn)
  760. {
  761. return (hpa_t)pfn << PAGE_SHIFT;
  762. }
  763. static inline bool kvm_is_error_gpa(struct kvm *kvm, gpa_t gpa)
  764. {
  765. unsigned long hva = gfn_to_hva(kvm, gpa_to_gfn(gpa));
  766. return kvm_is_error_hva(hva);
  767. }
  768. static inline void kvm_migrate_timers(struct kvm_vcpu *vcpu)
  769. {
  770. set_bit(KVM_REQ_MIGRATE_TIMER, &vcpu->requests);
  771. }
  772. enum kvm_stat_kind {
  773. KVM_STAT_VM,
  774. KVM_STAT_VCPU,
  775. };
  776. struct kvm_stats_debugfs_item {
  777. const char *name;
  778. int offset;
  779. enum kvm_stat_kind kind;
  780. struct dentry *dentry;
  781. };
  782. extern struct kvm_stats_debugfs_item debugfs_entries[];
  783. extern struct dentry *kvm_debugfs_dir;
  784. #if defined(CONFIG_MMU_NOTIFIER) && defined(KVM_ARCH_WANT_MMU_NOTIFIER)
  785. static inline int mmu_notifier_retry(struct kvm *kvm, unsigned long mmu_seq)
  786. {
  787. if (unlikely(kvm->mmu_notifier_count))
  788. return 1;
  789. /*
  790. * Ensure the read of mmu_notifier_count happens before the read
  791. * of mmu_notifier_seq. This interacts with the smp_wmb() in
  792. * mmu_notifier_invalidate_range_end to make sure that the caller
  793. * either sees the old (non-zero) value of mmu_notifier_count or
  794. * the new (incremented) value of mmu_notifier_seq.
  795. * PowerPC Book3s HV KVM calls this under a per-page lock
  796. * rather than under kvm->mmu_lock, for scalability, so
  797. * can't rely on kvm->mmu_lock to keep things ordered.
  798. */
  799. smp_rmb();
  800. if (kvm->mmu_notifier_seq != mmu_seq)
  801. return 1;
  802. return 0;
  803. }
  804. #endif
  805. #ifdef CONFIG_HAVE_KVM_IRQ_ROUTING
  806. #ifdef CONFIG_S390
  807. #define KVM_MAX_IRQ_ROUTES 4096 //FIXME: we can have more than that...
  808. #else
  809. #define KVM_MAX_IRQ_ROUTES 1024
  810. #endif
  811. int kvm_setup_default_irq_routing(struct kvm *kvm);
  812. int kvm_set_irq_routing(struct kvm *kvm,
  813. const struct kvm_irq_routing_entry *entries,
  814. unsigned nr,
  815. unsigned flags);
  816. int kvm_set_routing_entry(struct kvm_kernel_irq_routing_entry *e,
  817. const struct kvm_irq_routing_entry *ue);
  818. void kvm_free_irq_routing(struct kvm *kvm);
  819. #else
  820. static inline void kvm_free_irq_routing(struct kvm *kvm) {}
  821. #endif
  822. int kvm_send_userspace_msi(struct kvm *kvm, struct kvm_msi *msi);
  823. #ifdef CONFIG_HAVE_KVM_EVENTFD
  824. void kvm_eventfd_init(struct kvm *kvm);
  825. int kvm_ioeventfd(struct kvm *kvm, struct kvm_ioeventfd *args);
  826. #ifdef CONFIG_HAVE_KVM_IRQFD
  827. int kvm_irqfd(struct kvm *kvm, struct kvm_irqfd *args);
  828. void kvm_irqfd_release(struct kvm *kvm);
  829. void kvm_irq_routing_update(struct kvm *);
  830. #else
  831. static inline int kvm_irqfd(struct kvm *kvm, struct kvm_irqfd *args)
  832. {
  833. return -EINVAL;
  834. }
  835. static inline void kvm_irqfd_release(struct kvm *kvm) {}
  836. #endif
  837. #else
  838. static inline void kvm_eventfd_init(struct kvm *kvm) {}
  839. static inline int kvm_irqfd(struct kvm *kvm, struct kvm_irqfd *args)
  840. {
  841. return -EINVAL;
  842. }
  843. static inline void kvm_irqfd_release(struct kvm *kvm) {}
  844. #ifdef CONFIG_HAVE_KVM_IRQCHIP
  845. static inline void kvm_irq_routing_update(struct kvm *kvm)
  846. {
  847. }
  848. #endif
  849. static inline int kvm_ioeventfd(struct kvm *kvm, struct kvm_ioeventfd *args)
  850. {
  851. return -ENOSYS;
  852. }
  853. #endif /* CONFIG_HAVE_KVM_EVENTFD */
  854. #ifdef CONFIG_KVM_APIC_ARCHITECTURE
  855. static inline bool kvm_vcpu_is_bsp(struct kvm_vcpu *vcpu)
  856. {
  857. return vcpu->kvm->bsp_vcpu_id == vcpu->vcpu_id;
  858. }
  859. bool kvm_vcpu_compatible(struct kvm_vcpu *vcpu);
  860. #else
  861. static inline bool kvm_vcpu_compatible(struct kvm_vcpu *vcpu) { return true; }
  862. #endif
  863. #ifdef CONFIG_KVM_DEVICE_ASSIGNMENT
  864. long kvm_vm_ioctl_assigned_device(struct kvm *kvm, unsigned ioctl,
  865. unsigned long arg);
  866. void kvm_free_all_assigned_devices(struct kvm *kvm);
  867. #else
  868. static inline long kvm_vm_ioctl_assigned_device(struct kvm *kvm, unsigned ioctl,
  869. unsigned long arg)
  870. {
  871. return -ENOTTY;
  872. }
  873. static inline void kvm_free_all_assigned_devices(struct kvm *kvm) {}
  874. #endif
  875. static inline void kvm_make_request(int req, struct kvm_vcpu *vcpu)
  876. {
  877. set_bit(req, &vcpu->requests);
  878. }
  879. static inline bool kvm_check_request(int req, struct kvm_vcpu *vcpu)
  880. {
  881. if (test_bit(req, &vcpu->requests)) {
  882. clear_bit(req, &vcpu->requests);
  883. return true;
  884. } else {
  885. return false;
  886. }
  887. }
  888. extern bool kvm_rebooting;
  889. struct kvm_device {
  890. struct kvm_device_ops *ops;
  891. struct kvm *kvm;
  892. void *private;
  893. struct list_head vm_node;
  894. };
  895. /* create, destroy, and name are mandatory */
  896. struct kvm_device_ops {
  897. const char *name;
  898. int (*create)(struct kvm_device *dev, u32 type);
  899. /*
  900. * Destroy is responsible for freeing dev.
  901. *
  902. * Destroy may be called before or after destructors are called
  903. * on emulated I/O regions, depending on whether a reference is
  904. * held by a vcpu or other kvm component that gets destroyed
  905. * after the emulated I/O.
  906. */
  907. void (*destroy)(struct kvm_device *dev);
  908. int (*set_attr)(struct kvm_device *dev, struct kvm_device_attr *attr);
  909. int (*get_attr)(struct kvm_device *dev, struct kvm_device_attr *attr);
  910. int (*has_attr)(struct kvm_device *dev, struct kvm_device_attr *attr);
  911. long (*ioctl)(struct kvm_device *dev, unsigned int ioctl,
  912. unsigned long arg);
  913. };
  914. void kvm_device_get(struct kvm_device *dev);
  915. void kvm_device_put(struct kvm_device *dev);
  916. struct kvm_device *kvm_device_from_filp(struct file *filp);
  917. int kvm_register_device_ops(struct kvm_device_ops *ops, u32 type);
  918. void kvm_unregister_device_ops(u32 type);
  919. extern struct kvm_device_ops kvm_mpic_ops;
  920. extern struct kvm_device_ops kvm_xics_ops;
  921. #ifdef CONFIG_HAVE_KVM_CPU_RELAX_INTERCEPT
  922. static inline void kvm_vcpu_set_in_spin_loop(struct kvm_vcpu *vcpu, bool val)
  923. {
  924. vcpu->spin_loop.in_spin_loop = val;
  925. }
  926. static inline void kvm_vcpu_set_dy_eligible(struct kvm_vcpu *vcpu, bool val)
  927. {
  928. vcpu->spin_loop.dy_eligible = val;
  929. }
  930. #else /* !CONFIG_HAVE_KVM_CPU_RELAX_INTERCEPT */
  931. static inline void kvm_vcpu_set_in_spin_loop(struct kvm_vcpu *vcpu, bool val)
  932. {
  933. }
  934. static inline void kvm_vcpu_set_dy_eligible(struct kvm_vcpu *vcpu, bool val)
  935. {
  936. }
  937. #endif /* CONFIG_HAVE_KVM_CPU_RELAX_INTERCEPT */
  938. #endif