lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:	Tue, 06 Apr 2010 13:11:12 -0700
From:	"H. Peter Anvin" <hpa@...or.com>
To:	Roland Dreier <rdreier@...co.com>
CC:	杨硕 <shanqn@...il.com>,
	linux-kernel@...r.kernel.org
Subject: Re: in x86 architecture ,why the function atomic_sub_and_test() does
 not  disable the interrupt?

On 04/05/2010 11:07 PM, Roland Dreier wrote:
>  > static inline int atomic_sub_and_test(int i, atomic_t *v)
>  > {
>  > 	unsigned char c;
>  > 
>  > 	asm volatile(LOCK_PREFIX "subl %2,%0; sete %1"
>  > 		     : "+m" (v->counter), "=qm" (c)
>  > 		     : "ir" (i) : "memory");
>  > 	return c;
>  > }
> 
> Why would disabling interrupts be necessary?  The LOCK_PREFIX makes the
> subl atomic, and the sete just operates using the flag set by subl, so
> it doesn't matter if any interrupts occur or not (since returning from
> an interrupt must obviously restore flags).

Even without the LOCK prefix, subl would be atomic against local
interrupts.  The LOCK prefix is only necessary to make it atomic against
other processors.

	-hpa
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