Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp461563iob; Wed, 11 May 2022 19:23:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwpGthG8MdIeNfx3LFctjfD9FVH7Noo9H14rnogdrfEfKS90e7/b+nmwf1t2+RHcWpI5zDi X-Received: by 2002:a17:906:6a0e:b0:6f5:30c9:7c7d with SMTP id qw14-20020a1709066a0e00b006f530c97c7dmr25628390ejc.63.1652322184238; Wed, 11 May 2022 19:23:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652322184; cv=none; d=google.com; s=arc-20160816; b=H4nBInrZjEjKgcHIX4bKxdKuksw5ScSJspJVrWkYNAIy6JQIT1Pn9cG26GJrOzHynR T6H4XpUYf9wKMykXb5m7ISCeXhVHnUSHRf9uav46Gm9IZU00W+NdedzSLtTluthxL3S+ ToU1UBX09BSzSM88FKdBAmw5ajPuMuny+q9cV1UNh+bjD88idwb+JDBT+JIil0YFZSFO oBSP8jx804A4zLItN8iZbiwG9x0SjILncq19bs33/8Ai8vOrX4XnvFe93LJzqyWkDW7H 55TpAueNCWwg8NsTuwf+BeOGu4NFgsMl9m7xnewHiwaNZKDICCjP3e0ji/Jpw6H6MmRB BUmQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:user-agent :references:organization:in-reply-to:subject:cc:to:from :dkim-signature; bh=6XAsQFnhrZpWvc7RJwu2raTQ/L5Wv/W+iz3iayoq1a0=; b=RFmoRvLapM+T51J139qogfQQa1o7W9FJuclgQgBecTQcV0i/mxVd2iCq4kjZTvJNuv F4qmfT6rIKExSD7y8ek56/1uIG+tEkD1WYIh42bTjAg2ajst/e0mKNy+eFA1D0gPL2fC sh2b9LmTXL2lwMFXc79ROLbY0KMLS+x5wkf0+DTwmkx/62xH7jjWH3PduV1yQ7PSeSda zRqaFRaZLQVK9vSNN8I53iGbsySEGog/M9YR8q6sQIpErqv+uMXK4Na/dc6ipN5w5npq 2bjr9mvoH0+WrXt6JbLIou90Y/X/J34H22+h2K0qi7FpZ+onIIcO9GKO+6V0HExkryxu NrhA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=REf+YWLn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f12-20020a0564021e8c00b00425c39b4751si5476251edf.254.2022.05.11.19.22.38; Wed, 11 May 2022 19:23:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=REf+YWLn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236890AbiEKIol (ORCPT + 99 others); Wed, 11 May 2022 04:44:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45116 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243938AbiEKIog (ORCPT ); Wed, 11 May 2022 04:44:36 -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 A7B6D200F7D for ; Wed, 11 May 2022 01:44:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652258670; 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=6XAsQFnhrZpWvc7RJwu2raTQ/L5Wv/W+iz3iayoq1a0=; b=REf+YWLnEYGIUST6v3wPpiAawhX0i6ZLI0l9KpTQc9tVDcd7A/hGiBq8Qy0ZoKupbNQK3/ 9ajiu84pRVB1gkO3xGY1Ai9ppbQknGfOmfAstM3UYZ1gl+awqdzzpGPGNGrpWLzBNL6464 WtLD+o7TvDDRLudT4p2oY/f4MzTht90= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-669-NMVowrerMIai6WqcNK0bPA-1; Wed, 11 May 2022 04:44:27 -0400 X-MC-Unique: NMVowrerMIai6WqcNK0bPA-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B2059801210; Wed, 11 May 2022 08:44:26 +0000 (UTC) Received: from localhost (unknown [10.39.193.115]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1A9827AD9; Wed, 11 May 2022 08:44:15 +0000 (UTC) From: Cornelia Huck To: Jason Wang , "Michael S. Tsirkin" Cc: virtualization , linux-kernel , Thomas Gleixner , Peter Zijlstra , "Paul E. McKenney" , Marc Zyngier , Halil Pasic , eperezma , Cindy Lu , Stefano Garzarella , Xuan Zhuo Subject: Re: [PATCH V4 8/9] virtio: harden vring IRQ In-Reply-To: Organization: Red Hat GmbH References: <20220507071954.14455-1-jasowang@redhat.com> <20220507071954.14455-9-jasowang@redhat.com> <20220510072833-mutt-send-email-mst@kernel.org> User-Agent: Notmuch/0.34 (https://notmuchmail.org) Date: Wed, 11 May 2022 10:44:14 +0200 Message-ID: <87o804bgrl.fsf@redhat.com> MIME-Version: 1.0 Content-Type: text/plain X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Spam-Status: No, score=-3.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham 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 On Wed, May 11 2022, Jason Wang wrote: > On Tue, May 10, 2022 at 7:32 PM Michael S. Tsirkin wrote: >> >> On Sat, May 07, 2022 at 03:19:53PM +0800, Jason Wang wrote: >> > diff --git a/include/linux/virtio_config.h b/include/linux/virtio_config.h >> > index d8a2340f928e..23f1694cdbd5 100644 >> > --- a/include/linux/virtio_config.h >> > +++ b/include/linux/virtio_config.h >> > @@ -256,6 +256,18 @@ void virtio_device_ready(struct virtio_device *dev) >> > unsigned status = dev->config->get_status(dev); >> > >> > BUG_ON(status & VIRTIO_CONFIG_S_DRIVER_OK); >> > + >> > + /* >> > + * The virtio_synchronize_cbs() makes sure vring_interrupt() >> > + * will see the driver specific setup if it sees vq->broken >> > + * as false. >> > + */ >> > + virtio_synchronize_cbs(dev); >> >> since you mention vq->broken above, maybe add >> "set vq->broken to false" > > Ok. > >> >> > + __virtio_unbreak_device(dev); >> > + /* >> > + * The transport is expected ensure the visibility of >> >> to ensure > > Will fix. > >> >> > + * vq->broken >> >> let's add: "visibility by vq callbacks" > > Sure. > >> >> > before setting VIRTIO_CONFIG_S_DRIVER_OK. >> > + */ >> >> >> Can I see some analysis of existing transports showing >> this is actually the case for them? > > Yes. > >> And maybe add a comment near set_status to document the >> requirement. > > For PCI and MMIO, we can quote the memory-barriers.txt or explain that > wmb() is not needed before the MMIO writel(). > For CCW, it looks not obvious, it looks to me the IO was submitted via > __ssch() which has an inline assembly. Cornelia and Hali, could you > help me to understand if and how did virtio_ccw_set_status() can > ensure the visibility of the previous driver setup and vq->broken > here? I'm not sure I completely understand the question here, but let me try: virtio_ccw_set_status() uses a channel command to set the status, with the interesting stuff done inside ccw_io_helper(). That function - takes the subchannel lock, disabling interrupts - does the ssch; this instruction will fail if there's already another I/O in progress, or an interrupt is pending for the subchannel; on success, it is guaranteed that we'll get an interrupt eventually - unlock the subchannel, and wait for the interupt handler to eventually process the interrupt, so I guess it should see the vq->broken value? If the I/O fails, virtio_ccw_set_status() will revert its internal status to the old value. > > Thanks > >> >> > dev->config->set_status(dev, status | VIRTIO_CONFIG_S_DRIVER_OK); >> > }