tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

rump locking fix

We have been using rump a) in a system compiled with debugging and b)
with IPsec.  I have several changes, all due to Mark Keaton of BBN,
which I'll send here, and commit if there are no objections.


When compiling debug versions of the stock NetBSD 6 rump libraries,
gcc reports an error in spinlock.c:
  "Error: bad register name `%sil'".
This error was reported to gcc bugzilla in ticket 35102:

According to the bug report, this is not a gcc bug, but an issue with
the inline assembly code being compiled.  It appears that using the
"r" constraint for registers with the xchgb instruction (and other
instructions as well) is incorrect, and the "q" constraint should be
used instead.  Specifying an "r" constraint allows gcc to keep the
variable in any GPR, while the "q" constraint uses only registers "a",
"b", "c", or "d".

Note that this error does not occur when compiling optimized versions
of these libraries, only when compiling debug versions.

This commit changes the "r" constraints to "q" constraints in the
__cpu_simple_lock_try() function's inline assembly.  The changed code
then compiles cleanly for both optimized and debug versions.

--- a/netbsd/src/sys/rump/librump/rumpkern/arch/i386/spinlock.c
+++ b/netbsd/src/sys/rump/librump/rumpkern/arch/i386/spinlock.c
@@ -54,8 +54,8 @@ __cpu_simple_lock_try(__cpu_simple_lock_t *lockp)
        val = __SIMPLELOCK_LOCKED;
        __asm volatile ("xchgb %0,(%2)" : 
-           "=r" (val)
-           :"0" (val), "r" (lockp));
+           "=q" (val)
+           :"0" (val), "q" (lockp));
        return val == __SIMPLELOCK_UNLOCKED;

Attachment: pgpEJri3jMNmc.pgp
Description: PGP signature

Home | Main Index | Thread Index | Old Index