Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit bcede2f6 authored by Linus Torvalds's avatar Linus Torvalds
Browse files

Merge branch 'x86-efi-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip

* 'x86-efi-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  x86, efi: Break up large initrd reads
  x86, efi: EFI boot stub support
  efi: Add EFI file I/O data types
  efi.h: Add boottime->locate_handle search types
  efi.h: Add graphics protocol guids
  efi.h: Add allocation types for boottime->allocate_pages()
  efi.h: Add efi_image_loaded_t
  efi.h: Add struct definition for boot time services
  x86: Don't use magic strings for EFI loader signature
  x86: Add missing bzImage fields to struct setup_header
parents d0b9706c 2d2da60f
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -1489,6 +1489,13 @@ config EFI
	  resultant kernel should continue to boot on existing non-EFI
	  platforms.

config EFI_STUB
       bool "EFI stub support"
       depends on EFI
       ---help---
          This kernel feature allows a bzImage to be loaded directly
	  by EFI firmware without the use of a bootloader.

config SECCOMP
	def_bool y
	prompt "Enable seccomp to safely compute untrusted bytecode"
+9 −1
Original line number Diff line number Diff line
@@ -23,7 +23,15 @@ LDFLAGS_vmlinux := -T

hostprogs-y	:= mkpiggy

$(obj)/vmlinux: $(obj)/vmlinux.lds $(obj)/head_$(BITS).o $(obj)/misc.o $(obj)/string.o $(obj)/cmdline.o $(obj)/early_serial_console.o $(obj)/piggy.o FORCE
VMLINUX_OBJS = $(obj)/vmlinux.lds $(obj)/head_$(BITS).o $(obj)/misc.o \
	$(obj)/string.o $(obj)/cmdline.o $(obj)/early_serial_console.o \
	$(obj)/piggy.o

ifeq ($(CONFIG_EFI_STUB), y)
	VMLINUX_OBJS += $(obj)/eboot.o $(obj)/efi_stub_$(BITS).o
endif

$(obj)/vmlinux: $(VMLINUX_OBJS) FORCE
	$(call if_changed,ld)
	@:

+1022 −0

File added.

Preview size limit exceeded, changes collapsed.

+61 −0
Original line number Diff line number Diff line
#ifndef BOOT_COMPRESSED_EBOOT_H
#define BOOT_COMPRESSED_EBOOT_H

#define SEG_TYPE_DATA		(0 << 3)
#define SEG_TYPE_READ_WRITE	(1 << 1)
#define SEG_TYPE_CODE		(1 << 3)
#define SEG_TYPE_EXEC_READ	(1 << 1)
#define SEG_TYPE_TSS		((1 << 3) | (1 << 0))
#define SEG_OP_SIZE_32BIT	(1 << 0)
#define SEG_GRANULARITY_4KB	(1 << 0)

#define DESC_TYPE_CODE_DATA	(1 << 0)

#define EFI_PAGE_SIZE		(1UL << EFI_PAGE_SHIFT)
#define EFI_READ_CHUNK_SIZE	(1024 * 1024)

#define PIXEL_RGB_RESERVED_8BIT_PER_COLOR		0
#define PIXEL_BGR_RESERVED_8BIT_PER_COLOR		1
#define PIXEL_BIT_MASK					2
#define PIXEL_BLT_ONLY					3
#define PIXEL_FORMAT_MAX				4

struct efi_pixel_bitmask {
	u32 red_mask;
	u32 green_mask;
	u32 blue_mask;
	u32 reserved_mask;
};

struct efi_graphics_output_mode_info {
	u32 version;
	u32 horizontal_resolution;
	u32 vertical_resolution;
	int pixel_format;
	struct efi_pixel_bitmask pixel_information;
	u32 pixels_per_scan_line;
} __packed;

struct efi_graphics_output_protocol_mode {
	u32 max_mode;
	u32 mode;
	unsigned long info;
	unsigned long size_of_info;
	u64 frame_buffer_base;
	unsigned long frame_buffer_size;
} __packed;

struct efi_graphics_output_protocol {
	void *query_mode;
	unsigned long set_mode;
	unsigned long blt;
	struct efi_graphics_output_protocol_mode *mode;
};

struct efi_uga_draw_protocol {
	void *get_mode;
	void *set_mode;
	void *blt;
};

#endif /* BOOT_COMPRESSED_EBOOT_H */
+86 −0
Original line number Diff line number Diff line
/*
 * EFI call stub for IA32.
 *
 * This stub allows us to make EFI calls in physical mode with interrupts
 * turned off. Note that this implementation is different from the one in
 * arch/x86/platform/efi/efi_stub_32.S because we're _already_ in physical
 * mode at this point.
 */

#include <linux/linkage.h>
#include <asm/page_types.h>

/*
 * efi_call_phys(void *, ...) is a function with variable parameters.
 * All the callers of this function assure that all the parameters are 4-bytes.
 */

/*
 * In gcc calling convention, EBX, ESP, EBP, ESI and EDI are all callee save.
 * So we'd better save all of them at the beginning of this function and restore
 * at the end no matter how many we use, because we can not assure EFI runtime
 * service functions will comply with gcc calling convention, too.
 */

.text
ENTRY(efi_call_phys)
	/*
	 * 0. The function can only be called in Linux kernel. So CS has been
	 * set to 0x0010, DS and SS have been set to 0x0018. In EFI, I found
	 * the values of these registers are the same. And, the corresponding
	 * GDT entries are identical. So I will do nothing about segment reg
	 * and GDT, but change GDT base register in prelog and epilog.
	 */

	/*
	 * 1. Because we haven't been relocated by this point we need to
	 * use relative addressing.
	 */
	call	1f
1:	popl	%edx
	subl	$1b, %edx

	/*
	 * 2. Now on the top of stack is the return
	 * address in the caller of efi_call_phys(), then parameter 1,
	 * parameter 2, ..., param n. To make things easy, we save the return
	 * address of efi_call_phys in a global variable.
	 */
	popl	%ecx
	movl	%ecx, saved_return_addr(%edx)
	/* get the function pointer into ECX*/
	popl	%ecx
	movl	%ecx, efi_rt_function_ptr(%edx)

	/*
	 * 3. Call the physical function.
	 */
	call	*%ecx

	/*
	 * 4. Balance the stack. And because EAX contain the return value,
	 * we'd better not clobber it. We need to calculate our address
	 * again because %ecx and %edx are not preserved across EFI function
	 * calls.
	 */
	call	1f
1:	popl	%edx
	subl	$1b, %edx

	movl	efi_rt_function_ptr(%edx), %ecx
	pushl	%ecx

	/*
	 * 10. Push the saved return address onto the stack and return.
	 */
	movl	saved_return_addr(%edx), %ecx
	pushl	%ecx
	ret
ENDPROC(efi_call_phys)
.previous

.data
saved_return_addr:
	.long 0
efi_rt_function_ptr:
	.long 0
Loading