Prevent potential loss of memory map by overwrite on qemu-mips.
* grub-core/boot/mips/startup_raw.S [GRUB_MACHINE_MIPS_QEMU_MIPS]: Save ram size in $s4. * grub-core/kern/mips/qemu_mips/init.c (RAMSIZE): Removed. All users changed to grub_arch_memsize. * grub-core/kern/mips/startup.S (grub_arch_machine): Restrict to Loongson. [GRUB_MACHINE_MIPS_QEMU_MIPS]: Save grub_arch_memsize. * grub-core/loader/mips/linux.c (grub_linux_boot): Pass memory size. * include/grub/mips/qemu_mips/memory.h (grub_arch_memsize): New external variable.
This commit is contained in:
parent
5d420cd983
commit
566a191715
6 changed files with 44 additions and 7 deletions
15
ChangeLog
15
ChangeLog
|
@ -1,3 +1,18 @@
|
||||||
|
2011-05-17 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
|
Prevent potential loss of memory map by overwrite on qemu-mips.
|
||||||
|
|
||||||
|
* grub-core/boot/mips/startup_raw.S [GRUB_MACHINE_MIPS_QEMU_MIPS]:
|
||||||
|
Save ram size in $s4.
|
||||||
|
* grub-core/kern/mips/qemu_mips/init.c (RAMSIZE): Removed.
|
||||||
|
All users changed to grub_arch_memsize.
|
||||||
|
* grub-core/kern/mips/startup.S (grub_arch_machine): Restrict to
|
||||||
|
Loongson.
|
||||||
|
[GRUB_MACHINE_MIPS_QEMU_MIPS]: Save grub_arch_memsize.
|
||||||
|
* grub-core/loader/mips/linux.c (grub_linux_boot): Pass memory size.
|
||||||
|
* include/grub/mips/qemu_mips/memory.h (grub_arch_memsize): New
|
||||||
|
external variable.
|
||||||
|
|
||||||
2011-05-17 Colin Watson <cjwatson@ubuntu.com>
|
2011-05-17 Colin Watson <cjwatson@ubuntu.com>
|
||||||
|
|
||||||
* .bzrignore: Remove grub-dumpbios.
|
* .bzrignore: Remove grub-dumpbios.
|
||||||
|
|
|
@ -50,6 +50,11 @@ codestart:
|
||||||
|
|
||||||
/* Parse arguments. Has to be done before relocation.
|
/* Parse arguments. Has to be done before relocation.
|
||||||
So need to do it in asm. */
|
So need to do it in asm. */
|
||||||
|
#ifdef GRUB_MACHINE_MIPS_QEMU_MIPS
|
||||||
|
lui $t0, %hi (((16 << 20) - 264) | 0x80000000)
|
||||||
|
lw $s4, %lo (((16 << 20) - 264) | 0x80000000) ($t0)
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef GRUB_MACHINE_MIPS_LOONGSON
|
#ifdef GRUB_MACHINE_MIPS_LOONGSON
|
||||||
move $s2, $zero
|
move $s2, $zero
|
||||||
move $s3, $zero
|
move $s3, $zero
|
||||||
|
|
|
@ -10,8 +10,6 @@
|
||||||
#include <grub/cpu/memory.h>
|
#include <grub/cpu/memory.h>
|
||||||
#include <grub/memory.h>
|
#include <grub/memory.h>
|
||||||
|
|
||||||
#define RAMSIZE (*(grub_uint32_t *) ((16 << 20) - 264))
|
|
||||||
|
|
||||||
extern void grub_serial_init (void);
|
extern void grub_serial_init (void);
|
||||||
extern void grub_terminfo_init (void);
|
extern void grub_terminfo_init (void);
|
||||||
|
|
||||||
|
@ -24,7 +22,7 @@ grub_machine_init (void)
|
||||||
grub_arch_cpuclock = 64000000;
|
grub_arch_cpuclock = 64000000;
|
||||||
|
|
||||||
modend = grub_modules_get_end ();
|
modend = grub_modules_get_end ();
|
||||||
grub_mm_init_region ((void *) modend, RAMSIZE
|
grub_mm_init_region ((void *) modend, grub_arch_memsize
|
||||||
- (modend - GRUB_ARCH_LOWMEMVSTART));
|
- (modend - GRUB_ARCH_LOWMEMVSTART));
|
||||||
|
|
||||||
grub_install_get_time_ms (grub_rtc_get_time_ms);
|
grub_install_get_time_ms (grub_rtc_get_time_ms);
|
||||||
|
@ -59,6 +57,6 @@ grub_reboot (void)
|
||||||
grub_err_t
|
grub_err_t
|
||||||
grub_machine_mmap_iterate (grub_memory_hook_t hook)
|
grub_machine_mmap_iterate (grub_memory_hook_t hook)
|
||||||
{
|
{
|
||||||
hook (0, RAMSIZE, GRUB_MEMORY_AVAILABLE);
|
hook (0, grub_arch_memsize, GRUB_MEMORY_AVAILABLE);
|
||||||
return GRUB_ERR_NONE;
|
return GRUB_ERR_NONE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,12 +59,20 @@ VARIABLE (grub_arch_memsize)
|
||||||
.long 0
|
.long 0
|
||||||
VARIABLE (grub_arch_highmemsize)
|
VARIABLE (grub_arch_highmemsize)
|
||||||
.long 0
|
.long 0
|
||||||
|
#ifdef GRUB_MACHINE_MIPS_LOONGSON
|
||||||
VARIABLE (grub_arch_machine)
|
VARIABLE (grub_arch_machine)
|
||||||
.long GRUB_ARCH_MACHINE_FULOONG
|
.long GRUB_ARCH_MACHINE_FULOONG
|
||||||
|
#endif
|
||||||
cont:
|
cont:
|
||||||
/* Save our base. */
|
/* Save our base. */
|
||||||
move $s0, $ra
|
move $s0, $ra
|
||||||
|
|
||||||
|
#ifdef GRUB_MACHINE_MIPS_QEMU_MIPS
|
||||||
|
lui $t1, %hi(grub_arch_busclock)
|
||||||
|
addiu $t1, %lo(grub_arch_busclock)
|
||||||
|
sw $s4, 8($t1)
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef GRUB_MACHINE_MIPS_LOONGSON
|
#ifdef GRUB_MACHINE_MIPS_LOONGSON
|
||||||
lui $t1, %hi(grub_arch_busclock)
|
lui $t1, %hi(grub_arch_busclock)
|
||||||
addiu $t1, %lo(grub_arch_busclock)
|
addiu $t1, %lo(grub_arch_busclock)
|
||||||
|
|
|
@ -80,13 +80,21 @@ grub_linux_boot (void)
|
||||||
{
|
{
|
||||||
grub_err_t err;
|
grub_err_t err;
|
||||||
grub_relocator_chunk_t ch;
|
grub_relocator_chunk_t ch;
|
||||||
|
grub_uint32_t *memsize;
|
||||||
|
grub_uint32_t *magic;
|
||||||
|
char *str;
|
||||||
|
|
||||||
err = grub_relocator_alloc_chunk_addr (relocator, &ch,
|
err = grub_relocator_alloc_chunk_addr (relocator, &ch,
|
||||||
((16 << 20) - 256),
|
((16 << 20) - 264),
|
||||||
grub_strlen (params) + 1);
|
grub_strlen (params) + 1 + 8);
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
grub_strcpy (get_virtual_current_address (ch), params);
|
memsize = get_virtual_current_address (ch);
|
||||||
|
magic = memsize + 1;
|
||||||
|
*memsize = grub_mmap_get_lower ();
|
||||||
|
*magic = 0x12345678;
|
||||||
|
str = (char *) (magic + 1);
|
||||||
|
grub_strcpy (str, params);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,9 @@
|
||||||
#define GRUB_MACHINE_MEMORY_USABLE 0x81000000
|
#define GRUB_MACHINE_MEMORY_USABLE 0x81000000
|
||||||
|
|
||||||
#ifndef ASM_FILE
|
#ifndef ASM_FILE
|
||||||
|
|
||||||
|
extern grub_uint32_t grub_arch_memsize;
|
||||||
|
|
||||||
static inline grub_err_t
|
static inline grub_err_t
|
||||||
grub_machine_mmap_register (grub_uint64_t start __attribute__ ((unused)),
|
grub_machine_mmap_register (grub_uint64_t start __attribute__ ((unused)),
|
||||||
grub_uint64_t size __attribute__ ((unused)),
|
grub_uint64_t size __attribute__ ((unused)),
|
||||||
|
|
Loading…
Reference in a new issue