mirror of
https://codeberg.org/canoeboot/cbmk.git
synced 2024-11-22 10:14:44 +00:00
8d6376e61e
Of note: upstream has made several improvements to memory management, and several fixes to file systems. User-friendly change to LUKS: if the passphrase input failed, the user is prompted again for the correct passphrase, instead of GRUB just failing. Similar to cryptsetup luksOpen behaviour under Linux. This pulls in the following changes from upstream (gnu.org): * b53ec06a1 util/grub-mkrescue: Check existence of option arguments * ab9fe8030 loader/efi/fdt: Add fdtdump command to access device tree * 0cfec355d osdep/devmapper/getroot: Unmark 2 strings for translation * f171122f0 loader/emu/linux: Fix determination of program name * 828717833 disk/cryptodisk: Fix translatable message * 9a2134a70 tests: Add test for ZFS zstd * f96df6fe9 fs/zfs/zfs: Add support for zstd compression * 55d35d628 kern/efi/mm: Detect calls to grub_efi_drop_alloc() with wrong page counts * 61f1d0a61 kern/efi/mm: Change grub_efi_allocate_pages_real() to call semantically correct free function * dc0a3a27d kern/efi/mm: Change grub_efi_mm_add_regions() to keep track of map allocation size * b990df0be tests/util/grub-fs-tester: Fix EROFS label tests in grub-fs-tester * d41c64811 tests: Switch to requiring exfatprogs from exfat-utils * c1ee4da6a tests/util/grub-shell-luks-tester: Fix detached header test getting wrong header path * c22e052fe tests/util/grub-shell: Add flexibility in QEMU firmware handling * d2fc9dfcd tests/util/grub-shell: Use pflash instead of -bios to load UEFI firmware * 88a7e64c2 tests/util/grub-shell: Print gdbinfo if on EFI platform * b8d29f114 configure: Add Debian/Ubuntu DejaVu font path * 13b315c0a term/ns8250-spcr: Add one more 16550 debug type * 8abec8e15 loader/i386/multiboot_mbi: Fix handling of errors in broken aout-kludge * d35ff2251 net/drivers/ieee1275/ofnet: Remove 200 ms timeout in get_card_packet() to reduce input latency * 86df79275 commands/efi/tpm: Re-enable measurements on confidential computing platforms * 0b4d01794 util/grub-mkpasswd-pbkdf2: Simplify the main function implementation * fa36f6376 kern/ieee1275/init: Add IEEE 1275 Radix support for KVM on Power * c464f1ec3 fs/zfs/zfs: Mark vdev_zaps_v2 and head_errlog as supported * 2ffc14ba9 types: Add missing casts in compile-time byteswaps * c6ac49120 font: Add Fedora-specific font paths * 5e8989e4e fs/bfs: Fix improper grub_free() on non-existing files * c806e4dc8 io/gzio: Properly init a table * 243682baa io/gzio: Abort early when get_byte() reads nothing * bb65d81fe cli_lock: Add build option to block command line interface * 56e58828c fs/erofs: Add tests for EROFS in grub-fs-tester * 9d603061a fs/erofs: Add support for the EROFS * 1ba39de62 safemath: Add ALIGN_UP_OVF() which checks for an overflow * d291449ba docs: Fix spelling mistakes * 6cc2e4481 util/grub.d/00_header.in: Quote background image pathname in output * f456add5f disk/lvm: GRUB fails to detect LVM volumes due to an incorrect computation of mda_end * 386b59ddb disk/cryptodisk: Allow user to retry failed passphrase * 99b4c0c38 disk/mdraid1x_linux: Prevent infinite recursion * b272ed230 efi: Fix stack protector issues * 6744840b1 build: Track explicit module dependencies in Makefile.core.def Signed-off-by: Leah Rowe <leah@libreboot.org>
246 lines
8.6 KiB
Diff
246 lines
8.6 KiB
Diff
From 3273128b6dc6df83ef6b1d54d009a1ae26844bff Mon Sep 17 00:00:00 2001
|
|
From: Patrick Rudolph <patrick.rudolph@9elements.com>
|
|
Date: Sun, 15 Nov 2020 19:00:27 +0100
|
|
Subject: [PATCH 14/22] grub-core/bus/usb: Parse SuperSpeed companion
|
|
descriptors
|
|
|
|
Parse the SS_ENDPOINT_COMPANION descriptor, which is only present on USB 3.0
|
|
capable devices and xHCI controllers. Make the descendp an array of pointers
|
|
to the endpoint descriptor as it's no longer an continous array.
|
|
|
|
Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com>
|
|
---
|
|
grub-core/bus/usb/serial/common.c | 2 +-
|
|
grub-core/bus/usb/usb.c | 44 +++++++++++++++++++------------
|
|
grub-core/bus/usb/usbhub.c | 22 ++++++++++++----
|
|
grub-core/commands/usbtest.c | 2 +-
|
|
grub-core/disk/usbms.c | 2 +-
|
|
grub-core/term/usb_keyboard.c | 2 +-
|
|
include/grub/usb.h | 2 +-
|
|
include/grub/usbdesc.h | 11 +++++++-
|
|
8 files changed, 59 insertions(+), 28 deletions(-)
|
|
|
|
diff --git a/grub-core/bus/usb/serial/common.c b/grub-core/bus/usb/serial/common.c
|
|
index e9c995a0a..fc847d66d 100644
|
|
--- a/grub-core/bus/usb/serial/common.c
|
|
+++ b/grub-core/bus/usb/serial/common.c
|
|
@@ -72,7 +72,7 @@ grub_usbserial_attach (grub_usb_device_t usbdev, int configno, int interfno,
|
|
for (j = 0; j < interf->endpointcnt; j++)
|
|
{
|
|
struct grub_usb_desc_endp *endp;
|
|
- endp = &usbdev->config[0].interf[interfno].descendp[j];
|
|
+ endp = usbdev->config[0].interf[interfno].descendp[j];
|
|
|
|
if ((endp->endp_addr & 128) && (endp->attrib & 3) == 2
|
|
&& (in_endp == GRUB_USB_SERIAL_ENDPOINT_LAST_MATCHING
|
|
diff --git a/grub-core/bus/usb/usb.c b/grub-core/bus/usb/usb.c
|
|
index 7bd49d201..e578af793 100644
|
|
--- a/grub-core/bus/usb/usb.c
|
|
+++ b/grub-core/bus/usb/usb.c
|
|
@@ -118,7 +118,7 @@ grub_usb_device_initialize (grub_usb_device_t dev)
|
|
struct grub_usb_desc_device *descdev;
|
|
struct grub_usb_desc_config config;
|
|
grub_usb_err_t err;
|
|
- int i;
|
|
+ int i, j;
|
|
|
|
/* First we have to read first 8 bytes only and determine
|
|
* max. size of packet */
|
|
@@ -152,6 +152,7 @@ grub_usb_device_initialize (grub_usb_device_t dev)
|
|
int currif;
|
|
char *data;
|
|
struct grub_usb_desc *desc;
|
|
+ struct grub_usb_desc_endp *endp;
|
|
|
|
/* First just read the first 4 bytes of the configuration
|
|
descriptor, after that it is known how many bytes really have
|
|
@@ -201,24 +202,27 @@ grub_usb_device_initialize (grub_usb_device_t dev)
|
|
= (struct grub_usb_desc_if *) &data[pos];
|
|
pos += dev->config[i].interf[currif].descif->length;
|
|
|
|
+ dev->config[i].interf[currif].descendp = grub_malloc (
|
|
+ dev->config[i].interf[currif].descif->endpointcnt *
|
|
+ sizeof(struct grub_usb_desc_endp));
|
|
+
|
|
+ j = 0;
|
|
while (pos < config.totallen)
|
|
{
|
|
desc = (struct grub_usb_desc *)&data[pos];
|
|
- if (desc->type == GRUB_USB_DESCRIPTOR_ENDPOINT)
|
|
- break;
|
|
- if (!desc->length)
|
|
- {
|
|
- err = GRUB_USB_ERR_BADDEVICE;
|
|
- goto fail;
|
|
- }
|
|
- pos += desc->length;
|
|
- }
|
|
-
|
|
- /* Point to the first endpoint. */
|
|
- dev->config[i].interf[currif].descendp
|
|
- = (struct grub_usb_desc_endp *) &data[pos];
|
|
- pos += (sizeof (struct grub_usb_desc_endp)
|
|
- * dev->config[i].interf[currif].descif->endpointcnt);
|
|
+ if (desc->type == GRUB_USB_DESCRIPTOR_ENDPOINT) {
|
|
+ endp = (struct grub_usb_desc_endp *) &data[pos];
|
|
+ dev->config[i].interf[currif].descendp[j++] = endp;
|
|
+ pos += desc->length;
|
|
+ } else {
|
|
+ if (!desc->length)
|
|
+ {
|
|
+ err = GRUB_USB_ERR_BADDEVICE;
|
|
+ goto fail;
|
|
+ }
|
|
+ pos += desc->length;
|
|
+ }
|
|
+ }
|
|
}
|
|
}
|
|
|
|
@@ -226,8 +230,14 @@ grub_usb_device_initialize (grub_usb_device_t dev)
|
|
|
|
fail:
|
|
|
|
- for (i = 0; i < GRUB_USB_MAX_CONF; i++)
|
|
+ for (i = 0; i < GRUB_USB_MAX_CONF; i++) {
|
|
+ int currif;
|
|
+
|
|
+ for (currif = 0; currif < dev->config[i].descconf->numif; currif++)
|
|
+ grub_free (dev->config[i].interf[currif].descendp);
|
|
+
|
|
grub_free (dev->config[i].descconf);
|
|
+ }
|
|
|
|
return err;
|
|
}
|
|
diff --git a/grub-core/bus/usb/usbhub.c b/grub-core/bus/usb/usbhub.c
|
|
index f5608e330..2ae29cba1 100644
|
|
--- a/grub-core/bus/usb/usbhub.c
|
|
+++ b/grub-core/bus/usb/usbhub.c
|
|
@@ -82,8 +82,14 @@ grub_usb_hub_add_dev (grub_usb_controller_t controller,
|
|
if (i == GRUB_USBHUB_MAX_DEVICES)
|
|
{
|
|
grub_error (GRUB_ERR_IO, "can't assign address to USB device");
|
|
- for (i = 0; i < GRUB_USB_MAX_CONF; i++)
|
|
- grub_free (dev->config[i].descconf);
|
|
+ for (i = 0; i < GRUB_USB_MAX_CONF; i++) {
|
|
+ int currif;
|
|
+
|
|
+ for (currif = 0; currif < dev->config[i].descconf->numif; currif++)
|
|
+ grub_free (dev->config[i].interf[currif].descendp);
|
|
+
|
|
+ grub_free (dev->config[i].descconf);
|
|
+ }
|
|
grub_free (dev);
|
|
return NULL;
|
|
}
|
|
@@ -96,8 +102,14 @@ grub_usb_hub_add_dev (grub_usb_controller_t controller,
|
|
i, 0, 0, NULL);
|
|
if (err)
|
|
{
|
|
- for (i = 0; i < GRUB_USB_MAX_CONF; i++)
|
|
- grub_free (dev->config[i].descconf);
|
|
+ for (i = 0; i < GRUB_USB_MAX_CONF; i++) {
|
|
+ int currif;
|
|
+
|
|
+ for (currif = 0; currif < dev->config[i].descconf->numif; currif++)
|
|
+ grub_free (dev->config[i].interf[currif].descendp);
|
|
+
|
|
+ grub_free (dev->config[i].descconf);
|
|
+ }
|
|
grub_free (dev);
|
|
return NULL;
|
|
}
|
|
@@ -176,7 +188,7 @@ grub_usb_add_hub (grub_usb_device_t dev)
|
|
i++)
|
|
{
|
|
struct grub_usb_desc_endp *endp = NULL;
|
|
- endp = &dev->config[0].interf[0].descendp[i];
|
|
+ endp = dev->config[0].interf[0].descendp[i];
|
|
|
|
if ((endp->endp_addr & 128) && grub_usb_get_ep_type(endp)
|
|
== GRUB_USB_EP_INTERRUPT)
|
|
diff --git a/grub-core/commands/usbtest.c b/grub-core/commands/usbtest.c
|
|
index 2c6d93fe6..55a657635 100644
|
|
--- a/grub-core/commands/usbtest.c
|
|
+++ b/grub-core/commands/usbtest.c
|
|
@@ -185,7 +185,7 @@ usb_iterate (grub_usb_device_t dev, void *data __attribute__ ((unused)))
|
|
for (j = 0; j < interf->endpointcnt; j++)
|
|
{
|
|
struct grub_usb_desc_endp *endp;
|
|
- endp = &dev->config[0].interf[i].descendp[j];
|
|
+ endp = dev->config[0].interf[i].descendp[j];
|
|
|
|
grub_printf ("Endpoint #%d: %s, max packed size: %d, transfer type: %s, latency: %d\n",
|
|
endp->endp_addr & 15,
|
|
diff --git a/grub-core/disk/usbms.c b/grub-core/disk/usbms.c
|
|
index b81e3ad9d..b1512dc12 100644
|
|
--- a/grub-core/disk/usbms.c
|
|
+++ b/grub-core/disk/usbms.c
|
|
@@ -184,7 +184,7 @@ grub_usbms_attach (grub_usb_device_t usbdev, int configno, int interfno)
|
|
for (j = 0; j < interf->endpointcnt; j++)
|
|
{
|
|
struct grub_usb_desc_endp *endp;
|
|
- endp = &usbdev->config[0].interf[interfno].descendp[j];
|
|
+ endp = usbdev->config[0].interf[interfno].descendp[j];
|
|
|
|
if ((endp->endp_addr & 128) && (endp->attrib & 3) == 2)
|
|
/* Bulk IN endpoint. */
|
|
diff --git a/grub-core/term/usb_keyboard.c b/grub-core/term/usb_keyboard.c
|
|
index 7322d8dff..d590979f5 100644
|
|
--- a/grub-core/term/usb_keyboard.c
|
|
+++ b/grub-core/term/usb_keyboard.c
|
|
@@ -175,7 +175,7 @@ grub_usb_keyboard_attach (grub_usb_device_t usbdev, int configno, int interfno)
|
|
for (j = 0; j < usbdev->config[configno].interf[interfno].descif->endpointcnt;
|
|
j++)
|
|
{
|
|
- endp = &usbdev->config[configno].interf[interfno].descendp[j];
|
|
+ endp = usbdev->config[configno].interf[interfno].descendp[j];
|
|
|
|
if ((endp->endp_addr & 128) && grub_usb_get_ep_type(endp)
|
|
== GRUB_USB_EP_INTERRUPT)
|
|
diff --git a/include/grub/usb.h b/include/grub/usb.h
|
|
index 0f346af12..688c11f6d 100644
|
|
--- a/include/grub/usb.h
|
|
+++ b/include/grub/usb.h
|
|
@@ -153,7 +153,7 @@ struct grub_usb_interface
|
|
{
|
|
struct grub_usb_desc_if *descif;
|
|
|
|
- struct grub_usb_desc_endp *descendp;
|
|
+ struct grub_usb_desc_endp **descendp;
|
|
|
|
/* A driver is handling this interface. Do we need to support multiple drivers
|
|
for single interface?
|
|
diff --git a/include/grub/usbdesc.h b/include/grub/usbdesc.h
|
|
index aac5ab05a..bb2ab2e27 100644
|
|
--- a/include/grub/usbdesc.h
|
|
+++ b/include/grub/usbdesc.h
|
|
@@ -29,7 +29,8 @@ typedef enum {
|
|
GRUB_USB_DESCRIPTOR_INTERFACE,
|
|
GRUB_USB_DESCRIPTOR_ENDPOINT,
|
|
GRUB_USB_DESCRIPTOR_DEBUG = 10,
|
|
- GRUB_USB_DESCRIPTOR_HUB = 0x29
|
|
+ GRUB_USB_DESCRIPTOR_HUB = 0x29,
|
|
+ GRUB_USB_DESCRIPTOR_SS_ENDPOINT_COMPANION = 0x30
|
|
} grub_usb_descriptor_t;
|
|
|
|
struct grub_usb_desc
|
|
@@ -105,6 +106,14 @@ struct grub_usb_desc_endp
|
|
grub_uint8_t interval;
|
|
} GRUB_PACKED;
|
|
|
|
+struct grub_usb_desc_ssep {
|
|
+ grub_uint8_t length;
|
|
+ grub_uint8_t type;
|
|
+ grub_uint8_t maxburst;
|
|
+ grub_uint8_t attrib;
|
|
+ grub_uint16_t interval;
|
|
+} GRUB_PACKED;
|
|
+
|
|
struct grub_usb_desc_str
|
|
{
|
|
grub_uint8_t length;
|
|
--
|
|
2.39.2
|
|
|