Re: failed 'ljmp' in linear addressing mode

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Nov 28, 2006 at 05:40:56PM -0800, Jun Sun wrote:
> 
> Can you elaborate more why this last ljmp will fail?  I thought at this point
> the paging is turned off, and 0x1000-0000 would simply mean a physical
> address - which is a valid physical address in RAM, btw.
>
<snip>

I finally got it working, even though I don't understand at all. :)

I realized that after paging mode is turned off, 0x1000-0000 is actually
at the same flag 4G code segment as caller code.  So I tried to just
"call" and that worked.

Here is the excerpt of the related code in case someone else needs to
do the same:

In arch/i386/kernel/machine_kexec.c:

extern void do_os_switching(void);
void os_switch(void)
{
        void (*foo)(void);

        /* absolutely no irq */
        local_irq_disable();

        /* create identity mapping */
        foo=virt_to_phys(do_os_switching);
        identity_map_page((unsigned long)foo);

        /* jump to the real address */
        load_segments();
        set_gdt(phys_to_virt(0),0);
        set_idt(phys_to_virt(0),0);
        foo();
}

In arch/i386/kernel/acpi/wakeup.S:

        .align  4096
ENTRY(do_os_switching)
        /* JSUN, 0x11 was the boot up value for cr0. */
        movl    $0x11, %eax
        movl    %eax, %cr0

        /* clear cr4 */
        movl    $0, %eax
        movl    %eax, %cr4

        /* clear cr3, flush TLB */
        movl    $0, %eax
        movl    %eax, %cr3

        movl    $0x10000000,%eax
        call    *%eax

I have a second Linux kernel loaded at 0x1000-0000.  Now the only matter
remaining is to figure out why the tsc timer stopped working ... :)

Cheers.

Jun
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux