All of lore.kernel.org
 help / color / mirror / Atom feed
* Device tree support for x86 on Linux
@ 2021-07-29  8:43 Mislav Stublić
  2021-07-30 12:59 ` Daniel Kiper
  0 siblings, 1 reply; 5+ messages in thread
From: Mislav Stublić @ 2021-07-29  8:43 UTC (permalink / raw)
  To: grub-devel

Hi,

I am planning to add support for device tree loading on x86 with
UEFI and Linux as i understand this is currently not supported. We need
this for a board we are developing so i would test my patches in our
development environment.

I have gone through current x86 loader code and some similar use cases
so i  believe i could provide a patch but i also have some questions.

Is this a feature you would accept upstream?

As for technical questions, for this to work grub would need to set
setup_data pointer (part of setup_header for linux kernel) that points
to memory holding loaded dtb. But i'm not sure if such memory can
just be allocated with grub_zalloc or is there some other allocation
mechanism that would guarantee this will be preserved once control is
handed over to linux kernel.

Mislav


----- Disclaimer -----
This e-mail message and its attachments may contain privileged and/or confidential information. Please do not read the message if You are not its designated recipient. If You have received this message by mistake, please inform its sender and destroy the original message and its attachments without reading or storing of any kind. Any unauthorized use, distribution, reproduction or publication of this message is forbidden.

----- Pravne napomene -----
Ova elektronicka poruka i njeni prilozi mogu sadrzavati povlastene informacije i/ili povjerljive informacije. Molimo Vas da poruku ne citate ako niste njen naznaceni primatelj. Ako ste ovu poruku primili greskom, molimo Vas da o tome obavijestite posiljatelja i da izvornu poruku i njene privitke unistite bez citanja ili bilo kakvog pohranjivanja. Svaka neovlastena upotreba, distribucija, reprodukcija ili priopcavanje ove poruke zabranjena je.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Device tree support for x86 on Linux
  2021-07-29  8:43 Device tree support for x86 on Linux Mislav Stublić
@ 2021-07-30 12:59 ` Daniel Kiper
  2021-08-02 12:56   ` Mislav Stublić
  2021-08-02 13:18   ` Mislav Stublić
  0 siblings, 2 replies; 5+ messages in thread
From: Daniel Kiper @ 2021-07-30 12:59 UTC (permalink / raw)
  To: Mislav Stublić; +Cc: grub-devel

Hi Mislav,

On Thu, Jul 29, 2021 at 08:43:45AM +0000, Mislav Stublić wrote:
> Hi,
>
> I am planning to add support for device tree loading on x86 with
> UEFI and Linux as i understand this is currently not supported. We need
> this for a board we are developing so i would test my patches in our
> development environment.
>
> I have gone through current x86 loader code and some similar use cases
> so i  believe i could provide a patch but i also have some questions.
>
> Is this a feature you would accept upstream?

I do not see any issues with it. It would be nice if you could reuse
existing code as much as possible. And please remember that current GRUB
code does not allow you to load device tree files if UEFI Secure Boot is
enabled. You can find more info here: grub-core/kern/lockdown.c.

> As for technical questions, for this to work grub would need to set
> setup_data pointer (part of setup_header for linux kernel) that points
> to memory holding loaded dtb. But i'm not sure if such memory can
> just be allocated with grub_zalloc or is there some other allocation

The grub_zalloc() et consortes can be used for the GRUB "runtime" only.

> mechanism that would guarantee this will be preserved once control is
> handed over to linux kernel.

There are two functions in the GRUB which are doing what you want:
grub_relocator_alloc_chunk_align() and grub_relocator_alloc_chunk_addr().
It seems to me the former should be better for you.

Daniel


