A number of fixes and feature completeness work this time around: - Fix sunxi GOP reservation - Fix cursor position - Fix efi_get_variable - Allow more selftest parts to build on x86_64 - Allow unaligned memory access on armv7 - Implement ReinstallProtocolInterface - More sandbox preparation -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAABAgAGBQJbE/PWAAoJECszeR4D/txgp3wQAJyk8Y0N4ZpA9O3R/D8jvXvE nnk7UfRzIYx5qKFJ6yBRvPh//hjswD9ihNQ5/oVw62pqA1J28jCFDfGmIdDYVSk6 Itxvyx9O7DQBC4b1sHi5P5euZU/IuxQkUDszI1vOGhgt3al335EEliB4CWuRms2d mpOEm39o7eAcBtNTvbER9S+baDmFIcCMrCol/ayVLWwkd6B7X30GtzXCu9mHjoov M6KObSLh7lT0gqvYpHoCKIJR9q8b93tIqYyGuk+bBsZmo5IuuuQXqmhoB9LQ/M+p mQklJdXorJfk7/kks++I99WaPejcS5U679+A7RCPNiQM1ItavirpbosjdL1F8S5j EBsIxTBMnJhR/oQ1KEqRSiIIMzch/M1a6ikJr08Poy5wKVGJfSfJ69DDKCtmeEf+ 5aKNco0q23XcJa/Thc5BNr1wVM7QvhC0NszrvS6aG2IkkvGsKrD3xtB6J2aQeZlc JflYPtIELIT8RMn0zeFhNtA9KYCZINCq5Kn4jXz9zAD6vKHfQX1/sdAtojEjNblq e7A6aky8e2vHeiYPcz8HbFXwA6wL4qB70BIAYdqZQ73QZGz4bVTtk5YM5pjpHZYk uRjQWie+dwtB5EzuWAa1v63EcpM10kL0r3Dfv2bJt70iWzST7xtg4sH4xW1ekL8p q/mGsroVPJdI2byEbeol =gcE4 -----END PGP SIGNATURE----- Merge tag 'signed-efi-next' of git://github.com/agraf/u-boot Patch queue for efi - 2018-06-03 A number of fixes and feature completeness work this time around: - Fix sunxi GOP reservation - Fix cursor position - Fix efi_get_variable - Allow more selftest parts to build on x86_64 - Allow unaligned memory access on armv7 - Implement ReinstallProtocolInterface - More sandbox preparationlime2-spi
commit
a0115ceb56
@ -0,0 +1,22 @@ |
||||
/* SPDX-License-Identifier: GPL-2.0+ */ |
||||
/* |
||||
* Routines to access the system control register |
||||
* |
||||
* Copyright (c) 2018 Heinrich Schuchardt |
||||
*/ |
||||
|
||||
#include <linux/linkage.h> |
||||
|
||||
/* |
||||
* void allow_unaligned(void) - allow unaligned access |
||||
* |
||||
* This routine clears the aligned flag in the system control register. |
||||
* After calling this routine unaligned access does no longer lead to a |
||||
* data abort but is handled by the CPU. |
||||
*/ |
||||
ENTRY(allow_unaligned) |
||||
mrc p15, 0, r0, c1, c0, 0 @ load system control register
|
||||
bic r0, r0, #2 @ clear aligned flag
|
||||
mcr p15, 0, r0, c1, c0, 0 @ write system control register
|
||||
bx lr @ return
|
||||
ENDPROC(allow_unaligned) |
@ -0,0 +1,30 @@ |
||||
// SPDX-License-Identifier: GPL-2.0+
|
||||
/*
|
||||
* (C) 2018 Google, Inc |
||||
* Written by Simon Glass <sjg@chromium.org> |
||||
*/ |
||||
|
||||
#ifndef _SETJMP_H_ |
||||
#define _SETJMP_H_ |
||||
|
||||
struct jmp_buf_data { |
||||
/*
|
||||
* We're not sure how long this should be: |
||||
* |
||||
* amd64: 200 bytes |
||||
* arm64: 392 bytes |
||||
* armhf: 392 bytes |
||||
* |
||||
* So allow space for all of those, plus some extra. |
||||
* We don't need to worry about 16-byte alignment, since this does not |
||||
* run on Windows. |
||||
*/ |
||||
ulong data[128]; |
||||
}; |
||||
|
||||
typedef struct jmp_buf_data jmp_buf[1]; |
||||
|
||||
int setjmp(jmp_buf jmp); |
||||
__noreturn void longjmp(jmp_buf jmp, int ret); |
||||
|
||||
#endif /* _SETJMP_H_ */ |
@ -0,0 +1,12 @@ |
||||
// SPDX-License-Identifier: GPL-2.0+
|
||||
/*
|
||||
* Copyright 2013 Albert ARIBAUD <albert.u.boot@aribaud.net> |
||||
* |
||||
*/ |
||||
|
||||
char __efi_runtime_start[0] __attribute__((section(".__efi_runtime_start"))); |
||||
char __efi_runtime_stop[0] __attribute__((section(".__efi_runtime_stop"))); |
||||
char __efi_runtime_rel_start[0] |
||||
__attribute__((section(".__efi_runtime_rel_start"))); |
||||
char __efi_runtime_rel_stop[0] |
||||
__attribute__((section(".__efi_runtime_rel_stop"))); |
@ -0,0 +1,17 @@ |
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN" |
||||
"http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd" []> |
||||
|
||||
<book id="UBootEFI"> |
||||
<bookinfo> |
||||
<title>The U-Boot EFI subsystem</title> |
||||
</bookinfo> |
||||
|
||||
<toc></toc> |
||||
|
||||
<chapter id="BootServices"> |
||||
<title>Boot services</title> |
||||
!Ilib/efi_loader/efi_boottime.c |
||||
</chapter> |
||||
|
||||
</book> |
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,67 @@ |
||||
/*
|
||||
* efi_selftest_unaligned |
||||
* |
||||
* Copyright (c) 2018 Heinrich Schuchardt <xypron.glpk@gmx.de> |
||||
* |
||||
* SPDX-License-Identifier: GPL-2.0+ |
||||
* |
||||
* Test unaligned memory access on ARMv7. |
||||
*/ |
||||
|
||||
#include <efi_selftest.h> |
||||
|
||||
struct aligned_buffer { |
||||
char a[8] __aligned(8); |
||||
}; |
||||
|
||||
/*
|
||||
* Return an u32 at a give address. |
||||
* If the address is not four byte aligned, an unaligned memory access |
||||
* occurs. |
||||
* |
||||
* @addr: address to read |
||||
* @return: value at the address |
||||
*/ |
||||
static inline u32 deref(u32 *addr) |
||||
{ |
||||
int ret; |
||||
|
||||
asm( |
||||
"ldr %[out], [%[in]]\n\t" |
||||
: [out] "=r" (ret) |
||||
: [in] "r" (addr) |
||||
); |
||||
return ret; |
||||
} |
||||
|
||||
/*
|
||||
* Execute unit test. |
||||
* An unaligned memory access is executed. The result is checked. |
||||
* |
||||
* @return: EFI_ST_SUCCESS for success |
||||
*/ |
||||
static int execute(void) |
||||
{ |
||||
struct aligned_buffer buf = { |
||||
{0, 1, 2, 3, 4, 5, 6, 7}, |
||||
}; |
||||
void *v = &buf; |
||||
u32 r = 0; |
||||
|
||||
/* Read an unaligned address */ |
||||
r = deref(v + 1); |
||||
|
||||
/* UEFI only supports low endian systems */ |
||||
if (r != 0x04030201) { |
||||
efi_st_error("Unaligned access failed"); |
||||
return EFI_ST_FAILURE; |
||||
} |
||||
|
||||
return EFI_ST_SUCCESS; |
||||
} |
||||
|
||||
EFI_UNIT_TEST(unaligned) = { |
||||
.name = "unaligned memory access", |
||||
.phase = EFI_EXECUTE_BEFORE_BOOTTIME_EXIT, |
||||
.execute = execute, |
||||
}; |
@ -0,0 +1,196 @@ |
||||
// SPDX-License-Identifier: GPL-2.0+
|
||||
/*
|
||||
* efi_selftest_variables |
||||
* |
||||
* Copyright (c) 2018 Heinrich Schuchardt <xypron.glpk@gmx.de> |
||||
* |
||||
* This unit test checks the following protocol services: |
||||
* ConnectController, DisconnectController, |
||||
* InstallProtocol, ReinstallProtocol, UninstallProtocol, |
||||
* OpenProtocol, CloseProtcol, OpenProtocolInformation |
||||
*/ |
||||
|
||||
#include <efi_selftest.h> |
||||
|
||||
#define EFI_ST_MAX_DATA_SIZE 16 |
||||
#define EFI_ST_MAX_VARNAME_SIZE 40 |
||||
|
||||
static struct efi_boot_services *boottime; |
||||
static struct efi_runtime_services *runtime; |
||||
static efi_guid_t guid_vendor0 = |
||||
EFI_GUID(0x67029eb5, 0x0af2, 0xf6b1, |
||||
0xda, 0x53, 0xfc, 0xb5, 0x66, 0xdd, 0x1c, 0xe6); |
||||
static efi_guid_t guid_vendor1 = |
||||
EFI_GUID(0xff629290, 0x1fc1, 0xd73f, |
||||
0x8f, 0xb1, 0x32, 0xf9, 0x0c, 0xa0, 0x42, 0xea); |
||||
|
||||
/*
|
||||
* Setup unit test. |
||||
* |
||||
* @handle handle of the loaded image |
||||
* @systable system table |
||||
*/ |
||||
static int setup(const efi_handle_t img_handle, |
||||
const struct efi_system_table *systable) |
||||
{ |
||||
boottime = systable->boottime; |
||||
runtime = systable->runtime; |
||||
|
||||
return EFI_ST_SUCCESS; |
||||
} |
||||
|
||||
/*
|
||||
* Execute unit test. |
||||
*/ |
||||
static int execute(void) |
||||
{ |
||||
efi_status_t ret; |
||||
efi_uintn_t len; |
||||
u32 attr; |
||||
u8 v[16] = {0x5d, 0xd1, 0x5e, 0x51, 0x5a, 0x05, 0xc7, 0x0c, |
||||
0x35, 0x4a, 0xae, 0x87, 0xa5, 0xdf, 0x0f, 0x65,}; |
||||
u8 data[EFI_ST_MAX_DATA_SIZE]; |
||||
u16 varname[EFI_ST_MAX_VARNAME_SIZE]; |
||||
int flag; |
||||
efi_guid_t guid; |
||||
u64 max_storage, rem_storage, max_size; |
||||
|
||||
ret = runtime->query_variable_info(EFI_VARIABLE_BOOTSERVICE_ACCESS, |
||||
&max_storage, &rem_storage, |
||||
&max_size); |
||||
if (ret != EFI_SUCCESS) { |
||||
efi_st_todo("QueryVariableInfo failed\n"); |
||||
} else if (!max_storage || !rem_storage || !max_size) { |
||||
efi_st_error("QueryVariableInfo: wrong info\n"); |
||||
return EFI_ST_FAILURE; |
||||
} |
||||
/* Set variable 0 */ |
||||
ret = runtime->set_variable(L"efi_st_var0", &guid_vendor0, |
||||
EFI_VARIABLE_BOOTSERVICE_ACCESS, |
||||
3, v + 4); |
||||
if (ret != EFI_SUCCESS) { |
||||
efi_st_error("SetVariable failed\n"); |
||||
return EFI_ST_FAILURE; |
||||
} |
||||
data[3] = 0xff; |
||||
len = 3; |
||||
ret = runtime->get_variable(L"efi_st_var0", &guid_vendor0, |
||||
&attr, &len, data); |
||||
if (ret != EFI_SUCCESS) { |
||||
efi_st_error("GetVariable failed\n"); |
||||
return EFI_ST_FAILURE; |
||||
} |
||||
if (efi_st_memcmp(data, v + 4, 3)) { |
||||
efi_st_error("GetVariable returned wrong value\n"); |
||||
return EFI_ST_FAILURE; |
||||
} |
||||
if (data[3] != 0xff) { |
||||
efi_st_error("GetVariable wrote past the end of the buffer\n"); |
||||
return EFI_ST_FAILURE; |
||||
} |
||||
/* Set variable 1 */ |
||||
ret = runtime->set_variable(L"efi_st_var1", &guid_vendor1, |
||||
EFI_VARIABLE_BOOTSERVICE_ACCESS, |
||||
8, v); |
||||
if (ret != EFI_SUCCESS) { |
||||
efi_st_error("SetVariable failed\n"); |
||||
return EFI_ST_FAILURE; |
||||
} |
||||
len = EFI_ST_MAX_DATA_SIZE; |
||||
ret = runtime->get_variable(L"efi_st_var1", &guid_vendor1, |
||||
&attr, &len, data); |
||||
if (ret != EFI_SUCCESS) { |
||||
efi_st_error("GetVariable failed\n"); |
||||
return EFI_ST_FAILURE; |
||||
} |
||||
if (len != 8) { |
||||
efi_st_error("GetVariable returned wrong length %u\n", |
||||
(unsigned int)len); |
||||
return EFI_ST_FAILURE; |
||||
} |
||||
if (efi_st_memcmp(data, v, 8)) { |
||||
efi_st_error("GetVariable returned wrong value\n"); |
||||
return EFI_ST_FAILURE; |
||||
} |
||||
/* Append variable 1 */ |
||||
ret = runtime->set_variable(L"efi_st_var1", &guid_vendor1, |
||||
EFI_VARIABLE_BOOTSERVICE_ACCESS | |
||||
EFI_VARIABLE_APPEND_WRITE, |
||||
7, v + 8); |
||||
if (ret != EFI_SUCCESS) { |
||||
efi_st_error("SetVariable failed\n"); |
||||
return EFI_ST_FAILURE; |
||||
} |
||||
len = EFI_ST_MAX_DATA_SIZE; |
||||
ret = runtime->get_variable(L"efi_st_var1", &guid_vendor1, |
||||
&attr, &len, data); |
||||
if (ret != EFI_SUCCESS) { |
||||
efi_st_error("GetVariable failed\n"); |
||||
return EFI_ST_FAILURE; |
||||
} |
||||
if (len != 15) |
||||
efi_st_todo("GetVariable returned wrong length %u\n", |
||||
(unsigned int)len); |
||||
if (efi_st_memcmp(data, v, len)) |
||||
efi_st_todo("GetVariable returned wrong value\n"); |
||||
/* Enumerate variables */ |
||||
boottime->set_mem(&guid, 16, 0); |
||||
*varname = 0; |
||||
flag = 0; |
||||
for (;;) { |
||||
len = EFI_ST_MAX_VARNAME_SIZE; |
||||
ret = runtime->get_next_variable_name(&len, varname, &guid); |
||||
if (ret == EFI_NOT_FOUND) |
||||
break; |
||||
if (ret != EFI_SUCCESS) { |
||||
efi_st_todo("GetNextVariableName failed\n"); |
||||
break; |
||||
} |
||||
if (!efi_st_memcmp(&guid, &guid_vendor0, sizeof(efi_guid_t)) && |
||||
!efi_st_strcmp_16_8(varname, "efi_st_var0")) |
||||
flag |= 2; |
||||
if (!efi_st_memcmp(&guid, &guid_vendor1, sizeof(efi_guid_t)) && |
||||
!efi_st_strcmp_16_8(varname, "efi_st_var1")) |
||||
flag |= 2; |
||||
} |
||||
if (flag != 3) |
||||
efi_st_todo( |
||||
"GetNextVariableName did not return all variables\n"); |
||||
/* Delete variable 1 */ |
||||
ret = runtime->set_variable(L"efi_st_var1", &guid_vendor1, |
||||
0, 0, NULL); |
||||
if (ret != EFI_SUCCESS) { |
||||
efi_st_error("SetVariable failed\n"); |
||||
return EFI_ST_FAILURE; |
||||
} |
||||
len = EFI_ST_MAX_DATA_SIZE; |
||||
ret = runtime->get_variable(L"efi_st_var1", &guid_vendor1, |
||||
&attr, &len, data); |
||||
if (ret != EFI_NOT_FOUND) { |
||||
efi_st_error("Variable was not deleted\n"); |
||||
return EFI_ST_FAILURE; |
||||
} |
||||
/* Delete variable 0 */ |
||||
ret = runtime->set_variable(L"efi_st_var0", &guid_vendor0, |
||||
0, 0, NULL); |
||||
if (ret != EFI_SUCCESS) { |
||||
efi_st_error("SetVariable failed\n"); |
||||
return EFI_ST_FAILURE; |
||||
} |
||||
len = EFI_ST_MAX_DATA_SIZE; |
||||
ret = runtime->get_variable(L"efi_st_var0", &guid_vendor0, |
||||
&attr, &len, data); |
||||
if (ret != EFI_NOT_FOUND) { |
||||
efi_st_error("Variable was not deleted\n"); |
||||
return EFI_ST_FAILURE; |
||||
} |
||||
|
||||
return EFI_ST_SUCCESS; |
||||
} |
||||
|
||||
EFI_UNIT_TEST(variables) = { |
||||
.name = "variables", |
||||
.phase = EFI_EXECUTE_BEFORE_BOOTTIME_EXIT, |
||||
.setup = setup, |
||||
.execute = execute, |
||||
}; |
Loading…
Reference in new issue