Eliminate variable length arrays in grub_vsnprintf_real.
A bit tricky because this function has to continue to work without
heap for short strings. Fixing prealloc to 32 arguments is reasonable
but make all stack references use 32-bit offset rather than 8-bit one.
So split va_args preparsing to separate function and put the prealloc
into the caller.
Colin Watson [Wed, 27 Nov 2013 10:06:07 +0000 (10:06 +0000)]
Speed up test suite by avoiding fsync
Add grub_util_disable_fd_syncs call to turn grub_util_fd_sync calls into
no-ops, and use it in programs that copy files but do not need to take
special care to sync writes (grub-mknetdir, grub-rescue,
grub-mkstandalone).
On my laptop, this reduces partmap_test's runtime from 1236 seconds to
204 seconds.
Colin Watson [Wed, 13 Nov 2013 12:42:24 +0000 (12:42 +0000)]
Generate Makefile.*.am directly from gentpl.py, eliminating the use of Autogen. The Autogen definitions files remain intact as they offer a useful abstraction.
Andrey Borzenkov [Sun, 24 Nov 2013 17:12:17 +0000 (21:12 +0400)]
Explicitly check for linking format to use for efiemu64 module
Similar to check for target linking format, also check for efiemu64
instead of hardcoding -melf_x86_64. This fixes compilation on *BSD
variants. We cannot easily reuse main target check because platforms
are different (main target is 32 bit and efiemu64 - 64 bit).
This commit adds EFIEMU64_LINK_FORMAT that contains detected
link option and is used in efiemu64.o linking instead of hardcoded
value.
Colin Watson [Mon, 25 Nov 2013 18:04:50 +0000 (18:04 +0000)]
Add a --locale-directory option to grub-install and related tools.
* include/grub/util/install.h (GRUB_INSTALL_OPTIONS): Add
--locale-directory option.
(enum grub_install_options): Add
GRUB_INSTALL_OPTIONS_LOCALE_DIRECTORY.
* util/grub-install-common.c (grub_install_help_filter): Handle
GRUB_INSTALL_OPTIONS_LOCALE_DIRECTORY.
(grub_install_parse): Likewise.
(get_localedir): New function to check for a user-provided option
before trying grub_util_get_localedir.
(copy_locales): Use get_localedir rather than
grub_util_get_localedir. Handle differing locale directory layouts.
(grub_install_copy_files): Likewise.
* grub-core/kern/i386/pc/startup.S [__APPLE__]: Create _edata by placing
an object after data. While it doesn't seem right solution, it
works well enough and OSX isn't main compilation platform.
* gentpl.py: Add -ed2016 in order to make objconv accept our binary.
While it doesn't seem right solution, it works well enough and
OSX isn't main compilation platform.
Apple assembly doesn't handle symbol arithmetic well. So instead
of getting addres of kernel_sector + 4 define kernel_sector_high.
It also makes code more readable.
With Apple assembly in .macro environvemnt you have to use $$ instead
of $. So introduce new preprocessor macro MACRO_DOLLAR(x) which expands
to $$x on Apple and to $x on everything else.
* grub-core/gdb/i386/machdep.S: Use xorl %eax, %eax on both Apple
and non-Apple. This instruction is shorter and faster,
so no reason not to use it on both.
* grub-core/boot/i386/pc/boot.S: Fix floppy probe. Due to missing
%dx restore the probe worked on non-existant drive. Reorganize the
code a little bit to free 2 bytes necessary for push/pop.
* include/grub/i386/pc/memory.h: Decrease
GRUB_MEMORY_MACHINE_SCRATCH_SIZE and increase
GRUB_MEMORY_MACHINE_PROT_STACK_SIZE.
The binary doesn't change (checked). It's more to better reflect actual
usage.
* grub-core/kern/x86_64/efi/callwrap.S: Fix stack alignment.
Previously we misaligned stack by 8 in startup.S and compensated
for it in callwrap.S. According to ABI docs (EFI and sysv amd64)
right behaviour is to align stack in startup.S and keep it aligned
in callwrap.S. startup.S part was committed few commits before. This
takes care of callwrap.S.
Reported by: Gary Lin.
Remove -march=mips3 from TARGET_CCASFLAGS as it creates linking problem
when rest of GRUB is compiled for hisher stepping. Instead use
.set mips3/.set mips1 around cache and sync opcodes.
Add automated filesystem checking based on scripts I've used now for
quite some time locally. Most of the test require root so they are
skipped when run without necessarry privelegies.
Josh Triplett [Tue, 19 Nov 2013 13:31:40 +0000 (14:31 +0100)]
* grub-core/kern/x86_64/efi/startup.S (_start): Align the stack to a
16-byte boundary, as required by the x86-64 ABI, before calling
grub_main. In some cases, GCC emits code that assumes this
alignment, which crashes if not aligned. The EFI firmware is also
entitled to assume that stack alignment without checking.
Josh Triplett [Mon, 18 Nov 2013 17:00:52 +0000 (18:00 +0100)]
* grub-core/mmap/efi/mmap.c (grub_mmap_register): Round up/down to
4k page boundaries as expected by firmware rather than 1k
boundaries.
(grub_mmap_malign_and_register): Likewise.
* grub-core/kern/mm.c (grub_real_malloc): Decrease cut-off of moving the
pointer to 32K. This is the size of cache element which is the most
common allocation >1K. This way the pointer is always around blocks
of 32K and so we keep performance while decreasing fragmentation.
Colin Watson [Mon, 18 Nov 2013 16:16:33 +0000 (16:16 +0000)]
* tests/gzcompress_test.in: Skip if gzip is not installed (unlikely,
but for symmetry).
* tests/lzocompress_test.in: Skip if lzop is not installed.
* tests/xzcompress_test.in: Skip if xz is not installed.
* grub-core/kern/mm.c (grub_real_malloc): Don't update the pointer to
current memory when allocating large chunks. This significantly
decreases memory fragmentation.
* tests/util/grub-shell.in: For powerpc tests put the CD-ROM as primary
master since with some combinations of qemu and firmware only primary
IDE channel is available.
* grub-core/tests/gfxterm_menu.c: Skip high-resolution tests on
low-memory platforms where we don't have enough memory for them.
* grub-core/tests/videotest_checksum.c: Likewise.