Skip to contentSkip to conversation

xen: Enable -Wwrite-strings

PATCH In review Andrew Cooper 6 participants 24 messages Nov 21, 2023 – Nov 23, 2023

lore
Share & tools
lore
#0 lore raw

v2 cover xen: Enable -Wwrite-strings

Some patches from v1 committed. This is the rest, and they're mostly rewritten from scratch.

CI:
https://gitlab.com/xen-project/people/andyhhp/xen/-/pipelines/1080695374
https://cirrus-ci.com/build/5494986230202368

Andrew Cooper (5):
x86/setup: Clean up cmdline handling in create_dom0() x86/setup: Rework cmdline_cook() to be compatible with -Wwrite-strings x86/efi: Simplify efi_arch_handle_cmdline()
arm/efi: Simplify efi_arch_handle_cmdline()
xen: Enable -Wwrite-strings

 xen/Makefile                |  2 +-
 xen/arch/arm/efi/efi-boot.h | 16 +----------
 xen/arch/x86/efi/efi-boot.h | 10 +------
 xen/arch/x86/setup.c        | 56 ++++++++++++++++++++-----------------
 4 files changed, 34 insertions(+), 50 deletions(-)

base-commit: 10081c2dc571775b538bb00982606a39832ad7e3

Signature · 1 line
2.30.2
#1 lore raw

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

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.

