xen: Misc MISRA changes
cover xen: Misc MISRA changes
Misc fixes collected during today's call.
Andrew Cooper (3):
xen/lzo: Implement COPY{4,8} using memcpy() xen/x86: Drop useless non-Kconfig CONFIG_* variables xen/x86: Address two misc MISRA 17.7 violations
xen/arch/x86/alternative.c | 4 ++-- xen/arch/x86/include/asm/config.h | 4 ---- xen/arch/x86/nmi.c | 5 ++--- xen/common/lzo.c | 11 ++--------- xen/include/xen/acpi.h | 9 --------- xen/include/xen/watchdog.h | 13 +------------ 6 files changed, 7 insertions(+), 39 deletions(-)
base-commit: 26b122e3bf8f3921d87312fbf5e7e13872ae92b0
Signature · 1 line
2.30.2
PATCH 1/3 xen/lzo: Implement COPY{4,8} using memcpy()
This is simpler and easier for both humans and compilers to read.
It also addresses 6 instances of MISRA R5.3 violation (shadowing of the ptr_ local variable inside both {put,get}_unaligned()).
No change, not even in the compiled binary.
---
CC: George Dunlap <[email protected]>
CC: Jan Beulich <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Julien Grall <[email protected]>
CC: Roberto Bagnara <[email protected]>
CC: [email protected] <[email protected]>
CC: Oleksii Kurochko <[email protected]>
--- xen/common/lzo.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-)
xen/common/lzo.c +2 -9
@@ -25,15 +25,8 @@*/ -#define COPY4 (dst, src) \ - put_unaligned(get_unaligned((const u32 *)(src)), (u32 *)(dst)) -#if defined(__x86_64__) -#define COPY8 (dst, src) \ - put_unaligned(get_unaligned((const u64 *)(src)), (u64 *)(dst)) -#else -#define COPY8 (dst, src) \ - COPY4(dst, src); COPY4((dst) + 4, (src) + 4) -#endif +#define COPY4 (dst, src) memcpy(dst, src, 4) +#define COPY8 (dst, src) memcpy(dst, src, 8)#ifdef __MINIOS__# include <lib.h>
Signature · 1 line
2.30.2
Re: [PATCH 1/3] xen/lzo: Implement COPY{4,8} using memcpy()
Quoted 8 lines · Andrew Cooper
This is simpler and easier for both humans and compilers to read.
It also addresses 6 instances of MISRA R5.3 violation (shadowing of the
ptr_local variable inside both {put,get}_unaligned()).No change, not even in the compiled binary.
Signed-off-by Andrew Cooper <[email protected]>
Quoted 37 lines
---
CC: George Dunlap <[email protected]>
CC: Jan Beulich <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Julien Grall <[email protected]>
CC: Roberto Bagnara <[email protected]>
CC: [email protected] <[email protected]>
CC: Oleksii Kurochko <[email protected]>--- xen/common/lzo.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-)xen/common/lzo.c +2
-9@@ -25,15 +25,8 @@*/ -#define COPY4 (dst, src) \ - put_unaligned(get_unaligned((const u32 *)(src)), (u32 *)(dst)) -#if defined(__x86_64__) -#define COPY8 (dst, src) \ - put_unaligned(get_unaligned((const u64 *)(src)), (u64 *)(dst)) -#else -#define COPY8 (dst, src) \ - COPY4(dst, src); COPY4((dst) + 4, (src) + 4) -#endif +#define COPY4 (dst, src) memcpy(dst, src, 4) +#define COPY8 (dst, src) memcpy(dst, src, 8)#ifdef __MINIOS__# include <lib.h> Signature · 1 line
2.30.2
PATCH 2/3 xen/x86: Drop useless non-Kconfig CONFIG_* variables
In reply to Andrew CooperThese are all either completely unused, or do nothing useful.
---
CC: George Dunlap <[email protected]>
CC: Jan Beulich <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Julien Grall <[email protected]>
CC: Roberto Bagnara <[email protected]>
CC: [email protected] <[email protected]>
CC: Oleksii Kurochko <[email protected]>
--- xen/arch/x86/include/asm/config.h | 4 ---- xen/include/xen/acpi.h | 9 --------- xen/include/xen/watchdog.h | 11 ----------- 3 files changed, 24 deletions(-)
xen/arch/x86/include/asm/config.h +0 -4
@@ -20,7 +20,6 @@#define BITS_PER_XEN_ULONG BITS_PER_LONG#define CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS 1 -#define CONFIG_DISCONTIGMEM 1#define CONFIG_NUMA_EMU 1#define CONFIG_PAGEALLOC_MAX_ORDER (2 * PAGETABLE_ORDER)
@@ -30,11 +29,8 @@/* Intel P4 currently has largest cache line (L2 line size is 128 bytes). */ #define CONFIG_X86_L1_CACHE_SHIFT 7 -#define CONFIG_ACPI_SRAT 1#define CONFIG_ACPI_CSTATE 1 -#define CONFIG_WATCHDOG 1 -#define CONFIG_MULTIBOOT 1#define HZ 100
xen/include/xen/acpi.h +0 -9
@@ -140,15 +140,6 @@ int get_cpu_id(u32 acpi_id);unsigned int acpi_register_gsi (u32 gsi,int edge_level,int active_high_low);int acpi_gsi_to_irq (u32 gsi,unsigned int *irq); -/* -* This function undoes the effect of one call to acpi_register_gsi(). -* If this matches the last registration, any IRQ resources for gsi -* are freed. -*/ -#ifdef CONFIG_ACPI_DEALLOCATE_IRQ -void acpi_unregister_gsi (u32 gsi); -#endif -#ifdef CONFIG_ACPI_CSTATE /* * max_cstate sets the highest legal C-state.
xen/include/xen/watchdog.h +0 -11
@@ -9,8 +9,6 @@#include <xen/types.h> -#ifdef CONFIG_WATCHDOG -/* Try to set up a watchdog. */ int watchdog_setup (void );
@@ -23,13 +21,4 @@ void watchdog_disable(void);/* Is the watchdog currently enabled. */ bool watchdog_enabled (void ); -#else - -#define watchdog_setup () ((void)0) -#define watchdog_enable () ((void)0) -#define watchdog_disable () ((void)0) -#define watchdog_enabled () ((void)0) - -#endif -#endif /* __XEN_WATCHDOG_H__ */
Signature · 1 line
2.30.2
Re: [PATCH 2/3] xen/x86: Drop useless non-Kconfig CONFIG_* variables
Quoted 3 lines · Andrew Cooper
These are all either completely unused, or do nothing useful.
Signed-off-by Andrew Cooper <[email protected]>
Quoted 88 lines
---
CC: George Dunlap <[email protected]>
CC: Jan Beulich <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Julien Grall <[email protected]>
CC: Roberto Bagnara <[email protected]>
CC: [email protected] <[email protected]>
CC: Oleksii Kurochko <[email protected]>--- xen/arch/x86/include/asm/config.h | 4 ---- xen/include/xen/acpi.h | 9 --------- xen/include/xen/watchdog.h | 11 ----------- 3 files changed, 24 deletions(-)xen/arch/x86/include/asm/config.h +0
-4@@ -20,7 +20,6 @@#define BITS_PER_XEN_ULONG BITS_PER_LONG#define CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS 1 -#define CONFIG_DISCONTIGMEM 1#define CONFIG_NUMA_EMU 1#define CONFIG_PAGEALLOC_MAX_ORDER (2 * PAGETABLE_ORDER)@@ -30,11 +29,8 @@/* Intel P4 currently has largest cache line (L2 line size is 128 bytes). */ #define CONFIG_X86_L1_CACHE_SHIFT 7 -#define CONFIG_ACPI_SRAT 1#define CONFIG_ACPI_CSTATE 1 -#define CONFIG_WATCHDOG 1 -#define CONFIG_MULTIBOOT 1#define HZ 100xen/include/xen/acpi.h +0
-9@@ -140,15 +140,6 @@ int get_cpu_id(u32 acpi_id);unsigned int acpi_register_gsi (u32 gsi,int edge_level,int active_high_low);int acpi_gsi_to_irq (u32 gsi,unsigned int *irq); -/* -* This function undoes the effect of one call to acpi_register_gsi(). -* If this matches the last registration, any IRQ resources for gsi -* are freed. -*/ -#ifdef CONFIG_ACPI_DEALLOCATE_IRQ -void acpi_unregister_gsi (u32 gsi); -#endif -#ifdef CONFIG_ACPI_CSTATE /* * max_cstate sets the highest legal C-state. xen/include/xen/watchdog.h +0
-11@@ -9,8 +9,6 @@#include <xen/types.h> -#ifdef CONFIG_WATCHDOG -/* Try to set up a watchdog. */ int watchdog_setup (void );@@ -23,13 +21,4 @@ void watchdog_disable(void);/* Is the watchdog currently enabled. */ bool watchdog_enabled (void ); -#else - -#define watchdog_setup () ((void)0) -#define watchdog_enable () ((void)0) -#define watchdog_disable () ((void)0) -#define watchdog_enabled () ((void)0) - -#endif -#endif /* __XEN_WATCHDOG_H__ */ Signature · 1 line
2.30.2
Re: [PATCH 2/3] xen/x86: Drop useless non-Kconfig CONFIG_* variables
In reply to Andrew CooperQuoted 3 lines · Andrew Cooper
These are all either completely unused, or do nothing useful.
Signed-off-by Andrew Cooper <[email protected]>
Not an objection, i.e. you're fine to commit as is with Stefano's R-b, yet still a question:
xen/arch/x86/include/asm/config.h line 36
Quoted 8 lines
xen/arch/x86/include/asm/config.h +0
-2@@ -30,11 +29,8 @@/* Intel P4 currently has largest cache line (L2 line size is 128 bytes). */ #define CONFIG_X86_L1_CACHE_SHIFT 7 -#define CONFIG_ACPI_SRAT 1#define CONFIG_ACPI_CSTATE 1 -#define CONFIG_WATCHDOG 1
I wonder if this wouldn't make sense to become a proper Kconfig setting, thus ...
Quoted 13 lines
xen/include/xen/watchdog.h +0
-2@@ -9,8 +9,6 @@#include <xen/types.h> -#ifdef CONFIG_WATCHDOG -/* Try to set up a watchdog. */ int watchdog_setup (void );@@ -23,13 +21,4 @@ void watchdog_disable(void);/* Is the watchdog currently enabled. */
xen/include/xen/watchdog.h void watchdog_disable(void); · line 33
Quoted 10 lines
xen/include/xen/watchdog.h +0
-8bool watchdog_enabled (void ); -#else - -#define watchdog_setup () ((void)0) -#define watchdog_enable () ((void)0) -#define watchdog_disable () ((void)0) -#define watchdog_enabled () ((void)0) - -#endif
... assigning purpose to these stubs.
Jan
Re: [PATCH 2/3] xen/x86: Drop useless non-Kconfig CONFIG_* variables
Quoted 33 lines · Jan Beulich
Quoted 3 lines · Andrew Cooper
These are all either completely unused, or do nothing useful.
Signed-off-by Andrew Cooper <[email protected]>Not an objection, i.e. you're fine to commit as is with Stefano's R-b, yet still a question:
xen/arch/x86/include/asm/config.h line 36
Quoted 8 lines
xen/arch/x86/include/asm/config.h +0
-2@@ -30,11 +29,8 @@/* Intel P4 currently has largest cache line (L2 line size is 128 bytes). */ #define CONFIG_X86_L1_CACHE_SHIFT 7 -#define CONFIG_ACPI_SRAT 1#define CONFIG_ACPI_CSTATE 1 -#define CONFIG_WATCHDOG 1I wonder if this wouldn't make sense to become a proper
Kconfigsetting, thus ...Quoted 15 lines
xen/include/xen/watchdog.h +0
-2@@ -9,8 +9,6 @@#include <xen/types.h> -#ifdef CONFIG_WATCHDOG -/* Try to set up a watchdog. */ int watchdog_setup (void );@@ -23,13 +21,4 @@ void watchdog_disable(void);/* Is the watchdog currently enabled. */ bool watchdog_enabled (void );
Quoted 9 lines
xen/include/xen/watchdog.h void watchdog_disable(void); · line 33
Quoted 8 lines
xen/include/xen/watchdog.h +0
-8-#else - -#define watchdog_setup () ((void)0) -#define watchdog_enable () ((void)0) -#define watchdog_disable () ((void)0) -#define watchdog_enabled () ((void)0) - -#endif ... assigning purpose to these stubs.
Actually I need to keep CONFIG_WATCHDOG to not break the build on other architectures.
watchdog_{en,dis}able() are called from common/{debugtrace,keyhandler}.c.
I'll leave it in place for now, and we can Kconfig it up later.
~Andrew
PATCH 3/3 xen/x86: Address two misc MISRA 17.7 violations
In reply to Andrew CooperNeither text_poke() nor watchdog_setup() have return value consulted. Switch them to being void.
---
CC: George Dunlap <[email protected]>
CC: Jan Beulich <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Julien Grall <[email protected]>
CC: Roberto Bagnara <[email protected]>
CC: [email protected] <[email protected]>
CC: Oleksii Kurochko <[email protected]>
--- xen/arch/x86/alternative.c | 4 ++-- xen/arch/x86/nmi.c | 5 ++--- xen/include/xen/watchdog.h | 2 +- 3 files changed, 5 insertions(+), 6 deletions(-)
xen/arch/x86/alternative.c +2 -2
@@ -155,10 +155,10 @@ void init_or_livepatch add_nops(void *insns, unsigned int len)* "noinline" to cause control flow change and thus invalidate I$ and * cause refetch after modification. */ -static void *init_or_livepatch noinline +static void init_or_livepatch noinlinetext_poke (void *addr,const void *opcode,size_t len) { -return memcpy (addr, opcode, len); +memcpy (addr, opcode, len); }extern void *const __initdata_cf_clobber_start[];
xen/arch/x86/nmi.c +2 -3
@@ -464,12 +464,12 @@ bool watchdog_enabled(void)return !atomic_read (&watchdog_disable_count); } -int __init watchdog_setup (void ) +void __init watchdog_setup (void ) {unsigned int cpu;/* -* Activate periodic heartbeats. We cannot do this earlier during +* Activate periodic heartbeats. We cannot do this earlier during * setup because the timer infrastructure is not available. */ for_each_online_cpu ( cpu )
@@ -477,7 +477,6 @@ int __init watchdog_setup(void)register_cpu_notifier (&cpu_nmi_nfb);watchdog_enable (); -return 0 ; }/* Returns false if this was not a watchdog NMI, true otherwise */
xen/include/xen/watchdog.h +1 -1
@@ -10,7 +10,7 @@#include <xen/types.h> /* Try to set up a watchdog. */ -int watchdog_setup (void ); +void watchdog_setup (void );/* Enable the watchdog. */ void watchdog_enable (void );
Signature · 1 line
2.30.2
Re: [PATCH 3/3] xen/x86: Address two misc MISRA 17.7 violations
Quoted 4 lines · Andrew Cooper
Neither
text_poke()norwatchdog_setup()have return value consulted. Switch them to being void.Signed-off-by Andrew Cooper <[email protected]>
Quoted 74 lines
---
CC: George Dunlap <[email protected]>
CC: Jan Beulich <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Julien Grall <[email protected]>
CC: Roberto Bagnara <[email protected]>
CC: [email protected] <[email protected]>
CC: Oleksii Kurochko <[email protected]>--- xen/arch/x86/alternative.c | 4 ++-- xen/arch/x86/nmi.c | 5 ++--- xen/include/xen/watchdog.h | 2 +- 3 files changed, 5 insertions(+), 6 deletions(-)xen/arch/x86/alternative.c +2
-2@@ -155,10 +155,10 @@ void init_or_livepatch add_nops(void *insns, unsigned int len)* "noinline" to cause control flow change and thus invalidate I$ and * cause refetch after modification. */ -static void *init_or_livepatch noinline +static void init_or_livepatch noinlinetext_poke (void *addr,const void *opcode,size_t len) { -return memcpy (addr, opcode, len); +memcpy (addr, opcode, len); }extern void *const __initdata_cf_clobber_start[];xen/arch/x86/nmi.c +2
-3@@ -464,12 +464,12 @@ bool watchdog_enabled(void)return !atomic_read (&watchdog_disable_count); } -int __init watchdog_setup (void ) +void __init watchdog_setup (void ) {unsigned int cpu;/* -* Activate periodic heartbeats. We cannot do this earlier during +* Activate periodic heartbeats. We cannot do this earlier during * setup because the timer infrastructure is not available. */ for_each_online_cpu ( cpu )@@ -477,7 +477,6 @@ int __init watchdog_setup(void)register_cpu_notifier (&cpu_nmi_nfb);watchdog_enable (); -return 0 ; }/* Returns false if this was not a watchdog NMI, true otherwise */ xen/include/xen/watchdog.h +1
-1@@ -10,7 +10,7 @@#include <xen/types.h> /* Try to set up a watchdog. */ -int watchdog_setup (void ); +void watchdog_setup (void );/* Enable the watchdog. */ void watchdog_enable (void );Signature · 1 line
2.30.2
Hi Andrew,
We can consider this patch series to be in Xen 4.19:
~ Oleksii
Quoted 17 lines · Andrew Cooper
Misc fixes collected during today's call.
Andrew Cooper (3):
xen/lzo: Implement COPY{4,8} usingmemcpy()xen/x86: Drop useless non-Kconfig CONFIG_* variables xen/x86: Address two misc MISRA 17.7 violationsxen/arch/x86/alternative.c | 4 ++--
xen/arch/x86/include/asm/config.h| 4 ---- xen/arch/x86/nmi.c | 5 ++--- xen/common/lzo.c | 11 ++--------- xen/include/xen/acpi.h | 9 --------- xen/include/xen/watchdog.h | 13 +------------6 files changed, 7 insertions(+), 39 deletions(-)base-commit:
26b122e3bf8f3921d87312fbf5e7e13872ae92b0
Quoted 1 line · Andrew Cooper
Misc fixes collected during today's call.
Quoted 16 lines
Andrew Cooper (3):
xen/lzo: Implement COPY{4,8} usingmemcpy()xen/x86: Drop useless non-Kconfig CONFIG_* variables xen/x86: Address two misc MISRA 17.7 violationsxen/arch/x86/alternative.c | 4 ++--
xen/arch/x86/include/asm/config.h| 4 ---- xen/arch/x86/nmi.c | 5 ++--- xen/common/lzo.c | 11 ++--------- xen/include/xen/acpi.h | 9 --------- xen/include/xen/watchdog.h | 13 +------------6 files changed, 7 insertions(+), 39 deletions(-)base-commit:
26b122e3bf8f3921d87312fbf5e7e13872ae92b0