ucontext, kernel vs. userspace (glibc)

Mark Brown broonie at kernel.org
Thu Sep 2 05:42:36 PDT 2021


On Mon, Aug 30, 2021 at 08:40:03PM +1000, Benjamin Herrenschmidt wrote:

> 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).

I think the usefulness of such an interface is mainly a question for
userspace - I don't immediately see any issue with implementing it if
it's useful to people.

> 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.

You can figure out the maximum possible size for a context so it would
be possible to define a mechanism for pointing to extra data I guess but
yeah, it's going to be a problem when we start seeing systems with large
enough register state.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20210902/a888b003/attachment.sig>


More information about the linux-arm-kernel mailing list