From patchwork Mon Oct 14 16:23:31 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Jones X-Patchwork-Id: 3037651 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 5845F9F2B7 for ; Mon, 14 Oct 2013 16:24:22 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5F0002021E for ; Mon, 14 Oct 2013 16:24:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 494572020E for ; Mon, 14 Oct 2013 16:24:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756977Ab3JNQYH (ORCPT ); Mon, 14 Oct 2013 12:24:07 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41040 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755616Ab3JNQYG (ORCPT ); Mon, 14 Oct 2013 12:24:06 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r9EGNnUL019674 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 14 Oct 2013 12:23:49 -0400 Received: from hawk.usersys.redhat.com.com (vpn1-6-144.ams2.redhat.com [10.36.6.144]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r9EGNbux017054; Mon, 14 Oct 2013 12:23:48 -0400 From: Andrew Jones To: kvm@vger.kernel.org Cc: kvmarm@lists.cs.columbia.edu, gleb@redhat.com, christoffer.dall@linaro.org Subject: [PATCH 5/9] Add halt() and some error codes Date: Mon, 14 Oct 2013 18:23:31 +0200 Message-Id: <1381767815-12510-6-git-send-email-drjones@redhat.com> In-Reply-To: <1381767815-12510-1-git-send-email-drjones@redhat.com> References: <1381767815-12510-1-git-send-email-drjones@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add a halt function that can be used by the test infrastructure on error paths before exit() works. Also add some error codes that can be passed to halt() in case the serial isn't working either. Then, on register inspection of the halted guest we may be able to quickly determine the problem without having to find the halt() call-site using its return address. Signed-off-by: Andrew Jones --- lib/errno.h | 15 +++++++++++++++ lib/libcflat.h | 2 ++ lib/x86/io.c | 6 ++++++ 3 files changed, 23 insertions(+) create mode 100644 lib/errno.h diff --git a/lib/errno.h b/lib/errno.h new file mode 100644 index 0000000000000..4c7478229baf3 --- /dev/null +++ b/lib/errno.h @@ -0,0 +1,15 @@ +#ifndef _ERRNO_H_ +#define _ERRNO_H_ +/* + * Define some error codes for the test infrastructure's use. + * (Ab)use the standard E* names for syntax highlighting... + */ +#define MAXERR 127 /* exit(-1) */ +#define EINTR (MAXERR - 1) /* unhandled exception */ +#define EIO (MAXERR - 2) /* I/O error */ +#define ENXIO (MAXERR - 3) /* no serial */ +#define ENOEXEC (MAXERR - 4) /* bad test file format */ +#define ENOMEM (MAXERR - 5) /* Out of memory */ +#define ENODEV (MAXERR - 6) /* no testdev device */ +#define EINVAL (MAXERR - 7) /* Invalid argument */ +#endif diff --git a/lib/libcflat.h b/lib/libcflat.h index 140c172e77d54..a1be635ab4ee9 100644 --- a/lib/libcflat.h +++ b/lib/libcflat.h @@ -37,6 +37,7 @@ typedef _Bool bool; #define true 1 #define false 0 +extern void halt(int code); extern void exit(int code); extern unsigned long strlen(const char *buf); @@ -57,4 +58,5 @@ extern long atol(const char *ptr); #define offsetof(TYPE, MEMBER) __builtin_offsetof (TYPE, MEMBER) #define NULL ((void *)0UL) +#include "errno.h" #endif diff --git a/lib/x86/io.c b/lib/x86/io.c index d3b971ef67b0e..7a36c9ca0c951 100644 --- a/lib/x86/io.c +++ b/lib/x86/io.c @@ -1,4 +1,5 @@ #include "libcflat.h" +#include "processor.h" #include "smp.h" #include "io.h" #ifndef USE_SERIAL @@ -81,3 +82,8 @@ void exit(int code) asm volatile("out %0, %1" : : "a"(code), "d"((short)0xf4)); #endif } + +void halt(int code) +{ + safe_halt(); +}