diff --git a/graphics/virtio-gpud/src/scheme.rs b/graphics/virtio-gpud/src/scheme.rs index a874d782cd..c7b3bed07a 100644 --- a/graphics/virtio-gpud/src/scheme.rs +++ b/graphics/virtio-gpud/src/scheme.rs @@ -370,6 +370,11 @@ impl<'a> SchemeMut for Scheme<'a> { fn fsync(&mut self, id: usize) -> syscall::Result { let handle = self.handles.get(&id).ok_or(SysError::new(EINVAL))?; + if handle.vt != *handle.display.active_vt.borrow() { + // This is a protection against background VT's spamming us with flush requests. We will + // flush the resource on the next scanout anyway + return Ok(0); + } futures::executor::block_on(handle.display.flush(handle.vt, None)).unwrap(); Ok(0) } @@ -395,6 +400,12 @@ impl<'a> SchemeMut for Scheme<'a> { ) -> syscall::Result { let handle = self.handles.get(&id).ok_or(SysError::new(EINVAL))?; + if handle.vt != *handle.display.active_vt.borrow() { + // This is a protection against background VT's spamming us with flush requests. We will + // flush the resource on the next scanout anyway + return Ok(buf.len()); + } + let damage = unsafe { core::slice::from_raw_parts( buf.as_ptr() as *const Damage,