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

[PATCH v2 1/5] x86/setup: Clean up cmdline handling in create_dom0()


  • To: Xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • Date: Tue, 21 Nov 2023 20:15:36 +0000
  • Authentication-results: esa6.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Jan Beulich <JBeulich@xxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Roberto Bagnara <roberto.bagnara@xxxxxxxxxxx>, Nicola Vetrini <nicola.vetrini@xxxxxxxxxxx>
  • Delivery-date: Tue, 21 Nov 2023 20:15:59 +0000
  • Ironport-data: A9a23:IFo2MKN8Rs/+wvfvrR1Dl8FynXyQoLVcMsEvi/4bfWQNrUpw0jxSm mMXXmiPO/beYGX8KthzOo2x/UoOsJ7RndYxTwto+SlhQUwRpJueD7x1DKtS0wC6dZSfER09v 63yTvGacajYm1eF/k/F3oDJ9CQ6jefQAOOkVIYoAwgpLSd8UiAtlBl/rOAwh49skLCRDhiE/ Nj/uKUzAnf8s9JPGjxSs/7rRC9H5qyo42pB5AVmP5ingXeF/5UrJMNHTU2OByOQrrl8RoaSW +vFxbelyWLVlz9F5gSNy+uTnuUiG9Y+DCDW4pZkc/HKbitq/0Te5p0TJvsEAXq7vh3S9zxHJ HehgrTrIeshFvWkdO3wyHC0GQkmVUFN0OevzXRSLaV/ZqAJGpfh66wGMa04AWEX0qVYMyJz7 t9JEx8EcjW4uuion5mrVOY506zPLOGzVG8eknRpzDWfBvc6W5HTBa7N4Le03h9p2JoIR6yHI ZNEOHwwNH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p98i60xPY12jeq69bl7Lau5Z+Lf3JpMgJDz3mzj+pfYhlW7qP+AopqPyy8j8R4Z XxiiZlEcRvznvbOlivpxjg0RSI6kdm11bSjXGZnF7qqojBXzQ4B8BdwaJVGyGpo3YIjZVT0L 9v12ncjoFQDh/LgWDF78XIPisa3XackD4DlvIWhHoacaZ2Us4rkWRWlHklbavpVkrBmfwaOd grKt3A6/NfdlHfS3jYu21mx7WXNEgOIg==
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

There's a confusing mix of variables; a static dom0_cmdline[], and a cmdline
pointer which points to image->string before being pointed at the static
buffer in order to be passed into construct_dom0().  cmdline being a mutable
pointer falls over -Wwrite-strings builds.

Delete the cmdline pointer, and rename dom0_cmdline[] to cmdline extending it
to have full function scope.

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
---
CC: Jan Beulich <JBeulich@xxxxxxxx>
CC: Roger Pau Monné <roger.pau@xxxxxxxxxx>
CC: Wei Liu <wl@xxxxxxx>
CC: Stefano Stabellini <sstabellini@xxxxxxxxxx>
CC: Julien Grall <julien@xxxxxxx>
CC: Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>
CC: Bertrand Marquis <bertrand.marquis@xxxxxxx>
CC: Roberto Bagnara <roberto.bagnara@xxxxxxxxxxx>
CC: Nicola Vetrini <nicola.vetrini@xxxxxxxxxxx>

v2:
 * New.  This unravelled a bit, so I pulled it into a separate patch, but the
   end result is much clearer to follow IMO.
---
 xen/arch/x86/setup.c | 28 +++++++++++++---------------
 1 file changed, 13 insertions(+), 15 deletions(-)

diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c
index c41dfdb2bdf8..c0302c6bdd62 100644
--- a/xen/arch/x86/setup.c
+++ b/xen/arch/x86/setup.c
@@ -873,6 +873,8 @@ static struct domain *__init create_dom0(const module_t 
*image,
                                          module_t *initrd, const char *kextra,
                                          const char *loader)
 {
+    static char __initdata cmdline[MAX_GUEST_CMDLINE];
+
     struct xen_domctl_createdomain dom0_cfg = {
         .flags = IS_ENABLED(CONFIG_TBOOT) ? XEN_DOMCTL_CDF_s3_integrity : 0,
         .max_evtchn_port = -1,
@@ -885,7 +887,6 @@ static struct domain *__init create_dom0(const module_t 
*image,
         },
     };
     struct domain *d;
-    char *cmdline;
     domid_t domid;
 
     if ( opt_dom0_pvh )
@@ -913,33 +914,30 @@ static struct domain *__init create_dom0(const module_t 
*image,
         panic("Error creating d%uv0\n", domid);
 
     /* Grab the DOM0 command line. */
-    cmdline = image->string ? __va(image->string) : NULL;
-    if ( cmdline || kextra )
+    if ( image->string || kextra )
     {
-        static char __initdata dom0_cmdline[MAX_GUEST_CMDLINE];
-
-        cmdline = cmdline_cook(cmdline, loader);
-        safe_strcpy(dom0_cmdline, cmdline);
+        if ( image->string )
+            safe_strcpy(cmdline, cmdline_cook(__va(image->string), loader));
 
         if ( kextra )
             /* kextra always includes exactly one leading space. */
-            safe_strcat(dom0_cmdline, kextra);
+            safe_strcat(cmdline, kextra);
 
         /* Append any extra parameters. */
-        if ( skip_ioapic_setup && !strstr(dom0_cmdline, "noapic") )
-            safe_strcat(dom0_cmdline, " noapic");
+        if ( skip_ioapic_setup && !strstr(cmdline, "noapic") )
+            safe_strcat(cmdline, " noapic");
+
         if ( (strlen(acpi_param) == 0) && acpi_disabled )
         {
             printk("ACPI is disabled, notifying Domain 0 (acpi=off)\n");
             safe_strcpy(acpi_param, "off");
         }
-        if ( (strlen(acpi_param) != 0) && !strstr(dom0_cmdline, "acpi=") )
+
+        if ( (strlen(acpi_param) != 0) && !strstr(cmdline, "acpi=") )
         {
-            safe_strcat(dom0_cmdline, " acpi=");
-            safe_strcat(dom0_cmdline, acpi_param);
+            safe_strcat(cmdline, " acpi=");
+            safe_strcat(cmdline, acpi_param);
         }
-
-        cmdline = dom0_cmdline;
     }
 
     /*
-- 
2.30.2




 


Rackspace

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