vmentry.rs0.00%
1
// Copyright 2024 Google LLC2
//3
// Licensed under the Apache License, Version 2.0 (the "License");4
// you may not use this file except in compliance with the License.5
// You may obtain a copy of the License at6
//7
// https://www.apache.org/licenses/LICENSE-2.08
//9
// Unless required by applicable law or agreed to in writing, software10
// distributed under the License is distributed on an "AS IS" BASIS,11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.12
// See the License for the specific language governing permissions and13
// limitations under the License.14
15
use std::io::ErrorKind;16
17
use snafu::ResultExt;18
19
use crate::hv::hvf::check_ret;20
use crate::hv::hvf::vcpu::HvfVcpu;21
use crate::hv::{Result, error};22
use crate::sys::hvf::hv_vcpu_set_reg;23
24
impl HvfVcpu {25
pub fn entry_mmio(&mut self, data: u64) -> Result<()> {26
let Some(reg) = self.exit_reg.take() else {27
return Err(ErrorKind::InvalidInput.into()).context(error::RunVcpu);28
};29
let ret = unsafe { hv_vcpu_set_reg(self.vcpu_id, reg, data) };30
check_ret(ret).context(error::VcpuReg)31
}32
}33