linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1] partitions/efi: Add 'gpt_sector' kernel cmdline parameter
@ 2020-02-19 16:23 Dmitry Osipenko
  2020-02-19 16:26 ` Ard Biesheuvel
  2020-02-19 16:27 ` Christoph Hellwig
  0 siblings, 2 replies; 10+ messages in thread
From: Dmitry Osipenko @ 2020-02-19 16:23 UTC (permalink / raw)
  To: Jens Axboe, Davidlohr Bueso, Colin Cross, Thierry Reding,
	Jonathan Hunter, Michał Mirosław, David Heidelberg,
	Peter Geis
  Cc: linux-efi, linux-tegra, linux-block, linux-doc, linux-kernel

The gpt_sector=<sector> causes the GPT partition search to look at the
specified sector for a valid GPT header if the GPT is not found at the
beginning or the end of block device.

In particular this is needed for NVIDIA Tegra consumer-grade Android
devices in order to make them usable with the upstream kernel because
these devices use a proprietary / closed-source partition table format
for the EMMC and it's impossible to change the partition's format. Luckily
there is a GPT table in addition to the proprietary table, which is placed
in uncommon location of the EMMC storage and bootloader passes the
location to kernel using "gpt gpt_sector=<sector>" cmdline parameters.

This patch is based on the original work done by Colin Cross for the
downstream Android kernel.

Cc: Colin Cross <ccross@android.com>
Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
---
 Documentation/admin-guide/kernel-parameters.txt |  5 +++++
 block/partitions/efi.c                          | 15 +++++++++++++++
 2 files changed, 20 insertions(+)

diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
index 50138e6826a1..ee4781daa379 100644
--- a/Documentation/admin-guide/kernel-parameters.txt
+++ b/Documentation/admin-guide/kernel-parameters.txt
@@ -1382,6 +1382,11 @@
 			primary GPT is corrupted, it enables the backup/alternate
 			GPT to be used instead.
 
+	gpt_sector	[EFI] Forces GPT partition search to look at the
+			specified sector for a valid GPT header if the GPT is
+			not found at the beginning or the end of the block
+			device.
+
 	grcan.enable0=	[HW] Configuration of physical interface 0. Determines
 			the "Enable 0" bit of the configuration register.
 			Format: 0 | 1
diff --git a/block/partitions/efi.c b/block/partitions/efi.c
index db2fef7dfc47..0c8926d76d7a 100644
--- a/block/partitions/efi.c
+++ b/block/partitions/efi.c
@@ -103,6 +103,17 @@ force_gpt_fn(char *str)
 }
 __setup("gpt", force_gpt_fn);
 
+/* This allows a kernel command line option 'gpt_sector=<sector>' to
+ * enable GPT header lookup at a non-standard location.
+ */
+static u64 force_gpt_sector;
+static int __init
+force_gpt_sector_fn(char *str)
+{
+	WARN_ON(kstrtoull(str, 10, &force_gpt_sector) < 0);
+	return 1;
+}
+__setup("gpt_sector=", force_gpt_sector_fn);
 
 /**
  * efi_crc32() - EFI version of crc32 function
@@ -621,6 +632,10 @@ static int find_valid_gpt(struct parsed_partitions *state, gpt_header **gpt,
         if (!good_agpt && force_gpt)
                 good_agpt = is_gpt_valid(state, lastlba, &agpt, &aptes);
 
+	if (!good_agpt && force_gpt && force_gpt_sector)
+		good_agpt = is_gpt_valid(state, force_gpt_sector,
+					 &agpt, &aptes);
+
         /* The obviously unsuccessful case */
         if (!good_pgpt && !good_agpt)
                 goto fail;
-- 
2.24.0


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

* Re: [PATCH v1] partitions/efi: Add 'gpt_sector' kernel cmdline parameter
  2020-02-19 16:23 [PATCH v1] partitions/efi: Add 'gpt_sector' kernel cmdline parameter Dmitry Osipenko
