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 05 Aug 2006 11:09:58 PM UTC  
 
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 18 Sep 2006 07:37:13 PM UTC, comment #5:

Ok.

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:

#v+
[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.
#v-

Thomas Schwinge <tschwinge>
Project Administrator
Mon 18 Sep 2006 06:21:38 PM UTC, 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 18 Sep 2006 06:16:25 PM UTC, comment #3:

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

#v+
[...]
--- 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));
[...]
#v-

Why do we need that padding field at all?

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

Hi,

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).

Regards,
Samuel

Samuel Thibault <sthibaul>
Project MemberIn charge of this item.
Mon 07 Aug 2006 04:27:10 AM UTC, 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);
lgdt(&pdesc);
}
}

, 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 05 Aug 2006 11:09:58 PM UTC, 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):
   
   
Comment:
   

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

Digest:
   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 19 Sep 2006 12:27:00 AM UTCsthibaulStatusIn Progress=>Fixed
  Open/ClosedOpen=>Closed
Mon 18 Sep 2006 07:37:13 PM UTCtschwingeAssigned toNone=>sthibaul
Mon 18 Sep 2006 06:16:25 PM UTCtschwingeStatusConfirmed=>In Progress
  Carbon-Copy-=>Added sthibaul
Mon 07 Aug 2006 04:28:58 AM UTCsthibaulAttached File-=>Added patch-gnumach-seg-2, #10479
Mon 07 Aug 2006 04:28:30 AM UTCsthibaulAttached File-=>Added patch-gnumach-seg-1, #10478

Back to the top


Powered by Savane 3.1-cleanup