Release 4.14 arch/um/os-Linux/skas/mem.c
/*
* Copyright (C) 2002 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
* Licensed under the GPL
*/
#include <stddef.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>
#include <sys/mman.h>
#include <init.h>
#include <as-layout.h>
#include <mm_id.h>
#include <os.h>
#include <ptrace_user.h>
#include <registers.h>
#include <skas.h>
#include <sysdep/ptrace.h>
#include <sysdep/stub.h>
extern char batch_syscall_stub[], __syscall_stub_start[];
extern void wait_stub_done(int pid);
static inline unsigned long *check_init_stack(struct mm_id * mm_idp,
unsigned long *stack)
{
if (stack == NULL) {
stack = (unsigned long *) mm_idp->stack + 2;
*stack = 0;
}
return stack;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Bodo Stroesser | 48 | 100.00% | 1 | 100.00% |
Total | 48 | 100.00% | 1 | 100.00% |
static unsigned long syscall_regs[MAX_REG_NR];
static int __init init_syscall_regs(void)
{
get_safe_registers(syscall_regs, NULL);
syscall_regs[REGS_IP_INDEX] = STUB_CODE +
((unsigned long) batch_syscall_stub -
(unsigned long) __syscall_stub_start);
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Jeff Dike | 38 | 95.00% | 2 | 66.67% |
Ingo van Lil | 2 | 5.00% | 1 | 33.33% |
Total | 40 | 100.00% | 3 | 100.00% |
__initcall(init_syscall_regs);
static inline long do_syscall_stub(struct mm_id * mm_idp, void **addr)
{
int n, i;
long ret, offset;
unsigned long * data;
unsigned long * syscall;
int err, pid = mm_idp->u.pid;
n = ptrace_setregs(pid, syscall_regs);
if (n < 0) {
printk(UM_KERN_ERR "Registers - \n");
for (i = 0; i < MAX_REG_NR; i++)
printk(UM_KERN_ERR "\t%d\t0x%lx\n", i, syscall_regs[i]);
panic("do_syscall_stub : PTRACE_SETREGS failed, errno = %d\n",
-n);
}
err = ptrace(PTRACE_CONT, pid, 0, 0);
if (err)
panic("Failed to continue stub, pid = %d, errno = %d\n", pid,
errno);
wait_stub_done(pid);
/*
* When the stub stops, we find the following values on the
* beginning of the stack:
* (long )return_value
* (long )offset to failed sycall-data (0, if no error)
*/
ret = *((unsigned long *) mm_idp->stack);
offset = *((unsigned long *) mm_idp->stack + 1);
if (offset) {
data = (unsigned long *)(mm_idp->stack + offset - STUB_DATA);
printk(UM_KERN_ERR "do_syscall_stub : ret = %ld, offset = %ld, "
"data = %p\n", ret, offset, data);
syscall = (unsigned long *)((unsigned long)data + data[0]);
printk(UM_KERN_ERR "do_syscall_stub: syscall %ld failed, "
"return value = 0x%lx, expected return value = 0x%lx\n",
syscall[0], ret, syscall[7]);
printk(UM_KERN_ERR " syscall parameters: "
"0x%lx 0x%lx 0x%lx 0x%lx 0x%lx 0x%lx\n",
syscall[1], syscall[2], syscall[3],
syscall[4], syscall[5], syscall[6]);
for (n = 1; n < data[0]/sizeof(long); n++) {
if (n == 1)
printk(UM_KERN_ERR " additional syscall "
"data:");
if (n % 4 == 1)
printk("\n" UM_KERN_ERR " ");
printk(" 0x%lx", data[n]);
}
if (n > 1)
printk("\n");
}
else ret = 0;
*addr = check_init_stack(mm_idp, NULL);
return ret;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Bodo Stroesser | 201 | 54.47% | 1 | 11.11% |
Jeff Dike | 147 | 39.84% | 6 | 66.67% |
Gennady Sharapov | 19 | 5.15% | 1 | 11.11% |
Paolo 'Blaisorblade' Giarrusso | 2 | 0.54% | 1 | 11.11% |
Total | 369 | 100.00% | 9 | 100.00% |
long run_syscall_stub(struct mm_id * mm_idp, int syscall,
unsigned long *args, long expected, void **addr,
int done)
{
unsigned long *stack = check_init_stack(mm_idp, *addr);
*stack += sizeof(long);
stack += *stack / sizeof(long);
*stack++ = syscall;
*stack++ = args[0];
*stack++ = args[1];
*stack++ = args[2];
*stack++ = args[3];
*stack++ = args[4];
*stack++ = args[5];
*stack++ = expected;
*stack = 0;
if (!done && ((((unsigned long) stack) & ~UM_KERN_PAGE_MASK) <
UM_KERN_PAGE_SIZE - 10 * sizeof(long))) {
*addr = stack;
return 0;
}
return do_syscall_stub(mm_idp, addr);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Bodo Stroesser | 106 | 59.55% | 1 | 33.33% |
Jeff Dike | 72 | 40.45% | 2 | 66.67% |
Total | 178 | 100.00% | 3 | 100.00% |
long syscall_stub_data(struct mm_id * mm_idp,
unsigned long *data, int data_count,
void **addr, void **stub_addr)
{
unsigned long *stack;
int ret = 0;
/*
* If *addr still is uninitialized, it *must* contain NULL.
* Thus in this case do_syscall_stub correctly won't be called.
*/
if ((((unsigned long) *addr) & ~UM_KERN_PAGE_MASK) >=
UM_KERN_PAGE_SIZE - (10 + data_count) * sizeof(long)) {
ret = do_syscall_stub(mm_idp, addr);
/* in case of error, don't overwrite data on stack */
if (ret)
return ret;
}
stack = check_init_stack(mm_idp, *addr);
*addr = stack;
*stack = data_count * sizeof(long);
memcpy(stack + 1, data, data_count * sizeof(long));
*stub_addr = (void *)(((unsigned long)(stack + 1) &
~UM_KERN_PAGE_MASK) + STUB_DATA);
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Bodo Stroesser | 108 | 68.79% | 1 | 20.00% |
Jeff Dike | 49 | 31.21% | 4 | 80.00% |
Total | 157 | 100.00% | 5 | 100.00% |
int map(struct mm_id * mm_idp, unsigned long virt, unsigned long len, int prot,
int phys_fd, unsigned long long offset, int done, void **data)
{
int ret;
unsigned long args[] = { virt, len, prot,
MAP_SHARED | MAP_FIXED, phys_fd,
MMAP_OFFSET(offset) };
ret = run_syscall_stub(mm_idp, STUB_MMAP_NR, args, virt,
data, done);
return ret;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Jeff Dike | 77 | 91.67% | 5 | 83.33% |
Bodo Stroesser | 7 | 8.33% | 1 | 16.67% |
Total | 84 | 100.00% | 6 | 100.00% |
int unmap(struct mm_id * mm_idp, unsigned long addr, unsigned long len,
int done, void **data)
{
int ret;
unsigned long args[] = { (unsigned long) addr, len, 0, 0, 0,
0 };
ret = run_syscall_stub(mm_idp, __NR_munmap, args, 0,
data, done);
return ret;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Jeff Dike | 65 | 90.28% | 5 | 83.33% |
Bodo Stroesser | 7 | 9.72% | 1 | 16.67% |
Total | 72 | 100.00% | 6 | 100.00% |
int protect(struct mm_id * mm_idp, unsigned long addr, unsigned long len,
unsigned int prot, int done, void **data)
{
int ret;
unsigned long args[] = { addr, len, prot, 0, 0, 0 };
ret = run_syscall_stub(mm_idp, __NR_mprotect, args, 0,
data, done);
return ret;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Jeff Dike | 63 | 87.50% | 4 | 66.67% |
Bodo Stroesser | 7 | 9.72% | 1 | 16.67% |
Paolo 'Blaisorblade' Giarrusso | 2 | 2.78% | 1 | 16.67% |
Total | 72 | 100.00% | 6 | 100.00% |
Overall Contributors
Person | Tokens | Prop | Commits | CommitProp |
Jeff Dike | 567 | 51.92% | 11 | 61.11% |
Bodo Stroesser | 486 | 44.51% | 1 | 5.56% |
Gennady Sharapov | 19 | 1.74% | 1 | 5.56% |
Al Viro | 9 | 0.82% | 1 | 5.56% |
Paolo 'Blaisorblade' Giarrusso | 6 | 0.55% | 2 | 11.11% |
Nicolas Iooss | 3 | 0.27% | 1 | 5.56% |
Ingo van Lil | 2 | 0.18% | 1 | 5.56% |
Total | 1092 | 100.00% | 18 | 100.00% |
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.