Solved; kernel freezes with egcs -O3 in pre-2.1.126

Alberto Vignani (vignani@mail.tin.it)
Sun, 18 Oct 1998 01:47:13 +0200


Hi.

The responsible of the system freeze at boot in 125ac1...pre126 was _of course_
in time.c (not setup.c).

With egcs-1.1, -O2 (not inlined):

00000000 <calibrate_tsc>:
0: 57 pushl %edi
1: bf 51 c3 00 00 movl $0xc351,%edi
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6: 56 pushl %esi
7: 53 pushl %ebx
8: e4 61 inb $0x61,%al
a: 24 fd andb $0xfd,%al
c: 0c 01 orb $0x1,%al
e: e6 61 outb %al,$0x61
10: b0 b0 movb $0xb0,%al
12: e6 43 outb %al,$0x43
14: b0 0c movb $0xc,%al
16: e6 42 outb %al,$0x42
18: b0 e9 movb $0xe9,%al
1a: e6 42 outb %al,$0x42
1c: 0f 31 rdtsc
1e: 89 c3 movl %eax,%ebx
20: 89 d1 movl %edx,%ecx
22: e4 61 inb $0x61,%al
24: a8 20 testb $0x20,%al
26: 74 fa je 22 <calibrate_tsc+0x22>
28: 0f 31 rdtsc
2a: a3 04 00 00 00 movl %eax,0x4
2f: 29 d8 subl %ebx,%eax
31: 19 ca sbbl %ecx,%edx
33: 89 c1 movl %eax,%ecx
35: 31 c0 xorl %eax,%eax
37: 89 fa movl %edi,%edx
^^^^
39: f7 f1 divl %ecx,%eax
3b: 89 c6 movl %eax,%esi
3d: 89 f0 movl %esi,%eax
3f: 5b popl %ebx
40: 5e popl %esi
41: 5f popl %edi
42: c3 ret
43: 90 nop

with -O3 (inlined):

00000000 <time_init>:
0: 57 pushl %edi
1: 56 pushl %esi
2: 53 pushl %ebx
3: e8 fc ff ff ff call 4 <time_init+0x4>
8: a3 00 00 00 00 movl %eax,0x0
d: c7 05 04 00 00 movl $0x0,0x4
12: 00 00 00 00 00
17: f6 05 0c 00 00 testb $0x10,0xc
1c: 00 10
1e: 74 7c je 9c <time_init+0x9c>
20: c7 05 0c 00 00 movl $0x6c8,0xc
25: 00 c8 06 00 00
2a: c7 05 00 00 00 movl $0x0,0x0
2f: 00 00 00 00 00
34: c7 05 14 00 00 movl $0x1a8,0x14
39: 00 a8 01 00 00
3e: b8 51 c3 00 00 movl $0xc351,%eax
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
43: e4 61 inb $0x61,%al <- eax destroyed
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
45: 24 fd andb $0xfd,%al
47: 0c 01 orb $0x1,%al
49: e6 61 outb %al,$0x61
4b: b0 b0 movb $0xb0,%al
4d: e6 43 outb %al,$0x43
4f: b0 0c movb $0xc,%al
51: e6 42 outb %al,$0x42
53: b0 e9 movb $0xe9,%al
55: e6 42 outb %al,$0x42
57: 0f 31 rdtsc
59: 89 c3 movl %eax,%ebx
5b: 89 d1 movl %edx,%ecx
5d: e4 61 inb $0x61,%al
5f: a8 20 testb $0x20,%al
61: 74 fa je 5d <time_init+0x5d>
63: 0f 31 rdtsc
65: a3 04 00 00 00 movl %eax,0x4
6a: 29 d8 subl %ebx,%eax
6c: 19 ca sbbl %ecx,%edx
6e: 89 c1 movl %eax,%ecx
70: 31 c0 xorl %eax,%eax
72: 89 c2 movl %eax,%edx <- eax always zero
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
74: f7 f1 divl %ecx,%eax
76: 89 c6 movl %eax,%esi
78: 31 c0 xorl %eax,%eax
7a: ba 40 42 0f 00 movl $0xf4240,%edx
7f: f7 f6 divl %esi,%eax
81: a3 00 00 00 00 movl %eax,0x0
86: 89 c7 movl %eax,%edi
88: 57 pushl %edi
89: 89 35 00 00 00 movl %esi,0x0
8e: 00
8f: 68 33 00 00 00 pushl $0x33
94: e8 fc ff ff ff call 95 <time_init+0x95>
99: 83 c4 08 addl $0x8,%esp
9c: 68 14 00 00 00 pushl $0x14
a1: 6a 00 pushl $0x0
a3: e8 fc ff ff ff call a4 <time_init+0xa4>
a8: 83 c4 08 addl $0x8,%esp
ab: 5b popl %ebx
ac: 5e popl %esi
ad: 5f popl %edi
ae: c3 ret

A possible solution:

"movl %%eax, %0\n\t"
: "=r" (retval)
> : "D" (5 * 1000020/HZ)
> : /* we clobber: */ "eax", "ebx", "ecx", "edx", "edi", "cc", "memory");

replacing the "r" with an explicit edi. Of course this could be a bug in
egcs, as eax was declared as being clobbered from the inline function and
should have not been reused.
Anyone has a better solution?

Alberto

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/