[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH v3 3/3] cmdline: parse multiple instances of the vga option


  • To: xen-devel@xxxxxxxxxxxxxxxxxxxx
  • From: Roger Pau Monne <roger.pau@xxxxxxxxxx>
  • Date: Thu, 1 Jun 2023 15:05:18 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=5KbyhxApTsmQyQClBvfFt4PODwfZzCgM7GeO38igh0w=; b=No8rhiwd4u1IGjd1q+0/SltKscKPmzpXtj6A3WbZmAIPD6mCgOXQlEBZtcgDMFqHm9p+VKya9DtXLzSJYClsegr++OXagd/10dgB81i3ql52uQ3Ha8NX9F9S2rSenArRZo3jKyzpOlwS9R/MbfdF5jY6wZwH9j2bX2KzpDqijG4/m14PgKbwqZaGWTGcUqvuV/UpcFBbkK95fXMVK5dBfwXgcrCMpAwFbzhnnVGzOaMPFKMpdIhWlNjvPEOBTcA6asEdCUwOw43eyqpbinuSLIYPBXHCxK1q97U/Gky8Qk9WFgiG/0btbfpuTv/KDhmpmzUuiHvX+FY+16n8RxVadQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dOkryvORN9wobYipfIS4SvcvfWwj9TL8CNxxGA73WWPmOiWPXs4d9/kHfdy8PxVlEp9eCLs2RajjkRQmTG4DI9X+13GFrwF32q+ky+QlmmPzpIzr8yjmme4qCSNNhSMSpMQS3sYNx6EUyDmKcaB9Bbk6R/0Xz7V8f3i6tXcP70SidwiWOMwdjlho9xRFOUgsj/E195HFCauuULE1ts+DB5Tdj/6FnW+AasSJ7QRHwr5XajTSPhB+XRmU0Ijcir2gR2SPoiRo1IGY+r4lkANUk6vRYxRfR37CJYTYGhs1yEgx3z1aShX2mN/cQ0hb9jzS2qwfNZ0uVmDTo9LChYjsWw==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
  • Cc: Roger Pau Monne <roger.pau@xxxxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, Julien Grall <julien@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>
  • Delivery-date: Thu, 01 Jun 2023 13:06:03 +0000
  • Ironport-data: A9a23:rxmOO6q/FUQE9DJJWRLGShzK2YVeBmLWZBIvgKrLsJaIsI4StFCzt garIBmPPKyLNjPyed9wbtuy/U4H75GDnNJrQAZs/isxES8T9puZCYyVIHmrMnLJJKUvbq7FA +Y2MYCccZ9uHhcwgj/3b9ANeFEljfngqoLUUbKCYWYpA1c/Ek/NsDo788YhmIlknNOlNA2Ev NL2sqX3NUSsnjV5KQr40YrawP9UlKq04GtwUmAWP6gR5weAzyBNV/rzGInqR5fGatgMdgKFb 76rIIGRpgvx4xorA9W5pbf3GmVirmn6ZFXmZtJ+AsBOszAazsAA+v9T2Mk0MC+7vw6hjdFpo OihgLTrIesf0g8gr8xGO/VQO3kW0aSrY9YrK1Dn2SCY5xWun3cBX5yCpaz5VGEV0r8fPI1Ay RAXAA0sUiyzwNqq/L/lTuNMv58pHuX3ZqpK7xmMzRmBZRonabbqZvyToPR/hXI3jM0IGuvCb c0EbzYpdA7HfxBEJlYQDtQ5gfusgX78NTZfrTp5p4JuuzSVkFM3jearaYWJEjCJbZw9ckKwv GXJ8n6/GhgHHNee1SCE4jSngeqncSbTAdtLSubgraQ16LGV7kI1LDc7bASgm9agoB6RRsBzL lAK5RN7+MDe82TuFLERRSaQsHOC+xIRRddUO+k78x2WjLrZ5R6DAWoJRSIHb8Yp3Oc0TzE30 l6Cn/vyGCdi9raSTBq19KqQrD60ETgYKykFfyBsZRAe/9DprYU3jxTOZtVuCqi4ipvyAz6Y6 y+OhDgzgfMUl8Fj6kmg1VXOgjbprZ+QSAcwv1zTRjj8sV8/Y5O5bYu171Sd9exHMIuSUliGu j4DhtSa6+cNS5qKkURhXdkwIV1g3N7dWBW0vLKlN8BJG+iFk5J7Qb1t3Q==
  • Ironport-hdrordr: A9a23:v0QoKay4GwV3QCbkybN3KrPwF71zdoMgy1knxilNoH1uA7Wlfq WV98jzuiWE7wr5NEtQ+uxoQZPhfZq+z+8S3WByB9qftWDd0QPDEGgF1/qB/9SKIVybygcy79 YET0FIMrHN5IlB7PoTsWGDferJnrG8n5yVuQ==
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Parse all instances of the vga= option on the command line, in order
to always enforce the last selection on the command line.

Note that it's not safe to parse just the last occurrence of the vga=
option, as then a command line with `vga=current vga=keep` would
result in current being ignored.

Adjust the command line documentation to describe the new behavior.

Signed-off-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
---
Changes since v2:
 - New in this version.
---
Build tested only, as I don't have a system that does legacy boot and
has VGA output I can check.

