summary refs log tree commit diff
diff options
context:
space:
mode:
authorStephen Barber <smbarber@chromium.org>2019-12-19 14:26:25 -0800
committerCommit Bot <commit-bot@chromium.org>2019-12-20 21:33:44 +0000
commitd0e2a253de141373be9f9f0c7f9c66589fab7f70 (patch)
treeff82a34fed60663fa253ebd519845e88c39ddcef
parent458bb643441bc122fe7b39e1c0f526b4d5bd976a (diff)
downloadcrosvm-d0e2a253de141373be9f9f0c7f9c66589fab7f70.tar
crosvm-d0e2a253de141373be9f9f0c7f9c66589fab7f70.tar.gz
crosvm-d0e2a253de141373be9f9f0c7f9c66589fab7f70.tar.bz2
crosvm-d0e2a253de141373be9f9f0c7f9c66589fab7f70.tar.lz
crosvm-d0e2a253de141373be9f9f0c7f9c66589fab7f70.tar.xz
crosvm-d0e2a253de141373be9f9f0c7f9c66589fab7f70.tar.zst
crosvm-d0e2a253de141373be9f9f0c7f9c66589fab7f70.zip
crosvm: treat FailEntry as fatal to a vcpu
FailEntry indicates an arch-specific failure to enter a VM. Treat this as
fatal to the vcpu.

Pass the u64 hardware failure reason from the kvm_run struct up to the client.

BUG=chromium:1036009
TEST=crosvm on hatch nested VM dies immediately instead of infinite looping

Change-Id: Iecb279b5b08ae1edc085717dce65e3ca46cbd30e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1977221
Tested-by: kokoro <noreply+kokoro@google.com>
Tested-by: Stephen Barber <smbarber@chromium.org>
Reviewed-by: Stephen Barber <smbarber@chromium.org>
Commit-Queue: Stephen Barber <smbarber@chromium.org>
-rw-r--r--kvm/src/lib.rs17
-rw-r--r--src/linux.rs6
2 files changed, 21 insertions, 2 deletions
diff --git a/kvm/src/lib.rs b/kvm/src/lib.rs
index bc1abad..c5da845 100644
--- a/kvm/src/lib.rs
+++ b/kvm/src/lib.rs
@@ -1128,7 +1128,9 @@ pub enum VcpuExit {
     Hlt,
     IrqWindowOpen,
     Shutdown,
-    FailEntry,
+    FailEntry {
+        hardware_entry_failure_reason: u64,
+    },
     Intr,
     SetTpr,
     TprAccess,
@@ -1786,7 +1788,18 @@ impl RunnableVcpu {
                 KVM_EXIT_HLT => Ok(VcpuExit::Hlt),
                 KVM_EXIT_IRQ_WINDOW_OPEN => Ok(VcpuExit::IrqWindowOpen),
                 KVM_EXIT_SHUTDOWN => Ok(VcpuExit::Shutdown),
-                KVM_EXIT_FAIL_ENTRY => Ok(VcpuExit::FailEntry),
+                KVM_EXIT_FAIL_ENTRY => {
+                    // Safe because the exit_reason (which comes from the kernel) told us which
+                    // union field to use.
+                    let hardware_entry_failure_reason = unsafe {
+                        run.__bindgen_anon_1
+                            .fail_entry
+                            .hardware_entry_failure_reason
+                    };
+                    Ok(VcpuExit::FailEntry {
+                        hardware_entry_failure_reason,
+                    })
+                }
                 KVM_EXIT_INTR => Ok(VcpuExit::Intr),
                 KVM_EXIT_SET_TPR => Ok(VcpuExit::SetTpr),
                 KVM_EXIT_TPR_ACCESS => Ok(VcpuExit::TprAccess),
diff --git a/src/linux.rs b/src/linux.rs
index 57b3ef5..62bfd68 100644
--- a/src/linux.rs
+++ b/src/linux.rs
@@ -1346,6 +1346,12 @@ fn run_vcpu(
                         }
                         Ok(VcpuExit::Hlt) => break,
                         Ok(VcpuExit::Shutdown) => break,
+                        Ok(VcpuExit::FailEntry {
+                            hardware_entry_failure_reason,
+                        }) => {
+                            error!("vcpu hw run failure: {:#x}", hardware_entry_failure_reason);
+                            break;
+                        },
                         Ok(VcpuExit::SystemEvent(_, _)) => break,
                         Ok(r) => warn!("unexpected vcpu exit: {:?}", r),
                         Err(e) => match e.errno() {