Skip to contentSkip to conversation

xen: address MISRA C:2012 Rule 8.4

PATCH In review Nicola Vetrini 4 participants 33 messages Aug 9, 2023 – Aug 10, 2023

lore
Share & tools
lore
#0 lore raw

cover xen: address MISRA C:2012 Rule 8.4

Rule states the following:
"A compatible declaration shall be visible when an object or function with external linkage is defined".

This series deals with violations concerning functions and variables used by C code (thus not used only within asm). The resolution strategies are as follows:

1. make the functions/variables static
2. include the header that contains the compatible declaration, or add one in the header if that's not the case.

No functional change.

Additional notes:
- other cases, such as functions/variables used only in asm code will be possibly dealt with in future patches.
- functions in 'gcov_base.c' are deviated, since they are called only from code generated by gcc in a particular non-release build configuration;
- variables in 'xen/include/acpi/acglobal.h' are deviated temporarily, since it's uncertain whether modifying the include pattern to be compliant with the rule would introduce subtle bugs.

Nicola Vetrini (8):
arm/efi: address MISRA C:2012 Rule 8.4
xen/memory: address MISRA C:2012 Rule 8.4
xen: address MISRA C:2012 Rule 8.4
xen/arm: address MISRA C:2012 Rule 8.4
x86: address MISRA C:2012 Rule 8.4
xen/arm: mm: address MISRA C:2012 Rule 8.4
x86/i8259: address MISRA C:2012 Rule 8.4
x86/nmi: address MISRA C:2012 Rule 8.4

 xen/arch/arm/efi/efi-boot.h       | 2 +-
 xen/arch/arm/include/asm/mm.h     | 3 +++
 xen/arch/arm/setup.c              | 1 +
 xen/arch/arm/time.c               | 1 +
 xen/arch/x86/cpu/mcheck/mce.c     | 2 +-
 xen/arch/x86/cpu/mcheck/mce_amd.c | 2 +-
 xen/arch/x86/cpu/microcode/core.c | 2 +-
 xen/arch/x86/i8259.c              | 1 +
 xen/arch/x86/nmi.c                | 3 ++-
 xen/arch/x86/spec_ctrl.c          | 4 ++--
 xen/common/kernel.c               | 2 +-
 xen/common/memory.c               | 2 +-
 xen/include/xen/cper.h            | 3 +--
 xen/include/xen/time.h            | 1 +
 14 files changed, 18 insertions(+), 11 deletions(-)

--
2.34.1

#1 lore raw

PATCH 1/8 arm/efi: address MISRA C:2012 Rule 8.4

the function 'fdt_add_uefi_nodes' can be defined static, as its only callers are within the same file. This in turn avoids violating Rule 8.4 because no declaration is present.

No functional change.

---
 xen/arch/arm/efi/efi-boot.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
