Skip to contentSkip to conversation

address some violations of MISRA C Rule 8.4

PATCH Superseded Nicola Vetrini 2 participants 6 messages Dec 7, 2023

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#3 lore raw

PATCH v2 3/3 xen/mm: add declaration for first_valid_mfn

In reply to Nicola Vetrini

Such declaration is needed to comply with MISRA C Rule 8.4, because a compatible declaration is not visible in xen/common/page_alloc.c, where the variable is defined. That variable can't yet be static because of the lack of support from ARM and PPC for NUMA.

No functional change.

---
Having this declaration essentially sidesteps the current impossibility of having a static variable, as described in the comments in ARM and PCC's asm/numa.h.

---
 xen/include/xen/mm.h | 2 ++
 1 file changed, 2 insertions(+)
xen/include/xen/mm.h +2 -0
index 3d9b2d05a5c8..a13a9a46ced7 100644
@@ -118,6 +118,8 @@ int destroy_xen_mappings(unsigned long s, unsigned long e);
 /* Retrieve the MFN mapped by VA in Xen virtual address space. */
 mfn_t xen_map_to_mfn(unsigned long va);
 
+extern mfn_t first_valid_mfn;
+
 /*
  * Create only non-leaf page table entries for the
  * page range in Xen virtual address space.
Signature · 1 line
2.34.1
#2 lore raw

PATCH v2 2/3 x86/viridian: make build_assertions static

In reply to Nicola Vetrini

This is consistent with other instances of the same function and also resolves a violation of MISRA C:2012 Rule 8.4.

No functional change.

---
 xen/arch/x86/hvm/viridian/synic.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
xen/arch/x86/hvm/viridian/synic.c +1 -1
index 8cf600cec68f..3375e55e95ca 100644
@@ -18,7 +18,7 @@
 #include "private.h"
 
 
-void __init __maybe_unused build_assertions(void)
+static void __init __maybe_unused build_assertions(void)
 {
     BUILD_BUG_ON(sizeof(struct hv_message) != HV_MESSAGE_SIZE);
 }
Signature · 1 line
2.34.1
#0 lore raw

v2 cover address some violations of MISRA C Rule 8.4

MISRA C:2012 Rule 8.4 states:
"A compatible declaration shall be visible when an object or function with external linkage is defined".

Changes from v1:
- Patch 1/7 has been committed;
- Patch 2/7 has been dropped, as the fix is already part of [1];
- Patch 3/7 drops the addition of asmlinkage on variables. Discussion on how to handle the existing uses can be part of a separate patch;
- Patch 4/7 is unchanged;
- Patch 5/7 has been committed;
- Patch 6/7 has been dropped
- Patch 7/7 has been revised to have a declaration for first_valid_mfn, rather than a deviation for the absence of a declaration

[1] https://lore.kernel.org/xen-devel/[email protected]/

Nicola Vetrini (3):
xen/x86: add missing instances of asmlinkage attributes x86/viridian: make build_assertions static xen/mm: add declaration for first_valid_mfn

 xen/arch/x86/efi/efi-boot.h       | 5 +++--
 xen/arch/x86/hvm/viridian/synic.c | 2 +-
 xen/arch/x86/smpboot.c            | 2 +-
 xen/include/xen/mm.h              | 2 ++
 4 files changed, 7 insertions(+), 4 deletions(-)
Signature · 1 line
2.34.1
#1 lore raw

PATCH v2 1/3 xen/x86: add missing instances of asmlinkage attributes

No functional change.

---
Changes in v2:
- The attribute on boot_gdtr and l1_fixmap_x has been dropped, as detailed in the cover letter.

---
 xen/arch/x86/efi/efi-boot.h | 5 +++--
 xen/arch/x86/smpboot.c      | 2 +-
 2 files changed, 4 insertions(+), 3 deletions(-)
xen/arch/x86/efi/efi-boot.h +3 -2
index 86467da301e5..8ea64e31cdc2 100644
@@ -808,8 +808,9 @@ static const char *__init get_option(const char *cmd, const char *opt)
     return o;
 }
 
-void __init efi_multiboot2(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable,
-                           const char *cmdline)
+void asmlinkage __init efi_multiboot2(EFI_HANDLE ImageHandle,
+                                      EFI_SYSTEM_TABLE *SystemTable,
+                                      const char *cmdline)
 {
     EFI_GRAPHICS_OUTPUT_PROTOCOL *gop;
     EFI_HANDLE gop_handle;
xen/arch/x86/smpboot.c +1 -1
index 4c54ecbc91d7..8aa621533f3d 100644
@@ -310,7 +310,7 @@ static void set_cpu_sibling_map(unsigned int cpu)
     }
 }
 
-void start_secondary(void *unused)
+void asmlinkage start_secondary(void *unused)
 {
     struct cpu_info *info = get_cpu_info();
 
Signature · 1 line
2.34.1
#4 lore raw

Re: [XEN PATCH v2 3/3] xen/mm: add declaration for first_valid_mfn

In reply to Nicola Vetrini

Hi,

Quoted 5 lines · Nicola Vetrini

Such declaration is needed to comply with MISRA C Rule 8.4, because a compatible declaration is not visible in xen/common/page_alloc.c, where the variable is defined. That variable can't yet be static because of the lack of support from ARM and PPC for NUMA.

Quoted 7 lines

No functional change.

---
Having this declaration essentially sidesteps the current impossibility of having a static variable, as described in the comments in ARM and PCC's asm/numa.h.

With this change, is there any reason to keep the various declaration of first_valid_mfn in numa.h?

Cheers,

Signature · 1 line
Julien Grall
#5 lore raw

Re: [XEN PATCH v2 3/3] xen/mm: add declaration for first_valid_mfn

Quoted 10 lines · Julien Grall

Hi,

Quoted 7 lines · Nicola Vetrini

Such declaration is needed to comply with MISRA C Rule 8.4, because a compatible declaration is not visible in xen/common/page_alloc.c, where the variable is defined. That variable can't yet be static because of the lack of support from ARM and PPC for NUMA.

No functional change.

Quoted 8 lines
Quoted 5 lines

---
Having this declaration essentially sidesteps the current impossibility of having a static variable, as described in the comments in ARM and PCC's asm/numa.h.

With this change, is there any reason to keep the various declaration of first_valid_mfn in numa.h?

Cheers,

Good point: no reason comes to mind. I didn't think of it while revising the patch.

Signature · 2 lines
Nicola Vetrini, BSc
Software Engineer, BUGSENG srl (https://bugseng.com)