[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] x86/gen-cpuid: avoid violations of Misra rule 1.3
- To: Jan Beulich <jbeulich@xxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
- From: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
- Date: Wed, 2 Aug 2023 11:59:45 +0100
- Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.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=ULTEx47mnRQuAP2u8jn8rm48uieFQBZpTlSRk2k0kvw=; b=Zrz1FFUSIjunXEkVEUsqOK4ktc0m4iBfRoLGCovp55m4cSpTO9ZUTl/8YwhJef54+V36YeD+vEfK70EftYeGnNTXwUxtYbEImvlVkCCthwJ6ka+QMLVPY9t1PVZwmDbPQ3P9TO7sLwd6T/HFQ2wf4kHd2niF32kjRsGS1TcoVeWYmLbREKHFeWdnqRaUlbbs0KGhbkKBJjeGcccrqdCeLix6Vok5jRhEy3VcyaSm/iTjEifx0630nvKEMUNcey8CtmzRcfJ7Hnaqw2SGfn/b9LJRyksl+fX+hQ0A7SGlKs8J0qAJzKyOVV81C5c0uxWizwcbxNDv+a9A58ATcbQjZA==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cAd3yBBpQJQHpAS0lJy4GRnntigoBjVONMwA/CKFngO6AjM+LJYBTPMaSbqNCL0R4qA1YnvIAmfK7M4V+SvVlWhUrEyjpo48fEnN5zbkt7WSeHP8Go/tPWOdU3kjw6j3RYJg2h+If4QYyWYeJfMKExMmbRuJYmLA+zvQLFq7Aqyn7k16pTj4EwCWBQ81GRLv8bA2bjngVzBPxZ2r4W+ItboshdqREQXhoPeGTNeot2w36LkWLpWMmtcGOF37Dqln0jxw+75z4rpPkF3lhHmM8nYsuEWpPk/N6gdumWkGnI0niiJJ7kqiGoPC3j7qu8zLosM+MlZxgNx39AVRAgrn8g==
- Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
- Cc: Wei Liu <wl@xxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Nicola Vetrini <nicola.vetrini@xxxxxxxxxxx>
- Delivery-date: Wed, 02 Aug 2023 11:00:17 +0000
- Ironport-data: A9a23:xRzzBKyHrqJ8eHA2Y6N6t+f2xyrEfRIJ4+MujC+fZmUNrF6WrkVUm DAYW2HQOKnbYWHyftslOd++9RsPsMeDzt4yTAA5pCAxQypGp/SeCIXCJC8cHc8wwu7rFxs7s ppEOrEsCOhuExcwcz/0auCJQUFUjP3OHfykTrafYEidfCc8IA85kxVvhuUltYBhhNm9Emult Mj75sbSIzdJ4RYtWo4vw/zF8EoHUMja4mtC5QRuPaoT5TcyqlFOZH4hDfDpR5fHatE88t6SH 47r0Ly/92XFyBYhYvvNfmHTKxBirhb6ZGBiu1IOM0SQqkEqSh8ai87XAME0e0ZP4whlqvgqo Dl7WT5cfi9yVkHEsLx1vxC1iEiSN4UekFPMCSDXXcB+UyQq2pYjqhljJBheAGEWxgp4KUVK8 aUcDhYUUg2C3fmmxrCEY+dLme12eaEHPKtH0p1h5RfwKK98BLzmHeDN79Ie2yosjMdTG/qYf 9AedTdkcBXHZVtIJ0sTD5U92uyvgxETcRUB8A7T+fVxvjmVlVMuuFTuGIO9ltiibMNZhEuH4 EnB+Hz0GEoyP92D0zuVtHmrg4cjmAuiAtpCS+PhqqECbFu77TU3OTQvT2OAsNKpl0WfA4luF nIe0397xUQ13AnxJjXnZDW6qnOZuh8XW/JLDvY3rgqKz8L88wufQ2QJUDNFQNgnr9MtAywn0 EeTmNHkDiApt6eaIVqC8p+EoDX0PjIaRUcEZCQDSQJD/dT/uoA1jzrFU9l4Hai6yNbyHFnNL yuiqSE/g/AfiJAN3qDip1Tf2Wvz+d7OUxI/4RjRUiS99ARlaYW5Zouur1/G8fJHK4XfRV6E1 JQZp/WjACk1JcnlvESwrC8lRdlFO97t3OXgvGNS
- Ironport-hdrordr: A9a23:gktUoaHYTpmPrepTpLqELMeALOsnbusQ8zAXPiBKJCC9E/bo8v xG+c5w6faaslkssR0b9+xoW5PwI080l6QU3WB5B97LMDUO0FHCEGgI1/qA/9SPIUzDHu4279 YbT0B9YueAcGSTW6zBkXWF+9VL+qj5zEix792uq0uE1WtRGtldBwESMHf9LmRGADNoKLAeD5 Sm6s9Ot1ObCA8qhpTSPAhiYwDbzee77a7bXQ==
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
On 02/08/2023 10:43 am, Jan Beulich wrote:
> Structures or unions without any named members aren't liked by Misra
> (nor the C standard). Avoid emitting such for leaves without any known
> bits.
>
> At this occasion also add the script to the X86 section in ./MAINTAINERS.
>
> Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
>
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -601,6 +601,7 @@ F: xen/arch/x86/
> F: xen/include/public/arch-x86/
> F: xen/include/xen/lib/x86
> F: xen/lib/x86
> +F: xen/tools/gen-cpuid.py
> F: tools/firmware/hvmloader/
> F: tools/firmware/rombios/
> F: tools/firmware/vgabios/
> --- a/xen/tools/gen-cpuid.py
> +++ b/xen/tools/gen-cpuid.py
> @@ -367,6 +367,7 @@ def crunch_numbers(state):
> for word in range(state.nr_entries):
>
> names = []
> + empty = 1
> for bit in range(32):
>
> name = state.names.get(word * 32 + bit, "")
> @@ -380,9 +381,15 @@ def crunch_numbers(state):
> if name in ("APIC", "OSXSAVE", "OSPKE"):
> name = ""
>
> + if name:
> + empty = 0
> +
> names.append(name.lower())
>
> - state.bitfields.append("bool " + ":1, ".join(names) + ":1")
> + if empty:
> + state.bitfields.append("unsigned int empty_" + str(word) + ":32")
> + else:
> + state.bitfields.append("bool " + ":1, ".join(names) + ":1")
There's no need for the extra empty variable (this is python, not C).
if any(names):
state.bitfields.append("bool " + ":1, ".join(names) + ":1")
else:
state.bitfields.append("uint32_t empty_%s" % (word, ))
But there's a related bug later in the script which MISRA won't notice
unless it happens to run on the cset boundary introducing a new leaf.
I'll see about doing a patch to address both.
~Andrew
|