mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jun Sun <jsun@junsun.net>
To: "linux-os (Dick Johnson)" <linux-os@analogic.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: failed 'ljmp' in linear addressing mode
Date: Wed, 29 Nov 2006 20:53:41 -0800	[thread overview]
Message-ID: <20061130045341.GA11469@srv.junsun.net> (raw)
In-Reply-To: <20061129014056.GA31798@srv.junsun.net>

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

  reply	other threads:[~2006-11-30  4:53 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-11-22 23:41 Jun Sun
2006-11-27 13:58 ` linux-os (Dick Johnson)
2006-11-27 23:16   ` Jun Sun
2006-11-28 13:46     ` linux-os (Dick Johnson)
2006-11-28 19:45       ` Jun Sun
2006-11-28 23:49         ` linux-os (Dick Johnson)
2006-11-29  1:40           ` Jun Sun
2006-11-30  4:53             ` Jun Sun [this message]
2006-11-30 16:17       ` Phillip Susi
2006-12-01 22:20 ` Jun Sun

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20061130045341.GA11469@srv.junsun.net \
    --to=jsun@junsun.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-os@analogic.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome