ARM: KVM: guest_didnt_mean_it()
PATCH 7/8 ARM: KVM: guest_didnt_mean_it()
From: Rusty Russell <[email protected]>
Conditional instructions may trap even if the condition isn't true, so a good hypervisor will check this. The same can happen with undefined instructions, so the kernel should be doing this dance already (it isn't).
(See p1206 of ARMv7-A ARM)
Signed-off-by Rusty Russell <[email protected]>
--- arch/arm/include/asm/kvm_arm.h | 4 +++ arch/arm/include/asm/kvm_emulate.h | 2 + arch/arm/kvm/Makefile | 2 + arch/arm/kvm/arm.c | 3 ++ arch/arm/kvm/emulate.c | 41 +++++++++++++++++++++++++++ arch/arm/kvm/kvm_cond_match.S | 54 ++++++++++++++++++++++++++++++++++++ 6 files changed, 105 insertions(+), 1 deletions(-) create mode 100644 arch/arm/kvm/kvm_cond_match.S
arch/arm/include/asm/kvm_arm.h +4 -0
@@ -107,6 +107,10 @@#define HSR_ISS (HSR_IL - 1)#define HSR_ISV_SHIFT (24)#define HSR_ISV (1U << HSR_ISV_SHIFT) +#define HSR_CV_SHIFT (24) +#define HSR_CV (1U << HSR_CV_SHIFT) +#define HSR_COND_SHIFT (20) +#define HSR_COND (0xfU << HSR_COND_SHIFT)#define HSR_EC_UNKNOWN (0x00)#define HSR_EC_WFI (0x01)
arch/arm/include/asm/kvm_emulate.h +2 -0
@@ -49,6 +49,8 @@ int kvm_handle_cp15_64(struct kvm_vcpu *vcpu, struct kvm_run *run);int kvm_handle_wfi (struct kvm_vcpu *vcpu,struct kvm_run *run);int kvm_emulate_mmio_ls (struct kvm_vcpu *vcpu,phys_addr_t fault_ipa,unsigned long instr); +bool kvm_should_not_have_trapped (struct kvm_vcpu *vcpu); +bool kvm_cond_match (u32 flags,u32 cond);/* * Return the SPSR for the specified mode of the virtual CPU.
arch/arm/kvm/Makefile +1 -1
@@ -12,6 +12,6 @@ obj-$(CONFIG_KVM_ARM_HOST) += init.o interrupts.o exports.o kvm-arm-y += $(addprefix ../../../virt/kvm/, kvm_main.o coalesced_mmio.o) -kvm-arm-y += arm.o guest.o mmu.o emulate.o +kvm-arm-y += arm.o guest.o mmu.o emulate.o kvm_cond_match.o obj-$(CONFIG_KVM) += kvm-arm.o
arch/arm/kvm/arm.c +3 -0
@@ -414,6 +414,9 @@ static inline int handle_exit(struct kvm_vcpu *vcpu, struct kvm_run *run,BUG (); } +if (kvm_should_not_have_trapped (vcpu)) +return 0 ; +return arm_exit_handlers[hsr_ec](vcpu, run); }
arch/arm/kvm/emulate.c +41 -0
44 lines not on this page · raw message
arch/arm/kvm/kvm_cond_match.S new file +54 -0
54 lines not on this page · raw message