All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] 10_linux: Add devicetree command, if a dtb is present.
@ 2019-05-23 21:31 Dimitri John Ledkov
       [not found] ` <20190528092708.p5bvug222mppi56w@tomti.i.net-space.pl>
  0 siblings, 1 reply; 3+ messages in thread
From: Dimitri John Ledkov @ 2019-05-23 21:31 UTC (permalink / raw)
  To: grub-devel

Specifically support dtb paths as created by flash-kernel package on
Debian/Ubuntu systems, and a generic one. Possibly this needs to be
extended to support other devicetree blob paths as installed on other
distributions (similar to how multiple initrd paths are
supported).

This is particularly useful during new platforms bring up, which may
not yet be fully supported by Linux kernel. Currently I have tested
this patch, on top of Debian grub2 packaging/distro-patches to
successfully boot Asus Novago TP3700QL. Similarly other laptops would
find this useful, like Lenovo Mixx 630, Lenovo Yoga C630, and HP Envy
X2.

Signed-off-by: Dimitri John Ledkov <xnox@ubuntu.com>
---
 util/grub.d/10_linux.in | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in
index 4532266be..bb6c8912f 100644
--- a/util/grub.d/10_linux.in
+++ b/util/grub.d/10_linux.in
@@ -153,6 +153,13 @@ EOF
     sed "s/^/$submenu_indentation/" << EOF
 	echo	'$(echo "$message" | grub_quote)'
 	initrd	$(echo $initrd_path)
+EOF
+  fi
+  if test -n "${dtb}" ; then
+    message="$(gettext_printf "Loading device tree blob...")"
+    sed "s/^/$submenu_indentation/" << EOF
+	echo	'$(echo "$message" | grub_quote)'
+	devicetree  ${rel_dirname}/${dtb}
 EOF
   fi
   sed "s/^/$submenu_indentation/" << EOF
@@ -236,6 +243,14 @@ while [ "x$list" != "x" ] ; do
     gettext_printf "Found initrd image: %s\n" "$(echo $initrd_display)" >&2
   fi
 
+  dtb=
+  for i in "dtb-${version}" "dtb-${alt_version}" "dtb"; do
+    if test -e "${dirname}/${i}" ; then
+      dtb="$i"
+      break
+    fi
+  done
+
   config=
   for i in "${dirname}/config-${version}" "${dirname}/config-${alt_version}" "/etc/kernels/kernel-config-${version}" ; do
     if test -e "${i}" ; then
-- 
2.20.1



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

* Re: [PATCH] 10_linux: Add devicetree command, if a dtb is present.
       [not found] ` <20190528092708.p5bvug222mppi56w@tomti.i.net-space.pl>
@ 2019-05-28 11:01   ` Leif Lindholm
  2019-05-28 12:04     ` Dimitri John Ledkov
  0 siblings, 1 reply; 3+ messages in thread
From: Leif Lindholm @ 2019-05-28 11:01 UTC (permalink / raw)
  To: Daniel Kiper; +Cc: Dimitri John Ledkov, grub-devel, agraf

On Tue, May 28, 2019 at 11:27:08AM +0200, Daniel Kiper wrote:
> On Thu, May 23, 2019 at 10:31:13PM +0100, Dimitri John Ledkov wrote:
> > Specifically support dtb paths as created by flash-kernel package on
> > Debian/Ubuntu systems, and a generic one. Possibly this needs to be
> > extended to support other devicetree blob paths as installed on other
> > distributions (similar to how multiple initrd paths are
> > supported).
> >
> > This is particularly useful during new platforms bring up, which may
> > not yet be fully supported by Linux kernel. Currently I have tested
> > this patch, on top of Debian grub2 packaging/distro-patches to
> > successfully boot Asus Novago TP3700QL. Similarly other laptops would
> > find this useful, like Lenovo Mixx 630, Lenovo Yoga C630, and HP Envy
> > X2.
> >
> > Signed-off-by: Dimitri John Ledkov <xnox@ubuntu.com>
> 
> LGTM but I would like to hear Leif and/or Alex (CC-ed) opinion here.

