Merge tag 'kvmarm-5.5' of git://git.kernel.org/pub/scm/linux/kernel/git/kvmarm/kvmarm...
[sfrench/cifs-2.6.git] / include / linux / kvm_host.h
index 719fc3e15ea4e0181f314718951f9ff4fc2505c6..7a61ab50ca62446ae343094f0ca34e003b4fc6ab 100644 (file)
@@ -266,7 +266,8 @@ struct kvm_vcpu {
        struct preempt_notifier preempt_notifier;
 #endif
        int cpu;
-       int vcpu_id;
+       int vcpu_id; /* id given by userspace at creation */
+       int vcpu_idx; /* index in kvm->vcpus array */
        int srcu_idx;
        int mode;
        u64 requests;
@@ -278,7 +279,6 @@ struct kvm_vcpu {
        struct mutex mutex;
        struct kvm_run *run;
 
-       int guest_xcr0_loaded;
        struct swait_queue_head wq;
        struct pid __rcu *pid;
        int sigset_active;
@@ -571,13 +571,7 @@ static inline struct kvm_vcpu *kvm_get_vcpu_by_id(struct kvm *kvm, int id)
 
 static inline int kvm_vcpu_get_idx(struct kvm_vcpu *vcpu)
 {
-       struct kvm_vcpu *tmp;
-       int idx;
-
-       kvm_for_each_vcpu(idx, tmp, vcpu->kvm)
-               if (tmp == vcpu)
-                       return idx;
-       BUG();
+       return vcpu->vcpu_idx;
 }
 
 #define kvm_for_each_memslot(memslot, slots)   \
@@ -622,6 +616,7 @@ void kvm_exit(void);
 
 void kvm_get_kvm(struct kvm *kvm);
 void kvm_put_kvm(struct kvm *kvm);
+void kvm_put_kvm_no_destroy(struct kvm *kvm);
 
 static inline struct kvm_memslots *__kvm_memslots(struct kvm *kvm, int as_id)
 {
@@ -746,6 +741,28 @@ int kvm_write_guest_offset_cached(struct kvm *kvm, struct gfn_to_hva_cache *ghc,
                                  unsigned long len);
 int kvm_gfn_to_hva_cache_init(struct kvm *kvm, struct gfn_to_hva_cache *ghc,
                              gpa_t gpa, unsigned long len);
+
+#define __kvm_put_guest(kvm, gfn, offset, value, type)                 \
+({                                                                     \
+       unsigned long __addr = gfn_to_hva(kvm, gfn);                    \
+       type __user *__uaddr = (type __user *)(__addr + offset);        \
+       int __ret = -EFAULT;                                            \
+                                                                       \
+       if (!kvm_is_error_hva(__addr))                                  \
+               __ret = put_user(value, __uaddr);                       \
+       if (!__ret)                                                     \
+               mark_page_dirty(kvm, gfn);                              \
+       __ret;                                                          \
+})
+
+#define kvm_put_guest(kvm, gpa, value, type)                           \
+({                                                                     \
+       gpa_t __gpa = gpa;                                              \
+       struct kvm *__kvm = kvm;                                        \
+       __kvm_put_guest(__kvm, __gpa >> PAGE_SHIFT,                     \
+                       offset_in_page(__gpa), (value), type);          \
+})
+
 int kvm_clear_guest_page(struct kvm *kvm, gfn_t gfn, int offset, int len);
 int kvm_clear_guest(struct kvm *kvm, gpa_t gpa, unsigned long len);
 struct kvm_memory_slot *gfn_to_memslot(struct kvm *kvm, gfn_t gfn);
@@ -791,6 +808,8 @@ void kvm_reload_remote_mmus(struct kvm *kvm);
 bool kvm_make_vcpus_request_mask(struct kvm *kvm, unsigned int req,
                                 unsigned long *vcpu_bitmap, cpumask_var_t tmp);
 bool kvm_make_all_cpus_request(struct kvm *kvm, unsigned int req);
+bool kvm_make_cpus_request_mask(struct kvm *kvm, unsigned int req,
+                               unsigned long *vcpu_bitmap);
 
 long kvm_arch_dev_ioctl(struct file *filp,
                        unsigned int ioctl, unsigned long arg);
@@ -1240,7 +1259,7 @@ extern unsigned int halt_poll_ns_grow_start;
 extern unsigned int halt_poll_ns_shrink;
 
 struct kvm_device {
-       struct kvm_device_ops *ops;
+       const struct kvm_device_ops *ops;
        struct kvm *kvm;
        void *private;
        struct list_head vm_node;
@@ -1293,7 +1312,7 @@ struct kvm_device_ops {
 void kvm_device_get(struct kvm_device *dev);
 void kvm_device_put(struct kvm_device *dev);
 struct kvm_device *kvm_device_from_filp(struct file *filp);
-int kvm_register_device_ops(struct kvm_device_ops *ops, u32 type);
+int kvm_register_device_ops(const struct kvm_device_ops *ops, u32 type);
 void kvm_unregister_device_ops(u32 type);
 
 extern struct kvm_device_ops kvm_mpic_ops;