Skip to contentSkip to conversation

xen: fix missing headers and static storage duration

PATCH Superseded Nicola Vetrini 4 participants 35 messages Aug 11, 2023 – Aug 14, 2023

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#1 lore raw

PATCH 1/6 x86/hpet: make variable 'per_cpu__cpu_bc_channel' static

In reply to Nicola Vetrini

The variable is only ever used inside the file where it's defined, therefore it can have static storage. This also resolves a violation of MISRA C:2012 Rule 8.4 due to the absence of a declaration prior to the definition.

Fixes 3ba523ff957c ("CPUIDLE: enable MSI capable HPET for timer broadcast")
---
 xen/arch/x86/hpet.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
xen/arch/x86/hpet.c +1 -1
index a2df1c7df401..79c07f6a9e09 100644
@@ -49,7 +49,7 @@ static struct hpet_event_channel *__read_mostly hpet_events;
 /* msi hpet channels used for broadcast */
 static unsigned int __read_mostly num_hpets_used;
 
-DEFINE_PER_CPU(struct hpet_event_channel *, cpu_bc_channel);
+static DEFINE_PER_CPU(struct hpet_event_channel *, cpu_bc_channel);
 
 unsigned long __initdata hpet_address;
 int8_t __initdata opt_hpet_legacy_replacement = -1;
Signature · 1 line
2.34.1
#0 lore raw

cover xen: fix missing headers and static storage duration

The files touched by this series contain function or variable definitions with no prior declaration visible, because it's inside an header that is not included or it's not present anywhere. This is a risk in itself, but also violates MISRA C:2012 Rule 8.4, which states the following:
"A compatible declaration shall be visible when an object or function with external linkage is defined".

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:
- This series is a continuation of the work done here [1], so the same additional notes apply.

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

Nicola Vetrini (6):
x86/hpet: make variable 'per_cpu__cpu_bc_channel' static x86/setup: add missing headers
x86/vm_event: add missing include
cpufreq: add missing include of header 'pmstat.h' vpic/msix: make 'get_slot' static
drivers/video: make declarations of defined functions available

 xen/arch/x86/hpet.c              |  2 +-
 xen/arch/x86/include/asm/setup.h |  6 ------
 xen/arch/x86/setup.c             |  4 +++-
 xen/arch/x86/vm_event.c          |  1 +
 xen/drivers/cpufreq/cpufreq.c    |  1 +
 xen/drivers/video/vga.c          |  9 +--------
 xen/drivers/vpci/msix.c          |  2 +-
 xen/include/xen/cpuidle.h        |  2 +-
 xen/include/xen/vga.h            | 14 ++++++++++++++
 9 files changed, 23 insertions(+), 18 deletions(-)

--
2.34.1

#9 lore raw

PATCH 3/6 x86/vm_event: add missing include

The missing header included by this patch provides declarations for the functions 'vm_event_{fill_regs,set_registers,monitor_next_interrupt}' that are defined in the source file. This also resolves violations of MISRA C:2012 Rule 8.4.

Fixes adc75eba8b15 ("x86/vm_event: consolidate hvm_event_fill_regs and p2m_vm_event_fill_regs")
Fixes 975efd3baa8d ("introduce VM_EVENT_FLAG_SET_REGISTERS")
Fixes 9864841914c2 ("x86/vm_event: add support for VM_EVENT_REASON_INTERRUPT")
---
 xen/arch/x86/vm_event.c | 1 +
 1 file changed, 1 insertion(+)
xen/arch/x86/vm_event.c +1 -0
index 7027c08a926b..499b6b349d79 100644
@@ -20,6 +20,7 @@
 
 #include <xen/sched.h>
 #include <xen/mem_access.h>
+#include <xen/vm_event.h>
 #include <asm/vm_event.h>
 
 /* Implicitly serialized by the domctl lock. */
Signature · 1 line
2.34.1
#5 lore raw

PATCH 2/6 x86/setup: add missing headers

In reply to Nicola Vetrini

The missing headers declare variables 'xen_cpuidle' and 'use_invpcid' that are then defined inside the file.
This is undesirable and also violates MISRA C:2012 Rule 8.4. Adding suitable "#include"s resolves the issue.

The type of the variable 'xen_cpuidle' also changes according to s/s8/int8_t/.

Fixes 3eab82196b02 ("x86: PIT broadcast to fix local APIC timer stop issue for Deep C state")
Fixes 63dc135aeaf9 ("x86: invpcid support")
---
 xen/arch/x86/setup.c      | 4 +++-
 xen/include/xen/cpuidle.h | 2 +-
 2 files changed, 4 insertions(+), 2 deletions(-)
xen/arch/x86/setup.c +3 -1
index 80ae973d64e4..2bfc1fd00f8c 100644
@@ -47,10 +47,12 @@
 #include <asm/mach-generic/mach_apic.h> /* for generic_apic_probe */
 #include <asm/setup.h>
 #include <xen/cpu.h>
+#include <xen/cpuidle.h>
 #include <asm/nmi.h>
 #include <asm/alternative.h>
 #include <asm/mc146818rtc.h>
 #include <asm/cpu-policy.h>
+#include <asm/invpcid.h>
 #include <asm/spec_ctrl.h>
 #include <asm/guest.h>
 #include <asm/microcode.h>
@@ -88,7 +90,7 @@ boolean_param("noapic", skip_ioapic_setup);
 
 /* **** Linux config option: propagated to domain0. */
 /* xen_cpuidle: xen control cstate. */
-s8 __read_mostly xen_cpuidle = -1;
+int8_t __read_mostly xen_cpuidle = -1;
 boolean_param("cpuidle", xen_cpuidle);
 
 #ifndef NDEBUG
xen/include/xen/cpuidle.h +1 -1
index 521a8deb04c2..705d0c1135f0 100644
@@ -86,7 +86,7 @@ struct cpuidle_governor
     void (*reflect)         (struct acpi_processor_power *dev);
 };
 
