various ECLAIR and MISRA improvements
PATCH 4/4 x86/traps: address violation of MISRA C Rule 8.4
In reply to Nicola VetriniRule 8.4 states: "A compatible declaration shall be visible when an object or function with external linkage is defined".
The function do_general_protection is either used is asm code or only within this unit, so there is no risk of this getting out of sync with its definition, but the function must remain extern.
Therefore, this function is deviated using a comment-based deviation. No functional change.
--- xen/arch/x86/traps.c | 1 + 1 file changed, 1 insertion(+)
xen/arch/x86/traps.c +1 -0
@@ -1257,6 +1257,7 @@ void asmlinkage do_int3(struct cpu_user_regs *regs)pv_inject_hw_exception (X86_EXC_BP ,X86_EVENT_NO_EC ); } +/* SAF-1-safe */ void do_general_protection (struct cpu_user_regs *regs) {#ifdef CONFIG_PV
Signature · 1 line
2.34.1
cover various ECLAIR and MISRA improvements
Hi all,
this series contains various miscellaneous changes to the ECLAIR and deviations for MISRA rules
Nicola Vetrini (4):
docs/misra: exclude gdbsx from MISRA compliance automation/eclair_analysis: avoid an ECLAIR warning about escaping
x86: address violations of MISRA C Rule 8.4
x86/traps: address violation of MISRA C Rule 8.4
automation/eclair_analysis/ECLAIR/deviations.ecl | 4 ++-- docs/misra/exclude-list.json | 8 ++++++++ xen/arch/x86/desc.c | 1 + xen/arch/x86/mm.c | 2 +- xen/arch/x86/traps.c | 1 + 5 files changed, 13 insertions(+), 3 deletions(-)
Signature · 1 line
2.34.1
PATCH 1/4 docs/misra: exclude gdbsx from MISRA compliance
These files are used when debugging Xen, and are not meant to comply with MISRA rules at the moment.
No functional change.
--- docs/misra/exclude-list.json | 8 ++++++++ 1 file changed, 8 insertions(+)
docs/misra/exclude-list.json +8 -0
@@ -77,6 +77,14 @@ "rel_path": "arch/x86/dmi_scan.c", "comment": "Imported from Linux, ignore for now" }, + { + "rel_path": "arch/x86/gdbsx.c", + "comment": "Used for debugging Xen, ignore for now" + }, + { + "rel_path": "arch/x86/include/asm/gdbsx.h", + "comment": "Used for debugging Xen, ignore for now" + }, { "rel_path": "arch/x86/mpparse.c", "comment": "Imported from Linux, ignore for now"
Signature · 1 line
2.34.1
PATCH 2/4 automation/eclair_analysis: avoid an ECLAIR warning about escaping
In reply to Nicola VetriniThe parentheses in this regular expression should be doubly escaped because they are undergo escaping twice.
--- automation/eclair_analysis/ECLAIR/deviations.ecl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
automation/eclair_analysis/ECLAIR/deviations.ecl +2 -2
@@ -405,8 +405,8 @@ explicit comment indicating the fallthrough intention is present." # -doc_begin="printf()-like functions are allowed to use the variadic features provided by stdarg.h." --config=MC3R1.R17.1,reports+={deliberate,"any_area(^.*va_list.*$&&context(ancestor_or_self(^.*printk\(.*\)$)))"} --config=MC3R1.R17.1,reports+={deliberate,"any_area(^.*va_list.*$&&context(ancestor_or_self(^.*printf\(.*\)$)))"} +-config=MC3R1.R17.1,reports+={deliberate,"any_area(^.*va_list.*$&&context(ancestor_or_self(^.*printk\\(.*\\)$)))"} +-config=MC3R1.R17.1,reports+={deliberate,"any_area(^.*va_list.*$&&context(ancestor_or_self(^.*printf\\(.*\\)$)))"} -config=MC3R1.R17.1,reports+={deliberate,"any_area(^.*va_list.*$&&context(ancestor_or_self(name(panic)&&kind(function))))"} -config=MC3R1.R17.1,reports+={deliberate,"any_area(^.*va_list.*$&&context(ancestor_or_self(name(elf_call_log_callback)&&kind(function))))"} -config=MC3R1.R17.1,reports+={deliberate,"any_area(^.*va_list.*$&&context(ancestor_or_self(name(vprintk_common)&&kind(function))))"}
Signature · 1 line
2.34.1
PATCH 3/4 x86: address violations of MISRA C Rule 8.4
In reply to Nicola VetriniRule 8.4 states: "A compatible declaration shall be visible when an object or function with external linkage is defined."
These variables are only referenced from asm modules, so they need to be extern and there is negligible risk of them being used improperly without noticing.
As a result, they can be exempted using a comment-based deviation. No functional change.
---
Adding the asmlinkage macro to variables is not appropriate, as this pseudo-attribute may expand, for instance, to a different calling convention in the future (e.g. stdcall)
--- xen/arch/x86/desc.c | 1 + xen/arch/x86/mm.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-)
xen/arch/x86/desc.c +1 -0
@@ -91,6 +91,7 @@ seg_desc_t boot_compat_gdt[PAGE_SIZE / sizeof(seg_desc_t)] =* References boot_cpu_gdt_table for a short period, until the CPUs switch * onto their per-CPU GDTs. */ +/* SAF-1-safe */ const struct desc_ptr boot_gdtr = { .limit =LAST_RESERVED_GDT_BYTE , .base = (unsigned long )(boot_gdt -FIRST_RESERVED_GDT_ENTRY ),
xen/arch/x86/mm.c +1 -1
@@ -144,7 +144,7 @@ l1_pgentry_t __section(".bss.page_aligned") __aligned(PAGE_SIZE) l1_fixmap[L1_PAGETABLE_ENTRIES ]; l1_pgentry_t __section(".bss.page_aligned") __aligned(PAGE_SIZE) - l1_fixmap_x[L1_PAGETABLE_ENTRIES ]; + l1_fixmap_x[L1_PAGETABLE_ENTRIES ];/* SAF-1-safe */ bool __read_mostly machine_to_phys_mapping_valid;
Signature · 1 line
2.34.1
Re: [XEN PATCH 1/4] docs/misra: exclude gdbsx from MISRA compliance
In reply to Nicola VetriniQuoted 6 lines · Nicola Vetrini
These files are used when debugging Xen, and are not meant to comply with MISRA rules at the moment.
No functional change.
Signed-off-by Nicola Vetrini <[email protected]>
Re: [XEN PATCH 2/4] automation/eclair_analysis: avoid an ECLAIR warning about escaping
In reply to Nicola VetriniQuoted 2 lines · Nicola Vetrini
The parentheses in this regular expression should be doubly escaped because they are undergo escaping twice.
Do you maybe mean "undergo expansion twice"?
Jan
Quoted 20 lines
Signed-off-by Nicola Vetrini <[email protected]>--- automation/eclair_analysis/ECLAIR/deviations.ecl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)automation/eclair_analysis/ECLAIR/deviations.ecl +2
-2@@ -405,8 +405,8 @@ explicit comment indicating the fallthrough intention is present." # -doc_begin="printf()-like functions are allowed to use the variadic features provided by stdarg.h." --config=MC3R1.R17.1,reports+={deliberate,"any_area(^.*va_list.*$&&context(ancestor_or_self(^.*printk\(.*\)$)))"} --config=MC3R1.R17.1,reports+={deliberate,"any_area(^.*va_list.*$&&context(ancestor_or_self(^.*printf\(.*\)$)))"} +-config=MC3R1.R17.1,reports+={deliberate,"any_area(^.*va_list.*$&&context(ancestor_or_self(^.*printk\\(.*\\)$)))"} +-config=MC3R1.R17.1,reports+={deliberate,"any_area(^.*va_list.*$&&context(ancestor_or_self(^.*printf\\(.*\\)$)))"} -config=MC3R1.R17.1,reports+={deliberate,"any_area(^.*va_list.*$&&context(ancestor_or_self(name(panic)&&kind(function))))"} -config=MC3R1.R17.1,reports+={deliberate,"any_area(^.*va_list.*$&&context(ancestor_or_self(name(elf_call_log_callback)&&kind(function))))"} -config=MC3R1.R17.1,reports+={deliberate,"any_area(^.*va_list.*$&&context(ancestor_or_self(name(vprintk_common)&&kind(function))))"}
Stefano Stabellini
Acked-byRe: [XEN PATCH 2/4] automation/eclair_analysis: avoid an ECLAIR warning about escaping
Quoted 5 lines · Jan Beulich
Quoted 2 lines · Nicola Vetrini
The parentheses in this regular expression should be doubly escaped because they are undergo escaping twice.
Do you maybe mean "undergo expansion twice"?
Ahah yes. I fixed it on commit:
Quoted 21 lines
Quoted 20 lines
Signed-off-by Nicola Vetrini <[email protected]>--- automation/eclair_analysis/ECLAIR/deviations.ecl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)automation/eclair_analysis/ECLAIR/deviations.ecl +2
-2@@ -405,8 +405,8 @@ explicit comment indicating the fallthrough intention is present." # -doc_begin="printf()-like functions are allowed to use the variadic features provided by stdarg.h." --config=MC3R1.R17.1,reports+={deliberate,"any_area(^.*va_list.*$&&context(ancestor_or_self(^.*printk\(.*\)$)))"} --config=MC3R1.R17.1,reports+={deliberate,"any_area(^.*va_list.*$&&context(ancestor_or_self(^.*printf\(.*\)$)))"} +-config=MC3R1.R17.1,reports+={deliberate,"any_area(^.*va_list.*$&&context(ancestor_or_self(^.*printk\\(.*\\)$)))"} +-config=MC3R1.R17.1,reports+={deliberate,"any_area(^.*va_list.*$&&context(ancestor_or_self(^.*printf\\(.*\\)$)))"} -config=MC3R1.R17.1,reports+={deliberate,"any_area(^.*va_list.*$&&context(ancestor_or_self(name(panic)&&kind(function))))"} -config=MC3R1.R17.1,reports+={deliberate,"any_area(^.*va_list.*$&&context(ancestor_or_self(name(elf_call_log_callback)&&kind(function))))"} -config=MC3R1.R17.1,reports+={deliberate,"any_area(^.*va_list.*$&&context(ancestor_or_self(name(vprintk_common)&&kind(function))))"}
Re: [XEN PATCH 3/4] x86: address violations of MISRA C Rule 8.4
In reply to Nicola VetriniQuoted 6 lines · Nicola Vetrini
Rule 8.4 states: "A compatible declaration shall be visible when an object or function with external linkage is defined."
These variables are only referenced from asm modules, so they need to be extern and there is negligible risk of them being used improperly without noticing.
"asm modules" isn't quite correct, as there's one use from inline assembly. I have to admit I have no good wording suggestion other than explicitly covering both: "asm modules or inline assembly". Yet that then is ambiguous, as a use in inline assembly may also mean that symbol is actually visible to the compiler by being mentioned as on of the operands. Better ideas?
Quoted 4 lines
As a result, they can be exempted using a comment-based deviation. No functional change.
Signed-off-by Nicola Vetrini <[email protected]>
With suitably adjusted wording:
Jan
Re: [XEN PATCH 4/4] x86/traps: address violation of MISRA C Rule 8.4
In reply to Nicola VetriniQuoted 8 lines · Nicola Vetrini
Rule 8.4 states: "A compatible declaration shall be visible when an object or function with external linkage is defined".
The function
do_general_protectionis either used is asm code or only within this unit, so there is no risk of this getting out of sync with its definition, but the function must remain extern.
Quoted 4 lines
Therefore, this function is deviated using a comment-based deviation. No functional change.
Signed-off-by Nicola Vetrini <[email protected]>
Albeit here, too, I'm not entirely happy with the wording, but I'll let it go as is. While "there is no risk of this getting out of sync with its definition" is true for the C side, there's always the risk of assembly going out of sync with C, simply because the two cannot be properly connected by any means.
Jan
Re: [XEN PATCH 3/4] x86: address violations of MISRA C Rule 8.4
In reply to Jan BeulichQuoted 8 lines · Jan Beulich
Quoted 6 lines · Nicola Vetrini
Rule 8.4 states: "A compatible declaration shall be visible when an object or function with external linkage is defined."
These variables are only referenced from asm modules, so they need to be extern and there is negligible risk of them being used improperly without noticing.
Quoted 7 lines
"asm modules" isn't quite correct, as there's one use from inline assembly. I have to admit I have no good wording suggestion other than explicitly covering both: "asm modules or inline assembly". Yet that then is ambiguous, as a use in inline assembly may also mean that symbol is actually visible to the compiler by being mentioned as on of the operands. Better ideas?
Maybe generically "asm code" or just "asm"? It's not really relevant whether it's inline or not, as far as I understand.
Quoted 9 lines
Quoted 4 lines
As a result, they can be exempted using a comment-based deviation. No functional change.
Signed-off-by Nicola Vetrini <[email protected]>With suitably adjusted wording:
Acked-by Jan Beulich <[email protected]>Jan
Signature · 2 lines
Nicola Vetrini, BSc Software Engineer, BUGSENG srl (https://bugseng.com)