This is not my preferred solution to this problem (Dimitri, I'll ping
you offline regarding this).

Also it is fundamentally incompatible with UEFI Secure Boot (see
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=927888).

We should probably look into disabling the devicetree command by
default for the UEFI port. I'll revisit that point post release.

Regards,

Leif

> And this is not a release material.
> 
> Daniel
> 
> > ---
> >  util/grub.d/10_linux.in | 15 +++++++++++++++
> >  1 file changed, 15 insertions(+)
> >
> > diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in
> > index 4532266be..bb6c8912f 100644
> > --- a/util/grub.d/10_linux.in
> > +++ b/util/grub.d/10_linux.in
> > @@ -153,6 +153,13 @@ EOF
> >      sed "s/^/$submenu_indentation/" << EOF
> >  	echo	'$(echo "$message" | grub_quote)'
> >  	initrd	$(echo $initrd_path)
> > +EOF
> > +  fi
> > +  if test -n "${dtb}" ; then
> > +    message="$(gettext_printf "Loading device tree blob...")"
> > +    sed "s/^/$submenu_indentation/" << EOF
> > +	echo	'$(echo "$message" | grub_quote)'
> > +	devicetree  ${rel_dirname}/${dtb}
> >  EOF
> >    fi
> >    sed "s/^/$submenu_indentation/" << EOF
> > @@ -236,6 +243,14 @@ while [ "x$list" != "x" ] ; do
> >      gettext_printf "Found initrd image: %s\n" "$(echo $initrd_display)" >&2
> >    fi
> >
> > +  dtb=
> > +  for i in "dtb-${version}" "dtb-${alt_version}" "dtb"; do
> > +    if test -e "${dirname}/${i}" ; then
> > +      dtb="$i"
> > +      break
> > +    fi
> > +  done
> > +
> >    config=
> >    for i in "${dirname}/config-${version}" "${dirname}/config-${alt_version}" "/etc/kernels/kernel-config-${version}" ; do
> >      if test -e "${i}" ; then
> > --
> > 2.20.1


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

* Re: [PATCH] 10_linux: Add devicetree command, if a dtb is present.
  2019-05-28 11:01   ` Leif Lindholm
@ 2019-05-28 12:04     ` Dimitri John Ledkov
  0 siblings, 0 replies; 3+ messages in thread
From: Dimitri John Ledkov @ 2019-05-28 12:04 UTC (permalink / raw)
  To: Leif Lindholm; +Cc: Daniel Kiper, The development of GNU GRUB, agraf

On Tue, 28 May 2019 at 12:01, Leif Lindholm <leif.lindholm@linaro.org> wrote:
>
> On Tue, May 28, 2019 at 11:27:08AM +0200, Daniel Kiper wrote:
> > On Thu, May 23, 2019 at 10:31:13PM +0100, Dimitri John Ledkov wrote:
> > > Specifically support dtb paths as created by flash-kernel package on
> > > Debian/Ubuntu systems, and a generic one. Possibly this needs to be
> > > extended to support other devicetree blob paths as installed on other
> > > distributions (similar to how multiple initrd paths are
> > > supported).
> > >
> > > This is particularly useful during new platforms bring up, which may
> > > not yet be fully supported by Linux kernel. Currently I have tested
> > > this patch, on top of Debian grub2 packaging/distro-patches to
> > > successfully boot Asus Novago TP3700QL. Similarly other laptops would
> > > find this useful, like Lenovo Mixx 630, Lenovo Yoga C630, and HP Envy
> > > X2.
> > >
> > > Signed-off-by: Dimitri John Ledkov <xnox@ubuntu.com>
> >
> > LGTM but I would like to hear Leif and/or Alex (CC-ed) opinion here.
>
> This is not my preferred solution to this problem (Dimitri, I'll ping
> you offline regarding this).
>
> Also it is fundamentally incompatible with UEFI Secure Boot (see
> https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=927888).
>
> We should probably look into disabling the devicetree command by
> default for the UEFI port. I'll revisit that point post release.
>

