aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIlias Apalodimas <ilias.apalodimas@linaro.org>2021-05-22 23:59:46 +0300
committerIlias Apalodimas <ilias.apalodimas@linaro.org>2021-05-22 23:59:46 +0300
commit9378a4de56f20d9825e3df16ec15c5f1bd75cbc7 (patch)
tree2f98d03e810e855b9fad8dcdfda9cc47e0969226
parentfe10a5d9d7c263d0b08c69ce71d84d1691318de9 (diff)
efi_loader: support setvariable at runtime for RPMBsetvar_rt_optee_3
When the host OS owns the flash the EFI variables reside in, we can't support SetVariable at runtime, since we can't preserve the drivers on runtime. In order to solve this expose SetVariable as supported and install an empty config table. Upon the config table detection the OS can convert it's get/set variable and not call the EFI firmware Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
-rw-r--r--include/efi_api.h4
-rw-r--r--lib/efi_loader/efi_runtime.c1
-rw-r--r--lib/efi_loader/efi_variable_tee.c13
3 files changed, 17 insertions, 1 deletions
diff --git a/include/efi_api.h b/include/efi_api.h
index 18a1adf023..026dff38a5 100644
--- a/include/efi_api.h
+++ b/include/efi_api.h
@@ -421,6 +421,10 @@ struct efi_runtime_services {
EFI_GUID(0x1e2ed096, 0x30e2, 0x4254, 0xbd, \
0x89, 0x86, 0x3b, 0xbe, 0xf8, 0x23, 0x25)
+#define EFI_TEE_TABLE_GUID \
+ EFI_GUID(0x1e2ed096, 0x30e2, 0x4254, \
+ 0xbd, 0x89, 0x86, 0x3b, 0xbe, 0xf8, 0x23, 0x26)
+
struct efi_configuration_table {
efi_guid_t guid;
void *table;
diff --git a/lib/efi_loader/efi_runtime.c b/lib/efi_loader/efi_runtime.c
index 93a695fc27..d4bad06444 100644
--- a/lib/efi_loader/efi_runtime.c
+++ b/lib/efi_loader/efi_runtime.c
@@ -125,6 +125,7 @@ efi_status_t efi_init_runtime_supported(void)
EFI_RT_SUPPORTED_GET_VARIABLE |
EFI_RT_SUPPORTED_GET_NEXT_VARIABLE_NAME |
EFI_RT_SUPPORTED_SET_VIRTUAL_ADDRESS_MAP |
+ EFI_RT_SUPPORTED_SET_VARIABLE |
EFI_RT_SUPPORTED_CONVERT_POINTER;
/*
diff --git a/lib/efi_loader/efi_variable_tee.c b/lib/efi_loader/efi_variable_tee.c
index 51920bcb51..edbc3ef3a3 100644
--- a/lib/efi_loader/efi_variable_tee.c
+++ b/lib/efi_loader/efi_variable_tee.c
@@ -25,6 +25,7 @@ struct mm_connection {
u32 session;
};
+static const efi_guid_t tee_guid = EFI_TEE_TABLE_GUID;
/**
* get_connection() - Retrieve OP-TEE session for a specific UUID.
*
@@ -723,6 +724,13 @@ void efi_variables_boot_exit_notify(void)
efi_status_t efi_init_variables(void)
{
efi_status_t ret;
+ void *empty;
+ u64 addr = U32_MAX;
+
+ ret = efi_allocate_pages(EFI_ALLOCATE_ANY_PAGES,
+ EFI_RUNTIME_SERVICES_DATA, 1, &addr);
+ if (ret != EFI_SUCCESS)
+ return ret;
/* Create a cached copy of the variables that will be enabled on ExitBootServices() */
ret = efi_var_mem_init();
@@ -741,5 +749,8 @@ efi_status_t efi_init_variables(void)
if (ret != EFI_SUCCESS)
return ret;
- return EFI_SUCCESS;
+ empty = (void *)(uintptr_t)addr;
+ ret = efi_install_configuration_table(&tee_guid, empty);
+
+ return ret;
}