From owner-freebsd-current@FreeBSD.ORG Sun Aug 24 17:08:52 2014 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 2884B6A9 for ; Sun, 24 Aug 2014 17:08:52 +0000 (UTC) Received: from mail-lb0-x22c.google.com (mail-lb0-x22c.google.com [IPv6:2a00:1450:4010:c04::22c]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id A0C2E3057 for ; Sun, 24 Aug 2014 17:08:51 +0000 (UTC) Received: by mail-lb0-f172.google.com with SMTP id z11so11246559lbi.31 for ; Sun, 24 Aug 2014 10:08:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:cc:content-type; bh=GX+ffKya+VwekCqOSSDGdYz1e/Bedt+JIgaqLzK6Gto=; b=H92+b6tx1YVMbaTP5VXC7/G2itshuQgBwhbh74OQpT5OmcxtW0kdzo9yCmXVUlxxW/ 7TTf3jNZ+mv/IFyCOKUWBunYSvfe70ENZfKtE9bro4vpQdW2jsnIcG/eYeaJupaAyXe9 YEXpMMXJds7aHExUSwfvbVTJioxRmAXITNNO9yOmBXKCwkrobpp2PISgHawmv6JU07Y8 AVD8O9YrN9JTM2T0zk5OfliuZjNxHFc9is7NM/hqr2j9VgbZkKzisFzsrN+c2GiiLBHO CcsIsWo0ygB1WVnsUwoUsjxPDfeuSDtrEKX2RWGzGmOpQo6mk8a0g6h1wmPS0XX7hozz 9Qtw== MIME-Version: 1.0 X-Received: by 10.152.22.165 with SMTP id e5mr16095579laf.57.1408900129446; Sun, 24 Aug 2014 10:08:49 -0700 (PDT) Sender: crodr001@gmail.com Received: by 10.112.197.107 with HTTP; Sun, 24 Aug 2014 10:08:49 -0700 (PDT) In-Reply-To: <5003BFAC-D472-47CE-803B-F1AF8BF961B0@xcllnt.net> References: <853B0396-2C19-49DF-A8E8-8EB43D107597@xcllnt.net> <7CE168C1-6AF3-4AD2-80DB-192AEC49FD2B@xcllnt.net> <53F9AC50.1000000@yandex.ru> <5003BFAC-D472-47CE-803B-F1AF8BF961B0@xcllnt.net> Date: Sun, 24 Aug 2014 10:08:49 -0700 X-Google-Sender-Auth: S52pMNfnde2fi9U8KV42BoAGcks Message-ID: Subject: Re: mkimg used to create gpt image, problem booting From: Craig Rodrigues To: Marcel Moolenaar Content-Type: text/plain; charset=ISO-8859-1 Cc: "Andrey V. Elsukov" , freebsd-current Current X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 24 Aug 2014 17:08:52 -0000 On Sun, Aug 24, 2014 at 8:23 AM, Marcel Moolenaar wrote: > > On Aug 24, 2014, at 2:11 AM, Andrey V. Elsukov wrote: > >> On 24.08.2014 06:14, Craig Rodrigues wrote: > >>> I did some further debugging inside the loader by doing the following. >>> -> I added "CFLAGS += -DPART_DEBUG" to sys/boot/common/Makefile.inc >>> -> I added DEBUG() statements all over sys/boot/common/part.c >>> >>> I observed that in sys/boot/common/part.c in the ptbl_gptread() function, >>> that in this section: >>> >>> 305 ent = (struct gpt_ent *)tbl; >>> 306 size = MIN(hdr.hdr_entries * hdr.hdr_entsz, >>> 307 MAXTBLSZ * table->sectorsize); >>> 308 for (i = 0; i < size / hdr.hdr_entsz; i++, ent++) { >>> 309 if (uuid_equal(&ent->ent_type, &gpt_uuid_unused, NULL)) >>> 310 continue; >>> >>> ent->ent_type is all 0's, which matches gpt_uuid_unused, so it bails >>> out of the loop and never adds the gpt partitions to the list of partitions >>> that the loader can access. >> >> Yes, the problem is in the ptable_gptread() function. I'll commit the fix. >> > > Actually, no. There is *a* problem in that function: > The function does not respect hdr.hdr_entsz when it > needs the next entry. It simply uses "ent++", which > is fixed our definition of struct gpt_ent and may > not match the definition of the writer. Yes, you are correct. I looked at the GPT format here: http://en.wikipedia.org/wiki/GUID_Partition_Table Although the default size in the specification for a gpt entry is 128 bytes, which matches the size of our "struct gpt_entry", technically, the gpt header could specify a gpt entry size that is something other than 128 bytes. I guess the only restriction seems to be that you cannot have variable sized gpt entries.....they have to match the size of the gpt entry specified in the gpt header. I guess we haven't hit this yet because there are probably very few peopel creating gpt tables with entry sizes other than 128, but in the future, who knows? -- Craig