From mboxrd@z Thu Jan 1 00:00:00 1970 From: Hollis Blanchard Date: Mon, 28 Jan 2008 21:46:48 +0000 Subject: Re: [kvm-ppc-devel] [PATCH 5/5] Extract instruction emulate Message-Id: <1201556808.8969.146.camel@basalt> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: kvm-ppc@vger.kernel.org On Fri, 2008-01-25 at 15:12 +0800, Zhang Wei wrote: > Some instruction emulation need implemented for individual > processor. I extract general code from emulate.c to header > file inst.h. A new header 44x_inst.h is created for special > 44x emulation functions. > > Signed-off-by: Zhang Wei > --- > 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.h > > diff --git a/arch/powerpc/kvm/44x_inst.h b/arch/powerpc/kvm/44x_inst.h > new file mode 100644 > index 0000000..7529618 > --- /dev/null > +++ b/arch/powerpc/kvm/44x_inst.h ... > + > +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__ */ > diff --git a/arch/powerpc/kvm/emulate.c b/arch/powerpc/kvm/emulate.c > index ad4a26a..8eb2f31 100644 > --- a/arch/powerpc/kvm/emulate.c > +++ b/arch/powerpc/kvm/emulate.c ... > - 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 > - 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. -- 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 kvm-ppc-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-ppc-devel