summary refs log tree commit diff
path: root/x86_64
diff options
context:
space:
mode:
authorDylan Reid <dgreid@chromium.org>2018-03-21 18:26:22 -0700
committerchrome-bot <chrome-bot@chromium.org>2018-03-22 18:16:57 -0700
commit1776c645c9689ea740f854e77e33a0a341b9ae93 (patch)
tree1e1c98f8aaff584bdede01a4c9d81a4dc52ee3d9 /x86_64
parent5fc80ebd71eacdba5ad23f5eadfc086edda7d827 (diff)
downloadcrosvm-1776c645c9689ea740f854e77e33a0a341b9ae93.tar
crosvm-1776c645c9689ea740f854e77e33a0a341b9ae93.tar.gz
crosvm-1776c645c9689ea740f854e77e33a0a341b9ae93.tar.bz2
crosvm-1776c645c9689ea740f854e77e33a0a341b9ae93.tar.lz
crosvm-1776c645c9689ea740f854e77e33a0a341b9ae93.tar.xz
crosvm-1776c645c9689ea740f854e77e33a0a341b9ae93.tar.zst
crosvm-1776c645c9689ea740f854e77e33a0a341b9ae93.zip
x86_64: Add separate error for getting sregs
Re-using the set error could cause confusion.

BUG=none
TEST=none

Change-Id: I47445b28946484028bf96cff9ee0bc8c89b6f3e5
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/974741
Reviewed-by: Zach Reizner <zachr@chromium.org>
Diffstat (limited to 'x86_64')
-rw-r--r--x86_64/src/regs.rs12
1 files changed, 8 insertions, 4 deletions
diff --git a/x86_64/src/regs.rs b/x86_64/src/regs.rs
index 31b6bab..aac058e 100644
--- a/x86_64/src/regs.rs
+++ b/x86_64/src/regs.rs
@@ -22,10 +22,12 @@ pub enum Error {
     MsrIoctlFailed(sys_util::Error),
     /// Failed to configure the FPU.
     FpuIoctlFailed(sys_util::Error),
+    /// Failed to get sregs for this cpu.
+    GetSRegsIoctlFailed(sys_util::Error),
     /// Failed to set base registers for this cpu.
     SettingRegistersIoctl(sys_util::Error),
     /// Failed to set sregs for this cpu.
-    SRegsIoctlFailed(sys_util::Error),
+    SetSRegsIoctlFailed(sys_util::Error),
     /// Writing the GDT to RAM failed.
     WriteGDTFailure,
     /// Writing the IDT to RAM failed.
@@ -46,9 +48,11 @@ impl error::Error for Error {
                 "Setting up msrs failed",
             &Error::FpuIoctlFailed(_) =>
                 "Failed to configure the FPU",
+            &Error::GetSRegsIoctlFailed(_) =>
+                "Failed to get sregs for this cpu",
             &Error::SettingRegistersIoctl(_) =>
                 "Failed to set base registers for this cpu",
-            &Error::SRegsIoctlFailed(_) =>
+            &Error::SetSRegsIoctlFailed(_) =>
                 "Failed to set sregs for this cpu",
             &Error::WriteGDTFailure =>
                 "Writing the GDT to RAM failed",
@@ -298,12 +302,12 @@ fn setup_page_tables(mem: &GuestMemory, sregs: &mut kvm_sregs) -> Result<()> {
 /// * `mem` - The memory that will be passed to the guest.
 /// * `vcpu_fd` - The FD returned from the KVM_CREATE_VCPU ioctl.
 pub fn setup_sregs(mem: &GuestMemory, vcpu: &kvm::Vcpu) -> Result<()> {
-    let mut sregs: kvm_sregs = vcpu.get_sregs().map_err(Error::SRegsIoctlFailed)?;
+    let mut sregs: kvm_sregs = vcpu.get_sregs().map_err(Error::GetSRegsIoctlFailed)?;
 
     configure_segments_and_sregs(mem, &mut sregs)?;
     setup_page_tables(mem, &mut sregs)?; // TODO(dgreid) - Can this be done once per system instead?
 
-    vcpu.set_sregs(&sregs).map_err(Error::SRegsIoctlFailed)?;
+    vcpu.set_sregs(&sregs).map_err(Error::SetSRegsIoctlFailed)?;
 
     Ok(())
 }