aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/kvm_host.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/kvm_host.h')
-rw-r--r--include/linux/kvm_host.h39
1 files changed, 35 insertions, 4 deletions
diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
index d52623199978..900c76337e8f 100644
--- a/include/linux/kvm_host.h
+++ b/include/linux/kvm_host.h
@@ -14,6 +14,7 @@
14#include <linux/signal.h> 14#include <linux/signal.h>
15#include <linux/sched.h> 15#include <linux/sched.h>
16#include <linux/mm.h> 16#include <linux/mm.h>
17#include <linux/mmu_notifier.h>
17#include <linux/preempt.h> 18#include <linux/preempt.h>
18#include <linux/msi.h> 19#include <linux/msi.h>
19#include <linux/slab.h> 20#include <linux/slab.h>
@@ -50,6 +51,9 @@
50#define KVM_REQ_APF_HALT 12 51#define KVM_REQ_APF_HALT 12
51#define KVM_REQ_STEAL_UPDATE 13 52#define KVM_REQ_STEAL_UPDATE 13
52#define KVM_REQ_NMI 14 53#define KVM_REQ_NMI 14
54#define KVM_REQ_IMMEDIATE_EXIT 15
55#define KVM_REQ_PMU 16
56#define KVM_REQ_PMI 17
53 57
54#define KVM_USERSPACE_IRQ_SOURCE_ID 0 58#define KVM_USERSPACE_IRQ_SOURCE_ID 0
55 59
@@ -179,6 +183,7 @@ struct kvm_memory_slot {
179 unsigned long *rmap; 183 unsigned long *rmap;
180 unsigned long *dirty_bitmap; 184 unsigned long *dirty_bitmap;
181 unsigned long *dirty_bitmap_head; 185 unsigned long *dirty_bitmap_head;
186 unsigned long nr_dirty_pages;
182 struct kvm_lpage_info *lpage_info[KVM_NR_PAGE_SIZES - 1]; 187 struct kvm_lpage_info *lpage_info[KVM_NR_PAGE_SIZES - 1];
183 unsigned long userspace_addr; 188 unsigned long userspace_addr;
184 int user_alloc; 189 int user_alloc;
@@ -224,11 +229,20 @@ struct kvm_irq_routing_table {};
224 229
225#endif 230#endif
226 231
232#ifndef KVM_MEM_SLOTS_NUM
233#define KVM_MEM_SLOTS_NUM (KVM_MEMORY_SLOTS + KVM_PRIVATE_MEM_SLOTS)
234#endif
235
236/*
237 * Note:
238 * memslots are not sorted by id anymore, please use id_to_memslot()
239 * to get the memslot by its id.
240 */
227struct kvm_memslots { 241struct kvm_memslots {
228 int nmemslots;
229 u64 generation; 242 u64 generation;
230 struct kvm_memory_slot memslots[KVM_MEMORY_SLOTS + 243 struct kvm_memory_slot memslots[KVM_MEM_SLOTS_NUM];
231 KVM_PRIVATE_MEM_SLOTS]; 244 /* The mapping table from slot id to the index in memslots[]. */
245 int id_to_index[KVM_MEM_SLOTS_NUM];
232}; 246};
233 247
234struct kvm { 248struct kvm {
@@ -239,7 +253,6 @@ struct kvm {
239 struct srcu_struct srcu; 253 struct srcu_struct srcu;
240#ifdef CONFIG_KVM_APIC_ARCHITECTURE 254#ifdef CONFIG_KVM_APIC_ARCHITECTURE
241 u32 bsp_vcpu_id; 255 u32 bsp_vcpu_id;
242 struct kvm_vcpu *bsp_vcpu;
243#endif 256#endif
244 struct kvm_vcpu *vcpus[KVM_MAX_VCPUS]; 257 struct kvm_vcpu *vcpus[KVM_MAX_VCPUS];
245 atomic_t online_vcpus; 258 atomic_t online_vcpus;
@@ -302,6 +315,11 @@ static inline struct kvm_vcpu *kvm_get_vcpu(struct kvm *kvm, int i)
302 (vcpup = kvm_get_vcpu(kvm, idx)) != NULL; \ 315 (vcpup = kvm_get_vcpu(kvm, idx)) != NULL; \
303 idx++) 316 idx++)
304 317
318#define kvm_for_each_memslot(memslot, slots) \
319 for (memslot = &slots->memslots[0]; \
320 memslot < slots->memslots + KVM_MEM_SLOTS_NUM && memslot->npages;\
321 memslot++)
322
305int kvm_vcpu_init(struct kvm_vcpu *vcpu, struct kvm *kvm, unsigned id); 323int kvm_vcpu_init(struct kvm_vcpu *vcpu, struct kvm *kvm, unsigned id);
306void kvm_vcpu_uninit(struct kvm_vcpu *vcpu); 324void kvm_vcpu_uninit(struct kvm_vcpu *vcpu);
307 325
@@ -314,6 +332,7 @@ void kvm_exit(void);
314 332
315void kvm_get_kvm(struct kvm *kvm); 333void kvm_get_kvm(struct kvm *kvm);
316void kvm_put_kvm(struct kvm *kvm); 334void kvm_put_kvm(struct kvm *kvm);
335void update_memslots(struct kvm_memslots *slots, struct kvm_memory_slot *new);
317 336
318static inline struct kvm_memslots *kvm_memslots(struct kvm *kvm) 337static inline struct kvm_memslots *kvm_memslots(struct kvm *kvm)
319{ 338{
@@ -322,6 +341,18 @@ static inline struct kvm_memslots *kvm_memslots(struct kvm *kvm)
322 || lockdep_is_held(&kvm->slots_lock)); 341 || lockdep_is_held(&kvm->slots_lock));
323} 342}
324 343
344static inline struct kvm_memory_slot *
345id_to_memslot(struct kvm_memslots *slots, int id)
346{
347 int index = slots->id_to_index[id];
348 struct kvm_memory_slot *slot;
349
350 slot = &slots->memslots[index];
351
352 WARN_ON(slot->id != id);
353 return slot;
354}
355
325#define HPA_MSB ((sizeof(hpa_t) * 8) - 1) 356#define HPA_MSB ((sizeof(hpa_t) * 8) - 1)
326#define HPA_ERR_MASK ((hpa_t)1 << HPA_MSB) 357#define HPA_ERR_MASK ((hpa_t)1 << HPA_MSB)
327static inline int is_error_hpa(hpa_t hpa) { return hpa >> HPA_MSB; } 358static inline int is_error_hpa(hpa_t hpa) { return hpa >> HPA_MSB; }