diff options
author | Kenneth R Westerback <krw@cvs.openbsd.org> | 2021-06-02 22:44:28 +0000 |
---|---|---|
committer | Kenneth R Westerback <krw@cvs.openbsd.org> | 2021-06-02 22:44:28 +0000 |
commit | a490c7228f526f0a00bdbff73a9cc21d85c4542a (patch) | |
tree | c5a903c4519effad52ff92d14b34cd31139583c3 /sys/arch/arm64 | |
parent | f3bce683a87856150610d93f55e4453a1cd21bb2 (diff) |
Use the same logic in all copies of gpt_chk_mbr(), relaxing the
media length check to allow EFI GPT partitions to be smaller that
the entire disk.
Consistently use GPTSECTOR instead of randomly tossing in some
literal '1's.
ok kettenis@
Diffstat (limited to 'sys/arch/arm64')
-rw-r--r-- | sys/arch/arm64/stand/efiboot/efidev.c | 15 | ||||
-rw-r--r-- | sys/arch/arm64/stand/efiboot/softraid_arm64.c | 15 |
2 files changed, 14 insertions, 16 deletions
diff --git a/sys/arch/arm64/stand/efiboot/efidev.c b/sys/arch/arm64/stand/efiboot/efidev.c index a877173afe4..902faa7c8ba 100644 --- a/sys/arch/arm64/stand/efiboot/efidev.c +++ b/sys/arch/arm64/stand/efiboot/efidev.c @@ -1,4 +1,4 @@ -/* $OpenBSD: efidev.c,v 1.7 2021/06/02 15:31:15 kettenis Exp $ */ +/* $OpenBSD: efidev.c,v 1.8 2021/06/02 22:44:27 krw Exp $ */ /* * Copyright (c) 2015 YASUOKA Masahiko <yasuoka@yasuoka.net> @@ -164,12 +164,11 @@ gpt_chk_mbr(struct dos_partition *dp, u_int64_t dsize) found++; if (dp2->dp_typ != DOSPTYP_EFI) continue; + if (letoh32(dp2->dp_start) != GPTSECTOR) + continue; psize = letoh32(dp2->dp_size); - if (psize == (dsize - 1) || - psize == UINT32_MAX) { - if (letoh32(dp2->dp_start) == 1) - efi++; - } + if (psize <= (dsize - GPTSECTOR) || psize == UINT32_MAX) + efi++; } if (found == 1 && efi == 1) return (0); @@ -297,8 +296,8 @@ findopenbsd_gpt(efi_diskinfo_t ed, const char **err) return (-1); } - /* LBA1: GPT Header */ - lba = 1; + /* GPT Header */ + lba = GPTSECTOR; status = efid_io(F_READ, ed, EFI_SECTOBLK(ed, lba), EFI_BLKSPERSEC(ed), buf); if (EFI_ERROR(status)) { diff --git a/sys/arch/arm64/stand/efiboot/softraid_arm64.c b/sys/arch/arm64/stand/efiboot/softraid_arm64.c index 243543904fd..37177303337 100644 --- a/sys/arch/arm64/stand/efiboot/softraid_arm64.c +++ b/sys/arch/arm64/stand/efiboot/softraid_arm64.c @@ -1,4 +1,4 @@ -/* $OpenBSD: softraid_arm64.c,v 1.2 2020/12/09 18:10:18 krw Exp $ */ +/* $OpenBSD: softraid_arm64.c,v 1.3 2021/06/02 22:44:27 krw Exp $ */ /* * Copyright (c) 2012 Joel Sing <jsing@openbsd.org> @@ -402,12 +402,11 @@ gpt_chk_mbr(struct dos_partition *dp, u_int64_t dsize) found++; if (dp2->dp_typ != DOSPTYP_EFI) continue; + if (letoh32(dp2->dp_start) != GPTSECTOR) + continue; psize = letoh32(dp2->dp_size); - if (psize == (dsize - 1) || - psize == UINT32_MAX) { - if (letoh32(dp2->dp_start) == 1) - efi++; - } + if (psize <= (dsize - GPTSECTOR) || psize == UINT32_MAX) + efi++; } if (found == 1 && efi == 1) return (0); @@ -455,8 +454,8 @@ findopenbsd_gpt(struct sr_boot_volume *bv, const char **err) } bzero(buf, bv->sbv_secsize); - /* LBA1: GPT Header */ - lba = 1; + /* GPT Header */ + lba = GPTSECTOR; sr_strategy(bv, F_READ, lba * (bv->sbv_secsize / DEV_BSIZE), DEV_BSIZE, buf, NULL); memcpy(&gh, buf, sizeof(gh)); |