From nobody Mon Sep 28 18:34:07 2026 Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.47]) (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 DA9E13C1D42 for ; Wed, 19 Aug 2026 03:23:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787109839; cv=none; b=Uy3cG5Y76hg2d/dO96Pwx6Ln2x3ZDvdOl29QfpSp6SP07on99oaH7zrJTeQOlWXZP7i6G7TMJtGh8fiwcBxdkGXVORgmgq87Vaz5EHdl0MKsQf4rXYXUsrTxhF5Pyr34avdund6lcAMcwrC8eUjrDEHnWZIiRlN1Nn16jsQmLd0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787109839; c=relaxed/simple; bh=twctStMz2glKuytOng+MjWv8PPpTl8oQ8U1GCHp2qPQ=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=IAeQCBp/K92FGtPfcLf/1XyXVPqxwZOWNJ6l9paxc1SQefCXdBx06qZdJ7F7ODp1Zw8JxuxVNgv99J8C0p21pKfDTfHACaA5P3nmd9nSFUmy5PZBenv9pkQmJefoumBKcDpSSDttBbVWxht2fzJ+ZwySwiyXToF/pCHqZYOEA9Y= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=rIQdfG98; arc=none smtp.client-ip=209.85.128.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="rIQdfG98" Received: by mail-wm1-f47.google.com with SMTP id 5b1f17b1804b1-4954f5e8020so2721445e9.2 for ; Tue, 18 Aug 2026 20:23:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1787109836; x=1787714636; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=YtEvtzniYxx4klPLqQdqNe7N2Kiz89koYkf1e8fhtdk=; b=rIQdfG98R4sMDH0q5eGe7ht4FcvwbkjsL+MmcwQ1ATQ1X2QSoHJpbT0a/YfGzaADeo dwPPm0+PyFQs8Pd0lyW1MCyf+Q4K0LlfVDqQo6wYZjQW073J/2IhMyA0sC/O9/LgJ9Tu 1M9LiIdEMIg9SG4HURNzhXbila8ckmAGPgDGoNaz7TuDJw5nCim/JXl0vrXh3YaXWR64 MQpzib0jQfZuQ0NKk2KTqe82h28hJTGOu/rgycK1GjhL8TOZAh5DgBblI0cRPobEBVCZ iUEN2n83aAPj9G3Vv+ZaH/ImZegSrmvKEuwrSTWpnGsRbdoZzzirv8hKCnyjD5jf9tCP t25g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787109836; x=1787714636; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=YtEvtzniYxx4klPLqQdqNe7N2Kiz89koYkf1e8fhtdk=; b=O4KMcYhmgRQIeNrwXRjhrAX7F2ntVinJJKrsUjbkj7uaUgJAwYIxV0rNDfNpF0kcXH Tk7ARcD8nv2o6RXgQyrrvAwVv8BzSrXIbebHsWLDfEsXIkqPIKSPuaFtdM69xT4HM9xf RARnqLoSVcD2fcLscoYB5mTuVp1zEJGSo0QfHvkJFXeqMh6u3NrEgcDE4oRT4rRcz6Ed btO62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qQ= X-Received: by 2002:a05:600c:1385:b0:495:5890:8f6c with SMTP id 5b1f17b1804b1-499aa17dcd0mr23267545e9.7.1787109835651; Tue, 18 Aug 2026 20:23:55 -0700 (PDT) Received: from MacBook-Pro-von-Karl.localdomain (dynamic-2a02-3100-ae9e-1d01-58d3-443d-4fa6-01cd.310.pool.telefonica.de. [2a02:3100:ae9e:1d01:58d3:443d:4fa6:1cd]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-499aa09b199sm21248595e9.0.2026.08.18.20.23.53 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 18 Aug 2026 20:23:53 -0700 (PDT) From: Karl Mehltretter To: "Joerg Roedel (AMD)" , Will Deacon Cc: Karl Mehltretter , Suravee Suthikulpanit , Vasant Hegde , Robin Murphy , iommu@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [PATCH] iommu/amd: Do not reallocate GA log buffers on resume Date: Wed, 19 Aug 2026 05:23:49 +0200 Message-Id: <20260819032349.20354-1-kmehltretter@gmail.com> X-Mailer: git-send-email 2.39.5 (Apple Git-154) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Commit c5e1a1eb9279 ("iommu/amd: Simplify and Consolidate Virtual APIC (AVIC) Enablement") moved the GA log allocation from iommu_init_pci() to enable_iommus_vapic(), which is called on every resume. iommu_init_ga_log() assigns iommu->ga_log and iommu->ga_log_tail unconditionally. Each resume therefore replaces the boot-time pointers and leaks both old allocations. The function also uses GFP_KERNEL from a syscore resume callback, where interrupts are disabled and the non-boot CPUs are offline. Return early if both buffers are already allocated. Clear the pointers in free_ga_log() so a partial allocation failure cannot leave ga_log dangling. Fixes: c5e1a1eb9279 ("iommu/amd: Simplify and Consolidate Virtual APIC (AVI= C) Enablement") Assisted-by: Claude:claude-opus-5 Signed-off-by: Karl Mehltretter Reviewed-by: Ankit Soni Reviewed-by: Vasant Hegde --- Tested with custom QEMU with GA log emulation. Stock QEMU does not advertise GAMSup and cannot reach this path. After five pm_test=3Dcore cycles, nr_iommu_pages increased from 17 to 25 without the patch. Testing on AVIC-capable hardware would be welcome. drivers/iommu/amd/init.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/iommu/amd/init.c b/drivers/iommu/amd/init.c index 40726dfef2733..c6b106d5921e 100644 --- a/drivers/iommu/amd/init.c +++ b/drivers/iommu/amd/init.c @@ -909,7 +909,9 @@ static void free_ga_log(struct amd_iommu *iommu) { #ifdef CONFIG_IRQ_REMAP iommu_free_pages(iommu->ga_log); + iommu->ga_log =3D NULL; iommu_free_pages(iommu->ga_log_tail); + iommu->ga_log_tail =3D NULL; #endif } =20 @@ -956,6 +958,9 @@ static int iommu_init_ga_log(struct amd_iommu *iommu) if (WARN_ON_ONCE(!AMD_IOMMU_GUEST_IR_VAPIC(amd_iommu_guest_ir))) return -EINVAL; =20 + if (iommu->ga_log && iommu->ga_log_tail) + return 0; + iommu->ga_log =3D iommu_alloc_pages_node_sz(nid, GFP_KERNEL, GA_LOG_SIZE); if (!iommu->ga_log) goto err_out; base-commit: 4477a78374a57c3809b172ad30cceabda48c47c6 --=20 2.53.0