It's mostly encapsulating the current code inside of a while loop and
adding an extra else if for the "ask" option, there's a lot of
indentation changes.
---
 docs/misc/xen-command-line.pandoc |  3 ++
 xen/arch/x86/boot/cmdline.c       | 85 +++++++++++++++----------------
 2 files changed, 45 insertions(+), 43 deletions(-)

diff --git a/docs/misc/xen-command-line.pandoc 
b/docs/misc/xen-command-line.pandoc
index e0b89b7d3319..8cf2f3423d47 100644
--- a/docs/misc/xen-command-line.pandoc
+++ b/docs/misc/xen-command-line.pandoc
@@ -2628,6 +2628,9 @@ with the specified width, height and depth.
 `ask` option.  (N.B menu modes are displayed in hex, so `<mode>`
 should be a hexadecimal number)
 
+Note that all the occurrences of the vga option in the command line are parsed,
+and hence later occurrences can overwrite selections done by prior ones.
+
 The optional `keep` parameter causes Xen to continue using the vga
 console even after dom0 has been started.  The default behaviour is to
 relinquish control to dom0.
diff --git a/xen/arch/x86/boot/cmdline.c b/xen/arch/x86/boot/cmdline.c
index fc11c6d3c5c4..511e77e0c2b5 100644
--- a/xen/arch/x86/boot/cmdline.c
+++ b/xen/arch/x86/boot/cmdline.c
@@ -277,59 +277,58 @@ static u16 rows2vmode(unsigned int rows)
 
 static void vga_parse(const char *cmdline, early_boot_opts_t *ebo)
 {
-    const char *c;
-    unsigned int tmp, vesa_depth, vesa_height, vesa_width;
-
-    c = find_opt(cmdline, "vga=", true);
-
-    if ( !c )
-        return;
+    const char *c = cmdline;
 
-    ebo->boot_vid_mode = ASK_VGA;
-
-    if ( !strmaxcmp(c, "current", delim_chars_comma) )
-        ebo->boot_vid_mode = VIDEO_CURRENT_MODE;
-    else if ( !strsubcmp(c, "text-80x") )
-    {
-        c += strlen("text-80x");
-        ebo->boot_vid_mode = rows2vmode(strtoui(c, delim_chars_comma, NULL));
-    }
-    else if ( !strsubcmp(c, "gfx-") )
+    while ( (c = find_opt(c, "vga=", true)) != NULL )
     {
-        vesa_width = strtoui(c + strlen("gfx-"), "x", &c);
+        unsigned int tmp, vesa_depth, vesa_height, vesa_width;
 
-        if ( vesa_width > U16_MAX )
-            return;
+        if ( !strmaxcmp(c, "current", delim_chars_comma) )
+            ebo->boot_vid_mode = VIDEO_CURRENT_MODE;
+        else if ( !strsubcmp(c, "text-80x") )
+        {
+            c += strlen("text-80x");
+            ebo->boot_vid_mode = rows2vmode(strtoui(c, delim_chars_comma, 
NULL));
+        }
+        else if ( !strsubcmp(c, "gfx-") )
+        {
+            vesa_width = strtoui(c + strlen("gfx-"), "x", &c);
 
-        /*
-         * Increment c outside of strtoui() because otherwise some
-         * compiler may complain with following message:
-         * warning: operation on 'c' may be undefined.
-         */
-        ++c;
-        vesa_height = strtoui(c, "x", &c);
+            if ( vesa_width > U16_MAX )
+                return;
 
-        if ( vesa_height > U16_MAX )
-            return;
+            /*
+             * Increment c outside of strtoui() because otherwise some
+             * compiler may complain with following message:
+             * warning: operation on 'c' may be undefined.
+             */
+            ++c;
+            vesa_height = strtoui(c, "x", &c);
 
-        vesa_depth = strtoui(++c, delim_chars_comma, NULL);
+            if ( vesa_height > U16_MAX )
+                return;
 
-        if ( vesa_depth > U16_MAX )
-            return;
+            vesa_depth = strtoui(++c, delim_chars_comma, NULL);
 
-        ebo->vesa_width = vesa_width;
-        ebo->vesa_height = vesa_height;
-        ebo->vesa_depth = vesa_depth;
-        ebo->boot_vid_mode = VIDEO_VESA_BY_SIZE;
-    }
-    else if ( !strsubcmp(c, "mode-") )
-    {
-        tmp = strtoui(c + strlen("mode-"), delim_chars_comma, NULL);
+            if ( vesa_depth > U16_MAX )
+                return;
 
-        if ( tmp > U16_MAX )
-            return;
+            ebo->vesa_width = vesa_width;
+            ebo->vesa_height = vesa_height;
+            ebo->vesa_depth = vesa_depth;
+            ebo->boot_vid_mode = VIDEO_VESA_BY_SIZE;
+        }
+        else if ( !strsubcmp(c, "mode-") )
+        {
+            tmp = strtoui(c + strlen("mode-"), delim_chars_comma, NULL);
 
-        ebo->boot_vid_mode = tmp;
+            if ( tmp > U16_MAX )
+                return;
+
+            ebo->boot_vid_mode = tmp;
+        }
+        else if ( !strsubcmp(c, "ask") )
+            ebo->boot_vid_mode = ASK_VGA;
     }
 }
 #endif
-- 
2.40.0




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.