Page 1 of 1

Can i far jump to 0xffffffff80000000 from 32bit code???

Posted: Sun Jul 27, 2014 1:34 pm
by criny
first of all, sorry for my bad english...
I'm making POSIX-compatible kernel by myself just for fun...

My kernel code is below(by nasm)

Code: Select all

[bits 32]
[org 100000]
// start from grub 32bit direct jump mode

// set page table for 64bit kernel 
[virtual mem addr]     [pys mem  addr]
0xffffffff80000000~      0x0~

// make gdt for 64bit kernel and "lgdt"

// set cr0 register for jumping to 64bit mode

jmp 0x??:start64

start64:
// 64bit start
my code is like above...
above code is not work because page mapping table for virtual mem address 0x10000~ is not set...
I already know that in linux kernel code, early 4gb maaping code is existed....
I just want to jumping to 0xffffffff8000000 virtual address from 32bit code by not making early 4gb mapping table....
Is there a way??? trampoline like early 4gb mapping table is esseantial for 64bit kernel???

Re: Can i far jump to 0xffffffff80000000 from 32bit code???

Posted: Sun Jul 27, 2014 3:25 pm
by Nable
I think that this wiki article will help you: http://wiki.osdev.org/Entering_Long_Mode_Directly

Re: Can i far jump to 0xffffffff80000000 from 32bit code???

Posted: Sun Jul 27, 2014 4:43 pm
by Gigasoft
No, you can't. (And the wiki page has no relevance at all.)

Re: Can i far jump to 0xffffffff80000000 from 32bit code???

Posted: Sun Jul 27, 2014 6:31 pm
by Marionumber1
I know that you're using GRUB, but my way is to have a custom bootloader that loads the kernel as an ELF file. The bootloader runs in the first 1MiB of memory using identity-mapped paging, so it can make the jump into 64-bit code easily. Once it's up and running, it loads an ELF file off the filesystem to any arbitrary virtual address.

DISCLAIMER: I haven't actually implemented long mode support in the bootloader yet, but it's a trivial thing to add, and the general design is the same for both protected mode and long mode.

Re: Can i far jump to 0xffffffff80000000 from 32bit code???

Posted: Sun Jul 27, 2014 7:19 pm
by criny
Gigasoft wrote:No, you can't. (And the wiki page has no relevance at all.)
thank you for reply... I think that It's not allowed in x86 arcitecture now....
why linux kernel use eraly 4gb paging table is because of that....I think......