diff options
author | Hollis Blanchard <hollisb@us.ibm.com> | 2008-11-05 10:36:16 -0500 |
---|---|---|
committer | Avi Kivity <avi@redhat.com> | 2008-12-31 09:52:21 -0500 |
commit | 75f74f0dbe086c239b4b0cc5ed75b903ea3e663f (patch) | |
tree | c6774128934667d1c82a6e458d9a4233574a95a4 /arch/powerpc/include/asm | |
parent | c381a04313e7c0fb04246b1ff711e0b5726de6c0 (diff) |
KVM: ppc: refactor instruction emulation into generic and core-specific pieces
Cores provide 3 emulation hooks, implemented for example in the new
4xx_emulate.c:
kvmppc_core_emulate_op
kvmppc_core_emulate_mtspr
kvmppc_core_emulate_mfspr
Strictly speaking the last two aren't necessary, but provide for more
informative error reporting ("unknown SPR").
Long term I'd like to have instruction decoding autogenerated from tables of
opcodes, and that way we could aggregate universal, Book E, and core-specific
instructions more easily and without redundant switch statements.
Signed-off-by: Hollis Blanchard <hollisb@us.ibm.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'arch/powerpc/include/asm')
-rw-r--r-- | arch/powerpc/include/asm/kvm_ppc.h | 29 |
1 files changed, 6 insertions, 23 deletions
diff --git a/arch/powerpc/include/asm/kvm_ppc.h b/arch/powerpc/include/asm/kvm_ppc.h index 96d5de90ac5..aecf95d5fed 100644 --- a/arch/powerpc/include/asm/kvm_ppc.h +++ b/arch/powerpc/include/asm/kvm_ppc.h | |||
@@ -53,35 +53,13 @@ extern int kvmppc_handle_store(struct kvm_run *run, struct kvm_vcpu *vcpu, | |||
53 | extern int kvmppc_emulate_instruction(struct kvm_run *run, | 53 | extern int kvmppc_emulate_instruction(struct kvm_run *run, |
54 | struct kvm_vcpu *vcpu); | 54 | struct kvm_vcpu *vcpu); |
55 | extern int kvmppc_emulate_mmio(struct kvm_run *run, struct kvm_vcpu *vcpu); | 55 | extern int kvmppc_emulate_mmio(struct kvm_run *run, struct kvm_vcpu *vcpu); |
56 | extern int kvmppc_emul_tlbwe(struct kvm_vcpu *vcpu, u8 ra, u8 rs, u8 ws); | 56 | extern void kvmppc_emulate_dec(struct kvm_vcpu *vcpu); |
57 | extern int kvmppc_emul_tlbsx(struct kvm_vcpu *vcpu, u8 rt, u8 ra, u8 rb, u8 rc); | ||
58 | 57 | ||
59 | extern void kvmppc_mmu_map(struct kvm_vcpu *vcpu, u64 gvaddr, gfn_t gfn, | 58 | extern void kvmppc_mmu_map(struct kvm_vcpu *vcpu, u64 gvaddr, gfn_t gfn, |
60 | u64 asid, u32 flags); | 59 | u64 asid, u32 flags); |
61 | extern void kvmppc_mmu_priv_switch(struct kvm_vcpu *vcpu, int usermode); | 60 | extern void kvmppc_mmu_priv_switch(struct kvm_vcpu *vcpu, int usermode); |
62 | extern void kvmppc_mmu_switch_pid(struct kvm_vcpu *vcpu, u32 pid); | 61 | extern void kvmppc_mmu_switch_pid(struct kvm_vcpu *vcpu, u32 pid); |
63 | 62 | ||
64 | /* Helper function for "full" MSR writes. No need to call this if only EE is | ||
65 | * changing. */ | ||
66 | static inline void kvmppc_set_msr(struct kvm_vcpu *vcpu, u32 new_msr) | ||
67 | { | ||
68 | if ((new_msr & MSR_PR) != (vcpu->arch.msr & MSR_PR)) | ||
69 | kvmppc_mmu_priv_switch(vcpu, new_msr & MSR_PR); | ||
70 | |||
71 | vcpu->arch.msr = new_msr; | ||
72 | |||
73 | if (vcpu->arch.msr & MSR_WE) | ||
74 | kvm_vcpu_block(vcpu); | ||
75 | } | ||
76 | |||
77 | static inline void kvmppc_set_pid(struct kvm_vcpu *vcpu, u32 new_pid) | ||
78 | { | ||
79 | if (vcpu->arch.pid != new_pid) { | ||
80 | vcpu->arch.pid = new_pid; | ||
81 | vcpu->arch.swap_pid = 1; | ||
82 | } | ||
83 | } | ||
84 | |||
85 | /* Core-specific hooks */ | 63 | /* Core-specific hooks */ |
86 | 64 | ||
87 | extern int kvmppc_core_check_processor_compat(void); | 65 | extern int kvmppc_core_check_processor_compat(void); |
@@ -99,6 +77,11 @@ extern void kvmppc_core_queue_dec(struct kvm_vcpu *vcpu); | |||
99 | extern void kvmppc_core_queue_external(struct kvm_vcpu *vcpu, | 77 | extern void kvmppc_core_queue_external(struct kvm_vcpu *vcpu, |
100 | struct kvm_interrupt *irq); | 78 | struct kvm_interrupt *irq); |
101 | 79 | ||
80 | extern int kvmppc_core_emulate_op(struct kvm_run *run, struct kvm_vcpu *vcpu, | ||
81 | unsigned int op, int *advance); | ||
82 | extern int kvmppc_core_emulate_mtspr(struct kvm_vcpu *vcpu, int sprn, int rs); | ||
83 | extern int kvmppc_core_emulate_mfspr(struct kvm_vcpu *vcpu, int sprn, int rt); | ||
84 | |||
102 | extern void kvmppc_core_destroy_mmu(struct kvm_vcpu *vcpu); | 85 | extern void kvmppc_core_destroy_mmu(struct kvm_vcpu *vcpu); |
103 | 86 | ||
104 | #endif /* __POWERPC_KVM_PPC_H__ */ | 87 | #endif /* __POWERPC_KVM_PPC_H__ */ |