Yes, in an ideal world all devices would boot correctly with
SecureBoot enforced, using plain ACPI and no dtbs would be needed and
no devicetree command would be needed in grub at all. And when bugs in
ACPI are discovered vendors would issue firmware updates promptly that
would get applied by users in a timely manner using fwupd mechanism /
uefi capsules / windows updater.

In practice, I have had to patch dtbs on Intel NUCs, arm64 servers and
laptops. I suspect we will experience broken ACPI on other devices and
architectures in the future too (RISC-V comes to mind). This is an
unsecureboot crutch, that works in concert with other crutches already
available in the distros (i.e. at package upgrade time copying things
to /boot & generating matching sets of kernel/initrd/dtb). And makes
crutches look like a useful matching set, and works today. And yes,
this is not the preferred way of doing things. But I hope it will be
useful, however temporary, to whomever is working on new devices
brings-ups / iterating kernels&dtbs. In those cases automatic
integration of devicetree command in grub.cfg generator would be a
nice touch.

The alternative proposal would probably still end up reading the dtbs
from these very same paths, if we expect to ship dtbs in distro's and
make them upgradable using package managers. Unless they are
statically embeded / signed in the alternative utility to poke them
into UEFI environment.

Originally I submitted this as a distro patch to Debian, with
maintainer requesting it to be forwarded upstream - as this is a
universally general feature, rather than something distro specific:
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=929427


Regards,

Dimitri.


> Regards,
>
> Leif
>
> > And this is not a release material.
> >
> > Daniel
> >
> > > ---
> > >  util/grub.d/10_linux.in | 15 +++++++++++++++
> > >  1 file changed, 15 insertions(+)
> > >
> > > diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in
> > > index 4532266be..bb6c8912f 100644
> > > --- a/util/grub.d/10_linux.in
> > > +++ b/util/grub.d/10_linux.in
> > > @@ -153,6 +153,13 @@ EOF
> > >      sed "s/^/$submenu_indentation/" << EOF
> > >     echo    '$(echo "$message" | grub_quote)'
> > >     initrd  $(echo $initrd_path)
> > > +EOF
> > > +  fi
> > > +  if test -n "${dtb}" ; then
> > > +    message="$(gettext_printf "Loading device tree blob...")"
> > > +    sed "s/^/$submenu_indentation/" << EOF
> > > +   echo    '$(echo "$message" | grub_quote)'
> > > +   devicetree  ${rel_dirname}/${dtb}
> > >  EOF
> > >    fi
> > >    sed "s/^/$submenu_indentation/" << EOF
> > > @@ -236,6 +243,14 @@ while [ "x$list" != "x" ] ; do
> > >      gettext_printf "Found initrd image: %s\n" "$(echo $initrd_display)" >&2
> > >    fi
> > >
> > > +  dtb=
> > > +  for i in "dtb-${version}" "dtb-${alt_version}" "dtb"; do
> > > +    if test -e "${dirname}/${i}" ; then
> > > +      dtb="$i"
> > > +      break
> > > +    fi
> > > +  done
> > > +
> > >    config=
> > >    for i in "${dirname}/config-${version}" "${dirname}/config-${alt_version}" "/etc/kernels/kernel-config-${version}" ; do
> > >      if test -e "${i}" ; then
> > > --
> > > 2.20.1



-- 
Regards,

Dimitri.


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

end of thread, other threads:[~2019-05-28 12:05 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-23 21:31 [PATCH] 10_linux: Add devicetree command, if a dtb is present Dimitri John Ledkov
     [not found] ` <20190528092708.p5bvug222mppi56w@tomti.i.net-space.pl>
2019-05-28 11:01   ` Leif Lindholm
2019-05-28 12:04     ` Dimitri John Ledkov

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.