All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v4 3/5] partitions/efi: add support for uImage.FIT sub-partitions
@ 2022-11-08 23:03 ` Daniel Golle
  0 siblings, 0 replies; 8+ messages in thread
From: Daniel Golle @ 2022-11-08 23:03 UTC (permalink / raw)
  To: Jens Axboe, Miquel Raynal, Richard Weinberger,
	Vignesh Raghavendra, Davidlohr Bueso, Matthew Wilcox,
	Martin K. Petersen, Chaitanya Kulkarni, Daniel Golle, Ming Lei,
	linux-block, linux-kernel, linux-mtd, linux-efi

Add new GUID allowing to parse uImage.FIT stored in a GPT partition
and map filesystem sub-image as sub-partitions.

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
---
 block/partitions/efi.c | 9 +++++++++
 block/partitions/efi.h | 3 +++
 2 files changed, 12 insertions(+)

diff --git a/block/partitions/efi.c b/block/partitions/efi.c
index 5e9be13a56a8..bf87893eabe4 100644
--- a/block/partitions/efi.c
+++ b/block/partitions/efi.c
@@ -716,6 +716,9 @@ int efi_partition(struct parsed_partitions *state)
 	gpt_entry *ptes = NULL;
 	u32 i;
 	unsigned ssz = queue_logical_block_size(state->disk->queue) / 512;
+#ifdef CONFIG_FIT_PARTITION
+	u32 extra_slot = 65;
+#endif
 
 	if (!find_valid_gpt(state, &gpt, &ptes) || !gpt || !ptes) {
 		kfree(gpt);
@@ -749,6 +752,12 @@ int efi_partition(struct parsed_partitions *state)
 				ARRAY_SIZE(ptes[i].partition_name));
 		utf16_le_to_7bit(ptes[i].partition_name, label_max, info->volname);
 		state->parts[i + 1].has_info = true;
+		/* If this is a U-Boot FIT volume it may have subpartitions */
+#ifdef CONFIG_FIT_PARTITION
+		if (!efi_guidcmp(ptes[i].partition_type_guid, PARTITION_LINUX_FIT_GUID))
+			(void) parse_fit_partitions(state, start * ssz, size * ssz,
+						    &extra_slot, 127, 1);
+#endif
 	}
 	kfree(ptes);
 	kfree(gpt);
diff --git a/block/partitions/efi.h b/block/partitions/efi.h
index 84b9f36b9e47..06c11f6ae398 100644
--- a/block/partitions/efi.h
+++ b/block/partitions/efi.h
@@ -51,6 +51,9 @@
 #define PARTITION_LINUX_LVM_GUID \
     EFI_GUID( 0xe6d6d379, 0xf507, 0x44c2, \
               0xa2, 0x3c, 0x23, 0x8f, 0x2a, 0x3d, 0xf9, 0x28)
+#define PARTITION_LINUX_FIT_GUID \
+    EFI_GUID( 0xcae9be83, 0xb15f, 0x49cc, \
+              0x86, 0x3f, 0x08, 0x1b, 0x74, 0x4a, 0x2d, 0x93)
 
 typedef struct _gpt_header {
 	__le64 signature;
-- 
2.38.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH v4 3/5] partitions/efi: add support for uImage.FIT sub-partitions
@ 2022-11-08 23:03 ` Daniel Golle
  0 siblings, 0 replies; 8+ messages in thread
From: Daniel Golle @ 2022-11-08 23:03 UTC (permalink / raw)
  To: Jens Axboe, Miquel Raynal, Richard Weinberger,
	Vignesh Raghavendra, Davidlohr Bueso, Matthew Wilcox,
	Martin K. Petersen, Chaitanya Kulkarni, Daniel Golle, Ming Lei,
	linux-block, linux-kernel, linux-mtd, linux-efi

Add new GUID allowing to parse uImage.FIT stored in a GPT partition
and map filesystem sub-image as sub-partitions.

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
---
 block/partitions/efi.c | 9 +++++++++
 block/partitions/efi.h | 3 +++
 2 files changed, 12 insertions(+)

