All of lore.kernel.org
 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; 2+ messages 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 related	[flat|nested] 2+ messages in thread

* [PATCH] efi: add gpt_overprovisioned kernel command line parameter
@ 2017-07-13 22:21 ` Mark Salyzyn
  0 siblings, 0 replies; 2+ messages in thread
From: Mark Salyzyn @ 2017-07-13 22:21 UTC (permalink / raw)
  To: linux-kernel-u79uwXL29TY76Z2rM5mHXA
  Cc: Mark Salyzyn, Davidlohr Bueso, Jens Axboe,
	linux-efi-u79uwXL29TY76Z2rM5mHXA,
	linux-block-u79uwXL29TY76Z2rM5mHXA

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-z5hGa2qSFaRBDgjK7y7TUQ@public.gmane.org>
---
 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 related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-07-13 22:21 UTC | newest]

Thread overview: 2+ messages (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
2017-07-13 22:21 ` Mark Salyzyn

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.