lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <df357d87-3b4b-41a4-acdf-31289590b233@amd.com>
Date: Fri, 12 Sep 2025 14:37:13 -0500
From: Tom Lendacky <thomas.lendacky@....com>
To: Sean Christopherson <seanjc@...gle.com>,
 Ashish Kalra <Ashish.Kalra@....com>
Cc: tglx@...utronix.de, mingo@...hat.com, bp@...en8.de,
 dave.hansen@...ux.intel.com, x86@...nel.org, hpa@...or.com,
 pbonzini@...hat.com, herbert@...dor.apana.org.au, nikunj@....com,
 davem@...emloft.net, aik@....com, ardb@...nel.org, john.allen@....com,
 michael.roth@....com, Neeraj.Upadhyay@....com, linux-kernel@...r.kernel.org,
 kvm@...r.kernel.org, linux-crypto@...r.kernel.org
Subject: Re: [PATCH v4 1/3] x86/sev: Add new dump_rmp parameter to
 snp_leak_pages() API

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


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