bugThe GNU Hurd - Bugs: bug #17338, GNU Mach vs. GCC 4.1


bug #17338: GNU Mach vs. GCC 4.1

Submitted by:  Thomas Schwinge <tschwinge>
Submitted on:  Sat Aug 5 23:09:58 2006  
Category: GNU MachSeverity: 4 - Important
Priority: 7 - HighItem Group: Standard Compliance
Status: FixedPrivacy: Public
Assigned to: Samuel Thibault <sthibaul>Originator Name: 
Open/Closed: ClosedReproducibility: Every Time
Size (loc): NonePlanned Release: GNU Mach 1.4
Effort: 0.00
Wiki-like text discussion box: 

Add a New Comment (Rich MarkupRich Markup):

You are not logged in

Please log in, so followups can be emailed to you.


Mon Sep 18 19:37:13 2006, comment #5:


Please check in file #10478 (patch-gnumach-seg-1) and then mark this bug as `fixed' and `closed'.

I'd suggest the following for the ChangeLog entry:

[current date] Samuel Thibault <samuel.thibault@ens-lyon.org>

* i386/i386/seg.h (struct pseudo_descriptor): Pack structure and move the
padding field to the end.
(lgdt): Pass the whole structure to the lgdt assembly command.
(lidt): Likewise.

Thomas Schwinge <tschwinge>
Project Administrator
Mon Sep 18 18:21:38 2006, comment #4:

> + short pad;
> Why do we need that padding field at all?

Because there are arrays of struct pseudo_descriptor, which the hardware require to have this big items.

Samuel Thibault <sthibaul>
Project MemberIn charge of this item.
Mon Sep 18 18:16:25 2006, comment #3:

Quoting from file #10478 (patch-gnumach-seg-1):

--- i386/i386/seg.h 5 Apr 2001 06:39:20 -0000 1.2
+++ i386/i386/seg.h 7 Aug 2006 03:59:04 -0000
@@ -121,20 +121,20 @@ struct real_gate {
/* Format of a "pseudo-descriptor", used for loading the IDT and GDT. */
struct pseudo_descriptor
- short pad;
unsigned short limit;
unsigned long linear_base;
+ short pad;
+} _attribute_((packed));

Why do we need that padding field at all?

Thomas Schwinge <tschwinge>
Project Administrator
Sat Aug 26 09:55:15 2006, comment #2:


Still no decision on this. I'm just wondering: will gnumach ever be compiled by something else than gcc? If not, then the "nice solution" (patch-gnumach-seg-1) can be safely applied (since gcc supports the "packed" attribute since a long time).


Samuel Thibault <sthibaul>
Project MemberIn charge of this item.
Mon Aug 7 04:27:10 2006, comment #1:

GCC gets smarter and smarter... When seeing this:

struct pseudo_descriptor
short pad;
unsigned short limit;
unsigned long linear_base;
MACH_INLINE void lgdt(struct pseudo_descriptor *pdesc)
__asm volatile("lgdt %0" : : "m" (pdesc->limit));
gdt_init() {
struct pseudo_descriptor pdesc;

pdesc.limit = sizeof(gdt)-1;
pdesc.linear_base = kvtolin(&gdt);

, it understands that filling the linear_base field is not needed, since we only give the limit field to the asm statement... The result it this:

gcc 4.0:
<gdt_init+102>: movw $0x57,0xfffffffa(%ebp)
<gdt_init+108>: movl $0xc0000000,0xfffffffc(%ebp)
<gdt_init+115>: lgdtl 0xfffffffa(%ebp)

gcc 4.1:
<gdt_init+102>: movw $0x57,0xfffffffa(%ebp)
<gdt_init+108>: lgdtl 0xfffffffa(%ebp)

it doesn't fill the linear_base field!

There are two possible fixes, that I'll attach:

- reorder the structure, pack it, and give it as a whole to the asm statement.
- clobber memory in the asm statement.

My preference goes to the first, since it explains to gcc what we exactly want. That supposes the support of the "packed" attribute, however.

Samuel Thibault <sthibaul>
Project MemberIn charge of this item.
Sat Aug 5 23:09:58 2006, original submission:

GNU Mach, built with GCC 4.1, immediatelly makes the system reboot after being executed by GRUB.

This was confirmed a) with the standard Debian tool chain and Debian gnumach package and b) with a cross compiler tool chain, gnumach-1-branch and compiling in only a minimal set of device drivers.

Thomas Schwinge <tschwinge>
Project Administrator


(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):

Attached Files
file #10479:  patch-gnumach-seg-2 added by sthibaul (1013B - application/octet-stream - more dirty solution)
file #10478:  patch-gnumach-seg-1 added by sthibaul (1kB - application/octet-stream - nice solution)


Depends on the following items: None found

Items that depend on this one

   task dependencies.


CC list is empty


Do you think this task is very important?
If so, you can click here to add your encouragement to it.
This task has 0 encouragements so far.

Only logged-in users can vote.


Please enter the title of George Orwell's famous dystopian book (it's a date):



Follow 7 latest changes.

Date Changed By Updated Field Previous Value => Replaced By
Tue Sep 19 00:27:00 2006sthibaulStatusIn Progress=>Fixed
Mon Sep 18 19:37:13 2006tschwingeAssigned toNone=>sthibaul
Mon Sep 18 18:16:25 2006tschwingeStatusConfirmed=>In Progress
  Carbon-Copy-=>Added sthibaul
Mon Aug 7 04:28:58 2006sthibaulAttached File-=>Added patch-gnumach-seg-2, #10479
Mon Aug 7 04:28:30 2006sthibaulAttached File-=>Added patch-gnumach-seg-1, #10478

Back to the top

Powered by Savane 3.1-cleanup1