Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp4653441pxf; Tue, 30 Mar 2021 13:22:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxO1dExeshQNLQaaLB/X7thGInJ5bmDTOopKQRcX7YJcFd9gpm34FgoS9FrXscNV5Ecw0qe X-Received: by 2002:a50:9ea7:: with SMTP id a36mr36270854edf.174.1617135753910; Tue, 30 Mar 2021 13:22:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617135753; cv=none; d=google.com; s=arc-20160816; b=0ix4u8woX5eJTPv16aS9RRda/mUa5KI+rGTaWVXXBIMJ+ZqqMEs+81gN0VlX1kWImh NnMIBVZpPA5Lc4/JJcG7ENIhzvNWKhtY2soJdEMf/w3711wfpdGmOIA/b2bjDCptm06A +R/FA3sxvHAxAMxerQQz3D+rvr3a/S61+vZrbfw4rR4fBld1xTZtX3ocflNKTdjAycUR n8Hnnk3WflCNTGwcMlarPVANtfvtgCqwBg3gKTjeSl/5vmZQ5627y/cFIEfPrGLwXPgi HvTUuBLzvoVPXOkDhd1NETiRO2gr2Y0ucpaKyDFHXqCyNKaeqFqkie9PPOvcFbMB8ABV H0LQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:in-reply-to:cc:references:message-id:date :subject:mime-version:from:content-transfer-encoding:dkim-signature; bh=+fvRCak5nT+7vsNsQ37FYFv5hB/hQM4I7Onizfja+Yk=; b=ZRX607eRQlnJ42RcsX3URDeqpvtvkPgEPk+wQS9Ik5RRdE1mRFKKfKQT0BWHtpSk0Z vnsQnZn52Hlak//YWm6+Q2Z3TnImLxqZvfrfvS0LHhVYwK0SJPPwD6WhdErbV60V+Un7 /ZWAWE5tpscFoAoDgLvf5KyakzLdREMazYrcDBzXKdea1HztLqNaRg+B2V6hzq0quyfO A2tRqmCvkDGse+g3NE6UbbbfM9sZIc1TtPgwMhyuvfo0YUGZicZOPIMKIVql3ogGMw+9 9RyTShEFxnVDUOk5TcTbdheQrWO384WvutwoAddeSuDHQN9J/OBocL3WlkYKo9GcRPzj jzpQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amacapital-net.20150623.gappssmtp.com header.s=20150623 header.b=dyo9hBcc; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q3si16114365eji.445.2021.03.30.13.22.11; Tue, 30 Mar 2021 13:22:33 -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=@amacapital-net.20150623.gappssmtp.com header.s=20150623 header.b=dyo9hBcc; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229940AbhC3UVG (ORCPT + 99 others); Tue, 30 Mar 2021 16:21:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37122 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232394AbhC3UUl (ORCPT ); Tue, 30 Mar 2021 16:20:41 -0400 Received: from mail-pg1-x52d.google.com (mail-pg1-x52d.google.com [IPv6:2607:f8b0:4864:20::52d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1B770C061762 for ; Tue, 30 Mar 2021 13:20:30 -0700 (PDT) Received: by mail-pg1-x52d.google.com with SMTP id y32so11385782pga.11 for ; Tue, 30 Mar 2021 13:20:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amacapital-net.20150623.gappssmtp.com; s=20150623; h=content-transfer-encoding:from:mime-version:subject:date:message-id :references:cc:in-reply-to:to; bh=+fvRCak5nT+7vsNsQ37FYFv5hB/hQM4I7Onizfja+Yk=; b=dyo9hBcc2uhiFNIDb0P+xc3bKZmmyInA4bas7pmqj5KCVLdG2TYPs1dPhOUYmJjRm2 L8OX3M1ux4vxu3HbgUbSgVEokkRlNJ+9i8fvotEGIs8JZInGNe+3WEjmExm7boqErQvm Dlj8mdvz3MpgGdFlVD7dpz/uwGarh6a43aGmosqomfy87p0D2V4h3r/g0fA8Tj1sYqbw LIsj0coVi3FX4C/H6UFMTPZtzJLsWO72OBZUCV8Hsl8RSip1p6gyK5V8XhdQPTu6Xwt6 6/k1qgIQiij81yo7yqzX3mvU1HFiHBRAfDy0ydobg9JP+aW/S1KP2cmzGH0EJKcxWuNo Zvew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:content-transfer-encoding:from:mime-version :subject:date:message-id:references:cc:in-reply-to:to; bh=+fvRCak5nT+7vsNsQ37FYFv5hB/hQM4I7Onizfja+Yk=; b=j/yIb7KbjuOPxlev1q9rwhkmFKuRfEvunTwLPvWuMREUh8qfjmTYTnSDWcfDPUV8HH xNy6+8b/ikhmYSTIDXoqTtT9+8x+B+mgGMGy0bX8c4aqTPkO9K2F3v+2w98IvA/QR9kf XJ2dUCYuK8hryOldPSXBddfN0MCfFm4M378HRZ8zV2rMwRr6fbFFERubhuJTa96Nq2No MDROFIDig/KG6K50FVN/mzVBDoK9ldo6uPkyJl7r4R03IpY8bsKh1lwymKXpCLyXKPiW 8Xn3tb7ZWO2V4xuXSxyM6ZBIIafmk2bIcnpHkDYfr+Aiy1FX/7EDCw2nlsLMVuRkmRid rCHg== X-Gm-Message-State: AOAM531iU5g7p+4GGfJf4eXWg2JjhA2FO8rSx8FqiZBjH3RES4EFNBZv jD5LWsZSzfUPofODUILPtdAq5g== X-Received: by 2002:a63:545e:: with SMTP id e30mr30841258pgm.13.1617135629521; Tue, 30 Mar 2021 13:20:29 -0700 (PDT) Received: from ?IPv6:2601:646:c200:1ef2:30aa:f41a:f3f5:d36b? ([2601:646:c200:1ef2:30aa:f41a:f3f5:d36b]) by smtp.gmail.com with ESMTPSA id v25sm21757167pfn.51.2021.03.30.13.20.28 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 30 Mar 2021 13:20:28 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable From: Andy Lutomirski Mime-Version: 1.0 (1.0) Subject: Re: Candidate Linux ABI for Intel AMX and hypothetical new related features Date: Tue, 30 Mar 2021 13:20:27 -0700 Message-Id: References: Cc: Len Brown , Andy Lutomirski , Greg KH , "Bae, Chang Seok" , X86 ML , LKML , libc-alpha , Florian Weimer , Rich Felker , Kyle Huey , Keno Fischer , Linux API In-Reply-To: To: Dave Hansen X-Mailer: iPhone Mail (18D70) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > On Mar 30, 2021, at 12:12 PM, Dave Hansen wrote: >=20 > =EF=BB=BFOn 3/30/21 10:56 AM, Len Brown wrote: >> On Tue, Mar 30, 2021 at 1:06 PM Andy Lutomirski wro= te: >>>> On Mar 30, 2021, at 10:01 AM, Len Brown wrote: >>>> Is it required (by the "ABI") that a user program has everything >>>> on the stack for user-space XSAVE/XRESTOR to get back >>>> to the state of the program just before receiving the signal? >>> The current Linux signal frame format has XSTATE in uncompacted format, >>> so everything has to be there. >>> Maybe we could have an opt in new signal frame format, but the details w= ould need to be worked out. >>>=20 >>> It is certainly the case that a signal should be able to be delivered, r= un =E2=80=9Casync-signal-safe=E2=80=9D code, >>> and return, without corrupting register contents. >> And so an an acknowledgement: >>=20 >> We can't change the legacy signal stack format without breaking >> existing programs. The legacy is uncompressed XSTATE. It is a >> complete set of architectural state -- everything necessary to >> XRESTOR. Further, the sigreturn flow allows the signal handler to >> *change* any of that state, so that it becomes active upon return from >> signal. >=20 > One nit with this: XRSTOR itself can work with the compacted format or > uncompacted format. Unlike the XSAVE/XSAVEC side where compaction is > explicit from the instruction itself, XRSTOR changes its behavior by > reading XCOMP_BV. There's no XRSTORC. >=20 > The issue with using the compacted format is when legacy software in the > signal handler needs to go access the state. *That* is what can't > handle a change in the XSAVE buffer format (either optimized/XSAVEOPT, > or compacted/XSAVEC). The compacted format isn=E2=80=99t compact enough anyway. If we want to keep= AMX and AVX512 enabled in XCR0 then we need to further muck with the format= to omit the not-in-use features. I *think* we can pull this off in a way th= at still does the right thing wrt XRSTOR. If we go this route, I think we want a way for sigreturn to understand a poi= nter to the state instead of inline state to allow programs to change the st= ate. Or maybe just to have a way to ask sigreturn to skip the restore entir= ely.=