All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: [kvm-ppc-devel] [PATCH 5/5] Extract instruction emulate
@ 2008-01-28 21:46 Hollis Blanchard
  0 siblings, 0 replies; only message in thread
From: Hollis Blanchard @ 2008-01-28 21:46 UTC (permalink / raw)
  To: kvm-ppc

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 <wei.zhang@freescale.com>
> ---
>  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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2008-01-28 21:46 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-01-28 21:46 [kvm-ppc-devel] [PATCH 5/5] Extract instruction emulate Hollis Blanchard

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.