[PATCH] x86/pmstat: deal with Misra 8.4 violations

Jan Beulich posted 1 patch 2 weeks, 3 days ago
Failed in applying to current master (apply log)
[PATCH] x86/pmstat: deal with Misra 8.4 violations
Posted by Jan Beulich 2 weeks, 3 days ago
While the override #define-s in x86_64/platform_hypercall.c are good for
the consuming side of the compat variants of set_{cx,px}_pminfo(), the
producers lack the respective declarations. Include pmstat.h early,
before the overrides are put in place, while adding explicit
declarations of the compat functions (alongside structure forward
declarations).

Reported-by: Andrew Cooper <andrew.cooper3@citrix.com>
Signed-off-by: Jan Beulich <jbeulich@suse.com>

--- a/xen/arch/x86/x86_64/platform_hypercall.c
+++ b/xen/arch/x86/x86_64/platform_hypercall.c
@@ -4,8 +4,8 @@
 
 EMIT_FILE;
 
-#include <xen/lib.h>
 #include <xen/hypercall.h>
+#include <xen/pmstat.h>
 
 #define xen_platform_op     compat_platform_op
 #define xen_platform_op_t   compat_platform_op_t
--- a/xen/include/xen/pmstat.h
+++ b/xen/include/xen/pmstat.h
@@ -7,6 +7,12 @@
 
 int set_px_pminfo(uint32_t acpi_id, struct xen_processor_performance *perf);
 long set_cx_pminfo(uint32_t acpi_id, struct xen_processor_power *power);
+#ifdef CONFIG_COMPAT
+struct compat_processor_performance;
+int compat_set_px_pminfo(uint32_t acpi_id, struct compat_processor_performance *perf);
+struct compat_processor_power;
+long compat_set_cx_pminfo(uint32_t acpi_id, struct compat_processor_power *power);
+#endif
 uint32_t pmstat_get_cx_nr(unsigned int cpu);
 int pmstat_get_cx_stat(unsigned int cpu, struct pm_cx_stat *stat);
 int pmstat_reset_cx_stat(unsigned int cpu);
Re: [PATCH] x86/pmstat: deal with Misra 8.4 violations
Posted by Andrew Cooper 2 weeks, 3 days ago
On 19/11/2024 8:12 am, Jan Beulich wrote:
> While the override #define-s in x86_64/platform_hypercall.c are good for
> the consuming side of the compat variants of set_{cx,px}_pminfo(), the
> producers lack the respective declarations. Include pmstat.h early,
> before the overrides are put in place, while adding explicit
> declarations of the compat functions (alongside structure forward
> declarations).
>
> Reported-by: Andrew Cooper <andrew.cooper3@citrix.com>
> Signed-off-by: Jan Beulich <jbeulich@suse.com>
>
> --- a/xen/arch/x86/x86_64/platform_hypercall.c
> +++ b/xen/arch/x86/x86_64/platform_hypercall.c
> @@ -4,8 +4,8 @@
>  
>  EMIT_FILE;
>  
> -#include <xen/lib.h>
>  #include <xen/hypercall.h>
> +#include <xen/pmstat.h>
>  
>  #define xen_platform_op     compat_platform_op
>  #define xen_platform_op_t   compat_platform_op_t
> --- a/xen/include/xen/pmstat.h
> +++ b/xen/include/xen/pmstat.h
> @@ -7,6 +7,12 @@
>  
>  int set_px_pminfo(uint32_t acpi_id, struct xen_processor_performance *perf);
>  long set_cx_pminfo(uint32_t acpi_id, struct xen_processor_power *power);
> +#ifdef CONFIG_COMPAT
> +struct compat_processor_performance;
> +int compat_set_px_pminfo(uint32_t acpi_id, struct compat_processor_performance *perf);
> +struct compat_processor_power;
> +long compat_set_cx_pminfo(uint32_t acpi_id, struct compat_processor_power *power);
> +#endif
>  uint32_t pmstat_get_cx_nr(unsigned int cpu);
>  int pmstat_get_cx_stat(unsigned int cpu, struct pm_cx_stat *stat);
>  int pmstat_reset_cx_stat(unsigned int cpu);
>

Thanks for the patch.  I'll give it a spin along with the other 8.4 fixes.

~Andrew