^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: Device tree support for x86 on Linux
  2021-07-30 12:59 ` Daniel Kiper
@ 2021-08-02 12:56   ` Mislav Stublić
  2021-08-02 13:18   ` Mislav Stublić
  1 sibling, 0 replies; 5+ messages in thread
From: Mislav Stublić @ 2021-08-02 12:56 UTC (permalink / raw)
  To: Daniel Kiper; +Cc: grub-devel

Hi Daniel,

Regarding reusing existing code, there is grub-core/loader/efi/fdt.c which atleast  df s a f

-----Original Message-----
From: Daniel Kiper [mailto:dkiper@net-space.pl]
Sent: Friday, July 30, 2021 2:59 PM
To: Mislav Stublić
Cc: grub-devel@gnu.org
Subject: Re: Device tree support for x86 on Linux

Hi Mislav,

On Thu, Jul 29, 2021 at 08:43:45AM +0000, Mislav Stublić wrote:
> Hi,
>
> I am planning to add support for device tree loading on x86 with UEFI
> and Linux as i understand this is currently not supported. We need
> this for a board we are developing so i would test my patches in our
> development environment.
>
> I have gone through current x86 loader code and some similar use cases
> so i  believe i could provide a patch but i also have some questions.
>
> Is this a feature you would accept upstream?

I do not see any issues with it. It would be nice if you could reuse existing code as much as possible. And please remember that current GRUB code does not allow you to load device tree files if UEFI Secure Boot is enabled. You can find more info here: grub-core/kern/lockdown.c.

> As for technical questions, for this to work grub would need to set
> setup_data pointer (part of setup_header for linux kernel) that points
> to memory holding loaded dtb. But i'm not sure if such memory can just
> be allocated with grub_zalloc or is there some other allocation

The grub_zalloc() et consortes can be used for the GRUB "runtime" only.

> mechanism that would guarantee this will be preserved once control is
> handed over to linux kernel.

There are two functions in the GRUB which are doing what you want:
grub_relocator_alloc_chunk_align() and grub_relocator_alloc_chunk_addr().
It seems to me the former should be better for you.

Daniel


----- Disclaimer -----
This e-mail message and its attachments may contain privileged and/or confidential information. Please do not read the message if You are not its designated recipient. If You have received this message by mistake, please inform its sender and destroy the original message and its attachments without reading or storing of any kind. Any unauthorized use, distribution, reproduction or publication of this message is forbidden.

----- Pravne napomene -----
Ova elektronicka poruka i njeni prilozi mogu sadrzavati povlastene informacije i/ili povjerljive informacije. Molimo Vas da poruku ne citate ako niste njen naznaceni primatelj. Ako ste ovu poruku primili greskom, molimo Vas da o tome obavijestite posiljatelja i da izvornu poruku i njene privitke unistite bez citanja ili bilo kakvog pohranjivanja. Svaka neovlastena upotreba, distribucija, reprodukcija ili priopcavanje ove poruke zabranjena je.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: Device tree support for x86 on Linux
  2021-07-30 12:59 ` Daniel Kiper
  2021-08-02 12:56   ` Mislav Stublić
@ 2021-08-02 13:18   ` Mislav Stublić
  2021-08-02 15:04     ` Daniel Kiper
  1 sibling, 1 reply; 5+ messages in thread
From: Mislav Stublić @ 2021-08-02 13:18 UTC (permalink / raw)
  To: Daniel Kiper; +Cc: grub-devel

Hi Daniel,

Sorry, sent an unfinished mail by mistake.

Regarding reusing existing code, there is grub-core/loader/efi/fdt.c
which is mentioned in git log as not really platform specific (although
it was part of arm64, and does follow EBBR to a degree), but i'm not
sure if i can really use this for x86. grub-core/loader/efi/ftd.c uses
grub_efi_allocate_pages_real which, if i understand correctly, calls
UEFI to allocate memory in EfiACPIReclaimMemory. Not sure if this would
work for x86 (regarding ACPI and its handling in Linux) and also it
doesn't use grub_relocator_alloc_chunk_align as you mention.

Br,
Mislav

-----Original Message-----
From: Mislav Stublić
Sent: Monday, August 02, 2021 2:57 PM
To: 'Daniel Kiper'
Cc: grub-devel@gnu.org
Subject: RE: Device tree support for x86 on Linux

Hi Daniel,

Regarding reusing existing code, there is grub-core/loader/efi/fdt.c which atleast  df s a f

-----Original Message-----
From: Daniel Kiper [mailto:dkiper@net-space.pl]
Sent: Friday, July 30, 2021 2:59 PM
To: Mislav Stublić
Cc: grub-devel@gnu.org
Subject: Re: Device tree support for x86 on Linux

Hi Mislav,

On Thu, Jul 29, 2021 at 08:43:45AM +0000, Mislav Stublić wrote:
> Hi,
>
> I am planning to add support for device tree loading on x86 with UEFI
> and Linux as i understand this is currently not supported. We need
> this for a board we are developing so i would test my patches in our
> development environment.
>
> I have gone through current x86 loader code and some similar use cases
> so i  believe i could provide a patch but i also have some questions.
>
> Is this a feature you would accept upstream?

I do not see any issues with it. It would be nice if you could reuse existing code as much as possible. And please remember that current GRUB code does not allow you to load device tree files if UEFI Secure Boot is enabled. You can find more info here: grub-core/kern/lockdown.c.

> As for technical questions, for this to work grub would need to set
> setup_data pointer (part of setup_header for linux kernel) that points
> to memory holding loaded dtb. But i'm not sure if such memory can just
> be allocated with grub_zalloc or is there some other allocation

The grub_zalloc() et consortes can be used for the GRUB "runtime" only.

> mechanism that would guarantee this will be preserved once control is
> handed over to linux kernel.

There are two functions in the GRUB which are doing what you want:
grub_relocator_alloc_chunk_align() and grub_relocator_alloc_chunk_addr().
It seems to me the former should be better for you.

Daniel


----- Disclaimer -----
This e-mail message and its attachments may contain privileged and/or confidential information. Please do not read the message if You are not its designated recipient. If You have received this message by mistake, please inform its sender and destroy the original message and its attachments without reading or storing of any kind. Any unauthorized use, distribution, reproduction or publication of this message is forbidden.

----- Pravne napomene -----
Ova elektronicka poruka i njeni prilozi mogu sadrzavati povlastene informacije i/ili povjerljive informacije. Molimo Vas da poruku ne citate ako niste njen naznaceni primatelj. Ako ste ovu poruku primili greskom, molimo Vas da o tome obavijestite posiljatelja i da izvornu poruku i njene privitke unistite bez citanja ili bilo kakvog pohranjivanja. Svaka neovlastena upotreba, distribucija, reprodukcija ili priopcavanje ove poruke zabranjena je.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Device tree support for x86 on Linux
  2021-08-02 13:18   ` Mislav Stublić