@ 2020-02-19 16:26 ` Ard Biesheuvel
  2020-02-19 16:36   ` Dmitry Osipenko
  2020-02-19 16:27 ` Christoph Hellwig
  1 sibling, 1 reply; 10+ messages in thread
From: Ard Biesheuvel @ 2020-02-19 16:26 UTC (permalink / raw)
  To: Dmitry Osipenko
  Cc: Jens Axboe, Davidlohr Bueso, Colin Cross, Thierry Reding,
	Jonathan Hunter, Michał Mirosław, David Heidelberg,
	Peter Geis, linux-efi, linux-tegra, linux-block,
	Linux Doc Mailing List, Linux Kernel Mailing List

On Wed, 19 Feb 2020 at 17:25, Dmitry Osipenko <digetx@gmail.com> wrote:
>
> The gpt_sector=<sector> causes the GPT partition search to look at the
> specified sector for a valid GPT header if the GPT is not found at the
> beginning or the end of block device.
>
> In particular this is needed for NVIDIA Tegra consumer-grade Android
> devices in order to make them usable with the upstream kernel because
> these devices use a proprietary / closed-source partition table format
> for the EMMC and it's impossible to change the partition's format. Luckily
> there is a GPT table in addition to the proprietary table, which is placed
> in uncommon location of the EMMC storage and bootloader passes the
> location to kernel using "gpt gpt_sector=<sector>" cmdline parameters.
>
> This patch is based on the original work done by Colin Cross for the
> downstream Android kernel.
>
> Cc: Colin Cross <ccross@android.com>
> Signed-off-by: Dmitry Osipenko <digetx@gmail.com>

Which block device is this parameter applied to?

> ---
>  Documentation/admin-guide/kernel-parameters.txt |  5 +++++
>  block/partitions/efi.c                          | 15 +++++++++++++++
>  2 files changed, 20 insertions(+)
>
> diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
> index 50138e6826a1..ee4781daa379 100644
> --- a/Documentation/admin-guide/kernel-parameters.txt
> +++ b/Documentation/admin-guide/kernel-parameters.txt
> @@ -1382,6 +1382,11 @@
>                         primary GPT is corrupted, it enables the backup/alternate
>                         GPT to be used instead.
>
> +       gpt_sector      [EFI] Forces GPT partition search to look at the
> +                       specified sector for a valid GPT header if the GPT is
> +                       not found at the beginning or the end of the block
> +                       device.
> +
>         grcan.enable0=  [HW] Configuration of physical interface 0. Determines
>                         the "Enable 0" bit of the configuration register.
>                         Format: 0 | 1
> diff --git a/block/partitions/efi.c b/block/partitions/efi.c
> index db2fef7dfc47..0c8926d76d7a 100644
> --- a/block/partitions/efi.c
> +++ b/block/partitions/efi.c
> @@ -103,6 +103,17 @@ force_gpt_fn(char *str)
>  }
>  __setup("gpt", force_gpt_fn);
>
> +/* This allows a kernel command line option 'gpt_sector=<sector>' to
> + * enable GPT header lookup at a non-standard location.
> + */
> +static u64 force_gpt_sector;
> +static int __init
> +force_gpt_sector_fn(char *str)
> +{
> +       WARN_ON(kstrtoull(str, 10, &force_gpt_sector) < 0);
> +       return 1;
> +}
> +__setup("gpt_sector=", force_gpt_sector_fn);
>
>  /**
>   * efi_crc32() - EFI version of crc32 function
> @@ -621,6 +632,10 @@ static int find_valid_gpt(struct parsed_partitions *state, gpt_header **gpt,
>          if (!good_agpt && force_gpt)
>                  good_agpt = is_gpt_valid(state, lastlba, &agpt, &aptes);
>
> +       if (!good_agpt && force_gpt && force_gpt_sector)
> +               good_agpt = is_gpt_valid(state, force_gpt_sector,
> +                                        &agpt, &aptes);
> +
>          /* The obviously unsuccessful case */
>          if (!good_pgpt && !good_agpt)
>                  goto fail;
> --
> 2.24.0
>

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

* Re: [PATCH v1] partitions/efi: Add 'gpt_sector' kernel cmdline parameter
  2020-02-19 16:23 [PATCH v1] partitions/efi: Add 'gpt_sector' kernel cmdline parameter Dmitry Osipenko
  2020-02-19 16:26 ` Ard Biesheuvel
