Skip to contentSkip to conversation

Looks broken to me: x86, cyrix: debug

DISCUSSION Alan Cox 4 participants 5 messages Oct 11, 2008 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]

Alan Cox

author
#1 lore raw
Quoted 9 lines · On Sat, 11 Oct 2008 20:03:32 GMT Linux Kernel Mailing List…
Gitweb:     http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=026e2c05ef58ef413e2d52696f125d5ea1aa8bce
Commit:     026e2c05ef58ef413e2d52696f125d5ea1aa8bce
Parent:     93ded9b8fd42abe2c3607097963d8de6ad9117eb
Author:     Ingo Molnar <[email protected]>
AuthorDate: Tue Jul 22 11:58:14 2008 +0200
Committer:  Ingo Molnar <[email protected]>
CommitDate: Tue Jul 22 12:24:00 2008 +0200

x86, cyrix: debug

Looks broken to me:

Review

Quoted 3 lines
(quoted diff) +1 -1
 	/* Load/Store Serialize to mem access disable (=reorder it) */
-	setCx86(CX86_PCR0, getCx86(CX86_PCR0) & ~0x80);
+	setCx86_old(CX86_PCR0, getCx86_old(CX86_PCR0) & ~0x80);

Three problems:

1.

Quoted 1 line

+#define getCx86_old(reg) ({ outb((reg), 0x22); inb(0x23); })

Doesn't expand to any kind of returned value.

+#define setCx86_old(reg, data) do { \

Review

Quoted 3 lines
(quoted diff) +3 -0
+	outb((reg), 0x22); \
+	outb((data), 0x23); \
+} while (0)

2.
And even if it did it would seem to expand to

	outb reg, 0x22
	outb reg, 0x22
	inb 0x23
	outb something, 0x23

which doesn't in fact work as the outb/inb or outb/outb to 0x22/0x23 must be paired.

3.

What exactly does fiddling with stuff like the memory access ordering (which is rather important!) have to do with a single oneliner "cyrix:
debug" title and no changelog.

Alan

#2 lore raw
Quoted 3 lines · Alan Cox
Quoted 1 line

+#define getCx86_old(reg) ({ outb((reg), 0x22); inb(0x23); })

Doesn't expand to any kind of returned value.

Well, actually it returns the value of the inb() expression -- cf the
semantics of compound statements. The rest looks suspicious indeed.

Maciej

#3 lore raw
Quoted 8 lines · Maciej W. Rozycki
Quoted 3 lines · Alan Cox
Quoted 1 line

+#define getCx86_old(reg) ({ outb((reg), 0x22); inb(0x23); })

Doesn't expand to any kind of returned value.

Well, actually it returns the value of the inb() expression -- cf the
semantics of compound statements. The rest looks suspicious indeed.

indeed it's broken - will sort it out. It's all about breakage that has been in this code since v2.6.20, see c6744955d0. Will likely revert the whole thing.

Ingo

#4 lore raw
Quoted 7 lines · Ingo Molnar
Quoted 4 lines · Maciej W. Rozycki
Quoted 2 lines · Alan Cox
Quoted 1 line

+#define getCx86_old(reg) ({ outb((reg), 0x22); inb(0x23); })

Quoted 8 lines
Quoted 4 lines
Quoted 1 line

Doesn't expand to any kind of returned value.

Well, actually it returns the value of the inb() expression -- cf the
semantics of compound statements. The rest looks suspicious indeed.

indeed it's broken - will sort it out. It's all about breakage that has been in this code since v2.6.20, see c6744955d0. Will likely revert the whole thing.

In fact the whole commit looks buggy to me as it simply reintroduces the old bug at several places. The correct way of accessing the registers is precisely through the inline functions and never through a macro due to the ordering problem.

Willy

#5 lore raw
Quoted 4 lines · Willy Tarreau

In fact the whole commit looks buggy to me as it simply reintroduces the old bug at several places. The correct way of accessing the registers is precisely through the inline functions and never through a macro due to the ordering problem.

Well, with some GCC extensions macros can be written such that ordering
is kept, but inline functions tend to be simpler and often more readable.

Maciej