---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Wei Liu <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Julien Grall <[email protected]>
CC: Volodymyr Babchuk <[email protected]>
CC: Bertrand Marquis <[email protected]>
CC: Roberto Bagnara <[email protected]>
CC: Nicola Vetrini <[email protected]>

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(-)
xen/arch/x86/setup.c +13 -15
index c41dfdb2bdf8..c0302c6bdd62 100644
@@ -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;
     }
 
     /*
Signature · 1 line
2.30.2
Reviewed-by on v2 1/5
#2 lore raw

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

Quoted 11 lines · Andrew Cooper

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.

with two remarks:

xen/arch/x86/setup.c static struct domain *__init create_dom0(const module_t *image, · line 878

Quoted 9 lines
xen/arch/x86/setup.c +2 -0
@@ -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 = {

While I think I see why you're adding the blank line there, I'm not overly happy about you doing so: Our usual use of blank lines after declarations is to separate from statements, not from other (in this case non-static) declarations. (And really, just a remark, leaving it to you to keep as is or adjust.)

Quoted 24 lines
xen/arch/x86/setup.c +5 -9
@@ -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") )

xen/arch/x86/setup.c static struct domain *__init create_dom0(const module_t *image, · line 936

Quoted 10 lines
xen/arch/x86/setup.c +4 -1
+            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=") )

As you're touching this anyway, how about replacing the strlen() by just *acpi_param? We don't really care exactly how long the string is. (As an aside, strstr() uses like the one here are of course also pretty fragile. But of course that's nothing to care about in this change.)

Jan

#3 lore raw

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

Quoted 6 lines · Jan Beulich
Quoted 5 lines · Andrew Cooper

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.

Quoted 7 lines
Quoted 6 lines

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

No functional change.

Thanks.

Quoted 16 lines

with two remarks:

xen/arch/x86/setup.c static struct domain *__init create_dom0(const module_t *image, · line 878

Quoted 9 lines
xen/arch/x86/setup.c +2 -0
@@ -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 = {

While I think I see why you're adding the blank line there, I'm not overly happy about you doing so: Our usual use of blank lines after declarations is to separate from statements, not from other (in this case non-static) declarations. (And really, just a remark, leaving it to you to keep as is or adjust.)

We have plenty of examples of this pattern in the codebase already.  Not quite half of the cases with both static and local variable declarations, but not far off either.

From a clarity point of view it is helpful to separate the stack locals from the globals-with-local-scope.

Quoted 31 lines
Quoted 31 lines
xen/arch/x86/setup.c +7 -9
@@ -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");
Quoted 8 lines

xen/arch/x86/setup.c static struct domain *__init create_dom0(const module_t *image, · line 936

Quoted 4 lines
xen/arch/x86/setup.c +2 -1
         }
-        if ( (strlen(acpi_param) != 0) && !strstr(dom0_cmdline, "acpi=") )
+
+        if ( (strlen(acpi_param) != 0) && !strstr(cmdline, "acpi=") )

As you're touching this anyway, how about replacing the strlen() by just *acpi_param? We don't really care exactly how long the string is. (As an aside, strstr() uses like the one here are of course also pretty fragile. But of course that's nothing to care about in this change.)

There's the same pattern just above it, not touched, and this patch is already getting complicated.

I think there's other cleanup to do here, so I'll defer it to later.

~Andrew

#4 lore raw

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

Quoted 40 lines · Andrew Cooper
Quoted 31 lines · Jan Beulich
Quoted 30 lines · Andrew Cooper
xen/arch/x86/setup.c +7 -9
@@ -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");
Quoted 8 lines

xen/arch/x86/setup.c static struct domain *__init create_dom0(const module_t *image, · line 936

Quoted 4 lines
xen/arch/x86/setup.c +2 -1
         }
-        if ( (strlen(acpi_param) != 0) && !strstr(dom0_cmdline, "acpi=") )
+
+        if ( (strlen(acpi_param) != 0) && !strstr(cmdline, "acpi=") )

As you're touching this anyway, how about replacing the strlen() by just *acpi_param? We don't really care exactly how long the string is. (As an aside, strstr() uses like the one here are of course also pretty fragile. But of course that's nothing to care about in this change.)

Quoted 4 lines

There's the same pattern just above it, not touched, and this patch is already getting complicated.

I think there's other cleanup to do here, so I'll defer it to later.

It turns out that the optimiser already makes this transformation.

I shan't admit to how long I've just spent thinking I had a problem with my build...

~Andrew

#5 lore raw

PATCH v2 2/5 x86/setup: Rework cmdline_cook() to be compatible with -Wwrite-strings

In reply to Andrew Cooper

Rework the logic in __start_xen() to not potentially pass NULL into cmdline_cook(). This makes the logic easier to follow too, and the rest of __start_xen() is safe when initialising cmdline to the empty string.

Update cmdline_cook() to take and return const pointers, and write a description of what it does. It now requires a non-NULL input and guarentees to return a pointer somewhere in the 'p' string.

Note this only compiles because strstr() launders the const off the pointer when assigning to the mutable kextra, but that logic only mutates the mbi->cmdline buffer.

---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Wei Liu <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Julien Grall <[email protected]>
CC: Volodymyr Babchuk <[email protected]>
CC: Bertrand Marquis <[email protected]>
CC: Roberto Bagnara <[email protected]>
CC: Nicola Vetrini <[email protected]>

v2:
* create_dom0() changes split out into a previous patch
* Remove the logic for a NULL input, now that all callers have been adjusted

---
 xen/arch/x86/setup.c | 21 +++++++++++++--------
 1 file changed, 13 insertions(+), 8 deletions(-)
xen/arch/x86/setup.c +13 -8
index c0302c6bdd62..b171a8f4cf84 100644
@@ -837,10 +837,15 @@ static bool __init loader_is_grub2(const char *loader_name)
     return (p != NULL) && (p[5] != '0');
 }
 
-static char * __init cmdline_cook(char *p, const char *loader_name)
+/*
+ * Clean up a command line string passed to us by a bootloader.  Strip leading
+ * whitespace, and optionally strip the first parameter if our divination of
+ * the bootloader suggests that it prepended the image name.
+ *
+ * Always returns a pointer within @p.
+ */
+static const char *__init cmdline_cook(const char *p, const char *loader_name)
 {
-    p = p ? : "";
-
     /* Strip leading whitespace. */
     while ( *p == ' ' )
         p++;
@@ -969,8 +974,8 @@ static struct domain *__init create_dom0(const module_t *image,
 /* SAF-1-safe */
 void __init noreturn __start_xen(unsigned long mbi_p)
 {
-    const char *memmap_type = NULL, *loader;
-    char *cmdline, *kextra;
+    const char *memmap_type = NULL, *loader, *cmdline = "";
+    char *kextra;
     void *bsp_stack;
     struct cpu_info *info = get_cpu_info(), *bsp_info;
     unsigned int initrdidx, num_parked = 0;
@@ -1025,9 +1030,9 @@ void __init noreturn __start_xen(unsigned long mbi_p)
                                            : "unknown";
 
     /* Parse the command-line options. */
-    cmdline = cmdline_cook((mbi->flags & MBI_CMDLINE) ?
-                           __va(mbi->cmdline) : NULL,
-                           loader);
+    if ( mbi->flags & MBI_CMDLINE )
+        cmdline = cmdline_cook(__va(mbi->cmdline), loader);
+
     if ( (kextra = strstr(cmdline, " -- ")) != NULL )
     {
         /*
Signature · 1 line
2.30.2
Reviewed-by on v2 2/5
#6 lore raw

Re: [PATCH v2 2/5] x86/setup: Rework cmdline_cook() to be compatible with -Wwrite-strings

Quoted 8 lines · Andrew Cooper

Rework the logic in __start_xen() to not potentially pass NULL into cmdline_cook(). This makes the logic easier to follow too, and the rest of __start_xen() is safe when initialising cmdline to the empty string.

Update cmdline_cook() to take and return const pointers, and write a description of what it does. It now requires a non-NULL input and guarentees to return a pointer somewhere in the 'p' string.

Quoted 5 lines

Note this only compiles because strstr() launders the const off the pointer when assigning to the mutable kextra, but that logic only mutates the mbi->cmdline buffer.

#7 lore raw

PATCH v2 3/5 x86/efi: Simplify efi_arch_handle_cmdline()

In reply to Andrew Cooper

-Wwrite-strings is unhappy with assigning "xen" to a mutable pointer, but all this work is useless; it's making a memory allocation just to prepend the image name which cmdline_cook() intentionally strips back out.

Simply forgo the work and identify EFI_LOADER as one of the loaders which doesn't prepend the image name.

No functional change.

---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Wei Liu <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Julien Grall <[email protected]>
CC: Volodymyr Babchuk <[email protected]>
CC: Bertrand Marquis <[email protected]>
CC: Roberto Bagnara <[email protected]>
CC: Nicola Vetrini <[email protected]>

v2:
* Brand new.

I can't find anything which cares about the image name in the slightest. This logic is from bf6501a62e80 ("x86-64: EFI boot code") when EFI was introduced, at whcih point GRUB2 was the only excluded loader in cmdline_cook().

---
 xen/arch/x86/efi/efi-boot.h | 10 +---------
 xen/arch/x86/setup.c        |  7 +++++--
 2 files changed, 6 insertions(+), 11 deletions(-)
xen/arch/x86/efi/efi-boot.h +1 -9
index eebc54180bf7..1a2a2dd83c9b 100644
@@ -309,6 +309,7 @@ static void __init efi_arch_handle_cmdline(CHAR16 *image_name,
 {
     union string name;
 
+    /* NB place_string() prepends, so call in reverse order. */
     if ( cmdline_options )
     {
         name.w = cmdline_options;
@@ -317,15 +318,6 @@ static void __init efi_arch_handle_cmdline(CHAR16 *image_name,
     }
     if ( cfgfile_options )
         place_string(&mbi.cmdline, cfgfile_options);
-    /* Insert image name last, as it gets prefixed to the other options. */
-    if ( image_name )
-    {
-        name.w = image_name;
-        w2s(&name);
-    }
-    else
-        name.s = "xen";
-    place_string(&mbi.cmdline, name.s);
 
     if ( mbi.cmdline )
         mbi.flags |= MBI_CMDLINE;
xen/arch/x86/setup.c +5 -2
index b171a8f4cf84..200520392481 100644
@@ -850,8 +850,11 @@ static const char *__init cmdline_cook(const char *p, const char *loader_name)
     while ( *p == ' ' )
         p++;
 
-    /* GRUB2 and PVH don't not include image name as first item on command line. */
-    if ( xen_guest || loader_is_grub2(loader_name) )
+    /*
+     * PVH, our EFI loader, and GRUB2 don't not include image name as first
+     * item on command line.
+     */
+    if ( xen_guest || efi_enabled(EFI_LOADER) || loader_is_grub2(loader_name) )
         return p;
 
     /* Strip image name plus whitespace. */
Signature · 1 line
2.30.2
Reviewed-by on v2 3/5
#8 lore raw

Re: [PATCH v2 3/5] x86/efi: Simplify efi_arch_handle_cmdline()

Quoted 10 lines · Andrew Cooper

-Wwrite-strings is unhappy with assigning "xen" to a mutable pointer, but all this work is useless; it's making a memory allocation just to prepend the image name which cmdline_cook() intentionally strips back out.

Simply forgo the work and identify EFI_LOADER as one of the loaders which doesn't prepend the image name.

No functional change.

with one nit:

xen/arch/x86/setup.c static const char *__init cmdline_cook(const char *p, const char *loader_name) · line 854

Quoted 10 lines
xen/arch/x86/setup.c +2 -2
@@ -850,8 +850,11 @@ static const char *__init cmdline_cook(const char *p, const char *loader_name)
     while ( *p == ' ' )
         p++;
 
-    /* GRUB2 and PVH don't not include image name as first item on command line. */
-    if ( xen_guest || loader_is_grub2(loader_name) )
+    /*
+     * PVH, our EFI loader, and GRUB2 don't not include image name as first

Just "don't", or "do not"? (I realize it was this way before, but perhaps a good chance to tidy.)

Jan

Quoted 6 lines
xen/arch/x86/setup.c +3 -0
+     * item on command line.
+     */
+    if ( xen_guest || efi_enabled(EFI_LOADER) || loader_is_grub2(loader_name) )
         return p;
 
     /* Strip image name plus whitespace. */
#9 lore raw

Re: [PATCH v2 3/5] x86/efi: Simplify efi_arch_handle_cmdline()

Quoted 5 lines · Jan Beulich
Quoted 4 lines · Andrew Cooper

-Wwrite-strings is unhappy with assigning "xen" to a mutable pointer, but all this work is useless; it's making a memory allocation just to prepend the image name which cmdline_cook() intentionally strips back out.

Quoted 7 lines
Quoted 6 lines

Simply forgo the work and identify EFI_LOADER as one of the loaders which doesn't prepend the image name.

No functional change.

Thanks.

Quoted 8 lines

with one nit:

Quoted 6 lines
xen/arch/x86/setup.c +0 -0
@@ -850,8 +850,11 @@ static const char *__init cmdline_cook(const char *p, const char *loader_name)
     while ( *p == ' ' )
         p++;
 
Quoted 6 lines

xen/arch/x86/setup.c static const char *__init cmdline_cook(const char *p, const char *loader_name) · line 854

Quoted 4 lines
xen/arch/x86/setup.c +2 -2
-    /* GRUB2 and PVH don't not include image name as first item on command line. */
-    if ( xen_guest || loader_is_grub2(loader_name) )
+    /*
+     * PVH, our EFI loader, and GRUB2 don't not include image name as first

Just "don't", or "do not"? (I realize it was this way before, but perhaps a good chance to tidy.)

Will fix.  I completely missed that while rewording it.

~Andrew

#10 lore raw

PATCH v2 4/5 arm/efi: Simplify efi_arch_handle_cmdline()

In reply to Andrew Cooper

-Wwrite-strings is unhappy with assigning "xen" to a mutable pointer, but this logic looks incorrect. It was inherited from the x86 side, where the logic was redundant and has now been removed.

In the ARM case it inserts the image name into "xen,xen-bootargs" and there is no logic at all to strip this before parsing it as the command line.

The absence of any logic to strip an image name suggests that it shouldn't exist there, or having a Xen image named e.g. "hmp-unsafe" in the filesystem is going to lead to some unexpected behaviour on boot.

No functional change.

---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Wei Liu <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Julien Grall <[email protected]>
CC: Volodymyr Babchuk <[email protected]>
CC: Bertrand Marquis <[email protected]>
CC: Roberto Bagnara <[email protected]>
CC: Nicola Vetrini <[email protected]>

v2:
* New.

I'm afraid that all of this reasoning is based on reading the source code. I don't have any way to try this out in a real ARM UEFI environment.

---
 xen/arch/arm/efi/efi-boot.h | 16 +---------------
 1 file changed, 1 insertion(+), 15 deletions(-)
xen/arch/arm/efi/efi-boot.h +1 -15
index 1c3640bb65fd..59d217667ff3 100644
@@ -461,7 +461,7 @@ static void __init efi_arch_handle_cmdline(CHAR16 *image_name,
     union string name;
     char *buf;
     EFI_STATUS status;
-    int prop_len;
+    int prop_len = 0;
     int chosen;
 
     /* locate chosen node, which is where we add Xen module info. */
@@ -473,20 +473,6 @@ static void __init efi_arch_handle_cmdline(CHAR16 *image_name,
     if ( EFI_ERROR(status) )
         PrintErrMesg(L"Unable to allocate string buffer", status);
 
-    if ( image_name )
-    {
-        name.w = image_name;
-        w2s(&name);
-    }
-    else
-        name.s = "xen";
-
-    prop_len = 0;
-    prop_len += snprintf(buf + prop_len,
-                           EFI_PAGE_SIZE - prop_len, "%s", name.s);
-    if ( prop_len >= EFI_PAGE_SIZE )
-        blexit(L"FDT string overflow");
-
     if ( cfgfile_options )
     {
         PrintMessage(L"Using bootargs from Xen configuration file.");
Signature · 1 line
2.30.2
#11 lore raw

Re: [PATCH v2 4/5] arm/efi: Simplify efi_arch_handle_cmdline()

+ CC henry

Quoted 27 lines · Andrew Cooper

-Wwrite-strings is unhappy with assigning "xen" to a mutable pointer, but this logic looks incorrect. It was inherited from the x86 side, where the logic was redundant and has now been removed.

In the ARM case it inserts the image name into "xen,xen-bootargs" and there is no logic at all to strip this before parsing it as the command line.

The absence of any logic to strip an image name suggests that it shouldn't exist there, or having a Xen image named e.g. "hmp-unsafe" in the filesystem is going to lead to some unexpected behaviour on boot.

No functional change.

---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Wei Liu <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Julien Grall <[email protected]>
CC: Volodymyr Babchuk <[email protected]>
CC: Bertrand Marquis <[email protected]>
CC: Roberto Bagnara <[email protected]>
CC: Nicola Vetrini <[email protected]>

Quoted 5 lines

v2:
* New.

I'm afraid that all of this reasoning is based on reading the source code. I don't have any way to try this out in a real ARM UEFI environment.

I will test this one tomorrow on an arm board

#12 lore raw

Re: [PATCH v2 4/5] arm/efi: Simplify efi_arch_handle_cmdline()

Quoted 29 lines · Luca Fancellu

+ CC henry

Quoted 27 lines · Andrew Cooper

-Wwrite-strings is unhappy with assigning "xen" to a mutable pointer, but this logic looks incorrect. It was inherited from the x86 side, where the logic was redundant and has now been removed.

In the ARM case it inserts the image name into "xen,xen-bootargs" and there is no logic at all to strip this before parsing it as the command line.

The absence of any logic to strip an image name suggests that it shouldn't exist there, or having a Xen image named e.g. "hmp-unsafe" in the filesystem is going to lead to some unexpected behaviour on boot.

No functional change.

---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Wei Liu <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Julien Grall <[email protected]>
CC: Volodymyr Babchuk <[email protected]>
CC: Bertrand Marquis <[email protected]>
CC: Roberto Bagnara <[email protected]>
CC: Nicola Vetrini <[email protected]>

Quoted 6 lines
Quoted 5 lines

v2:
* New.

I'm afraid that all of this reasoning is based on reading the source code. I don't have any way to try this out in a real ARM UEFI environment.

I will test this one tomorrow on an arm board

Thanks.  I have a sneaking suspicion that:

xen/arch/arm/setup.c +0 -0
index 9b9018574919..8bca5b9a1523 100644
@@ -46,6 +46,12 @@

 #include <xsm/xsm.h>
 #include <asm/acpi.h>

+static int __init parse_ucode(const char *s)
+{
+    panic("Xen image name interpreted as a cmdline parameter\n"); +}
+custom_param("xen.efi", parse_xen);
+
 struct bootinfo __initdata bootinfo;

 /*

will trigger.

~Andrew

#13 lore raw

Re: [PATCH v2 4/5] arm/efi: Simplify efi_arch_handle_cmdline()

Hi Both,

Quoted 59 lines · Andrew Cooper
Quoted 29 lines · Luca Fancellu

+ CC henry

Quoted 27 lines · Andrew Cooper

-Wwrite-strings is unhappy with assigning "xen" to a mutable pointer, but this logic looks incorrect. It was inherited from the x86 side, where the logic was redundant and has now been removed.

In the ARM case it inserts the image name into "xen,xen-bootargs" and there is no logic at all to strip this before parsing it as the command line.

The absence of any logic to strip an image name suggests that it shouldn't exist there, or having a Xen image named e.g. "hmp-unsafe" in the filesystem is going to lead to some unexpected behaviour on boot.

No functional change.

---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Wei Liu <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Julien Grall <[email protected]>
CC: Volodymyr Babchuk <[email protected]>
CC: Bertrand Marquis <[email protected]>
CC: Roberto Bagnara <[email protected]>
CC: Nicola Vetrini <[email protected]>

Quoted 6 lines
Quoted 5 lines

v2:
* New.

I'm afraid that all of this reasoning is based on reading the source code. I don't have any way to try this out in a real ARM UEFI environment.

I will test this one tomorrow on an arm board

Thanks. I have a sneaking suspicion that:

xen/arch/arm/setup.c +6 -0
index 9b9018574919..8bca5b9a1523 100644
@@ -46,6 +46,12 @@
 #include <xsm/xsm.h>
 #include <asm/acpi.h>
 
+static int __init parse_ucode(const char *s)
+{
+    panic("Xen image name interpreted as a cmdline parameter\n");
+}
+custom_param("xen.efi", parse_xen);
+
 struct bootinfo __initdata bootinfo;
 
 /*
Quoted 1 line

will trigger.

I saw I am CCed for this patch, so I think I am now going to throw this series to our CI and see if it explodes. Do you want me to also include above hunk?

Kind regards,
Henry

Quoted 2 lines

~Andrew

#14 lore raw

Re: [PATCH v2 4/5] arm/efi: Simplify efi_arch_handle_cmdline()

Quoted 58 lines · Henry Wang

Hi Both,

Quoted 56 lines · Andrew Cooper
Quoted 29 lines · Luca Fancellu

+ CC henry

Quoted 27 lines · Andrew Cooper

-Wwrite-strings is unhappy with assigning "xen" to a mutable pointer, but this logic looks incorrect. It was inherited from the x86 side, where the logic was redundant and has now been removed.

In the ARM case it inserts the image name into "xen,xen-bootargs" and there is no logic at all to strip this before parsing it as the command line.

The absence of any logic to strip an image name suggests that it shouldn't exist there, or having a Xen image named e.g. "hmp-unsafe" in the filesystem is going to lead to some unexpected behaviour on boot.

No functional change.

---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Wei Liu <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Julien Grall <[email protected]>
CC: Volodymyr Babchuk <[email protected]>
CC: Bertrand Marquis <[email protected]>
CC: Roberto Bagnara <[email protected]>
CC: Nicola Vetrini <[email protected]>

Quoted 6 lines
Quoted 5 lines

v2:
* New.

I'm afraid that all of this reasoning is based on reading the source code. I don't have any way to try this out in a real ARM UEFI environment.

I will test this one tomorrow on an arm board

Thanks. I have a sneaking suspicion that:

xen/arch/arm/setup.c +6 -0
index 9b9018574919..8bca5b9a1523 100644
@@ -46,6 +46,12 @@
 #include <xsm/xsm.h>
 #include <asm/acpi.h>
 
+static int __init parse_ucode(const char *s)
+{
+    panic("Xen image name interpreted as a cmdline parameter\n");
+}
+custom_param("xen.efi", parse_xen);
+
 struct bootinfo __initdata bootinfo;
 
Quoted 5 lines
Quoted 3 lines
xen/arch/arm/setup.c +0 -0
 /*

will trigger.

I saw I am CCed for this patch, so I think I am now going to throw this series to our CI and see if it explodes. Do you want me to also include above hunk?

Depends - up to you.  It needs tailoring for the name of the Xen binary used, if it doesn't end up as a plain "xen.efi".

And to be more specific, it ought to trigger before this patch but cease triggering after it.

It's probably better suited to a manual dev test in a real ARM UEFI environment.

~Andrew

Reviewed-by Tested-by
#15 lore raw

Re: [PATCH v2 4/5] arm/efi: Simplify efi_arch_handle_cmdline()

In reply to Andrew Cooper
Quoted 34 lines · Andrew Cooper
Quoted 29 lines · Luca Fancellu

+ CC henry

Quoted 27 lines · Andrew Cooper

-Wwrite-strings is unhappy with assigning "xen" to a mutable pointer, but this logic looks incorrect. It was inherited from the x86 side, where the logic was redundant and has now been removed.

In the ARM case it inserts the image name into "xen,xen-bootargs" and there is no logic at all to strip this before parsing it as the command line.

The absence of any logic to strip an image name suggests that it shouldn't exist there, or having a Xen image named e.g. "hmp-unsafe" in the filesystem is going to lead to some unexpected behaviour on boot.

No functional change.

---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Wei Liu <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Julien Grall <[email protected]>
CC: Volodymyr Babchuk <[email protected]>
CC: Bertrand Marquis <[email protected]>
CC: Roberto Bagnara <[email protected]>
CC: Nicola Vetrini <[email protected]>

Quoted 7 lines
Quoted 6 lines
Quoted 5 lines

v2:
* New.

I'm afraid that all of this reasoning is based on reading the source code. I don't have any way to try this out in a real ARM UEFI environment.

I will test this one tomorrow on an arm board

I confirm that booting though UEFI on an arm board works

#16 lore raw

Re: [PATCH v2 4/5] arm/efi: Simplify efi_arch_handle_cmdline()

Quoted 36 lines · Luca Fancellu
Quoted 36 lines · Andrew Cooper
Quoted 32 lines · Luca Fancellu

+ CC henry

Quoted 30 lines · Andrew Cooper

-Wwrite-strings is unhappy with assigning "xen" to a mutable pointer, but this logic looks incorrect. It was inherited from the x86 side, where the logic was redundant and has now been removed.

In the ARM case it inserts the image name into "xen,xen-bootargs" and there is no logic at all to strip this before parsing it as the command line.

The absence of any logic to strip an image name suggests that it shouldn't exist there, or having a Xen image named e.g. "hmp-unsafe" in the filesystem is going to lead to some unexpected behaviour on boot.

No functional change.

---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Wei Liu <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Julien Grall <[email protected]>
CC: Volodymyr Babchuk <[email protected]>
CC: Bertrand Marquis <[email protected]>
CC: Roberto Bagnara <[email protected]>
CC: Nicola Vetrini <[email protected]>

v2:
* New.

Quoted 7 lines
Quoted 3 lines
Quoted 3 lines
Quoted 2 lines

I'm afraid that all of this reasoning is based on reading the source code. I don't have any way to try this out in a real ARM UEFI environment.

I will test this one tomorrow on an arm board

I confirm that booting though UEFI on an arm board works

Thanks, and you confirmed that the first cmdline parameter is still usable?

~Andrew

Reviewed-by
#17 lore raw

Re: [PATCH v2 4/5] arm/efi: Simplify efi_arch_handle_cmdline()

Quoted 39 lines · Andrew Cooper
Quoted 38 lines · Luca Fancellu
Quoted 38 lines · Andrew Cooper
Quoted 34 lines · Luca Fancellu

+ CC henry

Quoted 32 lines · Andrew Cooper

-Wwrite-strings is unhappy with assigning "xen" to a mutable pointer, but this logic looks incorrect. It was inherited from the x86 side, where the logic was redundant and has now been removed.

In the ARM case it inserts the image name into "xen,xen-bootargs" and there is no logic at all to strip this before parsing it as the command line.

The absence of any logic to strip an image name suggests that it shouldn't exist there, or having a Xen image named e.g. "hmp-unsafe" in the filesystem is going to lead to some unexpected behaviour on boot.

No functional change.

---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Wei Liu <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Julien Grall <[email protected]>
CC: Volodymyr Babchuk <[email protected]>
CC: Bertrand Marquis <[email protected]>
CC: Roberto Bagnara <[email protected]>
CC: Nicola Vetrini <[email protected]>

v2:
* New.

I'm afraid that all of this reasoning is based on reading the source code. I don't have any way to try this out in a real ARM UEFI environment.

Quoted 7 lines
Quoted 5 lines
Quoted 1 line
Quoted 1 line

I will test this one tomorrow on an arm board

I confirm that booting though UEFI on an arm board works

Thanks, and you confirmed that the first cmdline parameter is still usable?

Assuming Luca or Henry come back with a confirmation that the first command line parameter is still passed through correctly:

Tested-by
#18 lore raw

Re: [PATCH v2 4/5] arm/efi: Simplify efi_arch_handle_cmdline()

In reply to Andrew Cooper

Hi,

Quoted 31 lines · Andrew Cooper
Quoted 28 lines · Luca Fancellu
Quoted 28 lines · Andrew Cooper
Quoted 24 lines · Luca Fancellu

+ CC henry

Quoted 22 lines · Andrew Cooper

-Wwrite-strings is unhappy with assigning "xen" to a mutable pointer, but this logic looks incorrect. It was inherited from the x86 side, where the logic was redundant and has now been removed.

In the ARM case it inserts the image name into "xen,xen-bootargs" and there is no logic at all to strip this before parsing it as the command line.

The absence of any logic to strip an image name suggests that it shouldn't exist there, or having a Xen image named e.g. "hmp-unsafe" in the filesystem is going to lead to some unexpected behaviour on boot.

No functional change.

---
v2:
* New.

I'm afraid that all of this reasoning is based on reading the source code. I don't have any way to try this out in a real ARM UEFI environment.

Quoted 7 lines
Quoted 5 lines
Quoted 1 line
Quoted 1 line

I will test this one tomorrow on an arm board

I confirm that booting though UEFI on an arm board works

Thanks, and you confirmed that the first cmdline parameter is still usable?

Today I tried this series on an N1SDP board using UEFI boot. I had a device tree with
xen,xen-bootargs = "console=dtuart dtuart=serial0:115200n8 noreboot dom0_mem=1024M bootscrub=0 iommu=no";

Xen can be successfully boot on the board with the series applied, and I got

```
(XEN) Command line: console=dtuart dtuart=serial0:115200n8 noreboot dom0_mem=1024M bootscrub=0 iommu=no
[…]
```

Also I can interact with the board:

```
n1sdp login: root
root@n1sdp:~# ^C
root@n1sdp:~# ^C
root@n1sdp:~# ^C
```

So I think the first cmdline parameter is still usable. I will wait for Luca to confirm on his side as I believe he used a different board in his test.

Kind regards,
Henry

Quoted 2 lines

~Andrew

#19 lore raw

Re: [PATCH v2 4/5] arm/efi: Simplify efi_arch_handle_cmdline()

Hi,

Quoted 60 lines · Henry Wang

Hi,

Quoted 31 lines · Andrew Cooper
Quoted 28 lines · Luca Fancellu
Quoted 28 lines · Andrew Cooper
Quoted 24 lines · Luca Fancellu

+ CC henry

Quoted 22 lines · Andrew Cooper

-Wwrite-strings is unhappy with assigning "xen" to a mutable pointer, but this logic looks incorrect. It was inherited from the x86 side, where the logic was redundant and has now been removed.

In the ARM case it inserts the image name into "xen,xen-bootargs" and there is no logic at all to strip this before parsing it as the command line.

The absence of any logic to strip an image name suggests that it shouldn't exist there, or having a Xen image named e.g. "hmp-unsafe" in the filesystem is going to lead to some unexpected behaviour on boot.

No functional change.

---
v2:
* New.

I'm afraid that all of this reasoning is based on reading the source code. I don't have any way to try this out in a real ARM UEFI environment.

Quoted 7 lines
Quoted 5 lines
Quoted 1 line
Quoted 1 line

I will test this one tomorrow on an arm board

I confirm that booting though UEFI on an arm board works

Thanks, and you confirmed that the first cmdline parameter is still usable?

Today I tried this series on an N1SDP board using UEFI boot. I had a device tree with
xen,xen-bootargs = "console=dtuart dtuart=serial0:115200n8 noreboot dom0_mem=1024M bootscrub=0 iommu=no";

Xen can be successfully boot on the board with the series applied, and I got

```
(XEN) Command line: console=dtuart dtuart=serial0:115200n8 noreboot dom0_mem=1024M bootscrub=0 iommu=no
[…]
```

Also I can interact with the board:

```
n1sdp login: root
root@n1sdp:~# ^C
root@n1sdp:~# ^C
root@n1sdp:~# ^C
```
Quoted 2 lines

So I think the first cmdline parameter is still usable. I will wait for Luca to confirm on his side as I believe he used a different board in his test.

Also I tried to switch the order of the cmdline parameter in the device tree, for example use:
xen,xen-bootargs = “dom0_mem=512M console=dtuart dtuart=serial0:115200n8 noreboot bootscrub=0 iommu=no”;

This time I had:

```
[...]
(XEN) Command line: dom0_mem=512M console=dtuart dtuart=serial0:115200n8 noreboot  bootscrub=0 iommu=no
[…]
(XEN) Allocating 1:1 mappings totalling 512MB for dom0:
[…]
```

So I think we are fine.

Kind regards,
Henry

Quoted 9 lines

Kind regards,
Henry

Quoted 2 lines

~Andrew

#20 lore raw

Re: [PATCH v2 4/5] arm/efi: Simplify efi_arch_handle_cmdline()

In reply to Andrew Cooper
Quoted 43 lines · Andrew Cooper
Quoted 38 lines · Luca Fancellu
Quoted 38 lines · Andrew Cooper
Quoted 34 lines · Luca Fancellu

+ CC henry

Quoted 32 lines · Andrew Cooper

-Wwrite-strings is unhappy with assigning "xen" to a mutable pointer, but this logic looks incorrect. It was inherited from the x86 side, where the logic was redundant and has now been removed.

In the ARM case it inserts the image name into "xen,xen-bootargs" and there is no logic at all to strip this before parsing it as the command line.

The absence of any logic to strip an image name suggests that it shouldn't exist there, or having a Xen image named e.g. "hmp-unsafe" in the filesystem is going to lead to some unexpected behaviour on boot.

No functional change.

---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Wei Liu <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Julien Grall <[email protected]>
CC: Volodymyr Babchuk <[email protected]>
CC: Bertrand Marquis <[email protected]>
CC: Roberto Bagnara <[email protected]>
CC: Nicola Vetrini <[email protected]>

v2:
* New.

I'm afraid that all of this reasoning is based on reading the source code. I don't have any way to try this out in a real ARM UEFI environment.

Quoted 7 lines
Quoted 5 lines
Quoted 1 line
Quoted 1 line

I will test this one tomorrow on an arm board

I confirm that booting though UEFI on an arm board works

Thanks, and you confirmed that the first cmdline parameter is still usable?

Yes, I’m using a xen.cfg like this:

[global]
default=xen

[xen]
options=noreboot dom0_mem=4096M bootscrub=0 iommu=on loglvl=error guest_loglvl=error kernel=Image console=hvc0 earlycon=xenboot rootwait root=PARTUUID=6a60524d-061d-454a-bfd1-38989910eccd

And in Xen boot I can see this:

[...]
(XEN) Command line: noreboot dom0_mem=4096M bootscrub=0 iommu=on loglvl=error guest_loglvl=error [...]

So I think it’s passing every parameter

Quoted 2 lines

~Andrew

#21 lore raw

Re: [PATCH v2 4/5] arm/efi: Simplify efi_arch_handle_cmdline()

Quoted 56 lines · Luca Fancellu
Quoted 39 lines · Andrew Cooper
Quoted 35 lines · Luca Fancellu
Quoted 35 lines · Andrew Cooper
Quoted 32 lines · Luca Fancellu

+ CC henry

Quoted 30 lines · Andrew Cooper

-Wwrite-strings is unhappy with assigning "xen" to a mutable pointer, but this logic looks incorrect. It was inherited from the x86 side, where the logic was redundant and has now been removed.

In the ARM case it inserts the image name into "xen,xen-bootargs" and there is no logic at all to strip this before parsing it as the command line.

The absence of any logic to strip an image name suggests that it shouldn't exist there, or having a Xen image named e.g. "hmp-unsafe" in the filesystem is going to lead to some unexpected behaviour on boot.

No functional change.

---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Wei Liu <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Julien Grall <[email protected]>
CC: Volodymyr Babchuk <[email protected]>
CC: Bertrand Marquis <[email protected]>
CC: Roberto Bagnara <[email protected]>
CC: Nicola Vetrini <[email protected]>

v2:
* New.

Quoted 8 lines
Quoted 7 lines
Quoted 3 lines
Quoted 3 lines
Quoted 2 lines

I'm afraid that all of this reasoning is based on reading the source code. I don't have any way to try this out in a real ARM UEFI environment.

I will test this one tomorrow on an arm board

I confirm that booting though UEFI on an arm board works

Thanks, and you confirmed that the first cmdline parameter is still usable?

Yes, I’m using a xen.cfg like this:

[global]
default=xen

[xen]
options=noreboot dom0_mem=4096M bootscrub=0 iommu=on loglvl=error guest_loglvl=error kernel=Image console=hvc0 earlycon=xenboot rootwait root=PARTUUID=6a60524d-061d-454a-bfd1-38989910eccd

Quoted 7 lines

And in Xen boot I can see this:

[...]
(XEN) Command line: noreboot dom0_mem=4096M bootscrub=0 iommu=on loglvl=error guest_loglvl=error [...]

So I think it’s passing every parameter

Thankyou all for the testing.

~Andrew

Reviewed-by on v2 4/5
#22 lore raw

Re: [PATCH v2 4/5] arm/efi: Simplify efi_arch_handle_cmdline()

In reply to Andrew Cooper

Hi Andrew,

Quoted 10 lines · Andrew Cooper

-Wwrite-strings is unhappy with assigning "xen" to a mutable pointer, but this logic looks incorrect. It was inherited from the x86 side, where the logic was redundant and has now been removed.

In the ARM case it inserts the image name into "xen,xen-bootargs" and there is no logic at all to strip this before parsing it as the command line.

The absence of any logic to strip an image name suggests that it shouldn't exist there, or having a Xen image named e.g. "hmp-unsafe" in the filesystem is going to lead to some unexpected behaviour on boot.

I have noticed this behavior a few years ago but never really looked why
we added the name. So thanks for looking at it.

Quoted 4 lines

No functional change.

Cheers,

Signature · 1 line
Julien Grall
#23 lore raw

PATCH v2 5/5 xen: Enable -Wwrite-strings

In reply to Andrew Cooper

The codebase is now -Wwrite-strings clean. Activate the option to cause string literals to have a const type, and prevent any violations of MISRA Rule 7.4 being reintroduced.

---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Wei Liu <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Julien Grall <[email protected]>
CC: Volodymyr Babchuk <[email protected]>
CC: Bertrand Marquis <[email protected]>
CC: Michal Orzel <[email protected]>
CC: Roberto Bagnara <[email protected]>
CC: Nicola Vetrini <[email protected]>

---
 xen/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
xen/Makefile +1 -1
index 7b869f4b3037..ca571103c868 100644
@@ -392,7 +392,7 @@ endif
 CFLAGS-$(CONFIG_CC_SPLIT_SECTIONS) += -ffunction-sections -fdata-sections
 
 CFLAGS += -nostdinc -fno-builtin -fno-common
-CFLAGS += -Werror -Wredundant-decls -Wno-pointer-arith
+CFLAGS += -Werror -Wredundant-decls -Wwrite-strings -Wno-pointer-arith
 $(call cc-option-add,CFLAGS,CC,-Wvla)
 CFLAGS += -pipe -D__XEN__ -include $(srctree)/include/xen/config.h
 CFLAGS-$(CONFIG_DEBUG_INFO) += -g
Signature · 1 line
2.30.2