ucontext, kernel vs. userspace (glibc)

Benjamin Herrenschmidt benh at kernel.crashing.org
Mon Aug 30 03:40:03 PDT 2021


Hi Folks !

So I'm discovering arm64 intricacies and today, as I was looking at SVE
support (in the context of distro glibc backports.. don't ask), I
noticed that glibc has no provision for dealing with kernel generated
ucontext's in its {get,set,swap}_context functions...

(It says so explicitly in the code unless I misunderstood).

So one thing we did to "solve" this on ppc64 a while ago was to create
a swapcontext syscall which can operate as all 3 operations (you can
have NULL arguments), which also handles the sigprocmask (bonus:
atomically with the context get/set from a userspace perspective).

Would it make sense to do something similar on aarch64 ? (And have
glibc then exploit it).

The hard-to-solve thing is the case where the SVE context spills
outside of the ucontext itself, in the extra room on the stack, since
programs that "now" about ucontext will not have allocated space for
that, so that's more/less a lost cause already.

Cheers,
Ben.





More information about the linux-arm-kernel mailing list