[RFC/TRIVIAL PATCH 12/13] ARM: KVM: abstract condition checking away

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Marc Zyngier <marc.zyngier@xxxxxxx>
---
 arch/arm/include/asm/kvm_emulate.h | 10 ++++++++++
 arch/arm/kvm/arm.c                 | 13 ++++++++-----
 2 files changed, 18 insertions(+), 5 deletions(-)

diff --git a/arch/arm/include/asm/kvm_emulate.h b/arch/arm/include/asm/kvm_emulate.h
index 8bf7115..a5135de 100644
--- a/arch/arm/include/asm/kvm_emulate.h
+++ b/arch/arm/include/asm/kvm_emulate.h
@@ -143,4 +143,14 @@ static inline u8 kvm_vcpu_trap_get_fault(struct kvm_vcpu *vcpu)
 	return kvm_vcpu_get_hsr(vcpu) & HSR_FSC_TYPE;
 }
 
+static inline int kvm_vcpu_get_condition(struct kvm_vcpu *vcpu)
+{
+	u32 hsr = kvm_vcpu_get_hsr(vcpu);
+
+	if (hsr & HSR_CV)
+		return (hsr & HSR_COND) >> HSR_COND_SHIFT;
+
+	return -1;
+}
+
 #endif /* __ARM_KVM_EMULATE_H__ */
diff --git a/arch/arm/kvm/arm.c b/arch/arm/kvm/arm.c
index e2dd35d..2eb6105 100644
--- a/arch/arm/kvm/arm.c
+++ b/arch/arm/kvm/arm.c
@@ -527,7 +527,8 @@ static exit_handle_fn arm_exit_handlers[] = {
  */
 static bool kvm_condition_valid(struct kvm_vcpu *vcpu)
 {
-	unsigned long cpsr, cond, insn;
+	unsigned long cpsr, insn;
+	int cond;
 
 	/*
 	 * Exception Code 0 can only happen if we set HCR.TGE to 1, to
@@ -540,12 +541,14 @@ static bool kvm_condition_valid(struct kvm_vcpu *vcpu)
 	if (kvm_vcpu_get_hsr(vcpu) >> 30)
 		return true;
 
+	/* Is condition field valid? */
+	cond = kvm_vcpu_get_condition(vcpu);
+	if (cond == 0xE)
+		return true;
+
 	cpsr = *vcpu_cpsr(vcpu);
 
-	/* Is condition field valid? */
-	if ((kvm_vcpu_get_hsr(vcpu) & HSR_CV) >> HSR_CV_SHIFT)
-		cond = (kvm_vcpu_get_hsr(vcpu) & HSR_COND) >> HSR_COND_SHIFT;
-	else {
+	if (cond < 0) {
 		/* This can happen in Thumb mode: examine IT state. */
 		unsigned long it;
 
-- 
1.7.12



_______________________________________________
kvmarm mailing list
kvmarm@xxxxxxxxxxxxxxxxxxxxx
https://lists.cs.columbia.edu/cucslists/listinfo/kvmarm


[Index of Archives]     [Linux KVM]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux