Skip to content

Commit 5292595

Browse files
danglin44gregkh
authored andcommitted
parisc: fix out-of-register compiler error in ldcw inline assembler function
commit 45db073 upstream. The __ldcw macro has a problem when its argument needs to be reloaded from memory. The output memory operand and the input register operand both need to be reloaded using a register in class R1_REGS when generating 64-bit code. This fails because there's only a single register in the class. Instead, use a memory clobber. This also makes the __ldcw macro a compiler memory barrier. Signed-off-by: John David Anglin <dave.anglin@bell.net> Signed-off-by: Helge Deller <deller@gmx.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 31b6929 commit 5292595

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

‎arch/parisc/include/asm/ldcw.h‎

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,18 @@
3333

3434
#endif /*!CONFIG_PA20*/
3535

36-
/* LDCW, the only atomic read-write operation PA-RISC has. *sigh*. */
36+
/* LDCW, the only atomic read-write operation PA-RISC has. *sigh*.
37+
We don't explicitly expose that "*a" may be written as reload
38+
fails to find a register in class R1_REGS when "a" needs to be
39+
reloaded when generating 64-bit PIC code. Instead, we clobber
40+
memory to indicate to the compiler that the assembly code reads
41+
or writes to items other than those listed in the input and output
42+
operands. This may pessimize the code somewhat but __ldcw is
43+
usually used within code blocks surrounded by memory barriors. */
3744
#define __ldcw(a) ({ \
3845
unsigned __ret; \
39-
__asm__ __volatile__(__LDCW " 0(%2),%0" \
40-
: "=r" (__ret), "+m" (*(a)) : "r" (a)); \
46+
__asm__ __volatile__(__LDCW " 0(%1),%0" \
47+
: "=r" (__ret) : "r" (a) : "memory"); \
4148
__ret; \
4249
})
4350

0 commit comments

Comments
 (0)