diff options
author | Marc Zyngier <marc.zyngier@arm.com> | 2012-09-18 09:09:58 -0400 |
---|---|---|
committer | Christoffer Dall <cdall@cs.columbia.edu> | 2013-03-06 18:48:43 -0500 |
commit | 4926d445eb76bec8ebd71f5ed9e9c94fd738014d (patch) | |
tree | ba608d6643fea298f0f7517a142a4cde78114056 | |
parent | 23b415d61a80c0c63f43dd2b3a08a1fa0b79b8ea (diff) |
ARM: KVM: abstract exception class decoding away
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
-rw-r--r-- | arch/arm/include/asm/kvm_emulate.h | 5 | ||||
-rw-r--r-- | arch/arm/kvm/arm.c | 4 | ||||
-rw-r--r-- | arch/arm/kvm/mmu.c | 2 |
3 files changed, 8 insertions, 3 deletions
diff --git a/arch/arm/include/asm/kvm_emulate.h b/arch/arm/include/asm/kvm_emulate.h index a9b853f35aed..539f83ac167f 100644 --- a/arch/arm/include/asm/kvm_emulate.h +++ b/arch/arm/include/asm/kvm_emulate.h | |||
@@ -142,4 +142,9 @@ static inline bool kvm_vcpu_trap_il_is32bit(struct kvm_vcpu *vcpu) | |||
142 | return kvm_vcpu_get_hsr(vcpu) & HSR_IL; | 142 | return kvm_vcpu_get_hsr(vcpu) & HSR_IL; |
143 | } | 143 | } |
144 | 144 | ||
145 | static inline u8 kvm_vcpu_trap_get_class(struct kvm_vcpu *vcpu) | ||
146 | { | ||
147 | return kvm_vcpu_get_hsr(vcpu) >> HSR_EC_SHIFT; | ||
148 | } | ||
149 | |||
145 | #endif /* __ARM_KVM_EMULATE_H__ */ | 150 | #endif /* __ARM_KVM_EMULATE_H__ */ |
diff --git a/arch/arm/kvm/arm.c b/arch/arm/kvm/arm.c index 31616336255c..269900174102 100644 --- a/arch/arm/kvm/arm.c +++ b/arch/arm/kvm/arm.c | |||
@@ -559,7 +559,7 @@ static bool kvm_condition_valid(struct kvm_vcpu *vcpu) | |||
559 | * catch undefined instructions, and then we won't get past | 559 | * catch undefined instructions, and then we won't get past |
560 | * the arm_exit_handlers test anyway. | 560 | * the arm_exit_handlers test anyway. |
561 | */ | 561 | */ |
562 | BUG_ON(((kvm_vcpu_get_hsr(vcpu) & HSR_EC) >> HSR_EC_SHIFT) == 0); | 562 | BUG_ON(!kvm_vcpu_trap_get_class(vcpu)); |
563 | 563 | ||
564 | /* Top two bits non-zero? Unconditional. */ | 564 | /* Top two bits non-zero? Unconditional. */ |
565 | if (kvm_vcpu_get_hsr(vcpu) >> 30) | 565 | if (kvm_vcpu_get_hsr(vcpu) >> 30) |
@@ -609,7 +609,7 @@ static int handle_exit(struct kvm_vcpu *vcpu, struct kvm_run *run, | |||
609 | case ARM_EXCEPTION_DATA_ABORT: | 609 | case ARM_EXCEPTION_DATA_ABORT: |
610 | case ARM_EXCEPTION_PREF_ABORT: | 610 | case ARM_EXCEPTION_PREF_ABORT: |
611 | case ARM_EXCEPTION_HVC: | 611 | case ARM_EXCEPTION_HVC: |
612 | hsr_ec = (kvm_vcpu_get_hsr(vcpu) & HSR_EC) >> HSR_EC_SHIFT; | 612 | hsr_ec = kvm_vcpu_trap_get_class(vcpu); |
613 | 613 | ||
614 | if (hsr_ec >= ARRAY_SIZE(arm_exit_handlers) | 614 | if (hsr_ec >= ARRAY_SIZE(arm_exit_handlers) |
615 | || !arm_exit_handlers[hsr_ec]) { | 615 | || !arm_exit_handlers[hsr_ec]) { |
diff --git a/arch/arm/kvm/mmu.c b/arch/arm/kvm/mmu.c index d0f5f52c179f..41fa75df107f 100644 --- a/arch/arm/kvm/mmu.c +++ b/arch/arm/kvm/mmu.c | |||
@@ -593,7 +593,7 @@ int kvm_handle_guest_abort(struct kvm_vcpu *vcpu, struct kvm_run *run) | |||
593 | gfn_t gfn; | 593 | gfn_t gfn; |
594 | int ret, idx; | 594 | int ret, idx; |
595 | 595 | ||
596 | hsr_ec = kvm_vcpu_get_hsr(vcpu) >> HSR_EC_SHIFT; | 596 | hsr_ec = kvm_vcpu_trap_get_class(vcpu); |
597 | is_iabt = (hsr_ec == HSR_EC_IABT); | 597 | is_iabt = (hsr_ec == HSR_EC_IABT); |
598 | fault_ipa = kvm_vcpu_get_fault_ipa(vcpu); | 598 | fault_ipa = kvm_vcpu_get_fault_ipa(vcpu); |
599 | 599 | ||