From: Dexuan Cui <decui@microsoft.com>
To: dave.hansen@linux.intel.com, luto@kernel.org,
peterz@infradead.org, tglx@linutronix.de, mingo@redhat.com,
bp@alien8.de, x86@kernel.org, hpa@zytor.com,
brijesh.singh@amd.com
Cc: linux-kernel@vger.kernel.org, linux-hyperv@vger.kernel.org,
Dexuan Cui <decui@microsoft.com>
Subject: [PATCH] x86/sev: mem_encrypt_free_decrypted_mem(): encrypt the pages for AMD SME only
Date: Sun, 27 Nov 2022 17:28:52 -0800 [thread overview]
Message-ID: <20221128012852.8561-1-decui@microsoft.com> (raw)
sme_postprocess_startup() marks the __start_bss_decrypted pages shared
for AMD SME only, so here set_memory_encrypted() should be called for AMD
SME only, i.e. don't call the set_memory_encrypted() for TDX, otherwise the
error "failed to free unused decrypted pages" appears in 'dmesg'.
Fixes: b3f0907c71e0 ("x86/mm: Add .bss..decrypted section to hold shared variables")
Signed-off-by: Dexuan Cui <decui@microsoft.com>
---
arch/x86/mm/mem_encrypt_amd.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/x86/mm/mem_encrypt_amd.c b/arch/x86/mm/mem_encrypt_amd.c
index 9c4d8dbcb129..fd9b58402a22 100644
--- a/arch/x86/mm/mem_encrypt_amd.c
+++ b/arch/x86/mm/mem_encrypt_amd.c
@@ -516,7 +516,7 @@ void __init mem_encrypt_free_decrypted_mem(void)
* The unused memory range was mapped decrypted, change the encryption
* attribute from decrypted to encrypted before freeing it.
*/
- if (cc_platform_has(CC_ATTR_MEM_ENCRYPT)) {
+ if (sme_me_mask && cc_platform_has(CC_ATTR_MEM_ENCRYPT)) {
r = set_memory_encrypted(vaddr, npages);
if (r) {
pr_warn("failed to free unused decrypted pages\n");
--
2.25.1
next reply other threads:[~2022-11-28 1:29 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-28 1:28 Dexuan Cui [this message]
2022-11-28 2:38 ` [PATCH] x86/sev: mem_encrypt_free_decrypted_mem(): encrypt the pages for AMD SME only Dexuan Cui
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=20221128012852.8561-1-decui@microsoft.com \
--to=decui@microsoft.com \
--cc=bp@alien8.de \
--cc=brijesh.singh@amd.com \
--cc=dave.hansen@linux.intel.com \
--cc=hpa@zytor.com \
--cc=linux-hyperv@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@kernel.org \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
--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;
as well as URLs for NNTP newsgroup(s).