[kvm-unit-tests PATCH v2 1/6] x86: clean up exit use, use abort

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Change all exit()'s for the purpose of aborts to abort()'s. This changes
a handful of exit(-1)'s, which resulted in a 255 exit status (putting
the status in signal territory) to a 127 exit status (just below signal
territory), as 127 is defined as the unittest abort. Yes, stdlib would
use SIGABRT resulting in 134, but, well, we do what we can...

Signed-off-by: Andrew Jones <drjones@xxxxxxxxxx>
Reviewed-by: Radim Krčmář <rkrcmar@xxxxxxxxxx>
---
 lib/x86/desc.c            | 4 ++--
 x86/hyperv_stimer.c       | 9 +++------
 x86/pku.c                 | 4 ++--
 x86/smap.c                | 4 ++--
 x86/tscdeadline_latency.c | 4 ++--
 x86/vmx.c                 | 2 +-
 6 files changed, 12 insertions(+), 15 deletions(-)

diff --git a/lib/x86/desc.c b/lib/x86/desc.c
index 1a80c01283853..dd07d2c91d769 100644
--- a/lib/x86/desc.c
+++ b/lib/x86/desc.c
@@ -54,7 +54,7 @@ static void check_exception_table(struct ex_regs *regs)
         }
     }
     printf("unhandled exception %d\n", regs->vector);
-    exit(7);
+    abort();
 }
 
 static void (*exception_handlers[32])(struct ex_regs *regs);
@@ -78,7 +78,7 @@ void do_handle_exception(struct ex_regs *regs)
 	printf("unhandled cpu exception %d\n", regs->vector);
 	if (regs->vector == 14)
 		printf("PF at %p addr %p\n", regs->rip, read_cr2());
-	exit(7);
+	abort();
 }
 
 #define EX(NAME, N) extern char NAME##_fault;	\
diff --git a/x86/hyperv_stimer.c b/x86/hyperv_stimer.c
index 767459e55cc0b..bf2e4294ddade 100644
--- a/x86/hyperv_stimer.c
+++ b/x86/hyperv_stimer.c
@@ -99,8 +99,7 @@ static void process_stimer_msg(struct svcpu *svcpu,
         msg->header.message_type != HVMSG_NONE) {
         report("invalid Hyper-V SynIC msg type", false);
         report_summary();
-        exit(-1);
-        return;
+        abort();
     }
 
     if (msg->header.message_type == HVMSG_NONE) {
@@ -110,8 +109,7 @@ static void process_stimer_msg(struct svcpu *svcpu,
     if (msg->header.payload_size < sizeof(*payload)) {
         report("invalid Hyper-V SynIC msg payload size", false);
         report_summary();
-        exit(-1);
-        return;
+        abort();
     }
 
     /* Now process timer expiration message */
@@ -119,8 +117,7 @@ static void process_stimer_msg(struct svcpu *svcpu,
     if (payload->timer_index >= ARRAY_SIZE(svcpu->timer)) {
         report("invalid Hyper-V SynIC timer index", false);
         report_summary();
-        exit(-1);
-        return;
+        abort();
     }
     timer = &svcpu->timer[payload->timer_index];
     process_stimer_expired(svcpu, timer, payload->expiration_time,
diff --git a/x86/pku.c b/x86/pku.c
index 0e00b9984d70d..bcc0d5970f8d3 100644
--- a/x86/pku.c
+++ b/x86/pku.c
@@ -90,8 +90,8 @@ int main(int ac, char **av)
     unsigned int pkru_wd = 0x20;
 
     if (!(cpuid_indexed(7, 0).c & (1 << X86_FEATURE_PKU))) {
-        printf("PKU not enabled, exiting\n");
-        exit(1);
+        printf("PKU not enabled, aborting\n");
+        abort();
     }
 
     setup_vm();
diff --git a/x86/smap.c b/x86/smap.c
index d8a7ae82dc00b..69e71864dc9bf 100644
--- a/x86/smap.c
+++ b/x86/smap.c
@@ -92,8 +92,8 @@ int main(int ac, char **av)
 	unsigned long i;
 
 	if (!(cpuid_indexed(7, 0).b & (1 << X86_FEATURE_SMAP))) {
-		printf("SMAP not enabled, exiting\n");
-		exit(1);
+		printf("SMAP not enabled, aborting\n");
+		abort();
 	}
 
 	setup_vm();
diff --git a/x86/tscdeadline_latency.c b/x86/tscdeadline_latency.c
index 42f19cb92e518..c5f0b06f863d3 100644
--- a/x86/tscdeadline_latency.c
+++ b/x86/tscdeadline_latency.c
@@ -98,8 +98,8 @@ static void test_tsc_deadline_timer(void)
     if(enable_tsc_deadline_timer()) {
         printf("tsc deadline timer enabled\n");
     } else {
-        printf("tsc deadline timer not detected\n");
-        exit(1);
+        printf("tsc deadline timer not detected, aborting\n");
+        abort();
     }
 }
 
diff --git a/x86/vmx.c b/x86/vmx.c
index 3fa1a735881f7..a9cebcb6bdc0c 100644
--- a/x86/vmx.c
+++ b/x86/vmx.c
@@ -869,7 +869,7 @@ static int exit_handler()
 			, ret);
 	}
 	print_vmexit_info();
-	exit(-1);
+	abort();
 	return 0;
 }
 
-- 
2.4.3

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux