TO RESET: preempt_enable: check if no_preempt isn't negative

Change-Id: I1cef2077c50f3b3020870505dd065d10617f440e
This commit is contained in:
Masamichi Takagi
2020-06-15 12:48:25 +09:00
parent 4f7fd90300
commit 191e6f7499
6 changed files with 125 additions and 1 deletions

View File

@ -730,6 +730,49 @@ static void show_context_stack(struct pt_regs *regs)
} }
} }
#ifdef ENABLE_FUGAKU_HACKS
void __show_context_stack(struct thread *thread,
unsigned long pc, uintptr_t sp, int kprintf_locked)
{
uintptr_t stack_top;
unsigned long irqflags = 0;
stack_top = ALIGN_UP(sp, (uintptr_t)KERNEL_STACK_SIZE);
if (!kprintf_locked)
irqflags = kprintf_lock();
__kprintf("TID: %d, call stack (most recent first):\n",
thread->tid);
__kprintf("PC: %016lx, SP: %016lx\n", pc, sp);
for (;;) {
extern char _head[], _end[];
uintptr_t *fp, *lr;
fp = (uintptr_t *)sp;
lr = (uintptr_t *)(sp + 8);
if ((*fp <= sp)) {
break;
}
if ((*fp > stack_top)) {
break;
}
if ((*lr < (unsigned long)_head) ||
(*lr > (unsigned long)_end)) {
break;
}
__kprintf("PC: %016lx, SP: %016lx, FP: %016lx\n", *lr - 4, sp, *fp);
sp = *fp;
}
if (!kprintf_locked)
kprintf_unlock(irqflags);
}
#endif
void handle_IPI(unsigned int vector, struct pt_regs *regs) void handle_IPI(unsigned int vector, struct pt_regs *regs)
{ {
struct ihk_mc_interrupt_handler *h; struct ihk_mc_interrupt_handler *h;

View File

@ -868,6 +868,49 @@ void show_context_stack(uintptr_t *rbp) {
return; return;
} }
#ifdef ENABLE_FUGAKU_HACKS
void __show_context_stack(struct thread *thread,
unsigned long pc, uintptr_t sp, int kprintf_locked)
{
uintptr_t stack_top;
unsigned long irqflags = 0;
stack_top = ALIGN_UP(sp, (uintptr_t)KERNEL_STACK_SIZE);
if (!kprintf_locked)
irqflags = kprintf_lock();
__kprintf("TID: %d, call stack (most recent first):\n",
thread->tid);
__kprintf("PC: %016lx, SP: %016lx\n", pc, sp);
for (;;) {
extern char _head[], _end[];
uintptr_t *fp, *lr;
fp = (uintptr_t *)sp;
lr = (uintptr_t *)(sp + 8);
if ((*fp <= sp)) {
break;
}
if ((*fp > stack_top)) {
break;
}
if ((*lr < (unsigned long)_head) ||
(*lr > (unsigned long)_end)) {
break;
}
__kprintf("PC: %016lx, SP: %016lx, FP: %016lx\n", *lr - 4, sp, *fp);
sp = *fp;
}
if (!kprintf_locked)
kprintf_unlock(irqflags);
}
#endif
void interrupt_exit(struct x86_user_context *regs) void interrupt_exit(struct x86_user_context *regs)
{ {
if (interrupt_from_user(regs)) { if (interrupt_from_user(regs)) {

View File

@ -451,4 +451,12 @@ extern unsigned long ap_trampoline;
/* Local is cachable */ /* Local is cachable */
#define IHK_IKC_QUEUE_PT_ATTR (PTATTR_NO_EXECUTE | PTATTR_WRITABLE) #define IHK_IKC_QUEUE_PT_ATTR (PTATTR_NO_EXECUTE | PTATTR_WRITABLE)
#ifdef ENABLE_FUGAKU_HACKS
#ifndef __ASSEMBLY__
# define ALIGN_UP(x, align) ALIGN_DOWN((x) + (align) - 1, align)
# define ALIGN_DOWN(x, align) ((x) & ~((align) - 1))
#endif /* !__ASSEMBLY__ */
#endif
#endif #endif

View File

@ -53,5 +53,9 @@ struct x86_cpu_local_variables *get_x86_this_cpu_local(void);
void *get_x86_cpu_local_kstack(int id); void *get_x86_cpu_local_kstack(int id);
void *get_x86_this_cpu_kstack(void); void *get_x86_this_cpu_kstack(void);
#ifdef ENABLE_FUGAKU_HACKS
#define LOCALS_SPAN (4 * PAGE_SIZE)
#define KERNEL_STACK_SIZE LOCALS_SPAN
#endif
#endif #endif

View File

@ -21,7 +21,9 @@
#include <registers.h> #include <registers.h>
#include <string.h> #include <string.h>
#ifndef ENABLE_FUGAKU_HACKS
#define LOCALS_SPAN (4 * PAGE_SIZE) #define LOCALS_SPAN (4 * PAGE_SIZE)
#endif
struct x86_cpu_local_variables *locals; struct x86_cpu_local_variables *locals;
size_t x86_cpu_local_variables_span = LOCALS_SPAN; /* for debugger */ size_t x86_cpu_local_variables_span = LOCALS_SPAN; /* for debugger */

View File

@ -58,16 +58,40 @@ struct cpu_local_var *get_cpu_local_var(int id)
return clv + id; return clv + id;
} }
#ifdef ENABLE_FUGAKU_HACKS
void __show_context_stack(struct thread *thread,
unsigned long pc, uintptr_t sp, int kprintf_locked);
#endif
void preempt_enable(void) void preempt_enable(void)
{ {
#ifndef ENABLE_FUGAKU_HACKS
if (cpu_local_var_initialized) if (cpu_local_var_initialized)
--cpu_local_var(no_preempt); --cpu_local_var(no_preempt);
#else
if (cpu_local_var_initialized) {
--cpu_local_var(no_preempt);
if (cpu_local_var(no_preempt) < 0) {
//cpu_disable_interrupt();
__kprintf("%s: %d\n", __func__, cpu_local_var(no_preempt));
__kprintf("TID: %d, call stack from builtin frame (most recent first):\n",
cpu_local_var(current)->tid);
__show_context_stack(cpu_local_var(current), (uintptr_t)&preempt_enable,
(unsigned long)__builtin_frame_address(0), 1);
//arch_cpu_stop();
//cpu_halt();
}
}
#endif
} }
void preempt_disable(void) void preempt_disable(void)
{ {
if (cpu_local_var_initialized) if (cpu_local_var_initialized) {
++cpu_local_var(no_preempt); ++cpu_local_var(no_preempt);
}
} }
int add_backlog(int (*func)(void *arg), void *arg) int add_backlog(int (*func)(void *arg), void *arg)