NetBSD Problem Report #57358

From www@netbsd.org  Sun Apr 16 18:13:35 2023
Return-Path: <www@netbsd.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits))
	(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id 53C291A9239
	for <gnats-bugs@gnats.NetBSD.org>; Sun, 16 Apr 2023 18:13:35 +0000 (UTC)
Message-Id: <20230416181333.A16101A923A@mollari.NetBSD.org>
Date: Sun, 16 Apr 2023 18:13:33 +0000 (UTC)
From: campbell+netbsd@mumble.net
Reply-To: campbell+netbsd@mumble.net
To: gnats-bugs@NetBSD.org
Subject: panic: kernel diagnostic assertion "ret == 0" failed: file "/home/riastradh/netbsd/current/src/sys/dev/virtio/viocon.c", line 458
X-Send-Pr-Version: www-1.0

>Number:         57358
>Category:       kern
>Synopsis:       panic: kernel diagnostic assertion "ret == 0" failed: file "/home/riastradh/netbsd/current/src/sys/dev/virtio/viocon.c", line 458
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    yamaguchi
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Apr 16 18:15:01 +0000 2023
>Closed-Date:    Wed Sep 06 12:10:05 +0000 2023
>Last-Modified:  Wed Sep 06 12:10:05 +0000 2023
>Originator:     Taylor R Campbell
>Release:        current
>Organization:
The NetBSD Condation
>Environment:
>Description:
# cu -l /dev/ttyVI00
Connected
[  47.4172685] panic: kernel diagnostic assertion "ret == 0" failed: file "/home/riastradh/netbsd/current/src/sys/dev/virtio/viocon.c", line 458
[  47.4172685] cpu0: Begin traceback...
[  47.4172685] trace fp ffffc000bf0279a0
[  47.4172685] fp ffffc000bf0279d0 vpanic() at ffffc000005d23a8 netbsd:vpanic+0x178
[  47.4172685] fp ffffc000bf027a30 kern_assert() at ffffc0000086dc28 netbsd:kern_assert+0x58
[  47.4172685] fp ffffc000bf027ac0 vioconstart() at ffffc000003e5050 netbsd:vioconstart+0x200
[  47.4172685] fp ffffc000bf027b30 ttwrite() at ffffc000005fb7d8 netbsd:ttwrite+0x284
[  47.4172685] fp ffffc000bf027c00 cdev_write() at ffffc000005b9698 netbsd:cdev_write+0x88
[  47.4172685] fp ffffc000bf027c50 spec_write() at ffffc0000065d724 netbsd:spec_write+0xe4
[  47.4172685] fp ffffc000bf027ce0 VOP_WRITE() at ffffc0000064de24 netbsd:VOP_WRITE+0x130
[  47.4172685] fp ffffc000bf027d50 vn_write() at ffffc00000644ea8 netbsd:vn_write+0x108
[  47.4172685] fp ffffc000bf027da0 dofilewrite() at ffffc000005e4bc0 netbsd:dofilewrite+0x70
[  47.4172685] fp ffffc000bf027e20 syscall() at ffffc000000b424c netbsd:syscall+0x19c
[  47.4172685] tf ffffc000bf027ed0 el0_trap() at ffffc000000b77f0 netbsd:el1_trap_exit+0x68
[  47.4172685] ---- SVC Instruction Execution: trapframe 0xffffc000bf027ed0 (304 bytes) ----

>How-To-Repeat:
# add to GENERIC
viocon* at virtio?

# run on host
qemu-system-* ... -device virtio-serial -chardev socket,path=/tmp/ttyVI00,server=on,wait=off,id=ttyVI00 -device virtconsole,chardev=ttyVI00,name=org.NetBSD.dev.ttyVI00 ...

# run in guest
cu -l /dev/ttyVI00
>Fix:
Yes, please!

>Release-Note:

>Audit-Trail:

Responsible-Changed-From-To: kern-bug-people->yamaguchi
Responsible-Changed-By: riastradh@NetBSD.org
Responsible-Changed-When: Sun, 16 Apr 2023 18:30:29 +0000
Responsible-Changed-Why:
regression likely in the recent virtio(4) rototill


From: "Shoichi YAMAGUCHI" <yamaguchi@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/57358 CVS commit: src/sys/dev/pci
Date: Wed, 19 Apr 2023 00:38:30 +0000

 Module Name:	src
 Committed By:	yamaguchi
 Date:		Wed Apr 19 00:38:30 UTC 2023

 Modified Files:
 	src/sys/dev/pci: virtio.c

 Log Message:
 Fix not to allocate unnecessary descriptor

 fixes PR/57358


 To generate a diff of this commit:
 cvs rdiff -u -r1.75 -r1.76 src/sys/dev/pci/virtio.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

State-Changed-From-To: open->feedback
State-Changed-By: dholland@NetBSD.org
State-Changed-When: Fri, 12 May 2023 18:41:15 +0000
State-Changed-Why:
fixed?


From: "Martin Husemann" <martin@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/57358 CVS commit: [netbsd-10] src/sys/dev
Date: Sat, 3 Jun 2023 14:40:26 +0000

 Module Name:	src
 Committed By:	martin
 Date:		Sat Jun  3 14:40:25 UTC 2023

 Modified Files:
 	src/sys/dev/pci [netbsd-10]: virtio.c virtio_pci.c virtiovar.h
 	src/sys/dev/virtio [netbsd-10]: virtio_mmio.c

 Log Message:
 Pull up following revision(s) (requested by yamaguchi in ticket #186):

 	sys/dev/pci/virtio_pci.c: revision 1.41
 	sys/dev/pci/virtio_pci.c: revision 1.42
 	sys/dev/virtio/virtio_mmio.c: revision 1.10
 	sys/dev/pci/virtiovar.h: revision 1.29
 	sys/dev/pci/virtio.c: revision 1.75
 	sys/dev/pci/virtio.c: revision 1.76
 	sys/dev/pci/virtio.c: revision 1.77
 	sys/dev/pci/virtio.c: revision 1.78

 virtio@pci: Fix assertion on detach.

 If the child never attached in the first place, it's OK for it to not
 have detached.

 XXX This should not be a set of flags; this should be a state
 enumeration, because some flags make no sense, like FINISHED|FAILED.

 XXX This should not be asserted separately in each bus; there should
 be a single place in virtio.c to assert this, uniformly in all buses.

 PR kern/57357

 Use enumeration for state of a child driver instead of flags
 and check its detaching by using sc->sc_child in virtio_softc
 pointed out by riastradh, thanks.
 fixes PR/57357

 Fix not to allocate unnecessary descriptor
 fixes PR/57358

 virtio(4): change variable name, nfc

 virtio(4): change members of struct vring_desc_extra before free a slot

 This prevents the following race condition.
 1. Thread-A: calls virtio_dequeue_commit() and
              puts a slot into free descriptor chain in vq_free_slot()
 2. Thread-B: calls virtio_enqueue_prep() and get the slot stored by Thread-A
 3. Thread-B: calls virtio_enqueue_reserve() and
              changes desc_base and desc_free_idx for the slot
 4. Thread-A: changes the same members updated by Thread-B
 reported by hannken, thanks.


 To generate a diff of this commit:
 cvs rdiff -u -r1.63.2.4 -r1.63.2.5 src/sys/dev/pci/virtio.c
 cvs rdiff -u -r1.38.4.1 -r1.38.4.2 src/sys/dev/pci/virtio_pci.c
 cvs rdiff -u -r1.24.4.1 -r1.24.4.2 src/sys/dev/pci/virtiovar.h
 cvs rdiff -u -r1.7.4.1 -r1.7.4.2 src/sys/dev/virtio/virtio_mmio.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

State-Changed-From-To: feedback->closed
State-Changed-By: riastradh@NetBSD.org
State-Changed-When: Wed, 06 Sep 2023 12:10:05 +0000
State-Changed-Why:
fixed and pulled up to 10, not relevant to earlire branches
thanks!


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.47 2022/09/11 19:34:41 kim Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2023 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.