diff --git a/block/partitions/efi.c b/block/partitions/efi.c
index 5e9be13a56a8..bf87893eabe4 100644
--- a/block/partitions/efi.c
+++ b/block/partitions/efi.c
@@ -716,6 +716,9 @@ int efi_partition(struct parsed_partitions *state)
 	gpt_entry *ptes = NULL;
 	u32 i;
 	unsigned ssz = queue_logical_block_size(state->disk->queue) / 512;
+#ifdef CONFIG_FIT_PARTITION
+	u32 extra_slot = 65;
+#endif
 
 	if (!find_valid_gpt(state, &gpt, &ptes) || !gpt || !ptes) {
 		kfree(gpt);
@@ -749,6 +752,12 @@ int efi_partition(struct parsed_partitions *state)
 				ARRAY_SIZE(ptes[i].partition_name));
 		utf16_le_to_7bit(ptes[i].partition_name, label_max, info->volname);
 		state->parts[i + 1].has_info = true;
+		/* If this is a U-Boot FIT volume it may have subpartitions */
+#ifdef CONFIG_FIT_PARTITION
+		if (!efi_guidcmp(ptes[i].partition_type_guid, PARTITION_LINUX_FIT_GUID))
+			(void) parse_fit_partitions(state, start * ssz, size * ssz,
+						    &extra_slot, 127, 1);
+#endif
 	}
 	kfree(ptes);
 	kfree(gpt);
diff --git a/block/partitions/efi.h b/block/partitions/efi.h
index 84b9f36b9e47..06c11f6ae398 100644
--- a/block/partitions/efi.h
+++ b/block/partitions/efi.h
@@ -51,6 +51,9 @@
 #define PARTITION_LINUX_LVM_GUID \
     EFI_GUID( 0xe6d6d379, 0xf507, 0x44c2, \
               0xa2, 0x3c, 0x23, 0x8f, 0x2a, 0x3d, 0xf9, 0x28)
+#define PARTITION_LINUX_FIT_GUID \
+    EFI_GUID( 0xcae9be83, 0xb15f, 0x49cc, \
+              0x86, 0x3f, 0x08, 0x1b, 0x74, 0x4a, 0x2d, 0x93)
 
 typedef struct _gpt_header {
 	__le64 signature;
-- 
2.38.1


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH v4 3/5] partitions/efi: add support for uImage.FIT sub-partitions
  2022-11-08 23:03 ` Daniel Golle
@ 2022-11-09  9:13   ` Ard Biesheuvel
  -1 siblings, 0 replies; 8+ messages in thread
From: Ard Biesheuvel @ 2022-11-09  9:13 UTC (permalink / raw)
  To: Daniel Golle
  Cc: Jens Axboe, Miquel Raynal, Richard Weinberger,
	Vignesh Raghavendra, Davidlohr Bueso, Matthew Wilcox,
	Martin K. Petersen, Chaitanya Kulkarni, Ming Lei, linux-block,
	linux-kernel, linux-mtd, linux-efi

On Wed, 9 Nov 2022 at 00:05, Daniel Golle <daniel@makrotopia.org> wrote:
>
> Add new GUID allowing to parse uImage.FIT stored in a GPT partition
> and map filesystem sub-image as sub-partitions.
>
> Signed-off-by: Daniel Golle <daniel@makrotopia.org>

I'm not sure I follow the logic here.

You are adding uImage.FIT support as a pseudo-partition type right?
And the only partition driver that supports it is GPT?

Does that mean that all the other types would need a similar change to
be able to detect these subvolumes?

