Re: [PATCH v3 01/14] x86/sev: Rename snp_init() in the boot/compressed/sev.c file

From: Tom Lendacky
Date: Tue Apr 09 2024 - 13:44:26 EST


On 4/9/24 12:09, Borislav Petkov wrote:
On Mon, Mar 25, 2024 at 05:26:20PM -0500, Tom Lendacky wrote:
The snp_init() in boot/compressed/sev.c is local to that file and is not
called from outside of the file. Change the name so that it is not tied
to the function definition in arch/x86/include/asm/sev.h.

That part I don't understand: I can rename the function without making
it static and it builds fine, so where is it "tied" to the function
definition in kernel proper?

When it's not static and has the name snp_init(), then it has to match the definition in arch/x86/include/asm/sev.h, which is really intended for the snp_init() in arch/x86/kernel/sev.c when called from arch/x86/mm/mem_encrypt_identity.c.

So, yes, changing the name would be enough except then it remains not a static and you can get a compiler warning about not having a prototype for it if the -Wmissing-prototypes option is ever applied to that file (I don't believe it is today because it is in the decompressor code, but that can change). And since nothing calls the snp_init() in arch/x86/boot/compressed/sev.c from outside of that file, making it static was appropriate.

Thanks,
Tom


Don't get me wrong - leaking kernel proper symbols into the decompressor
has been a pet peeve of mine for a while now but this is not the case
here, is it?

And yes, the patch is fine - I'm just asking...

Thx.