From patchwork Thu Jul 28 13:55:00 2022 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: 594075 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:b345:0:0:0:0 with SMTP id w5csp546665maz; Thu, 28 Jul 2022 07:26:40 -0700 (PDT) X-Google-Smtp-Source: AGRyM1t4ZvVnJVQLX1DO3nj38VMVkYA84bzicIV3gMHNnqCuRLDk0YxGjeA+nPEO+r7IsoJY8UH8 X-Received: by 2002:a05:620a:190c:b0:6b6:3ca8:a453 with SMTP id bj12-20020a05620a190c00b006b63ca8a453mr20105852qkb.174.1659018400077; Thu, 28 Jul 2022 07:26:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659018400; cv=none; d=google.com; s=arc-20160816; b=00BnCSrYgBjFqBx8rSMdr6AN0GmHmZYLAbqQHqD9AvjwKOzKu65lSxCOkOEqXRx4pt 0ScoAHrYpI/hKf5vBFipSR+RIqjvcJzqWbxeMSZFO2yQunE7IJvcitJiUAgsQ7TuVNgu 8sVDGeDwe900cMyMbToD6OVl3AS2mipBrdLnryXRzPzchooNVDILRfO4S8tAjUkPjJ+t mq82rVq/BttD6ZwmakoLTC9iwvUNCTqPVTByGow61C8nPzAioo1zGR8ihxxhKtTI9V+m UF5KZPuZiG9kCs7S0nk5hmY8i6+F+dutu8Exvh65eXozcxIxvMJoOW4Z6c+FXg+G59sy bucQ== 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=WTel/fQ7Gj1d2ni3sryAwF0T/iksivK0kIXjy8395Xc=; b=o+acVhMc6cGyDTnCLziaQHD0y+GY8sAr5Y6fAeeHG6du3keFmI6H6FFlGtV22PTa6b duZovZ5kUF6mFbBne0bTb1PD/6kDTB0VZyMacbPvyPK/QBmyewqnj/ciiz6OvCnK803J r56+xUUogGZ9oKoft3NCo7G1//8cjlQISrkAXHJ8tPi2FuaX821kpNhgoY752D0DJoMi EJgLz9On1IgqudOB+WsHeepM/1x3PaEyYGOe9UkIScpqB+tAIoyMPV7QTpSVHhPXj6is QNijh8n2MdXBUbWs/nWwVCDv93tpS8uCW1ZXThBmzl1SxJad/FLvF8WaOYHyNLl2YqFS 2BlA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kb1xxsEz; 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 y126-20020a376484000000b006b5cd7e5c23si505229qkb.283.2022.07.28.07.26.39 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 28 Jul 2022 07:26:40 -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=kb1xxsEz; 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]:35388 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oH4TH-0006oK-KY for patch@linaro.org; Thu, 28 Jul 2022 10:26:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38898) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oH3yy-0003lT-6R for qemu-devel@nongnu.org; Thu, 28 Jul 2022 09:55:21 -0400 Received: from mail-wr1-x436.google.com ([2a00:1450:4864:20::436]:37855) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oH3yu-0000Nf-Jm for qemu-devel@nongnu.org; Thu, 28 Jul 2022 09:55:19 -0400 Received: by mail-wr1-x436.google.com with SMTP id u5so2295335wrm.4 for ; Thu, 28 Jul 2022 06:55:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=WTel/fQ7Gj1d2ni3sryAwF0T/iksivK0kIXjy8395Xc=; b=kb1xxsEzQrWgYuE2LMINFYLvrfst53N1FSmkhmBZM5MO1Sf3yZ1DaaNLnIAspPktEr ZowhjUlj2EEvVaCi/L5sEL0LO3caPfxFse0PQ53R1w4MfZdiI6rlb9Vvpz5w42k1t6DC DC+Fzfmvawm3cANMWmAB3W8h4J1TlfmxNfnnwxiVVaB5ec2TGC3OzlBpREUXvyrF4gLQ fcWEapJgh2OkKQBrbLD4R2RecCNbiUAJZGlcfv9wquM3VLE7LXXpbUnG+scdL3x9oeGz gbZs6YLnRZEg309Zrrkt4NyZ5tILOKmitD1WpNoCxm2p3ZRtWtyx/XiskPMvvWrLFD7C TD+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=WTel/fQ7Gj1d2ni3sryAwF0T/iksivK0kIXjy8395Xc=; b=BOIDMrGfZ+c/EXX/GnapKpQWV69L+JQZnV26jNFSEWwGLOhYtUaV7s1/NwUJajbGjL PTcklEYMN49Y3Fw7tWh160Rt8TJmFTb8ET9JSyKdnTmfWIa4k6ZD8ky0cAkdeURaHQiQ x+I6RrVy2shL2EPrlytk/UZFZAYf35KIRF1EfQalzlJaMZaYbssPIGWkFy9MiXyYMjuY UY07YIMOTwifQHaOfTTYr4rKrLTKiy3P/MHKGTDawFFnpHTfC/Eop35gGQDKadfmVtuW 02UW2SsnARkBSRFC0FRT4/cbNqdQXW8sXUOGyNCzPL7/2qGjoogLE2R3u9ZHgg25z/Fp yITw== X-Gm-Message-State: AJIora9XG5A3s8PX09EN8s/zAqXy1R619Q7MpApWGx8ra2L3GRhqROX2 QSCfCUvg0VfyOC+v9BpNqmi2/z5txNG81Q== X-Received: by 2002:a05:6000:78b:b0:21e:a0fd:ce with SMTP id bu11-20020a056000078b00b0021ea0fd00cemr8658386wrb.309.1659016506054; Thu, 28 Jul 2022 06:55:06 -0700 (PDT) Received: from zen.linaroharston ([185.81.254.11]) by smtp.gmail.com with ESMTPSA id v11-20020a5d43cb000000b0021ec76a0c36sm1005656wrr.106.2022.07.28.06.55.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Jul 2022 06:55:04 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id AE7731FFB8; Thu, 28 Jul 2022 14:55:03 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: mst@redhat.com, =?utf-8?q?Alex_Benn=C3=A9e?= Subject: [PATCH v2 1/4] hw/virtio: incorporate backend features in features Date: Thu, 28 Jul 2022 14:55:00 +0100 Message-Id: <20220728135503.1060062-2-alex.bennee@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220728135503.1060062-1-alex.bennee@linaro.org> References: <20220728135503.1060062-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" There are some extra bits used over a vhost-user connection which are hidden from the device itself. We need to set them here to ensure we enable things like the protocol extensions. Currently net/vhost-user.c has it's own inscrutable way of persisting this data but it really should live in the core vhost_user code. Signed-off-by: Alex Bennée Message-Id: <20220726192150.2435175-7-alex.bennee@linaro.org> Signed-off-by: Alex Bennée --- hw/virtio/vhost-user.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c index 75b8df21a4..1936a44e82 100644 --- a/hw/virtio/vhost-user.c +++ b/hw/virtio/vhost-user.c @@ -1460,7 +1460,14 @@ static int vhost_user_set_features(struct vhost_dev *dev, */ bool log_enabled = features & (0x1ULL << VHOST_F_LOG_ALL); - return vhost_user_set_u64(dev, VHOST_USER_SET_FEATURES, features, + /* + * We need to include any extra backend only feature bits that + * might be needed by our device. Currently this includes the + * VHOST_USER_F_PROTOCOL_FEATURES bit for enabling protocol + * features. + */ + return vhost_user_set_u64(dev, VHOST_USER_SET_FEATURES, + features | dev->backend_features, log_enabled); } From patchwork Thu Jul 28 13:55:01 2022 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: 594074 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:b345:0:0:0:0 with SMTP id w5csp543924maz; Thu, 28 Jul 2022 07:23:12 -0700 (PDT) X-Google-Smtp-Source: AGRyM1t0nDRPcK8uBV/6ArEUkE4ulg36qM4gfUJVUaAhQhCMPLbVueDLRBgi4ifY0BSezWYf0HAr X-Received: by 2002:a37:b147:0:b0:6b5:fa14:ac00 with SMTP id a68-20020a37b147000000b006b5fa14ac00mr20617807qkf.606.1659018192766; Thu, 28 Jul 2022 07:23:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659018192; cv=none; d=google.com; s=arc-20160816; b=Z063cFo+8wIi+uB3C1599ivM4+4wY9buH0JTDSlIK/CQKt2Wm12dhPw7jVl/fTKPGU 2CiB+fNjjNkgP46KD7T/VdHYym6Rsq5SN+Ou3ujaAQ6mD3s20gVlz4md8HBTtGpBugE/ I3ftKuX8dCg5cuA28hAUbiP9mlXFbyZAQjdLLdiuuOlrhfpAGeFbou5Hzp3zWvmXud7b /Yg86Ch62yTONFY6MqljHjYzKIxHYksncD1b1hYYd68A8FT1yJLlfSo+/RkVDBrDJcTh 5HUjEJchQ4WgUNsUFDf9lkVqjCDxQ7DUAO7S/Wt+mGbDOY/xlK4DbCRQHZU2WD3SQZuV utJw== 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=s3nGxeo53LwaMo+sziN/l2Vq3ARUUV/BFGaJ8lB68So=; b=sBkksCt65CEgfdrZfJxm6VXh/6j7MFSSdC8FOy+O0LO/Sz0JPAPXScX+RfXdIbism0 Q7ZRoOTVg3+i4+oGj8olDNM65rxWYt5DpE0/2uf7SZkpOqOrmqFHpc/zxQ/gRAY/VQoM EF9x1DXiFVK+V665zLBUUG6f+wzvvrEqGEYMLsfgK0q/rcnnANYGraY1PHaSFZm1g3Kg 7QMyMw6jRIg/OcmoUNTB+l+6yOwxobs1BEuk3htr98j8UfvNipRPPmczDTy28ab117nc KjyUodwCIeatcD7v30mRkrjTvxCTbtHE7atmECDhOkb4avHi7Ss3/mTCHmDQXdynnqXq qusg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=MGrs9tXD; 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 bs25-20020ac86f19000000b0031eda5fb76csi487216qtb.470.2022.07.28.07.23.12 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 28 Jul 2022 07:23:12 -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=MGrs9tXD; 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]:59240 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oH4Pw-0003iB-Cv for patch@linaro.org; Thu, 28 Jul 2022 10:23:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38884) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oH3yx-0003jg-AO for qemu-devel@nongnu.org; Thu, 28 Jul 2022 09:55:19 -0400 Received: from mail-wr1-x434.google.com ([2a00:1450:4864:20::434]:38777) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oH3yt-0000O8-Iz for qemu-devel@nongnu.org; Thu, 28 Jul 2022 09:55:18 -0400 Received: by mail-wr1-x434.google.com with SMTP id k8so106401wrd.5 for ; Thu, 28 Jul 2022 06:55:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=s3nGxeo53LwaMo+sziN/l2Vq3ARUUV/BFGaJ8lB68So=; b=MGrs9tXDlvLXSSn7iB84K2BjzlHGW4MRyLBsDK66IfpiJRcqVGx9gqgLojWQu6ZTmA bIOmPkjmey2DYXMe3Dm/gKxU6v89usiaFqKialqe6kzKeSRVRBqI2OTHwyDWReBqfOB3 yW1yeTsJdPqKaMDkkLdmQkZafyU60uUQ21gtRBzYdIWjweyJX49zsSAkPJ+wH2i2KgZB OQCUwqBRKS/uMUnczv/iYOmjdvkdIRr+sH5Tq0tlxNpBUri7qJO+t29trYN2bekaBBsm FkIA/q18c6fEQ++sBGfq7upoCRz5v60LlU6qOumPtIzyAlUkSp/aVgeO+eUB47m5qVHX L4wA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=s3nGxeo53LwaMo+sziN/l2Vq3ARUUV/BFGaJ8lB68So=; b=kVR7tdVa+z/Dt/rirWA6VN3sR9OhwhWKJqhmvPCxJkwXILFzumFRfwo9lDY3+bqyZt OpzqROSP4zrmXkKb8X1L8gEOJHeTHL4Oja3KCkYegym4U3fBkVixSCqF3v21+NAZ21v+ 1ryLHasvbR709ZwZi9HNmlAJM4SlbwV9K/wUPoFYhyAnwB4Yq/ZijRMyxkUy6aKs/Kl1 Os5napXwz1VDGBV9Wi0BYxxRdftCTS4QFKbYFi+VSUwmcF33daQIRS5m4C0JRX1LbUD9 NO8ArBNEemeKM+PKGqCVD65DaisUssLDCYLktg1OIEakVBLsGa/RphwOQlcK5+CNCgQB QCWA== X-Gm-Message-State: AJIora/9OrDEymwDGPQ37NElHUnJv+mpXD9y7SIvf/fND7jmq55yJ19v +UKu37I6Ih5nNsg9fim9ufG+UrXQ78E15g== X-Received: by 2002:a5d:648c:0:b0:21e:9872:5a38 with SMTP id o12-20020a5d648c000000b0021e98725a38mr10321607wri.556.1659016508197; Thu, 28 Jul 2022 06:55:08 -0700 (PDT) Received: from zen.linaroharston ([185.81.254.11]) by smtp.gmail.com with ESMTPSA id n65-20020a1c2744000000b0039c54bb28f2sm1397186wmn.36.2022.07.28.06.55.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Jul 2022 06:55:04 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id C53761FFBA; Thu, 28 Jul 2022 14:55:03 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: mst@redhat.com, =?utf-8?q?Alex_Benn=C3=A9e?= Subject: [PATCH v2 2/4] hw/virtio: gracefully handle unset vhost_dev vdev Date: Thu, 28 Jul 2022 14:55:01 +0100 Message-Id: <20220728135503.1060062-3-alex.bennee@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220728135503.1060062-1-alex.bennee@linaro.org> References: <20220728135503.1060062-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::434; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x434.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" I've noticed asserts firing because we query the status of vdev after a vhost connection is closed down. Rather than faulting on the NULL indirect just quietly reply false. Signed-off-by: Alex Bennée Message-Id: <20220726192150.2435175-8-alex.bennee@linaro.org> --- hw/virtio/vhost.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c index 0827d631c0..f758f177bb 100644 --- a/hw/virtio/vhost.c +++ b/hw/virtio/vhost.c @@ -306,7 +306,7 @@ static inline void vhost_dev_log_resize(struct vhost_dev *dev, uint64_t size) dev->log_size = size; } -static int vhost_dev_has_iommu(struct vhost_dev *dev) +static bool vhost_dev_has_iommu(struct vhost_dev *dev) { VirtIODevice *vdev = dev->vdev; @@ -316,8 +316,12 @@ static int vhost_dev_has_iommu(struct vhost_dev *dev) * does not have IOMMU, there's no need to enable this feature * which may cause unnecessary IOTLB miss/update transactions. */ - return virtio_bus_device_iommu_enabled(vdev) && - virtio_host_has_feature(vdev, VIRTIO_F_IOMMU_PLATFORM); + if (vdev) { + return virtio_bus_device_iommu_enabled(vdev) && + virtio_host_has_feature(vdev, VIRTIO_F_IOMMU_PLATFORM); + } else { + return false; + } } static void *vhost_memory_map(struct vhost_dev *dev, hwaddr addr, From patchwork Thu Jul 28 13:55:02 2022 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: 594071 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:b345:0:0:0:0 with SMTP id w5csp526499maz; Thu, 28 Jul 2022 07:06:30 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uBypUqWn8JJkp+tB+UTe1sxmnEY+5sqEUOnhMmNRavNOcrRtPcn7VbNza8W2pmJ9j/7qgO X-Received: by 2002:a05:6214:234d:b0:474:6000:44a4 with SMTP id hu13-20020a056214234d00b00474600044a4mr13500778qvb.6.1659017190014; Thu, 28 Jul 2022 07:06:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659017190; cv=none; d=google.com; s=arc-20160816; b=tm9Zm0DW+ByLWYcf8DNEXfsyMbt+MaPKYk0nYGLQZ1DM8ZT1DyXbXxY6UZs1Lf6gFd I/HP8fLFVb6TK7Ca++TvAbVHJhbFmJTFAAUJxmeZf0cqVMzHx+A1Iwrxp978P5i3luf2 6ZcE3OsGf+ILA44Uz587HM0jYetLhwfG2alqXiu++cfr6JgCfipbwtjHH57Ni9PgNyIK k2aSdkG3/2+EX+zYY6wXhYImwnVw0RIvalxqw9uFknHkobGjT1tzM8Wo3kD9txabhySG E0GLYCmaOKSHJTCEeuYsnz7oTbB+5tItGN97KyMVpZw4urnrdBvcV2I8PUvtz+lbFMl7 FsUw== 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=qn9sIffAzV9IF+yjjzIzifr78tit+1ZOBIt0UyqO2Rk=; b=CzrFrBpI5qHIxgOqi4D4ZurxG+eM8FgfmhOwD2AdeWOkRbHNFzHQ4XRbXkfivw+FhY L6npi/foQrpNDOw7hVUH0kQ2cY4MliyjkIdPWMSyQ9dVq+VF5cV8bokRU+gPwkmd5ofh 0ucO9EQnsAshaAGhX+dAgmYLP5sQs/QZE04L4GSnrYQFWgATBTllzI+6SqARrwcX5AJ9 zfEZtU7hj9Vhi8P+pdLXDrdwiUShezvzUw/vzaGO3RTwmBfjzzcyhRPol6MaWD5np7YY yw5VglJPTFZDzqbxG15jgSx0FN7zO1VUmVLww9jFYiuKt1pLtAaykdBER+kZa71wRy5k qvqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=sgPyErci; 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 hf4-20020a0562140e8400b00474835244d7si546566qvb.125.2022.07.28.07.06.29 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 28 Jul 2022 07:06:30 -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=sgPyErci; 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]:35358 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oH49l-0003Xd-Hp for patch@linaro.org; Thu, 28 Jul 2022 10:06:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38984) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oH3zC-00040t-N0 for qemu-devel@nongnu.org; Thu, 28 Jul 2022 09:55:35 -0400 Received: from mail-wr1-x435.google.com ([2a00:1450:4864:20::435]:38778) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oH3yw-0000OI-B6 for qemu-devel@nongnu.org; Thu, 28 Jul 2022 09:55:34 -0400 Received: by mail-wr1-x435.google.com with SMTP id k8so106449wrd.5 for ; Thu, 28 Jul 2022 06:55:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=qn9sIffAzV9IF+yjjzIzifr78tit+1ZOBIt0UyqO2Rk=; b=sgPyErciTNQttlWPS4JPv27YVf7tmojFhsZR9M/WZngizsHWCfovQpwMgyaCu3WxyN +ZWRwuKuS4XX1chuuVcV6JTIEVeywSGfzz0iMHQ7+hBO0Uz10nO0wZxtdfuriBZeI3su +WuGzOonIXeVtU4Y1YQmHHXd6NwFNlE0NZs4HBGRSVbCdBSKjKPsYQqHfTYae42/tMcN RRMYRD1sNkK77Vmg5WXBTcOWeT+O9blgS8mWNLbpOqbL94u+RaJiqAK1NBDLduRTjOSI bW+S01sSi2lvy/XJudEcIXf20iGdBa/He+6CG6I2scyT48KHrG1+RD3jZrt8lgUPARd6 mz9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=qn9sIffAzV9IF+yjjzIzifr78tit+1ZOBIt0UyqO2Rk=; b=0hGtfqPMELLiBe8nt6XgaDKdXKDoyVmDtlQG0/y0yR+i1dG9D9ERTvRQa13TL8tQfR QZ0R/JrrirLF5It5u8Lay3zCHIcay5rRM0fhU5c2iSasbNMyxFsYPitpex4SpHzNFsqU 3D3YR4oCMA8bAjfMUS02R/iNyd8Bj+t2baf6zTjoSqOgtvTrmgZxtDd8oJ/ll1geq+EC otsk06DdPxnaUK1Q5gfhgiKRjzFkDGphL+sHH/g6AC8Rf3tOjveixp7LsHh+cvzAYpX+ Emuc7AlnIVEAvRO0+MNLZXuqoq4eLu+OxPm5VOmXdhY7QaY45T7427EJrqKJBGM6vwVH lQpQ== X-Gm-Message-State: AJIora++aRlZ7oK1Pw8NM4Ry4bCLL+eYKAZaANbpnzPqZ2XkCS/GOBeD U9uSY360pC8bhXgmUvoh2zGlxNi+LMuB7w== X-Received: by 2002:a5d:6642:0:b0:21e:f918:b093 with SMTP id f2-20020a5d6642000000b0021ef918b093mr2098786wrw.173.1659016509030; Thu, 28 Jul 2022 06:55:09 -0700 (PDT) Received: from zen.linaroharston ([185.81.254.11]) by smtp.gmail.com with ESMTPSA id l21-20020a05600c1d1500b003a326b84340sm6114560wms.44.2022.07.28.06.55.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Jul 2022 06:55:04 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id DB9871FFBB; Thu, 28 Jul 2022 14:55:03 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: mst@redhat.com, =?utf-8?q?Alex_Benn=C3=A9e?= Subject: [PATCH v2 3/4] hw/virtio: handle un-configured shutdown in virtio-pci Date: Thu, 28 Jul 2022 14:55:02 +0100 Message-Id: <20220728135503.1060062-4-alex.bennee@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220728135503.1060062-1-alex.bennee@linaro.org> References: <20220728135503.1060062-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::435; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x435.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, 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" The assert() protecting against leakage is a little aggressive and causes needless crashes if a device is shutdown without having been configured. In this case no descriptors are lost because none have been assigned. Signed-off-by: Alex Bennée Message-Id: <20220726192150.2435175-9-alex.bennee@linaro.org> --- hw/virtio/virtio-pci.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c index 45327f0b31..5ce61f9b45 100644 --- a/hw/virtio/virtio-pci.c +++ b/hw/virtio/virtio-pci.c @@ -996,9 +996,14 @@ static int virtio_pci_set_guest_notifiers(DeviceState *d, int nvqs, bool assign) nvqs = MIN(nvqs, VIRTIO_QUEUE_MAX); - /* When deassigning, pass a consistent nvqs value - * to avoid leaking notifiers. + /* + * When deassigning, pass a consistent nvqs value to avoid leaking + * notifiers. But first check we've actually been configured, exit + * early if we haven't. */ + if (!assign && !proxy->nvqs_with_notifiers) { + return 0; + } assert(assign || nvqs == proxy->nvqs_with_notifiers); proxy->nvqs_with_notifiers = nvqs; From patchwork Thu Jul 28 13:55:03 2022 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: 594073 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:b345:0:0:0:0 with SMTP id w5csp543912maz; Thu, 28 Jul 2022 07:23:12 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vbEbn5VLFGWsGRhgXR4STEa5G/yf1buWM6U1hapI6flYQ0Up1XsDqMnfmr9qfJD21kYFBU X-Received: by 2002:a05:6214:19e5:b0:474:1648:455a with SMTP id q5-20020a05621419e500b004741648455amr23679883qvc.42.1659018191975; Thu, 28 Jul 2022 07:23:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659018191; cv=none; d=google.com; s=arc-20160816; b=U4y/S+lZpjQOTiHIf7C4ZilCL+4a0feTXhoeVHdF8ClMQjF3GGxAzo1MmdKbmsYJBk KLXGm4q/HhZy3LeCOH4l3S7CS8myCUaOsSwELu052GLnaCd8ZAocJEFoT7AqFbEetO8W +Ssce8YoeF6MSOrneDLoel0YfqpouLPwPwuXdFzkN8JQYvTJNByf0GYsXaV6IZsiXtmI 7/HhBnWhVR+PTodIxeh6vnNxktK3dqlorjLEp4FIfKFG2ani/qt2dIbuZSzdJF6gkos8 Z6H3eHvwooT37crTSsSjDaCW1JnXp/PSrn4QYNbIZwhFSLo1IVOkB/FSRXYOu3PcAl+K p7hA== 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=5cs2obCibuFrGV6ezAp7TXix+CRt2n51MrtUoaGrvvI=; b=XSJx3z/PDf9bzce84UWrco/wjPb8jcPiHZVcyz5J+rXHJgU6gTiXItNcXqF22y3Jxs dJYRuosxCVniYw9NjFLmEoGygVnVo1FGkHfIkUbDsE8uzdHAaAj5Am5IeQUz4ohM1Fr+ f81tQGauujt9+uLmqRPz14HFXwExDKSylHYinzwXvrU7Pld8JLtDnfoJ7qhuf2Rc0wWx 55Q7Ci+974AXQNqhEa8SxTN42Er6nWe2mE2Tw67Jk3Dneyv4cF4vMuMCJF5OkzQWoab8 xvmFjSdVHY1gJmUTD3rb2LGF56IcTM03sOdKCd0kU98vKIc+zW/MkbB50nbzqTg3hf5I PuqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=MrnT4XOU; 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 j9-20020ac806c9000000b0031eeedea94csi484708qth.80.2022.07.28.07.23.11 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 28 Jul 2022 07:23:11 -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=MrnT4XOU; 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]:59262 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oH4Pv-0003jG-Ht for patch@linaro.org; Thu, 28 Jul 2022 10:23:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38910) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oH3yz-0003lh-9H for qemu-devel@nongnu.org; Thu, 28 Jul 2022 09:55:21 -0400 Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]:33448) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oH3yw-0000Of-AU for qemu-devel@nongnu.org; Thu, 28 Jul 2022 09:55:20 -0400 Received: by mail-wm1-x32a.google.com with SMTP id a18-20020a05600c349200b003a30de68697so3399129wmq.0 for ; Thu, 28 Jul 2022 06:55:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=5cs2obCibuFrGV6ezAp7TXix+CRt2n51MrtUoaGrvvI=; b=MrnT4XOU2T9Hl+vLx07czaWcVUXSw2LsafTLH/hmjIa1Ea9ftq2AA2jeTte5zxGdz8 ExMYhS6Ws/1l8HsbBsXgmAqXuawDQxNmJqVA9IQFP8SFbIt23lP+WqXqeoLIyGAq7HWv GFecnfQQY+qZgT2NKbjaxO3OFxCAF8vDbSm93slLwYn3lYHWUqaWTGKNMi7hlakqANSz Tjm5Xugeu4NbKbbzFhm6OHSxApun4idvy4ow6aJoo4rWSvKxI7RkJB7sdf6vVFUuOT4p wL9BIr0t+T3D5W4eQd/jLJeprK/c3MbMdXj+vKXjrcvxDwaVZ+HrWYuU+eOS6GOe/Rsr e5qA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=5cs2obCibuFrGV6ezAp7TXix+CRt2n51MrtUoaGrvvI=; b=44GOUUGcY0xdrcsDjAAMe/i6Hfnlf/y3ykJF6wBzzr2QkvFmxW6ni4XBbgaBFfWV9L Jm1yURH0l10dwzB72VPt30rEwA6GdJbozAvrcQmMqKL0lfBg6UMj/mvy8aj3cOKHzbLc rCnUX+8nhLz+d+MdJPG8++YooBZhteHp1yyts97dNHqw07uizH8edvsFgzyqd9Wji3h3 fi94xkWXYWzyD71GDMdlRnx8zEGWXisBxteYclRlV3sp7Vaw37N1Sb4HNTg9quRMZxbC mRRAynpVoTe5ZpWF8lTPuY1GtHEpfpxMfz0tSfNRbTDr4xZExffBb45pYXdBV54epAeM /p8A== X-Gm-Message-State: AJIora8jlO4TamIqknk9yKWqm9HT1fr2UyknQ1601iHPnyztERfMzq+/ WN0pW/J72leavXi3PyIddigW4w== X-Received: by 2002:a05:600c:190b:b0:3a3:45c5:9f43 with SMTP id j11-20020a05600c190b00b003a345c59f43mr6661857wmq.130.1659016511371; Thu, 28 Jul 2022 06:55:11 -0700 (PDT) Received: from zen.linaroharston ([185.81.254.11]) by smtp.gmail.com with ESMTPSA id y8-20020adfdf08000000b0021e084d9133sm1296133wrl.27.2022.07.28.06.55.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Jul 2022 06:55:10 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id E789B1FFBC; Thu, 28 Jul 2022 14:55:03 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: mst@redhat.com, =?utf-8?q?Alex_Benn=C3=A9e?= , Jason Wang Subject: [PATCH v2 4/4] hw/virtio: fix vhost_user_read tracepoint Date: Thu, 28 Jul 2022 14:55:03 +0100 Message-Id: <20220728135503.1060062-5-alex.bennee@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220728135503.1060062-1-alex.bennee@linaro.org> References: <20220728135503.1060062-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32a; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x32a.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" As reads happen in the callback we were never seeing them. We only really care about the header so move the tracepoint to when the header is complete. Fixes: 6ca6d8ee9d (hw/virtio: add vhost_user_[read|write] trace points) Signed-off-by: Alex Bennée Acked-by: Jason Wang Message-Id: <20220726192150.2435175-10-alex.bennee@linaro.org> --- hw/virtio/vhost-user.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c index 1936a44e82..c0b50deaf2 100644 --- a/hw/virtio/vhost-user.c +++ b/hw/virtio/vhost-user.c @@ -295,6 +295,8 @@ static int vhost_user_read_header(struct vhost_dev *dev, VhostUserMsg *msg) return -EPROTO; } + trace_vhost_user_read(msg->hdr.request, msg->hdr.flags); + return 0; } @@ -544,8 +546,6 @@ static int vhost_user_set_log_base(struct vhost_dev *dev, uint64_t base, } } - trace_vhost_user_read(msg.hdr.request, msg.hdr.flags); - return 0; }