Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp2400570ioo; Sat, 28 May 2022 12:26:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzb4hG2QvKwHTp+n4xq7uQf63oCla6qq4NRHxVQFGKO6h232/mWooe3Pa+GXXoXmtjdN3WN X-Received: by 2002:a17:902:b688:b0:162:3124:cde2 with SMTP id c8-20020a170902b68800b001623124cde2mr28875851pls.166.1653765977253; Sat, 28 May 2022 12:26:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653765977; cv=none; d=google.com; s=arc-20160816; b=L9LNjdKxlPLlTJ99R8mOqF1bdEC9X68oDexvD67pDjDZHg0wVnKQdgMViClOElZuZh 0bCyehqRL2E3Qa3Q7HS60Kguzx1ANTZOS10E7CPCsSJHWmgsrvx9B0ofEeQlKqPO1CCn e5skSyyo/hYYrUvTuoMK8GZlGKUokeMzqfpxCJdUTJRP1q+bpBhnr468wAG73sr9HHus bgOcKMeoiVim+kzodAtjpJ5aQkQvXl25tWE6gY63kWO3on+6YF6JX1r5nRAI3TsE4fyG SFkDAzjeAoes+Q/9SF3HkKtMedP8+QOI3fPGwg+UAcycUiTmmCG+tcc31LoBi3px3pvT OhFQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=l2Lh+gpGDkrHKWoEv+QKFc0qknv05ZH2I5oLoT3BQ3w=; b=eWSmQtvb5GakTYlARrR1TU61f8FThO/hhr29JK9ifWpE2ZW0UrDzk06Y0BkTe8DJdX 1BzEStsqo0x6t+1SavxJWfoKBhQDdM1Rl7AZPw5RtQQMaBpYu5m3DlHQoV1OM4qybua2 CMUWIty2oMSNhhyZ3Amu0l0nGo3xbaajdQ3dNUsn+DGkq6o31dj1lRetVh9CEWgyFzOw eF7sNHUJqS9pxgfj3ktz8UH4RjBZr9YrtFgYTtM3HA5rSqVnqhFKOvfl8NYL3mx/Vl3I P367dPKhLp8Ic77QSEEwtq6bUeekCqB15z8xNRS4sDspNYpQXDfPuJuljjoPrMO4bxXV 6ZZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ez9AvT1B; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id k66-20020a632445000000b003fba6069b4dsi7524678pgk.74.2022.05.28.12.26.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 May 2022 12:26:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ez9AvT1B; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id A45E5506C7; Sat, 28 May 2022 11:55:53 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244306AbiE0KuL (ORCPT + 99 others); Fri, 27 May 2022 06:50:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35270 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242000AbiE0KuJ (ORCPT ); Fri, 27 May 2022 06:50:09 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 65F1912B02B for ; Fri, 27 May 2022 03:50:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1653648607; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=l2Lh+gpGDkrHKWoEv+QKFc0qknv05ZH2I5oLoT3BQ3w=; b=ez9AvT1B4NZ/MUDoOykLozkTNl8FJXcGC15qzLS0DRTXuXdkh63SwQEPnVC0UWwRtiA3sC 2hxEopK8rrOzSipx/hZOzvb/vrd6hHPHXKOFv7/uc0fl5/eBb83K2zzHvMBs3A0eDTi5ga WXKypaY0X0DhTZWNPXoeAi2l7lEuYk8= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-387-yJuHBR7mOgqLnyaEAAbrJA-1; Fri, 27 May 2022 06:50:06 -0400 X-MC-Unique: yJuHBR7mOgqLnyaEAAbrJA-1 Received: by mail-wm1-f72.google.com with SMTP id m10-20020a05600c3b0a00b003948b870a8dso4645661wms.2 for ; Fri, 27 May 2022 03:50:06 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=l2Lh+gpGDkrHKWoEv+QKFc0qknv05ZH2I5oLoT3BQ3w=; b=21pkoYYB/muzoYit4Gw5n8kXYv7l2mADQpdW3waaLaVrB2sUDVml8hxh+tjw2y5v6w jT2Stvbta9SwBnaI8ClfWSCbmN/eGU1dOQRgpclh5BAw4W6FY1hHGMn3RjhPVIp0QXdO 7/25fdFsZmqeHkFt/mEjl6hi+QPucmu9CILI65iZK3SKv2UCB8NHQMRj0WQv7SMqiRZ9 3wHgv8ZeupPM8GU/LmDE5IapUu24hcqveoSHY3d3S4xZX193ZEtVtporng0C1X36AAqV 1g2cPe0BWopWveWSWK9Orp4WuaGJ4/lJUpgQIk2V5jXM4QVCup5AfFP+iADm8jO4RgWh zONA== X-Gm-Message-State: AOAM530eDaNmYr8B29pc0t46sx+cNdgFsRest8w2OC/zri66xqVqqJji lClN/ejOLCnOzuYqs8f6vlVDb/Y0yohcOA4WiTtX3OTepAUJb8JD+hiwzB7wJRB6K/V8k5W/M7O gJzOqtZ/X+8WH7RpkWzijucsl X-Received: by 2002:adf:d1e7:0:b0:20f:dd30:489b with SMTP id g7-20020adfd1e7000000b0020fdd30489bmr19682800wrd.94.1653648605107; Fri, 27 May 2022 03:50:05 -0700 (PDT) X-Received: by 2002:adf:d1e7:0:b0:20f:dd30:489b with SMTP id g7-20020adfd1e7000000b0020fdd30489bmr19682778wrd.94.1653648604834; Fri, 27 May 2022 03:50:04 -0700 (PDT) Received: from redhat.com ([2.55.130.213]) by smtp.gmail.com with ESMTPSA id r2-20020a7bc082000000b00397402ae674sm1828344wmh.11.2022.05.27.03.50.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 May 2022 03:50:04 -0700 (PDT) Date: Fri, 27 May 2022 06:50:00 -0400 From: "Michael S. Tsirkin" To: Jason Wang Cc: virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org, tglx@linutronix.de, peterz@infradead.org, paulmck@kernel.org, maz@kernel.org, pasic@linux.ibm.com, cohuck@redhat.com, eperezma@redhat.com, lulu@redhat.com, sgarzare@redhat.com, xuanzhuo@linux.alibaba.com, Vineeth Vijayan , Peter Oberparleiter , linux-s390@vger.kernel.org Subject: Re: [PATCH V6 9/9] virtio: use WARN_ON() to warning illegal status value Message-ID: <20220527064118-mutt-send-email-mst@kernel.org> References: <20220527060120.20964-1-jasowang@redhat.com> <20220527060120.20964-10-jasowang@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220527060120.20964-10-jasowang@redhat.com> X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org At a minimum, I don't see why it's part of the series. Host can always crash the guest if it wants to ... The point of BUG_ON is device or driver is already corrupted so we should not try to drive it. If you still want this in pls come up with a better commit log explaining the why. On Fri, May 27, 2022 at 02:01:20PM +0800, Jason Wang wrote: > We used to use BUG_ON() in virtio_device_ready() to detect illegal not really, BUG_ON just crashes the kernel. we detect by checking status. > status value, this seems sub-optimal since the value is under the > control of the device. Switch to use WARN_ON() instead. some people use crash on warn so ... > > Cc: Thomas Gleixner > Cc: Peter Zijlstra > Cc: "Paul E. McKenney" > Cc: Marc Zyngier > Cc: Halil Pasic > Cc: Cornelia Huck > Cc: Vineeth Vijayan > Cc: Peter Oberparleiter > Cc: linux-s390@vger.kernel.org > Signed-off-by: Jason Wang > --- > include/linux/virtio_config.h | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/include/linux/virtio_config.h b/include/linux/virtio_config.h > index d4edfd7d91bb..9a36051ceb76 100644 > --- a/include/linux/virtio_config.h > +++ b/include/linux/virtio_config.h > @@ -255,7 +255,7 @@ void virtio_device_ready(struct virtio_device *dev) > { > unsigned status = dev->config->get_status(dev); > > - BUG_ON(status & VIRTIO_CONFIG_S_DRIVER_OK); > + WARN_ON(status & VIRTIO_CONFIG_S_DRIVER_OK); > we lose debuggability as guest will try to continue. if we are doing this let us print a helpful message and dump a lot of state right here. > /* > * The virtio_synchronize_cbs() makes sure vring_interrupt() > -- > 2.25.1