Skip to content

Commit 75bb6f2

Browse files
authored
Merge branch 'cloud-hypervisor:main' into dev
2 parents b67dd09 + fa94967 commit 75bb6f2

17 files changed

Lines changed: 151 additions & 41 deletions

File tree

Cargo.lock

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ acpi_tables = "0.2.0"
5656
kvm-bindings = "0.14.0"
5757
kvm-ioctls = "0.24.0"
5858
linux-loader = "0.13.2"
59-
mshv-bindings = "0.6.7"
60-
mshv-ioctls = "0.6.7"
59+
mshv-bindings = "0.6.8"
60+
mshv-ioctls = "0.6.8"
6161
seccompiler = "0.5.0"
6262
vfio-bindings = { version = "0.6.2", default-features = false }
6363
vfio-ioctls = { version = "0.6.0", default-features = false }

fuzz/Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

fuzz/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ libc = "0.2.183"
2525
libfuzzer-sys = "0.4.12"
2626
linux-loader = { version = "0.13.2", features = ["bzimage", "elf", "pe"] }
2727
micro_http = { git = "https://github.com/firecracker-microvm/micro-http", branch = "main" }
28-
mshv-bindings = "0.6.7"
28+
mshv-bindings = "0.6.8"
2929
net_util = { path = "../net_util" }
3030
seccompiler = "0.5.0"
3131
virtio-devices = { path = "../virtio-devices" }

hypervisor/src/arch/x86/mod.rs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,36 @@ pub mod msr_index;
2828
// MTRR constants
2929
pub const MTRR_ENABLE: u64 = 0x800; // IA32_MTRR_DEF_TYPE MSR: E (MTRRs enabled) flag, bit 11
3030
pub const MTRR_MEM_TYPE_WB: u64 = 0x6;
31+
pub const MTRR_MSR_INDICES: [u32; 28] = [
32+
msr_index::MSR_MTRRdefType,
33+
msr_index::MSR_IA32_MTRR_PHYSBASE0,
34+
msr_index::MSR_IA32_MTRR_PHYSMASK0,
35+
msr_index::MSR_IA32_MTRR_PHYSBASE1,
36+
msr_index::MSR_IA32_MTRR_PHYSMASK1,
37+
msr_index::MSR_IA32_MTRR_PHYSBASE2,
38+
msr_index::MSR_IA32_MTRR_PHYSMASK2,
39+
msr_index::MSR_IA32_MTRR_PHYSBASE3,
40+
msr_index::MSR_IA32_MTRR_PHYSMASK3,
41+
msr_index::MSR_IA32_MTRR_PHYSBASE4,
42+
msr_index::MSR_IA32_MTRR_PHYSMASK4,
43+
msr_index::MSR_IA32_MTRR_PHYSBASE5,
44+
msr_index::MSR_IA32_MTRR_PHYSMASK5,
45+
msr_index::MSR_IA32_MTRR_PHYSBASE6,
46+
msr_index::MSR_IA32_MTRR_PHYSMASK6,
47+
msr_index::MSR_IA32_MTRR_PHYSBASE7,
48+
msr_index::MSR_IA32_MTRR_PHYSMASK7,
49+
msr_index::MSR_MTRRfix64K_00000,
50+
msr_index::MSR_MTRRfix16K_80000,
51+
msr_index::MSR_MTRRfix16K_A0000,
52+
msr_index::MSR_MTRRfix4K_C0000,
53+
msr_index::MSR_MTRRfix4K_C8000,
54+
msr_index::MSR_MTRRfix4K_D0000,
55+
msr_index::MSR_MTRRfix4K_D8000,
56+
msr_index::MSR_MTRRfix4K_E0000,
57+
msr_index::MSR_MTRRfix4K_E8000,
58+
msr_index::MSR_MTRRfix4K_F0000,
59+
msr_index::MSR_MTRRfix4K_F8000,
60+
];
3161

3262
// IOAPIC pins
3363
pub const NUM_IOAPIC_PINS: usize = 24;

