mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Marco Felsch <m.felsch@pengutronix.de>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH v2 1/4] partitions: efi: add support to specify gpt-location
Date: Thu, 24 Apr 2025 14:08:44 +0200	[thread overview]
Message-ID: <aAopzC7K6bqoxunE@pengutronix.de> (raw)
In-Reply-To: <20250423140913.1530237-1-m.felsch@pengutronix.de>

On Wed, Apr 23, 2025 at 04:09:10PM +0200, Marco Felsch wrote:
> -static __maybe_unused struct partition_desc *efi_partition_create_table(struct block_device *blk)
> +static __maybe_unused struct partition_desc *
> +efi_partition_create_table(struct block_device *blk, sector_t gpt_location)
>  {
>  	struct efi_partition_desc *epd = xzalloc(sizeof(*epd));
>  	gpt_header *gpt;
>  
> +	if (gpt_location < 2) {
> +		pr_err("Invalid starting LBA (%llu) of array of partition entries\n",
> +		       gpt_location);
> +		return ERR_PTR(-EINVAL);
> +	}
> +
>  	partition_desc_init(&epd->pd, blk);
>  
>  	epd->gpt = xzalloc(512);
> @@ -594,10 +601,10 @@ static __maybe_unused struct partition_desc *efi_partition_create_table(struct b
>  	gpt->header_size = cpu_to_le32(sizeof(*gpt));
>  	gpt->my_lba = cpu_to_le64(1);
>  	gpt->alternate_lba = cpu_to_le64(last_lba(blk));
> -	gpt->first_usable_lba = cpu_to_le64(34);
> +	gpt->first_usable_lba = cpu_to_le64(gpt_location + 32);

Since you are changing this default you should also check against
gpt->first_usable_lba in efi_partition_mkpart():

	if (start_lba < 34) {
		pr_err("invalid start LBA %lld, minimum is 34\n", start_lba);
		return -EINVAL;
	}

We should have done that from the start, but now that you are touching
it it's your turn ;)

Sascha

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



      parent reply	other threads:[~2025-04-24 16:04 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-23 14:09 Marco Felsch
2025-04-23 14:09 ` [PATCH v2 2/4] parted: add support for gpt-location Marco Felsch
2025-04-24 12:00   ` Sascha Hauer
2025-04-24 20:34     ` Marco Felsch
2025-04-23 14:09 ` [PATCH v2 3/4] defaultenv-2: add support to automatically create an initial GPT table Marco Felsch
2025-04-24 11:51   ` Sascha Hauer
2025-04-23 14:09 ` [PATCH v2 4/4] ARM: riotboard: drop static barebox-environment handling Marco Felsch
2025-04-24  8:02   ` Ahmad Fatoum
2025-04-24  8:45     ` Marco Felsch
2025-04-24 17:49     ` Alexander Shiyan
2025-04-24 12:08 ` Sascha Hauer [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aAopzC7K6bqoxunE@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=m.felsch@pengutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox