KVM: PPC: Add QPR registers
[safe/jmp/linux-2.6] / arch / powerpc / include / asm / kvm_host.h
index d4caa61..4b14dcd 100644 (file)
@@ -21,7 +21,8 @@
 #define __POWERPC_KVM_HOST_H__
 
 #include <linux/mutex.h>
-#include <linux/timer.h>
+#include <linux/hrtimer.h>
+#include <linux/interrupt.h>
 #include <linux/types.h>
 #include <linux/kvm_types.h>
 #include <asm/kvm_asm.h>
 #define KVM_COALESCED_MMIO_PAGE_OFFSET 1
 
 /* We don't currently support large pages. */
-#define KVM_PAGES_PER_HPAGE (1UL << 31)
+#define KVM_NR_PAGE_SIZES      1
+#define KVM_PAGES_PER_HPAGE(x) (1UL<<31)
+
+#define HPTEG_CACHE_NUM 1024
 
 struct kvm;
 struct kvm_run;
@@ -62,6 +66,17 @@ struct kvm_vcpu_stat {
        u32 dec_exits;
        u32 ext_intr_exits;
        u32 halt_wakeup;
+#ifdef CONFIG_PPC64
+       u32 pf_storage;
+       u32 pf_instruc;
+       u32 sp_storage;
+       u32 sp_instruc;
+       u32 queue_intr;
+       u32 ld;
+       u32 ld_slow;
+       u32 st;
+       u32 st_slow;
+#endif
 };
 
 enum kvm_exit_types {
@@ -108,20 +123,90 @@ struct kvmppc_exit_timing {
 struct kvm_arch {
 };
 
+struct kvmppc_pte {
+       u64 eaddr;
+       u64 vpage;
+       u64 raddr;
+       bool may_read;
+       bool may_write;
+       bool may_execute;
+};
+
+struct kvmppc_mmu {
+       /* book3s_64 only */
+       void (*slbmte)(struct kvm_vcpu *vcpu, u64 rb, u64 rs);
+       u64  (*slbmfee)(struct kvm_vcpu *vcpu, u64 slb_nr);
+       u64  (*slbmfev)(struct kvm_vcpu *vcpu, u64 slb_nr);
+       void (*slbie)(struct kvm_vcpu *vcpu, u64 slb_nr);
+       void (*slbia)(struct kvm_vcpu *vcpu);
+       /* book3s */
+       void (*mtsrin)(struct kvm_vcpu *vcpu, u32 srnum, ulong value);
+       u32  (*mfsrin)(struct kvm_vcpu *vcpu, u32 srnum);
+       int  (*xlate)(struct kvm_vcpu *vcpu, gva_t eaddr, struct kvmppc_pte *pte, bool data);
+       void (*reset_msr)(struct kvm_vcpu *vcpu);
+       void (*tlbie)(struct kvm_vcpu *vcpu, ulong addr, bool large);
+       int  (*esid_to_vsid)(struct kvm_vcpu *vcpu, u64 esid, u64 *vsid);
+       u64  (*ea_to_vp)(struct kvm_vcpu *vcpu, gva_t eaddr, bool data);
+       bool (*is_dcbz32)(struct kvm_vcpu *vcpu);
+};
+
+struct hpte_cache {
+       u64 host_va;
+       u64 pfn;
+       ulong slot;
+       struct kvmppc_pte pte;
+};
+
 struct kvm_vcpu_arch {
-       u32 host_stack;
+       ulong host_stack;
        u32 host_pid;
+#ifdef CONFIG_PPC64
+       ulong host_msr;
+       ulong host_r2;
+       void *host_retip;
+       ulong trampoline_lowmem;
+       ulong trampoline_enter;
+       ulong highmem_handler;
+       ulong rmcall;
+       ulong host_paca_phys;
+       struct kvmppc_mmu mmu;
+#endif
 
-       u64 fpr[32];
        ulong gpr[32];
 
+       u64 fpr[32];
+       u32 fpscr;
+
+#ifdef CONFIG_ALTIVEC
+       vector128 vr[32];
+       vector128 vscr;
+#endif
+
+#ifdef CONFIG_VSX
+       u64 vsr[32];
+#endif
+
+#ifdef CONFIG_PPC_BOOK3S
+       /* For Gekko paired singles */
+       u32 qpr[32];
+#endif
+
        ulong pc;
-       u32 cr;
        ulong ctr;
        ulong lr;
+
+#ifdef CONFIG_BOOKE
        ulong xer;
+       u32 cr;
+#endif
 
        ulong msr;
+#ifdef CONFIG_PPC64
+       ulong shadow_msr;
+       ulong shadow_srr1;
+       ulong hflags;
+       ulong guest_owned_ext;
+#endif
        u32 mmucr;
        ulong sprg0;
        ulong sprg1;
@@ -148,6 +233,7 @@ struct kvm_vcpu_arch {
        u32 ivor[64];
        ulong ivpr;
        u32 pir;
+       u32 pvr;
 
        u32 shadow_pid;
        u32 pid;
@@ -173,8 +259,13 @@ struct kvm_vcpu_arch {
 #endif
 
        u32 last_inst;
+#ifdef CONFIG_PPC64
+       ulong fault_dsisr;
+#endif
        ulong fault_dear;
        ulong fault_esr;
+       ulong queued_dear;
+       ulong queued_esr;
        gpa_t paddr_accessed;
 
        u8 io_gpr; /* GPR used as IO source/target */
@@ -184,8 +275,15 @@ struct kvm_vcpu_arch {
 
        u32 cpr0_cfgaddr; /* holds the last set cpr0_cfgaddr */
 
-       struct timer_list dec_timer;
+       struct hrtimer dec_timer;
+       struct tasklet_struct tasklet;
+       u64 dec_jiffies;
        unsigned long pending_exceptions;
+
+#ifdef CONFIG_PPC64
+       struct hpte_cache hpte_cache[HPTEG_CACHE_NUM];
+       int hpte_cache_offset;
+#endif
 };
 
 #endif /* __POWERPC_KVM_HOST_H__ */