From patchwork Mon Jul 10 15:35:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 701032 Delivered-To: patch@linaro.org Received: by 2002:adf:fcc5:0:0:0:0:0 with SMTP id f5csp5243662wrs; Mon, 10 Jul 2023 08:37:53 -0700 (PDT) X-Google-Smtp-Source: APBJJlEicc11pUHYBUCP7XJqNu0i/Oj/ZJnL68RXPr5MqiKTt7k5vYiNALCfMekpagZO6TGrcy8A X-Received: by 2002:a67:eb93:0:b0:444:bf88:c6d5 with SMTP id e19-20020a67eb93000000b00444bf88c6d5mr5886316vso.1.1689003473083; Mon, 10 Jul 2023 08:37:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689003473; cv=none; d=google.com; s=arc-20160816; b=beBU9ifrbuh0KiyJjVHGAvKHTCWz69mb6jBA617yR5AmXT+EIOEZCNh4yu5V1ZXQw1 8sFdNoE68GRHb3HCNCZlA++/CECwZI6sqQnzWxnKVfPHz+1keIH8urcpFVYah8NpGqHS eZVnjmkQQB5/l8zqqNJ5vriDp7KkLiGSMsXJhwLs3FaBdvvLc5wkmWXdWMPjywid+v0E TQVqjbWTH0tkyTKxPBcheDKAhaSgFHPB0AdnO8RiNSBlLL/SKpcTuwsy7PQgEjc9wqi6 Zawt4Mg/A8Egbx9JQ8+Fr+PVrUOeUdck0C6x7vOYMpvFTdbcA86DbqZphHM7V8gOtGXA s1ww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=+hje6WZSjT0couLKOVg8pz8KNazy1XWWPGcIUxlVXlw=; fh=pHpVzH22N3up2JSv0jV3vGkBG2/OCgsTpbbdQUlofss=; b=yGgNNmmYs41NNGUCE8alq1WijDSB7TeanvDCLpTv+ywfQLcRg/W+oGoeujKSQFPi0g YbbPjQw4t0MKMgNrs+b2hdZ4ovZbP2Od2U7fUjzg6F/O4WdGPaSAtH9BSNqR2rGjGuyq 8niui3M9KOl2Vh761obyBHNNvFVVT8i4lZ2fX3ZQuy9wOxRE87+nrWfpzfCM8c+vTQmU k8ZHB66LMTY0TazQGhy299HFy/KRbyqgUekcEQHDaw4IL5GoNEmtCh/9nLG4OmJXsaFD v3rmS2/CJq4mv/m+eVFIHUtqC/3dF+xz0uHG5Kj+4QgxT1o3BGHKfsGXW1hRN5+AKRCw ypLg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dScf+GYE; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id p5-20020a0c8c85000000b0062b6cdfa0a8si5506763qvb.56.2023.07.10.08.37.52 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 10 Jul 2023 08:37:53 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dScf+GYE; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qIsvi-0005xh-TA; Mon, 10 Jul 2023 11:36:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qIsvX-0005qS-E5 for qemu-devel@nongnu.org; Mon, 10 Jul 2023 11:35:52 -0400 Received: from mail-wr1-x436.google.com ([2a00:1450:4864:20::436]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qIsvJ-0004np-Gx for qemu-devel@nongnu.org; Mon, 10 Jul 2023 11:35:51 -0400 Received: by mail-wr1-x436.google.com with SMTP id ffacd0b85a97d-31434226a2eso5489673f8f.1 for ; Mon, 10 Jul 2023 08:35:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1689003336; x=1691595336; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=+hje6WZSjT0couLKOVg8pz8KNazy1XWWPGcIUxlVXlw=; b=dScf+GYEj3ctwO9WuCXFy0yxJ3B0LV0V0i8bC1r6JpbiaAldVwo/K8eKPwhd/jg/pI 2jLPNATky/tXkRu2pPN8+ioJ97SQUzIlDpQLrxDSlvwfVfWbThhbQrbNBYSEtrCnRtL5 D7roIwllb2KQ2lhMVeuxvMyeE2bCgCOyJkHj3vWjkJEK1eQXm1PDbsr1y9RPsbHqxK3g g4i9CY2MWPTZZ7n5c5jqdl6l5dtXGUHtrMNgwnkAFio/uKQe5zWfwF+Y7TdFKDOJDEbr Vwxa/MDPutQf07jM78ZWbk5VhP2xZwFAsmcLSL7K34PP8WESfI9RNkae8oYxfTJ0FcqJ n/bg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689003336; x=1691595336; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+hje6WZSjT0couLKOVg8pz8KNazy1XWWPGcIUxlVXlw=; b=juLsGsN2GYm+88d9Xng2f5LLd/5xLMWRSE9ycmgrsOsOcq93SjcKOn/3D4hvWut0VJ S32kp7t1tkhXR3TnLmNLydqiUZq9uqpdLMlmPZM9xdYM5zZD7CX2X6uLmjpnb28XW23R 88l0VxB+M8il4OagXimRbzyqJX8V7LP2lj1V1LpfGBN624M9sy82YFz5WAlGy+WMX6b8 7AM9YqPIx430jkQQb9/AuK01HhwkOHTeHtRsURPS2WL3gxSKx9OzYI8tcbpAmdMxX9rW WjLlQCjj6q4KayW18Jl6CIweR+0qMXOV+uGksh4yI+Eff5jhmyvPNupJA8smoa7vMpO/ hySw== X-Gm-Message-State: ABy/qLZMuG9sA+dmPUgWXZuoRA8smlmz9+SHaYyhMdF4RPv44yf7xbmM xnT6dJnBvUzlIt1FLYpnOcweqg== X-Received: by 2002:a5d:52cc:0:b0:314:f7e:8755 with SMTP id r12-20020a5d52cc000000b003140f7e8755mr14618439wrv.55.1689003335788; Mon, 10 Jul 2023 08:35:35 -0700 (PDT) Received: from zen.linaroharston ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id k6-20020adfd846000000b00314315071bbsm12040583wrl.38.2023.07.10.08.35.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jul 2023 08:35:33 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 553FF1FFCC; Mon, 10 Jul 2023 16:35:24 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Jason Wang , Viresh Kumar , Raphael Norwitz , Paolo Bonzini , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , qemu-block@nongnu.org, Eric Blake , "Michael S. Tsirkin" , Mark Cave-Ayland , Kevin Wolf , Markus Armbruster , Gerd Hoffmann , Mathieu Poirier , Hanna Reitz , =?utf-8?q?Alex_Benn=C3=A9e?= , Erik Schilling , "Gonglei (Arei)" , Eduardo Habkost , Fam Zheng , virtio-fs@redhat.com, Stefan Hajnoczi Subject: [RFC PATCH v3 18/20] hw/virtio: validate F_STANDALONE also supports other protocol features Date: Mon, 10 Jul 2023 16:35:20 +0100 Message-Id: <20230710153522.3469097-19-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230710153522.3469097-1-alex.bennee@linaro.org> References: <20230710153522.3469097-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::436; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x436.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org If the backend advertises F_STANDALONE validate that it supports the other mandatory features or error out. Signed-off-by: Alex Bennée --- hw/virtio/vhost-user.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c index 28b021d5d3..3116b3e46a 100644 --- a/hw/virtio/vhost-user.c +++ b/hw/virtio/vhost-user.c @@ -74,6 +74,8 @@ enum VhostUserProtocolFeature { /* Feature 14 reserved for VHOST_USER_PROTOCOL_F_INBAND_NOTIFICATIONS. */ VHOST_USER_PROTOCOL_F_CONFIGURE_MEM_SLOTS = 15, VHOST_USER_PROTOCOL_F_STATUS = 16, + VHOST_USER_PROTOCOL_F_XEN_MMAP = 17, + VHOST_USER_PROTOCOL_F_STANDALONE = 18, VHOST_USER_PROTOCOL_F_MAX }; @@ -2048,6 +2050,21 @@ static int vhost_user_backend_init(struct vhost_dev *dev, void *opaque, } } + /* + * If the backend supports F_STANDALONE we should validate it + * supports the other features we expect. We can't check for + * F_CONFIG support until we know if there is a config space + * to manage. + */ + if (virtio_has_feature(protocol_features, + VHOST_USER_PROTOCOL_F_STANDALONE)) { + if (!virtio_has_feature(protocol_features, VHOST_USER_PROTOCOL_F_STATUS)) { + error_setg(errp, "vhost-user device expecting F_STANDALONE device to also " + "support F_STATUS but it does not."); + return -EPROTO; + } + } + /* final set of protocol features */ dev->protocol_features = protocol_features; err = vhost_user_set_protocol_features(dev, dev->protocol_features);