From: Brian Gerst <brgerst@gmail.com>
To: linux-kernel@vger.kernel.org, x86@kernel.org
Cc: Thomas Gleixner <tglx@linutronix.de>,
Borislav Petkov <bp@alien8.de>, Ard Biesheuvel <ardb@kernel.org>,
Juergen Gross <jgross@suse.com>,
Tom Lendacky <thomas.lendacky@amd.com>,
Brian Gerst <brgerst@gmail.com>
Subject: [PATCH v2 1/5] x86/sme: Clear decrypted BSS separately
Date: Thu, 30 Jul 2026 15:58:50 -0400 [thread overview]
Message-ID: <20260730195854.421115-2-brgerst@gmail.com> (raw)
In-Reply-To: <20260730195854.421115-1-brgerst@gmail.com>
The decrypted BSS section needs to be cleared after it is remapped as
decrypted memory. Separate it so that the normal BSS section can be
cleared earlier.
Signed-off-by: Brian Gerst <brgerst@gmail.com>
---
arch/x86/kernel/vmlinux.lds.S | 2 +-
arch/x86/mm/mem_encrypt_amd.c | 4 ++++
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/arch/x86/kernel/vmlinux.lds.S b/arch/x86/kernel/vmlinux.lds.S
index 2438b89a4620..e64c797e06c7 100644
--- a/arch/x86/kernel/vmlinux.lds.S
+++ b/arch/x86/kernel/vmlinux.lds.S
@@ -365,9 +365,9 @@ SECTIONS
*(.bss..page_aligned)
. = ALIGN(PAGE_SIZE);
*(BSS_MAIN)
- BSS_DECRYPTED
. = ALIGN(PAGE_SIZE);
__bss_stop = .;
+ BSS_DECRYPTED
}
/*
diff --git a/arch/x86/mm/mem_encrypt_amd.c b/arch/x86/mm/mem_encrypt_amd.c
index 2f8c32173972..50a53fa10c96 100644
--- a/arch/x86/mm/mem_encrypt_amd.c
+++ b/arch/x86/mm/mem_encrypt_amd.c
@@ -476,6 +476,10 @@ void __init early_set_mem_enc_dec_hypercall(unsigned long vaddr, unsigned long s
void __init sme_early_init(void)
{
+ /* Needs to be cleared even if encryption is not enabled */
+ memset(__start_bss_decrypted, 0,
+ (unsigned long) __end_bss_decrypted - (unsigned long) __start_bss_decrypted);
+
if (!sme_me_mask)
return;
--
2.55.0
next prev parent reply other threads:[~2026-07-30 19:59 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-30 19:58 [PATCH v2 0/5] x86/boot: Early boot cleanups Brian Gerst
2026-07-30 19:58 ` Brian Gerst [this message]
2026-07-30 19:58 ` [PATCH v2 2/5] x86/boot/64: Clear BSS as early as possible Brian Gerst
2026-07-30 19:58 ` [PATCH v2 3/5] x86/boot: Remove hardcoded boot_param constants Brian Gerst
2026-07-30 19:58 ` [PATCH v2 4/5] x86/boot/64: Remove copy_bootdata() call Brian Gerst
2026-07-30 19:58 ` [PATCH v2 5/5] x86/boot/64: Copy boot parameters and command line earlier Brian Gerst
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=20260730195854.421115-2-brgerst@gmail.com \
--to=brgerst@gmail.com \
--cc=ardb@kernel.org \
--cc=bp@alien8.de \
--cc=jgross@suse.com \
--cc=linux-kernel@vger.kernel.org \
--cc=tglx@linutronix.de \
--cc=thomas.lendacky@amd.com \
--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