[Android-virt] [RFC PATCH 4/6] ARM: KVM: Inject undefined exception on guest error

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

 



When the guest does something we do not like, let it know about it!

Signed-off-by: Christoffer Dall <c.dall at virtualopensystems.com>
---
 arch/arm/kvm/arm.c     |    5 ++---
 arch/arm/kvm/emulate.c |   14 ++++++++++----
 2 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/arch/arm/kvm/arm.c b/arch/arm/kvm/arm.c
index 62c0e5f..0c8dff4 100644
--- a/arch/arm/kvm/arm.c
+++ b/arch/arm/kvm/arm.c
@@ -393,13 +393,12 @@ static int handle_hvc(struct kvm_vcpu *vcpu, struct kvm_run *run)
 {
 	/*
 	 * Guest called HVC instruction:
-	 * So far we are not doing anything here, but in the longer run we are
-	 * probably going to have some hypercall interface entry point
-	 * starting from here.
+	 * Let it know we don't want that by injecting an undefined exception.
 	 */
 	kvm_debug("hvc: %x (at %08x)", vcpu->arch.hsr & ((1 << 16) - 1),
 				     vcpu->arch.regs.pc);
 	kvm_debug("         HSR: %8x", vcpu->arch.hsr);
+	kvm_inject_undefined(vcpu);
 	return 0;
 }
 
diff --git a/arch/arm/kvm/emulate.c b/arch/arm/kvm/emulate.c
index 2fdc026..a09dd10 100644
--- a/arch/arm/kvm/emulate.c
+++ b/arch/arm/kvm/emulate.c
@@ -186,22 +186,26 @@ static void print_cp_instr(const struct coproc_params *p)
 
 int kvm_handle_cp10_id(struct kvm_vcpu *vcpu, struct kvm_run *run)
 {
-	return -EINVAL;
+	kvm_inject_undefined(vcpu);
+	return 0;
 }
 
 int kvm_handle_cp_0_13_access(struct kvm_vcpu *vcpu, struct kvm_run *run)
 {
-	return -EINVAL;
+	kvm_inject_undefined(vcpu);
+	return 0;
 }
 
 int kvm_handle_cp14_load_store(struct kvm_vcpu *vcpu, struct kvm_run *run)
 {
-	return -EINVAL;
+	kvm_inject_undefined(vcpu);
+	return 0;
 }
 
 int kvm_handle_cp14_access(struct kvm_vcpu *vcpu, struct kvm_run *run)
 {
-	return -EINVAL;
+	kvm_inject_undefined(vcpu);
+	return 0;
 }
 
 static bool ignore_write(struct kvm_vcpu *vcpu,
@@ -384,6 +388,8 @@ static int emulate_cp15(struct kvm_vcpu *vcpu,
 	kvm_err("Unsupported guest CP15 access at: %08x\n",
 		vcpu->arch.regs.pc);
 	print_cp_instr(params);
+	kvm_inject_undefined(vcpu);
+	return 0;
 fail:
 	return -EINVAL;
 }



[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