-extern s8 xen_cpuidle;
+extern int8_t xen_cpuidle;
 extern struct cpuidle_governor *cpuidle_current_governor;
 
 bool cpuidle_using_deep_cstate(void);
Signature · 1 line
2.34.1
#22 lore raw

PATCH 4/6 cpufreq: add missing include of header 'pmstat.h'

In reply to Nicola Vetrini

The missing header included by this patch provides a declaration for 'set_px_pminfo' that is visible prior to the definition in this file. This also resolves a violation of MISRA C:2012 Rule 8.4.

Fixes 452119c09420 ("x86 and ia64: move cpufreq notify code to commone place")
---
 xen/drivers/cpufreq/cpufreq.c | 1 +
 1 file changed, 1 insertion(+)
xen/drivers/cpufreq/cpufreq.c +1 -0
index 2321c7dd07b1..4482bbe53a1e 100644
@@ -39,6 +39,7 @@
 #include <xen/guest_access.h>
 #include <xen/domain.h>
 #include <xen/cpu.h>
+#include <xen/pmstat.h>
 #include <asm/io.h>
 #include <asm/processor.h>
 
Signature · 1 line
2.34.1
#29 lore raw

PATCH 6/6 drivers/video: make declarations of defined functions available

In reply to Nicola Vetrini

The declarations for 'vesa_{init,early_init,endboot}' needed by 'xen/drivers/video/vesa.c' and 'fill_console_start_info' in 'vga.c' are now available by moving the relative code inside 'vga.h' and including "<xen/console.h>" respectively.
This also resolves violations of MISRA C:2012 Rule 8.4.

Fixes ebb26b509f1a ("xen/x86: make VGA support selectable")
Fixes 6d9199bd0f22 ("x86-64: enable hypervisor output on VESA frame buffer")
---
 xen/arch/x86/include/asm/setup.h |  6 ------
 xen/drivers/video/vga.c          |  9 +--------
 xen/include/xen/vga.h            | 14 ++++++++++++++
 3 files changed, 15 insertions(+), 14 deletions(-)
xen/arch/x86/include/asm/setup.h +0 -6
index b0e6a39e2365..dfdd9e555149 100644
@@ -25,12 +25,6 @@ void subarch_init_memory(void);
 
 void init_IRQ(void);
 
