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

Re: [XEN PATCH] xen: Add SAF deviations for MISRA C:2012 Rule 7.1


  • To: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • From: Luca Fancellu <Luca.Fancellu@xxxxxxx>
  • Date: Tue, 3 Oct 2023 17:14:25 +0000
  • Accept-language: en-GB, en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=mxUv3krlITL9EK8xxRsTN+CqaSO146fvJEvl0o/jJ9c=; b=Pmkr8mfRYEk43L8YE6Snc9m9qAkAOvTgQzRE6d2xq4G+opGllatp3jfwEqODbzc939k/E58JgW6/8GGyUfPXABhQUXgZ6CMRkNZ4RvWsQWbZp++AkEuAxpmuwlH6DlzWPYo9ucfJmk9UQUflV4KjgKmvlZywIsKJcLCZ3DNs7tE22dwoOjqHPOzyVXVHbAoTJRCyZE95K0cEVpT0dW7bOAdzTx0iK28VUMYWIe2ukWQCLsHCj8FgAgH0qFMAf4TaGrg5FIx18y1Zvjwga+B9jsC6J6AqospvzxBOiUC1Kw39GtKaVP9lrzr0XdBc/NAQqya4fmu9XOgS8g8R9CDlOw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=d/3oJy36jHBkeVqr9k2mwBaXnNowtF5jpLC+Pz9gQKF2WTI0TuAgsA2VmHctUBtAygzf/uSPJpw4szQyMrPrKJmcKWBS6bL+QM+1cQ+QDco9cWULsCezwteDDQw0KEBl5vFT7PV5ywR4yDACZ7iye14TdsjYbPWhP7K9g1fW56G/hosnWdZBddSDax6dBXuDO/gon4fjHfCIdQdutEnQEcPOon2AJW1UQdRCW/CDwtCqEOHZAVPEl1gEazhcTwYCFMgmXFqKSQxMNXJGn/wqaYtL+ODSixhjfoRbpwuu9jY/Ja4HByUqbZu3Su7dDsRhn8DfXa4CvbKjFqEy0pEKSw==
  • Authentication-results-original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com;
  • Cc: Nicola Vetrini <nicola.vetrini@xxxxxxxxxxx>, Xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, "michal.orzel@xxxxxxx" <michal.orzel@xxxxxxx>, "xenia.ragiadakou@xxxxxxx" <xenia.ragiadakou@xxxxxxx>, "ayan.kumar.halder@xxxxxxx" <ayan.kumar.halder@xxxxxxx>, "consulting@xxxxxxxxxxx" <consulting@xxxxxxxxxxx>, "jbeulich@xxxxxxxx" <jbeulich@xxxxxxxx>, "roger.pau@xxxxxxxxxx" <roger.pau@xxxxxxxxxx>, Henry Wang <Henry.Wang@xxxxxxx>, Simone Ballarin <simone.ballarin@xxxxxxxxxxx>, Doug Goldstein <cardoe@xxxxxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Wei Liu <wl@xxxxxxx>
  • Delivery-date: Tue, 03 Oct 2023 17:15:36 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Nodisclaimer: true
  • Original-authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com;
  • Thread-index: AQHZ9g+v7vFsnMRst0ybMa+ffKOLU7A4PhuAgAAP1gA=
  • Thread-topic: [XEN PATCH] xen: Add SAF deviations for MISRA C:2012 Rule 7.1


