History

efi/libstub: Distinguish between native/mixed not 32/64 bit

Currently, we support mixed mode by casting all boot time firmware calls to 64-bit explicitly on native 64-bit systems, and to 32-bit on 32-bit systems or 64-bit systems running with 32-bit firmware. Due to this explicit awareness of the bitness in the code, we do a lot of casting even on generic code that is shared with other architectures, where mixed mode does not even exist. This casting leads to loss of coverage of type checking by the compiler, which we should try to avoid. So instead of distinguishing between 32-bit vs 64-bit, distinguish between native vs mixed, and limit all the nasty casting and pointer mangling to the code that actually deals with mixed mode.

Ard Biesheuvel committed 6 years ago

Commit f958efe1 parent 1786e836 files · +49 −44Browse files

Showing the changes to include/linux (1 of 6 files). Show all

Unified · Split

include/linux/efi.h+3−3
@@ -49,11 +49,11 @@ typedef u64 efi_physical_addr_t; · 48 unmodified lines
4949 typedef void *efi_handle_t;
5050
5151 #define efi_get_handle_at(array, idx) \
52− (efi_is_64bit() ? (efi_handle_t)(unsigned long)((u64 *)(array))[idx] \
52+ (efi_is_native() ? (array)[idx] \
5353 : (efi_handle_t)(unsigned long)((u32 *)(array))[idx])
5454
5555 #define efi_get_handle_num(size) \
56− ((size) / (efi_is_64bit() ? sizeof(u64) : sizeof(u32)))
56+ ((size) / (efi_is_native() ? sizeof(efi_handle_t) : sizeof(u32)))
5757
5858 #define for_each_efi_handle(handle, array, size, i) \
5959 for (i = 0; \
@@ -805,7 +805,7 @@ typedef struct { · 745 unmodified lines
805805 typedef union {
806806 struct {
807807 efi_guid_t guid;
808− unsigned long table;
808+ void *table;
809809 };
810810 efi_config_table_32_t mixed_mode;
811811 } efi_config_table_t;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t