KVM: SVM: Trap access to the cr8 register
[safe/jmp/linux-2.6] / drivers / kvm / kvm.h
index ccba958..0d3555b 100644 (file)
@@ -20,6 +20,8 @@
 #include <linux/kvm.h>
 #include <linux/kvm_para.h>
 
+#include "types.h"
+
 #define KVM_MAX_VCPUS 4
 #define KVM_ALIAS_SLOTS 4
 #define KVM_MEMORY_SLOTS 8
  */
 #define KVM_REQ_TLB_FLUSH          0
 
-/*
- * Address types:
- *
- *  gva - guest virtual address
- *  gpa - guest physical address
- *  gfn - guest frame number
- *  hva - host virtual address
- *  hpa - host physical address
- *  hfn - host frame number
- */
-
-typedef unsigned long  gva_t;
-typedef u64            gpa_t;
-typedef unsigned long  gfn_t;
-
-typedef unsigned long  hva_t;
-typedef u64            hpa_t;
-typedef unsigned long  hfn_t;
-
 #define NR_PTE_CHAIN_ENTRIES 5
 
 struct kvm_pte_chain {
@@ -135,15 +118,15 @@ struct kvm_mmu {
 
 #define KVM_NR_MEM_OBJS 40
 
+/*
+ * We don't want allocation failures within the mmu code, so we preallocate
+ * enough memory for a single page fault in a cache.
+ */
 struct kvm_mmu_memory_cache {
        int nobjs;
        void *objects[KVM_NR_MEM_OBJS];
 };
 
-/*
- * We don't want allocation failures within the mmu code, so we preallocate
- * enough memory for a single page fault in a cache.
- */
 struct kvm_guest_debug {
        int enabled;
        unsigned long bp[4];
@@ -185,48 +168,6 @@ struct kvm_vcpu_stat {
        u32 insn_emulation_fail;
 };
 
-struct kvm_io_device {
-       void (*read)(struct kvm_io_device *this,
-                    gpa_t addr,
-                    int len,
-                    void *val);
-       void (*write)(struct kvm_io_device *this,
-                     gpa_t addr,
-                     int len,
-                     const void *val);
-       int (*in_range)(struct kvm_io_device *this, gpa_t addr);
-       void (*destructor)(struct kvm_io_device *this);
-
-       void             *private;
-};
-
-static inline void kvm_iodevice_read(struct kvm_io_device *dev,
-                                    gpa_t addr,
-                                    int len,
-                                    void *val)
-{
-       dev->read(dev, addr, len, val);
-}
-
-static inline void kvm_iodevice_write(struct kvm_io_device *dev,
-                                     gpa_t addr,
-                                     int len,
-                                     const void *val)
-{
-       dev->write(dev, addr, len, val);
-}
-
-static inline int kvm_iodevice_inrange(struct kvm_io_device *dev, gpa_t addr)
-{
-       return dev->in_range(dev, addr);
-}
-
-static inline void kvm_iodevice_destructor(struct kvm_io_device *dev)
-{
-       if (dev->destructor)
-               dev->destructor(dev);
-}
-
 /*
  * It would be nice to use something smarter than a linear search, TBD...
  * Thankfully we dont expect many devices to register (famous last words :),
@@ -300,10 +241,12 @@ struct kvm_vm_stat {
        u32 mmu_pde_zapped;
        u32 mmu_flooded;
        u32 mmu_recycled;
+       u32 remote_tlb_flush;
 };
 
 struct kvm {
        struct mutex lock; /* protects everything except vcpus */
+       struct mm_struct *mm; /* userspace tied to this vm */
        int naliases;
        struct kvm_mem_alias aliases[KVM_ALIAS_SLOTS];
        int nmemslots;
@@ -345,11 +288,6 @@ static inline int irqchip_in_kernel(struct kvm *kvm)
        return pic_irqchip(kvm) != NULL;
 }
 
-struct descriptor_table {
-       u16 limit;
-       unsigned long base;
-} __attribute__((packed));
-
 /* The guest did something we don't support. */
 #define pr_unimpl(vcpu, fmt, ...)                                      \
  do {                                                                  \
@@ -374,11 +312,9 @@ int kvm_init(void *opaque, unsigned int vcpu_size,
                  struct module *module);
 void kvm_exit(void);
 
-hpa_t gpa_to_hpa(struct kvm *kvm, gpa_t gpa);
 #define HPA_MSB ((sizeof(hpa_t) * 8) - 1)
 #define HPA_ERR_MASK ((hpa_t)1 << HPA_MSB)
 static inline int is_error_hpa(hpa_t hpa) { return hpa >> HPA_MSB; }
-hpa_t gva_to_hpa(struct kvm_vcpu *vcpu, gva_t gva);
 struct page *gva_to_page(struct kvm_vcpu *vcpu, gva_t gva);
 
 extern struct page *bad_page;
@@ -391,9 +327,14 @@ int kvm_set_memory_region(struct kvm *kvm,
 int __kvm_set_memory_region(struct kvm *kvm,
                            struct kvm_userspace_memory_region *mem,
                            int user_alloc);
+int kvm_arch_set_memory_region(struct kvm *kvm,
+                               struct kvm_userspace_memory_region *mem,
+                               struct kvm_memory_slot old,
+                               int user_alloc);
 gfn_t unalias_gfn(struct kvm *kvm, gfn_t gfn);
 struct page *gfn_to_page(struct kvm *kvm, gfn_t gfn);
-void kvm_release_page(struct page *page);
+void kvm_release_page_clean(struct page *page);
+void kvm_release_page_dirty(struct page *page);
 int kvm_read_guest_page(struct kvm *kvm, gfn_t gfn, void *data, int offset,
                        int len);
 int kvm_read_guest(struct kvm *kvm, gpa_t gpa, void *data, unsigned long len);
@@ -461,6 +402,7 @@ void kvm_arch_vcpu_free(struct kvm_vcpu *vcpu);
 void kvm_arch_vcpu_load(struct kvm_vcpu *vcpu, int cpu);
 void kvm_arch_vcpu_put(struct kvm_vcpu *vcpu);
 struct kvm_vcpu *kvm_arch_vcpu_create(struct kvm *kvm, unsigned int id);
+int kvm_arch_vcpu_setup(struct kvm_vcpu *vcpu);
 void kvm_arch_vcpu_destroy(struct kvm_vcpu *vcpu);
 
 int kvm_arch_vcpu_reset(struct kvm_vcpu *vcpu);
@@ -492,6 +434,10 @@ static inline int memslot_id(struct kvm *kvm, struct kvm_memory_slot *slot)
        return slot - kvm->memslots;
 }
 
+static inline gpa_t gfn_to_gpa(gfn_t gfn)
+{
+       return (gpa_t)gfn << PAGE_SHIFT;
+}
 
 enum kvm_stat_kind {
        KVM_STAT_VM,
@@ -506,4 +452,8 @@ struct kvm_stats_debugfs_item {
 };
 extern struct kvm_stats_debugfs_item debugfs_entries[];
 
+#if defined(CONFIG_X86)
+#include "x86.h"
+#endif
+
 #endif