From: Davidlohr Bueso <davidlohr@hp.com>
To: Andrew Morton <akpm@linux-foundation.org>, Jens Axboe <axboe@kernel.dk>
Cc: Matt Domsch <Matt_Domsch@dell.com>, Jim Hull <jim.hull@hp.com>,
Karel Zak <kzak@redhat.com>, Peter Jones <pjones@redhat.com>,
Chegu Vinod <chegu_vinod@hp.com>,
Aswin Chandramouleeswaran <aswin@hp.com>,
linux-kernel@vger.kernel.org, Davidlohr Bueso <davidlohr@hp.com>
Subject: [PATCH 1/8] partitions/efi: use lba-aware partition records
Date: Mon, 5 Aug 2013 22:21:09 -0700 [thread overview]
Message-ID: <1375766476-4204-2-git-send-email-davidlohr@hp.com> (raw)
In-Reply-To: <1375766476-4204-1-git-send-email-davidlohr@hp.com>
The kernel's GPT implementation currently uses the generic
'struct partition' type for dealing with legacy MBR partition
records. While this is is useful for disklabels that we designed
for CHS addressing, such as msdos, it doesn't adapt well to newer
standards that use LBA instead, such as GUID partition tables.
Furthermore, these generic partition structures do not have all the
required fields to properly follow the UEFI specs.
While a CHS address can be translated to LBA, it's much simpler and
cleaner to just replace the partition type. This patch adds a new
'gpt_record' type that is fully compliant with EFI and will allow,
in the next patches, to add more checks to properly verify a protective
MBR, which is paramount to probing a device that makes use of GPT.
Signed-off-by: Davidlohr Bueso <davidlohr@hp.com>
---
block/partitions/efi.c | 7 +++----
block/partitions/efi.h | 16 +++++++++++++++-
2 files changed, 18 insertions(+), 5 deletions(-)
diff --git a/block/partitions/efi.c b/block/partitions/efi.c
index c85fc89..3ebd3d8 100644
--- a/block/partitions/efi.c
+++ b/block/partitions/efi.c
@@ -149,11 +149,10 @@ static u64 last_lba(struct block_device *bdev)
bdev_logical_block_size(bdev)) - 1ULL;
}
-static inline int
-pmbr_part_valid(struct partition *part)
+static inline int pmbr_part_valid(gpt_record *part)
{
- if (part->sys_ind == EFI_PMBR_OSTYPE_EFI_GPT &&
- le32_to_cpu(part->start_sect) == 1UL)
+ if (part->os_type == EFI_PMBR_OSTYPE_EFI_GPT &&
+ le32_to_cpu(part->start_sector) == 1UL)
return 1;
return 0;
}
diff --git a/block/partitions/efi.h b/block/partitions/efi.h
index b69ab72..46cf1a4 100644
--- a/block/partitions/efi.h
+++ b/block/partitions/efi.h
@@ -101,11 +101,25 @@ typedef struct _gpt_entry {
efi_char16_t partition_name[72 / sizeof (efi_char16_t)];
} __attribute__ ((packed)) gpt_entry;
+typedef struct _gpt_record {
+ u8 boot_indicator; /* unused by EFI, set to 0x80 for bootable */
+ u8 start_head; /* unused by EFI, pt start in CHS */
+ u8 start_sector; /* unused by EFI, pt start in CHS */
+ u8 start_track;
+ u8 os_type; /* EFI and legacy non-EFI OS types */
+ u8 end_head; /* unused by EFI, pt end in CHS */
+ u8 end_sector; /* unused by EFI, pt end in CHS */
+ u8 end_track; /* unused by EFI, pt end in CHS */
+ __le32 starting_lba; /* used by EFI - start addr of the on disk pt */
+ __le32 size_in_lba; /* used by EFI - size of pt in LBA */
+} __attribute__ ((packed)) gpt_record;
+
+
typedef struct _legacy_mbr {
u8 boot_code[440];
__le32 unique_mbr_signature;
__le16 unknown;
- struct partition partition_record[4];
+ gpt_record partition_record[4];
__le16 signature;
} __attribute__ ((packed)) legacy_mbr;
--
1.7.11.7
next prev parent reply other threads:[~2013-08-06 5:29 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-08-06 5:21 [PATCH 0/8] partitions/efi: detect hybrid mbrs Davidlohr Bueso
2013-08-06 5:21 ` Davidlohr Bueso [this message]
2013-09-02 10:10 ` [PATCH 1/8] partitions/efi: use lba-aware partition records Karel Zak
2013-09-03 5:01 ` Davidlohr Bueso
2013-08-06 5:21 ` [PATCH 2/8] partitions/efi: check pmbr record's starting lba Davidlohr Bueso
2013-08-06 5:21 ` [PATCH 3/8] partitions/efi: do not require gpt partition to begin at sector 1 Davidlohr Bueso
2013-08-06 5:21 ` [PATCH 4/8] partitions/efi: detect hybrid MBRs Davidlohr Bueso
2013-08-06 5:21 ` [PATCH 5/8] partitions/efi: account for pmbr size in lba Davidlohr Bueso
2013-08-06 5:21 ` [PATCH 6/8] partitions/efi: compare first and last usable LBAs Davidlohr Bueso
2013-08-06 5:21 ` [PATCH 7/8] partitions/efi: delete annoying emacs style comments Davidlohr Bueso
2013-08-06 5:21 ` [PATCH 8/8] partitions/efi: some style cleanups Davidlohr Bueso
2013-08-06 21:16 ` [PATCH 0/8] partitions/efi: detect hybrid mbrs Andrew Morton
2013-08-06 22:39 ` Davidlohr Bueso
2013-08-15 16:59 ` Davidlohr Bueso
2013-08-15 19:29 ` Andrew Morton
2013-08-16 1:37 ` Davidlohr Bueso
2013-09-02 10:33 ` Karel Zak
2013-09-03 12:33 ` Matt Fleming
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=1375766476-4204-2-git-send-email-davidlohr@hp.com \
--to=davidlohr@hp.com \
--cc=Matt_Domsch@dell.com \
--cc=akpm@linux-foundation.org \
--cc=aswin@hp.com \
--cc=axboe@kernel.dk \
--cc=chegu_vinod@hp.com \
--cc=jim.hull@hp.com \
--cc=kzak@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=pjones@redhat.com \
/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
all inboxes | Powered by JetHome®