public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Tom Lendacky <thomas.lendacky@amd.com>
To: Sean Christopherson <seanjc@google.com>,
	Ashish Kalra <Ashish.Kalra@amd.com>
Cc: tglx@linutronix.de, mingo@redhat.com, bp@alien8.de,
	dave.hansen@linux.intel.com, x86@kernel.org, hpa@zytor.com,
	pbonzini@redhat.com, herbert@gondor.apana.org.au, 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 14:37:13 -0500	[thread overview]
Message-ID: <df357d87-3b4b-41a4-acdf-31289590b233@amd.com> (raw)
In-Reply-To: <aMRnnNVYBrasJnZF@google.com>

On 9/12/25 13:34, Sean Christopherson wrote:
> On Wed, Sep 10, 2025, Ashish Kalra wrote:
>> 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) {}
> 
> This stub is unnecessary.  As pointed out elsewhere[*], I'm pretty sure all these
> stubs are unnecessary.
> 
> Oof.  Even worse, the stubs appear to be actively hiding bugs.  The APIs are
> guarded with CONFIG_KVM_AMD_SEV=y, but **KVM** doesn't call any of these outside
> of SEV code.  I.e. if *KVM* were the only user, the stubs would just be dead code.
> 
> But the below build failures show that they aren't dead code, which means that
> kernels with CONFIG_KVM_AMD_SEV=n will silently (until something explodes) do the
> wrong thing, because the stubs are hiding the missing dependencies.
> 
> arch/x86/boot/startup/sev-shared.c: In function ‘pvalidate_4k_page’:
> arch/x86/boot/startup/sev-shared.c:820:17: error: implicit declaration of function ‘sev_evict_cache’ [-Wimplicit-function-declaration]
>   820 |                 sev_evict_cache((void *)vaddr, 1);

Yeah, this one is on me. sev_evict_cache() is guest code and should be
under the CONFIG_AMD_MEM_ENCRYPT #ifdef.

>       |                 ^~~~~~~~~~~~~~~
>   AR      arch/x86/realmode/built-in.a
> arch/x86/coco/sev/core.c: In function ‘pvalidate_pages’:
> arch/x86/coco/sev/core.c:386:25: error: implicit declaration of function ‘sev_evict_cache’ [-Wimplicit-function-declaration]
>   386 |                         sev_evict_cache(pfn_to_kaddr(e->gfn), e->pagesize ? 512 : 1);
>       |                         ^~~~~~~~~~~~~~~
> arch/x86/mm/mem_encrypt.c: In function ‘mem_encrypt_setup_arch’:
> arch/x86/mm/mem_encrypt.c:112:17: error: implicit declaration of function ‘snp_fixup_e820_tables’ [-Wimplicit-function-declaration]
>   112 |                 snp_fixup_e820_tables();

This function is only meant to be used if we're going to run SEV guests,
so being guarded by CONFIG_KVM_AMD_SEV was on purpose. I'm just not sure
why the stub didn't get used...  or did you remove them?

>       |                 ^~~~~~~~~~~~~~~~~~~~~
> arch/x86/mm/fault.c: In function ‘show_fault_oops’:
> arch/x86/mm/fault.c:587:17: error: implicit declaration of function ‘snp_dump_hva_rmpentry’ [-Wimplicit-function-declaration]
>   587 |                 snp_dump_hva_rmpentry(address);

Ditto here.

>       |                 ^~~~~~~~~~~~~~~~~~~~~
> arch/x86/kernel/cpu/amd.c: In function ‘bsp_determine_snp’:
> arch/x86/kernel/cpu/amd.c:370:21: error: implicit declaration of function ‘snp_probe_rmptable_info’ [-Wimplicit-function-declaration]
>   370 |                     snp_probe_rmptable_info()) {

and here.

Thanks,
Tom

>       |                     ^~~~~~~~~~~~~~~~~~~~~~~
>   AR      drivers/iommu/amd/built-in.a
>   AR      drivers/iommu/built-in.a
>   AR      drivers/built-in.a
> 
> [*] https://lore.kernel.org/all/aMHP5EO-ucJGdHXz@google.com


  reply	other threads:[~2025-09-12 19:37 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
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 [this message]
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=df357d87-3b4b-41a4-acdf-31289590b233@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