grub-devel.gnu.org archive mirror
 help / color / mirror / Atom feed
From: "Vladimir 'φ-coder/phcoder' Serbinenko" <phcoder@gmail.com>
To: The development of GNU GRUB <grub-devel@gnu.org>
Subject: Re: [PATCH] add arm64 UEFI Linux loader
Date: Wed, 18 Dec 2013 18:23:06 +0100	[thread overview]
Message-ID: <52B1D9FA.209@gmail.com> (raw)
In-Reply-To: <20131218165439.GD22356@rocoto.smurfnet.nu>

[-- Attachment #1: Type: text/plain, Size: 3613 bytes --]

On 18.12.2013 17:54, Leif Lindholm wrote:
> On Mon, Dec 16, 2013 at 10:34:51PM +0100, Vladimir 'φ-coder/phcoder' Serbinenko wrote:
>>> +static void
>>> +get_fdt (void)
>>> +{
>>> +  grub_efi_configuration_table_t *tables;
>>> +  unsigned int i;
>>> +  int fdt_loaded;
>>> +  int size;
>>> +
>>> +  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
>>> +  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.
> 

>>> +  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
> /
>     Leif
> 
> _______________________________________________
> Grub-devel mailing list
> Grub-devel@gnu.org
> https://lists.gnu.org/mailman/listinfo/grub-devel
> 



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 291 bytes --]

  parent reply	other threads:[~2013-12-18 17:23 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-16 13:55 [PATCH] add arm64 UEFI Linux loader Leif Lindholm
2013-12-16 16:13 ` Andrey Borzenkov
2013-12-16 16:24   ` Leif Lindholm
2013-12-16 21:34     ` Vladimir 'φ-coder/phcoder' Serbinenko
2013-12-18 16:54       ` Leif Lindholm
2013-12-18 17:12         ` Andrey Borzenkov
2013-12-18 17:23         ` Vladimir 'φ-coder/phcoder' Serbinenko [this message]
2013-12-19 18:57           ` Leif Lindholm
2013-12-19 19:06             ` Vladimir 'φ-coder/phcoder' Serbinenko
2013-12-19 20:57               ` Leif Lindholm
2013-12-16 16:23 ` Vladimir 'φ-coder/phcoder' Serbinenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=52B1D9FA.209@gmail.com \
    --to=phcoder@gmail.com \
    --cc=grub-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).