> ---
>  block/partitions/efi.c | 9 +++++++++
>  block/partitions/efi.h | 3 +++
>  2 files changed, 12 insertions(+)
>
> diff --git a/block/partitions/efi.c b/block/partitions/efi.c
> index 5e9be13a56a8..bf87893eabe4 100644
> --- a/block/partitions/efi.c
> +++ b/block/partitions/efi.c
> @@ -716,6 +716,9 @@ int efi_partition(struct parsed_partitions *state)
>         gpt_entry *ptes = NULL;
>         u32 i;
>         unsigned ssz = queue_logical_block_size(state->disk->queue) / 512;
> +#ifdef CONFIG_FIT_PARTITION
> +       u32 extra_slot = 65;
> +#endif
>
>         if (!find_valid_gpt(state, &gpt, &ptes) || !gpt || !ptes) {
>                 kfree(gpt);
> @@ -749,6 +752,12 @@ int efi_partition(struct parsed_partitions *state)
>                                 ARRAY_SIZE(ptes[i].partition_name));
>                 utf16_le_to_7bit(ptes[i].partition_name, label_max, info->volname);
>                 state->parts[i + 1].has_info = true;
> +               /* If this is a U-Boot FIT volume it may have subpartitions */
> +#ifdef CONFIG_FIT_PARTITION
> +               if (!efi_guidcmp(ptes[i].partition_type_guid, PARTITION_LINUX_FIT_GUID))
> +                       (void) parse_fit_partitions(state, start * ssz, size * ssz,
> +                                                   &extra_slot, 127, 1);
> +#endif
>         }
>         kfree(ptes);
>         kfree(gpt);
> diff --git a/block/partitions/efi.h b/block/partitions/efi.h
> index 84b9f36b9e47..06c11f6ae398 100644
> --- a/block/partitions/efi.h
> +++ b/block/partitions/efi.h
> @@ -51,6 +51,9 @@
>  #define PARTITION_LINUX_LVM_GUID \
>      EFI_GUID( 0xe6d6d379, 0xf507, 0x44c2, \
>                0xa2, 0x3c, 0x23, 0x8f, 0x2a, 0x3d, 0xf9, 0x28)
> +#define PARTITION_LINUX_FIT_GUID \
> +    EFI_GUID( 0xcae9be83, 0xb15f, 0x49cc, \
> +              0x86, 0x3f, 0x08, 0x1b, 0x74, 0x4a, 0x2d, 0x93)
>
>  typedef struct _gpt_header {
>         __le64 signature;
> --
> 2.38.1
>

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v4 3/5] partitions/efi: add support for uImage.FIT sub-partitions
@ 2022-11-09  9:13   ` Ard Biesheuvel
  0 siblings, 0 replies; 8+ messages in thread
From: Ard Biesheuvel @ 2022-11-09  9:13 UTC (permalink / raw)
  To: Daniel Golle
  Cc: Jens Axboe, Miquel Raynal, Richard Weinberger,
	Vignesh Raghavendra, Davidlohr Bueso, Matthew Wilcox,
	Martin K. Petersen, Chaitanya Kulkarni, Ming Lei, linux-block,
	linux-kernel, linux-mtd, linux-efi

On Wed, 9 Nov 2022 at 00:05, Daniel Golle <daniel@makrotopia.org> wrote:
>
> Add new GUID allowing to parse uImage.FIT stored in a GPT partition
> and map filesystem sub-image as sub-partitions.
>
> Signed-off-by: Daniel Golle <daniel@makrotopia.org>

I'm not sure I follow the logic here.

You are adding uImage.FIT support as a pseudo-partition type right?
And the only partition driver that supports it is GPT?

Does that mean that all the other types would need a similar change to
be able to detect these subvolumes?

> ---
>  block/partitions/efi.c | 9 +++++++++
>  block/partitions/efi.h | 3 +++
>  2 files changed, 12 insertions(+)
>
> diff --git a/block/partitions/efi.c b/block/partitions/efi.c
> index 5e9be13a56a8..bf87893eabe4 100644
> --- a/block/partitions/efi.c
> +++ b/block/partitions/efi.c
> @@ -716,6 +716,9 @@ int efi_partition(struct parsed_partitions *state)
>         gpt_entry *ptes = NULL;
>         u32 i;
>         unsigned ssz = queue_logical_block_size(state->disk->queue) / 512;
> +#ifdef CONFIG_FIT_PARTITION
> +       u32 extra_slot = 65;
> +#endif
>
>         if (!find_valid_gpt(state, &gpt, &ptes) || !gpt || !ptes) {
>                 kfree(gpt);
> @@ -749,6 +752,12 @@ int efi_partition(struct parsed_partitions *state)
>                                 ARRAY_SIZE(ptes[i].partition_name));
>                 utf16_le_to_7bit(ptes[i].partition_name, label_max, info->volname);
>                 state->parts[i + 1].has_info = true;
> +               /* If this is a U-Boot FIT volume it may have subpartitions */
> +#ifdef CONFIG_FIT_PARTITION
> +               if (!efi_guidcmp(ptes[i].partition_type_guid, PARTITION_LINUX_FIT_GUID))
> +                       (void) parse_fit_partitions(state, start * ssz, size * ssz,
> +                                                   &extra_slot, 127, 1);
> +#endif
>         }
>         kfree(ptes);
>         kfree(gpt);
> diff --git a/block/partitions/efi.h b/block/partitions/efi.h
> index 84b9f36b9e47..06c11f6ae398 100644
> --- a/block/partitions/efi.h
> +++ b/block/partitions/efi.h
> @@ -51,6 +51,9 @@
>  #define PARTITION_LINUX_LVM_GUID \
>      EFI_GUID( 0xe6d6d379, 0xf507, 0x44c2, \
>                0xa2, 0x3c, 0x23, 0x8f, 0x2a, 0x3d, 0xf9, 0x28)
> +#define PARTITION_LINUX_FIT_GUID \
> +    EFI_GUID( 0xcae9be83, 0xb15f, 0x49cc, \
> +              0x86, 0x3f, 0x08, 0x1b, 0x74, 0x4a, 0x2d, 0x93)
>
>  typedef struct _gpt_header {
>         __le64 signature;
> --
> 2.38.1
>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v4 3/5] partitions/efi: add support for uImage.FIT sub-partitions
  2022-11-09  9:13   ` Ard Biesheuvel
