From: Dave Hansen <dave.hansen@intel.com>
To: Hamza Mahfooz <hamzamahfooz@linux.microsoft.com>, x86@kernel.org
Cc: Thomas Gleixner <tglx@kernel.org>, Ingo Molnar <mingo@redhat.com>,
Borislav Petkov <bp@alien8.de>,
Dave Hansen <dave.hansen@linux.intel.com>,
"H. Peter Anvin" <hpa@zytor.com>,
Andy Lutomirski <luto@kernel.org>,
Peter Zijlstra <peterz@infradead.org>,
Ard Biesheuvel <ardb@kernel.org>,
Nathan Chancellor <nathan@kernel.org>, Rong Xu <xur@google.com>,
Kees Cook <kees@kernel.org>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v4] x86/mm/64: free the gap between BSS_MAIN and BSS_DECRYPTED
Date: Mon, 20 Jul 2026 05:10:45 -0700 [thread overview]
Message-ID: <c22e7d85-ae4e-4d7d-abba-51a6dd717e8f@intel.com> (raw)
In-Reply-To: <20260720112010.1095917-1-hamzamahfooz@linux.microsoft.com>
On 7/20/26 04:20, Hamza Mahfooz wrote:
> This region is unused and takes up, up to 2 MiB
> of memory if AMD_MEM_ENCRYPT is enabled. So, free it in
> mem_encrypt_free_decrypted_mem().
For something like this, I'd really appreciate if contributors bring
_some_ kind of mention of testing to the changelog.
A great addition to this would be a blurb that mentioned an increase in
MemFree on boot, or a note about the delta in dmesg on startup that
shows the patch working.
> diff --git a/arch/x86/kernel/vmlinux.lds.S b/arch/x86/kernel/vmlinux.lds.S
> index 4711a35e706c..179578a08da1 100644
> --- a/arch/x86/kernel/vmlinux.lds.S
> +++ b/arch/x86/kernel/vmlinux.lds.S
> @@ -88,6 +88,8 @@ const_cpu_current_top_of_stack = cpu_current_top_of_stack;
> * decrypted to avoid exposing more than we wish.
> */
> #define BSS_DECRYPTED \
> + . = ALIGN(PAGE_SIZE); \
> + __start_bss_decrypted_gap = .; \
> . = ALIGN(PMD_SIZE); \
> __start_bss_decrypted = .; \
> __pi___start_bss_decrypted = .; \
> diff --git a/arch/x86/mm/mem_encrypt_amd.c b/arch/x86/mm/mem_encrypt_amd.c
> index 2f8c32173972..8d518571ae5c 100644
> --- a/arch/x86/mm/mem_encrypt_amd.c
> +++ b/arch/x86/mm/mem_encrypt_amd.c
> @@ -566,4 +566,10 @@ void __init mem_encrypt_free_decrypted_mem(void)
> }
>
> free_init_pages("unused decrypted", vaddr, vaddr_end);
> +
> + vaddr = PFN_ALIGN(__start_bss_decrypted_gap);
> + vaddr_end = PFN_ALIGN(__start_bss_decrypted);
> +
> + free_kernel_image_pages("unused kernel image (bss_decrypted gap)",
> + (void *)vaddr, (void *)vaddr_end);
> }
What purpose do the two new PFN_ALIGN()s serve?
next prev parent reply other threads:[~2026-07-20 12:10 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-20 11:20 Hamza Mahfooz
2026-07-20 12:10 ` Dave Hansen [this message]
2026-07-20 16:02 ` Hamza Mahfooz
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=c22e7d85-ae4e-4d7d-abba-51a6dd717e8f@intel.com \
--to=dave.hansen@intel.com \
--cc=ardb@kernel.org \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=hamzamahfooz@linux.microsoft.com \
--cc=hpa@zytor.com \
--cc=kees@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@kernel.org \
--cc=mingo@redhat.com \
--cc=nathan@kernel.org \
--cc=peterz@infradead.org \
--cc=tglx@kernel.org \
--cc=x86@kernel.org \
--cc=xur@google.com \
/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
Powered by JetHome