lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Fri, 21 May 2021 11:41:24 +0200
From:   Thomas Gleixner <tglx@...utronix.de>
To:     Dave Hansen <dave.hansen@...el.com>, Len Brown <lenb@...nel.org>
Cc:     Borislav Petkov <bp@...en8.de>, Willy Tarreau <w@....eu>,
        Andy Lutomirski <luto@...nel.org>,
        Florian Weimer <fweimer@...hat.com>,
        "Bae\, Chang Seok" <chang.seok.bae@...el.com>,
        X86 ML <x86@...nel.org>, LKML <linux-kernel@...r.kernel.org>,
        Linux API <linux-api@...r.kernel.org>,
        "libc-alpha\@sourceware.org" <libc-alpha@...rceware.org>,
        Rich Felker <dalias@...c.org>, Kyle Huey <me@...ehuey.com>,
        Keno Fischer <keno@...iacomputing.com>,
        Arjan van de Ven <arjan@...ux.intel.com>
Subject: Re: Candidate Linux ABI for Intel AMX and hypothetical new related features

Dave, Len,

On Thu, May 20 2021 at 15:53, Dave Hansen wrote:
> On 5/20/21 2:41 PM, Len Brown wrote:
>> So the questions are:
>> 1. who calls it -- a call/thread or process?  the application?  a
>> library -- which library?
>> 2. is it optional, or mandatory?
>> 3. if it is mandatory, what is the best way to enforce it?
>> 4. should we have a "release" system call too?
>> 
>> 1. Every thread needs a context switch buffer.  Does every thread make
>> the system call?  It seems sort of awkward for a library to always
>> make a system call before doing a TMUL.  It would be functionally
>> harmless, but it would add latency to an otherwise low-latency
>> operation.  If some central library does it, and caches that it has
>> done it before, then it would be ugly, but at least it would remove an
>> unnecessary user/kernel transition.
>
> Our system calls are *REALLY* fast.  We can even do a vsyscall for this
> if we want to get the overhead down near zero.  Userspace can also cache
> the "I did the prctl()" state in thread-local storage if it wants to
> avoid the syscall.

Correct.

>> 2. If it is optional, then v5 is code complete -- because it allows
>> you to allocate either explicitly via prtcl, or transparently via #NM.
>
> It needs to be mandatory.  If it's not, then nobody will use it, and
> they'll suffer the dreaded SIGSEGV-on-vmalloc()-failure and start filing
> bug reports.

Yes. Plus mandatory allows to do access control. IOW the prctl() can
return EPERM.

>> 3. If it is mandatory, then we should re-purpose the XFD mechanism:
>> app starts with XFD armed, by default
>> if app touches AMX before prctl, it takes a signal (and dies).

Yes.

>> When app calls prctl, allocate buffer disarm XFD for that app (exactly
>> what #NM trap does today).
>
> Yes, that sounds like a good use of XFD.

Agreed.

>> 4. I don't see a justification for a release concept, but it is
>> possible -- though sort of sticky with possible nested calls from
>> combinations of apps and libraries.  If that were sorted out by a
>> central library, then the actual system call on the last release per
>> thread would re-arm XFD to prevent access until the next explicit
>> request.  Unclear if it is important that the kernel actually do the
>> free -- some things might run faster if we keep it around...
>
> I think would be more of a get/put model rather than an allocate/free model.
>
> The "put" could effectively be a noop for now.

Yes.

> But, if we don't put this in the ABI up front, we can't add it later.
> That means that we could never add a lazy-free, even if we wanted to.

As I said somewhere in that thread, something like:

       prctl(PR_QUERY_XSTATE_FEATURES,....
       prctl(PR_ENABLE_XSTATE_FEATURES,....
       prctl(PR_DISABLE_XSTATE_FEATURES,....

To make this work you need refcounting and the last put (DISABLE) drops
the buffer and re-arms XFD. But of course an application/library can do
the put late if it knows that it's going to use it over and over.

Thanks,

        tglx

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