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:
Naoki Hamada
2014-07-01 16:03:11 +09:00
parent dc7f38c8c7
commit 83ced89fa3
4 changed files with 54 additions and 1 deletions

View File

@ -53,6 +53,8 @@
#define DO_USER_MODE
#define __NR_coredump 999
struct ikc_scd_packet {
int msg;
int ref;

View File

@ -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;

View File

@ -223,4 +223,5 @@ enum {
#undef SYSCALL_HANDLED
#undef SYSCALL_DELEGATED
#define __NR_coredump 999 /* pseudo syscall for coredump */
#endif

View File

@ -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);