@ 2021-08-02 15:04     ` Daniel Kiper
  0 siblings, 0 replies; 5+ messages in thread
From: Daniel Kiper @ 2021-08-02 15:04 UTC (permalink / raw)
  To: Mislav Stublić; +Cc: grub-devel

On Mon, Aug 02, 2021 at 01:18:21PM +0000, Mislav Stublić wrote:
> Hi Daniel,
>
> Sorry, sent an unfinished mail by mistake.

No worries.

> Regarding reusing existing code, there is grub-core/loader/efi/fdt.c
> which is mentioned in git log as not really platform specific (although
> it was part of arm64, and does follow EBBR to a degree), but i'm not
> sure if i can really use this for x86. grub-core/loader/efi/ftd.c uses
> grub_efi_allocate_pages_real which, if i understand correctly, calls
> UEFI to allocate memory in EfiACPIReclaimMemory. Not sure if this would
> work for x86 (regarding ACPI and its handling in Linux) and also it
> doesn't use grub_relocator_alloc_chunk_align as you mention.

Feel free to change anything what you need. Of course your changes
cannot break existing code. If you think a design document/email/...
will be better posting before the patches feel free to do that too.

Daniel


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-08-02 15:04 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-29  8:43 Device tree support for x86 on Linux Mislav Stublić
2021-07-30 12:59 ` Daniel Kiper
2021-08-02 12:56   ` Mislav Stublić
2021-08-02 13:18   ` Mislav Stublić
2021-08-02 15:04     ` Daniel Kiper

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.