MCPcopy Create free account
hub / github.com/cloud-hypervisor/cloud-hypervisor / update

Method update

vmm/src/interrupt.rs:243–295  ·  view source on GitHub ↗
(
        &self,
        index: InterruptIndex,
        config: InterruptSourceConfig,
        masked: bool,
        set_gsi: bool,
    )

Source from the content-addressed store, hash-verified

241 }
242
243 fn update(
244 &self,
245 index: InterruptIndex,
246 config: InterruptSourceConfig,
247 masked: bool,
248 set_gsi: bool,
249 ) -> Result<()> {
250 if let Some(route) = self.irq_routes.get(&index) {
251 let mut route = route.lock().unwrap();
252 let gsi = if masked {
253 match route.gsi {
254 Some(gsi) => gsi,
255 // No update needed if masked and no GSI was ever allocated
256 None => return Ok(()),
257 }
258 } else {
259 // Allocate a GSI when the interrupt vector is first unmasked
260 route.allocate_gsi()?
261 };
262
263 let entry = RoutingEntry {
264 route: self.vm.make_routing_entry(gsi, &config),
265 masked,
266 };
267
268 // When mask a msi irq, entry.masked is set to be true,
269 // and the gsi will not be passed to KVM through KVM_SET_GSI_ROUTING.
270 // So it's required to call disable() (which deassign KVM_IRQFD) before
271 // set_gsi_routes() to avoid kernel panic (see #3827)
272 if masked {
273 route.disable(self.vm.as_ref())?;
274 }
275
276 let mut routes = self.gsi_msi_routes.lock().unwrap();
277 routes.insert(gsi, entry);
278 if set_gsi {
279 self.set_gsi_routes(&routes)?;
280 }
281
282 // Assign KVM_IRQFD after KVM_SET_GSI_ROUTING to avoid
283 // panic on kernel which not have commit a80ced6ea514
284 // (KVM: SVM: fix panic on out-of-bounds guest IRQ).
285 if !masked {
286 route.enable(self.vm.as_ref())?;
287 }
288
289 return Ok(());
290 }
291
292 Err(io::Error::other(format!(
293 "update: Invalid interrupt index {index}"
294 )))
295 }
296
297 fn set_gsi(&self) -> Result<()> {
298 let routes = self.gsi_msi_routes.lock().unwrap();

Callers 1

sha256_readerMethod · 0.45

Calls 7

set_gsi_routesMethod · 0.80
getMethod · 0.45
allocate_gsiMethod · 0.45
make_routing_entryMethod · 0.45
disableMethod · 0.45
insertMethod · 0.45
enableMethod · 0.45

Tested by

no test coverage detected