Skip to contentSkip to conversation

xen/arch/x86: Fix early boot command line parsing

PATCH In review Daniel Kiper 3 participants 3 messages Dec 3, 2013 – Dec 4, 2013

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 xen/arch/x86: Fix early boot command line parsing

There is no reliable way to encode NUL character as a character so encode it as a number. Read: http://sourceware.org/binutils/docs/as/Characters.html.
Octal and hex encoding do not work on at least one system (GNU assembler version 2.22 (x86_64-linux-gnu) using BFD version (GNU Binutils for Debian) 2.22). Without this fix e.g. no-real-mode option at the end of xen.gz command line is not detected.

v2 - suggestions/fixes:
- add relevant comment to assembly file (suggested by Andrew Cooper),
- leave encoding of other characters as is for readability (suggested by Jan Beulich).

---
 xen/arch/x86/boot/cmdline.S |   10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
xen/arch/x86/boot/cmdline.S +9 -1
index 05ffb94..b83975e 100644
@@ -138,7 +138,15 @@
         call    .Lstrlen
         add     $4,%esp
         xadd    %eax,%ebx
-        cmpb    $'\0',(%ebx)
+        /*
+         * There is no reliable way to encode NUL character as a character so encode
+         * it as a number. Read: http://sourceware.org/binutils/docs/as/Characters.html.
+         * Octal and hex encoding do not work on at least one system (GNU assembler
+         * version 2.22 (x86_64-linux-gnu) using BFD version (GNU Binutils for Debian) 2.22).
+         * Without this fix e.g. no-real-mode option at the end of xen.gz command line
+         * is not detected.
+         */
+        cmpb    $0,(%ebx)
         je      3f
         cmpb    $' ',(%ebx)
         je      3f
Signature · 1 line
1.7.10.4
Reviewed-by on v2 1/1
#1 lore raw
Quoted 7 lines · Daniel Kiper

There is no reliable way to encode NUL character as a character so encode it as a number. Read: http://sourceware.org/binutils/docs/as/Characters.html.
Octal and hex encoding do not work on at least one system (GNU assembler version 2.22 (x86_64-linux-gnu) using BFD version (GNU Binutils for Debian) 2.22). Without this fix e.g. no-real-mode option at the end of xen.gz command line is not detected.

Quoted 7 lines

v2 - suggestions/fixes:
- add relevant comment to assembly file (suggested by Andrew Cooper),
- leave encoding of other characters as is for readability (suggested by Jan Beulich).

I was thinking more along the lines of /* NULL check (as $'\0' == 0x30 in GAS) */

Either way, at least it is obvious.

Quoted 25 lines
---
 xen/arch/x86/boot/cmdline.S |   10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
xen/arch/x86/boot/cmdline.S +9 -1
index 05ffb94..b83975e 100644
@@ -138,7 +138,15 @@
         call    .Lstrlen
         add     $4,%esp
         xadd    %eax,%ebx
-        cmpb    $'\0',(%ebx)
+        /*
+         * There is no reliable way to encode NUL character as a character so encode
+         * it as a number. Read: http://sourceware.org/binutils/docs/as/Characters.html.
+         * Octal and hex encoding do not work on at least one system (GNU assembler
+         * version 2.22 (x86_64-linux-gnu) using BFD version (GNU Binutils for Debian) 2.22).
+         * Without this fix e.g. no-real-mode option at the end of xen.gz command line
+         * is not detected.
+         */
+        cmpb    $0,(%ebx)
         je      3f
         cmpb    $' ',(%ebx)
         je      3f
Acked-by
#2 lore raw
Quoted 15 lines · Andrew Cooper
Quoted 14 lines · Daniel Kiper

There is no reliable way to encode NUL character as a character so encode it as a number. Read: http://sourceware.org/binutils/docs/as/Characters.html.
Octal and hex encoding do not work on at least one system (GNU assembler version 2.22 (x86_64-linux-gnu) using BFD version (GNU Binutils for Debian) 2.22).
Without this fix e.g. no-real-mode option at the end of xen.gz command line is not detected.

v2 - suggestions/fixes:
- add relevant comment to assembly file (suggested by Andrew Cooper),
- leave encoding of other characters as is for readability (suggested by Jan Beulich).

Quoted 8 lines
Quoted 1 line

I was thinking more along the lines of /* NULL check (as $'\0' == 0x30 in GAS) */

Either way, at least it is obvious.

Quoted 36 lines
Quoted 24 lines
---
 xen/arch/x86/boot/cmdline.S |   10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
xen/arch/x86/boot/cmdline.S +2 -1
index 05ffb94..b83975e 100644
@@ -138,7 +138,15 @@
         call    .Lstrlen
         add     $4,%esp
         xadd    %eax,%ebx
-        cmpb    $'\0',(%ebx)
+        /*
+         * There is no reliable way to encode NUL character as a character

so encode
+ * it as a number. Read:
http://sourceware.org/binutils/docs/as/Characters.html.
+ * Octal and hex encoding do not work on at least one system (GNU
assembler
+ * version 2.22 (x86_64-linux-gnu) using BFD version (GNU Binutils
for Debian) 2.22).
+ * Without this fix e.g. no-real-mode option at the end of xen.gz
command line

xen/arch/x86/boot/cmdline.S line 152

Quoted 6 lines
xen/arch/x86/boot/cmdline.S +3 -0
+         * is not detected.
+         */
+        cmpb    $0,(%ebx)
         je      3f
         cmpb    $' ',(%ebx)
         je      3f

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel