Experimental implementation of map & write.

Data is still dummy.
Not even compiled.
	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:50:25 +09:00
parent 83ced89fa3
commit 53a80e0720
4 changed files with 42 additions and 5 deletions

View File

@ -54,6 +54,10 @@
#define DO_USER_MODE
#define __NR_coredump 999
struct coretable {
int len;
void *addr;
}
struct ikc_scd_packet {
int msg;

View File

@ -1241,8 +1241,12 @@ int __do_in_kernel_syscall(ihk_os_t os, struct mcctrl_channel *c, struct syscall
dprintk("coredump called as a pseudo syscall\n");
{
struct file *file;
int ret, len;
int ret, len, chunks, i;
Mm_segment_t oldfs = get_fs();
struct coretable *coretable;
unsigned long phys, tablephys, rphys;
unsigned long *pt;
int tablesize, size;
set_fs(KERNEL_DS);
/* Any Linux documentation states that we should not
@ -1256,11 +1260,28 @@ int __do_in_kernel_syscall(ihk_os_t os, struct mcctrl_channel *c, struct syscall
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);
chunks = req->args[0]; /* > 0 */
/* first we map the chunk table */
tablesize = sizeof(struct coretable) * chunks;
tablephys = ihk_device_map_memory(ihk_os_to_dev(os), req->args[1], tablesize);
coretable = ihk_device_map_virtula(ihk_os_dev(os), tablephys, tablesize, NULL, 0);
for (i = 0; i < chunks; i++) {
/* xxx:map and write the chunk out */
rphys = coretable[i].addr;
size = coretable[i].len;
phys = ihk_device_map_memory(ihk_os_to_dev(os), rphys, size);
pt = ihk_device_map_virtula(ihk_os_dev(os), phys, size, NULL, 0);
ret = file->f_op->write(file, pt, size, &file->f_pos);
if (ret != len) {
dprintk("core file write failed(%d).\n", ret);
}
ihk_device_unmap_virtual(ihk_os_to_dev(os), pt, PAGE_SIZE);
ihk_device_unmap_memory(ihk_os_to_dev(os), phys, PAGE_SIZE);
}
/* xxx:unmap the chunk */
/* unmap the chunk table */
ihk_device_unmap_virtual(ihk_os_to_dev(os), coretable, PAGE_SIZE);
ihk_device_unmap_memory(ihk_os_to_dev(os), tablephys, PAGE_SIZE);
fail:
filp_close(file, NULL);
set_fs(oldfs);

View File

@ -224,4 +224,9 @@ enum {
#undef SYSCALL_DELEGATED
#define __NR_coredump 999 /* pseudo syscall for coredump */
struct coretable {
int len;
void *addr;
}
#endif

View File

@ -211,8 +211,15 @@ static void unhandled_page_fault(struct process *proc, void *fault_addr, void *r
/* core dump framework test */
struct syscall_request request IHK_DMA_ALIGN;
int ret;
struct coretable coreentry[3];
coreentry[0] = {8, virt_to_phys("this is ")};
coreentry[1] = {7, virt_to_phys("a test ")};
coreentry[2] = {15, virt_to_phys("for coredump.\n")};
request.number = __NR_coredump;
request.args[0] = 3;
request.args[1] = virt_to_phys(&coreentry);
/* no data for now */
ret = do_syscall(&request, proc->uctx,
proc->cpu_id, proc->pid);