Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

x86/mm: Free sme_early_buffer after init

The contents of sme_early_buffer should be cleared after
__sme_early_enc_dec() because it is used to move encrypted and decrypted
data, but since __sme_early_enc_dec() is __init this buffer simply can be
freed after init.

This saves a page that is otherwise unreferenced after init.

Reported-by: Cfir Cohen <cfir@google.com>
Signed-off-by: David Rientjes <rientjes@google.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lkml.kernel.org/r/alpine.DEB.2.21.1907101318170.197432@chino.kir.corp.google.com

authored by

David Rientjes and committed by
Thomas Gleixner
ffdb07f3 e74bd969

+1 -1
+1 -1
arch/x86/mm/mem_encrypt.c
··· 41 41 bool sev_enabled __section(.data); 42 42 43 43 /* Buffer used for early in-place encryption by BSP, no locking needed */ 44 - static char sme_early_buffer[PAGE_SIZE] __aligned(PAGE_SIZE); 44 + static char sme_early_buffer[PAGE_SIZE] __initdata __aligned(PAGE_SIZE); 45 45 46 46 /* 47 47 * This routine does not change the underlying encryption setting of the