mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jun Sun <jsun@junsun.net>
To: linux-kernel@vger.kernel.org
Subject: failed 'ljmp' in linear addressing mode
Date: Wed, 22 Nov 2006 15:41:11 -0800	[thread overview]
Message-ID: <20061122234111.GA8499@srv.junsun.net> (raw)


I am plowing along as I am learning about the in'n'outs about i386.  I am
totally stuck on this one.  I would appreciate any help.

As you can see, the function turns off paging mode (of course it
runs from identically mapped page) and tries to jump to an absolute
address at 0x10000000.  It appears the machine would reboot when running
"ljmp" instruction.

Any pointers?

I was not too certain about the %cs, %ds business and did quite 
a few experiments with different values but with no luck.

Thanks in advance.

Jun

--------------------------

/* [JSUN] we will map this page into identity mapping before execution */
        .align  4096
ENTRY(do_os_switching)
	/* interrupt is disabled! */

        /* the black magic, some copied form relocate_new_kernel, JSUN */
        /* Set cr0 to a known state:
         * 31 0 == Paging disabled
         * 18 0 == Alignment check disabled
         * 16 0 == Write protect disabled
         * 3  0 == No task switch
         * 2  0 == Don't do FP software emulation.
         * 0  1 == Proctected mode enabled
         */

        movl    %cr0, %eax
        andl    $~((1<<31)|(1<<18)|(1<<16)|(1<<3)|(1<<2)), %eax
        orl     $(1<<0), %eax
        movl    %eax, %cr0


        /* JSUN, 0x11 was the boot up value for cr0.
        movl    $0x11, %eax
        movl    %eax, %cr0
        */

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

	/* why this? */
        jmp     1f
1:

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

        /*
        movl    $(__KERNEL_DS),%eax
        movl    %eax,%ds
        movl    %eax,%es
        movl    %eax,%fs
        movl    %eax,%gs
        movl    %eax,%ss
        */

        ljmp    $(__KERNEL_CS), $0x10000000


             reply	other threads:[~2006-11-22 23:41 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-11-22 23:41 Jun Sun [this message]
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
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=20061122234111.GA8499@srv.junsun.net \
    --to=jsun@junsun.net \
    --cc=linux-kernel@vger.kernel.org \
    /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