hypervisor/src/arch/x86/msr_index.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,22 @@ pub const MSR_IA32_RTIT_ADDR3_B: ::std::os::raw::c_uint = 0x00000587;
8585
pub const MSR_IA32_RTIT_CR3_MATCH: ::std::os::raw::c_uint = 0x00000572;
8686
pub const MSR_IA32_RTIT_OUTPUT_BASE: ::std::os::raw::c_uint = 0x00000560;
8787
pub const MSR_IA32_RTIT_OUTPUT_MASK: ::std::os::raw::c_uint = 0x00000561;
88+
pub const MSR_IA32_MTRR_PHYSBASE0: ::std::os::raw::c_uint = 0x00000200;
89+
pub const MSR_IA32_MTRR_PHYSMASK0: ::std::os::raw::c_uint = 0x00000201;
90+
pub const MSR_IA32_MTRR_PHYSBASE1: ::std::os::raw::c_uint = 0x00000202;
91+
pub const MSR_IA32_MTRR_PHYSMASK1: ::std::os::raw::c_uint = 0x00000203;
92+
pub const MSR_IA32_MTRR_PHYSBASE2: ::std::os::raw::c_uint = 0x00000204;
93+
pub const MSR_IA32_MTRR_PHYSMASK2: ::std::os::raw::c_uint = 0x00000205;
94+
pub const MSR_IA32_MTRR_PHYSBASE3: ::std::os::raw::c_uint = 0x00000206;
95+
pub const MSR_IA32_MTRR_PHYSMASK3: ::std::os::raw::c_uint = 0x00000207;
96+
pub const MSR_IA32_MTRR_PHYSBASE4: ::std::os::raw::c_uint = 0x00000208;
97+
pub const MSR_IA32_MTRR_PHYSMASK4: ::std::os::raw::c_uint = 0x00000209;
98+
pub const MSR_IA32_MTRR_PHYSBASE5: ::std::os::raw::c_uint = 0x0000020a;
99+
pub const MSR_IA32_MTRR_PHYSMASK5: ::std::os::raw::c_uint = 0x0000020b;
100+
pub const MSR_IA32_MTRR_PHYSBASE6: ::std::os::raw::c_uint = 0x0000020c;
101+
pub const MSR_IA32_MTRR_PHYSMASK6: ::std::os::raw::c_uint = 0x0000020d;
102+
pub const MSR_IA32_MTRR_PHYSBASE7: ::std::os::raw::c_uint = 0x0000020e;
103+
pub const MSR_IA32_MTRR_PHYSMASK7: ::std::os::raw::c_uint = 0x0000020f;
88104
pub const MSR_MTRRfix64K_00000: ::std::os::raw::c_uint = 0x00000250;
89105
pub const MSR_MTRRfix16K_80000: ::std::os::raw::c_uint = 0x00000258;
90106
pub const MSR_MTRRfix16K_A0000: ::std::os::raw::c_uint = 0x00000259;

hypervisor/src/kvm/mod.rs

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@ pub use x86_64::{CpuId, ExtendedControlRegisters, MsrEntries, VcpuKvmState};
7070
use crate::ClockData;
7171
#[cfg(target_arch = "x86_64")]
7272
use crate::arch::x86::{
73-
CpuIdEntry, FpuState, LapicState, MsrEntry, NUM_IOAPIC_PINS, SpecialRegisters, XsaveState,
73+
CpuIdEntry, FpuState, LapicState, MTRR_MSR_INDICES, MsrEntry, NUM_IOAPIC_PINS,
74+
SpecialRegisters, XsaveState,
7475
};
7576
use crate::{CpuState, IoEventAddress, IrqRoutingEntry, MpState, StandardRegisters};
7677
// aarch64 dependencies
@@ -1128,9 +1129,21 @@ impl KvmHypervisor {
11281129
/// Retrieve the list of MSRs supported by the hypervisor.
11291130
///
11301131
fn get_msr_list(&self) -> hypervisor::Result<MsrList> {
1131-
self.kvm
1132+
let mut indices = self
1133+
.kvm
11321134
.get_msr_index_list()
1133-
.map_err(|e| hypervisor::HypervisorError::GetMsrList(e.into()))
1135+
.map_err(|e| hypervisor::HypervisorError::GetMsrList(e.into()))?
1136+
.as_slice()
1137+
.to_vec();
1138+
1139+
// KVM_GET_MSR_INDEX_LIST does not include MTRR MSRs, but firmware may update them before an early boot snapshot.
1140+
indices.extend(MTRR_MSR_INDICES);
1141+
1142+
let mut msr_list = MsrList::new(indices.len())
1143+
.map_err(|e| hypervisor::HypervisorError::GetMsrList(e.into()))?;
1144+
msr_list.as_mut_slice().copy_from_slice(&indices);
1145+
1146+
Ok(msr_list)
11341147
}
11351148
}
11361149