@ 2020-02-19 16:27 ` Christoph Hellwig
  2020-02-19 16:38   ` Dmitry Osipenko
  2020-02-19 16:59   ` Stephen Warren
  1 sibling, 2 replies; 10+ messages in thread
From: Christoph Hellwig @ 2020-02-19 16:27 UTC (permalink / raw)
  To: Dmitry Osipenko
  Cc: Jens Axboe, Davidlohr Bueso, Colin Cross, Thierry Reding,
	Jonathan Hunter, Michał Mirosław, David Heidelberg,
	Peter Geis, linux-efi, linux-tegra, linux-block, linux-doc,
	linux-kernel

On Wed, Feb 19, 2020 at 07:23:39PM +0300, Dmitry Osipenko wrote:
> The gpt_sector=<sector> causes the GPT partition search to look at the
> specified sector for a valid GPT header if the GPT is not found at the
> beginning or the end of block device.
> 
> In particular this is needed for NVIDIA Tegra consumer-grade Android
> devices in order to make them usable with the upstream kernel because
> these devices use a proprietary / closed-source partition table format
> for the EMMC and it's impossible to change the partition's format. Luckily
> there is a GPT table in addition to the proprietary table, which is placed
> in uncommon location of the EMMC storage and bootloader passes the
> location to kernel using "gpt gpt_sector=<sector>" cmdline parameters.
> 
> This patch is based on the original work done by Colin Cross for the
> downstream Android kernel.

I don't think a magic command line is the way to go.  The best would be
to reverse-engineer the proprietary partition table format.  If that is
too hard we can at least key off the odd GPT location based of it's
magic number.

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

* Re: [PATCH v1] partitions/efi: Add 'gpt_sector' kernel cmdline parameter
  2020-02-19 16:26 ` Ard Biesheuvel
@ 2020-02-19 16:36   ` Dmitry Osipenko
  0 siblings, 0 replies; 10+ messages in thread
From: Dmitry Osipenko @ 2020-02-19 16:36 UTC (permalink / raw)
  To: Ard Biesheuvel
  Cc: Jens Axboe, Davidlohr Bueso, Colin Cross, Thierry Reding,
	Jonathan Hunter, Michał Mirosław, David Heidelberg,
	Peter Geis, linux-efi, linux-tegra, linux-block,
	Linux Doc Mailing List, Linux Kernel Mailing List

19.02.2020 19:26, Ard Biesheuvel пишет:
> On Wed, 19 Feb 2020 at 17:25, Dmitry Osipenko <digetx@gmail.com> wrote:
>>
>> The gpt_sector=<sector> causes the GPT partition search to look at the
>> specified sector for a valid GPT header if the GPT is not found at the
>> beginning or the end of block device.
>>
>> In particular this is needed for NVIDIA Tegra consumer-grade Android
>> devices in order to make them usable with the upstream kernel because
>> these devices use a proprietary / closed-source partition table format
>> for the EMMC and it's impossible to change the partition's format. Luckily
>> there is a GPT table in addition to the proprietary table, which is placed
>> in uncommon location of the EMMC storage and bootloader passes the
>> location to kernel using "gpt gpt_sector=<sector>" cmdline parameters.
>>
>> This patch is based on the original work done by Colin Cross for the
>> downstream Android kernel.
>>
>> Cc: Colin Cross <ccross@android.com>
>> Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
> 
> Which block device is this parameter applied to?

All available devices.

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

* Re: [PATCH v1] partitions/efi: Add 'gpt_sector' kernel cmdline parameter
  2020-02-19 16:27 ` Christoph Hellwig
