Skip to contentSkip to conversation

UEFI-based HTTP Boot

RFC In review Ken Lin 5 participants 11 messages Jan 20, 2017 – Jan 25, 2017

lore
Share & tools
lore
author
#1 lore raw

RFC 1/2 net: add efihttp to do HTTP(S) Boot by UEFI HTTP Protocol

In reply to Ken Lin

This patch implements HTTP Boot by using UEFI HTTP Protocols defined in the UEFI spec (v2.5+):

28.6 EFI HTTP Protocols

It would be better to make efihttp as a single module similar to http.mod. But I cannot fit my implementation to the interfaces (grub_net_app_protocol). Some operations conflict: there is packets_pulled(), but no read(). So I placed efihttp in the net.mod.

It will be much appreciated to have suggestions of the best way to get this patch integrated in grub.

---
 grub-core/Makefile.core.def         |   1 +
 grub-core/net/bootp.c               |   6 +
 grub-core/net/drivers/efi/efihttp.c | 386 ++++++++++++++++++++++++++++++++++++
 grub-core/net/drivers/efi/efinet.c  |   1 +
 grub-core/net/net.c                 |  36 +++-
 include/grub/efi/api.h              |  17 ++
 include/grub/efi/http.h             | 221 +++++++++++++++++++++
 include/grub/err.h                  |   3 +-
 include/grub/net.h                  |   1 +
 9 files changed, 669 insertions(+), 3 deletions(-)
 create mode 100755 grub-core/net/drivers/efi/efihttp.c
 create mode 100755 include/grub/efi/http.h
grub-core/Makefile.core.def +1 -0
index 2dfa22a..6a35951 100644
@@ -2143,6 +2143,7 @@ module = {
   common = net/ethernet.c;
   common = net/arp.c;
   common = net/netbuff.c;
+  efi = net/drivers/efi/efihttp.c;
 };
 
 module = {
grub-core/net/bootp.c +6 -0
index de9239c..17ac54c 100644
@@ -26,6 +26,9 @@
 #include <grub/datetime.h>
 #include <grub/time.h>
 #include <grub/list.h>
+#ifdef GRUB_MACHINE_EFI
+#include <grub/efi/http.h>
+#endif
 
 static int
 dissect_url (const char *url, char **proto, char **host, char **path)
@@ -339,6 +342,9 @@ grub_net_configure_by_dhcp_ack (const char *name,
 	    }
 	  else
 	    grub_errno = GRUB_ERR_NONE;
+#ifdef GRUB_MACHINE_EFI
+          grub_efihttp_configure (card, bp);
+#endif
 
 	  grub_free (proto);
 	  grub_free (ip);
grub-core/net/drivers/efi/efihttp.c new file +386 -0

386 lines not on this page · raw message

grub-core/net/drivers/efi/efinet.c +1 -0
index 82a28fb..82b0fdd 100644
@@ -518,6 +518,7 @@ grub_efinet_create_dhcp_ack_from_device_path (grub_efi_device_path_t *dp, int *u
 	}
       grub_memcpy (bp->boot_file, uri_dp->uri, uri_len);
       grub_memcpy (&bp->your_ip, ipv4->local_ip_address, sizeof (bp->your_ip));
+      grub_memcpy (&bp->subnet_mask, ipv4->subnet_mask, sizeof (bp->subnet_mask));
       grub_memcpy (&bp->server_ip, ipv4->remote_ip_address, sizeof (bp->server_ip));
 
       bp->vendor[0] = GRUB_NET_BOOTP_RFC1048_MAGIC_0;
grub-core/net/net.c +34 -2
index 2b329ee..90c5b48 100644
@@ -32,6 +32,9 @@
 #include <grub/loader.h>
 #include <grub/bufio.h>
 #include <grub/kernel.h>
+#ifdef GRUB_MACHINE_EFI
+#include <grub/efi/http.h>
+#endif
 
 GRUB_MOD_LICENSE ("GPLv3+");
 
@@ -1504,7 +1507,12 @@ grub_net_fs_open (struct grub_file *file_out, const char *name)
       return grub_errno;
     }
 
-  err = file->device->net->protocol->open (file, name);
+#ifdef GRUB_MACHINE_EFI
+  if (grub_efihttp)
+      err =  grub_efihttp_open (file, name);
+  else
+#endif
+      err = file->device->net->protocol->open (file, name);
   if (err)
     {
       while (file->device->net->packs.first)
@@ -1543,7 +1551,12 @@ grub_net_fs_close (grub_file_t file)
       grub_netbuff_free (file->device->net->packs.first->nb);
       grub_net_remove_packet (file->device->net->packs.first);
     }
