Re: [meta-intel] [PATCH RFC] systemd-boot_%.bbappend: Add stub command line modifications patch

2017-06-19 Thread Wold, Saul
On Mon, 2017-06-19 at 13:19 +0200, Patrick Ohly wrote:
> On Wed, 2017-06-14 at 18:47 -0700, California Sullivan wrote:
> > 
> > Allows you to modify the command line when called from EFI shell
> > instead of the entire command line getting replaced.
> > 
> > Signed-off-by: California Sullivan  > >
> > ---
> > I liked this idea so I gave it a shot. Let me know what you think.
> > Commit message is a WIP. Its getting late but I'd like some
> > feedback.
> > 
> >  ...ub-allow-smarter-command-line-modificatio.patch | 132
> > +
> >  .../systemd-boot/systemd-boot_%.bbappend   |   1 +
> >  2 files changed, 133 insertions(+)
> >  create mode 100644 common/recipes-bsp/systemd-boot/systemd-
> > boot/0001-boot-efi-stub-allow-smarter-command-line-
> > modificatio.patch
> > 
> > diff --git a/common/recipes-bsp/systemd-boot/systemd-boot/0001-
> > boot-efi-stub-allow-smarter-command-line-modificatio.patch
> > b/common/recipes-bsp/systemd-boot/systemd-boot/0001-boot-efi-stub-
> > allow-smarter-command-line-modificatio.patch
> > new file mode 100644
> > index 000..9cc92c9
> > --- /dev/null
> > +++ b/common/recipes-bsp/systemd-boot/systemd-boot/0001-boot-efi-
> > stub-allow-smarter-command-line-modificatio.patch
> > @@ -0,0 +1,132 @@
> > +From 47a4ce351911625f227b8b29d9c307d5c32fd32f Mon Sep 17 00:00:00
> > 2001
> > +From: California Sullivan 
> > +Date: Wed, 14 Jun 2017 17:33:30 -0700
> > +Subject: [PATCH] boot: efi: stub: allow smarter command line
> > modifications
> > +
> > +Currently, the command line is replaced with anything that ends up
> > in
> > +LoadOptions. LoadOptions gets populated by the firmware, and EFI
> > shell
> > +command line information when running a binary. This includes the
> > name
> > +of the binary itself, so it will usually break booting from the
> > EFI
> > +shell.
> > +
> > +Instead, have LoadOptions modify the command line in the following
> > way:
> > +
> > +bootx64 root=/dev/sda -> prepend the command line (default)
> > +bootx64 ^console=/dev/tty0 -> prepend the command line (explicit)
> > +bootx64 $console=/dev/tty0 -> append the command line
> > +bootx64 !console=/dev/tty0 root=/dev/sda -> replace the command
> > line
> > +
> > +The '^', '$' and '!' characters act as sentinel values, telling
> > the EFI
> > +stub how to handle LoadOptions values, as well as indicating where
> > +command line modifications in LoadOptions should begin.
> > +
> > +Note that with the default case, bootx64 will end up in the kernel
> > +command line, as we use the sentinel values to decide where to
> > begin the
> > +command line modifications.
> 
> As I was the one who proposed the syntax above, I should refrain from
> commenting on it ;-} Someone else should say "yay" or "nay".
> 
I generally agree with this syntax it's succinct and models RE syntax

> Regarding the code, I think this is something that should be
> submitted
> upstream once we agree that we want this. The code review and perhaps
> even merging can happen upstream.
> 
Agreed, it would be nice for upstream also, but should not block the
implementation and usage here in meta-intel (or maybe in OE).  I guess
that's another discussion point.

Sau!
> -- 
> Best Regards, Patrick Ohly
> 
> The content of this message is my personal opinion only and although
> I am an employee of Intel, the statements I make here in no way
> represent Intel's position on the issue, nor am I authorized to speak
> on behalf of Intel on this matter.
> 
> 
> 
-- 
___
meta-intel mailing list
meta-intel@yoctoproject.org
https://lists.yoctoproject.org/listinfo/meta-intel


Re: [meta-intel] [PATCH RFC] systemd-boot_%.bbappend: Add stub command line modifications patch