@ 2020-02-19 16:38   ` Dmitry Osipenko
  2020-02-19 16:59   ` Stephen Warren
  1 sibling, 0 replies; 10+ messages in thread
From: Dmitry Osipenko @ 2020-02-19 16:38 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Jens Axboe, Davidlohr Bueso, Colin Cross, Thierry Reding,
	Jonathan Hunter, Michał Mirosław, David Heidelberg,
	Peter Geis, linux-efi, linux-tegra, linux-block, linux-doc,
	linux-kernel

19.02.2020 19:27, Christoph Hellwig пишет:
> On Wed, Feb 19, 2020 at 07:23:39PM +0300, Dmitry Osipenko wrote:
>> The gpt_sector=<sector> causes the GPT partition search to look at the
>> specified sector for a valid GPT header if the GPT is not found at the
>> beginning or the end of block device.
>>
>> In particular this is needed for NVIDIA Tegra consumer-grade Android
>> devices in order to make them usable with the upstream kernel because
>> these devices use a proprietary / closed-source partition table format
>> for the EMMC and it's impossible to change the partition's format. Luckily
>> there is a GPT table in addition to the proprietary table, which is placed
>> in uncommon location of the EMMC storage and bootloader passes the
>> location to kernel using "gpt gpt_sector=<sector>" cmdline parameters.
>>
>> This patch is based on the original work done by Colin Cross for the
>> downstream Android kernel.
> 
> I don't think a magic command line is the way to go.  The best would be
> to reverse-engineer the proprietary partition table format.  If that is
> too hard we can at least key off the odd GPT location based of it's
> magic number.

I'll try to take a look at RE, pretty sure somebody tried to do that before.

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

* Re: [PATCH v1] partitions/efi: Add 'gpt_sector' kernel cmdline parameter
  2020-02-19 16:27 ` Christoph Hellwig
  2020-02-19 16:38   ` Dmitry Osipenko
@ 2020-02-19 16:59   ` Stephen Warren
  2020-02-19 17:44     ` Dmitry Osipenko
  2020-02-24 16:33     ` Karel Zak
  1 sibling, 2 replies; 10+ messages in thread
From: Stephen Warren @ 2020-02-19 16:59 UTC (permalink / raw)
  To: Christoph Hellwig, Dmitry Osipenko
  Cc: Jens Axboe, Davidlohr Bueso, Colin Cross, Thierry Reding,
	Jonathan Hunter, Michał Mirosław, David Heidelberg,
	Peter Geis, linux-efi, linux-tegra, linux-block, linux-doc,
	linux-kernel

On 2/19/20 9:27 AM, Christoph Hellwig wrote:
> On Wed, Feb 19, 2020 at 07:23:39PM +0300, Dmitry Osipenko wrote:
>> The gpt_sector=<sector> causes the GPT partition search to look at the
>> specified sector for a valid GPT header if the GPT is not found at the
>> beginning or the end of block device.
>>
>> In particular this is needed for NVIDIA Tegra consumer-grade Android
>> devices in order to make them usable with the upstream kernel because
>> these devices use a proprietary / closed-source partition table format
>> for the EMMC and it's impossible to change the partition's format. Luckily
>> there is a GPT table in addition to the proprietary table, which is placed
>> in uncommon location of the EMMC storage and bootloader passes the
>> location to kernel using "gpt gpt_sector=<sector>" cmdline parameters.
>>
>> This patch is based on the original work done by Colin Cross for the
>> downstream Android kernel.
> 
> I don't think a magic command line is the way to go.  The best would be
> to reverse-engineer the proprietary partition table format.  If that is
> too hard we can at least key off the odd GPT location based of it's
> magic number.

I thought that the backup GPT was always present in the standard 
location; it's just the primary GPT that's in an odd location. So, this 
kernel parameter just forces the kernel to look first for the primary 
GPT in the unusual location, thus avoiding an error message when that's 
not there, and the system falls back to the backup GPT.

Or, do I misremember the layout, or the kernel's behaviour if primary 
GPT is missing?

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

* Re: [PATCH v1] partitions/efi: Add 'gpt_sector' kernel cmdline parameter
  2020-02-19 16:59   ` Stephen Warren
