From: Robert Millan <rmh@aybabtu.com>
To: grub-devel@gnu.org
Subject: [PATCH] memtest86+ fix
Date: Wed, 2 Jan 2008 18:05:33 +0100 [thread overview]
Message-ID: <20080102170533.GA29024@thorin> (raw)
[-- Attachment #1: Type: text/plain, Size: 659 bytes --]
This fixes boot for memtest86+ (and actually, Linux zImages since they were
all affected).
The problem was that the first code in grub_linux_boot_zimage copied the
payload from 0x100000 to 0x10000. Since GRUB starts at 0x8200 and is
typicaly more than 8 kiB in size, it'll most likely overwrite part of it.
A bit of reestructuring was necessary to allow grub_dl_unload_all() to happen
unconditionally as first step, since the information on whether this is a
"big linux" was not promptly available.
Comments?
--
Robert Millan
<GPLv2> I know my rights; I want my phone call!
<DRM> What use is a phone call, if you are unable to speak?
(as seen on /.)
[-- Attachment #2: memtest.diff --]
[-- Type: text/x-diff, Size: 4152 bytes --]
2008-01-02 Robert Millan <rmh@aybabtu.com>
* kern/i386/loader.S (grub_linux_big): New variable.
(grub_linux_boot_zimage): Rename to ...
(grub_linux_boot): ... this.
(grub_linux_boot_bzimage): Merge with `grub_linux_boot_zimage'.
(grub_linux_boot_zimage): Conditionalize zImage copy.
* include/grub/i386/loader.h (grub_linux_big): Add prototype.
(grub_linux_boot_bzimage): Remove prototype.
(grub_linux_boot_zimage): Rename to ...
(grub_linux_boot): ... this.
* loader/i386/pc/linux.c (big_linux): Replace with `grub_linux_big'.
(grub_linux_boot): Remove function.
diff -urp grub2/include/grub/i386/loader.h grub2.mt/include/grub/i386/loader.h
--- grub2/include/grub/i386/loader.h 2007-10-17 11:38:55.000000000 +0200
+++ grub2.mt/include/grub/i386/loader.h 2008-01-02 17:51:45.000000000 +0100
@@ -26,11 +26,11 @@
extern grub_uint32_t EXPORT_VAR(grub_linux_prot_size);
extern char *EXPORT_VAR(grub_linux_tmp_addr);
extern char *EXPORT_VAR(grub_linux_real_addr);
+extern grub_int32_t EXPORT_VAR(grub_linux_big);
extern grub_addr_t EXPORT_VAR(grub_os_area_addr);
extern grub_size_t EXPORT_VAR(grub_os_area_size);
-void EXPORT_FUNC(grub_linux_boot_zimage) (void) __attribute__ ((noreturn));
-void EXPORT_FUNC(grub_linux_boot_bzimage) (void) __attribute__ ((noreturn));
+void EXPORT_FUNC(grub_linux_boot) (void) __attribute__ ((noreturn));
/* The asm part of the multiboot loader. */
void EXPORT_FUNC(grub_multiboot_real_boot) (grub_addr_t entry,
diff -urp grub2/kern/i386/loader.S grub2.mt/kern/i386/loader.S
--- grub2/kern/i386/loader.S 2007-10-17 22:04:23.000000000 +0200
+++ grub2.mt/kern/i386/loader.S 2008-01-02 17:52:42.000000000 +0100
@@ -56,8 +56,17 @@ VARIABLE(grub_linux_tmp_addr)
.long 0
VARIABLE(grub_linux_real_addr)
.long 0
+VARIABLE(grub_linux_big)
+ .long 0
-FUNCTION(grub_linux_boot_zimage)
+FUNCTION(grub_linux_boot)
+ /* Must be done before zImage copy. */
+ call EXT_C(grub_dl_unload_all)
+
+ movl EXT_C(grub_linux_big), %ebx
+ test %ebx, %ebx
+ jne bzimage
+
/* copy the kernel */
movl EXT_C(grub_linux_prot_size), %ecx
addl $3, %ecx
@@ -68,9 +77,7 @@ FUNCTION(grub_linux_boot_zimage)
rep
movsl
-FUNCTION(grub_linux_boot_bzimage)
- call EXT_C(grub_dl_unload_all)
-
+bzimage:
movl EXT_C(grub_linux_real_addr), %ebx
/* copy the real mode code */
diff -urp grub2/loader/i386/pc/linux.c grub2.mt/loader/i386/pc/linux.c
--- grub2/loader/i386/pc/linux.c 2008-01-02 16:28:50.000000000 +0100
+++ grub2.mt/loader/i386/pc/linux.c 2008-01-02 17:51:35.000000000 +0100
@@ -33,23 +33,10 @@
static grub_dl_t my_mod;
-static int big_linux;
static grub_size_t linux_mem_size;
static int loaded;
static grub_err_t
-grub_linux_boot (void)
-{
- if (big_linux)
- grub_linux_boot_bzimage ();
- else
- grub_linux_boot_zimage ();
-
- /* Never reach here. */
- return GRUB_ERR_NONE;
-}
-
-static grub_err_t
grub_linux_unload (void)
{
grub_dl_unref (my_mod);
@@ -106,14 +93,14 @@ grub_rescue_cmd_linux (int argc, char *a
goto fail;
}
- big_linux = 0;
+ grub_linux_big = 0;
setup_sects = lh.setup_sects;
linux_mem_size = 0;
if (lh.header == grub_cpu_to_le32 (GRUB_LINUX_MAGIC_SIGNATURE)
&& grub_le_to_cpu16 (lh.version) >= 0x0200)
{
- big_linux = (lh.loadflags & GRUB_LINUX_FLAG_BIG_KERNEL);
+ grub_linux_big = (lh.loadflags & GRUB_LINUX_FLAG_BIG_KERNEL);
lh.type_of_loader = GRUB_LINUX_BOOT_LOADER_TYPE;
/* Put the real mode part at as a high location as possible. */
@@ -158,7 +145,7 @@ grub_rescue_cmd_linux (int argc, char *a
grub_linux_tmp_addr = (char *) GRUB_LINUX_BZIMAGE_ADDR + prot_size;
- if (! big_linux
+ if (! grub_linux_big
&& prot_size > (grub_size_t) (grub_linux_real_addr
- (char *) GRUB_LINUX_ZIMAGE_ADDR))
{
@@ -177,7 +164,7 @@ grub_rescue_cmd_linux (int argc, char *a
}
grub_printf (" [Linux-%s, setup=0x%x, size=0x%x]\n",
- big_linux ? "bzImage" : "zImage", real_size, prot_size);
+ grub_linux_big ? "bzImage" : "zImage", real_size, prot_size);
for (i = 1; i < argc; i++)
if (grub_memcmp (argv[i], "vga=", 4) == 0)
next reply other threads:[~2008-01-02 17:06 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-01-02 17:05 Robert Millan [this message]
2008-01-02 23:46 ` [PATCH] memtest86+ fix Yoshinori K. Okuji
2008-01-03 1:06 ` Robert Millan
2008-01-05 1:09 ` Yoshinori K. Okuji
2008-01-05 1:18 ` Pavel Roskin
2008-01-05 11:50 ` Robert Millan
2008-01-05 12:04 ` Yoshinori K. Okuji
2008-01-05 12:13 ` Robert Millan
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=20080102170533.GA29024@thorin \
--to=rmh@aybabtu.com \
--cc=grub-devel@gnu.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.