diff options
author | Alexander Graf <agraf@suse.de> | 2010-03-24 16:48:21 -0400 |
---|---|---|
committer | Avi Kivity <avi@redhat.com> | 2010-05-17 05:16:56 -0400 |
commit | 8963221d7d7244cc828dfca5649404c747599b3e (patch) | |
tree | 6e563c1e86ca166a70848c105756f0a2cbe2ee8d /arch/powerpc/kvm/book3s.c | |
parent | 4b389ca2e733b986c5282690e4e0314f000e6228 (diff) |
KVM: PPC: Split instruction reading out
The current check_ext function reads the instruction and then does
the checking. Let's split the reading out so we can reuse it for
different functions.
Signed-off-by: Alexander Graf <agraf@suse.de>
Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'arch/powerpc/kvm/book3s.c')
-rw-r--r-- | arch/powerpc/kvm/book3s.c | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/arch/powerpc/kvm/book3s.c b/arch/powerpc/kvm/book3s.c index 34e1a342bec8..358d5f78311a 100644 --- a/arch/powerpc/kvm/book3s.c +++ b/arch/powerpc/kvm/book3s.c | |||
@@ -651,26 +651,34 @@ void kvmppc_giveup_ext(struct kvm_vcpu *vcpu, ulong msr) | |||
651 | kvmppc_recalc_shadow_msr(vcpu); | 651 | kvmppc_recalc_shadow_msr(vcpu); |
652 | } | 652 | } |
653 | 653 | ||
654 | static int kvmppc_check_ext(struct kvm_vcpu *vcpu, unsigned int exit_nr) | 654 | static int kvmppc_read_inst(struct kvm_vcpu *vcpu) |
655 | { | 655 | { |
656 | ulong srr0 = vcpu->arch.pc; | 656 | ulong srr0 = vcpu->arch.pc; |
657 | int ret; | 657 | int ret; |
658 | 658 | ||
659 | /* Need to do paired single emulation? */ | ||
660 | if (!(vcpu->arch.hflags & BOOK3S_HFLAG_PAIRED_SINGLE)) | ||
661 | return EMULATE_DONE; | ||
662 | |||
663 | /* Read out the instruction */ | ||
664 | ret = kvmppc_ld(vcpu, &srr0, sizeof(u32), &vcpu->arch.last_inst, false); | 659 | ret = kvmppc_ld(vcpu, &srr0, sizeof(u32), &vcpu->arch.last_inst, false); |
665 | if (ret == -ENOENT) { | 660 | if (ret == -ENOENT) { |
666 | vcpu->arch.msr = kvmppc_set_field(vcpu->arch.msr, 33, 33, 1); | 661 | vcpu->arch.msr = kvmppc_set_field(vcpu->arch.msr, 33, 33, 1); |
667 | vcpu->arch.msr = kvmppc_set_field(vcpu->arch.msr, 34, 36, 0); | 662 | vcpu->arch.msr = kvmppc_set_field(vcpu->arch.msr, 34, 36, 0); |
668 | vcpu->arch.msr = kvmppc_set_field(vcpu->arch.msr, 42, 47, 0); | 663 | vcpu->arch.msr = kvmppc_set_field(vcpu->arch.msr, 42, 47, 0); |
669 | kvmppc_book3s_queue_irqprio(vcpu, BOOK3S_INTERRUPT_INST_STORAGE); | 664 | kvmppc_book3s_queue_irqprio(vcpu, BOOK3S_INTERRUPT_INST_STORAGE); |
670 | } else if(ret == EMULATE_DONE) { | 665 | return EMULATE_AGAIN; |
666 | } | ||
667 | |||
668 | return EMULATE_DONE; | ||
669 | } | ||
670 | |||
671 | static int kvmppc_check_ext(struct kvm_vcpu *vcpu, unsigned int exit_nr) | ||
672 | { | ||
673 | |||
674 | /* Need to do paired single emulation? */ | ||
675 | if (!(vcpu->arch.hflags & BOOK3S_HFLAG_PAIRED_SINGLE)) | ||
676 | return EMULATE_DONE; | ||
677 | |||
678 | /* Read out the instruction */ | ||
679 | if (kvmppc_read_inst(vcpu) == EMULATE_DONE) | ||
671 | /* Need to emulate */ | 680 | /* Need to emulate */ |
672 | return EMULATE_FAIL; | 681 | return EMULATE_FAIL; |
673 | } | ||
674 | 682 | ||
675 | return EMULATE_AGAIN; | 683 | return EMULATE_AGAIN; |
676 | } | 684 | } |