From patchwork Thu Jun 29 10:06:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicola Vetrini X-Patchwork-Id: 13296839 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D47B0EB64DC for ; Thu, 29 Jun 2023 10:07:26 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.556720.869451 (Exim 4.92) (envelope-from ) id 1qEoYL-0000nW-DY; Thu, 29 Jun 2023 10:07:05 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 556720.869451; Thu, 29 Jun 2023 10:07:05 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qEoYL-0000nP-AL; Thu, 29 Jun 2023 10:07:05 +0000 Received: by outflank-mailman (input) for mailman id 556720; Thu, 29 Jun 2023 10:07:04 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qEoYK-0000mz-CU for xen-devel@lists.xenproject.org; Thu, 29 Jun 2023 10:07:04 +0000 Received: from support.bugseng.com (mail.bugseng.com [162.55.131.47]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id b1690b83-1664-11ee-b237-6b7b168915f2; Thu, 29 Jun 2023 12:07:02 +0200 (CEST) Received: from nico.bugseng.com (unknown [151.43.188.44]) by support.bugseng.com (Postfix) with ESMTPSA id C30534EE0739; Thu, 29 Jun 2023 12:06:59 +0200 (CEST) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: b1690b83-1664-11ee-b237-6b7b168915f2 From: Nicola Vetrini To: xen-devel@lists.xenproject.org Cc: sstabellini@kernel.org, michal.orzel@amd.com, xenia.ragiadakou@amd.com, ayan.kumar.halder@amd.com, consulting@bugseng.com, jbeulich@suse.com, andrew.cooper3@citrix.com, roger.pau@citrix.com, bertrand.marquis@arm.com, julien@xen.org, Nicola Vetrini , Volodymyr Babchuk Subject: [XEN PATCH v3 1/3] xen/arch/arm: fix violations of MISRA C:2012 Rule 3.1 Date: Thu, 29 Jun 2023 12:06:15 +0200 Message-Id: <7996a8bb62e62076d48bdf289e37352bb5e43b52.1688032865.git.nicola.vetrini@bugseng.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 In the files `xen/arch/arm/include/asm/arm(32|64)/flushtlb.h' there are a few occurrences of nested '//' character sequences inside C-style comment blocks, which violate Rule 3.1. The patch aims to resolve those by changing the inner comments to arm asm comments, delimited by ';' instead. Signed-off-by: Nicola Vetrini Reviewed-by: Luca Fancellu Reviewed-by: Stefano Stabellini --- Changes: - Resending the patch with the right maintainers in CC. Changes in V2: - Split the patch into a series and reworked the fix. - Apply the fix to the arm32 `flushtlb.h' file, for consistency Changes in V3: - Switched to arm asm comment in `arm(32|64)/flushtlb.h' --- xen/arch/arm/include/asm/arm32/flushtlb.h | 8 ++++---- xen/arch/arm/include/asm/arm64/flushtlb.h | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/xen/arch/arm/include/asm/arm32/flushtlb.h b/xen/arch/arm/include/asm/arm32/flushtlb.h index 22ee3b317b..61c25a3189 100644 --- a/xen/arch/arm/include/asm/arm32/flushtlb.h +++ b/xen/arch/arm/include/asm/arm32/flushtlb.h @@ -4,10 +4,10 @@ /* * Every invalidation operation use the following patterns: * - * DSB ISHST // Ensure prior page-tables updates have completed - * TLBI... // Invalidate the TLB - * DSB ISH // Ensure the TLB invalidation has completed - * ISB // See explanation below + * DSB ISHST ; Ensure prior page-tables updates have completed + * TLBI... ; Invalidate the TLB + * DSB ISH ; Ensure the TLB invalidation has completed + * ISB ; See explanation below * * For Xen page-tables the ISB will discard any instructions fetched * from the old mappings. diff --git a/xen/arch/arm/include/asm/arm64/flushtlb.h b/xen/arch/arm/include/asm/arm64/flushtlb.h index 56c6fc763b..45642201d1 100644 --- a/xen/arch/arm/include/asm/arm64/flushtlb.h +++ b/xen/arch/arm/include/asm/arm64/flushtlb.h @@ -4,10 +4,10 @@ /* * Every invalidation operation use the following patterns: * - * DSB ISHST // Ensure prior page-tables updates have completed - * TLBI... // Invalidate the TLB - * DSB ISH // Ensure the TLB invalidation has completed - * ISB // See explanation below + * DSB ISHST ; Ensure prior page-tables updates have completed + * TLBI... ; Invalidate the TLB + * DSB ISH ; Ensure the TLB invalidation has completed + * ISB ; See explanation below * * ARM64_WORKAROUND_REPEAT_TLBI: * Modification of the translation table for a virtual address might lead to From patchwork Thu Jun 29 10:06:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicola Vetrini X-Patchwork-Id: 13296840 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 49370EB64D9 for ; Thu, 29 Jun 2023 10:07:27 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.556722.869461 (Exim 4.92) (envelope-from ) id 1qEoYQ-00014y-Lk; Thu, 29 Jun 2023 10:07:10 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 556722.869461; Thu, 29 Jun 2023 10:07:10 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qEoYQ-00014n-Ik; Thu, 29 Jun 2023 10:07:10 +0000 Received: by outflank-mailman (input) for mailman id 556722; Thu, 29 Jun 2023 10:07:09 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qEoYP-0000mz-HI for xen-devel@lists.xenproject.org; Thu, 29 Jun 2023 10:07:09 +0000 Received: from support.bugseng.com (mail.bugseng.com [162.55.131.47]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id b501fc14-1664-11ee-b237-6b7b168915f2; Thu, 29 Jun 2023 12:07:08 +0200 (CEST) Received: from nico.bugseng.com (unknown [151.43.188.44]) by support.bugseng.com (Postfix) with ESMTPSA id 829344EE0738; Thu, 29 Jun 2023 12:07:05 +0200 (CEST) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: b501fc14-1664-11ee-b237-6b7b168915f2 From: Nicola Vetrini To: xen-devel@lists.xenproject.org Cc: sstabellini@kernel.org, michal.orzel@amd.com, xenia.ragiadakou@amd.com, ayan.kumar.halder@amd.com, consulting@bugseng.com, jbeulich@suse.com, andrew.cooper3@citrix.com, roger.pau@citrix.com, bertrand.marquis@arm.com, julien@xen.org, Nicola Vetrini , Rahul Singh , Volodymyr Babchuk Subject: [XEN PATCH v3 2/3] xen/drivers/passthrough/arm/smmu-v3.c: fix violations of MISRA C:2012 Rule 3.1 Date: Thu, 29 Jun 2023 12:06:16 +0200 Message-Id: <8a8d5ed47f24791d3927345fafed07023a8b0b76.1688032865.git.nicola.vetrini@bugseng.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 In the file `xen/drivers/passthrough/arm/smmu-v3.c' there are a few occurrences of nested '//' character sequences inside C-style comment blocks, which violate Rule 3.1. The patch aims to resolve those by replacing the nested comments with equivalent constructs that do not violate the rule. Signed-off-by: Nicola Vetrini Changes: - Resending the patch with the right maintainers in CC. Changes in V2: - Split the patch into a series and reworked the fix. - Apply the fix to the arm32 `flushtlb.h' file, for consistency Changes in V3: - Revised the comment to make it clear the function the parallel control flows in the comment belong to. Reviewed-by: Luca Fancellu Reviewed-by: Stefano Stabellini Acked-by: Rahul Singh --- xen/drivers/passthrough/arm/smmu-v3.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/xen/drivers/passthrough/arm/smmu-v3.c b/xen/drivers/passthrough/arm/smmu-v3.c index 720aa69ff2..cdbb505134 100644 --- a/xen/drivers/passthrough/arm/smmu-v3.c +++ b/xen/drivers/passthrough/arm/smmu-v3.c @@ -1047,10 +1047,10 @@ static int arm_smmu_atc_inv_domain(struct arm_smmu_domain *smmu_domain, * before we read 'nr_ats_masters' in case of a concurrent call to * arm_smmu_enable_ats(): * - * // unmap() // arm_smmu_enable_ats() - * TLBI+SYNC atomic_inc(&nr_ats_masters); - * smp_mb(); [...] - * atomic_read(&nr_ats_masters); pci_enable_ats() // writel() + * --- unmap() --- --- arm_smmu_enable_ats() --- + * TLBI+SYNC atomic_inc(&nr_ats_masters); + * smp_mb(); [...] + * atomic_read(&nr_ats_masters); pci_enable_ats() (see writel()) * * Ensures that we always see the incremented 'nr_ats_masters' count if * ATS was enabled at the PCI device before completion of the TLBI. From patchwork Thu Jun 29 10:06:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicola Vetrini X-Patchwork-Id: 13296841 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3C213EB64D9 for ; Thu, 29 Jun 2023 10:07:36 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.556724.869471 (Exim 4.92) (envelope-from ) id 1qEoYU-0001PT-TI; Thu, 29 Jun 2023 10:07:14 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 556724.869471; Thu, 29 Jun 2023 10:07:14 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qEoYU-0001PM-Pq; Thu, 29 Jun 2023 10:07:14 +0000 Received: by outflank-mailman (input) for mailman id 556724; Thu, 29 Jun 2023 10:07:13 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qEoYT-0000mz-TN for xen-devel@lists.xenproject.org; Thu, 29 Jun 2023 10:07:13 +0000 Received: from support.bugseng.com (mail.bugseng.com [162.55.131.47]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id b7dfd45c-1664-11ee-b237-6b7b168915f2; Thu, 29 Jun 2023 12:07:13 +0200 (CEST) Received: from nico.bugseng.com (unknown [151.43.188.44]) by support.bugseng.com (Postfix) with ESMTPSA id B76564EE0739; Thu, 29 Jun 2023 12:07:10 +0200 (CEST) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: b7dfd45c-1664-11ee-b237-6b7b168915f2 From: Nicola Vetrini To: xen-devel@lists.xenproject.org Cc: sstabellini@kernel.org, michal.orzel@amd.com, xenia.ragiadakou@amd.com, ayan.kumar.halder@amd.com, consulting@bugseng.com, jbeulich@suse.com, andrew.cooper3@citrix.com, roger.pau@citrix.com, bertrand.marquis@arm.com, julien@xen.org, Nicola Vetrini , George Dunlap , Wei Liu Subject: [XEN PATCH v3 3/3] xen: fix violations of MISRA C:2012 Rule 3.1 Date: Thu, 29 Jun 2023 12:06:17 +0200 Message-Id: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 In the files modified by this patch there are a few occurrences of nested '//' character sequences inside C-style comment blocks, which violate Rule 3.1. The patch aims to resolve those by removing the nested comments. In the file 'xen/common/xmalloc_tlsf.c' the comment has been replaces by an ASSERT, to ensure that the invariant in the comment is enforced. In the file 'xen/include/xen/atomic.h' the nested comment has been removed, since the code sample is already explained by the preceding comment. Signed-off-by: Nicola Vetrini Changes: - Resending the patch with the right maintainers in CC. Changes in V2: - Split the patch into a series and reworked the fix; - Apply the fix to the arm32 `flushtlb.h' file, for consistency. Changes in V3: - Replaced commmented-out 'if' with an ASSERT( *fl >= 0 ). Reviewed-by: Luca Fancellu --- xen/common/xmalloc_tlsf.c | 4 +--- xen/include/xen/atomic.h | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/xen/common/xmalloc_tlsf.c b/xen/common/xmalloc_tlsf.c index 75bdf18c4e..95affcc571 100644 --- a/xen/common/xmalloc_tlsf.c +++ b/xen/common/xmalloc_tlsf.c @@ -140,9 +140,7 @@ static inline void MAPPING_SEARCH(unsigned long *r, int *fl, int *sl) *fl = flsl(*r) - 1; *sl = (*r >> (*fl - MAX_LOG2_SLI)) - MAX_SLI; *fl -= FLI_OFFSET; - /*if ((*fl -= FLI_OFFSET) < 0) // FL will be always >0! - *fl = *sl = 0; - */ + ASSERT( *fl >= 0 ); *r &= ~t; } } diff --git a/xen/include/xen/atomic.h b/xen/include/xen/atomic.h index 529213ebbb..fa750a18ae 100644 --- a/xen/include/xen/atomic.h +++ b/xen/include/xen/atomic.h @@ -78,7 +78,7 @@ static inline void _atomic_set(atomic_t *v, int i); * int old = atomic_read(&v); * int new = old + 1; * if ( likely(old == atomic_cmpxchg(&v, old, new)) ) - * break; // success! + * break; * } */ static inline int atomic_cmpxchg(atomic_t *v, int old, int new);