mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Wolfgang Walter <wolfgang.walter@stwm.de>
To: "H. Peter Anvin" <hpa@zytor.com>
Cc: Herbert Xu <herbert@gondor.apana.org.au>,
	Suresh Siddha <suresh.b.siddha@intel.com>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Ingo Molnar <mingo@elte.hu>,
	viro@zeniv.linux.org.uk, vegard.nossum@gmail.com
Subject: Re: Kernel oops with 2.6.26, padlock and ipsec: probably problem with fpu state changes
Date: Sat, 9 Aug 2008 12:50:42 +0200	[thread overview]
Message-ID: <200808091250.43184.wolfgang.walter@stwm.de> (raw)
In-Reply-To: <489D0F69.9050307@zytor.com>

On Saturday 09 August 2008, H. Peter Anvin wrote:
> Wolfgang Walter wrote:
> > 
> > These FPU changes are already in 2.6.26. Undoing them, would that be 
accepted 
> > for 2.6.26 stable?
> > 
> > Maybe the following solution would be possible: if a processor with 
padlock is 
> > detected the memory for xstate is always allocated when the thread is 
created 
> > instead "lazy"?
> > 
> 
> That will effectively happen, so it doesn't really matter.

With the patch? I don't think so:

With the patch the following changes compared with 2.6.25:

* processes which do not use FPU/SSE will not start saving and loading there 
xstate any more (and will not allocate xstate memory) if kernel is using 
padlock with the crypto-framework. Its similar to other places where the 
kernel uses MMX/SSE and protects them with kernel_fpu_begin(); 
kernel_fpu_end(); isn't it?

* if user space uses FPU/SSE its xstate will be saved though it is not really 
necessary.

* the crypto-framework using padlock can not be preempted any more while 
executing padlock-opcodes.

This is what Hebert fears.



What I'm not really understand - and Suresh probably could tell us - if with 
2.6.25 and earlier the following could happen:

1) a process is using FPU/SSE so it has a saved xstate BUT its not loaded 
because of lazy loading of FPU state (didn't use FPU/SSE for some time).

2) padlock usage by kernel without kernel_fpu_begin() kernel_fpu_end() sets 
TS_USEDFPU of this task but its not loaded

3) in __switch_to() the process then saves its FPU/SSE state overwriting its 
real xstate.

If I understand Suresh explanations correctly this could not happen.

The problem only exists at task creation time: a race between initialising 
TS_USEDFPU, used_math()) and setting the xstate pointer to NULL.

So wouldn't this help:

* a flag TS_INITIALISING is set for this task bevor used_math and TS_USEDFPU 
is set
* then math-state of the new task is initialisied including setting xstate to 
NULL
* then the flag is cleared
* math_state_restore() in trap_32.c does nothing if this flag is set.

Another possibility would be to use xstate for tracking if math has ever be 
used by this task and made TS_USEDFPU only valid if xtate != NULL

Both would only reestablish 2.6.25 behaviour.


But even if one or both would work its no solution for 2.6.26 (and probably 
2.6.27). My trust in 2.6.26 increased enough to use it on desktops and I 
would be a little bit nervous with such changes :-).

> 
> The true optimization would be to recognize that the state doesn't have 
> to be saved, and track when we did so, and so on and so forth.

Yes that would be perfect. But fixing the race between math-state 
initialisation and setting xtsate to NULL would be good enough. With ipsec 
traffic some tasks would save and restore unecessarily its xstate (as it is 
the case with 2.6.25 and earlier).

There is no way to know if it was the kernel who caused a math fault?

> 
> VIA really did their customers a disservice tying this to CR0.TS.
> 
> 	-hpa
> 
> 


Regards,
-- 
Wolfgang Walter
Studentenwerk München
Anstalt des öffentlichen Rechts

  reply	other threads:[~2008-08-09 10:50 UTC|newest]

Thread overview: 68+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <200807171653.59177.wolfgang.walter@stwm.de>
     [not found] ` <200807301411.01622.wolfgang.walter@stwm.de>
     [not found]   ` <20080806103354.GA31623@gondor.apana.org.au>
