process.c (ea68a3e9d14e9e0bf017d178fb4bd53b6deb1482) process.c (6032aca0deb9c138df122192f8ef02de1fdccf25)
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * Copyright (C) 2015 Thomas Meyer (thomas@m3y3r.de)
4 * Copyright (C) 2002- 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
5 */
6
7#include <stdlib.h>
8#include <stdbool.h>

--- 248 unchanged lines hidden (view full) ---

257 printk(UM_KERN_ERR "mapping mmap stub at 0x%lx failed, errno = %d\n",
258 STUB_CODE, errno);
259 exit(1);
260 }
261
262 if (stack != NULL) {
263 fd = phys_mapping(uml_to_phys(stack), &offset);
264 addr = mmap((void *) STUB_DATA,
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * Copyright (C) 2015 Thomas Meyer (thomas@m3y3r.de)
4 * Copyright (C) 2002- 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
5 */
6
7#include <stdlib.h>
8#include <stdbool.h>

--- 248 unchanged lines hidden (view full) ---

257 printk(UM_KERN_ERR "mapping mmap stub at 0x%lx failed, errno = %d\n",
258 STUB_CODE, errno);
259 exit(1);
260 }
261
262 if (stack != NULL) {
263 fd = phys_mapping(uml_to_phys(stack), &offset);
264 addr = mmap((void *) STUB_DATA,
265 UM_KERN_PAGE_SIZE, PROT_READ | PROT_WRITE,
265 STUB_DATA_PAGES * UM_KERN_PAGE_SIZE, PROT_READ | PROT_WRITE,
266 MAP_FIXED | MAP_SHARED, fd, offset);
267 if (addr == MAP_FAILED) {
268 printk(UM_KERN_ERR "mapping segfault stack at 0x%lx failed, errno = %d\n",
269 STUB_DATA, errno);
270 exit(1);
271 }
272 }
273 if (stack != NULL) {
274 struct sigaction sa;
275
276 unsigned long v = STUB_CODE +
277 (unsigned long) stub_segv_handler -
278 (unsigned long) __syscall_stub_start;
279
266 MAP_FIXED | MAP_SHARED, fd, offset);
267 if (addr == MAP_FAILED) {
268 printk(UM_KERN_ERR "mapping segfault stack at 0x%lx failed, errno = %d\n",
269 STUB_DATA, errno);
270 exit(1);
271 }
272 }
273 if (stack != NULL) {
274 struct sigaction sa;
275
276 unsigned long v = STUB_CODE +
277 (unsigned long) stub_segv_handler -
278 (unsigned long) __syscall_stub_start;
279
280 set_sigstack((void *) STUB_DATA, UM_KERN_PAGE_SIZE);
280 set_sigstack((void *) STUB_DATA, STUB_DATA_PAGES * UM_KERN_PAGE_SIZE);
281 sigemptyset(&sa.sa_mask);
282 sa.sa_flags = SA_ONSTACK | SA_NODEFER | SA_SIGINFO;
283 sa.sa_sigaction = (void *) v;
284 sa.sa_restorer = NULL;
285 if (sigaction(SIGSEGV, &sa, NULL) < 0) {
286 printk(UM_KERN_ERR "%s - setting SIGSEGV handler failed - errno = %d\n",
287 __func__, errno);
288 exit(1);

--- 221 unchanged lines hidden (view full) ---

510
511static int __init init_thread_regs(void)
512{
513 get_safe_registers(thread_regs, thread_fp_regs);
514 /* Set parent's instruction pointer to start of clone-stub */
515 thread_regs[REGS_IP_INDEX] = STUB_CODE +
516 (unsigned long) stub_clone_handler -
517 (unsigned long) __syscall_stub_start;
281 sigemptyset(&sa.sa_mask);
282 sa.sa_flags = SA_ONSTACK | SA_NODEFER | SA_SIGINFO;
283 sa.sa_sigaction = (void *) v;
284 sa.sa_restorer = NULL;
285 if (sigaction(SIGSEGV, &sa, NULL) < 0) {
286 printk(UM_KERN_ERR "%s - setting SIGSEGV handler failed - errno = %d\n",
287 __func__, errno);
288 exit(1);

--- 221 unchanged lines hidden (view full) ---

510
511static int __init init_thread_regs(void)
512{
513 get_safe_registers(thread_regs, thread_fp_regs);
514 /* Set parent's instruction pointer to start of clone-stub */
515 thread_regs[REGS_IP_INDEX] = STUB_CODE +
516 (unsigned long) stub_clone_handler -
517 (unsigned long) __syscall_stub_start;
518 thread_regs[REGS_SP_INDEX] = STUB_DATA + UM_KERN_PAGE_SIZE -
518 thread_regs[REGS_SP_INDEX] = STUB_DATA + STUB_DATA_PAGES * UM_KERN_PAGE_SIZE -
519 sizeof(void *);
520#ifdef __SIGNAL_FRAMESIZE
521 thread_regs[REGS_SP_INDEX] -= __SIGNAL_FRAMESIZE;
522#endif
523 return 0;
524}
525
526__initcall(init_thread_regs);

--- 206 unchanged lines hidden ---
519 sizeof(void *);
520#ifdef __SIGNAL_FRAMESIZE
521 thread_regs[REGS_SP_INDEX] -= __SIGNAL_FRAMESIZE;
522#endif
523 return 0;
524}
525
526__initcall(init_thread_regs);

--- 206 unchanged lines hidden ---