Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 28 Jun 2012 06:58:12 +0000 (UTC)
From:      "Andrey V. Elsukov" <ae@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-user@freebsd.org
Subject:   svn commit: r237688 - in user/ae/bootcode/sys/boot: common i386/pmbr
Message-ID:  <201206280658.q5S6wCu0058234@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201206280658.q5S6wCu0058234>