From patchwork Tue Feb 20 13:35:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Federico Serafini X-Patchwork-Id: 13564019 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 0A3FFC5475B for ; Tue, 20 Feb 2024 13:35:59 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.683532.1063093 (Exim 4.92) (envelope-from ) id 1rcQHW-00026s-9K; Tue, 20 Feb 2024 13:35:34 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 683532.1063093; Tue, 20 Feb 2024 13:35:34 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1rcQHW-00026l-5m; Tue, 20 Feb 2024 13:35:34 +0000 Received: by outflank-mailman (input) for mailman id 683532; Tue, 20 Feb 2024 13:35:32 +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 1rcQHU-00026f-I1 for xen-devel@lists.xenproject.org; Tue, 20 Feb 2024 13:35:32 +0000 Received: from support.bugseng.com (mail.bugseng.com [162.55.131.47]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id ea744172-cff4-11ee-8a52-1f161083a0e0; Tue, 20 Feb 2024 14:35:31 +0100 (CET) Received: from Dell.bugseng.com (unknown [37.163.67.214]) by support.bugseng.com (Postfix) with ESMTPSA id 78BC44EE073A; Tue, 20 Feb 2024 14:35:29 +0100 (CET) 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: ea744172-cff4-11ee-8a52-1f161083a0e0 From: Federico Serafini To: xen-devel@lists.xenproject.org Cc: consulting@bugseng.com, Federico Serafini , Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , Wei Liu Subject: [XEN PATCH] x86/uaccess: add attribute noreturn to __{get,put}_user_bad() Date: Tue, 20 Feb 2024 14:35:20 +0100 Message-Id: <1595eac56587d20c7f86128bc5652c31c3a72772.1708436010.git.federico.serafini@bugseng.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 __get_user_bad() and __put_user_bad() are undefined symbols used to assert the unreachability of a program point: a call to one of such functions is optimized away if it is considered unreachable by the compiler. Otherwise, a linker error is reported. In accordance with the purpose of such constructs: 1) add the attribute noreturn to __get_user_bad() and __put_user_bad(); 2) change return type of __get_user_bad() to void (returning long is a leftover from the past). Point (1) meets the requirements to deviate MISRA C:2012 Rule 16.3 ("An unconditional break statement shall terminate every switch clause") since functions with noreturn attribute are considered as allowed terminals for switch clauses. Point (2) addresses several violations of MISRA C:2012 Rule 17.7 ("The value returned by a function having non-void return type shall be used"). No functional change. Signed-off-by: Federico Serafini Reviewed-by: Jan Beulich --- xen/arch/x86/include/asm/uaccess.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xen/arch/x86/include/asm/uaccess.h b/xen/arch/x86/include/asm/uaccess.h index 7443519d5b..c7bafaf10f 100644 --- a/xen/arch/x86/include/asm/uaccess.h +++ b/xen/arch/x86/include/asm/uaccess.h @@ -21,8 +21,8 @@ unsigned int copy_from_guest_ll(void *to, const void __user *from, unsigned int unsigned int copy_to_unsafe_ll(void *to, const void *from, unsigned int n); unsigned int copy_from_unsafe_ll(void *to, const void *from, unsigned int n); -extern long __get_user_bad(void); -extern void __put_user_bad(void); +extern void noreturn __get_user_bad(void); +extern void noreturn __put_user_bad(void); #define UA_KEEP(args...) args #define UA_DROP(args...)