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:   Wed, 12 Sep 2018 11:30:10 -0400
From:   Rik van Riel <riel@...riel.com>
To:     Andy Lutomirski <luto@...capital.net>,
        Sebastian Andrzej Siewior <bigeasy@...utronix.de>
Cc:     linux-kernel@...r.kernel.org, x86@...nel.org,
        Andy Lutomirski <luto@...nel.org>,
        Paolo Bonzini <pbonzini@...hat.com>,
        Radim Krčmář <rkrcmar@...hat.com>,
        kvm@...r.kernel.org, "Jason A. Donenfeld" <Jason@...c4.com>
Subject: Re: [RFC PATCH 04/10] x86/fpu: eager switch PKRU state

On Wed, 2018-09-12 at 08:20 -0700, Andy Lutomirski wrote:
> > 
> > --- a/arch/x86/mm/pkeys.c
> > +++ b/arch/x86/mm/pkeys.c
> > @@ -18,6 +18,20 @@
> > 
> > #include <asm/cpufeature.h>             /* boot_cpu_has,
> > ...            */
> > #include <asm/mmu_context.h>            /*
> > vma_pkey()                   */
> > +#include <asm/fpu/internal.h>
> > +
> > +void write_pkru(u32 pkru)
> > +{
> > +    if (!boot_cpu_has(X86_FEATURE_OSPKE))
> > +        return;
> > +
> > +    current->thread.fpu.pkru = pkru;
> > +
> 
> I thought that the offset of PKRU in the xstate was fixed after boot.

You are right, it is.  However, that offset would need
to be stored somewhere, and the value read every time
we wanted to read or store the PKRU value from/to the
floating point state.

I suspect that would not be any faster than keeping a
copy of the PKRU value in a known location.

> Anyway, as written, this needs a lockdep assertion that we’re not
> preemptible, an explicit preempt_disable(), or a comment explaining
> why it’s okay if we get preempted in this function.
> 
> > +    __fpregs_changes_begin();

This handles the preemption disabling, see patch
3 of the series.

> > +    __fpregs_load_activate(&current->thread.fpu,
> > smp_processor_id());
> > +    __write_pkru(pkru);
> > +    __fpregs_changes_end();
> > +}
> > 
> > int __execute_only_pkey(struct mm_struct *mm)
> > {
> > -- 
> > 2.19.0
> > 
> 
> 
-- 
All Rights Reversed.

Download attachment "signature.asc" of type "application/pgp-signature" (489 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