From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AFED1CCA482 for ; Fri, 1 Jul 2022 06:31:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235031AbiGAGbb (ORCPT ); Fri, 1 Jul 2022 02:31:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36006 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232260AbiGAGba (ORCPT ); Fri, 1 Jul 2022 02:31:30 -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 39BE91402E for ; Thu, 30 Jun 2022 23:31:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1656657088; 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=t4mq0djcD9YM3JASrOeZhnSSARiulyBSa0GkqeNjlYw=; b=JZhvhR+f+kWD4Dcc8nshOcQE+cHPYJ3T0hJRHxwa0unW9J39bCxSB/Wt5KAWXZCFFUPnpO i4ZlpH9fc3z7VtXmcfs+sPDqwbylli8811UCRKKSz3pyPdrJbH6y5g5Hv6is+rX3BP9Qxp HnxGI5njVb6Ix7TBKD7Q6IYf9FfvrnE= Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-279-vyEdNDOvMR2KkaFL7e1y9Q-1; Fri, 01 Jul 2022 02:31:27 -0400 X-MC-Unique: vyEdNDOvMR2KkaFL7e1y9Q-1 Received: by mail-ed1-f70.google.com with SMTP id q18-20020a056402519200b004358ce90d97so1100164edd.4 for ; Thu, 30 Jun 2022 23:31:27 -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=t4mq0djcD9YM3JASrOeZhnSSARiulyBSa0GkqeNjlYw=; b=Pt/yJQQQiXPl38TCr4J+TKZAamtSM85UgJLt1BH94TkS2e7enipuAifZf1fytOxAPd x2Yszxs5wbUr3eOlh3Sc8H3e/X4QUwDGjaSG6GajGViAX+Yhn//kpt74ljeplwXZjzFq c9LGGH5hX/eFeU4eRKyIkHszxFK8KrGVXwTll7Xjtq7upm9Lr8z+l9KJig8rV+t/JUEA sqs2Fbkfcm2+g+ktu/xQoio0EWVcU47ItGdvQaXJN57CqRQitzhG2oQ1EZ/pjgthDfox LNUKUM7CB9TS447JF2Qw6IKbDmUEWEvwLPVs/M6ogtV4rAMfYToqASduUEkuJhPCDhlG gI/A== X-Gm-Message-State: AJIora+OOv5ezF5nv/LOQd7GaAu3jbnUfCHr2ZNv0evzIJmpbYrpLkYF uYMOT/JzKD5XRSMpqcy3gjUEoNVBfSnWGh+ANYgoJX3ZzRtsBK+Aw4oLc23e9yoCbwQT4Mvwtca aUHJvYnYm0oxppsB1 X-Received: by 2002:a17:907:2704:b0:72a:596f:8b9f with SMTP id w4-20020a170907270400b0072a596f8b9fmr7711917ejk.761.1656657086008; Thu, 30 Jun 2022 23:31:26 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uBC6Csq0KK3mHQr921uHGRsVzPm9YamAGsOXqm/7tt8aIzVOGmGN35oK+8gpDy+vr5kzch1Q== X-Received: by 2002:a17:907:2704:b0:72a:596f:8b9f with SMTP id w4-20020a170907270400b0072a596f8b9fmr7711894ejk.761.1656657085791; Thu, 30 Jun 2022 23:31:25 -0700 (PDT) Received: from redhat.com ([2.55.3.188]) by smtp.gmail.com with ESMTPSA id ia10-20020a170907a06a00b0070b7875aa6asm9874051ejc.166.2022.06.30.23.31.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Jun 2022 23:31:25 -0700 (PDT) Date: Fri, 1 Jul 2022 02:31:18 -0400 From: "Michael S. Tsirkin" To: Xuan Zhuo Cc: virtualization@lists.linux-foundation.org, Richard Weinberger , Anton Ivanov , Johannes Berg , Jason Wang , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Hans de Goede , Mark Gross , Vadim Pasternak , Bjorn Andersson , Mathieu Poirier , Cornelia Huck , Halil Pasic , Eric Farman , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Sven Schnelle , Alexei Starovoitov , Daniel Borkmann , Jesper Dangaard Brouer , John Fastabend , Vincent Whitchurch , linux-um@lists.infradead.org, netdev@vger.kernel.org, platform-driver-x86@vger.kernel.org, linux-remoteproc@vger.kernel.org, linux-s390@vger.kernel.org, kvm@vger.kernel.org, bpf@vger.kernel.org, kangjie.xu@linux.alibaba.com Subject: Re: [PATCH v11 25/40] virtio: allow to unbreak/break virtqueue individually Message-ID: <20220701022950-mutt-send-email-mst@kernel.org> References: <20220629065656.54420-1-xuanzhuo@linux.alibaba.com> <20220629065656.54420-26-xuanzhuo@linux.alibaba.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220629065656.54420-26-xuanzhuo@linux.alibaba.com> Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On Wed, Jun 29, 2022 at 02:56:41PM +0800, Xuan Zhuo wrote: > This patch allows the new introduced > __virtqueue_break()/__virtqueue_unbreak() to break/unbreak the > virtqueue. > > Signed-off-by: Xuan Zhuo I wonder how this interacts with the hardening patches. Jason? > --- > drivers/virtio/virtio_ring.c | 24 ++++++++++++++++++++++++ > include/linux/virtio.h | 3 +++ > 2 files changed, 27 insertions(+) > > diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c > index 5ec43607cc15..7b02be7fce67 100644 > --- a/drivers/virtio/virtio_ring.c > +++ b/drivers/virtio/virtio_ring.c > @@ -2744,6 +2744,30 @@ unsigned int virtqueue_get_vring_size(struct virtqueue *_vq) > } > EXPORT_SYMBOL_GPL(virtqueue_get_vring_size); > > +/* > + * This function should only be called by the core, not directly by the driver. > + */ > +void __virtqueue_break(struct virtqueue *_vq) > +{ > + struct vring_virtqueue *vq = to_vvq(_vq); > + > + /* Pairs with READ_ONCE() in virtqueue_is_broken(). */ > + WRITE_ONCE(vq->broken, true); > +} > +EXPORT_SYMBOL_GPL(__virtqueue_break); > + > +/* > + * This function should only be called by the core, not directly by the driver. > + */ > +void __virtqueue_unbreak(struct virtqueue *_vq) > +{ > + struct vring_virtqueue *vq = to_vvq(_vq); > + > + /* Pairs with READ_ONCE() in virtqueue_is_broken(). */ > + WRITE_ONCE(vq->broken, false); > +} I don't think these "Pairs" comments have any value. > +EXPORT_SYMBOL_GPL(__virtqueue_unbreak); > + > bool virtqueue_is_broken(struct virtqueue *_vq) > { > struct vring_virtqueue *vq = to_vvq(_vq); > diff --git a/include/linux/virtio.h b/include/linux/virtio.h > index 1272566adec6..dc474a0d48d1 100644 > --- a/include/linux/virtio.h > +++ b/include/linux/virtio.h > @@ -138,6 +138,9 @@ bool is_virtio_device(struct device *dev); > void virtio_break_device(struct virtio_device *dev); > void __virtio_unbreak_device(struct virtio_device *dev); > > +void __virtqueue_break(struct virtqueue *_vq); > +void __virtqueue_unbreak(struct virtqueue *_vq); > + > void virtio_config_changed(struct virtio_device *dev); > #ifdef CONFIG_PM_SLEEP > int virtio_device_freeze(struct virtio_device *dev); > -- > 2.31.0