Lines 3-8
Link Here
|
3 |
* Licensed under the GPL |
3 |
* Licensed under the GPL |
4 |
*/ |
4 |
*/ |
5 |
|
5 |
|
|
|
6 |
/* Include this first, before anything else includes <signal.h> */ |
7 |
#include "siginfo_segv.h" |
8 |
|
6 |
#include <stdio.h> |
9 |
#include <stdio.h> |
7 |
#include <stdlib.h> |
10 |
#include <stdlib.h> |
8 |
#include <stdarg.h> |
11 |
#include <stdarg.h> |
Lines 23-29
Link Here
|
23 |
#include "mem_user.h" |
26 |
#include "mem_user.h" |
24 |
#include "ptrace_user.h" |
27 |
#include "ptrace_user.h" |
25 |
#include "registers.h" |
28 |
#include "registers.h" |
|
|
29 |
#include "skas.h" |
26 |
#include "skas_ptrace.h" |
30 |
#include "skas_ptrace.h" |
|
|
31 |
#include "sysdep/sigcontext.h" |
32 |
#include "user.h" |
27 |
|
33 |
|
28 |
static int ptrace_child(void) |
34 |
static int ptrace_child(void) |
29 |
{ |
35 |
{ |
Lines 142-155
static int stop_ptraced_child(int pid, int exitcode, int mustexit)
Link Here
|
142 |
} |
148 |
} |
143 |
|
149 |
|
144 |
/* Changed only during early boot */ |
150 |
/* Changed only during early boot */ |
145 |
int ptrace_faultinfo = 1; |
151 |
int ptrace_faultinfo; |
146 |
int ptrace_ldt = 1; |
152 |
static int disable_ptrace_faultinfo; |
147 |
int proc_mm = 1; |
153 |
|
148 |
int skas_needs_stub = 0; |
154 |
int ptrace_ldt; |
|
|
155 |
static int disable_ptrace_ldt; |
156 |
|
157 |
int proc_mm; |
158 |
static int disable_proc_mm; |
159 |
|
160 |
int have_switch_mm; |
161 |
static int disable_switch_mm; |
162 |
|
163 |
int have_siginfo_segv; |
164 |
static int disable_siginfo_segv; |
165 |
|
166 |
int have_ptrace_switch_mm; |
167 |
static int disable_ptrace_switch_mm; |
168 |
|
169 |
int have_vcpu; |
170 |
static int disable_vcpu; |
171 |
|
172 |
int skas_needs_stub; |
149 |
|
173 |
|
150 |
static int __init skas0_cmd_param(char *str, int* add) |
174 |
static int __init skas0_cmd_param(char *str, int* add) |
151 |
{ |
175 |
{ |
152 |
ptrace_faultinfo = proc_mm = 0; |
176 |
disable_ptrace_faultinfo = 1; |
|
|
177 |
disable_ptrace_ldt = 1; |
178 |
disable_proc_mm = 1; |
179 |
|
180 |
disable_switch_mm = 1; |
181 |
disable_siginfo_segv = 1; |
182 |
disable_ptrace_switch_mm = 1; |
183 |
disable_vcpu = 1; |
184 |
|
153 |
return 0; |
185 |
return 0; |
154 |
} |
186 |
} |
155 |
|
187 |
|
Lines 159-173
static int __init mode_skas0_cmd_param(char *str, int* add)
Link Here
|
159 |
__attribute__((alias("skas0_cmd_param"))); |
191 |
__attribute__((alias("skas0_cmd_param"))); |
160 |
|
192 |
|
161 |
__uml_setup("skas0", skas0_cmd_param, |
193 |
__uml_setup("skas0", skas0_cmd_param, |
162 |
"skas0\n" |
194 |
"skas0\n" |
163 |
" Disables SKAS3 usage, so that SKAS0 is used, unless \n" |
195 |
" Disables SKAS3 and SKAS4 usage, so that SKAS0 is used\n\n"); |
164 |
" you specify mode=tt.\n\n"); |
|
|
165 |
|
196 |
|
166 |
__uml_setup("mode=skas0", mode_skas0_cmd_param, |
197 |
__uml_setup("mode=skas0", mode_skas0_cmd_param, |
167 |
"mode=skas0\n" |
198 |
"mode=skas0\n" |
168 |
" Disables SKAS3 usage, so that SKAS0 is used, unless you \n" |
199 |
" Disables SKAS3 and SKAS4 usage, so that SKAS0 is used.\n\n"); |
169 |
" specify mode=tt. Note that this was recently added - on \n" |
|
|
170 |
" older kernels you must use simply \"skas0\".\n\n"); |
171 |
|
200 |
|
172 |
/* Changed only during early boot */ |
201 |
/* Changed only during early boot */ |
173 |
static int force_sysemu_disabled = 0; |
202 |
static int force_sysemu_disabled = 0; |
Lines 362-368
void __init os_early_checks(void)
Link Here
|
362 |
|
391 |
|
363 |
static int __init noprocmm_cmd_param(char *str, int* add) |
392 |
static int __init noprocmm_cmd_param(char *str, int* add) |
364 |
{ |
393 |
{ |
365 |
proc_mm = 0; |
394 |
disable_proc_mm = 1; |
366 |
return 0; |
395 |
return 0; |
367 |
} |
396 |
} |
368 |
|
397 |
|
Lines 374-380
__uml_setup("noprocmm", noprocmm_cmd_param,
Link Here
|
374 |
|
403 |
|
375 |
static int __init noptracefaultinfo_cmd_param(char *str, int* add) |
404 |
static int __init noptracefaultinfo_cmd_param(char *str, int* add) |
376 |
{ |
405 |
{ |
377 |
ptrace_faultinfo = 0; |
406 |
disable_ptrace_faultinfo = 1; |
378 |
return 0; |
407 |
return 0; |
379 |
} |
408 |
} |
380 |
|
409 |
|
Lines 386-392
__uml_setup("noptracefaultinfo", noptracefaultinfo_cmd_param,
Link Here
|
386 |
|
415 |
|
387 |
static int __init noptraceldt_cmd_param(char *str, int* add) |
416 |
static int __init noptraceldt_cmd_param(char *str, int* add) |
388 |
{ |
417 |
{ |
389 |
ptrace_ldt = 0; |
418 |
disable_ptrace_ldt = 1; |
390 |
return 0; |
419 |
return 0; |
391 |
} |
420 |
} |
392 |
|
421 |
|
Lines 396-402
__uml_setup("noptraceldt", noptraceldt_cmd_param,
Link Here
|
396 |
" To support PTRACE_LDT, the host needs to be patched using\n" |
425 |
" To support PTRACE_LDT, the host needs to be patched using\n" |
397 |
" the current skas3 patch.\n\n"); |
426 |
" the current skas3 patch.\n\n"); |
398 |
|
427 |
|
399 |
static inline void check_skas3_ptrace_faultinfo(void) |
428 |
static inline void __init check_skas3_ptrace_faultinfo(void) |
400 |
{ |
429 |
{ |
401 |
struct ptrace_faultinfo fi; |
430 |
struct ptrace_faultinfo fi; |
402 |
int pid, n; |
431 |
int pid, n; |
Lines 406-428
static inline void check_skas3_ptrace_faultinfo(void)
Link Here
|
406 |
|
435 |
|
407 |
n = ptrace(PTRACE_FAULTINFO, pid, 0, &fi); |
436 |
n = ptrace(PTRACE_FAULTINFO, pid, 0, &fi); |
408 |
if (n < 0) { |
437 |
if (n < 0) { |
409 |
ptrace_faultinfo = 0; |
|
|
410 |
if (errno == EIO) |
438 |
if (errno == EIO) |
411 |
non_fatal("not found\n"); |
439 |
non_fatal("not found\n"); |
412 |
else |
440 |
else |
413 |
perror("not found"); |
441 |
perror("not found"); |
414 |
} |
442 |
} else if (disable_ptrace_faultinfo) |
|
|
443 |
non_fatal("found but disabled on command line\n"); |
415 |
else { |
444 |
else { |
416 |
if (!ptrace_faultinfo) |
445 |
ptrace_faultinfo = 1; |
417 |
non_fatal("found but disabled on command line\n"); |
446 |
non_fatal("found\n"); |
418 |
else |
|
|
419 |
non_fatal("found\n"); |
420 |
} |
447 |
} |
421 |
|
448 |
|
422 |
stop_ptraced_child(pid, 1, 1); |
449 |
stop_ptraced_child(pid, 1, 1); |
423 |
} |
450 |
} |
424 |
|
451 |
|
425 |
static inline void check_skas3_ptrace_ldt(void) |
452 |
static inline void __init check_skas3_ptrace_ldt(void) |
426 |
{ |
453 |
{ |
427 |
#ifdef PTRACE_LDT |
454 |
#ifdef PTRACE_LDT |
428 |
int pid, n; |
455 |
int pid, n; |
Lines 442-479
static inline void check_skas3_ptrace_ldt(void)
Link Here
|
442 |
else { |
469 |
else { |
443 |
perror("not found"); |
470 |
perror("not found"); |
444 |
} |
471 |
} |
445 |
ptrace_ldt = 0; |
472 |
} else if (disable_ptrace_ldt) |
446 |
} |
473 |
non_fatal("found, but use is disabled\n"); |
447 |
else { |
474 |
else { |
448 |
if (ptrace_ldt) |
475 |
ptrace_ldt = 1; |
449 |
non_fatal("found\n"); |
476 |
non_fatal("found\n"); |
450 |
else |
|
|
451 |
non_fatal("found, but use is disabled\n"); |
452 |
} |
477 |
} |
453 |
|
478 |
|
454 |
stop_ptraced_child(pid, 1, 1); |
479 |
stop_ptraced_child(pid, 1, 1); |
455 |
#else |
|
|
456 |
/* PTRACE_LDT might be disabled via cmdline option. |
457 |
* We want to override this, else we might use the stub |
458 |
* without real need |
459 |
*/ |
460 |
ptrace_ldt = 1; |
461 |
#endif |
480 |
#endif |
462 |
} |
481 |
} |
463 |
|
482 |
|
464 |
static inline void check_skas3_proc_mm(void) |
483 |
static inline void __init check_skas3_proc_mm(void) |
465 |
{ |
484 |
{ |
466 |
non_fatal(" - /proc/mm..."); |
485 |
non_fatal(" - /proc/mm..."); |
467 |
if (access("/proc/mm", W_OK) < 0) { |
486 |
if (access("/proc/mm", W_OK) < 0) |
468 |
proc_mm = 0; |
|
|
469 |
perror("not found"); |
487 |
perror("not found"); |
470 |
} |
488 |
else if (disable_proc_mm) |
471 |
else if (!proc_mm) |
|
|
472 |
non_fatal("found but disabled on command line\n"); |
489 |
non_fatal("found but disabled on command line\n"); |
473 |
else non_fatal("found\n"); |
490 |
else { |
|
|
491 |
proc_mm = 1; |
492 |
non_fatal("found\n"); |
493 |
} |
474 |
} |
494 |
} |
475 |
|
495 |
|
476 |
void can_do_skas(void) |
496 |
static void __init can_do_skas3(void) |
477 |
{ |
497 |
{ |
478 |
non_fatal("Checking for the skas3 patch in the host:\n"); |
498 |
non_fatal("Checking for the skas3 patch in the host:\n"); |
479 |
|
499 |
|
Lines 481-488
void can_do_skas(void)
Link Here
|
481 |
check_skas3_ptrace_faultinfo(); |
501 |
check_skas3_ptrace_faultinfo(); |
482 |
check_skas3_ptrace_ldt(); |
502 |
check_skas3_ptrace_ldt(); |
483 |
|
503 |
|
484 |
if (!proc_mm || !ptrace_faultinfo || !ptrace_ldt) |
504 |
if (!proc_mm || (!ptrace_faultinfo && !have_siginfo_segv) || |
|
|
505 |
!ptrace_ldt) |
506 |
skas_needs_stub = 1; |
507 |
} |
508 |
|
509 |
static void *fault_address; |
510 |
|
511 |
static __init int check_fault_info(struct faultinfo *fi) |
512 |
{ |
513 |
return (FAULT_ADDRESS(*fi) == (unsigned long) fault_address) && |
514 |
FAULT_WRITE(*fi) && SEGV_IS_FIXABLE(fi); |
515 |
} |
516 |
|
517 |
static jmp_buf siginfo_buf; |
518 |
|
519 |
static void __init segv_handler(int sig, siginfo_t *si, void *foo) |
520 |
{ |
521 |
struct faultinfo fi; |
522 |
int n; |
523 |
|
524 |
GET_FAULTINFO_FROM_SI(fi, *si); |
525 |
n = check_fault_info(&fi) ? 1 : 2; |
526 |
longjmp(siginfo_buf, n); |
527 |
} |
528 |
|
529 |
static int __init fault(void) |
530 |
{ |
531 |
struct sigaction sa, old; |
532 |
int err, n; |
533 |
|
534 |
/* |
535 |
* The cast is needed because the CPP manipulations of |
536 |
* siginfo_t resulted in sa_sigaction having an old_siginfo_t |
537 |
* parameter. |
538 |
*/ |
539 |
sa.sa_sigaction = (void (*)(int, old_siginfo_t *, void *)) segv_handler; |
540 |
sigemptyset(&sa.sa_mask); |
541 |
sa.sa_flags = SA_SIGINFO | SA_NODEFER; |
542 |
|
543 |
err = sigaction(SIGSEGV, &sa, &old); |
544 |
if (err) |
545 |
fatal_perror("sigaction"); |
546 |
|
547 |
/* |
548 |
* Provide a guaranteed invalid address by mapping a page into |
549 |
* a hole in the address space and then unmapping it. |
550 |
*/ |
551 |
fault_address = mmap(NULL, UM_KERN_PAGE_SIZE, PROT_READ | PROT_WRITE, |
552 |
MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); |
553 |
if (fault_address == MAP_FAILED) |
554 |
fatal_perror("mmap failed"); |
555 |
|
556 |
if (munmap(fault_address, UM_KERN_PAGE_SIZE) < 0) |
557 |
fatal_perror("munmap failed"); |
558 |
|
559 |
n = setjmp(siginfo_buf); |
560 |
if (n == 0) |
561 |
*((unsigned long *) fault_address) = 0; |
562 |
|
563 |
err = sigaction(SIGSEGV, &old, NULL); |
564 |
|
565 |
return n; |
566 |
} |
567 |
|
568 |
static int __init nogetsiginfo_cmd_param(char *str, int *add) |
569 |
{ |
570 |
disable_siginfo_segv = 1; |
571 |
return 0; |
572 |
} |
573 |
|
574 |
__uml_setup("nogetsiginfo", nogetsiginfo_cmd_param, |
575 |
"nogetsiginfo\n" |
576 |
" Turns off usage of PTRACE_GETSIGINFO to read page fault information\n" |
577 |
" from a child process, even if the host supports it.\n\n"); |
578 |
|
579 |
#ifndef PTRACE_GETSIGINFO |
580 |
#define PTRACE_GETSIGINFO 0x4202 |
581 |
#endif |
582 |
|
583 |
static int __init check_siginfo(void) |
584 |
{ |
585 |
siginfo_t si; |
586 |
struct faultinfo fi; |
587 |
int ok, pid, err, status; |
588 |
|
589 |
non_fatal("\tFull CPU fault information in siginfo_t ... "); |
590 |
ok = fault(); |
591 |
if (ok) |
592 |
non_fatal("OK\n"); |
593 |
else { |
594 |
non_fatal("Failed\n"); |
595 |
return 0; |
596 |
} |
597 |
|
598 |
non_fatal("\tFull CPU fault information in PTRACE_GETSIGINFO ... "); |
599 |
|
600 |
pid = fork(); |
601 |
if (pid < 0) |
602 |
fatal_perror("fork failed"); |
603 |
else if (pid == 0) { |
604 |
ptrace(PTRACE_TRACEME, 0, 0, 0); |
605 |
fault(); |
606 |
exit(1); |
607 |
} |
608 |
|
609 |
while (1) { |
610 |
err = waitpid(pid, &status, WUNTRACED); |
611 |
if (err < 0) |
612 |
fatal_perror("wait failed"); |
613 |
|
614 |
if (WIFSTOPPED(status) && (WSTOPSIG(status) == SIGSEGV)) |
615 |
break; |
616 |
} |
617 |
|
618 |
err = ptrace(PTRACE_GETSIGINFO, pid, 0, &si); |
619 |
if (err < 0) |
620 |
fatal_perror("PTRACE_GETSIGINFO failed"); |
621 |
|
622 |
ptrace(PTRACE_KILL, pid, 0, 0); |
623 |
|
624 |
GET_FAULTINFO_FROM_SI(fi, si); |
625 |
ok = check_fault_info(&fi); |
626 |
if (ok) |
627 |
non_fatal("OK\n"); |
628 |
else |
629 |
non_fatal("Failed\n"); |
630 |
|
631 |
if (disable_siginfo_segv) |
632 |
non_fatal("Extended PTRACE_GETSIGINFO disabled on command " |
633 |
"line\n"); |
634 |
else |
635 |
have_siginfo_segv = 1; |
636 |
|
637 |
return ok; |
638 |
} |
639 |
|
640 |
static struct user_regs return_regs; |
641 |
int self_mm_fd; |
642 |
|
643 |
static int switch_mm_works; |
644 |
|
645 |
static __init void after_switch(void) |
646 |
{ |
647 |
/* |
648 |
* If we are really in a new address space, setting this to |
649 |
* zero won't affect the value of 1 already set in the old |
650 |
* address space. |
651 |
*/ |
652 |
switch_mm_works = 0; |
653 |
|
654 |
switch_mm(self_mm_fd, NULL, &return_regs, 0, 0); |
655 |
} |
656 |
|
657 |
static int __init check_switch_mm(void) |
658 |
{ |
659 |
char *mm_stack; |
660 |
int err, there = -1; |
661 |
|
662 |
non_fatal("\t/proc/self/mm ... "); |
663 |
self_mm_fd = open("/proc/self/mm", O_RDONLY); |
664 |
if (self_mm_fd < 0) |
665 |
goto bad; |
666 |
non_fatal("OK\n"); |
667 |
|
668 |
mm_stack = mmap(NULL, UM_KERN_PAGE_SIZE, PROT_READ | PROT_WRITE, |
669 |
MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); |
670 |
if (mm_stack == MAP_FAILED) |
671 |
goto bad; |
672 |
|
673 |
non_fatal("\tnew_mm ... "); |
674 |
there = new_mm(); |
675 |
if (there < 0) |
676 |
goto bad_unmap; |
677 |
non_fatal("OK\n"); |
678 |
|
679 |
switch_mm_works = 1; |
680 |
|
681 |
non_fatal("\tswitching over ... "); |
682 |
err = switch_mm(there, &return_regs, NULL, (unsigned long) after_switch, |
683 |
((unsigned long) &mm_stack[UM_KERN_PAGE_SIZE]) - |
684 |
sizeof(void *)); |
685 |
if (err < 0) |
686 |
goto bad_close; |
687 |
non_fatal("switched back ... "); |
688 |
if (!switch_mm_works) |
689 |
goto bad_close; |
690 |
else |
691 |
non_fatal("OK\n"); |
692 |
|
693 |
munmap(mm_stack, UM_KERN_PAGE_SIZE); |
694 |
close(there); |
695 |
|
696 |
if (disable_switch_mm) |
697 |
non_fatal("switch_mm support disabled on command line\n"); |
698 |
else |
699 |
have_switch_mm = 1; |
700 |
|
701 |
return 1; |
702 |
bad_close: |
703 |
if (there > 0) |
704 |
close(there); |
705 |
bad_unmap: |
706 |
munmap(mm_stack, UM_KERN_PAGE_SIZE); |
707 |
bad: |
708 |
non_fatal("Failed - \n"); |
709 |
perror(""); |
710 |
return 0; |
711 |
} |
712 |
|
713 |
static int ptrace_switch_mm_works; |
714 |
|
715 |
static int __init after_ptrace_switch(void) |
716 |
{ |
717 |
ptrace_switch_mm_works = 1; |
718 |
exit(0); |
719 |
} |
720 |
|
721 |
static int __init check_ptrace_switch_mm(void) |
722 |
{ |
723 |
void *stack; |
724 |
unsigned long regs[MAX_REG_NR]; |
725 |
int pid, here, err, status; |
726 |
|
727 |
non_fatal("\tPTRACE_SWITCH_MM ... "); |
728 |
pid = fork(); |
729 |
if (pid == 0){ |
730 |
ptrace(PTRACE_TRACEME, 0, 0, 0); |
731 |
kill(getpid(), SIGSTOP); |
732 |
|
733 |
exit(0); |
734 |
} |
735 |
else if (pid < 0) |
736 |
goto bad; |
737 |
|
738 |
stack = mmap(NULL, UM_KERN_PAGE_SIZE, PROT_READ | PROT_WRITE, |
739 |
MAP_SHARED | MAP_ANONYMOUS, -1, 0); |
740 |
if (stack == MAP_FAILED) |
741 |
goto bad; |
742 |
|
743 |
here = open("/proc/self/mm", O_RDONLY); |
744 |
if (here < 0) |
745 |
goto bad_unmap; |
746 |
|
747 |
err = waitpid(pid, &status, WUNTRACED); |
748 |
if (err < 0) |
749 |
goto bad_close; |
750 |
else if (err != pid) { |
751 |
non_fatal("waitpid returned %d, expected %d\n", err, pid); |
752 |
goto bad_close; |
753 |
} else if (!WIFSTOPPED(status) || (WSTOPSIG(status) != SIGSTOP)) { |
754 |
non_fatal("waitpid returned status 0x%d\n", status); |
755 |
goto bad_close; |
756 |
} |
757 |
|
758 |
err = ptrace(PTRACE_GETREGS, pid, 0, regs); |
759 |
if (err < 0) |
760 |
goto bad_close; |
761 |
|
762 |
regs[REGS_IP_INDEX] = (unsigned long) after_ptrace_switch; |
763 |
regs[REGS_SP_INDEX] = (unsigned long) stack + UM_KERN_PAGE_SIZE - |
764 |
sizeof(void *); |
765 |
|
766 |
if (ptrace(PTRACE_SETREGS, pid, 0, regs) < 0) |
767 |
goto bad_close; |
768 |
|
769 |
if (ptrace(PTRACE_SWITCH_MM, pid, NULL, here) < 0) |
770 |
goto bad_close; |
771 |
|
772 |
if (ptrace(PTRACE_CONT, pid, NULL, 0) < 0) |
773 |
goto bad_close; |
774 |
|
775 |
err = waitpid(pid, &status, WUNTRACED); |
776 |
if (err < 0) |
777 |
goto bad_close; |
778 |
else if(err != pid) { |
779 |
non_fatal("waitpid returned %d, expected %d\n", err, pid); |
780 |
goto bad_close; |
781 |
} else if (!WIFEXITED(status) || (WEXITSTATUS(status) != 0)) { |
782 |
non_fatal("waitpid returned status 0x%d\n", status); |
783 |
goto bad_close; |
784 |
} |
785 |
|
786 |
if (!ptrace_switch_mm_works) |
787 |
goto bad_close; |
788 |
else |
789 |
non_fatal("OK\n"); |
790 |
|
791 |
if (disable_ptrace_switch_mm) |
792 |
non_fatal("PTRACE_SWITCH_MM support disabled on command " |
793 |
"line\n"); |
794 |
else |
795 |
have_ptrace_switch_mm = 1; |
796 |
|
797 |
close(here); |
798 |
munmap(stack, UM_KERN_PAGE_SIZE); |
799 |
|
800 |
return 1; |
801 |
|
802 |
bad_close: |
803 |
close(here); |
804 |
bad_unmap: |
805 |
munmap(stack, UM_KERN_PAGE_SIZE); |
806 |
bad: |
807 |
non_fatal("Failed - \n"); |
808 |
perror(""); |
809 |
return 0; |
810 |
} |
811 |
|
812 |
#ifdef UML_CONFIG_X86_32 |
813 |
extern int host_gdt_entry_tls_min; |
814 |
extern void host_tls_support(void); |
815 |
|
816 |
static __init int init_vcpu_arch(struct vcpu_arch *vcpu){ |
817 |
struct user_desc *tls = vcpu->tls_array; |
818 |
int i, err; |
819 |
|
820 |
host_tls_support(); |
821 |
memset(tls, 0, sizeof(vcpu->tls_array)); |
822 |
for (i = 0; i < ARRAY_SIZE(vcpu->tls_array); i++) { |
823 |
tls[i].entry_number = host_gdt_entry_tls_min + i; |
824 |
err = get_thread_area(&tls[i]); |
825 |
if (err) { |
826 |
perror("get_thread_area"); |
827 |
return err; |
828 |
} |
829 |
} |
830 |
return 0; |
831 |
} |
832 |
#else |
833 |
static int init_vcpu_arch(struct vcpu_arch *vcpu){ |
834 |
return 0; |
835 |
} |
836 |
#endif |
837 |
|
838 |
static struct vcpu_user vcpu_data; |
839 |
|
840 |
static __init int check_vcpu(void) |
841 |
{ |
842 |
void *stack; |
843 |
int err; |
844 |
|
845 |
non_fatal("\tvcpu ... "); |
846 |
|
847 |
stack = mmap(NULL, UM_KERN_PAGE_SIZE, PROT_READ | PROT_WRITE, |
848 |
MAP_SHARED | MAP_ANONYMOUS, -1, 0); |
849 |
if (stack == MAP_FAILED) |
850 |
goto bad; |
851 |
|
852 |
get_safe_registers(vcpu_data.regs.regs); |
853 |
vcpu_data.regs.regs[REGS_IP_INDEX] = (unsigned long) ptrace_child; |
854 |
vcpu_data.regs.regs[REGS_SP_INDEX] = (unsigned long) stack + |
855 |
UM_KERN_PAGE_SIZE - sizeof(void *); |
856 |
|
857 |
if (init_vcpu_arch(&vcpu_data.arch)) |
858 |
goto bad; |
859 |
|
860 |
err = vcpu(-1, &vcpu_data); |
861 |
munmap(stack, UM_KERN_PAGE_SIZE); |
862 |
if (err) { |
863 |
non_fatal("vcpu failed with errno %d\n", err); |
864 |
goto bad; |
865 |
} |
866 |
|
867 |
if (vcpu_data.event != VCPU_SYSCALL) { |
868 |
non_fatal("vcpu returned with event = %d\n", vcpu_data.event); |
869 |
goto bad; |
870 |
} |
871 |
|
872 |
non_fatal("OK\n"); |
873 |
|
874 |
if (disable_vcpu) |
875 |
non_fatal("vcpu support disabled on command line\n"); |
876 |
else |
877 |
have_vcpu = 1; |
878 |
|
879 |
return 1; |
880 |
|
881 |
bad: |
882 |
non_fatal("Failed\n"); |
883 |
return 0; |
884 |
} |
885 |
|
886 |
static int __init can_do_skas4(void) |
887 |
{ |
888 |
int ret; |
889 |
|
890 |
non_fatal("Checking for SKAS4 support in the host:\n"); |
891 |
|
892 |
ret = check_switch_mm() && check_ptrace_switch_mm() && check_siginfo() |
893 |
&& check_vcpu(); |
894 |
if (ret) |
485 |
skas_needs_stub = 1; |
895 |
skas_needs_stub = 1; |
|
|
896 |
|
897 |
return ret; |
898 |
} |
899 |
|
900 |
void __init can_do_skas(void) |
901 |
{ |
902 |
if (!can_do_skas4()) |
903 |
can_do_skas3(); |
904 |
} |
905 |
|
906 |
int get_new_mm(void) |
907 |
{ |
908 |
int err; |
909 |
|
910 |
err = new_mm(); |
911 |
if (err < 0) |
912 |
err = -errno; |
913 |
|
914 |
return err; |
486 |
} |
915 |
} |
487 |
|
916 |
|
488 |
int __init parse_iomem(char *str, int *add) |
917 |
int __init parse_iomem(char *str, int *add) |