mirror of
https://chromium.googlesource.com/crosvm/crosvm
synced 2024-12-26 13:10:56 +00:00
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>
This commit is contained in:
parent
5fc80ebd71
commit
1776c645c9
1 changed files with 8 additions and 4 deletions
|
@ -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(())
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue