Accepting request 587448 from Base:System

OBS-URL: https://build.opensuse.org/request/show/587448
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/grub2?expand=0&rev=178
This commit is contained in:
Dominique Leuenberger 2018-03-19 22:30:33 +00:00 committed by Git OBS Bridge
commit e30accbdcf
6 changed files with 278 additions and 164 deletions

View File

@ -3,7 +3,7 @@ From: Michael Chang <mchang@suse.com>
Date: Wed, 22 Feb 2017 14:27:50 +0800 Date: Wed, 22 Feb 2017 14:27:50 +0800
Subject: [PATCH] Support UEFI networking protocols Subject: [PATCH] Support UEFI networking protocols
References: fate#320130, bsc#1015589 References: fate#320130, bsc#1015589, bsc#1076132
Patch-Mainline: no Patch-Mainline: no
V1: V1:
@ -16,13 +16,21 @@ V2:
* Relaxed UEFI Protocol requirement * Relaxed UEFI Protocol requirement
* Support Intel OPA (Omni-Path Architecture) PXE Boot * Support Intel OPA (Omni-Path Architecture) PXE Boot
V3:
* Fix bufio in calculating address of next_buf
* Check HTTP respond code
* Use HEAD request method to test before GET
* Finish HTTP transaction in one go
* Fix bsc#1076132
--- ---
grub-core/Makefile.core.def | 18 + grub-core/Makefile.core.def | 18 +
grub-core/io/bufio.c | 2 +-
grub-core/kern/efi/efi.c | 96 ++- grub-core/kern/efi/efi.c | 96 ++-
grub-core/net/drivers/efi/efinet.c | 27 + grub-core/net/drivers/efi/efinet.c | 27 +
grub-core/net/efi/dhcp.c | 397 ++++++++++ grub-core/net/efi/dhcp.c | 397 ++++++++++
grub-core/net/efi/efi_netfs.c | 57 ++ grub-core/net/efi/efi_netfs.c | 57 ++
grub-core/net/efi/http.c | 360 +++++++++ grub-core/net/efi/http.c | 419 +++++++++++
grub-core/net/efi/ip4_config.c | 398 ++++++++++ grub-core/net/efi/ip4_config.c | 398 ++++++++++
grub-core/net/efi/ip6_config.c | 422 +++++++++++ grub-core/net/efi/ip6_config.c | 422 +++++++++++
grub-core/net/efi/net.c | 1428 ++++++++++++++++++++++++++++++++++++ grub-core/net/efi/net.c | 1428 ++++++++++++++++++++++++++++++++++++
@ -33,7 +41,7 @@ V2:
include/grub/efi/http.h | 215 ++++++ include/grub/efi/http.h | 215 ++++++
include/grub/net/efi.h | 144 ++++ include/grub/net/efi.h | 144 ++++
util/grub-mknetdir.c | 23 +- util/grub-mknetdir.c | 23 +-
16 files changed, 4567 insertions(+), 40 deletions(-) 17 files changed, 4627 insertions(+), 41 deletions(-)
create mode 100644 grub-core/net/efi/dhcp.c create mode 100644 grub-core/net/efi/dhcp.c
create mode 100644 grub-core/net/efi/efi_netfs.c create mode 100644 grub-core/net/efi/efi_netfs.c
create mode 100644 grub-core/net/efi/http.c create mode 100644 grub-core/net/efi/http.c
@ -46,7 +54,7 @@ V2:
create mode 100644 include/grub/net/efi.h create mode 100644 include/grub/net/efi.h
diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def
index a65c27f..e93c772 100644 index a65c27f7f..e93c77255 100644
--- a/grub-core/Makefile.core.def --- a/grub-core/Makefile.core.def
+++ b/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def
@@ -2167,6 +2167,18 @@ module = { @@ -2167,6 +2167,18 @@ module = {
@ -81,8 +89,21 @@ index a65c27f..e93c772 100644
}; };
module = { module = {
diff --git a/grub-core/io/bufio.c b/grub-core/io/bufio.c
index 22438277d..d0b0f71b6 100644
--- a/grub-core/io/bufio.c
+++ b/grub-core/io/bufio.c
@@ -132,7 +132,7 @@ grub_bufio_read (grub_file_t file, char *buf, grub_size_t len)
return res;
/* Need to read some more. */
- next_buf = (file->offset + res + len - 1) & ~((grub_off_t) bufio->block_size - 1);
+ next_buf = (grub_divmod64 (file->offset + res + len - 1, bufio->block_size, NULL)) * bufio->block_size;
/* Now read between file->offset + res and bufio->buffer_at. */
if (file->offset + res < next_buf)
{
diff --git a/grub-core/kern/efi/efi.c b/grub-core/kern/efi/efi.c diff --git a/grub-core/kern/efi/efi.c b/grub-core/kern/efi/efi.c
index d467785..0ceaa48 100644 index d467785fc..0ceaa487c 100644
--- a/grub-core/kern/efi/efi.c --- a/grub-core/kern/efi/efi.c
+++ b/grub-core/kern/efi/efi.c +++ b/grub-core/kern/efi/efi.c
@@ -672,7 +672,7 @@ grub_efi_print_device_path (grub_efi_device_path_t *dp) @@ -672,7 +672,7 @@ grub_efi_print_device_path (grub_efi_device_path_t *dp)
@ -213,7 +234,7 @@ index d467785..0ceaa48 100644
grub_printf ("/UnknownMessaging(%x)", (unsigned) subtype); grub_printf ("/UnknownMessaging(%x)", (unsigned) subtype);
break; break;
diff --git a/grub-core/net/drivers/efi/efinet.c b/grub-core/net/drivers/efi/efinet.c diff --git a/grub-core/net/drivers/efi/efinet.c b/grub-core/net/drivers/efi/efinet.c
index 82a28fb..f189209 100644 index 82a28fb6e..f189209ba 100644
--- a/grub-core/net/drivers/efi/efinet.c --- a/grub-core/net/drivers/efi/efinet.c
+++ b/grub-core/net/drivers/efi/efinet.c +++ b/grub-core/net/drivers/efi/efinet.c
@@ -24,6 +24,7 @@ @@ -24,6 +24,7 @@
@ -286,7 +307,7 @@ index 82a28fb..f189209 100644
diff --git a/grub-core/net/efi/dhcp.c b/grub-core/net/efi/dhcp.c diff --git a/grub-core/net/efi/dhcp.c b/grub-core/net/efi/dhcp.c
new file mode 100644 new file mode 100644
index 0000000..dbef63d index 000000000..dbef63d8c
--- /dev/null --- /dev/null
+++ b/grub-core/net/efi/dhcp.c +++ b/grub-core/net/efi/dhcp.c
@@ -0,0 +1,397 @@ @@ -0,0 +1,397 @@
@ -689,7 +710,7 @@ index 0000000..dbef63d
+grub_command_func_t grub_efi_net_bootp6 = grub_cmd_efi_bootp6; +grub_command_func_t grub_efi_net_bootp6 = grub_cmd_efi_bootp6;
diff --git a/grub-core/net/efi/efi_netfs.c b/grub-core/net/efi/efi_netfs.c diff --git a/grub-core/net/efi/efi_netfs.c b/grub-core/net/efi/efi_netfs.c
new file mode 100644 new file mode 100644
index 0000000..ef371d8 index 000000000..ef371d885
--- /dev/null --- /dev/null
+++ b/grub-core/net/efi/efi_netfs.c +++ b/grub-core/net/efi/efi_netfs.c
@@ -0,0 +1,57 @@ @@ -0,0 +1,57 @@
@ -752,10 +773,10 @@ index 0000000..ef371d8
+} +}
diff --git a/grub-core/net/efi/http.c b/grub-core/net/efi/http.c diff --git a/grub-core/net/efi/http.c b/grub-core/net/efi/http.c
new file mode 100644 new file mode 100644
index 0000000..816a3cd index 000000000..3f61fd2fa
--- /dev/null --- /dev/null
+++ b/grub-core/net/efi/http.c +++ b/grub-core/net/efi/http.c
@@ -0,0 +1,360 @@ @@ -0,0 +1,419 @@
+ +
+#include <grub/efi/api.h> +#include <grub/efi/api.h>
+#include <grub/efi/efi.h> +#include <grub/efi/efi.h>
@ -858,7 +879,8 @@ index 0000000..816a3cd
+ response_callback_done = 1; + response_callback_done = 1;
+} +}
+ +
+struct grub_efi_http_data +static grub_err_t
+efihttp_request (grub_efi_http_t *http, char *server, char *name, int use_https, int headeronly, grub_off_t *file_size)
+{ +{
+ grub_efi_http_request_data_t request_data; + grub_efi_http_request_data_t request_data;
+ grub_efi_http_message_t request_message; + grub_efi_http_message_t request_message;
@ -867,46 +889,34 @@ index 0000000..816a3cd
+ grub_efi_http_message_t response_message; + grub_efi_http_message_t response_message;
+ grub_efi_http_token_t response_token; + grub_efi_http_token_t response_token;
+ grub_efi_http_header_t request_headers[3]; + grub_efi_http_header_t request_headers[3];
+};
+ +
+static grub_err_t
+grub_efihttp_open (struct grub_efi_net_device *dev,
+ int prefer_ip6 __attribute__ ((unused)),
+ grub_file_t file,
+ const char *filename __attribute__ ((unused)),
+ int type)
+{
+ grub_efi_status_t status; + grub_efi_status_t status;
+ grub_uint32_t length, i;
+ grub_efi_boot_services_t *b = grub_efi_system_table->boot_services; + grub_efi_boot_services_t *b = grub_efi_system_table->boot_services;
+ grub_efi_http_t *http = dev->http;
+ char *url = NULL; + char *url = NULL;
+ +
+ struct grub_efi_http_data *data = grub_malloc (sizeof (*data)); + request_headers[0].field_name = (grub_efi_char8_t *)"Host";
+ + request_headers[0].field_value = (grub_efi_char8_t *)server;
+ grub_memset (data, 0, sizeof (*data)); + request_headers[1].field_name = (grub_efi_char8_t *)"Accept";
+ + request_headers[1].field_value = (grub_efi_char8_t *)"*/*";
+ data->request_headers[0].field_name = (grub_efi_char8_t *)"Host"; + request_headers[2].field_name = (grub_efi_char8_t *)"User-Agent";
+ data->request_headers[0].field_value = (grub_efi_char8_t *)file->device->net->server; + request_headers[2].field_value = (grub_efi_char8_t *)"UefiHttpBoot/1.0";
+ data->request_headers[1].field_name = (grub_efi_char8_t *)"Accept";
+ data->request_headers[1].field_value = (grub_efi_char8_t *)"*/*";
+ data->request_headers[2].field_name = (grub_efi_char8_t *)"User-Agent";
+ data->request_headers[2].field_value = (grub_efi_char8_t *)"UefiHttpBoot/1.0";
+ +
+ { + {
+ grub_efi_ipv6_address_t address; + grub_efi_ipv6_address_t address;
+ const char *rest; + const char *rest;
+ grub_efi_char16_t *ucs2_url; + grub_efi_char16_t *ucs2_url;
+ grub_size_t url_len, ucs2_url_len; + grub_size_t url_len, ucs2_url_len;
+ const char *protocol = (type == 1) ? "https" : "http"; + const char *protocol = (use_https == 1) ? "https" : "http";
+ +
+ if (grub_efi_string_to_ip6_address (file->device->net->server, &address, &rest) && *rest == 0) + if (grub_efi_string_to_ip6_address (server, &address, &rest) && *rest == 0)
+ url = grub_xasprintf ("%s://[%s]%s", protocol, file->device->net->server, file->device->net->name); + url = grub_xasprintf ("%s://[%s]%s", protocol, server, name);
+ else + else
+ url = grub_xasprintf ("%s://%s%s", protocol, file->device->net->server, file->device->net->name); + url = grub_xasprintf ("%s://%s%s", protocol, server, name);
+ +
+ if (!url) + if (!url)
+ {
+ return grub_errno; + return grub_errno;
+ }
+ +
+ url_len = grub_strlen (url); + url_len = grub_strlen (url);
+ ucs2_url_len = url_len * GRUB_MAX_UTF16_PER_UTF8; + ucs2_url_len = url_len * GRUB_MAX_UTF16_PER_UTF8;
@ -921,21 +931,21 @@ index 0000000..816a3cd
+ ucs2_url_len = grub_utf8_to_utf16 (ucs2_url, ucs2_url_len, (grub_uint8_t *)url, url_len, NULL); /* convert string format from ascii to usc2 */ + ucs2_url_len = grub_utf8_to_utf16 (ucs2_url, ucs2_url_len, (grub_uint8_t *)url, url_len, NULL); /* convert string format from ascii to usc2 */
+ ucs2_url[ucs2_url_len] = 0; + ucs2_url[ucs2_url_len] = 0;
+ grub_free (url); + grub_free (url);
+ data->request_data.url = ucs2_url; + request_data.url = ucs2_url;
+ } + }
+ +
+ data->request_data.method = GRUB_EFI_HTTPMETHODGET; + request_data.method = (headeronly > 0) ? GRUB_EFI_HTTPMETHODHEAD : GRUB_EFI_HTTPMETHODGET;
+ +
+ data->request_message.data.request = &data->request_data; + request_message.data.request = &request_data;
+ data->request_message.header_count = 3; + request_message.header_count = 3;
+ data->request_message.headers = data->request_headers; + request_message.headers = request_headers;
+ data->request_message.body_length = 0; + request_message.body_length = 0;
+ data->request_message.body = NULL; + request_message.body = NULL;
+ +
+ /* request token */ + /* request token */
+ data->request_token.event = NULL; + request_token.event = NULL;
+ data->request_token.status = GRUB_EFI_NOT_READY; + request_token.status = GRUB_EFI_NOT_READY;
+ data->request_token.message = &data->request_message; + request_token.message = &request_message;
+ +
+ request_callback_done = 0; + request_callback_done = 0;
+ status = efi_call_5 (b->create_event, + status = efi_call_5 (b->create_event,
@ -943,63 +953,63 @@ index 0000000..816a3cd
+ GRUB_EFI_TPL_CALLBACK, + GRUB_EFI_TPL_CALLBACK,
+ grub_efi_http_request_callback, + grub_efi_http_request_callback,
+ NULL, + NULL,
+ &data->request_token.event); + &request_token.event);
+ +
+ if (status != GRUB_EFI_SUCCESS) + if (status != GRUB_EFI_SUCCESS)
+ { + {
+ grub_free (data->request_data.url); + grub_free (request_data.url);
+ return grub_error (GRUB_ERR_IO, "Fail to create an event! status=0x%x\n", status); + return grub_error (GRUB_ERR_IO, "Fail to create an event! status=0x%x\n", status);
+ } + }
+ +
+ status = efi_call_2 (http->request, http, &data->request_token); + status = efi_call_2 (http->request, http, &request_token);
+ +
+ if (status != GRUB_EFI_SUCCESS) + if (status != GRUB_EFI_SUCCESS)
+ { + {
+ efi_call_1 (b->close_event, data->request_token.event); + efi_call_1 (b->close_event, request_token.event);
+ grub_free (data->request_data.url); + grub_free (request_data.url);
+ return grub_error (GRUB_ERR_IO, "Fail to send a request! status=0x%x\n", status); + return grub_error (GRUB_ERR_IO, "Fail to send a request! status=0x%x\n", status);
+ } + }
+ /* TODO: Add Timeout */ + /* TODO: Add Timeout */
+ while (!request_callback_done) + while (!request_callback_done)
+ efi_call_1(http->poll, http); + efi_call_1(http->poll, http);
+ +
+ data->response_data.status_code = GRUB_EFI_HTTP_STATUS_UNSUPPORTED_STATUS; + response_data.status_code = GRUB_EFI_HTTP_STATUS_UNSUPPORTED_STATUS;
+ data->response_message.data.response = &data->response_data; + response_message.data.response = &response_data;
+ /* herader_count will be updated by the HTTP driver on response */ + /* herader_count will be updated by the HTTP driver on response */
+ data->response_message.header_count = 0; + response_message.header_count = 0;
+ /* headers will be populated by the driver on response */ + /* headers will be populated by the driver on response */
+ data->response_message.headers = NULL; + response_message.headers = NULL;
+ /* use zero BodyLength to only receive the response headers */ + /* use zero BodyLength to only receive the response headers */
+ data->response_message.body_length = 0; + response_message.body_length = 0;
+ data->response_message.body = NULL; + response_message.body = NULL;
+ data->response_token.event = NULL; + response_token.event = NULL;
+ +
+ status = efi_call_5 (b->create_event, + status = efi_call_5 (b->create_event,
+ GRUB_EFI_EVT_NOTIFY_SIGNAL, + GRUB_EFI_EVT_NOTIFY_SIGNAL,
+ GRUB_EFI_TPL_CALLBACK, + GRUB_EFI_TPL_CALLBACK,
+ grub_efi_http_response_callback, + grub_efi_http_response_callback,
+ NULL, + NULL,
+ &data->response_token.event); + &response_token.event);
+ +
+ if (status != GRUB_EFI_SUCCESS) + if (status != GRUB_EFI_SUCCESS)
+ { + {
+ efi_call_1 (b->close_event, data->request_token.event); + efi_call_1 (b->close_event, request_token.event);
+ grub_free (data->request_data.url); + grub_free (request_data.url);
+ return grub_error (GRUB_ERR_IO, "Fail to create an event! status=0x%x\n", status); + return grub_error (GRUB_ERR_IO, "Fail to create an event! status=0x%x\n", status);
+ } + }
+ +
+ data->response_token.status = GRUB_EFI_SUCCESS; + response_token.status = GRUB_EFI_SUCCESS;
+ data->response_token.message = &data->response_message; + response_token.message = &response_message;
+ +
+ /* wait for HTTP response */ + /* wait for HTTP response */
+ response_callback_done = 0; + response_callback_done = 0;
+ status = efi_call_2 (http->response, http, &data->response_token); + status = efi_call_2 (http->response, http, &response_token);
+ +
+ if (status != GRUB_EFI_SUCCESS) + if (status != GRUB_EFI_SUCCESS)
+ { + {
+ efi_call_1 (b->close_event, data->response_token.event); + efi_call_1 (b->close_event, response_token.event);
+ efi_call_1 (b->close_event, data->request_token.event); + efi_call_1 (b->close_event, request_token.event);
+ grub_free (data->request_data.url); + grub_free (request_data.url);
+ return grub_error (GRUB_ERR_IO, "Fail to receive a response! status=%d\n", (int)status); + return grub_error (GRUB_ERR_IO, "Fail to receive a response! status=%d\n", (int)status);
+ } + }
+ +
@ -1007,33 +1017,136 @@ index 0000000..816a3cd
+ while (!response_callback_done) + while (!response_callback_done)
+ efi_call_1 (http->poll, http); + efi_call_1 (http->poll, http);
+ +
+ /* check the HTTP status code */ + if (response_message.data.response->status_code != GRUB_EFI_HTTP_STATUS_200_OK)
+ {
+ grub_efi_http_status_code_t status_code = response_message.data.response->status_code;
+
+ if (response_message.headers)
+ efi_call_1 (b->free_pool, response_message.headers);
+ efi_call_1 (b->close_event, response_token.event);
+ efi_call_1 (b->close_event, request_token.event);
+ grub_free (request_data.url);
+ if (status_code == GRUB_EFI_HTTP_STATUS_404_NOT_FOUND)
+ {
+ return grub_error (GRUB_ERR_FILE_NOT_FOUND, _("file `%s' not found"), name);
+ }
+ else
+ {
+ return grub_error (GRUB_ERR_NET_UNKNOWN_ERROR,
+ _("unsupported uefi http status code 0x%x"), status_code);
+ }
+ }
+
+ if (file_size)
+ {
+ int i;
+ /* parse the length of the file from the ContentLength header */ + /* parse the length of the file from the ContentLength header */
+ for (length = 0, i = 0; i < data->response_message.header_count; ++i) + for (*file_size = 0, i = 0; i < (int)response_message.header_count; ++i)
+ { + {
+ if (!grub_strcmp((const char*)data->response_message.headers[i].field_name, "Content-Length")) + if (!grub_strcmp((const char*)response_message.headers[i].field_name, "Content-Length"))
+ { + {
+ length = grub_strtoul((const char*)data->response_message.headers[i].field_value, 0, 10); + *file_size = grub_strtoul((const char*)response_message.headers[i].field_value, 0, 10);
+ break; + break;
+ } + }
+ } + }
+ }
+ +
+ file->size = (grub_off_t)length; + if (response_message.headers)
+ efi_call_1 (b->free_pool, response_message.headers);
+ efi_call_1 (b->close_event, response_token.event);
+ efi_call_1 (b->close_event, request_token.event);
+ grub_free (request_data.url);
+
+ return GRUB_ERR_NONE;
+}
+
+static grub_ssize_t
+efihttp_read (struct grub_efi_net_device *dev,
+ char *buf,
+ grub_size_t len)
+{
+ grub_efi_http_message_t response_message;
+ grub_efi_http_token_t response_token;
+
+ grub_efi_status_t status;
+ grub_size_t sum = 0;
+ grub_efi_boot_services_t *b = grub_efi_system_table->boot_services;
+ grub_efi_http_t *http = dev->http;
+
+ if (!len)
+ {
+ grub_error (GRUB_ERR_BUG, "Invalid arguments to EFI HTTP Read");
+ return -1;
+ }
+
+ efi_call_5 (b->create_event,
+ GRUB_EFI_EVT_NOTIFY_SIGNAL,
+ GRUB_EFI_TPL_CALLBACK,
+ grub_efi_http_response_callback,
+ NULL,
+ &response_token.event);
+
+ while (len)
+ {
+ response_message.data.response = NULL;
+ response_message.header_count = 0;
+ response_message.headers = NULL;
+ response_message.body_length = len;
+ response_message.body = buf;
+
+ response_token.message = &response_message;
+ response_token.status = GRUB_EFI_NOT_READY;
+
+ response_callback_done = 0;
+
+ status = efi_call_2 (http->response, http, &response_token);
+ if (status != GRUB_EFI_SUCCESS)
+ {
+ efi_call_1 (b->close_event, response_token.event);
+ grub_error (GRUB_ERR_IO, "Error! status=%d\n", (int)status);
+ return -1;
+ }
+
+ while (!response_callback_done)
+ efi_call_1(http->poll, http);
+
+ sum += response_message.body_length;
+ buf += response_message.body_length;
+ len -= response_message.body_length;
+ }
+
+ efi_call_1 (b->close_event, response_token.event);
+
+ return sum;
+}
+
+static grub_err_t
+grub_efihttp_open (struct grub_efi_net_device *dev,
+ int prefer_ip6 __attribute__ ((unused)),
+ grub_file_t file,
+ const char *filename __attribute__ ((unused)),
+ int type)
+{
+ grub_err_t err;
+ grub_off_t size;
+ char *buf;
+
+ err = efihttp_request (dev->http, file->device->net->server, file->device->net->name, type, 1, 0);
+ if (err != GRUB_ERR_NONE)
+ return err;
+
+ err = efihttp_request (dev->http, file->device->net->server, file->device->net->name, type, 0, &size);
+ if (err != GRUB_ERR_NONE)
+ return err;
+
+ buf = grub_malloc (size);
+ efihttp_read (dev, buf, size);
+
+ file->size = size;
+ file->data = buf;
+ file->not_easily_seekable = 0; + file->not_easily_seekable = 0;
+ file->data = data;
+ file->device->net->offset = 0; + file->device->net->offset = 0;
+ +
+ /* release */
+ /* On response, this array is allocated and
+ populated by the HTTP driver. It is the responsibility of the caller
+ to free this memory on both request and response. */
+ if (data->response_message.headers)
+ efi_call_1 (b->free_pool, data->response_message.headers);
+
+ efi_call_1 (b->close_event, data->response_token.event);
+ efi_call_1 (b->close_event, data->request_token.event);
+ grub_free (data->request_data.url);
+
+ return GRUB_ERR_NONE; + return GRUB_ERR_NONE;
+} +}
+ +
@ -1042,71 +1155,38 @@ index 0000000..816a3cd
+ int prefer_ip6 __attribute__ ((unused)), + int prefer_ip6 __attribute__ ((unused)),
+ grub_file_t file) + grub_file_t file)
+{ +{
+ struct grub_efi_http_data *data = file->data; + if (file->data)
+ + grub_free (file->data);
+ if (data)
+ grub_free (data);
+ +
+ file->data = 0; + file->data = 0;
+ file->offset = 0; + file->offset = 0;
+ file->size = 0;
+ file->device->net->offset = 0; + file->device->net->offset = 0;
+ return GRUB_ERR_NONE; + return GRUB_ERR_NONE;
+} +}
+ +
+static grub_ssize_t +static grub_ssize_t
+grub_efihttp_read (struct grub_efi_net_device *dev, +grub_efihttp_read (struct grub_efi_net_device *dev __attribute__((unused)),
+ int prefer_ip6 __attribute__((unused)), + int prefer_ip6 __attribute__((unused)),
+ grub_file_t file, + grub_file_t file,
+ char *buf, + char *buf,
+ grub_size_t len) + grub_size_t len)
+{ +{
+ grub_efi_status_t status; + grub_size_t r = len;
+ grub_size_t sum = 0;
+ grub_efi_boot_services_t *b = grub_efi_system_table->boot_services;
+ grub_efi_http_t *http = dev->http;
+ struct grub_efi_http_data *data = file->data;
+ +
+ grub_memset (data, 0, sizeof (*data)); + if (!file->data || !buf || !len)
+ efi_call_5 (b->create_event, + return 0;
+ GRUB_EFI_EVT_NOTIFY_SIGNAL,
+ GRUB_EFI_TPL_CALLBACK,
+ grub_efi_http_response_callback,
+ NULL,
+ &data->response_token.event);
+ +
+ while (len) + if ((file->device->net->offset + len) > file->size)
+ r = file->size - file->device->net->offset;
+
+ if (r)
+ { + {
+ data->response_message.data.response = NULL; + grub_memcpy (buf, (char *)file->data + file->device->net->offset, r);
+ data->response_message.header_count = 0; + file->device->net->offset += r;
+ data->response_message.headers = NULL;
+ data->response_message.body_length = len;
+ data->response_message.body = buf;
+
+ data->response_token.message = &data->response_message;
+ data->response_token.status = GRUB_EFI_NOT_READY;
+
+ response_callback_done = 0;
+
+ status = efi_call_2 (http->response, http, &data->response_token);
+ if (status != GRUB_EFI_SUCCESS)
+ {
+ efi_call_1 (b->close_event, data->response_token.event);
+ grub_error (GRUB_ERR_IO, "Error! status=%d\n", (int)status);
+ return -1;
+ } + }
+ +
+ while (!response_callback_done) + return r;
+ efi_call_1(http->poll, http);
+
+ file->device->net->offset += data->response_message.body_length;
+ sum += data->response_message.body_length;
+ buf += data->response_message.body_length;
+ len -= data->response_message.body_length;
+ }
+
+ efi_call_1 (b->close_event, data->response_token.event);
+
+ return sum;
+} +}
+ +
+struct grub_efi_net_io io_http = +struct grub_efi_net_io io_http =
@ -1118,7 +1198,7 @@ index 0000000..816a3cd
+ }; + };
diff --git a/grub-core/net/efi/ip4_config.c b/grub-core/net/efi/ip4_config.c diff --git a/grub-core/net/efi/ip4_config.c b/grub-core/net/efi/ip4_config.c
new file mode 100644 new file mode 100644
index 0000000..b711a5d index 000000000..b711a5d94
--- /dev/null --- /dev/null
+++ b/grub-core/net/efi/ip4_config.c +++ b/grub-core/net/efi/ip4_config.c
@@ -0,0 +1,398 @@ @@ -0,0 +1,398 @@
@ -1522,7 +1602,7 @@ index 0000000..b711a5d
+ }; + };
diff --git a/grub-core/net/efi/ip6_config.c b/grub-core/net/efi/ip6_config.c diff --git a/grub-core/net/efi/ip6_config.c b/grub-core/net/efi/ip6_config.c
new file mode 100644 new file mode 100644
index 0000000..017c4d0 index 000000000..017c4d05b
--- /dev/null --- /dev/null
+++ b/grub-core/net/efi/ip6_config.c +++ b/grub-core/net/efi/ip6_config.c
@@ -0,0 +1,422 @@ @@ -0,0 +1,422 @@
@ -1950,7 +2030,7 @@ index 0000000..017c4d0
+ }; + };
diff --git a/grub-core/net/efi/net.c b/grub-core/net/efi/net.c diff --git a/grub-core/net/efi/net.c b/grub-core/net/efi/net.c
new file mode 100644 new file mode 100644
index 0000000..0bac343 index 000000000..0bac343b4
--- /dev/null --- /dev/null
+++ b/grub-core/net/efi/net.c +++ b/grub-core/net/efi/net.c
@@ -0,0 +1,1428 @@ @@ -0,0 +1,1428 @@
@ -3384,7 +3464,7 @@ index 0000000..0bac343
+} +}
diff --git a/grub-core/net/efi/pxe.c b/grub-core/net/efi/pxe.c diff --git a/grub-core/net/efi/pxe.c b/grub-core/net/efi/pxe.c
new file mode 100644 new file mode 100644
index 0000000..4b6b48c index 000000000..4b6b48cb1
--- /dev/null --- /dev/null
+++ b/grub-core/net/efi/pxe.c +++ b/grub-core/net/efi/pxe.c
@@ -0,0 +1,424 @@ @@ -0,0 +1,424 @@
@ -3813,7 +3893,7 @@ index 0000000..4b6b48c
+ }; + };
+ +
diff --git a/grub-core/net/net.c b/grub-core/net/net.c diff --git a/grub-core/net/net.c b/grub-core/net/net.c
index 5cc0d2f..02bbe95 100644 index 5cc0d2f3b..02bbe956b 100644
--- a/grub-core/net/net.c --- a/grub-core/net/net.c
+++ b/grub-core/net/net.c +++ b/grub-core/net/net.c
@@ -32,6 +32,9 @@ @@ -32,6 +32,9 @@
@ -3923,7 +4003,7 @@ index 5cc0d2f..02bbe95 100644
+#endif +#endif
} }
diff --git a/include/grub/efi/api.h b/include/grub/efi/api.h diff --git a/include/grub/efi/api.h b/include/grub/efi/api.h
index 99ba068..cfedd78 100644 index 99ba068e3..cfedd7895 100644
--- a/include/grub/efi/api.h --- a/include/grub/efi/api.h
+++ b/include/grub/efi/api.h +++ b/include/grub/efi/api.h
@@ -588,6 +588,23 @@ typedef grub_uint16_t grub_efi_ipv6_address_t[8]; @@ -588,6 +588,23 @@ typedef grub_uint16_t grub_efi_ipv6_address_t[8];
@ -4175,7 +4255,7 @@ index 99ba068..cfedd78 100644
diff --git a/include/grub/efi/dhcp.h b/include/grub/efi/dhcp.h diff --git a/include/grub/efi/dhcp.h b/include/grub/efi/dhcp.h
new file mode 100644 new file mode 100644
index 0000000..fdb88eb index 000000000..fdb88eb81
--- /dev/null --- /dev/null
+++ b/include/grub/efi/dhcp.h +++ b/include/grub/efi/dhcp.h
@@ -0,0 +1,343 @@ @@ -0,0 +1,343 @@
@ -4524,7 +4604,7 @@ index 0000000..fdb88eb
+#endif /* ! GRUB_EFI_DHCP_HEADER */ +#endif /* ! GRUB_EFI_DHCP_HEADER */
diff --git a/include/grub/efi/http.h b/include/grub/efi/http.h diff --git a/include/grub/efi/http.h b/include/grub/efi/http.h
new file mode 100644 new file mode 100644
index 0000000..c5e9a89 index 000000000..c5e9a89f5
--- /dev/null --- /dev/null
+++ b/include/grub/efi/http.h +++ b/include/grub/efi/http.h
@@ -0,0 +1,215 @@ @@ -0,0 +1,215 @@
@ -4745,7 +4825,7 @@ index 0000000..c5e9a89
+#endif /* !GRUB_EFI_HTTP_HEADER */ +#endif /* !GRUB_EFI_HTTP_HEADER */
diff --git a/include/grub/net/efi.h b/include/grub/net/efi.h diff --git a/include/grub/net/efi.h b/include/grub/net/efi.h
new file mode 100644 new file mode 100644
index 0000000..de90d22 index 000000000..de90d223e
--- /dev/null --- /dev/null
+++ b/include/grub/net/efi.h +++ b/include/grub/net/efi.h
@@ -0,0 +1,144 @@ @@ -0,0 +1,144 @@
@ -4894,7 +4974,7 @@ index 0000000..de90d22
+ +
+#endif /* ! GRUB_NET_EFI_HEADER */ +#endif /* ! GRUB_NET_EFI_HEADER */
diff --git a/util/grub-mknetdir.c b/util/grub-mknetdir.c diff --git a/util/grub-mknetdir.c b/util/grub-mknetdir.c
index 82073d5..ae31271 100644 index 82073d5cc..ae31271bb 100644
--- a/util/grub-mknetdir.c --- a/util/grub-mknetdir.c
+++ b/util/grub-mknetdir.c +++ b/util/grub-mknetdir.c
@@ -32,13 +32,15 @@ @@ -32,13 +32,15 @@
@ -4976,5 +5056,5 @@ index 82073d5..ae31271 100644
if (!grub_install_source_directory) if (!grub_install_source_directory)
{ {
-- --
2.6.2 2.13.6

View File

@ -1,8 +1,8 @@
Index: grub-2.02~beta2/grub-core/fs/btrfs.c Index: grub-2.02/grub-core/fs/btrfs.c
=================================================================== ===================================================================
--- grub-2.02~beta2.orig/grub-core/fs/btrfs.c --- grub-2.02.orig/grub-core/fs/btrfs.c
+++ grub-2.02~beta2/grub-core/fs/btrfs.c +++ grub-2.02/grub-core/fs/btrfs.c
@@ -2439,6 +2439,238 @@ out: @@ -2446,6 +2446,242 @@ out:
return 0; return 0;
} }
@ -198,6 +198,10 @@ Index: grub-2.02~beta2/grub-core/fs/btrfs.c
+ } + }
+ +
+ id = subvolid; + id = subvolid;
+
+ if (id == GRUB_BTRFS_ROOT_VOL_OBJECTID)
+ subvol = grub_strdup ("");
+ else
+ while (id != GRUB_BTRFS_ROOT_VOL_OBJECTID) + while (id != GRUB_BTRFS_ROOT_VOL_OBJECTID)
+ { + {
+ grub_uint64_t parent_id; + grub_uint64_t parent_id;
@ -241,7 +245,7 @@ Index: grub-2.02~beta2/grub-core/fs/btrfs.c
static struct grub_fs grub_btrfs_fs = { static struct grub_fs grub_btrfs_fs = {
.name = "btrfs", .name = "btrfs",
.dir = grub_btrfs_dir, .dir = grub_btrfs_dir,
@@ -2457,6 +2689,7 @@ static struct grub_fs grub_btrfs_fs = { @@ -2464,6 +2700,7 @@ static struct grub_fs grub_btrfs_fs = {
static grub_command_t cmd_info; static grub_command_t cmd_info;
static grub_command_t cmd_mount_subvol; static grub_command_t cmd_mount_subvol;
static grub_extcmd_t cmd_list_subvols; static grub_extcmd_t cmd_list_subvols;
@ -249,7 +253,7 @@ Index: grub-2.02~beta2/grub-core/fs/btrfs.c
static char * static char *
subvolid_set_env (struct grub_env_var *var __attribute__ ((unused)), subvolid_set_env (struct grub_env_var *var __attribute__ ((unused)),
@@ -2527,6 +2760,11 @@ GRUB_MOD_INIT (btrfs) @@ -2534,6 +2771,11 @@ GRUB_MOD_INIT (btrfs)
"[-p|-n] [-o var] DEVICE", "[-p|-n] [-o var] DEVICE",
"Print list of BtrFS subvolumes on " "Print list of BtrFS subvolumes on "
"DEVICE.", options); "DEVICE.", options);

View File

@ -1,7 +1,12 @@
Index: grub-2.02~rc2/grub-core/kern/fs.c GRUB cannot write Btrfs file systems from the bootloader, so it cannot
modify values set from userspace (e.g. "next_entry" set by grub2-once).
As a workaround use the Btrfs header to store known data of the GRUB environment
block.
---
Index: grub-2.02/grub-core/kern/fs.c
=================================================================== ===================================================================
--- grub-2.02~rc2.orig/grub-core/kern/fs.c --- grub-2.02.orig/grub-core/kern/fs.c
+++ grub-2.02~rc2/grub-core/kern/fs.c +++ grub-2.02/grub-core/kern/fs.c
@@ -27,6 +27,7 @@ @@ -27,6 +27,7 @@
#include <grub/mm.h> #include <grub/mm.h>
#include <grub/term.h> #include <grub/term.h>
@ -24,10 +29,10 @@ Index: grub-2.02~rc2/grub-core/kern/fs.c
ret += size; ret += size;
len -= size; len -= size;
sector -= ((size + offset) >> GRUB_DISK_SECTOR_BITS); sector -= ((size + offset) >> GRUB_DISK_SECTOR_BITS);
Index: grub-2.02~rc2/util/grub-editenv.c Index: grub-2.02/util/grub-editenv.c
=================================================================== ===================================================================
--- grub-2.02~rc2.orig/util/grub-editenv.c --- grub-2.02.orig/util/grub-editenv.c
+++ grub-2.02~rc2/util/grub-editenv.c +++ grub-2.02/util/grub-editenv.c
@@ -23,8 +23,11 @@ @@ -23,8 +23,11 @@
#include <grub/util/misc.h> #include <grub/util/misc.h>
#include <grub/lib/envblk.h> #include <grub/lib/envblk.h>
@ -239,13 +244,14 @@ Index: grub-2.02~rc2/util/grub-editenv.c
set_variables (const char *name, int argc, char *argv[]) set_variables (const char *name, int argc, char *argv[])
{ {
grub_envblk_t envblk; grub_envblk_t envblk;
@@ -217,8 +393,26 @@ set_variables (const char *name, int arg @@ -217,8 +393,27 @@ set_variables (const char *name, int arg
*(p++) = 0; *(p++) = 0;
- if (! grub_envblk_set (envblk, argv[0], p)) - if (! grub_envblk_set (envblk, argv[0], p))
- grub_util_error ("%s", _("environment block too small")); - grub_util_error ("%s", _("environment block too small"));
+ if (strcmp (argv[0], "next_entry") == 0 && fs_envblk) + if ((strcmp (argv[0], "next_entry") == 0 ||
+ strcmp (argv[0], "health_checker_flag") == 0) && fs_envblk)
+ { + {
+ grub_envblk_t envblk_fs; + grub_envblk_t envblk_fs;
+ envblk_fs = open_envblk_fs (envblk); + envblk_fs = open_envblk_fs (envblk);
@ -268,7 +274,7 @@ Index: grub-2.02~rc2/util/grub-editenv.c
argc--; argc--;
argv++; argv++;
@@ -226,26 +420,158 @@ set_variables (const char *name, int arg @@ -226,26 +421,158 @@ set_variables (const char *name, int arg
write_envblk (name, envblk); write_envblk (name, envblk);
grub_envblk_close (envblk); grub_envblk_close (envblk);
@ -427,7 +433,7 @@ Index: grub-2.02~rc2/util/grub-editenv.c
int int
main (int argc, char *argv[]) main (int argc, char *argv[])
{ {
@@ -277,6 +603,9 @@ main (int argc, char *argv[]) @@ -277,6 +604,9 @@ main (int argc, char *argv[])
command = argv[curindex++]; command = argv[curindex++];
} }
@ -437,10 +443,10 @@ Index: grub-2.02~rc2/util/grub-editenv.c
if (strcmp (command, "create") == 0) if (strcmp (command, "create") == 0)
grub_util_create_envblk_file (filename); grub_util_create_envblk_file (filename);
else if (strcmp (command, "list") == 0) else if (strcmp (command, "list") == 0)
Index: grub-2.02~rc2/util/grub.d/00_header.in Index: grub-2.02/util/grub.d/00_header.in
=================================================================== ===================================================================
--- grub-2.02~rc2.orig/util/grub.d/00_header.in --- grub-2.02.orig/util/grub.d/00_header.in
+++ grub-2.02~rc2/util/grub.d/00_header.in +++ grub-2.02/util/grub.d/00_header.in
@@ -46,6 +46,11 @@ cat << EOF @@ -46,6 +46,11 @@ cat << EOF
if [ -s \$prefix/grubenv ]; then if [ -s \$prefix/grubenv ]; then
load_env load_env

View File

@ -4,6 +4,8 @@ insmod search
insmod configfile insmod configfile
insmod legacy_configfile insmod legacy_configfile
insmod lvm insmod lvm
insmod mdraid09
insmod mdraid1x
set debian_cddev="" set debian_cddev=""
set debian_cdarch="" set debian_cdarch=""

View File

@ -1,3 +1,25 @@
-------------------------------------------------------------------
Mon Mar 12 07:31:10 UTC 2018 - mchang@suse.com
- Fix UEFI HTTPS Boot from ISO installation image (bsc#1076132)
* 0001-add-support-for-UEFI-network-protocols.patch
-------------------------------------------------------------------
Tue Mar 6 08:21:43 UTC 2018 - mchang@suse.com
- fix wrong command output when default subvolume is toplevel tree with
id 5 (bsc#1078775)
* grub2-btrfs-09-get-default-subvolume.patch
- insert mdraid modules to support software RAID (bsc#1078775)
* grub2-xen-pv-firmware.cfg
-------------------------------------------------------------------
Thu Mar 1 18:36:33 UTC 2018 - iforster@suse.com
- Rename grub2-btrfs-workaround-grub2-once.patch to
grub2-grubenv-in-btrfs-header.patch
- Store GRUB environment variable health_checker_flag in Btrfs header
------------------------------------------------------------------- -------------------------------------------------------------------
Tue Feb 13 09:05:45 UTC 2018 - mchang@suse.com Tue Feb 13 09:05:45 UTC 2018 - mchang@suse.com

View File

@ -197,7 +197,7 @@ Patch58: grub2-xen-linux16.patch
Patch59: grub2-efi-disable-video-cirrus-and-bochus.patch Patch59: grub2-efi-disable-video-cirrus-and-bochus.patch
Patch60: grub2-editenv-add-warning-message.patch Patch60: grub2-editenv-add-warning-message.patch
Patch61: grub2-vbe-blacklist-preferred-1440x900x32.patch Patch61: grub2-vbe-blacklist-preferred-1440x900x32.patch
Patch64: grub2-btrfs-workaround-grub2-once.patch Patch64: grub2-grubenv-in-btrfs-header.patch
Patch65: grub2-mkconfig-aarch64.patch Patch65: grub2-mkconfig-aarch64.patch
Patch70: grub2-default-distributor.patch Patch70: grub2-default-distributor.patch
Patch71: grub2-menu-unrestricted.patch Patch71: grub2-menu-unrestricted.patch