@ 2020-02-19 17:44     ` Dmitry Osipenko
  2020-02-24 16:33     ` Karel Zak
  1 sibling, 0 replies; 10+ messages in thread
From: Dmitry Osipenko @ 2020-02-19 17:44 UTC (permalink / raw)
  To: Stephen Warren, Christoph Hellwig
  Cc: Jens Axboe, Davidlohr Bueso, Colin Cross, Thierry Reding,
	Jonathan Hunter, Michał Mirosław, David Heidelberg,
	Peter Geis, linux-efi, linux-tegra, linux-block, linux-doc,
	linux-kernel

19.02.2020 19:59, Stephen Warren пишет:
> On 2/19/20 9:27 AM, Christoph Hellwig wrote:
>> On Wed, Feb 19, 2020 at 07:23:39PM +0300, Dmitry Osipenko wrote:
>>> The gpt_sector=<sector> causes the GPT partition search to look at the
>>> specified sector for a valid GPT header if the GPT is not found at the
>>> beginning or the end of block device.
>>>
>>> In particular this is needed for NVIDIA Tegra consumer-grade Android
>>> devices in order to make them usable with the upstream kernel because
>>> these devices use a proprietary / closed-source partition table format
>>> for the EMMC and it's impossible to change the partition's format.
>>> Luckily
>>> there is a GPT table in addition to the proprietary table, which is
>>> placed
>>> in uncommon location of the EMMC storage and bootloader passes the
>>> location to kernel using "gpt gpt_sector=<sector>" cmdline parameters.
>>>
>>> This patch is based on the original work done by Colin Cross for the
>>> downstream Android kernel.
>>
>> I don't think a magic command line is the way to go.  The best would be
>> to reverse-engineer the proprietary partition table format.  If that is
>> too hard we can at least key off the odd GPT location based of it's
>> magic number.
> 
> I thought that the backup GPT was always present in the standard
> location; it's just the primary GPT that's in an odd location. So, this
> kernel parameter just forces the kernel to look first for the primary
> GPT in the unusual location, thus avoiding an error message when that's
> not there, and the system falls back to the backup GPT.
> 
> Or, do I misremember the layout, or the kernel's behaviour if primary
> GPT is missing?

The backup GPT not always presents in the standard location. For example
Tegra30 ASUS Google Nexus 7 has a backup GPT in the proper location and
this is what KMSG prints:

[    1.722888] Primary GPT is invalid, using alternate GPT.
[    1.723076]  mmcblk1: p1 p2 p3 p4 p5 p6 p7 p8 p9 p10

But this doesn't work for Tegra20 Acer A500 and (IIRC) Tegra30 Ouya
because both primary and backup GPTs are invalid at the standard locations.

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

* Re: [PATCH v1] partitions/efi: Add 'gpt_sector' kernel cmdline parameter
  2020-02-19 16:59   ` Stephen Warren
  2020-02-19 17:44     ` Dmitry Osipenko
@ 2020-02-24 16:33     ` Karel Zak
  2020-02-24 17:23       ` Dmitry Osipenko
  1 sibling, 1 reply; 10+ messages in thread
From: Karel Zak @ 2020-02-24 16:33 UTC (permalink / raw)
  To: Stephen Warren
  Cc: Christoph Hellwig, Dmitry Osipenko, Jens Axboe, Davidlohr Bueso,
	Colin Cross, Thierry Reding, Jonathan Hunter,
	Michał Mirosław, David Heidelberg, Peter Geis,
	linux-efi, linux-tegra, linux-block, linux-doc, linux-kernel

