mirror of
https://github.com/tbsdtv/linux_media.git
synced 2025-07-23 20:51:03 +02:00
x86/compressed/acpi: Move EFI system table lookup to helper
Future patches for SEV-SNP-validated CPUID will also require early parsing of the EFI configuration. Incrementally move the related code into a set of helpers that can be re-used for that purpose. 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-26-brijesh.singh@amd.com
This commit is contained in:
committed by
Borislav Petkov
parent
7c4146e888
commit
58f3e6b71f
@@ -105,7 +105,7 @@ static acpi_physical_address kexec_get_rsdp_addr(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Get systab from boot params. */
|
/* Get systab from boot params. */
|
||||||
systab = (efi_system_table_64_t *) (ei->efi_systab | ((__u64)ei->efi_systab_hi << 32));
|
systab = (efi_system_table_64_t *)efi_get_system_table(boot_params);
|
||||||
if (!systab)
|
if (!systab)
|
||||||
error("EFI system table not found in kexec boot_params.");
|
error("EFI system table not found in kexec boot_params.");
|
||||||
|
|
||||||
@@ -118,9 +118,8 @@ static acpi_physical_address kexec_get_rsdp_addr(void) { return 0; }
|
|||||||
static acpi_physical_address efi_get_rsdp_addr(void)
|
static acpi_physical_address efi_get_rsdp_addr(void)
|
||||||
{
|
{
|
||||||
#ifdef CONFIG_EFI
|
#ifdef CONFIG_EFI
|
||||||
unsigned long systab, config_tables;
|
unsigned long systab_pa, config_tables;
|
||||||
unsigned int nr_tables;
|
unsigned int nr_tables;
|
||||||
struct efi_info *ei;
|
|
||||||
enum efi_type et;
|
enum efi_type et;
|
||||||
bool efi_64;
|
bool efi_64;
|
||||||
|
|
||||||
@@ -132,24 +131,18 @@ static acpi_physical_address efi_get_rsdp_addr(void)
|
|||||||
else
|
else
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
/* Get systab from boot params. */
|
systab_pa = efi_get_system_table(boot_params);
|
||||||
ei = &boot_params->efi_info;
|
if (!systab_pa)
|
||||||
#ifdef CONFIG_X86_64
|
error("EFI support advertised, but unable to locate system table.");
|
||||||
systab = ei->efi_systab | ((__u64)ei->efi_systab_hi << 32);
|
|
||||||
#else
|
|
||||||
systab = ei->efi_systab;
|
|
||||||
#endif
|
|
||||||
if (!systab)
|
|
||||||
error("EFI system table not found.");
|
|
||||||
|
|
||||||
/* Handle EFI bitness properly */
|
/* Handle EFI bitness properly */
|
||||||
if (efi_64) {
|
if (efi_64) {
|
||||||
efi_system_table_64_t *stbl = (efi_system_table_64_t *)systab;
|
efi_system_table_64_t *stbl = (efi_system_table_64_t *)systab_pa;
|
||||||
|
|
||||||
config_tables = stbl->tables;
|
config_tables = stbl->tables;
|
||||||
nr_tables = stbl->nr_tables;
|
nr_tables = stbl->nr_tables;
|
||||||
} else {
|
} else {
|
||||||
efi_system_table_32_t *stbl = (efi_system_table_32_t *)systab;
|
efi_system_table_32_t *stbl = (efi_system_table_32_t *)systab_pa;
|
||||||
|
|
||||||
config_tables = stbl->tables;
|
config_tables = stbl->tables;
|
||||||
nr_tables = stbl->nr_tables;
|
nr_tables = stbl->nr_tables;
|
||||||
|
@@ -48,3 +48,32 @@ enum efi_type efi_get_type(struct boot_params *bp)
|
|||||||
|
|
||||||
return et;
|
return et;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* efi_get_system_table - Given a pointer to boot_params, retrieve the physical address
|
||||||
|
* of the EFI system table.
|
||||||
|
*
|
||||||
|
* @bp: pointer to boot_params
|
||||||
|
*
|
||||||
|
* Return: EFI system table address on success. On error, return 0.
|
||||||
|
*/
|
||||||
|
unsigned long efi_get_system_table(struct boot_params *bp)
|
||||||
|
{
|
||||||
|
unsigned long sys_tbl_pa;
|
||||||
|
struct efi_info *ei;
|
||||||
|
enum efi_type et;
|
||||||
|
|
||||||
|
/* Get systab from boot params. */
|
||||||
|
ei = &bp->efi_info;
|
||||||
|
#ifdef CONFIG_X86_64
|
||||||
|
sys_tbl_pa = ei->efi_systab | ((__u64)ei->efi_systab_hi << 32);
|
||||||
|
#else
|
||||||
|
sys_tbl_pa = ei->efi_systab;
|
||||||
|
#endif
|
||||||
|
if (!sys_tbl_pa) {
|
||||||
|
debug_putstr("EFI system table not found.");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return sys_tbl_pa;
|
||||||
|
}
|
||||||
|
@@ -185,11 +185,17 @@ enum efi_type {
|
|||||||
#ifdef CONFIG_EFI
|
#ifdef CONFIG_EFI
|
||||||
/* helpers for early EFI config table access */
|
/* helpers for early EFI config table access */
|
||||||
enum efi_type efi_get_type(struct boot_params *bp);
|
enum efi_type efi_get_type(struct boot_params *bp);
|
||||||
|
unsigned long efi_get_system_table(struct boot_params *bp);
|
||||||
#else
|
#else
|
||||||
static inline enum efi_type efi_get_type(struct boot_params *bp)
|
static inline enum efi_type efi_get_type(struct boot_params *bp)
|
||||||
{
|
{
|
||||||
return EFI_TYPE_NONE;
|
return EFI_TYPE_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline unsigned long efi_get_system_table(struct boot_params *bp)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
#endif /* CONFIG_EFI */
|
#endif /* CONFIG_EFI */
|
||||||
|
|
||||||
#endif /* BOOT_COMPRESSED_MISC_H */
|
#endif /* BOOT_COMPRESSED_MISC_H */
|
||||||
|
Reference in New Issue
Block a user