All of lore.kernel.org
 help / color / mirror / Atom feed
From: "H. Peter Anvin" <hpa@zytor.com>
To: Borislav Petkov <bp@alien8.de>
Cc: X86 ML <x86@kernel.org>, LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 3/3] x86, FPU: Do not use static_cpu_has before alternatives
Date: Mon, 29 Apr 2013 11:58:49 -0700	[thread overview]
Message-ID: <517EC2E9.4030303@zytor.com> (raw)
In-Reply-To: <20130429185123.GB7049@pd.tnic>

On 04/29/2013 11:51 AM, Borislav Petkov wrote:
> On Mon, Apr 29, 2013 at 08:42:30AM -0700, H. Peter Anvin wrote:
>> I *was* considering adding static_cpu_has_safe() at some point which
>> would have a three-state jump, with the default (pre-alternatives)
>> jump pointing to dynamic detection code.
> 
> Actually, if we teach __static_cpu_has to do something like
> ALTERNATIVE_JUMP arch/x86/lib/copy_user_64.S but make the second
> alternative insn alt2 be none, i.e. no replacement, we can have:
> 
> * pre-alternatives: JMP dynamic_detection
> * post-alternatives:
>   - feature present: delete JMP
>   - feature absent: s/dynamic_detection/t_no/, i.e., patch only the label.

That is what I was referring to, yes.

> And even though asm goto supports multiple labels, we need to be able
> to either patch the label only or patch out the whole instruction -
> otherwise we'll be adding additional NOP bytes.

This doesn't seem to matter.

> I wonder if it would make sense to teach the alternatives to skip the
> opcode when patching so that we can say: "we only want to patch the
> label so we're patching in the offset now but leaving the single JMP
> opcode in there."
> 
> But for that we either need flags in struct alt_instr or do something
> ad-hoc apply_alternatives already does for relative jumps (0xe8).
> 
>> This might be useful here, on the other hand, perhaps it is acceptable
>> for use_eager_fpu() to be initially false?
> 
> Hmm, I don't know, FPU code is crazy. OTOH, does CR0.TS even matter on
> non-lazy FPU restore machines?

Yes, CR0.TS should be zero, or we'll get #NM traps when user space tries
to access the FPU.  For lazy restore CR0.TS should be set so we get the
#NM trap and can restore the FPU.

	-hpa




  reply	other threads:[~2013-04-29 18:59 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-29 14:04 [PATCH 0/3] FPU detection in C, second try Borislav Petkov
2013-04-29 14:04 ` [PATCH 1/3] x86: Get rid of ->hard_math and all the FPU asm fu Borislav Petkov
2013-04-29 14:04 ` [PATCH 2/3] x86: Sanity-check static_cpu_has usage Borislav Petkov
2013-04-29 15:38   ` H. Peter Anvin
2013-04-29 14:04 ` [PATCH 3/3] x86, FPU: Do not use static_cpu_has before alternatives Borislav Petkov
2013-04-29 15:42   ` H. Peter Anvin
2013-04-29 18:51     ` Borislav Petkov
2013-04-29 18:58       ` H. Peter Anvin [this message]
  -- strict thread matches above, loose matches on Subject: below --
2013-04-08 15:57 [PATCH 0/4] x86: FPU detection in C Borislav Petkov
2013-04-08 15:57 ` [PATCH 1/4] x86: Get rid of ->hard_math and all the FPU asm fu Borislav Petkov
2013-04-08 16:26   ` [tip:x86/cpu] " tip-bot for H. Peter Anvin
2013-06-12 20:48   ` [tip:x86/fpu] " tip-bot for H. Peter Anvin
2013-04-08 15:57 ` [PATCH 2/4] x86: Fold-in trivial check_config function Borislav Petkov
2013-04-08 16:27   ` [tip:x86/cpu] " tip-bot for Borislav Petkov
2013-04-16 13:51   ` tip-bot for Borislav Petkov
2013-04-08 15:57 ` [PATCH 3/4] x86, AMD: Correct {rd,wr}msr_amd_safe warnings Borislav Petkov
2013-04-08 16:28   ` [tip:x86/cpu] " tip-bot for Borislav Petkov
2013-04-16 13:53   ` tip-bot for Borislav Petkov
2013-04-08 15:57 ` [PATCH 4/4] x86, CPU, AMD: Drop useless label Borislav Petkov
2013-04-08 16:29   ` [tip:x86/cpu] " tip-bot for Borislav Petkov
2013-04-16 13:54   ` tip-bot for Borislav Petkov
2013-04-10 11:08 ` [PATCH 0/4] x86: FPU detection in C Ingo Molnar
2013-04-10 12:24   ` Borislav Petkov
2013-04-10 12:25     ` Ingo Molnar
2013-04-10 13:32       ` Borislav Petkov
2013-04-10 15:35         ` H. Peter Anvin
2013-04-10 16:11           ` Borislav Petkov
2013-04-10 21:29             ` [PATCH] x86, FPU: Fix FPU initialization Borislav Petkov
2013-04-11 12:09               ` Ingo Molnar
2013-04-11 14:23                 ` Borislav Petkov
2013-04-11 19:26                 ` H. Peter Anvin
2013-04-11 20:23                   ` Borislav Petkov
2013-04-12  5:32                     ` Ingo Molnar
2013-04-12  5:34                       ` H. Peter Anvin
2013-04-12  9:47                         ` Borislav Petkov
2013-04-12 11:26                           ` Borislav Petkov
2013-04-15 10:08                             ` Ingo Molnar
2013-04-15 10:17                               ` Borislav Petkov
2013-04-15 10:18                                 ` Ingo Molnar
2013-04-15 15:54                                   ` Borislav Petkov
2013-04-15 22:04                                     ` Borislav Petkov
2013-04-16  9:25                                       ` Ingo Molnar
2013-04-16  9:48                                         ` Borislav Petkov
2013-04-16 10:08                                           ` [GIT PULL] Rebase tip:x86/cpu Borislav Petkov
2013-04-16 11:35                                             ` Ingo Molnar
2013-04-16 11:33                                           ` [PATCH] x86, FPU: Fix FPU initialization Ingo Molnar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=517EC2E9.4030303@zytor.com \
    --to=hpa@zytor.com \
    --cc=bp@alien8.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.