linux-um archives
 help / color / mirror / Atom feed
From: Blaisorblade <blaisorblade@yahoo.it>
To: Jeff Dike <jdike@addtoit.com>, Alexander Viro <viro@zeniv.linux.org.uk>
Cc: Andrew Morton <akpm@osdl.org>,
	linux-kernel@vger.kernel.org,
	user-mode-linux-devel@lists.sourceforge.net
Subject: Re: [uml-devel] [PATCH 06/14] uml: make UML_SETJMP always safe
Date: Sat, 14 Oct 2006 02:13:55 +0200	[thread overview]
Message-ID: <200610140213.56153.blaisorblade@yahoo.it> (raw)
In-Reply-To: <20061009180013.GB4931@ccure.user-mode-linux.org>

On Monday 09 October 2006 20:00, Jeff Dike wrote:
> On Thu, Oct 05, 2006 at 11:38:52PM +0200, Paolo 'Blaisorblade' Giarrusso 
wrote:
> > From: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>
> >
> > If enable is moved by GCC in a register its value may not be preserved
> > after coming back there with longjmp(). So, mark it as volatile to
> > prevent this; this is suggested (it seems) in info gcc, when it talks
> > about -Wuninitialized. I re-read this and it seems to say something
> > different, but I still believe this may be needed.
> >
> > Signed-off-by: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>
> > ---
> >
> >  arch/um/include/longjmp.h |    3 ++-
> >  1 files changed, 2 insertions(+), 1 deletions(-)
> >
> > diff --git a/arch/um/include/longjmp.h b/arch/um/include/longjmp.h
> > index e93c6d3..e860bc5 100644
> > --- a/arch/um/include/longjmp.h
> > +++ b/arch/um/include/longjmp.h
> > @@ -12,7 +12,8 @@ #define UML_LONGJMP(buf, val) do { \
> >  } while(0)
> >
> >  #define UML_SETJMP(buf) ({ \
> > -	int n, enable;	   \
> > +	int n;	   \
> > +	volatile int enable;	\
> >  	enable = get_signals(); \
> >  	n = setjmp(*buf); \
> >  	if(n != 0) \
>
> I agree with this, but not entirely with your reasoning.  The
> -Wuninitialized documentation just talks about when gcc emits a
> warning.
>
> What we want is a guarantee that enable is not cached in a register,
> but is stored in memory.  What documentation I can find seems to imply
> that is the case ("accesses to volatile objects must have settled
> before the next sequence point").
>
> However, given the prevailing opinion that essentially all volatile
> declarations are hiding bugs, I wouldn't mind a bit of review of this
> from someone holding this opinion.

I agree with that, so I think Al (whom I cc'ed) will be able to evaluate this.
 - however I think that the problem with volatile is that it does not have any 
semantic wrt cache - volatile does not even work with host-to-device 
operation (the thing it was thought for) if you have reasonable caches - 
unless the var is in a MMIO region with disabled caches.

So relying on volatile for variables shared between threads is not useful.

Note that raw_spinlock_t counter is volatile, however - separate caches 
flushes or atomic operations are needed, but it may avoid the need for a full 
barrier() operation or a volatile "memory" clobber - GCC knows only the 
volatile object has changed, while with barrier() it must assume everything 
must be reloaded. However, at least one barrier operation is needed for a 
spinlock to prevent GCC from moving code outside of critical sections.
-- 
Inform me of my mistakes, so I can keep imitating Homer Simpson's "Doh!".
Paolo Giarrusso, aka Blaisorblade
http://www.user-mode-linux.org/~blaisorblade
Chiacchiera con i tuoi amici in tempo reale! 
 http://it.yahoo.com/mail_it/foot/*http://it.messenger.yahoo.com 


-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel

  reply	other threads:[~2006-10-14  0:14 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-10-05 21:32 [uml-devel] [PATCH 00/14] UML: simple changes for 2.6.19 Paolo 'Blaisorblade' Giarrusso
2006-10-05 21:38 ` [uml-devel] [PATCH 01/14] uml: fix compilation options for USER_OBJS Paolo 'Blaisorblade' Giarrusso
2006-10-09 16:32   ` Jeff Dike
2006-10-11 11:08     ` Paolo Giarrusso
2006-10-13 20:10       ` Jeff Dike
2006-10-26  6:08         ` Blaisorblade
2006-10-05 21:38 ` [uml-devel] [PATCH 02/14] uml: revert wrong patch Paolo 'Blaisorblade' Giarrusso
2006-10-05 21:45   ` Andi Kleen
2006-10-05 21:45     ` Blaisorblade
2006-10-05 21:38 ` [uml-devel] [PATCH 03/14] uml: correct removal of pte_mkexec Paolo 'Blaisorblade' Giarrusso
2006-10-05 21:38 ` [uml-devel] [PATCH 04/14] uml: readd forgot prototype Paolo 'Blaisorblade' Giarrusso
2006-10-06  1:00   ` Andrew Morton
2006-10-09 18:12     ` Jeff Dike
2006-10-05 21:38 ` [uml-devel] [PATCH 05/14] uml: make TT mode compile after setjmp-related changes Paolo 'Blaisorblade' Giarrusso
2006-10-05 21:38 ` [uml-devel] [PATCH 06/14] uml: make UML_SETJMP always safe Paolo 'Blaisorblade' Giarrusso
2006-10-09 18:00   ` Jeff Dike
2006-10-14  0:13     ` Blaisorblade [this message]
2006-10-05 21:38 ` [uml-devel] [PATCH 07/14] uml: fix processor selection to exclude unsupported processors and features Paolo 'Blaisorblade' Giarrusso
2006-10-05 21:38 ` [uml-devel] [PATCH 08/14] uml: fix uname under setarch i386 Paolo 'Blaisorblade' Giarrusso
2006-10-05 21:39 ` [uml-devel] [PATCH 09/14] uml: declare in Kconfig our partial LOCKDEP support Paolo 'Blaisorblade' Giarrusso
2006-10-05 21:39 ` [uml-devel] [PATCH 10/14] uml: allow using again x86/x86_64 crypto code Paolo 'Blaisorblade' Giarrusso
2006-10-05 21:39 ` [uml-devel] [PATCH 11/14] uml: asm offsets duplication removal Paolo 'Blaisorblade' Giarrusso
2006-10-05 21:39 ` [uml-devel] [PATCH 12/14] uml: remove duplicate export Paolo 'Blaisorblade' Giarrusso
2006-10-05 21:39 ` [uml-devel] [PATCH 13/14] uml: deprecate CONFIG_MODE_TT Paolo 'Blaisorblade' Giarrusso
2006-10-09 18:05   ` Jeff Dike
2006-10-05 21:39 ` [uml-devel] [PATCH 14/14] uml: allow finer tuning for host VMSPLIT setting Paolo 'Blaisorblade' Giarrusso
2006-10-09 18:11 ` [uml-devel] [PATCH 00/14] UML: simple changes for 2.6.19 Jeff Dike

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=200610140213.56153.blaisorblade@yahoo.it \
    --to=blaisorblade@yahoo.it \
    --cc=akpm@osdl.org \
    --cc=jdike@addtoit.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=user-mode-linux-devel@lists.sourceforge.net \
    --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