Unverified Commit d7071743 authored by Atish Patra's avatar Atish Patra Committed by Palmer Dabbelt
Browse files

RISC-V: Add EFI stub support.



Add a RISC-V architecture specific stub code that actually copies the
actual kernel image to a valid address and jump to it after boot services
are terminated. Enable UEFI related kernel configs as well for RISC-V.

Signed-off-by: default avatarAtish Patra <atish.patra@wdc.com>
Link: https://lore.kernel.org/r/20200421033336.9663-4-atish.patra@wdc.com


[ardb: - move hartid fetch into check_platform_features()
       - use image_size not reserve_size
       - select ISA_C
       - do not use dram_base]
Signed-off-by: default avatarArd Biesheuvel <ardb@kernel.org>
Signed-off-by: default avatarPalmer Dabbelt <palmerdabbelt@google.com>
parent cb7d2dd5
Loading
Loading
Loading
Loading
+22 −0
Original line number Diff line number Diff line
@@ -401,6 +401,26 @@ config CMDLINE_FORCE

endchoice

config EFI_STUB
	bool

config EFI
	bool "UEFI runtime support"
	depends on OF
	select LIBFDT
	select UCS2_STRING
	select EFI_PARAMS_FROM_FDT
	select EFI_STUB
	select EFI_GENERIC_STUB
	select RISCV_ISA_C
	default y
	help
	  This option provides support for runtime services provided
	  by UEFI firmware (such as non-volatile variables, realtime
	  clock, and platform reset). A UEFI stub is also provided to
	  allow the kernel to be booted as an EFI application. This
	  is only useful on systems that have UEFI firmware.

endmenu

config BUILTIN_DTB
@@ -413,3 +433,5 @@ menu "Power management options"
source "kernel/power/Kconfig"

endmenu

source "drivers/firmware/Kconfig"
+1 −0
Original line number Diff line number Diff line
@@ -80,6 +80,7 @@ head-y := arch/riscv/kernel/head.o
core-y += arch/riscv/

libs-y += arch/riscv/lib/
libs-$(CONFIG_EFI_STUB) += $(objtree)/drivers/firmware/efi/libstub/lib.a

PHONY += vdso_install
vdso_install:
+1 −0
Original line number Diff line number Diff line
@@ -130,3 +130,4 @@ CONFIG_DEBUG_BLOCK_EXT_DEVT=y
# CONFIG_RUNTIME_TESTING_MENU is not set
CONFIG_MEMTEST=y
# CONFIG_SYSFS_SYSCALL is not set
CONFIG_EFI=y
+35 −0
Original line number Diff line number Diff line
/* SPDX-License-Identifier: GPL-2.0 */
/*
 * Copyright (C) 2020 Western Digital Corporation or its affiliates.
 */
#ifndef _ASM_EFI_H
#define _ASM_EFI_H

#include <asm/io.h>
#include <asm/mmu_context.h>
#include <asm/ptrace.h>
#include <asm/tlbflush.h>

/* on RISC-V, the FDT may be located anywhere in system RAM */
static inline unsigned long efi_get_max_fdt_addr(unsigned long image_addr)
{
	return ULONG_MAX;
}

/* Load initrd at enough distance from DRAM start */
static inline unsigned long efi_get_max_initrd_addr(unsigned long image_addr)
{
	return image_addr + SZ_256M;
}

#define alloc_screen_info(x...)		(&screen_info)

static inline void free_screen_info(struct screen_info *si)
{
}

static inline void efifb_setup_from_dmi(struct screen_info *si, const char *opt)
{
}

#endif /* _ASM_EFI_H */
+2 −1
Original line number Diff line number Diff line
@@ -111,7 +111,7 @@ config EFI_GENERIC_STUB

config EFI_ARMSTUB_DTB_LOADER
	bool "Enable the DTB loader"
	depends on EFI_GENERIC_STUB
	depends on EFI_GENERIC_STUB && !RISCV
	default y
	help
	  Select this config option to add support for the dtb= command
@@ -128,6 +128,7 @@ config EFI_GENERIC_STUB_INITRD_CMDLINE_LOADER
	bool "Enable the command line initrd loader" if !X86
	depends on EFI_STUB && (EFI_GENERIC_STUB || X86)
	default y
	depends on !RISCV
	help
	  Select this config option to add support for the initrd= command
	  line parameter, allowing an initrd that resides on the same volume
Loading