Alioth Code Coverage

vmentry.rs0.00%

1// Copyright 2024 Google LLC
2//
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 at
6//
7// https://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// 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 and
13// limitations under the License.
14
15use std::io::ErrorKind;
16
17use snafu::ResultExt;
18
19use crate::hv::hvf::check_ret;
20use crate::hv::hvf::vcpu::HvfVcpu;
21use crate::hv::{Result, error};
22use crate::sys::hvf::hv_vcpu_set_reg;
23
24impl 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