2017-06-19 Thread Patrick Ohly
On Wed, 2017-06-14 at 18:47 -0700, California Sullivan wrote:
> Allows you to modify the command line when called from EFI shell
> instead of the entire command line getting replaced.
> 
> Signed-off-by: California Sullivan 
> ---
> I liked this idea so I gave it a shot. Let me know what you think.
> Commit message is a WIP. Its getting late but I'd like some feedback.
> 
>  ...ub-allow-smarter-command-line-modificatio.patch | 132 
> +
>  .../systemd-boot/systemd-boot_%.bbappend   |   1 +
>  2 files changed, 133 insertions(+)
>  create mode 100644 
> common/recipes-bsp/systemd-boot/systemd-boot/0001-boot-efi-stub-allow-smarter-command-line-modificatio.patch
> 
> diff --git 
> a/common/recipes-bsp/systemd-boot/systemd-boot/0001-boot-efi-stub-allow-smarter-command-line-modificatio.patch
>  
> b/common/recipes-bsp/systemd-boot/systemd-boot/0001-boot-efi-stub-allow-smarter-command-line-modificatio.patch
> new file mode 100644
> index 000..9cc92c9
> --- /dev/null
> +++ 
> b/common/recipes-bsp/systemd-boot/systemd-boot/0001-boot-efi-stub-allow-smarter-command-line-modificatio.patch
> @@ -0,0 +1,132 @@
> +From 47a4ce351911625f227b8b29d9c307d5c32fd32f Mon Sep 17 00:00:00 2001
> +From: California Sullivan 
> +Date: Wed, 14 Jun 2017 17:33:30 -0700
> +Subject: [PATCH] boot: efi: stub: allow smarter command line modifications
> +
> +Currently, the command line is replaced with anything that ends up in
> +LoadOptions. LoadOptions gets populated by the firmware, and EFI shell
> +command line information when running a binary. This includes the name
> +of the binary itself, so it will usually break booting from the EFI
> +shell.
> +
> +Instead, have LoadOptions modify the command line in the following way:
> +
> +bootx64 root=/dev/sda -> prepend the command line (default)
> +bootx64 ^console=/dev/tty0 -> prepend the command line (explicit)
> +bootx64 $console=/dev/tty0 -> append the command line
> +bootx64 !console=/dev/tty0 root=/dev/sda -> replace the command line
> +
> +The '^', '$' and '!' characters act as sentinel values, telling the EFI
> +stub how to handle LoadOptions values, as well as indicating where
> +command line modifications in LoadOptions should begin.
> +
> +Note that with the default case, bootx64 will end up in the kernel
> +command line, as we use the sentinel values to decide where to begin the
> +command line modifications.

As I was the one who proposed the syntax above, I should refrain from
commenting on it ;-} Someone else should say "yay" or "nay".

Regarding the code, I think this is something that should be submitted
upstream once we agree that we want this. The code review and perhaps
even merging can happen upstream.

-- 
Best Regards, Patrick Ohly

The content of this message is my personal opinion only and although
I am an employee of Intel, the statements I make here in no way
represent Intel's position on the issue, nor am I authorized to speak
on behalf of Intel on this matter.



-- 
___
meta-intel mailing list
meta-intel@yoctoproject.org
https://lists.yoctoproject.org/listinfo/meta-intel


Re: [meta-intel] [PATCH RFC] systemd-boot_%.bbappend: Add stub command line modifications patch

2017-06-14 Thread Cal Sullivan
This was supposed to be in reply to Patrick's comment on patch 1/4 of my 
previous set, but I missed a letter at the end of the message ID. Oops.


---
Cal

On 06/14/2017 06:47 PM, California Sullivan wrote:

Allows you to modify the command line when called from EFI shell
instead of the entire command line getting replaced.

Signed-off-by: California Sullivan 
---
I liked this idea so I gave it a shot. Let me know what you think.
Commit message is a WIP. Its getting late but I'd like some feedback.

  ...ub-allow-smarter-command-line-modificatio.patch | 132 +
  .../systemd-boot/systemd-boot_%.bbappend   |   1 +
  2 files changed, 133 insertions(+)
  create mode 100644 
common/recipes-bsp/systemd-boot/systemd-boot/0001-boot-efi-stub-allow-smarter-command-line-modificatio.patch

diff --git 
a/common/recipes-bsp/systemd-boot/systemd-boot/0001-boot-efi-stub-allow-smarter-command-line-modificatio.patch
 
