hc
2024-10-22 8ac6c7a54ed1b98d142dce24b11c6de6a1e239a5
kernel/arch/um/os-Linux/skas/process.c
....@@ -1,10 +1,11 @@
1
+// SPDX-License-Identifier: GPL-2.0
12 /*
23 * Copyright (C) 2015 Thomas Meyer (thomas@m3y3r.de)
34 * Copyright (C) 2002- 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
4
- * Licensed under the GPL
55 */
66
77 #include <stdlib.h>
8
+#include <stdbool.h>
89 #include <unistd.h>
910 #include <sched.h>
1011 #include <errno.h>
....@@ -249,6 +250,7 @@
249250 }
250251
251252 int userspace_pid[NR_CPUS];
253
+int kill_userspace_mm[NR_CPUS];
252254
253255 /**
254256 * start_userspace() - prepare a new userspace process
....@@ -342,6 +344,8 @@
342344 interrupt_end();
343345
344346 while (1) {
347
+ if (kill_userspace_mm[0])
348
+ fatal_sigsegv();
345349
346350 /*
347351 * This can legitimately fail if the process loads a
....@@ -425,9 +429,9 @@
425429 case SIGBUS:
426430 case SIGFPE:
427431 case SIGWINCH:
428
- block_signals();
432
+ block_signals_trace();
429433 (*sig_info[sig])(sig, (struct siginfo *)&si, regs);
430
- unblock_signals();
434
+ unblock_signals_trace();
431435 break;
432436 default:
433437 printk(UM_KERN_ERR "userspace - child stopped "
....@@ -625,10 +629,10 @@
625629 cb_arg = arg;
626630 cb_back = &here;
627631
628
- block_signals();
632
+ block_signals_trace();
629633 if (UML_SETJMP(&here) == 0)
630634 UML_LONGJMP(&initial_jmpbuf, INIT_JMP_CALLBACK);
631
- unblock_signals();
635
+ unblock_signals_trace();
632636
633637 cb_proc = NULL;
634638 cb_arg = NULL;
....@@ -637,17 +641,32 @@
637641
638642 void halt_skas(void)
639643 {
640
- block_signals();
644
+ block_signals_trace();
641645 UML_LONGJMP(&initial_jmpbuf, INIT_JMP_HALT);
642646 }
643647
648
+static bool noreboot;
649
+
650
+static int __init noreboot_cmd_param(char *str, int *add)
651
+{
652
+ noreboot = true;
653
+ return 0;
654
+}
655
+
656
+__uml_setup("noreboot", noreboot_cmd_param,
657
+"noreboot\n"
658
+" Rather than rebooting, exit always, akin to QEMU's -no-reboot option.\n"
659
+" This is useful if you're using CONFIG_PANIC_TIMEOUT in order to catch\n"
660
+" crashes in CI\n");
661
+
644662 void reboot_skas(void)
645663 {
646
- block_signals();
647
- UML_LONGJMP(&initial_jmpbuf, INIT_JMP_REBOOT);
664
+ block_signals_trace();
665
+ UML_LONGJMP(&initial_jmpbuf, noreboot ? INIT_JMP_HALT : INIT_JMP_REBOOT);
648666 }
649667
650668 void __switch_mm(struct mm_id *mm_idp)
651669 {
652670 userspace_pid[0] = mm_idp->u.pid;
671
+ kill_userspace_mm[0] = mm_idp->kill;
653672 }