2.1.97: Broken asm() for set_ldt_desc()

Horst von Brand (vonbrand@sleipnir.valparaiso.cl)
Sat, 18 Apr 1998 23:00:13 -0400


This funcion (in include/asm-i386/system.h) now reads:

#define _set_tssldt_desc(n,addr,limit,type) \
__asm__ __volatile__ ("movw %3,0(%2)\n\t" \
"movw %%ax,2(%2)\n\t" \
"rorl $16,%%eax\n\t" \
"movb %%al,4(%2)\n\t" \
"movb %4,5(%2)\n\t" \
"movb $0,6(%2)\n\t" \
"movb %%ah,7(%2)\n\t" \
"rorl $16,%%eax" \
: "=m"(*(n)) : "a" (addr), "r"(n), "g"(limit), "i"(type))

#define set_tss_desc(n,addr) \
_set_tssldt_desc(((char *) (n)),((int)(addr)),235,0x89)
#define set_ldt_desc(n,addr,size) \
_set_tssldt_desc(((char *) (n)),((int)(addr)),((size << 3) -
1),0x82)

but it is called (in arch/i386/kernel/process.c) as:

set_ldt_desc(gdt+(nr<<1)+FIRST_LDT_ENTRY, ldt, ldt_size);

(the last argument used to be constant, and is now a variable). Note that
the instruction that starts the definition "movw %3,0(%2)" can only take a
register or constant as %3 (Perhaps I'm wrong here?), so the constraints of
the instruction aren't necesarily fulfilled anymore. The following patch
fixes this:

--- include/asm-i386/system.h-dist-2.1.97 Sat Apr 18 15:50:08 1998
+++ include/asm-i386/system.h Sat Apr 18 16:43:12 1998
@@ -293,7 +293,7 @@
"movb $0,6(%2)\n\t" \
"movb %%ah,7(%2)\n\t" \
"rorl $16,%%eax" \
- : "=m"(*(n)) : "a" (addr), "r"(n), "g"(limit), "i"(type))
+ : "=m"(*(n)) : "a" (addr), "r"(n), "ir"(limit), "i"(type))

#define set_tss_desc(n,addr) \
_set_tssldt_desc(((char *) (n)),((int)(addr)),235,0x89)

In case it makes any difference, I'm using egcs-980321 and binutils-2.9.0.3
to build my kernels. I'm now running the patched 2.1.97

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu