summaryrefslogtreecommitdiff
path: root/gnu-efi
diff options
context:
space:
mode:
authorSteve McIntyre <steve@einval.com>2022-06-23 00:16:56 +0100
committerSteve McIntyre <steve@einval.com>2022-06-23 00:16:56 +0100
commite6ace38abd705fbe24349152b7c90d473404e86e (patch)
tree50e7a2d6b00d650fcbee8b0c54f0a0eacefc6929 /gnu-efi
parent8529e0f7f70f427a7202815061362eceba6bfc50 (diff)
downloadefi-boot-shim-upstream/15.6.tar.gz
efi-boot-shim-upstream/15.6.zip
New upstream version 15.6upstream/15.6
Diffstat (limited to 'gnu-efi')
-rwxr-xr-xgnu-efi/Make.defaults2
-rw-r--r--gnu-efi/gnuefi/crt0-efi-aarch64.S143
-rw-r--r--gnu-efi/gnuefi/crt0-efi-ia32.S8
-rw-r--r--gnu-efi/gnuefi/crt0-efi-x86_64.S10
-rw-r--r--gnu-efi/inc/efidef.h7
-rw-r--r--gnu-efi/inc/efiprot.h35
6 files changed, 62 insertions, 143 deletions
diff --git a/gnu-efi/Make.defaults b/gnu-efi/Make.defaults
index 5ce8f7cb..3b56150d 100755
--- a/gnu-efi/Make.defaults
+++ b/gnu-efi/Make.defaults
@@ -153,13 +153,11 @@ endif
# Set HAVE_EFI_OBJCOPY if objcopy understands --target efi-[app|bsdrv|rtdrv],
# otherwise we need to compose the PE/COFF header using the assembler
#
-ifneq ($(ARCH),aarch64)
ifneq ($(ARCH),arm)
ifneq ($(ARCH),mips64el)
export HAVE_EFI_OBJCOPY=y
endif
endif
-endif
ifeq ($(ARCH),arm)
CFLAGS += -marm
diff --git a/gnu-efi/gnuefi/crt0-efi-aarch64.S b/gnu-efi/gnuefi/crt0-efi-aarch64.S
index a96b5eb8..0fefec0c 100644
--- a/gnu-efi/gnuefi/crt0-efi-aarch64.S
+++ b/gnu-efi/gnuefi/crt0-efi-aarch64.S
@@ -16,136 +16,11 @@
* either version 2 of the License, or (at your option) any later version.
*/
- .section .text.head
-
- /*
- * Magic "MZ" signature for PE/COFF
- */
- .globl ImageBase
-ImageBase:
- .ascii "MZ"
- .skip 58 // 'MZ' + pad + offset == 64
- .long pe_header - ImageBase // Offset to the PE header.
-pe_header:
- .ascii "PE"
- .short 0
-coff_header:
- .short 0xaa64 // AArch64
- .short 4 // nr_sections
- .long 0 // TimeDateStamp
- .long 0 // PointerToSymbolTable
- .long 1 // NumberOfSymbols
- .short section_table - optional_header // SizeOfOptionalHeader
- .short 0x206 // Characteristics.
- // IMAGE_FILE_DEBUG_STRIPPED |
- // IMAGE_FILE_EXECUTABLE_IMAGE |
- // IMAGE_FILE_LINE_NUMS_STRIPPED
-optional_header:
- .short 0x20b // PE32+ format
- .byte 0x02 // MajorLinkerVersion
- .byte 0x14 // MinorLinkerVersion
- .long _text_size // SizeOfCode
- .long _alldata_size // SizeOfInitializedData
- .long 0 // SizeOfUninitializedData
- .long _start - ImageBase // AddressOfEntryPoint
- .long _start - ImageBase // BaseOfCode
-
-extra_header_fields:
- .quad 0 // ImageBase
- .long 0x1000 // SectionAlignment
- .long 0x200 // FileAlignment
- .short 0 // MajorOperatingSystemVersion
- .short 0 // MinorOperatingSystemVersion
- .short 0 // MajorImageVersion
- .short 0 // MinorImageVersion
- .short 0 // MajorSubsystemVersion
- .short 0 // MinorSubsystemVersion
- .long 0 // Win32VersionValue
-
- .long _erodata - ImageBase // SizeOfImage
-
- // Everything before the kernel image is considered part of the header
- .long _start - ImageBase // SizeOfHeaders
- .long 0 // CheckSum
- .short EFI_SUBSYSTEM // Subsystem
- .short 0 // DllCharacteristics
- .quad 0 // SizeOfStackReserve
- .quad 0 // SizeOfStackCommit
- .quad 0 // SizeOfHeapReserve
- .quad 0 // SizeOfHeapCommit
- .long 0 // LoaderFlags
- .long 0x6 // NumberOfRvaAndSizes
-
- .quad 0 // ExportTable
- .quad 0 // ImportTable
- .quad 0 // ResourceTable
- .quad 0 // ExceptionTable
- .quad 0 // CertificationTable
- .quad 0 // BaseRelocationTable
-
- // Section table
-section_table:
- .ascii ".text\0\0\0"
- .long _evtext - _start // VirtualSize
- .long _start - ImageBase // VirtualAddress
- .long _etext - _start // SizeOfRawData
- .long _start - ImageBase // PointerToRawData
-
- .long 0 // PointerToRelocations (0 for executables)
- .long 0 // PointerToLineNumbers (0 for executables)
- .short 0 // NumberOfRelocations (0 for executables)
- .short 0 // NumberOfLineNumbers (0 for executables)
- /*
- * EFI_IMAGE_SCN_MEM_READ | EFI_IMAGE_SCN_MEM_EXECUTE | EFI_IMAGE_SCN_CNT_CODE
- */
- .long 0x60000020 // Characteristics (section flags)
-
- .ascii ".data\0\0\0"
- .long _data_vsize // VirtualSize
- .long _data - ImageBase // VirtualAddress
- .long _data_size // SizeOfRawData
- .long _data - ImageBase // PointerToRawData
-
- .long 0 // PointerToRelocations (0 for executables)
- .long 0 // PointerToLineNumbers (0 for executables)
- .short 0 // NumberOfRelocations (0 for executables)
- .short 0 // NumberOfLineNumbers (0 for executables)
- /*
- * EFI_IMAGE_SCN_MEM_WRITE | EFI_IMAGE_SCN_MEM_READ | EFI_IMAGE_SCN_CNT_INITIALIZED_DATA
- */
- .long 0xc0000040 // Characteristics (section flags)
-
- .ascii ".sbat\0\0\0"
- .long _sbat_vsize // VirtualSize
- .long _sbat - ImageBase // VirtualAddress
- .long _sbat_size // SizeOfRawData
- .long _sbat - ImageBase // PointerToRawData
-
- .long 0 // PointerToRelocations (0 for executables)
- .long 0 // PointerToLineNumbers (0 for executables)
- .short 0 // NumberOfRelocations (0 for executables)
- .short 0 // NumberOfLineNumbers (0 for executables)
- /*
- * EFI_IMAGE_SCN_MEM_READ | EFI_IMAGE_SCN_ALIGN_8BYTES | EFI_IMAGE_SCN_CNT_INITIALIZED_DATA
- */
- .long 0x40400040 // Characteristics (section flags)
-
- .ascii ".rodata\0"
- .long _rodata_vsize // VirtualSize
- .long _rodata - ImageBase // VirtualAddress
- .long _rodata_size // SizeOfRawData
- .long _rodata - ImageBase // PointerToRawData
-
- .long 0 // PointerToRelocations (0 for executables)
- .long 0 // PointerToLineNumbers (0 for executables)
- .short 0 // NumberOfRelocations (0 for executables)
- .short 0 // NumberOfLineNumbers (0 for executables)
- /*
- * EFI_IMAGE_SCN_MEM_READ | EFI_IMAGE_SCN_ALIGN_8BYTES | EFI_IMAGE_SCN_CNT_INITIALIZED_DATA
- */
- .long 0x40400040 // Characteristics (section flags)
+ .text
.align 12
+
+ .globl _start
_start:
stp x29, x30, [sp, #-32]!
mov x29, sp
@@ -164,3 +39,15 @@ _start:
0: ldp x29, x30, [sp], #32
ret
+
+ // hand-craft a dummy .reloc section so EFI knows it's a relocatable executable:
+ .data
+.dummy0:
+.dummy1:
+ .4byte 0
+
+#define IMAGE_REL_ABSOLUTE 0
+ .section .reloc, "a"
+ .4byte .dummy1-.dummy0 // Page RVA
+ .4byte 10 // Block Size (2*4+2)
+ .2byte (IMAGE_REL_ABSOLUTE<<12) + 0 // reloc for dummy
diff --git a/gnu-efi/gnuefi/crt0-efi-ia32.S b/gnu-efi/gnuefi/crt0-efi-ia32.S
index 2c567461..c9b3ea67 100644
--- a/gnu-efi/gnuefi/crt0-efi-ia32.S
+++ b/gnu-efi/gnuefi/crt0-efi-ia32.S
@@ -68,10 +68,10 @@ _start:
.data
.dummy0:
.dummy1:
- .long 0
+ .4byte 0
#define IMAGE_REL_ABSOLUTE 0
.section .reloc, "a"
- .long .dummy1-.dummy0 // Page RVA
- .long 10 // Block Size (2*4+2)
- .word (IMAGE_REL_ABSOLUTE<<12) + 0 // reloc for dummy
+ .4byte .dummy1-.dummy0 // Page RVA
+ .4byte 10 // Block Size (2*4+2)
+ .2byte (IMAGE_REL_ABSOLUTE<<12) + 0 // reloc for dummy
diff --git a/gnu-efi/gnuefi/crt0-efi-x86_64.S b/gnu-efi/gnuefi/crt0-efi-x86_64.S
index 1a87dbd3..0d99c151 100644
--- a/gnu-efi/gnuefi/crt0-efi-x86_64.S
+++ b/gnu-efi/gnuefi/crt0-efi-x86_64.S
@@ -59,18 +59,16 @@ _start:
call efi_main
addq $8, %rsp
-.exit:
ret
// hand-craft a dummy .reloc section so EFI knows it's a relocatable executable:
.data
.dummy0:
.dummy1:
- .long 0
+ .4byte 0
#define IMAGE_REL_ABSOLUTE 0
.section .reloc, "a"
- .long .dummy1-.dummy0 // Page RVA
- .long 10 // Block Size (2*4+2)
- .word (IMAGE_REL_ABSOLUTE<<12) + 0 // reloc for dummy
-
+ .4byte .dummy1-.dummy0 // Page RVA
+ .4byte 10 // Block Size (2*4+2)
+ .2byte (IMAGE_REL_ABSOLUTE<<12) + 0 // reloc for dummy
diff --git a/gnu-efi/inc/efidef.h b/gnu-efi/inc/efidef.h
index a552c7d9..841cc9ac 100644
--- a/gnu-efi/inc/efidef.h
+++ b/gnu-efi/inc/efidef.h
@@ -169,12 +169,13 @@ typedef enum {
#define EFI_MEMORY_WC 0x0000000000000002
#define EFI_MEMORY_WT 0x0000000000000004
#define EFI_MEMORY_WB 0x0000000000000008
-#define EFI_MEMORY_UCE 0x0000000000000010
-
-// physical memory protection on range
+#define EFI_MEMORY_UCE 0x0000000000000010
#define EFI_MEMORY_WP 0x0000000000001000
+
+// physical memory protection on range
#define EFI_MEMORY_RP 0x0000000000002000
#define EFI_MEMORY_XP 0x0000000000004000
+#define EFI_MEMORY_RO 0x0000000000020000
// range requires a runtime mapping
#define EFI_MEMORY_RUNTIME 0x8000000000000000
diff --git a/gnu-efi/inc/efiprot.h b/gnu-efi/inc/efiprot.h
index c83a574f..4013ab25 100644
--- a/gnu-efi/inc/efiprot.h
+++ b/gnu-efi/inc/efiprot.h
@@ -1422,4 +1422,39 @@ typedef struct _EFI_EBC_PROTOCOL {
EFI_EBC_GET_VERSION GetVersion;
} EFI_EBC_PROTOCOL;
+INTERFACE_DECL(_EFI_MEMORY_ATTRIBUTE_PROTOCOL);
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_GET_MEMORY_ATTRIBUTES)(
+ IN struct _EFI_MEMORY_ATTRIBUTE_PROTOCOL *This,
+ IN EFI_PHYSICAL_ADDRESS BaseAddress,
+ IN UINT64 Length,
+ OUT UINT64 *Attributes
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_SET_MEMORY_ATTRIBUTES)(
+ IN struct _EFI_MEMORY_ATTRIBUTE_PROTOCOL *This,
+ IN EFI_PHYSICAL_ADDRESS BaseAddress,
+ IN UINT64 Length,
+ IN UINT64 Attributes
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_CLEAR_MEMORY_ATTRIBUTES)(
+ IN struct _EFI_MEMORY_ATTRIBUTE_PROTOCOL *This,
+ IN EFI_PHYSICAL_ADDRESS BaseAddress,
+ IN UINT64 Length,
+ IN UINT64 Attributes
+ );
+
+typedef struct _EFI_MEMORY_ATTRIBUTE_PROTOCOL {
+ EFI_GET_MEMORY_ATTRIBUTES GetMemoryAttributes;
+ EFI_SET_MEMORY_ATTRIBUTES SetMemoryAttributes;
+ EFI_CLEAR_MEMORY_ATTRIBUTES ClearMemoryAttributes;
+} EFI_MEMORY_ATTRIBUTE_PROTOCOL;
+
#endif