From: Rusty Russell <rusty.russ...@linaro.org> We determine whether we're in thumb mode and whether it's a wide instruction when we copy it in, so just initialize is_thumb and is_thumb32 there.
Signed-off-by: Rusty Russell <rusty.russ...@linaro.org> --- arch/arm/kvm/emulate.c | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/arch/arm/kvm/emulate.c b/arch/arm/kvm/emulate.c index d619ad8..ca24828 100644 --- a/arch/arm/kvm/emulate.c +++ b/arch/arm/kvm/emulate.c @@ -662,9 +662,6 @@ static bool kvm_decode_thumb_ls(struct kvm_vcpu *vcpu, struct arm_insn *ti) bool is16; int i; - ti->is_thumb = true; - ti->is_thumb32 = is_wide_instruction(ti->instr); - is16 = !ti->is_thumb32; if (is16) { ti->t16.opcode = (ti->instr >> 10) & 0x3f; @@ -697,11 +694,13 @@ static bool kvm_decode_thumb_ls(struct kvm_vcpu *vcpu, struct arm_insn *ti) static int kvm_decode(struct kvm_vcpu *vcpu, unsigned long pc, u32 psr, struct arm_insn *ai) { - bool is_thumb = !!(psr & PSR_T_BIT); - unsigned int instr_len = is_thumb ? 2 : 4; int err; + unsigned int instr_len; + + ai->is_thumb = psr & PSR_T_BIT; + instr_len = ai->is_thumb ? 2 : 4; - BUG_ON(!is_thumb && (pc & 0x3)); + BUG_ON(!ai->is_thumb && (pc & 0x3)); /* Zero out high bits for thumb case, and so it's set on error. */ ai->instr = 0; @@ -711,24 +710,25 @@ static int kvm_decode(struct kvm_vcpu *vcpu, unsigned long pc, u32 psr, if (err) return err; - /* - * Is it a 32 bit thumb instruction? Can't get it all in 1 go, since - * it can actually go over a page boundary. - */ - if (is_thumb && is_wide_instruction(ai->instr)) { - ai->instr = ai->instr << 16; - err = copy_from_guest(vcpu, &ai->instr, - pc + instr_len, instr_len); - if (err) - return err; + if (ai->is_thumb) { + /* + * Is it a 32 bit thumb instruction? Can't get it all + * in 1 go, since it can actually go over a page + * boundary. + */ + ai->is_thumb32 = is_wide_instruction(ai->instr); + + if (ai->is_thumb32) { + ai->instr = ai->instr << 16; + err = copy_from_guest(vcpu, &ai->instr, + pc + instr_len, instr_len); + if (err) + return err; + } + return kvm_decode_thumb_ls(vcpu, ai); } - if (!is_thumb && !kvm_decode_arm_ls(vcpu, ai)) - return -ENOENT; - else if (is_thumb && !kvm_decode_thumb_ls(vcpu, ai)) - return -ENOENT; - - return 0; + return kvm_decode_arm_ls(vcpu, ai); } static bool execute(struct kvm_vcpu *vcpu, struct kvm_exit_mmio *mmio, -- 1.7.10.4 -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html