public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Chuck Ebbert <76306.1226@compuserve.com>
To: Andrew Morton <akpm@osdl.org>
Cc: torvalds@osdl.org, mingo@redhat.com, ak@suse.de,
	linux-kernel@vger.kernel.org, trond.myklebust@fys.uio.no,
	Andreas Schwab <schwab@suse.de>
Subject: Re: set_bit() is broken on i386?
Date: Sat, 21 Jan 2006 02:43:25 -0500	[thread overview]
Message-ID: <200601210245_MC3-1-B656-5DCD@compuserve.com> (raw)

In-Reply-To: <20060120183857.188ef516.akpm@osdl.org>

On Fri, 20 Jan 2006, Andrew Morton wrote:

> We need to somehow tell the compiler "this assembly statement altered
> memory and you can't cache memory contents across it".  That's what
> "memory" (ie: barrier()) does.  I don't think there's a way of telling gcc
> _what_ memory was clobbered - just "all of memory".

I think you can do that by specifying an output operand that you
never use in your assembler code, e.g. changing this:

|       __asm__ __volatile__( "lock ; "
|               "btsl %1,%0"
|               :"=m" (ADDR)
|               :"Ir" (nr));

to this:

| #define LONGBITS (8 * sizeof(unsigned long))
|
|       __asm__ __volatile__( "lock ; "
|               "btsl %2,%1"
|               :"=m"(*(&ADDR + nr/LONGBITS))
|               :"m" (ADDR), "Ir" (nr));

fixes my example program by telling the compiler what memory location
is altered.  (Note that %0 is never used inside the asm code.)
So iff 'nr' is a constant you can clobber specific memory locations.
-- 
Chuck
Currently reading: _Sun Of Suns_ by Karl Schroeder

             reply	other threads:[~2006-01-21  7:48 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-01-21  7:43 Chuck Ebbert [this message]
  -- strict thread matches above, loose matches on Subject: below --
2006-01-21 20:49 set_bit() is broken on i386? Chuck Ebbert
2006-01-21  2:07 Kenny Simpson
2006-01-21  1:46 Kenny Simpson
2006-01-21  1:38 Kenny Simpson
2006-01-21  0:53 Chuck Ebbert
2006-01-21  1:15 ` Trond Myklebust
2006-01-21  1:49   ` Andreas Schwab
2006-01-21  2:38     ` Andrew Morton
2006-01-21 19:26       ` Trond Myklebust
2006-01-21  1:32 ` Valdis.Kletnieks
2006-01-21  2:01   ` Grzegorz Kulewski
2006-01-21  1:48 ` Andrew Morton

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=200601210245_MC3-1-B656-5DCD@compuserve.com \
    --to=76306.1226@compuserve.com \
    --cc=ak@suse.de \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=schwab@suse.de \
    --cc=torvalds@osdl.org \
    --cc=trond.myklebust@fys.uio.no \
    /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