From patchwork Wed Oct 18 14:18:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simone Ballarin X-Patchwork-Id: 13427158 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 84A92CDB483 for ; Wed, 18 Oct 2023 14:19:08 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.618595.962442 (Exim 4.92) (envelope-from ) id 1qt7Ny-0005UC-UL; Wed, 18 Oct 2023 14:18:58 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 618595.962442; Wed, 18 Oct 2023 14:18:58 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qt7Ny-0005U5-RO; Wed, 18 Oct 2023 14:18:58 +0000 Received: by outflank-mailman (input) for mailman id 618595; Wed, 18 Oct 2023 14:18:57 +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 1qt7Nx-0004vw-B0 for xen-devel@lists.xenproject.org; Wed, 18 Oct 2023 14:18:57 +0000 Received: from support.bugseng.com (mail.bugseng.com [162.55.131.47]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 44dd416c-6dc1-11ee-9b0e-b553b5be7939; Wed, 18 Oct 2023 16:18:54 +0200 (CEST) Received: from beta.station (net-188-218-250-245.cust.vodafonedsl.it [188.218.250.245]) by support.bugseng.com (Postfix) with ESMTPSA id 4169E4EE0740; Wed, 18 Oct 2023 16:18:54 +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: 44dd416c-6dc1-11ee-9b0e-b553b5be7939 From: Simone Ballarin To: xen-devel@lists.xenproject.org Cc: consulting@bugseng.com, sstabellini@kernel.org, Simone Ballarin , Julien Grall , Bertrand Marquis , Volodymyr Babchuk Subject: [XEN PATCH 1/4] xen/arm: address violations of MISRA C:2012 Rule 13.1 Date: Wed, 18 Oct 2023 16:18:48 +0200 Message-Id: <31a926a09dfcef43d13a402fd3b235aeba48009d.1697638210.git.simone.ballarin@bugseng.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 Rule 13.1: Initializer lists shall not contain persistent side effects This patch moves expressions with side-effects into new variables before the initializer lists. Function calls do not necessarily have side-effects, in these cases the GCC pure or const attributes are added when possible. No functional changes. Signed-off-by: Simone Ballarin --- Function attributes pure and const do not need to be added as GCC attributes, they can be added using ECLAIR configurations. --- xen/arch/arm/device.c | 6 +++--- xen/arch/arm/guestcopy.c | 12 ++++++++---- xen/arch/arm/include/asm/current.h | 2 +- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/xen/arch/arm/device.c b/xen/arch/arm/device.c index 1f631d3274..e9be078415 100644 --- a/xen/arch/arm/device.c +++ b/xen/arch/arm/device.c @@ -319,6 +319,8 @@ int handle_device(struct domain *d, struct dt_device_node *dev, p2m_type_t p2mt, int res; paddr_t addr, size; bool own_device = !dt_device_for_passthrough(dev); + bool dev_is_hostbridge = is_pci_passthrough_enabled() && + device_get_class(dev) == DEVICE_PCI_HOSTBRIDGE; /* * We want to avoid mapping the MMIO in dom0 for the following cases: * - The device is owned by dom0 (i.e. it has been flagged for @@ -329,9 +331,7 @@ int handle_device(struct domain *d, struct dt_device_node *dev, p2m_type_t p2mt, struct map_range_data mr_data = { .d = d, .p2mt = p2mt, - .skip_mapping = !own_device || - (is_pci_passthrough_enabled() && - (device_get_class(dev) == DEVICE_PCI_HOSTBRIDGE)), + .skip_mapping = !own_device || dev_is_hostbridge, .iomem_ranges = iomem_ranges, .irq_ranges = irq_ranges }; diff --git a/xen/arch/arm/guestcopy.c b/xen/arch/arm/guestcopy.c index 6716b03561..3ec6743bf6 100644 --- a/xen/arch/arm/guestcopy.c +++ b/xen/arch/arm/guestcopy.c @@ -109,27 +109,31 @@ static unsigned long copy_guest(void *buf, uint64_t addr, unsigned int len, unsigned long raw_copy_to_guest(void *to, const void *from, unsigned int len) { + struct vcpu *current_vcpu = current; return copy_guest((void *)from, (vaddr_t)to, len, - GVA_INFO(current), COPY_to_guest | COPY_linear); + GVA_INFO(current_vcpu), COPY_to_guest | COPY_linear); } unsigned long raw_copy_to_guest_flush_dcache(void *to, const void *from, unsigned int len) { - return copy_guest((void *)from, (vaddr_t)to, len, GVA_INFO(current), + struct vcpu *current_vcpu = current; + return copy_guest((void *)from, (vaddr_t)to, len, GVA_INFO(current_vcpu), COPY_to_guest | COPY_flush_dcache | COPY_linear); } unsigned long raw_clear_guest(void *to, unsigned int len) { - return copy_guest(NULL, (vaddr_t)to, len, GVA_INFO(current), + struct vcpu *current_vcpu = current; + return copy_guest(NULL, (vaddr_t)to, len, GVA_INFO(current_vcpu), COPY_to_guest | COPY_linear); } unsigned long raw_copy_from_guest(void *to, const void __user *from, unsigned int len) { - return copy_guest(to, (vaddr_t)from, len, GVA_INFO(current), + struct vcpu *current_vcpu = current; + return copy_guest(to, (vaddr_t)from, len, GVA_INFO(current_vcpu), COPY_from_guest | COPY_linear); } diff --git a/xen/arch/arm/include/asm/current.h b/xen/arch/arm/include/asm/current.h index 6973eeb1d1..a66e28fefb 100644 --- a/xen/arch/arm/include/asm/current.h +++ b/xen/arch/arm/include/asm/current.h @@ -28,7 +28,7 @@ struct cpu_info { uint32_t flags; }; -static inline struct cpu_info *get_cpu_info(void) +static inline __attribute_pure__ struct cpu_info *get_cpu_info(void) { #ifdef __clang__ unsigned long sp; From patchwork Wed Oct 18 14:18:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simone Ballarin X-Patchwork-Id: 13427160 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 86B26CDB482 for ; Wed, 18 Oct 2023 14:19:09 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.618597.962454 (Exim 4.92) (envelope-from ) id 1qt7Nz-0005fX-O1; Wed, 18 Oct 2023 14:18:59 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 618597.962454; Wed, 18 Oct 2023 14:18:59 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qt7Nz-0005eA-HF; Wed, 18 Oct 2023 14:18:59 +0000 Received: by outflank-mailman (input) for mailman id 618597; Wed, 18 Oct 2023 14:18:58 +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 1qt7Ny-0004vw-BC for xen-devel@lists.xenproject.org; Wed, 18 Oct 2023 14:18:58 +0000 Received: from support.bugseng.com (mail.bugseng.com [162.55.131.47]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 4527c161-6dc1-11ee-9b0e-b553b5be7939; Wed, 18 Oct 2023 16:18:55 +0200 (CEST) Received: from beta.station (net-188-218-250-245.cust.vodafonedsl.it [188.218.250.245]) by support.bugseng.com (Postfix) with ESMTPSA id A47764EE0743; Wed, 18 Oct 2023 16:18:54 +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: 4527c161-6dc1-11ee-9b0e-b553b5be7939 From: Simone Ballarin To: xen-devel@lists.xenproject.org Cc: consulting@bugseng.com, sstabellini@kernel.org, Simone Ballarin , Doug Goldstein , Andrew Cooper , George Dunlap , Jan Beulich , Julien Grall , Wei Liu Subject: [XEN PATCH 2/4] automation/eclair: add deviations and call properties. Date: Wed, 18 Oct 2023 16:18:49 +0200 Message-Id: <8f426cc761c734d457a74416dd5b83fd10128c26.1697638210.git.simone.ballarin@bugseng.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 Deviate violations of MISRA C:2012 Rule 13.1 caused by functions vcpu_runnable and __bad_atomic_size. These functions contain side-effects such as debugging logs, assertions and failures that cannot cause unexpected behaviors. Add "noeffect" call property to functions read_u.*_atomic and get_cycles. Signed-off-by: Simone Ballarin Acked-by: Stefano Stabellini --- .../eclair_analysis/ECLAIR/call_properties.ecl | 10 ++++++++++ automation/eclair_analysis/ECLAIR/deviations.ecl | 13 +++++++++++++ docs/misra/deviations.rst | 11 +++++++++++ 3 files changed, 34 insertions(+) diff --git a/automation/eclair_analysis/ECLAIR/call_properties.ecl b/automation/eclair_analysis/ECLAIR/call_properties.ecl index 3f7794bf8b..f410a6aa58 100644 --- a/automation/eclair_analysis/ECLAIR/call_properties.ecl +++ b/automation/eclair_analysis/ECLAIR/call_properties.ecl @@ -104,3 +104,13 @@ Furthermore, their uses do initialize the involved variables as needed by futher -call_properties+={"macro(^(__)?(raw_)?copy_from_(paddr|guest|compat)(_offset)?$)", {"pointee_write(1=always)", "pointee_read(1=never)", "taken()"}} -call_properties+={"macro(^(__)?copy_to_(guest|compat)(_offset)?$)", {"pointee_write(2=always)", "pointee_read(2=never)", "taken()"}} -doc_end + +-doc_begin="Functions generated by build_atomic_read cannot be considered pure +since the input pointer is volatile." +-call_properties+={"^read_u(8|16|32|64|int)_atomic.*$", {"noeffect"}} +-doc_end + +-doc_begin="get_cycles does not perform visible side-effects " +-call_property+={"name(get_cycles)", {"noeffect"}} +-doc_end + diff --git a/automation/eclair_analysis/ECLAIR/deviations.ecl b/automation/eclair_analysis/ECLAIR/deviations.ecl index fa56e5c00a..b80ccea7bc 100644 --- a/automation/eclair_analysis/ECLAIR/deviations.ecl +++ b/automation/eclair_analysis/ECLAIR/deviations.ecl @@ -233,6 +233,19 @@ this." -config=MC3R1.R10.1,etypes+={safe, "stmt(operator(and||or||xor||not||and_assign||or_assign||xor_assign))", "any()"} +# +# Series 13. +# + +-doc_begin="Function __bad_atomic_size is intended to generate a linkage error +if invoked. Calling it in intentionally unreachable switch cases is safe even +in a initializer list." +-config=MC3R1.R13.1,reports+={safe, "first_area(^.*__bad_atomic_size.*$)"} +-doc_end + +-doc_begin="Function vcpu_runnable contains pragmas and other side-effects for +debugging purposes, their invocation is safe even in a initializer list." +-config=MC3R1.R13.1,reports+={safe, "first_area(^.*vcpu_runnable.*$)"} -doc_end -doc_begin="See Section \"4.5 Integers\" of \"GCC_MANUAL\", where it says that diff --git a/docs/misra/deviations.rst b/docs/misra/deviations.rst index 8511a18925..2fcdb8da58 100644 --- a/docs/misra/deviations.rst +++ b/docs/misra/deviations.rst @@ -192,6 +192,17 @@ Deviations related to MISRA C:2012 Rules: See automation/eclair_analysis/deviations.ecl for the full explanation. - Tagged as `safe` for ECLAIR. + * - R13.1 + - Function __bad_atomic_size is intended to generate a linkage error if + invoked. Calling it in intentionally unreachable switch cases is + safe even in a initializer list. + - Tagged as `safe` for ECLAIR. + + * - R13.1 + - Function vcpu_runnable contains pragmas and other side-effects for + debugging purposes, their invocation is safe even in a initializer list. + - Tagged as `safe` for ECLAIR. + * - R13.5 - All developers and reviewers can be safely assumed to be well aware of the short-circuit evaluation strategy for logical operators. From patchwork Wed Oct 18 14:18:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simone Ballarin X-Patchwork-Id: 13427162 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 CD67DCDB484 for ; Wed, 18 Oct 2023 14:19:19 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.618598.962470 (Exim 4.92) (envelope-from ) id 1qt7O0-0006C5-U0; Wed, 18 Oct 2023 14:19:00 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 618598.962470; Wed, 18 Oct 2023 14:19:00 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qt7O0-0006Al-Qa; Wed, 18 Oct 2023 14:19:00 +0000 Received: by outflank-mailman (input) for mailman id 618598; Wed, 18 Oct 2023 14:18:59 +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 1qt7Nz-0004vw-BS for xen-devel@lists.xenproject.org; Wed, 18 Oct 2023 14:18:59 +0000 Received: from support.bugseng.com (mail.bugseng.com [162.55.131.47]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 4570c89c-6dc1-11ee-9b0e-b553b5be7939; Wed, 18 Oct 2023 16:18:55 +0200 (CEST) Received: from beta.station (net-188-218-250-245.cust.vodafonedsl.it [188.218.250.245]) by support.bugseng.com (Postfix) with ESMTPSA id 2CA834EE0741; Wed, 18 Oct 2023 16:18:55 +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: 4570c89c-6dc1-11ee-9b0e-b553b5be7939 From: Simone Ballarin To: xen-devel@lists.xenproject.org Cc: consulting@bugseng.com, sstabellini@kernel.org, Simone Ballarin , Andrew Cooper , George Dunlap , Jan Beulich , Julien Grall , Wei Liu Subject: [XEN PATCH 3/4] xen/include: add pure and const attributes Date: Wed, 18 Oct 2023 16:18:50 +0200 Message-Id: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 Add const and pure attributes to address reports of MISRA C:2012 Rule 13.1: Initializer lists shall not contain persistent side effects Add pure attribute to function pdx_to_pfn. Add const attribute to functions generated by TYPE_SAFE. These functions are used in initializer lists: adding the attributes ensures that no effect will be performed by them. Signed-off-by: Simone Ballarin Reviewed-by: Stefano Stabellini --- Function attributes pure and const do not need to be added as GCC attributes, they can be added using ECLAIR configurations. --- xen/include/xen/pdx.h | 2 +- xen/include/xen/typesafe.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/xen/include/xen/pdx.h b/xen/include/xen/pdx.h index f3fbc4273a..5d1050967a 100644 --- a/xen/include/xen/pdx.h +++ b/xen/include/xen/pdx.h @@ -164,7 +164,7 @@ static inline unsigned long pfn_to_pdx(unsigned long pfn) * @param pdx Page index * @return Obtained pfn after decompressing the pdx */ -static inline unsigned long pdx_to_pfn(unsigned long pdx) +static inline __attribute_pure__ unsigned long pdx_to_pfn(unsigned long pdx) { return (pdx & pfn_pdx_bottom_mask) | ((pdx << pfn_pdx_hole_shift) & pfn_top_mask); diff --git a/xen/include/xen/typesafe.h b/xen/include/xen/typesafe.h index 7ecd3b4a8d..615df6f944 100644 --- a/xen/include/xen/typesafe.h +++ b/xen/include/xen/typesafe.h @@ -21,8 +21,8 @@ #define TYPE_SAFE(_type, _name) \ typedef struct { _type _name; } _name##_t; \ - static inline _name##_t _##_name(_type n) { return (_name##_t) { n }; } \ - static inline _type _name##_x(_name##_t n) { return n._name; } + static inline __attribute_const__ _name##_t _##_name(_type n) { return (_name##_t) { n }; } \ + static inline __attribute_const__ _type _name##_x(_name##_t n) { return n._name; } #else From patchwork Wed Oct 18 14:18:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simone Ballarin X-Patchwork-Id: 13427161 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 3688CCDB47E for ; Wed, 18 Oct 2023 14:19:18 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.618596.962448 (Exim 4.92) (envelope-from ) id 1qt7Nz-0005Xw-Az; Wed, 18 Oct 2023 14:18:59 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 618596.962448; Wed, 18 Oct 2023 14:18:59 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qt7Nz-0005Ws-3s; Wed, 18 Oct 2023 14:18:59 +0000 Received: by outflank-mailman (input) for mailman id 618596; Wed, 18 Oct 2023 14:18:57 +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 1qt7Nx-0005Dj-J1 for xen-devel@lists.xenproject.org; Wed, 18 Oct 2023 14:18:57 +0000 Received: from support.bugseng.com (mail.bugseng.com [162.55.131.47]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 45c0c852-6dc1-11ee-98d4-6d05b1d4d9a1; Wed, 18 Oct 2023 16:18:56 +0200 (CEST) Received: from beta.station (net-188-218-250-245.cust.vodafonedsl.it [188.218.250.245]) by support.bugseng.com (Postfix) with ESMTPSA id A09F04EE0744; Wed, 18 Oct 2023 16:18:55 +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: 45c0c852-6dc1-11ee-98d4-6d05b1d4d9a1 From: Simone Ballarin To: xen-devel@lists.xenproject.org Cc: consulting@bugseng.com, sstabellini@kernel.org, Simone Ballarin , George Dunlap , Dario Faggioli , Andrew Cooper , Jan Beulich , Julien Grall , Wei Liu Subject: [XEN PATCH 4/4] xen: address violations of MISRA C:2012 Rule 13.1 Date: Wed, 18 Oct 2023 16:18:51 +0200 Message-Id: <1e0f12095bcbc82ae3585c9fcf57bec7e324049c.1697638210.git.simone.ballarin@bugseng.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 Rule 13.1: Initializer lists shall not contain persistent side effects This patch moves expressions with side-effects outside the initializer lists. No functional changes. Signed-off-by: Simone Ballarin --- xen/common/sched/core.c | 16 ++++++++++++---- xen/drivers/char/ns16550.c | 4 +++- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/xen/common/sched/core.c b/xen/common/sched/core.c index 12deefa745..519884f989 100644 --- a/xen/common/sched/core.c +++ b/xen/common/sched/core.c @@ -1504,6 +1504,8 @@ long vcpu_yield(void) { struct vcpu * v=current; spinlock_t *lock; + domid_t domain_id; + int vcpu_id; rcu_read_lock(&sched_res_rculock); @@ -1515,7 +1517,9 @@ long vcpu_yield(void) SCHED_STAT_CRANK(vcpu_yield); - TRACE_2D(TRC_SCHED_YIELD, current->domain->domain_id, current->vcpu_id); + domain_id = current->domain->domain_id; + vcpu_id = current->vcpu_id; + TRACE_2D(TRC_SCHED_YIELD, domain_id, vcpu_id); raise_softirq(SCHEDULE_SOFTIRQ); return 0; } @@ -1888,14 +1892,17 @@ ret_t do_sched_op(int cmd, XEN_GUEST_HANDLE_PARAM(void) arg) case SCHEDOP_shutdown: { struct sched_shutdown sched_shutdown; + domid_t domain_id; + int vcpu_id; ret = -EFAULT; if ( copy_from_guest(&sched_shutdown, arg, 1) ) break; + domain_id = current->domain->domain_id; + vcpu_id = current->vcpu_id; TRACE_3D(TRC_SCHED_SHUTDOWN, - current->domain->domain_id, current->vcpu_id, - sched_shutdown.reason); + domain_id, vcpu_id, sched_shutdown.reason); ret = domain_shutdown(current->domain, (u8)sched_shutdown.reason); break; @@ -1905,13 +1912,14 @@ ret_t do_sched_op(int cmd, XEN_GUEST_HANDLE_PARAM(void) arg) { struct sched_shutdown sched_shutdown; struct domain *d = current->domain; + int vcpu_id = current->vcpu_id; ret = -EFAULT; if ( copy_from_guest(&sched_shutdown, arg, 1) ) break; TRACE_3D(TRC_SCHED_SHUTDOWN_CODE, - d->domain_id, current->vcpu_id, sched_shutdown.reason); + d->domain_id, vcpu_id, sched_shutdown.reason); spin_lock(&d->shutdown_lock); if ( d->shutdown_code == SHUTDOWN_CODE_INVALID ) diff --git a/xen/drivers/char/ns16550.c b/xen/drivers/char/ns16550.c index 28ddedd50d..0b3d8b2a30 100644 --- a/xen/drivers/char/ns16550.c +++ b/xen/drivers/char/ns16550.c @@ -445,10 +445,12 @@ static void __init cf_check ns16550_init_postirq(struct serial_port *port) struct msi_info msi = { .sbdf = PCI_SBDF(0, uart->ps_bdf[0], uart->ps_bdf[1], uart->ps_bdf[2]), - .irq = rc = uart->irq, + .irq = uart->irq, .entry_nr = 1 }; + rc = uart->irq; + if ( rc > 0 ) { struct msi_desc *msi_desc = NULL;