From: Breno Leitao <leitao@debian.org>
To: Thomas Gleixner <tglx@kernel.org>, Ingo Molnar <mingo@redhat.com>,
Borislav Petkov <bp@alien8.de>,
Dave Hansen <dave.hansen@linux.intel.com>,
x86@kernel.org, "H. Peter Anvin" <hpa@zytor.com>,
Tom Lendacky <thomas.lendacky@amd.com>,
Neeraj Upadhyay <Neeraj.Upadhyay@amd.com>,
Nikunj A Dadhania <nikunj@amd.com>
Cc: linux-kernel@vger.kernel.org, catalin.marinas@arm.com,
kernel-team@meta.com, Breno Leitao <leitao@debian.org>
Subject: [PATCH] x86/sev: Fix kmemleak false positive for the RMP segment descriptors
Date: Mon, 02 Nov 2026 08:49:37 -0800 [thread overview]
Message-ID: <20261102-sev-rmp-kmemleak-v1-1-e6fb2eb96e79@debian.org> (raw)
kmemleak reports the RMP segment descriptor as leaked on SEV-SNP hosts:
unreferenced object 0xff11000140e23b40 (size 32):
comm "swapper/0", pid 1, jiffies 4294680964
hex dump (first 32 bytes):
00 00 00 40 00 00 a0 ff 00 fc 05 04 00 00 00 00 ...@............
00 c0 5f 40 00 00 00 00 00 00 00 00 00 00 00 00 .._@............
backtrace (crc abf63fca):
__kmalloc_cache_noprof+0x2e2/0x650
alloc_rmp_segment_desc+0xdf/0x250
setup_contiguous_rmptable+0xb0/0xd0
setup_rmptable+0x13/0x60
snp_rmptable_init+0x45/0xd0
iommu_snp_enable+0x77/0xb0
state_next+0x184/0xed0
iommu_go_to_state+0x3a/0x90
pci_iommu_init+0x32/0x50
The descriptor is still in use: get_raw_rmpentry() reads it on every RMP
lookup. Its only reference lives in rmp_segment_table[], and
alloc_rmp_segment_table() takes that table from the page allocator.
kmemleak does not scan page allocator memory, so it never sees the
reference, and mark these segments as leaked when they are not.
Register the table with kmemleak, so it is scanned like any other
object.
kmemleak_alloc() registers a block of memory with kmemleak, so kmemleak
scans it and counts pointers into it, do it with rmp_segment_table.
Signed-off-by: Breno Leitao <leitao@debian.org>
---
arch/x86/virt/svm/sev.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/arch/x86/virt/svm/sev.c b/arch/x86/virt/svm/sev.c
index bd70c4d0b774a3..751ccbdfeba98d 100644
--- a/arch/x86/virt/svm/sev.c
+++ b/arch/x86/virt/svm/sev.c
@@ -20,6 +20,7 @@
#include <linux/amd-iommu.h>
#include <linux/nospec.h>
#include <linux/workqueue.h>
+#include <linux/kmemleak.h>
#include <asm/sev.h>
#include <asm/processor.h>
@@ -361,6 +362,7 @@ static void __init free_rmp_segment_table(void)
kfree(desc);
}
+ kmemleak_free(rmp_segment_table);
free_page((unsigned long)rmp_segment_table);
rmp_segment_table = NULL;
@@ -376,6 +378,7 @@ static bool __init alloc_rmp_segment_table(void)
return false;
rmp_segment_table = page_address(page);
+ kmemleak_alloc(rmp_segment_table, RST_SIZE, 1, GFP_KERNEL);
return true;
}
---
base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4
change-id: 20261102-sev-rmp-kmemleak-053969ac2126
Best regards,
--
Breno Leitao <leitao@debian.org>
next reply other threads:[~2026-11-02 16:49 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-02 16:49 Breno Leitao [this message]
2026-11-02 20:48 ` Dave Hansen
2026-11-02 22:30 ` Breno Leitao
2026-11-02 22:54 ` Dave Hansen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261102-sev-rmp-kmemleak-v1-1-e6fb2eb96e79@debian.org \
--to=leitao@debian.org \
--cc=Neeraj.Upadhyay@amd.com \
--cc=bp@alien8.de \
--cc=catalin.marinas@arm.com \
--cc=dave.hansen@linux.intel.com \
--cc=hpa@zytor.com \
--cc=kernel-team@meta.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=nikunj@amd.com \
--cc=tglx@kernel.org \
--cc=thomas.lendacky@amd.com \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®