[Skiboot] [RFC PATCH v5 14/16] Add an ultravisor device tree in secure memory
Alexey Kardashevskiy
aik at ozlabs.ru
Thu Mar 12 12:43:16 AEDT 2020
On 28/02/2020 07:40, Ryan Grimm wrote:
> This patch adds a UV FDT created in secure memory. It is allocated
> directly after the ultravisor.
>
> The UV FDT will contain information like the wrapping key.
Who is the consumer of this FDT?
>
> The code uses libfdt directly to ensure only secure memory is used.
>
> Signed-off-by: Ryan Grimm <grimm at linux.ibm.com>
> Signed-off-by: Ram Pai <linuxram at us.ibm.com>
> ---
> hw/ultravisor.c | 26 +++++++++++++++++++++++++-
> include/ultravisor.h | 1 +
> 2 files changed, 26 insertions(+), 1 deletion(-)
>
> diff --git a/hw/ultravisor.c b/hw/ultravisor.c
> index 277faeeb..da5b8346 100644
> --- a/hw/ultravisor.c
> +++ b/hw/ultravisor.c
> @@ -12,6 +12,7 @@
> #include <console.h>
> #include <chip.h>
> #include <libstb/container.h>
> +#include <libfdt/libfdt.h>
>
> static struct dt_node *uv_fw_node;
> static uint64_t uv_base_addr;
> @@ -115,9 +116,27 @@ static int uv_decompress_image(void)
> return OPAL_SUCCESS;
> }
>
> +static int create_dtb_uv(void *uv_fdt)
> +{
> + if (fdt_create(uv_fdt, UV_FDT_MAX_SIZE)) {
> + prerror("UV: Failed to create uv_fdt\n");
> + return OPAL_NO_MEM;
> + }
> +
> + fdt_finish_reservemap(uv_fdt);
> + fdt_begin_node(uv_fdt, "");
> + fdt_property_string(uv_fdt, "description", "Ultravisor fdt");
> + fdt_begin_node(uv_fdt, "ibm,uv-fdt");
> + fdt_property_string(uv_fdt, "compatible", "ibm,uv-fdt");
> + fdt_end_node(uv_fdt);
> + fdt_finish(uv_fdt);
Every one of these fdt_xxxx() can fail.
> +
> + return OPAL_SUCCESS;
> +}
> +
> void init_uv()
> {
> - uint64_t uv_dt_src, uv_fw_sz;
> + uint64_t uv_dt_src, uv_fw_sz, uv_fdt_addr;
> struct dt_node *reserved_mem;
> int ret;
>
> @@ -151,6 +170,11 @@ void init_uv()
>
> dt_add_property_u64(uv_fw_node, "memcons", (u64)&uv_memcons);
> debug_descriptor.uv_memcons_phys = (u64)&uv_memcons;
> +
> + uv_base_addr = dt_get_address(uv_fw_node, 0, NULL);
> + uv_fdt_addr = uv_base_addr + UV_LOAD_MAX_SIZE;
> + create_dtb_uv((void *)uv_fdt_addr);
create_dtb_uv() can fail but we ignore it? Thanks,
> + dt_add_property_u64(uv_fw_node, "uv-fdt", uv_fdt_addr);
> err:
> local_free(uv_image);
> }
> diff --git a/include/ultravisor.h b/include/ultravisor.h
> index 26a986cd..347b085d 100644
> --- a/include/ultravisor.h
> +++ b/include/ultravisor.h
> @@ -14,6 +14,7 @@
> #define UCALL_BUFSIZE 4
> #define UV_READ_SCOM 0xF114
> #define UV_WRITE_SCOM 0xF118
> +#define UV_FDT_MAX_SIZE 0x100000
>
> extern long ucall(unsigned long opcode, unsigned long *retbuf, ...);
> extern int start_uv(uint64_t entry, void *fdt);
>
--
Alexey
More information about the Skiboot
mailing list