From nobody Sat Nov 23 21:25:58 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1730827144; cv=none; d=zohomail.com; s=zohoarc; b=c/AdXfNu88DjbS2CQKLWSfCBSD2MjaFbEu111XUVShguhq9Lj1PQ1Gobw4+FEj6ZLFTiJrZknBWJOmUf1PNVuhJiD79QZZ9DBueLcnfEKEFe6lu4XjYIT8GFIc8IxElgEBhRiT+sWYf4eTUM8B3O/6uP75JirDjc36r126gYM1I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1730827144; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=si1GAzVFo9p7658TUKQsKQkHM9JnDZDIhZcoRXj69KM=; b=DVbHlLI6srjiDsKtGp8dcM6jxnKAknmni75JA3Eya5/C4au2sWvw5XGRV8X5O77tuyKwrGScnPLPWzh+K7H7y5h4OGUDzGeo9NZkaDt1QvRN6T1Rzg9tl5Q1F4qbzjuaMjVSDW1CMoi+EXEkW9t4Uk+dr+COQc3ktXR3L0ixtaE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1730827144840378.1027233337435; Tue, 5 Nov 2024 09:19:04 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t8NC8-0001hi-Fg; Tue, 05 Nov 2024 12:18:20 -0500 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 1t8NC7-0001hE-4H for qemu-devel@nongnu.org; Tue, 05 Nov 2024 12:18:19 -0500 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1t8NC5-0007qy-Cu for qemu-devel@nongnu.org; Tue, 05 Nov 2024 12:18:18 -0500 Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-431695fa98bso45153525e9.3 for ; Tue, 05 Nov 2024 09:18:16 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-431bd947c0esm235361215e9.24.2024.11.05.09.18.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Nov 2024 09:18:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1730827095; x=1731431895; darn=nongnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=si1GAzVFo9p7658TUKQsKQkHM9JnDZDIhZcoRXj69KM=; b=d6+s1AYuc/EjF0UFVJ3RhNSaj/DNdNjpcMnHakCLB9PXUDsm2134MmQd27obv017LF Z68J9A6TH2xBNtPF6IEbSHEqXAAIJKs8vYNVwPFCc4h/Iq6fOAsPXSH3ye/FU8ZfHAoo 3DPlIx4qOJHKCryj0ivDEcjIfV/pIiPeYacppR/eGnD7umBo4lodCNLb8PgpylVMiqzf X2gSxfagk5beLowjm8TKNmaLFEyS9w02PRm4GIDZ2aIsqkskXn1fJDeHHumDlx7Blvuj tJcKIGt044/bYPGSXCGlZUb0wptk94kHpUnGH0XF2LNUG+riJnZjl76iO5trevS21PEX uR7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730827095; x=1731431895; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=si1GAzVFo9p7658TUKQsKQkHM9JnDZDIhZcoRXj69KM=; b=TEntwREauOjPTy1smLiUGzKhKxMdhwCFzZsKkPdB//RyTt7EzpKQkSJ50YOZ1ZuTsE sz9jV9codC2LJUipEOvby1lUeFvNGQd1CAhzaikEqpQyUXcUxTetoUbVIK8y8+RRz/zs yzEqW/oNZVHkE0X8vvGoIm87lJUzrWVEEibnzFX3mPfz6ZUzycagmpp88BlMYeQe5KFx ZOhoZGeUD1yqO94Jj+g8ubtQj5/Atrz1uoQXKXczI7IZsZe76goGnOTfcPIq6jOviOTc OKPAQuReZu3To6fqMfSrdiZLbpd6w+6jWIN/wElBr4ojpWjbfG4P96SAUW5m8ER9Oyap GrWw== X-Gm-Message-State: AOJu0YyKg4CTnvWCdc8qcbtKtMCXbOVyOLc/9wDDCT8YMXnoyvJ6vOBt DIZnF6ICNK63508efKHT1PvEozcP61fgiGU2msxFxzG291l5IBGrDXylRbqV/1DClS+Wn/bl4Oz V X-Google-Smtp-Source: AGHT+IFGSmz/Jy6/gaONdVJhHsv0rJnsI+bn/BrmkZNERox6s7mnYokPZp6uBuDqTgUhviOWbfuWWw== X-Received: by 2002:a05:600c:1d1d:b0:42f:4f6:f8f3 with SMTP id 5b1f17b1804b1-4319ac6fbf7mr323454725e9.7.1730827095190; Tue, 05 Nov 2024 09:18:15 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Cc: "Michael S. Tsirkin" , Marcel Apfelbaum , David Woodhouse Subject: [PATCH] hw/i386/pc: Don't try to init PCI NICs if there is no PCI bus Date: Tue, 5 Nov 2024 17:18:13 +0000 Message-Id: <20241105171813.3031969-1-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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: pass client-ip=2a00:1450:4864:20::32f; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32f.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 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1730827145187116600 Content-Type: text/plain; charset="utf-8" The 'isapc' machine type has no PCI bus, but pc_nic_init() still calls pci_init_nic_devices() passing it a NULL bus pointer. This causes the clang sanitizer to complain: $ ./build/clang/qemu-system-i386 -M isapc ../../hw/pci/pci.c:1866:39: runtime error: member access within null pointe= r of type 'PCIBus' (aka 'struct PCIBus') SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior ../../hw/pci/pci.c:= 1866:39 in This is because pci_init_nic_devices() does &bus->qbus which is undefined behaviour on a NULL pointer even though we're not actually dereferencing the pointer. (We don't actually crash as a result, so if you aren't running a sanitizer build then there are no user-visible effects.) Make pc_nic_init() avoid trying to initialize PCI NICs on a non-PCI system. Cc: qemu-stable@nongnu.org Fixes: 8d39f9ba14d64 ("hw/i386/pc: use qemu_get_nic_info() and pci_init_nic= _devices()") Signed-off-by: Peter Maydell Reviewed-by: Bernhard Beschow --- This shows up if you run "make check" on a ubsan build. --- hw/i386/pc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 2047633e4cf..1af1a1a1823 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1251,7 +1251,9 @@ void pc_nic_init(PCMachineClass *pcmc, ISABus *isa_bu= s, PCIBus *pci_bus) } =20 /* Anything remaining should be a PCI NIC */ - pci_init_nic_devices(pci_bus, mc->default_nic); + if (pci_bus) { + pci_init_nic_devices(pci_bus, mc->default_nic); + } =20 rom_reset_order_override(); } --=20 2.34.1