public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "H. Peter Anvin" <hpa@zytor.com>
To: Graeme Russ <graeme.russ@gmail.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: x86 embedded - Problem getting past 'move compressed kernel before decompression'
Date: Sat, 20 Feb 2010 21:45:54 -0800	[thread overview]
Message-ID: <4B80C892.9000303@zytor.com> (raw)
In-Reply-To: <4B80946D.1030503@gmail.com>

On 02/20/2010 06:03 PM, Graeme Russ wrote:
> 
> The following is something I have hacked together to jump into the 32-bit
> start address of the Linux Kernel:
> 
> struct boot_params boot_params __attribute__((aligned(16)));
> struct setup_header *hdr = (struct setup_header *)(0x90000 + 0x1f1);
> 
> void boot_zimage(void *setup_base)
> {
> 	memset(&boot_params, 0x00, sizeof boot_params);
> 	memcpy(&boot_params.hdr, hdr, sizeof (*hdr));
> 
> 	boot_params.alt_mem_k = 128 * 1024;
> 	boot_params.e820_entries = 1;
> 	boot_params.e820_map[0].addr = 0x00000000;
> 	boot_params.e820_map[0].size = 128 * 1024;
> 	boot_params.e820_map[0].type = 1;
> 
> 	asm(	"movw	$0x18, %%cx\n" \
> 		"movl	%%ecx, %%ds\n" \
> 		"movl	%%ecx, %%es\n" \
> 		"movl	%%ecx, %%fs\n" \
> 		"movl	%%ecx, %%gs\n" \
> 		"movl	%%ecx, %%ss\n" \
> 		"xorl	%%ebp, %%ebp\n" \
> 		"xorl	%%edi, %%edi\n" \
> 		"xorl	%%ebx, %%ebx\n" \
> 		"movl	%0, %%esi\n"
                        ^^
> 		"movl   $0x100000, %%eax\n" \
> 		"jmpl	*%%eax" : : "r"(&boot_params));
                                     ^

At this point you have probably clobbered the register that you have
your boot_params in.

Instead, do something like:

	asm volatile(
 		"movl	%0, %%ds\n" \
 		"movl	%0, %%es\n" \
 		"movl	%0, %%fs\n" \
 		"movl	%0, %%gs\n" \
		"movl	%0, %%ss\n" \
		"xorl	%ebp, %ebp\n" \
		"xorl	%ebx, %ebx\n" \
 		"movl   $0x100000, %%eax\n" \
 		"ljmpl	$0x10,$0x100000"
	 : : "S" (&boot_params), "D" (0), "c" (0x18));

	-hpa

-- 
H. Peter Anvin, Intel Open Source Technology Center
I work for Intel.  I don't speak on their behalf.


  reply	other threads:[~2010-02-21  5:45 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-02-21  2:03 x86 embedded - Problem getting past 'move compressed kernel before decompression' Graeme Russ
2010-02-21  5:45 ` H. Peter Anvin [this message]
2010-02-21  5:53   ` H. Peter Anvin
2010-02-21  9:11     ` Yuhong Bao
2010-02-21 22:51     ` Graeme Russ
2010-02-27  5:06       ` Graeme Russ
2010-03-01 11:56         ` Graeme Russ
2010-03-01 16:46           ` H. Peter Anvin
2010-03-01 19:41             ` Graeme Russ
2010-03-01 19:43               ` H. Peter Anvin
2010-03-01 19:59                 ` Graeme Russ
2010-03-05 13:02                   ` Graeme Russ

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=4B80C892.9000303@zytor.com \
    --to=hpa@zytor.com \
    --cc=graeme.russ@gmail.com \
    --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