[RFC PATCH 2/6] powerpc/64s: Helpers to switch between linear and vmapped stack pointers
Christophe Leroy
christophe.leroy at csgroup.eu
Sun Nov 6 06:28:27 AEDT 2022
Le 05/11/2022 à 09:00, Christophe Leroy a écrit :
>
>
> Le 04/11/2022 à 18:27, Andrew Donnellan a écrit :
>> powerpc unfortunately has too many places where we run stuff in real mode.
>>
>> With CONFIG_VMAP_STACK enabled, this means we need to be able to swap the
>> stack pointer to use the linear mapping when we enter a real mode section,
>> and back afterwards.
>>
>> Store the top bits of the stack pointer in both the linear map and the
>> vmalloc space in the PACA, and add some helper macros/functions to swap
>> between them.
>
> That may work when pagesize is 64k because stack is on a single page,
> but I doubt is works with 4k pages, because vmalloc may allocate non
> contiguous pages.
>
[snip]
>
>> +
>> +#else // __ASSEMBLY__
>> +
>> +#include <asm/paca.h>
>> +#include <asm/reg.h>
>> +#include <linux/mm.h>
>> +
>> +#define stack_pa(ptr) (is_vmalloc_addr((ptr)) ? (void *)vmalloc_to_phys((void *)(ptr)) : (void *)ptr)
>> +
>> +static __always_inline void swap_stack_linear(void)
>> +{
>> + current_stack_pointer = get_paca()->kstack_linear_base | \
>> + (current_stack_pointer & (THREAD_SIZE - 1));
>
> That looks hacky. I think you can't just change current_stack_pointer on
> the fly. You have to provide something similar to call_do_softirq() or
> call_do_irq()
>
Maybe you can have a look at Nic's RFC for calling functions in real
mode :
https://patchwork.ozlabs.org/project/linuxppc-dev/patch/20210212012041.392566-1-npiggin@gmail.com/
Christophe
More information about the Linuxppc-dev
mailing list