From: Hollis Blanchard <hollisb@us.ibm.com>
To: kvm-ppc@vger.kernel.org
Subject: Re: [kvm-ppc-devel] [PATCH 5/5] Extract instruction emulate
Date: Mon, 28 Jan 2008 21:46:48 +0000 [thread overview]
Message-ID: <1201556808.8969.146.camel@basalt> (raw)
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
reply other threads:[~2008-01-28 21:46 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1201556808.8969.146.camel@basalt \
--to=hollisb@us.ibm.com \
--cc=kvm-ppc@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.