mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-11-14 00:47:26 +00:00
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. -----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEEbcT5xx8ppvoGt20zxIHbvCwFGsQFAl2aVscACgkQxIHbvCwF GsTx+Q//ThJM6BGFE3Rk2pI0SXGqyPK1CIt78S8xj9WFjowpnL4y3sU5NQryzf7k OdGvl4KnO+qNHVIaUuOU+ylCms/DdJZcqljBE+VGRiHijjeWuWb4zv70655/DQra zxBXhmGM1RoabTR6ZosXDx9QRz+qg7eVP66oFHXAPjiAj0UEYiiKTO4wCV882POa thqI/mEg7wFI9abyVbvpG36ROT/h0t5uvH0B7h/rsCMOK9ABHrWOcy6/xibu0gZT Y25/ve6fxGfd8vW1b4/z/F+hPXqy+LYbblm+hZ+mCDPZ0kblmqmbeXGydDZkr2UN pm6niczwWqb5PL1Z5KevfytbojQTN6vnedIw3yUEFA6Znh2uSW4pry1xMQbpfkuw EQc0r0eoxlMyc0PCYqKoznrje0GXBaEG71+wcG5hhWQCzdx3BktUosrLdAdj4Km+ nho+WxOSXv3rPntY9etQ6U+EyyOyDXMHud2tnE3BN0L+gIl7pLyf3TCS/NumTAFm R7Gf9/YjazExmdJrpEjq+rBVHoF7+wdfBzok6aEw1BmTqqNiBEGpkywgg7eHYjIG lThM4VE14VITGq95FbnkhmH33NDD89UQ4DRbPWC10IajSZbGktUpIRYdYQKKHGDq vRWaaF61eDOIY4xQlX3ecDlsi5rKF2EdBtqAxWekZAAMA64okcw= =nzgb -----END PGP SIGNATURE----- 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.
This commit is contained in:
commit
8679be2956
11 changed files with 91 additions and 45 deletions
|
@ -6,7 +6,6 @@
|
||||||
|
|
||||||
#include <common.h>
|
#include <common.h>
|
||||||
#include <dm.h>
|
#include <dm.h>
|
||||||
#include <efi_loader.h>
|
|
||||||
#include <env.h>
|
#include <env.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <ns16550.h>
|
#include <ns16550.h>
|
||||||
|
@ -224,19 +223,6 @@ int board_early_init_f(void)
|
||||||
|
|
||||||
int board_late_init(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 defined(CONFIG_TEGRA_SUPPORT_NON_SECURE)
|
||||||
if (tegra_cpu_is_non_secure()) {
|
if (tegra_cpu_is_non_secure()) {
|
||||||
printf("CPU is in NS mode\n");
|
printf("CPU is in NS mode\n");
|
||||||
|
|
|
@ -531,7 +531,6 @@ config CMD_ENV_FLAGS
|
||||||
config CMD_NVEDIT_EFI
|
config CMD_NVEDIT_EFI
|
||||||
bool "env [set|print] -e - set/print UEFI variables"
|
bool "env [set|print] -e - set/print UEFI variables"
|
||||||
depends on EFI_LOADER
|
depends on EFI_LOADER
|
||||||
default y
|
|
||||||
imply HEXDUMP
|
imply HEXDUMP
|
||||||
help
|
help
|
||||||
UEFI variables are encoded as some form of U-Boot variables.
|
UEFI variables are encoded as some form of U-Boot variables.
|
||||||
|
|
|
@ -330,7 +330,7 @@ out:
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* do_env_print_efi() - set UEFI variable
|
* do_env_set_efi() - set UEFI variable
|
||||||
*
|
*
|
||||||
* @cmdtp: Command table
|
* @cmdtp: Command table
|
||||||
* @flag: Command flag
|
* @flag: Command flag
|
||||||
|
|
|
@ -621,6 +621,18 @@ static int nvme_get_info_from_identify(struct nvme_dev *dev)
|
||||||
return 0;
|
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)
|
int nvme_scan_namespace(void)
|
||||||
{
|
{
|
||||||
struct uclass *uc;
|
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))
|
if (nvme_identify(ndev, ns->ns_id, 0, (dma_addr_t)(long)id))
|
||||||
return -EIO;
|
return -EIO;
|
||||||
|
|
||||||
|
memcpy(&ns->eui64, &id->eui64, sizeof(id->eui64));
|
||||||
flbas = id->flbas & NVME_NS_FLBAS_LBA_MASK;
|
flbas = id->flbas & NVME_NS_FLBAS_LBA_MASK;
|
||||||
ns->flbas = flbas;
|
ns->flbas = flbas;
|
||||||
ns->lba_shift = id->lbaf[flbas].ds;
|
ns->lba_shift = id->lbaf[flbas].ds;
|
||||||
|
|
|
@ -637,6 +637,7 @@ struct nvme_ns {
|
||||||
struct list_head list;
|
struct list_head list;
|
||||||
struct nvme_dev *dev;
|
struct nvme_dev *dev;
|
||||||
unsigned ns_id;
|
unsigned ns_id;
|
||||||
|
u8 eui64[8];
|
||||||
int devnum;
|
int devnum;
|
||||||
int lba_shift;
|
int lba_shift;
|
||||||
u8 flbas;
|
u8 flbas;
|
||||||
|
|
|
@ -422,6 +422,7 @@ struct efi_device_path_acpi_path {
|
||||||
# define DEVICE_PATH_SUB_TYPE_MSG_USB 0x05
|
# define DEVICE_PATH_SUB_TYPE_MSG_USB 0x05
|
||||||
# define DEVICE_PATH_SUB_TYPE_MSG_MAC_ADDR 0x0b
|
# define DEVICE_PATH_SUB_TYPE_MSG_MAC_ADDR 0x0b
|
||||||
# define DEVICE_PATH_SUB_TYPE_MSG_USB_CLASS 0x0f
|
# 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_SD 0x1a
|
||||||
# define DEVICE_PATH_SUB_TYPE_MSG_MMC 0x1d
|
# define DEVICE_PATH_SUB_TYPE_MSG_MMC 0x1d
|
||||||
|
|
||||||
|
@ -464,6 +465,12 @@ struct efi_device_path_sd_mmc_path {
|
||||||
u8 slot_number;
|
u8 slot_number;
|
||||||
} __packed;
|
} __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_TYPE_MEDIA_DEVICE 0x04
|
||||||
# define DEVICE_PATH_SUB_TYPE_HARD_DRIVE_PATH 0x01
|
# define DEVICE_PATH_SUB_TYPE_HARD_DRIVE_PATH 0x01
|
||||||
# define DEVICE_PATH_SUB_TYPE_CDROM_PATH 0x02
|
# define DEVICE_PATH_SUB_TYPE_CDROM_PATH 0x02
|
||||||
|
|
|
@ -78,4 +78,16 @@ int nvme_scan_namespace(void);
|
||||||
*/
|
*/
|
||||||
int nvme_print_info(struct udevice *udev);
|
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__ */
|
#endif /* __NVME_H__ */
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
#include <dm.h>
|
#include <dm.h>
|
||||||
#include <usb.h>
|
#include <usb.h>
|
||||||
#include <mmc.h>
|
#include <mmc.h>
|
||||||
|
#include <nvme.h>
|
||||||
#include <efi_loader.h>
|
#include <efi_loader.h>
|
||||||
#include <part.h>
|
#include <part.h>
|
||||||
#include <sandboxblockdev.h>
|
#include <sandboxblockdev.h>
|
||||||
|
@ -451,6 +452,11 @@ static unsigned dp_size(struct udevice *dev)
|
||||||
return dp_size(dev->parent) +
|
return dp_size(dev->parent) +
|
||||||
sizeof(struct efi_device_path_sd_mmc_path);
|
sizeof(struct efi_device_path_sd_mmc_path);
|
||||||
#endif
|
#endif
|
||||||
|
#if defined(CONFIG_NVME)
|
||||||
|
case UCLASS_NVME:
|
||||||
|
return dp_size(dev->parent) +
|
||||||
|
sizeof(struct efi_device_path_nvme);
|
||||||
|
#endif
|
||||||
#ifdef CONFIG_SANDBOX
|
#ifdef CONFIG_SANDBOX
|
||||||
case UCLASS_ROOT:
|
case UCLASS_ROOT:
|
||||||
/*
|
/*
|
||||||
|
@ -583,6 +589,20 @@ static void *dp_fill(void *buf, struct udevice *dev)
|
||||||
sddp->slot_number = dev->seq;
|
sddp->slot_number = dev->seq;
|
||||||
return &sddp[1];
|
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
|
#endif
|
||||||
default:
|
default:
|
||||||
debug("%s(%u) %s: unhandled parent class: %s (%u)\n",
|
debug("%s(%u) %s: unhandled parent class: %s (%u)\n",
|
||||||
|
|
|
@ -148,6 +148,21 @@ static char *dp_msging(char *s, struct efi_device_path *dp)
|
||||||
|
|
||||||
break;
|
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_SD:
|
||||||
case DEVICE_PATH_SUB_TYPE_MSG_MMC: {
|
case DEVICE_PATH_SUB_TYPE_MSG_MMC: {
|
||||||
const char *typename =
|
const char *typename =
|
||||||
|
|
|
@ -478,10 +478,12 @@ efi_status_t EFIAPI efi_set_variable(u16 *variable_name,
|
||||||
old_size = 0;
|
old_size = 0;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if ((data_size == 0 &&
|
if (data_size == 0 || !attributes ||
|
||||||
!(attributes & EFI_VARIABLE_APPEND_WRITE)) ||
|
(attributes & EFI_VARIABLE_APPEND_WRITE)) {
|
||||||
!attributes) {
|
/*
|
||||||
/* delete, but nothing to do */
|
* Trying to delete or to update a non-existent
|
||||||
|
* variable.
|
||||||
|
*/
|
||||||
ret = EFI_NOT_FOUND;
|
ret = EFI_NOT_FOUND;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,9 +21,6 @@ static const efi_guid_t guid_vendor0 =
|
||||||
static const efi_guid_t guid_vendor1 =
|
static const efi_guid_t guid_vendor1 =
|
||||||
EFI_GUID(0xff629290, 0x1fc1, 0xd73f,
|
EFI_GUID(0xff629290, 0x1fc1, 0xd73f,
|
||||||
0x8f, 0xb1, 0x32, 0xf9, 0x0c, 0xa0, 0x42, 0xea);
|
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.
|
* Setup unit test.
|
||||||
|
@ -120,7 +117,8 @@ static int execute(void)
|
||||||
7, v + 8);
|
7, v + 8);
|
||||||
if (ret != EFI_SUCCESS) {
|
if (ret != EFI_SUCCESS) {
|
||||||
efi_st_error("SetVariable(APPEND_WRITE) failed\n");
|
efi_st_error("SetVariable(APPEND_WRITE) failed\n");
|
||||||
} else {
|
return EFI_ST_FAILURE;
|
||||||
|
}
|
||||||
len = EFI_ST_MAX_DATA_SIZE;
|
len = EFI_ST_MAX_DATA_SIZE;
|
||||||
ret = runtime->get_variable(L"efi_st_var1", &guid_vendor1,
|
ret = runtime->get_variable(L"efi_st_var1", &guid_vendor1,
|
||||||
&attr, &len, data);
|
&attr, &len, data);
|
||||||
|
@ -133,22 +131,15 @@ static int execute(void)
|
||||||
(unsigned int)len);
|
(unsigned int)len);
|
||||||
if (memcmp(data, v, len))
|
if (memcmp(data, v, len))
|
||||||
efi_st_todo("GetVariable returned wrong value\n");
|
efi_st_todo("GetVariable returned wrong value\n");
|
||||||
}
|
|
||||||
/* Append variable 2 */
|
/* Append variable 2 */
|
||||||
ret = runtime->set_variable(L"efi_none", &guid_vendor1,
|
ret = runtime->set_variable(L"efi_none", &guid_vendor1,
|
||||||
EFI_VARIABLE_BOOTSERVICE_ACCESS |
|
EFI_VARIABLE_BOOTSERVICE_ACCESS |
|
||||||
EFI_VARIABLE_APPEND_WRITE,
|
EFI_VARIABLE_APPEND_WRITE,
|
||||||
15, v);
|
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");
|
efi_st_error("SetVariable(APPEND_WRITE) with size 0 to non-existent variable returns wrong code\n");
|
||||||
/* Append variable 3 */
|
return EFI_ST_FAILURE;
|
||||||
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");
|
|
||||||
/* Enumerate variables */
|
/* Enumerate variables */
|
||||||
boottime->set_mem(&guid, 16, 0);
|
boottime->set_mem(&guid, 16, 0);
|
||||||
*varname = 0;
|
*varname = 0;
|
||||||
|
|
Loading…
Reference in a new issue