-#ifdef CONFIG_VIDEO
-void vesa_init(void);
-#else
-static inline void vesa_init(void) {};
-#endif
-
 int construct_dom0(
     struct domain *d,
     const module_t *image, unsigned long image_headroom,
xen/drivers/video/vga.c +1 -8
index 0a03508bee60..b62a47e000e7 100644
@@ -9,6 +9,7 @@
 #include <xen/mm.h>
 #include <xen/param.h>
 #include <xen/vga.h>
+#include <xen/console.h>
 #include <xen/pci.h>
 #include <asm/io.h>
 
@@ -54,14 +55,6 @@ string_param("vga", opt_vga);
 static unsigned int columns, lines;
 #define ATTRIBUTE   7
 
-#ifdef CONFIG_X86
-void vesa_early_init(void);
-void vesa_endboot(bool_t keep);
-#else
-#define vesa_early_init() ((void)0)
-#define vesa_endboot(x)   ((void)0)
-#endif
-
 void __init video_init(void)
 {
     char *p;
xen/include/xen/vga.h +14 -0
index f72b63d446b1..ffd73c9db135 100644
@@ -15,4 +15,18 @@
 extern struct xen_vga_console_info vga_console_info;
 #endif
 
+#ifdef CONFIG_X86
+void vesa_early_init(void);
+void vesa_endboot(bool_t keep);
+#else
+#define vesa_early_init() ((void)0)
+#define vesa_endboot(x)   ((void)0)
+#endif
+
+#ifdef CONFIG_VIDEO
+void vesa_init(void);
+#else
+static inline void vesa_init(void) {};
+#endif
+
 #endif /* _XEN_VGA_H */
Signature · 1 line
2.34.1
#25 lore raw

PATCH 5/6 vpic/msix: make 'get_slot' static

In reply to Nicola Vetrini

The function can become static since it's used only within this file. This also resolves a violation of MISRA C:2012 Rule 8.4 due to the absence of a declaration before the function definition.

Fixes b177892d2d0e ("vpci/msix: handle accesses adjacent to the MSI-X table")
---
 xen/drivers/vpci/msix.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
xen/drivers/vpci/msix.c +1 -1
index 25bde77586a4..f9df506f29bf 100644
@@ -223,7 +223,7 @@ static void __iomem *get_table(const struct vpci *vpci, unsigned int slot)
     return msix->table[slot];
 }
 
-unsigned int get_slot(const struct vpci *vpci, unsigned long addr)
+static unsigned int get_slot(const struct vpci *vpci, unsigned long addr)
 {
     unsigned long pfn = PFN_DOWN(addr);
 
Signature · 1 line
2.34.1
Reviewed-by on v1 1/6
#2 lore raw

Re: [XEN PATCH 1/6] x86/hpet: make variable 'per_cpu__cpu_bc_channel' static

In reply to Nicola Vetrini
Quoted 7 lines · Nicola Vetrini

The variable is only ever used inside the file where it's defined, therefore it can have static storage. This also resolves a violation of MISRA C:2012 Rule 8.4 due to the absence of a declaration prior to the definition.

Fixes 3ba523ff957c ("CPUIDLE: enable MSI capable HPET for timer broadcast")
Quoted 20 lines
---
 xen/arch/x86/hpet.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
xen/arch/x86/hpet.c +1 -1
index a2df1c7df401..79c07f6a9e09 100644
@@ -49,7 +49,7 @@ static struct hpet_event_channel *__read_mostly hpet_events;
 /* msi hpet channels used for broadcast */
 static unsigned int __read_mostly num_hpets_used;
 
-DEFINE_PER_CPU(struct hpet_event_channel *, cpu_bc_channel);
+static DEFINE_PER_CPU(struct hpet_event_channel *, cpu_bc_channel);
 
 unsigned long __initdata hpet_address;
 int8_t __initdata opt_hpet_legacy_replacement = -1;
Signature · 1 line
2.34.1
#3 lore raw

Re: [XEN PATCH 1/6] x86/hpet: make variable 'per_cpu__cpu_bc_channel' static

Adding x86 maintainers

Quoted 33 lines · Stefano Stabellini
Quoted 7 lines · Nicola Vetrini

The variable is only ever used inside the file where it's defined, therefore it can have static storage. This also resolves a violation of MISRA C:2012 Rule 8.4 due to the absence of a declaration prior to the definition.

Fixes 3ba523ff957c ("CPUIDLE: enable MSI capable HPET for timer broadcast")
Quoted 20 lines
---
 xen/arch/x86/hpet.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
xen/arch/x86/hpet.c +1 -1
index a2df1c7df401..79c07f6a9e09 100644
@@ -49,7 +49,7 @@ static struct hpet_event_channel *__read_mostly hpet_events;
 /* msi hpet channels used for broadcast */
 static unsigned int __read_mostly num_hpets_used;
 
-DEFINE_PER_CPU(struct hpet_event_channel *, cpu_bc_channel);
+static DEFINE_PER_CPU(struct hpet_event_channel *, cpu_bc_channel);
 
 unsigned long __initdata hpet_address;
 int8_t __initdata opt_hpet_legacy_replacement = -1;
Signature · 1 line
2.34.1
Reviewed-by on v1 2/6
#6 lore raw

Re: [XEN PATCH 2/6] x86/setup: add missing headers

In reply to Nicola Vetrini
Quoted 11 lines · Nicola Vetrini

The missing headers declare variables 'xen_cpuidle' and 'use_invpcid' that are then defined inside the file.
This is undesirable and also violates MISRA C:2012 Rule 8.4. Adding suitable "#include"s resolves the issue.

The type of the variable 'xen_cpuidle' also changes according to s/s8/int8_t/.

Fixes 3eab82196b02 ("x86: PIT broadcast to fix local APIC timer stop issue for Deep C state")
Fixes 63dc135aeaf9 ("x86: invpcid support")
Quoted 47 lines
---
 xen/arch/x86/setup.c      | 4 +++-
 xen/include/xen/cpuidle.h | 2 +-
 2 files changed, 4 insertions(+), 2 deletions(-)
xen/arch/x86/setup.c +3 -1
index 80ae973d64e4..2bfc1fd00f8c 100644
@@ -47,10 +47,12 @@
 #include <asm/mach-generic/mach_apic.h> /* for generic_apic_probe */
 #include <asm/setup.h>
 #include <xen/cpu.h>
+#include <xen/cpuidle.h>
 #include <asm/nmi.h>
 #include <asm/alternative.h>
 #include <asm/mc146818rtc.h>
 #include <asm/cpu-policy.h>
+#include <asm/invpcid.h>
 #include <asm/spec_ctrl.h>
 #include <asm/guest.h>
 #include <asm/microcode.h>
@@ -88,7 +90,7 @@ boolean_param("noapic", skip_ioapic_setup);
 
 /* **** Linux config option: propagated to domain0. */
 /* xen_cpuidle: xen control cstate. */
-s8 __read_mostly xen_cpuidle = -1;
+int8_t __read_mostly xen_cpuidle = -1;
 boolean_param("cpuidle", xen_cpuidle);
 
 #ifndef NDEBUG
xen/include/xen/cpuidle.h +1 -1
index 521a8deb04c2..705d0c1135f0 100644
@@ -86,7 +86,7 @@ struct cpuidle_governor
     void (*reflect)         (struct acpi_processor_power *dev);
 };
 
-extern s8 xen_cpuidle;
+extern int8_t xen_cpuidle;
 extern struct cpuidle_governor *cpuidle_current_governor;
 
 bool cpuidle_using_deep_cstate(void);
Signature · 1 line
2.34.1
#10 lore raw

Re: [XEN PATCH 3/6] x86/vm_event: add missing include

In reply to Nicola Vetrini
Quoted 18 lines · Nicola Vetrini

The missing header included by this patch provides declarations for the functions 'vm_event_{fill_regs,set_registers,monitor_next_interrupt}' that are defined in the source file. This also resolves violations of MISRA C:2012 Rule 8.4.

Fixes adc75eba8b15 ("x86/vm_event: consolidate hvm_event_fill_regs and p2m_vm_event_fill_regs")
Fixes 975efd3baa8d ("introduce VM_EVENT_FLAG_SET_REGISTERS")
Fixes 9864841914c2 ("x86/vm_event: add support for VM_EVENT_REASON_INTERRUPT")
---
 xen/arch/x86/vm_event.c | 1 +
 1 file changed, 1 insertion(+)
xen/arch/x86/vm_event.c +0 -0
index 7027c08a926b..499b6b349d79 100644

xen/arch/x86/vm_event.c line 26

Quoted 7 lines
xen/arch/x86/vm_event.c +1 -0
@@ -20,6 +20,7 @@
 
 #include <xen/sched.h>
 #include <xen/mem_access.h>
+#include <xen/vm_event.h>
 #include <asm/vm_event.h>
 
 /* Implicitly serialized by the domctl lock. */

I think the problem here is that ./arch/x86/include/asm/vm_event.h, differently from ./arch/arm/include/asm/vm_event.h, doesn't #include <xen/vm_event.h>

Reviewed-by on v1 4/6
#23 lore raw

Re: [XEN PATCH 4/6] cpufreq: add missing include of header 'pmstat.h'

In reply to Nicola Vetrini
Quoted 6 lines · Nicola Vetrini

The missing header included by this patch provides a declaration for 'set_px_pminfo' that is visible prior to the definition in this file. This also resolves a violation of MISRA C:2012 Rule 8.4.

Fixes 452119c09420 ("x86 and ia64: move cpufreq notify code to commone place")
Quoted 19 lines
---
 xen/drivers/cpufreq/cpufreq.c | 1 +
 1 file changed, 1 insertion(+)
xen/drivers/cpufreq/cpufreq.c +1 -0
index 2321c7dd07b1..4482bbe53a1e 100644
@@ -39,6 +39,7 @@
 #include <xen/guest_access.h>
 #include <xen/domain.h>
 #include <xen/cpu.h>
+#include <xen/pmstat.h>
 #include <asm/io.h>
 #include <asm/processor.h>
 
Signature · 1 line
2.34.1
Reviewed-by on v1 5/6
#26 lore raw

Re: [XEN PATCH 5/6] vpic/msix: make 'get_slot' static

In reply to Nicola Vetrini
Quoted 6 lines · Nicola Vetrini

The function can become static since it's used only within this file. This also resolves a violation of MISRA C:2012 Rule 8.4 due to the absence of a declaration before the function definition.

Fixes b177892d2d0e ("vpci/msix: handle accesses adjacent to the MSI-X table")
Quoted 20 lines
---
 xen/drivers/vpci/msix.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
xen/drivers/vpci/msix.c +1 -1
index 25bde77586a4..f9df506f29bf 100644
@@ -223,7 +223,7 @@ static void __iomem *get_table(const struct vpci *vpci, unsigned int slot)
     return msix->table[slot];
 }
 
