From owner-svn-src-user@FreeBSD.ORG Thu Jun 28 06:58:12 2012 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id D89231065677; Thu, 28 Jun 2012 06:58:12 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id A9C318FC14; Thu, 28 Jun 2012 06:58:12 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5S6wCUk058238; Thu, 28 Jun 2012 06:58:12 GMT (envelope-from ae@svn.freebsd.org) Received: (from ae@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5S6wCu0058234; Thu, 28 Jun 2012 06:58:12 GMT (envelope-from ae@svn.freebsd.org) Message-Id: <201206280658.q5S6wCu0058234@svn.freebsd.org> From: "Andrey V. Elsukov" Date: Thu, 28 Jun 2012 06:58:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237688 - in user/ae/bootcode/sys/boot: common i386/pmbr X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 28 Jun 2012 06:58:13 -0000 Author: ae Date: Thu Jun 28 06:58:12 2012 New Revision: 237688 URL: http://svn.freebsd.org/changeset/base/237688 Log: Don't try to detect GEOM's signature in the last sector. This is the path to the Dark Side. Discussed with: marcel Modified: user/ae/bootcode/sys/boot/common/part.c user/ae/bootcode/sys/boot/i386/pmbr/pmbr.s Modified: user/ae/bootcode/sys/boot/common/part.c ============================================================================== --- user/ae/bootcode/sys/boot/common/part.c Thu Jun 28 06:49:04 2012 (r237687) +++ user/ae/bootcode/sys/boot/common/part.c Thu Jun 28 06:58:12 2012 (r237688) @@ -256,24 +256,12 @@ ptable_gptread(struct ptable *table, voi } } offset = pri ? hdr.hdr_lba_alt: table->sectors - 1; - while (offset > 0) { - /* Read the backup GPT header. */ - if (dread(dev, buf, 1, offset) != 0) { - phdr = NULL; - break; - } + /* Read the backup GPT header. */ + if (dread(dev, buf, 1, offset) != 0) + phdr = NULL; + else phdr = gpt_checkhdr((struct gpt_hdr *)buf, offset, table->sectors, table->sectorsize); - if (phdr != NULL) - break; - /* - * Skip GEOM metadata and try to read backup - * GPT header again. - */ - if (memcmp(buf, GEOM_MAGIC, sizeof(GEOM_MAGIC) - 1) != 0) - break; - offset--; - } if (phdr != NULL) { /* * Compare primary and backup headers. Modified: user/ae/bootcode/sys/boot/i386/pmbr/pmbr.s ============================================================================== --- user/ae/bootcode/sys/boot/i386/pmbr/pmbr.s Thu Jun 28 06:49:04 2012 (r237687) +++ user/ae/bootcode/sys/boot/i386/pmbr/pmbr.s Thu Jun 28 06:58:12 2012 (r237688) @@ -44,7 +44,6 @@ .set GPT_SIG,0 .set GPT_SIG_0,0x20494645 # "EFI " .set GPT_SIG_1,0x54524150 # "PART" - .set GEOM_MAGIC,0x4d4f4547 # "GEOM" .set GPT_MYLBA,24 .set GPT_PART_LBA,72 .set GPT_NPART,80 @@ -109,19 +108,13 @@ main.2a: movw $GPT_ADDR,%bx jnz main.2b jmp load_part main.2b: cmpb $1,%dh # Reading primary? - je main.3 # Try backup if yes - cmpl $GEOM_MAGIC,GPT_ADDR # GEOM sig at backup location? - jz main.3 # Skip GEOM metadata - jmp err_pt # Invalid table found + jne err_pt # If no - invalid table found # # Try alternative LBAs from the last sector for the GPT header. # main.3: movb $0,%dh # %dh := 0 (reading backup) movw $DPBUF+DPBUF_SEC,%si # %si = last sector + 1 movw $lba,%di # %di = $lba - cmpl $0,(%si) # - jnz main.3a # - decl 0x4(%si) # 0x4(%si) = last sec (32-64) main.3a: decl (%si) # 0x0(%si) = last sec (0-31) movw $2,%cx rep