CHROMIUM: block: partitions: efi: Add support for IGNOREME G... [chromiumos/third_party/kernel : release-R51-8172.B-chromeos-3.14]

13 views
Skip to first unread message

Julius Werner (Gerrit)

unread,
Jun 21, 2016, 7:21:04 PM6/21/16
to Gwendal Grignou, Douglas Anderson, Bernie Thompson
Hello Gwendal Grignou, Douglas Anderson, Bernie Thompson,

I'd like you to do a code review. Please visit

https://chromium-review.googlesource.com/354652

to review the following change.


Change subject: CHROMIUM: block: partitions: efi: Add support for IGNOREME
GPT signature
......................................................................

CHROMIUM: block: partitions: efi: Add support for IGNOREME GPT signature

This patch adds support for a special GPT header signature marker (using
the string 'IGNOREME' instead of the spec's 'EFI PART'). This tells the
kernel to ignore this GPT completely and look at the other one instead.
Since the kernel always prefers the primary GPT anyway, all we really
need to do effectively is to check whether the primary GPT is marked
'IGNOREME' and force evaluation of the secondary one in that case.

BUG=chrome-os-partner:52595
TEST=Booted on Minnie with 'IGNOREME' primary GPT

Change-Id: Ibaee639fac9fa2f04b8836ef153c95b7d0b045a4
Signed-off-by: Julius Werner <jwe...@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/340080
Reviewed-by: Gwendal Grignou <gwe...@chromium.org>
(cherry picked from commit abba28d0a1b7361da6e2023352e92687166ca30d)
---
M block/partitions/efi.c
M block/partitions/efi.h
2 files changed, 22 insertions(+), 10 deletions(-)



diff --git a/block/partitions/efi.c b/block/partitions/efi.c
index 4bf0f97..b33671d 100644
--- a/block/partitions/efi.c
+++ b/block/partitions/efi.c
@@ -348,23 +348,32 @@
* @lba is the logical block address of the GPT header to test
* @gpt is a GPT header ptr, filled on return.
* @ptes is a PTEs ptr, filled on return.
+ * @ignored is filled on return with 1 if this is an IGNOREME GPT,
+ * 0 otherwise. May be NULL.
*
* Description: returns 1 if valid, 0 on error.
* If valid, returns pointers to newly allocated GPT header and PTEs.
*/
static int is_gpt_valid(struct parsed_partitions *state, u64 lba,
- gpt_header **gpt, gpt_entry **ptes)
+ gpt_header **gpt, gpt_entry **ptes, int *ignored)
{
u32 crc, origcrc;
u64 lastlba;

+ if (ignored)
+ *ignored = 0;
if (!ptes)
return 0;
if (!(*gpt = alloc_read_gpt_header(state, lba)))
return 0;

/* Check the GUID Partition Table signature */
- if (le64_to_cpu((*gpt)->signature) != GPT_HEADER_SIGNATURE) {
+ if (le64_to_cpu((*gpt)->signature) == GPT_HEADER_SIGNATURE_IGNORED) {
+ pr_debug("GUID Partition Table at LBA %llu marked IGNOREME\n");
+ if (ignored)
+ *ignored = 1;
+ goto fail;
+ } else if (le64_to_cpu((*gpt)->signature) != GPT_HEADER_SIGNATURE) {
pr_debug("GUID Partition Table Header signature is wrong:"
"%lld != %lld\n",
(unsigned long long)le64_to_cpu((*gpt)->signature),
@@ -592,7 +601,7 @@
static int find_valid_gpt(struct parsed_partitions *state, gpt_header
**gpt,
gpt_entry **ptes)
{
- int good_pgpt = 0, good_agpt = 0, good_pmbr = 0;
+ int good_pgpt = 0, good_agpt = 0, good_pmbr = 0, pgpt_ignored = 0;
gpt_header *pgpt = NULL, *agpt = NULL;
gpt_entry *pptes = NULL, *aptes = NULL;
legacy_mbr *legacymbr;
@@ -622,19 +631,20 @@
}

good_pgpt = is_gpt_valid(state, GPT_PRIMARY_PARTITION_TABLE_LBA,
- &pgpt, &pptes);
+ &pgpt, &pptes, &pgpt_ignored);
if (good_pgpt)
good_agpt = is_gpt_valid(state,
le64_to_cpu(pgpt->alternate_lba),
- &agpt, &aptes);
- if (!good_agpt && force_gpt)
- good_agpt = is_gpt_valid(state, lastlba, &agpt, &aptes);
+ &agpt, &aptes, NULL);
+ if (!good_agpt && (force_gpt || pgpt_ignored))
+ good_agpt = is_gpt_valid(state, lastlba, &agpt, &aptes, NULL);

/* The obviously unsuccessful case */
if (!good_pgpt && !good_agpt)
goto fail;

- compare_gpts(pgpt, agpt, lastlba);
+ if (!pgpt_ignored)
+ compare_gpts(pgpt, agpt, lastlba);

/* The good cases */
if (good_pgpt) {
@@ -651,7 +661,8 @@
*ptes = aptes;
kfree(pgpt);
kfree(pptes);
- pr_warn("Primary GPT is invalid, using alternate GPT.\n");
+ pr_warn("Primary GPT is %s, using alternate GPT.\n",
+ pgpt_ignored ? "being ignored" : "invalid");
return 1;
}

diff --git a/block/partitions/efi.h b/block/partitions/efi.h
index 4efcafb..3a13ef9 100644
--- a/block/partitions/efi.h
+++ b/block/partitions/efi.h
@@ -40,7 +40,8 @@
#define GPT_MBR_PROTECTIVE 1
#define GPT_MBR_HYBRID 2

-#define GPT_HEADER_SIGNATURE 0x5452415020494645ULL
+#define GPT_HEADER_SIGNATURE 0x5452415020494645ULL /* 'EFI PART' */
+#define GPT_HEADER_SIGNATURE_IGNORED 0x454d45524f4e4749ULL /* 'IGNOREME' */
#define GPT_HEADER_REVISION_V1 0x00010000
#define GPT_PRIMARY_PARTITION_TABLE_LBA 1


--
To view, visit https://chromium-review.googlesource.com/354652
To unsubscribe, visit https://chromium-review.googlesource.com/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ibaee639fac9fa2f04b8836ef153c95b7d0b045a4
Gerrit-PatchSet: 1
Gerrit-Project: chromiumos/third_party/kernel
Gerrit-Branch: release-R51-8172.B-chromeos-3.14
Gerrit-Owner: Julius Werner <jwe...@chromium.org>
Gerrit-Reviewer: Bernie Thompson <bhtho...@chromium.org>
Gerrit-Reviewer: Douglas Anderson <dian...@chromium.org>
Gerrit-Reviewer: Gwendal Grignou <gwe...@chromium.org>

Bernie Thompson (Gerrit)

unread,
Jun 21, 2016, 7:44:52 PM6/21/16
to Julius Werner, Douglas Anderson, Gwendal Grignou
Bernie Thompson has posted comments on this change. (
https://chromium-review.googlesource.com/354652 )

Change subject: CHROMIUM: block: partitions: efi: Add support for IGNOREME
GPT signature
......................................................................


Patch Set 1: Verified+1 Code-Review+2 Commit-Queue+1
Gerrit-MessageType: comment
Gerrit-Change-Id: Ibaee639fac9fa2f04b8836ef153c95b7d0b045a4
Gerrit-PatchSet: 1
Gerrit-Project: chromiumos/third_party/kernel
Gerrit-Branch: release-R51-8172.B-chromeos-3.14
Gerrit-Owner: Julius Werner <jwe...@chromium.org>
Gerrit-Reviewer: Bernie Thompson <bhtho...@chromium.org>
Gerrit-Reviewer: Douglas Anderson <dian...@chromium.org>
Gerrit-Reviewer: Gwendal Grignou <gwe...@chromium.org>
Gerrit-HasComments: No

ChromeOS Commit Bot (Gerrit)

unread,
Jun 21, 2016, 7:51:26 PM6/21/16
to Julius Werner, Bernie Thompson, Douglas Anderson, Gwendal Grignou
ChromeOS Commit Bot has submitted this change and it was merged. (
https://chromium-review.googlesource.com/354652 )

Change subject: CHROMIUM: block: partitions: efi: Add support for IGNOREME
GPT signature
......................................................................


CHROMIUM: block: partitions: efi: Add support for IGNOREME GPT signature

This patch adds support for a special GPT header signature marker (using
the string 'IGNOREME' instead of the spec's 'EFI PART'). This tells the
kernel to ignore this GPT completely and look at the other one instead.
Since the kernel always prefers the primary GPT anyway, all we really
need to do effectively is to check whether the primary GPT is marked
'IGNOREME' and force evaluation of the secondary one in that case.

BUG=chrome-os-partner:52595
TEST=Booted on Minnie with 'IGNOREME' primary GPT

Change-Id: Ibaee639fac9fa2f04b8836ef153c95b7d0b045a4
Signed-off-by: Julius Werner <jwe...@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/340080
Reviewed-by: Gwendal Grignou <gwe...@chromium.org>
(cherry picked from commit abba28d0a1b7361da6e2023352e92687166ca30d)
Reviewed-on: https://chromium-review.googlesource.com/354652
Reviewed-by: Bernie Thompson <bhtho...@chromium.org>
Commit-Queue: Bernie Thompson <bhtho...@chromium.org>
Tested-by: Bernie Thompson <bhtho...@chromium.org>
---
M block/partitions/efi.c
M block/partitions/efi.h
2 files changed, 22 insertions(+), 10 deletions(-)

Approvals:
Bernie Thompson: Looks good to me, approved; Ready; Verified
Gerrit-MessageType: merged
Gerrit-Change-Id: Ibaee639fac9fa2f04b8836ef153c95b7d0b045a4
Gerrit-PatchSet: 2
Gerrit-Project: chromiumos/third_party/kernel
Gerrit-Branch: release-R51-8172.B-chromeos-3.14
Gerrit-Owner: Julius Werner <jwe...@chromium.org>
Gerrit-Reviewer: Bernie Thompson <bhtho...@chromium.org>
Gerrit-Reviewer: ChromeOS Commit Bot <chromeos-...@chromium.org>
Reply all
Reply to author
Forward
0 new messages