virtio-devices: console: Fix atomic corruption in ConsoleResizer

The update_console_size method was using fetch_and on the acked_features
atomic, which modified the atomic and cleared other feature bits.
Changed it to use a non-destructive load and bitwise AND.

Signed-off-by: Andrei Vagin <avagin@google.com>
This commit is contained in:
Andrei Vagin
2026-03-05 23:01:11 +00:00
committed by Wei Liu
parent 01e4053bef
commit 9f569c7b8d

View File

@@ -526,11 +526,7 @@ impl ConsoleResizer {
if let Some(tty) = self.tty.as_ref() {
let (cols, rows) = get_win_size(tty);
self.config.lock().unwrap().update_console_size(cols, rows);
if self
.acked_features
.fetch_and(1u64 << VIRTIO_CONSOLE_F_SIZE, Ordering::AcqRel)
!= 0
{
if self.acked_features.load(Ordering::Acquire) & (1u64 << VIRTIO_CONSOLE_F_SIZE) != 0 {
// Send the interrupt to the driver
let _ = self.config_evt.write(1);
}