b/common/recipes-bsp/systemd-boot/systemd-boot/0001-boot-efi-stub-allow-smarter-command-line-modificatio.patch
new file mode 100644
index 000..9cc92c9
--- /dev/null
+++ 
b/common/recipes-bsp/systemd-boot/systemd-boot/0001-boot-efi-stub-allow-smarter-command-line-modificatio.patch
@@ -0,0 +1,132 @@
+From 47a4ce351911625f227b8b29d9c307d5c32fd32f Mon Sep 17 00:00:00 2001
+From: California Sullivan 
+Date: Wed, 14 Jun 2017 17:33:30 -0700
+Subject: [PATCH] boot: efi: stub: allow smarter command line modifications
+
+Currently, the command line is replaced with anything that ends up in
+LoadOptions. LoadOptions gets populated by the firmware, and EFI shell
+command line information when running a binary. This includes the name
+of the binary itself, so it will usually break booting from the EFI
+shell.
+
+Instead, have LoadOptions modify the command line in the following way:
+
+bootx64 root=/dev/sda -> prepend the command line (default)
+bootx64 ^console=/dev/tty0 -> prepend the command line (explicit)
+bootx64 $console=/dev/tty0 -> append the command line
+bootx64 !console=/dev/tty0 root=/dev/sda -> replace the command line
+
+The '^', '$' and '!' characters act as sentinel values, telling the EFI
+stub how to handle LoadOptions values, as well as indicating where
+command line modifications in LoadOptions should begin.
+
+Note that with the default case, bootx64 will end up in the kernel
+command line, as we use the sentinel values to decide where to begin the
+command line modifications.
+
+Signed-off-by: California Sullivan 
+---
+ src/boot/efi/stub.c | 82 ++---
+ 1 file changed, 78 insertions(+), 4 deletions(-)
+
+diff --git a/src/boot/efi/stub.c b/src/boot/efi/stub.c
+index 74e95fd..a4b34a2 100644
+--- a/src/boot/efi/stub.c
 b/src/boot/efi/stub.c
