]> git.baikalelectronics.ru Git - kernel.git/commitdiff
x86/compressed/64: Add identity mapping for Confidential Computing blob
authorMichael Roth <michael.roth@amd.com>
Thu, 24 Feb 2022 16:56:17 +0000 (10:56 -0600)
committerBorislav Petkov <bp@suse.de>
Thu, 7 Apr 2022 14:47:11 +0000 (16:47 +0200)
The run-time kernel will need to access the Confidential Computing blob
very early during boot to access the CPUID table it points to. At that
stage, it will be relying on the identity-mapped page table set up by
the boot/compressed kernel, so make sure the blob and the CPUID table it
points to are mapped in advance.

  [ bp: Massage. ]

Signed-off-by: Michael Roth <michael.roth@amd.com>
Signed-off-by: Brijesh Singh <brijesh.singh@amd.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Link: https://lore.kernel.org/r/20220307213356.2797205-38-brijesh.singh@amd.com
arch/x86/boot/compressed/ident_map_64.c
arch/x86/boot/compressed/misc.h
arch/x86/boot/compressed/sev.c

index 99348ee7999b115ebe544ee00a275931bef9e8fe..44c350d627c79b4b13e29bfe74cbec1e5c69879f 100644 (file)
@@ -163,8 +163,9 @@ void initialize_identity_maps(void *rmode)
        cmdline = get_cmd_line_ptr();
        kernel_add_identity_map(cmdline, cmdline + COMMAND_LINE_SIZE);
 
+       sev_prep_identity_maps(top_level_pgt);
+
        /* Load the new page-table. */
-       sev_verify_cbit(top_level_pgt);
        write_cr3(top_level_pgt);
 }
 
index aae2722c6e9abb915854107e95cbcc351cdd02f3..75d284ec763f0c64826ca512ab73e11dae488399 100644 (file)
@@ -127,6 +127,7 @@ void sev_es_shutdown_ghcb(void);
 extern bool sev_es_check_ghcb_fault(unsigned long address);
 void snp_set_page_private(unsigned long paddr);
 void snp_set_page_shared(unsigned long paddr);
+void sev_prep_identity_maps(unsigned long top_level_pgt);
 #else
 static inline void sev_enable(struct boot_params *bp) { }
 static inline void sev_es_shutdown_ghcb(void) { }
@@ -136,6 +137,7 @@ static inline bool sev_es_check_ghcb_fault(unsigned long address)
 }
 static inline void snp_set_page_private(unsigned long paddr) { }
 static inline void snp_set_page_shared(unsigned long paddr) { }
+static inline void sev_prep_identity_maps(unsigned long top_level_pgt) { }
 #endif
 
 /* acpi.c */
index dd3cf55696d4d03af2be6a1da1761b5b6698b187..1e4930ce2c958533c4b353093cd219261b909896 100644 (file)
@@ -478,3 +478,24 @@ bool snp_init(struct boot_params *bp)
 
        return true;
 }
+
+void sev_prep_identity_maps(unsigned long top_level_pgt)
+{
+       /*
+        * The Confidential Computing blob is used very early in uncompressed
+        * kernel to find the in-memory CPUID table to handle CPUID
+        * instructions. Make sure an identity-mapping exists so it can be
+        * accessed after switchover.
+        */
+       if (sev_snp_enabled()) {
+               unsigned long cc_info_pa = boot_params->cc_blob_address;
+               struct cc_blob_sev_info *cc_info;
+
+               kernel_add_identity_map(cc_info_pa, cc_info_pa + sizeof(*cc_info));
+
+               cc_info = (struct cc_blob_sev_info *)cc_info_pa;
+               kernel_add_identity_map(cc_info->cpuid_phys, cc_info->cpuid_phys + cc_info->cpuid_len);
+       }
+
+       sev_verify_cbit(top_level_pgt);
+}