From: Rusty Russell <rusty.russell@xxxxxxxxxx> We need the C bit, so hand down the psr through the callchain. Signed-off-by: Rusty Russell <rusty.russell@xxxxxxxxxx> --- arch/arm/kvm/emulate.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/arch/arm/kvm/emulate.c b/arch/arm/kvm/emulate.c index ca24828..5ac4cf7 100644 --- a/arch/arm/kvm/emulate.c +++ b/arch/arm/kvm/emulate.c @@ -318,7 +318,7 @@ struct arm_decode { u32 opc; u32 opc_mask; - bool (*decode)(struct kvm_vcpu *vcpu, struct arm_insn *ai); + bool (*decode)(struct kvm_vcpu *vcpu, struct arm_insn *ai, u32 psr); struct arm_insn template; }; @@ -387,7 +387,7 @@ u32 shift(u32 value, u8 N, enum SRType type, u8 amount, bool carry_in) return value & mask; } -static bool decode_arm_wb(struct kvm_vcpu *vcpu, struct arm_insn *ai) +static bool decode_arm_wb(struct kvm_vcpu *vcpu, struct arm_insn *ai, u32 psr) { u32 base_addr, offset; @@ -408,7 +408,7 @@ static bool decode_arm_wb(struct kvm_vcpu *vcpu, struct arm_insn *ai) /* Register operation */ enum SRType s_type; u8 shift_n; - bool c_bit = *vcpu_cpsr(vcpu) & PSR_C_BIT; + bool c_bit = psr & PSR_C_BIT; u32 s_reg = *vcpu_reg(vcpu, ai->Rm); s_type = decode_imm_shift(ai->type, ai->shift_n, &shift_n); @@ -426,7 +426,7 @@ static bool decode_arm_wb(struct kvm_vcpu *vcpu, struct arm_insn *ai) return true; } -static bool decode_arm_ls(struct kvm_vcpu *vcpu, struct arm_insn *ai) +static bool decode_arm_ls(struct kvm_vcpu *vcpu, struct arm_insn *ai, u32 psr) { u8 A = (ai->instr >> 25) & 1; @@ -436,10 +436,11 @@ static bool decode_arm_ls(struct kvm_vcpu *vcpu, struct arm_insn *ai) ai->type = (ai->instr >> 5) & 0x3; ai->shift_n = (ai->instr >> 7) & 0x1f; - return decode_arm_wb(vcpu, ai); + return decode_arm_wb(vcpu, ai, psr); } -static bool decode_arm_extra(struct kvm_vcpu *vcpu, struct arm_insn *ai) +static bool decode_arm_extra(struct kvm_vcpu *vcpu, struct arm_insn *ai, + u32 psr) { ai->register_form = !((ai->instr >> 22) & 1); ai->imm = ((ai->instr >> 4) & 0xf0) | (ai->instr & 0xf); @@ -447,7 +448,7 @@ static bool decode_arm_extra(struct kvm_vcpu *vcpu, struct arm_insn *ai) ai->type = 0; /* SRType_LSL */ ai->shift_n = 0; - return decode_arm_wb(vcpu, ai); + return decode_arm_wb(vcpu, ai, psr); } /* @@ -527,7 +528,8 @@ static const struct arm_decode arm_decode[] = { .template = { .len = 2, .w = false, .sign_extend = true, }, }, }; -static bool kvm_decode_arm_ls(struct kvm_vcpu *vcpu, struct arm_insn *ai) +static bool kvm_decode_arm_ls(struct kvm_vcpu *vcpu, struct arm_insn *ai, + u32 psr) { int i; @@ -537,7 +539,7 @@ static bool kvm_decode_arm_ls(struct kvm_vcpu *vcpu, struct arm_insn *ai) ai->len = d->template.len; ai->w = d->template.w; ai->sign_extend = d->template.sign_extend; - return d->decode(vcpu, ai); + return d->decode(vcpu, ai, psr); } } return false; @@ -728,7 +730,7 @@ static int kvm_decode(struct kvm_vcpu *vcpu, unsigned long pc, u32 psr, return kvm_decode_thumb_ls(vcpu, ai); } - return kvm_decode_arm_ls(vcpu, ai); + return kvm_decode_arm_ls(vcpu, ai, psr); } 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 majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html