Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F99121390
D42245.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D42245.diff
View Options
diff --git a/sys/sys/disk/gpt.h b/sys/sys/disk/gpt.h
--- a/sys/sys/disk/gpt.h
+++ b/sys/sys/disk/gpt.h
@@ -82,6 +82,13 @@
CTASSERT(offsetof(struct gpt_hdr, padding) == 92);
#endif
+/*
+ * The GPT standard (section 5.3 of UEFI standard version 2.10) requires
+ * we reserve at least 16k after the PMBR and the GPT header for the GPT
+ * Array Entries.
+ */
+#define GPT_MIN_RESERVED 16384
+
struct gpt_ent {
gpt_uuid_t ent_type;
gpt_uuid_t ent_uuid;
diff --git a/usr.bin/mkimg/gpt.c b/usr.bin/mkimg/gpt.c
--- a/usr.bin/mkimg/gpt.c
+++ b/usr.bin/mkimg/gpt.c
@@ -24,7 +24,7 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
+#include <sys/param.h>
#include <sys/errno.h>
#include <stddef.h>
#include <stdint.h>
@@ -124,13 +124,21 @@
return (crc ^ ~0U);
}
+/*
+ * Return the number of sectors needed to store the partition table.
+ */
static u_int
gpt_tblsz(void)
{
- u_int ents;
+ u_int eps; /* Entries per Sector */
- ents = secsz / sizeof(struct gpt_ent);
- return ((nparts + ents - 1) / ents);
+ /*
+ * Count the number of sectors needed for the GPT Entry Array to store
+ * the number of partitions defined for this image. Enforce the 16kB
+ * minimum space for the GPT Entry Array per UEFI v2.10 Section 5.3.
+ */
+ eps = secsz / sizeof(struct gpt_ent);
+ return (MAX(howmany(GPT_MIN_RESERVED, secsz), howmany(nparts, eps)));
}
static lba_t
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Oct 7, 2:53 PM (10 h, 23 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
13787737
Default Alt Text
D42245.diff (1 KB)
Attached To
Mode
D42245: mkimg: Ensure GPT Entry Array is at least 16k
Attached
Detach File
Event Timeline
Log In to Comment