From: Tom Lendacky <thomas.lendacky@amd.com>
To: Ashish Kalra <Ashish.Kalra@amd.com>,
tglx@linutronix.de, mingo@redhat.com, bp@alien8.de,
dave.hansen@linux.intel.com, x86@kernel.org, hpa@zytor.com,
seanjc@google.com, pbonzini@redhat.com,
herbert@gondor.apana.org.au
Cc: nikunj@amd.com, davem@davemloft.net, aik@amd.com,
ardb@kernel.org, john.allen@amd.com, michael.roth@amd.com,
Neeraj.Upadhyay@amd.com, linux-kernel@vger.kernel.org,
kvm@vger.kernel.org, linux-crypto@vger.kernel.org
Subject: Re: [PATCH v4 1/3] x86/sev: Add new dump_rmp parameter to snp_leak_pages() API
Date: Fri, 12 Sep 2025 09:52:40 -0500 [thread overview]
Message-ID: <7132d855-d855-43c4-83a7-a6d165fc1a75@amd.com> (raw)
In-Reply-To: <c6d2fbe31bd9e2638eaefaabe6d0ffc55f5886bd.1757543774.git.ashish.kalra@amd.com>
On 9/10/25 17:55, Ashish Kalra wrote:
> From: Ashish Kalra <ashish.kalra@amd.com>
>
> When leaking certain page types, such as Hypervisor Fixed (HV_FIXED)
> pages, it does not make sense to dump RMP contents for the 2MB range of
> the page(s) being leaked. In the case of HV_FIXED pages, this is not an
> error situation where the surrounding 2MB page RMP entries can provide
> debug information.
>
> Add new __snp_leak_pages() API with dump_rmp bool parameter to support
> continue adding pages to the snp_leaked_pages_list but not issue
> dump_rmpentry().
>
> Make snp_leak_pages() a wrapper for the common case which also allows
> existing users to continue to dump RMP entries.
>
> Suggested-by: Thomas Lendacky <Thomas.Lendacky@amd.com>
> Suggested-by: Sean Christopherson <seanjc@google.com>
> Signed-off-by: Ashish Kalra <ashish.kalra@amd.com>
Reviewed-by: Tom Lendacky <thomas.lendacky@amd.com>
> ---
> arch/x86/include/asm/sev.h | 8 +++++++-
> arch/x86/virt/svm/sev.c | 7 ++++---
> 2 files changed, 11 insertions(+), 4 deletions(-)
>
> diff --git a/arch/x86/include/asm/sev.h b/arch/x86/include/asm/sev.h
> index 00475b814ac4..7a1ae990b15f 100644
> --- a/arch/x86/include/asm/sev.h
> +++ b/arch/x86/include/asm/sev.h
> @@ -635,10 +635,15 @@ void snp_dump_hva_rmpentry(unsigned long address);
> int psmash(u64 pfn);
> int rmp_make_private(u64 pfn, u64 gpa, enum pg_level level, u32 asid, bool immutable);
> int rmp_make_shared(u64 pfn, enum pg_level level);
> -void snp_leak_pages(u64 pfn, unsigned int npages);
> +void __snp_leak_pages(u64 pfn, unsigned int npages, bool dump_rmp);
> void kdump_sev_callback(void);
> void snp_fixup_e820_tables(void);
>
> +static inline void snp_leak_pages(u64 pfn, unsigned int pages)
> +{
> + __snp_leak_pages(pfn, pages, true);
> +}
> +
> static inline void sev_evict_cache(void *va, int npages)
> {
> volatile u8 val __always_unused;
> @@ -668,6 +673,7 @@ static inline int rmp_make_private(u64 pfn, u64 gpa, enum pg_level level, u32 as
> return -ENODEV;
> }
> static inline int rmp_make_shared(u64 pfn, enum pg_level level) { return -ENODEV; }
> +static inline void __snp_leak_pages(u64 pfn, unsigned int npages, bool dump_rmp) {}
> static inline void snp_leak_pages(u64 pfn, unsigned int npages) {}
> static inline void kdump_sev_callback(void) { }
> static inline void snp_fixup_e820_tables(void) {}
> diff --git a/arch/x86/virt/svm/sev.c b/arch/x86/virt/svm/sev.c
> index 942372e69b4d..ee643a6cd691 100644
> --- a/arch/x86/virt/svm/sev.c
> +++ b/arch/x86/virt/svm/sev.c
> @@ -1029,7 +1029,7 @@ int rmp_make_shared(u64 pfn, enum pg_level level)
> }
> EXPORT_SYMBOL_GPL(rmp_make_shared);
>
> -void snp_leak_pages(u64 pfn, unsigned int npages)
> +void __snp_leak_pages(u64 pfn, unsigned int npages, bool dump_rmp)
> {
> struct page *page = pfn_to_page(pfn);
>
> @@ -1052,14 +1052,15 @@ void snp_leak_pages(u64 pfn, unsigned int npages)
> (PageHead(page) && compound_nr(page) <= npages))
> list_add_tail(&page->buddy_list, &snp_leaked_pages_list);
>
> - dump_rmpentry(pfn);
> + if (dump_rmp)
> + dump_rmpentry(pfn);
> snp_nr_leaked_pages++;
> pfn++;
> page++;
> }
> spin_unlock(&snp_leaked_pages_list_lock);
> }
> -EXPORT_SYMBOL_GPL(snp_leak_pages);
> +EXPORT_SYMBOL_GPL(__snp_leak_pages);
>
> void kdump_sev_callback(void)
> {
next prev parent reply other threads:[~2025-09-12 14:52 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-10 22:55 [PATCH v4 0/3] crypto: ccp - Add AMD Seamless Firmware Servicing (SFS) driver Ashish Kalra
2025-09-10 22:55 ` [PATCH v4 1/3] x86/sev: Add new dump_rmp parameter to snp_leak_pages() API Ashish Kalra
2025-09-12 14:52 ` Tom Lendacky [this message]
2025-09-12 15:58 ` Borislav Petkov
2025-09-12 18:34 ` Sean Christopherson
2025-09-13 10:55 ` Borislav Petkov
2025-09-16 3:51 ` Herbert Xu
2025-09-16 10:27 ` Borislav Petkov
2025-09-12 18:34 ` Sean Christopherson
2025-09-12 19:37 ` Tom Lendacky
2025-09-12 19:41 ` Sean Christopherson
2025-09-12 19:52 ` Tom Lendacky
2025-09-10 22:55 ` [PATCH v4 2/3] crypto: ccp - Add new HV-Fixed page allocation/free API Ashish Kalra
2025-09-12 14:57 ` Tom Lendacky
2025-09-10 22:55 ` [PATCH v4 3/3] crypto: ccp - Add AMD Seamless Firmware Servicing (SFS) driver Ashish Kalra
2025-09-12 15:49 ` Tom Lendacky
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=7132d855-d855-43c4-83a7-a6d165fc1a75@amd.com \
--to=thomas.lendacky@amd.com \
--cc=Ashish.Kalra@amd.com \
--cc=Neeraj.Upadhyay@amd.com \
--cc=aik@amd.com \
--cc=ardb@kernel.org \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=davem@davemloft.net \
--cc=herbert@gondor.apana.org.au \
--cc=hpa@zytor.com \
--cc=john.allen@amd.com \
--cc=kvm@vger.kernel.org \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=michael.roth@amd.com \
--cc=mingo@redhat.com \
--cc=nikunj@amd.com \
--cc=pbonzini@redhat.com \
--cc=seanjc@google.com \
--cc=tglx@linutronix.de \
--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