From: Rusty Russell <rusty@rustcorp.com.au>
To: Will Deacon <will.deacon@arm.com>
Cc: Christoffer Dall <c.dall@virtualopensystems.com>,
"kvm@vger.kernel.org" <kvm@vger.kernel.org>,
dave.martin@linaro.org, Rusty Russell <rusty.russell@linaro.org>
Subject: [PATCH 08/10] kvm: avoid using vcpu_cpsr() by passing down PSR.
Date: Wed, 24 Oct 2012 21:55:21 +1030 [thread overview]
Message-ID: <1351077923-17977-9-git-send-email-rusty@rustcorp.com.au> (raw)
In-Reply-To: <1351077923-17977-1-git-send-email-rusty@rustcorp.com.au>
From: Rusty Russell <rusty.russell@linaro.org>
We need the C bit, so hand down the psr through the callchain.
Signed-off-by: Rusty Russell <rusty.russell@linaro.org>
---
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
next prev parent reply other threads:[~2012-10-24 11:29 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-05 7:58 [PATCH 0/3] KVM_VCPU_GET_REG_LIST API Rusty Russell
2012-09-05 7:58 ` [PATCH 1/3] KVM: Move KVM_SET_ONE_REG/KVM_GET_ONE_REG to generic code Rusty Russell
2012-09-19 14:17 ` Alexander Graf
2012-09-05 7:58 ` [PATCH 2/3] KVM: Add KVM_REG_SIZE() helper Rusty Russell
2012-09-19 14:18 ` Alexander Graf
2012-09-05 7:58 ` [PATCH 3/3] KVM: Add KVM_VCPU_GET_REG_LIST/KVM_CAP_REG_LIST Rusty Russell
2012-09-19 14:22 ` Alexander Graf
2012-10-10 18:12 ` Marcelo Tosatti
2012-10-11 8:11 ` Rusty Russell
2012-10-18 14:45 ` [PATCH 0/3] KVM_VCPU_GET_REG_LIST API Avi Kivity
2012-10-19 0:36 ` Rusty Russell
2012-10-19 6:19 ` Rusty Russell
2012-10-19 16:06 ` Christoffer Dall
2012-10-22 3:09 ` Rusty Russell
2012-10-22 17:45 ` Will Deacon
2012-10-22 18:11 ` Christoffer Dall
2012-10-24 11:25 ` RFC: Move kvm's instruction decoding into generic code Rusty Russell
2012-10-24 11:25 ` [PATCH 01/10] kvm: split out instruction structure from decoding method Rusty Russell
2012-10-24 11:25 ` [PATCH 02/10] kvm: split out instruction decode from emulation Rusty Russell
2012-10-24 11:25 ` [PATCH 03/10] kvm: split out instruction decode from emulation (thumb instructions) Rusty Russell
2012-10-24 11:25 ` [PATCH 04/10] kvm: completely separate decoding from execution Rusty Russell
2012-10-24 11:25 ` [PATCH 05/10] kvm: move instruction copying inside kvm_decode() Rusty Russell
2012-10-24 11:25 ` [PATCH 06/10] kvm: cleanup use of instr Rusty Russell
2012-10-24 11:25 ` [PATCH 07/10] kvm: clean up use of is_wide_instruction() Rusty Russell
2012-10-24 11:25 ` Rusty Russell [this message]
2012-10-24 11:25 ` [PATCH 09/10] kvm: avoid reference vcpu->arch.hxfar by making thumb offset_addr relative Rusty Russell
2012-10-24 11:25 ` [PATCH 10/10] opcode: move generic instruction decode out of KVM Rusty Russell
2012-10-24 16:27 ` RFC: Move kvm's instruction decoding into generic code Dave Martin
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=1351077923-17977-9-git-send-email-rusty@rustcorp.com.au \
--to=rusty@rustcorp.com.au \
--cc=c.dall@virtualopensystems.com \
--cc=dave.martin@linaro.org \
--cc=kvm@vger.kernel.org \
--cc=rusty.russell@linaro.org \
--cc=will.deacon@arm.com \
/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.