Lines Matching refs:kvm

193 bool kvm_make_vcpus_request_mask(struct kvm *kvm, unsigned int req,
195 bool kvm_make_all_cpus_request(struct kvm *kvm, unsigned int req);
231 int kvm_io_bus_register_dev(struct kvm *kvm, enum kvm_bus bus_idx, gpa_t addr,
233 int kvm_io_bus_unregister_dev(struct kvm *kvm, enum kvm_bus bus_idx,
235 struct kvm_io_device *kvm_io_bus_get_dev(struct kvm *kvm, enum kvm_bus bus_idx,
270 bool kvm_unmap_gfn_range(struct kvm *kvm, struct kvm_gfn_range *range);
271 bool kvm_age_gfn(struct kvm *kvm, struct kvm_gfn_range *range);
272 bool kvm_test_age_gfn(struct kvm *kvm, struct kvm_gfn_range *range);
324 struct kvm *kvm; member
661 struct kvm *kvm, int irq_source_id, int level,
694 bool kvm_arch_irqchip_in_kernel(struct kvm *kvm);
704 static inline int kvm_arch_nr_memslot_as_ids(struct kvm *kvm) in kvm_arch_nr_memslot_as_ids() argument
720 static inline bool kvm_arch_has_private_mem(struct kvm *kvm) in kvm_arch_has_private_mem() argument
727 static inline bool kvm_arch_has_readonly_mem(struct kvm *kvm) in kvm_arch_has_readonly_mem() argument
750 struct kvm { struct
888 static inline void kvm_vm_dead(struct kvm *kvm) in kvm_vm_dead() argument
890 kvm->vm_dead = true; in kvm_vm_dead()
891 kvm_make_all_cpus_request(kvm, KVM_REQ_VM_DEAD); in kvm_vm_dead()
894 static inline void kvm_vm_bugged(struct kvm *kvm) in kvm_vm_bugged() argument
896 kvm->vm_bugged = true; in kvm_vm_bugged()
897 kvm_vm_dead(kvm); in kvm_vm_bugged()
901 #define KVM_BUG(cond, kvm, fmt...) \ argument
905 if (WARN_ONCE(__ret && !(kvm)->vm_bugged, fmt)) \
906 kvm_vm_bugged(kvm); \
910 #define KVM_BUG_ON(cond, kvm) \ argument
914 if (WARN_ON_ONCE(__ret && !(kvm)->vm_bugged)) \
915 kvm_vm_bugged(kvm); \
927 #define KVM_BUG_ON_DATA_CORRUPTION(cond, kvm) \ argument
933 else if (WARN_ON_ONCE(__ret && !(kvm)->vm_bugged)) \
934 kvm_vm_bugged(kvm); \
944 vcpu->____srcu_idx = srcu_read_lock(&vcpu->kvm->srcu); in kvm_vcpu_srcu_read_lock()
949 srcu_read_unlock(&vcpu->kvm->srcu, vcpu->____srcu_idx); in kvm_vcpu_srcu_read_unlock()
957 static inline bool kvm_dirty_log_manual_protect_and_init_set(struct kvm *kvm) in kvm_dirty_log_manual_protect_and_init_set() argument
959 return !!(kvm->manual_dirty_log_protect & KVM_DIRTY_LOG_INITIALLY_SET); in kvm_dirty_log_manual_protect_and_init_set()
962 static inline struct kvm_io_bus *kvm_get_bus(struct kvm *kvm, enum kvm_bus idx) in kvm_get_bus() argument
964 return srcu_dereference_check(kvm->buses[idx], &kvm->srcu, in kvm_get_bus()
965 lockdep_is_held(&kvm->slots_lock) || in kvm_get_bus()
966 !refcount_read(&kvm->users_count)); in kvm_get_bus()
969 static inline struct kvm_vcpu *kvm_get_vcpu(struct kvm *kvm, int i) in kvm_get_vcpu() argument
971 int num_vcpus = atomic_read(&kvm->online_vcpus); in kvm_get_vcpu()
976 return xa_load(&kvm->vcpu_array, i); in kvm_get_vcpu()
979 #define kvm_for_each_vcpu(idx, vcpup, kvm) \ argument
980 xa_for_each_range(&kvm->vcpu_array, idx, vcpup, 0, \
981 (atomic_read(&kvm->online_vcpus) - 1))
983 static inline struct kvm_vcpu *kvm_get_vcpu_by_id(struct kvm *kvm, int id) in kvm_get_vcpu_by_id() argument
991 vcpu = kvm_get_vcpu(kvm, id); in kvm_get_vcpu_by_id()
994 kvm_for_each_vcpu(i, vcpu, kvm) in kvm_get_vcpu_by_id()
1000 void kvm_destroy_vcpus(struct kvm *kvm);
1006 void kvm_arch_post_irq_ack_notifier_list_update(struct kvm *kvm);
1007 void kvm_arch_post_irq_routing_update(struct kvm *kvm);
1009 static inline void kvm_arch_post_irq_ack_notifier_list_update(struct kvm *kvm) in kvm_arch_post_irq_ack_notifier_list_update() argument
1012 static inline void kvm_arch_post_irq_routing_update(struct kvm *kvm) in kvm_arch_post_irq_routing_update() argument
1033 void kvm_get_kvm(struct kvm *kvm);
1034 bool kvm_get_kvm_safe(struct kvm *kvm);
1035 void kvm_put_kvm(struct kvm *kvm);
1037 void kvm_put_kvm_no_destroy(struct kvm *kvm);
1039 static inline struct kvm_memslots *__kvm_memslots(struct kvm *kvm, int as_id) in __kvm_memslots() argument
1042 return srcu_dereference_check(kvm->memslots[as_id], &kvm->srcu, in __kvm_memslots()
1043 lockdep_is_held(&kvm->slots_lock) || in __kvm_memslots()
1044 !refcount_read(&kvm->users_count)); in __kvm_memslots()
1047 static inline struct kvm_memslots *kvm_memslots(struct kvm *kvm) in kvm_memslots() argument
1049 return __kvm_memslots(kvm, 0); in kvm_memslots()
1056 return __kvm_memslots(vcpu->kvm, as_id); in kvm_vcpu_memslots()
1064 bool kvm_are_all_memslots_empty(struct kvm *kvm);
1197 int kvm_set_memory_region(struct kvm *kvm,
1199 int __kvm_set_memory_region(struct kvm *kvm,
1201 void kvm_arch_free_memslot(struct kvm *kvm, struct kvm_memory_slot *slot);
1202 void kvm_arch_memslots_updated(struct kvm *kvm, u64 gen);
1203 int kvm_arch_prepare_memory_region(struct kvm *kvm,
1207 void kvm_arch_commit_memory_region(struct kvm *kvm,
1212 void kvm_arch_flush_shadow_all(struct kvm *kvm);
1214 void kvm_arch_flush_shadow_memslot(struct kvm *kvm,
1220 struct page *gfn_to_page(struct kvm *kvm, gfn_t gfn);
1221 unsigned long gfn_to_hva(struct kvm *kvm, gfn_t gfn);
1222 unsigned long gfn_to_hva_prot(struct kvm *kvm, gfn_t gfn, bool *writable);
1229 kvm_pfn_t gfn_to_pfn(struct kvm *kvm, gfn_t gfn);
1230 kvm_pfn_t gfn_to_pfn_prot(struct kvm *kvm, gfn_t gfn, bool write_fault,
1244 int kvm_read_guest_page(struct kvm *kvm, gfn_t gfn, void *data, int offset,
1246 int kvm_read_guest(struct kvm *kvm, gpa_t gpa, void *data, unsigned long len);
1247 int kvm_read_guest_cached(struct kvm *kvm, struct gfn_to_hva_cache *ghc,
1249 int kvm_read_guest_offset_cached(struct kvm *kvm, struct gfn_to_hva_cache *ghc,
1252 int kvm_write_guest_page(struct kvm *kvm, gfn_t gfn, const void *data,
1254 int kvm_write_guest(struct kvm *kvm, gpa_t gpa, const void *data,
1256 int kvm_write_guest_cached(struct kvm *kvm, struct gfn_to_hva_cache *ghc,
1258 int kvm_write_guest_offset_cached(struct kvm *kvm, struct gfn_to_hva_cache *ghc,
1261 int kvm_gfn_to_hva_cache_init(struct kvm *kvm, struct gfn_to_hva_cache *ghc,
1264 #define __kvm_get_guest(kvm, gfn, offset, v) \ argument
1266 unsigned long __addr = gfn_to_hva(kvm, gfn); \
1275 #define kvm_get_guest(kvm, gpa, v) \ argument
1278 struct kvm *__kvm = kvm; \
1284 #define __kvm_put_guest(kvm, gfn, offset, v) \ argument
1286 unsigned long __addr = gfn_to_hva(kvm, gfn); \
1293 mark_page_dirty(kvm, gfn); \
1297 #define kvm_put_guest(kvm, gpa, v) \ argument
1300 struct kvm *__kvm = kvm; \
1306 int kvm_clear_guest(struct kvm *kvm, gpa_t gpa, unsigned long len);
1307 struct kvm_memory_slot *gfn_to_memslot(struct kvm *kvm, gfn_t gfn);
1308 bool kvm_is_visible_gfn(struct kvm *kvm, gfn_t gfn);
1311 void mark_page_dirty_in_slot(struct kvm *kvm, const struct kvm_memory_slot *memslot, gfn_t gfn);
1312 void mark_page_dirty(struct kvm *kvm, gfn_t gfn);
1342 void kvm_gpc_init(struct gfn_to_pfn_cache *gpc, struct kvm *kvm);
1446 void kvm_flush_remote_tlbs(struct kvm *kvm);
1447 void kvm_flush_remote_tlbs_range(struct kvm *kvm, gfn_t gfn, u64 nr_pages);
1448 void kvm_flush_remote_tlbs_memslot(struct kvm *kvm,
1459 void kvm_mmu_invalidate_begin(struct kvm *kvm);
1460 void kvm_mmu_invalidate_range_add(struct kvm *kvm, gfn_t start, gfn_t end);
1461 void kvm_mmu_invalidate_end(struct kvm *kvm);
1462 bool kvm_mmu_unmap_gfn_range(struct kvm *kvm, struct kvm_gfn_range *range);
1470 int kvm_vm_ioctl_check_extension(struct kvm *kvm, long ext);
1472 void kvm_arch_mmu_enable_log_dirty_pt_masked(struct kvm *kvm,
1476 void kvm_arch_sync_dirty_log(struct kvm *kvm, struct kvm_memory_slot *memslot);
1479 int kvm_vm_ioctl_get_dirty_log(struct kvm *kvm, struct kvm_dirty_log *log);
1480 int kvm_get_dirty_log(struct kvm *kvm, struct kvm_dirty_log *log,
1484 int kvm_vm_ioctl_irq_line(struct kvm *kvm, struct kvm_irq_level *irq_level,
1486 int kvm_vm_ioctl_enable_cap(struct kvm *kvm,
1514 int kvm_arch_vcpu_precreate(struct kvm *kvm, unsigned int id);
1520 int kvm_arch_pm_notifier(struct kvm *kvm, unsigned long state);
1553 int kvm_arch_post_init_vm(struct kvm *kvm);
1554 void kvm_arch_pre_destroy_vm(struct kvm *kvm);
1555 void kvm_arch_create_vm_debugfs(struct kvm *kvm);
1562 static inline struct kvm *kvm_arch_alloc_vm(void) in kvm_arch_alloc_vm()
1564 return kzalloc(sizeof(struct kvm), GFP_KERNEL_ACCOUNT); in kvm_arch_alloc_vm()
1568 static inline void __kvm_arch_free_vm(struct kvm *kvm) in __kvm_arch_free_vm() argument
1570 kvfree(kvm); in __kvm_arch_free_vm()
1574 static inline void kvm_arch_free_vm(struct kvm *kvm) in kvm_arch_free_vm() argument
1576 __kvm_arch_free_vm(kvm); in kvm_arch_free_vm()
1581 static inline int kvm_arch_flush_remote_tlbs(struct kvm *kvm) in kvm_arch_flush_remote_tlbs() argument
1586 int kvm_arch_flush_remote_tlbs(struct kvm *kvm);
1590 static inline int kvm_arch_flush_remote_tlbs_range(struct kvm *kvm, in kvm_arch_flush_remote_tlbs_range() argument
1596 int kvm_arch_flush_remote_tlbs_range(struct kvm *kvm, gfn_t gfn, u64 nr_pages);
1600 void kvm_arch_register_noncoherent_dma(struct kvm *kvm);
1601 void kvm_arch_unregister_noncoherent_dma(struct kvm *kvm);
1602 bool kvm_arch_has_noncoherent_dma(struct kvm *kvm);
1604 static inline void kvm_arch_register_noncoherent_dma(struct kvm *kvm) in kvm_arch_register_noncoherent_dma() argument
1608 static inline void kvm_arch_unregister_noncoherent_dma(struct kvm *kvm) in kvm_arch_unregister_noncoherent_dma() argument
1612 static inline bool kvm_arch_has_noncoherent_dma(struct kvm *kvm) in kvm_arch_has_noncoherent_dma() argument
1618 void kvm_arch_start_assignment(struct kvm *kvm);
1619 void kvm_arch_end_assignment(struct kvm *kvm);
1620 bool kvm_arch_has_assigned_device(struct kvm *kvm);
1622 static inline void kvm_arch_start_assignment(struct kvm *kvm) in kvm_arch_start_assignment() argument
1626 static inline void kvm_arch_end_assignment(struct kvm *kvm) in kvm_arch_end_assignment() argument
1630 static __always_inline bool kvm_arch_has_assigned_device(struct kvm *kvm) in kvm_arch_has_assigned_device() argument
1665 bool kvm_arch_intc_initialized(struct kvm *kvm);
1667 static inline bool kvm_arch_intc_initialized(struct kvm *kvm) in kvm_arch_intc_initialized() argument
1683 int kvm_arch_init_vm(struct kvm *kvm, unsigned long type);
1684 void kvm_arch_destroy_vm(struct kvm *kvm);
1685 void kvm_arch_sync_events(struct kvm *kvm);
1698 int kvm_irq_map_gsi(struct kvm *kvm,
1700 int kvm_irq_map_chip_pin(struct kvm *kvm, unsigned irqchip, unsigned pin);
1702 int kvm_set_irq(struct kvm *kvm, int irq_source_id, u32 irq, int level,
1704 int kvm_set_msi(struct kvm_kernel_irq_routing_entry *irq_entry, struct kvm *kvm,
1707 struct kvm *kvm, int irq_source_id,
1709 bool kvm_irq_has_notifier(struct kvm *kvm, unsigned irqchip, unsigned pin);
1710 void kvm_notify_acked_gsi(struct kvm *kvm, int gsi);
1711 void kvm_notify_acked_irq(struct kvm *kvm, unsigned irqchip, unsigned pin);
1712 void kvm_register_irq_ack_notifier(struct kvm *kvm,
1714 void kvm_unregister_irq_ack_notifier(struct kvm *kvm,
1716 int kvm_request_irq_source_id(struct kvm *kvm);
1717 void kvm_free_irq_source_id(struct kvm *kvm, int irq_source_id);
1718 bool kvm_arch_irqfd_allowed(struct kvm *kvm, struct kvm_irqfd *args);
1808 static inline int memslot_id(struct kvm *kvm, gfn_t gfn) in memslot_id() argument
1810 return gfn_to_memslot(kvm, gfn)->id; in memslot_id()
1836 static inline bool kvm_is_gpa_in_memslot(struct kvm *kvm, gpa_t gpa) in kvm_is_gpa_in_memslot() argument
1838 unsigned long hva = gfn_to_hva(kvm, gpa_to_gfn(gpa)); in kvm_is_gpa_in_memslot()
1850 mark_page_dirty_in_slot(gpc->kvm, gpc->memslot, gpa_to_gfn(gpc->gpa)); in kvm_gpc_mark_dirty_in_slot()
1859 struct kvm *kvm; member
2036 static inline int mmu_invalidate_retry(struct kvm *kvm, unsigned long mmu_seq) in mmu_invalidate_retry() argument
2038 if (unlikely(kvm->mmu_invalidate_in_progress)) in mmu_invalidate_retry()
2053 if (kvm->mmu_invalidate_seq != mmu_seq) in mmu_invalidate_retry()
2058 static inline int mmu_invalidate_retry_gfn(struct kvm *kvm, in mmu_invalidate_retry_gfn() argument
2062 lockdep_assert_held(&kvm->mmu_lock); in mmu_invalidate_retry_gfn()
2069 if (unlikely(kvm->mmu_invalidate_in_progress)) { in mmu_invalidate_retry_gfn()
2074 if (WARN_ON_ONCE(kvm->mmu_invalidate_range_start == INVALID_GPA || in mmu_invalidate_retry_gfn()
2075 kvm->mmu_invalidate_range_end == INVALID_GPA)) in mmu_invalidate_retry_gfn()
2078 if (gfn >= kvm->mmu_invalidate_range_start && in mmu_invalidate_retry_gfn()
2079 gfn < kvm->mmu_invalidate_range_end) in mmu_invalidate_retry_gfn()
2083 if (kvm->mmu_invalidate_seq != mmu_seq) in mmu_invalidate_retry_gfn()
2094 static inline bool mmu_invalidate_retry_gfn_unsafe(struct kvm *kvm, in mmu_invalidate_retry_gfn_unsafe() argument
2106 if (unlikely(READ_ONCE(kvm->mmu_invalidate_in_progress)) && in mmu_invalidate_retry_gfn_unsafe()
2107 gfn >= kvm->mmu_invalidate_range_start && in mmu_invalidate_retry_gfn_unsafe()
2108 gfn < kvm->mmu_invalidate_range_end) in mmu_invalidate_retry_gfn_unsafe()
2111 return READ_ONCE(kvm->mmu_invalidate_seq) != mmu_seq; in mmu_invalidate_retry_gfn_unsafe()
2119 bool kvm_arch_can_set_irq_routing(struct kvm *kvm);
2120 int kvm_set_irq_routing(struct kvm *kvm,
2124 int kvm_init_irq_routing(struct kvm *kvm);
2125 int kvm_set_routing_entry(struct kvm *kvm,
2128 void kvm_free_irq_routing(struct kvm *kvm);
2132 static inline void kvm_free_irq_routing(struct kvm *kvm) {} in kvm_free_irq_routing() argument
2134 static inline int kvm_init_irq_routing(struct kvm *kvm) in kvm_init_irq_routing() argument
2141 int kvm_send_userspace_msi(struct kvm *kvm, struct kvm_msi *msi);
2143 void kvm_eventfd_init(struct kvm *kvm);
2144 int kvm_ioeventfd(struct kvm *kvm, struct kvm_ioeventfd *args);
2147 int kvm_irqfd(struct kvm *kvm, struct kvm_irqfd *args);
2148 void kvm_irqfd_release(struct kvm *kvm);
2149 bool kvm_notify_irqfd_resampler(struct kvm *kvm,
2152 void kvm_irq_routing_update(struct kvm *);
2154 static inline int kvm_irqfd(struct kvm *kvm, struct kvm_irqfd *args) in kvm_irqfd() argument
2159 static inline void kvm_irqfd_release(struct kvm *kvm) {} in kvm_irqfd_release() argument
2161 static inline bool kvm_notify_irqfd_resampler(struct kvm *kvm, in kvm_notify_irqfd_resampler() argument
2169 void kvm_arch_irq_routing_update(struct kvm *kvm);
2236 struct kvm *kvm; member
2332 int kvm_arch_update_irqfd_routing(struct kvm *kvm, unsigned int host_irq,
2374 void kvm_arch_guest_memory_reclaimed(struct kvm *kvm);
2385 typedef int (*kvm_vm_thread_fn_t)(struct kvm *kvm, uintptr_t data);
2387 int kvm_vm_create_worker_thread(struct kvm *kvm, kvm_vm_thread_fn_t thread_fn,
2438 static inline unsigned long kvm_get_memory_attributes(struct kvm *kvm, gfn_t gfn) in kvm_get_memory_attributes() argument
2440 return xa_to_value(xa_load(&kvm->mem_attr_array, gfn)); in kvm_get_memory_attributes()
2443 bool kvm_range_has_memory_attributes(struct kvm *kvm, gfn_t start, gfn_t end,
2445 bool kvm_arch_pre_set_memory_attributes(struct kvm *kvm,
2447 bool kvm_arch_post_set_memory_attributes(struct kvm *kvm,
2450 static inline bool kvm_mem_is_private(struct kvm *kvm, gfn_t gfn) in kvm_mem_is_private() argument
2453 kvm_get_memory_attributes(kvm, gfn) & KVM_MEMORY_ATTRIBUTE_PRIVATE; in kvm_mem_is_private()
2456 static inline bool kvm_mem_is_private(struct kvm *kvm, gfn_t gfn) in kvm_mem_is_private() argument
2463 int kvm_gmem_get_pfn(struct kvm *kvm, struct kvm_memory_slot *slot,
2466 static inline int kvm_gmem_get_pfn(struct kvm *kvm, in kvm_gmem_get_pfn() argument
2470 KVM_BUG_ON(1, kvm); in kvm_gmem_get_pfn()
2476 int kvm_arch_gmem_prepare(struct kvm *kvm, gfn_t gfn, kvm_pfn_t pfn, int max_order);
2501 typedef int (*kvm_gmem_populate_cb)(struct kvm *kvm, gfn_t gfn, kvm_pfn_t pfn,
2504 long kvm_gmem_populate(struct kvm *kvm, gfn_t gfn, void __user *src, long npages,