Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp3127657rdb; Tue, 6 Feb 2024 07:57:19 -0800 (PST) X-Google-Smtp-Source: AGHT+IHKhj7Cs0+lq5SpeP14WEXdvJClD7pAdfusjnOK7vF5xKxdmemi3p9LbxWfuI3fQZV4fqdY X-Received: by 2002:a17:906:5ac8:b0:a36:917f:556e with SMTP id x8-20020a1709065ac800b00a36917f556emr2128111ejs.15.1707235039114; Tue, 06 Feb 2024 07:57:19 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707235039; cv=pass; d=google.com; s=arc-20160816; b=WuJPtcejzauf3ZkbwcMljIthI00AeUsCE5vuSkCuksNjIMd2jNKRmDrr24bWnGT9n+ s5Qckprfh2dOPt6yS6V6bWowwp9ZS+UZ4c5aop0z4Vu71E2KZT8OkrQJo0W4qIrGCLMg DFUDp8uV6P479cpRL5UmfzuqCHVN9ZXgicBjmNoV0kqxwkNuPMzflbjBOngCX4aEYuHi pAVrNI3YD0fHtEOOVBcQKyQMfuj32g0MzBadQ7oD0KoO8v3HLeDkMW6l7qlnQnym/tfj h/4YlnvoCBDwimnTZ2oARrOt2tWMcUvaH3q2GIKk7z6N1FP2czvDCi4nITnOVePDGfWL hvRw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=OaTEG/kcinyrw5Lp6MTv1pW09dqJMhWlKXXDkBtUnZU=; fh=fTPekQw4pcJXapqL0xsVfArpmOP20ewt4efsMNsvXIY=; b=s5EQqJMrLTQlg88rydjSJvwh5MJzUEHqrbWgrU+b7EwxFzjvuQVygbVBTI/Km0OQSS Z3zJhmD/tJuYiznnaE6R/CgY8mU7Su2FR6IPX35YldKTJLHoeAvvMNMOmS4BAM/W/sk1 zYpE9M++lfFYLvRGmfTr36eeK/AXo0XV0wAWnK2Ep5CdL3uK/KC0L+U2I8B09FPjiw+T MVKVdw4DbfSwp/9xq8T6vlUY4sL1bSF9BnoS8KSgkJbK0fr8VAdQGX7/0oTAMSxMRj6L ndpJVeS+mNQx10JI52RbiYTVjgpTcnQuRQK8iZ/P1d1WjGBx4hh3apO3axdaZX/v2RTw xI1g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=CC8CTamr; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-55286-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-55286-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Forwarded-Encrypted: i=1; AJvYcCUi9FtpgyE0cr2vMnqfSoAOyXZLhjn8mwxdw4RSYtjmoIj22zpEP9AmaJWfTDRUqgBi39nYdd45jz4CT5MreslGBapht3a7KkptFpFk/A== Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id n22-20020a170906379600b00a37bf0b2220si1231547ejc.454.2024.02.06.07.57.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 07:57:19 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-55286-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=CC8CTamr; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-55286-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-55286-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id D9E831F27054 for ; Tue, 6 Feb 2024 15:57:18 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 30A5D134CEB; Tue, 6 Feb 2024 15:57:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="CC8CTamr" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 819A213473E for ; Tue, 6 Feb 2024 15:56:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707235021; cv=none; b=UO+c/XOyhlxZ/MXf13XEBcRgA98WsiFDeb016fDwfc/E7Pj44v+AWe27HHBopw5n5mcgH1bDlR01f9MOapcU3W1wqblrJPYOqvg5uAGudlY3TwrolU3Zcl+fAIG6hAfKrqZDCbEV15i/6sm/t6+Jd9r85Oz9tHRFGivAshJM4JA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707235021; c=relaxed/simple; bh=F/z9jhc2DNpq42Uj0IwIW4uQheTDId/6OFJGQsAfoP0=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=BH7iHoS0zxE0WxYbQnFxwSwv6eAWRu4053DAFr2MJWt4GjekTg3dLRANo+hjdS47uZzMCFGZNyh8CJRAv/MfwLXnzfDok2zqB5cua3SQ1rOwONVEY462N0CHfCAuNZodom+I4fzVYB4RrEnjoDDIpxdi8X8/jZwrPPFXawRTCH8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=CC8CTamr; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1707235018; 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=OaTEG/kcinyrw5Lp6MTv1pW09dqJMhWlKXXDkBtUnZU=; b=CC8CTamrdS/IieWz0w9zD2mbvo1lGLe+q/4JcyWbXutLNC1FBvrbZ1JX3GzuJr09rgo/q3 BYERBrQ9sIY79lErecLQ02yza1iYjuLQ97C6fxGq8siVooutzqhMNmqlPzrL/4VTimku7o uEzoxBWiJdL3fPL8760pwEi0W+IuiC4= Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-497-CDzoUVetPMmgmprhCM_YKA-1; Tue, 06 Feb 2024 10:56:56 -0500 X-MC-Unique: CDzoUVetPMmgmprhCM_YKA-1 Received: by mail-ed1-f71.google.com with SMTP id 4fb4d7f45d1cf-55fcdc80ddbso2581278a12.0 for ; Tue, 06 Feb 2024 07:56:56 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707235015; x=1707839815; 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=OaTEG/kcinyrw5Lp6MTv1pW09dqJMhWlKXXDkBtUnZU=; b=Oa7f+6/ZM3/p96ss8Ykqkh2eYy+VYpiKSENvIBhYwoVtAN0dgzrAZRKYRl+Wm15K2G TQczyaLsX34cXNGalz4PfGThJkmXcBXzqxEdTpvqvvcZnJMDd4AreDzyvjCi52DJtPoR 5CuSjy9XOAeKDDnJ0OXGiZVunNQAHtAs2ysYn7Y9iR2foWeRpYmDFWSxCr051/kDFR1u d812OUsaKeg2dlF0rHQPNlD+ORiX/dOCSlNYS3m1FcBhwt+8OH8e+RoweMWB5kqYgfKg Ji+2ogOknkiELsdWU8Recw9GjH/Tg1PuYgVyffwMavf53u+e1jQZfXGh+O6C/p1CERUj 1b/g== X-Gm-Message-State: AOJu0YxafHaOjgDUgG6pimrcCL7EirjYYpzliUMtgQYUASFg2UbH13OI hYkeP5x/VI7Fsw/1xFJ4E99MSno29aGv9Y6g0IZ1gB8fERmQtrSTqvq3ajtuuQwLdGxzUOVR/0T LP73NrxhV8qXzG6DngJTA3ZnTfenGn/ooAeZ87riWd6oJeDC/DAchj4X7NlscWg== X-Received: by 2002:a05:6402:31a2:b0:560:c1cc:ba9 with SMTP id dj2-20020a05640231a200b00560c1cc0ba9mr416728edb.28.1707235015563; Tue, 06 Feb 2024 07:56:55 -0800 (PST) X-Received: by 2002:a05:6402:31a2:b0:560:c1cc:ba9 with SMTP id dj2-20020a05640231a200b00560c1cc0ba9mr416706edb.28.1707235015186; Tue, 06 Feb 2024 07:56:55 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCVqSkksK7XpMD9RJv1iaBa7WpQTCPLDeXDC+QEQcTfC56ij53hliMpewCvvKdqyxFlPXjoAg8KIKMRTPTLM5OZeKRYMhXoegc0ER6Q9YzkeecTdAOW981jgJe0/INtGfdeZiuthTuP7bcF6zohPqycrmuIWxC9BvSlWeiMeABUpsUGZ7k0x04Vso0b15PKJoIrx0HhEmxjyDOqnDnEkcGnQVafnwWoSUBtlxmYe/219a3DWagn2tevXtOSIV0O7UBE4jYS+1E7b4dQWDyPf Received: from redhat.com ([2.52.129.159]) by smtp.gmail.com with ESMTPSA id w13-20020aa7da4d000000b00560422bd11asm1160996eds.30.2024.02.06.07.56.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 07:56:54 -0800 (PST) Date: Tue, 6 Feb 2024 10:56:50 -0500 From: "Michael S. Tsirkin" To: Stefano Garzarella Cc: virtualization@lists.linux.dev, Shannon Nelson , Eugenio =?iso-8859-1?Q?P=E9rez?= , kvm@vger.kernel.org, Kevin Wolf , Jason Wang , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] vhost-vdpa: fail enabling virtqueue in certain conditions Message-ID: <20240206105558-mutt-send-email-mst@kernel.org> References: <20240206145154.118044-1-sgarzare@redhat.com> 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: <20240206145154.118044-1-sgarzare@redhat.com> better @subj: try late vq enable only if negotiated On Tue, Feb 06, 2024 at 03:51:54PM +0100, Stefano Garzarella wrote: > If VHOST_BACKEND_F_ENABLE_AFTER_DRIVER_OK is not negotiated, we expect > the driver to enable virtqueue before setting DRIVER_OK. If the driver > tries anyway, better to fail right away as soon as we get the ioctl. > Let's also update the documentation to make it clearer. > > We had a problem in QEMU for not meeting this requirement, see > https://lore.kernel.org/qemu-devel/20240202132521.32714-1-kwolf@redhat.com/ > > Fixes: 9f09fd6171fe ("vdpa: accept VHOST_BACKEND_F_ENABLE_AFTER_DRIVER_OK backend feature") > Cc: eperezma@redhat.com > Signed-off-by: Stefano Garzarella > --- > include/uapi/linux/vhost_types.h | 3 ++- > drivers/vhost/vdpa.c | 4 ++++ > 2 files changed, 6 insertions(+), 1 deletion(-) > > diff --git a/include/uapi/linux/vhost_types.h b/include/uapi/linux/vhost_types.h > index d7656908f730..5df49b6021a7 100644 > --- a/include/uapi/linux/vhost_types.h > +++ b/include/uapi/linux/vhost_types.h > @@ -182,7 +182,8 @@ struct vhost_vdpa_iova_range { > /* Device can be resumed */ > #define VHOST_BACKEND_F_RESUME 0x5 > /* Device supports the driver enabling virtqueues both before and after > - * DRIVER_OK > + * DRIVER_OK. If this feature is not negotiated, the virtqueues must be > + * enabled before setting DRIVER_OK. > */ > #define VHOST_BACKEND_F_ENABLE_AFTER_DRIVER_OK 0x6 > /* Device may expose the virtqueue's descriptor area, driver area and > diff --git a/drivers/vhost/vdpa.c b/drivers/vhost/vdpa.c > index bc4a51e4638b..1fba305ba8c1 100644 > --- a/drivers/vhost/vdpa.c > +++ b/drivers/vhost/vdpa.c > @@ -651,6 +651,10 @@ static long vhost_vdpa_vring_ioctl(struct vhost_vdpa *v, unsigned int cmd, > case VHOST_VDPA_SET_VRING_ENABLE: > if (copy_from_user(&s, argp, sizeof(s))) > return -EFAULT; > + if (!vhost_backend_has_feature(vq, > + VHOST_BACKEND_F_ENABLE_AFTER_DRIVER_OK) && > + (ops->get_status(vdpa) & VIRTIO_CONFIG_S_DRIVER_OK)) > + return -EINVAL; > ops->set_vq_ready(vdpa, idx, s.num); > return 0; > case VHOST_VDPA_GET_VRING_GROUP: > -- > 2.43.0