2008-08-06 17:33     ` Wolfgang Walter
2008-08-06 20:14       ` Suresh Siddha
2008-08-06 21:21         ` Suresh Siddha
2008-08-07  0:38           ` Wolfgang Walter
2008-08-08  8:44           ` Wolfgang Walter
2008-08-08 18:31           ` Vegard Nossum
2008-08-07 16:23         ` Wolfgang Walter
2008-08-08 10:36           ` Wolfgang Walter
2008-08-08 18:53             ` Suresh Siddha
2008-08-08 19:01               ` H. Peter Anvin
2008-08-08 19:19                 ` Wolfgang Walter
2008-08-08 23:11                 ` Suresh Siddha
2008-08-09  0:38                   ` Herbert Xu
2008-08-09  1:23                     ` Herbert Xu
2008-08-09  1:54                     ` Wolfgang Walter
2008-08-09  2:16                       ` Herbert Xu
2008-08-09  3:09                         ` Wolfgang Walter
2008-08-09  3:20                           ` Herbert Xu
2008-08-09 14:29                     ` Herbert Xu
2008-08-09 14:32                       ` Herbert Xu
2008-08-09 17:52                         ` Suresh Siddha
2008-08-10  5:30                           ` Herbert Xu
2008-08-10  5:41                             ` H. Peter Anvin
2008-08-11 22:57                               ` Suresh Siddha
2008-08-09 17:48                     ` Suresh Siddha
2008-08-09  1:28                   ` Wolfgang Walter
2008-08-09 13:31                   ` Herbert Xu
2008-08-09 14:37                   ` Herbert Xu
2008-08-09 15:14                     ` Wolfgang Walter
2008-08-09 15:57                     ` Wolfgang Walter
2008-08-09 16:10                       ` H. Peter Anvin
2008-08-09 17:02                         ` Wolfgang Walter
2008-08-09 18:52                         ` Suresh Siddha
2008-08-09 19:37                           ` Suresh Siddha
2008-08-09 22:59                             ` Wolfgang Walter
2008-08-10  3:05                             ` Herbert Xu
2008-08-11 19:01                               ` Suresh Siddha
2008-08-11 19:22                                 ` Ingo Molnar
2008-08-11 19:24                                   ` H. Peter Anvin
2008-08-11 20:19                                     ` Suresh Siddha
2008-08-12  0:39                                       ` Herbert Xu
2008-08-12  0:42                                         ` H. Peter Anvin
2008-08-12  0:46                                           ` Herbert Xu
2008-08-12  0:48                                             ` H. Peter Anvin
2008-08-12  0:52                                               ` Herbert Xu
2008-08-12  0:38                                 ` Wolfgang Walter
2008-08-12 11:43                                 ` Wolfgang Walter
2008-08-12 12:02                                   ` Herbert Xu
2008-08-12 18:28                                     ` Suresh Siddha
2008-08-12 23:40                                       ` Herbert Xu
2008-08-09 18:12                       ` Suresh Siddha
2008-08-09 18:54                         ` Suresh Siddha
2008-08-09 16:05                     ` H. Peter Anvin
2008-08-09 18:14                       ` Suresh Siddha
2008-08-10  0:29                       ` Herbert Xu
2008-08-10  1:56                         ` Wolfgang Walter
2008-08-10  1:59                           ` Herbert Xu
2008-08-09 17:59                     ` Suresh Siddha
2008-08-10  1:40                       ` Herbert Xu
2008-08-09  1:49                 ` Herbert Xu
2008-08-09  1:59                   ` H. Peter Anvin
2008-08-09  2:43                   ` Wolfgang Walter
2008-08-09  3:30                     ` H. Peter Anvin
2008-08-09 10:50                       ` Wolfgang Walter [this message]
2008-08-08 19:09             ` Wolfgang Walter
2008-08-08 19:32               ` Suresh Siddha
2008-08-08 23:10                 ` Wolfgang Walter
2008-08-08 23:15                   ` Suresh Siddha

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=200808091250.43184.wolfgang.walter@stwm.de \
    --to=wolfgang.walter@stwm.de \
    --cc=herbert@gondor.apana.org.au \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=netdev@vger.kernel.org \
    --cc=suresh.b.siddha@intel.com \
    --cc=vegard.nossum@gmail.com \
    --cc=viro@zeniv.linux.org.uk \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®