Initial commit for core dump.
We can create a dummy core file when gpe occurs. modified: executer/kernel/mcctrl.h modified: executer/kernel/syscall.c modified: kernel/include/syscall.h modified: kernel/mem.c
This commit is contained in:
@ -53,6 +53,8 @@
|
||||
|
||||
#define DO_USER_MODE
|
||||
|
||||
#define __NR_coredump 999
|
||||
|
||||
struct ikc_scd_packet {
|
||||
int msg;
|
||||
int ref;
|
||||
|
||||
@ -46,7 +46,7 @@
|
||||
|
||||
#define ALIGN_WAIT_BUF(z) (((z + 63) >> 6) << 6)
|
||||
|
||||
//#define SC_DEBUG
|
||||
#define SC_DEBUG
|
||||
|
||||
#ifdef SC_DEBUG
|
||||
#define dprintk(...) printk(__VA_ARGS__)
|
||||
@ -1236,6 +1236,39 @@ int __do_in_kernel_syscall(ihk_os_t os, struct mcctrl_channel *c, struct syscall
|
||||
goto out;
|
||||
}
|
||||
|
||||
case __NR_coredump:
|
||||
/* xxx */
|
||||
dprintk("coredump called as a pseudo syscall\n");
|
||||
{
|
||||
struct file *file;
|
||||
int ret, len;
|
||||
Mm_segment_t oldfs = get_fs();
|
||||
|
||||
set_fs(KERNEL_DS);
|
||||
/* Any Linux documentation states that we should not
|
||||
* open a file from a kernel module, but our karma makes
|
||||
* leads us to do this. Precisely, Here we emulate the core
|
||||
* dump routine of the Linux kernel in linux/fs/exec.c.
|
||||
* So we have a legitimate reason.
|
||||
*/
|
||||
file = filp_open("core", O_CREAT | O_RDWR | O_LARGEFILE, 0600);
|
||||
if (IS_ERR(file) || !file->f_op || !file->f_op->write) {
|
||||
dprintk("cannot open core file\n");
|
||||
goto fail;
|
||||
}
|
||||
len = 10;
|
||||
ret = file->f_op->write(file, "core file", len, &file->f_pos);
|
||||
if (ret != len) {
|
||||
dprintk("core file write failed(%d).\n", ret);
|
||||
}
|
||||
fail:
|
||||
filp_close(file, NULL);
|
||||
set_fs(oldfs);
|
||||
|
||||
}
|
||||
error = 0;
|
||||
ret = 0;
|
||||
break;
|
||||
default:
|
||||
error = -ENOSYS;
|
||||
goto out;
|
||||
|
||||
@ -223,4 +223,5 @@ enum {
|
||||
#undef SYSCALL_HANDLED
|
||||
#undef SYSCALL_DELEGATED
|
||||
|
||||
#define __NR_coredump 999 /* pseudo syscall for coredump */
|
||||
#endif
|
||||
|
||||
17
kernel/mem.c
17
kernel/mem.c
@ -206,6 +206,23 @@ static void unhandled_page_fault(struct process *proc, void *fault_addr, void *r
|
||||
/* TODO */
|
||||
ihk_mc_debug_show_interrupt_context(regs);
|
||||
|
||||
{
|
||||
/* xxx */
|
||||
/* core dump framework test */
|
||||
struct syscall_request request IHK_DMA_ALIGN;
|
||||
int ret;
|
||||
|
||||
request.number = __NR_coredump;
|
||||
/* no data for now */
|
||||
ret = do_syscall(&request, proc->uctx,
|
||||
proc->cpu_id, proc->pid);
|
||||
if (ret == 0) {
|
||||
kprintf("dumped core.\n");
|
||||
} else {
|
||||
kprintf("core dump failed.\n");
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef DEBUG_PRINT_MEM
|
||||
{
|
||||
uint64_t *sp = (void *)REGS_GET_STACK_POINTER(regs);
|
||||
|
||||
Reference in New Issue
Block a user