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

[PATCH v4 2/2] arm/gic_v3: address violations of MISRA C Rule 2.1


  • To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Dmytro Prokopchuk1 <dmytro_prokopchuk1@xxxxxxxx>
  • Date: Mon, 29 Sep 2025 18:43:11 +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=1x3ib5+D29JOj///4+abaLXCnrAt2rgzaFpirzRaK68=; b=VHVcXgkplPS2WCM6KJ17Neuqxm9Iq4WocYvpF+ANwBSC3n63HLTVvkarysPmHCeV5tndigrzm00kEBo3TQ7JxYCZfPzmKQKLIsgpJJdTIhil6z1R1Op8sv/JGpKrdGVJrj70rwC1fDgBoN79tc2XX+c3cEZtNNDwo6mAPIHlQjM7uNzW3I0/XYNgv3OJWo845L19L0vYfmnrWRkExatUbUw6rlZX9NvGl0Xc1z/j1NWF80V3V7kpUf6Bdc3Sj7o1FyBzi5zMG6Kc353hmm1+V0qJ8+44grj99/ZZ8Id0UZdjq1H2pVB13HVw0kBOwCeryCUp+0i5rh6gfjMta9hqeQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=I1VpH4Qm+FEb5QOr7cUjFDh3Pk0CPB9V1zXCNEeGNrAACs9V7SO7ZvuvUTWwnanyGD8r8qdlmCWL9GjNtBPg819W/f1N2VO899Ik4D7x7BZ1QnuroN8xaeqjMrqFHNYdLAk/Bq8R20+A/mDEGD4++0GcGJVeUPvPwJKbCRAt6fpQqcEInTt55j37QlUDscjxHJcWLCdx+8422z/y7oyyQVBYjSuabuaFeb6mqqEi0S0LSUONtvIii2VFWjDwaoCxOCeDs3AhMyhOelmUnvRrEoUPMTNp7cAMdjB03f91i71qKuInNnR2OQk7se/+gs6kWmOxJlPAs4ieCMb6O0z2iA==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=epam.com;
  • Cc: Dmytro Prokopchuk1 <dmytro_prokopchuk1@xxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>
  • Delivery-date: Mon, 29 Sep 2025 18:43:20 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHcMXDoriceWLTjBkO+YV17n/oK0w==
  • Thread-topic: [PATCH v4 2/2] arm/gic_v3: address violations of MISRA C Rule 2.1

MISRA C Rule 2.1 states: "A project shall not contain unreachable code".
In certain build configuration the following 'gicv3_its_setup_collection()'
function is defined as inline and contains the macro 'BUG()'. This resulted
in violation due to the function became non-returning.

To ensure compliance with MISRA C Rule 2.1 remove inline function and its
'BUG()'-based unreachable code. Provide unconditional function declaration
for 'gicv3_its_setup_collection()'. Rely on the compiler's DCE to remove
unused function calls, and use the 'gicv3_its_host_has_its()' predicate,
which always returns false when 'CONFIG_HAS_ITS' is disabled, to statically
resolve conditional branches:
    if ( gicv3_its_host_has_its() )
    {
        ...
        ret = gicv3_its_setup_collection(smp_processor_id());
        if ( ret )
            return ret;
    }

Signed-off-by: Dmytro Prokopchuk <dmytro_prokopchuk1@xxxxxxxx>
---
 xen/arch/arm/include/asm/gic_v3_its.h | 11 ++---------
 1 file changed, 2 insertions(+), 9 deletions(-)

diff --git a/xen/arch/arm/include/asm/gic_v3_its.h 
b/xen/arch/arm/include/asm/gic_v3_its.h
index 0737e67aa6..fc5a84892c 100644
--- a/xen/arch/arm/include/asm/gic_v3_its.h
+++ b/xen/arch/arm/include/asm/gic_v3_its.h
@@ -131,6 +131,8 @@ struct host_its {
     unsigned int flags;
 };
 
+/* Map a collection for this host CPU to each host ITS. */
+int gicv3_its_setup_collection(unsigned int cpu);
 
 #ifdef CONFIG_HAS_ITS
 
@@ -160,9 +162,6 @@ int gicv3_its_init(void);
 void gicv3_set_redist_address(paddr_t address, unsigned int redist_id);
 uint64_t gicv3_get_redist_address(unsigned int cpu, bool use_pta);
 
-/* Map a collection for this host CPU to each host ITS. */
-int gicv3_its_setup_collection(unsigned int cpu);
-
 /* Initialize and destroy the per-domain parts of the virtual ITS support. */
 int vgic_v3_its_init_domain(struct domain *d);
 void vgic_v3_its_free_domain(struct domain *d);
@@ -256,12 +255,6 @@ static inline void gicv3_set_redist_address(paddr_t 
address,
 {
 }
 
-static inline int gicv3_its_setup_collection(unsigned int cpu)
-{
-    /* We should never get here without an ITS. */
-    BUG();
-}
-
 static inline int vgic_v3_its_init_domain(struct domain *d)
 {
     return 0;
-- 
2.43.0



 


Rackspace

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