kvm_host.h 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553
  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/mm.h>
  15. #include <linux/preempt.h>
  16. #include <linux/marker.h>
  17. #include <linux/msi.h>
  18. #include <asm/signal.h>
  19. #include <linux/kvm.h>
  20. #include <linux/kvm_para.h>
  21. #include <linux/kvm_types.h>
  22. #include <asm/kvm_host.h>
  23. /*
  24. * vcpu->requests bit members
  25. */
  26. #define KVM_REQ_TLB_FLUSH 0
  27. #define KVM_REQ_MIGRATE_TIMER 1
  28. #define KVM_REQ_REPORT_TPR_ACCESS 2
  29. #define KVM_REQ_MMU_RELOAD 3
  30. #define KVM_REQ_TRIPLE_FAULT 4
  31. #define KVM_REQ_PENDING_TIMER 5
  32. #define KVM_REQ_UNHALT 6
  33. #define KVM_REQ_MMU_SYNC 7
  34. #define KVM_REQ_KVMCLOCK_UPDATE 8
  35. #define KVM_REQ_KICK 9
  36. #define KVM_USERSPACE_IRQ_SOURCE_ID 0
  37. struct kvm;
  38. struct kvm_vcpu;
  39. extern struct kmem_cache *kvm_vcpu_cache;
  40. /*
  41. * It would be nice to use something smarter than a linear search, TBD...
  42. * Thankfully we dont expect many devices to register (famous last words :),
  43. * so until then it will suffice. At least its abstracted so we can change
  44. * in one place.
  45. */
  46. struct kvm_io_bus {
  47. int dev_count;
  48. #define NR_IOBUS_DEVS 6
  49. struct kvm_io_device *devs[NR_IOBUS_DEVS];
  50. };
  51. void kvm_io_bus_init(struct kvm_io_bus *bus);
  52. void kvm_io_bus_destroy(struct kvm_io_bus *bus);
  53. int kvm_io_bus_write(struct kvm_io_bus *bus, gpa_t addr, int len,
  54. const void *val);
  55. int kvm_io_bus_read(struct kvm_io_bus *bus, gpa_t addr, int len,
  56. void *val);
  57. int __kvm_io_bus_register_dev(struct kvm_io_bus *bus,
  58. struct kvm_io_device *dev);
  59. int kvm_io_bus_register_dev(struct kvm *kvm, struct kvm_io_bus *bus,
  60. struct kvm_io_device *dev);
  61. void __kvm_io_bus_unregister_dev(struct kvm_io_bus *bus,
  62. struct kvm_io_device *dev);
  63. void kvm_io_bus_unregister_dev(struct kvm *kvm, struct kvm_io_bus *bus,
  64. struct kvm_io_device *dev);
  65. struct kvm_vcpu {
  66. struct kvm *kvm;
  67. #ifdef CONFIG_PREEMPT_NOTIFIERS
  68. struct preempt_notifier preempt_notifier;
  69. #endif
  70. int vcpu_id;
  71. struct mutex mutex;
  72. int cpu;
  73. struct kvm_run *run;
  74. unsigned long requests;
  75. unsigned long guest_debug;
  76. int fpu_active;
  77. int guest_fpu_loaded;
  78. wait_queue_head_t wq;
  79. int sigset_active;
  80. sigset_t sigset;
  81. struct kvm_vcpu_stat stat;
  82. #ifdef CONFIG_HAS_IOMEM
  83. int mmio_needed;
  84. int mmio_read_completed;
  85. int mmio_is_write;
  86. int mmio_size;
  87. unsigned char mmio_data[8];
  88. gpa_t mmio_phys_addr;
  89. #endif
  90. struct kvm_vcpu_arch arch;
  91. };
  92. struct kvm_memory_slot {
  93. gfn_t base_gfn;
  94. unsigned long npages;
  95. unsigned long flags;
  96. unsigned long *rmap;
  97. unsigned long *dirty_bitmap;
  98. struct {
  99. unsigned long rmap_pde;
  100. int write_count;
  101. } *lpage_info[KVM_NR_PAGE_SIZES - 1];
  102. unsigned long userspace_addr;
  103. int user_alloc;
  104. };
  105. struct kvm_kernel_irq_routing_entry {
  106. u32 gsi;
  107. u32 type;
  108. int (*set)(struct kvm_kernel_irq_routing_entry *e,
  109. struct kvm *kvm, int level);
  110. union {
  111. struct {
  112. unsigned irqchip;
  113. unsigned pin;
  114. } irqchip;
  115. struct msi_msg msi;
  116. };
  117. struct list_head link;
  118. };
  119. struct kvm {
  120. spinlock_t mmu_lock;
  121. spinlock_t requests_lock;
  122. struct rw_semaphore slots_lock;
  123. struct mm_struct *mm; /* userspace tied to this vm */
  124. int nmemslots;
  125. struct kvm_memory_slot memslots[KVM_MEMORY_SLOTS +
  126. KVM_PRIVATE_MEM_SLOTS];
  127. #ifdef CONFIG_KVM_APIC_ARCHITECTURE
  128. u32 bsp_vcpu_id;
  129. struct kvm_vcpu *bsp_vcpu;
  130. #endif
  131. struct kvm_vcpu *vcpus[KVM_MAX_VCPUS];
  132. atomic_t online_vcpus;
  133. struct list_head vm_list;
  134. struct mutex lock;
  135. struct kvm_io_bus mmio_bus;
  136. struct kvm_io_bus pio_bus;
  137. #ifdef CONFIG_HAVE_KVM_EVENTFD
  138. struct {
  139. spinlock_t lock;
  140. struct list_head items;
  141. } irqfds;
  142. #endif
  143. struct kvm_vm_stat stat;
  144. struct kvm_arch arch;
  145. atomic_t users_count;
  146. #ifdef KVM_COALESCED_MMIO_PAGE_OFFSET
  147. struct kvm_coalesced_mmio_dev *coalesced_mmio_dev;
  148. struct kvm_coalesced_mmio_ring *coalesced_mmio_ring;
  149. #endif
  150. struct mutex irq_lock;
  151. #ifdef CONFIG_HAVE_KVM_IRQCHIP
  152. struct list_head irq_routing; /* of kvm_kernel_irq_routing_entry */
  153. struct hlist_head mask_notifier_list;
  154. #endif
  155. #ifdef KVM_ARCH_WANT_MMU_NOTIFIER
  156. struct mmu_notifier mmu_notifier;
  157. unsigned long mmu_notifier_seq;
  158. long mmu_notifier_count;
  159. #endif
  160. };
  161. /* The guest did something we don't support. */
  162. #define pr_unimpl(vcpu, fmt, ...) \
  163. do { \
  164. if (printk_ratelimit()) \
  165. printk(KERN_ERR "kvm: %i: cpu%i " fmt, \
  166. current->tgid, (vcpu)->vcpu_id , ## __VA_ARGS__); \
  167. } while (0)
  168. #define kvm_printf(kvm, fmt ...) printk(KERN_DEBUG fmt)
  169. #define vcpu_printf(vcpu, fmt...) kvm_printf(vcpu->kvm, fmt)
  170. static inline struct kvm_vcpu *kvm_get_vcpu(struct kvm *kvm, int i)
  171. {
  172. smp_rmb();
  173. return kvm->vcpus[i];
  174. }
  175. #define kvm_for_each_vcpu(idx, vcpup, kvm) \
  176. for (idx = 0, vcpup = kvm_get_vcpu(kvm, idx); \
  177. idx < atomic_read(&kvm->online_vcpus) && vcpup; \
  178. vcpup = kvm_get_vcpu(kvm, ++idx))
  179. int kvm_vcpu_init(struct kvm_vcpu *vcpu, struct kvm *kvm, unsigned id);
  180. void kvm_vcpu_uninit(struct kvm_vcpu *vcpu);
  181. void vcpu_load(struct kvm_vcpu *vcpu);
  182. void vcpu_put(struct kvm_vcpu *vcpu);
  183. int kvm_init(void *opaque, unsigned int vcpu_size,
  184. struct module *module);
  185. void kvm_exit(void);
  186. void kvm_get_kvm(struct kvm *kvm);
  187. void kvm_put_kvm(struct kvm *kvm);
  188. #define HPA_MSB ((sizeof(hpa_t) * 8) - 1)
  189. #define HPA_ERR_MASK ((hpa_t)1 << HPA_MSB)
  190. static inline int is_error_hpa(hpa_t hpa) { return hpa >> HPA_MSB; }
  191. struct page *gva_to_page(struct kvm_vcpu *vcpu, gva_t gva);
  192. extern struct page *bad_page;
  193. extern pfn_t bad_pfn;
  194. int is_error_page(struct page *page);
  195. int is_error_pfn(pfn_t pfn);
  196. int kvm_is_error_hva(unsigned long addr);
  197. int kvm_set_memory_region(struct kvm *kvm,
  198. struct kvm_userspace_memory_region *mem,
  199. int user_alloc);
  200. int __kvm_set_memory_region(struct kvm *kvm,
  201. struct kvm_userspace_memory_region *mem,
  202. int user_alloc);
  203. int kvm_arch_set_memory_region(struct kvm *kvm,
  204. struct kvm_userspace_memory_region *mem,
  205. struct kvm_memory_slot old,
  206. int user_alloc);
  207. void kvm_disable_largepages(void);
  208. void kvm_arch_flush_shadow(struct kvm *kvm);
  209. gfn_t unalias_gfn(struct kvm *kvm, gfn_t gfn);
  210. struct page *gfn_to_page(struct kvm *kvm, gfn_t gfn);
  211. unsigned long gfn_to_hva(struct kvm *kvm, gfn_t gfn);
  212. void kvm_release_page_clean(struct page *page);
  213. void kvm_release_page_dirty(struct page *page);
  214. void kvm_set_page_dirty(struct page *page);
  215. void kvm_set_page_accessed(struct page *page);
  216. pfn_t gfn_to_pfn(struct kvm *kvm, gfn_t gfn);
  217. void kvm_release_pfn_dirty(pfn_t);
  218. void kvm_release_pfn_clean(pfn_t pfn);
  219. void kvm_set_pfn_dirty(pfn_t pfn);
  220. void kvm_set_pfn_accessed(pfn_t pfn);
  221. void kvm_get_pfn(pfn_t pfn);
  222. int kvm_read_guest_page(struct kvm *kvm, gfn_t gfn, void *data, int offset,
  223. int len);
  224. int kvm_read_guest_atomic(struct kvm *kvm, gpa_t gpa, void *data,
  225. unsigned long len);
  226. int kvm_read_guest(struct kvm *kvm, gpa_t gpa, void *data, unsigned long len);
  227. int kvm_write_guest_page(struct kvm *kvm, gfn_t gfn, const void *data,
  228. int offset, int len);
  229. int kvm_write_guest(struct kvm *kvm, gpa_t gpa, const void *data,
  230. unsigned long len);
  231. int kvm_clear_guest_page(struct kvm *kvm, gfn_t gfn, int offset, int len);
  232. int kvm_clear_guest(struct kvm *kvm, gpa_t gpa, unsigned long len);
  233. struct kvm_memory_slot *gfn_to_memslot(struct kvm *kvm, gfn_t gfn);
  234. int kvm_is_visible_gfn(struct kvm *kvm, gfn_t gfn);
  235. void mark_page_dirty(struct kvm *kvm, gfn_t gfn);
  236. void kvm_vcpu_block(struct kvm_vcpu *vcpu);
  237. void kvm_resched(struct kvm_vcpu *vcpu);
  238. void kvm_load_guest_fpu(struct kvm_vcpu *vcpu);
  239. void kvm_put_guest_fpu(struct kvm_vcpu *vcpu);
  240. void kvm_flush_remote_tlbs(struct kvm *kvm);
  241. void kvm_reload_remote_mmus(struct kvm *kvm);
  242. long kvm_arch_dev_ioctl(struct file *filp,
  243. unsigned int ioctl, unsigned long arg);
  244. long kvm_arch_vcpu_ioctl(struct file *filp,
  245. unsigned int ioctl, unsigned long arg);
  246. int kvm_dev_ioctl_check_extension(long ext);
  247. int kvm_get_dirty_log(struct kvm *kvm,
  248. struct kvm_dirty_log *log, int *is_dirty);
  249. int kvm_vm_ioctl_get_dirty_log(struct kvm *kvm,
  250. struct kvm_dirty_log *log);
  251. int kvm_vm_ioctl_set_memory_region(struct kvm *kvm,
  252. struct
  253. kvm_userspace_memory_region *mem,
  254. int user_alloc);
  255. long kvm_arch_vm_ioctl(struct file *filp,
  256. unsigned int ioctl, unsigned long arg);
  257. int kvm_arch_vcpu_ioctl_get_fpu(struct kvm_vcpu *vcpu, struct kvm_fpu *fpu);
  258. int kvm_arch_vcpu_ioctl_set_fpu(struct kvm_vcpu *vcpu, struct kvm_fpu *fpu);
  259. int kvm_arch_vcpu_ioctl_translate(struct kvm_vcpu *vcpu,
  260. struct kvm_translation *tr);
  261. int kvm_arch_vcpu_ioctl_get_regs(struct kvm_vcpu *vcpu, struct kvm_regs *regs);
  262. int kvm_arch_vcpu_ioctl_set_regs(struct kvm_vcpu *vcpu, struct kvm_regs *regs);
  263. int kvm_arch_vcpu_ioctl_get_sregs(struct kvm_vcpu *vcpu,
  264. struct kvm_sregs *sregs);
  265. int kvm_arch_vcpu_ioctl_set_sregs(struct kvm_vcpu *vcpu,
  266. struct kvm_sregs *sregs);
  267. int kvm_arch_vcpu_ioctl_get_mpstate(struct kvm_vcpu *vcpu,
  268. struct kvm_mp_state *mp_state);
  269. int kvm_arch_vcpu_ioctl_set_mpstate(struct kvm_vcpu *vcpu,
  270. struct kvm_mp_state *mp_state);
  271. int kvm_arch_vcpu_ioctl_set_guest_debug(struct kvm_vcpu *vcpu,
  272. struct kvm_guest_debug *dbg);
  273. int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run);
  274. int kvm_arch_init(void *opaque);
  275. void kvm_arch_exit(void);
  276. int kvm_arch_vcpu_init(struct kvm_vcpu *vcpu);
  277. void kvm_arch_vcpu_uninit(struct kvm_vcpu *vcpu);
  278. void kvm_arch_vcpu_free(struct kvm_vcpu *vcpu);
  279. void kvm_arch_vcpu_load(struct kvm_vcpu *vcpu, int cpu);
  280. void kvm_arch_vcpu_put(struct kvm_vcpu *vcpu);
  281. struct kvm_vcpu *kvm_arch_vcpu_create(struct kvm *kvm, unsigned int id);
  282. int kvm_arch_vcpu_setup(struct kvm_vcpu *vcpu);
  283. void kvm_arch_vcpu_destroy(struct kvm_vcpu *vcpu);
  284. int kvm_arch_vcpu_reset(struct kvm_vcpu *vcpu);
  285. void kvm_arch_hardware_enable(void *garbage);
  286. void kvm_arch_hardware_disable(void *garbage);
  287. int kvm_arch_hardware_setup(void);
  288. void kvm_arch_hardware_unsetup(void);
  289. void kvm_arch_check_processor_compat(void *rtn);
  290. int kvm_arch_vcpu_runnable(struct kvm_vcpu *vcpu);
  291. int kvm_arch_interrupt_allowed(struct kvm_vcpu *vcpu);
  292. void kvm_free_physmem(struct kvm *kvm);
  293. struct kvm *kvm_arch_create_vm(void);
  294. void kvm_arch_destroy_vm(struct kvm *kvm);
  295. void kvm_free_all_assigned_devices(struct kvm *kvm);
  296. void kvm_arch_sync_events(struct kvm *kvm);
  297. int kvm_cpu_get_interrupt(struct kvm_vcpu *v);
  298. int kvm_cpu_has_interrupt(struct kvm_vcpu *v);
  299. int kvm_cpu_has_pending_timer(struct kvm_vcpu *vcpu);
  300. void kvm_vcpu_kick(struct kvm_vcpu *vcpu);
  301. int kvm_is_mmio_pfn(pfn_t pfn);
  302. struct kvm_irq_ack_notifier {
  303. struct hlist_node link;
  304. unsigned gsi;
  305. void (*irq_acked)(struct kvm_irq_ack_notifier *kian);
  306. };
  307. #define KVM_ASSIGNED_MSIX_PENDING 0x1
  308. struct kvm_guest_msix_entry {
  309. u32 vector;
  310. u16 entry;
  311. u16 flags;
  312. };
  313. struct kvm_assigned_dev_kernel {
  314. struct kvm_irq_ack_notifier ack_notifier;
  315. struct work_struct interrupt_work;
  316. struct list_head list;
  317. int assigned_dev_id;
  318. int host_busnr;
  319. int host_devfn;
  320. unsigned int entries_nr;
  321. int host_irq;
  322. bool host_irq_disabled;
  323. struct msix_entry *host_msix_entries;
  324. int guest_irq;
  325. struct kvm_guest_msix_entry *guest_msix_entries;
  326. unsigned long irq_requested_type;
  327. int irq_source_id;
  328. int flags;
  329. struct pci_dev *dev;
  330. struct kvm *kvm;
  331. spinlock_t assigned_dev_lock;
  332. };
  333. struct kvm_irq_mask_notifier {
  334. void (*func)(struct kvm_irq_mask_notifier *kimn, bool masked);
  335. int irq;
  336. struct hlist_node link;
  337. };
  338. void kvm_register_irq_mask_notifier(struct kvm *kvm, int irq,
  339. struct kvm_irq_mask_notifier *kimn);
  340. void kvm_unregister_irq_mask_notifier(struct kvm *kvm, int irq,
  341. struct kvm_irq_mask_notifier *kimn);
  342. void kvm_fire_mask_notifiers(struct kvm *kvm, int irq, bool mask);
  343. int kvm_set_irq(struct kvm *kvm, int irq_source_id, int irq, int level);
  344. void kvm_notify_acked_irq(struct kvm *kvm, unsigned irqchip, unsigned pin);
  345. void kvm_register_irq_ack_notifier(struct kvm *kvm,
  346. struct kvm_irq_ack_notifier *kian);
  347. void kvm_unregister_irq_ack_notifier(struct kvm *kvm,
  348. struct kvm_irq_ack_notifier *kian);
  349. int kvm_request_irq_source_id(struct kvm *kvm);
  350. void kvm_free_irq_source_id(struct kvm *kvm, int irq_source_id);
  351. /* For vcpu->arch.iommu_flags */
  352. #define KVM_IOMMU_CACHE_COHERENCY 0x1
  353. #ifdef CONFIG_IOMMU_API
  354. int kvm_iommu_map_pages(struct kvm *kvm, gfn_t base_gfn,
  355. unsigned long npages);
  356. int kvm_iommu_map_guest(struct kvm *kvm);
  357. int kvm_iommu_unmap_guest(struct kvm *kvm);
  358. int kvm_assign_device(struct kvm *kvm,
  359. struct kvm_assigned_dev_kernel *assigned_dev);
  360. int kvm_deassign_device(struct kvm *kvm,
  361. struct kvm_assigned_dev_kernel *assigned_dev);
  362. #else /* CONFIG_IOMMU_API */
  363. static inline int kvm_iommu_map_pages(struct kvm *kvm,
  364. gfn_t base_gfn,
  365. unsigned long npages)
  366. {
  367. return 0;
  368. }
  369. static inline int kvm_iommu_map_guest(struct kvm *kvm)
  370. {
  371. return -ENODEV;
  372. }
  373. static inline int kvm_iommu_unmap_guest(struct kvm *kvm)
  374. {
  375. return 0;
  376. }
  377. static inline int kvm_assign_device(struct kvm *kvm,
  378. struct kvm_assigned_dev_kernel *assigned_dev)
  379. {
  380. return 0;
  381. }
  382. static inline int kvm_deassign_device(struct kvm *kvm,
  383. struct kvm_assigned_dev_kernel *assigned_dev)
  384. {
  385. return 0;
  386. }
  387. #endif /* CONFIG_IOMMU_API */
  388. static inline void kvm_guest_enter(void)
  389. {
  390. account_system_vtime(current);
  391. current->flags |= PF_VCPU;
  392. }
  393. static inline void kvm_guest_exit(void)
  394. {
  395. account_system_vtime(current);
  396. current->flags &= ~PF_VCPU;
  397. }
  398. static inline int memslot_id(struct kvm *kvm, struct kvm_memory_slot *slot)
  399. {
  400. return slot - kvm->memslots;
  401. }
  402. static inline gpa_t gfn_to_gpa(gfn_t gfn)
  403. {
  404. return (gpa_t)gfn << PAGE_SHIFT;
  405. }
  406. static inline hpa_t pfn_to_hpa(pfn_t pfn)
  407. {
  408. return (hpa_t)pfn << PAGE_SHIFT;
  409. }
  410. static inline void kvm_migrate_timers(struct kvm_vcpu *vcpu)
  411. {
  412. set_bit(KVM_REQ_MIGRATE_TIMER, &vcpu->requests);
  413. }
  414. enum kvm_stat_kind {
  415. KVM_STAT_VM,
  416. KVM_STAT_VCPU,
  417. };
  418. struct kvm_stats_debugfs_item {
  419. const char *name;
  420. int offset;
  421. enum kvm_stat_kind kind;
  422. struct dentry *dentry;
  423. };
  424. extern struct kvm_stats_debugfs_item debugfs_entries[];
  425. extern struct dentry *kvm_debugfs_dir;
  426. #ifdef KVM_ARCH_WANT_MMU_NOTIFIER
  427. static inline int mmu_notifier_retry(struct kvm_vcpu *vcpu, unsigned long mmu_seq)
  428. {
  429. if (unlikely(vcpu->kvm->mmu_notifier_count))
  430. return 1;
  431. /*
  432. * Both reads happen under the mmu_lock and both values are
  433. * modified under mmu_lock, so there's no need of smb_rmb()
  434. * here in between, otherwise mmu_notifier_count should be
  435. * read before mmu_notifier_seq, see
  436. * mmu_notifier_invalidate_range_end write side.
  437. */
  438. if (vcpu->kvm->mmu_notifier_seq != mmu_seq)
  439. return 1;
  440. return 0;
  441. }
  442. #endif
  443. #ifdef CONFIG_HAVE_KVM_IRQCHIP
  444. #define KVM_MAX_IRQ_ROUTES 1024
  445. int kvm_setup_default_irq_routing(struct kvm *kvm);
  446. int kvm_set_irq_routing(struct kvm *kvm,
  447. const struct kvm_irq_routing_entry *entries,
  448. unsigned nr,
  449. unsigned flags);
  450. void kvm_free_irq_routing(struct kvm *kvm);
  451. #else
  452. static inline void kvm_free_irq_routing(struct kvm *kvm) {}
  453. #endif
  454. #ifdef CONFIG_HAVE_KVM_EVENTFD
  455. void kvm_irqfd_init(struct kvm *kvm);
  456. int kvm_irqfd(struct kvm *kvm, int fd, int gsi, int flags);
  457. void kvm_irqfd_release(struct kvm *kvm);
  458. #else
  459. static inline void kvm_irqfd_init(struct kvm *kvm) {}
  460. static inline int kvm_irqfd(struct kvm *kvm, int fd, int gsi, int flags)
  461. {
  462. return -EINVAL;
  463. }
  464. static inline void kvm_irqfd_release(struct kvm *kvm) {}
  465. #endif /* CONFIG_HAVE_KVM_EVENTFD */
  466. #ifdef CONFIG_KVM_APIC_ARCHITECTURE
  467. static inline bool kvm_vcpu_is_bsp(struct kvm_vcpu *vcpu)
  468. {
  469. return vcpu->kvm->bsp_vcpu_id == vcpu->vcpu_id;
  470. }
  471. #endif
  472. #endif