From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-f73.google.com (mail-pj1-f73.google.com [209.85.216.73]) (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 814C03BF68E for ; Thu, 23 Apr 2026 21:23:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.73 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776979418; cv=none; b=iDg6S8OzbF09ekbX7iwy20lyTHQt+6Pg0+ImY5mrrdFcaTSB7NAymdQZPtvyml+m3RmIWALvJGlN8+9uiSqQvYGixwwN+P5E7reffqdtN6uFgV7vj3aj6a7mqbmOZNfvPTIbjtG3RQSjyPXkmvXyRa6N3S1+DrrzCqnB8cYEGVs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776979418; c=relaxed/simple; bh=k0MqtokF5x5FrnuJGyuULJNyUYCZIUvKCsZhPGRTT5M=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=WLuXZ+0GRx83Uy0nddkmt5JPGkIneFvRp66EConoV3NJRZ/6BGEgmRUGMn1bQtAFTurqBVXX6u8g6y/qjcyc4WJClcg6Jo529nOqJOT6pC/ZMuc2MdX3H5gpeL7OwqpMLtcLxA6SNBUUfVf1DxA/TmbWyrB2XFCVmdU++PDsaQI= 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=o9QrzpOE; arc=none smtp.client-ip=209.85.216.73 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="o9QrzpOE" Received: by mail-pj1-f73.google.com with SMTP id 98e67ed59e1d1-35fbb5779e8so8012731a91.3 for ; Thu, 23 Apr 2026 14:23:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1776979412; x=1777584212; 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=ys4uatxpJYM7Kl1KgUYRndxIbkLNusGMab4h1bmL7Us=; b=o9QrzpOEoG27XXUFVJqcJBtO11q92FrGntzJZz5mtF2nn6Hu0VYdUkvfA6EiSqVQFq sP+TbIFvXazbxKgYUDqQOAVgu10q+2+HM7qyQ5EUxWZSHJJvj6jnCr2uE5JDNFYN00Qu 5yM0c79bo8yHIYNIyjqhDZ24d3CRez8ZKHVJOm/3rCC/rwi6ezuhQy6vymXvhxKA1S1s nel1hpOYqiV39X1XE1tMtnJfUlE0NtRZcUrkTEkvyfO+gSRRmIumvaGq+enqMz4plyaX bZK/COP7o0lMy/skFw034jke/umUFw5Pfjf5nGn3Q1Es/Z3UxT6su5VuCnU1ElRE+GMU GLHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776979412; x=1777584212; 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=ys4uatxpJYM7Kl1KgUYRndxIbkLNusGMab4h1bmL7Us=; b=InsGjpWcrdoe5HNkg8Kz9EaLEFPLPzuEE89SgmqsqUbHomJ3AfoC3a/G5xUzLm8a1q dg9pMucrTpeYZfqg0dumcPiL708VbJGd+Pr2fmZt4nIri0Anma/drUsZ4FV1QFSmqurU Tth8zjhAzD9BE45/L3jCchGQZqbbNadgfyO/GSjr5NZQjOFy5vQcX1YFwT7qz/HOqx6h jqdbL6SpZi7xHcIJehNYGV+jqH3n5UGFIA9dgOvaTKFKAd/j3X8qrzXzeRCY9Eu0ec6q nSnzAoOWaO46Q89ujvLsxH1MUcfmVGGb2M0hDWZ5BQarmk+1R3j/Vik1fHxy1KBWj2cw 6mpA== X-Forwarded-Encrypted: i=1; AFNElJ9iFP2k4khNBe4J2BRv+UQCsXz79DASPih4lnKvaPSUeU0xSlvbICbpbh8c7fSf3DG7bF+H+B92Bx0=@vger.kernel.org X-Gm-Message-State: AOJu0YwWuiWnVsCdS3bWhtX3RbIfE1ZP2Y//eS7Qhmmc6LDziu5f+5/9 mfaRzUvei44KVHxzlNGoa2TkLeU4+06/fcaNkao6U2HmVvyr6CTAQLa2LDaGGHDvWSEFlbP3cwj jdZykn0EEDfZ7TQ== X-Received: from pjbbj17.prod.google.com ([2002:a17:90b:891:b0:362:b5ab:9cd3]) (user=dmatlack job=prod-delivery.src-stubby-dispatcher) by 2002:a17:90a:51a3:b0:362:bb93:f25e with SMTP id 98e67ed59e1d1-362bb93f462mr8872524a91.23.1776979412273; Thu, 23 Apr 2026 14:23:32 -0700 (PDT) Date: Thu, 23 Apr 2026 21:23:11 +0000 In-Reply-To: <20260423212316.3431746-1-dmatlack@google.com> Precedence: bulk X-Mailing-List: linux-doc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260423212316.3431746-1-dmatlack@google.com> X-Mailer: git-send-email 2.54.0.rc2.544.gc7ae2d5bb8-goog Message-ID: <20260423212316.3431746-8-dmatlack@google.com> Subject: [PATCH v4 07/11] PCI: liveupdate: Inherit ACS flags in incoming preserved devices From: David Matlack To: iommu@lists.linux.dev, kexec@lists.infradead.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-pci@vger.kernel.org Cc: Adithya Jayachandran , Alexander Graf , Alex Williamson , Bjorn Helgaas , Chris Li , David Matlack , David Rientjes , Jacob Pan , Jason Gunthorpe , Joerg Roedel , Jonathan Corbet , Josh Hilke , Leon Romanovsky , Lukas Wunner , Mike Rapoport , Parav Pandit , Pasha Tatashin , Pranjal Shrivastava , Pratyush Yadav , Robin Murphy , Saeed Mahameed , Samiullah Khawaja , Shuah Khan , Will Deacon , William Tu , Yi Liu Content-Type: text/plain; charset="UTF-8" Inherit Access Control Services (ACS) flags on all incoming preserved devices (endpoints and upstream bridges) during a Live Update. Inheriting ACS flags avoids changing routing rules while memory transactions are in flight from preserved devices. This is also strictly necessary to ensure that IOMMU group assignments do not change across a Live Update for preserved devices, as changing ACS configurations can split or merge IOMMU groups. Signed-off-by: David Matlack --- drivers/pci/liveupdate.c | 10 ++++++++++ drivers/pci/pci.c | 10 +++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/drivers/pci/liveupdate.c b/drivers/pci/liveupdate.c index 88125f9a2c6b..a9a89f7bd3e5 100644 --- a/drivers/pci/liveupdate.c +++ b/drivers/pci/liveupdate.c @@ -118,6 +118,16 @@ * This enables the PCI core and any drivers bound to the bridge to participate * in the Live Update so that preserved endpoints can continue issuing memory * transactions during the Live Update. + * + * Handling Preserved Devices + * ========================== + * + * The PCI core treats preserved devices differently than non-preserved devices. + * This section enumerates those differences. + * + * * The PCI core inherits all ACS flags enabled on incoming preserved devices + * rather than assigning new ones. This ensures that TLPs are routed the same + * way after Live Update and ensures that IOMMU groups do not change. */ #define pr_fmt(fmt) "PCI: liveupdate: " fmt diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index 8f7cfcc00090..e615b7c3e430 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -1017,6 +1017,15 @@ void pci_enable_acs(struct pci_dev *dev) bool enable_acs = false; int pos; + /* + * ACS flags must be inherited from the previous kernel during a Live + * Update for preserved devices (which includes endpoints and any + * upstream bridges) to avoid changing routing while memory transactions + * are in flight. + */ + if (pci_liveupdate_incoming(dev)) + return; + /* If an iommu is present we start with kernel default caps */ if (pci_acs_enable) { if (pci_dev_specific_enable_acs(dev)) @@ -1041,7 +1050,6 @@ void pci_enable_acs(struct pci_dev *dev) PCI_ACS_RR | PCI_ACS_CR | PCI_ACS_EC, ~(PCI_ACS_RR | PCI_ACS_CR | PCI_ACS_EC)); __pci_config_acs(dev, &caps, config_acs_param, 0, 0); - pci_write_config_word(dev, pos + PCI_ACS_CTRL, caps.ctrl); } -- 2.54.0.rc2.544.gc7ae2d5bb8-goog