@ 2022-11-09 11:40     ` Daniel Golle
  -1 siblings, 0 replies; 8+ messages in thread
From: Daniel Golle @ 2022-11-09 11:40 UTC (permalink / raw)
  To: Ard Biesheuvel
  Cc: Jens Axboe, Miquel Raynal, Richard Weinberger,
	Vignesh Raghavendra, Davidlohr Bueso, Matthew Wilcox,
	Martin K. Petersen, Chaitanya Kulkarni, Ming Lei, linux-block,
	linux-kernel, linux-mtd, linux-efi

On Wed, Nov 09, 2022 at 10:13:48AM +0100, Ard Biesheuvel wrote:
> On Wed, 9 Nov 2022 at 00:05, Daniel Golle <daniel@makrotopia.org> wrote:
> >
> > Add new GUID allowing to parse uImage.FIT stored in a GPT partition
> > and map filesystem sub-image as sub-partitions.
> >
> > Signed-off-by: Daniel Golle <daniel@makrotopia.org>
> 
> I'm not sure I follow the logic here.
> 
> You are adding uImage.FIT support as a pseudo-partition type right?

Yes, exactly.

> And the only partition driver that supports it is GPT?

Support for uImage.FIT subvolumes is added only for GPT partitions for
now. Being the most flexible/modern partition table type I don't think
anything else is actually relevant for new designs.

In other patches in the series following this one I also want to allow
enabling scanning for partitions on mtdblock and ubiblock devices.

On embedded devices with raw NOR or NAND storage those can then be used
to directly store a uImage.FIT and the FIT partition parsers is then
used on that whole block device, mapping the filesystem sub-image(s)
as mtdblockXpY or ubiblockXpY.

> 
> Does that mean that all the other types would need a similar change to
> be able to detect these subvolumes?

If you wanted to support uImage.FIT subvolumes inside other types of
partitions, then yes, this would have to be implemented for those as
well.

I've also written a (not very clean) implementation of that for MBR
partitions, it is needed e.g. on MT7623 because one cannot use GPT on
the block device used for booting with that SoC as the BootROM expects
to load the preloader exactly from where GPT would be located...
I wasn't planning on submitting that upstream though.

And other than for GPT and MBR, I don't think implementing detection of
uImage.FIT subvolumes makes any sense (but maybe I got something wrong
here or didn't fully understand your question).

> 
> > ---
> >  block/partitions/efi.c | 9 +++++++++
> >  block/partitions/efi.h | 3 +++
> >  2 files changed, 12 insertions(+)
> >
> > diff --git a/block/partitions/efi.c b/block/partitions/efi.c
> > index 5e9be13a56a8..bf87893eabe4 100644
> > --- a/block/partitions/efi.c
> > +++ b/block/partitions/efi.c
> > @@ -716,6 +716,9 @@ int efi_partition(struct parsed_partitions *state)
> >         gpt_entry *ptes = NULL;
> >         u32 i;
> >         unsigned ssz = queue_logical_block_size(state->disk->queue) / 512;
> > +#ifdef CONFIG_FIT_PARTITION
> > +       u32 extra_slot = 65;
> > +#endif
> >
> >         if (!find_valid_gpt(state, &gpt, &ptes) || !gpt || !ptes) {
> >                 kfree(gpt);
> > @@ -749,6 +752,12 @@ int efi_partition(struct parsed_partitions *state)
> >                                 ARRAY_SIZE(ptes[i].partition_name));
> >                 utf16_le_to_7bit(ptes[i].partition_name, label_max, info->volname);
> >                 state->parts[i + 1].has_info = true;
> > +               /* If this is a U-Boot FIT volume it may have subpartitions */
> > +#ifdef CONFIG_FIT_PARTITION
> > +               if (!efi_guidcmp(ptes[i].partition_type_guid, PARTITION_LINUX_FIT_GUID))
> > +                       (void) parse_fit_partitions(state, start * ssz, size * ssz,
> > +                                                   &extra_slot, 127, 1);
> > +#endif
> >         }
> >         kfree(ptes);
> >         kfree(gpt);
> > diff --git a/block/partitions/efi.h b/block/partitions/efi.h
> > index 84b9f36b9e47..06c11f6ae398 100644
> > --- a/block/partitions/efi.h
> > +++ b/block/partitions/efi.h
> > @@ -51,6 +51,9 @@
> >  #define PARTITION_LINUX_LVM_GUID \
> >      EFI_GUID( 0xe6d6d379, 0xf507, 0x44c2, \
> >                0xa2, 0x3c, 0x23, 0x8f, 0x2a, 0x3d, 0xf9, 0x28)
> > +#define PARTITION_LINUX_FIT_GUID \
> > +    EFI_GUID( 0xcae9be83, 0xb15f, 0x49cc, \
> > +              0x86, 0x3f, 0x08, 0x1b, 0x74, 0x4a, 0x2d, 0x93)
> >
> >  typedef struct _gpt_header {
> >         __le64 signature;
> > --
> > 2.38.1
> >

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v4 3/5] partitions/efi: add support for uImage.FIT sub-partitions
@ 2022-11-09 11:40     ` Daniel Golle
  0 siblings, 0 replies; 8+ messages in thread
