@@ -50,7 +50,8 @@ static acpi_physical_address efi_get_rsdp_addr(void)
50
50
acpi_physical_address rsdp_addr = 0 ;
51
51
52
52
#ifdef CONFIG_EFI
53
- efi_system_table_t * systab ;
53
+ unsigned long systab , systab_tables , config_tables ;
54
+ unsigned int nr_tables ;
54
55
struct efi_info * ei ;
55
56
bool efi_64 ;
56
57
int size , i ;
@@ -70,46 +71,57 @@ static acpi_physical_address efi_get_rsdp_addr(void)
70
71
71
72
/* Get systab from boot params. */
72
73
#ifdef CONFIG_X86_64
73
- systab = ( efi_system_table_t * )( ei -> efi_systab | ((__u64 )ei -> efi_systab_hi << 32 ) );
74
+ systab = ei -> efi_systab | ((__u64 )ei -> efi_systab_hi << 32 );
74
75
#else
75
76
if (ei -> efi_systab_hi || ei -> efi_memmap_hi ) {
76
77
debug_putstr ("Error getting RSDP address: EFI system table located above 4GB.\n" );
77
78
return 0 ;
78
79
}
79
- systab = ( efi_system_table_t * ) ei -> efi_systab ;
80
+ systab = ei -> efi_systab ;
80
81
#endif
81
82
if (!systab )
82
83
error ("EFI system table not found." );
83
84
84
- /*
85
- * Get EFI tables from systab.
86
- */
87
- size = efi_64 ? sizeof (efi_config_table_64_t ) :
88
- sizeof (efi_config_table_32_t );
85
+ /* Handle EFI bitness properly */
86
+ if (efi_64 ) {
87
+ efi_system_table_64_t * stbl = (efi_system_table_64_t * )systab ;
88
+
89
+ config_tables = stbl -> tables ;
90
+ nr_tables = stbl -> nr_tables ;
91
+ size = sizeof (efi_config_table_64_t );
92
+ } else {
93
+ efi_system_table_32_t * stbl = (efi_system_table_32_t * )systab ;
89
94
90
- for (i = 0 ; i < systab -> nr_tables ; i ++ ) {
95
+ config_tables = stbl -> tables ;
96
+ nr_tables = stbl -> nr_tables ;
97
+ size = sizeof (efi_config_table_32_t );
98
+ }
99
+
100
+ if (!config_tables )
101
+ error ("EFI config tables not found." );
102
+
103
+ /* Get EFI tables from systab. */
104
+ for (i = 0 ; i < nr_tables ; i ++ ) {
91
105
acpi_physical_address table ;
92
- void * config_tables ;
93
106
efi_guid_t guid ;
94
107
95
- config_tables = (void * )(systab -> tables + size * i );
108
+ config_tables += size ;
109
+
96
110
if (efi_64 ) {
97
- efi_config_table_64_t * tmp_table ;
111
+ efi_config_table_64_t * tbl = ( efi_config_table_64_t * ) config_tables ;
98
112
99
- tmp_table = config_tables ;
100
- guid = tmp_table -> guid ;
101
- table = tmp_table -> table ;
113
+ guid = tbl -> guid ;
114
+ table = tbl -> table ;
102
115
103
116
if (!IS_ENABLED (CONFIG_X86_64 ) && table >> 32 ) {
104
117
debug_putstr ("Error getting RSDP address: EFI config table located above 4GB.\n" );
105
118
return 0 ;
106
119
}
107
120
} else {
108
- efi_config_table_32_t * tmp_table ;
121
+ efi_config_table_32_t * tbl = ( efi_config_table_32_t * ) config_tables ;
109
122
110
- tmp_table = config_tables ;
111
- guid = tmp_table -> guid ;
112
- table = tmp_table -> table ;
123
+ guid = tbl -> guid ;
124
+ table = tbl -> table ;
113
125
}
114
126
115
127
if (!(efi_guidcmp (guid , ACPI_TABLE_GUID )))
0 commit comments