From owner-dev-commits-src-branches@freebsd.org Wed Jul 21 16:14:05 2021 Return-Path: Delivered-To: dev-commits-src-branches@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id C14BD666704; Wed, 21 Jul 2021 16:14:05 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4GVLHd4qXzz3LrN; Wed, 21 Jul 2021 16:14:05 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 8793F21387; Wed, 21 Jul 2021 16:14:05 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 16LGE5Qu080403; Wed, 21 Jul 2021 16:14:05 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 16LGE5uE080402; Wed, 21 Jul 2021 16:14:05 GMT (envelope-from git) Date: Wed, 21 Jul 2021 16:14:05 GMT Message-Id: <202107211614.16LGE5uE080402@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Warner Losh Subject: git: b0b483b64be8 - stable/13 - Fix pmbr issues > 2TB MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: imp X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: b0b483b64be8533c8113500850ae8de2d127a98d Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 21 Jul 2021 16:14:05 -0000 The branch stable/13 has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=b0b483b64be8533c8113500850ae8de2d127a98d commit b0b483b64be8533c8113500850ae8de2d127a98d Author: Emrion AuthorDate: 2021-07-13 20:37:59 +0000 Commit: Warner Losh 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 #