On 2021/9/18 上午12:40, Peter Zijlstra wrote: [snip] > - printk(KERN_EMERG "BUG: stack guard page was hit at %p (stack is %p..%p)\n", > - (void *)fault_address, current->stack, > - (char *)current->stack + THREAD_SIZE - 1); > - die(message, regs, 0); > + const char *name = stack_type_name(info->type); > + > + printk(KERN_EMERG "BUG: %s stack guard page was hit at %p (stack is %p..%p)\n", > + name, (void *)fault_address, info->begin, info->end); Just found that the printed pointer address is not correct: BUG: NMI stack guard page was hit at 0000000085fd977b (stack is 000000003a55b09e..00000000d8cce1a5) Maybe we could use %px instead? Regards, Michael Wang > + > + die("stack guard page", regs, 0); > > /* Be absolutely certain we don't return. */ > - panic("%s", message); > + panic("%s stack guard hit", name); > } > #endif > > @@ -353,6 +355,7 @@ DEFINE_IDTENTRY_DF(exc_double_fault) > > #ifdef CONFIG_VMAP_STACK > unsigned long address = read_cr2(); > + struct stack_info info; > #endif > > #ifdef CONFIG_X86_ESPFIX64 > @@ -455,10 +458,8 @@ DEFINE_IDTENTRY_DF(exc_double_fault) > * stack even if the actual trigger for the double fault was > * something else. > */ > - if ((unsigned long)task_stack_page(tsk) - 1 - address < PAGE_SIZE) { > - handle_stack_overflow("kernel stack overflow (double-fault)", > - regs, address); > - } > + if (get_stack_guard_info((void *)address, &info)) > + handle_stack_overflow(regs, address, &info); > #endif > > pr_emerg("PANIC: double fault, error_code: 0x%lx\n", error_code); > diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c > index b2eefdefc108..edb5152f0866 100644 > --- a/arch/x86/mm/fault.c > +++ b/arch/x86/mm/fault.c > @@ -32,6 +32,7 @@ > #include <asm/pgtable_areas.h> /* VMALLOC_START, ... */ > #include <asm/kvm_para.h> /* kvm_handle_async_pf */ > #include <asm/vdso.h> /* fixup_vdso_exception() */ > +#include <asm/irq_stack.h> > > #define CREATE_TRACE_POINTS > #include <asm/trace/exceptions.h> > @@ -631,6 +632,9 @@ static noinline void > page_fault_oops(struct pt_regs *regs, unsigned long error_code, > unsigned long address) > { > +#ifdef CONFIG_VMAP_STACK > + struct stack_info info; > +#endif > unsigned long flags; > int sig; > > @@ -649,9 +653,7 @@ page_fault_oops(struct pt_regs *regs, unsigned long error_code, > * that we're in vmalloc space to avoid this. > */ > if (is_vmalloc_addr((void *)address) && > - (((unsigned long)current->stack - 1 - address < PAGE_SIZE) || > - address - ((unsigned long)current->stack + THREAD_SIZE) < PAGE_SIZE)) { > - unsigned long stack = __this_cpu_ist_top_va(DF) - sizeof(void *); > + get_stack_guard_info((void *)address, &info)) { > /* > * We're likely to be running with very little stack space > * left. It's plausible that we'd hit this condition but > @@ -662,13 +664,11 @@ page_fault_oops(struct pt_regs *regs, unsigned long error_code, > * and then double-fault, though, because we're likely to > * break the console driver and lose most of the stack dump. > */ > - asm volatile ("movq %[stack], %%rsp\n\t" > - "call handle_stack_overflow\n\t" > - "1: jmp 1b" > - : ASM_CALL_CONSTRAINT > - : "D" ("kernel stack overflow (page fault)"), > - "S" (regs), "d" (address), > - [stack] "rm" (stack)); > + call_on_stack(__this_cpu_ist_top_va(DF) - sizeof(void*), > + handle_stack_overflow, > + ASM_CALL_ARG3, > + , [arg1] "r" (regs), [arg2] "r" (address), [arg3] "r" (&info)); > + > unreachable(); > } > #endif >