Date: Wed, 21 Jul 2021 16:14:05 GMT From: Warner Losh <imp@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Subject: git: b0b483b64be8 - stable/13 - Fix pmbr issues > 2TB Message-ID: <202107211614.16LGE5uE080402@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=b0b483b64be8533c8113500850ae8de2d127a98d commit b0b483b64be8533c8113500850ae8de2d127a98d Author: Emrion <kmachine@free.fr> AuthorDate: 2021-07-13 20:37:59 +0000 Commit: Warner Losh <imp@FreeBSD.org> CommitDate: 2021-07-21 16:13:10 +0000 Fix pmbr issues > 2TB These issues have low impact because they require precise circumstances to trigger one of them. The disk must be > 2 TiB in size and either: - The primary GPT header is dammaged. - The freebsd-boot partiton is located farther than the first 2 TiB of the disc and one of its sectors takes place at a lba value that makes the higher 32 bits of this very value change. Errors and corrections folow: - decl and incl don't affect CF, so replace with subl/addl $1 - repe uses %cx, so move size to it with movw - moving a 64-bit value with %cx of 2 (should be 4) so addresses > 2TB will work. PR: 233180 Reviewed by: imp@ (applied patch using description in bug) Differential Revision: https://reviews.freebsd.org/D31100 (cherry picked from commit 0ca9f1d4a3b772036309fb1c14262ec77c674c5d) --- stand/i386/pmbr/pmbr.S | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/stand/i386/pmbr/pmbr.S b/stand/i386/pmbr/pmbr.S index 1a758812edd3..c394835757af 100644 --- a/stand/i386/pmbr/pmbr.S +++ b/stand/i386/pmbr/pmbr.S @@ -114,8 +114,9 @@ main.2b: cmpb $1,%dh # Reading primary? main.3: movb $0,%dh # %dh := 0 (reading backup) movw $DPBUF+DPBUF_SEC,%si # %si = last sector + 1 movw $lba,%di # %di = $lba -main.3a: decl (%si) # 0x0(%si) = last sec (0-31) - movw $2,%cx +main.3a: subl $1, (%si) # 0x0(%si) = last sec (0-31) + sbbl $0, 4(%si) + movw $4,%cx rep movsw # $lastsec--, copy it to $lba jmp main.2a # Read the next sector @@ -128,7 +129,7 @@ load_part: movw $GPT_ADDR+GPT_PART_LBA,%si call read scan: movw %bx,%si # Compare partition UUID movw $boot_uuid,%di # with FreeBSD boot UUID - movb $0x10,%cl + movw $0x10,%cx repe cmpsb jnz next_part # Didn't match, next partition # @@ -150,7 +151,7 @@ load_boot: push %si # Save %si jnz next_boot mov %bx,%es # Reset %es to zero jmp LOAD # Jump to boot code -next_boot: incl (%si) # Next LBA +next_boot: addl $1,(%si) # Next LBA adcl $0,4(%si) mov %es,%ax # Adjust segment for next addw $SECSIZE/16,%ax # sector @@ -171,7 +172,7 @@ next_part: decl GPT_ADDR+GPT_NPART # Was this the last partition? addw %ax,%bx # Next partition cmpw $PART_ADDR+0x200,%bx # Still in sector? jb scan - incl GPT_ADDR+GPT_PART_LBA # Next sector + addl $1, GPT_ADDR+GPT_PART_LBA # Next sector adcl $0,GPT_ADDR+GPT_PART_LBA+4 jmp load_part #
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202107211614.16LGE5uE080402>