On Wed, Feb 19, 2020 at 09:59:54AM -0700, Stephen Warren wrote:
> On 2/19/20 9:27 AM, Christoph Hellwig wrote:
> > On Wed, Feb 19, 2020 at 07:23:39PM +0300, Dmitry Osipenko wrote:
> > > The gpt_sector=<sector> causes the GPT partition search to look at the
> > > specified sector for a valid GPT header if the GPT is not found at the
> > > beginning or the end of block device.
> > > 
> > > In particular this is needed for NVIDIA Tegra consumer-grade Android
> > > devices in order to make them usable with the upstream kernel because
> > > these devices use a proprietary / closed-source partition table format
> > > for the EMMC and it's impossible to change the partition's format. Luckily
> > > there is a GPT table in addition to the proprietary table, which is placed
> > > in uncommon location of the EMMC storage and bootloader passes the
> > > location to kernel using "gpt gpt_sector=<sector>" cmdline parameters.
> > > 
> > > This patch is based on the original work done by Colin Cross for the
> > > downstream Android kernel.
> > 
> > I don't think a magic command line is the way to go.  The best would be
> > to reverse-engineer the proprietary partition table format.  If that is
> > too hard we can at least key off the odd GPT location based of it's
> > magic number.

 +1

> I thought that the backup GPT was always present in the standard location;

If they have proprietary stuff on begin of the device and valid backup
GPT at the end of the device then designer of this junk is crazy, because
many GPT fdisk-like tools will try to recover from the backup header and 
overwrite the unknown (invalid) stuff at the begin of the device...

    Karel


-- 
 Karel Zak  <kzak@redhat.com>
 http://karelzak.blogspot.com


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

* Re: [PATCH v1] partitions/efi: Add 'gpt_sector' kernel cmdline parameter
  2020-02-24 16:33     ` Karel Zak
@ 2020-02-24 17:23       ` Dmitry Osipenko
  2020-02-24 18:22         ` Dmitry Osipenko
  0 siblings, 1 reply; 10+ messages in thread
From: Dmitry Osipenko @ 2020-02-24 17:23 UTC (permalink / raw)
  To: Karel Zak, Stephen Warren
  Cc: Christoph Hellwig, Jens Axboe, Davidlohr Bueso, Colin Cross,
	Thierry Reding, Jonathan Hunter, Michał Mirosław,
	David Heidelberg, Peter Geis, linux-efi, linux-tegra,
	linux-block, linux-doc, linux-kernel

24.02.2020 19:33, Karel Zak пишет:
> On Wed, Feb 19, 2020 at 09:59:54AM -0700, Stephen Warren wrote:
>> On 2/19/20 9:27 AM, Christoph Hellwig wrote:
>>> On Wed, Feb 19, 2020 at 07:23:39PM +0300, Dmitry Osipenko wrote:
>>>> The gpt_sector=<sector> causes the GPT partition search to look at the
>>>> specified sector for a valid GPT header if the GPT is not found at the
>>>> beginning or the end of block device.
>>>>
>>>> In particular this is needed for NVIDIA Tegra consumer-grade Android
>>>> devices in order to make them usable with the upstream kernel because
>>>> these devices use a proprietary / closed-source partition table format
>>>> for the EMMC and it's impossible to change the partition's format. Luckily
>>>> there is a GPT table in addition to the proprietary table, which is placed
>>>> in uncommon location of the EMMC storage and bootloader passes the
>>>> location to kernel using "gpt gpt_sector=<sector>" cmdline parameters.
>>>>
>>>> This patch is based on the original work done by Colin Cross for the
>>>> downstream Android kernel.
>>>
>>> I don't think a magic command line is the way to go.  The best would be
>>> to reverse-engineer the proprietary partition table format.  If that is
>>> too hard we can at least key off the odd GPT location based of it's
>>> magic number.
> 
>  +1
> 
>> I thought that the backup GPT was always present in the standard location;
> 
> If they have proprietary stuff on begin of the device and valid backup
> GPT at the end of the device then designer of this junk is crazy, because
> many GPT fdisk-like tools will try to recover from the backup header and 
> overwrite the unknown (invalid) stuff at the begin of the device...

It's a problem created by vendor, but these devices are assumed to run
Android-only. So it's not really that bad :)

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

* Re: [PATCH v1] partitions/efi: Add 'gpt_sector' kernel cmdline parameter
  2020-02-24 17:23       ` Dmitry Osipenko