xen/arch/arm/efi/efi-boot.h +1 -1
index f24df2abb9..1c3640bb65 100644
@@ -227,7 +227,7 @@ static EFI_STATUS __init efi_process_memory_map_bootinfo(EFI_MEMORY_DESCRIPTOR *
  * of the System table address, the address of the final EFI memory map,
  * and memory map information.
  */
-EFI_STATUS __init fdt_add_uefi_nodes(EFI_SYSTEM_TABLE *sys_table,
+static EFI_STATUS __init fdt_add_uefi_nodes(EFI_SYSTEM_TABLE *sys_table,
                                             void *fdt,
                                             EFI_MEMORY_DESCRIPTOR *memory_map,
                                             UINTN map_size,
Signature · 1 line
2.34.1
Reviewed-by on v1 1/8
#2 lore raw

Re: [XEN PATCH 1/8] arm/efi: address MISRA C:2012 Rule 8.4

Quoted 11 lines · Nicola Vetrini

the function 'fdt_add_uefi_nodes' can be defined static, as its only callers are within the same file. This in turn avoids violating Rule 8.4 because no declaration is present.

No functional change.

With

Fixes 6d70ea10d49f ("Add ARM EFI boot support”)
#3 lore raw

Re: [XEN PATCH 1/8] arm/efi: address MISRA C:2012 Rule 8.4

Quoted 8 lines · Luca Fancellu
Quoted 8 lines · Nicola Vetrini

the function 'fdt_add_uefi_nodes' can be defined static, as its only callers are within the same file. This in turn avoids violating Rule 8.4 because no declaration is present.

No functional change.

Quoted 7 lines
Quoted 1 line

With

Fixes 6d70ea10d49f ("Add ARM EFI boot support”)
#4 lore raw

PATCH 2/8 xen/memory: address MISRA C:2012 Rule 8.4

In reply to Nicola Vetrini

The function 'ioreq_server_max_frames' can be defined static, as its only uses are within the same file. This in turn avoids violating Rule 8.4 because no declaration is present.

No functional change.

---
 xen/common/memory.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
xen/common/memory.c +1 -1
index c206fa4808..b1dcbaf551 100644
@@ -1120,7 +1120,7 @@ static long xatp_permission_check(struct domain *d, unsigned int space)
     return xsm_add_to_physmap(XSM_TARGET, current->domain, d);
 }
 
-unsigned int ioreq_server_max_frames(const struct domain *d)
+static unsigned int ioreq_server_max_frames(const struct domain *d)
 {
     unsigned int nr = 0;
 
Signature · 1 line
2.34.1
Reviewed-by on v1 2/8
#5 lore raw

Re: [XEN PATCH 2/8] xen/memory: address MISRA C:2012 Rule 8.4

Quoted 11 lines · Nicola Vetrini

The function 'ioreq_server_max_frames' can be defined static, as its only uses are within the same file. This in turn avoids violating Rule 8.4 because no declaration is present.

No functional change.

Makes sense,

Maybe it’s also better adding this:

Fixes 9244528955de ("xen/memory: Fix acquire_resource size semantics”)

If the maintainers agree

#6 lore raw

Re: [XEN PATCH 2/8] xen/memory: address MISRA C:2012 Rule 8.4

Quoted 10 lines · Luca Fancellu
Quoted 9 lines · Nicola Vetrini

The function 'ioreq_server_max_frames' can be defined static, as its only uses are within the same file. This in turn avoids violating Rule 8.4 because no declaration is present.

No functional change.

Quoted 8 lines

Makes sense,

Maybe it’s also better adding this:

Fixes 9244528955de ("xen/memory: Fix acquire_resource size semantics”)

If the maintainers agree

I for one agree; in fact I did ask for Fixes: tags throughout this series, but in the context of another patch. As said there I also think titles and descriptions want writing differently here.

Jan

#7 lore raw

Re: [XEN PATCH 2/8] xen/memory: address MISRA C:2012 Rule 8.4

In reply to Luca Fancellu
Quoted 6 lines · Luca Fancellu
Quoted 6 lines · Nicola Vetrini

The function 'ioreq_server_max_frames' can be defined static, as its only uses are within the same file. This in turn avoids violating Rule 8.4 because no declaration is present.

Quoted 7 lines
Quoted 3 lines

No functional change.

Makes sense,

Quoted 4 lines

Maybe it’s also better adding this:

Fixes 9244528955de ("xen/memory: Fix acquire_resource size semantics”)

If the maintainers agree

Yes

#8 lore raw

PATCH 3/8 xen: address MISRA C:2012 Rule 8.4

In reply to Nicola Vetrini

The variable 'saved_cmdline' can be defined static, as its only uses are within the same file. This in turn avoids violating Rule 8.4 because no declaration is present.

---
 xen/common/kernel.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
xen/common/kernel.c +1 -1
index fb919f3d9c..52aa287627 100644
@@ -28,7 +28,7 @@ CHECK_feature_info;
 
 enum system_state system_state = SYS_STATE_early_boot;
 
-xen_commandline_t saved_cmdline;
+static xen_commandline_t saved_cmdline;
 static const char __initconst opt_builtin_cmdline[] = CONFIG_CMDLINE;
 
 static int assign_integer_param(const struct kernel_param *param, uint64_t val)
Signature · 1 line
2.34.1
#9 lore raw
Quoted 18 lines · Nicola Vetrini

The variable 'saved_cmdline' can be defined static, as its only uses are within the same file. This in turn avoids violating Rule 8.4 because no declaration is present.

---
xen/common/kernel.c | 2 +-

1 file changed, 1 insertion(+), 1 deletion(-)
xen/common/kernel.c +0 -0
index fb919f3d9c..52aa287627 100644

xen/common/kernel.c CHECK_feature_info; · line 31

Quoted 5 lines
xen/common/kernel.c +1 -1
@@ -28,7 +28,7 @@ CHECK_feature_info;
 
 enum system_state system_state = SYS_STATE_early_boot;
 
-xen_commandline_t saved_cmdline;
+static xen_commandline_t saved_cmdline;

I see this line was touched by fa97833ae18e4a42c0e5ba4e781173457b5d3397, have you checked that making it static was not affecting anything else?

Quoted 7 lines
xen/common/kernel.c +0 -0
 static const char __initconst opt_builtin_cmdline[] = CONFIG_CMDLINE;
 
 static int assign_integer_param(const struct kernel_param *param, uint64_t val)
Signature · 1 line
2.34.1
#10 lore raw
Quoted 17 lines · Luca Fancellu
Quoted 17 lines · Nicola Vetrini

The variable 'saved_cmdline' can be defined static, as its only uses are within the same file. This in turn avoids violating Rule 8.4 because no declaration is present.

---
xen/common/kernel.c | 2 +-

1 file changed, 1 insertion(+), 1 deletion(-)
xen/common/kernel.c +0 -0
index fb919f3d9c..52aa287627 100644
@@ -28,7 +28,7 @@ CHECK_feature_info;
 
Quoted 7 lines

xen/common/kernel.c CHECK_feature_info; · line 31

Quoted 4 lines
xen/common/kernel.c +1 -1
 enum system_state system_state = SYS_STATE_early_boot;
 
-xen_commandline_t saved_cmdline;
+static xen_commandline_t saved_cmdline;

I see this line was touched by fa97833ae18e4a42c0e5ba4e781173457b5d3397, have you checked that making it static was not affecting anything else?

The code requiring the symbol to be non-static went away in e6ee01ad24b6 ("xen/version: Drop compat/kernel.c"). That's where the symbol would have wanted to become static. But that was very easy to overlook.

Jan

Reviewed-by
#11 lore raw
Quoted 30 lines · Jan Beulich
Quoted 17 lines · Luca Fancellu
Quoted 17 lines · Nicola Vetrini

The variable 'saved_cmdline' can be defined static, as its only uses are within the same file. This in turn avoids violating Rule 8.4 because no declaration is present.

---
xen/common/kernel.c | 2 +-

1 file changed, 1 insertion(+), 1 deletion(-)
xen/common/kernel.c +0 -0
index fb919f3d9c..52aa287627 100644
@@ -28,7 +28,7 @@ CHECK_feature_info;
 
Quoted 7 lines

xen/common/kernel.c CHECK_feature_info; · line 31

Quoted 4 lines
xen/common/kernel.c +1 -1
 enum system_state system_state = SYS_STATE_early_boot;
 
-xen_commandline_t saved_cmdline;
+static xen_commandline_t saved_cmdline;

I see this line was touched by fa97833ae18e4a42c0e5ba4e781173457b5d3397, have you checked that making it static was not affecting anything else?

Quoted 3 lines

The code requiring the symbol to be non-static went away in e6ee01ad24b6 ("xen/version: Drop compat/kernel.c"). That's where the symbol would have wanted to become static. But that was very easy to overlook.

Yes you are right Jan,

Possibly with the Fixes tag

Cheers,
Luca

Reviewed-by
#12 lore raw
Quoted 32 lines · Luca Fancellu
Quoted 28 lines · Jan Beulich
Quoted 17 lines · Luca Fancellu
Quoted 17 lines · Nicola Vetrini

The variable 'saved_cmdline' can be defined static, as its only uses are within the same file. This in turn avoids violating Rule 8.4 because no declaration is present.

---
xen/common/kernel.c | 2 +-

1 file changed, 1 insertion(+), 1 deletion(-)
xen/common/kernel.c +0 -0
index fb919f3d9c..52aa287627 100644
@@ -28,7 +28,7 @@ CHECK_feature_info;
 
Quoted 7 lines

xen/common/kernel.c CHECK_feature_info; · line 31

Quoted 4 lines
xen/common/kernel.c +1 -1
 enum system_state system_state = SYS_STATE_early_boot;
 
-xen_commandline_t saved_cmdline;
+static xen_commandline_t saved_cmdline;

I see this line was touched by fa97833ae18e4a42c0e5ba4e781173457b5d3397, have you checked that making it static was not affecting anything else?

Quoted 3 lines

The code requiring the symbol to be non-static went away in e6ee01ad24b6 ("xen/version: Drop compat/kernel.c"). That's where the symbol would have wanted to become static. But that was very easy to overlook.

Quoted 5 lines

Yes you are right Jan,

Possibly with the Fixes tag

#13 lore raw
In reply to Luca Fancellu
Quoted 17 lines · Luca Fancellu
Quoted 17 lines · Nicola Vetrini

The variable 'saved_cmdline' can be defined static, as its only uses are within the same file. This in turn avoids violating Rule 8.4 because no declaration is present.

---
xen/common/kernel.c | 2 +-

1 file changed, 1 insertion(+), 1 deletion(-)
xen/common/kernel.c +0 -0
index fb919f3d9c..52aa287627 100644
@@ -28,7 +28,7 @@ CHECK_feature_info;
 
Quoted 9 lines

xen/common/kernel.c CHECK_feature_info; · line 31

Quoted 4 lines
xen/common/kernel.c +1 -1
 enum system_state system_state = SYS_STATE_early_boot;
 
-xen_commandline_t saved_cmdline;
+static xen_commandline_t saved_cmdline;

I see this line was touched by fa97833ae18e4a42c0e5ba4e781173457b5d3397, have you checked that making it static was not affecting anything else?

Though Jan already replied on this, the commit(s) were tested by patchew and our pipeline. This is normally our process, apart from MISRA checks.

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

PATCH 4/8 xen/arm: address MISRA C:2012 Rule 8.4

In reply to Nicola Vetrini

'xen/hypercall.h' is included in 'xen/arch/arm/setup.c' to allow the declaration of 'arch_get_xen_caps' to be visible when defining the function.

The header 'xen/delay.h' is included in 'xen/arch/arm/time.c' to allow the declaration of 'udelay' to be visible.

At the same time, a declaration for 'get_sec' is added in 'xen/include/xen/time.h' to be available for every call site (in particular cper.h).

---
 xen/arch/arm/setup.c   | 1 +
 xen/arch/arm/time.c    | 1 +
 xen/include/xen/cper.h | 3 +--
 xen/include/xen/time.h | 1 +
 4 files changed, 4 insertions(+), 2 deletions(-)
xen/arch/arm/setup.c +1 -0
index bbf72b69aa..44ccea03ca 100644
@@ -32,6 +32,7 @@
 #include <xen/libfdt/libfdt-xen.h>
 #include <xen/acpi.h>
 #include <xen/warning.h>
+#include <xen/hypercall.h>
 #include <asm/alternative.h>
 #include <asm/page.h>
 #include <asm/current.h>
xen/arch/arm/time.c +1 -0
index 0b482d7db3..3535bd8ac7 100644
@@ -17,6 +17,7 @@
 #include <xen/softirq.h>
 #include <xen/sched.h>
 #include <xen/time.h>
+#include <xen/delay.h>
 #include <xen/sched.h>
 #include <xen/event.h>
 #include <xen/acpi.h>
xen/include/xen/cper.h +1 -2
index 7c6a4c45ce..de8f385bdd 100644
@@ -23,8 +23,7 @@
 
 #include <xen/types.h>
 #include <xen/string.h>
-
-extern unsigned long get_sec(void);
+#include <xen/time.h>
 
 typedef struct {
 	uint8_t b[16];
xen/include/xen/time.h +1 -0
index 5aafdda4f3..67c586b736 100644
@@ -36,6 +36,7 @@ s_time_t get_s_time_fixed(u64 at_tick);
 s_time_t get_s_time(void);
 unsigned long get_localtime(struct domain *d);
 uint64_t get_localtime_us(struct domain *d);
+unsigned long get_sec(void);
 
 struct tm {
     int     tm_sec;         /* seconds */
Signature · 1 line
2.34.1
#15 lore raw

Re: [XEN PATCH 4/8] xen/arm: address MISRA C:2012 Rule 8.4

Quoted 11 lines · Nicola Vetrini

'xen/hypercall.h' is included in 'xen/arch/arm/setup.c' to allow the declaration of 'arch_get_xen_caps' to be visible when defining the function.

The header 'xen/delay.h' is included in 'xen/arch/arm/time.c' to allow the declaration of 'udelay' to be visible.

At the same time, a declaration for 'get_sec' is added in 'xen/include/xen/time.h' to be available for every call site (in particular cper.h).

Quoted 7 lines
---
 xen/arch/arm/setup.c   | 1 +
 xen/arch/arm/time.c    | 1 +
 xen/include/xen/cper.h | 3 +--
 xen/include/xen/time.h | 1 +
 4 files changed, 4 insertions(+), 2 deletions(-)

I would have almost put this off as Arm-only, but then saw this diffstat. How come you consider cper.h Arm-related? This is used only by APEI source files, which in turn are used only by x86 afaics. So I think you want to split off the movement of the get_sec() declaration.

As to title and description (perhaps affecting more than just this patch):
Failing to have declarations in scope where definitions appear is an at least latent bug. We fix these as we find them anyway, so Misra is secondary here. Hence I'd like to suggest that you declare any such change as an actual bugfix, ideally including a Fixes: tag. It is of course fine to mention that this then also addresses Misra rule 8.4.

Jan

#16 lore raw

Re: [XEN PATCH 4/8] xen/arm: address MISRA C:2012 Rule 8.4

Quoted 29 lines · Jan Beulich
Quoted 11 lines · Nicola Vetrini

'xen/hypercall.h' is included in 'xen/arch/arm/setup.c' to allow the declaration of 'arch_get_xen_caps' to be visible when defining the function.

The header 'xen/delay.h' is included in 'xen/arch/arm/time.c' to allow the declaration of 'udelay' to be visible.

At the same time, a declaration for 'get_sec' is added in 'xen/include/xen/time.h' to be available for every call site (in particular cper.h).

Quoted 7 lines

---

xen/arch/arm/setup.c   | 1 +
xen/arch/arm/time.c    | 1 +
xen/include/xen/cper.h | 3 +--
xen/include/xen/time.h | 1 +
4 files changed, 4 insertions(+), 2 deletions(-)

I would have almost put this off as Arm-only, but then saw this diffstat. How come you consider cper.h Arm-related? This is used only by APEI source files, which in turn are used only by x86 afaics. So I think you want to split off the movement of the get_sec() declaration.

Quoted 5 lines

As to title and description (perhaps affecting more than just this patch):
Failing to have declarations in scope where definitions appear is an at least latent bug. We fix these as we find them anyway, so Misra is secondary here. Hence I'd like to suggest that you declare any such change as an actual bugfix, ideally including a Fixes: tag.

To prevent back and forth I would suggest also to have a look in sending-patches.pandoc, ### Fixes section, on the expected syntax for the tag

Quoted 5 lines

It is of
course fine to mention that this then also addresses Misra rule 8.4.

Jan

#17 lore raw

Re: [XEN PATCH 4/8] xen/arm: address MISRA C:2012 Rule 8.4

Quoted 4 lines

To prevent back and forth I would suggest also to have a look in sending-patches.pandoc,
### Fixes section, on the expected syntax for the tag

Thanks

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

Re: [XEN PATCH 4/8] xen/arm: address MISRA C:2012 Rule 8.4

In reply to Jan Beulich
Quoted 20 lines · Jan Beulich
Quoted 11 lines · Nicola Vetrini

'xen/hypercall.h' is included in 'xen/arch/arm/setup.c' to allow the declaration of 'arch_get_xen_caps' to be visible when defining the function.

The header 'xen/delay.h' is included in 'xen/arch/arm/time.c' to allow the declaration of 'udelay' to be visible.

At the same time, a declaration for 'get_sec' is added in 'xen/include/xen/time.h' to be available for every call site (in particular cper.h).

Quoted 7 lines
---
 xen/arch/arm/setup.c   | 1 +
 xen/arch/arm/time.c    | 1 +
 xen/include/xen/cper.h | 3 +--
 xen/include/xen/time.h | 1 +
 4 files changed, 4 insertions(+), 2 deletions(-)
Quoted 5 lines

I would have almost put this off as Arm-only, but then saw this diffstat. How come you consider cper.h Arm-related? This is used only by APEI source files, which in turn are used only by x86 afaics. So I think you want to split off the movement of the get_sec() declaration.

My mistake, I squashed the arm and the cper part together to avoid touching the time headers twice, but the old tag remained.

Quoted 8 lines

As to title and description (perhaps affecting more than just this patch):
Failing to have declarations in scope where definitions appear is an at least latent bug. We fix these as we find them anyway, so Misra is secondary here. Hence I'd like to suggest that you declare any such change as an actual bugfix, ideally including a Fixes: tag. It is of course fine to mention that this then also addresses Misra rule 8.4.

Jan

Ok

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

Re: [XEN PATCH 4/8] xen/arm: address MISRA C:2012 Rule 8.4

In reply to Jan Beulich
Quoted 25 lines · Jan Beulich
Quoted 11 lines · Nicola Vetrini

'xen/hypercall.h' is included in 'xen/arch/arm/setup.c' to allow the declaration of 'arch_get_xen_caps' to be visible when defining the function.

The header 'xen/delay.h' is included in 'xen/arch/arm/time.c' to allow the declaration of 'udelay' to be visible.

At the same time, a declaration for 'get_sec' is added in 'xen/include/xen/time.h' to be available for every call site (in particular cper.h).

Quoted 7 lines
---
 xen/arch/arm/setup.c   | 1 +
 xen/arch/arm/time.c    | 1 +
 xen/include/xen/cper.h | 3 +--
 xen/include/xen/time.h | 1 +
 4 files changed, 4 insertions(+), 2 deletions(-)

I would have almost put this off as Arm-only, but then saw this diffstat. How come you consider cper.h Arm-related? This is used only by APEI source files, which in turn are used only by x86 afaics. So I think you want to split off the movement of the get_sec() declaration.

Quoted 6 lines

As to title and description (perhaps affecting more than just this patch):
Failing to have declarations in scope where definitions appear is an at least latent bug. We fix these as we find them anyway, so Misra is secondary here. Hence I'd like to suggest that you declare any such change as an actual bugfix, ideally including a Fixes: tag. It is of course fine to mention that this then also addresses Misra rule 8.4.

As you split the patches moving cper.h out, and fixing the commit message, please add my Reviewed-by for the setup.c/time.c/time.h changes.

#20 lore raw

PATCH 5/8 x86: address MISRA C:2012 Rule 8.4

In reply to Nicola Vetrini

The functions and variables touched by this commit can be static, as they are only used within the same unit. This in turn addresses the absence of declarations that violates Rule 8.4.

---
 xen/arch/x86/cpu/mcheck/mce.c     | 2 +-
 xen/arch/x86/cpu/mcheck/mce_amd.c | 2 +-
 xen/arch/x86/cpu/microcode/core.c | 2 +-
 xen/arch/x86/nmi.c                | 2 +-
 xen/arch/x86/spec_ctrl.c          | 4 ++--
 5 files changed, 6 insertions(+), 6 deletions(-)
xen/arch/x86/cpu/mcheck/mce.c +1 -1
index 57e1eb221e..6141b7eb9c 100644
@@ -599,7 +599,7 @@ unsigned int mce_firstbank(struct cpuinfo_x86 *c)
            c->x86_vendor == X86_VENDOR_INTEL && c->x86_model < 0x1a;
 }
 
-int show_mca_info(int inited, struct cpuinfo_x86 *c)
+static int show_mca_info(int inited, struct cpuinfo_x86 *c)
 {
     static enum mcheck_type g_type = mcheck_unset;
 
xen/arch/x86/cpu/mcheck/mce_amd.c +1 -1
index adc36522cc..72f3feeaee 100644
@@ -87,7 +87,7 @@ enum mc_ec_type {
     MC_EC_BUS_TYPE = 0x0800,
 };
 
-enum mc_ec_type
+static enum mc_ec_type
 mc_ec2type(uint16_t errorcode)
 {
     if ( errorcode & MC_EC_BUS_TYPE )
xen/arch/x86/cpu/microcode/core.c +1 -1
index bec8b55db2..9fcb9c1c3a 100644
@@ -149,7 +149,7 @@ static int __init cf_check parse_ucode(const char *s)
 }
 custom_param("ucode", parse_ucode);
 
-void __init microcode_scan_module(
+static void __init microcode_scan_module(
     unsigned long *module_map,
     const multiboot_info_t *mbi)
 {
xen/arch/x86/nmi.c +1 -1
index c5c28300b0..104e366bd3 100644
@@ -108,7 +108,7 @@ static unsigned int lapic_nmi_owner;
  *     be enabled
  * -1: the lapic NMI watchdog is disabled, but can be enabled
  */
-int nmi_active;
+static int nmi_active;
 
 #define K7_EVNTSEL_ENABLE	(1 << 22)
 #define K7_EVNTSEL_INT		(1 << 20)
xen/arch/x86/spec_ctrl.c +2 -2
index ebe56a96cd..9b8fdb5303 100644
@@ -43,9 +43,9 @@ static enum ind_thunk {
 } opt_thunk __initdata = THUNK_DEFAULT;
 
 static int8_t __initdata opt_ibrs = -1;
-int8_t __initdata opt_stibp = -1;
+static int8_t __initdata opt_stibp = -1;
 bool __ro_after_init opt_ssbd;
-int8_t __initdata opt_psfd = -1;
+static int8_t __initdata opt_psfd = -1;
 
 int8_t __ro_after_init opt_ibpb_ctxt_switch = -1;
 int8_t __read_mostly opt_eager_fpu = -1;
Signature · 1 line
2.34.1
#21 lore raw

Re: [XEN PATCH 5/8] x86: address MISRA C:2012 Rule 8.4

Quoted 5 lines · Nicola Vetrini

The functions and variables touched by this commit can be static, as they are only used within the same unit. This in turn addresses the absence of declarations that violates Rule 8.4.

I'm happy with the code changes here and also in patch 3, but please make the titles meaningful (in patch 3 the prefix also wants to be more specific). As mentioned, the Misra rule is secondary here, and hence doesn't need to be present in the titles.

Jan

#22 lore raw

PATCH 6/8 xen/arm: mm: address MISRA C:2012 Rule 8.4

In reply to Nicola Vetrini

Add a declaration for the variable 'init_ttbr' to resolve the violation of Rule 8.4 present in the associated source file 'mm.c'.

No functional changes.

---
 xen/arch/arm/include/asm/mm.h | 3 +++
 1 file changed, 3 insertions(+)
xen/arch/arm/include/asm/mm.h +3 -0
index 5b530f0f40..698e54aff0 100644
@@ -165,6 +165,9 @@ struct page_info
 #define _PGC_need_scrub   _PGC_allocated
 #define PGC_need_scrub    PGC_allocated
 
+/* Non-boot CPUs use this to find the correct pagetables. */
+extern uint64_t init_ttbr;
+
 extern mfn_t directmap_mfn_start, directmap_mfn_end;
 extern vaddr_t directmap_virt_end;
 #ifdef CONFIG_ARM_64
Signature · 1 line
2.34.1
Reviewed-by on v1 6/8
#23 lore raw

Re: [XEN PATCH 6/8] xen/arm: mm: address MISRA C:2012 Rule 8.4

Quoted 11 lines · Nicola Vetrini

Add a declaration for the variable 'init_ttbr' to resolve the violation of Rule 8.4 present in the associated source file 'mm.c'.

No functional changes.

---

With:

Fixes 4557c2292854 ("xen: arm: rewrite start of day page table and cpu bring up")

If maintainers are ok

Quoted 21 lines

xen/arch/arm/include/asm/mm.h | 3 +++

1 file changed, 3 insertions(+)
xen/arch/arm/include/asm/mm.h +3 -0
index 5b530f0f40..698e54aff0 100644
@@ -165,6 +165,9 @@ struct page_info
 #define _PGC_need_scrub   _PGC_allocated
 #define PGC_need_scrub    PGC_allocated
 
+/* Non-boot CPUs use this to find the correct pagetables. */
+extern uint64_t init_ttbr;
+
 extern mfn_t directmap_mfn_start, directmap_mfn_end;
 extern vaddr_t directmap_virt_end;
 #ifdef CONFIG_ARM_64
Signature · 1 line
2.34.1
Reviewed-by
#24 lore raw

Re: [XEN PATCH 6/8] xen/arm: mm: address MISRA C:2012 Rule 8.4

Quoted 10 lines · Luca Fancellu
Quoted 9 lines · Nicola Vetrini

Add a declaration for the variable 'init_ttbr' to resolve the violation of Rule 8.4 present in the associated source file 'mm.c'.

No functional changes.

---

Quoted 7 lines

With:

Fixes 4557c2292854 ("xen: arm: rewrite start of day page table and cpu bring up")

If maintainers are ok

Yes

#25 lore raw

PATCH 7/8 x86/i8259: address MISRA C:2012 Rule 8.4

In reply to Nicola Vetrini

The additional header file makes the declaration for the function 'init_IRQ', defined in this file visible, thereby resolving the violation of Rule 8.4.

No functional change.

---
 xen/arch/x86/i8259.c | 1 +
 1 file changed, 1 insertion(+)
xen/arch/x86/i8259.c +1 -0
index 6b35be10f0..9b02a3a0ae 100644
@@ -19,6 +19,7 @@
 #include <xen/delay.h>
 #include <asm/apic.h>
 #include <asm/asm_defns.h>
+#include <asm/setup.h>
 #include <io_ports.h>
 #include <irq_vectors.h>
 
Signature · 1 line
2.34.1
#26 lore raw

Re: [XEN PATCH 7/8] x86/i8259: address MISRA C:2012 Rule 8.4

Quoted 16 lines · Nicola Vetrini

The additional header file makes the declaration for the function 'init_IRQ', defined in this file visible, thereby resolving the violation of Rule 8.4.

No functional change.

---
 xen/arch/x86/i8259.c | 1 +
 1 file changed, 1 insertion(+)
xen/arch/x86/i8259.c +0 -0
index 6b35be10f0..9b02a3a0ae 100644

xen/arch/x86/i8259.c line 24

Quoted 6 lines
xen/arch/x86/i8259.c +1 -0
@@ -19,6 +19,7 @@
 #include <xen/delay.h>
 #include <asm/apic.h>
 #include <asm/asm_defns.h>
+#include <asm/setup.h>
 #include <io_ports.h>
 #include <irq_vectors.h>

A patch adding this #include has been pending for almost 3 months:
https://lists.xen.org/archives/html/xen-devel/2023-05/msg00896.html

Jan

#27 lore raw

Re: [XEN PATCH 7/8] x86/i8259: address MISRA C:2012 Rule 8.4

Quoted 27 lines · Jan Beulich
Quoted 16 lines · Nicola Vetrini

The additional header file makes the declaration for the function 'init_IRQ', defined in this file visible, thereby resolving the violation of Rule 8.4.

No functional change.

---
 xen/arch/x86/i8259.c | 1 +
 1 file changed, 1 insertion(+)
xen/arch/x86/i8259.c +0 -0
index 6b35be10f0..9b02a3a0ae 100644

xen/arch/x86/i8259.c line 24

Quoted 6 lines
xen/arch/x86/i8259.c +1 -0
@@ -19,6 +19,7 @@
 #include <xen/delay.h>
 #include <asm/apic.h>
 #include <asm/asm_defns.h>
+#include <asm/setup.h>
 #include <io_ports.h>
 #include <irq_vectors.h>

A patch adding this #include has been pending for almost 3 months:
https://lists.xen.org/archives/html/xen-devel/2023-05/msg00896.html

Quoted 1 line

Jan

So do you prefer going forward with that patch or this one (mentioning it in the additional commit context of course)?

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

Re: [XEN PATCH 7/8] x86/i8259: address MISRA C:2012 Rule 8.4

Quoted 28 lines · Nicola Vetrini
Quoted 12 lines · Jan Beulich
Quoted 11 lines · Nicola Vetrini

The additional header file makes the declaration for the function 'init_IRQ', defined in this file visible, thereby resolving the violation of Rule 8.4.

No functional change.

---
 xen/arch/x86/i8259.c | 1 +
 1 file changed, 1 insertion(+)
Quoted 14 lines

xen/arch/x86/i8259.c line 24

Quoted 11 lines
xen/arch/x86/i8259.c +1 -0
index 6b35be10f0..9b02a3a0ae 100644
@@ -19,6 +19,7 @@
 #include <xen/delay.h>
 #include <asm/apic.h>
 #include <asm/asm_defns.h>
+#include <asm/setup.h>
 #include <io_ports.h>
 #include <irq_vectors.h>

A patch adding this #include has been pending for almost 3 months:
https://lists.xen.org/archives/html/xen-devel/2023-05/msg00896.html

Quoted 3 lines

So do you prefer going forward with that patch or this one (mentioning it
in the additional commit context of course)?

I would prefer using the much older patch, but of course this requires someone providing R-b or A-b.

Jan

#29 lore raw

Re: [XEN PATCH 7/8] x86/i8259: address MISRA C:2012 Rule 8.4

Quoted 29 lines · Jan Beulich
Quoted 28 lines · Nicola Vetrini
Quoted 26 lines · Jan Beulich
Quoted 16 lines · Nicola Vetrini

The additional header file makes the declaration for the function 'init_IRQ', defined in this file visible, thereby resolving the violation of Rule 8.4.

No functional change.

---
 xen/arch/x86/i8259.c | 1 +
 1 file changed, 1 insertion(+)
xen/arch/x86/i8259.c +0 -0
index 6b35be10f0..9b02a3a0ae 100644

xen/arch/x86/i8259.c line 24

Quoted 6 lines
xen/arch/x86/i8259.c +1 -0
@@ -19,6 +19,7 @@
 #include <xen/delay.h>
 #include <asm/apic.h>
 #include <asm/asm_defns.h>
+#include <asm/setup.h>
 #include <io_ports.h>
 #include <irq_vectors.h>

A patch adding this #include has been pending for almost 3 months:
https://lists.xen.org/archives/html/xen-devel/2023-05/msg00896.html

Quoted 6 lines
Quoted 3 lines

So do you prefer going forward with that patch or this one (mentioning it
in the additional commit context of course)?

I would prefer using the much older patch, but of course this requires someone providing R-b or A-b.

Hi Jan, normally I'd be happy to do that but that patch makes other changes that I don't feel confident enough to Ack.

For instance:

+ for ( offs = 0, i = pic_alias_mask & -pic_alias_mask ?: 2;
+ offs <= pic_alias_mask; offs += i )

pic_alias_mask is declared as unsigned int.

#30 lore raw

Re: [XEN PATCH 7/8] x86/i8259: address MISRA C:2012 Rule 8.4

Quoted 34 lines · Stefano Stabellini
Quoted 33 lines · Jan Beulich
Quoted 31 lines · Nicola Vetrini
Quoted 12 lines · Jan Beulich
Quoted 11 lines · Nicola Vetrini

The additional header file makes the declaration for the function 'init_IRQ', defined in this file visible, thereby resolving the violation of Rule 8.4.

No functional change.

---
 xen/arch/x86/i8259.c | 1 +
 1 file changed, 1 insertion(+)
Quoted 14 lines

xen/arch/x86/i8259.c line 24

Quoted 11 lines
xen/arch/x86/i8259.c +1 -0
index 6b35be10f0..9b02a3a0ae 100644
@@ -19,6 +19,7 @@
 #include <xen/delay.h>
 #include <asm/apic.h>
 #include <asm/asm_defns.h>
+#include <asm/setup.h>
 #include <io_ports.h>
 #include <irq_vectors.h>

A patch adding this #include has been pending for almost 3 months:
https://lists.xen.org/archives/html/xen-devel/2023-05/msg00896.html

So do you prefer going forward with that patch or this one (mentioning it
in the additional commit context of course)?

Quoted 5 lines
Quoted 2 lines

I would prefer using the much older patch, but of course this requires someone providing R-b or A-b.

Hi Jan, normally I'd be happy to do that but that patch makes other changes that I don't feel confident enough to Ack.

I understand that in general, but for this specific case ...

Quoted 6 lines

For instance:

(quoted diff) +2 -0
+    for ( offs = 0, i = pic_alias_mask & -pic_alias_mask ?: 2;
+          offs <= pic_alias_mask; offs += i )

pic_alias_mask is declared as unsigned int.

... you're concerned of me negating it? That's a common pattern to determine the largest power-of-2 factor. I'm unaware of a good alternative.

Jan

#31 lore raw

PATCH 8/8 x86/nmi: address MISRA C:2012 Rule 8.4

In reply to Nicola Vetrini

Include an additional header to make the declarations for functions 'watchdog_*' visible prior to their definition in the file, thereby resolving the violations of Rule 8.4.

No functional change.

---
 xen/arch/x86/nmi.c | 1 +
 1 file changed, 1 insertion(+)
xen/arch/x86/nmi.c +1 -0
index 104e366bd3..dc79c25e3f 100644
@@ -24,6 +24,7 @@
 #include <xen/console.h>
 #include <xen/smp.h>
 #include <xen/keyhandler.h>
+#include <xen/watchdog.h>
 #include <xen/cpu.h>
 #include <asm/current.h>
 #include <asm/mc146818rtc.h>
Signature · 1 line
2.34.1
Reviewed-by on v1 8/8
#32 lore raw

Re: [XEN PATCH 8/8] x86/nmi: address MISRA C:2012 Rule 8.4

Quoted 5 lines · Nicola Vetrini

Include an additional header to make the declarations for functions 'watchdog_*' visible prior to their definition in the file, thereby resolving the violations of Rule 8.4.

No functional change.

Fixes c8177e691f0f ("watchdog: Move watchdog from being x86 specific to common code")
Quoted 1 line