Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E2D7DC433F5 for ; Fri, 3 Sep 2021 12:27:25 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A7F95603E7 for ; Fri, 3 Sep 2021 12:27:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org A7F95603E7 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Content-Type: List-Subscribe:List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: In-Reply-To:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date: Reply-To:Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date :Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=cgZtHyQv+HWVKUZBuMGlWMhxDWv+QmAv2tcsml2geJk=; b=i9R3ajiSrLn2lLaKDMk838EHkt 67jr+Tb1zLhnaZmolWys5Mu1xz6vPbiIEstLNMJzWMfSGVIKRzfnDNhqjM1gT2bjJcyP8j6cpMk6r IP4TKA1hu+I9vphmUZU0BE3L635gj+R2OSSAOi5VOyk0VccADXPuLpm9PjfM6cb8MtO314o0ZYSBq 5IhU5rkxmzYCj5s71CadsGsYk+kjI4nFJbw1DOWk+EUCJesRusBUaOrT/DGd0WKICJDU3SEWsznRb zTr0sSnfWwjmbWndSwNCNpVp3Q5XdSX6wHKfcE9ky2Cre1Q+IWSuOIAfqlu59T1uHUqlxC5gIo0ey L04TUt2Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mM8Gb-00BuYi-7g; Fri, 03 Sep 2021 12:25:57 +0000 Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mM8GX-00BuYE-2k for linux-arm-kernel@lists.infradead.org; Fri, 03 Sep 2021 12:25:54 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id 3B3E861051; Fri, 3 Sep 2021 12:25:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1630671952; bh=GsEK9r1K1O4cH+pNothml42tT01IyTiVnISJleR+miw=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=q9bOYbjhbdsLFbKTvVv8RWNRyjS0okjEYhGWjLoxLaBxwBMihpbDHtrcFchqZz4gw KEpEcBSlt/bVTI39Bo6UZzVU6Kyq8MeI2/H11z63nia5oSmasNRwVZ/a/SURK21kl2 vTzcGQmyaohUhEIMmpoKrMP8PUtPzxLB3lSWg76X29ZRFvmI29UyuRd09R2x6EeKEe 4jjCaiBk/0HzbfEidQ5dXRMhP2VsUxr5Zk49wRkZgknTWrTgnU1cJxF2cunImJKB/J h2vgXbWO6XJZd8KqDUCOiQiASEJnUR8o7PQzfzvHATEateyVAQfEqllDOT6YiZcLXe QkwrfUEa2rwnw== Date: Fri, 3 Sep 2021 13:25:19 +0100 From: Mark Brown To: Benjamin Herrenschmidt Cc: linux-arm-kernel@lists.infradead.org, Catalin Marinas , Will Deacon , Szabolcs Nagy , benh@amazon.com Subject: Re: ucontext, kernel vs. userspace (glibc) Message-ID: <20210903122519.GH4932@sirena.org.uk> References: <131d684ea46de6330ab90532ab73729d6c0690bd.camel@kernel.crashing.org> <20210902124236.GA4402@sirena.org.uk> MIME-Version: 1.0 In-Reply-To: X-Cookie: Darth Vader sleeps with a Teddywookie. User-Agent: Mutt/1.10.1 (2018-07-13) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210903_052553_195490_CB137DAA X-CRM114-Status: GOOD ( 23.54 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: multipart/mixed; boundary="===============4113053861247412018==" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org --===============4113053861247412018== Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="ewQ5hdP4CtoTt3oD" Content-Disposition: inline --ewQ5hdP4CtoTt3oD Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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. --ewQ5hdP4CtoTt3oD Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAABCgAdFiEEreZoqmdXGLWf4p/qJNaLcl1Uh9AFAmEyFC4ACgkQJNaLcl1U h9CCHAf+L6ytffk7Vb6XW1um/N67sMOY+lS6NKIsIZ6uzkx78gXzd2l8U3c0Fva6 v1XgDG12A2Bbl7wuIOcqsBUSWSqgxFnYwP3iAoTBfGfcyQO4QIp75u2eTfbeIWG6 ZBs0F7qW2dGYJnBw4OkTHg0Qwmu0hmMGqO30KdPBcOWXqsB+pgJnpPD9eQonaP1q zd8wQY3etJ6i+x8SRYU0INxAp8qoR6qBaQ/96bo1dEKPSQMN7VVZiyZFkimQaDFY InJ2fNz9Cmul8G0Ffh4IJdkAx7IvAhqID9YnCGb2Har7ez7nTgL2LmAtQDDVY4zW duJxOSw8yevpbVnOKWS+JpoEujWB3w== =yOTT -----END PGP SIGNATURE----- --ewQ5hdP4CtoTt3oD-- --===============4113053861247412018== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel --===============4113053861247412018==--