From nobody Sat May 18 17:34:35 2024 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=1598688813; cv=none; d=zohomail.com; s=zohoarc; b=Sj3vkt0R4g2zOVaEySW9eMP+K68QmfcEg7y14978J7JDgfc/L62ceO6gAi+7USGK17KrSodivkGEdBvnFI/1OxW0kcW9+EOd6k8zF6UPYatCrREUuzp6WZmblY/q3ftZusDS84cAJzFCUF1xt9vQCwE9kxw+vNJqoRyO6Tq7FiU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1598688813; h=Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:Sender:Subject:To; bh=pa/nGmYArA+W8XID/Wfow4kMcHrkgEAEcyP129IRBCU=; b=DBNIRUJyMJZwEUP17DJDWkCkXxYYO3hjpaqggyB/vZnJocjNRA9l0FR9DCWoxwOhUUSm/RR8VZlV1QVZcl+8kdsY4NybBKvWUUzrcRTzvRaHqQc48MgDb1ty+YMnvqEC+dg2hH+seyCCZK+flNVZ3yVLDF2Pvv+blbQ5z8y+3z0= 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 1598688813038871.2542685764115; Sat, 29 Aug 2020 01:13:33 -0700 (PDT) Received: from localhost ([::1]:46670 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kBvzP-0006iu-41 for importer@patchew.org; Sat, 29 Aug 2020 04:13:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36016) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kBvyq-0006Jd-PQ for qemu-devel@nongnu.org; Sat, 29 Aug 2020 04:12:56 -0400 Received: from mail-pl1-x644.google.com ([2607:f8b0:4864:20::644]:43903) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kBvyo-0001Fi-T3 for qemu-devel@nongnu.org; Sat, 29 Aug 2020 04:12:56 -0400 Received: by mail-pl1-x644.google.com with SMTP id y6so727324plk.10 for ; Sat, 29 Aug 2020 01:12:54 -0700 (PDT) Received: from localhost.localdomain ([203.163.239.118]) by smtp.googlemail.com with ESMTPSA id l1sm1820627pfc.164.2020.08.29.01.12.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 29 Aug 2020 01:12:51 -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; bh=pa/nGmYArA+W8XID/Wfow4kMcHrkgEAEcyP129IRBCU=; b=N/MHV2I+SgM+88F0+8FoGf1zKRcEdg2Gouf176q4UnyZaof/Yhvb+8qykAYOORpE98 aH5yQQWsKWF5kx70ull6+Tpcmo2XNECl9W2HyKgb8pSwB2LovHlilQyP5jUWs2XepRHd q2WtkwALQJiXcy4lWMRBWlgqQO+0HTK9bvTUjY4MNavfllwbWozIxqGPZdiJeKfZLZpi dQ34HBlrkHCAt5C3xFEBYtX3TW629KDi6i2w2C5yo3hlKupRI3v0LAUd0HOT5L3EX+Cz SqH2rYIH/DD6FNSk31T4RaFPq4EwXAMsOXxVcocb6wRCU33hS0apZNywdrFvnMRMnX+D RrQQ== 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; bh=pa/nGmYArA+W8XID/Wfow4kMcHrkgEAEcyP129IRBCU=; b=jtNElKNHy+U2Fdea46cc0l5GaYjvwaJh4F+NMsLGjlxenBQwfKVBbUu0NFx5/e30X2 uVbCSoR06ggm/AlJ1UwifT7zrY/npHFXsJcOYtnQm9RTVx6HRaRKiAWntoBoz4riIZeI vy9yDdcOyXRKNGLlNdnWztSmybuRXNz2KZmOCFKg6eESPFv00o/uJ/YoVY14LSJzOXWn OUw1oaz8KM2WWdCf9ZrAEieJvTHOAWg87ritgJ+xH1LHrSCrQl/R189appIxNTvFX8up 5zsUnkEo8fpyX93HaFbKhqmlmZUsN4d8Us+bEuaTPyyrEzCr3cBAIe2b6TLxgZRDzalE n3RQ== X-Gm-Message-State: AOAM5302fLDEXE/iW32xl+ddTjuX/xkt0bU4ckafoSAZwEwWBvOf30DO WNJVcKLMCvqsSG6fwIzzASmuLtLwVVTW6Q== X-Google-Smtp-Source: ABdhPJyZ+PXhtYOLozMB8rtERnvhAn7W8fMaq8kYNxhojHNvfhjFo6j6fg2Z7yjnfAs8j6bfQw0+XQ== X-Received: by 2002:a17:90a:9418:: with SMTP id r24mr2267558pjo.69.1598688772359; Sat, 29 Aug 2020 01:12:52 -0700 (PDT) From: Ani Sinha To: qemu-devel@nongnu.org Subject: [PATCH] Fix a gap where acpi_pcihp_find_hotplug_bus() returns a non-hotpluggable bus Date: Sat, 29 Aug 2020 13:42:33 +0530 Message-Id: <20200829081233.10120-1-ani@anisinha.ca> X-Mailer: git-send-email 2.17.1 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::644; envelope-from=ani@anisinha.ca; helo=mail-pl1-x644.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: Ani Sinha , Igor Mammedov , jusual@redhat.com, "Michael S. Tsirkin" 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 would be wrong since t= he root bus is not hotpluggable. In general, this can potentially happen to ot= her buses as well. In this patch, we fix the issue in this function by checking if the bus ret= urned by the function is actually hotpluggable. If not, we simply return NULL. Th= is avoids the scenario where we are actually returning a non-hotpluggable bus. Signed-off-by: Ani Sinha --- hw/acpi/pcihp.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/hw/acpi/pcihp.c b/hw/acpi/pcihp.c index 39b1f74442..f148e73c89 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 (!qbus_is_hotpluggable(BUS(find.bus))) { + find.bus =3D NULL; + } return find.bus; } =20 --=20 2.17.1