Extract instruction emulate
Quoted 19 lines · Zhang Wei
Some instruction emulation need implemented for individual processor. I extract general code from
emulate.cto header fileinst.h. A new header44x_inst.his created for special 44x emulation functions.Signed-off-by Zhang Wei <[email protected]>--- arch/powerpc/kvm/44x_inst.h | 192 +++++++++++++++++++++++++++++++++ arch/powerpc/kvm/emulate.c | 245 +------------------------------------------ arch/powerpc/kvm/inst.h | 132 +++++++++++++++++++++++ 3 files changed, 329 insertions(+), 240 deletions(-) create mode 100644 arch/powerpc/kvm/44x_inst.h create mode 100644 arch/powerpc/kvm/inst.harch/powerpc/kvm/44x_inst.h new file +0
-0
...
Quoted 37 lines
arch/powerpc/kvm/44x_inst.h new file +33
-0+ +static int emul_tlbsx (struct kvm_vcpu *vcpu,u32 inst) +{ +int index; +unsigned int as =get_mmucr_sts (vcpu); +unsigned int pid =get_mmucr_stid (vcpu); +unsigned int ra; +unsigned int rb; +unsigned int rc; +unsigned int rt; +unsigned int ea; + + rt =get_rt (inst); + ra =get_ra (inst); + rb =get_rb (inst); + rc =get_rc (inst); + + ea = vcpu->arch.gpr[rb]; +if (ra) + ea += vcpu->arch.gpr[ra]; + + index =kvmppc_tlb_index (vcpu, ea, pid, as); +if (rc) { +if (index <0 ) + vcpu->arch.cr &= ~0x20000000 ; +else + vcpu->arch.cr |=0x20000000 ; + } + vcpu->arch.gpr[rt] = index; + +return EMULATE_DONE ; +} +#endif /* __ARCH_POWERPC_KVM_44X_INST_H__ */ arch/powerpc/kvm/emulate.c +0
-0
...
Quoted 19 lines
arch/powerpc/kvm/emulate.c +0
-19-case 914 : {/* tlbsx */ -int index; -unsigned int as =get_mmucr_sts (vcpu); -unsigned int pid =get_mmucr_stid (vcpu); - - rt =get_rt (inst); - ra =get_ra (inst); - rb =get_rb (inst); - rc =get_rc (inst); - - ea = vcpu->arch.gpr[rb]; -if (ra) - ea += vcpu->arch.gpr[ra]; - - index =kvmppc_tlb_index (vcpu, ea, pid, as); -if (rc) { -if (index <0 ) - vcpu->arch.cr &= ~0x20000000 ; -else
arch/powerpc/kvm/emulate.c
Quoted 10 lines
arch/powerpc/kvm/emulate.c +2
-5- vcpu->arch.cr |=0x20000000 ; - } - vcpu->arch.gpr[rt] = index; - - } +case 914 :/* tlbsx */ + emulated =emul_tlbsx (vcpu, inst);break ;case 966 :/* iccci */
What do you think about using vcpu callbacks instead of ifdefs? If we use ifdefs, we will need to build multiple modules to support multiple guest types.
I'm assuming that all PowerPC instructions have unique opcodes across all implementations, which may not be a safe assumption. Does anybody know? It's not really a big deal in this case, other than what to name the callbacks.
Signature · 12 lines
Hollis Blanchard IBM Linux Technology Center ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ kvm-ppc-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/kvm-ppc-devel