Re: [PATCH kvm-unit-test 2/6] Introduce atomic operations

Glauber Costa
2010-08-27T11:39:33Z

On Fri, Aug 27, 2010 at 01:49:20PM +0800, Jason Wang wrote:
> +u64 atomic64_cmpxchg(atomic64_t *v, u64 old, u64 new)
> +{
> + u64 ret;
> + u64 _old = old;
> + u64 _new = new;
> +
> + asm volatile("lock cmpxchgq %1,%2"
> + : "=a" (ret)
> + : "r" (_new),
> + "m" (*(volatile long *)&v->counter), "0"(_old)
> + : "memory"
> + );
> + return ret;
> +}
> +
This is wrong.
See http://git.kernel.org/?p=linux/kernel/git/x86/linux-2.6-tip.git;a=commitdiff;h=113fc5a6e8c2288619ff7e8187a6f556b7e0d372

you need to explicitly mark you are changing the memory, here.

Btw, this is mostly header copying, and can miss bug fixes like the one above. Isn't there
a way to just specify in the test they are needed, and then grab them from linux automatically?