From patchwork Tue Aug 29 00:12:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jordan Niethe X-Patchwork-Id: 1827043 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20221208 header.b=R3gmJE1t; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=112.213.38.117; helo=lists.ozlabs.org; envelope-from=slof-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=patchwork.ozlabs.org) Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4RZSY045bMz1yfy for ; Tue, 29 Aug 2023 10:12:19 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20221208 header.b=R3gmJE1t; dkim-atps=neutral Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4RZSXz0Spyz2ytZ for ; Tue, 29 Aug 2023 10:12:19 +1000 (AEST) X-Original-To: slof@lists.ozlabs.org Delivered-To: slof@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20221208 header.b=R3gmJE1t; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::635; helo=mail-pl1-x635.google.com; envelope-from=jniethe5@gmail.com; receiver=lists.ozlabs.org) Received: from mail-pl1-x635.google.com (mail-pl1-x635.google.com [IPv6:2607:f8b0:4864:20::635]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4RZSXr1566z2xjw for ; Tue, 29 Aug 2023 10:12:10 +1000 (AEST) Received: by mail-pl1-x635.google.com with SMTP id d9443c01a7336-1c0d5b16aacso20733705ad.1 for ; Mon, 28 Aug 2023 17:12:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1693267928; x=1693872728; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=lDv8c+XWAg1F3cIJFIQcYbWLzUD5ekuBcEW7hsJ1UXQ=; b=R3gmJE1thE8xuX4t2Ixx1I3398fJqTr/ldkuT5dY1weUbPUwfEL5fVFodJ7FD/6zR2 EKmgl8Ys/2nAlAE8RWpIqps9lRVIeYJV7gR31wICekQ5uwQ2MiKZT9EoiJhVHC0BomrG BBa8gA//umXgy9m9kPbZRzcHxAlJBRSXin7M61Ru2qqD6ahar9qVTik5KGV5o1S0rhFn OvkRq9ewysEAY1EN5jQk7xPdr+t/UOG+0tT7OUEjzL5UnQDXKc3xqOkIiAUnr+LbGhVu p88CY/Os6z745cgZ1hUN7GJ6RZI+/rO/CfscKmKbAho5vsvJdb4X+iZjnK/AQqjwiLqh DR7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693267928; x=1693872728; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=lDv8c+XWAg1F3cIJFIQcYbWLzUD5ekuBcEW7hsJ1UXQ=; b=cezIilKSivrQ5BEbHi5Hq0eAQWm0IWHKhnWbzg0P2wlh6TLBrP1K3FSmsvslc3ljNH 8jRnD/xiCROj7x5pWmxK/owv7rU+/O6jTgyJadMFKimnlv0AE+5Z8hF1pzGBWZlZNW1S 1ibnb5XVaADOwKpQvnI8KRKyPfB6Zt2Ybio6TsMcFvt9ukx5pFx2yIdh21HORIE3UNoM ubNuZaRl6Zq2+jvWKOkN9s40eAxGW1tE7Sw9F8/mm9Oe2R1eNRYrmRf3nxZzwREfxF98 IswKVoJLZyxUEajHaAq7XMGeaGAVRMqEQUHvLmAsRiJseNsXJ9m3L8C1gpSVrMaH1/kJ bw/A== X-Gm-Message-State: AOJu0YzmhdxGSruAikIbBNpQA9SUdHemu30nkOMkYAvzb31UOKnWttXO +1e9YHzM09eNu9abq30KBZ3Z2wv6utg= X-Google-Smtp-Source: AGHT+IHGqBOzBVNz9s3l7g6kqqoVtgYzvMAtEjXKh5KcWQQzmE1TfqHY4uS2lrICsLjjI4Sh2rclNQ== X-Received: by 2002:a17:902:8c8c:b0:1c1:de2b:e1d0 with SMTP id t12-20020a1709028c8c00b001c1de2be1d0mr3179060plo.32.1693267928144; Mon, 28 Aug 2023 17:12:08 -0700 (PDT) Received: from pwon.ozlabs.ibm.com ([146.112.118.69]) by smtp.gmail.com with ESMTPSA id y3-20020a170902ed4300b001b80760fd04sm7979870plb.112.2023.08.28.17.12.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Aug 2023 17:12:07 -0700 (PDT) From: Jordan Niethe To: slof@lists.ozlabs.org Date: Tue, 29 Aug 2023 10:12:00 +1000 Message-Id: <20230829001201.11892-1-jniethe5@gmail.com> X-Mailer: git-send-email 2.39.3 MIME-Version: 1.0 Subject: [SLOF] [PATCH v2 1/2] virtio-serial: Make read and write methods report failure X-BeenThere: slof@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Patches for https://github.com/aik/SLOF" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: thuth@redhat.com, kconsul@linux.vnet.ibm.com, groug@kaod.org Errors-To: slof-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "SLOF" From: Kautuk Consul The read and write methods return successfully even if the virtio device is closed (virtiodev is 0) and it is not able to send or receive any characters. Make the read and write methods return 0 to indicate they did not succeed in this case. This also fixes an invalid stack access in the read method. Fixes: 8174acd ("virtio-serial: Close device completely") Signed-off-by: Kautuk Consul Signed-off-by: Jordan Niethe Reviewed-by: Thomas Huth --- v2: - Rework commit message slightly --- board-qemu/slof/virtio-serial.fs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/board-qemu/slof/virtio-serial.fs b/board-qemu/slof/virtio-serial.fs index 82868e2..41e2e04 100644 --- a/board-qemu/slof/virtio-serial.fs +++ b/board-qemu/slof/virtio-serial.fs @@ -67,7 +67,7 @@ virtiodev virtio-serial-init drop ; : write ( addr len -- actual ) - virtiodev 0= IF nip EXIT THEN + virtiodev 0= IF 2drop 0 EXIT THEN tuck 0 ?DO dup c@ virtiodev SWAP virtio-serial-putchar @@ -78,7 +78,7 @@ virtiodev virtio-serial-init drop : read ( addr len -- actual ) 0= IF drop 0 EXIT THEN - virtiodev 0= IF nip EXIT THEN + virtiodev 0= IF drop 0 EXIT THEN virtiodev virtio-serial-haschar 0= IF 0 swap c! -2 EXIT THEN virtiodev virtio-serial-getchar swap c! 1 ;