TO RESET: add debug instruments, map Linux areas for tofu
Change-Id: I09880cad3b87182cb663d414041254817c254759
This commit is contained in:
@ -235,7 +235,6 @@ void (*mcctrl_zap_page_range)(struct vm_area_struct *vma,
|
||||
|
||||
struct inode_operations *mcctrl_hugetlbfs_inode_operations;
|
||||
|
||||
|
||||
static int symbols_init(void)
|
||||
{
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,17,0)
|
||||
|
||||
@ -82,6 +82,9 @@ void preempt_enable(void)
|
||||
|
||||
//arch_cpu_stop();
|
||||
//cpu_halt();
|
||||
#ifdef ENABLE_FUGAKU_HACKS
|
||||
panic("panic: negative preemption??");
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -788,7 +788,11 @@ out_remote_pf:
|
||||
syscall_channel_send(resp_channel, &pckt);
|
||||
|
||||
rc = do_kill(NULL, info.pid, info.tid, info.sig, &info.info, 0);
|
||||
#ifndef ENABLE_FUGAKU_HACKS
|
||||
dkprintf("SCD_MSG_SEND_SIGNAL: do_kill(pid=%d, tid=%d, sig=%d)=%d\n", info.pid, info.tid, info.sig, rc);
|
||||
#else
|
||||
kprintf("SCD_MSG_SEND_SIGNAL: do_kill(pid=%d, tid=%d, sig=%d)=%d\n", info.pid, info.tid, info.sig, rc);
|
||||
#endif
|
||||
ret = 0;
|
||||
break;
|
||||
|
||||
|
||||
@ -106,6 +106,9 @@ struct cpu_local_var {
|
||||
ihk_spinlock_t migq_lock;
|
||||
struct list_head migq;
|
||||
int in_interrupt;
|
||||
#ifdef ENABLE_FUGAKU_HACKS
|
||||
int in_page_fault;
|
||||
#endif
|
||||
int no_preempt;
|
||||
int timer_enabled;
|
||||
unsigned long nr_ctx_switches;
|
||||
|
||||
32
kernel/mem.c
32
kernel/mem.c
@ -954,6 +954,9 @@ static void query_free_mem_interrupt_handler(void *priv)
|
||||
}
|
||||
|
||||
kprintf("McKernel free pages in total: %d\n", pages);
|
||||
#ifdef ENABLE_FUGAKU_HACKS
|
||||
panic("PANIC");
|
||||
#endif
|
||||
|
||||
if (find_command_line("memdebug")) {
|
||||
extern void kmalloc_memcheck(void);
|
||||
@ -1346,7 +1349,13 @@ static void unhandled_page_fault(struct thread *thread, void *fault_addr,
|
||||
|
||||
if (!(reason & PF_USER)) {
|
||||
cpu_local_var(kernel_mode_pf_regs) = regs;
|
||||
#ifndef ENABLE_FUGAKU_HACKS
|
||||
panic("panic: kernel mode PF");
|
||||
#else
|
||||
kprintf("panic: kernel mode PF");
|
||||
for (;;) cpu_pause();
|
||||
//panic("panic: kernel mode PF");
|
||||
#endif
|
||||
}
|
||||
|
||||
//dkprintf("now dump a core file\n");
|
||||
@ -1382,6 +1391,20 @@ static void page_fault_handler(void *fault_addr, uint64_t reason, void *regs)
|
||||
__FUNCTION__, fault_addr, reason, regs);
|
||||
|
||||
preempt_disable();
|
||||
#ifdef ENABLE_FUGAKU_HACKS
|
||||
++cpu_local_var(in_page_fault);
|
||||
if (cpu_local_var(in_page_fault) > 1) {
|
||||
kprintf("%s: PF in PF??\n", __func__);
|
||||
cpu_disable_interrupt();
|
||||
if (!(reason & PF_USER)) {
|
||||
cpu_local_var(kernel_mode_pf_regs) = regs;
|
||||
panic("panic: kernel mode PF in PF");
|
||||
}
|
||||
while (1) {
|
||||
panic("PANIC");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
cpu_enable_interrupt();
|
||||
|
||||
@ -1451,9 +1474,9 @@ out_linux:
|
||||
preempt_enable();
|
||||
|
||||
#ifdef ENABLE_FUGAKU_DEBUG
|
||||
kprintf("%s: sending SIGSTOP to TID: %d\n", __func__, thread->tid);
|
||||
do_kill(thread, thread->proc->pid, thread->tid, SIGSTOP, NULL, 0);
|
||||
goto out;
|
||||
//kprintf("%s: sending SIGSTOP to TID: %d\n", __func__, thread->tid);
|
||||
//do_kill(thread, thread->proc->pid, thread->tid, SIGSTOP, NULL, 0);
|
||||
//goto out;
|
||||
#endif
|
||||
|
||||
memset(&info, '\0', sizeof info);
|
||||
@ -1484,6 +1507,9 @@ out_linux:
|
||||
out_ok:
|
||||
#endif
|
||||
error = 0;
|
||||
#ifdef ENABLE_FUGAKU_HACKS
|
||||
--cpu_local_var(in_page_fault);
|
||||
#endif
|
||||
preempt_enable();
|
||||
out:
|
||||
dkprintf("%s: addr: %p, reason: %lx, regs: %p -> error: %d\n",
|
||||
|
||||
110
kernel/syscall.c
110
kernel/syscall.c
@ -204,6 +204,14 @@ long do_syscall(struct syscall_request *req, int cpu)
|
||||
++thread->in_syscall_offload;
|
||||
}
|
||||
|
||||
#ifdef ENABLE_FUGAKU_HACKS
|
||||
#if 0
|
||||
if (req->number == __NR_write && req->args[0] == 1) {
|
||||
return req->args[2];
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* The current thread is the requester */
|
||||
req->rtid = cpu_local_var(current)->tid;
|
||||
|
||||
@ -1930,6 +1938,10 @@ do_mmap(const uintptr_t addr0, const size_t len0, const int prot,
|
||||
__FUNCTION__, proc->straight_va, range->pgshift);
|
||||
|
||||
ptattr = arch_vrflag_to_ptattr(range->flag, PF_POPULATE, NULL);
|
||||
|
||||
#ifdef ENABLE_FUGAKU_HACKS
|
||||
if (1) { // Un-safe mapping of covering physical range
|
||||
#endif
|
||||
error = ihk_mc_pt_set_range(proc->vm->address_space->page_table,
|
||||
proc->vm,
|
||||
(void *)range->start,
|
||||
@ -1956,6 +1968,90 @@ do_mmap(const uintptr_t addr0, const size_t len0, const int prot,
|
||||
proc->straight_pa,
|
||||
psize,
|
||||
proc->straight_map_threshold);
|
||||
|
||||
#ifdef ENABLE_FUGAKU_HACKS
|
||||
}
|
||||
else { // Safe mapping of only LWK memory ranges
|
||||
size_t max_pgsize = 0;
|
||||
size_t min_pgsize = 0xFFFFFFFFFFFFFFFF;
|
||||
|
||||
/*
|
||||
* Iterate LWK phsyical memory chunks and map them to their
|
||||
* corresponding offset in the straight range using the largest
|
||||
* suitable pages.
|
||||
*/
|
||||
for (i = 0; i < ihk_mc_get_nr_memory_chunks(); ++i) {
|
||||
unsigned long start, end, pa;
|
||||
void *va, *va_end;
|
||||
size_t pgsize;
|
||||
int pg2align;
|
||||
|
||||
ihk_mc_get_memory_chunk(i, &start, &end, NULL);
|
||||
va = proc->straight_va + (start - straight_pa_start);
|
||||
va_end = va + (end - start);
|
||||
pa = start;
|
||||
|
||||
while (va < va_end) {
|
||||
pgsize = (va_end - va) + 1;
|
||||
retry:
|
||||
error = arch_get_smaller_page_size(NULL, pgsize,
|
||||
&pgsize, &pg2align);
|
||||
if (error) {
|
||||
ekprintf("%s: arch_get_smaller_page_size() failed"
|
||||
" during straight mapping: %d\n",
|
||||
__func__, error);
|
||||
proc->straight_va = 0;
|
||||
goto straight_out;
|
||||
}
|
||||
|
||||
/* Are virtual or physical not page aligned for this size? */
|
||||
if (((unsigned long)va & (pgsize - 1)) ||
|
||||
(pa & (pgsize - 1))) {
|
||||
goto retry;
|
||||
}
|
||||
|
||||
error = ihk_mc_pt_set_range(
|
||||
proc->vm->address_space->page_table,
|
||||
proc->vm,
|
||||
va,
|
||||
va + pgsize,
|
||||
pa,
|
||||
ptattr,
|
||||
pg2align + PAGE_SHIFT,
|
||||
range,
|
||||
0);
|
||||
|
||||
if (error) {
|
||||
kprintf("%s: ihk_mc_pt_set_range() failed"
|
||||
" during straight mapping: %d\n",
|
||||
__func__, error);
|
||||
proc->straight_va = 0;
|
||||
goto straight_out;
|
||||
}
|
||||
|
||||
if (pgsize > max_pgsize)
|
||||
max_pgsize = pgsize;
|
||||
|
||||
if (pgsize < min_pgsize)
|
||||
min_pgsize = pgsize;
|
||||
|
||||
va += pgsize;
|
||||
pa += pgsize;
|
||||
}
|
||||
}
|
||||
|
||||
region->map_end = (unsigned long)proc->straight_va +
|
||||
proc->straight_len;
|
||||
proc->straight_pa = straight_pa_start;
|
||||
kprintf("%s: straight mapping: 0x%lx:%lu @ "
|
||||
"min_pgsize: %lu, max_pgsize: %lu\n",
|
||||
__FUNCTION__,
|
||||
proc->straight_va,
|
||||
proc->straight_len,
|
||||
min_pgsize,
|
||||
max_pgsize);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
straight_out:
|
||||
|
||||
@ -2284,8 +2380,15 @@ straight_out:
|
||||
range->straight_start =
|
||||
(unsigned long)proc->straight_va +
|
||||
(straight_phys - proc->straight_pa);
|
||||
#ifndef ENABLE_FUGAKU_HACKS
|
||||
dkprintf("%s: range 0x%lx:%lu is straight starting at 0x%lx\n",
|
||||
__FUNCTION__, addr, len, range->straight_start);
|
||||
__FUNCTION__, addr, len, range->straight_start);
|
||||
#else
|
||||
dkprintf("%s: range 0x%lx:%lu is straight starting at 0x%lx"
|
||||
" (phys: 0x%lx)\n",
|
||||
__FUNCTION__, addr, len, range->straight_start,
|
||||
straight_phys);
|
||||
#endif
|
||||
if (!zero_at_free) {
|
||||
memset((void *)phys_to_virt(straight_phys), 0, len);
|
||||
}
|
||||
@ -2435,6 +2538,11 @@ SYSCALL_DECLARE(munmap)
|
||||
out:
|
||||
dkprintf("[%d]sys_munmap(%lx,%lx): %d\n",
|
||||
ihk_mc_get_processor_id(), addr, len0, error);
|
||||
#ifdef ENABLE_FUGAKU_HACKS
|
||||
if (error) {
|
||||
kprintf("%s: error: %d\n", __func__, error);
|
||||
}
|
||||
#endif
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user