From patchwork Tue Jun 25 10:14:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alessandro Zucchelli X-Patchwork-Id: 13710818 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 C145CC2BBCA for ; Tue, 25 Jun 2024 10:14:54 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.747548.1154993 (Exim 4.92) (envelope-from ) id 1sM3CI-0007mE-Gv; Tue, 25 Jun 2024 10:14:46 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 747548.1154993; Tue, 25 Jun 2024 10:14:46 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sM3CI-0007m7-ET; Tue, 25 Jun 2024 10:14:46 +0000 Received: by outflank-mailman (input) for mailman id 747548; Tue, 25 Jun 2024 10:14:45 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sM3CH-0007WK-H4 for xen-devel@lists.xenproject.org; Tue, 25 Jun 2024 10:14:45 +0000 Received: from support.bugseng.com (mail.bugseng.com [162.55.131.47]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id be0c93ce-32db-11ef-b4bb-af5377834399; Tue, 25 Jun 2024 12:14:44 +0200 (CEST) Received: from delta.bugseng.com.homenet.telecomitalia.it (host-87-17-171-46.retail.telecomitalia.it [87.17.171.46]) by support.bugseng.com (Postfix) with ESMTPSA id 899554EE073D; Tue, 25 Jun 2024 12:14:41 +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: be0c93ce-32db-11ef-b4bb-af5377834399 From: Alessandro Zucchelli To: xen-devel@lists.xenproject.org Cc: consulting@bugseng.com, Alessandro Zucchelli , Andrew Cooper , George Dunlap , Jan Beulich , Julien Grall , Stefano Stabellini Subject: [PATCH 1/3] common/kernel: address violation of MISRA C Rule 13.6 Date: Tue, 25 Jun 2024 12:14:19 +0200 Message-Id: <54949b0561263b9f18da500255836d89ca8838ba.1719308599.git.alessandro.zucchelli@bugseng.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 In the file common/kernel.c macro ARRAY_SIZE is called with argument current->domain->handle. Once expanded, this ARRAY_SIZE's argument is used in sizeof operations and thus 'current', being a macro that expands to a function call with potential side effects, generates a violation. To address this violation the value of current->domain is therefore stored in a variable called 'd' before passing it to macro ARRAY_SIZE. No functional change. Signed-off-by: Alessandro Zucchelli --- xen/common/kernel.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/xen/common/kernel.c b/xen/common/kernel.c index b44b2439ca..76b4f27aef 100644 --- a/xen/common/kernel.c +++ b/xen/common/kernel.c @@ -660,14 +660,15 @@ long do_xen_version(int cmd, XEN_GUEST_HANDLE_PARAM(void) arg) case XENVER_guest_handle: { + struct domain *d = current->domain; xen_domain_handle_t hdl; if ( deny ) memset(&hdl, 0, ARRAY_SIZE(hdl)); - BUILD_BUG_ON(ARRAY_SIZE(current->domain->handle) != ARRAY_SIZE(hdl)); + BUILD_BUG_ON(ARRAY_SIZE(d->handle) != ARRAY_SIZE(hdl)); - if ( copy_to_guest(arg, deny ? hdl : current->domain->handle, + if ( copy_to_guest(arg, deny ? hdl : d->handle, ARRAY_SIZE(hdl) ) ) return -EFAULT; return 0; From patchwork Tue Jun 25 10:14:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alessandro Zucchelli X-Patchwork-Id: 13710820 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 3BB19C30653 for ; Tue, 25 Jun 2024 10:14:58 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.747550.1155003 (Exim 4.92) (envelope-from ) id 1sM3CM-00084A-OI; Tue, 25 Jun 2024 10:14:50 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 747550.1155003; Tue, 25 Jun 2024 10:14:50 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sM3CM-000843-Lh; Tue, 25 Jun 2024 10:14:50 +0000 Received: by outflank-mailman (input) for mailman id 747550; Tue, 25 Jun 2024 10:14:49 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sM3CL-0007WK-9l for xen-devel@lists.xenproject.org; Tue, 25 Jun 2024 10:14:49 +0000 Received: from support.bugseng.com (mail.bugseng.com [162.55.131.47]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id c03fbf98-32db-11ef-b4bb-af5377834399; Tue, 25 Jun 2024 12:14:47 +0200 (CEST) Received: from delta.bugseng.com.homenet.telecomitalia.it (host-87-17-171-46.retail.telecomitalia.it [87.17.171.46]) by support.bugseng.com (Postfix) with ESMTPSA id F3BAD4EE0754; Tue, 25 Jun 2024 12:14:45 +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: c03fbf98-32db-11ef-b4bb-af5377834399 From: Alessandro Zucchelli To: xen-devel@lists.xenproject.org Cc: consulting@bugseng.com, Alessandro Zucchelli , Andrew Cooper , George Dunlap , Jan Beulich , Julien Grall , Stefano Stabellini Subject: [PATCH 2/3] xen/event: address violation of MISRA C Rule 13.6 Date: Tue, 25 Jun 2024 12:14:20 +0200 Message-Id: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 In the file include/xen/event.h macro set_bit is called with argument current->pause_flags. Once expanded this set_bit's argument is used in sizeof operations and thus 'current', being a macro that expands to a function call with potential side effects, generates a violation. To address this violation the value of current is therefore stored in a variable called 'v' before passing it to macro set_bit. No functional change. Signed-off-by: Alessandro Zucchelli Reviewed-by: Stefano Stabellini --- xen/include/xen/event.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/xen/include/xen/event.h b/xen/include/xen/event.h index f1472ea1eb..48b79f3d62 100644 --- a/xen/include/xen/event.h +++ b/xen/include/xen/event.h @@ -183,13 +183,14 @@ static bool evtchn_usable(const struct evtchn *evtchn) /* Wait on a Xen-attached event channel. */ #define wait_on_xen_event_channel(port, condition) \ do { \ + struct vcpu *v = current; \ if ( condition ) \ break; \ - set_bit(_VPF_blocked_in_xen, ¤t->pause_flags); \ + set_bit(_VPF_blocked_in_xen, &v->pause_flags); \ smp_mb(); /* set blocked status /then/ re-evaluate condition */ \ if ( condition ) \ { \ - clear_bit(_VPF_blocked_in_xen, ¤t->pause_flags); \ + clear_bit(_VPF_blocked_in_xen, &v->pause_flags); \ break; \ } \ raise_softirq(SCHEDULE_SOFTIRQ); \ @@ -198,7 +199,8 @@ static bool evtchn_usable(const struct evtchn *evtchn) #define prepare_wait_on_xen_event_channel(port) \ do { \ - set_bit(_VPF_blocked_in_xen, ¤t->pause_flags); \ + struct vcpu *v = current; \ + set_bit(_VPF_blocked_in_xen, &v->pause_flags); \ raise_softirq(SCHEDULE_SOFTIRQ); \ smp_mb(); /* set blocked status /then/ caller does his work */ \ } while ( 0 ) From patchwork Tue Jun 25 10:14:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alessandro Zucchelli X-Patchwork-Id: 13710821 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 C23D2C2BBCA for ; Tue, 25 Jun 2024 10:15:00 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.747553.1155014 (Exim 4.92) (envelope-from ) id 1sM3CQ-0008OD-23; Tue, 25 Jun 2024 10:14:54 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 747553.1155014; Tue, 25 Jun 2024 10:14:54 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sM3CP-0008O2-Uu; Tue, 25 Jun 2024 10:14:53 +0000 Received: by outflank-mailman (input) for mailman id 747553; Tue, 25 Jun 2024 10:14:52 +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 1sM3CO-0007Vr-Lz for xen-devel@lists.xenproject.org; Tue, 25 Jun 2024 10:14:52 +0000 Received: from support.bugseng.com (mail.bugseng.com [162.55.131.47]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id c28c9499-32db-11ef-90a3-e314d9c70b13; Tue, 25 Jun 2024 12:14:52 +0200 (CEST) Received: from delta.bugseng.com.homenet.telecomitalia.it (host-87-17-171-46.retail.telecomitalia.it [87.17.171.46]) by support.bugseng.com (Postfix) with ESMTPSA id 94A5B4EE073D; Tue, 25 Jun 2024 12:14:49 +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: c28c9499-32db-11ef-90a3-e314d9c70b13 From: Alessandro Zucchelli To: xen-devel@lists.xenproject.org Cc: consulting@bugseng.com, Alessandro Zucchelli , Andrew Cooper , George Dunlap , Jan Beulich , Julien Grall , Stefano Stabellini Subject: [PATCH 3/3] common/softirq: address violation of MISRA C Rule 13.6 Date: Tue, 25 Jun 2024 12:14:21 +0200 Message-Id: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 In the file common/softirq macro set_bit is called with argument smp_processor_id. Once expanded this set_bit's argument is used in sizeof operations and thus 'smp_processor_id', being a macro that expands to a function call with potential side effects, generates a violation. To address this violation the value of smp_processor_id is therefore stored in a variable called 'cpu' before passing it to macro set_bit. No functional change. Signed-off-by: Alessandro Zucchelli Reviewed-by: Stefano Stabellini --- xen/common/softirq.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/xen/common/softirq.c b/xen/common/softirq.c index bee4a82009..c5f3870534 100644 --- a/xen/common/softirq.c +++ b/xen/common/softirq.c @@ -139,7 +139,8 @@ void cpu_raise_softirq_batch_finish(void) void raise_softirq(unsigned int nr) { - set_bit(nr, &softirq_pending(smp_processor_id())); + unsigned int cpu = smp_processor_id(); + set_bit(nr, &softirq_pending(cpu)); } /*