From owner-svn-src-stable-10@freebsd.org Tue Jul 21 15:50:16 2015 Return-Path: Delivered-To: svn-src-stable-10@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 863DF9A71EB; Tue, 21 Jul 2015 15:50:16 +0000 (UTC) (envelope-from allanjude@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 5875F1923; Tue, 21 Jul 2015 15:50:16 +0000 (UTC) (envelope-from allanjude@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.70]) by repo.freebsd.org (8.14.9/8.14.9) with ESMTP id t6LFoGWp022942; Tue, 21 Jul 2015 15:50:16 GMT (envelope-from allanjude@FreeBSD.org) Received: (from allanjude@localhost) by repo.freebsd.org (8.14.9/8.14.9/Submit) id t6LFoFAw022940; Tue, 21 Jul 2015 15:50:15 GMT (envelope-from allanjude@FreeBSD.org) Message-Id: <201507211550.t6LFoFAw022940@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: allanjude set sender to allanjude@FreeBSD.org using -f From: Allan Jude Date: Tue, 21 Jul 2015 15:50:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r285756 - in stable/10: sbin/geom/class/part sys/geom/part X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 21 Jul 2015 15:50:16 -0000 Author: allanjude (doc committer) Date: Tue Jul 21 15:50:14 2015 New Revision: 285756 URL: https://svnweb.freebsd.org/changeset/base/285756 Log: MFC: r285594 New partition flag for gpart, writes the 0xee partition in the pmbr in the second slot, rather than the first. Works around Lenovo legacy GPT boot issue PR: 184910 Approved by: re (gjb), marcel Relnotes: yes Sponsored by: ScaleEngine Inc. Differential Revision: https://reviews.freebsd.org/D3140 Modified: stable/10/sbin/geom/class/part/gpart.8 stable/10/sys/geom/part/g_part_gpt.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sbin/geom/class/part/gpart.8 ============================================================================== --- stable/10/sbin/geom/class/part/gpart.8 Tue Jul 21 15:28:07 2015 (r285755) +++ stable/10/sbin/geom/class/part/gpart.8 Tue Jul 21 15:50:14 2015 (r285756) @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd May 5, 2015 +.Dd July 14, 2015 .Dt GPART 8 .Os .Sh NAME @@ -933,6 +933,12 @@ start-up script. See .Xr gptboot 8 for more details. +.It Cm lenovofix +Setting this attribute overwrites the Protective MBR with a new one where +the 0xee partition is the second, rather than the first record. +This resolves a BIOS compatibility issue with some Lenovo models including the +X220, T420, and T520, allowing them to boot from GPT partitioned disks +without using EFI. .El .Pp The scheme-specific attributes for MBR: Modified: stable/10/sys/geom/part/g_part_gpt.c ============================================================================== --- stable/10/sys/geom/part/g_part_gpt.c Tue Jul 21 15:28:07 2015 (r285755) +++ stable/10/sys/geom/part/g_part_gpt.c Tue Jul 21 15:50:14 2015 (r285756) @@ -1007,6 +1007,7 @@ g_part_gpt_setunset(struct g_part_table { struct g_part_gpt_entry *entry; struct g_part_gpt_table *table; + struct g_provider *pp; uint8_t *p; uint64_t attr; int i; @@ -1036,6 +1037,21 @@ g_part_gpt_setunset(struct g_part_table } } return (0); + } else if (strcasecmp(attrib, "lenovofix") == 0) { + /* + * Write the 0xee GPT entry to slot #1 (2nd slot) in the pMBR. + * This workaround allows Lenovo X220, T420, T520, etc to boot + * from GPT Partitions in BIOS mode. + */ + + if (entry != NULL) + return (ENXIO); + + pp = LIST_FIRST(&basetable->gpt_gp->consumer)->provider; + bzero(table->mbr + DOSPARTOFF, DOSPARTSIZE * NDOSPART); + gpt_write_mbr_entry(table->mbr, ((set) ? 1 : 0), 0xee, 1, + MIN(pp->mediasize / pp->sectorsize - 1, UINT32_MAX)); + return (0); } if (entry == NULL)