From nobody Mon Feb 9 21:18:47 2026 Received: from mail-pj1-f74.google.com (mail-pj1-f74.google.com [209.85.216.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5232335D5EA for ; Thu, 29 Jan 2026 21:25:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.74 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769721945; cv=none; b=MgCWo5p5WSTkkryNuXJl56ubTlSFRzpjzDejejnOVkC4fBi8Xs4elW4aYVNG+kJxCBvRHh+z21huZqtOtlyIR/K+OCFDQPAB0wDjycQm+zxinIfbVXB3Gvj4ZHnLXDsp1KF4q9v/IX4FFDrEQGRyh4DDzP33g8yOUVukep+3vWo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769721945; c=relaxed/simple; bh=WQ9zgAmCTBZ4bwjQYNH8OonhSwck2yad34xCkVdAyYE=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=NVugHnz9iOsWAymwBnKuKaZWkZcenvQfnk4lZsE1iPnKN0gDAzOKIoAgcU5eYX4IZWLaZXaYkJUnPgwxm57SUpJOcM8MljoazCfdiDHwF2Qp1ogsJEEl+0HipGokRJvs6IZOxVfU2M6EFRsxqHux3QsE6jPwkyLYWQD5x8/szBY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--dmatlack.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=XjVaCgTF; arc=none smtp.client-ip=209.85.216.74 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--dmatlack.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="XjVaCgTF" Received: by mail-pj1-f74.google.com with SMTP id 98e67ed59e1d1-352de7a89e1so1182240a91.1 for ; Thu, 29 Jan 2026 13:25:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1769721943; x=1770326743; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=u1Z3QHTjPxpYvShlt2cO6c78554A0ZIR6ozbVe3TjI8=; b=XjVaCgTFQyi6ghx7LAtflhE0rRuGae3zRnMF+wJ64bOcpbaClnEJCHeeFPuNMx0bhj Chg5w3+Rx1+NgQiC/X3EpKjOM5AHlPxMXucXPInqNLq5W2iNCZO09+LE2qwLNDBEXIPE k6KPrSjv+Nicpr3qeTwLiE4/7n7Eq4kAhYE1RGrPbyQj1PFa5a168R4x8Ag9H2obFNnC MioljlYyKnMLyNKbtxL/nZduWIAaIE13aEIZ/x9ZtOBBqDhg6avJOIdW/06RH84x6bAT mspO0qAoOXdpPYicKB0pO4XSn/yd4pHPLC5KY91JNeLGhYPPPelvXvLyDFk+A+VUIMw2 d43g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769721943; x=1770326743; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=u1Z3QHTjPxpYvShlt2cO6c78554A0ZIR6ozbVe3TjI8=; b=eKu0V4ba8RSrTHSXD3Ez6X0qDuPvy51l6LQPJ72Hs9BUzjDXyPLlqlNo4sPT9bgpDu ZQWe3S8zSASPZ+Y8ILuFUPlOuxP7EagW9sXj3NLPsTRD8cx5aBAMQXvKfq/pFfeXmO9V daa+QOCfbjmeaunsAvvBnNwW+Z2r+8YtfkBGhGv/gWKWh+ni3PeE7YMFr/HI1D2Y5DlQ xlqam1Aql/cfSAVQk3T2q+X05yziEIpUnkuy0xz7FuQsQFWLwRT38IsxY/o7Qeokoi/y HKNsOI3Cpt31TlSgJ0p1c+DBpCzDvsjGsw3oOBYgp6gedt5rV7hG4kqU/9NxoBKWErmV 6NVg== X-Forwarded-Encrypted: i=1; AJvYcCVv8bzGSRwFPHuYKA1iLx+Zwg3XSEUVzSY55tJc8V6jeZYl3C5LikOBigmRnoDIItR9OqaPJhysUYER25A=@vger.kernel.org X-Gm-Message-State: AOJu0YzMqzyX1zQc5LxQwxatKVVHmy+e0o7GyC1zygi+IwyNE0V2yv5n QiLk5xmlc4AJuxGrZQ5rK62YG5Lq2wGLC6oTZVnh/+RerrBrqd4GB0QPJDxN17gIiTacsIcya8u B0/TOBWADOhcUhg== X-Received: from pjblb16.prod.google.com ([2002:a17:90b:4a50:b0:352:b92b:ef8]) (user=dmatlack job=prod-delivery.src-stubby-dispatcher) by 2002:a17:90b:28c5:b0:343:684c:f8a0 with SMTP id 98e67ed59e1d1-3543b3ae12dmr762757a91.23.1769721942669; Thu, 29 Jan 2026 13:25:42 -0800 (PST) Date: Thu, 29 Jan 2026 21:24:50 +0000 In-Reply-To: <20260129212510.967611-1-dmatlack@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260129212510.967611-1-dmatlack@google.com> X-Mailer: git-send-email 2.53.0.rc1.225.gd81095ad13-goog Message-ID: <20260129212510.967611-4-dmatlack@google.com> Subject: [PATCH v2 03/22] PCI: Inherit bus numbers from previous kernel during Live Update From: David Matlack To: Alex Williamson Cc: Adithya Jayachandran , Alexander Graf , Alex Mastro , Alistair Popple , Andrew Morton , Ankit Agrawal , Bjorn Helgaas , Chris Li , David Matlack , David Rientjes , Jacob Pan , Jason Gunthorpe , Jason Gunthorpe , Jonathan Corbet , Josh Hilke , Kevin Tian , kexec@lists.infradead.org, kvm@vger.kernel.org, Leon Romanovsky , Leon Romanovsky , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-mm@kvack.org, linux-pci@vger.kernel.org, Lukas Wunner , "=?UTF-8?q?Micha=C5=82=20Winiarski?=" , Mike Rapoport , Parav Pandit , Pasha Tatashin , Pranjal Shrivastava , Pratyush Yadav , Raghavendra Rao Ananta , Rodrigo Vivi , Saeed Mahameed , Samiullah Khawaja , Shuah Khan , "=?UTF-8?q?Thomas=20Hellstr=C3=B6m?=" , Tomita Moeko , Vipin Sharma , Vivek Kasireddy , William Tu , Yi Liu , Zhu Yanjun Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Inherit bus numbers from the previous kernel during a Live Update when one or more PCI devices are being preserved. This is necessary so that preserved devices can DMA through the IOMMU during a Live Update (changing bus numbers would break IOMMU translation). Signed-off-by: David Matlack --- drivers/pci/probe.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index af6356c5a156..ca6e5f79debb 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -1351,6 +1351,20 @@ static bool pci_ea_fixed_busnrs(struct pci_dev *dev,= u8 *sec, u8 *sub) return true; } =20 +static bool pci_assign_all_busses(void) +{ + /* + * During a Live Update where devices are preserved by the previous + * kernel, inherit all bus numbers assigned by the previous kernel. Bus + * numbers must remain stable for preserved devices so that they can + * perform DMA during the Live Update uninterrupted. + */ + if (pci_liveupdate_incoming_nr_devices()) + return false; + + return pcibios_assign_all_busses(); +} + /* * pci_scan_bridge_extend() - Scan buses behind a bridge * @bus: Parent bus the bridge is on @@ -1378,6 +1392,7 @@ static int pci_scan_bridge_extend(struct pci_bus *bus= , struct pci_dev *dev, int max, unsigned int available_buses, int pass) { + bool assign_all_busses =3D pci_assign_all_busses(); struct pci_bus *child; int is_cardbus =3D (dev->hdr_type =3D=3D PCI_HEADER_TYPE_CARDBUS); u32 buses, i, j =3D 0; @@ -1424,7 +1439,7 @@ static int pci_scan_bridge_extend(struct pci_bus *bus= , struct pci_dev *dev, pci_write_config_word(dev, PCI_BRIDGE_CONTROL, bctl & ~PCI_BRIDGE_CTL_MASTER_ABORT); =20 - if ((secondary || subordinate) && !pcibios_assign_all_busses() && + if ((secondary || subordinate) && !assign_all_busses && !is_cardbus && !broken) { unsigned int cmax, buses; =20 @@ -1467,7 +1482,7 @@ static int pci_scan_bridge_extend(struct pci_bus *bus= , struct pci_dev *dev, * do in the second pass. */ if (!pass) { - if (pcibios_assign_all_busses() || broken || is_cardbus) + if (assign_all_busses || broken || is_cardbus) =20 /* * Temporarily disable forwarding of the @@ -1542,7 +1557,7 @@ static int pci_scan_bridge_extend(struct pci_bus *bus= , struct pci_dev *dev, max+i+1)) break; while (parent->parent) { - if ((!pcibios_assign_all_busses()) && + if (!assign_all_busses && (parent->busn_res.end > max) && (parent->busn_res.end <=3D max+i)) { j =3D 1; --=20 2.53.0.rc1.225.gd81095ad13-goog