From: Daniel Golle @ 2022-11-09 11:40 UTC (permalink / raw)
  To: Ard Biesheuvel
  Cc: Jens Axboe, Miquel Raynal, Richard Weinberger,
	Vignesh Raghavendra, Davidlohr Bueso, Matthew Wilcox,
	Martin K. Petersen, Chaitanya Kulkarni, Ming Lei, linux-block,
	linux-kernel, linux-mtd, linux-efi

On Wed, Nov 09, 2022 at 10:13:48AM +0100, Ard Biesheuvel wrote:
> On Wed, 9 Nov 2022 at 00:05, Daniel Golle <daniel@makrotopia.org> wrote:
> >
> > Add new GUID allowing to parse uImage.FIT stored in a GPT partition
> > and map filesystem sub-image as sub-partitions.
> >
> > Signed-off-by: Daniel Golle <daniel@makrotopia.org>
> 
> I'm not sure I follow the logic here.
> 
> You are adding uImage.FIT support as a pseudo-partition type right?

Yes, exactly.

> And the only partition driver that supports it is GPT?

Support for uImage.FIT subvolumes is added only for GPT partitions for
now. Being the most flexible/modern partition table type I don't think
anything else is actually relevant for new designs.

In other patches in the series following this one I also want to allow
enabling scanning for partitions on mtdblock and ubiblock devices.

