-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
efi: libstub: Move screen_info handling to common code
Currently, arm64, RISC-V and LoongArch rely on the fact that struct screen_info can be accessed directly, due to the fact that the EFI stub and the core kernel are part of the same image. This will change after a future patch, so let's ensure that the screen_info handling is able to deal with this, by adopting the arm32 approach of passing it as a configuration table. While at it, switch to ACPI reclaim memory to hold the screen_info data, which is more appropriate for this kind of allocation. Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
- Loading branch information
Ard Biesheuvel
committed
Nov 9, 2022
1 parent
0606480
commit 732ea9d
Showing
14 changed files
with
121 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// SPDX-License-Identifier: GPL-2.0 | ||
|
||
#include <linux/efi.h> | ||
#include <asm/efi.h> | ||
|
||
#include "efistub.h" | ||
|
||
/* | ||
* There are two ways of populating the core kernel's struct screen_info via the stub: | ||
* - using a configuration table, like below, which relies on the EFI init code | ||
* to locate the table and copy the contents; | ||
* - by linking directly to the core kernel's copy of the global symbol. | ||
* | ||
* The latter is preferred because it makes the EFIFB earlycon available very | ||
* early, but it only works if the EFI stub is part of the core kernel image | ||
* itself. The zboot decompressor can only use the configuration table | ||
* approach. | ||
* | ||
* In order to support both methods from the same build of the EFI stub | ||
* library, provide this dummy global definition of struct screen_info. If it | ||
* is required to satisfy a link dependency, it means we need to override the | ||
* __weak alloc and free methods with the ones below, and those will be pulled | ||
* in as well. | ||
*/ | ||
struct screen_info screen_info; | ||
|
||
static efi_guid_t screen_info_guid = LINUX_EFI_SCREEN_INFO_TABLE_GUID; | ||
|
||
struct screen_info *alloc_screen_info(void) | ||
{ | ||
struct screen_info *si; | ||
efi_status_t status; | ||
|
||
status = efi_bs_call(allocate_pool, EFI_ACPI_RECLAIM_MEMORY, | ||
sizeof(*si), (void **)&si); | ||
|
||
if (status != EFI_SUCCESS) | ||
return NULL; | ||
|
||
status = efi_bs_call(install_configuration_table, | ||
&screen_info_guid, si); | ||
if (status == EFI_SUCCESS) | ||
return si; | ||
|
||
efi_bs_call(free_pool, si); | ||
return NULL; | ||
} | ||
|
||
void free_screen_info(struct screen_info *si) | ||
{ | ||
if (!si) | ||
return; | ||
|
||
efi_bs_call(install_configuration_table, &screen_info_guid, NULL); | ||
efi_bs_call(free_pool, si); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters