Received: from list by lists.gnu.org with archive (Exim 4.71) id 1VtimT-0005fl-I7 for mharc-grub-devel@gnu.org; Thu, 19 Dec 2013 13:57:09 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48915) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VtimL-0005eY-Qu for grub-devel@gnu.org; Thu, 19 Dec 2013 13:57:07 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VtimE-0006BE-Fp for grub-devel@gnu.org; Thu, 19 Dec 2013 13:57:01 -0500 Received: from mail-qc0-f174.google.com ([209.85.216.174]:57167) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VtimE-0006B8-Ax for grub-devel@gnu.org; Thu, 19 Dec 2013 13:56:54 -0500 Received: by mail-qc0-f174.google.com with SMTP id n7so1304503qcx.19 for ; Thu, 19 Dec 2013 10:56:53 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:subject:message-id:references :mime-version:content-type:content-disposition :content-transfer-encoding:in-reply-to:user-agent; bh=aWWuNY9TldQO+Ny6bz26qgpC9KwbF7NyoUfzE92Fwps=; b=mvMdZiHiZDS7lYbh1Mhh71UuMvZmbn65da0yMqFn8df/ph1+FAxIMOthqOLL2F+qXL Qx5zDNQ2+bVCArAgfQi99cJu3vjJP/n3BpRxSkvdbWUTlmiRVCe9uKk/0g+pGP9ah9DQ xKkz2PeDvjm+WZYyua/xOTr0dbROcRCBrrFdrlF7sQpTs6wAOJw3PgC3WRxZVjtFReXU RrwRTPS9CZp/jVgRhMtdjmkoYS5KBx0HNry8RSwZW3TwqtmT+JqZkVRGWLzhmEDx6ypW J23U8sEAVqDMm1jgL/dpluucPSTRFfQwDmQNRjtCjBnLu1wXlOO/eAqNXoBJ6MM265xf dASA== X-Gm-Message-State: ALoCoQntft6xQnKswCKaTyH9gDcAlBR5VYoW21K4uXtXzG5rTQR6u/USJ5EgcOQPsiwCWgnnZeEy X-Received: by 10.224.46.8 with SMTP id h8mr5919901qaf.49.1387479413475; Thu, 19 Dec 2013 10:56:53 -0800 (PST) Received: from rocoto.smurfnet.nu ([2001:4b98:dc0:41:216:3eff:fea7:75f3]) by mx.google.com with ESMTPSA id hb2sm12515350qeb.6.2013.12.19.10.56.52 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 19 Dec 2013 10:56:52 -0800 (PST) Date: Thu, 19 Dec 2013 19:57:10 +0100 From: Leif Lindholm To: The development of GNU GRUB Subject: Re: [PATCH] add arm64 UEFI Linux loader Message-ID: <20131219185710.GE22356@rocoto.smurfnet.nu> References: <20131216135551.GV22356@rocoto.smurfnet.nu> <20131216201301.24356028@opensuse.site> <20131216162403.GW22356@rocoto.smurfnet.nu> <52AF71FB.1080700@gmail.com> <20131218165439.GD22356@rocoto.smurfnet.nu> <52B1D9FA.209@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <52B1D9FA.209@gmail.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.85.216.174 X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: The development of GNU GRUB List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 Dec 2013 18:57:08 -0000 On Wed, Dec 18, 2013 at 06:23:06PM +0100, Vladimir 'φ-coder/phcoder' Serbinenko wrote: > >>> + if (!orig_fdt) > >>> + { > >>> + fdt_loaded = 0; > >>> + /* Look for FDT in UEFI config tables. */ > >>> + tables = grub_efi_system_table->configuration_table; > >>> + > >>> + for (i = 0; i < grub_efi_system_table->num_table_entries; i++) > >>> + if (grub_memcmp (&tables[i].vendor_guid, &fdt_guid, sizeof (fdt_guid)) > >>> + == 0) > >>> + { > >>> + orig_fdt = tables[i].vendor_table; > >>> + grub_dprintf ("linux", "found registered FDT @ 0x%p\n", orig_fdt); > >>> + break; > >>> + } > >>> + } > >>> + else > >>> + fdt_loaded = 1; > >>> + > >>> + size = > >>> + orig_fdt ? grub_fdt_get_totalsize (orig_fdt) : GRUB_FDT_EMPTY_TREE_SZ; > >>> + size += grub_strlen (linux_args) + 0x400; > >>> + > >>> + grub_dprintf ("linux", "allocating %d bytes for fdt\n", size); > >>> + fdt = grub_efi_allocate_pages (0, BYTES_TO_PAGES (size)); > >>> + if (!fdt) > >>> + return; > >>> + > >>> + if (orig_fdt) > >>> + { > >>> + grub_memmove (fdt, orig_fdt, size); > >>> + grub_fdt_set_totalsize (fdt, size); > >>> + if (fdt_loaded) > >>> + grub_free (orig_fdt); > >> > >> There is a problem with this: in case of failure orig_fdt isn't > >> available for next try anymore. > > > > Right. I need to also NULL orig_fdt, will do. > > > I think that you have to keep orig_fdt as otherwise only first attempt > to boot will use FDT supplied by system. Second one won't, likely > resulting in another failure No, I null/free FDT loaded with "devicetree" command. Anyway, I have refactored this handling a bit in my updated set, also improving readability. > >>> + if (!loaded) > >>> + { > >>> + grub_error (GRUB_ERR_BAD_ARGUMENT, > >>> + N_("you need to load the kernel first")); > >>> + goto fail; > >>> + } > >>> + > >>> + files = grub_zalloc (argc * sizeof (files[0])); > >>> + if (!files) > >>> + goto fail; > >>> + > >>> + for (i = 0; i < argc; i++) > >>> + { > >>> + grub_file_filter_disable_compression (); > >>> + files[i] = grub_file_open (argv[i]); > >>> + if (!files[i]) > >>> + goto fail; > >>> + nfiles++; > >>> + size += ALIGN_UP (grub_file_size (files[i]), 4); > >>> + } > >>> + > >> Why don't you use methods from loader/linux.c ? > > > > Umm, this entire function is quite embarassing - it is left around from > > when I included Matthew Garrett's "linuxefi" code for understanding the > > process better.. > > Updated set contains the much simpler one which I meant to include. > > ARM* do not even support multiple initrds. > > They're concatenated in memory if you use common functions and results > in valid cpio which will be decompressed/parsed by Linux. Done. Cleaning up patch for submitting v2. > >>> + if (grub_file_read (file, kernel_mem, kernel_size) > >>> + != (grub_int64_t) kernel_size) > >>> + { > >>> + grub_error (GRUB_ERR_FILE_READ_ERROR, N_("Can't read kernel %s"), > >>> + argv[0]); > >> Please look at similar place in other architectures. > > > > i386 looks near-identical, apart from the fact that their bzImage has > > a size field which the ARM64 image does not. If you want me to change > > something here, I'm afraid you will have to rub my nose in it. > > > if grub_errno is set you shouldn't override it. And please use the same > message verbatim (unexpected end of file): it decreases work for translators Well, since I have already checked the file size before this, any failure will be an i/o error - so I'll just goto fail instead. / Leif