Merge branch 'master' of postpeta.pccluster.org:mckernel
This commit is contained in:
@ -109,6 +109,8 @@ struct program_image_section {
|
||||
void *fp;
|
||||
};
|
||||
|
||||
#define SHELL_PATH_MAX_LEN 1024
|
||||
|
||||
struct program_load_desc {
|
||||
int num_sections;
|
||||
int status;
|
||||
@ -134,6 +136,7 @@ struct program_load_desc {
|
||||
unsigned long rlimit_stack_cur;
|
||||
unsigned long rlimit_stack_max;
|
||||
unsigned long interp_align;
|
||||
char shell_path[SHELL_PATH_MAX_LEN];
|
||||
struct program_image_section sections[0];
|
||||
};
|
||||
|
||||
|
||||
14
kernel/mem.c
14
kernel/mem.c
@ -180,7 +180,7 @@ void freecore(struct coretable **);
|
||||
* \param regs A pointer to a x86_regs structure.
|
||||
*/
|
||||
|
||||
static void coredump(struct process *proc, void *regs)
|
||||
void coredump(struct process *proc, void *regs)
|
||||
{
|
||||
struct syscall_request request IHK_DMA_ALIGN;
|
||||
int ret;
|
||||
@ -216,9 +216,9 @@ static void unhandled_page_fault(struct process *proc, void *fault_addr, void *r
|
||||
unsigned long error = ((struct x86_regs *)regs)->error;
|
||||
|
||||
irqflags = kprintf_lock();
|
||||
__kprintf("[%d] Page fault for 0x%lX\n",
|
||||
dkprintf("[%d] Page fault for 0x%lX\n",
|
||||
ihk_mc_get_processor_id(), address);
|
||||
__kprintf("%s for %s access in %s mode (reserved bit %s set), "
|
||||
dkprintf("%s for %s access in %s mode (reserved bit %s set), "
|
||||
"it %s an instruction fetch\n",
|
||||
(error & PF_PROT ? "protection fault" : "no page found"),
|
||||
(error & PF_WRITE ? "write" : "read"),
|
||||
@ -230,14 +230,14 @@ static void unhandled_page_fault(struct process *proc, void *fault_addr, void *r
|
||||
list_for_each_entry(range, &vm->vm_range_list, list) {
|
||||
if (range->start <= address && range->end > address) {
|
||||
found = 1;
|
||||
__kprintf("address is in range, flag: 0x%X! \n",
|
||||
dkprintf("address is in range, flag: 0x%X! \n",
|
||||
range->flag);
|
||||
ihk_mc_pt_print_pte(vm->page_table, (void*)address);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
__kprintf("address is out of range! \n");
|
||||
dkprintf("address is out of range! \n");
|
||||
}
|
||||
|
||||
kprintf_unlock(irqflags);
|
||||
@ -246,8 +246,8 @@ static void unhandled_page_fault(struct process *proc, void *fault_addr, void *r
|
||||
ihk_mc_debug_show_interrupt_context(regs);
|
||||
|
||||
|
||||
dkprintf("now dump a core file\n");
|
||||
coredump(proc, regs);
|
||||
//dkprintf("now dump a core file\n");
|
||||
//coredump(proc, regs);
|
||||
|
||||
#ifdef DEBUG_PRINT_MEM
|
||||
{
|
||||
|
||||
@ -311,6 +311,9 @@ SYSCALL_DECLARE(wait4)
|
||||
struct waitq_entry waitpid_wqe;
|
||||
int empty = 1;
|
||||
|
||||
if (options & ~(WNOHANG | WUNTRACED | WCONTINUED)) {
|
||||
return -EINVAL;
|
||||
}
|
||||
rescan:
|
||||
child = NULL;
|
||||
pid = (int)ihk_mc_syscall_arg0(ctx);
|
||||
@ -333,7 +336,7 @@ rescan:
|
||||
ihk_mc_spinlock_unlock_noirq(&child_iter->lock);
|
||||
}
|
||||
|
||||
if (empty) {
|
||||
if (empty || (!child && pid != -1)) {
|
||||
ihk_mc_spinlock_unlock_noirq(&proc->ftn->lock);
|
||||
return -ECHILD;
|
||||
}
|
||||
@ -400,7 +403,7 @@ terminate(int rc, int sig, ihk_mc_user_context_t *ctx)
|
||||
struct fork_tree_node *child, *next;
|
||||
|
||||
request.number = __NR_exit_group;
|
||||
request.args[0] = ((rc & 0x00ff) << 8) | (sig & 0x7f);
|
||||
request.args[0] = ((rc & 0x00ff) << 8) | (sig & 0xff);
|
||||
|
||||
#ifdef DCFA_KMOD
|
||||
do_mod_exit(rc);
|
||||
@ -430,7 +433,7 @@ terminate(int rc, int sig, ihk_mc_user_context_t *ctx)
|
||||
|
||||
ihk_mc_spinlock_lock_noirq(&ftn->lock);
|
||||
ftn->pid = proc->pid;
|
||||
ftn->exit_status = ((rc & 0x00ff) << 8) | (sig & 0x7f);
|
||||
ftn->exit_status = ((rc & 0x00ff) << 8) | (sig & 0xff);
|
||||
ftn->status = PS_ZOMBIE;
|
||||
ihk_mc_spinlock_unlock_noirq(&ftn->lock);
|
||||
|
||||
@ -1245,15 +1248,20 @@ SYSCALL_DECLARE(execve)
|
||||
|
||||
dkprintf("execve(): ELF desc received, num sections: %d\n",
|
||||
desc->num_sections);
|
||||
|
||||
if (desc->shell_path[0]) {
|
||||
dkprintf("execve(): shell interpreter: %s\n", desc->shell_path);
|
||||
}
|
||||
|
||||
/* Flatten argv and envp into kernel-space buffers */
|
||||
argv_flat_len = flatten_strings(-1, argv, &argv_flat);
|
||||
argv_flat_len = flatten_strings(-1, (desc->shell_path[0] ?
|
||||
desc->shell_path : NULL), argv, &argv_flat);
|
||||
if (argv_flat_len == 0) {
|
||||
kprintf("ERROR: no argv for executable: %s?\n", filename);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
envp_flat_len = flatten_strings(-1, envp, &envp_flat);
|
||||
envp_flat_len = flatten_strings(-1, NULL, envp, &envp_flat);
|
||||
if (envp_flat_len == 0) {
|
||||
kprintf("ERROR: no envp for executable: %s?\n", filename);
|
||||
return -EINVAL;
|
||||
@ -2009,6 +2017,7 @@ SYSCALL_DECLARE(sched_setaffinity)
|
||||
struct process *thread;
|
||||
int cpu_id;
|
||||
unsigned long irqstate;
|
||||
extern int num_processors;
|
||||
|
||||
if (sizeof(k_cpu_set) > len) {
|
||||
kprintf("%s:%d\n Too small buffer.", __FILE__, __LINE__);
|
||||
@ -2023,11 +2032,13 @@ SYSCALL_DECLARE(sched_setaffinity)
|
||||
|
||||
// XXX: We should build something like cpu_available_mask in advance
|
||||
CPU_ZERO(&cpu_set);
|
||||
extern int num_processors;
|
||||
for (cpu_id = 0; cpu_id < num_processors; cpu_id++)
|
||||
if (CPU_ISSET(cpu_id, &k_cpu_set))
|
||||
CPU_SET(cpu_id, &cpu_set);
|
||||
|
||||
if(tid == 0)
|
||||
tid = cpu_local_var(current)->tid;
|
||||
|
||||
for (cpu_id = 0; cpu_id < num_processors; cpu_id++) {
|
||||
irqstate = ihk_mc_spinlock_lock(&get_cpu_local_var(cpu_id)->runq_lock);
|
||||
list_for_each_entry(thread, &get_cpu_local_var(cpu_id)->runq, sched_list)
|
||||
@ -2064,6 +2075,7 @@ SYSCALL_DECLARE(sched_getaffinity)
|
||||
int found = 0;
|
||||
int i;
|
||||
unsigned long irqstate;
|
||||
extern int num_processors;
|
||||
|
||||
if (sizeof(k_cpu_set) > len) {
|
||||
kprintf("%s:%d Too small buffer.\n", __FILE__, __LINE__);
|
||||
@ -2071,7 +2083,9 @@ SYSCALL_DECLARE(sched_getaffinity)
|
||||
}
|
||||
len = MIN2(len, sizeof(k_cpu_set));
|
||||
|
||||
extern int num_processors;
|
||||
if(tid == 0)
|
||||
tid = cpu_local_var(current)->tid;
|
||||
|
||||
for (i = 0; i < num_processors && !found; i++) {
|
||||
struct process *thread;
|
||||
irqstate = ihk_mc_spinlock_lock(&get_cpu_local_var(i)->runq_lock);
|
||||
|
||||
Reference in New Issue
Block a user