From patchwork Fri Jul 20 15:39:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Przywara X-Patchwork-Id: 10537871 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id CBEDE603B5 for ; Fri, 20 Jul 2018 15:41:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AEBF7298DB for ; Fri, 20 Jul 2018 15:41:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AC1582995A; Fri, 20 Jul 2018 15:41:35 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 198602990C for ; Fri, 20 Jul 2018 15:41:35 +0000 (UTC) Received: from localhost ([::1]:48655 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fgXXC-0000DZ-9R for patchwork-qemu-devel@patchwork.kernel.org; Fri, 20 Jul 2018 11:41:34 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57607) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fgXVd-0007PW-8Q for qemu-devel@nongnu.org; Fri, 20 Jul 2018 11:39:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fgXVa-0008Fn-Hw for qemu-devel@nongnu.org; Fri, 20 Jul 2018 11:39:57 -0400 Received: from foss.arm.com ([217.140.101.70]:46148) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fgXVa-0008Em-BK for qemu-devel@nongnu.org; Fri, 20 Jul 2018 11:39:54 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id C1FC415A2; Fri, 20 Jul 2018 08:39:53 -0700 (PDT) Received: from e104803-lin.cambridge.arm.com (e104803-lin.cambridge.arm.com [10.1.206.130]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 263D03F5B3; Fri, 20 Jul 2018 08:39:52 -0700 (PDT) From: Andre Przywara To: Andrew Jones Date: Fri, 20 Jul 2018 16:39:39 +0100 Message-Id: <20180720153942.26821-2-andre.przywara@arm.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180720153942.26821-1-andre.przywara@arm.com> References: <20180720153942.26821-1-andre.przywara@arm.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 217.140.101.70 Subject: [Qemu-devel] [kvm-unit-tests PATCH v2 1/4] mark exit() and abort() as non-returning functions X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , kvm@vger.kernel.org, Marc Zyngier , Christoffer Dall , qemu-devel@nongnu.org, Eric Auger , kvmarm@lists.cs.columbia.edu Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP exit() and abort() are functions that never return, and (at least) GCC has an attribute to flag those functions accordingly. This allows the compiler to do further optimizations and to omit various warnings about uninitialized variables, for instance. Since the actual "play-dead" function is in (inline) assembly, the compiler does not recognize its fatal nature, so help it with the __builtin_unreachable() hint. Flag the prototypes of our fatal functions accordingly. Signed-off-by: Andre Przywara Reviewed-by: Andrew Jones --- lib/arm/io.c | 1 + lib/libcflat.h | 7 ++++--- lib/powerpc/io.c | 1 + lib/x86/io.c | 1 + 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/arm/io.c b/lib/arm/io.c index 603456f..d2c1a07 100644 --- a/lib/arm/io.c +++ b/lib/arm/io.c @@ -83,4 +83,5 @@ void exit(int code) { chr_testdev_exit(code); halt(code); + __builtin_unreachable(); } diff --git a/lib/libcflat.h b/lib/libcflat.h index cc56553..7529958 100644 --- a/lib/libcflat.h +++ b/lib/libcflat.h @@ -84,8 +84,8 @@ typedef u64 phys_addr_t; extern void puts(const char *s); extern int __getchar(void); extern int getchar(void); -extern void exit(int code); -extern void abort(void); +extern void exit(int code) __attribute__((noreturn)); +extern void abort(void) __attribute__((noreturn)); extern long atol(const char *ptr); extern char *getenv(const char *name); @@ -107,7 +107,8 @@ extern void report(const char *msg_fmt, bool pass, ...) extern void report_xfail(const char *msg_fmt, bool xfail, bool pass, ...) __attribute__((format(printf, 1, 4))); extern void report_abort(const char *msg_fmt, ...) - __attribute__((format(printf, 1, 2))); + __attribute__((format(printf, 1, 2))) + __attribute__((noreturn)); extern void report_skip(const char *msg_fmt, ...) __attribute__((format(printf, 1, 2))); extern void report_info(const char *msg_fmt, ...) diff --git a/lib/powerpc/io.c b/lib/powerpc/io.c index 915e12e..217eb07 100644 --- a/lib/powerpc/io.c +++ b/lib/powerpc/io.c @@ -35,4 +35,5 @@ void exit(int code) printf("\nEXIT: STATUS=%d\n", ((code) << 1) | 1); rtas_power_off(); halt(code); + __builtin_unreachable(); } diff --git a/lib/x86/io.c b/lib/x86/io.c index 7e1c16d..057f579 100644 --- a/lib/x86/io.c +++ b/lib/x86/io.c @@ -82,6 +82,7 @@ void exit(int code) #else asm volatile("out %0, %1" : : "a"(code), "d"((short)0xf4)); #endif + __builtin_unreachable(); } void __iomem *ioremap(phys_addr_t phys_addr, size_t size)