Re: [PATCH] x86/pmstat: deal with Misra 8.4 violations
Posted by Andrew Cooper 2 weeks, 3 days ago
On 19/11/2024 10:30 am, Andrew Cooper wrote:
> On 19/11/2024 8:12 am, Jan Beulich wrote:
>> While the override #define-s in x86_64/platform_hypercall.c are good for
>> the consuming side of the compat variants of set_{cx,px}_pminfo(), the
>> producers lack the respective declarations. Include pmstat.h early,
>> before the overrides are put in place, while adding explicit
>> declarations of the compat functions (alongside structure forward
>> declarations).
>>
>> Reported-by: Andrew Cooper <andrew.cooper3@citrix.com>
>> Signed-off-by: Jan Beulich <jbeulich@suse.com>
>>
>> --- a/xen/arch/x86/x86_64/platform_hypercall.c
>> +++ b/xen/arch/x86/x86_64/platform_hypercall.c
>> @@ -4,8 +4,8 @@
>>  
>>  EMIT_FILE;
>>  
>> -#include <xen/lib.h>
>>  #include <xen/hypercall.h>
>> +#include <xen/pmstat.h>
>>  
>>  #define xen_platform_op     compat_platform_op
>>  #define xen_platform_op_t   compat_platform_op_t
>> --- a/xen/include/xen/pmstat.h
>> +++ b/xen/include/xen/pmstat.h
>> @@ -7,6 +7,12 @@
>>  
>>  int set_px_pminfo(uint32_t acpi_id, struct xen_processor_performance *perf);
>>  long set_cx_pminfo(uint32_t acpi_id, struct xen_processor_power *power);
>> +#ifdef CONFIG_COMPAT
>> +struct compat_processor_performance;
>> +int compat_set_px_pminfo(uint32_t acpi_id, struct compat_processor_performance *perf);
>> +struct compat_processor_power;
>> +long compat_set_cx_pminfo(uint32_t acpi_id, struct compat_processor_power *power);
>> +#endif
>>  uint32_t pmstat_get_cx_nr(unsigned int cpu);
>>  int pmstat_get_cx_stat(unsigned int cpu, struct pm_cx_stat *stat);
>>  int pmstat_reset_cx_stat(unsigned int cpu);
>>
> Thanks for the patch.  I'll give it a spin along with the other 8.4 fixes.

https://gitlab.com/xen-project/people/andyhhp/xen/-/pipelines/1550621091
pending to run, with all 8.4 fixes including a prototype fix for the
do_mca() issue too.

~Andrew

Re: [PATCH] x86/pmstat: deal with Misra 8.4 violations
Posted by Andrew Cooper 2 weeks, 3 days ago
On 19/11/2024 10:55 am, Andrew Cooper wrote:
> On 19/11/2024 10:30 am, Andrew Cooper wrote:
>> On 19/11/2024 8:12 am, Jan Beulich wrote:
>>> While the override #define-s in x86_64/platform_hypercall.c are good for
>>> the consuming side of the compat variants of set_{cx,px}_pminfo(), the
>>> producers lack the respective declarations. Include pmstat.h early,
>>> before the overrides are put in place, while adding explicit
>>> declarations of the compat functions (alongside structure forward
>>> declarations).
>>>
>>> Reported-by: Andrew Cooper <andrew.cooper3@citrix.com>
>>> Signed-off-by: Jan Beulich <jbeulich@suse.com>
>>>
>>> --- a/xen/arch/x86/x86_64/platform_hypercall.c
>>> +++ b/xen/arch/x86/x86_64/platform_hypercall.c
>>> @@ -4,8 +4,8 @@
>>>  
>>>  EMIT_FILE;
>>>  
>>> -#include <xen/lib.h>
>>>  #include <xen/hypercall.h>
>>> +#include <xen/pmstat.h>
>>>  
>>>  #define xen_platform_op     compat_platform_op
>>>  #define xen_platform_op_t   compat_platform_op_t
>>> --- a/xen/include/xen/pmstat.h
>>> +++ b/xen/include/xen/pmstat.h
>>> @@ -7,6 +7,12 @@
>>>  
>>>  int set_px_pminfo(uint32_t acpi_id, struct xen_processor_performance *perf);
>>>  long set_cx_pminfo(uint32_t acpi_id, struct xen_processor_power *power);
>>> +#ifdef CONFIG_COMPAT
>>> +struct compat_processor_performance;
>>> +int compat_set_px_pminfo(uint32_t acpi_id, struct compat_processor_performance *perf);
>>> +struct compat_processor_power;
>>> +long compat_set_cx_pminfo(uint32_t acpi_id, struct compat_processor_power *power);
>>> +#endif
>>>  uint32_t pmstat_get_cx_nr(unsigned int cpu);
>>>  int pmstat_get_cx_stat(unsigned int cpu, struct pm_cx_stat *stat);
>>>  int pmstat_reset_cx_stat(unsigned int cpu);
>>>
>> Thanks for the patch.  I'll give it a spin along with the other 8.4 fixes.
> https://gitlab.com/xen-project/people/andyhhp/xen/-/pipelines/1550621091
> pending to run, with all 8.4 fixes including a prototype fix for the
> do_mca() issue too.

Eclair was happy with the result, so:

Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
Tested-by: Andrew Cooper <andrew.cooper3@citrix.com>