Compare commits

...

3 Commits

Author SHA1 Message Date
Yi Wang 9f346ae461
Merge a511497b0a into e99540e5e9 2024-04-05 08:53:53 -07:00
dependabot[bot] e99540e5e9 build: Bump serde_json from 1.0.114 to 1.0.115 in /fuzz
Bumps [serde_json](https://github.com/serde-rs/json) from 1.0.114 to 1.0.115.
- [Release notes](https://github.com/serde-rs/json/releases)
- [Commits](https://github.com/serde-rs/json/compare/v1.0.114...v1.0.115)

---
updated-dependencies:
- dependency-name: serde_json
  dependency-type: indirect
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-04-05 00:05:39 +00:00
Yi Wang a511497b0a vmm: interrupt: fix kernel panic on out-of-bounds guest IRQ
It may casue kernel out-of-bounds panic when set_gsi_routing
before irq routing update using enable(). Though kernel
has been fixed this in commit a80ced6e(KVM: SVM: fix panic on
out-of-bounds guest IRQ) which has not been include in 5.15, it's
better to avoid this in cloud-hypervisor.

It is worth noting that when unmask a gsi disable() should be
called before set_gsi_routing(), as entry.masked is set to be
true so we should call disable() before set_gsi_routing() update
the kvm->irq_routing.

Signed-off-by: Yi Wang <foxywang@tencent.com>
2024-04-03 12:07:35 +08:00
2 changed files with 18 additions and 7 deletions

4
fuzz/Cargo.lock generated
View File

@ -720,9 +720,9 @@ dependencies = [
[[package]]
name = "serde_json"
version = "1.0.114"
version = "1.0.115"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c5f09b1bd632ef549eaa9f60a1f8de742bdbc698e6cee2095fc84dde5f549ae0"
checksum = "12dc5c46daa8e9fdf4f5e71b6cf9a53f2487da0e86e55808e2d35539666497dd"
dependencies = [
"itoa",
"ryu",

View File

@ -177,18 +177,29 @@ impl InterruptSourceGroup for MsiInterruptGroup {
route: self.vm.make_routing_entry(route.gsi, &config),
masked,
};
// When mask a msi irq, entry.masked is set to be true,
// and the gsi will not be passed to KVM through KVM_SET_GSI_ROUTING.
// so it's safe to call disable() which deassign KVM_IRQFD
// before set_gsi_routes().
if masked {
route.disable(&self.vm)?;
} else {
route.enable(&self.vm)?;
}
let mut routes = self.gsi_msi_routes.lock().unwrap();
routes.insert(route.gsi, entry);
if set_gsi {
return self.set_gsi_routes(&routes);
} else {
return Ok(());
self.set_gsi_routes(&routes)?;
}
// Assign KVM_IRQFD after KVM_SET_GSI_ROUTING to avoid
// panic on kernel which not have commit a80ced6ea514
// (KVM: SVM: fix panic on out-of-bounds guest IRQ).
if !masked {
route.enable(&self.vm)?;
}
return Ok(());
}
Err(io::Error::new(