Re: [RFC 11/14] x86: add support for Dynamic Kernel Stacks

From: Andi Kleen
Date: Tue Mar 12 2024 - 17:58:09 EST


Pasha Tatashin <pasha.tatashin@xxxxxxxxxx> writes:

> diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c
> index d6375b3c633b..651c558b10eb 100644
> --- a/arch/x86/mm/fault.c
> +++ b/arch/x86/mm/fault.c
> @@ -1198,6 +1198,9 @@ do_kern_addr_fault(struct pt_regs *regs, unsigned long hw_error_code,
> if (is_f00f_bug(regs, hw_error_code, address))
> return;
>
> + if (dynamic_stack_fault(current, address))
> + return;

Probably I'm missing something here, but since you are on the same stack as
you are trying to fix up, how can this possibly work?

Fault on missing stack
#PF
<will push more stuff onto the missing stack causing a double fault>

You would need a separate stack just to handle this. But the normal
page fault handler couldn't use it because it needs to be able to block.

Ah I get it -- you handle it in the double fault handler? So every
stack grow will be a #DF too? That's scary.


-Andi