mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] efi: add gpt_overprovisioned kernel command line parameter
@ 2017-07-13 22:21 Mark Salyzyn
  0 siblings, 0 replies; only message in thread
From: Mark Salyzyn @ 2017-07-13 22:21 UTC (permalink / raw)
  To: linux-kernel
  Cc: Mark Salyzyn, Davidlohr Bueso, Jens Axboe, linux-efi, linux-block

Allow a gpt partition table to be used if it is overprovisioned, the
last usable lba in the GPT headers is beyond the device boundaries.
This feature is enabled if gpt_overprovisioned is added to the kernel
command line.  It will not expose any individual partitions that go
beyond the device boundaries, just the ones that are under that limit.

Default off, one can perform an exploratory boot of the kernel and
triage or backup the properly provisioned partitions.  This would
allow the system to at least partially boot. For example if the boot,
root or system filesystems reside on properly provisioned partitions.

Examples, helpful should a RAID array be resized downwards, or
during embedded development should an overprovisioned partition
table update be flashed to a device by accident.

Signed-off-by: Mark Salyzyn <salyzyn@android.com>
---
 block/partitions/efi.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/block/partitions/efi.c b/block/partitions/efi.c
index 39f70d968754..e18ee5cf138c 100644
--- a/block/partitions/efi.c
+++ b/block/partitions/efi.c
@@ -117,6 +117,15 @@ force_gpt_fn(char *str)
 }
 __setup("gpt", force_gpt_fn);
 
+static int overprovisioned_gpt;
+static int __init
+overprovisioned_gpt_fn(char *str)
+{
+	overprovisioned_gpt = 1;
+	return 1;
+}
+__setup("gpt_overprovisioned", overprovisioned_gpt_fn);
+
 
 /**
  * efi_crc32() - EFI version of crc32 function
@@ -420,7 +429,8 @@ static int is_gpt_valid(struct parsed_partitions *state, u64 lba,
 		pr_debug("GPT: last_usable_lba incorrect: %lld > %lld\n",
 			 (unsigned long long)le64_to_cpu((*gpt)->last_usable_lba),
 			 (unsigned long long)lastlba);
-		goto fail;
+		if (!overprovisioned_gpt)
+			goto fail;
 	}
 	if (le64_to_cpu((*gpt)->last_usable_lba) < le64_to_cpu((*gpt)->first_usable_lba)) {
 		pr_debug("GPT: last_usable_lba incorrect: %lld > %lld\n",
-- 
2.13.2.932.g7449e964c-goog

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2017-07-13 22:22 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-07-13 22:21 [PATCH] efi: add gpt_overprovisioned kernel command line parameter Mark Salyzyn

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®