From nobody Tue Feb 10 02:54:43 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1600329167; cv=none; d=zohomail.com; s=zohoarc; b=c9GaKcKyTI/i59z6Oaj/vjxeWMatvR0hOt1YzuanI6/RmyN0svYjCOBbbuIZkOfjGNZzkf8ng6B2vm/Lw0dU78jw4wClLPOizByrRYNX4g55aRWr4ebXkSHBWvKh7bePv0uSykvdnlJbXp/DXd3fonbLReJAocolTBlPR5xlK8Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1600329167; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=WIzwySGHusyyqcxBP6wP/5K/w/rrBhlYTKtBQXK9Uy8=; b=gQRtgq3e7PFuS6/V3hbn+DHIMiYdBjoJ6UfajltbBbflKmr1Z8m8PEYl4CiTj/BGIqXL54btZOg8K8m5YJhXZ6Pms1IqDL/kCsclv7vaJkR85L2uru2H7e7sR3XD3Tbd5DOUczOFaJokF2wbAi67xfTC+sDR2UWjfD/kij2diHQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1600329167755692.1373140529952; Thu, 17 Sep 2020 00:52:47 -0700 (PDT) Received: from localhost ([::1]:52686 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kIoik-000687-M2 for importer@patchew.org; Thu, 17 Sep 2020 03:52:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50686) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kIoeH-000858-TW for qemu-devel@nongnu.org; Thu, 17 Sep 2020 03:48:09 -0400 Received: from mail-pj1-x1044.google.com ([2607:f8b0:4864:20::1044]:55373) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kIoeF-0004oz-P1 for qemu-devel@nongnu.org; Thu, 17 Sep 2020 03:48:09 -0400 Received: by mail-pj1-x1044.google.com with SMTP id q4so828449pjh.5 for ; Thu, 17 Sep 2020 00:48:06 -0700 (PDT) Received: from localhost.localdomain ([115.96.122.113]) by smtp.googlemail.com with ESMTPSA id y3sm20572516pfb.18.2020.09.17.00.48.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Sep 2020 00:48:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=anisinha-ca.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=WIzwySGHusyyqcxBP6wP/5K/w/rrBhlYTKtBQXK9Uy8=; b=gxO3Vwy3/F2P44bpyPiYBuQfkF33M9CXr3wejPzTTda6Q6/MhtDRKoLjXTHfw1K6qI GzyFRlWrJsZ1mZiSar3lDpB98jinYFTyZxkLRKloqIyfSVA3HJ68rIRwFkpoU3W/jYf0 ctiT96rknVPdV6eMvQXrEvMzez8PaEXR5g135tMfrV0sG81oXB2mSGX+ucNUi7PWD3wj pARFsHglks6tTRm8Y0eqGiph23La/YVez3eSMUs9B6J7yzlj1/dJ9KnI1194gqfmIquB uEOxwgYD4hKOk+eFW6oTuMnuLuAnOuWmj8G5j+7+bPz7tktRCvIGD+Gpvs1wTLfBMxLX ktcg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=WIzwySGHusyyqcxBP6wP/5K/w/rrBhlYTKtBQXK9Uy8=; b=GuCzbrvW8RMs1yF5SXOiblVOlhNU+gh3KYnIWNJLTP2HI6tEERjJ357pvyNd9xn4kX Z7FxLHIe60xSZXVkdXlvRYpHByBi11V74oRVPqIzJrqcGsGjq1m4Rj9lsj921URPvKpG pjgfoIrLd6DFTQN07yRUmCeXqqs8o9ES0ry3BZ5HrRhiOBnJAaE/iMUZiXDautoyJ4Bf HdVgKphGUPA0JeqHibF5YmU5xT5TmGEQWrYM1/XNMwS+kcYz6X+wpq6RnnIattRMrm/p cbSBlTavYF3aGYQeXMLQkFWOEI6zECh0xOUOqD9rd9SbC75gBOfArYNCztfANn/JDcKQ ga7g== X-Gm-Message-State: AOAM530Ltrn5CW8/ZUszSlI9/ChQLvc1rYwMyOuFUWkp+MIBZfOu64pp 5ngekZpTgADi+o7BJAedQFu4jBZYvqJcOLul X-Google-Smtp-Source: ABdhPJz0727rqNl+WZRjGLmP54xs8X6tRYy9Cb2VVfn11YKBBcvB/DmqTmY2SHKgGw6o2ngAuUgRDg== X-Received: by 2002:a17:90a:f992:: with SMTP id cq18mr7452906pjb.136.1600328885660; Thu, 17 Sep 2020 00:48:05 -0700 (PDT) From: Ani Sinha To: qemu-devel@nongnu.org Subject: [PATCH v6 04/12] Fix a gap where acpi_pcihp_find_hotplug_bus() returns a non-hotpluggable bus Date: Thu, 17 Sep 2020 13:17:24 +0530 Message-Id: <20200917074733.13612-5-ani@anisinha.ca> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200917074733.13612-1-ani@anisinha.ca> References: <20200917074733.13612-1-ani@anisinha.ca> Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::1044; envelope-from=ani@anisinha.ca; helo=mail-pj1-x1044.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eduardo Habkost , "Michael S. Tsirkin" , jusual@redhat.com, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Aleksandar Markovic , Paolo Bonzini , Ani Sinha , Igor Mammedov , Aurelien Jarno , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" When ACPI hotplug for the root bus is disabled, the bsel property for that bus is not set. Please see the following commit: 3d7e78aa7777f ("Introduce a new flag for i440fx to disable PCI hotplug on t= he root bus"). As a result, when acpi_pcihp_find_hotplug_bus() is called with bsel set to 0, it may return the root bus. This can cause devices attached to the root bus to get hot-unplugged if the user issues the follow= ing set of commmands: outl 0xae10 0 outl 0xae08 your_slot Thanks to Julia for pointing this out here: https://www.mail-archive.com/qemu-devel@nongnu.org/msg734548.html In this patch, we fix the issue in this function by checking if the bus whi= ch is returned by the function is actually hotpluggable. If not, we simply ret= urn NULL. This avoids the scenario where we were returning a non-hotpluggable b= us. Signed-off-by: Ani Sinha Reviewed-by: Igor Mammedov --- hw/acpi/pcihp.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/hw/acpi/pcihp.c b/hw/acpi/pcihp.c index 39b1f74442..32ae8b2c0a 100644 --- a/hw/acpi/pcihp.c +++ b/hw/acpi/pcihp.c @@ -147,6 +147,21 @@ static PCIBus *acpi_pcihp_find_hotplug_bus(AcpiPciHpSt= ate *s, int bsel) if (!bsel && !find.bus) { find.bus =3D s->root; } + + /* + * Check if find.bus is actually hotpluggable. If bsel is set to + * NULL for example on the root bus in order to make it + * non-hotpluggable, find.bus will match the root bus when bsel + * is 0. See acpi_pcihp_test_hotplug_bus() above. Since the + * bus is not hotpluggable however, we should not select the bus. + * Instead, we should set find.bus to NULL in that case. In the check + * below, we generalize this case for all buses, not just the root bus. + * The callers of this function check for a null return value and + * handle them appropriately. + */ + if (find.bus && !qbus_is_hotpluggable(BUS(find.bus))) { + find.bus =3D NULL; + } return find.bus; } =20 --=20 2.17.1