scripts/run_integration_tests_aarch64.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ fi
285285

286286
# Run tests on dbus_api
287287
if [ $RES -eq 0 ]; then
288-
cargo build --features "dbus_api" --all --release --target "$BUILD_TARGET"
288+
cargo build --features "mshv,dbus_api" --all --release --target "$BUILD_TARGET"
289289
export RUST_BACKTRACE=1
290290
# integration tests now do not reply on build feature "dbus_api"
291291
time cargo nextest run $test_features --retries 3 --no-fail-fast --no-tests=pass --test-threads=$(($(nproc) / 4)) "dbus_api::$test_filter" -- ${test_binary_args[*]}
@@ -294,14 +294,14 @@ fi
294294

295295
# Run tests on fw_cfg
296296
if [ $RES -eq 0 ]; then
297-
cargo build --features "fw_cfg" --all --release --target "$BUILD_TARGET"
297+
cargo build --features "mshv,fw_cfg" --all --release --target "$BUILD_TARGET"
298298
export RUST_BACKTRACE=1
299299
time cargo nextest run $test_features --retries 3 --no-fail-fast --no-tests=pass --test-threads=$(($(nproc) / 4)) "fw_cfg::$test_filter" -- ${test_binary_args[*]}
300300
RES=$?
301301
fi
302302

303303
if [ $RES -eq 0 ]; then
304-
cargo build --features "ivshmem" --all --release --target "$BUILD_TARGET"
304+
cargo build --features "mshv,ivshmem" --all --release --target "$BUILD_TARGET"
305305
export RUST_BACKTRACE=1
306306
time cargo nextest run $test_features --retries 3 --no-fail-fast --no-tests=pass --test-threads=$(($(nproc) / 4)) "ivshmem::$test_filter" -- ${test_binary_args[*]}
307307

virtio-devices/src/mem.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -834,6 +834,10 @@ impl Mem {
834834
})
835835
}
836836

837+
pub fn plugged_size(&self) -> u64 {
838+
self.config.lock().unwrap().plugged_size
839+
}
840+
837841
pub fn resize(&mut self, size: u64) -> result::Result<(), Error> {
838842
let mut config = self.config.lock().unwrap();
839843
config.resize(size).map_err(|e| {

virtio-devices/src/vdpa.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ impl Vdpa {
217217

218218
fn activate_vdpa(
219219
&mut self,
220-
mem: &GuestMemoryMmap,
220+
_mem: &GuestMemoryMmap,
221221
virtio_interrupt: &dyn VirtioInterrupt,
222222
queues: &[(usize, Queue, EventFd)],
223223
) -> Result<()> {
@@ -269,13 +269,7 @@ impl Vdpa {
269269
self.vhost
270270
.as_ref()
271271
.unwrap()
272-
.set_vring_base(
273-
*queue_index,
274-
queue
275-
.avail_idx(mem, Ordering::Acquire)
276-
.map_err(Error::GetAvailableIndex)?
277-
.0,
278-
)
272+
.set_vring_base(*queue_index, 0)
279273
.map_err(Error::SetVringBase)?;
280274

281275
if let Some(eventfd) =

0 commit comments

Comments
 (0)