On embedded devices with raw NOR or NAND storage those can then be used
to directly store a uImage.FIT and the FIT partition parsers is then
used on that whole block device, mapping the filesystem sub-image(s)
as mtdblockXpY or ubiblockXpY.

> 
> Does that mean that all the other types would need a similar change to
> be able to detect these subvolumes?

If you wanted to support uImage.FIT subvolumes inside other types of
partitions, then yes, this would have to be implemented for those as
well.

I've also written a (not very clean) implementation of that for MBR
partitions, it is needed e.g. on MT7623 because one cannot use GPT on
the block device used for booting with that SoC as the BootROM expects
to load the preloader exactly from where GPT would be located...
I wasn't planning on submitting that upstream though.

And other than for GPT and MBR, I don't think implementing detection of
uImage.FIT subvolumes makes any sense (but maybe I got something wrong
here or didn't fully understand your question).

> 
> > ---
> >  block/partitions/efi.c | 9 +++++++++
> >  block/partitions/efi.h | 3 +++
> >  2 files changed, 12 insertions(+)
> >
> > diff --git a/block/partitions/efi.c b/block/partitions/efi.c
> > index 5e9be13a56a8..bf87893eabe4 100644
> > --- a/block/partitions/efi.c
> > +++ b/block/partitions/efi.c
> > @@ -716,6 +716,9 @@ int efi_partition(struct parsed_partitions *state)
> >         gpt_entry *ptes = NULL;
> >         u32 i;
> >         unsigned ssz = queue_logical_block_size(state->disk->queue) / 512;
> > +#ifdef CONFIG_FIT_PARTITION
> > +       u32 extra_slot = 65;
> > +#endif
> >
> >         if (!find_valid_gpt(state, &gpt, &ptes) || !gpt || !ptes) {
> >                 kfree(gpt);
> > @@ -749,6 +752,12 @@ int efi_partition(struct parsed_partitions *state)
> >                                 ARRAY_SIZE(ptes[i].partition_name));
> >                 utf16_le_to_7bit(ptes[i].partition_name, label_max, info->volname);
> >                 state->parts[i + 1].has_info = true;
> > +               /* If this is a U-Boot FIT volume it may have subpartitions */
> > +#ifdef CONFIG_FIT_PARTITION
> > +               if (!efi_guidcmp(ptes[i].partition_type_guid, PARTITION_LINUX_FIT_GUID))
> > +                       (void) parse_fit_partitions(state, start * ssz, size * ssz,
> > +                                                   &extra_slot, 127, 1);
> > +#endif
> >         }
> >         kfree(ptes);
> >         kfree(gpt);
> > diff --git a/block/partitions/efi.h b/block/partitions/efi.h
> > index 84b9f36b9e47..06c11f6ae398 100644
> > --- a/block/partitions/efi.h
> > +++ b/block/partitions/efi.h
> > @@ -51,6 +51,9 @@
> >  #define PARTITION_LINUX_LVM_GUID \
> >      EFI_GUID( 0xe6d6d379, 0xf507, 0x44c2, \
> >                0xa2, 0x3c, 0x23, 0x8f, 0x2a, 0x3d, 0xf9, 0x28)
> > +#define PARTITION_LINUX_FIT_GUID \
> > +    EFI_GUID( 0xcae9be83, 0xb15f, 0x49cc, \
> > +              0x86, 0x3f, 0x08, 0x1b, 0x74, 0x4a, 0x2d, 0x93)
> >
> >  typedef struct _gpt_header {
> >         __le64 signature;
> > --
> > 2.38.1
> >

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v4 3/5] partitions/efi: add support for uImage.FIT sub-partitions
  2022-11-08 23:03 ` Daniel Golle
@ 2022-12-09  1:45   ` Davidlohr Bueso
  -1 siblings, 0 replies; 8+ messages in thread
