[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20190207111340.xaz7faetcags4qsb@linutronix.de>
Date: Thu, 7 Feb 2019 12:13:40 +0100
From: Sebastian Andrzej Siewior <bigeasy@...utronix.de>
To: Borislav Petkov <bp@...en8.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>,
Rik van Riel <riel@...riel.com>,
Dave Hansen <dave.hansen@...ux.intel.com>
Subject: Re: [PATCH 11/22] x86/fpu: Make get_xsave_field_ptr() and
get_xsave_addr() use feature number instead of mask
On 2019-01-28 19:49:59 [+0100], Borislav Petkov wrote:
> > --- a/arch/x86/kernel/fpu/xstate.c
> > +++ b/arch/x86/kernel/fpu/xstate.c
> > @@ -830,15 +830,15 @@ static void *__raw_xsave_addr(struct xregs_state *xsave, int xfeature_nr)
…
> > -void *get_xsave_addr(struct xregs_state *xsave, int xstate_feature)
> > +void *get_xsave_addr(struct xregs_state *xsave, int xfeature_nr)
> > {
> > - int xfeature_nr;
> > + u64 xfeature_mask = 1ULL << xfeature_nr;
>
> You can paste directly BIT_ULL(xfeature_nr) where you need it in this
> function...
changed.
> > @@ -850,11 +850,11 @@ void *get_xsave_addr(struct xregs_state *xsave, int xstate_feature)
> > * have not enabled. Remember that pcntxt_mask is
> > * what we write to the XCR0 register.
> > */
> > - WARN_ONCE(!(xfeatures_mask & xstate_feature),
> > + WARN_ONCE(!(xfeatures_mask & xfeature_mask),
>
> ... and turn this into:
>
> WARN_ONCE(!(xfeatures_mask & BIT_ULL(xfeature_nr))
>
> which is more readable than the AND of two variables which I had to
> re-focus my eyes to see the difference. :)
>
you mean with vs without the `s' ?
> Oh and this way, gcc generates better code by doing simply a BT
> directly:
>
> # arch/x86/kernel/fpu/xstate.c:852: WARN_ONCE(!(xfeatures_mask & BIT_ULL(xfeature_nr)),
> .loc 1 852 2 view .LVU258
> movq xfeatures_mask(%rip), %rax # xfeatures_mask, tmp124
> btq %rsi, %rax # xfeature_nr, tmp124
interesting. gcc should know that it can use btq or shift + and because
it has all the raw data.
Anyway, I replaced the two user of xfeature_mask with
BIT_ULL(xfeature_nr).
> Thx.
Sebastian
Powered by blists - more mailing lists