Adding V-ext regs to signal context w/o expanding kernel struct sigcontext to avoid glibc ABI break
Vineet Gupta
vineetg at rivosinc.com
Fri Dec 23 11:42:46 PST 2022
On 12/22/22 18:27, Vincent Chen wrote:
> If I understand correctly, in your patch, the kernel uses rt_sigframe
> to back up all register contexts in the user space, including RVV
> registers.
Discussing this all moot point but still...
> Therefore, the user program needs to reserve enough memory
> space for the kernel, which enough size of this memory space is the
> sizeof(rt_sigframe) plus rvv_sc_size.
In my patch, rt_sigframe has the c99 flexible array. So it doesn't add
any extra space on its own.
The total size increase is same whether we add it to kernel sigcontext
or rt_sigframe. And since glibc sigcontext is not changed, application
is unaware of rvv_sc_size in either case.
> However, the rvv_sc_size is
> unexpected to existing RISC-V programs.
Again not sure how it is different in both cases.
> Therefore, some memory of the
> existing program may be corrupted by the kernel when the kernel backs
> up the RVV registers context.
kernel builds signal frame on top of existing user stack.
setup_rt_frame
get_sigframe
sp = regs->sp;
So it can't possibly corrupt any existing user stack area. Sure when
expanding the stack user stack rlimit etc may hit when doing put_user.
But again that is same for both approaches.
FWIW kernel with my patch can be found below: it survives full glibc
testsuite run w/o any regression so it definitely works w/o any obvious
user memory corruption.
git://git.kernel.org/pub/scm/linux/kernel/git/vgupta/linux.git
#rvv-v13.2-use-rt_sigframe
-Vineet
More information about the linux-riscv
mailing list