From: Davidlohr Bueso @ 2022-12-09  1:45 UTC (permalink / raw)
  To: Daniel Golle
  Cc: Jens Axboe, Miquel Raynal, Richard Weinberger,
	Vignesh Raghavendra, Matthew Wilcox, Martin K. Petersen,
	Chaitanya Kulkarni, Ming Lei, linux-block, linux-kernel,
	linux-mtd, linux-efi

On Tue, 08 Nov 2022, Daniel Golle wrote:

>Add new GUID allowing to parse uImage.FIT stored in a GPT partition
>and map filesystem sub-image as sub-partitions.
>
>Signed-off-by: Daniel Golle <daniel@makrotopia.org>
>---
> block/partitions/efi.c | 9 +++++++++
> block/partitions/efi.h | 3 +++
> 2 files changed, 12 insertions(+)
>
>diff --git a/block/partitions/efi.c b/block/partitions/efi.c
>index 5e9be13a56a8..bf87893eabe4 100644
>--- a/block/partitions/efi.c
>+++ b/block/partitions/efi.c
>@@ -716,6 +716,9 @@ int efi_partition(struct parsed_partitions *state)
>	gpt_entry *ptes = NULL;
>	u32 i;
>	unsigned ssz = queue_logical_block_size(state->disk->queue) / 512;
>+#ifdef CONFIG_FIT_PARTITION
>+	u32 extra_slot = 65;
>+#endif

You can move this in the branch below where you call parse_fit_partitions().