+@@ -93,15 +93,89 @@ EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE 
*sys_table) {
+ /* if we are not in secure boot mode, accept a custom command line 
and replace the built-in one */
+ if (!secure && loaded_image->LoadOptionsSize > 0 && *(CHAR16 
*)loaded_image->LoadOptions != 0) {
+ CHAR16 *options;
++CHAR8 mode;
+ CHAR8 *line;
++UINTN options_len;
++UINTN total_len;
+ UINTN i;
++UINTN j;
++UINTN k;
+
+ options = (CHAR16 *)loaded_image->LoadOptions;
+-cmdline_len = (loaded_image->LoadOptionsSize / 
sizeof(CHAR16)) * sizeof(CHAR8);
+-line = AllocatePool(cmdline_len);
+-for (i = 0; i < cmdline_len; i++)
+-line[i] = options[i];
++options_len = (loaded_image->LoadOptionsSize / 
sizeof(CHAR16)) * sizeof(CHAR8);
++
++mode = '?';
++/* walk through options to find sentinel values indicating 
alternative modes
++* also use this index to begin the command line changes
++* this lets us avoid adding the binary name to the command 
line */
++for(i = 0; i < options_len; i++) {
++if (options[i] == '$' ||
++options[i] == '!' ||
++options[i] == '^') {
++mode = options[i];
++break;
++}
++}
++
++switch(mode) {
++
++/* append to the cmdline */
++case '$':
++total_len = cmdline_len + options_len - i + 1;
++i++;
++line = AllocatePool(total_len);
++for (j = 0; j < cmdline_len; j++)
++line[j] = cmdline[j];
++
++line[j++] = ' ';
++
++for (k = 0; i + k < options_len && j + k < total_len; 
k++)
++line[j + k] = options[i + k];
++
++

[meta-intel] [PATCH RFC] systemd-boot_%.bbappend: Add stub command line modifications patch

2017-06-14 Thread California Sullivan
Allows you to modify the command line when called from EFI shell
instead of the entire command line getting replaced.

Signed-off-by: California Sullivan 
---
I liked this idea so I gave it a shot. Let me know what you think.
Commit message is a WIP. Its getting late but I'd like some feedback.

 ...ub-allow-smarter-command-line-modificatio.patch | 132 +
 .../systemd-boot/systemd-boot_%.bbappend   |   1 +
 2 files changed, 133 insertions(+)
 create mode 100644 
common/recipes-bsp/systemd-boot/systemd-boot/0001-boot-efi-stub-allow-smarter-command-line-modificatio.patch

diff --git 
a/common/recipes-bsp/systemd-boot/systemd-boot/0001-boot-efi-stub-allow-smarter-command-line-modificatio.patch
 
b/common/recipes-bsp/systemd-boot/systemd-boot/0001-boot-efi-stub-allow-smarter-command-line-modificatio.patch
new file mode 100644
index 000..9cc92c9
--- /dev/null
+++ 
b/common/recipes-bsp/systemd-boot/systemd-boot/0001-boot-efi-stub-allow-smarter-command-line-modificatio.patch
@@ -0,0 +1,132 @@
+From 47a4ce351911625f227b8b29d9c307d5c32fd32f Mon Sep 17 00:00:00 2001
+From: California Sullivan 
+Date: Wed, 14 Jun 2017 17:33:30 -0700
+Subject: [PATCH] boot: efi: stub: allow smarter command line modifications
+
+Currently, the command line is replaced with anything that ends up in
+LoadOptions. LoadOptions gets populated by the firmware, and EFI shell
+command line information when running a binary. This includes the name
+of the binary itself, so it will usually break booting from the EFI
+shell.
+
+Instead, have LoadOptions modify the command line in the following way:
+
+bootx64 root=/dev/sda -> prepend the command line (default)
+bootx64 ^console=/dev/tty0 -> prepend the command line (explicit)
+bootx64 $console=/dev/tty0 -> append the command line
+bootx64 !console=/dev/tty0 root=/dev/sda -> replace the command line
+
+The '^', '$' and '!' characters act as sentinel values, telling the EFI
+stub how to handle LoadOptions values, as well as indicating where
+command line modifications in LoadOptions should begin.
+
+Note that with the default case, bootx64 will end up in the kernel
+command line, as we use the sentinel values to decide where to begin the
+command line modifications.
+
+Signed-off-by: California Sullivan 
+---
+ src/boot/efi/stub.c | 82 ++---
+ 1 file changed, 78 insertions(+), 4 deletions(-)
+
+diff --git a/src/boot/efi/stub.c b/src/boot/efi/stub.c
+index 74e95fd..a4b34a2 100644
+--- a/src/boot/efi/stub.c
 b/src/boot/efi/stub.c
+@@ -93,15 +93,89 @@ EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE 
*sys_table) {
+ /* if we are not in secure boot mode, accept a custom command line 
and replace the built-in one */
+ if (!secure && loaded_image->LoadOptionsSize > 0 && *(CHAR16 
*)loaded_image->LoadOptions != 0) {
+ CHAR16 *options;
++CHAR8 mode;
+ CHAR8 *line;
++UINTN options_len;
++UINTN total_len;
+ UINTN i;
++UINTN j;
++UINTN k;
+ 
+ options = (CHAR16 *)loaded_image->LoadOptions;
+-cmdline_len = (loaded_image->LoadOptionsSize / 
sizeof(CHAR16)) * sizeof(CHAR8);
+-line = AllocatePool(cmdline_len);
+-for (i = 0; i < cmdline_len; i++)
+-line[i] = options[i];
++options_len = (loaded_image->LoadOptionsSize / 
sizeof(CHAR16)) * sizeof(CHAR8);
++
++mode = '?';
++/* walk through options to find sentinel values indicating 
alternative modes
++* also use this index to begin the command line changes
++* this lets us avoid adding the binary name to the command 
line */
++for(i = 0; i < options_len; i++) {
++if (options[i] == '$' ||
++options[i] == '!' ||
++options[i] == '^') {
++mode = options[i];
++break;
++}
++}
++
++switch(mode) {
++
++/* append to the cmdline */
++case '$':
++total_len = cmdline_len + options_len - i + 1;
++i++;
++line = AllocatePool(total_len);
++for (j = 0; j < cmdline_len; j++)
++line[j] = cmdline[j];
++
++line[j++] = ' ';
++
++for (k = 0; i + k < options_len && j + k < total_len; 
k++)
++line[j + k] = options[i + k];
++
++break;
++
++/* replace the cmdline */
++case '!':
++total_len = options_len - i;
++i++;
++line = All