diff mbox series

[v4] disk: dos: Add all options for EFI System Partitions

Message ID 20240302112034.593441-1-pbrobinson@gmail.com
State Changes Requested
Delegated to: Tom Rini
Headers show
Series [v4] disk: dos: Add all options for EFI System Partitions | expand

Commit Message

Peter Robinson March 2, 2024, 11:20 a.m. UTC
The EFI spec states that the ESP can be any of FAT12/16/32 but for
compatibility doesn't necssarily require the partition to be the
EFI partition table ID of 0xef. A number of arm devices will not
find their firmware on a FAT partition with an ID of 0xef so also
allow the original FAT12/16/32 partition IDs as they are also
permissable for an ESP.

Signed-off-by: Peter Robinson <pbrobinson@gmail.com>
---

v2:
- Add 0x0c option
- Make hex constants consistent
- Move from if to switch statement
v3:
- Fix switch brain fart
v4:
- Drop boot_ind out of switch

 disk/part_dos.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

Comments

Mark Kettenis March 2, 2024, 11:33 a.m. UTC | #1
> From: Peter Robinson <pbrobinson@gmail.com>
> Date: Sat,  2 Mar 2024 11:20:31 +0000
> 
> The EFI spec states that the ESP can be any of FAT12/16/32 but for
> compatibility doesn't necssarily require the partition to be the
> EFI partition table ID of 0xef. A number of arm devices will not
> find their firmware on a FAT partition with an ID of 0xef so also
> allow the original FAT12/16/32 partition IDs as they are also
> permissable for an ESP.
> 
> Signed-off-by: Peter Robinson <pbrobinson@gmail.com>

Reviewed-by: Mark Kettenis <kettenis@openbsd.org>

> ---
> 
> v2:
> - Add 0x0c option
> - Make hex constants consistent
> - Move from if to switch statement
> v3:
> - Fix switch brain fart
> v4:
> - Drop boot_ind out of switch
> 
>  disk/part_dos.c | 13 ++++++++++++-
>  1 file changed, 12 insertions(+), 1 deletion(-)
> 
> diff --git a/disk/part_dos.c b/disk/part_dos.c
> index 567ead7511d..a35181dff4f 100644
> --- a/disk/part_dos.c
> +++ b/disk/part_dos.c
> @@ -40,10 +40,21 @@ static int get_bootable(dos_partition_t *p)
>  {
>  	int ret = 0;
>  
> -	if (p->sys_ind == 0xef)
> +	switch (p->sys_ind) {
> +	case 0x01:
> +	case 0x06:
> +	case 0x0b:
> +	case 0x0c:
> +	case 0xef:
>  		ret |= PART_EFI_SYSTEM_PARTITION;
> +		break;
> +	default:
> +		break;
> +	}
> +
>  	if (p->boot_ind == 0x80)
>  		ret |= PART_BOOTABLE;
> +
>  	return ret;
>  }
>  
> -- 
> 2.44.0
> 
>
Ilias Apalodimas March 5, 2024, 9:01 a.m. UTC | #2
On Sat, 2 Mar 2024 at 13:20, Peter Robinson <pbrobinson@gmail.com> wrote:
>
> The EFI spec states that the ESP can be any of FAT12/16/32 but for
> compatibility doesn't necssarily require the partition to be the
> EFI partition table ID of 0xef. A number of arm devices will not
> find their firmware on a FAT partition with an ID of 0xef so also
> allow the original FAT12/16/32 partition IDs as they are also
> permissable for an ESP.
>
> Signed-off-by: Peter Robinson <pbrobinson@gmail.com>
> ---
>
> v2:
> - Add 0x0c option
> - Make hex constants consistent
> - Move from if to switch statement
> v3:
> - Fix switch brain fart
> v4:
> - Drop boot_ind out of switch
>
>  disk/part_dos.c | 13 ++++++++++++-
>  1 file changed, 12 insertions(+), 1 deletion(-)
>
> diff --git a/disk/part_dos.c b/disk/part_dos.c
> index 567ead7511d..a35181dff4f 100644
> --- a/disk/part_dos.c
> +++ b/disk/part_dos.c
> @@ -40,10 +40,21 @@ static int get_bootable(dos_partition_t *p)
>  {
>         int ret = 0;
>
> -       if (p->sys_ind == 0xef)
> +       switch (p->sys_ind) {
> +       case 0x01:
> +       case 0x06:
> +       case 0x0b:
> +       case 0x0c:
> +       case 0xef:
>                 ret |= PART_EFI_SYSTEM_PARTITION;
> +               break;
> +       default:
> +               break;
> +       }
> +
>         if (p->boot_ind == 0x80)
>                 ret |= PART_BOOTABLE;
> +
>         return ret;
>  }
>
> --
> 2.44.0
>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Tom Rini March 7, 2024, 2:34 p.m. UTC | #3
On Sat, Mar 02, 2024 at 11:20:31AM +0000, Peter Robinson wrote:

> The EFI spec states that the ESP can be any of FAT12/16/32 but for
> compatibility doesn't necssarily require the partition to be the
> EFI partition table ID of 0xef. A number of arm devices will not
> find their firmware on a FAT partition with an ID of 0xef so also
> allow the original FAT12/16/32 partition IDs as they are also
> permissable for an ESP.
> 
> Signed-off-by: Peter Robinson <pbrobinson@gmail.com>
> Reviewed-by: Mark Kettenis <kettenis@openbsd.org>
> Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>

This leads to these failures in CI:
https://source.denx.de/u-boot/u-boot/-/jobs/794519#L598
diff mbox series

Patch

diff --git a/disk/part_dos.c b/disk/part_dos.c
index 567ead7511d..a35181dff4f 100644
--- a/disk/part_dos.c
+++ b/disk/part_dos.c
@@ -40,10 +40,21 @@  static int get_bootable(dos_partition_t *p)
 {
 	int ret = 0;
 
-	if (p->sys_ind == 0xef)
+	switch (p->sys_ind) {
+	case 0x01:
+	case 0x06:
+	case 0x0b:
+	case 0x0c:
+	case 0xef:
 		ret |= PART_EFI_SYSTEM_PARTITION;
+		break;
+	default:
+		break;
+	}
+
 	if (p->boot_ind == 0x80)
 		ret |= PART_BOOTABLE;
+
 	return ret;
 }