From nobody Fri Apr 17 04:46:27 2026 Received: from mail-wm1-f54.google.com (mail-wm1-f54.google.com [209.85.128.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E8D56330D2A for ; Mon, 23 Feb 2026 17:37:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771868258; cv=none; b=eRqk0G/7iKkWEuSL6H8blAmJsgvy21SgvktbXeJtE5ZWiyedXUZ17TSHjY/ATMJI4b8qgZUt44biZN4ExPaZoRoIiA4FKh/ziX/BovbTP3qOxkS4DCvBpEILy03/C78YfoqsInq8cD3riKne09VfiYrlGZzLlRlay6RU4VToYlM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771868258; c=relaxed/simple; bh=bNE1C/ycXlu3DoYv5hPAJ1NqqZt7vvoqqFWzSQqVdcM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:To:Cc; b=o5gUJ1SSgoB6Qxpt/Ml5l5Bfw0gEaHC+HC15YZb/aVykbXMdtTYoHrGsKxoaTobxv64M1xIBV2NTpgoDNfH0m+gvANVYSu1xN2ySqkeE3pXgJpIe5vwP11aU9JwPMGHxKE4rk1XN8FhKUJF3nNoOVHkXqWC3qHaO+SK9sxkXh1k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=KCcWNvbM; arc=none smtp.client-ip=209.85.128.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="KCcWNvbM" Received: by mail-wm1-f54.google.com with SMTP id 5b1f17b1804b1-48370174e18so25039275e9.2 for ; Mon, 23 Feb 2026 09:37:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1771868255; x=1772473055; darn=vger.kernel.org; h=cc:to:message-id:content-transfer-encoding:mime-version:subject :date:from:from:to:cc:subject:date:message-id:reply-to; bh=aqudQbT7/MPE0BjTOSVNKoEUnhB2WCPkvdNMz5SxcQI=; b=KCcWNvbM2OFLVdrwl+NwCFbTUmr8XGRWzYqyNFxmv4oSnu10s5aDEhto/JXr8YMHbb yVkks57v5ACsLZQJGM2Y4JekyejCr5qZuGcNG3QLxMuALAc1qWYQKsAcXJJ9cyQvDHED 1PBvATv9btDL24DMU0mu0weBBjP+CyJor8RPqhzXTPRPCX0uZ8CNOWsVbWiAgoxSt9rH DHg1deKAxENNroFZd7gyqOag/MNN7sVu0090E8K/0k2RgqDM783+gCDBbbHgX3KohizB YReslYAwNxF4VPpeyp7Yzqv1714hMw0metd+x//ZVnQ1x8g6uFPZaWKciP3G0ILIeiFV emIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771868255; x=1772473055; h=cc:to:message-id:content-transfer-encoding:mime-version:subject :date:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=aqudQbT7/MPE0BjTOSVNKoEUnhB2WCPkvdNMz5SxcQI=; b=EFxsQPS84NiME39u25vFDxSvv72/R+wPbE0mo8x4m2q9MbsKx8rn163gT0/Ngdoak3 sqQJX2/mcKuDx+LIq9pl5ugG7sk6ekcUStm1Wtxy16Glw3idM5WknxRG1usEwnU4wxcv SlL1eObAMvK5xs7iuyDZkgP6pyujeY9F6CIkTt0UmmeEOcvpv+8OmrbwrYOAOIFnErB9 yCsCl/WlZieYwhSnLNpuY/DLdammpEyerS4Dfh0SJsCCo47KengConrr7GAEPABMwnvN qm+ix0MDbt4ymXW7ehKpCLw26Jw6/x31ikbLuKy22uDCH2+i9EOPQ+iQpzPIdYjL0QpP bSsw== X-Forwarded-Encrypted: i=1; AJvYcCXGVi9hw61Nhenhw8u2tUDc7CY/rDT1FXbm72snL0ZaWob5XOEYGy+EHw3vsaj7ntCERAVh78FTnGtnxX8=@vger.kernel.org X-Gm-Message-State: AOJu0YwKTheEhBBwDewrOqM7ltUBgjfSLCwwhQPQJXwwM9ptBkhgr9f6 /T6DQNugHP8ECW/pRa3j5+b6G4nuFLaN3QtjvtQuOmP2EBOkAiiCYSEZozwI/ROb X-Gm-Gg: AZuq6aJzEAYdQojWWha9d3qsAbx73ifSMl8JSPXuvNAc7fcMavxpE9JAASCCxbVJ9K8 v5zhYYdu/MFIw5F4sYZTd7DzaKrU/uhq1Vx/7d5jiAsmfaYyHLxVq4GpOPeUdIJQjqN9yUDNMUk bXKO0vtVFZXmdT9p5WHy+fJnJkjWDRtr4GNmok+rEfC/hAPTQJ6N0N0Gsda7SjTIZX/0U75InNO fKnzIpriH0YP88/4uKuCKU50Qo58VzweRhp9CSt5Duq0nqmSLfBCurQWRuvyacWxU5qghbJlDrn 6qlvO1VBS3aI8UspBnRo1G4AbQXuiTz+jOLYfiBYJ1A7Ywyflj3kDQMmSt2t2CibLVKOxHXcOvb zmzIO+XZI6QDGBJJFShNC5NwB9ZxRUKZ9Pk7JGZAP5i9B6B1M5AzHXWp5rr5lyffRZtP48KaGLv 10wntilVEI3W3vlXkzD+93lw== X-Received: by 2002:a05:600c:1c04:b0:480:1b65:b741 with SMTP id 5b1f17b1804b1-483a95cfc62mr177427845e9.15.1771868254679; Mon, 23 Feb 2026 09:37:34 -0800 (PST) Received: from localhost ([89.150.43.23]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-43970d3ff27sm22403922f8f.22.2026.02.23.09.37.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Feb 2026 09:37:34 -0800 (PST) From: Filip Hejsek Date: Mon, 23 Feb 2026 18:37:02 +0100 Subject: [PATCH RESEND] virtio_console: read size from config space during device init Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260223-virtio-console-fix-v1-1-0cf08303b428@gmail.com> To: Amit Shah , Arnd Bergmann , Greg Kroah-Hartman , Rusty Russell Cc: "Michael S. Tsirkin" , virtualization@lists.linux.dev, linux-kernel@vger.kernel.org X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1771868253; l=4024; i=filip.hejsek@gmail.com; s=20250912; h=from:subject:message-id; bh=bNE1C/ycXlu3DoYv5hPAJ1NqqZt7vvoqqFWzSQqVdcM=; b=lp8kdQlCCgnQtMa8C7vRgUSI7TnDds3ZVs1AdbQIEpUq7q8dq5pICepK/m8EZrIJcX+yltyxE qtFxaw1slVjDu0yGmY4YkfAYnKKgKX5mpzIzt4fYvV2AlYITn7VdZWx X-Developer-Key: i=filip.hejsek@gmail.com; a=ed25519; pk=nakB8gEK3oi+Q/5dBTMCy/LgZL47NP60z1jeDR6O/WU= Previously, the size was only read upon receiving the config interrupt. This interrupt is sent when the size changes. However, we also need to read the initial size. Also make sure to only read the size from config if F_SIZE is enabled. Fixes: 9778829cffd4 ("virtio: console: Store each console's size in the con= sole structure") Signed-off-by: Filip Hejsek --- This is a resend of [1], which hasn't received any response. I found this bug while developing patches for QEMU that add virtio console resize support. If you want to test this, you can get my QEMU patches from [2]. You will need to disable multiport using `-device virtio-serial,max_ports=3D1`. [1]: https://lore.kernel.org/all/20251224-virtio-console-fix-v1-1-69d034969= 2dc@gmail.com/ [2]: https://lore.kernel.org/all/20250921-console-resize-v5-0-89e3c6727060@= gmail.com/ I'll also repeat my questions from the previous submission here. These are things that confused me when I was trying to understand the surrounding cod= e, but should in no way prevent merging this patch. - Why does use_multiport use __virtio_test_bit instead of virtio_has_feature? - The VIRTIO_CONSOLE_RESIZE handler sets irq_requested to 1, which I think makes no sense? --- drivers/char/virtio_console.c | 52 ++++++++++++++++++++++++++-------------= ---- 1 file changed, 31 insertions(+), 21 deletions(-) diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c index 088182e54d..c355f6d392 100644 --- a/drivers/char/virtio_console.c +++ b/drivers/char/virtio_console.c @@ -1771,32 +1771,40 @@ static void config_intr(struct virtio_device *vdev) schedule_work(&portdev->config_work); } =20 -static void config_work_handler(struct work_struct *work) +static void update_size_from_config(struct ports_device *portdev) { - struct ports_device *portdev; + struct virtio_device *vdev; + struct port *port; + u16 rows, cols; =20 - portdev =3D container_of(work, struct ports_device, config_work); - if (!use_multiport(portdev)) { - struct virtio_device *vdev; - struct port *port; - u16 rows, cols; + vdev =3D portdev->vdev; =20 - vdev =3D portdev->vdev; - virtio_cread(vdev, struct virtio_console_config, cols, &cols); - virtio_cread(vdev, struct virtio_console_config, rows, &rows); + /* + * We'll use this way of resizing only for legacy support. + * For multiport devices, use control messages to indicate + * console size changes so that it can be done per-port. + * + * Don't test F_SIZE at all if we're rproc: not a valid feature. + */ + if (is_rproc_serial(vdev) || + use_multiport(portdev) || + !virtio_has_feature(vdev, VIRTIO_CONSOLE_F_SIZE)) + return; =20 - port =3D find_port_by_id(portdev, 0); - set_console_size(port, rows, cols); + virtio_cread(vdev, struct virtio_console_config, cols, &cols); + virtio_cread(vdev, struct virtio_console_config, rows, &rows); =20 - /* - * We'll use this way of resizing only for legacy - * support. For newer userspace - * (VIRTIO_CONSOLE_F_MULTPORT+), use control messages - * to indicate console size changes so that it can be - * done per-port. - */ - resize_console(port); - } + port =3D find_port_by_id(portdev, 0); + set_console_size(port, rows, cols); + resize_console(port); +} + +static void config_work_handler(struct work_struct *work) +{ + struct ports_device *portdev; + + portdev =3D container_of(work, struct ports_device, config_work); + update_size_from_config(portdev); } =20 static int init_vqs(struct ports_device *portdev) @@ -2054,6 +2062,8 @@ static int virtcons_probe(struct virtio_device *vdev) __send_control_msg(portdev, VIRTIO_CONSOLE_BAD_ID, VIRTIO_CONSOLE_DEVICE_READY, 1); =20 + update_size_from_config(portdev); + return 0; =20 free_chrdev: --- base-commit: b927546677c876e26eba308550207c2ddf812a43 change-id: 20251224-virtio-console-fix-3d46980ef569 Best regards, --=20 Filip Hejsek