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 smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 38B8DE71076 for ; Thu, 21 Sep 2023 14:04:39 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id BB62341B72; Thu, 21 Sep 2023 14:04:38 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org BB62341B72 Authentication-Results: smtp4.osuosl.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=WsyHyF92 X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id oJn7UF5UvXKK; Thu, 21 Sep 2023 14:04:35 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp4.osuosl.org (Postfix) with ESMTPS id 11EEC4185D; Thu, 21 Sep 2023 14:04:35 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 11EEC4185D Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id D78B4C0039; Thu, 21 Sep 2023 14:04:34 +0000 (UTC) Received: from smtp2.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by lists.linuxfoundation.org (Postfix) with ESMTP id BE397C0032 for ; Thu, 21 Sep 2023 14:04:33 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 8B77A40235 for ; Thu, 21 Sep 2023 14:04:33 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 8B77A40235 Authentication-Results: smtp2.osuosl.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=WsyHyF92 X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id d7XhITETRpZl for ; Thu, 21 Sep 2023 14:04:32 +0000 (UTC) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by smtp2.osuosl.org (Postfix) with ESMTPS id 6D0B24013C for ; Thu, 21 Sep 2023 14:04:32 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 6D0B24013C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695305071; 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=mYFUdBslfSemlERse4Us5f4NKymG/+Lupcjrt0UUg2s=; b=WsyHyF92vLUx2QtA8TW82B4LQpG06xOGu96R7raQ+PU6d27SBCOwcuDmBf9sSQ5xLQOsSc fwqYdgda3ZjEXJYIMBDvOv5BDhrcAsncK031Ic+wBJFRRNuCmAgjbFj0+y0ooALFKQKV7D I3KnmHsiTC65j/RuSKTpb1tmepukMbs= Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-145-88QcThnSOo6AHQGMHMurDQ-1; Thu, 21 Sep 2023 10:03:08 -0400 X-MC-Unique: 88QcThnSOo6AHQGMHMurDQ-1 Received: by mail-ej1-f70.google.com with SMTP id a640c23a62f3a-9a9d7a801a3so76021366b.2 for ; Thu, 21 Sep 2023 07:03:06 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695304980; x=1695909780; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=mYFUdBslfSemlERse4Us5f4NKymG/+Lupcjrt0UUg2s=; b=GPiyFUZwNUO5m2J0xQnldR+vfv1NW0NVBhMTo/96Ng1AXeTlogQhuhrZbM9GHEWNEq KmuotMKYhSzVVxHqy21FFGL+qCEJ8z/Dlp6asiJTb0YpKtN9WIGCMcjOO7LIG3yFHmhB zsvvzOBehtEfvMMNsSFcC1eB7rXcjDUzUwG0++UwAbkUuexYdR8RpJh9NX7VOQJb9aVx D5Am7RPIGgqTEu/Wn3RAdRKjv8zXOtgioSTUt8gzgUVp96u938VgeTqXohSpgHyZdNQy 02sgSJjVg8oUg1ssaao3AoEODzYjSLRhjhj567rKTrdcMObKACTqzUh7vcD98c0HkeCo TaTg== X-Gm-Message-State: AOJu0YylDz0/8E+VQVKCC+mi5c3j+kIX74poC35wB/WeFv9hAr2fA1Qa 8o1VLWt5KzBn2efRve3+cIqfT1INGfeh34f2cIikehpEBM+KhOkDbqKddDJjo1L7b1tW9LzWDD1 eZ6s6f+T54VV2WqDsdbboILak9468s4atiKvGPt5KhA== X-Received: by 2002:a17:906:13:b0:9a5:7e63:2e0 with SMTP id 19-20020a170906001300b009a57e6302e0mr5496748eja.30.1695304980525; Thu, 21 Sep 2023 07:03:00 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEGDrtu0JFw6590Ay/MhiYHIEI6g5Txx1wcLitr4s1+bWtmtSPAeMYJ5QGJ2kmybduZxOWLIA== X-Received: by 2002:a17:906:13:b0:9a5:7e63:2e0 with SMTP id 19-20020a170906001300b009a57e6302e0mr5496721eja.30.1695304980143; Thu, 21 Sep 2023 07:03:00 -0700 (PDT) Received: from redhat.com ([2.52.150.187]) by smtp.gmail.com with ESMTPSA id dt11-20020a170906b78b00b009ae482d70besm1079598ejb.134.2023.09.21.07.02.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Sep 2023 07:02:59 -0700 (PDT) Date: Thu, 21 Sep 2023 10:02:53 -0400 From: "Michael S. Tsirkin" To: Xuan Zhuo Subject: Re: [PATCH v14 30/42] virtio_pci: introduce helper to get/set queue reset Message-ID: <20230921100112-mutt-send-email-mst@kernel.org> References: <20220801063902.129329-1-xuanzhuo@linux.alibaba.com> <20220801063902.129329-31-xuanzhuo@linux.alibaba.com> MIME-Version: 1.0 In-Reply-To: <20220801063902.129329-31-xuanzhuo@linux.alibaba.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline Cc: Vadim Pasternak , linux-remoteproc@vger.kernel.org, Alexei Starovoitov , virtualization@lists.linux-foundation.org, Eric Dumazet , Alexander Gordeev , Anton Ivanov , linux-s390@vger.kernel.org, kvm@vger.kernel.org, Daniel Borkmann , Richard Weinberger , Vincent Whitchurch , John Fastabend , Halil Pasic , Jakub Kicinski , platform-driver-x86@vger.kernel.org, Eric Farman , Jesper Dangaard Brouer , Vasily Gorbik , kangjie.xu@linux.alibaba.com, Heiko Carstens , linux-um@lists.infradead.org, Mark Gross , Hans de Goede , Bjorn Andersson , bpf@vger.kernel.org, Paolo Abeni , Mathieu Poirier , netdev@vger.kernel.org, Cornelia Huck , Sven Schnelle , Johannes Berg , "David S. Miller" X-BeenThere: virtualization@lists.linux-foundation.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Linux virtualization List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: virtualization-bounces@lists.linux-foundation.org Sender: "Virtualization" On Mon, Aug 01, 2022 at 02:38:50PM +0800, Xuan Zhuo wrote: > Introduce new helpers to implement queue reset and get queue reset > status. > > https://github.com/oasis-tcs/virtio-spec/issues/124 > https://github.com/oasis-tcs/virtio-spec/issues/139 > > Signed-off-by: Xuan Zhuo > Acked-by: Jason Wang > --- > drivers/virtio/virtio_pci_modern_dev.c | 39 ++++++++++++++++++++++++++ > include/linux/virtio_pci_modern.h | 2 ++ > 2 files changed, 41 insertions(+) > > diff --git a/drivers/virtio/virtio_pci_modern_dev.c b/drivers/virtio/virtio_pci_modern_dev.c > index fa2a9445bb18..869cb46bef96 100644 > --- a/drivers/virtio/virtio_pci_modern_dev.c > +++ b/drivers/virtio/virtio_pci_modern_dev.c > @@ -3,6 +3,7 @@ > #include > #include > #include > +#include > > /* > * vp_modern_map_capability - map a part of virtio pci capability > @@ -474,6 +475,44 @@ void vp_modern_set_status(struct virtio_pci_modern_device *mdev, > } > EXPORT_SYMBOL_GPL(vp_modern_set_status); > > +/* > + * vp_modern_get_queue_reset - get the queue reset status > + * @mdev: the modern virtio-pci device > + * @index: queue index > + */ > +int vp_modern_get_queue_reset(struct virtio_pci_modern_device *mdev, u16 index) > +{ > + struct virtio_pci_modern_common_cfg __iomem *cfg; > + > + cfg = (struct virtio_pci_modern_common_cfg __iomem *)mdev->common; > + > + vp_iowrite16(index, &cfg->cfg.queue_select); > + return vp_ioread16(&cfg->queue_reset); > +} > +EXPORT_SYMBOL_GPL(vp_modern_get_queue_reset); > + Actually, this does not validate that the config structure is big enough. So it can access some unrelated memory. Don't know whether that's exploitable e.g. for CoCo but not nice, anyway. Need to validate the size and disable reset if it's too small. > +/* > + * vp_modern_set_queue_reset - reset the queue > + * @mdev: the modern virtio-pci device > + * @index: queue index > + */ > +void vp_modern_set_queue_reset(struct virtio_pci_modern_device *mdev, u16 index) > +{ > + struct virtio_pci_modern_common_cfg __iomem *cfg; > + > + cfg = (struct virtio_pci_modern_common_cfg __iomem *)mdev->common; > + > + vp_iowrite16(index, &cfg->cfg.queue_select); > + vp_iowrite16(1, &cfg->queue_reset); > + > + while (vp_ioread16(&cfg->queue_reset)) > + msleep(1); > + > + while (vp_ioread16(&cfg->cfg.queue_enable)) > + msleep(1); > +} > +EXPORT_SYMBOL_GPL(vp_modern_set_queue_reset); > + > /* > * vp_modern_queue_vector - set the MSIX vector for a specific virtqueue > * @mdev: the modern virtio-pci device > diff --git a/include/linux/virtio_pci_modern.h b/include/linux/virtio_pci_modern.h > index 05123b9a606f..c4eeb79b0139 100644 > --- a/include/linux/virtio_pci_modern.h > +++ b/include/linux/virtio_pci_modern.h > @@ -113,4 +113,6 @@ void __iomem * vp_modern_map_vq_notify(struct virtio_pci_modern_device *mdev, > u16 index, resource_size_t *pa); > int vp_modern_probe(struct virtio_pci_modern_device *mdev); > void vp_modern_remove(struct virtio_pci_modern_device *mdev); > +int vp_modern_get_queue_reset(struct virtio_pci_modern_device *mdev, u16 index); > +void vp_modern_set_queue_reset(struct virtio_pci_modern_device *mdev, u16 index); > #endif > -- > 2.31.0 _______________________________________________ Virtualization mailing list Virtualization@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/virtualization