Bug 175086 - [gpt] 9.1 does not boot from GPT partition that can have more that 128 partition entries (worked under 7.4-STABLE, bug in sys/boot/common/gpt.c) [regression]
Summary: [gpt] 9.1 does not boot from GPT partition that can have more that 128 partit...
Status: In Progress
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 9.1-PRERELEASE
Hardware: Any Any
: Normal Affects Only Me
Assignee: Andrey V. Elsukov
URL:
Keywords:
: 186515 (view as bug list)
Depends on:
Blocks:
 
Reported: 2013-01-07 07:00 UTC by Andre.Albsmeier
Modified: 2024-02-05 10:44 UTC (History)
5 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andre.Albsmeier 2013-01-07 07:00:00 UTC
Booting from a GPT partitioned disk that can have more
than 128 parition entries (e.g. 248 in this case)
fails under 9.1 but worked under 7.4.

This is due to a test that was introduced in sys/boot/common/gpt.c:

...
#define MAXTBLENTS      128
...
        if (bcmp(hdr->hdr_sig, GPT_HDR_SIG, sizeof(hdr->hdr_sig)) != 0 ||
            hdr->hdr_lba_self != hdrlba || hdr->hdr_revision < 0x00010000 ||
            hdr->hdr_entsz < sizeof(struct gpt_ent) ||
            hdr->hdr_entries > MAXTBLENTS || DEV_BSIZE % hdr->hdr_entsz != 0) {
                printf("%s: invalid %s GPT header\n", BOOTPROG, which);
                return (-1);
        }

Fix: 

The check should be removed since a GPT header with more than
128 possible parition entries is not invalid and can legally
be created with gpart.
How-To-Repeat: 
Create a disk using

gpart create -s gpt -n 248 $disk

and add bootcode and system to it. Add some delay into gptinit()
of sys/boot/i386/gptboot/gptboot.c so you can read the error
messages before reset occurs:

invalid primary GPT header
invalid backup GPT header
unable to load GPT
Comment 1 Andrey V. Elsukov freebsd_committer freebsd_triage 2015-12-10 10:48:36 UTC
*** Bug 186515 has been marked as a duplicate of this bug. ***
Comment 2 Mark Linimon freebsd_committer freebsd_triage 2024-01-20 22:34:01 UTC
^Triage: to submitter: is this aging PR still relevant?
Comment 3 Andre Albsmeier 2024-02-05 10:44:31 UTC
> is this aging PR still relevant?

No idea. Since the buggy code ist still there (see stand/libsa/gpt.c) I assume 
yes.