-  file->device->net->protocol->close (file);
+#ifdef GRUB_MACHINE_EFI
+  if (grub_efihttp)
+      grub_efihttp_close (file);
+  else
+#endif
+      file->device->net->protocol->close (file);
   grub_free (file->device->net->name);
   return GRUB_ERR_NONE;
 }
@@ -1774,6 +1787,25 @@ grub_net_seek_real (struct grub_file *file, grub_off_t offset)
 static grub_ssize_t
 grub_net_fs_read (grub_file_t file, char *buf, grub_size_t len)
 {
+#ifdef GRUB_MACHINE_EFI
+  if (grub_efihttp)
+  {
+      /* adjust the offset */
+      if (file->offset > file->device->net->offset)
+      {
+          grub_efihttp_read (file, NULL, (file->offset - file->device->net->offset));
+      }
+      else if (file->offset < file->device->net->offset)
+      {
+          grub_efihttp_close (file);
+          grub_efihttp_open (file, file->device->net->name);
+          if (file->offset)
+              grub_efihttp_read (file, NULL, file->offset);
+      }
+
+      return grub_efihttp_read (file, buf, len);
+  }
+#endif
   if (file->offset != file->device->net->offset)
     {
       grub_err_t err;
include/grub/efi/api.h +17 -0
index 99ba068..6a37eb9 100644
@@ -982,6 +982,23 @@ struct grub_efi_bios_device_path
 } GRUB_PACKED;
 typedef struct grub_efi_bios_device_path grub_efi_bios_device_path_t;
 
+/* Service Binding definitions */
+struct grub_efi_service_binding;
+
+typedef grub_efi_status_t
+(*grub_efi_service_binding_create_child) (struct grub_efi_service_binding *this,
+                                          grub_efi_handle_t *child_handle);
+
+typedef grub_efi_status_t
+(*grub_efi_service_binding_destroy_child) (struct grub_efi_service_binding *this,
+                                           grub_efi_handle_t *child_handle);
+
+typedef struct grub_efi_service_binding
+{
+  grub_efi_service_binding_create_child create_child;
+  grub_efi_service_binding_destroy_child destroy_child;
+} grub_efi_service_binding_t;
+
 struct grub_efi_open_protocol_information_entry
 {
   grub_efi_handle_t agent_handle;
include/grub/efi/http.h new file +221 -0

221 lines not on this page · raw message

include/grub/err.h +2 -1
index 1590c68..eb0fc0e 100644
@@ -71,7 +71,8 @@ typedef enum
     GRUB_ERR_NET_PACKET_TOO_BIG,
     GRUB_ERR_NET_NO_DOMAIN,
     GRUB_ERR_EOF,
-    GRUB_ERR_BAD_SIGNATURE
+    GRUB_ERR_BAD_SIGNATURE,
+    GRUB_ERR_EFI
   }
 grub_err_t;
 
include/grub/net.h +1 -0
index 67c801e..d175b8f 100644
@@ -435,6 +435,7 @@ struct grub_net_bootp_packet
   grub_uint16_t flags;
   grub_uint32_t	client_ip;
   grub_uint32_t your_ip;
+  grub_uint32_t subnet_mask;
   grub_uint32_t	server_ip;
   grub_uint32_t	gateway_ip;
   grub_net_bootp_mac_addr_t mac_addr;
Signature · 1 line
2.7.4
author
#2 lore raw

RFC 2/2 net: workaround to bypass corruption of the efihttp function pointer

In reply to Ken Lin

It's a workaround to bypass the corruption of the Request function pointer. The function pointer crashes after the grub menu is shown. Here is the log:

net/drivers/efi/efihttp.c:175: b->create_event() net/drivers/efi/efihttp.c:188: grub_efihttp:0x3edc4020, grub_efihttp->request:0xafafafafafafafaf net/drivers/efi/efihttp.c:191: Before grub_efihttp->request(), url:http://192.168.111.1/boot/grub/x86_64-efi/part_gpt.mod
!!!! X64 Exception Type - 0D(#GP - General Protection) CPU Apic ID - 00000000 !!!! RIP - 000000003E74C59B, CS - 0000000000000038, RFLAGS - 0000000000210202 ExceptionData - 0000000000000000

RAX  - 000000003BD24280, RCX - 000000003EDC4020, RDX - 000000003BC5B500
RBX  - 000000003BC5B600, RSP - 000000003FAFA6D0, RBP - 000000003BC5B4A0
RSI  - 000000003EDC4020, RDI - AFAFAFAFAFAFAFAF
R8   - 000000003BC5B340, R9  - 000000003BC5B1A0, R10 - 0000000000000013
R11  - 0000000000000058, R12 - 000000003E74C594, R13 - 000000003E754D13
R14  - 000000003BC5B460, R15 - 0000000000000000
DS   - 0000000000000030, ES  - 0000000000000030, FS  - 0000000000000030
GS   - 0000000000000030, SS  - 0000000000000030
CR0  - 0000000080000033, CR2 - 0000000000000000, CR3 - 000000003FA99000
CR4  - 0000000000000668, CR8 - 0000000000000000
DR0  - 0000000000000000, DR1 - 0000000000000000, DR2 - 0000000000000000
DR3  - 0000000000000000, DR6 - 00000000FFFF0FF0, DR7 - 0000000000000400

GDTR - 000000003FA87698 0000000000000047, LDTR - 0000000000000000
IDTR - 000000003F4FA018 0000000000000FFF, TR - 0000000000000000
FXSAVE_STATE - 000000003FAFA330
!!!! Find PE image (No PDB) (ImageBase=000000003E74C000, EntryPoint=000000003E74C400) !!!!

HTTP Boot can’t work without this workaround.
The root cause is unknown. It is much appreciated for any kind of suggestions for debugging this.

---
 grub-core/net/net.c | 3 +++
 1 file changed, 3 insertions(+)
grub-core/net/net.c +3 -0
index 90c5b48..e258109 100644
@@ -1661,6 +1661,9 @@ static void
 grub_net_poll_cards_idle_real (void)
 {
   struct grub_net_card *card;
+#ifdef GRUB_MACHINE_EFI
+  if (grub_efihttp) return;
+#endif
   FOR_NET_CARDS (card)
   {
     grub_uint64_t ctime = grub_get_time_ms ();
Signature · 1 line
2.7.4

Ken Lin

author
#0 lore raw

cover UEFI-based HTTP Boot

This RFC patchset is stacked on the previous HTTP boot patchset:
https://lists.gnu.org/archive/html/grub-devel/2016-12/msg00088.html
It re-uses some code from it, e.g. the DCHPACK
with vendor_class_identifier=HTTPClient.

Instead of implementing HTTP and HTTPS boot totally from software, UEFI firmware already defines APIs for HTTP(s).
Please check UEFI spec. 2.5 and plus for the detail:

28.6 EFI HTTP Protocols

Then why two implementations? For older UEFI firmwares (UEFI 2.4 and older), the HTTP(s) APIs are not available. In the case,
Grub can fall back to the software-based implementation.
In the first patch of this patchset, grub-core/net/drivers/efi/efihttp.c:76 to 81 is the code to query if the HTTP Protocol is supported by the UEFI firmware.

This patchset was tested on QEMU+OVMF and it works flawlessly.

The main goals of this RFC is to ask for opinions and suggestion to make the first patch modularized as much as possible.
In the second patch, there is some codes related TCP re-transmission that need to pass by for the HTTP Boot to work.

More details are described in the logs of each patch.

Ken Lin (2):
net: add efihttp to do HTTP(S) Boot by UEFI HTTP Protocol
net: workaround to bypass corruption of the efihttp function pointer

 grub-core/Makefile.core.def         |   1 +
 grub-core/net/bootp.c               |   6 +
 grub-core/net/drivers/efi/efihttp.c | 386 ++++++++++++++++++++++++++++++++++++
 grub-core/net/drivers/efi/efinet.c  |   1 +
 grub-core/net/net.c                 |  39 +++-
 include/grub/efi/api.h              |  17 ++
 include/grub/efi/http.h             | 221 +++++++++++++++++++++
 include/grub/err.h                  |   3 +-
 include/grub/net.h                  |   1 +
 9 files changed, 672 insertions(+), 3 deletions(-)
 create mode 100755 grub-core/net/drivers/efi/efihttp.c
 create mode 100755 include/grub/efi/http.h
Signature · 1 line
2.7.4
#3 lore raw
Quoted 11 lines · Ken Lin

This RFC patchset is stacked on the previous HTTP boot patchset:
https://lists.gnu.org/archive/html/grub-devel/2016-12/msg00088.html
It re-uses some code from it, e.g. the DCHPACK
with vendor_class_identifier=HTTPClient.

Instead of implementing HTTP and HTTPS boot totally from software, UEFI firmware already defines APIs for HTTP(s).
Please check UEFI spec. 2.5 and plus for the detail:

28.6 EFI HTTP Protocols

Without reviewing patches themselves - we usually prefer to rely on firmware as little as possible. We already have HTTP support, so what is missing in grub that requires what amounts to full re-implementation? Cannot we rather fix our HTTP support instead? This will automatically benefit all supported platforms, of which EFI is just one.

Quoted 41 lines

Then why two implementations? For older UEFI firmwares (UEFI 2.4 and older), the HTTP(s) APIs are not available. In the case,
Grub can fall back to the software-based implementation.
In the first patch of this patchset, grub-core/net/drivers/efi/efihttp.c:76 to 81 is the code to query if the HTTP Protocol is supported by the UEFI firmware.

This patchset was tested on QEMU+OVMF and it works flawlessly.

The main goals of this RFC is to ask for opinions and suggestion to make the first patch modularized as much as possible.
In the second patch, there is some codes related TCP re-transmission that need to pass by for the HTTP Boot to work.

More details are described in the logs of each patch.

Ken Lin (2):
net: add efihttp to do HTTP(S) Boot by UEFI HTTP Protocol
net: workaround to bypass corruption of the efihttp function pointer

 grub-core/Makefile.core.def         |   1 +
 grub-core/net/bootp.c               |   6 +
 grub-core/net/drivers/efi/efihttp.c | 386 ++++++++++++++++++++++++++++++++++++
 grub-core/net/drivers/efi/efinet.c  |   1 +
 grub-core/net/net.c                 |  39 +++-
 include/grub/efi/api.h              |  17 ++
 include/grub/efi/http.h             | 221 +++++++++++++++++++++
 include/grub/err.h                  |   3 +-
 include/grub/net.h                  |   1 +
 9 files changed, 672 insertions(+), 3 deletions(-)
 create mode 100755 grub-core/net/drivers/efi/efihttp.c
 create mode 100755 include/grub/efi/http.h

--
2.7.4

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

#4 lore raw

Hi Andrei,

We didn’t “re-implement” the existing http feature in grub2. What we do is putting a piece of code to check the availability of the http protocol in the firmware. If available, we use the http protocol offered by the firmware. If not, we follow the original http path.

Does this make sense to you?

Regards,
Clay

On 1/20/17, 10:50 PM, "Andrei Borzenkov" <[email protected]> wrote:

On Fri, Jan 20, 2017 at 4:13 AM, Ken Lin <[email protected]> wrote:
> This RFC patchset is stacked on the previous HTTP boot patchset:
> https://lists.gnu.org/archive/html/grub-devel/2016-12/msg00088.html
> It re-uses some code from it, e.g. the DCHPACK
> with vendor_class_identifier=HTTPClient.
>
> Instead of implementing HTTP and HTTPS boot totally from software, > UEFI firmware already defines APIs for HTTP(s).
> Please check UEFI spec. 2.5 and plus for the detail:
>
> 28.6 EFI HTTP Protocols
>

Without reviewing patches themselves - we usually prefer to rely on firmware as little as possible. We already have HTTP support, so what is missing in grub that requires what amounts to full re-implementation? Cannot we rather fix our HTTP support instead? This will automatically benefit all supported platforms, of which EFI is just one.

> Then why two implementations? For older UEFI firmwares (UEFI 2.4 and older), > the HTTP(s) APIs are not available. In the case,
> Grub can fall back to the software-based implementation.
> In the first patch of this patchset, grub-core/net/drivers/efi/efihttp.c:76 to 81 > is the code to query if the HTTP Protocol is supported by the UEFI firmware. >
> This patchset was tested on QEMU+OVMF and it works flawlessly.
>
> The main goals of this RFC is to ask for opinions and suggestion to make > the first patch modularized as much as possible.
> In the second patch, there is some codes related TCP re-transmission > that need to pass by for the HTTP Boot to work.
>
> More details are described in the logs of each patch.
>
>
> Ken Lin (2):
> net: add efihttp to do HTTP(S) Boot by UEFI HTTP Protocol
> net: workaround to bypass corruption of the efihttp function pointer
>
> grub-core/Makefile.core.def | 1 +
> grub-core/net/bootp.c | 6 +
> grub-core/net/drivers/efi/efihttp.c | 386 ++++++++++++++++++++++++++++++++++++
> grub-core/net/drivers/efi/efinet.c | 1 +
> grub-core/net/net.c | 39 +++-
> include/grub/efi/api.h | 17 ++
> include/grub/efi/http.h | 221 +++++++++++++++++++++
> include/grub/err.h | 3 +-
> include/grub/net.h | 1 +
> 9 files changed, 672 insertions(+), 3 deletions(-)
> create mode 100755 grub-core/net/drivers/efi/efihttp.c
> create mode 100755 include/grub/efi/http.h
>
> --
> 2.7.4
>
>
> _______________________________________________
> Grub-devel mailing list
> [email protected]
> https://lists.gnu.org/mailman/listinfo/grub-devel

#5 lore raw
In reply to Andrei Borzenkov

The main reason is HTTPS. We've been looking at it for a while. Recently a few patches of HTTPS Boot were already merge in the EDK2 main tree (before this, it was in the EDK2-staging tree).

Please see: https://github.com/tianocore/edk2/search?q=tls&type=Commits

For the software-based implementation, it will be a lot of works to support this, e.g. interfaces to import or remove certificates, grub has to depend on GnuTLS or OpenSSL libraries. This means that grub has to release a new version once GnuTLS or OpenSSL bump their ABIs, etc.

The ideal picture from us is as below:
* For the UEFI firmware v2.4 and older: use the software-based HTTP boot. The limitation is this does not include HTTPS.

* For the UEFI firmware v2.5 and newer: use the UEFI-based HTTP(S) boot (this RFC patchset). Both HTTP and HTTPS are supported.

I hope this help you and the other maintainers understand the background of the HTTP(s) Boot patches from us.
________________________________________
From: Andrei Borzenkov <[email protected]>
Sent: Friday, January 20, 2017 10:50:56 PM
To: The development of GNU GRUB
Cc: Lin, Ken (HPS OE-Linux TDC); Chang, Clay (HPS OE-Linux TDC); Lin, Keng-Yu; Knippers, Linda; Ruan, Michael (HPS OE-Linux/VMware TDC)
Subject: Re: [RFC 0/2] UEFI-based HTTP Boot

Quoted 11 lines · Ken Lin

This RFC patchset is stacked on the previous HTTP boot patchset:
https://lists.gnu.org/archive/html/grub-devel/2016-12/msg00088.html
It re-uses some code from it, e.g. the DCHPACK
with vendor_class_identifier=HTTPClient.

Instead of implementing HTTP and HTTPS boot totally from software, UEFI firmware already defines APIs for HTTP(s).
Please check UEFI spec. 2.5 and plus for the detail:

28.6 EFI HTTP Protocols

Without reviewing patches themselves - we usually prefer to rely on firmware as little as possible. We already have HTTP support, so what is missing in grub that requires what amounts to full re-implementation? Cannot we rather fix our HTTP support instead? This will automatically benefit all supported platforms, of which EFI is just one.

Quoted 41 lines

Then why two implementations? For older UEFI firmwares (UEFI 2.4 and older), the HTTP(s) APIs are not available. In the case,
Grub can fall back to the software-based implementation.
In the first patch of this patchset, grub-core/net/drivers/efi/efihttp.c:76 to 81 is the code to query if the HTTP Protocol is supported by the UEFI firmware.

This patchset was tested on QEMU+OVMF and it works flawlessly.

The main goals of this RFC is to ask for opinions and suggestion to make the first patch modularized as much as possible.
In the second patch, there is some codes related TCP re-transmission that need to pass by for the HTTP Boot to work.

More details are described in the logs of each patch.

Ken Lin (2):
net: add efihttp to do HTTP(S) Boot by UEFI HTTP Protocol
net: workaround to bypass corruption of the efihttp function pointer

 grub-core/Makefile.core.def         |   1 +
 grub-core/net/bootp.c               |   6 +
 grub-core/net/drivers/efi/efihttp.c | 386 ++++++++++++++++++++++++++++++++++++
 grub-core/net/drivers/efi/efinet.c  |   1 +
 grub-core/net/net.c                 |  39 +++-
 include/grub/efi/api.h              |  17 ++
 include/grub/efi/http.h             | 221 +++++++++++++++++++++
 include/grub/err.h                  |   3 +-
 include/grub/net.h                  |   1 +
 9 files changed, 672 insertions(+), 3 deletions(-)
 create mode 100755 grub-core/net/drivers/efi/efihttp.c
 create mode 100755 include/grub/efi/http.h

--
2.7.4

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

#6 lore raw

21.01.2017 06:37, Lin, Keng-Yu пишет:

Quoted 3 lines

The main reason is HTTPS. We've been looking at it for a while.

Recently a few patches of HTTPS Boot were already merge in the EDK2 main tree (before this, it was in the EDK2-staging tree).

Quoted 5 lines

Please see:
https://github.com/tianocore/edk2/search?q=tls&type=Commits

For the software-based implementation, it will be a lot of works to

support this, e.g. interfaces to import or remove certificates, grub has

I do not see how your patch solves this either. UEFI provides no guarantee that necessary certificates are available in non-volatile store, so either your patch relies on some third-party software to do it on every boot or on implementation specific behavior that stores information permanently. Having hooks in grub to manage this information would free it from these assumptions and then it does not matter whether grub will manage it via EFI interface or using own internal implementation.

to depend on GnuTLS or OpenSSL libraries. This means that grub has to release a new version once GnuTLS or OpenSSL bump their ABIs, etc.

GRUB already reuses libgcrypto. It may be possible to reuse gnutls in the same way. Sure, it is a lot of work, but then this will also be available on every platform.

Quoted 3 lines

The ideal picture from us is as below: * For the UEFI firmware v2.4 and older: use the software-based HTTP

boot. The limitation is this does not include HTTPS.

Quoted 2 lines

* For the UEFI firmware v2.5 and newer: use the UEFI-based HTTP(S)

boot (this RFC patchset). Both HTTP and HTTPS are supported.

This hardly can be used in this form. First, grub is using SNP and relies on being the only consumer of network device. We already had quite serious problems when firmware raced with grub for card access. Your patch spawns off additional protocol(s) that compete with grub. This cannot work reliably unless we switch grub to MNP.

Second your patch completely bypasses grub event loop and busy waits for transfer completion. It should hook into general grub net polling framework.

Quoted 2 lines

I hope this help you and the other maintainers understand the

background of the HTTP(s) Boot patches from us.

Quoted 68 lines

________________________________________
From: Andrei Borzenkov <[email protected]>
Sent: Friday, January 20, 2017 10:50:56 PM
To: The development of GNU GRUB
Cc: Lin, Ken (HPS OE-Linux TDC); Chang, Clay (HPS OE-Linux TDC); Lin, Keng-Yu; Knippers, Linda; Ruan, Michael (HPS OE-Linux/VMware TDC)
Subject: Re: [RFC 0/2] UEFI-based HTTP Boot

Quoted 11 lines · Ken Lin

This RFC patchset is stacked on the previous HTTP boot patchset:
https://lists.gnu.org/archive/html/grub-devel/2016-12/msg00088.html
It re-uses some code from it, e.g. the DCHPACK
with vendor_class_identifier=HTTPClient.

Instead of implementing HTTP and HTTPS boot totally from software, UEFI firmware already defines APIs for HTTP(s).
Please check UEFI spec. 2.5 and plus for the detail:

28.6 EFI HTTP Protocols

Without reviewing patches themselves - we usually prefer to rely on firmware as little as possible. We already have HTTP support, so what is missing in grub that requires what amounts to full re-implementation? Cannot we rather fix our HTTP support instead? This will automatically benefit all supported platforms, of which EFI is just one.

Quoted 41 lines

Then why two implementations? For older UEFI firmwares (UEFI 2.4 and older), the HTTP(s) APIs are not available. In the case,
Grub can fall back to the software-based implementation.
In the first patch of this patchset, grub-core/net/drivers/efi/efihttp.c:76 to 81 is the code to query if the HTTP Protocol is supported by the UEFI firmware.

This patchset was tested on QEMU+OVMF and it works flawlessly.

The main goals of this RFC is to ask for opinions and suggestion to make the first patch modularized as much as possible.
In the second patch, there is some codes related TCP re-transmission that need to pass by for the HTTP Boot to work.

More details are described in the logs of each patch.

Ken Lin (2):
net: add efihttp to do HTTP(S) Boot by UEFI HTTP Protocol
net: workaround to bypass corruption of the efihttp function pointer

 grub-core/Makefile.core.def         |   1 +
 grub-core/net/bootp.c               |   6 +
 grub-core/net/drivers/efi/efihttp.c | 386 ++++++++++++++++++++++++++++++++++++
 grub-core/net/drivers/efi/efinet.c  |   1 +
 grub-core/net/net.c                 |  39 +++-
 include/grub/efi/api.h              |  17 ++
 include/grub/efi/http.h             | 221 +++++++++++++++++++++
 include/grub/err.h                  |   3 +-
 include/grub/net.h                  |   1 +
 9 files changed, 672 insertions(+), 3 deletions(-)
 create mode 100755 grub-core/net/drivers/efi/efihttp.c
 create mode 100755 include/grub/efi/http.h

--
2.7.4

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

#7 lore raw
In reply to Andrei Borzenkov
Quoted 13 lines · Andrei Borzenkov
Quoted 11 lines · Ken Lin

This RFC patchset is stacked on the previous HTTP boot patchset:
https://lists.gnu.org/archive/html/grub-devel/2016-12/msg00088.html
It re-uses some code from it, e.g. the DCHPACK
with vendor_class_identifier=HTTPClient.

Instead of implementing HTTP and HTTPS boot totally from software, UEFI firmware already defines APIs for HTTP(s).
Please check UEFI spec. 2.5 and plus for the detail:

28.6 EFI HTTP Protocols

Quoted 6 lines

Without reviewing patches themselves - we usually prefer to rely on firmware as little as possible. We already have HTTP support, so what is missing in grub that requires what amounts to full re-implementation? Cannot we rather fix our HTTP support instead? This will automatically benefit all supported platforms, of which EFI is just one.

Nothing wrong in providing firmware based approach in addition to grub's native stack of getting the similar things done. And there's no prioity for what has to be implemented first imho. Occasionally people would prefer firmware based stack because they need new features it provides that haven't been worked out in grub, such as the https or fibre networks, or simply to avoid bug from grub, like the SNP woes among some UEFI box.

Thanks,
Michael

Quoted 47 lines
Quoted 34 lines

Then why two implementations? For older UEFI firmwares (UEFI 2.4 and older), the HTTP(s) APIs are not available. In the case,
Grub can fall back to the software-based implementation.
In the first patch of this patchset, grub-core/net/drivers/efi/efihttp.c:76 to 81 is the code to query if the HTTP Protocol is supported by the UEFI firmware.

This patchset was tested on QEMU+OVMF and it works flawlessly.

The main goals of this RFC is to ask for opinions and suggestion to make the first patch modularized as much as possible.
In the second patch, there is some codes related TCP re-transmission that need to pass by for the HTTP Boot to work.

More details are described in the logs of each patch.

Ken Lin (2):
net: add efihttp to do HTTP(S) Boot by UEFI HTTP Protocol
net: workaround to bypass corruption of the efihttp function pointer

 grub-core/Makefile.core.def         |   1 +
 grub-core/net/bootp.c               |   6 +
 grub-core/net/drivers/efi/efihttp.c | 386 ++++++++++++++++++++++++++++++++++++
 grub-core/net/drivers/efi/efinet.c  |   1 +
 grub-core/net/net.c                 |  39 +++-
 include/grub/efi/api.h              |  17 ++
 include/grub/efi/http.h             | 221 +++++++++++++++++++++
 include/grub/err.h                  |   3 +-
 include/grub/net.h                  |   1 +
 9 files changed, 672 insertions(+), 3 deletions(-)
 create mode 100755 grub-core/net/drivers/efi/efihttp.c
 create mode 100755 include/grub/efi/http.h
Quoted 8 lines

--
2.7.4

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

#8 lore raw
Quoted 21 lines · Michael Chang
Quoted 13 lines · Andrei Borzenkov
Quoted 11 lines · Ken Lin

This RFC patchset is stacked on the previous HTTP boot patchset:
https://lists.gnu.org/archive/html/grub-devel/2016-12/msg00088.html
It re-uses some code from it, e.g. the DCHPACK
with vendor_class_identifier=HTTPClient.

Instead of implementing HTTP and HTTPS boot totally from software, UEFI firmware already defines APIs for HTTP(s).
Please check UEFI spec. 2.5 and plus for the detail:

28.6 EFI HTTP Protocols

Quoted 6 lines

Without reviewing patches themselves - we usually prefer to rely on firmware as little as possible. We already have HTTP support, so what is missing in grub that requires what amounts to full re-implementation? Cannot we rather fix our HTTP support instead? This will automatically benefit all supported platforms, of which EFI is just one.

Quoted 2 lines

Nothing wrong in providing firmware based approach in addition to grub's native stack of getting the similar things done.

You cannot both shut off all layered protocols on physical adapter and makes use of these layered protocols. This will need to implement alternative networking stack first.

Quoted 61 lines

And there's no prioity for what has
to be implemented first imho. Occasionally people would prefer firmware based stack because they need new features it provides that haven't been worked out in grub, such as the https or fibre networks, or simply to avoid bug from grub, like the SNP woes among some UEFI box.

Thanks,
Michael

Quoted 43 lines
Quoted 34 lines

Then why two implementations? For older UEFI firmwares (UEFI 2.4 and older), the HTTP(s) APIs are not available. In the case,
Grub can fall back to the software-based implementation.
In the first patch of this patchset, grub-core/net/drivers/efi/efihttp.c:76 to 81 is the code to query if the HTTP Protocol is supported by the UEFI firmware.

This patchset was tested on QEMU+OVMF and it works flawlessly.

The main goals of this RFC is to ask for opinions and suggestion to make the first patch modularized as much as possible.
In the second patch, there is some codes related TCP re-transmission that need to pass by for the HTTP Boot to work.

More details are described in the logs of each patch.

Ken Lin (2):
net: add efihttp to do HTTP(S) Boot by UEFI HTTP Protocol
net: workaround to bypass corruption of the efihttp function pointer

 grub-core/Makefile.core.def         |   1 +
 grub-core/net/bootp.c               |   6 +
 grub-core/net/drivers/efi/efihttp.c | 386 ++++++++++++++++++++++++++++++++++++
 grub-core/net/drivers/efi/efinet.c  |   1 +
 grub-core/net/net.c                 |  39 +++-
 include/grub/efi/api.h              |  17 ++
 include/grub/efi/http.h             | 221 +++++++++++++++++++++
 include/grub/err.h                  |   3 +-
 include/grub/net.h                  |   1 +
 9 files changed, 672 insertions(+), 3 deletions(-)
 create mode 100755 grub-core/net/drivers/efi/efihttp.c
 create mode 100755 include/grub/efi/http.h
Quoted 8 lines

--
2.7.4

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

Quoted 4 lines

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

#9 lore raw
Quoted 22 lines · Andrei Borzenkov
Quoted 21 lines · Michael Chang
Quoted 19 lines · Andrei Borzenkov
Quoted 11 lines · Ken Lin

This RFC patchset is stacked on the previous HTTP boot patchset:
https://lists.gnu.org/archive/html/grub-devel/2016-12/msg00088.html
It re-uses some code from it, e.g. the DCHPACK
with vendor_class_identifier=HTTPClient.

Instead of implementing HTTP and HTTPS boot totally from software, UEFI firmware already defines APIs for HTTP(s).
Please check UEFI spec. 2.5 and plus for the detail:

28.6 EFI HTTP Protocols

Without reviewing patches themselves - we usually prefer to rely on firmware as little as possible. We already have HTTP support, so what is missing in grub that requires what amounts to full re-implementation? Cannot we rather fix our HTTP support instead? This will automatically benefit all supported platforms, of which EFI is just one.

Quoted 6 lines
Quoted 2 lines

Nothing wrong in providing firmware based approach in addition to grub's native stack of getting the similar things done.

You cannot both shut off all layered protocols on physical adapter and makes use of these layered protocols. This will need to implement alternative networking stack first.

They don't have to be runtime switch to operate at the same time. Make them distinct modules, and provid a swith for controlling the image being built. We already have --native switch in grub2-install to incorporate native disk modules rather than firmware's.

Thanks,
Michael

Quoted 67 lines
Quoted 58 lines

And there's no prioity for what has
to be implemented first imho. Occasionally people would prefer firmware based stack because they need new features it provides that haven't been worked out in grub, such as the https or fibre networks, or simply to avoid bug from grub, like the SNP woes among some UEFI box.

Thanks,
Michael

Quoted 43 lines
Quoted 34 lines

Then why two implementations? For older UEFI firmwares (UEFI 2.4 and older), the HTTP(s) APIs are not available. In the case,
Grub can fall back to the software-based implementation.
In the first patch of this patchset, grub-core/net/drivers/efi/efihttp.c:76 to 81 is the code to query if the HTTP Protocol is supported by the UEFI firmware.

This patchset was tested on QEMU+OVMF and it works flawlessly.

The main goals of this RFC is to ask for opinions and suggestion to make the first patch modularized as much as possible.
In the second patch, there is some codes related TCP re-transmission that need to pass by for the HTTP Boot to work.

More details are described in the logs of each patch.

Ken Lin (2):
net: add efihttp to do HTTP(S) Boot by UEFI HTTP Protocol
net: workaround to bypass corruption of the efihttp function pointer

 grub-core/Makefile.core.def         |   1 +
 grub-core/net/bootp.c               |   6 +
 grub-core/net/drivers/efi/efihttp.c | 386 ++++++++++++++++++++++++++++++++++++
 grub-core/net/drivers/efi/efinet.c  |   1 +
 grub-core/net/net.c                 |  39 +++-
 include/grub/efi/api.h              |  17 ++
 include/grub/efi/http.h             | 221 +++++++++++++++++++++
 include/grub/err.h                  |   3 +-
 include/grub/net.h                  |   1 +
 9 files changed, 672 insertions(+), 3 deletions(-)
 create mode 100755 grub-core/net/drivers/efi/efihttp.c
 create mode 100755 include/grub/efi/http.h
Quoted 8 lines

--
2.7.4

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

Quoted 4 lines

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

Quoted 4 lines

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

#10 lore raw
Quoted 26 lines · Michael Chang
Quoted 25 lines · Andrei Borzenkov
Quoted 23 lines · Michael Chang
Quoted 13 lines · Andrei Borzenkov
Quoted 11 lines · Ken Lin

This RFC patchset is stacked on the previous HTTP boot patchset:
https://lists.gnu.org/archive/html/grub-devel/2016-12/msg00088.html
It re-uses some code from it, e.g. the DCHPACK
with vendor_class_identifier=HTTPClient.

Instead of implementing HTTP and HTTPS boot totally from software, UEFI firmware already defines APIs for HTTP(s).
Please check UEFI spec. 2.5 and plus for the detail:

28.6 EFI HTTP Protocols

Quoted 6 lines

Without reviewing patches themselves - we usually prefer to rely on firmware as little as possible. We already have HTTP support, so what is missing in grub that requires what amounts to full re-implementation? Cannot we rather fix our HTTP support instead? This will automatically benefit all supported platforms, of which EFI is just one.

Nothing wrong in providing firmware based approach in addition to grub's native stack of getting the similar things done.

Quoted 9 lines
Quoted 3 lines

You cannot both shut off all layered protocols on physical adapter and makes use of these layered protocols. This will need to implement alternative networking stack first.

They don't have to be runtime switch to operate at the same time. Make them distinct modules, and provid a swith for controlling the image being built. We already have --native switch in grub2-install to incorporate native disk modules rather than firmware's.

These patches hook into network stack of grub. So they either must comply with this stack (which means - provide alternative network driver for reasons I mentioned) or they must pretend "efihttp" is disk.