Re: bzImage ~ 900K with i386 test11-pre2

From: Andrea Arcangeli (andrea@suse.de)
Date: Sun Nov 12 2000 - 10:37:05 EST


On Sun, Nov 12, 2000 at 06:14:36AM -0700, Eric W. Biederman wrote:
> x86-64 doesn't load the segment registers at all before use.

Yes, before switching to 64bit long mode we never do any data access. We do a
stack access to clear eflags only while we still run in legacy mode with paging
disabled and so we only rely on ss to be valid when the bootloader jumps at
0x100000 for executing the head.S code (and not anymore on the gdt_48 layout).

> I can tell you don't have real hardware. The non obviousness

Current code definitely works fine on the simnow simulator so if current code
shouldn't work because it's buggy then at least the simulator is sure buggy as
well (and that isn't going to be the case as its behaviour is in full sync with
the specs as far I can see).

> So while you load the gdt before you set a segment register later,
> which is good the more important part was still missed.

Sorry but I don't see the missing part. Are you sure you're not missing this
part of the x86-64 specs?

        Data and Stack Segments:

        In 64-bit mode, the contents of the ES, DS, and SS segment registers
        are ignored. All fields (base, limit, and attribute) in the
        corresponding segment descriptor registers (hidden part) are also
        ignored.

        Address calculations in 64-bit mode that reference the ES, DS, or SS
        segments, are treated as if the segment base is zero. Rather than
        perform limit checks, the processor instead checks that all
        virtual-address references are in canonical form.

You'll find the above at the top of page 42 of the specs.

Basically in 64bit long mode only CS matters and basically only to specify
CS.L=1 and CS.D=0.

The only subtle case is during iret where we need a valid data segment for some
subtle reason (but that's unrelated to head.S that instead only needs to
switch to 64bit mode and jump into head64.c where we do the rest of the work
like clearing bss in C). Infact we need only 1 32bit compatibility mode data
segment in the gdt.

> O.k. on monday I'll dig up my patch and that clears this up.

Sure, go ahead if you weren't missing that basic part of the long mode specs.
Thanks.

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



This archive was generated by hypermail 2b29 : Wed Nov 15 2000 - 21:00:22 EST