~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/x86/boot/compressed/mem.c

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 // SPDX-License-Identifier: GPL-2.0-only
  2 
  3 #include "error.h"
  4 #include "misc.h"
  5 #include "tdx.h"
  6 #include "sev.h"
  7 #include <asm/shared/tdx.h>
  8 
  9 /*
 10  * accept_memory() and process_unaccepted_memory() called from EFI stub which
 11  * runs before decompressor and its early_tdx_detect().
 12  *
 13  * Enumerate TDX directly from the early users.
 14  */
 15 static bool early_is_tdx_guest(void)
 16 {
 17         static bool once;
 18         static bool is_tdx;
 19 
 20         if (!IS_ENABLED(CONFIG_INTEL_TDX_GUEST))
 21                 return false;
 22 
 23         if (!once) {
 24                 u32 eax, sig[3];
 25 
 26                 cpuid_count(TDX_CPUID_LEAF_ID, 0, &eax,
 27                             &sig[0], &sig[2],  &sig[1]);
 28                 is_tdx = !memcmp(TDX_IDENT, sig, sizeof(sig));
 29                 once = true;
 30         }
 31 
 32         return is_tdx;
 33 }
 34 
 35 void arch_accept_memory(phys_addr_t start, phys_addr_t end)
 36 {
 37         /* Platform-specific memory-acceptance call goes here */
 38         if (early_is_tdx_guest()) {
 39                 if (!tdx_accept_memory(start, end))
 40                         panic("TDX: Failed to accept memory\n");
 41         } else if (sev_snp_enabled()) {
 42                 snp_accept_memory(start, end);
 43         } else {
 44                 error("Cannot accept memory: unknown platform\n");
 45         }
 46 }
 47 
 48 bool init_unaccepted_memory(void)
 49 {
 50         guid_t guid = LINUX_EFI_UNACCEPTED_MEM_TABLE_GUID;
 51         struct efi_unaccepted_memory *table;
 52         unsigned long cfg_table_pa;
 53         unsigned int cfg_table_len;
 54         enum efi_type et;
 55         int ret;
 56 
 57         et = efi_get_type(boot_params_ptr);
 58         if (et == EFI_TYPE_NONE)
 59                 return false;
 60 
 61         ret = efi_get_conf_table(boot_params_ptr, &cfg_table_pa, &cfg_table_len);
 62         if (ret) {
 63                 warn("EFI config table not found.");
 64                 return false;
 65         }
 66 
 67         table = (void *)efi_find_vendor_table(boot_params_ptr, cfg_table_pa,
 68                                               cfg_table_len, guid);
 69         if (!table)
 70                 return false;
 71 
 72         if (table->version != 1)
 73                 error("Unknown version of unaccepted memory table\n");
 74 
 75         /*
 76          * In many cases unaccepted_table is already set by EFI stub, but it
 77          * has to be initialized again to cover cases when the table is not
 78          * allocated by EFI stub or EFI stub copied the kernel image with
 79          * efi_relocate_kernel() before the variable is set.
 80          *
 81          * It must be initialized before the first usage of accept_memory().
 82          */
 83         unaccepted_table = table;
 84 
 85         return true;
 86 }
 87 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php