Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp1826704pxf; Fri, 26 Mar 2021 16:23:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwFwPPFqUMBVhswvK8KTuM82jcBWu1Md3TBE4WzQ23hkVH8elLU6ZIYtQLqwaFfb0TUtN6+ X-Received: by 2002:a05:6402:31a7:: with SMTP id dj7mr17897208edb.33.1616801004993; Fri, 26 Mar 2021 16:23:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616801004; cv=none; d=google.com; s=arc-20160816; b=QvYCbv0xWlCMZ2dhE/1LW9+qXWDYj4wGUmYOG1noBt0eNn5XodfjgFncH5nS+2oyvW JbhF6vXmPebpXtexyPCYiGMsyEd5475/jOemkJp0Cj+EOQhNft7gC9DsA6yTkNjRhJmu xtc9yOR75xLuWAcTvAJ6hc4dVXGwNKhByPgXY9WoBTvPVgZFuxd44cIzFHyymkk13jx7 uGtrd5J9WBSKgRODWDVIM8Tr4k4FkZKPrmaThlfKprQyqT9ey3P3x3FKT2s1+5RUj0Y9 HXnEhvSUgwkj73yZprrA7bkQLrHqBAiOfSD/+x4pf/32/I6MxXm1PUfqxO7TzG5Wof4W dctQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=U71xr8ZCvdIYDEuAbTf0dw+H+Gka6HA0wYyfo/TKEMY=; b=WCQl7SCWCoKK3fa3SQa4K7IN+sjZGnDslVvjqF9tYDEqKvFJtyAAQD2emTdvCTXTtw E6/ibKfuGRn2+LzJzXGgo00b56xLAD3p+Qtz7RyN3LPjR3+B63YDzmLJij7DsbrHRJ1v k+zrwMqhZczFLfOGVLPd8g+hwLqMtS6nIP96gxLvxznoVjFwSWP6s0n2hFU3ZmJRx9pz LUOlBVK6uy6t0lf6swVOaMFeMaT6jI30H1QxYhTTIs9Li9mEVDrs5PQXTLVKipqnHdK6 C8NSGjrXJk7aChc72+p9yyNolCOTouWMAz/L58z9RnjLCRICocateiArpuFT4VxmT5dN t+Fg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=kgkWB2u0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b17si7575382ejp.314.2021.03.26.16.23.02; Fri, 26 Mar 2021 16:23:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=kgkWB2u0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231297AbhCZXUd (ORCPT + 99 others); Fri, 26 Mar 2021 19:20:33 -0400 Received: from mail.kernel.org ([198.145.29.99]:38574 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231706AbhCZXS1 (ORCPT ); Fri, 26 Mar 2021 19:18:27 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 4CC3161A38 for ; Fri, 26 Mar 2021 23:18:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1616800707; bh=gOUhHgYPRp8RB7xmeqPi4U4o0hzbDr/hS2GiFjT/kzs=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=kgkWB2u0z8UWDa8pvMaIT0HQqVRWxkNt40dKPnB/UJQT32ZX8crLoTkNYRaQs6Nq6 972T99eypWVXa2yGsV5rJgQ3yne9dLXrl7h2wYw+ZuzTOxr+NJZYV6YcLzXTEPCwMT eXhhn5QdYjokxIi8O0TQEX84yyXsmZeq8xq33JaNFHW+OkS/M+KXOfW88BGQnzo2Gv TN7Rk1E9Z70kkdpErTY8c59hT2qf49TMmx0a3Ql46t/H1+pDjBOk+ACJ/UOGtXC9FH 1Cb3+KgTJVf0k0CHPakHkpdQeweY8xCEJnfq1oMHYe3rWX2g+EMNOtn+PACrBcPrns NoTdgBMgoc12g== Received: by mail-ej1-f47.google.com with SMTP id b7so10777823ejv.1 for ; Fri, 26 Mar 2021 16:18:27 -0700 (PDT) X-Gm-Message-State: AOAM5306NMxOLZ+n5heKUElUu9pCuSzeVLpNvwVOfDiqXxVyeFSGMVd3 pOB+esUKwE6NQO9S2quoc/8cCknuzev8YEqif8W2vg== X-Received: by 2002:a17:906:1494:: with SMTP id x20mr17630167ejc.101.1616800705721; Fri, 26 Mar 2021 16:18:25 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Andy Lutomirski Date: Fri, 26 Mar 2021 16:18:14 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: Candidate Linux ABI for Intel AMX and hypothetical new related features To: Andy Lutomirski Cc: "Bae, Chang Seok" , Dave Hansen , X86 ML , LKML , libc-alpha , Florian Weimer , Rich Felker , Kyle Huey , Keno Fischer , Linux API Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Sigh, cc linux-api, not linux-abi. On Fri, Mar 26, 2021 at 4:12 PM Andy Lutomirski wrote: > > Hi all- > > After some discussion on IRC, I have a proposal for a Linux ABI for > using Intel AMX and other similar features. It works like this: > > First, we make XCR0 dynamic. This looks a lot like Keno's patch but > with a different API, outlined below. Different tasks can have > different XCR0 values. The default XCR0 for new tasks does not > include big features like AMX. XMM and YMM are still there. The AVX2 > states are debatable -- see below. > > To detect features and control XCR0, we add some new arch_prctls: > > arch_prctl(ARCH_GET_XCR0_SUPPORT, 0, ...); > > returns the set of XCR0 bits supported on the current kernel. > > arch_prctl(ARCH_GET_XCR0_LAZY_SUPPORT, 0, ...); > > returns 0. See below. > > arch_prctl(ARCH_SET_XCR0, xcr0, lazy_states, sigsave_states, > sigclear_states, 0); > > Sets xcr0. All states are preallocated except that states in > lazy_states may be unallocated in the kernel until used. (Not > supported at all in v1. lazy_states & ~xcr0 != 0 is illegal.) States > in sigsave_states are saved in the signal frame. States in > sigclear_states are reset to the init state on signal delivery. > States in sigsave_states are restored by sigreturn, and states not in > sigsave_states are left alone by sigreturn. > > Optionally we do not support PKRU at all in XCR0 -- it doesn't make > that much sense as an XSAVE feature, and I'm not convinced that trying > to correctly context switch XINUSE[PKRU] is worthwhile. I doubt we > get it right today. > > Optionally we come up with a new format for new features in the signal > frame, since the current format is showing its age. Taking 8kB for a > signal with AMX is one thing. Taking another 8kB for a nested signal > if AMX is not in use is worse. > > Optionally we make AVX-512 also default off, which fixes what is > arguably a serious ABI break with AVX-512: lots of programs, following > POSIX (!), seem to think that they know much much space to allocate > for sigaltstack(). AVX-512 is too big. > > Thoughts? > > --Andy