3 * modules/writer/kernel_operations_x86.c
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 * Copyright (C) Samsung Electronics, 2013
21 * 2013 Alexander Aksenov <a.aksenov@samsung.com>: SWAP Writer module kernel
26 #include <asm/ptrace.h>
27 #include <asm/uaccess.h>
29 #include <linux/kernel.h>
30 #include <linux/sched.h>
33 #include "kernel_operations.h"
36 /* ======================= ARGS ========================== */
38 int get_args(unsigned long args[], int cnt, struct pt_regs *regs)
40 int i, stack_args = 0;
42 /* If we're in kernel mode on x86, get arguments from bx, cx, dx, si,
45 if (!user_mode(regs)) {
47 args_in_regs = cnt < 5 ? cnt : 5;
50 switch (args_in_regs) {
66 /* Get other args from stack */
67 for (i = stack_args; i < cnt; ++i) {
68 unsigned long *args_in_sp = (unsigned long *)regs->sp +
70 if (get_user(args[i], args_in_sp))
71 printk("failed to dereference a pointer, addr=%p\n",
79 /* ================== KERNEL SHARED MEM ===================== */
81 const char *get_shared_kmem(struct mm_struct *mm, unsigned long *start,
85 struct vm_area_struct *vma_vdso;
87 vdso = (unsigned long)mm->context.vdso;
88 vma_vdso = find_vma_intersection(mm, vdso, vdso + 1);
90 if (vma_vdso == NULL) {
91 print_err("Cannot get VDSO mapping\n");
95 *start = vma_vdso->vm_start;
96 *end = vma_vdso->vm_end;