Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

parisc: fix ldcw inline assembler

There are two reasons to expose the memory *a in the asm:

1) To prevent the compiler from discarding a preceeding write to *a, and
2) to prevent it from caching *a in a register over the asm.

The change has had a few days testing with a SMP build of 2.6.22.19
running on a rp3440.

This patch is about the correctness of the __ldcw() macro itself.
The use of the macro should be confined to small inline functions
to try to limit the effect of clobbering memory on GCC's optimization
of loads and stores.

Signed-off-by: Dave Anglin <dave.anglin@nrc-cnrc.gc.ca>
Signed-off-by: Helge Deller <deller@gmx.de>
Signed-off-by: Kyle McMartin <kyle@mcmartin.ca>

authored by

Helge Deller and committed by
Kyle McMartin
7d17e276 4fb11781

+2 -2
+2 -2
arch/parisc/include/asm/system.h
··· 168 168 /* LDCW, the only atomic read-write operation PA-RISC has. *sigh*. */ 169 169 #define __ldcw(a) ({ \ 170 170 unsigned __ret; \ 171 - __asm__ __volatile__(__LDCW " 0(%1),%0" \ 172 - : "=r" (__ret) : "r" (a)); \ 171 + __asm__ __volatile__(__LDCW " 0(%2),%0" \ 172 + : "=r" (__ret), "+m" (*(a)) : "r" (a)); \ 173 173 __ret; \ 174 174 }) 175 175