diff mbox series

x86/pmstat: deal with Misra 8.4 violations

Message ID 06b4f2c5-8470-4375-9311-c31921d7aaa8@suse.com (mailing list archive)
State New
Headers show
Series x86/pmstat: deal with Misra 8.4 violations | expand

Commit Message

Jan Beulich Nov. 19, 2024, 8:12 a.m. UTC
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>

Comments

Andrew Cooper Nov. 19, 2024, 10:30 a.m. UTC | #1
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
Andrew Cooper Nov. 19, 2024, 10:55 a.m. UTC | #2
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
Andrew Cooper Nov. 19, 2024, 12:04 p.m. UTC | #3
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>
diff mbox series

Patch

--- 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);