From patchwork Thu Dec 11 12:19:23 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 42145 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f72.google.com (mail-la0-f72.google.com [209.85.215.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 7D7FB26C6D for ; Thu, 11 Dec 2014 12:38:43 +0000 (UTC) Received: by mail-la0-f72.google.com with SMTP id gq15sf3364579lab.11 for ; Thu, 11 Dec 2014 04:38:42 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:date :message-id:in-reply-to:references:subject:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:list-subscribe :errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list; bh=OAp2JGP5aY30v10EsG9YDVfdJ13j5hd2XSrNj9m6bt4=; b=YeEmCv4A8ruJdhkQiVwdlQFkJ53rpYX9lkofDfDYMUP28WUbhsFxjmTLPvRQbrmjEI 219UwCcxNO3h5V36bTAp5d87SSPTlFfu1KoUjI0gX0E0HJw1L6sCR/SyGvPDXk6bs5hm xRNt8/szLYduCIvwX6oY8MFTgYWyBNIPRmwFg2CUnGA6rF9pHjgpjIQlBc5xsLvOfs+y Xx28a79Wzbv6T3IULp1xSYTev2tgy3Vig9wVHr7DE6t+EMhTavKdte7yRur2ICfadnqx LBf9zhMRMM/9Ol95+wdSyb5K4saI8Oft9vr9cZybZSnvcW3fMXqgBS8apDdsI7lOh7XX NgOg== X-Gm-Message-State: ALoCoQk8oh2XIl3HBDceFRpmDCnRHwffvim7NC/c/h7yQKtUwtcia4B/LgpkqoWxhQlF4glcPMKK X-Received: by 10.180.24.131 with SMTP id u3mr2470830wif.4.1418301522179; Thu, 11 Dec 2014 04:38:42 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.28.137 with SMTP id b9ls313679lah.29.gmail; Thu, 11 Dec 2014 04:38:41 -0800 (PST) X-Received: by 10.112.170.7 with SMTP id ai7mr9742039lbc.67.1418301521752; Thu, 11 Dec 2014 04:38:41 -0800 (PST) Received: from mail-la0-f47.google.com (mail-la0-f47.google.com. [209.85.215.47]) by mx.google.com with ESMTPS id tf9si1162583lbb.67.2014.12.11.04.38.41 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 11 Dec 2014 04:38:41 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.47 as permitted sender) client-ip=209.85.215.47; Received: by mail-la0-f47.google.com with SMTP id hz20so4089128lab.6 for ; Thu, 11 Dec 2014 04:38:41 -0800 (PST) X-Received: by 10.152.2.74 with SMTP id 10mr9519700las.38.1418301521600; Thu, 11 Dec 2014 04:38:41 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.142.69 with SMTP id ru5csp508333lbb; Thu, 11 Dec 2014 04:38:40 -0800 (PST) X-Received: by 10.140.100.228 with SMTP id s91mr18418151qge.31.1418301519990; Thu, 11 Dec 2014 04:38:39 -0800 (PST) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id s7si1091803qas.40.2014.12.11.04.38.39 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 11 Dec 2014 04:38:39 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Received: from localhost ([::1]:50677 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xz30x-00019k-1S for patch@linaro.org; Thu, 11 Dec 2014 07:38:39 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44762) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xz2j8-00058Q-Tq for qemu-devel@nongnu.org; Thu, 11 Dec 2014 07:20:19 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Xz2j7-0007WC-S4 for qemu-devel@nongnu.org; Thu, 11 Dec 2014 07:20:14 -0500 Received: from mnementh.archaic.org.uk ([2001:8b0:1d0::1]:54567) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xz2j7-0006sg-Ks for qemu-devel@nongnu.org; Thu, 11 Dec 2014 07:20:13 -0500 Received: from pm215 by mnementh.archaic.org.uk with local (Exim 4.80) (envelope-from ) id 1Xz2ip-00018f-DW for qemu-devel@nongnu.org; Thu, 11 Dec 2014 12:19:55 +0000 From: Peter Maydell To: qemu-devel@nongnu.org Date: Thu, 11 Dec 2014 12:19:23 +0000 Message-Id: <1418300395-4348-2-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1418300395-4348-1-git-send-email-peter.maydell@linaro.org> References: <1418300395-4348-1-git-send-email-peter.maydell@linaro.org> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:8b0:1d0::1 Subject: [Qemu-devel] [PULL 01/33] Pass semihosting exit code back to system. X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: peter.maydell@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.47 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 From: Liviu Ionescu In order to run unit tests under semihosting, it is necessary to pass the application exit code back to the system. ARM defines only the code to be used for non-error application exit (ADP_Stopped_ApplicationExit), all other codes should return non-zero exit codes. This patch checks if the application code passed via TARGET_SYS_EXIT is ADP_Stopped_ApplicationExit, and return 0, otherwise return 1. Signed-off-by: Liviu Ionescu Signed-off-by: Peter Maydell --- target-arm/arm-semi.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/target-arm/arm-semi.c b/target-arm/arm-semi.c index ebb5235..a8b83e6 100644 --- a/target-arm/arm-semi.c +++ b/target-arm/arm-semi.c @@ -58,6 +58,10 @@ #define TARGET_SYS_HEAPINFO 0x16 #define TARGET_SYS_EXIT 0x18 +/* ADP_Stopped_ApplicationExit is used for exit(0), + * anything else is implemented as exit(1) */ +#define ADP_Stopped_ApplicationExit (0x20026) + #ifndef O_BINARY #define O_BINARY 0 #endif @@ -551,8 +555,11 @@ uint32_t do_arm_semihosting(CPUARMState *env) return 0; } case TARGET_SYS_EXIT: - gdb_exit(env, 0); - exit(0); + /* ARM specifies only Stopped_ApplicationExit as normal + * exit, everything else is considered an error */ + ret = (args == ADP_Stopped_ApplicationExit) ? 0 : 1; + gdb_exit(env, ret); + exit(ret); default: fprintf(stderr, "qemu: Unsupported SemiHosting SWI 0x%02x\n", nr); cpu_dump_state(cs, stderr, fprintf, 0);