summaryrefslogtreecommitdiff
path: root/arch/powerpc/kvm/e500_emulate.c
diff options
context:
space:
mode:
authorAlexander Graf <agraf@suse.de>2012-05-04 14:01:33 +0200
committerAlexander Graf <agraf@suse.de>2012-05-06 16:19:12 +0200
commitc46dc9a86148bc37c31d67a22a3887144ba7aa81 (patch)
treeba2a4f49072d3524d607ce3add83ef697fae517b /arch/powerpc/kvm/e500_emulate.c
parent5b74716ebab10e7bce960d148fe6d8f6920451e5 (diff)
KVM: PPC: Emulator: clean up instruction parsing
Instructions on PPC are pretty similarly encoded. So instead of every instruction emulation code decoding the instruction fields itself, we can move that code to more generic places and rely on the compiler to optimize the unused bits away. This has 2 advantages. It makes the code smaller and it makes the code less error prone, as the instruction fields are always available, so accidental misusage is reduced. Functionally, this patch doesn't change anything. Signed-off-by: Alexander Graf <agraf@suse.de>
Diffstat (limited to 'arch/powerpc/kvm/e500_emulate.c')
-rw-r--r--arch/powerpc/kvm/e500_emulate.c16
1 files changed, 5 insertions, 11 deletions
diff --git a/arch/powerpc/kvm/e500_emulate.c b/arch/powerpc/kvm/e500_emulate.c
index 99155f847a6a..9b2dcda71950 100644
--- a/arch/powerpc/kvm/e500_emulate.c
+++ b/arch/powerpc/kvm/e500_emulate.c
@@ -86,9 +86,9 @@ int kvmppc_core_emulate_op(struct kvm_run *run, struct kvm_vcpu *vcpu,
unsigned int inst, int *advance)
{
int emulated = EMULATE_DONE;
- int ra;
- int rb;
- int rt;
+ int ra = get_ra(inst);
+ int rb = get_rb(inst);
+ int rt = get_rt(inst);
switch (get_op(inst)) {
case 31:
@@ -96,11 +96,11 @@ int kvmppc_core_emulate_op(struct kvm_run *run, struct kvm_vcpu *vcpu,
#ifdef CONFIG_KVM_E500MC
case XOP_MSGSND:
- emulated = kvmppc_e500_emul_msgsnd(vcpu, get_rb(inst));
+ emulated = kvmppc_e500_emul_msgsnd(vcpu, rb);
break;
case XOP_MSGCLR:
- emulated = kvmppc_e500_emul_msgclr(vcpu, get_rb(inst));
+ emulated = kvmppc_e500_emul_msgclr(vcpu, rb);
break;
#endif
@@ -113,20 +113,14 @@ int kvmppc_core_emulate_op(struct kvm_run *run, struct kvm_vcpu *vcpu,
break;
case XOP_TLBSX:
- rb = get_rb(inst);
emulated = kvmppc_e500_emul_tlbsx(vcpu,rb);
break;
case XOP_TLBILX:
- ra = get_ra(inst);
- rb = get_rb(inst);
- rt = get_rt(inst);
emulated = kvmppc_e500_emul_tlbilx(vcpu, rt, ra, rb);
break;
case XOP_TLBIVAX:
- ra = get_ra(inst);
- rb = get_rb(inst);
emulated = kvmppc_e500_emul_tlbivax(vcpu, ra, rb);
break;