-unsigned int get_slot(const struct vpci *vpci, unsigned long addr)
+static unsigned int get_slot(const struct vpci *vpci, unsigned long addr)
 {
     unsigned long pfn = PFN_DOWN(addr);
 
Signature · 1 line
2.34.1
Reviewed-by on v1 6/6
#30 lore raw

Re: [XEN PATCH 6/6] drivers/video: make declarations of defined functions available

In reply to Nicola Vetrini
Quoted 9 lines · Nicola Vetrini

The declarations for 'vesa_{init,early_init,endboot}' needed by 'xen/drivers/video/vesa.c' and 'fill_console_start_info' in 'vga.c' are now available by moving the relative code inside 'vga.h' and including "<xen/console.h>" respectively.
This also resolves violations of MISRA C:2012 Rule 8.4.

Fixes ebb26b509f1a ("xen/x86: make VGA support selectable")
Fixes 6d9199bd0f22 ("x86-64: enable hypervisor output on VESA frame buffer")
Quoted 76 lines
---
 xen/arch/x86/include/asm/setup.h |  6 ------
 xen/drivers/video/vga.c          |  9 +--------
 xen/include/xen/vga.h            | 14 ++++++++++++++
 3 files changed, 15 insertions(+), 14 deletions(-)
xen/arch/x86/include/asm/setup.h +0 -6
index b0e6a39e2365..dfdd9e555149 100644
@@ -25,12 +25,6 @@ void subarch_init_memory(void);
 
 void init_IRQ(void);
 
-#ifdef CONFIG_VIDEO
-void vesa_init(void);
-#else
-static inline void vesa_init(void) {};
-#endif
-
 int construct_dom0(
     struct domain *d,
     const module_t *image, unsigned long image_headroom,
xen/drivers/video/vga.c +1 -8
index 0a03508bee60..b62a47e000e7 100644
@@ -9,6 +9,7 @@
 #include <xen/mm.h>
 #include <xen/param.h>
 #include <xen/vga.h>
+#include <xen/console.h>
 #include <xen/pci.h>
 #include <asm/io.h>
 
@@ -54,14 +55,6 @@ string_param("vga", opt_vga);
 static unsigned int columns, lines;
 #define ATTRIBUTE   7
 
-#ifdef CONFIG_X86
-void vesa_early_init(void);
-void vesa_endboot(bool_t keep);
-#else
-#define vesa_early_init() ((void)0)
-#define vesa_endboot(x)   ((void)0)
-#endif
-
 void __init video_init(void)
 {
     char *p;
xen/include/xen/vga.h +14 -0
index f72b63d446b1..ffd73c9db135 100644
@@ -15,4 +15,18 @@
 extern struct xen_vga_console_info vga_console_info;
 #endif
 
+#ifdef CONFIG_X86
+void vesa_early_init(void);
+void vesa_endboot(bool_t keep);
+#else
+#define vesa_early_init() ((void)0)
+#define vesa_endboot(x)   ((void)0)
+#endif
+
+#ifdef CONFIG_VIDEO
+void vesa_init(void);
+#else
+static inline void vesa_init(void) {};
+#endif
+
 #endif /* _XEN_VGA_H */
Signature · 1 line
2.34.1
#11 lore raw

Re: [XEN PATCH 3/6] x86/vm_event: add missing include

In reply to Stefano Stabellini
Quoted 12 lines
Quoted 12 lines
xen/arch/x86/vm_event.c +1 -0
index 7027c08a926b..499b6b349d79 100644
@@ -20,6 +20,7 @@
 
 #include <xen/sched.h>
 #include <xen/mem_access.h>
+#include <xen/vm_event.h>
 #include <asm/vm_event.h>
 
Quoted 5 lines

xen/arch/x86/vm_event.c line 26

Quoted 1 line
xen/arch/x86/vm_event.c +0 -0
 /* Implicitly serialized by the domctl lock. */

I think the problem here is that ./arch/x86/include/asm/vm_event.h, differently from ./arch/arm/include/asm/vm_event.h, doesn't #include <xen/vm_event.h>

I see your point. Do you think it would be better to include xen/vm_event.h in asm/vm_event.h for x86 or move the inclusion of xen/vm_event.h for arm to the source file, as done in the patch?

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

Re: [XEN PATCH 3/6] x86/vm_event: add missing include

Hi,

Quoted 18 lines · Nicola Vetrini
Quoted 12 lines
Quoted 12 lines
xen/arch/x86/vm_event.c +1 -0
index 7027c08a926b..499b6b349d79 100644
@@ -20,6 +20,7 @@
 
  #include <xen/sched.h>
  #include <xen/mem_access.h>
+#include <xen/vm_event.h>
  #include <asm/vm_event.h>
 
Quoted 5 lines

xen/arch/x86/vm_event.c line 26

Quoted 1 line
xen/arch/x86/vm_event.c +0 -0
  /* Implicitly serialized by the domctl lock. */

I think the problem here is that ./arch/x86/include/asm/vm_event.h, differently from ./arch/arm/include/asm/vm_event.h, doesn't #include <xen/vm_event.h>

Quoted 3 lines

I see your point. Do you think it would be better to include xen/vm_event.h in asm/vm_event.h for x86 or move the inclusion of xen/vm_event.h for arm to the source file, as done in the patch?

I think it is a bit odd require the C file to include the arch-specific header and the common one. It would be better to include only one.

My preference would be to include <asm/...> from <xen/...> and then only include the latter in the C file.

Cheers,

Signature · 1 line
Julien Grall
#13 lore raw

Re: [XEN PATCH 3/6] x86/vm_event: add missing include

Quoted 23 lines · Julien Grall
Quoted 17 lines · Nicola Vetrini
Quoted 11 lines
Quoted 11 lines
xen/arch/x86/vm_event.c +1 -0
index 7027c08a926b..499b6b349d79 100644
@@ -20,6 +20,7 @@
 
  #include <xen/sched.h>
  #include <xen/mem_access.h>
+#include <xen/vm_event.h>
  #include <asm/vm_event.h>
 
Quoted 5 lines

xen/arch/x86/vm_event.c line 26

Quoted 1 line
xen/arch/x86/vm_event.c +0 -0
  /* Implicitly serialized by the domctl lock. */

I think the problem here is that ./arch/x86/include/asm/vm_event.h, differently from ./arch/arm/include/asm/vm_event.h, doesn't #include <xen/vm_event.h>

Quoted 4 lines

I see your point. Do you think it would be better to include xen/vm_event.h in asm/vm_event.h for x86 or move the inclusion of xen/vm_event.h for arm to
the source file, as done in the patch?

Quoted 5 lines

I think it is a bit odd require the C file to include the arch-specific header and the common one. It would be better to include only one.

My preference would be to include <asm/...> from <xen/...> and then only include the latter in the C file.

+1

Jan

Acked-by
#4 lore raw

Re: [XEN PATCH 1/6] x86/hpet: make variable 'per_cpu__cpu_bc_channel' static

In reply to Stefano Stabellini
Quoted 10 lines · Stefano Stabellini
Quoted 7 lines · Nicola Vetrini

The variable is only ever used inside the file where it's defined, therefore it can have static storage. This also resolves a violation of MISRA C:2012 Rule 8.4 due to the absence of a declaration prior to the definition.

Fixes 3ba523ff957c ("CPUIDLE: enable MSI capable HPET for timer broadcast")
Acked-by
#7 lore raw

Re: [XEN PATCH 2/6] x86/setup: add missing headers

In reply to Stefano Stabellini
Quoted 6 lines · Stefano Stabellini
Quoted 5 lines · Nicola Vetrini

The missing headers declare variables 'xen_cpuidle' and 'use_invpcid' that are then defined inside the file.
This is undesirable and also violates MISRA C:2012 Rule 8.4. Adding suitable "#include"s resolves the issue.

Quoted 6 lines
Quoted 6 lines

The type of the variable 'xen_cpuidle' also changes according to s/s8/int8_t/.

Fixes 3eab82196b02 ("x86: PIT broadcast to fix local APIC timer stop issue for Deep C state")
Fixes 63dc135aeaf9 ("x86: invpcid support")

One request: Please can you get used to putting the Fixes: tags first, so one doesn't need to (try to) remember to move them in the course of committing?

Quoted 1 line

Jan

#14 lore raw

Re: [XEN PATCH 3/6] x86/vm_event: add missing include

In reply to Nicola Vetrini
Quoted 9 lines · Nicola Vetrini

The missing header included by this patch provides declarations for the functions 'vm_event_{fill_regs,set_registers,monitor_next_interrupt}' that are defined in the source file. This also resolves violations of MISRA C:2012 Rule 8.4.

Fixes adc75eba8b15 ("x86/vm_event: consolidate hvm_event_fill_regs and p2m_vm_event_fill_regs")
Fixes 975efd3baa8d ("introduce VM_EVENT_FLAG_SET_REGISTERS")
Fixes 9864841914c2 ("x86/vm_event: add support for VM_EVENT_REASON_INTERRUPT")

It's hard to see how it can be three commit here. The oldest one is at fault, I would say.

Also please remember to Cc maintainers.

Jan

Quoted 10 lines
xen/arch/x86/vm_event.c +1 -0
@@ -20,6 +20,7 @@
 
 #include <xen/sched.h>
 #include <xen/mem_access.h>
+#include <xen/vm_event.h>
 #include <asm/vm_event.h>
 
 /* Implicitly serialized by the domctl lock. */
Acked-by
#24 lore raw

Re: [XEN PATCH 4/6] cpufreq: add missing include of header 'pmstat.h'

In reply to Stefano Stabellini
Quoted 9 lines · Stefano Stabellini
Quoted 6 lines · Nicola Vetrini

The missing header included by this patch provides a declaration for 'set_px_pminfo' that is visible prior to the definition in this file. This also resolves a violation of MISRA C:2012 Rule 8.4.

Fixes 452119c09420 ("x86 and ia64: move cpufreq notify code to commone place")
#8 lore raw

Re: [XEN PATCH 2/6] x86/setup: add missing headers

In reply to Jan Beulich
Quoted 9 lines
Quoted 4 lines
Quoted 4 lines
Fixes 3eab82196b02 ("x86: PIT broadcast to fix local APIC timer stop issue for Deep C state")
Fixes 63dc135aeaf9 ("x86: invpcid support")

One request: Please can you get used to putting the Fixes: tags first, so one doesn't need to (try to) remember to move them in the course of committing?

Sure. Sorry, I didn't notice the ordering in other commits.

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

Re: [XEN PATCH 5/6] vpic/msix: make 'get_slot' static

In reply to Nicola Vetrini
Quoted 6 lines · Nicola Vetrini

The function can become static since it's used only within this file. This also resolves a violation of MISRA C:2012 Rule 8.4 due to the absence of a declaration before the function definition.

Fixes b177892d2d0e ("vpci/msix: handle accesses adjacent to the MSI-X table")

Nit (typo): In the title you mean "vpci/msix", just like this quoted commit has it. This is important-ish because we also have "vpic" elsewhere in the tree. (Can certainly be adjusted while committing.)

Jan

#31 lore raw

Re: [XEN PATCH 6/6] drivers/video: make declarations of defined functions available

In reply to Nicola Vetrini

xen/drivers/video/vga.c line 12

Quoted 7 lines · Nicola Vetrini
xen/drivers/video/vga.c +1 -0
@@ -9,6 +9,7 @@
 #include <xen/mm.h>
 #include <xen/param.h>
 #include <xen/vga.h>
+#include <xen/console.h>

xen/vga.h, which you move the declarations to, is already included here. Why the need for xen/console.h?

Jan

#28 lore raw

Re: [XEN PATCH 5/6] vpic/msix: make 'get_slot' static

In reply to Jan Beulich
Quoted 5 lines · Jan Beulich
Quoted 4 lines · Nicola Vetrini

The function can become static since it's used only within this file. This also resolves a violation of MISRA C:2012 Rule 8.4 due to the absence of a declaration before the function definition.

Quoted 8 lines
Quoted 2 lines
Fixes b177892d2d0e ("vpci/msix: handle accesses adjacent to the MSI-X table")

Nit (typo): In the title you mean "vpci/msix", just like this quoted commit has it. This is important-ish because we also have "vpic" elsewhere in the tree. (Can certainly be adjusted while committing.)

Jan

Yes, I meant to write 'vpci/msix'.

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

Re: [XEN PATCH 6/6] drivers/video: make declarations of defined functions available

In reply to Jan Beulich
Quoted 12 lines · Jan Beulich

xen/drivers/video/vga.c line 12

Quoted 7 lines · Nicola Vetrini
xen/drivers/video/vga.c +1 -0
@@ -9,6 +9,7 @@
 #include <xen/mm.h>
 #include <xen/param.h>
 #include <xen/vga.h>
+#include <xen/console.h>

xen/vga.h, which you move the declarations to, is already included here. Why the need for xen/console.h?

Quoted 1 line

Jan

vga.c needs a declaration for fill_console_start_info, which is declared in console.h, as stated in the commit message (it could be clarified perhaps).

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

Re: [XEN PATCH 6/6] drivers/video: make declarations of defined functions available

Quoted 14 lines · Nicola Vetrini
Quoted 12 lines · Jan Beulich

xen/drivers/video/vga.c line 12

Quoted 7 lines · Nicola Vetrini
xen/drivers/video/vga.c +1 -0
@@ -9,6 +9,7 @@
 #include <xen/mm.h>
 #include <xen/param.h>
 #include <xen/vga.h>
+#include <xen/console.h>

xen/vga.h, which you move the declarations to, is already included here.
Why the need for xen/console.h?

Quoted 3 lines

vga.c needs a declaration for fill_console_start_info, which is declared in console.h, as
stated in the commit message (it could be clarified perhaps).

Ah, I see. It's not very fortunate mixing of two separate adjustments. But then I'm inclined to ask: When fill_console_start_info() is defined in vga.c, wouldn't it make sense to move its declaration to vga.h? The more considering the type of its parameter?

Jan

#34 lore raw

Re: [XEN PATCH 6/6] drivers/video: make declarations of defined functions available

Quoted 15 lines · Jan Beulich
Quoted 14 lines · Nicola Vetrini
Quoted 12 lines · Jan Beulich

xen/drivers/video/vga.c line 12

Quoted 7 lines · Nicola Vetrini
xen/drivers/video/vga.c +1 -0
@@ -9,6 +9,7 @@
 #include <xen/mm.h>
 #include <xen/param.h>
 #include <xen/vga.h>
+#include <xen/console.h>

xen/vga.h, which you move the declarations to, is already included here.
Why the need for xen/console.h?

Quoted 5 lines
Quoted 3 lines

vga.c needs a declaration for fill_console_start_info, which is declared in console.h, as
stated in the commit message (it could be clarified perhaps).

Ah, I see. It's not very fortunate mixing of two separate adjustments.

Well, they are not so separate, because they both deal with what the functions in vga.c need to be compliant with Rule 8.4.

Quoted 5 lines

But then I'm inclined to ask: When fill_console_start_info() is defined in vga.c, wouldn't it make sense to move its declaration to vga.h? The more considering the type of its parameter?

Jan

I see no downside. This change would imply having to include <xen/vga.h> in both
- x86/platform_hypercall.c
- x86/pv/dom0_build.c
which seems okay.

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

Re: [XEN PATCH 3/6] x86/vm_event: add missing include

In reply to Jan Beulich
Quoted 6 lines · Jan Beulich
Quoted 5 lines · Nicola Vetrini

The missing header included by this patch provides declarations for the functions 'vm_event_{fill_regs,set_registers,monitor_next_interrupt}' that are defined in the source file. This also resolves violations of MISRA C:2012 Rule 8.4.

Quoted 7 lines
Quoted 4 lines
Fixes adc75eba8b15 ("x86/vm_event: consolidate hvm_event_fill_regs and p2m_vm_event_fill_regs")
Fixes 975efd3baa8d ("introduce VM_EVENT_FLAG_SET_REGISTERS")
Fixes 9864841914c2 ("x86/vm_event: add support for VM_EVENT_REASON_INTERRUPT")

It's hard to see how it can be three commit here. The oldest one is at fault, I would say.

Since the patch is concerned with more than one function then in a sense I agree
with you (the headers should have been included in the proper way the first time around), but
then more definitions have been added by adc75eba8b15 and 9864841914c2, and these should have
triggered a refactoring too. I can leave just 975efd3baa8d in the Fixes if the preferred way is to list just the first problematic commit (perhaps with a little explanation after --- ).

Quoted 2 lines

Also please remember to Cc maintainers.

Yes, sorry. I must have forgotten to run add_maintainers.

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

Re: [XEN PATCH 3/6] x86/vm_event: add missing include

Hi,

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

The missing header included by this patch provides declarations for the functions 'vm_event_{fill_regs,set_registers,monitor_next_interrupt}' that are defined in the source file. This also resolves violations of MISRA C:2012 Rule 8.4.

Fixes adc75eba8b15 ("x86/vm_event: consolidate hvm_event_fill_regs and p2m_vm_event_fill_regs")
Fixes 975efd3baa8d ("introduce VM_EVENT_FLAG_SET_REGISTERS")
Fixes 9864841914c2 ("x86/vm_event: add support for VM_EVENT_REASON_INTERRUPT")
Quoted 7 lines
Quoted 2 lines

It's hard to see how it can be three commit here. The oldest one is at fault, I would say.

Since the patch is concerned with more than one function then in a sense I agree
with you (the headers should have been included in the proper way the first time around), but
then more definitions have been added by adc75eba8b15 and 9864841914c2, and these should have
triggered a refactoring too. I can leave just 975efd3baa8d in the Fixes if the preferred way is to list just the first problematic commit (perhaps with a little explanation after --- ).

To be honest, I don't exactly see the value of using Fixes tag for those patches. I agree they are technically issues, but they are unlikely going to be backported.

So if it were me, I would just drop all the Fixes tags for missing includes unless there is an actual bug associated with them (e.g. a caller was miscalling the function because the
prototype was incorrect).

Cheers,

Signature · 1 line
Julien Grall
#17 lore raw

Re: [XEN PATCH 3/6] x86/vm_event: add missing include

Hi,

Quoted 27 lines · Julien Grall

Hi,

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

The missing header included by this patch provides declarations for the functions 'vm_event_{fill_regs,set_registers,monitor_next_interrupt}' that are defined in the source file. This also resolves violations of MISRA C:2012 Rule 8.4.

Fixes adc75eba8b15 ("x86/vm_event: consolidate hvm_event_fill_regs and p2m_vm_event_fill_regs")
Fixes 975efd3baa8d ("introduce VM_EVENT_FLAG_SET_REGISTERS")
Fixes 9864841914c2 ("x86/vm_event: add support for VM_EVENT_REASON_INTERRUPT")
Quoted 7 lines
Quoted 2 lines

It's hard to see how it can be three commit here. The oldest one is at fault, I would say.

Since the patch is concerned with more than one function then in a sense I agree
with you (the headers should have been included in the proper way the first time around), but
then more definitions have been added by adc75eba8b15 and 9864841914c2, and these should have
triggered a refactoring too. I can leave just 975efd3baa8d in the Fixes if the preferred way is to list just the first problematic commit (perhaps with a little explanation after --- ).

To be honest, I don't exactly see the value of using Fixes tag for those patches. I agree they are technically issues, but they are unlikely going to be backported.

Quoted 6 lines

So if it were me, I would just drop all the Fixes tags for missing includes unless there is an actual bug associated
with them (e.g. a caller was miscalling the function because the prototype was incorrect).

Cheers,

Adding those tags for this kind of situation was requested on the previous discussion [1], so in this series I kept the same strategy (though probably here I put too many of them).

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

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

Re: [XEN PATCH 3/6] x86/vm_event: add missing include

In reply to Nicola Vetrini

CC-ing the missing maintainers here, both from x86 and vm_event

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

Re: [XEN PATCH 3/6] x86/vm_event: add missing include

In reply to Nicola Vetrini

Hi Nicola,

Quoted 33 lines · Nicola Vetrini
Quoted 32 lines · Julien Grall

Hi,

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

The missing header included by this patch provides declarations for the functions 'vm_event_{fill_regs,set_registers,monitor_next_interrupt}' that are defined in the source file. This also resolves violations of MISRA C:2012 Rule 8.4.

Fixes adc75eba8b15 ("x86/vm_event: consolidate hvm_event_fill_regs and p2m_vm_event_fill_regs")
Fixes 975efd3baa8d ("introduce VM_EVENT_FLAG_SET_REGISTERS")
Fixes 9864841914c2 ("x86/vm_event: add support for VM_EVENT_REASON_INTERRUPT")
Quoted 7 lines
Quoted 2 lines

It's hard to see how it can be three commit here. The oldest one is at fault, I would say.

Since the patch is concerned with more than one function then in a sense I agree
with you (the headers should have been included in the proper way the first time around), but
then more definitions have been added by adc75eba8b15 and 9864841914c2, and these should have
triggered a refactoring too. I can leave just 975efd3baa8d in the Fixes if the preferred way is to list just the first problematic commit (perhaps with a little explanation after --- ).

To be honest, I don't exactly see the value of using Fixes tag for those patches. I agree they are technically issues, but they are unlikely going to be backported.

So if it were me, I would just drop all the Fixes tags for missing includes unless there is an actual bug associated
with them (e.g. a caller was miscalling the function because the prototype was incorrect).

Quoted 4 lines
Quoted 1 line

Cheers,

Adding those tags for this kind of situation was requested on the previous discussion [1], so in this series I kept the same strategy (though probably here I put too many of them).

I disagree with the suggestion made. They are just noise for this sort of patch and require extra digging (I assume you spent 10-15min to figure out the multiple fixes) for a limited benefits (I don't expect anyone to backport the patches).

Cheers,

Signature · 1 line
Julien Grall
#19 lore raw

Re: [XEN PATCH 3/6] x86/vm_event: add missing include

Quoted 51 lines · Julien Grall

Hi Nicola,

Quoted 41 lines · Nicola Vetrini
Quoted 40 lines · Julien Grall

Hi,

Quoted 18 lines · Nicola Vetrini
Quoted 14 lines · Jan Beulich
Quoted 6 lines · Nicola Vetrini

The missing header included by this patch provides declarations for the functions 'vm_event_{fill_regs,set_registers,monitor_next_interrupt}' that are defined in the source file. This also resolves violations of MISRA C:2012 Rule 8.4.

Quoted 6 lines
Fixes adc75eba8b15 ("x86/vm_event: consolidate hvm_event_fill_regs

and p2m_vm_event_fill_regs")

Fixes 975efd3baa8d ("introduce VM_EVENT_FLAG_SET_REGISTERS")
Fixes 9864841914c2 ("x86/vm_event: add support for

VM_EVENT_REASON_INTERRUPT")

Quoted 2 lines

It's hard to see how it can be three commit here. The oldest one is at fault, I would say.

Quoted 9 lines

Since the patch is concerned with more than one function then in a sense I agree
with you (the headers should have been included in the proper way the first time around), but
then more definitions have been added by adc75eba8b15 and 9864841914c2, and these should have
triggered a refactoring too. I can leave just 975efd3baa8d in the Fixes if the preferred way is to list just the first problematic commit (perhaps with a little explanation after --- ).

To be honest, I don't exactly see the value of using Fixes tag for those patches. I agree they are technically issues, but they are unlikely going to be backported.

So if it were me, I would just drop all the Fixes tags for missing includes unless there is an actual bug associated
with them (e.g. a caller was miscalling the function because the prototype was incorrect).

Quoted 6 lines
Quoted 1 line

Cheers,

Adding those tags for this kind of situation was requested on the previous discussion [1],
so in this series I kept the same strategy (though probably here I put too many of them).

Quoted 4 lines

I disagree with the suggestion made. They are just noise for this sort of patch and require extra digging (I assume you spent 10-15min to figure out the multiple fixes) for a limited benefits (I don't expect anyone to backport the patches).

While I agree that Fixes: is primarily for marking of backporting candidates, I don't think this is its exclusive purpose. As far as I'm concerned, it also aids review in the specific cases here (this isn't a commonly occurring aspect, though, I agree). Yet the primary reason I asked for them to be added is because each of the omissions is an at least latent bug.

Jan

#20 lore raw

Re: [XEN PATCH 3/6] x86/vm_event: add missing include

Hi Jan,

Quoted 57 lines · Jan Beulich
Quoted 51 lines · Julien Grall

Hi Nicola,

Quoted 41 lines · Nicola Vetrini
Quoted 40 lines · Julien Grall

Hi,

Quoted 18 lines · Nicola Vetrini
Quoted 14 lines · Jan Beulich
Quoted 6 lines · Nicola Vetrini

The missing header included by this patch provides declarations for the functions 'vm_event_{fill_regs,set_registers,monitor_next_interrupt}' that are defined in the source file. This also resolves violations of MISRA C:2012 Rule 8.4.

Quoted 6 lines
Fixes adc75eba8b15 ("x86/vm_event: consolidate hvm_event_fill_regs

and p2m_vm_event_fill_regs")

Fixes 975efd3baa8d ("introduce VM_EVENT_FLAG_SET_REGISTERS")
Fixes 9864841914c2 ("x86/vm_event: add support for

VM_EVENT_REASON_INTERRUPT")

Quoted 2 lines

It's hard to see how it can be three commit here. The oldest one is at fault, I would say.

Quoted 9 lines

Since the patch is concerned with more than one function then in a sense I agree
with you (the headers should have been included in the proper way the first time around), but
then more definitions have been added by adc75eba8b15 and 9864841914c2, and these should have
triggered a refactoring too. I can leave just 975efd3baa8d in the Fixes if the preferred way is to list just the first problematic commit (perhaps with a little explanation after --- ).

To be honest, I don't exactly see the value of using Fixes tag for those patches. I agree they are technically issues, but they are unlikely going to be backported.

So if it were me, I would just drop all the Fixes tags for missing includes unless there is an actual bug associated
with them (e.g. a caller was miscalling the function because the prototype was incorrect).

Quoted 6 lines
Quoted 1 line

Cheers,

Adding those tags for this kind of situation was requested on the previous discussion [1],
so in this series I kept the same strategy (though probably here I put too many of them).

Quoted 4 lines

I disagree with the suggestion made. They are just noise for this sort of patch and require extra digging (I assume you spent 10-15min to figure out the multiple fixes) for a limited benefits (I don't expect anyone to backport the patches).

Quoted 6 lines

While I agree that Fixes: is primarily for marking of backporting candidates, I don't think this is its exclusive purpose. As far as I'm concerned, it also aids review in the specific cases here (this isn't a commonly occurring aspect, though, I agree). Yet the primary reason I asked for them to be added is because each of the omissions is an at least latent bug.

I agree they are latent bugs. But the question is whether the time looking up the histoy is well spent?

In this situation, we have a lot of of similar patches where we need to add Fixes. So there is quite a bit of time sinked into finding the original commit message. Is it valuable? I don't believe so.

A least for Arm, I would not require the tag to be added for any missing prototypes.

Cheers,

Signature · 1 line
Julien Grall