From patchwork Tue Jul 26 19:21:37 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: 593480 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:b811:0:0:0:0 with SMTP id fc17csp3829461mab; Tue, 26 Jul 2022 12:48:46 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vdtJ7jvEDIRRusFJX03OhHk3VuITIbPM4ULxQRns1MImOjYSh/L/88HkcxpJOi4Qr7Lq3a X-Received: by 2002:a0c:b414:0:b0:473:8ccb:3811 with SMTP id u20-20020a0cb414000000b004738ccb3811mr15853917qve.65.1658864926412; Tue, 26 Jul 2022 12:48:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658864926; cv=none; d=google.com; s=arc-20160816; b=itSuMqb+s3+QQN1bJmG8xd9PZfyApuj5bXezd2YxTfqlnfXZn3w35MJWmAjOosSgp0 guBu1hRHNRiDFmsc5TUexNlLatAUHV7lzumUnRiZfCbY55+tZ5Gj82ez4Up0eW7qRVeG SPfP8/C168918gwpCypgoJwMn76FWDSkueoUo0kmuxCm+q+J/NR351NZ2sniFJUmrdgx 8b4BxL9b6+4mwvm0Wz8v4UhFJn/9rt61mAfu9JbhtRBB/j+HxEW9mNtd0Jo02/rt3Jj9 n56pYah6OqLWssLASKRGn6cXKslVvK9yzw20AuYwxf3GfLd6JzZ0S7hV9xkOI2keNnTq SGdw== 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=dtgiw49DbQeIrzltHG3Fc2GoOsMK1WlBSvR6Tgd5p8o=; b=RFs1fmgy+w41zhPiXTHSduUZrSAkDfL7iLQcvjkc4SIlMQcNyDKfQMsFOnX/zjJDQy cU3tmh1zdYjVapBcx1+ZLzHMbTQJNaG8ig1PYwcdbGLy3Rp64TJ2KMLM/Vv4zIby0RJ1 q5cWTFMx6ZbPat8KqByu4fhDKC4g8Tx0Xw98N+oiaVF0T2lby+sMjFk94IXSF2MjC3fw RPiNkgDK4U+HztSyz+6ZNiLo6YF+nxtoCaFCYtlzm20NlpXv7U5d1Gwp+oDJeuRvpzjS gxFKFGLAZsDsvEE/nZySvObIGpBTkKenOD1v5IkSdm9DnmbCeGJsSz79K+pdpoNVI7mM as9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=I6++dGXR; 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 bp8-20020a05620a458800b0069c2a49989asi8621249qkb.480.2022.07.26.12.48.46 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 26 Jul 2022 12:48:46 -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=I6++dGXR; 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]:35854 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oGQXo-00068D-8o for patch@linaro.org; Tue, 26 Jul 2022 15:48:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49018) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oGQ88-0003HN-Li for qemu-devel@nongnu.org; Tue, 26 Jul 2022 15:22:09 -0400 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]:37768) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oGQ86-0002MG-6o for qemu-devel@nongnu.org; Tue, 26 Jul 2022 15:22:07 -0400 Received: by mail-wm1-x334.google.com with SMTP id c187-20020a1c35c4000000b003a30d88fe8eso11898659wma.2 for ; Tue, 26 Jul 2022 12:22:05 -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=dtgiw49DbQeIrzltHG3Fc2GoOsMK1WlBSvR6Tgd5p8o=; b=I6++dGXR/r6EXe9HQKIYlBLX+SqqIxoZcw+d+iIfMwVYNxH/NSY9NygXDz8bBeZ0Es bfASyqOUHuvZxLxcE9QbCL4FiS807KLVrKpTqgafHNFfHzpOGvHhsRa4z6EY9mWXCVrm mGt706UgzQ/xCxXijQ5kyG6CpCQ4f+rNBO60kV2z0yZNveEzWYMJ5cHaPFTUM/IrFzur 72X+Mo7FVf64po3N3yV7qAgVp/AhSoLCKsRR2FhTVVRXnzEGvdIyffrhXmxtJUIq+YzP uvISeaaXkEg1cJWuSYWcetNf6yvMSAXiOjtskWIZZ2VDkJU0EQruugQy8eZxN/tsBycM QPyw== 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=dtgiw49DbQeIrzltHG3Fc2GoOsMK1WlBSvR6Tgd5p8o=; b=JqO/sa7V4o7bwYgiciNSnrgSUXkFH8imYrX0bvdqUPkUV0QQpz1GYWIhj74AYMKB7f LRafd2ppGc0blTHQ6n4LjPhbxJHX0SIPBmU72tHKACTEHQzu/uSw2r47dLxelTChdk08 Vvbiej9d7q8whmwwDZZlhHemYhvAtY1DSLQAg3JRw+bLhHBgnqUKJL8A9jlow+YY+apc 21VZwLESg73x7HsHdqqiUI86DrcgZJvAcqnmidoJ7V2mfT8CD0yNDRdRodBhScpiTm1w NmBY6Qr2XHxwj4cs61qsbnSkT571sT4d2B81D5g236HBxFLXVKb7KkYPYghM+fobCzNz BjyQ== X-Gm-Message-State: AJIora9BS/fJf2/IeIUjdrFy8UB7ROGPpr7wPsGLXSGMYKoDC3QQhK/E Ni1I8qc/TLHnrKrNasKUNtcr7g== X-Received: by 2002:a05:600c:3546:b0:3a3:2df8:42c9 with SMTP id i6-20020a05600c354600b003a32df842c9mr429614wmq.161.1658863324857; Tue, 26 Jul 2022 12:22:04 -0700 (PDT) Received: from zen.linaroharston ([185.81.254.11]) by smtp.gmail.com with ESMTPSA id z11-20020a05600c0a0b00b003a17ab4e7c8sm27433520wmp.39.2022.07.26.12.21.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Jul 2022 12:21:58 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id F347A1FFC0; Tue, 26 Jul 2022 20:21:50 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: slp@redhat.com, mst@redhat.com, marcandre.lureau@redhat.com, stefanha@redhat.com, mathieu.poirier@linaro.org, viresh.kumar@linaro.org, mark.cave-ayland@ilande.co.uk, jasowang@redhat.com, =?utf-8?q?Alex_Benn?= =?utf-8?q?=C3=A9e?= Subject: [PATCH v3 08/21] hw/virtio: handle un-configured shutdown in virtio-pci Date: Tue, 26 Jul 2022 20:21:37 +0100 Message-Id: <20220726192150.2435175-9-alex.bennee@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220726192150.2435175-1-alex.bennee@linaro.org> References: <20220726192150.2435175-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::334; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x334.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" 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 --- 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;