All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mark Brown <broonie@kernel.org>
To: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: linux-arm-kernel@lists.infradead.org,
	Catalin Marinas <catalin.marinas@arm.com>,
	Will Deacon <will@kernel.org>,
	Szabolcs Nagy <szabolcs.nagy@arm.com>,
	benh@amazon.com
Subject: Re: ucontext, kernel vs. userspace (glibc)
Date: Fri, 3 Sep 2021 13:25:19 +0100	[thread overview]
Message-ID: <20210903122519.GH4932@sirena.org.uk> (raw)
In-Reply-To: <ba3f8cda482dfa650af5dd3d1e95376e18bcd324.camel@kernel.crashing.org>


[-- Attachment #1.1: Type: text/plain, Size: 2347 bytes --]

On Fri, Sep 03, 2021 at 05:14:28PM +1000, Benjamin Herrenschmidt wrote:

> Well, the problem as far as I can tell is that the glibc implementation
> of these today. They support "FPSIMD" but that's about it (so no SVE or
> anything else) along with a comment:

> 	/* Check for FP SIMD context.  We don't support restoring
> 	   contexts created by the kernel, so this context must have
> 	   been created by getcontext.  Hence we can rely on the
> 	   first extension block being the FP SIMD context.  */

The kernel does generate a FPSIMD context in addition to any SVE context
for compatibility, though that doesn't mean you can actually fully
restore them successfully with glibc.  For contexts generated by glibc
note that unless a function signature involves a SVE type the SVE
register contents are caller saved:

   https://github.com/ARM-software/abi-aa/blob/main/aapcs64/aapcs64.rst#id48

so glibc will be fine just ignoring SVE when it generates contexts given
that it'll be doing that inside a non-SVE function call.

Like Szabolcs says BTI is going to cause issues restoring kernel
generated contexts even without extensions like SVE adding extra
register state.

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

> Extra data for userspace generated ucontext's isn't going to fly much,
> there's really no "place" to put it (those things can be part of
> structures etc...) and no "hook" to allocate/free sub structures.

> So you need whatever struct ucontext is used in userspace to be big
> enough.

Indeed, it'd have to be joined up with an increase of the userspace
ucontext.

> That said, I think the current one might be enough for sve512 (I need
> to check) and we could have glibc define something much bigger (16KB ?)
> without much damage I suspect.

Yes, the current context should be big enough for 512 bit SVE - that's
why the kernel clamps the default SVE vector length to 512 bits, so we
sidestep these issues by default even if the user happens to have a
system that can do larger vector lengths.  Not an immediate issue with
actual hardware in any case, though that code currently kicks in on
qemu's cpu=max.

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

[-- Attachment #2: Type: text/plain, Size: 176 bytes --]

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

      parent reply	other threads:[~2021-09-03 12:27 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-30 10:40 ucontext, kernel vs. userspace (glibc) Benjamin Herrenschmidt
2021-08-31 17:44 ` Catalin Marinas
2021-09-02 12:42 ` Mark Brown
2021-09-03  7:14   ` Benjamin Herrenschmidt
2021-09-03 11:02     ` Szabolcs Nagy
2021-09-03 12:25     ` Mark Brown [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210903122519.GH4932@sirena.org.uk \
    --to=broonie@kernel.org \
    --cc=benh@amazon.com \
    --cc=benh@kernel.crashing.org \
    --cc=catalin.marinas@arm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=szabolcs.nagy@arm.com \
    --cc=will@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.