>
>	if (!find_valid_gpt(state, &gpt, &ptes) || !gpt || !ptes) {
>		kfree(gpt);
>@@ -749,6 +752,12 @@ int efi_partition(struct parsed_partitions *state)
>				ARRAY_SIZE(ptes[i].partition_name));
>		utf16_le_to_7bit(ptes[i].partition_name, label_max, info->volname);
>		state->parts[i + 1].has_info = true;
>+		/* If this is a U-Boot FIT volume it may have subpartitions */
>+#ifdef CONFIG_FIT_PARTITION
>+		if (!efi_guidcmp(ptes[i].partition_type_guid, PARTITION_LINUX_FIT_GUID))
>+			(void) parse_fit_partitions(state, start * ssz, size * ssz,
>+						    &extra_slot, 127, 1);
>+#endif
>	}
>	kfree(ptes);
>	kfree(gpt);
>diff --git a/block/partitions/efi.h b/block/partitions/efi.h
>index 84b9f36b9e47..06c11f6ae398 100644
>--- a/block/partitions/efi.h
>+++ b/block/partitions/efi.h
>@@ -51,6 +51,9 @@
> #define PARTITION_LINUX_LVM_GUID \
>     EFI_GUID( 0xe6d6d379, 0xf507, 0x44c2, \
>               0xa2, 0x3c, 0x23, 0x8f, 0x2a, 0x3d, 0xf9, 0x28)
>+#define PARTITION_LINUX_FIT_GUID \
>+    EFI_GUID( 0xcae9be83, 0xb15f, 0x49cc, \
>+              0x86, 0x3f, 0x08, 0x1b, 0x74, 0x4a, 0x2d, 0x93)
>
> typedef struct _gpt_header {
>	__le64 signature;
>--
>2.38.1
>

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v4 3/5] partitions/efi: add support for uImage.FIT sub-partitions
@ 2022-12-09  1:45   ` Davidlohr Bueso
  0 siblings, 0 replies; 8+ messages in thread
From: Davidlohr Bueso @ 2022-12-09  1:45 UTC (permalink / raw)
  To: Daniel Golle
  Cc: Jens Axboe, Miquel Raynal, Richard Weinberger,
	Vignesh Raghavendra, Matthew Wilcox, Martin K. Petersen,
	Chaitanya Kulkarni, Ming Lei, linux-block, linux-kernel,
	linux-mtd, linux-efi

On Tue, 08 Nov 2022, Daniel Golle wrote:

>Add new GUID allowing to parse uImage.FIT stored in a GPT partition
>and map filesystem sub-image as sub-partitions.
>
>Signed-off-by: Daniel Golle <daniel@makrotopia.org>
>---
> block/partitions/efi.c | 9 +++++++++
> block/partitions/efi.h | 3 +++
> 2 files changed, 12 insertions(+)
>
>diff --git a/block/partitions/efi.c b/block/partitions/efi.c
>index 5e9be13a56a8..bf87893eabe4 100644
>--- a/block/partitions/efi.c
>+++ b/block/partitions/efi.c
>@@ -716,6 +716,9 @@ int efi_partition(struct parsed_partitions *state)
>	gpt_entry *ptes = NULL;
>	u32 i;
>	unsigned ssz = queue_logical_block_size(state->disk->queue) / 512;
>+#ifdef CONFIG_FIT_PARTITION
>+	u32 extra_slot = 65;
>+#endif

You can move this in the branch below where you call parse_fit_partitions().

>
>	if (!find_valid_gpt(state, &gpt, &ptes) || !gpt || !ptes) {
>		kfree(gpt);
>@@ -749,6 +752,12 @@ int efi_partition(struct parsed_partitions *state)
>				ARRAY_SIZE(ptes[i].partition_name));
>		utf16_le_to_7bit(ptes[i].partition_name, label_max, info->volname);
>		state->parts[i + 1].has_info = true;
>+		/* If this is a U-Boot FIT volume it may have subpartitions */
>+#ifdef CONFIG_FIT_PARTITION
>+		if (!efi_guidcmp(ptes[i].partition_type_guid, PARTITION_LINUX_FIT_GUID))
>+			(void) parse_fit_partitions(state, start * ssz, size * ssz,
>+						    &extra_slot, 127, 1);
>+#endif
>	}
>	kfree(ptes);
>	kfree(gpt);
>diff --git a/block/partitions/efi.h b/block/partitions/efi.h
>index 84b9f36b9e47..06c11f6ae398 100644
>--- a/block/partitions/efi.h
>+++ b/block/partitions/efi.h
>@@ -51,6 +51,9 @@
> #define PARTITION_LINUX_LVM_GUID \
>     EFI_GUID( 0xe6d6d379, 0xf507, 0x44c2, \
>               0xa2, 0x3c, 0x23, 0x8f, 0x2a, 0x3d, 0xf9, 0x28)
>+#define PARTITION_LINUX_FIT_GUID \
>+    EFI_GUID( 0xcae9be83, 0xb15f, 0x49cc, \
>+              0x86, 0x3f, 0x08, 0x1b, 0x74, 0x4a, 0x2d, 0x93)
>
> typedef struct _gpt_header {
>	__le64 signature;
>--
>2.38.1
>

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2022-12-09  2:15 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-08 23:03 [PATCH v4 3/5] partitions/efi: add support for uImage.FIT sub-partitions Daniel Golle
2022-11-08 23:03 ` Daniel Golle
2022-11-09  9:13 ` Ard Biesheuvel
2022-11-09  9:13   ` Ard Biesheuvel
2022-11-09 11:40   ` Daniel Golle
2022-11-09 11:40     ` Daniel Golle
2022-12-09  1:45 ` Davidlohr Bueso
2022-12-09  1:45   ` Davidlohr Bueso

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.