efi_loader: Add bounce buffers
cover efi_loader: Add bounce buffers
While testing our shiny new EFI support, I stumbled across systems that have disk I/O hardware that can only access the lower 32bits of our physical address space.
This is not a problem when running with the normal U-Boot flow, since we define all "pointers" that get in use in our environment, so we can just put them inside the lower 32bits.
But when a higher level application such as an EFI payload comes across, it doesn't know about these constraints. So we need to allocate bounce buffers for the payload and use them instead.
Alexander Graf (2):
efi_loader: Add bounce buffer support
efi_loader: Select bounce buffers for known-bad boards
configs/ls2080a_emu_defconfig | 1 + configs/ls2080a_simu_defconfig | 1 + configs/ls2080aqds_SECURE_BOOT_defconfig | 1 + configs/ls2080aqds_defconfig | 1 + configs/ls2080aqds_nand_defconfig | 1 + configs/ls2080ardb_SECURE_BOOT_defconfig | 1 + configs/ls2080ardb_defconfig | 1 + configs/ls2080ardb_nand_defconfig | 1 + configs/xilinx_zynqmp_ep_defconfig | 1 + configs/xilinx_zynqmp_zc1751_xm015_dc1_defconfig | 1 + configs/xilinx_zynqmp_zc1751_xm016_dc2_defconfig | 1 + configs/xilinx_zynqmp_zc1751_xm019_dc5_defconfig | 1 + configs/xilinx_zynqmp_zcu102_defconfig | 1 + configs/xilinx_zynqmp_zcu102_revB_defconfig | 1 + include/efi_loader.h | 5 ++ lib/efi_loader/Kconfig | 9 +++ lib/efi_loader/efi_disk.c | 70 +++++++++++++++++++++--- lib/efi_loader/efi_memory.c | 16 ++++++ 18 files changed, 105 insertions(+), 9 deletions(-)
Signature · 1 line
1.8.5.6
PATCH 1/2 efi_loader: Add bounce buffer support
Some hardware that is supported by U-Boot can not handle DMA above 32bits. For these systems, we need to come up with a way to expose the disk interface in a safe way.
This patch implements EFI specific bounce buffers. For non-EFI cases, this apparently was no issue so far, since we can just define our environment variables conveniently.
--- include/efi_loader.h | 5 ++++ lib/efi_loader/Kconfig | 9 ++++++ lib/efi_loader/efi_disk.c | 70 +++++++++++++++++++++++++++++++++++++++------ lib/efi_loader/efi_memory.c | 16 +++++++++++ 4 files changed, 91 insertions(+), 9 deletions(-)
include/efi_loader.h +5 -0
@@ -139,6 +139,11 @@ uint64_t efi_add_memory_map(uint64_t start, uint64_t pages, int memory_type,/* Called by board init to initialize the EFI memory map */ int efi_memory_init (void ); +#ifdef CONFIG_EFI_LOADER_BOUNCE_BUFFER +extern void *efi_bounce_buffer; +#define EFI_LOADER_BOUNCE_BUFFER_SIZE (64 * 1024 * 1024) +#endif +/* Convert strings from normal C strings to uEFI strings */ static inline void ascii2unicode (u16 *unicode,char *ascii) {
lib/efi_loader/Kconfig +9 -0
@@ -7,3 +7,12 @@ config EFI_LOADER on top of U-Boot. If this option is enabled, U-Boot will expose EFI interfaces to a loaded EFI application, enabling it to reuse U-Boot's device drivers. + +config EFI_LOADER_BOUNCE_BUFFER + bool "EFI Applications use bounce buffers for DMA operations" + depends on EFI_LOADER && ARM64 + default n + help + Some hardware does not support DMA to full 64bit addresses. For this + hardware we can create a bounce buffer so that payloads don't have to + worry about platform details.
lib/efi_loader/efi_disk.c +61 -9
96 lines not on this page · raw message
lib/efi_loader/efi_memory.c +16 -0
@@ -27,6 +27,10 @@ struct efi_mem_list {/* This list contains all memory map items */ LIST_HEAD (efi_mem); +#ifdef CONFIG_EFI_LOADER_BOUNCE_BUFFER +void *efi_bounce_buffer; +#endif +/* * Sorts the memory list from highest address to lowest address *
@@ -349,5 +353,17 @@ int efi_memory_init(void)efi_add_memory_map (runtime_start, runtime_pages,EFI_RUNTIME_SERVICES_CODE , false); +#ifdef CONFIG_EFI_LOADER_BOUNCE_BUFFER +/* Request a 32bit 64MB bounce buffer region */ +uint64_t efi_bounce_buffer_addr =0xffffffff ; + +if (efi_allocate_pages (1 ,EFI_LOADER_DATA , + (64 *1024 *1024 ) >>EFI_PAGE_SHIFT , + &efi_bounce_buffer_addr) !=EFI_SUCCESS ) +return -1 ; + + efi_bounce_buffer = (void *)(uintptr_t )efi_bounce_buffer_addr; +#endif +return 0 ; }
Signature · 1 line
1.8.5.6
PATCH 1/2 efi_loader: Add bounce buffer support
Quoted 9 lines · Alexander Graf
Some hardware that is supported by U-Boot can not handle DMA above 32bits. For these systems, we need to come up with a way to expose the disk interface in a safe way.
This patch implements EFI specific bounce buffers. For non-EFI cases, this apparently was no issue so far, since we can just define our environment variables conveniently.
Signed-off-by Alexander Graf <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160530/3b294b7a/attachment.sig>
PATCH 2/2 efi_loader: Select bounce buffers for known-bad boards
In reply to Alexander GrafWe know for certain that we have 32bit DMA hardware, but 64bit addresses on LS2085A and ZynqMP, so let's enable EFI bounce buffers for all defconfigs on these SoCs.
--- configs/ls2080a_emu_defconfig | 1 + configs/ls2080a_simu_defconfig | 1 + configs/ls2080aqds_SECURE_BOOT_defconfig | 1 + configs/ls2080aqds_defconfig | 1 + configs/ls2080aqds_nand_defconfig | 1 + configs/ls2080ardb_SECURE_BOOT_defconfig | 1 + configs/ls2080ardb_defconfig | 1 + configs/ls2080ardb_nand_defconfig | 1 + configs/xilinx_zynqmp_ep_defconfig | 1 + configs/xilinx_zynqmp_zc1751_xm015_dc1_defconfig | 1 + configs/xilinx_zynqmp_zc1751_xm016_dc2_defconfig | 1 + configs/xilinx_zynqmp_zc1751_xm019_dc5_defconfig | 1 + configs/xilinx_zynqmp_zcu102_defconfig | 1 + configs/xilinx_zynqmp_zcu102_revB_defconfig | 1 + 14 files changed, 14 insertions(+)
configs/ls2080a_emu_defconfig +1 -0
@@ -26,3 +26,4 @@ CONFIG_CMD_CACHE=y CONFIG_SYS_NS16550=y CONFIG_OF_LIBFDT=y CONFIG_BOOTP_VCI_STRING="U-Boot.LS2080A-EMU" +CONFIG_EFI_LOADER_BOUNCE_BUFFER=y
configs/ls2080a_simu_defconfig +1 -0
@@ -29,3 +29,4 @@ CONFIG_NET_RANDOM_ETHADDR=y CONFIG_SYS_NS16550=y CONFIG_OF_LIBFDT=y CONFIG_BOOTP_VCI_STRING="U-Boot.LS2080A-SIMU" +CONFIG_EFI_LOADER_BOUNCE_BUFFER=y
configs/ls2080aqds_SECURE_BOOT_defconfig +1 -0
@@ -30,3 +30,4 @@ CONFIG_E1000=y CONFIG_SYS_NS16550=y CONFIG_FSL_DSPI=y CONFIG_RSA=y +CONFIG_EFI_LOADER_BOUNCE_BUFFER=y
configs/ls2080aqds_defconfig +1 -0
@@ -29,3 +29,4 @@ CONFIG_NETDEVICES=y CONFIG_E1000=y CONFIG_SYS_NS16550=y CONFIG_FSL_DSPI=y +CONFIG_EFI_LOADER_BOUNCE_BUFFER=y
configs/ls2080aqds_nand_defconfig +1 -0
@@ -23,3 +23,4 @@ CONFIG_NETDEVICES=y CONFIG_E1000=y CONFIG_SYS_NS16550=y CONFIG_OF_LIBFDT=y +CONFIG_EFI_LOADER_BOUNCE_BUFFER=y
configs/ls2080ardb_SECURE_BOOT_defconfig +1 -0
@@ -30,3 +30,4 @@ CONFIG_E1000=y CONFIG_SYS_NS16550=y CONFIG_FSL_DSPI=y CONFIG_RSA=y +CONFIG_EFI_LOADER_BOUNCE_BUFFER=y
configs/ls2080ardb_defconfig +1 -0
@@ -29,3 +29,4 @@ CONFIG_NETDEVICES=y CONFIG_E1000=y CONFIG_SYS_NS16550=y CONFIG_FSL_DSPI=y +CONFIG_EFI_LOADER_BOUNCE_BUFFER=y
configs/ls2080ardb_nand_defconfig +1 -0
@@ -23,3 +23,4 @@ CONFIG_NETDEVICES=y CONFIG_E1000=y CONFIG_SYS_NS16550=y CONFIG_OF_LIBFDT=y +CONFIG_EFI_LOADER_BOUNCE_BUFFER=y
configs/xilinx_zynqmp_ep_defconfig +1 -0
@@ -55,3 +55,4 @@ CONFIG_G_DNL_MANUFACTURER="Xilinx" CONFIG_G_DNL_VENDOR_NUM=0x03fd CONFIG_G_DNL_PRODUCT_NUM=0x0300 # CONFIG_REGEX is not set +CONFIG_EFI_LOADER_BOUNCE_BUFFER=y
configs/xilinx_zynqmp_zc1751_xm015_dc1_defconfig +1 -0
@@ -50,3 +50,4 @@ CONFIG_USB_GADGET_DOWNLOAD=y CONFIG_G_DNL_MANUFACTURER="Xilinx" CONFIG_G_DNL_VENDOR_NUM=0x03FD CONFIG_G_DNL_PRODUCT_NUM=0x0300 +CONFIG_EFI_LOADER_BOUNCE_BUFFER=y
configs/xilinx_zynqmp_zc1751_xm016_dc2_defconfig +1 -0
@@ -47,3 +47,4 @@ CONFIG_USB_GADGET_DOWNLOAD=y CONFIG_G_DNL_MANUFACTURER="Xilinx" CONFIG_G_DNL_VENDOR_NUM=0x03FD CONFIG_G_DNL_PRODUCT_NUM=0x0300 +CONFIG_EFI_LOADER_BOUNCE_BUFFER=y
configs/xilinx_zynqmp_zc1751_xm019_dc5_defconfig +1 -0
@@ -29,3 +29,4 @@ CONFIG_SYS_I2C_CADENCE=y CONFIG_DM_MMC=y CONFIG_ZYNQ_SDHCI=y CONFIG_DM_ETH=y +CONFIG_EFI_LOADER_BOUNCE_BUFFER=y
configs/xilinx_zynqmp_zcu102_defconfig +1 -0
@@ -48,3 +48,4 @@ CONFIG_USB_GADGET_DOWNLOAD=y CONFIG_G_DNL_MANUFACTURER="Xilinx" CONFIG_G_DNL_VENDOR_NUM=0x03FD CONFIG_G_DNL_PRODUCT_NUM=0x0300 +CONFIG_EFI_LOADER_BOUNCE_BUFFER=y
configs/xilinx_zynqmp_zcu102_revB_defconfig +1 -0
@@ -48,3 +48,4 @@ CONFIG_USB_GADGET_DOWNLOAD=y CONFIG_G_DNL_MANUFACTURER="Xilinx" CONFIG_G_DNL_VENDOR_NUM=0x03FD CONFIG_G_DNL_PRODUCT_NUM=0x0300 +CONFIG_EFI_LOADER_BOUNCE_BUFFER=y
Signature · 1 line
1.8.5.6
PATCH 2/2 efi_loader: Select bounce buffers for known-bad boards
Quoted 5 lines · Alexander Graf
We know for certain that we have 32bit DMA hardware, but 64bit addresses on LS2085A and ZynqMP, so let's enable EFI bounce buffers for all defconfigs on these SoCs.
Signed-off-by Alexander Graf <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160530/cdd83814/attachment.sig>
cover efi_loader: Add bounce buffers
In reply to Alexander GrafQuoted 11 lines · Alexander Graf
While testing our shiny new EFI support, I stumbled across systems that have disk I/O hardware that can only access the lower 32bits of our physical address space.
This is not a problem when running with the normal U-Boot flow, since we define all "pointers" that get in use in our environment, so we can just put them inside the lower 32bits.
But when a higher level application such as an EFI payload comes across, it doesn't know about these constraints. So we need to allocate bounce buffers for the payload and use them instead.
Alexander,
The low 32-bit physical memory is required for this to work, isn't it? There was a discussion to move to high memory for LS2080 so the memory can be continuous for OS.
York
Quoted 25 lines
Alexander Graf (2):
efi_loader: Add bounce buffer support
efi_loader: Select bounce buffers for known-bad boardsconfigs/ls2080a_emu_defconfig | 1 + configs/ls2080a_simu_defconfig | 1 + configs/ls2080aqds_SECURE_BOOT_defconfig | 1 + configs/ls2080aqds_defconfig | 1 + configs/ls2080aqds_nand_defconfig | 1 + configs/ls2080ardb_SECURE_BOOT_defconfig | 1 + configs/ls2080ardb_defconfig | 1 + configs/ls2080ardb_nand_defconfig | 1 + configs/xilinx_zynqmp_ep_defconfig | 1 + configs/xilinx_zynqmp_zc1751_xm015_dc1_defconfig | 1 + configs/xilinx_zynqmp_zc1751_xm016_dc2_defconfig | 1 + configs/xilinx_zynqmp_zc1751_xm019_dc5_defconfig | 1 + configs/xilinx_zynqmp_zcu102_defconfig | 1 + configs/xilinx_zynqmp_zcu102_revB_defconfig | 1 + include/efi_loader.h | 5 ++ lib/efi_loader/Kconfig | 9 +++ lib/efi_loader/efi_disk.c | 70 +++++++++++++++++++++--- lib/efi_loader/efi_memory.c | 16 ++++++ 18 files changed, 105 insertions(+), 9 deletions(-)
cover efi_loader: Add bounce buffers
Quoted 17 lines
Am 11.05.2016 um 18:33 schrieb York Sun <[email protected]>:
Quoted 5 lines · Alexander Graf
While testing our shiny new EFI support, I stumbled across systems that have disk I/O hardware that can only access the lower 32bits of our physical address space.
Quoted 7 lines
This is not a problem when running with the normal U-Boot flow, since we define all "pointers" that get in use in our environment, so we can just put them inside the lower 32bits.
But when a higher level application such as an EFI payload comes across, it doesn't know about these constraints. So we need to allocate bounce buffers for the payload and use them instead.
Quoted 5 lines
Alexander,
The low 32-bit physical memory is required for this to work, isn't it? There was a discussion to move to high memory for LS2080 so the memory can be continuous for OS.
So how would that work in the non-efi case? Do you configure the smmu statically to give you an offset between device memory view and physical?
In that case we can probably extend the patch to make the config variable a max addr instead of bool. Then the bounce buffer would be inside the shifted 32bit window.
Alex
Quoted 28 lines
York
Quoted 24 lines
Alexander Graf (2):
efi_loader: Add bounce buffer support
efi_loader: Select bounce buffers for known-bad boardsconfigs/ls2080a_emu_defconfig | 1 + configs/ls2080a_simu_defconfig | 1 + configs/ls2080aqds_SECURE_BOOT_defconfig | 1 + configs/ls2080aqds_defconfig | 1 + configs/ls2080aqds_nand_defconfig | 1 + configs/ls2080ardb_SECURE_BOOT_defconfig | 1 + configs/ls2080ardb_defconfig | 1 + configs/ls2080ardb_nand_defconfig | 1 + configs/xilinx_zynqmp_ep_defconfig | 1 + configs/xilinx_zynqmp_zc1751_xm015_dc1_defconfig | 1 + configs/xilinx_zynqmp_zc1751_xm016_dc2_defconfig | 1 + configs/xilinx_zynqmp_zc1751_xm019_dc5_defconfig | 1 + configs/xilinx_zynqmp_zcu102_defconfig | 1 + configs/xilinx_zynqmp_zcu102_revB_defconfig | 1 + include/efi_loader.h | 5 ++ lib/efi_loader/Kconfig | 9 +++ lib/efi_loader/efi_disk.c | 70 +++++++++++++++++++++--- lib/efi_loader/efi_memory.c | 16 ++++++ 18 files changed, 105 insertions(+), 9 deletions(-)
cover efi_loader: Add bounce buffers
Quoted 17 lines · Alexander Graf
Quoted 17 lines
Am 11.05.2016 um 18:33 schrieb York Sun <[email protected]>:
Quoted 12 lines · Alexander Graf
While testing our shiny new EFI support, I stumbled across systems that have disk I/O hardware that can only access the lower 32bits of our physical address space.
This is not a problem when running with the normal U-Boot flow, since we define all "pointers" that get in use in our environment, so we can just put them inside the lower 32bits.
But when a higher level application such as an EFI payload comes across, it doesn't know about these constraints. So we need to allocate bounce buffers for the payload and use them instead.
Quoted 7 lines
Quoted 5 lines
Alexander,
The low 32-bit physical memory is required for this to work, isn't it? There was a discussion to move to high memory for LS2080 so the memory can be continuous for OS.
So how would that work in the non-efi case? Do you configure the smmu statically to give you an offset between device memory view and physical?
Alex,
We are still waiting for more thorough testing on all drivers. This was an effort to provide continuous memory for OS. As you know, only 2GB memory is available under 32-bit space. All other memory shows up at above 39-bit space. Limited tests proved Linux can boot with the high memory. However, some drivers may not be happy with the missing 32-bit memory space. The final call is not made yet.
York
Quoted 36 lines
In that case we can probably extend the patch to make the config variable a max addr instead of bool. Then the bounce buffer would be inside the shifted 32bit window.
Alex
Quoted 28 lines
York
Quoted 24 lines
Alexander Graf (2):
efi_loader: Add bounce buffer support
efi_loader: Select bounce buffers for known-bad boardsconfigs/ls2080a_emu_defconfig | 1 + configs/ls2080a_simu_defconfig | 1 + configs/ls2080aqds_SECURE_BOOT_defconfig | 1 + configs/ls2080aqds_defconfig | 1 + configs/ls2080aqds_nand_defconfig | 1 + configs/ls2080ardb_SECURE_BOOT_defconfig | 1 + configs/ls2080ardb_defconfig | 1 + configs/ls2080ardb_nand_defconfig | 1 + configs/xilinx_zynqmp_ep_defconfig | 1 + configs/xilinx_zynqmp_zc1751_xm015_dc1_defconfig | 1 + configs/xilinx_zynqmp_zc1751_xm016_dc2_defconfig | 1 + configs/xilinx_zynqmp_zc1751_xm019_dc5_defconfig | 1 + configs/xilinx_zynqmp_zcu102_defconfig | 1 + configs/xilinx_zynqmp_zcu102_revB_defconfig | 1 + include/efi_loader.h | 5 ++ lib/efi_loader/Kconfig | 9 +++ lib/efi_loader/efi_disk.c | 70 +++++++++++++++++++++--- lib/efi_loader/efi_memory.c | 16 ++++++ 18 files changed, 105 insertions(+), 9 deletions(-)
cover efi_loader: Add bounce buffers
Quoted 30 lines
Am 11.05.2016 um 19:09 schrieb York Sun <[email protected]>:
Quoted 18 lines · Alexander Graf
Quoted 17 lines
Quoted 16 lines
Am 11.05.2016 um 18:33 schrieb York Sun <[email protected]>:
On 05/11/2016 09:25 AM, Alexander Graf wrote:
While testing our shiny new EFI support, I stumbled across systems that have disk I/O hardware that can only access the lower 32bits of our physical address space.This is not a problem when running with the normal U-Boot flow, since we define all "pointers" that get in use in our environment, so we can just put them inside the lower 32bits.
But when a higher level application such as an EFI payload comes across, it doesn't know about these constraints. So we need to allocate bounce buffers for the payload and use them instead.
Quoted 7 lines
Quoted 5 lines
Alexander,
The low 32-bit physical memory is required for this to work, isn't it? There was a discussion to move to high memory for LS2080 so the memory can be continuous for OS.
So how would that work in the non-efi case? Do you configure the smmu statically to give you an offset between device memory view and physical?
Quoted 8 lines
Alex,
We are still waiting for more thorough testing on all drivers. This was an effort to provide continuous memory for OS. As you know, only 2GB memory is available under 32-bit space. All other memory shows up at above 39-bit space. Limited tests proved Linux can boot with the high memory. However, some drivers may not be happy with the missing 32-bit memory space. The final call is not made yet.
Yes, I remember the discussion and I think it's a great idea. In Linux we shouldn't have any issue at all, since we have full SMMU support there, so a device can always just see everything inside its 32bit addressable space.
But in U-Boot things are not quite as clear to me. I don't think we configure any smmu mapping today, do we? So in that scenario, what's the plan to get it working? The simplest thing I could come up with were simple prepopulated iommu tables that just give us an offset, preferably one that allows us to just cut off the upper 32bits for addresses.
Alex