Skip to contentSkip to conversation

Clean up x86 write-protect test

PATCH Linus Torvalds 1 participant 1 message Oct 14, 2000 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw
Quoted 3 lines · Brian Gerst

Also, Could somebody who has a machine with a known buggy processor give this patch a try?

I like the patch. Would you mind re-writing the exception handling the other way around, though:

Instead of doing it like this:

+ __asm__ __volatile__(

+               "       movb %0,%1      \n"
+               "1:     movb %1,%0      \n"
+               "       jmp 3f          \n"
+               "2:     incl %2         \n"
+               "3:                     \n"
+               ".section __ex_table,\"a\"\n"
+               "       .align 4        \n"
+               "       .long 1b,2b     \n"
+               ".previous              \n"

+:"=m" (*(char *) vaddr),
+ "=q" (tmp_reg),
+ "=r" (flag)
+:"2" (flag)
+:"memory");

it would be nicer to simply to the other way around (if exception happens, "flag" is untouched and jumped over, if not, flag is cleared):

+ __asm__ __volatile__(

+               "       movb %0,%1      \n"
+               "1:     movb %1,%0      \n"
+               "       xor %2,%2       \n"
+               "2:                     \n"
+               ".section __ex_table,\"a\"\n"
+               "       .align 4        \n"
+               "       .long 1b,2b     \n"
+               ".previous              \n"

+:"=m" (*(char *) vaddr),
+ "=q" (tmp_reg),
+ "=r" (flag)
+:"2" (1)
+:"memory");

which basically means that if flag stays as "1", then the exception happened, but if the exception didn't happen the code will fall through the "xor" and clear "flag".

After that, and testing that it works on a broken machine, I'd love to apply it.

Linus

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
Please read the FAQ at http://www.tux.org/lkml/