@ 2020-02-24 18:22         ` Dmitry Osipenko
  0 siblings, 0 replies; 10+ messages in thread
From: Dmitry Osipenko @ 2020-02-24 18:22 UTC (permalink / raw)
  To: Karel Zak, Stephen Warren, Jens Axboe
  Cc: Christoph Hellwig, Davidlohr Bueso, Colin Cross, Thierry Reding,
	Jonathan Hunter, Michał Mirosław, David Heidelberg,
	Peter Geis, linux-efi, linux-tegra, linux-block, linux-doc,
	linux-kernel

24.02.2020 20:23, Dmitry Osipenko пишет:
> 24.02.2020 19:33, Karel Zak пишет:
>> On Wed, Feb 19, 2020 at 09:59:54AM -0700, Stephen Warren wrote:
>>> On 2/19/20 9:27 AM, Christoph Hellwig wrote:
>>>> On Wed, Feb 19, 2020 at 07:23:39PM +0300, Dmitry Osipenko wrote:
>>>>> The gpt_sector=<sector> causes the GPT partition search to look at the
>>>>> specified sector for a valid GPT header if the GPT is not found at the
>>>>> beginning or the end of block device.
>>>>>
>>>>> In particular this is needed for NVIDIA Tegra consumer-grade Android
>>>>> devices in order to make them usable with the upstream kernel because
>>>>> these devices use a proprietary / closed-source partition table format
>>>>> for the EMMC and it's impossible to change the partition's format. Luckily
>>>>> there is a GPT table in addition to the proprietary table, which is placed
>>>>> in uncommon location of the EMMC storage and bootloader passes the
>>>>> location to kernel using "gpt gpt_sector=<sector>" cmdline parameters.
>>>>>
>>>>> This patch is based on the original work done by Colin Cross for the
>>>>> downstream Android kernel.
>>>>
>>>> I don't think a magic command line is the way to go.  The best would be
>>>> to reverse-engineer the proprietary partition table format.  If that is
>>>> too hard we can at least key off the odd GPT location based of it's
>>>> magic number.
>>
>>  +1
>>
>>> I thought that the backup GPT was always present in the standard location;
>>
>> If they have proprietary stuff on begin of the device and valid backup
>> GPT at the end of the device then designer of this junk is crazy, because
>> many GPT fdisk-like tools will try to recover from the backup header and 
>> overwrite the unknown (invalid) stuff at the begin of the device...
> 
> It's a problem created by vendor, but these devices are assumed to run
> Android-only. So it's not really that bad :)
> 

Is there any way to mark parts of block device as read-only? Such that
userspace couldn't write to the RO-marked sectors, I guess that could
help to save someone's bacon.

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

end of thread, other threads:[~2020-02-24 18:22 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-19 16:23 [PATCH v1] partitions/efi: Add 'gpt_sector' kernel cmdline parameter Dmitry Osipenko
2020-02-19 16:26 ` Ard Biesheuvel
2020-02-19 16:36   ` Dmitry Osipenko
2020-02-19 16:27 ` Christoph Hellwig
2020-02-19 16:38   ` Dmitry Osipenko
2020-02-19 16:59   ` Stephen Warren
2020-02-19 17:44     ` Dmitry Osipenko
2020-02-24 16:33     ` Karel Zak
2020-02-24 17:23       ` Dmitry Osipenko
2020-02-24 18:22         ` Dmitry Osipenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).