163e158a0SMatt Evans /*
263e158a0SMatt Evans * PPC64 cpu-specific definitions
363e158a0SMatt Evans *
463e158a0SMatt Evans * Copyright 2011 Matt Evans <matt@ozlabs.org>, IBM Corporation.
563e158a0SMatt Evans *
663e158a0SMatt Evans * This program is free software; you can redistribute it and/or modify it
763e158a0SMatt Evans * under the terms of the GNU General Public License version 2 as published
863e158a0SMatt Evans * by the Free Software Foundation.
963e158a0SMatt Evans */
1063e158a0SMatt Evans
1163e158a0SMatt Evans #ifndef KVM__KVM_CPU_ARCH_H
1263e158a0SMatt Evans #define KVM__KVM_CPU_ARCH_H
1363e158a0SMatt Evans
1463e158a0SMatt Evans /* Architecture-specific kvm_cpu definitions. */
1563e158a0SMatt Evans
1663e158a0SMatt Evans #include <linux/kvm.h> /* for struct kvm_regs */
175e8d833bSMatt Evans #include <stdbool.h>
1863e158a0SMatt Evans #include <pthread.h>
1963e158a0SMatt Evans
20e6655b75SMichael Ellerman #define MSR_SF (1ULL<<63)
21e6655b75SMichael Ellerman #define MSR_HV (1ULL<<60)
22e6655b75SMichael Ellerman #define MSR_VEC (1ULL<<25)
23e6655b75SMichael Ellerman #define MSR_VSX (1ULL<<23)
24e6655b75SMichael Ellerman #define MSR_POW (1ULL<<18)
25e6655b75SMichael Ellerman #define MSR_EE (1ULL<<15)
26e6655b75SMichael Ellerman #define MSR_PR (1ULL<<14)
27e6655b75SMichael Ellerman #define MSR_FP (1ULL<<13)
28e6655b75SMichael Ellerman #define MSR_ME (1ULL<<12)
29e6655b75SMichael Ellerman #define MSR_FE0 (1ULL<<11)
30e6655b75SMichael Ellerman #define MSR_SE (1ULL<<10)
31e6655b75SMichael Ellerman #define MSR_BE (1ULL<<9)
32e6655b75SMichael Ellerman #define MSR_FE1 (1ULL<<8)
33e6655b75SMichael Ellerman #define MSR_IR (1ULL<<5)
34e6655b75SMichael Ellerman #define MSR_DR (1ULL<<4)
35e6655b75SMichael Ellerman #define MSR_PMM (1ULL<<2)
36e6655b75SMichael Ellerman #define MSR_RI (1ULL<<1)
37e6655b75SMichael Ellerman #define MSR_LE (1ULL<<0)
3863e158a0SMatt Evans
39f17e5a37SMatt Evans #define POWER7_EXT_IRQ 0
40f17e5a37SMatt Evans
41*015785d4SBalbir Singh #define LPCR_ILE (1 << (63-38))
42*015785d4SBalbir Singh
4363e158a0SMatt Evans struct kvm;
4463e158a0SMatt Evans
4563e158a0SMatt Evans struct kvm_cpu {
4663e158a0SMatt Evans pthread_t thread; /* VCPU thread */
4763e158a0SMatt Evans
4863e158a0SMatt Evans unsigned long cpu_id;
4963e158a0SMatt Evans
5063e158a0SMatt Evans struct kvm *kvm; /* parent KVM */
5163e158a0SMatt Evans int vcpu_fd; /* For VCPU ioctls() */
5263e158a0SMatt Evans struct kvm_run *kvm_run;
53e300a5eeSMichael Ellerman struct kvm_cpu_task *task;
5463e158a0SMatt Evans
5563e158a0SMatt Evans struct kvm_regs regs;
5663e158a0SMatt Evans struct kvm_sregs sregs;
5763e158a0SMatt Evans struct kvm_fpu fpu;
5863e158a0SMatt Evans
5963e158a0SMatt Evans u8 is_running;
6063e158a0SMatt Evans u8 paused;
6163e158a0SMatt Evans u8 needs_nmi;
6263e158a0SMatt Evans /*
6363e158a0SMatt Evans * Although PPC KVM doesn't yet support coalesced MMIO, generic code
6463e158a0SMatt Evans * needs this in our kvm_cpu:
6563e158a0SMatt Evans */
6663e158a0SMatt Evans struct kvm_coalesced_mmio_ring *ring;
6763e158a0SMatt Evans };
6863e158a0SMatt Evans
6963e158a0SMatt Evans void kvm_cpu__irq(struct kvm_cpu *vcpu, int pin, int level);
7063e158a0SMatt Evans
715e8d833bSMatt Evans /* This is never actually called on PPC. */
kvm_cpu__emulate_io(struct kvm_cpu * vcpu,u16 port,void * data,int direction,int size,u32 count)724123ca55SMarc Zyngier static inline bool kvm_cpu__emulate_io(struct kvm_cpu *vcpu, u16 port, void *data, int direction, int size, u32 count)
735e8d833bSMatt Evans {
745e8d833bSMatt Evans return false;
755e8d833bSMatt Evans }
765e8d833bSMatt Evans
779b735910SMarc Zyngier bool kvm_cpu__emulate_mmio(struct kvm_cpu *vcpu, u64 phys_addr, u8 *data, u32 len, u8 is_write);
785e8d833bSMatt Evans
7963e158a0SMatt Evans #endif /* KVM__KVM_CPU_ARCH_H */
80