[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: Nicola Vetrini <nicola.vetrini@xxxxxxxxxxx>
  • From: Luca Fancellu <Luca.Fancellu@xxxxxxx>
  • Date: Wed, 4 Oct 2023 10:06:34 +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=KSxV9CbDmv/eabP+OzrKRnb/60s/9YtXZ/4MxiNumxY=; b=YO8Az5bb5Wq8SXMwhrJJVV0DYppHBpgsbTb9wRJ4IuICTVWYz3cNPCdC8BTH8pFzpKQzF3PzsGXyk5zdz724v+GrDhsjV/SCY6nIHQJseUuxuKeq0xSqBKGe4PyFDwYwC0zlVLu6kqLAMEnJpmnLuUPJ3pqvvZogwCBO0cNS4AvKysYI4PXdZh6kRHKTNE+8o3T84DqX4Ab+ZWW1JjO2POc2Qx3bhyVvZ/TxIyqATifkfuI2ov8U/PKgm0dcbmRtfknk/NUBNA5CaLQIlTBLU6a2SlHmPlaf8C7WXz5ymnvUN5Cl6/C1zp4I61SMO6ZmEXIYmA9X6Irk3KDw5/Sv4A==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mVvbXRhDfDkHPT5pfpJpcaNP7HO36fUC5hVC6L5o75IH4YSza3QjB0QzolwsrfwusWCz+wKg/QSFkzGt3UXpBYg4x+IXnma0hDWer/32vs6wa7v5sAUQXXHmEleP85lgakl68KtEgUk2wWFNfIpfZcyRFRusu1Fqecr/HQwP7ecxdLvK3aBf07QmB0l7IvhD/9OCIJxXls/VPPpSZaiRYN63I7StlN86bZHUFnxUGJm4WP87uWBFFtTfhLE8tpkL4EHeXcpYtBSL6L19s7VtO2dBMKHpCVrdVvS38DrDe3gnoFwL8CawYKZM/j92ChxuMp2PCuJEi9w+mL2gpj8qAA==
  • Authentication-results-original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com;
  • Cc: Stefano Stabellini <sstabellini@xxxxxxxxxx>, Xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxxx>, "michal.orzel@xxxxxxx" <michal.orzel@xxxxxxx>, "xenia.ragiadakou@xxxxxxx" <xenia.ragiadakou@xxxxxxx>, Ayan Kumar Halder <ayan.kumar.halder@xxxxxxx>, "consulting@xxxxxxxxxxx" <consulting@xxxxxxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, Roger Pau Monné <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>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • Delivery-date: Wed, 04 Oct 2023 10:07:42 +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: AQHZ9qj87vFsnMRst0ybMa+ffKOLU7A5Z4mA
  • Thread-topic: [XEN PATCH] xen: Add SAF deviations for MISRA C:2012 Rule 7.1

Hi Nicola,

> On 4 Oct 2023, at 10:56, andrew.cooper3@xxxxxxxxxx wrote:
> 
> On 03/10/2023 9:46 pm, Stefano Stabellini wrote:
>> On Tue, 3 Oct 2023, 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>
>>> 
>> "SAF" discussion aside that can be resolved elsewhere:
>> 
>> Reviewed-by: Stefano Stabellini <sstabellini@xxxxxxxxxx>
> 
> Well no.  "SAF" aside (and SAF does need fixing before reposting this patch, 
> otherwise it's just unnecessary churn), ...
> 
>>> diff --git a/xen/arch/x86/hvm/svm/svm.h b/xen/arch/x86/hvm/svm/svm.h
>>> index d2a781fc3fb5..d0623b72ccfa 100644
>>> --- a/xen/arch/x86/hvm/svm/svm.h
>>> +++ b/xen/arch/x86/hvm/svm/svm.h
>>> @@ -57,14 +57,23 @@ static inline void svm_invlpga(unsigned long linear, 
>>> uint32_t asid)
>>> #define INSTR_INT3 INSTR_ENC(X86EMUL_OPC( 0, 0xcc), 0)
>>> #define INSTR_ICEBP INSTR_ENC(X86EMUL_OPC( 0, 0xf1), 0)
>>> #define INSTR_HLT INSTR_ENC(X86EMUL_OPC( 0, 0xf4), 0)
>>> +/* SAF-2-safe */
>>> #define INSTR_XSETBV INSTR_ENC(X86EMUL_OPC(0x0f, 0x01), 0321)
>>> +/* SAF-2-safe */
>>> #define INSTR_VMRUN INSTR_ENC(X86EMUL_OPC(0x0f, 0x01), 0330)
>>> +/* SAF-2-safe */
>>> #define INSTR_VMCALL INSTR_ENC(X86EMUL_OPC(0x0f, 0x01), 0331)
>>> +/* SAF-2-safe */
>>> #define INSTR_VMLOAD INSTR_ENC(X86EMUL_OPC(0x0f, 0x01), 0332)
>>> +/* SAF-2-safe */
>>> #define INSTR_VMSAVE INSTR_ENC(X86EMUL_OPC(0x0f, 0x01), 0333)
>>> +/* SAF-2-safe */
>>> #define INSTR_STGI INSTR_ENC(X86EMUL_OPC(0x0f, 0x01), 0334)
>>> +/* SAF-2-safe */
>>> #define INSTR_CLGI INSTR_ENC(X86EMUL_OPC(0x0f, 0x01), 0335)
>>> +/* SAF-2-safe */
>>> #define INSTR_INVLPGA INSTR_ENC(X86EMUL_OPC(0x0f, 0x01), 0337)
>>> +/* SAF-2-safe */
>>> #define INSTR_RDTSCP INSTR_ENC(X86EMUL_OPC(0x0f, 0x01), 0371)
>>> #define INSTR_INVD INSTR_ENC(X86EMUL_OPC(0x0f, 0x08), 0)
>>> #define INSTR_WBINVD INSTR_ENC(X86EMUL_OPC(0x0f, 0x09), 0)
> 
> ... this has broken a tabulated structure to have comments ahead of lines 
> with octal numbers, while ...
> 
>>> 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;
>>> }
> 
> ... this has comments at the end of lines with octal numbers.
> 
> So which is it?

I agree with Andrew here in this sense: the in-code comment is supposed to be 
on the line *before* the violation,
not on the same line, so I’m also wondering how it is fixing the very first 
violation.

Cheers,
Luca

> 
> ~Andrew


 


Rackspace

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