mirror of
https://chromium.googlesource.com/crosvm/crosvm
synced 2024-11-25 05:03:05 +00:00
hypervisor: kvm: verify get_all_msrs gets all the MSRs
`get_msrs` truncates the vector on partial success. Haven't seen this fail. Adding the check as a precaution. Change-Id: I7c3a4c2408daa9d7a00257ae758da45011a40311 Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4515456 Reviewed-by: Elie Kheirallah <khei@google.com> Commit-Queue: Frederick Mayle <fmayle@google.com> Reviewed-by: Noah Gold <nkgold@google.com>
This commit is contained in:
parent
2d7bb01a4b
commit
6cc983d3f5
1 changed files with 10 additions and 1 deletions
|
@ -886,13 +886,22 @@ impl VcpuX86_64 for KvmVcpu {
|
|||
}
|
||||
|
||||
fn get_all_msrs(&self) -> Result<Vec<Register>> {
|
||||
let mut msrs = self
|
||||
let mut msrs: Vec<_> = self
|
||||
.kvm
|
||||
.get_msr_index_list()?
|
||||
.into_iter()
|
||||
.map(|i| Register { id: i, value: 0 })
|
||||
.collect();
|
||||
let count = msrs.len();
|
||||
self.get_msrs(&mut msrs)?;
|
||||
if msrs.len() != count {
|
||||
error!(
|
||||
"failed to get all MSRs: requested {}, got {}",
|
||||
count,
|
||||
msrs.len()
|
||||
);
|
||||
return Err(base::Error::new(libc::EPERM));
|
||||
}
|
||||
Ok(msrs)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue