[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v2] misra: add deviation of Rule 2.1 for BUG() macro


  • To: Jan Beulich <jbeulich@xxxxxxxx>
  • From: Dmytro Prokopchuk1 <dmytro_prokopchuk1@xxxxxxxx>
  • Date: Tue, 16 Sep 2025 19:35:44 +0000
  • Accept-language: en-US, uk-UA, ru-RU
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=epam.com; dmarc=pass action=none header.from=epam.com; dkim=pass header.d=epam.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=XO9Ci9v8RoygCBNXTpGGWjmCTKLPTHUrEUbQDhQ1Dtc=; b=Wzf8IkEKjB8NB6QvQe/ih74P5ZidSGEk+tNCcG41nBam+hzxe3Ow7ByINwI7iDaWsW3OtBnQ/tINhg7hdoufIccRIPa240RFJLwA44Fo2wGCIJzjPibi3CfwpyN6SYeKr/9dcIWgNVFeencjdLbHWdLeafmy0ykRkW1VZJdjvf3EiyBnVxFLhpHTgBVzNXTOX5AqXbXiTSIZpCtPzGJAs7Tx7U4XaTyea5sExQSO3dyhPPdttOaR0b9ASNjyqTRXLyVJbTA7tnJ9dM6cMEldmYpX2dijRFuwVYm/9hZLgmXT2ZvoHdeTSttlvv5v5fcH+B73bdZjAuEVCK7Rel3b3A==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ouGrjqbScgE8Xjgw1XYz+XNpkj/CJehELmsBxI1P7mvlwxP18Mz1+yd4/E7gL//OmmXKh+LYbDr+AlgEX/NBvyhj8aYNHWy9fumCUO4wvzAXR3GYbAPyW4yV7xO+Dsrn3QBtuvUPL73c2RHPdjl+FRccWduFc/FXaJQUBWdSTTt5Pnr1cju5+/Hip61hrYhb5RroiGdcuFRz3zFdoAu/cLCzEKe/XQDjr4PWR8nwdmvrzisYwdZrBE/F+U/7Eh5nMJFJ1KO08fD1my504Hd00dBFDj688gTazpHfyLw63esKBEVVkJcWpcK1sjQv2GgLtMdmOzfZT11QegcVoXiCFA==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=epam.com;
  • Cc: Nicola Vetrini <nicola.vetrini@xxxxxxxxxxx>, Doug Goldstein <cardoe@xxxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Anthony PERARD <anthony.perard@xxxxxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, Julien Grall <julien@xxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Tue, 16 Sep 2025 19:36:07 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHcJwfEWjVU7vF+102YDgRq9OEY77SV3fSAgABWKoA=
  • Thread-topic: [PATCH v2] misra: add deviation of Rule 2.1 for BUG() macro


On 9/16/25 17:27, Jan Beulich wrote:
> On 16.09.2025 14:45, Dmytro Prokopchuk1 wrote:
>> --- a/docs/misra/deviations.rst
>> +++ b/docs/misra/deviations.rst
>> @@ -98,6 +98,23 @@ Deviations related to MISRA C:2012 Rules:
>>          even when debug-only assertions like `ASSERT_UNREACHABLE()` are 
>> removed.
>>        - ECLAIR has been configured to ignore those statements.
>>   
>> +   * - R2.1
>> +     - In the specific build configuration (when the config CONFIG_ACPI is 
>> not
>> +       defined) the 'BUG()' macro is intentionally used in the 
>> 'prepare_acpi()'
>> +       function in the header file 'xen/arch/arm/include/asm/domain_build.h'
>> +       defined as 'static inline' to trigger a runtime error if ACPI-related
>> +       features are used incorrectly.
>> +     - Tagged as `deliberate` for ECLAIR.
> 
> I response to me outlining a deviation-less alternative you tried it out
> and said it works. Then why is the deviation still being put in place?

Yes, that's true.
I started with that prepare_acpi() function and I tried to move it into 
xen/include/xen/acpi.h header file under appropriate #ifdef:
https://gitlab.com/xen-project/people/dimaprkp4k/xen/-/commit/d15cf91de92f1f8ec67911c51a13e7f095c1bcdd

The Eclair didn't report violations related to the prepare_acpi().
I was confused why Eclair continued to report other violations, and 
didn't report for the prepare_acpi().
After a while I realized that this header file 'xen/include/xen/acpi.h' 
was placed into exclude list 'docs/misra/exclude-list.json',
where:
         {
             "rel_path": "include/xen/acpi.h",
             "comment": "Imported from Linux, ignore for now"
         },

So, all violations from  the 'include/xen/acpi.h' file were ignored.
It was just a coincidence.

> 
>> +   * - R2.1
>> +     - In the specific build configuration (when the config CONFIG_HAS_ITS 
>> is not
>> +       defined) the 'BUG()' macro is intentionally used in the 
>> 'gicv3_do_LPI()'
>> +       and 'gicv3_its_setup_collection()' functions defined as 'static 
>> inline'
>> +       in the header file 'xen/arch/arm/include/asm/gic_v3_its.h' to catch 
>> and
>> +       prevent any unintended execution of code that should only run when 
>> ITS is
>> +       available.
>> +     - Tagged as `deliberate` for ECLAIR.
> 
> Taking both together and considering that really, when we no longer limit
> Misra checking to specific configurations, we are going to have many more
> of such "problems", I fear this way of deviating them simply doesn't scale.
> Imo this needs a SAF-style deviation that can be applied without needing to
> add a new section of text every time.
> 
> Jan

I agree. Actually, I saw similar functions. It could be tricky to 
maintain Eclair configs.

I will create SAF-based patch.

Thanks,
Dmytro.

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.