Re: [PATCH 07/11] treewide: Replace the use of mem_encrypt_active() with prot_guest_has()

From
Tom Lendacky <thomas.lendacky@amd.com>
Date
2021-08-10 19:49:05
Also in
amd-gfx, dri-devel, kexec, kvm, linux-efi, linux-fsdevel, linux-iommu, linux-s390, lkml, platform-driver-x86
Reply to
Kuppuswamy, Sathyanarayanan, 2021-08-10
On 8/10/21 1:45 PM, Kuppuswamy, Sathyanarayanan wrote:

On 7/27/21 3:26 PM, Tom Lendacky wrote:
quoted
diff --git a/arch/x86/kernel/head64.c b/arch/x86/kernel/head64.c
index de01903c3735..cafed6456d45 100644
--- a/arch/x86/kernel/head64.c
+++ b/arch/x86/kernel/head64.c
@@ -19,7 +19,7 @@
  #include <linux/start_kernel.h>
  #include <linux/io.h>
  #include <linux/memblock.h>
-#include <linux/mem_encrypt.h>
+#include <linux/protected_guest.h>
  #include <linux/pgtable.h>
    #include <asm/processor.h>
@@ -285,7 +285,7 @@ unsigned long __head __startup_64(unsigned long
physaddr,
       * there is no need to zero it after changing the memory encryption
       * attribute.
       */
-    if (mem_encrypt_active()) {
+    if (prot_guest_has(PATTR_MEM_ENCRYPT)) {
          vaddr = (unsigned long)__start_bss_decrypted;
          vaddr_end = (unsigned long)__end_bss_decrypted;

Since this change is specific to AMD, can you replace PATTR_MEM_ENCRYPT with
prot_guest_has(PATTR_SME) || prot_guest_has(PATTR_SEV). It is not used in
TDX.
This is a direct replacement for now. I think the change you're requesting
should be done as part of the TDX support patches so it's clear why it is
being changed.

But, wouldn't TDX still need to do something with this shared/unencrypted
area, though? Or since it is shared, there's actually nothing you need to
do (the bss decrpyted section exists even if CONFIG_AMD_MEM_ENCRYPT is not
configured)?

Thanks,
Tom
Thread (43 messages) 43 messages, 9 authors, last reply 2021-08-13
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help