From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f45.google.com (mail-wr1-f45.google.com [209.85.221.45]) (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 3624926A0B9 for ; Sun, 2 Aug 2026 19:48:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.45 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785700112; cv=none; b=cEMqnjhX1kt71tK2oaodLbncUv4Q5ImrBf4VR7CTpr9aMK4NrpkAXPtc957FEodIKzJBE5hLE+GTcUemAN7a4aO3VJqXwqmfnp+exiDSY7qBK0U1AgmBiPXkQK4UML2XoMF0uOJ4ZTEIaVlRLD7vpHwjYbCIPRx3vZmyC22aixA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785700112; c=relaxed/simple; bh=LkBm8EG2uZavCvEVbOADDIQOY5+xUftLQcPsVAGPXO8=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=UCCyqSs0vQ/+V38bxwxduT9zqInBn3Kf/tMAQGhAtL8aL+F0x4Uxlcx7cPw2OeQ3ckIUCmW/EBLF3GYZHzHwrR79X1lZL+NT7lCTYobUbJSzPfgSTomzzVFGJBLupKRHrXsYzhDduu46BmAhUx+0SzUHEjszzNQ/m6Ibi0IL744= 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=myQuttQi; arc=none smtp.client-ip=209.85.221.45 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="myQuttQi" Received: by mail-wr1-f45.google.com with SMTP id ffacd0b85a97d-47362928f65so2637076f8f.2 for ; Sun, 02 Aug 2026 12:48:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1785700109; x=1786304909; darn=vger.kernel.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=I8QMn2ksXm3uoxHvww2d4cky/knVUFaCbpvrqdsZVhI=; b=myQuttQizn+XR13ZueHfIWFU9RbqF6z9WYMQ3G1cWIeWmRuuOy0O7VwSfSV/HPrzkT Z5Lvu822tW5wYFbxa5YXqmzZyoDME6xKFSYXJgLnpC/N6p+lssLWqjTivNh5X+yoALpH mQzh3PK5P3hnSSw24qgYz5y3ZL5nReGe2khGTxpfN7EFOnCrhXQWhaJTuZSnCyF/up6/ /U91mOy/mxU+wLz7Qbame2LEMc9fvL3M8+Pw6ui3cpMWNFai3+iwTlnHgeCppi0ahxNa 9B4MUUuV9Xg1IlNRfObx8L9M72xkPWiWx15Kr9gyWnGb3sx9fgFFtx2MhnhGnJ4t/3yY s+qw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785700109; x=1786304909; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=I8QMn2ksXm3uoxHvww2d4cky/knVUFaCbpvrqdsZVhI=; b=BDcRV1AKubaz8Ar71bQeAkdA8hkXIQ7tY/Of9l1uTlKGuUm4QZck0RwvPL7zMhZ1Co kqRedslt2UXdPiytmwRTjZGew6h/gGb/ZoDHr0rMB8ug6AFg/QdHuUzSZpsqFq/ABFLk 0TJox9dfmZYs5q0lMEn0sB24HSEwJckGGYaE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with SMTP id ffacd0b85a97d-47fd9f93ed8mr15437528f8f.29.1785700109211; Sun, 02 Aug 2026 12:48:29 -0700 (PDT) Received: from home-linux (dynamic-2a02-3102-44b4-cc00-3af3-abff-fe75-d5da.310.pool.telefonica.de. [2a02:3102:44b4:cc00:3af3:abff:fe75:d5da]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-47fd45895b6sm26428310f8f.26.2026.08.02.12.48.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 02 Aug 2026 12:48:28 -0700 (PDT) Date: Sun, 2 Aug 2026 21:48:26 +0200 From: Abhin Parekadan Jose To: "Michael S. Tsirkin" Cc: jasowangio@gmail.com, xuanzhuo@linux.alibaba.com, eperezma@redhat.com, virtualization@lists.linux.dev, linux-kernel@vger.kernel.org Subject: Re: [PATCH 0/2] virtio_pci_modern: fix vp_reset() hang on unresponsive device Message-ID: References: <20260802174059.4082-1-abhinjoses@gmail.com> <20260802134443-mutt-send-email-mst@kernel.org> <20260802145944-mutt-send-email-mst@kernel.org> 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=us-ascii Content-Disposition: inline In-Reply-To: <20260802145944-mutt-send-email-mst@kernel.org> On Sun, Aug 02, 2026 at 03:08:12PM -0400, Michael S. Tsirkin wrote: > On Sun, Aug 02, 2026 at 06:28:03PM +0000, Abhin Parekadan Jose wrote: > > On Sun, Aug 02, 2026 at 01:47:01PM -0400, Michael S. Tsirkin wrote: > > > On Sun, Aug 02, 2026 at 05:40:57PM +0000, Abhin Parekadan Jose wrote: > > > > While investigating a syzbot report of a WARN_ON_ONCE firing in > > > > virtio_dev_remove() [1], > > > > > > > > > And I responded to that syzbot report, and I quote: > > > > > > So it writes 0 into pci command, effectively killing the device, > > > and then is unhappy that the driver prints warnings? > > > Who thought it's a good idea? Why? > > > > I was learning how to reproduce syzbot bugs when I found this > > issue by writing 0 to PCI_COMMAND to simulate an unresponsive > > device. > > Yea I have no idea where does this syzbot "bug report" > come from. Poking at random at device registers is ... not > a very good idea. > > > While doing that I noticed that echo 1 > /sys/../remove > > hung completely rather than just printing the warning. Since the > > device_status register lives in the virtio common config MMIO > > space and has defined values(based on the bits set) in the spec. > > I thought it made sense for virtio to detect this and handle it > > gracefully rather than spin forever, so I wrote up a small fix > > for that. > > > > > > I found a related but more serious issue: > > > > vp_reset() in the modern virtio-pci transport can hang indefinitely > > > > if PCI_COMMAND memory-space decode is disabled while the device is > > > > bound (e.g. surprise removal, hardware fault, or -- as reproduced > > > > here -- a direct write to the PCI_COMMAND register). The status > > > > register poll loop has no way to distinguish "device still resetting" > > > > from "device unreachable," so it never terminates. > > > > > > > > Patch 1 adds a VIRTIO_STATUS_ERROR() check that recognizes an > > > > all-ones status read as invalid (per spec, bits 4-5 are reserved and > > > > can never legitimately be set) and warns once at the point the bad > > > > read actually happens. > > > > > > > > Patch 2 uses that check to break out of vp_reset()'s poll loop > > > > instead of spinning forever. > > > > > > Was all this including the cover letter written with ai assistance? > > > if yes pls disclose this. > > > > Yes, I used AI assistance (Claude). The commit messages were written > > by me and then refined with AI for spelling and grammar; the cover > > letter was generated by Claude and reviewed by me. > > I suggest limiting it to fixing spelling and grammar exclusively. It > tends to do things like dramatize, e.g. "more serious issue", like it > did here. > > > The code, testing, > > and debugging were done by me -- I reproduced the hang in QEMU, > > debugged to reach the hanging loop, and wrote the actual fix. > > > > I should have disclosed this upfront. I'll do so in future > > submissions. > > > > Do I need to add Assisted-by: Claude to the > > commit messages? > > Assisted-by: Claude:claude-sonnet-4-6 > > > > > > P.S. This is my first kernel patch set. > > > Thanks, keep at it. Bonus points if you find a real fix for > issues raised in thread about surprise removal, see e.g. here > cover.1752094439.git.mst@redhat.com > but don't expect it to be easy. > That looks interesting (haven't gone through in detail but got a gist of it). I'll try it out and make suggestions if I find a good solution. As for the current patch set, does it make sense to drop macro `VIRTIO_STATUS_ERROR` and use `PCI_POSSIBLE_ERROR` to break out of the loop, I could test it by actually doing a surprise removal on qemu via the monitor or just drop this patch set and try on cover.1752094439.git.mst@redhat.com patch set? > -- > MST >