> On 3 Oct 2023, at 17:17, andrew.cooper3@xxxxxxxxxx wrote:
> 
> On 03/10/2023 4:37 pm, Nicola Vetrini wrote:
>> As specified in rules.rst, these constants can be used
>> in the code.
>> Their deviation is now accomplished by using a SAF comment,
>> rather than an ECLAIR configuration.
>> 
>> Signed-off-by: Nicola Vetrini <nicola.vetrini@xxxxxxxxxxx>
>> ---
>> automation/eclair_analysis/ECLAIR/deviations.ecl | 6 ------
>> docs/misra/safe.json                             | 8 ++++++++
>> xen/arch/x86/hvm/svm/emulate.c                   | 6 +++---
>> xen/arch/x86/hvm/svm/svm.h                       | 9 +++++++++
>> xen/common/inflate.c                             | 4 ++--
>> 5 files changed, 22 insertions(+), 11 deletions(-)
>> 
>> diff --git a/automation/eclair_analysis/ECLAIR/deviations.ecl 
>> b/automation/eclair_analysis/ECLAIR/deviations.ecl
>> index d8170106b449..fbb806a75d73 100644
>> --- a/automation/eclair_analysis/ECLAIR/deviations.ecl
>> +++ b/automation/eclair_analysis/ECLAIR/deviations.ecl
>> @@ -132,12 +132,6 @@ safe."
>> # Series 7.
>> #
>> 
>> --doc_begin="Usage of the following constants is safe, since they are given 
>> as-is
>> -in the inflate algorithm specification and there is therefore no risk of 
>> them
>> -being interpreted as decimal constants."
>> --config=MC3R1.R7.1,literals={safe, 
>> "^0(007|37|070|213|236|300|321|330|331|332|333|334|335|337|371)$"}
>> --doc_end
>> -
>> -doc_begin="Violations in files that maintainers have asked to not modify in 
>> the
>> context of R7.2."
>> -file_tag+={adopted_r7_2,"^xen/include/xen/libfdt/.*$"}
>> diff --git a/docs/misra/safe.json b/docs/misra/safe.json
>> index 39c5c056c7d4..7ea47344ffcc 100644
>> --- a/docs/misra/safe.json
>> +++ b/docs/misra/safe.json
>> @@ -20,6 +20,14 @@
>>         },
>>         {
>>             "id": "SAF-2-safe",
>> +            "analyser": {
>> +                "eclair": "MC3R1.R7.1"
>> +            },
>> +            "name": "Rule 7.1: constants defined in specifications, 
>> manuals, and algorithm descriptions",
>> +            "text": "It is safe to use certain octal constants the way they 
>> are defined in specifications, manuals, and algorithm descriptions."
>> +        },
>> +        {
>> +            "id": "SAF-3-safe",
>>             "analyser": {},
>>             "name": "Sentinel",
>>             "text": "Next ID to be used"
>> diff --git a/xen/arch/x86/hvm/svm/emulate.c b/xen/arch/x86/hvm/svm/emulate.c
>> index aa2c61c433b3..c5e3341c6316 100644
>> --- a/xen/arch/x86/hvm/svm/emulate.c
>> +++ b/xen/arch/x86/hvm/svm/emulate.c
>> @@ -90,9 +90,9 @@ unsigned int svm_get_insn_len(struct vcpu *v, unsigned int 
>> instr_enc)
>>         if ( !instr_modrm )
>>             return emul_len;
>> 
>> -        if ( modrm_mod       == MASK_EXTR(instr_modrm, 0300) &&
>> -             (modrm_reg & 7) == MASK_EXTR(instr_modrm, 0070) &&
>> -             (modrm_rm  & 7) == MASK_EXTR(instr_modrm, 0007) )
>> +        if ( modrm_mod       == MASK_EXTR(instr_modrm, 0300) && /* 
>> SAF-2-safe */
>> +             (modrm_reg & 7) == MASK_EXTR(instr_modrm, 0070) && /* 
>> SAF-2-safe */
>> +             (modrm_rm  & 7) == MASK_EXTR(instr_modrm, 0007) )  /* 
>> SAF-2-safe */
>>             return emul_len;
>>     }
> 

Hi Andrew,

> This is line noise, and later examples are even worse.
> 
> What does SAF mean?  It's presumably not the Scalable Agile Framework.

Please have a look on docs/misra/documenting-violations.rst, you will find all 
the
info about it.

> 
> It is meaningless to anyone reading the code who doesn't know it's a
> magic identifier to suppress violations.
> 
> Looking in scripts/xen_analysis, it appears to be a labelling scheme
> we've in invented for the purpose of cross-referencing, in which case it
> needs to be changed to something more obviously safety/misra/etc related
> to make the code clearer to follow.
> 
> ~Andrew
> 




 


Rackspace

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