diff options
author | Tom Rini <trini@konsulko.com> | 2019-10-08 18:43:37 -0400 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2019-10-08 18:43:37 -0400 |
commit | 8679be295682878177097557867929caa8e26b98 (patch) | |
tree | 3e4ac7c3ca2b9ddef6177a0bfdf4f81de7d194fd | |
parent | ca88313dcd02b686851d7bc76fe941935fa014bc (diff) | |
parent | 3b728f8728fa7c596d30ecd27ebb64d37a54a12e (diff) |
Merge tag 'efi-2020-01-rc1' of https://gitlab.denx.de/u-boot/custodians/u-boot-efi
Pull request for UEFI sub-system for efi-2020-01-rc1
The major corrections in this pull request are:
Fixes for the SetVariable() boot service.
Device path node for NVMe drives.
Disable CONFIG_CMD_NVEDIT by default.
-rw-r--r-- | arch/arm/mach-tegra/board2.c | 14 | ||||
-rw-r--r-- | cmd/Kconfig | 1 | ||||
-rw-r--r-- | cmd/nvedit_efi.c | 2 | ||||
-rw-r--r-- | drivers/nvme/nvme.c | 13 | ||||
-rw-r--r-- | drivers/nvme/nvme.h | 1 | ||||
-rw-r--r-- | include/efi_api.h | 7 | ||||
-rw-r--r-- | include/nvme.h | 12 | ||||
-rw-r--r-- | lib/efi_loader/efi_device_path.c | 20 | ||||
-rw-r--r-- | lib/efi_loader/efi_device_path_to_text.c | 15 | ||||
-rw-r--r-- | lib/efi_loader/efi_variable.c | 10 | ||||
-rw-r--r-- | lib/efi_selftest/efi_selftest_variables.c | 41 |
11 files changed, 91 insertions, 45 deletions
diff --git a/arch/arm/mach-tegra/board2.c b/arch/arm/mach-tegra/board2.c index f13bd256cc2..07f54f06848 100644 --- a/arch/arm/mach-tegra/board2.c +++ b/arch/arm/mach-tegra/board2.c @@ -6,7 +6,6 @@ #include <common.h> #include <dm.h> -#include <efi_loader.h> #include <env.h> #include <errno.h> #include <ns16550.h> @@ -224,19 +223,6 @@ int board_early_init_f(void) int board_late_init(void) { -#if CONFIG_IS_ENABLED(EFI_LOADER) - if (gd->bd->bi_dram[1].start) { - /* - * Only bank 0 is below board_get_usable_ram_top(), so all of - * bank 1 is not mapped by the U-Boot MMU configuration, and so - * we must prevent EFI from using it. - */ - efi_add_memory_map(gd->bd->bi_dram[1].start, - gd->bd->bi_dram[1].size >> EFI_PAGE_SHIFT, - EFI_BOOT_SERVICES_DATA, false); - } -#endif - #if defined(CONFIG_TEGRA_SUPPORT_NON_SECURE) if (tegra_cpu_is_non_secure()) { printf("CPU is in NS mode\n"); diff --git a/cmd/Kconfig b/cmd/Kconfig index 4e61565aab1..8e55b34c961 100644 --- a/cmd/Kconfig +++ b/cmd/Kconfig @@ -531,7 +531,6 @@ config CMD_ENV_FLAGS config CMD_NVEDIT_EFI bool "env [set|print] -e - set/print UEFI variables" depends on EFI_LOADER - default y imply HEXDUMP help UEFI variables are encoded as some form of U-Boot variables. diff --git a/cmd/nvedit_efi.c b/cmd/nvedit_efi.c index ed6d09a5304..ede4cd5235e 100644 --- a/cmd/nvedit_efi.c +++ b/cmd/nvedit_efi.c @@ -330,7 +330,7 @@ out: } /** - * do_env_print_efi() - set UEFI variable + * do_env_set_efi() - set UEFI variable * * @cmdtp: Command table * @flag: Command flag diff --git a/drivers/nvme/nvme.c b/drivers/nvme/nvme.c index 47f101e2808..ee6b581d9e1 100644 --- a/drivers/nvme/nvme.c +++ b/drivers/nvme/nvme.c @@ -621,6 +621,18 @@ static int nvme_get_info_from_identify(struct nvme_dev *dev) return 0; } +int nvme_get_namespace_id(struct udevice *udev, u32 *ns_id, u8 *eui64) +{ + struct nvme_ns *ns = dev_get_priv(udev); + + if (ns_id) + *ns_id = ns->ns_id; + if (eui64) + memcpy(eui64, ns->eui64, sizeof(ns->eui64)); + + return 0; +} + int nvme_scan_namespace(void) { struct uclass *uc; @@ -657,6 +669,7 @@ static int nvme_blk_probe(struct udevice *udev) if (nvme_identify(ndev, ns->ns_id, 0, (dma_addr_t)(long)id)) return -EIO; + memcpy(&ns->eui64, &id->eui64, sizeof(id->eui64)); flbas = id->flbas & NVME_NS_FLBAS_LBA_MASK; ns->flbas = flbas; ns->lba_shift = id->lbaf[flbas].ds; diff --git a/drivers/nvme/nvme.h b/drivers/nvme/nvme.h index 922f7abfe85..0e8cb221a7a 100644 --- a/drivers/nvme/nvme.h +++ b/drivers/nvme/nvme.h @@ -637,6 +637,7 @@ struct nvme_ns { struct list_head list; struct nvme_dev *dev; unsigned ns_id; + u8 eui64[8]; int devnum; int lba_shift; u8 flbas; diff --git a/include/efi_api.h b/include/efi_api.h index 37e56da4603..22396172e15 100644 --- a/include/efi_api.h +++ b/include/efi_api.h @@ -422,6 +422,7 @@ struct efi_device_path_acpi_path { # define DEVICE_PATH_SUB_TYPE_MSG_USB 0x05 # define DEVICE_PATH_SUB_TYPE_MSG_MAC_ADDR 0x0b # define DEVICE_PATH_SUB_TYPE_MSG_USB_CLASS 0x0f +# define DEVICE_PATH_SUB_TYPE_MSG_NVME 0x17 # define DEVICE_PATH_SUB_TYPE_MSG_SD 0x1a # define DEVICE_PATH_SUB_TYPE_MSG_MMC 0x1d @@ -464,6 +465,12 @@ struct efi_device_path_sd_mmc_path { u8 slot_number; } __packed; +struct efi_device_path_nvme { + struct efi_device_path dp; + u32 ns_id; + u8 eui64[8]; +} __packed; + #define DEVICE_PATH_TYPE_MEDIA_DEVICE 0x04 # define DEVICE_PATH_SUB_TYPE_HARD_DRIVE_PATH 0x01 # define DEVICE_PATH_SUB_TYPE_CDROM_PATH 0x02 diff --git a/include/nvme.h b/include/nvme.h index 2c3d14d2418..2cdf8ce320c 100644 --- a/include/nvme.h +++ b/include/nvme.h @@ -78,4 +78,16 @@ int nvme_scan_namespace(void); */ int nvme_print_info(struct udevice *udev); +/** + * nvme_get_namespace_id - return namespace identifier + * + * This returns the namespace identifier. + * + * @udev: NVMe controller device + * @ns_id: Place where to put the name space identifier + * @eui64: Place where to put the IEEE Extended Unique Identifier + * @return: 0 on success, -ve on error + */ +int nvme_get_namespace_id(struct udevice *udev, u32 *ns_id, u8 *eui64); + #endif /* __NVME_H__ */ diff --git a/lib/efi_loader/efi_device_path.c b/lib/efi_loader/efi_device_path.c index 86297bb7c11..897fc1b2e8a 100644 --- a/lib/efi_loader/efi_device_path.c +++ b/lib/efi_loader/efi_device_path.c @@ -10,6 +10,7 @@ #include <dm.h> #include <usb.h> #include <mmc.h> +#include <nvme.h> #include <efi_loader.h> #include <part.h> #include <sandboxblockdev.h> @@ -451,6 +452,11 @@ static unsigned dp_size(struct udevice *dev) return dp_size(dev->parent) + sizeof(struct efi_device_path_sd_mmc_path); #endif +#if defined(CONFIG_NVME) + case UCLASS_NVME: + return dp_size(dev->parent) + + sizeof(struct efi_device_path_nvme); +#endif #ifdef CONFIG_SANDBOX case UCLASS_ROOT: /* @@ -584,6 +590,20 @@ static void *dp_fill(void *buf, struct udevice *dev) return &sddp[1]; } #endif +#if defined(CONFIG_NVME) + case UCLASS_NVME: { + struct efi_device_path_nvme *dp = + dp_fill(buf, dev->parent); + u32 ns_id; + + dp->dp.type = DEVICE_PATH_TYPE_MESSAGING_DEVICE; + dp->dp.sub_type = DEVICE_PATH_SUB_TYPE_MSG_NVME; + dp->dp.length = sizeof(*dp); + nvme_get_namespace_id(dev, &ns_id, dp->eui64); + memcpy(&dp->ns_id, &ns_id, sizeof(ns_id)); + return &dp[1]; + } +#endif default: debug("%s(%u) %s: unhandled parent class: %s (%u)\n", __FILE__, __LINE__, __func__, diff --git a/lib/efi_loader/efi_device_path_to_text.c b/lib/efi_loader/efi_device_path_to_text.c index 0f3796b373b..af1adbb71ef 100644 --- a/lib/efi_loader/efi_device_path_to_text.c +++ b/lib/efi_loader/efi_device_path_to_text.c @@ -148,6 +148,21 @@ static char *dp_msging(char *s, struct efi_device_path *dp) break; } + case DEVICE_PATH_SUB_TYPE_MSG_NVME: { + struct efi_device_path_nvme *ndp = + (struct efi_device_path_nvme *)dp; + u32 ns_id; + int i; + + memcpy(&ns_id, &ndp->ns_id, sizeof(ns_id)); + s += sprintf(s, "NVMe(0x%x,", ns_id); + for (i = 0; i < sizeof(ndp->eui64); ++i) + s += sprintf(s, "%s%02x", i ? "-" : "", + ndp->eui64[i]); + s += sprintf(s, ")"); + + break; + } case DEVICE_PATH_SUB_TYPE_MSG_SD: case DEVICE_PATH_SUB_TYPE_MSG_MMC: { const char *typename = diff --git a/lib/efi_loader/efi_variable.c b/lib/efi_loader/efi_variable.c index 4c554c546b2..d0daf7bdebb 100644 --- a/lib/efi_loader/efi_variable.c +++ b/lib/efi_loader/efi_variable.c @@ -478,10 +478,12 @@ efi_status_t EFIAPI efi_set_variable(u16 *variable_name, old_size = 0; } } else { - if ((data_size == 0 && - !(attributes & EFI_VARIABLE_APPEND_WRITE)) || - !attributes) { - /* delete, but nothing to do */ + if (data_size == 0 || !attributes || + (attributes & EFI_VARIABLE_APPEND_WRITE)) { + /* + * Trying to delete or to update a non-existent + * variable. + */ ret = EFI_NOT_FOUND; goto out; } diff --git a/lib/efi_selftest/efi_selftest_variables.c b/lib/efi_selftest/efi_selftest_variables.c index a6b41d1f008..5d98c029b86 100644 --- a/lib/efi_selftest/efi_selftest_variables.c +++ b/lib/efi_selftest/efi_selftest_variables.c @@ -21,9 +21,6 @@ static const efi_guid_t guid_vendor0 = static const efi_guid_t guid_vendor1 = EFI_GUID(0xff629290, 0x1fc1, 0xd73f, 0x8f, 0xb1, 0x32, 0xf9, 0x0c, 0xa0, 0x42, 0xea); -static const efi_guid_t guid_global = - EFI_GUID(0x8be4df61, 0x93ca, 0x11d2, - 0xaa, 0x0d, 0x00, 0xe0, 0x98, 0x03, 0x2b, 0x8c); /* * Setup unit test. @@ -120,35 +117,29 @@ static int execute(void) 7, v + 8); if (ret != EFI_SUCCESS) { efi_st_error("SetVariable(APPEND_WRITE) failed\n"); - } else { - 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 (memcmp(data, v, len)) - efi_st_todo("GetVariable returned wrong value\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 (memcmp(data, v, len)) + efi_st_todo("GetVariable returned wrong value\n"); /* Append variable 2 */ ret = runtime->set_variable(L"efi_none", &guid_vendor1, EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_APPEND_WRITE, 15, v); - if (ret != EFI_NOT_FOUND) + if (ret != EFI_NOT_FOUND) { efi_st_error("SetVariable(APPEND_WRITE) with size 0 to non-existent variable returns wrong code\n"); - /* Append variable 3 */ - ret = runtime->set_variable(L"PlatformLangCodes", &guid_global, - EFI_VARIABLE_BOOTSERVICE_ACCESS | - EFI_VARIABLE_RUNTIME_ACCESS | - EFI_VARIABLE_APPEND_WRITE, - 15, v); - if (ret != EFI_WRITE_PROTECTED) - efi_st_todo("SetVariable(APPEND_WRITE) to read-only variable returns wrong code\n"); + return EFI_ST_FAILURE; + } /* Enumerate variables */ boottime->set_mem(&guid, 16, 0); *varname = 0; |