From a6e7719bbe05993613a8de69dba14fa092144925 Mon Sep 17 00:00:00 2001 From: Andrey Borzenkov Date: Wed, 25 Dec 2013 22:36:28 +0400 Subject: [PATCH 001/722] fix EFI detection on Windows We are on legacy BIOS if GetFirmwareEnvironmentVariable fails (returns zero) *and* extended error information is ERROR_INVALID_FUNCTION. Cf. http://msdn.microsoft.com/en-us/library/windows/desktop/ms724325%28v=vs.85%29.aspx --- ChangeLog | 5 +++++ grub-core/osdep/windows/platform.c | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 41bcebfb3..21ec1c77c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2013-12-25 Andrey Borzenkov + + * grub-core/osdep/windows/platform.c (get_platform): Fix EFI + detection. + 2013-12-24 Vladimir Serbinenko * configure.ac: Set version to 2.02~beta2. diff --git a/grub-core/osdep/windows/platform.c b/grub-core/osdep/windows/platform.c index f2b9d7143..d217efe17 100644 --- a/grub-core/osdep/windows/platform.c +++ b/grub-core/osdep/windows/platform.c @@ -100,7 +100,7 @@ get_platform (void) if (!func_GetFirmwareEnvironmentVariableW (L"BootOrder", GRUB_EFI_GLOBAL_VARIABLE_GUID_WINDOWS_STR, buffer, sizeof (buffer)) - && GetLastError () != ERROR_INVALID_FUNCTION) + && GetLastError () == ERROR_INVALID_FUNCTION) { platform = PLAT_BIOS; return; From 5bda44d7f98c36f87144869ec58b518f80a69b56 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Wed, 25 Dec 2013 23:31:42 +0100 Subject: [PATCH 002/722] * grub-core/kern/arm/cache_armv6.S: Remove .arch directive. As these functions are used on pre-ARMv6 CPUs as well we don't want to make assembler assume that architecture is higher than default one. --- ChangeLog | 7 +++++++ grub-core/kern/arm/cache_armv6.S | 1 - 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 21ec1c77c..153bc43c1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2013-12-25 Vladimir Serbinenko + + * grub-core/kern/arm/cache_armv6.S: Remove .arch directive. + + As these functions are used on pre-ARMv6 CPUs as well we don't want + to make assembler assume that architecture is higher than default one. + 2013-12-25 Andrey Borzenkov * grub-core/osdep/windows/platform.c (get_platform): Fix EFI diff --git a/grub-core/kern/arm/cache_armv6.S b/grub-core/kern/arm/cache_armv6.S index 39da1dfc6..dfaded0eb 100644 --- a/grub-core/kern/arm/cache_armv6.S +++ b/grub-core/kern/arm/cache_armv6.S @@ -22,7 +22,6 @@ .text .syntax unified .arm - .arch armv6 # define DMB mcr p15, 0, r0, c7, c10, 5 # define DSB mcr p15, 0, r0, c7, c10, 4 From 51f941a0d871fe9af20d57574272e62d52b3375c Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Fri, 27 Dec 2013 03:03:32 +0000 Subject: [PATCH 003/722] * INSTALL (Cross-compiling the GRUB): Fix some spelling mistakes. * docs/grub.texi (Getting the source code): Likewise. --- ChangeLog | 5 +++++ INSTALL | 10 +++++----- docs/grub-dev.texi | 8 ++++---- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index 21ec1c77c..e61d48bc3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2013-12-27 Colin Watson + + * INSTALL (Cross-compiling the GRUB): Fix some spelling mistakes. + * docs/grub.texi (Getting the source code): Likewise. + 2013-12-25 Andrey Borzenkov * grub-core/osdep/windows/platform.c (get_platform): Fix EFI diff --git a/INSTALL b/INSTALL index afc957ca9..db12530df 100644 --- a/INSTALL +++ b/INSTALL @@ -140,7 +140,7 @@ If build and host are different make check isn't available. If build and host are different man pages are not generated. As an example imagine you have a build system running on FreeBSD on sparc -which prepares packages for developpers running amd64 GNU/Linux laptop and +which prepares packages for developers running amd64 GNU/Linux laptop and they need to make images for ARM board running U-boot. In this case: build=sparc64-freebsd @@ -149,7 +149,7 @@ target=arm-uboot For this example the configure line might look like (more details below) (some options are optional and included here for completeness but some rarely -used options are omited): +used options are omitted): ./configure BUILD_CC=gcc BUILD_FREETYPE=freetype-config --host=amd64-linux-gnu CC=amd64-linux-gnu-gcc CFLAGS="-g -O2" FREETYPE=amd64-linux-gnu-freetype-config @@ -196,9 +196,9 @@ corresponding platform are not needed for the platform in question. 11. TARGET_RANLIB= for ranlib for target. - Additionally for emu, for host and target. - 1. SDL is looked for in stadard linker directories (-lSDL) (optional) - 2. libpciaccess is looked for in stadard linker directories (-lpciaccess) (optional) - 3. libusb is looked for in stadard linker directories (-lusb) (optional) + 1. SDL is looked for in standard linker directories (-lSDL) (optional) + 2. libpciaccess is looked for in standard linker directories (-lpciaccess) (optional) + 3. libusb is looked for in standard linker directories (-lusb) (optional) - Platform-agnostic tools and data. 1. make is the tool you execute after ./configure. diff --git a/docs/grub-dev.texi b/docs/grub-dev.texi index c79685052..7c6244cdb 100644 --- a/docs/grub-dev.texi +++ b/docs/grub-dev.texi @@ -108,16 +108,16 @@ The branches available are: @table @samp @item master - Main developpement branch. + Main development branch. @item grub-legacy GRUB 0.97 codebase. Kept for reference and legal reasons @item multiboot Multiboot specfication @item multiboot2 Multiboot2 specfication -@item developper branches - Prefixed with developper name. Every developper of a team manages his own branches. - Developper branches do not need changelog entries. +@item developer branches + Prefixed with developer name. Every developer of a team manages his own branches. + Developer branches do not need changelog entries. @end table Once you have used @kbd{git clone} to fetch an initial copy of a branch, you From 30a338460ad97c190502a1067979dac2fc548f16 Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Fri, 27 Dec 2013 03:05:38 +0000 Subject: [PATCH 004/722] * NEWS: First draft of 2.02 entry. --- ChangeLog | 4 ++ NEWS | 119 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 123 insertions(+) diff --git a/ChangeLog b/ChangeLog index e61d48bc3..53f048128 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2013-12-27 Colin Watson + + * NEWS: First draft of 2.02 entry. + 2013-12-27 Colin Watson * INSTALL (Cross-compiling the GRUB): Fix some spelling mistakes. diff --git a/NEWS b/NEWS index 4bb5f9801..577d9fd73 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,122 @@ +New in 2.02: + +* New/improved filesystem and disk support: + * Big-endian UFS1. + * Experimental 64-bit ext2 support. + * Various fixes for non-512-byte sector devices. + * New `proc' filesystem framework, used by LUKS disks. + * Fix DM-RAID partition handling. + * New `nativedisk' command to switch from firmware to native disk drivers. + * Compressed HFS+. + * DragonFly BSD labels. + * CBFS (coreboot). + * Handle partitioned LVM properly. + * Use LVM UUIDs whenever possible. + * GPT PReP. + * New `progress' module that shows progress information while reading + files. + +* New/improved terminal and video support: + * Monochrome text (matching `hercules' in GRUB Legacy). + * Morse code output using system speaker. + * `spkmodem' output (simple data protocol using system speaker). + * Handle Japanese special keys. + * coreboot framebuffer. + * Serial on ARC. + * Native vt100 handling for grub-emu, replacing the use of the curses + library. + * New gfxmenu options for terminal window positioning, theme background + image handling, and scrollbar padding, plus `item_pixmap_style' and + `highlight_overlay'. + * Support several more image types (paletted and greyscale). + +* Boot protocol improvements: + * Support Apple FAT binaries on non-Apple platforms. + * Improve FreeDOS direct loading support compatibility. + * Enable `linux16' on all x86 platforms, not just BIOS. + * New TrueCrypt ISO loader. + +* New/improved network support: + * New variables `net_default_*' containing properties of the default + interface. + * Autoload `http' and `tftp' modules if necessary. + * Improve TFTP robustness. + * Parse `nd' disk names in GRUB Legacy configuration files. + * Issue separate DNS queries for IPv4 and IPv6. + +* New/improved platform support: + * New `efifwsetup' and `lsefi' commands on EFI platforms. + * New `cmosclean', `cmosdump', and `cmosset' commands on platforms with + CMOS support. + * New `cbmemc', `coreboot_boottime', and `lscoreboot' commands on + coreboot. + * Improve opcode parsing in ACPI halt implementation. + * Use the TSC as a possible time source on i386-ieee1275. + * Merge PowerPC grub-mkrescue implementation with the common one. + * Support grub-mkrescue on i386-ieee1275, sparc64, bootinfo machines such + as pSeries, and mips-arc. + * Make grub-mkrescue better support Apple Intel Macs on CD. + * Enable GRUB Legacy configuration file parsing on EFI. + * Support halt for Loongson 2E. + * ARM U-Boot and EFI ports. + * Reorganise platform-dependent code in utilities to avoid #ifdef mess. + * AROS and Haiku support for userspace utilities. + * Xen PV port. + * Fix EFI stack alignment. + * ARM64 EFI port. + * On Linux, read partition start offsets from sysfs if possible. + * New grub-macbless utility, and better integration with Mac firmware in + grub-install. + * Support Yeeloong 3A. + * Add `cpuid --pae' option to detect Physical Address Extension on x86. + +* Security: + * Add optional facility to enforce that all files read by the core image + from disk have a valid detached digital signature. + +* Performance: + * Avoid costly division operations in many places. + * New boot time analysis framework (`./configure --enable-boot-time'). + * Initialise USB ports in parallel. + * New `testspeed' command to test file read speed. + +* Scripting: + * New `eval' and `tr' commands. + * grub-script-check fails on scripts containing no commands. + +* Installation and other utility improvements: + * Add option to compress files on installation or image creation. + * Using grub-reboot no longer requires setting `GRUB_DEFAULT=saved'. + * Support probing EFI System Partition (requires os-prober >= 1.58). + * Fix inconsistent use of `GRUB_CRYPTODISK_ENABLE' and + `GRUB_ENABLE_CRYPTODISK'; the latter is now used consistently. + * grub-mount handles symbolic links to directories. + * Support disabling submenus with `GRUB_DISABLE_SUBMENU' configuration key + for grub-mkconfig. + * grub-install, grub-mknetdir, grub-mkrescue, and grub-mkstandalone + rewritten in C. They should now work in supported non-Unix-like + environments. + * Reorganise timeout handling using new `timeout_style' environment + variable and `GRUB_TIMEOUT_STYLE' configuration key for grub-mkconfig. + Menu hotkeys pressed during a hidden timeout now boot the corresponding + menu entry immediately. + * New `file' command and grub-file utility to check file types. + * New syslinux configuration file parser. + +* Build system: + * Remove all uses of nested functions; GRUB no longer requires an + executable stack. + * Fix documentation build with Texinfo >= 5.1. + * More robust and documented cross-compiling support. + * Partial clang support for some platforms. + * Eliminate the use of AutoGen. This allowed some performance + improvements to the build system. + * Fix build with FreeType >= 2.5.1. + * Make gentpl.py compatible with Python 3. It now requires at least + Python 2.6. + +* Revision control moved to git. + New in 2.00: * Appearance: From 8442d3e956fa3775419b0b3ce65f4289875e7ecf Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Sat, 28 Dec 2013 02:20:27 +0000 Subject: [PATCH 005/722] * NEWS: The cmosclean command in fact dates back to 1.99. Remove mention of it from 2.02. --- ChangeLog | 5 +++++ NEWS | 3 +-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index da3c2dfdf..c33856eab 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2013-12-28 Colin Watson + + * NEWS: The cmosclean command in fact dates back to 1.99. Remove + mention of it from 2.02. + 2013-12-27 Vladimir Serbinenko * grub-core/kern/arm/cache_armv6.S: Remove .arch directive. diff --git a/NEWS b/NEWS index 577d9fd73..b74c05f63 100644 --- a/NEWS +++ b/NEWS @@ -46,8 +46,7 @@ New in 2.02: * New/improved platform support: * New `efifwsetup' and `lsefi' commands on EFI platforms. - * New `cmosclean', `cmosdump', and `cmosset' commands on platforms with - CMOS support. + * New `cmosdump' and `cmosset' commands on platforms with CMOS support. * New `cbmemc', `coreboot_boottime', and `lscoreboot' commands on coreboot. * Improve opcode parsing in ACPI halt implementation. From 989af025829b20a19f4d3ee01e86f4ee9de7cf1e Mon Sep 17 00:00:00 2001 From: Andrey Borzenkov Date: Sat, 28 Dec 2013 09:01:20 +0400 Subject: [PATCH 006/722] remove unused error.h from kern/emu/misc.c Fixes compilation on mingw32, where include is apparently missing. --- ChangeLog | 5 +++++ grub-core/kern/emu/misc.c | 1 - 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index c33856eab..0401f6154 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2013-12-28 Andrey Borzenkov + + * grub-core/kern/emu/misc.c: Remove unused error.h; fixes compilation + on mingw. + 2013-12-28 Colin Watson * NEWS: The cmosclean command in fact dates back to 1.99. Remove diff --git a/grub-core/kern/emu/misc.c b/grub-core/kern/emu/misc.c index 43471b4ef..bb606da28 100644 --- a/grub-core/kern/emu/misc.c +++ b/grub-core/kern/emu/misc.c @@ -20,7 +20,6 @@ #include #include -#include #include #include #include From 093dec7370650ecfa9b770210e21b8d6b03f1df3 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sat, 28 Dec 2013 17:25:14 +0100 Subject: [PATCH 007/722] Don't abort() on unavailable coreboot tables if not running on coreboot. --- ChangeLog | 4 ++++ grub-core/kern/i386/coreboot/cbtable.c | 2 +- grub-core/kern/i386/coreboot/init.c | 5 +++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 0401f6154..ed6d77cc8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2013-12-28 Vladimir Serbinenko + + Don't abort() on unavailable coreboot tables if not running on coreboot. + 2013-12-28 Andrey Borzenkov * grub-core/kern/emu/misc.c: Remove unused error.h; fixes compilation diff --git a/grub-core/kern/i386/coreboot/cbtable.c b/grub-core/kern/i386/coreboot/cbtable.c index e3bb7b2e0..1669bc0ca 100644 --- a/grub-core/kern/i386/coreboot/cbtable.c +++ b/grub-core/kern/i386/coreboot/cbtable.c @@ -55,7 +55,7 @@ grub_linuxbios_table_iterate (int (*hook) (grub_linuxbios_table_item_t, if (check_signature (table_header)) goto signature_found; - grub_fatal ("Could not find coreboot table\n"); + return 0; signature_found: diff --git a/grub-core/kern/i386/coreboot/init.c b/grub-core/kern/i386/coreboot/init.c index 6b150b47d..3314f027f 100644 --- a/grub-core/kern/i386/coreboot/init.c +++ b/grub-core/kern/i386/coreboot/init.c @@ -51,6 +51,7 @@ grub_exit (void) grub_addr_t grub_modbase = GRUB_KERNEL_I386_COREBOOT_MODULES_ADDR; static grub_uint64_t modend; +static int have_memory = 0; /* Helper for grub_machine_init. */ static int @@ -82,6 +83,8 @@ heap_init (grub_uint64_t addr, grub_uint64_t size, grub_memory_type_t type, grub_mm_init_region ((void *) (grub_addr_t) begin, (grub_size_t) (end - begin)); + have_memory = 1; + return 0; } @@ -97,6 +100,8 @@ grub_machine_init (void) grub_vga_text_init (); grub_machine_mmap_iterate (heap_init, NULL); + if (!have_memory) + grub_fatal ("No memory found"); grub_video_coreboot_fb_late_init (); From 0e309454f6f184c3704d7b78687e314f14a07b3c Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 30 Dec 2013 06:49:15 +0100 Subject: [PATCH 008/722] * NEWS: Add few missing entries. Correct existing ones. --- ChangeLog | 4 ++++ NEWS | 27 ++++++++++++++++++++++----- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index ed6d77cc8..db843006d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2013-12-30 Vladimir Serbinenko + + * NEWS: Add few missing entries. Correct existing ones. + 2013-12-28 Vladimir Serbinenko Don't abort() on unavailable coreboot tables if not running on coreboot. diff --git a/NEWS b/NEWS index b74c05f63..49a2459b6 100644 --- a/NEWS +++ b/NEWS @@ -35,6 +35,8 @@ New in 2.02: * Improve FreeDOS direct loading support compatibility. * Enable `linux16' on all x86 platforms, not just BIOS. * New TrueCrypt ISO loader. + * multiboot2 boot-services EFI specification. + * multiboot2 full-file specfication. * New/improved network support: * New variables `net_default_*' containing properties of the default @@ -44,11 +46,17 @@ New in 2.02: * Parse `nd' disk names in GRUB Legacy configuration files. * Issue separate DNS queries for IPv4 and IPv6. +* Coreboot improvements: + * CBFS support both in on-disk images (loopback) and flash. + * Ability to launch another payload from flash or disk + * Coreboot framebuffer + * CBMEMC support (both logging and inspecting logs) + * Inspecting coreboot timestamps. + * Inspecting coreboot tables. + * New/improved platform support: * New `efifwsetup' and `lsefi' commands on EFI platforms. * New `cmosdump' and `cmosset' commands on platforms with CMOS support. - * New `cbmemc', `coreboot_boottime', and `lscoreboot' commands on - coreboot. * Improve opcode parsing in ACPI halt implementation. * Use the TSC as a possible time source on i386-ieee1275. * Merge PowerPC grub-mkrescue implementation with the common one. @@ -68,6 +76,7 @@ New in 2.02: grub-install. * Support Yeeloong 3A. * Add `cpuid --pae' option to detect Physical Address Extension on x86. + * Support for USB debug dongles. * Security: * Add optional facility to enforce that all files read by the core image @@ -78,6 +87,7 @@ New in 2.02: * New boot time analysis framework (`./configure --enable-boot-time'). * Initialise USB ports in parallel. * New `testspeed' command to test file read speed. + * Speed-up gfxterm by storing intermediate results in more compact format. * Scripting: * New `eval' and `tr' commands. @@ -95,6 +105,7 @@ New in 2.02: * grub-install, grub-mknetdir, grub-mkrescue, and grub-mkstandalone rewritten in C. They should now work in supported non-Unix-like environments. + * Native mingw support, including ability to install on EFI under windows. * Reorganise timeout handling using new `timeout_style' environment variable and `GRUB_TIMEOUT_STYLE' configuration key for grub-mkconfig. Menu hotkeys pressed during a hidden timeout now boot the corresponding @@ -107,12 +118,19 @@ New in 2.02: executable stack. * Fix documentation build with Texinfo >= 5.1. * More robust and documented cross-compiling support. - * Partial clang support for some platforms. + * Partial clang support for some platforms (experimental). + * Partial mingw64 x86_64-efi compile support (highly experimental). + * Partial mingw32 i386-* (other than already present i386-pc) + compile support (highly experimental). * Eliminate the use of AutoGen. This allowed some performance improvements to the build system. + * Remove variable length arrays. + * OpenBSD compile and tools support (NetBSD and FreeBSD were already supported). * Fix build with FreeType >= 2.5.1. * Make gentpl.py compatible with Python 3. It now requires at least Python 2.6. + * modinfo.sh contains build information now. + * Added many new tests to improve robustness. * Revision control moved to git. @@ -142,7 +160,6 @@ New in 2.00: * IEEE1275 serial. * EFI serial. * Network stack for BIOS, IEEE1275, EMU and EFI, including TFTP, HTTP and DNS. - * VBE on coreboot support. * New filesystem, filters and disks formats: * DVH partition map. @@ -166,7 +183,7 @@ New in 2.00: * multidevice, mirrored and raidz(2,3) ZFS support. * RAID LVM (internal RAIDing) support. * ZFS crypto support. - * ZLE and GZIP on ZFS support. + * ZLE, LZ4 and GZIP on ZFS support. * Support ZFS up to 33. * HFS string is now treated like mac-roman and not UTF-8 * HFS mtime support. From 668add258ff7ffcfdc2c501fe5eb32e53c69b6f4 Mon Sep 17 00:00:00 2001 From: Andrey Borzenkov Date: Mon, 30 Dec 2013 12:56:19 +0000 Subject: [PATCH 009/722] strip .eh_frame section from arm64-efi kernel Fixes grub-mkimage error "relocation 0x105 is not implemented yet." --- ChangeLog | 4 ++++ grub-core/Makefile.core.def | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index db843006d..8c1ececa1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2013-12-30 Andrey Borzenkov + + * grub-core/Makefile.core.def: strip .eh_frame section for arm64-efi. + 2013-12-30 Vladimir Serbinenko * NEWS: Add few missing entries. Correct existing ones. diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def index c916246de..42443bc00 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def @@ -66,7 +66,7 @@ kernel = { arm_efi_stripflags = '--strip-unneeded -K start -R .note -R .comment -R .note.gnu.gold-version'; arm64_efi_ldflags = '-Wl,-r,-d'; - arm64_efi_stripflags = '--strip-unneeded -K start -R .note -R .comment -R .note.gnu.gold-version'; + arm64_efi_stripflags = '--strip-unneeded -K start -R .note -R .comment -R .note.gnu.gold-version -R .eh_frame'; i386_pc_ldflags = '$(TARGET_IMG_LDFLAGS)'; i386_pc_ldflags = '$(TARGET_IMG_BASE_LDOPT),0x9000'; From c9e839e2caaf278491f99e7d181cf20dcf5f0b75 Mon Sep 17 00:00:00 2001 From: Andrey Borzenkov Date: Tue, 7 Jan 2014 10:38:54 +0400 Subject: [PATCH 010/722] use {grub,boot}aa64.efi for boot images on AArch64 According to UEFI 2.4 specification, default boot file name on AArch64 is BOOTAA64.EFI (3.4.1.1 Removable Media Boot Behavior). Also set default GRUB image name to grubaa64.efi to match it. --- util/grub-install.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/util/grub-install.c b/util/grub-install.c index 8cfe0eaa2..4608b80fe 100644 --- a/util/grub-install.c +++ b/util/grub-install.c @@ -1091,7 +1091,7 @@ main (int argc, char *argv[]) efi_file = "BOOTARM.EFI"; break; case GRUB_INSTALL_PLATFORM_ARM64_EFI: - efi_file = "BOOTAARCH64.EFI"; + efi_file = "BOOTAA64.EFI"; break; default: grub_util_error ("%s", _("You've found a bug")); @@ -1118,7 +1118,7 @@ main (int argc, char *argv[]) efi_file = "grubarm.efi"; break; case GRUB_INSTALL_PLATFORM_ARM64_EFI: - efi_file = "grubarm64.efi"; + efi_file = "grubaa64.efi"; break; default: efi_file = "grub.efi"; From 94cee4a4c201bb506377b2c26e072eee8cb19d6f Mon Sep 17 00:00:00 2001 From: Andrey Borzenkov Date: Tue, 7 Jan 2014 18:43:02 +0400 Subject: [PATCH 011/722] fix 32 bit compilation on MinGW-w64 Use _FILE_OFFSET_BITS macro to distinguish between native MinGW and 32 bit under MinGW-64. The latter does not require fseeko/ftello redefinition which it already does in case of _FILE_OFFSET_BITS=64. --- ChangeLog | 5 +++++ include/grub/osdep/hostfile_windows.h | 3 +++ 2 files changed, 8 insertions(+) diff --git a/ChangeLog b/ChangeLog index 8c1ececa1..e87f0a7a4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2014-01-07 Andrey Borzenkov + + * include/grub/osdep/hostfile_windows.h: Do not redefine fseeko/ftello + on MinGW-64 when compiling for 32 bits. + 2013-12-30 Andrey Borzenkov * grub-core/Makefile.core.def: strip .eh_frame section for arm64-efi. diff --git a/include/grub/osdep/hostfile_windows.h b/include/grub/osdep/hostfile_windows.h index 36615b2c4..79efcfa50 100644 --- a/include/grub/osdep/hostfile_windows.h +++ b/include/grub/osdep/hostfile_windows.h @@ -69,8 +69,11 @@ enum grub_util_fd_open_flags_t #if defined (__MINGW32__) && !defined (__MINGW64__) +/* 32 bit on MinGW-64 already redefines them if _FILE_OFFSET_BITS=64 */ +#if !defined(_FILE_OFFSET_BITS) #define fseeko fseeko64 #define ftello ftello64 +#endif #endif From e7cfa8d5e1c6d54d40731065e535889b2e8bc9a2 Mon Sep 17 00:00:00 2001 From: Andrey Borzenkov Date: Tue, 7 Jan 2014 20:34:25 +0400 Subject: [PATCH 012/722] Change grub-mkrescue to use bootaa64.efi too Also add ChangeLog entry for previous change. --- ChangeLog | 7 +++++++ util/grub-mkrescue.c | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index e87f0a7a4..0b9fa05b2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2014-01-07 Andrey Borzenkov + + * util/grub-install.c: Use bootaa64.efi instead of bootaarch64.efi on + arm64 to comply with EFI specification. Also use grubaa64.efi for + consistency. + * util/grub-mkrescue.c: Change to use bootaa64.efi too. + 2014-01-07 Andrey Borzenkov * include/grub/osdep/hostfile_windows.h: Do not redefine fseeko/ftello diff --git a/util/grub-mkrescue.c b/util/grub-mkrescue.c index 317879d0b..0d03e55d2 100644 --- a/util/grub-mkrescue.c +++ b/util/grub-mkrescue.c @@ -663,7 +663,7 @@ main (int argc, char *argv[]) make_image_fwdisk_abs (GRUB_INSTALL_PLATFORM_ARM_EFI, "arm-efi", imgname); free (imgname); - imgname = grub_util_path_concat (2, efidir_efi_boot, "bootaarch64.efi"); + imgname = grub_util_path_concat (2, efidir_efi_boot, "bootaa64.efi"); make_image_fwdisk_abs (GRUB_INSTALL_PLATFORM_ARM64_EFI, "arm64-efi", imgname); free (imgname); From 4d21c1019904598a991e847eef049c65f9c49bd9 Mon Sep 17 00:00:00 2001 From: Leif Lindholm Date: Tue, 7 Jan 2014 17:52:50 +0000 Subject: [PATCH 013/722] arm64: set correct length of device path end entry The length of the Device Path End entry in the grub_linux_boot() function was incorrectly set to 0. This triggers an assert failure in debug builds of Tianocore. Set it to sizeof (grub_efi_device_path_t). --- ChangeLog | 4 ++++ grub-core/loader/arm64/linux.c | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 0b9fa05b2..4ec5517bd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2014-01-07 Leif Lindholm + + * grub-core/loader/arm64/linux.c: correctly set device path end length. + 2014-01-07 Andrey Borzenkov * util/grub-install.c: Use bootaa64.efi instead of bootaarch64.efi on diff --git a/grub-core/loader/arm64/linux.c b/grub-core/loader/arm64/linux.c index 9d15aad62..75ad871a8 100644 --- a/grub-core/loader/arm64/linux.c +++ b/grub-core/loader/arm64/linux.c @@ -268,7 +268,7 @@ grub_linux_boot (void) mempath[1].header.type = GRUB_EFI_END_DEVICE_PATH_TYPE; mempath[1].header.subtype = GRUB_EFI_END_ENTIRE_DEVICE_PATH_SUBTYPE; - mempath[1].header.length = 0; + mempath[1].header.length = sizeof (grub_efi_device_path_t); b = grub_efi_system_table->boot_services; status = b->load_image (0, grub_efi_image_handle, From ccd21a65ed5ebce27b1e78b56208169fbf30351e Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Wed, 8 Jan 2014 11:05:20 +0000 Subject: [PATCH 014/722] * Makefile.util.def (grub-macbless): Change mansection to 8. --- ChangeLog | 4 ++++ Makefile.util.def | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 4ec5517bd..b445f1215 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2014-01-08 Colin Watson + + * Makefile.util.def (grub-macbless): Change mansection to 8. + 2014-01-07 Leif Lindholm * grub-core/loader/arm64/linux.c: correctly set device path end length. diff --git a/Makefile.util.def b/Makefile.util.def index 985e76ca4..3c99be2b0 100644 --- a/Makefile.util.def +++ b/Makefile.util.def @@ -405,7 +405,7 @@ program = { program = { name = grub-macbless; installdir = sbin; - mansection = 1; + mansection = 8; common = util/grub-macbless.c; common = grub-core/osdep/init.c; common = grub-core/kern/emu/argp_common.c; From 0776112c5311196889a15058a3b1be4c81ba5e05 Mon Sep 17 00:00:00 2001 From: Andrey Borzenkov Date: Sun, 12 Jan 2014 15:29:21 +0400 Subject: [PATCH 015/722] add part_apple to EFI rescue image to fix missing prefix On Mac rescue image is booted from HFS+ partition, so bootpath looks like /ACPI(a0341d0,0)/PCI(1,1f)/ATAPI(0,0,0)/HD(3,5d1,ca3,0000000000000000,20,0)/EndEntire grub fails to find device for this path because it cannot scan partition table. The simplest fix is to add part_apple by default. --- util/grub-mkrescue.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/util/grub-mkrescue.c b/util/grub-mkrescue.c index 0d03e55d2..34e0b7aff 100644 --- a/util/grub-mkrescue.c +++ b/util/grub-mkrescue.c @@ -653,11 +653,15 @@ main (int argc, char *argv[]) make_image_fwdisk_abs (GRUB_INSTALL_PLATFORM_IA64_EFI, "ia64-efi", imgname); free (imgname); + grub_install_push_module ("part_apple"); img64 = grub_util_path_concat (2, efidir_efi_boot, "bootx64.efi"); make_image_fwdisk_abs (GRUB_INSTALL_PLATFORM_X86_64_EFI, "x86_64-efi", img64); + grub_install_pop_module (); + grub_install_push_module ("part_apple"); img32 = grub_util_path_concat (2, efidir_efi_boot, "bootia32.efi"); make_image_fwdisk_abs (GRUB_INSTALL_PLATFORM_I386_EFI, "i386-efi", img32); + grub_install_pop_module (); imgname = grub_util_path_concat (2, efidir_efi_boot, "bootarm.efi"); make_image_fwdisk_abs (GRUB_INSTALL_PLATFORM_ARM_EFI, "arm-efi", imgname); @@ -707,7 +711,9 @@ main (int argc, char *argv[]) free (efidir); } + grub_install_push_module ("part_apple"); make_image_fwdisk (GRUB_INSTALL_PLATFORM_POWERPC_IEEE1275, "powerpc-ieee1275", "powerpc-ieee1275/core.elf"); + grub_install_pop_module (); if (source_dirs[GRUB_INSTALL_PLATFORM_POWERPC_IEEE1275]) { From 09a836e59c1103ed9aa238dcd526da670c9b0d90 Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Fri, 17 Jan 2014 02:30:52 +0000 Subject: [PATCH 016/722] freebsd/hostdisk.c is only ever compiled on FreeBSD * grub-core/osdep/freebsd/hostdisk.c (grub_util_fd_open): Remove redundant preprocessor conditional. --- ChangeLog | 5 +++++ grub-core/osdep/freebsd/hostdisk.c | 2 -- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index b445f1215..6613b4ee5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2014-01-17 Colin Watson + + * grub-core/osdep/freebsd/hostdisk.c (grub_util_fd_open): Remove + redundant preprocessor conditional. + 2014-01-08 Colin Watson * Makefile.util.def (grub-macbless): Change mansection to 8. diff --git a/grub-core/osdep/freebsd/hostdisk.c b/grub-core/osdep/freebsd/hostdisk.c index bd5fddb91..eb202dcc8 100644 --- a/grub-core/osdep/freebsd/hostdisk.c +++ b/grub-core/osdep/freebsd/hostdisk.c @@ -108,7 +108,6 @@ grub_util_fd_open (const char *os_dev, int flags) ret = open (os_dev, flags, S_IROTH | S_IRGRP | S_IRUSR | S_IWUSR); -#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) if (! (sysctl_oldflags & 0x10) && sysctlbyname ("kern.geom.debugflags", NULL , 0, &sysctl_oldflags, sysctl_size)) { @@ -116,7 +115,6 @@ grub_util_fd_open (const char *os_dev, int flags) close (ret); return GRUB_UTIL_FD_INVALID; } -#endif return ret; } From ff66b8e7d8397c40bdd57ada31665b605c20c565 Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Fri, 17 Jan 2014 15:24:50 +0000 Subject: [PATCH 017/722] Prefer more portable test(1) constructs * util/grub.d/00_header.in (make_timeout): Use && rather than test -a. * util/grub.d/10_windows.in: Likewise. * util/grub.d/10_netbsd.in (netbsd_load_fs_module): Use || rather than test -o. * util/grub.d/30_os-prober.in: Use && rather than test -a, and || rather than test -o. --- ChangeLog | 12 +++++++++++- util/grub.d/00_header.in | 2 +- util/grub.d/10_netbsd.in | 2 +- util/grub.d/10_windows.in | 4 ++-- util/grub.d/30_os-prober.in | 4 ++-- 5 files changed, 17 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6613b4ee5..c8e95a6b9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,14 @@ -2014-01-17 Colin Watson +2014-01-17 Colin Watson + + * util/grub.d/00_header.in (make_timeout): Use && rather than test + -a. + * util/grub.d/10_windows.in: Likewise. + * util/grub.d/10_netbsd.in (netbsd_load_fs_module): Use || rather + than test -o. + * util/grub.d/30_os-prober.in: Use && rather than test -a, and || + rather than test -o. + +2014-01-17 Colin Watson * grub-core/osdep/freebsd/hostdisk.c (grub_util_fd_open): Remove redundant preprocessor conditional. diff --git a/util/grub.d/00_header.in b/util/grub.d/00_header.in index 0c82f2315..ce2ec819d 100644 --- a/util/grub.d/00_header.in +++ b/util/grub.d/00_header.in @@ -285,7 +285,7 @@ make_timeout () if [ "x${3}" != "x" ] ; then timeout="${2}" style="${3}" - elif [ "x${1}" != "x" -a "x${1}" != "x0" ] ; then + elif [ "x${1}" != "x" ] && [ "x${1}" != "x0" ] ; then # Handle the deprecated GRUB_HIDDEN_TIMEOUT scheme. timeout="${1}" if [ "x${2}" != "x0" ] ; then diff --git a/util/grub.d/10_netbsd.in b/util/grub.d/10_netbsd.in index 29a0e41a9..9988a42bc 100644 --- a/util/grub.d/10_netbsd.in +++ b/util/grub.d/10_netbsd.in @@ -69,7 +69,7 @@ netbsd_load_fs_module () kversion=$(zcat -f "${kernel}" | strings | sed -n -e '/^@(#)NetBSD/ { s/^@(#)NetBSD \([0-9\.]*\) .*$/\1/g ; p ; q ; }') kmodule="/stand/${karch}/${kversion}/modules/${kmod}/${kmod}.kmod" - if test -z "$karch" -o -z "$kversion" -o ! -f "${kmodule}"; then + if test -z "$karch" || test -z "$kversion" || test ! -f "${kmodule}"; then return fi diff --git a/util/grub.d/10_windows.in b/util/grub.d/10_windows.in index 9025914f6..48bd95546 100644 --- a/util/grub.d/10_windows.in +++ b/util/grub.d/10_windows.in @@ -66,11 +66,11 @@ for drv in $drives ; do osid= # Check for Vista bootmgr. - if [ -f "$dir"/bootmgr -a -f "$dir"/boot/bcd ] ; then + if [ -f "$dir"/bootmgr ] && [ -f "$dir"/boot/bcd ] ; then OS="$(gettext "Windows Vista/7 (loader)")" osid=bootmgr # Check for NTLDR. - elif [ -f "$dir"/ntldr -a -f "$dir"/ntdetect.com -a -f "$dir"/boot.ini ] ; then + elif [ -f "$dir"/ntldr ] && [ -f "$dir"/ntdetect.com ] && [ -f "$dir"/boot.ini ] ; then OS=`get_os_name_from_boot_ini "$dir"/boot.ini` || OS="$(gettext "Windows NT/2000/XP (loader)")" osid=ntldr needmap=t diff --git a/util/grub.d/30_os-prober.in b/util/grub.d/30_os-prober.in index 0470e6685..7cf8487d6 100644 --- a/util/grub.d/30_os-prober.in +++ b/util/grub.d/30_os-prober.in @@ -30,7 +30,7 @@ if [ "x${GRUB_DISABLE_OS_PROBER}" = "xtrue" ]; then exit 0 fi -if [ -z "`which os-prober 2> /dev/null`" -o -z "`which linux-boot-prober 2> /dev/null`" ] ; then +if [ -z "`which os-prober 2> /dev/null`" ] || [ -z "`which linux-boot-prober 2> /dev/null`" ] ; then # missing os-prober and/or linux-boot-prober exit 0 fi @@ -119,7 +119,7 @@ for OS in ${OSPROBED} ; do EXPUUID="${EXPUUID}@${DEVICE#*@}" fi - if [ "x${GRUB_OS_PROBER_SKIP_LIST}" != "x" -a "x`echo ${GRUB_OS_PROBER_SKIP_LIST} | grep -i -e '\b'${EXPUUID}'\b'`" != "x" ] ; then + if [ "x${GRUB_OS_PROBER_SKIP_LIST}" != "x" ] && [ "x`echo ${GRUB_OS_PROBER_SKIP_LIST} | grep -i -e '\b'${EXPUUID}'\b'`" != "x" ] ; then echo "Skipped ${LONGNAME} on ${DEVICE} by user request." >&2 continue fi From 5acc8020b46605703a59915d4166520788dfdf00 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sat, 18 Jan 2014 16:31:10 +0100 Subject: [PATCH 018/722] * NEWS: Add few missing entries. --- ChangeLog | 4 ++++ NEWS | 18 +++++++++++++++--- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index c8e95a6b9..6a19f8504 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2014-01-18 Vladimir Serbinenko + + * NEWS: Add few missing entries. + 2014-01-17 Colin Watson * util/grub.d/00_header.in (make_timeout): Use && rather than test diff --git a/NEWS b/NEWS index 49a2459b6..a61df942a 100644 --- a/NEWS +++ b/NEWS @@ -15,6 +15,8 @@ New in 2.02: * GPT PReP. * New `progress' module that shows progress information while reading files. + * ZFS features support. + * ZFS LZ4 support. * New/improved terminal and video support: * Monochrome text (matching `hercules' in GRUB Legacy). @@ -36,6 +38,7 @@ New in 2.02: * Enable `linux16' on all x86 platforms, not just BIOS. * New TrueCrypt ISO loader. * multiboot2 boot-services EFI specification. + * multiboot2 EFI memory map specification. * multiboot2 full-file specfication. * New/improved network support: @@ -51,12 +54,15 @@ New in 2.02: * Ability to launch another payload from flash or disk * Coreboot framebuffer * CBMEMC support (both logging and inspecting logs) - * Inspecting coreboot timestamps. - * Inspecting coreboot tables. + * Command for inspecting coreboot timestamps (`coreboot_boottime'). + * Command for inspecting coreboot tables (`lscoreboot'). + * New target default_payload.elf. + * Increased maximal core size. * New/improved platform support: * New `efifwsetup' and `lsefi' commands on EFI platforms. * New `cmosdump' and `cmosset' commands on platforms with CMOS support. + * New command `pcidump' for PCI platforms. * Improve opcode parsing in ACPI halt implementation. * Use the TSC as a possible time source on i386-ieee1275. * Merge PowerPC grub-mkrescue implementation with the common one. @@ -77,6 +83,8 @@ New in 2.02: * Support Yeeloong 3A. * Add `cpuid --pae' option to detect Physical Address Extension on x86. * Support for USB debug dongles. + * Support for *-emu on all platforms (previously only i386/x86_64 worked). + * Support *-emu on Windows. * Security: * Add optional facility to enforce that all files read by the core image @@ -88,6 +96,8 @@ New in 2.02: * Initialise USB ports in parallel. * New `testspeed' command to test file read speed. * Speed-up gfxterm by storing intermediate results in more compact format. + * Lazy LVM/mdraid scan. + * Disk hints. * Scripting: * New `eval' and `tr' commands. @@ -105,7 +115,8 @@ New in 2.02: * grub-install, grub-mknetdir, grub-mkrescue, and grub-mkstandalone rewritten in C. They should now work in supported non-Unix-like environments. - * Native mingw support, including ability to install on EFI under windows. + * Native mingw support. + * Ability to install on EFI under windows. * Reorganise timeout handling using new `timeout_style' environment variable and `GRUB_TIMEOUT_STYLE' configuration key for grub-mkconfig. Menu hotkeys pressed during a hidden timeout now boot the corresponding @@ -122,6 +133,7 @@ New in 2.02: * Partial mingw64 x86_64-efi compile support (highly experimental). * Partial mingw32 i386-* (other than already present i386-pc) compile support (highly experimental). + * Support for grub-mkpasswd on Windows. * Eliminate the use of AutoGen. This allowed some performance improvements to the build system. * Remove variable length arrays. From 7e7293d745ef7c0a13d8cbf12f474843edfdd0ab Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sat, 18 Jan 2014 16:41:47 +0100 Subject: [PATCH 019/722] * grub-core/kern/efi/efi.c: Ensure that the result starts with / and has no //. --- ChangeLog | 5 +++++ grub-core/kern/efi/efi.c | 25 +++++++++++++++++-------- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6a19f8504..b04a4ef70 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2014-01-18 Vladimir Serbinenko + + * grub-core/kern/efi/efi.c: Ensure that the result starts with / + and has no //. + 2014-01-18 Vladimir Serbinenko * NEWS: Add few missing entries. diff --git a/grub-core/kern/efi/efi.c b/grub-core/kern/efi/efi.c index b253141f2..b9eb1ab1e 100644 --- a/grub-core/kern/efi/efi.c +++ b/grub-core/kern/efi/efi.c @@ -309,7 +309,7 @@ grub_efi_modules_addr (void) char * grub_efi_get_filename (grub_efi_device_path_t *dp0) { - char *name = 0, *p; + char *name = 0, *p, *pi; grub_size_t filesize = 0; grub_efi_device_path_t *dp; @@ -328,7 +328,7 @@ grub_efi_get_filename (grub_efi_device_path_t *dp0) grub_efi_uint16_t len; len = ((GRUB_EFI_DEVICE_PATH_LENGTH (dp) - 4) / sizeof (grub_efi_char16_t)); - filesize += GRUB_MAX_UTF8_PER_UTF16 * len + 1; + filesize += GRUB_MAX_UTF8_PER_UTF16 * len + 2; } dp = GRUB_EFI_NEXT_DEVICE_PATH (dp); @@ -356,12 +356,12 @@ grub_efi_get_filename (grub_efi_device_path_t *dp0) grub_efi_file_path_device_path_t *fp; grub_efi_uint16_t len; - if (p != name) - *p++ = '/'; + *p++ = '/'; len = ((GRUB_EFI_DEVICE_PATH_LENGTH (dp) - 4) / sizeof (grub_efi_char16_t)); fp = (grub_efi_file_path_device_path_t *) dp; + p = (char *) grub_utf16_to_utf8 ((unsigned char *) p, fp->path_name, len); } @@ -370,10 +370,19 @@ grub_efi_get_filename (grub_efi_device_path_t *dp0) *p = '\0'; - /* EFI breaks paths with backslashes. */ - for (p = name; *p; p++) - if (*p == '\\') - *p = '/'; + for (pi = name, p = name; *pi;) + { + /* EFI breaks paths with backslashes. */ + if (*pi == '\\' || *pi == '/') + { + *p++ = '/'; + while (*pi == '\\' || *pi == '/') + pi++; + continue; + } + *p++ = *pi++; + } + *p = '\0'; return name; } From ae80f312700c72fcb0222a7865ea69f37517a313 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sat, 18 Jan 2014 16:43:29 +0100 Subject: [PATCH 020/722] * util/grub-mount.c: Extend GCC warning workaround to grub-mount. --- ChangeLog | 4 ++++ util/grub-mount.c | 7 ++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index b04a4ef70..8534158b6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2014-01-18 Vladimir Serbinenko + + * util/grub-mount.c: Extend GCC warning workaround to grub-mount. + 2014-01-18 Vladimir Serbinenko * grub-core/kern/efi/efi.c: Ensure that the result starts with / diff --git a/util/grub-mount.c b/util/grub-mount.c index 118881e0d..19de2e620 100644 --- a/util/grub-mount.c +++ b/util/grub-mount.c @@ -41,8 +41,13 @@ #include #include +#pragma GCC diagnostic ignored "-Wmissing-prototypes" +#pragma GCC diagnostic ignored "-Wmissing-declarations" +#include +#pragma GCC diagnostic error "-Wmissing-prototypes" +#pragma GCC diagnostic error "-Wmissing-declarations" + #include "progname.h" -#include "argp.h" static const char *root = NULL; grub_device_t dev = NULL; From dcecae1a49996bbaefb4133a878215594eb5094a Mon Sep 17 00:00:00 2001 From: Andrey Borzenkov Date: Sat, 18 Jan 2014 19:50:54 +0400 Subject: [PATCH 021/722] reintroduce BUILD_LDFLAGS for the cross-compile case This allows providing separate LDFLAGS for build and host environments, which are not necessary the same for cross-compile case. In particular, it allows building host programs statically to not depend on presence of libraries at run-time (e.g. MinGW DLLs on Windows) while continue to use default dynamic linking at build time. Also fix obsolete comments in confgure.ac - we do use different environment for build and host now. --- ChangeLog | 7 +++++++ INSTALL | 3 ++- Makefile.am | 8 ++++---- configure.ac | 13 ++++++++----- grub-core/Makefile.am | 6 +++--- 5 files changed, 24 insertions(+), 13 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8534158b6..9c3ef2e21 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2014-01-07 Andrey Borzenkov + + * configure.ac: Add support for BUILD_LDFLAGS. + * Makefile.am: Use BUILD_LDFLAGS for build time programs here ... + * grub-core/Makefile.am: ... and here. + * INSTALL: Mention BUILD_LDFLAGS. + 2014-01-18 Vladimir Serbinenko * util/grub-mount.c: Extend GCC warning workaround to grub-mount. diff --git a/INSTALL b/INSTALL index db12530df..b67cd7f34 100644 --- a/INSTALL +++ b/INSTALL @@ -168,7 +168,8 @@ corresponding platform are not needed for the platform in question. generate sin and cos tables. 2. BUILD_CFLAGS= for C options for build. 3. BUILD_CPPFLAGS= for C preprocessor options for build. - 4. BUILD_FREETYPE= for freetype-config for build (optional). + 4. BUILD_LDFLAGS= for linker options for build. + 5. BUILD_FREETYPE= for freetype-config for build (optional). - For host 1. --host= to autoconf name of host. diff --git a/Makefile.am b/Makefile.am index 320e86f8f..1bbec0e79 100644 --- a/Makefile.am +++ b/Makefile.am @@ -67,20 +67,20 @@ endif starfield_theme_files = $(srcdir)/themes/starfield/blob_w.png $(srcdir)/themes/starfield/boot_menu_c.png $(srcdir)/themes/starfield/boot_menu_e.png $(srcdir)/themes/starfield/boot_menu_ne.png $(srcdir)/themes/starfield/boot_menu_n.png $(srcdir)/themes/starfield/boot_menu_nw.png $(srcdir)/themes/starfield/boot_menu_se.png $(srcdir)/themes/starfield/boot_menu_s.png $(srcdir)/themes/starfield/boot_menu_sw.png $(srcdir)/themes/starfield/boot_menu_w.png $(srcdir)/themes/starfield/slider_c.png $(srcdir)/themes/starfield/slider_n.png $(srcdir)/themes/starfield/slider_s.png $(srcdir)/themes/starfield/starfield.png $(srcdir)/themes/starfield/terminal_box_c.png $(srcdir)/themes/starfield/terminal_box_e.png $(srcdir)/themes/starfield/terminal_box_ne.png $(srcdir)/themes/starfield/terminal_box_n.png $(srcdir)/themes/starfield/terminal_box_nw.png $(srcdir)/themes/starfield/terminal_box_se.png $(srcdir)/themes/starfield/terminal_box_s.png $(srcdir)/themes/starfield/terminal_box_sw.png $(srcdir)/themes/starfield/terminal_box_w.png $(srcdir)/themes/starfield/theme.txt $(srcdir)/themes/starfield/README $(srcdir)/themes/starfield/COPYING.CC-BY-SA-3.0 build-grub-mkfont: util/grub-mkfont.c grub-core/unidata.c grub-core/kern/emu/misc.c util/misc.c - $(BUILD_CC) -o $@ -I$(top_srcdir)/include $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) -DGRUB_MKFONT=1 -DGRUB_BUILD=1 -DGRUB_UTIL=1 -DGRUB_BUILD_PROGRAM_NAME=\"build-grub-mkfont\" $^ $(build_freetype_cflags) $(build_freetype_libs) + $(BUILD_CC) -o $@ -I$(top_srcdir)/include $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) $(BUILD_LDFLAGS) -DGRUB_MKFONT=1 -DGRUB_BUILD=1 -DGRUB_UTIL=1 -DGRUB_BUILD_PROGRAM_NAME=\"build-grub-mkfont\" $^ $(build_freetype_cflags) $(build_freetype_libs) CLEANFILES += build-grub-mkfont garbage-gen: util/garbage-gen.c - $(BUILD_CC) -o $@ $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) $^ + $(BUILD_CC) -o $@ $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) $(BUILD_LDFLAGS) $^ CLEANFILES += garbage-gen EXTRA_DIST += util/garbage-gen.c build-grub-gen-asciih: util/grub-gen-asciih.c - $(BUILD_CC) -o $@ -I$(top_srcdir)/include $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) -DGRUB_MKFONT=1 -DGRUB_BUILD=1 -DGRUB_UTIL=1 $^ $(build_freetype_cflags) $(build_freetype_libs) -Wall -Werror + $(BUILD_CC) -o $@ -I$(top_srcdir)/include $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) $(BUILD_LDFLAGS) -DGRUB_MKFONT=1 -DGRUB_BUILD=1 -DGRUB_UTIL=1 $^ $(build_freetype_cflags) $(build_freetype_libs) -Wall -Werror CLEANFILES += build-grub-gen-asciih build-grub-gen-widthspec: util/grub-gen-widthspec.c - $(BUILD_CC) -o $@ -I$(top_srcdir)/include $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) -DGRUB_MKFONT=1 -DGRUB_BUILD=1 -DGRUB_UTIL=1 $^ $(build_freetype_cflags) $(build_freetype_libs) -Wall -Werror + $(BUILD_CC) -o $@ -I$(top_srcdir)/include $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) $(BUILD_LDFLAGS) -DGRUB_MKFONT=1 -DGRUB_BUILD=1 -DGRUB_UTIL=1 $^ $(build_freetype_cflags) $(build_freetype_libs) -Wall -Werror CLEANFILES += build-grub-gen-widthspec if COND_STARFIELD diff --git a/configure.ac b/configure.ac index 7c5d080b8..2e4cf3c2e 100644 --- a/configure.ac +++ b/configure.ac @@ -26,11 +26,10 @@ dnl This is necessary because the target type in autoconf does not dnl describe such a system very well. dnl dnl The current strategy is to use variables with no prefix (such as -dnl CC, CFLAGS, etc.) for the host type as well as the build type, -dnl because GRUB does not need to use those variables for the build -dnl type, so there is no conflict. Variables with the prefix "TARGET_" -dnl (such as TARGET_CC, TARGET_CFLAGS, etc.) are used for the target -dnl type. +dnl CC, CFLAGS, etc.) for the host type, variables with prefix "BUILD_" +dnl (such as BUILD_CC, BUILD_CFLAGS, etc.) for the build type and variables +dnl with the prefix "TARGET_" (such as TARGET_CC, TARGET_CFLAGS, etc.) are +dnl used for the target type. See INSTALL for full list of variables. AC_INIT([GRUB],[2.02~beta2],[bug-grub@gnu.org]) @@ -477,6 +476,7 @@ AC_SUBST(HOST_CC) AC_SUBST(BUILD_CC) AC_SUBST(BUILD_CFLAGS) AC_SUBST(BUILD_CPPFLAGS) +AC_SUBST(BUILD_LDFLAGS) AC_SUBST(TARGET_CC) AC_SUBST(TARGET_NM) AC_SUBST(TARGET_RANLIB) @@ -1290,10 +1290,12 @@ SAVED_CC="$CC" SAVED_CPP="$CPP" SAVED_CFLAGS="$CFLAGS" SAVED_CPPFLAGS="$CPPFLAGS" +SAVED_LDFLAGS="$LDFLAGS" CC="$BUILD_CC" CPP="$BUILD_CPP" CFLAGS="$BUILD_CFLAGS" CPPFLAGS="$BUILD_CPPFLAGS" +LDFLAGS="$BUILD_LDFAGS" unset ac_cv_c_bigendian unset ac_cv_header_ft2build_h @@ -1356,6 +1358,7 @@ CC="$SAVED_CC" CPP="$SAVED_CPP" CFLAGS="$SAVED_CFLAGS" CPPFLAGS="$SAVED_CPPFLAGS" +LDFLAGS="$SAVED_LDFLAGS" DJVU_FONT_SOURCE= diff --git a/grub-core/Makefile.am b/grub-core/Makefile.am index 1b3142d21..13b797910 100644 --- a/grub-core/Makefile.am +++ b/grub-core/Makefile.am @@ -27,14 +27,14 @@ CPPFLAGS_LIBRARY += $(CPPFLAGS_PLATFORM) CCASFLAGS_LIBRARY += $(CCASFLAGS_PLATFORM) build-grub-pep2elf: $(top_srcdir)/util/grub-pe2elf.c $(top_srcdir)/grub-core/kern/emu/misc.c $(top_srcdir)/util/misc.c - $(BUILD_CC) -o $@ -I$(top_srcdir)/include $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) -DGRUB_BUILD=1 -DGRUB_TARGET_WORDSIZE=64 -DGRUB_UTIL=1 -DGRUB_BUILD_PROGRAM_NAME=\"build-grub-pep2elf\" $^ + $(BUILD_CC) -o $@ -I$(top_srcdir)/include $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) $(BUILD_LDFLAGS) -DGRUB_BUILD=1 -DGRUB_TARGET_WORDSIZE=64 -DGRUB_UTIL=1 -DGRUB_BUILD_PROGRAM_NAME=\"build-grub-pep2elf\" $^ build-grub-pe2elf: $(top_srcdir)/util/grub-pe2elf.c $(top_srcdir)/grub-core/kern/emu/misc.c $(top_srcdir)/util/misc.c - $(BUILD_CC) -o $@ -I$(top_srcdir)/include $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) -DGRUB_BUILD=1 -DGRUB_TARGET_WORDSIZE=32 -DGRUB_UTIL=1 -DGRUB_BUILD_PROGRAM_NAME=\"build-grub-pe2elf\" $^ + $(BUILD_CC) -o $@ -I$(top_srcdir)/include $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) $(BUILD_LDFLAGS) -DGRUB_BUILD=1 -DGRUB_TARGET_WORDSIZE=32 -DGRUB_UTIL=1 -DGRUB_BUILD_PROGRAM_NAME=\"build-grub-pe2elf\" $^ # gentrigtables gentrigtables: gentrigtables.c - $(BUILD_CC) -o $@ -I$(top_srcdir)/include $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) $< $(BUILD_LIBM) + $(BUILD_CC) -o $@ -I$(top_srcdir)/include $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) $(BUILD_LDFLAGS) $< $(BUILD_LIBM) CLEANFILES += gentrigtables # trigtables.c From 3abb9563712f73bc48a33d428a3ab4c756191904 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sat, 18 Jan 2014 16:57:35 +0100 Subject: [PATCH 022/722] * grub-core/term/terminfo.c: Recognize keys F1-F12. --- ChangeLog | 4 ++ grub-core/term/terminfo.c | 86 +++++++++++++++++++++++---------------- 2 files changed, 54 insertions(+), 36 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9c3ef2e21..bdfbf44da 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2014-01-18 Vladimir Serbinenko + + * grub-core/term/terminfo.c: Recognize keys F1-F12. + 2014-01-07 Andrey Borzenkov * configure.ac: Add support for BUILD_LDFLAGS. diff --git a/grub-core/term/terminfo.c b/grub-core/term/terminfo.c index 3d48b198f..f0d3e3deb 100644 --- a/grub-core/term/terminfo.c +++ b/grub-core/term/terminfo.c @@ -460,28 +460,31 @@ grub_terminfo_readkey (struct grub_term_input *term, int *keys, int *len, {'@', GRUB_TERM_KEY_INSERT}, }; - static struct - { - char key; - unsigned ascii; - } - four_code_table[] = + static unsigned four_code_table[] = { - {'1', GRUB_TERM_KEY_HOME}, - {'3', GRUB_TERM_KEY_DC}, - {'5', GRUB_TERM_KEY_PPAGE}, - {'6', GRUB_TERM_KEY_NPAGE}, - {'7', GRUB_TERM_KEY_HOME}, - {'8', GRUB_TERM_KEY_END} + [1] = GRUB_TERM_KEY_HOME, + [3] = GRUB_TERM_KEY_DC, + [5] = GRUB_TERM_KEY_PPAGE, + [6] = GRUB_TERM_KEY_NPAGE, + [7] = GRUB_TERM_KEY_HOME, + [8] = GRUB_TERM_KEY_END, + [17] = GRUB_TERM_KEY_F6, + [18] = GRUB_TERM_KEY_F7, + [19] = GRUB_TERM_KEY_F8, + [20] = GRUB_TERM_KEY_F9, + [21] = GRUB_TERM_KEY_F10, + [23] = GRUB_TERM_KEY_F11, + [24] = GRUB_TERM_KEY_F12, }; char fx_key[] = { 'P', 'Q', 'w', 'x', 't', 'u', - 'q', 'r', 'p', 'M', 'A', 'B' }; + 'q', 'r', 'p', 'M', 'A', 'B', 'H', 'F' }; unsigned fx_code[] = { GRUB_TERM_KEY_F1, GRUB_TERM_KEY_F2, GRUB_TERM_KEY_F3, GRUB_TERM_KEY_F4, GRUB_TERM_KEY_F5, GRUB_TERM_KEY_F6, GRUB_TERM_KEY_F7, GRUB_TERM_KEY_F8, GRUB_TERM_KEY_F9, - GRUB_TERM_KEY_F10, GRUB_TERM_KEY_F11, GRUB_TERM_KEY_F12 }; + GRUB_TERM_KEY_F10, GRUB_TERM_KEY_F11, GRUB_TERM_KEY_F12, + GRUB_TERM_KEY_HOME, GRUB_TERM_KEY_END }; unsigned i; if (c == '\e') @@ -492,19 +495,13 @@ grub_terminfo_readkey (struct grub_term_input *term, int *keys, int *len, { CONTINUE_READ; - switch (c) - { - case 'H': - keys[0] = GRUB_TERM_KEY_HOME; - *len = 1; - return; - case 'F': - keys[0] = GRUB_TERM_KEY_END; - *len = 1; - return; - default: - return; - } + for (i = 0; i < ARRAY_SIZE (fx_key); i++) + if (fx_key[i] == c) + { + keys[0] = fx_code[i]; + *len = 1; + return; + } } if (c != '[') @@ -523,6 +520,15 @@ grub_terminfo_readkey (struct grub_term_input *term, int *keys, int *len, switch (c) { + case '[': + CONTINUE_READ; + if (c >= 'A' && c <= 'E') + { + keys[0] = GRUB_TERM_KEY_F1 + c - 'A'; + *len = 1; + return; + } + return; case 'O': CONTINUE_READ; for (i = 0; i < ARRAY_SIZE (fx_key); i++) @@ -555,18 +561,26 @@ grub_terminfo_readkey (struct grub_term_input *term, int *keys, int *len, return; } - default: - for (i = 0; i < ARRAY_SIZE (four_code_table); i++) - if (four_code_table[i].key == c) + case '1' ... '9': + { + unsigned val = c - '0'; + CONTINUE_READ; + if (c >= '0' && c <= '9') { + val = val * 10 + (c - '0'); CONTINUE_READ; - if (c != '~') - return; - keys[0] = four_code_table[i].ascii; - *len = 1; - return; } - return; + if (c != '~') + return; + if (val >= ARRAY_SIZE (four_code_table) + || four_code_table[val] == 0) + return; + keys[0] = four_code_table[val]; + *len = 1; + return; + } + default: + return; } } #undef CONTINUE_READ From 9b9c4686f07644eb9c4f4786ff121bb9e19e31cd Mon Sep 17 00:00:00 2001 From: Andrey Borzenkov Date: Sat, 18 Jan 2014 20:01:16 +0400 Subject: [PATCH 023/722] Fix ChangeLog date --- ChangeLog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index bdfbf44da..fcbf2207b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,7 +2,7 @@ * grub-core/term/terminfo.c: Recognize keys F1-F12. -2014-01-07 Andrey Borzenkov +2014-01-18 Andrey Borzenkov * configure.ac: Add support for BUILD_LDFLAGS. * Makefile.am: Use BUILD_LDFLAGS for build time programs here ... From 5ef569df5b359048ee55c5000e2679855cb87e06 Mon Sep 17 00:00:00 2001 From: Andrey Borzenkov Date: Sat, 18 Jan 2014 20:04:11 +0400 Subject: [PATCH 024/722] Use _W64 to detect MinGW W64-32 instead of _FILE_OFFSET_BITS In 94cee4a4c201bb506377b2c26e072eee8cb19d6f I overlooked that config.h unconditionally sets _FILE_OFFSET_BITS, so it cannot be used to detect MinGW W64 environment. It looks like Emacs folks already found solution; instead of _FILE_OFFSET_BITS use _W64 as suggested in http://lists.gnu.org/archive/html/emacs-devel/2013-03/msg00723.html --- ChangeLog | 5 +++++ include/grub/osdep/hostfile_windows.h | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index fcbf2207b..5aac7c1d8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2014-01-18 Andrey Borzenkov + + * include/grub/osdep/hostfile_windows.h: Use _W64 instead of + FILE_OFFSET_BITS to differentiate between native MinGW and Mingw W64. + 2014-01-18 Vladimir Serbinenko * grub-core/term/terminfo.c: Recognize keys F1-F12. diff --git a/include/grub/osdep/hostfile_windows.h b/include/grub/osdep/hostfile_windows.h index 79efcfa50..bf6451b6d 100644 --- a/include/grub/osdep/hostfile_windows.h +++ b/include/grub/osdep/hostfile_windows.h @@ -69,8 +69,8 @@ enum grub_util_fd_open_flags_t #if defined (__MINGW32__) && !defined (__MINGW64__) -/* 32 bit on MinGW-64 already redefines them if _FILE_OFFSET_BITS=64 */ -#if !defined(_FILE_OFFSET_BITS) +/* 32 bit on Mingw-w64 already redefines them if _FILE_OFFSET_BITS=64 */ +#ifndef _W64 #define fseeko fseeko64 #define ftello ftello64 #endif From 1ecf96fcc4bd882381bf21a461a12baf3c5ecf77 Mon Sep 17 00:00:00 2001 From: Andrey Borzenkov Date: Sat, 18 Jan 2014 20:41:24 +0400 Subject: [PATCH 025/722] add BUILD_EXEEXT support to fix make clean on Windows Add $(BUILD_EXEEXT) to ensure files are removed. Also add CLEANFILES where appropriate. --- ChangeLog | 7 +++++++ Makefile.am | 16 ++++++++-------- Makefile.util.def | 2 +- configure.ac | 21 ++++++++++++++++----- grub-core/Makefile.am | 14 ++++++++------ 5 files changed, 40 insertions(+), 20 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5aac7c1d8..dad2da2fa 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2014-01-18 Andrey Borzenkov + + * configure.ac: Add support for BUILD_EXEEXT and use it ... + * Makefile.am: ... here. + * Makefile.util.def: ... and here. + * grub-core/Makefile.am: ... and here. + 2014-01-18 Andrey Borzenkov * include/grub/osdep/hostfile_windows.h: Use _W64 instead of diff --git a/Makefile.am b/Makefile.am index 1bbec0e79..aa526f573 100644 --- a/Makefile.am +++ b/Makefile.am @@ -66,22 +66,22 @@ endif starfield_theme_files = $(srcdir)/themes/starfield/blob_w.png $(srcdir)/themes/starfield/boot_menu_c.png $(srcdir)/themes/starfield/boot_menu_e.png $(srcdir)/themes/starfield/boot_menu_ne.png $(srcdir)/themes/starfield/boot_menu_n.png $(srcdir)/themes/starfield/boot_menu_nw.png $(srcdir)/themes/starfield/boot_menu_se.png $(srcdir)/themes/starfield/boot_menu_s.png $(srcdir)/themes/starfield/boot_menu_sw.png $(srcdir)/themes/starfield/boot_menu_w.png $(srcdir)/themes/starfield/slider_c.png $(srcdir)/themes/starfield/slider_n.png $(srcdir)/themes/starfield/slider_s.png $(srcdir)/themes/starfield/starfield.png $(srcdir)/themes/starfield/terminal_box_c.png $(srcdir)/themes/starfield/terminal_box_e.png $(srcdir)/themes/starfield/terminal_box_ne.png $(srcdir)/themes/starfield/terminal_box_n.png $(srcdir)/themes/starfield/terminal_box_nw.png $(srcdir)/themes/starfield/terminal_box_se.png $(srcdir)/themes/starfield/terminal_box_s.png $(srcdir)/themes/starfield/terminal_box_sw.png $(srcdir)/themes/starfield/terminal_box_w.png $(srcdir)/themes/starfield/theme.txt $(srcdir)/themes/starfield/README $(srcdir)/themes/starfield/COPYING.CC-BY-SA-3.0 -build-grub-mkfont: util/grub-mkfont.c grub-core/unidata.c grub-core/kern/emu/misc.c util/misc.c +build-grub-mkfont$(BUILD_EXEEXT): util/grub-mkfont.c grub-core/unidata.c grub-core/kern/emu/misc.c util/misc.c $(BUILD_CC) -o $@ -I$(top_srcdir)/include $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) $(BUILD_LDFLAGS) -DGRUB_MKFONT=1 -DGRUB_BUILD=1 -DGRUB_UTIL=1 -DGRUB_BUILD_PROGRAM_NAME=\"build-grub-mkfont\" $^ $(build_freetype_cflags) $(build_freetype_libs) -CLEANFILES += build-grub-mkfont +CLEANFILES += build-grub-mkfont$(BUILD_EXEEXT) -garbage-gen: util/garbage-gen.c +garbage-gen$(BUILD_EXEEXT): util/garbage-gen.c $(BUILD_CC) -o $@ $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) $(BUILD_LDFLAGS) $^ -CLEANFILES += garbage-gen +CLEANFILES += garbage-gen$(BUILD_EXEEXT) EXTRA_DIST += util/garbage-gen.c -build-grub-gen-asciih: util/grub-gen-asciih.c +build-grub-gen-asciih$(BUILD_EXEEXT): util/grub-gen-asciih.c $(BUILD_CC) -o $@ -I$(top_srcdir)/include $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) $(BUILD_LDFLAGS) -DGRUB_MKFONT=1 -DGRUB_BUILD=1 -DGRUB_UTIL=1 $^ $(build_freetype_cflags) $(build_freetype_libs) -Wall -Werror -CLEANFILES += build-grub-gen-asciih +CLEANFILES += build-grub-gen-asciih$(BUILD_EXEEXT) -build-grub-gen-widthspec: util/grub-gen-widthspec.c +build-grub-gen-widthspec$(BUILD_EXEEXT): util/grub-gen-widthspec.c $(BUILD_CC) -o $@ -I$(top_srcdir)/include $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) $(BUILD_LDFLAGS) -DGRUB_MKFONT=1 -DGRUB_BUILD=1 -DGRUB_UTIL=1 $^ $(build_freetype_cflags) $(build_freetype_libs) -Wall -Werror -CLEANFILES += build-grub-gen-widthspec +CLEANFILES += build-grub-gen-widthspec$(BUILD_EXEEXT) if COND_STARFIELD starfield_DATA = dejavu_10.pf2 dejavu_12.pf2 dejavu_bold_14.pf2 dejavu_14.pf2 dejavu_16.pf2 $(starfield_theme_files) diff --git a/Makefile.util.def b/Makefile.util.def index 3c99be2b0..83df212f4 100644 --- a/Makefile.util.def +++ b/Makefile.util.def @@ -708,7 +708,7 @@ script = { name = grub-fs-tester; common = tests/util/grub-fs-tester.in; installdir = noinst; - dependencies = garbage-gen; + dependencies = 'garbage-gen$(BUILD_EXEEXT)'; }; script = { diff --git a/configure.ac b/configure.ac index 2e4cf3c2e..cf3de3be1 100644 --- a/configure.ac +++ b/configure.ac @@ -38,7 +38,8 @@ AC_CONFIG_AUX_DIR([build-aux]) # We don't want -g -O2 by default in CFLAGS : ${CFLAGS=""} -# Checks for host and target systems. +# Checks for build, host and target systems. +AC_CANONICAL_BUILD AC_CANONICAL_HOST save_program_prefix="${program_prefix}" AC_CANONICAL_TARGET @@ -422,6 +423,16 @@ case "$build_os" in haiku*) BUILD_LIBM= ;; *) BUILD_LIBM=-lm ;; esac + +dnl FIXME proper test seems to require too deep dive into Autoconf internals. +dnl For now just list known platforms that we support. + +case "$build_os" in + cygwin*|mingw32*|mingw64*) BUILD_EXEEXT=.exe ;; + *) BUILD_EXEEXT= ;; +esac +AC_SUBST(BUILD_EXEEXT) + # For gnulib. gl_INIT @@ -765,11 +776,11 @@ if test x"$platform" = xemu ; then *windows* | *cygwin* | *mingw*) if test x${target_cpu} = xi386 ; then grub_cv_target_cc_link_format=-mi386pe; - TARGET_OBJ2ELF='./build-grub-pe2elf'; + TARGET_OBJ2ELF='./build-grub-pe2elf$(BUILD_EXEEXT)'; fi if test x${target_cpu} = xx86_64 ; then grub_cv_target_cc_link_format=-mi386pep; - TARGET_OBJ2ELF='./build-grub-pep2elf'; + TARGET_OBJ2ELF='./build-grub-pep2elf$(BUILD_EXEEXT)'; fi TARGET_LDFLAGS="$TARGET_LDFLAGS -Wl,$grub_cv_target_cc_link_format" ;; @@ -803,10 +814,10 @@ elif test x"$target_cpu" = xi386 || test x"$target_cpu" = xx86_64; then fi TARGET_LDFLAGS="$TARGET_LDFLAGS -Wl,$grub_cv_target_cc_link_format" if test x"$grub_cv_target_cc_link_format" = x-mi386pe ; then - TARGET_OBJ2ELF='./build-grub-pe2elf'; + TARGET_OBJ2ELF='./build-grub-pe2elf$(BUILD_EXEEXT)'; fi if test x"$grub_cv_target_cc_link_format" = x-mi386pep ; then - TARGET_OBJ2ELF='./build-grub-pep2elf'; + TARGET_OBJ2ELF='./build-grub-pep2elf$(BUILD_EXEEXT)'; fi fi diff --git a/grub-core/Makefile.am b/grub-core/Makefile.am index 13b797910..826b3dd7c 100644 --- a/grub-core/Makefile.am +++ b/grub-core/Makefile.am @@ -26,20 +26,22 @@ CFLAGS_LIBRARY += $(CFLAGS_PLATFORM) -fno-builtin CPPFLAGS_LIBRARY += $(CPPFLAGS_PLATFORM) CCASFLAGS_LIBRARY += $(CCASFLAGS_PLATFORM) -build-grub-pep2elf: $(top_srcdir)/util/grub-pe2elf.c $(top_srcdir)/grub-core/kern/emu/misc.c $(top_srcdir)/util/misc.c +build-grub-pep2elf$(BUILD_EXEEXT): $(top_srcdir)/util/grub-pe2elf.c $(top_srcdir)/grub-core/kern/emu/misc.c $(top_srcdir)/util/misc.c $(BUILD_CC) -o $@ -I$(top_srcdir)/include $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) $(BUILD_LDFLAGS) -DGRUB_BUILD=1 -DGRUB_TARGET_WORDSIZE=64 -DGRUB_UTIL=1 -DGRUB_BUILD_PROGRAM_NAME=\"build-grub-pep2elf\" $^ +CLEANFILES += build-grub-pep2elf$(BUILD_EXEEXT) -build-grub-pe2elf: $(top_srcdir)/util/grub-pe2elf.c $(top_srcdir)/grub-core/kern/emu/misc.c $(top_srcdir)/util/misc.c +build-grub-pe2elf$(BUILD_EXEEXT): $(top_srcdir)/util/grub-pe2elf.c $(top_srcdir)/grub-core/kern/emu/misc.c $(top_srcdir)/util/misc.c $(BUILD_CC) -o $@ -I$(top_srcdir)/include $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) $(BUILD_LDFLAGS) -DGRUB_BUILD=1 -DGRUB_TARGET_WORDSIZE=32 -DGRUB_UTIL=1 -DGRUB_BUILD_PROGRAM_NAME=\"build-grub-pe2elf\" $^ +CLEANFILES += build-grub-pe2elf$(BUILD_EXEEXT) # gentrigtables -gentrigtables: gentrigtables.c +gentrigtables$(BUILD_EXEEXT): gentrigtables.c $(BUILD_CC) -o $@ -I$(top_srcdir)/include $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) $(BUILD_LDFLAGS) $< $(BUILD_LIBM) -CLEANFILES += gentrigtables +CLEANFILES += gentrigtables$(BUILD_EXEEXT) # trigtables.c -trigtables.c: gentrigtables gentrigtables.c $(top_srcdir)/configure.ac - ./gentrigtables > $@ +trigtables.c: gentrigtables$(BUILD_EXEEXT) gentrigtables.c $(top_srcdir)/configure.ac + ./gentrigtables$(BUILD_EXEEXT) > $@ CLEANFILES += trigtables.c # XXX Use Automake's LEX & YACC support From f371dd5da81701f7bc3d28c67cb4c2c289728691 Mon Sep 17 00:00:00 2001 From: Andrey Borzenkov Date: Sat, 18 Jan 2014 21:22:57 +0400 Subject: [PATCH 026/722] fix include loop on MinGW due to libintl.h pulling stdio.h In file included from ./include/grub/dl.h:23:0, from grub-core/lib/libgcrypt-grub/cipher/rfc2268.c:3: ./include/grub/list.h:34:18: warning: conflicting types for 'grub_list_push' [en abled by default] void EXPORT_FUNC(grub_list_push) (grub_list_t *head, grub_list_t item); ^ ./include/grub/symbol.h:68:25: note: in definition of macro 'EXPORT_FUNC' # define EXPORT_FUNC(x) x ^ In file included from ./include/grub/fs.h:30:0, from ./include/grub/file.h:25, from ./grub-core/lib/posix_wrap/stdio.h:23, from c:\mingw\include\libintl.h:314, from ./include/grub/i18n.h:33, from ./include/grub/misc.h:27, from ./include/grub/list.h:25, from ./include/grub/dl.h:28, from grub-core/lib/libgcrypt-grub/cipher/rfc2268.c:3: ./include/grub/partition.h:106:3: note: previous implicit declaration of 'grub_l ist_push' was here grub_list_push (GRUB_AS_LIST_P (&grub_partition_map_list), ^ list.h needs just ATTRIBUTE_ERROR from misc.h; split compiler features into separate file grub/compiler.h and include it instead. --- ChangeLog | 14 ++++++++ grub-core/commands/fileXX.c | 1 + grub-core/efiemu/prepare.c | 1 + grub-core/loader/i386/xen_file.c | 1 + grub-core/loader/i386/xen_fileXX.c | 1 + grub-core/video/capture.c | 1 + include/grub/command.h | 1 + include/grub/compiler.h | 51 ++++++++++++++++++++++++++++++ include/grub/dl.h | 1 + include/grub/list.h | 4 +-- include/grub/misc.h | 29 +---------------- include/grub/procfs.h | 1 + 12 files changed, 76 insertions(+), 30 deletions(-) create mode 100644 include/grub/compiler.h diff --git a/ChangeLog b/ChangeLog index dad2da2fa..dad469b43 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2014-01-18 Andrey Borzenkov + + * include/grub/misc.h: Move macros for compiler features to ... + * include/grub/compiler.h: ... new file. + * include/grub/list.h: Include instead of . + * grub-core/commands/fileXX.c: Include . + * grub-core/efiemu/prepare.c: Include . + * grub-core/loader/i386/xen_file.c: Include . + * grub-core/loader/i386/xen_fileXX.c: Include . + * grub-core/video/capture.c: Include . + * include/grub/command.h: Include . + * include/grub/dl.h: Include . + * include/grub/procfs.h: Include . + 2014-01-18 Andrey Borzenkov * configure.ac: Add support for BUILD_EXEEXT and use it ... diff --git a/grub-core/commands/fileXX.c b/grub-core/commands/fileXX.c index c9857ff67..58e1094c6 100644 --- a/grub-core/commands/fileXX.c +++ b/grub-core/commands/fileXX.c @@ -18,6 +18,7 @@ #include #include +#include #pragma GCC diagnostic ignored "-Wcast-align" diff --git a/grub-core/efiemu/prepare.c b/grub-core/efiemu/prepare.c index fb1b25d17..84c3368a8 100644 --- a/grub-core/efiemu/prepare.c +++ b/grub-core/efiemu/prepare.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include diff --git a/grub-core/loader/i386/xen_file.c b/grub-core/loader/i386/xen_file.c index ebbf6aa11..ff23235f0 100644 --- a/grub-core/loader/i386/xen_file.c +++ b/grub-core/loader/i386/xen_file.c @@ -18,6 +18,7 @@ #include #include +#include grub_elf_t grub_xen_file (grub_file_t file) diff --git a/grub-core/loader/i386/xen_fileXX.c b/grub-core/loader/i386/xen_fileXX.c index 6df001576..73a5f90fd 100644 --- a/grub-core/loader/i386/xen_fileXX.c +++ b/grub-core/loader/i386/xen_fileXX.c @@ -17,6 +17,7 @@ */ #include +#include static grub_err_t parse_xen_guest (grub_elf_t elf, struct grub_xen_file_info *xi, diff --git a/grub-core/video/capture.c b/grub-core/video/capture.c index 67c8edde8..4f83c7441 100644 --- a/grub-core/video/capture.c +++ b/grub-core/video/capture.c @@ -4,6 +4,7 @@ #include #include #include +#include static struct { diff --git a/include/grub/command.h b/include/grub/command.h index 8705a6355..eee4e847e 100644 --- a/include/grub/command.h +++ b/include/grub/command.h @@ -22,6 +22,7 @@ #include #include #include +#include typedef enum grub_command_flags { diff --git a/include/grub/compiler.h b/include/grub/compiler.h new file mode 100644 index 000000000..c9e1d7a73 --- /dev/null +++ b/include/grub/compiler.h @@ -0,0 +1,51 @@ +/* compiler.h - macros for various compiler features */ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2002,2003,2005,2006,2007,2008,2009,2010,2014 Free Software Foundation, Inc. + * + * GRUB is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GRUB is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GRUB. If not, see . + */ + +#ifndef GRUB_COMPILER_HEADER +#define GRUB_COMPILER_HEADER 1 + +/* GCC version checking borrowed from glibc. */ +#if defined(__GNUC__) && defined(__GNUC_MINOR__) +# define GNUC_PREREQ(maj,min) \ + ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min)) +#else +# define GNUC_PREREQ(maj,min) 0 +#endif + +/* Does this compiler support compile-time error attributes? */ +#if GNUC_PREREQ(4,3) +# define ATTRIBUTE_ERROR(msg) \ + __attribute__ ((__error__ (msg))) +#else +# define ATTRIBUTE_ERROR(msg) __attribute__ ((noreturn)) +#endif + +#if GNUC_PREREQ(4,4) +# define GNU_PRINTF gnu_printf +#else +# define GNU_PRINTF printf +#endif + +#if GNUC_PREREQ(3,4) +# define WARN_UNUSED_RESULT __attribute__ ((warn_unused_result)) +#else +# define WARN_UNUSED_RESULT +#endif + +#endif /* ! GRUB_COMPILER_HEADER */ diff --git a/include/grub/dl.h b/include/grub/dl.h index d29a899f5..9562fa663 100644 --- a/include/grub/dl.h +++ b/include/grub/dl.h @@ -26,6 +26,7 @@ #include #include #include +#include #endif /* diff --git a/include/grub/list.h b/include/grub/list.h index edd20adfd..d170ff6da 100644 --- a/include/grub/list.h +++ b/include/grub/list.h @@ -21,8 +21,8 @@ #define GRUB_LIST_HEADER 1 #include -#include -#include +#include +#include struct grub_list { diff --git a/include/grub/misc.h b/include/grub/misc.h index 2cf74b550..c6cd4564d 100644 --- a/include/grub/misc.h +++ b/include/grub/misc.h @@ -25,34 +25,7 @@ #include #include #include - -/* GCC version checking borrowed from glibc. */ -#if defined(__GNUC__) && defined(__GNUC_MINOR__) -# define GNUC_PREREQ(maj,min) \ - ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min)) -#else -# define GNUC_PREREQ(maj,min) 0 -#endif - -/* Does this compiler support compile-time error attributes? */ -#if GNUC_PREREQ(4,3) -# define ATTRIBUTE_ERROR(msg) \ - __attribute__ ((__error__ (msg))) -#else -# define ATTRIBUTE_ERROR(msg) __attribute__ ((noreturn)) -#endif - -#if GNUC_PREREQ(4,4) -# define GNU_PRINTF gnu_printf -#else -# define GNU_PRINTF printf -#endif - -#if GNUC_PREREQ(3,4) -# define WARN_UNUSED_RESULT __attribute__ ((warn_unused_result)) -#else -# define WARN_UNUSED_RESULT -#endif +#include #define ALIGN_UP(addr, align) \ ((addr + (typeof (addr)) align - 1) & ~((typeof (addr)) align - 1)) diff --git a/include/grub/procfs.h b/include/grub/procfs.h index d393da77f..8cc331d94 100644 --- a/include/grub/procfs.h +++ b/include/grub/procfs.h @@ -20,6 +20,7 @@ #define GRUB_PROCFS_HEADER 1 #include +#include struct grub_procfs_entry { From 6c519b5c6c95a0d486c548157b2af3d4fb4e0bbe Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sat, 18 Jan 2014 19:26:40 +0100 Subject: [PATCH 027/722] * grub-core/commands/macbless.c: Rename FILE and DIR to avoid conflicts. Reported by: Andrey Borzenkov. --- ChangeLog | 7 +++++++ grub-core/commands/macbless.c | 6 +++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index dad469b43..9d1a3f051 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2014-01-18 Vladimir Serbinenko + + * grub-core/commands/macbless.c: Rename FILE and DIR to avoid + conflicts. + + Reported by: Andrey Borzenkov. + 2014-01-18 Andrey Borzenkov * include/grub/misc.h: Move macros for compiler features to ... diff --git a/grub-core/commands/macbless.c b/grub-core/commands/macbless.c index c5210833e..4724edd77 100644 --- a/grub-core/commands/macbless.c +++ b/grub-core/commands/macbless.c @@ -37,7 +37,7 @@ struct find_node_context grub_uint64_t inode_found; char *dirname; enum - { NONE, FILE, DIR } found; + { FOUND_NONE, FOUND_FILE, FOUND_DIR } found; }; static int @@ -53,7 +53,7 @@ find_inode (const char *filename, && grub_strcasecmp (ctx->dirname, filename) == 0))) { ctx->inode_found = info->inode; - ctx->found = info->dir ? DIR : FILE; + ctx->found = info->dir ? FOUND_DIR : FOUND_FILE; } return 0; } @@ -175,7 +175,7 @@ grub_mac_bless_file (grub_device_t dev, const char *path_in, int intel) grub_free (path); return grub_mac_bless_inode (dev, (grub_uint32_t) ctx.inode_found, - (ctx.found == DIR), intel); + (ctx.found == FOUND_DIR), intel); } static grub_err_t From 6ba983559dcffa0fa69c7fc861b5a16b4877a92c Mon Sep 17 00:00:00 2001 From: Mike Gilbert Date: Sat, 18 Jan 2014 19:41:15 +0100 Subject: [PATCH 028/722] * Makefile.util.def: Link grub-ofpathname with zfs libs. --- ChangeLog | 4 ++++ Makefile.util.def | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 9d1a3f051..edceb66db 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2014-01-01 Mike Gilbert + + * Makefile.util.def: Link grub-ofpathname with zfs libs. + 2014-01-18 Vladimir Serbinenko * grub-core/commands/macbless.c: Rename FILE and DIR to avoid diff --git a/Makefile.util.def b/Makefile.util.def index 83df212f4..a286a89cd 100644 --- a/Makefile.util.def +++ b/Makefile.util.def @@ -384,7 +384,7 @@ program = { ldadd = libgrubgcry.a; ldadd = libgrubkern.a; ldadd = grub-core/gnulib/libgnu.a; - ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBUTIL) $(LIBGEOM)'; + ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBUTIL) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)'; }; program = { From 0b47c57ad62e314fac9c77cc17bdea032f945fca Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sat, 18 Jan 2014 19:43:19 +0100 Subject: [PATCH 029/722] * Makefile.am (default_payload.elf): Add modules multiboot cbmemc linux16 gzio echo help. --- ChangeLog | 7 ++++++- Makefile.am | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index edceb66db..cff9386d3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,9 @@ -2014-01-01 Mike Gilbert +2014-01-18 Vladimir Serbinenko + + * Makefile.am (default_payload.elf): Add modules + multiboot cbmemc linux16 gzio echo help. + +2014-01-18 Mike Gilbert * Makefile.util.def: Link grub-ofpathname with zfs libs. diff --git a/Makefile.am b/Makefile.am index aa526f573..97c062d7d 100644 --- a/Makefile.am +++ b/Makefile.am @@ -399,7 +399,7 @@ bootcheck: $(BOOTCHECKS) if COND_i386_coreboot default_payload.elf: grub-mkstandalone grub-mkimage - pkgdatadir=. ./grub-mkstandalone --grub-mkimage=./grub-mkimage -O i386-coreboot -o $@ --modules='ahci pata ehci uhci ohci usb_keyboard usbms part_msdos xfs ext2 fat at_keyboard part_gpt usbserial_usbdebug cbfs' --install-modules='ls linux search configfile normal cbtime cbls memrw iorw minicmd lsmmap lspci halt reboot hexdump pcidump regexp setpci lsacpi chain test serial' --fonts= --themes= --locales= -d grub-core/ /boot/grub/grub.cfg=$(srcdir)/coreboot.cfg + pkgdatadir=. ./grub-mkstandalone --grub-mkimage=./grub-mkimage -O i386-coreboot -o $@ --modules='ahci pata ehci uhci ohci usb_keyboard usbms part_msdos xfs ext2 fat at_keyboard part_gpt usbserial_usbdebug cbfs' --install-modules='ls linux search configfile normal cbtime cbls memrw iorw minicmd lsmmap lspci halt reboot hexdump pcidump regexp setpci lsacpi chain test serial multiboot cbmemc linux16 gzio echo help' --fonts= --themes= --locales= -d grub-core/ /boot/grub/grub.cfg=$(srcdir)/coreboot.cfg endif windowsdir=$(top_builddir)/$(PACKAGE)-$(VERSION)-for-windows From e0a850947f541e5078304699106f9f66a79e4151 Mon Sep 17 00:00:00 2001 From: Andrey Borzenkov Date: Sat, 18 Jan 2014 22:48:04 +0400 Subject: [PATCH 030/722] fix removal of {cpu,machine} links on mingw/msys At least on Windows 2003 using "ln -s dir1 dir2" in msys shell succeeds, but results in what looks like hard link. Subsequent "rm -f dir2" (e.g. during second config.status invocation) fails. Check that we also can remove link to directory. Make it more clear in message that we are checking "ln -s". --- ChangeLog | 5 +++++ acinclude.m4 | 6 +++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index cff9386d3..c3bfa9fcb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2014-01-18 Andrey Borzenkov + + * acinclude.m4 (grub_CHECK_LINK_DIR): Check that we can also remove + symbolic link to directory. It fails in Msys shell on Windows 2003. + 2014-01-18 Vladimir Serbinenko * Makefile.am (default_payload.elf): Add modules diff --git a/acinclude.m4 b/acinclude.m4 index 32d5477d1..b2bb88d83 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -418,15 +418,15 @@ else [fi] ]) -dnl Check if ln can handle directories properly (mingw). +dnl Check if ln -s can handle directories properly (mingw). AC_DEFUN([grub_CHECK_LINK_DIR],[ -AC_MSG_CHECKING([whether ln can handle directories properly]) +AC_MSG_CHECKING([whether ln -s can handle directories properly]) [mkdir testdir 2>/dev/null case $srcdir in [\\/$]* | ?:[\\/]* ) reldir=$srcdir/include/grub/util ;; *) reldir=../$srcdir/include/grub/util ;; esac -if ln -s $reldir testdir/util 2>/dev/null ; then] +if ln -s $reldir testdir/util 2>/dev/null && rm -f testdir/util 2>/dev/null ; then] AC_MSG_RESULT([yes]) [link_dir=yes else From 41155a57223e346b990a3d1b6708fa85351ab256 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sat, 18 Jan 2014 19:54:09 +0100 Subject: [PATCH 031/722] * grub-core/normal/main.c (read_config_file): Buffer config file. Reduces boot time. --- ChangeLog | 5 +++++ grub-core/normal/main.c | 14 +++++++++++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index c3bfa9fcb..c84f7e7cc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2014-01-18 Vladimir Serbinenko + + * grub-core/normal/main.c (read_config_file): Buffer config file. + Reduces boot time. + 2014-01-18 Andrey Borzenkov * acinclude.m4 (grub_CHECK_LINK_DIR): Check that we can also remove diff --git a/grub-core/normal/main.c b/grub-core/normal/main.c index c36663f73..3a926fc5f 100644 --- a/grub-core/normal/main.c +++ b/grub-core/normal/main.c @@ -32,6 +32,7 @@ #include #include #include +#include GRUB_MOD_LICENSE ("GPLv3+"); @@ -104,7 +105,7 @@ read_config_file_getline (char **line, int cont __attribute__ ((unused)), static grub_menu_t read_config_file (const char *config) { - grub_file_t file; + grub_file_t rawfile, file; char *old_file = 0, *old_dir = 0; char *config_dir, *ptr = 0; const char *ctmp; @@ -122,10 +123,17 @@ read_config_file (const char *config) } /* Try to open the config file. */ - file = grub_file_open (config); - if (! file) + rawfile = grub_file_open (config); + if (! rawfile) return 0; + file = grub_bufio_open (rawfile, 0); + if (! file) + { + grub_file_close (file); + return 0; + } + ctmp = grub_env_get ("config_file"); if (ctmp) old_file = grub_strdup (ctmp); From b204b718cc00432f18be861b8bf4342e50feef90 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sat, 18 Jan 2014 20:02:51 +0100 Subject: [PATCH 032/722] * util/grub-install.c: Fix a typo. --- ChangeLog | 4 ++++ util/grub-install.c | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index c84f7e7cc..9360345ef 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2014-01-18 Vladimir Serbinenko + + * util/grub-install.c: Fix a typo. + 2014-01-18 Vladimir Serbinenko * grub-core/normal/main.c (read_config_file): Buffer config file. diff --git a/util/grub-install.c b/util/grub-install.c index 4608b80fe..5903f340a 100644 --- a/util/grub-install.c +++ b/util/grub-install.c @@ -1259,7 +1259,7 @@ main (int argc, char *argv[]) if (!config.is_cryptodisk_enabled && have_cryptodisk) grub_util_error (_("attempt to install to encrypted disk without cryptodisk enabled. " - "Set `%s' in file `%s'."), "GRUB_ENABLE_CRYPTODISK=1", + "Set `%s' in file `%s'."), "GRUB_ENABLE_CRYPTODISK=y", grub_util_get_config_filename ()); if (disk_module && grub_strcmp (disk_module, "ata") == 0) From 015045471ed815fc45ba9fba52cb34582d129a96 Mon Sep 17 00:00:00 2001 From: Andrey Borzenkov Date: Sat, 18 Jan 2014 23:15:40 +0400 Subject: [PATCH 033/722] use MODULE_FILES for genemuinit* instead of MOD_FILES MinGW native nm does not support ELF binaries. --- ChangeLog | 8 ++++++++ grub-core/Makefile.am | 8 ++++---- grub-core/genemuinit.sh | 4 ++-- grub-core/genemuinitheader.sh | 4 ++-- 4 files changed, 16 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9360345ef..4688ff4e6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2014-01-18 Andrey Borzenkov + + * grub-core/Makefile.am: Build grub_emu_init.[ch] from MODULE_FILES + instead of MOD_FILES. + * grub-core/genemuinit.sh: Simplify stripping of suffix so it works + both with and without .exe. + * grub-core/genemuinitheader.sh: Same. + 2014-01-18 Vladimir Serbinenko * util/grub-install.c: Fix a typo. diff --git a/grub-core/Makefile.am b/grub-core/Makefile.am index 826b3dd7c..5c087c83b 100644 --- a/grub-core/Makefile.am +++ b/grub-core/Makefile.am @@ -294,12 +294,12 @@ grub_emu-grub_emu_init.$(OBJEXT):grub_emu_init.h kern/emu/grub_emu_dyn-main.$(OBJEXT):grub_emu_init.h grub_emu_dyn-grub_emu_init.$(OBJEXT):grub_emu_init.h -grub_emu_init.h: genemuinitheader.sh $(MOD_FILES) - rm -f $@; echo $(MOD_FILES) | sh $(srcdir)/genemuinitheader.sh $(TARGET_NM) > $@ +grub_emu_init.h: genemuinitheader.sh $(MODULE_FILES) + rm -f $@; echo $(MODULE_FILES) | sh $(srcdir)/genemuinitheader.sh $(TARGET_NM) > $@ CLEANFILES += grub_emu_init.h -grub_emu_init.c: grub_emu_init.h genemuinit.sh $(MOD_FILES) - rm -f $@; echo $(MOD_FILES) | sh $(srcdir)/genemuinit.sh $(TARGET_NM) > $@ +grub_emu_init.c: grub_emu_init.h genemuinit.sh $(MODULE_FILES) + rm -f $@; echo $(MODULE_FILES) | sh $(srcdir)/genemuinit.sh $(TARGET_NM) > $@ CLEANFILES += grub_emu_init.c endif diff --git a/grub-core/genemuinit.sh b/grub-core/genemuinit.sh index 45c15ecb9..8c6bb1c18 100644 --- a/grub-core/genemuinit.sh +++ b/grub-core/genemuinit.sh @@ -47,7 +47,7 @@ EOF read mods for line in $mods; do if ${nm} --defined-only -P -p ${line} | grep grub_mod_init > /dev/null; then - echo "grub_${line}_init ();" | sed 's,\.mod,,g;' + echo "grub_${line%%.*}_init ();" fi done @@ -63,7 +63,7 @@ EOF for line in $mods; do if ${nm} --defined-only -P -p ${line} | grep grub_mod_fini > /dev/null; then - echo "grub_${line}_fini ();" | sed 's,\.mod,,g;' + echo "grub_${line%%.*}_fini ();" fi done diff --git a/grub-core/genemuinitheader.sh b/grub-core/genemuinitheader.sh index 6b83f5993..a99a15d06 100644 --- a/grub-core/genemuinitheader.sh +++ b/grub-core/genemuinitheader.sh @@ -44,9 +44,9 @@ EOF read mods for line in $mods; do if ${nm} --defined-only -P -p ${line} | grep grub_mod_init > /dev/null; then - echo "void grub_${line}_init (void);" | sed 's,\.mod,,g;' + echo "void grub_${line%%.*}_init (void);" fi if ${nm} --defined-only -P -p ${line} | grep grub_mod_fini > /dev/null; then - echo "void grub_${line}_fini (void);" | sed 's,\.mod,,g;' + echo "void grub_${line%%.*}_fini (void);" fi done From 049f63824c654ca10dc9073decc139ccd2f9a06b Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Fri, 17 Jan 2014 02:28:46 +0000 Subject: [PATCH 034/722] Ignore EPERM when modifying kern.geom.debugflags Many tests fail when run as a non-root user on FreeBSD. The failures all amount to an inability to open files using grub_util_fd_open, because we cannot set the kern.geom.debugflags sysctl. This sysctl is indeed important to allow us to do such things as installing GRUB to the MBR, but if we need to do that and can't then we will get an error later. Enforcing it here is unnecessary and prevents otherwise perfectly reasonable operations. --- ChangeLog | 7 +++++++ grub-core/osdep/freebsd/hostdisk.c | 12 ++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4688ff4e6..10abfe28f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2014-01-19 Colin Watson + + * grub-core/osdep/freebsd/hostdisk.c (grub_util_fd_open): Ignore + EPERM when modifying kern.geom.debugflags. It is only a problem for + such things as installing GRUB to the MBR, in which case there'll be + an error later anyway, not for opening files during tests. + 2014-01-18 Andrey Borzenkov * grub-core/Makefile.am: Build grub_emu_init.[ch] from MODULE_FILES diff --git a/grub-core/osdep/freebsd/hostdisk.c b/grub-core/osdep/freebsd/hostdisk.c index eb202dcc8..6145d0735 100644 --- a/grub-core/osdep/freebsd/hostdisk.c +++ b/grub-core/osdep/freebsd/hostdisk.c @@ -102,8 +102,16 @@ grub_util_fd_open (const char *os_dev, int flags) if (! (sysctl_oldflags & 0x10) && sysctlbyname ("kern.geom.debugflags", NULL , 0, &sysctl_flags, sysctl_size)) { - grub_error (GRUB_ERR_BAD_DEVICE, "cannot set flags of sysctl kern.geom.debugflags"); - return GRUB_UTIL_FD_INVALID; + if (errno == EPERM) + /* Running as an unprivileged user; don't worry about restoring + flags, although if we try to write to anything interesting such + as the MBR then we may fail later. */ + sysctl_oldflags = 0x10; + else + { + grub_error (GRUB_ERR_BAD_DEVICE, "cannot set flags of sysctl kern.geom.debugflags"); + return GRUB_UTIL_FD_INVALID; + } } ret = open (os_dev, flags, S_IROTH | S_IRGRP | S_IRUSR | S_IWUSR); From d99d2f84166b0f60673d5c0714605a153946c0fc Mon Sep 17 00:00:00 2001 From: Paulo Flabiano Smorigo Date: Tue, 21 Jan 2014 10:49:39 -0200 Subject: [PATCH 035/722] change stop condition to avoid infinite loops In net/net.c there is a while (1) that only exits if there is a stop condition and more then 10 packages or if there is no package received. If GRUB is idle and enter in this loop, the only condition to leave is if it doesn't have incoming packages. In a network with heavy traffic this never happens. --- ChangeLog | 12 ++++++++++++ grub-core/net/net.c | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 10abfe28f..f69d8c7e0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2014-01-21 Paulo Flabiano Smorigo + + * grub-core/net/net.c (receive_packets): Change stop condition to avoid + infinite loops. + + In net/net.c there is a while (1) that only exits if there is a stop + condition and more then 10 packages or if there is no package received. + + If GRUB is idle and enter in this loop, the only condition to leave is + if it doesn't have incoming packages. In a network with heavy traffic + this never happens. + 2014-01-19 Colin Watson * grub-core/osdep/freebsd/hostdisk.c (grub_util_fd_open): Ignore diff --git a/grub-core/net/net.c b/grub-core/net/net.c index 0e57e93e8..56355f3c9 100644 --- a/grub-core/net/net.c +++ b/grub-core/net/net.c @@ -1453,7 +1453,7 @@ receive_packets (struct grub_net_card *card, int *stop_condition) } card->opened = 1; } - while (1) + while (received < 100) { /* Maybe should be better have a fixed number of packets for each card and just mark them as used and not used. */ From 6f65e36cc4f92fe40672181eccf12eac4afb6738 Mon Sep 17 00:00:00 2001 From: Paulo Flabiano Smorigo Date: Tue, 21 Jan 2014 11:03:51 -0200 Subject: [PATCH 036/722] increase network try interval gradually * grub-core/net/arp.c (grub_net_arp_send_request): Increase network try interval gradually. * grub-core/net/icmp6.c (grub_net_icmp6_send_request): Likewise. * grub-core/net/net.c (grub_net_fs_read_real): Likewise. * grub-core/net/tftp.c (tftp_open): Likewise. * include/grub/net.h (GRUB_NET_INTERVAL_ADDITION): New define. --- ChangeLog | 9 +++++++++ grub-core/net/arp.c | 3 ++- grub-core/net/icmp6.c | 3 ++- grub-core/net/net.c | 5 +++-- grub-core/net/tftp.c | 3 ++- include/grub/net.h | 1 + 6 files changed, 19 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index f69d8c7e0..f5618a6eb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2014-01-21 Paulo Flabiano Smorigo + + * grub-core/net/arp.c (grub_net_arp_send_request): Increase network try + interval gradually. + * grub-core/net/icmp6.c (grub_net_icmp6_send_request): Likewise. + * grub-core/net/net.c (grub_net_fs_read_real): Likewise. + * grub-core/net/tftp.c (tftp_open): Likewise. + * include/grub/net.h (GRUB_NET_INTERVAL_ADDITION): New define. + 2014-01-21 Paulo Flabiano Smorigo * grub-core/net/net.c (receive_packets): Change stop condition to avoid diff --git a/grub-core/net/arp.c b/grub-core/net/arp.c index e92c7e7da..d62d0cc1e 100644 --- a/grub-core/net/arp.c +++ b/grub-core/net/arp.c @@ -110,7 +110,8 @@ grub_net_arp_send_request (struct grub_net_network_level_interface *inf, return GRUB_ERR_NONE; pending_req = proto_addr->ipv4; have_pending = 0; - grub_net_poll_cards (GRUB_NET_INTERVAL, &have_pending); + grub_net_poll_cards (GRUB_NET_INTERVAL + (i * GRUB_NET_INTERVAL_ADDITION), + &have_pending); if (grub_net_link_layer_resolve_check (inf, proto_addr)) return GRUB_ERR_NONE; nb.data = nbd; diff --git a/grub-core/net/icmp6.c b/grub-core/net/icmp6.c index 2741e6f11..bbc902014 100644 --- a/grub-core/net/icmp6.c +++ b/grub-core/net/icmp6.c @@ -518,7 +518,8 @@ grub_net_icmp6_send_request (struct grub_net_network_level_interface *inf, { if (grub_net_link_layer_resolve_check (inf, proto_addr)) break; - grub_net_poll_cards (GRUB_NET_INTERVAL, 0); + grub_net_poll_cards (GRUB_NET_INTERVAL + (i * GRUB_NET_INTERVAL_ADDITION), + 0); if (grub_net_link_layer_resolve_check (inf, proto_addr)) break; nb->data = nbd; diff --git a/grub-core/net/net.c b/grub-core/net/net.c index 56355f3c9..1521d8d2c 100644 --- a/grub-core/net/net.c +++ b/grub-core/net/net.c @@ -1558,8 +1558,9 @@ grub_net_fs_read_real (grub_file_t file, char *buf, grub_size_t len) if (!net->eof) { try++; - grub_net_poll_cards (GRUB_NET_INTERVAL, &net->stall); - } + grub_net_poll_cards (GRUB_NET_INTERVAL + + (try * GRUB_NET_INTERVAL_ADDITION), &net->stall); + } else return total; } diff --git a/grub-core/net/tftp.c b/grub-core/net/tftp.c index 9c489f1fc..517361427 100644 --- a/grub-core/net/tftp.c +++ b/grub-core/net/tftp.c @@ -398,7 +398,8 @@ tftp_open (struct grub_file *file, const char *filename) destroy_pq (data); return err; } - grub_net_poll_cards (GRUB_NET_INTERVAL, &data->have_oack); + grub_net_poll_cards (GRUB_NET_INTERVAL + (i * GRUB_NET_INTERVAL_ADDITION), + &data->have_oack); if (data->have_oack) break; } diff --git a/include/grub/net.h b/include/grub/net.h index de6259ee1..0e0a605c5 100644 --- a/include/grub/net.h +++ b/include/grub/net.h @@ -532,5 +532,6 @@ extern char *grub_net_default_server; #define GRUB_NET_TRIES 40 #define GRUB_NET_INTERVAL 400 +#define GRUB_NET_INTERVAL_ADDITION 20 #endif /* ! GRUB_NET_HEADER */ From 36387ece6be1b912c778d4a5f068801f99385fa2 Mon Sep 17 00:00:00 2001 From: Andrey Borzenkov Date: Tue, 21 Jan 2014 19:29:33 +0400 Subject: [PATCH 037/722] look for DejaVu also in /usr/share/fonts/truetype It is installed in this path on openSUSE. --- ChangeLog | 4 ++++ configure.ac | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index f5618a6eb..9f5d81dfb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2014-01-21 Andrey Borzenkov + + * configure.ac: Look for DejaVuSans also in /usr/share/fonts/truetype. + 2014-01-21 Paulo Flabiano Smorigo * grub-core/net/arp.c (grub_net_arp_send_request): Increase network try diff --git a/configure.ac b/configure.ac index cf3de3be1..120263e9c 100644 --- a/configure.ac +++ b/configure.ac @@ -1389,7 +1389,7 @@ fi if test x"$starfield_excuse" = x; then for ext in pcf pcf.gz bdf bdf.gz ttf ttf.gz; do - for dir in . /usr/src /usr/share/fonts/X11/misc /usr/share/fonts/truetype/ttf-dejavu /usr/share/fonts/dejavu; do + for dir in . /usr/src /usr/share/fonts/X11/misc /usr/share/fonts/truetype/ttf-dejavu /usr/share/fonts/dejavu /usr/share/fonts/truetype; do if test -f "$dir/DejaVuSans.$ext"; then DJVU_FONT_SOURCE="$dir/DejaVuSans.$ext" break 2 From 443b3222621b6df1e5e01bd6fb2c496568065f92 Mon Sep 17 00:00:00 2001 From: Andrey Borzenkov Date: Tue, 21 Jan 2014 19:41:11 +0400 Subject: [PATCH 038/722] Show detected path to DejaVuSans in configure summary --- ChangeLog | 1 + configure.ac | 1 + 2 files changed, 2 insertions(+) diff --git a/ChangeLog b/ChangeLog index 9f5d81dfb..3ba57aed8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,7 @@ 2014-01-21 Andrey Borzenkov * configure.ac: Look for DejaVuSans also in /usr/share/fonts/truetype. + Show detected font path in summary. 2014-01-21 Paulo Flabiano Smorigo diff --git a/configure.ac b/configure.ac index 120263e9c..8888c2ff2 100644 --- a/configure.ac +++ b/configure.ac @@ -1816,6 +1816,7 @@ echo grub-mount: No "($grub_mount_excuse)" fi if [ x"$starfield_excuse" = x ]; then echo starfield theme: Yes +echo With DejaVuSans font from $DJVU_FONT_SOURCE else echo starfield theme: No "($starfield_excuse)" fi From eec4237a3265b024cc97d3cd287bdea7cd187f48 Mon Sep 17 00:00:00 2001 From: Andrey Borzenkov Date: Tue, 21 Jan 2014 20:54:09 +0400 Subject: [PATCH 039/722] add GRUB_WINDOWS_EXTRA_DIST to allow shipping runtime files Not all toolkits provide static libraries. This patch enables creation of self contained distribution that does not require pre-existing runtime libraries. Intended usage is export GRUB_WINDOWS_EXTRA_DIST="/path/to/liblzma.dll /path/to/libintl.dll" make make windowszip As those libraries and locations are dependent on toolchain in use, trying to autodetect them is likely impossible. So just provide a simple way to package everything in one step. Also remove $(windowsdir) after ZIP was created same as other "make dist" targets. --- ChangeLog | 5 +++++ Makefile.am | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/ChangeLog b/ChangeLog index 3ba57aed8..1ede37091 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2014-01-21 Andrey Borzenkov + + * Makefile.am: Allow adding extra files to generated Windows ZIP + archive by setting GRUB_WINDOWS_EXTRA_DIST. + 2014-01-21 Andrey Borzenkov * configure.ac: Look for DejaVuSans also in /usr/share/fonts/truetype. diff --git a/Makefile.am b/Makefile.am index 97c062d7d..f02ae0a39 100644 --- a/Makefile.am +++ b/Makefile.am @@ -420,10 +420,14 @@ windowsdir: $(PROGRAMS) $(starfield_DATA) $(platform_DATA) for x in $(starfield_DATA); do \ cp -fp $$x $(windowsdir)/themes/starfield/$$(basename $$x); \ done + for x in $(GRUB_WINDOWS_EXTRA_DIST); do \ + cp -fp $$x $(windowsdir); \ + done windowszip=$(top_builddir)/$(PACKAGE)-$(VERSION)-for-windows.zip windowszip: windowsdir test -f $(windowszip) && rm $(windowszip) || true zip -r $(windowszip) $(windowsdir) + rm -rf $(windowsdir) EXTRA_DIST += linguas.sh From d08059309f83388312b7f3e533f4b70d803f7bda Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Thu, 23 Jan 2014 12:05:36 +0000 Subject: [PATCH 040/722] * util/grub-install.c (write_to_disk): Add an info message. --- ChangeLog | 4 ++++ util/grub-install.c | 1 + 2 files changed, 5 insertions(+) diff --git a/ChangeLog b/ChangeLog index 1ede37091..eee8e78a7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2014-01-23 Colin Watson + + * util/grub-install.c (write_to_disk): Add an info message. + 2014-01-21 Andrey Borzenkov * Makefile.am: Allow adding extra files to generated Windows ZIP diff --git a/util/grub-install.c b/util/grub-install.c index 5903f340a..787dc90fc 100644 --- a/util/grub-install.c +++ b/util/grub-install.c @@ -675,6 +675,7 @@ write_to_disk (grub_device_t dev, const char *fn) core_img = grub_util_read_image (fn); + grub_util_info ("writing `%s' to `%s'", fn, dev->disk->name); err = grub_disk_write (dev->disk, 0, 0, core_size, core_img); free (core_img); From 95cd131ea0085ce16a4f2bfabc22d83548fc85cf Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 24 Jan 2014 18:09:25 +0100 Subject: [PATCH 041/722] * util/grub-install.c: List available targets. --- ChangeLog | 4 ++++ include/grub/util/install.h | 2 ++ util/grub-install-common.c | 30 ++++++++++++++++++++++++++++++ util/grub-install.c | 10 ++++++++-- 4 files changed, 44 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index eee8e78a7..20e8baaa2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2014-01-24 Vladimir Serbinenko + + * util/grub-install.c: List available targets. + 2014-01-23 Colin Watson * util/grub-install.c (write_to_disk): Add an info message. diff --git a/include/grub/util/install.h b/include/grub/util/install.h index bc987aadc..aedcd29f9 100644 --- a/include/grub/util/install.h +++ b/include/grub/util/install.h @@ -138,6 +138,8 @@ grub_install_get_platform_cpu (enum grub_install_plat platid); const char * grub_install_get_platform_platform (enum grub_install_plat platid); +char * +grub_install_get_platforms_string (void); typedef enum { GRUB_COMPRESSION_AUTO, diff --git a/util/grub-install-common.c b/util/grub-install-common.c index 6ea0a8e17..c8bedcb2e 100644 --- a/util/grub-install-common.c +++ b/util/grub-install-common.c @@ -667,6 +667,36 @@ static struct [GRUB_INSTALL_PLATFORM_ARM_UBOOT] = { "arm", "uboot" }, }; +char * +grub_install_get_platforms_string (void) +{ + char **arr = xmalloc (sizeof (char *) * ARRAY_SIZE (platforms)); + int platform_strins_len = 0; + char *platforms_string; + char *ptr; + unsigned i; + for (i = 0; i < ARRAY_SIZE (platforms); i++) + { + arr[i] = xasprintf ("%s-%s", platforms[i].cpu, + platforms[i].platform); + platform_strins_len += strlen (arr[i]) + 2; + } + ptr = platforms_string = xmalloc (platform_strins_len); + qsort (arr, ARRAY_SIZE (platforms), sizeof (char *), grub_qsort_strcmp); + for (i = 0; i < ARRAY_SIZE (platforms); i++) + { + strcpy (ptr, arr[i]); + ptr += strlen (arr[i]); + *ptr++ = ','; + *ptr++ = ' '; + free (arr[i]); + } + ptr[-2] = 0; + free (arr); + + return platforms_string; +} + char * grub_install_get_platform_name (enum grub_install_plat platid) { diff --git a/util/grub-install.c b/util/grub-install.c index 787dc90fc..2e6226a37 100644 --- a/util/grub-install.c +++ b/util/grub-install.c @@ -256,7 +256,7 @@ static struct argp_option options[] = { OPTION_HIDDEN, 0, 2}, {"target", OPTION_TARGET, N_("TARGET"), /* TRANSLATORS: "TARGET" as in "target platform". */ - 0, N_("install GRUB for TARGET platform [default=%s]"), 2}, + 0, N_("install GRUB for TARGET platform [default=%s]; available targets: %s"), 2}, {"grub-setup", OPTION_SETUP, "FILE", OPTION_HIDDEN, 0, 2}, {"grub-mkrelpath", OPTION_MKRELPATH, "FILE", OPTION_HIDDEN, 0, 2}, {"grub-mkdevicemap", OPTION_MKDEVICEMAP, "FILE", OPTION_HIDDEN, 0, 2}, @@ -340,7 +340,13 @@ help_filter (int key, const char *text, void *input __attribute__ ((unused))) case OPTION_BOOT_DIRECTORY: return xasprintf (text, GRUB_DIR_NAME, GRUB_BOOT_DIR_NAME "/" GRUB_DIR_NAME); case OPTION_TARGET: - return xasprintf (text, get_default_platform ()); + { + char *plats = grub_install_get_platforms_string (); + char *ret; + ret = xasprintf (text, get_default_platform (), plats); + free (plats); + return ret; + } case ARGP_KEY_HELP_POST_DOC: return xasprintf (text, program_name, GRUB_BOOT_DIR_NAME "/" GRUB_DIR_NAME); default: From 61c8482b2097dfc08d76c36a1087bc3d243f4db1 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 24 Jan 2014 18:20:27 +0100 Subject: [PATCH 042/722] Fix several translatable strings. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Suggested by: D. Prévot. --- ChangeLog | 6 ++++++ grub-core/commands/syslinuxcfg.c | 2 +- grub-core/loader/arm64/linux.c | 2 +- util/grub-syslinux2cfg.c | 4 ++-- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 20e8baaa2..e149d8ef3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2014-01-24 Vladimir Serbinenko + + Fix several translatable strings. + + Suggested by: D. Prévot. + 2014-01-24 Vladimir Serbinenko * util/grub-install.c: List available targets. diff --git a/grub-core/commands/syslinuxcfg.c b/grub-core/commands/syslinuxcfg.c index a4bfc40b6..00ae113c5 100644 --- a/grub-core/commands/syslinuxcfg.c +++ b/grub-core/commands/syslinuxcfg.c @@ -50,7 +50,7 @@ static const struct grub_arg_option options[] = N_("root directory of the syslinux disk [default=/]."), N_("DIR"), ARG_TYPE_STRING}, {"cwd", 'c', 0, - N_("current directory of the syslinux [default is parent directory of input file]."), + N_("current directory of syslinux [default is parent directory of input file]."), N_("DIR"), ARG_TYPE_STRING}, {"isolinux", 'i', 0, N_("assume input is an isolinux configuration file."), 0, 0}, {"pxelinux", 'p', 0, N_("assume input is a pxelinux configuration file."), 0, 0}, diff --git a/grub-core/loader/arm64/linux.c b/grub-core/loader/arm64/linux.c index 75ad871a8..65129c21a 100644 --- a/grub-core/loader/arm64/linux.c +++ b/grub-core/loader/arm64/linux.c @@ -120,7 +120,7 @@ check_kernel (struct grub_arm64_linux_kernel_header *lh) if ((lh->code0 & 0xffff) != GRUB_EFI_PE_MAGIC) return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, - N_("plain Image kernel not supported - rebuild with CONFIG_(U)EFI_STUB enabled")); + N_("plain image kernel not supported - rebuild with CONFIG_(U)EFI_STUB enabled")); grub_dprintf ("linux", "UEFI stub kernel:\n"); grub_dprintf ("linux", "text_offset = 0x%012llx\n", diff --git a/util/grub-syslinux2cfg.c b/util/grub-syslinux2cfg.c index 5e944c20a..f4fda6db9 100644 --- a/util/grub-syslinux2cfg.c +++ b/util/grub-syslinux2cfg.c @@ -66,10 +66,10 @@ static struct argp_option options[] = { N_("root directory of the syslinux disk [default=/]."), 0}, {"target-cwd", 'T', N_("DIR"), 0, N_( - "current directory of the syslinux as it will be seen on runtime [default is parent directory of input file]." + "current directory of syslinux as it will be seen on runtime [default is parent directory of input file]." ), 0}, {"cwd", 'c', N_("DIR"), 0, - N_("current directory of the syslinux [default is parent directory of input file]."), 0}, + N_("current directory of syslinux [default is parent directory of input file]."), 0}, {"output", 'o', N_("FILE"), 0, N_("write output to FILE [default=stdout]."), 0}, {"isolinux", 'i', 0, 0, N_("assume input is an isolinux configuration file."), 0}, From 1440b7ebae47e1cb710e920bec9d88c4d75ff432 Mon Sep 17 00:00:00 2001 From: Andrey Borzenkov Date: Sat, 25 Jan 2014 19:54:51 +0400 Subject: [PATCH 043/722] do not set default prefix in grub-mkimage Default prefix is likely wrong on Unix and completely wrong on Windows. Let caller set it explicitly to avoid any ambiguity. --- ChangeLog | 4 ++++ util/grub-mkimage.c | 16 +++++++++++----- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index e149d8ef3..b405b7ee5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2014-01-25 Andrey Borzenkov + + * util/grub-mkimage.c: Make prefix argument mandatory. + 2014-01-24 Vladimir Serbinenko Fix several translatable strings. diff --git a/util/grub-mkimage.c b/util/grub-mkimage.c index a2bd4c196..1e0bcf1bf 100644 --- a/util/grub-mkimage.c +++ b/util/grub-mkimage.c @@ -64,7 +64,7 @@ static struct argp_option options[] = { {"directory", 'd', N_("DIR"), 0, /* TRANSLATORS: platform here isn't identifier. It can be translated. */ N_("use images and modules under DIR [default=%s/]"), 0}, - {"prefix", 'p', N_("DIR"), 0, N_("set prefix directory [default=%s]"), 0}, + {"prefix", 'p', N_("DIR"), 0, N_("set prefix directory"), 0}, {"memdisk", 'm', N_("FILE"), 0, /* TRANSLATORS: "memdisk" here isn't an identifier, it can be translated. "embed" is a verb (command description). "*/ @@ -93,8 +93,6 @@ help_filter (int key, const char *text, void *input __attribute__ ((unused))) { case 'd': return xasprintf (text, grub_util_get_pkglibdir ()); - case 'p': - return xasprintf (text, DEFAULT_DIRECTORY); case 'O': { char *formats = grub_install_get_image_targets_string (), *ret; @@ -268,6 +266,15 @@ main (int argc, char *argv[]) exit(1); } + if (!arguments.prefix) + { + char *program = xstrdup(program_name); + printf ("%s\n", _("Prefix not specified (use the -p option).")); + argp_help (&argp, stderr, ARGP_HELP_STD_USAGE, program); + free (program); + exit(1); + } + if (arguments.output) { fp = grub_util_fopen (arguments.output, "wb"); @@ -287,8 +294,7 @@ main (int argc, char *argv[]) strcpy (ptr, dn); } - grub_install_generate_image (arguments.dir, - arguments.prefix ? : DEFAULT_DIRECTORY, fp, + grub_install_generate_image (arguments.dir, arguments.prefix, fp, arguments.output, arguments.modules, arguments.memdisk, arguments.pubkeys, arguments.npubkeys, arguments.config, From 5ae584c0b0c64b445c0820037d74058595133af3 Mon Sep 17 00:00:00 2001 From: Andrey Borzenkov Date: Sat, 25 Jan 2014 21:49:41 +0400 Subject: [PATCH 044/722] fix Mingw W64-32 cross compile failure due to printf redefinition in libintl.h In file included from util/misc.c:36:0: ./include/grub/emu/misc.h:56:1: error: 'libintl_printf' is an unrecognized format function type [-Werror=format=] char * EXPORT_FUNC(xasprintf) (const char *fmt, ...) __attribute__ ((format (printf, 1, 2))) WARN_UNUSED_RESULT; ^ ./include/grub/emu/misc.h:58:1: error: 'libintl_printf' is an unrecognized format function type [-Werror=format=] The reason is libintl.h which redefines printf as libintl_printf. The problem is not present in native MinGW build which avoids redefinition. Use (format (__printf__) instead which is valid replacement in GCC. v2: add grub-core/lib/libgcrypt/src/g10lib.h v3: modify g10lib.h during import --- ChangeLog | 9 +++++++++ include/grub/crypto.h | 2 +- include/grub/emu/misc.h | 8 ++++---- include/grub/err.h | 2 +- util/import_gcry.py | 6 ++++++ 5 files changed, 21 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index b405b7ee5..c93f11fbb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ + +2014-01-25 Andrey Borzenkov + + * include/grub/crypto.h: Replace __attribute__ ((format (printf)) with + __attribute__ ((format (__printf__)) to fix compilation under MinGW-w64. + * include/grub/emu/misc.h: ... and here. + * include/grub/err.h: ... and here. + * util/import_gcry.py: ... and here (in files g10lib.h). + 2014-01-25 Andrey Borzenkov * util/grub-mkimage.c: Make prefix argument mandatory. diff --git a/include/grub/crypto.h b/include/grub/crypto.h index ec1b980d2..a24e89dd9 100644 --- a/include/grub/crypto.h +++ b/include/grub/crypto.h @@ -408,7 +408,7 @@ void _gcry_assert_failed (const char *expr, const char *file, int line, const char *func) __attribute__ ((noreturn)); void _gcry_burn_stack (int bytes); -void _gcry_log_error( const char *fmt, ... ) __attribute__ ((format (printf, 1, 2))); +void _gcry_log_error( const char *fmt, ... ) __attribute__ ((format (__printf__, 1, 2))); #ifdef GRUB_UTIL diff --git a/include/grub/emu/misc.h b/include/grub/emu/misc.h index dde48c192..a588ba21d 100644 --- a/include/grub/emu/misc.h +++ b/include/grub/emu/misc.h @@ -53,11 +53,11 @@ grub_util_device_is_mapped (const char *dev); void * EXPORT_FUNC(xmalloc) (grub_size_t size) WARN_UNUSED_RESULT; void * EXPORT_FUNC(xrealloc) (void *ptr, grub_size_t size) WARN_UNUSED_RESULT; char * EXPORT_FUNC(xstrdup) (const char *str) WARN_UNUSED_RESULT; -char * EXPORT_FUNC(xasprintf) (const char *fmt, ...) __attribute__ ((format (printf, 1, 2))) WARN_UNUSED_RESULT; +char * EXPORT_FUNC(xasprintf) (const char *fmt, ...) __attribute__ ((format (__printf__, 1, 2))) WARN_UNUSED_RESULT; -void EXPORT_FUNC(grub_util_warn) (const char *fmt, ...) __attribute__ ((format (printf, 1, 2))); -void EXPORT_FUNC(grub_util_info) (const char *fmt, ...) __attribute__ ((format (printf, 1, 2))); -void EXPORT_FUNC(grub_util_error) (const char *fmt, ...) __attribute__ ((format (printf, 1, 2), noreturn)); +void EXPORT_FUNC(grub_util_warn) (const char *fmt, ...) __attribute__ ((format (__printf__, 1, 2))); +void EXPORT_FUNC(grub_util_info) (const char *fmt, ...) __attribute__ ((format (__printf__, 1, 2))); +void EXPORT_FUNC(grub_util_error) (const char *fmt, ...) __attribute__ ((format (__printf__, 1, 2), noreturn)); grub_uint64_t EXPORT_FUNC (grub_util_get_cpu_time_ms) (void); diff --git a/include/grub/err.h b/include/grub/err.h index 9896fccf9..1590c688e 100644 --- a/include/grub/err.h +++ b/include/grub/err.h @@ -91,6 +91,6 @@ int EXPORT_FUNC(grub_error_pop) (void); void EXPORT_FUNC(grub_print_error) (void); extern int EXPORT_VAR(grub_err_printed_errors); int grub_err_printf (const char *fmt, ...) - __attribute__ ((format (printf, 1, 2))); + __attribute__ ((format (__printf__, 1, 2))); #endif /* ! GRUB_ERR_HEADER */ diff --git a/util/import_gcry.py b/util/import_gcry.py index 63ebb90f1..2b3322d3a 100644 --- a/util/import_gcry.py +++ b/util/import_gcry.py @@ -534,6 +534,12 @@ for src in sorted (os.listdir (os.path.join (indir, "src"))): fw.close () continue + if src == "g10lib.h": + fw.write (f.read ().replace ("(printf,f,a)", "(__printf__,f,a)")) + f.close () + fw.close () + continue + fw.write (f.read ()) f.close () fw.close () From 9afe2053c9b37820888bd5e77acd35c0eacf6699 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sun, 26 Jan 2014 02:36:05 +0100 Subject: [PATCH 045/722] * grub-core/term/serial.c (grub_serial_register): Fix invalid free. Ensure that pointers are inited to NULL and that pointers are not accessed after free. --- ChangeLog | 5 +++++ grub-core/term/serial.c | 8 ++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index c93f11fbb..67b4d5c2a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2014-01-26 Vladimir Serbinenko + + * grub-core/term/serial.c (grub_serial_register): Fix invalid free. + Ensure that pointers are inited to NULL and that pointers are not + accessed after free. 2014-01-25 Andrey Borzenkov diff --git a/grub-core/term/serial.c b/grub-core/term/serial.c index b581a763e..c9b5574ae 100644 --- a/grub-core/term/serial.c +++ b/grub-core/term/serial.c @@ -338,23 +338,23 @@ grub_serial_register (struct grub_serial_port *port) grub_free (indata); return grub_errno; } - - out = grub_malloc (sizeof (*out)); + + out = grub_zalloc (sizeof (*out)); if (!out) { - grub_free (in); grub_free (indata); grub_free ((char *) in->name); + grub_free (in); return grub_errno; } outdata = grub_malloc (sizeof (*outdata)); if (!outdata) { - grub_free (in); grub_free (indata); grub_free ((char *) in->name); grub_free (out); + grub_free (in); return grub_errno; } From 35f2d96c0d68772c831952b2ee4eba6519d6ea1b Mon Sep 17 00:00:00 2001 From: Mike Gilbert Date: Sun, 26 Jan 2014 02:56:04 +0100 Subject: [PATCH 046/722] grub-install: support for partitioned partx loop devices. * grub-core/osdep/linux/getroot.c (grub_util_part_to_disk): Detect /dev/loopX as being the parent of /dev/loopXpY. --- ChangeLog | 7 +++++++ grub-core/osdep/linux/getroot.c | 13 +++++++++++++ 2 files changed, 20 insertions(+) diff --git a/ChangeLog b/ChangeLog index 67b4d5c2a..bbec1e70b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2014-01-26 Mike Gilbert + + grub-install: support for partitioned partx loop devices. + + * grub-core/osdep/linux/getroot.c (grub_util_part_to_disk): Detect + /dev/loopX as being the parent of /dev/loopXpY. + 2014-01-26 Vladimir Serbinenko * grub-core/term/serial.c (grub_serial_register): Fix invalid free. diff --git a/grub-core/osdep/linux/getroot.c b/grub-core/osdep/linux/getroot.c index 772de0a9b..19581d329 100644 --- a/grub-core/osdep/linux/getroot.c +++ b/grub-core/osdep/linux/getroot.c @@ -883,6 +883,19 @@ grub_util_part_to_disk (const char *os_dev, struct stat *st, *pp = '\0'; return path; } + + /* If this is a loop device */ + if ((strncmp ("loop", p, 4) == 0) && p[4] >= '0' && p[4] <= '9') + { + char *pp = p + 4; + while (*pp >= '0' && *pp <= '9') + pp++; + if (*pp == 'p') + *is_part = 1; + /* /dev/loop[0-9]+p[0-9]* */ + *pp = '\0'; + return path; + } } return path; From 7f64fb590cd80517e1381693a16d7cf2486fa808 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sun, 26 Jan 2014 03:31:10 +0100 Subject: [PATCH 047/722] * grub-core/term/at_keyboard.c: Tolerate missing keyboard. --- ChangeLog | 4 ++++ grub-core/term/at_keyboard.c | 3 +++ 2 files changed, 7 insertions(+) diff --git a/ChangeLog b/ChangeLog index bbec1e70b..d37d4a6fc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2014-01-26 Vladimir Serbinenko + + * grub-core/term/at_keyboard.c: Tolerate missing keyboard. + 2014-01-26 Mike Gilbert grub-install: support for partitioned partx loop devices. diff --git a/grub-core/term/at_keyboard.c b/grub-core/term/at_keyboard.c index f5071ce69..b4257e84a 100644 --- a/grub-core/term/at_keyboard.c +++ b/grub-core/term/at_keyboard.c @@ -396,6 +396,9 @@ fetch_key (int *is_break) if (! KEYBOARD_ISREADY (grub_inb (KEYBOARD_REG_STATUS))) return -1; at_key = grub_inb (KEYBOARD_REG_DATA); + /* May happen if no keyboard is connected. Just ignore this. */ + if (at_key == 0xff) + return -1; if (at_key == 0xe0) { e0_received = 1; From ba584da163bc4dc2a36988ae327733ba10251143 Mon Sep 17 00:00:00 2001 From: Paulo Flabiano Smorigo Date: Wed, 29 Jan 2014 13:26:00 -0200 Subject: [PATCH 048/722] .gitignore: add missing files and .exe variants. --- .gitignore | 7 +++++++ ChangeLog | 6 +++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 2b0156acd..18ab8e812 100644 --- a/.gitignore +++ b/.gitignore @@ -58,6 +58,8 @@ grub-emu.exe grub-emu-lite.exe grub_emu_init.c grub_emu_init.h +/grub-file +/grub-file.exe grub-fstest grub-fstest.exe grub_fstest_init.c @@ -66,6 +68,8 @@ grub_func_test grub-install grub-install.exe grub-kbdcomp +/grub-macbless +/grub-macbless.exe grub-macho2img /grub-menulst2cfg /grub-menulst2cfg.exe @@ -120,6 +124,8 @@ grub-shell grub-shell-tester grub-sparc64-setup grub-sparc64-setup.exe +/grub-syslinux2cfg +/grub-syslinux2cfg.exe gzcompress_test hddboot_test help_test @@ -194,6 +200,7 @@ grub-core/modinfo.sh grub-core/*.module grub-core/*.module.exe grub-core/*.pp +grub-core/kernel.img.bin util/bash-completion.d/grub grub-core/gnulib/alloca.h grub-core/gnulib/arg-nonnull.h diff --git a/ChangeLog b/ChangeLog index bbec1e70b..b996df81c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2014-01-29 Paulo Flabiano Smorigo + + * .gitignore: add missing files and .exe variants. + 2014-01-26 Mike Gilbert grub-install: support for partitioned partx loop devices. @@ -1109,7 +1113,7 @@ 2013-12-14 Vladimir Serbinenko - * .gitignore: Add .exe variants. Add missing files. Remove few outdated + * .gitignore: add .exe variants. add missing files. remove few outdated entries. 2013-12-14 Vladimir Serbinenko From ba424f37a95cf3f9c9995e051383424e328d13f6 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Wed, 29 Jan 2014 23:41:48 +0100 Subject: [PATCH 049/722] * util/grub-mkfont.c: Downgrade warnings about unhandled features to debug. --- ChangeLog | 5 +++++ util/grub-mkfont.c | 14 ++++++++------ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5692a5b7a..ce0ea891c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2014-01-29 Vladimir Serbinenko + + * util/grub-mkfont.c: Downgrade warnings about unhandled features + to debug. + 2014-01-29 Vladimir Serbinenko * grub-core/term/at_keyboard.c: Tolerate missing keyboard. diff --git a/util/grub-mkfont.c b/util/grub-mkfont.c index 3cb02ad5c..3de07ee9c 100644 --- a/util/grub-mkfont.c +++ b/util/grub-mkfont.c @@ -516,8 +516,8 @@ process_cursive (struct gsub_feature *feature, } if (grub_be_to_cpu16 (lookup->flag) & ~GSUB_RTL_CHAR) { - printf (_("Unsupported substitution flag: 0x%x\n"), - grub_be_to_cpu16 (lookup->flag)); + grub_util_info ("unsupported substitution flag: 0x%x", + grub_be_to_cpu16 (lookup->flag)); } switch (feattag) { @@ -577,7 +577,8 @@ process_cursive (struct gsub_feature *feature, There are 2 coverage specifications: list and range. This warning is thrown when another coverage specification is detected. */ - printf (_("Unsupported coverage specification: %d\n"), covertype); + fprintf (stderr, + _("Unsupported coverage specification: %d\n"), covertype); } } } @@ -616,7 +617,8 @@ add_font (struct grub_font_info *font_info, FT_Face face, int nocut) grub_uint32_t feattag = grub_be_to_cpu32 (features->features[i].feature_tag); if (feature->params) - printf (_("WARNING: unsupported font feature parameters: %x\n"), + fprintf (stderr, + _("WARNING: unsupported font feature parameters: %x\n"), grub_be_to_cpu16 (feature->params)); switch (feattag) { @@ -647,8 +649,8 @@ add_font (struct grub_font_info *font_info, FT_Face face, int nocut) if (!grub_isgraph (str[j])) str[j] = '?'; /* TRANSLATORS: It's gsub feature, not gsub font. */ - printf (_("Unknown gsub font feature 0x%x (%s)\n"), - feattag, str); + grub_util_info ("Unknown gsub font feature 0x%x (%s)", + feattag, str); } } } From 4686e163f278ae7cfaab3bebbde215f5688c7e3f Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Wed, 29 Jan 2014 23:43:25 +0100 Subject: [PATCH 050/722] * grub-core/disk/ahci.c: Do not enable I/O decoding and keep enabling busmaster for the end. --- ChangeLog | 5 +++++ grub-core/disk/ahci.c | 10 ++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index ce0ea891c..8c3745065 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2014-01-29 Vladimir Serbinenko + + * grub-core/disk/ahci.c: Do not enable I/O decoding and keep + enabling busmaster for the end. + 2014-01-29 Vladimir Serbinenko * util/grub-mkfont.c: Downgrade warnings about unhandled features diff --git a/grub-core/disk/ahci.c b/grub-core/disk/ahci.c index 0b13fb8eb..18c13270c 100644 --- a/grub-core/disk/ahci.c +++ b/grub-core/disk/ahci.c @@ -194,10 +194,8 @@ grub_ahci_pciinit (grub_pci_device_t dev, return 0; addr = grub_pci_make_address (dev, GRUB_PCI_REG_COMMAND); - grub_pci_write_word (addr, grub_pci_read_word (addr) | - GRUB_PCI_COMMAND_IO_ENABLED - | GRUB_PCI_COMMAND_MEM_ENABLED - | GRUB_PCI_COMMAND_BUS_MASTER); + grub_pci_write_word (addr, grub_pci_read_word (addr) + | GRUB_PCI_COMMAND_MEM_ENABLED); hba = grub_pci_device_map_range (dev, bar & GRUB_PCI_ADDR_MEM_MASK, sizeof (hba)); @@ -621,6 +619,10 @@ grub_ahci_pciinit (grub_pci_device_t dev, if (adevs[i] && (adevs[i]->hba->ports[adevs[i]->port].sig >> 16) == 0xeb14) adevs[i]->atapi = 1; + addr = grub_pci_make_address (dev, GRUB_PCI_REG_COMMAND); + grub_pci_write_word (addr, grub_pci_read_word (addr) + | GRUB_PCI_COMMAND_BUS_MASTER); + for (i = 0; i < nports; i++) if (adevs[i]) { From 3142b2feacc45ae42f4d3e6891d233727da4c3e1 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Wed, 29 Jan 2014 23:45:18 +0100 Subject: [PATCH 051/722] * grub-core/disk/ahci.c: Allocate and clean space for all possible 32 slots to avoid pointing to uninited area. --- ChangeLog | 5 +++++ grub-core/disk/ahci.c | 8 +++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 8c3745065..b2b54b952 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2014-01-29 Vladimir Serbinenko + + * grub-core/disk/ahci.c: Allocate and clean space for all possible 32 + slots to avoid pointing to uninited area. + 2014-01-29 Vladimir Serbinenko * grub-core/disk/ahci.c: Do not enable I/O decoding and keep diff --git a/grub-core/disk/ahci.c b/grub-core/disk/ahci.c index 18c13270c..d63fd09fd 100644 --- a/grub-core/disk/ahci.c +++ b/grub-core/disk/ahci.c @@ -358,7 +358,7 @@ grub_ahci_pciinit (grub_pci_device_t dev, grub_dprintf ("ahci", "err: %x\n", adevs[i]->hba->ports[adevs[i]->port].sata_error); - adevs[i]->command_list_chunk = grub_memalign_dma32 (1024, sizeof (struct grub_ahci_cmd_head)); + adevs[i]->command_list_chunk = grub_memalign_dma32 (1024, sizeof (struct grub_ahci_cmd_head) * 32); if (!adevs[i]->command_list_chunk) { adevs[i] = 0; @@ -376,6 +376,12 @@ grub_ahci_pciinit (grub_pci_device_t dev, adevs[i]->command_list = grub_dma_get_virt (adevs[i]->command_list_chunk); adevs[i]->command_table = grub_dma_get_virt (adevs[i]->command_table_chunk); + + grub_memset ((void *) adevs[i]->command_list, 0, + sizeof (struct grub_ahci_cmd_table)); + grub_memset ((void *) adevs[i]->command_table, 0, + sizeof (struct grub_ahci_cmd_head) * 32); + adevs[i]->command_list->command_table_base = grub_dma_get_phys (adevs[i]->command_table_chunk); From 07ea8daa8606160a18778af9a806d61b884d8d73 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Wed, 29 Jan 2014 23:46:17 +0100 Subject: [PATCH 052/722] * grub-core/disk/ahci.c: Add safety cleanups. --- ChangeLog | 4 ++++ grub-core/disk/ahci.c | 10 ++++++++++ 2 files changed, 14 insertions(+) diff --git a/ChangeLog b/ChangeLog index b2b54b952..148607f03 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2014-01-29 Vladimir Serbinenko + + * grub-core/disk/ahci.c: Add safety cleanups. + 2014-01-29 Vladimir Serbinenko * grub-core/disk/ahci.c: Allocate and clean space for all possible 32 diff --git a/grub-core/disk/ahci.c b/grub-core/disk/ahci.c index d63fd09fd..643e691ef 100644 --- a/grub-core/disk/ahci.c +++ b/grub-core/disk/ahci.c @@ -454,6 +454,7 @@ grub_ahci_pciinit (grub_pci_device_t dev, adevs[i]->hba->ports[adevs[i]->port].fis_base = grub_dma_get_phys (adevs[i]->rfis); adevs[i]->hba->ports[adevs[i]->port].command_list_base = grub_dma_get_phys (adevs[i]->command_list_chunk); + adevs[i]->hba->ports[adevs[i]->port].command_issue = 0; adevs[i]->hba->ports[adevs[i]->port].command |= GRUB_AHCI_HBA_PORT_CMD_FRE; } @@ -600,6 +601,9 @@ grub_ahci_pciinit (grub_pci_device_t dev, failed_adevs[i] = adevs[i]; adevs[i] = 0; } + + grub_dprintf ("ahci", "cleaning up failed devs\n"); + for (i = 0; i < nports; i++) if (failed_adevs[i] && (fr_running & (1 << i))) failed_adevs[i]->hba->ports[failed_adevs[i]->port].command &= ~GRUB_AHCI_HBA_PORT_CMD_FRE; @@ -855,6 +859,12 @@ grub_ahci_reset_port (struct grub_ahci_device *dev, int force) { struct grub_disk_ata_pass_through_parms parms2; dev->hba->ports[dev->port].command &= ~GRUB_AHCI_HBA_PORT_CMD_ST; + dev->hba->ports[dev->port].command_issue = 0; + dev->command_list[0].config = 0; + dev->command_table[0].prdt[0].unused = 0; + dev->command_table[0].prdt[0].size = 0; + dev->command_table[0].prdt[0].data_base = 0; + endtime = grub_get_time_ms () + 1000; while ((dev->hba->ports[dev->port].command & GRUB_AHCI_HBA_PORT_CMD_CR)) if (grub_get_time_ms () > endtime) From d6b94c5eb2a968ebb64f7937d244a267d56f10ab Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Wed, 29 Jan 2014 23:49:51 +0100 Subject: [PATCH 053/722] * grub-core/disk/ahci.c: Properly handle transactions with no transferred data. --- ChangeLog | 5 +++++ grub-core/disk/ahci.c | 7 +++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 148607f03..1cd2b398c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2014-01-29 Vladimir Serbinenko + + * grub-core/disk/ahci.c: Properly handle transactions with no + transferred data. + 2014-01-29 Vladimir Serbinenko * grub-core/disk/ahci.c: Add safety cleanups. diff --git a/grub-core/disk/ahci.c b/grub-core/disk/ahci.c index 643e691ef..fdd40c64d 100644 --- a/grub-core/disk/ahci.c +++ b/grub-core/disk/ahci.c @@ -932,7 +932,10 @@ grub_ahci_readwrite_real (struct grub_ahci_device *dev, if (parms->size > GRUB_AHCI_PRDT_MAX_CHUNK_LENGTH) return grub_error (GRUB_ERR_BUG, "too big data buffer"); - bufc = grub_memalign_dma32 (1024, parms->size + (parms->size & 1)); + if (parms->size) + bufc = grub_memalign_dma32 (1024, parms->size + (parms->size & 1)); + else + bufc = grub_memalign_dma32 (1024, 512); grub_dprintf ("ahci", "AHCI tfd = %x, CL=%p\n", dev->hba->ports[dev->port].task_file_data, @@ -942,7 +945,7 @@ grub_ahci_readwrite_real (struct grub_ahci_device *dev, = (5 << GRUB_AHCI_CONFIG_CFIS_LENGTH_SHIFT) // | GRUB_AHCI_CONFIG_CLEAR_R_OK | (0 << GRUB_AHCI_CONFIG_PMP_SHIFT) - | (1 << GRUB_AHCI_CONFIG_PRDT_LENGTH_SHIFT) + | ((parms->size ? 1 : 0) << GRUB_AHCI_CONFIG_PRDT_LENGTH_SHIFT) | (parms->cmdsize ? GRUB_AHCI_CONFIG_ATAPI : 0) | (parms->write ? GRUB_AHCI_CONFIG_WRITE : GRUB_AHCI_CONFIG_READ) | (parms->taskfile.cmd == 8 ? (1 << 8) : 0); From 9abbaae7cdc5ffba6065c089c9ebb076864d9bbd Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Wed, 29 Jan 2014 23:50:49 +0100 Subject: [PATCH 054/722] * grub-core/disk/ahci.c: Increase timeout. Some SSDs take up to 7 seconds to recover if last poweroff was bad. --- ChangeLog | 5 +++++ grub-core/disk/ahci.c | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 1cd2b398c..cfa9c8379 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2014-01-29 Vladimir Serbinenko + + * grub-core/disk/ahci.c: Increase timeout. Some SSDs take up to + 7 seconds to recover if last poweroff was bad. + 2014-01-29 Vladimir Serbinenko * grub-core/disk/ahci.c: Properly handle transactions with no diff --git a/grub-core/disk/ahci.c b/grub-core/disk/ahci.c index fdd40c64d..5e4a6397a 100644 --- a/grub-core/disk/ahci.c +++ b/grub-core/disk/ahci.c @@ -1022,7 +1022,7 @@ grub_ahci_readwrite_real (struct grub_ahci_device *dev, grub_dprintf ("ahci", "AHCI tfd = %x\n", dev->hba->ports[dev->port].task_file_data); - endtime = grub_get_time_ms () + (spinup ? 10000 : 5000); + endtime = grub_get_time_ms () + (spinup ? 20000 : 20000); while ((dev->hba->ports[dev->port].command_issue & 1)) if (grub_get_time_ms () > endtime) { From 511ece7cebe261bcdd4a1d3f50ed9c05a234bcc6 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 3 Feb 2014 14:34:27 +0100 Subject: [PATCH 055/722] * util/grub-mkfont.c: Build fix for argp.h with older gcc. --- ChangeLog | 4 ++++ util/grub-mkfont.c | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/ChangeLog b/ChangeLog index cfa9c8379..78910884b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2014-02-03 Vladimir Serbinenko + + * util/grub-mkfont.c: Build fix for argp.h with older gcc. + 2014-01-29 Vladimir Serbinenko * grub-core/disk/ahci.c: Increase timeout. Some SSDs take up to diff --git a/util/grub-mkfont.c b/util/grub-mkfont.c index 3de07ee9c..e6485b40f 100644 --- a/util/grub-mkfont.c +++ b/util/grub-mkfont.c @@ -33,7 +33,11 @@ #ifndef GRUB_BUILD #define _GNU_SOURCE 1 +#pragma GCC diagnostic ignored "-Wmissing-prototypes" +#pragma GCC diagnostic ignored "-Wmissing-declarations" #include +#pragma GCC diagnostic error "-Wmissing-prototypes" +#pragma GCC diagnostic error "-Wmissing-declarations" #endif #include From 006c78f378629e83db718ce6e3f83d2f2c68ce7e Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 3 Feb 2014 14:35:51 +0100 Subject: [PATCH 056/722] * util/grub-mkrescue.c: Build fix for argp.h with older gcc. --- ChangeLog | 4 ++++ util/grub-mkrescue.c | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/ChangeLog b/ChangeLog index 78910884b..eb72cc383 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2014-02-03 Vladimir Serbinenko + + * util/grub-mkrescue.c: Build fix for argp.h with older gcc. + 2014-02-03 Vladimir Serbinenko * util/grub-mkfont.c: Build fix for argp.h with older gcc. diff --git a/util/grub-mkrescue.c b/util/grub-mkrescue.c index 34e0b7aff..e71983982 100644 --- a/util/grub-mkrescue.c +++ b/util/grub-mkrescue.c @@ -25,7 +25,11 @@ #include #include #include +#pragma GCC diagnostic ignored "-Wmissing-prototypes" +#pragma GCC diagnostic ignored "-Wmissing-declarations" #include +#pragma GCC diagnostic error "-Wmissing-prototypes" +#pragma GCC diagnostic error "-Wmissing-declarations" #include #include From e4dbf247b656eb9577020af653ff37159fc340f2 Mon Sep 17 00:00:00 2001 From: Paulo Flabiano Smorigo Date: Tue, 4 Feb 2014 18:41:38 -0200 Subject: [PATCH 057/722] add grub_env_set_net_property function * grub-core/net/bootp.c: Remove set_env_limn_ro. * grub-core/net/net.c: Add grub_env_set_net_property. * include/grub/net.h: Likewise. --- ChangeLog | 8 ++++++ grub-core/net/bootp.c | 63 +++++++++++-------------------------------- grub-core/net/net.c | 38 ++++++++++++++++++++++++++ include/grub/net.h | 4 +++ 4 files changed, 66 insertions(+), 47 deletions(-) diff --git a/ChangeLog b/ChangeLog index eb72cc383..5af574818 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2014-02-04 Paulo Flabiano Smorigo + + Add grub_env_set_net_property function. + + * grub-core/net/bootp.c: Remove set_env_limn_ro. + * grub-core/net/net.c: Add grub_env_set_net_property. + * include/grub/net.h: Likewise. + 2014-02-03 Vladimir Serbinenko * util/grub-mkrescue.c: Build fix for argp.h with older gcc. diff --git a/grub-core/net/bootp.c b/grub-core/net/bootp.c index c14e9de57..6310ed447 100644 --- a/grub-core/net/bootp.c +++ b/grub-core/net/bootp.c @@ -25,41 +25,6 @@ #include #include -static char * -grub_env_write_readonly (struct grub_env_var *var __attribute__ ((unused)), - const char *val __attribute__ ((unused))) -{ - return NULL; -} - -static void -set_env_limn_ro (const char *intername, const char *suffix, - const char *value, grub_size_t len) -{ - char *varname, *varvalue; - char *ptr; - varname = grub_xasprintf ("net_%s_%s", intername, suffix); - if (!varname) - return; - for (ptr = varname; *ptr; ptr++) - if (*ptr == ':') - *ptr = '_'; - varvalue = grub_malloc (len + 1); - if (!varvalue) - { - grub_free (varname); - return; - } - - grub_memcpy (varvalue, value, len); - varvalue[len] = 0; - grub_env_set (varname, varvalue); - grub_register_variable_hook (varname, 0, grub_env_write_readonly); - grub_env_export (varname); - grub_free (varname); - grub_free (varvalue); -} - static void parse_dhcp_vendor (const char *name, const void *vend, int limit, int *mask) { @@ -136,20 +101,24 @@ parse_dhcp_vendor (const char *name, const void *vend, int limit, int *mask) } continue; case GRUB_NET_BOOTP_HOSTNAME: - set_env_limn_ro (name, "hostname", (const char *) ptr, taglength); - break; + grub_env_set_net_property (name, "hostname", (const char *) ptr, + taglength); + break; case GRUB_NET_BOOTP_DOMAIN: - set_env_limn_ro (name, "domain", (const char *) ptr, taglength); - break; + grub_env_set_net_property (name, "domain", (const char *) ptr, + taglength); + break; case GRUB_NET_BOOTP_ROOT_PATH: - set_env_limn_ro (name, "rootpath", (const char *) ptr, taglength); - break; + grub_env_set_net_property (name, "rootpath", (const char *) ptr, + taglength); + break; case GRUB_NET_BOOTP_EXTENSIONS_PATH: - set_env_limn_ro (name, "extensionspath", (const char *) ptr, taglength); - break; + grub_env_set_net_property (name, "extensionspath", (const char *) ptr, + taglength); + break; /* If you need any other options please contact GRUB development team. */ @@ -211,8 +180,8 @@ grub_net_configure_by_dhcp_ack (const char *name, } if (size > OFFSET_OF (boot_file, bp)) - set_env_limn_ro (name, "boot_file", (char *) bp->boot_file, - sizeof (bp->boot_file)); + grub_env_set_net_property (name, "boot_file", bp->boot_file, + sizeof (bp->boot_file)); if (is_def) grub_net_default_server = 0; if (is_def && !grub_net_default_server && bp->server_ip) @@ -243,8 +212,8 @@ grub_net_configure_by_dhcp_ack (const char *name, if (size > OFFSET_OF (server_name, bp) && bp->server_name[0]) { - set_env_limn_ro (name, "dhcp_server_name", (char *) bp->server_name, - sizeof (bp->server_name)); + grub_env_set_net_property (name, "dhcp_server_name", bp->server_name, + sizeof (bp->server_name)); if (is_def && !grub_net_default_server) { grub_net_default_server = grub_strdup (bp->server_name); diff --git a/grub-core/net/net.c b/grub-core/net/net.c index 1521d8d2c..f2e723bd4 100644 --- a/grub-core/net/net.c +++ b/grub-core/net/net.c @@ -1480,6 +1480,44 @@ receive_packets (struct grub_net_card *card, int *stop_condition) grub_print_error (); } +static char * +grub_env_write_readonly (struct grub_env_var *var __attribute__ ((unused)), + const char *val __attribute__ ((unused))) +{ + return NULL; +} + +grub_err_t +grub_env_set_net_property (const char *intername, const char *suffix, + const char *value, grub_size_t len) +{ + char *varname, *varvalue; + char *ptr; + + varname = grub_xasprintf ("net_%s_%s", intername, suffix); + if (!varname) + return grub_errno; + for (ptr = varname; *ptr; ptr++) + if (*ptr == ':') + *ptr = '_'; + varvalue = grub_malloc (len + 1); + if (!varvalue) + { + grub_free (varname); + return grub_errno; + } + + grub_memcpy (varvalue, value, len); + varvalue[len] = 0; + grub_err_t ret = grub_env_set (varname, varvalue); + grub_register_variable_hook (varname, 0, grub_env_write_readonly); + grub_env_export (varname); + grub_free (varname); + grub_free (varvalue); + + return ret; +} + void grub_net_poll_cards (unsigned time, int *stop_condition) { diff --git a/include/grub/net.h b/include/grub/net.h index 0e0a605c5..538baa33e 100644 --- a/include/grub/net.h +++ b/include/grub/net.h @@ -480,6 +480,10 @@ grub_net_addr_to_str (const grub_net_network_level_address_t *target, void grub_net_hwaddr_to_str (const grub_net_link_level_address_t *addr, char *str); +grub_err_t +grub_env_set_net_property (const char *intername, const char *suffix, + const char *value, grub_size_t len); + void grub_net_poll_cards (unsigned time, int *stop_condition); From 9585647a25b65f98db6bd22c569b34795512f046 Mon Sep 17 00:00:00 2001 From: Paulo Flabiano Smorigo Date: Tue, 4 Feb 2014 19:00:55 -0200 Subject: [PATCH 058/722] add bootpath parser for open firmware It enables net boot even when there is no bootp/dhcp server. * grub-core/net/drivers/ieee1275/ofnet.c: Add grub_ieee1275_parse_bootpath and call it at grub_ieee1275_net_config_real. * grub-core/kern/ieee1275/init.c: Add bootpath to grub_ieee1275_net_config. * include/grub/ieee1275/ieee1275.h: Likewise. --- ChangeLog | 13 +++ grub-core/kern/ieee1275/init.c | 7 +- grub-core/net/drivers/ieee1275/ofnet.c | 107 ++++++++++++++++++++++++- include/grub/ieee1275/ieee1275.h | 5 +- 4 files changed, 125 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5af574818..07caf46f0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2014-02-04 Paulo Flabiano Smorigo + + Add bootpath parser for open firmware. + + It enables net boot even when there is no bootp/dhcp server. + + * grub-core/net/drivers/ieee1275/ofnet.c: Add grub_ieee1275_parse_bootpath + and call it at grub_ieee1275_net_config_real. + * grub-core/kern/ieee1275/init.c: Add bootpath to + grub_ieee1275_net_config. + * include/grub/ieee1275/ieee1275.h: Likewise. + + 2014-02-04 Paulo Flabiano Smorigo Add grub_env_set_net_property function. diff --git a/grub-core/kern/ieee1275/init.c b/grub-core/kern/ieee1275/init.c index 89b2822e1..d5bd74d35 100644 --- a/grub-core/kern/ieee1275/init.c +++ b/grub-core/kern/ieee1275/init.c @@ -80,9 +80,8 @@ grub_translate_ieee1275_path (char *filepath) } } -void (*grub_ieee1275_net_config) (const char *dev, - char **device, - char **path); +void (*grub_ieee1275_net_config) (const char *dev, char **device, char **path, + char *bootpath); void grub_machine_get_bootlocation (char **device, char **path) { @@ -126,7 +125,7 @@ grub_machine_get_bootlocation (char **device, char **path) *ptr = 0; if (grub_ieee1275_net_config) - grub_ieee1275_net_config (canon, device, path); + grub_ieee1275_net_config (canon, device, path, bootpath); grub_free (dev); grub_free (canon); } diff --git a/grub-core/net/drivers/ieee1275/ofnet.c b/grub-core/net/drivers/ieee1275/ofnet.c index 4483c9122..eea8e71d3 100644 --- a/grub-core/net/drivers/ieee1275/ofnet.c +++ b/grub-core/net/drivers/ieee1275/ofnet.c @@ -127,8 +127,111 @@ bootp_response_properties[] = { .name = "bootpreply-packet", .offset = 0x2a}, }; +enum +{ + BOOTARGS_SERVER_ADDR, + BOOTARGS_FILENAME, + BOOTARGS_CLIENT_ADDR, + BOOTARGS_GATEWAY_ADDR, + BOOTARGS_BOOTP_RETRIES, + BOOTARGS_TFTP_RETRIES, + BOOTARGS_SUBNET_MASK, + BOOTARGS_BLOCKSIZE +}; + +static int +grub_ieee1275_parse_bootpath (const char *devpath, char *bootpath, + char **device, struct grub_net_card **card) +{ + char *args; + char *comma_char = 0; + char *equal_char = 0; + grub_size_t field_counter = 0; + + grub_net_network_level_address_t client_addr, gateway_addr, subnet_mask; + grub_net_link_level_address_t hw_addr; + grub_net_interface_flags_t flags = 0; + struct grub_net_network_level_interface *inter; + + hw_addr.type = GRUB_NET_LINK_LEVEL_PROTOCOL_ETHERNET; + + args = bootpath + grub_strlen (devpath) + 1; + do + { + comma_char = grub_strchr (args, ','); + if (comma_char != 0) + *comma_char = 0; + + /* Check if it's an option (like speed=auto) and not a default parameter */ + equal_char = grub_strchr (args, '='); + if (equal_char != 0) + { + *equal_char = 0; + grub_env_set_net_property ((*card)->name, args, equal_char + 1, + grub_strlen(equal_char + 1)); + *equal_char = '='; + } + else + { + switch (field_counter++) + { + case BOOTARGS_SERVER_ADDR: + *device = grub_xasprintf ("tftp,%s", args); + if (!*device) + return grub_errno; + break; + + case BOOTARGS_CLIENT_ADDR: + grub_net_resolve_address (args, &client_addr); + break; + + case BOOTARGS_GATEWAY_ADDR: + grub_net_resolve_address (args, &gateway_addr); + break; + + case BOOTARGS_SUBNET_MASK: + grub_net_resolve_address (args, &subnet_mask); + break; + } + } + args = comma_char + 1; + if (comma_char != 0) + *comma_char = ','; + } while (comma_char != 0); + + if ((client_addr.ipv4 != 0) && (subnet_mask.ipv4 != 0)) + { + grub_ieee1275_phandle_t devhandle; + grub_ieee1275_finddevice (devpath, &devhandle); + grub_ieee1275_get_property (devhandle, "mac-address", + hw_addr.mac, sizeof(hw_addr.mac), 0); + inter = grub_net_add_addr ((*card)->name, *card, &client_addr, &hw_addr, + flags); + grub_net_add_ipv4_local (inter, + __builtin_ctz (~grub_le_to_cpu32 (subnet_mask.ipv4))); + } + + if (gateway_addr.ipv4 != 0) + { + grub_net_network_level_netaddress_t target; + char *rname; + + target.type = GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV4; + target.ipv4.base = 0; + target.ipv4.masksize = 0; + rname = grub_xasprintf ("%s:default", ((*card)->name)); + if (rname) + grub_net_add_route_gw (rname, target, gateway_addr); + else + return grub_errno; + } + + return 0; +} + static void -grub_ieee1275_net_config_real (const char *devpath, char **device, char **path) +grub_ieee1275_net_config_real (const char *devpath, char **device, char **path, + char *bootpath) { struct grub_net_card *card; @@ -158,6 +261,8 @@ grub_ieee1275_net_config_real (const char *devpath, char **device, char **path) } grub_free (canon); + grub_ieee1275_parse_bootpath (devpath, bootpath, device, &card); + for (i = 0; i < ARRAY_SIZE (bootp_response_properties); i++) if (grub_ieee1275_get_property_length (grub_ieee1275_chosen, bootp_response_properties[i].name, diff --git a/include/grub/ieee1275/ieee1275.h b/include/grub/ieee1275/ieee1275.h index dc54beabb..8e4251303 100644 --- a/include/grub/ieee1275/ieee1275.h +++ b/include/grub/ieee1275/ieee1275.h @@ -70,8 +70,9 @@ struct grub_ieee1275_devalias }; extern void (*EXPORT_VAR(grub_ieee1275_net_config)) (const char *dev, - char **device, - char **path); + char **device, + char **path, + char *bootargs); /* Maps a device alias to a pathname. */ extern grub_ieee1275_phandle_t EXPORT_VAR(grub_ieee1275_chosen); From d0949e374731e3f36c279774cd08fadd6553dcee Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Thu, 20 Feb 2014 10:11:43 +0100 Subject: [PATCH 059/722] * grub-core/disk/ahci.c: Ignore NPORTS field and rely on PI exclusively. --- ChangeLog | 5 +++++ grub-core/disk/ahci.c | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 07caf46f0..aec689d5d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2014-02-20 Vladimir Serbinenko + + * grub-core/disk/ahci.c: Ignore NPORTS field and rely on PI + exclusively. + 2014-02-04 Paulo Flabiano Smorigo Add bootpath parser for open firmware. diff --git a/grub-core/disk/ahci.c b/grub-core/disk/ahci.c index 5e4a6397a..89365cd09 100644 --- a/grub-core/disk/ahci.c +++ b/grub-core/disk/ahci.c @@ -322,7 +322,7 @@ grub_ahci_pciinit (grub_pci_device_t dev, grub_dprintf ("ahci", "GLC:%x\n", hba->global_control); - nports = (hba->cap & GRUB_AHCI_HBA_CAP_NPORTS_MASK) + 1; + nports = (GRUB_AHCI_HBA_CAP_NPORTS_MASK) + 1; grub_dprintf ("ahci", "%d AHCI ports, PI = 0x%x\n", nports, hba->ports_implemented); From f94b2b4eeb5ec804671d5a0efa4ce779c179b68f Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 28 Feb 2014 09:47:57 +0100 Subject: [PATCH 060/722] * grub-core/kern/i386/coreboot/mmap.c: Filter out 0xa0000-0x100000 region. --- ChangeLog | 5 ++++ grub-core/kern/i386/coreboot/mmap.c | 38 ++++++++++++++++++++++++----- 2 files changed, 37 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index aec689d5d..c2983f261 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2014-02-28 Vladimir Serbinenko + + * grub-core/kern/i386/coreboot/mmap.c: Filter out 0xa0000-0x100000 + region. + 2014-02-20 Vladimir Serbinenko * grub-core/disk/ahci.c: Ignore NPORTS field and rely on PI diff --git a/grub-core/kern/i386/coreboot/mmap.c b/grub-core/kern/i386/coreboot/mmap.c index 119797551..4d29f6b7d 100644 --- a/grub-core/kern/i386/coreboot/mmap.c +++ b/grub-core/kern/i386/coreboot/mmap.c @@ -44,18 +44,44 @@ iterate_linuxbios_table (grub_linuxbios_table_item_t table_item, void *data) mem_region = (mem_region_t) ((long) table_item + sizeof (struct grub_linuxbios_table_item)); - while ((long) mem_region < (long) table_item + (long) table_item->size) + for (; (long) mem_region < (long) table_item + (long) table_item->size; + mem_region++) { - if (ctx->hook (mem_region->addr, mem_region->size, + grub_uint64_t start = mem_region->addr; + grub_uint64_t end = mem_region->addr + mem_region->size; + /* Mark region 0xa0000 - 0x100000 as reserved. */ + if (start < 0x100000 && end >= 0xa0000 + && mem_region->type == GRUB_MACHINE_MEMORY_AVAILABLE) + { + if (start < 0xa0000 + && ctx->hook (start, 0xa0000 - start, + /* Multiboot mmaps match with the coreboot mmap + definition. Therefore, we can just pass type + through. */ + mem_region->type, + ctx->hook_data)) + return 1; + if (start < 0xa0000) + start = 0xa0000; + if (start >= end) + continue; + + if (ctx->hook (start, (end > 0x100000 ? 0x100000 : end) - start, + GRUB_MEMORY_RESERVED, + ctx->hook_data)) + return 1; + start = 0x100000; + + if (end <= start) + continue; + } + if (ctx->hook (start, end - start, /* Multiboot mmaps match with the coreboot mmap definition. Therefore, we can just pass type through. */ - (((mem_region->type <= GRUB_MACHINE_MEMORY_BADRAM) && (mem_region->type >= GRUB_MACHINE_MEMORY_AVAILABLE)) - || mem_region->type == GRUB_MEMORY_COREBOOT_TABLES) ? mem_region->type : GRUB_MEMORY_RESERVED, + mem_region->type, ctx->hook_data)) return 1; - - mem_region++; } return 0; From 4a70fed815c12090c772ed911363520d0f02cf36 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 28 Feb 2014 09:48:57 +0100 Subject: [PATCH 061/722] * grub-core/loader/i386/multiboot_mbi.c (grub_multiboot_make_mbi): Limit location to 640K. --- ChangeLog | 5 +++++ grub-core/loader/i386/multiboot_mbi.c | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index c2983f261..feea17861 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2014-02-28 Vladimir Serbinenko + + * grub-core/loader/i386/multiboot_mbi.c (grub_multiboot_make_mbi): Limit + location to 640K. + 2014-02-28 Vladimir Serbinenko * grub-core/kern/i386/coreboot/mmap.c: Filter out 0xa0000-0x100000 diff --git a/grub-core/loader/i386/multiboot_mbi.c b/grub-core/loader/i386/multiboot_mbi.c index 7431aa49b..f10c087f7 100644 --- a/grub-core/loader/i386/multiboot_mbi.c +++ b/grub-core/loader/i386/multiboot_mbi.c @@ -446,7 +446,7 @@ grub_multiboot_make_mbi (grub_uint32_t *target) bufsize = grub_multiboot_get_mbi_size (); err = grub_relocator_alloc_chunk_align (grub_multiboot_relocator, &ch, - 0x10000, 0x100000 - bufsize, + 0x10000, 0xa0000 - bufsize, bufsize, 4, GRUB_RELOCATOR_PREFERENCE_NONE, 0); if (err) From dfc5ccfa97e15c8c83c98594570e4e07b3630877 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 28 Feb 2014 09:50:47 +0100 Subject: [PATCH 062/722] * grub-core/mmap/i386/uppermem.c (lower_hook) [COREBOOT]: Ignore low tables for low memory calculations. --- ChangeLog | 5 +++++ grub-core/mmap/i386/uppermem.c | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index feea17861..5edbf6728 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2014-02-28 Vladimir Serbinenko + + * grub-core/mmap/i386/uppermem.c (lower_hook) [COREBOOT]: Ignore low + tables for low memory calculations. + 2014-02-28 Vladimir Serbinenko * grub-core/loader/i386/multiboot_mbi.c (grub_multiboot_make_mbi): Limit diff --git a/grub-core/mmap/i386/uppermem.c b/grub-core/mmap/i386/uppermem.c index bd8b429c4..a6be9896d 100644 --- a/grub-core/mmap/i386/uppermem.c +++ b/grub-core/mmap/i386/uppermem.c @@ -31,8 +31,12 @@ lower_hook (grub_uint64_t addr, grub_uint64_t size, grub_memory_type_t type, if (type != GRUB_MEMORY_AVAILABLE) return 0; +#ifdef GRUB_MACHINE_COREBOOT + if (addr <= 0x1000) +#else if (addr == 0) - *lower = size; +#endif + *lower = size + addr; return 0; } From bec35dad2a86b2412e9ce11d09f47f1d01ccc616 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 28 Feb 2014 10:07:11 +0100 Subject: [PATCH 063/722] * grub-core/kern/i386/pc/mmap.c: Fallback to EISA memory map if E820 failed to return any regions. --- ChangeLog | 5 +++++ grub-core/kern/i386/pc/mmap.c | 40 ++++++++++++++++++----------------- 2 files changed, 26 insertions(+), 19 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5edbf6728..2e98f3961 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2014-02-28 Vladimir Serbinenko + + * grub-core/kern/i386/pc/mmap.c: Fallback to EISA memory map + if E820 failed to return any regions. + 2014-02-28 Vladimir Serbinenko * grub-core/mmap/i386/uppermem.c (lower_hook) [COREBOOT]: Ignore low diff --git a/grub-core/kern/i386/pc/mmap.c b/grub-core/kern/i386/pc/mmap.c index 8009e833c..f1375f3e1 100644 --- a/grub-core/kern/i386/pc/mmap.c +++ b/grub-core/kern/i386/pc/mmap.c @@ -141,33 +141,35 @@ grub_get_mmap_entry (struct grub_machine_mmap_entry *entry, grub_err_t grub_machine_mmap_iterate (grub_memory_hook_t hook, void *hook_data) { - grub_uint32_t cont; + grub_uint32_t cont = 0; struct grub_machine_mmap_entry *entry = (struct grub_machine_mmap_entry *) GRUB_MEMORY_MACHINE_SCRATCH_ADDR; + int e820_works = 0; - grub_memset (entry, 0, sizeof (entry)); + while (1) + { + grub_memset (entry, 0, sizeof (entry)); - /* Check if grub_get_mmap_entry works. */ - cont = grub_get_mmap_entry (entry, 0); + cont = grub_get_mmap_entry (entry, cont); - if (entry->size) - do - { - if (hook (entry->addr, entry->len, - /* GRUB mmaps have been defined to match with the E820 definition. - Therefore, we can just pass type through. */ - entry->type, hook_data)) - break; + if (!entry->size) + break; - if (! cont) - break; + if (entry->len) + e820_works = 1; + if (entry->len + && hook (entry->addr, entry->len, + /* GRUB mmaps have been defined to match with + the E820 definition. + Therefore, we can just pass type through. */ + entry->type, hook_data)) + break; - grub_memset (entry, 0, sizeof (entry)); + if (! cont) + break; + } - cont = grub_get_mmap_entry (entry, cont); - } - while (entry->size); - else + if (!e820_works) { grub_uint32_t eisa_mmap = grub_get_eisa_mmap (); From 86402b4e0fec7d0e5637f70a3103a4d9c3f62839 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 28 Feb 2014 10:50:05 +0100 Subject: [PATCH 064/722] * include/grub/i386/openbsd_bootarg.h: Add addr and frequency fields. * grub-core/loader/i386/bsd.c (grub_cmd_openbsd): Fill addr field. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Suggested by: Markus Müller. --- ChangeLog | 7 +++++++ grub-core/loader/i386/bsd.c | 2 ++ include/grub/i386/openbsd_bootarg.h | 2 ++ 3 files changed, 11 insertions(+) diff --git a/ChangeLog b/ChangeLog index 2e98f3961..770269c9c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2014-02-28 Vladimir Serbinenko + + * include/grub/i386/openbsd_bootarg.h: Add addr and frequency fields. + * grub-core/loader/i386/bsd.c (grub_cmd_openbsd): Fill addr field. + + Suggested by: Markus Müller. + 2014-02-28 Vladimir Serbinenko * grub-core/kern/i386/pc/mmap.c: Fallback to EISA memory map diff --git a/grub-core/loader/i386/bsd.c b/grub-core/loader/i386/bsd.c index ea0edfafe..19985f03e 100644 --- a/grub-core/loader/i386/bsd.c +++ b/grub-core/loader/i386/bsd.c @@ -1646,6 +1646,7 @@ grub_cmd_openbsd (grub_extcmd_context_t ctxt, int argc, char *argv[]) serial.device = (GRUB_OPENBSD_COM_MAJOR << 8) | port; serial.speed = speed; + serial.addr = grub_ns8250_hw_get_port (port); grub_bsd_add_meta (OPENBSD_BOOTARG_CONSOLE, &serial, sizeof (serial)); bootflags |= OPENBSD_RB_SERCONS; @@ -1656,6 +1657,7 @@ grub_cmd_openbsd (grub_extcmd_context_t ctxt, int argc, char *argv[]) grub_memset (&serial, 0, sizeof (serial)); serial.device = (GRUB_OPENBSD_VGA_MAJOR << 8); + serial.addr = 0xffffffff; grub_bsd_add_meta (OPENBSD_BOOTARG_CONSOLE, &serial, sizeof (serial)); bootflags &= ~OPENBSD_RB_SERCONS; } diff --git a/include/grub/i386/openbsd_bootarg.h b/include/grub/i386/openbsd_bootarg.h index 01ca4868b..9ebe6b4e4 100644 --- a/include/grub/i386/openbsd_bootarg.h +++ b/include/grub/i386/openbsd_bootarg.h @@ -75,6 +75,8 @@ struct grub_openbsd_bootarg_console { grub_uint32_t device; grub_uint32_t speed; + grub_uint32_t addr; + grub_uint32_t frequency; }; struct grub_openbsd_bootarg_pcibios From e4a1fe391906bfcd1a778c5ec4e242c4b07d429d Mon Sep 17 00:00:00 2001 From: Nikunj A Dadhania Date: Thu, 20 Mar 2014 16:57:12 +0530 Subject: [PATCH 065/722] ieee1275: check for IBM pseries emulated machine is_qemu is not being set lead to disabling of feature like GRUB_IEEE1275_FLAG_HAS_CURSORONOFF. This resulted in cursor not being displayed during the grub-menu edit. Signed-off-by: Nikunj A Dadhania --- grub-core/kern/ieee1275/cmain.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/grub-core/kern/ieee1275/cmain.c b/grub-core/kern/ieee1275/cmain.c index d92ae14f5..3e12e6b24 100644 --- a/grub-core/kern/ieee1275/cmain.c +++ b/grub-core/kern/ieee1275/cmain.c @@ -84,8 +84,10 @@ grub_ieee1275_find_options (void) rc = grub_ieee1275_get_property (root, "model", tmp, sizeof (tmp), 0); - if (rc >= 0 && !grub_strcmp (tmp, "Emulated PC")) + if (rc >= 0 && (!grub_strcmp (tmp, "Emulated PC") + || !grub_strcmp (tmp, "IBM pSeries (emulated by qemu)"))) { is_qemu = 1; + } if (rc >= 0 && grub_strncmp (tmp, "IBM", 3) == 0) grub_ieee1275_set_flag (GRUB_IEEE1275_FLAG_NO_TREE_SCANNING_FOR_DISKS); From 68f17b2b300e4eaf9852c23d0b652d6e210ac180 Mon Sep 17 00:00:00 2001 From: Fu Wei Date: Wed, 26 Mar 2014 08:13:07 +0100 Subject: [PATCH 066/722] * grub-core/loader/arm64/linux.c: Remove redundant "0x". --- ChangeLog | 4 ++++ grub-core/loader/arm64/linux.c | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 770269c9c..44ce649e4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2014-03-26 Fu Wei + + * grub-core/loader/arm64/linux.c: Remove redundant "0x". + 2014-02-28 Vladimir Serbinenko * include/grub/i386/openbsd_bootarg.h: Add addr and frequency fields. diff --git a/grub-core/loader/arm64/linux.c b/grub-core/loader/arm64/linux.c index 65129c21a..f1d10a164 100644 --- a/grub-core/loader/arm64/linux.c +++ b/grub-core/loader/arm64/linux.c @@ -68,7 +68,7 @@ get_firmware_fdt (void) if (grub_memcmp (&tables[i].vendor_guid, &fdt_guid, sizeof (fdt_guid)) == 0) { firmware_fdt = tables[i].vendor_table; - grub_dprintf ("linux", "found registered FDT @ 0x%p\n", firmware_fdt); + grub_dprintf ("linux", "found registered FDT @ %p\n", firmware_fdt); break; } From 46b74dd3cbb3a97a7abeb7f0464de548006e0e3d Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Wed, 26 Mar 2014 08:48:30 +0100 Subject: [PATCH 067/722] * grub-core/lib/relocator.c: Fix the case when end of leftover is used. --- ChangeLog | 4 ++++ grub-core/lib/relocator.c | 2 ++ 2 files changed, 6 insertions(+) diff --git a/ChangeLog b/ChangeLog index 44ce649e4..b3f077a5e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2014-03-26 Vladimir Serbinenko + + * grub-core/lib/relocator.c: Fix the case when end of leftover is used. + 2014-03-26 Fu Wei * grub-core/loader/arm64/linux.c: Remove redundant "0x". diff --git a/grub-core/lib/relocator.c b/grub-core/lib/relocator.c index 9f9770bc4..cb11ea5fa 100644 --- a/grub-core/lib/relocator.c +++ b/grub-core/lib/relocator.c @@ -865,6 +865,8 @@ malloc_in_range (struct grub_relocator *rel, % GRUB_RELOCATOR_FIRMWARE_REQUESTS_QUANT; struct grub_relocator_fw_leftover *lo = events[last_lo].leftover; + if (offend == 0 && alloc_end != alloc_start) + offend = GRUB_RELOCATOR_FIRMWARE_REQUESTS_QUANT; lo->freebytes[offstart / 8] &= ((1 << (8 - (start % 8))) - 1); grub_memset (lo->freebytes + (offstart + 7) / 8, 0, From 9b35fe819f642f9277534d97f73024eb6734057d Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Mon, 31 Mar 2014 13:51:17 +0100 Subject: [PATCH 068/722] Fix grub-probe -0 option * util/grub-probe,c (options): Make -0 work again (broken by conversion to argp). (main): Simplify logic. --- ChangeLog | 6 ++++++ util/grub-probe.c | 7 ++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index b3f077a5e..46a656184 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2014-03-31 Colin Watson + + * util/grub-probe,c (options): Make -0 work again (broken by + conversion to argp). + (main): Simplify logic. + 2014-03-26 Vladimir Serbinenko * grub-core/lib/relocator.c: Fix the case when end of leftover is used. diff --git a/util/grub-probe.c b/util/grub-probe.c index 1f3b59f05..80509be8a 100644 --- a/util/grub-probe.c +++ b/util/grub-probe.c @@ -711,6 +711,7 @@ static struct argp_option options[] = { N_("use FILE as the device map [default=%s]"), 0}, {"target", 't', N_("TARGET"), 0, 0, 0}, {"verbose", 'v', 0, 0, N_("print verbose messages."), 0}, + {0, '0', 0, 0, N_("separate items in output using ASCII NUL characters"), 0}, { 0, 0, 0, 0, 0, 0 } }; @@ -884,11 +885,7 @@ main (int argc, char *argv[]) else probe (arguments.devices[0], NULL, delim); - if (!arguments.zero_delim && (print == PRINT_BIOS_HINT - || print == PRINT_IEEE1275_HINT - || print == PRINT_BAREMETAL_HINT - || print == PRINT_EFI_HINT - || print == PRINT_ARC_HINT)) + if (delim == ' ') putchar ('\n'); /* Free resources. */ From 24024dac7f51d3c0df8e1bec63c02d52828de534 Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Mon, 31 Mar 2014 14:48:33 +0100 Subject: [PATCH 069/722] Fix partmap, cryptodisk, and abstraction handling in grub-mkconfig. Commit 588744d0dc655177d5883bdcb8f72ff5160109ed caused grub-mkconfig no longer to be forgiving of trailing spaces on grub-probe output lines, which among other things means that util/grub.d/10_linux.in no longer detects LVM. To fix this, make grub-probe's output delimiting more consistent. As a bonus, this improves the coverage of the -0 option. Fixes Debian bug #735935. * grub-core/disk/cryptodisk.c (grub_util_cryptodisk_get_abstraction): Add a user-data argument. * grub-core/disk/diskfilter.c (grub_diskfilter_get_partmap): Likewise. * include/grub/cryptodisk.h (grub_util_cryptodisk_get_abstraction): Update prototype. * include/grub/diskfilter.h (grub_diskfilter_get_partmap): Likewise. * util/grub-install.c (push_partmap_module, push_cryptodisk_module, probe_mods): Adjust for extra user-data arguments. * util/grub-probe.c (do_print, probe_partmap, probe_cryptodisk_uuid, probe_abstraction): Use configured delimiter. Update callers. --- ChangeLog | 25 ++++++++++++++++++++ grub-core/disk/cryptodisk.c | 19 +++++++-------- grub-core/disk/diskfilter.c | 5 ++-- include/grub/cryptodisk.h | 3 ++- include/grub/diskfilter.h | 3 ++- util/grub-install.c | 14 +++++++---- util/grub-probe.c | 46 ++++++++++++++++++------------------- 7 files changed, 74 insertions(+), 41 deletions(-) diff --git a/ChangeLog b/ChangeLog index 46a656184..d613bf6ae 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,28 @@ +2014-03-31 Colin Watson + + Fix partmap, cryptodisk, and abstraction handling in grub-mkconfig. + + Commit 588744d0dc655177d5883bdcb8f72ff5160109ed caused grub-mkconfig + no longer to be forgiving of trailing spaces on grub-probe output + lines, which among other things means that util/grub.d/10_linux.in + no longer detects LVM. To fix this, make grub-probe's output + delimiting more consistent. As a bonus, this improves the coverage + of the -0 option. + + Fixes Debian bug #735935. + + * grub-core/disk/cryptodisk.c + (grub_util_cryptodisk_get_abstraction): Add a user-data argument. + * grub-core/disk/diskfilter.c (grub_diskfilter_get_partmap): + Likewise. + * include/grub/cryptodisk.h (grub_util_cryptodisk_get_abstraction): + Update prototype. + * include/grub/diskfilter.h (grub_diskfilter_get_partmap): Likewise. + * util/grub-install.c (push_partmap_module, push_cryptodisk_module, + probe_mods): Adjust for extra user-data arguments. + * util/grub-probe.c (do_print, probe_partmap, probe_cryptodisk_uuid, + probe_abstraction): Use configured delimiter. Update callers. + 2014-03-31 Colin Watson * util/grub-probe,c (options): Make -0 work again (broken by diff --git a/grub-core/disk/cryptodisk.c b/grub-core/disk/cryptodisk.c index 75c6e1f91..f0e3a900a 100644 --- a/grub-core/disk/cryptodisk.c +++ b/grub-core/disk/cryptodisk.c @@ -762,25 +762,26 @@ grub_cryptodisk_cheat_insert (grub_cryptodisk_t newdev, const char *name, void grub_util_cryptodisk_get_abstraction (grub_disk_t disk, - void (*cb) (const char *val)) + void (*cb) (const char *val, void *data), + void *data) { grub_cryptodisk_t dev = (grub_cryptodisk_t) disk->data; - cb ("cryptodisk"); - cb (dev->modname); + cb ("cryptodisk", data); + cb (dev->modname, data); if (dev->cipher) - cb (dev->cipher->cipher->modname); + cb (dev->cipher->cipher->modname, data); if (dev->secondary_cipher) - cb (dev->secondary_cipher->cipher->modname); + cb (dev->secondary_cipher->cipher->modname, data); if (dev->essiv_cipher) - cb (dev->essiv_cipher->cipher->modname); + cb (dev->essiv_cipher->cipher->modname, data); if (dev->hash) - cb (dev->hash->modname); + cb (dev->hash->modname, data); if (dev->essiv_hash) - cb (dev->essiv_hash->modname); + cb (dev->essiv_hash->modname, data); if (dev->iv_hash) - cb (dev->iv_hash->modname); + cb (dev->iv_hash->modname, data); } const char * diff --git a/grub-core/disk/diskfilter.c b/grub-core/disk/diskfilter.c index 28b70c666..e8a3bcbd1 100644 --- a/grub-core/disk/diskfilter.c +++ b/grub-core/disk/diskfilter.c @@ -354,7 +354,8 @@ grub_diskfilter_memberlist (grub_disk_t disk) void grub_diskfilter_get_partmap (grub_disk_t disk, - void (*cb) (const char *pm)) + void (*cb) (const char *pm, void *data), + void *data) { struct grub_diskfilter_lv *lv = disk->data; struct grub_diskfilter_pv *pv; @@ -376,7 +377,7 @@ grub_diskfilter_get_partmap (grub_disk_t disk, continue; } for (s = 0; pv->partmaps[s]; s++) - cb (pv->partmaps[s]); + cb (pv->partmaps[s], data); } } diff --git a/include/grub/cryptodisk.h b/include/grub/cryptodisk.h index 66f3e1e22..f2ad2a79a 100644 --- a/include/grub/cryptodisk.h +++ b/include/grub/cryptodisk.h @@ -145,7 +145,8 @@ grub_cryptodisk_cheat_insert (grub_cryptodisk_t newdev, const char *name, grub_disk_t source, const char *cheat); void grub_util_cryptodisk_get_abstraction (grub_disk_t disk, - void (*cb) (const char *val)); + void (*cb) (const char *val, void *data), + void *data); char * grub_util_get_geli_uuid (const char *dev); diff --git a/include/grub/diskfilter.h b/include/grub/diskfilter.h index 042fe04a5..1aedcd3df 100644 --- a/include/grub/diskfilter.h +++ b/include/grub/diskfilter.h @@ -202,7 +202,8 @@ grub_diskfilter_get_pv_from_disk (grub_disk_t disk, struct grub_diskfilter_vg **vg); void grub_diskfilter_get_partmap (grub_disk_t disk, - void (*cb) (const char *val)); + void (*cb) (const char *val, void *data), + void *data); #endif #endif /* ! GRUB_RAID_H */ diff --git a/util/grub-install.c b/util/grub-install.c index 2e6226a37..e9c6a4656 100644 --- a/util/grub-install.c +++ b/util/grub-install.c @@ -387,7 +387,7 @@ probe_raid_level (grub_disk_t disk) } static void -push_partmap_module (const char *map) +push_partmap_module (const char *map, void *data __attribute__ ((unused))) { char buf[50]; @@ -401,6 +401,12 @@ push_partmap_module (const char *map) grub_install_push_module (buf); } +static void +push_cryptodisk_module (const char *mod, void *data __attribute__ ((unused))) +{ + grub_install_push_module (mod); +} + static void probe_mods (grub_disk_t disk) { @@ -412,11 +418,11 @@ probe_mods (grub_disk_t disk) grub_util_info ("no partition map found for %s", disk->name); for (part = disk->partition; part; part = part->parent) - push_partmap_module (part->partmap->name); + push_partmap_module (part->partmap->name, NULL); if (disk->dev->id == GRUB_DISK_DEVICE_DISKFILTER_ID) { - grub_diskfilter_get_partmap (disk, push_partmap_module); + grub_diskfilter_get_partmap (disk, push_partmap_module, NULL); have_abstractions = 1; } @@ -432,7 +438,7 @@ probe_mods (grub_disk_t disk) if (disk->dev->id == GRUB_DISK_DEVICE_CRYPTODISK_ID) { grub_util_cryptodisk_get_abstraction (disk, - grub_install_push_module); + push_cryptodisk_module, NULL); have_abstractions = 1; have_cryptodisk = 1; } diff --git a/util/grub-probe.c b/util/grub-probe.c index 80509be8a..ecb7b6bbd 100644 --- a/util/grub-probe.c +++ b/util/grub-probe.c @@ -130,13 +130,14 @@ get_targets_string (void) } static void -do_print (const char *x) +do_print (const char *x, void *data) { - grub_printf ("%s ", x); + char delim = *(const char *) data; + grub_printf ("%s%c", x, delim); } static void -probe_partmap (grub_disk_t disk) +probe_partmap (grub_disk_t disk, char delim) { grub_partition_t part; grub_disk_memberlist_t list = NULL, tmp; @@ -147,10 +148,10 @@ probe_partmap (grub_disk_t disk) } for (part = disk->partition; part; part = part->parent) - printf ("%s ", part->partmap->name); + printf ("%s%c", part->partmap->name, delim); if (disk->dev->id == GRUB_DISK_DEVICE_DISKFILTER_ID) - grub_diskfilter_get_partmap (disk, do_print); + grub_diskfilter_get_partmap (disk, do_print, &delim); /* In case of LVM/RAID, check the member devices as well. */ if (disk->dev->memberlist) @@ -159,7 +160,7 @@ probe_partmap (grub_disk_t disk) } while (list) { - probe_partmap (list->disk); + probe_partmap (list->disk, delim); tmp = list->next; free (list); list = tmp; @@ -167,7 +168,7 @@ probe_partmap (grub_disk_t disk) } static void -probe_cryptodisk_uuid (grub_disk_t disk) +probe_cryptodisk_uuid (grub_disk_t disk, char delim) { grub_disk_memberlist_t list = NULL, tmp; @@ -178,7 +179,7 @@ probe_cryptodisk_uuid (grub_disk_t disk) } while (list) { - probe_cryptodisk_uuid (list->disk); + probe_cryptodisk_uuid (list->disk, delim); tmp = list->next; free (list); list = tmp; @@ -186,7 +187,7 @@ probe_cryptodisk_uuid (grub_disk_t disk) if (disk->dev->id == GRUB_DISK_DEVICE_CRYPTODISK_ID) { const char *uu = grub_util_cryptodisk_get_uuid (disk); - grub_printf ("%s ", uu); + grub_printf ("%s%c", uu, delim); } } @@ -210,7 +211,7 @@ probe_raid_level (grub_disk_t disk) } static void -probe_abstraction (grub_disk_t disk) +probe_abstraction (grub_disk_t disk, char delim) { grub_disk_memberlist_t list = NULL, tmp; int raid_level; @@ -219,7 +220,7 @@ probe_abstraction (grub_disk_t disk) list = disk->dev->memberlist (disk); while (list) { - probe_abstraction (list->disk); + probe_abstraction (list->disk, delim); tmp = list->next; free (list); @@ -229,26 +230,26 @@ probe_abstraction (grub_disk_t disk) if (disk->dev->id == GRUB_DISK_DEVICE_DISKFILTER_ID && (grub_memcmp (disk->name, "lvm/", sizeof ("lvm/") - 1) == 0 || grub_memcmp (disk->name, "lvmid/", sizeof ("lvmid/") - 1) == 0)) - printf ("lvm "); + printf ("lvm%c", delim); if (disk->dev->id == GRUB_DISK_DEVICE_DISKFILTER_ID && grub_memcmp (disk->name, "ldm/", sizeof ("ldm/") - 1) == 0) - printf ("ldm "); + printf ("ldm%c", delim); if (disk->dev->id == GRUB_DISK_DEVICE_CRYPTODISK_ID) - grub_util_cryptodisk_get_abstraction (disk, do_print); + grub_util_cryptodisk_get_abstraction (disk, do_print, &delim); raid_level = probe_raid_level (disk); if (raid_level >= 0) { - printf ("diskfilter "); + printf ("diskfilter%c", delim); if (disk->dev->raidname) - printf ("%s ", disk->dev->raidname (disk)); + printf ("%s%c", disk->dev->raidname (disk), delim); } if (raid_level == 5) - printf ("raid5rec "); + printf ("raid5rec%c", delim); if (raid_level == 6) - printf ("raid6rec "); + printf ("raid6rec%c", delim); } static void @@ -630,16 +631,14 @@ probe (const char *path, char **device_names, char delim) if (print == PRINT_ABSTRACTION) { - probe_abstraction (dev->disk); - putchar (delim); + probe_abstraction (dev->disk, delim); grub_device_close (dev); continue; } if (print == PRINT_CRYPTODISK_UUID) { - probe_cryptodisk_uuid (dev->disk); - putchar (delim); + probe_cryptodisk_uuid (dev->disk, delim); grub_device_close (dev); continue; } @@ -647,8 +646,7 @@ probe (const char *path, char **device_names, char delim) if (print == PRINT_PARTMAP) { /* Check if dev->disk itself is contained in a partmap. */ - probe_partmap (dev->disk); - putchar (delim); + probe_partmap (dev->disk, delim); grub_device_close (dev); continue; } From 4afd0107efa6a2d9cbe6fc71c529264dc2b9fb8a Mon Sep 17 00:00:00 2001 From: Thomas Falcon Date: Mon, 31 Mar 2014 15:32:30 +0100 Subject: [PATCH 070/722] btrfs: fix get_root key comparison failures due to endianness * grub-core/fs/btrfs.c (get_root): Convert GRUB_BTRFS_ROOT_VOL_OBJECTID to little-endian. --- ChangeLog | 7 +++++++ grub-core/fs/btrfs.c | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index d613bf6ae..6eca73e35 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2014-03-31 Thomas Falcon + + btrfs: fix get_root key comparison failures due to endianness + + * grub-core/fs/btrfs.c (get_root): Convert + GRUB_BTRFS_ROOT_VOL_OBJECTID to little-endian. + 2014-03-31 Colin Watson Fix partmap, cryptodisk, and abstraction handling in grub-mkconfig. diff --git a/grub-core/fs/btrfs.c b/grub-core/fs/btrfs.c index 89666b6fd..f7b6c1520 100644 --- a/grub-core/fs/btrfs.c +++ b/grub-core/fs/btrfs.c @@ -1201,7 +1201,7 @@ get_root (struct grub_btrfs_data *data, struct grub_btrfs_key *key, struct grub_btrfs_key key_out, key_in; struct grub_btrfs_root_item ri; - key_in.object_id = GRUB_BTRFS_ROOT_VOL_OBJECTID; + key_in.object_id = grub_cpu_to_le64_compile_time (GRUB_BTRFS_ROOT_VOL_OBJECTID); key_in.offset = 0; key_in.type = GRUB_BTRFS_ITEM_TYPE_ROOT_ITEM; err = lower_bound (data, &key_in, &key_out, From 9706066791b994a55fb2d3d532a86aa1fde2a457 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Thu, 3 Apr 2014 21:31:12 +0200 Subject: [PATCH 071/722] * grub-core/osdep/linux/getroot.c (grub_util_part_to_disk): Support NVMe device names. --- ChangeLog | 5 +++++ grub-core/osdep/linux/getroot.c | 17 +++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/ChangeLog b/ChangeLog index 6eca73e35..20a366188 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2014-04-03 Vladimir Serbinenko + + * grub-core/osdep/linux/getroot.c (grub_util_part_to_disk): Support NVMe + device names. + 2014-03-31 Thomas Falcon btrfs: fix get_root key comparison failures due to endianness diff --git a/grub-core/osdep/linux/getroot.c b/grub-core/osdep/linux/getroot.c index 19581d329..7007193d9 100644 --- a/grub-core/osdep/linux/getroot.c +++ b/grub-core/osdep/linux/getroot.c @@ -896,6 +896,23 @@ grub_util_part_to_disk (const char *os_dev, struct stat *st, *pp = '\0'; return path; } + + /* If this is a NVMe device */ + if ((strncmp ("nvme", p, 4) == 0) && p[4] >= '0' && p[4] <= '9') + { + char *pp = p + 4; + while (*pp >= '0' && *pp <= '9') + pp++; + if (*pp == 'n') + pp++; + while (*pp >= '0' && *pp <= '9') + pp++; + if (*pp == 'p') + *is_part = 1; + /* /dev/nvme[0-9]+n[0-9]+p[0-9]* */ + *pp = '\0'; + return path; + } } return path; From 8063ce197f3196da077c667ba7a6a82173608fbb Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 4 Apr 2014 07:58:42 +0200 Subject: [PATCH 072/722] Replace few instances of memcmp/memcpy in the code that should be grub_memcmp/grub_memcpy. --- ChangeLog | 5 +++++ grub-core/commands/acpihalt.c | 4 ++-- grub-core/commands/legacycfg.c | 4 ++-- grub-core/lib/relocator.c | 2 +- grub-core/loader/i386/bsd.c | 4 ++-- 5 files changed, 12 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 20a366188..f633fae06 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2014-04-04 Vladimir Serbinenko + + Replace few instances of memcmp/memcpy in the code that should be + grub_memcmp/grub_memcpy. + 2014-04-03 Vladimir Serbinenko * grub-core/osdep/linux/getroot.c (grub_util_part_to_disk): Support NVMe diff --git a/grub-core/commands/acpihalt.c b/grub-core/commands/acpihalt.c index 09421a6c6..83bdfe1f2 100644 --- a/grub-core/commands/acpihalt.c +++ b/grub-core/commands/acpihalt.c @@ -214,8 +214,8 @@ get_sleep_type (grub_uint8_t *table, grub_uint8_t *ptr, grub_uint8_t *end, } case GRUB_ACPI_OPCODE_NAME: ptr++; - if ((!scope || memcmp (scope, "\\", scope_len) == 0) && - (memcmp (ptr, "_S5_", 4) == 0 || memcmp (ptr, "\\_S5_", 4) == 0)) + if ((!scope || grub_memcmp (scope, "\\", scope_len) == 0) && + (grub_memcmp (ptr, "_S5_", 4) == 0 || grub_memcmp (ptr, "\\_S5_", 4) == 0)) { int ll; grub_uint8_t *ptr2 = ptr; diff --git a/grub-core/commands/legacycfg.c b/grub-core/commands/legacycfg.c index e42a9d83e..2c09fb7dd 100644 --- a/grub-core/commands/legacycfg.c +++ b/grub-core/commands/legacycfg.c @@ -580,7 +580,7 @@ check_password_md5_real (const char *entered, GRUB_MD_MD5->write (ctx, entered, enteredlen); digest = GRUB_MD_MD5->read (ctx); GRUB_MD_MD5->final (ctx); - memcpy (alt_result, digest, MD5_HASHLEN); + grub_memcpy (alt_result, digest, MD5_HASHLEN); GRUB_MD_MD5->init (ctx); GRUB_MD_MD5->write (ctx, entered, enteredlen); @@ -596,7 +596,7 @@ check_password_md5_real (const char *entered, for (i = 0; i < 1000; i++) { - memcpy (alt_result, digest, 16); + grub_memcpy (alt_result, digest, 16); GRUB_MD_MD5->init (ctx); if ((i & 1) != 0) diff --git a/grub-core/lib/relocator.c b/grub-core/lib/relocator.c index cb11ea5fa..f759c7f41 100644 --- a/grub-core/lib/relocator.c +++ b/grub-core/lib/relocator.c @@ -652,7 +652,7 @@ malloc_in_range (struct grub_relocator *rel, for (i = 0; i < (BITS_IN_BYTE * sizeof (grub_addr_t) / DIGITSORT_BITS); i++) { - memset (counter, 0, (1 + (1 << DIGITSORT_BITS)) * sizeof (counter[0])); + grub_memset (counter, 0, (1 + (1 << DIGITSORT_BITS)) * sizeof (counter[0])); for (j = 0; j < N; j++) counter[((events[j].pos >> (DIGITSORT_BITS * i)) & DIGITSORT_MASK) + 1]++; diff --git a/grub-core/loader/i386/bsd.c b/grub-core/loader/i386/bsd.c index 19985f03e..41ef9109e 100644 --- a/grub-core/loader/i386/bsd.c +++ b/grub-core/loader/i386/bsd.c @@ -1082,7 +1082,7 @@ grub_netbsd_add_boot_disk_and_wedge (void) grub_crypto_hash (GRUB_MD_MD5, hash, buf.raw, GRUB_DISK_SECTOR_SIZE); - memcpy (biw.matchhash, hash, 16); + grub_memcpy (biw.matchhash, hash, 16); grub_bsd_add_meta (NETBSD_BTINFO_BOOTWEDGE, &biw, sizeof (biw)); } @@ -1100,7 +1100,7 @@ grub_netbsd_add_boot_disk_and_wedge (void) bid.labelsector = partmapsector; bid.label.type = buf.label.type; bid.label.checksum = buf.label.checksum; - memcpy (bid.label.packname, buf.label.packname, 16); + grub_memcpy (bid.label.packname, buf.label.packname, 16); } else { From 6f6d4aa02cbc522fadbc8dc42a43dedfca40da0d Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 4 Apr 2014 08:02:38 +0200 Subject: [PATCH 073/722] * include/grub/libgcc.h: Remove ctzsi2 and ctzdi2. They're no longer pulled from libgcc. --- ChangeLog | 5 +++++ include/grub/libgcc.h | 7 ------- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index f633fae06..094fbcad2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2014-04-04 Vladimir Serbinenko + + * include/grub/libgcc.h: Remove ctzsi2 and ctzdi2. They're no longer + pulled from libgcc. + 2014-04-04 Vladimir Serbinenko Replace few instances of memcmp/memcpy in the code that should be diff --git a/include/grub/libgcc.h b/include/grub/libgcc.h index fdc6611a0..97233d79e 100644 --- a/include/grub/libgcc.h +++ b/include/grub/libgcc.h @@ -42,13 +42,6 @@ void EXPORT_FUNC (__bswapsi2) (void); # ifdef HAVE___BSWAPDI2 void EXPORT_FUNC (__bswapdi2) (void); # endif -# ifdef HAVE___CTZDI2 -void EXPORT_FUNC (__ctzdi2) (void); -# endif -# ifdef HAVE___CTZSI2 -void EXPORT_FUNC (__ctzsi2) (void); -# endif -#endif #ifdef HAVE__RESTGPR_14_X void EXPORT_FUNC (_restgpr_14_x) (void); From 2009da62f2fa19634c4485edaccf9c88ab98b276 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 4 Apr 2014 08:11:15 +0200 Subject: [PATCH 074/722] Add missing #endif --- include/grub/libgcc.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/grub/libgcc.h b/include/grub/libgcc.h index 97233d79e..8e93b6792 100644 --- a/include/grub/libgcc.h +++ b/include/grub/libgcc.h @@ -42,6 +42,7 @@ void EXPORT_FUNC (__bswapsi2) (void); # ifdef HAVE___BSWAPDI2 void EXPORT_FUNC (__bswapdi2) (void); # endif +#endif #ifdef HAVE__RESTGPR_14_X void EXPORT_FUNC (_restgpr_14_x) (void); From a72fc329ebd81c03d7a2e6ad422e573e5a4d3213 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sun, 6 Apr 2014 00:44:44 +0200 Subject: [PATCH 075/722] * grub-core/lib/syslinux_parse.c: Fix timeout quoting. --- ChangeLog | 4 ++++ grub-core/lib/syslinux_parse.c | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 094fbcad2..11de90895 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2014-04-06 Vladimir Serbinenko + + * grub-core/lib/syslinux_parse.c: Fix timeout quoting. + 2014-04-04 Vladimir Serbinenko * include/grub/libgcc.h: Remove ctzsi2 and ctzdi2. They're no longer diff --git a/grub-core/lib/syslinux_parse.c b/grub-core/lib/syslinux_parse.c index 21fa17504..6bc504b7c 100644 --- a/grub-core/lib/syslinux_parse.c +++ b/grub-core/lib/syslinux_parse.c @@ -1432,7 +1432,7 @@ config_file (struct output_buffer *outbuf, for (curentry = menu.entries; curentry->next; curentry = curentry->next); lentry = curentry; - print_string ("set timeout='"); + print_string ("set timeout="); err = print_num (outbuf, (menu.timeout + 9) / 10); if (err) return err; From c4badfe8363cc41dbedfabaa238b6c8a884e03c8 Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Thu, 10 Apr 2014 14:42:41 +0100 Subject: [PATCH 076/722] Improve LVM "logical_volumes" string matching * grub-core/disk/lvm.c (grub_lvm_detect): Search for "logical_volumes" block a little more accurately. --- ChangeLog | 5 +++++ grub-core/disk/lvm.c | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 11de90895..c98e0df79 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2014-04-10 Colin Watson + + * grub-core/disk/lvm.c (grub_lvm_detect): Search for + "logical_volumes" block a little more accurately. + 2014-04-06 Vladimir Serbinenko * grub-core/lib/syslinux_parse.c: Fix timeout quoting. diff --git a/grub-core/disk/lvm.c b/grub-core/disk/lvm.c index 483c17eb5..862a9664f 100644 --- a/grub-core/disk/lvm.c +++ b/grub-core/disk/lvm.c @@ -333,10 +333,10 @@ grub_lvm_detect (grub_disk_t disk, } } - p = grub_strstr (p, "logical_volumes"); + p = grub_strstr (p, "logical_volumes {"); if (p) { - p += sizeof ("logical_volumes = ") - 1; + p += sizeof ("logical_volumes {") - 1; /* And add all the lvs to the volume group. */ while (1) From 3a310e842fb7a9818c2e7cf0f4118f13660871d2 Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Thu, 10 Apr 2014 16:54:33 +0100 Subject: [PATCH 077/722] Tolerate devices with no filesystem UUID returned by os-prober * util/grub.d/30_os-prober.in: Tolerate devices with no filesystem UUID. Other parts of grub-mkconfig tolerate these, they were previously allowed here up to commit 55e706c918922def17f5012c23cfe88c4c645208, and they can arise in practice when the system has active LVM snapshots. Fixes Ubuntu bug #1287436. --- ChangeLog | 9 +++++++++ util/grub.d/30_os-prober.in | 23 +++++++++++++---------- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index c98e0df79..30d0cace4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2014-04-10 Colin Watson + + * util/grub.d/30_os-prober.in: Tolerate devices with no filesystem + UUID. Other parts of grub-mkconfig tolerate these, they were + previously allowed here up to commit + 55e706c918922def17f5012c23cfe88c4c645208, and they can arise in + practice when the system has active LVM snapshots. + Fixes Ubuntu bug #1287436. + 2014-04-10 Colin Watson * grub-core/disk/lvm.c (grub_lvm_detect): Search for diff --git a/util/grub.d/30_os-prober.in b/util/grub.d/30_os-prober.in index 7cf8487d6..6f38c82a5 100644 --- a/util/grub.d/30_os-prober.in +++ b/util/grub.d/30_os-prober.in @@ -112,16 +112,17 @@ for OS in ${OSPROBED} ; do LONGNAME="`echo ${OS} | cut -d ':' -f 2 | tr '^' ' '`" LABEL="`echo ${OS} | cut -d ':' -f 3 | tr '^' ' '`" BOOT="`echo ${OS} | cut -d ':' -f 4`" - UUID="`${grub_probe} --target=fs_uuid --device ${DEVICE%@*}`" - EXPUUID="$UUID" + if UUID="`${grub_probe} --target=fs_uuid --device ${DEVICE%@*}`"; then + EXPUUID="$UUID" - if [ x"${DEVICE#*@}" != x ] ; then + if [ x"${DEVICE#*@}" != x ] ; then EXPUUID="${EXPUUID}@${DEVICE#*@}" - fi + fi - if [ "x${GRUB_OS_PROBER_SKIP_LIST}" != "x" ] && [ "x`echo ${GRUB_OS_PROBER_SKIP_LIST} | grep -i -e '\b'${EXPUUID}'\b'`" != "x" ] ; then - echo "Skipped ${LONGNAME} on ${DEVICE} by user request." >&2 - continue + if [ "x${GRUB_OS_PROBER_SKIP_LIST}" != "x" ] && [ "x`echo ${GRUB_OS_PROBER_SKIP_LIST} | grep -i -e '\b'${EXPUUID}'\b'`" != "x" ] ; then + echo "Skipped ${LONGNAME} on ${DEVICE} by user request." >&2 + continue + fi fi BTRFS="`echo ${OS} | cut -d ':' -f 5`" @@ -277,9 +278,11 @@ EOF echo "$title_correction_code" ;; macosx) - OSXUUID="${UUID}" - osx_entry xnu_kernel 32 - osx_entry xnu_kernel64 64 + if [ "${UUID}" ]; then + OSXUUID="${UUID}" + osx_entry xnu_kernel 32 + osx_entry xnu_kernel64 64 + fi ;; hurd) onstr="$(gettext_printf "(on %s)" "${DEVICE}")" From 5a6db38d62235094a903882b71ef2749b4c19cbb Mon Sep 17 00:00:00 2001 From: Piotr Krysiuk Date: Sun, 20 Apr 2014 15:58:45 +0200 Subject: [PATCH 078/722] Allow loading old kernels by placing GDT in conventional memory. --- ChangeLog | 5 +++++ grub-core/lib/i386/relocator.c | 11 +++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 30d0cace4..1be8e5e64 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2014-04-20 Piotr Krysiuk + + * grub-core/lib/i386/relocator.c: Allow loading old kernels by placing + GDT in conventional memory. + 2014-04-10 Colin Watson * util/grub.d/30_os-prober.in: Tolerate devices with no filesystem diff --git a/grub-core/lib/i386/relocator.c b/grub-core/lib/i386/relocator.c index d2a1b27ae..ffaf25f08 100644 --- a/grub-core/lib/i386/relocator.c +++ b/grub-core/lib/i386/relocator.c @@ -81,10 +81,13 @@ grub_relocator32_boot (struct grub_relocator *rel, void *relst; grub_relocator_chunk_t ch; - err = grub_relocator_alloc_chunk_align (rel, &ch, 0, - (0xffffffff - RELOCATOR_SIZEOF (32)) - + 1, RELOCATOR_SIZEOF (32), 16, - GRUB_RELOCATOR_PREFERENCE_NONE, + /* Specific memory range due to Global Descriptor Table for use by payload + that we will store in returned chunk. The address range and preference + are based on "THE LINUX/x86 BOOT PROTOCOL" specification. */ + err = grub_relocator_alloc_chunk_align (rel, &ch, 0x1000, + 0x9a000 - RELOCATOR_SIZEOF (32), + RELOCATOR_SIZEOF (32), 16, + GRUB_RELOCATOR_PREFERENCE_LOW, avoid_efi_bootservices); if (err) return err; From 4b8b9135f1676924a8458da528d264bbc7bbb301 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sun, 20 Apr 2014 16:12:41 +0200 Subject: [PATCH 079/722] * grub-core/kern/misc.c (__bzero): Don't compile in GRUB_UTIL. Reported by: Yves Blusseau . --- ChangeLog | 6 ++++++ grub-core/kern/misc.c | 3 +++ 2 files changed, 9 insertions(+) diff --git a/ChangeLog b/ChangeLog index 1be8e5e64..ba5e2054f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2014-04-20 Vladimir Serbinenko + + * grub-core/kern/misc.c (__bzero): Don't compile in GRUB_UTIL. + + Reported by: Yves Blusseau . + 2014-04-20 Piotr Krysiuk * grub-core/lib/i386/relocator.c: Allow loading old kernels by placing diff --git a/grub-core/kern/misc.c b/grub-core/kern/misc.c index 54db2e125..c5c815d8d 100644 --- a/grub-core/kern/misc.c +++ b/grub-core/kern/misc.c @@ -542,6 +542,9 @@ memset (void *s, int c, grub_size_t n) return grub_memset (s, c, n); } +#endif + +#if !defined(GRUB_UTIL) && defined(__APPLE__) void GRUB_BUILTIN_ATTR __bzero (void *s, grub_size_t n) { From 480c89858e58a2360d62fdafbeda3e7080133e9e Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 12 May 2014 10:01:48 +0200 Subject: [PATCH 080/722] * grub-core/commands/verify.c (grub_pubkey_open): Fix memdisk check. --- ChangeLog | 5 +++++ grub-core/commands/verify.c | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index ba5e2054f..c32d4c6f4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2014-06-21 Vladimir Serbinenko + + * grub-core/commands/verify.c (grub_pubkey_open): Fix memdisk + check. + 2014-04-20 Vladimir Serbinenko * grub-core/kern/misc.c (__bzero): Don't compile in GRUB_UTIL. diff --git a/grub-core/commands/verify.c b/grub-core/commands/verify.c index a9dfd8852..6349ccfba 100644 --- a/grub-core/commands/verify.c +++ b/grub-core/commands/verify.c @@ -835,7 +835,7 @@ grub_pubkey_open (grub_file_t io, const char *filename) if (!sec) return io; - if (io->device->disk && io->device->disk->id == GRUB_DISK_DEVICE_MEMDISK_ID) + if (io->device->disk && io->device->disk->dev->id == GRUB_DISK_DEVICE_MEMDISK_ID) return io; fsuf = grub_malloc (grub_strlen (filename) + sizeof (".sig")); if (!fsuf) From 2c2c5c720d79c54af39a5a4423f2d6a48d21bfda Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Thu, 15 May 2014 14:36:48 +0200 Subject: [PATCH 081/722] * grub-core/commands/verify.c (grub_pubkey_open): Trust procfs. --- ChangeLog | 4 ++++ grub-core/commands/verify.c | 4 +++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index c32d4c6f4..6d2f8c635 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2014-06-21 Vladimir Serbinenko + + * grub-core/commands/verify.c (grub_pubkey_open): Trust procfs. + 2014-06-21 Vladimir Serbinenko * grub-core/commands/verify.c (grub_pubkey_open): Fix memdisk diff --git a/grub-core/commands/verify.c b/grub-core/commands/verify.c index 6349ccfba..525bdd187 100644 --- a/grub-core/commands/verify.c +++ b/grub-core/commands/verify.c @@ -835,7 +835,9 @@ grub_pubkey_open (grub_file_t io, const char *filename) if (!sec) return io; - if (io->device->disk && io->device->disk->dev->id == GRUB_DISK_DEVICE_MEMDISK_ID) + if (io->device->disk && + (io->device->disk->dev->id == GRUB_DISK_DEVICE_MEMDISK_ID + || io->device->disk->dev->id == GRUB_DISK_DEVICE_PROCFS_ID)) return io; fsuf = grub_malloc (grub_strlen (filename) + sizeof (".sig")); if (!fsuf) From 87de66d9d83446ecddb29cfbdf7369102c8e209e Mon Sep 17 00:00:00 2001 From: Trevor Woerner Date: Sat, 21 Jun 2014 20:26:47 +0200 Subject: [PATCH 082/722] * util/grub-gen-asciih.c (add_glyph): Fix uninitialised variable. --- ChangeLog | 4 ++++ util/grub-gen-asciih.c | 15 +++++++++------ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6d2f8c635..8929dbbbb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2014-06-21 Trevor Woerner + + * util/grub-gen-asciih.c (add_glyph): Fix uninitialised variable. + 2014-06-21 Vladimir Serbinenko * grub-core/commands/verify.c (grub_pubkey_open): Trust procfs. diff --git a/util/grub-gen-asciih.c b/util/grub-gen-asciih.c index e01447ae9..e35dcb78f 100644 --- a/util/grub-gen-asciih.c +++ b/util/grub-gen-asciih.c @@ -81,14 +81,14 @@ add_glyph (FT_UInt glyph_idx, FT_Face face, err = FT_Load_Glyph (face, glyph_idx, flag); if (err) { - printf ("Freetype Error %d loading glyph 0x%x for U+0x%x", + fprintf (stderr, "Freetype Error %d loading glyph 0x%x for U+0x%x", err, glyph_idx, char_code); if (err > 0 && err < (signed) ARRAY_SIZE (ft_errmsgs)) - printf (": %s\n", ft_errmsgs[err]); + fprintf (stderr, ": %s\n", ft_errmsgs[err]); else - printf ("\n"); - return; + fprintf (stderr, "\n"); + exit (1); } glyph = face->glyph; @@ -128,7 +128,6 @@ add_glyph (FT_UInt glyph_idx, FT_Face face, static void write_font_ascii_bitmap (FILE *file, FT_Face face) { - struct grub_glyph_info glyph; int char_code; fprintf (file, "/* THIS CHUNK OF BYTES IS AUTOMATICALLY GENERATED */\n"); @@ -138,10 +137,14 @@ write_font_ascii_bitmap (FILE *file, FT_Face face) for (char_code = 0; char_code <= 0x7f; char_code++) { FT_UInt glyph_idx; - + struct grub_glyph_info glyph; + glyph_idx = FT_Get_Char_Index (face, char_code); if (!glyph_idx) return; + + memset (&glyph, 0, sizeof(glyph)); + add_glyph (glyph_idx, face, char_code, &glyph); if (glyph.width == 8 && glyph.height == 16 From 3f3ec8ef44f484ef581d030b0d8500c8906b673f Mon Sep 17 00:00:00 2001 From: Stephane Rochoy Date: Sun, 22 Jun 2014 01:34:57 +0200 Subject: [PATCH 083/722] * grub-core/commands/efi/lsefisystab.c (grub_cmd_lsefisystab): Show EFI system table physical address. --- ChangeLog | 5 +++++ grub-core/commands/efi/lsefisystab.c | 1 + 2 files changed, 6 insertions(+) diff --git a/ChangeLog b/ChangeLog index 8929dbbbb..1dba603ca 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2014-06-21 Stephane Rochoy + + * grub-core/commands/efi/lsefisystab.c (grub_cmd_lsefisystab): Show + EFI system table physical address. + 2014-06-21 Trevor Woerner * util/grub-gen-asciih.c (add_glyph): Fix uninitialised variable. diff --git a/grub-core/commands/efi/lsefisystab.c b/grub-core/commands/efi/lsefisystab.c index eda8c5ff3..8717db91e 100644 --- a/grub-core/commands/efi/lsefisystab.c +++ b/grub-core/commands/efi/lsefisystab.c @@ -52,6 +52,7 @@ grub_cmd_lsefisystab (struct grub_command *cmd __attribute__ ((unused)), grub_efi_configuration_table_t *t; unsigned int i; + grub_printf ("Address: %p\n", st); grub_printf ("Signature: %016" PRIxGRUB_UINT64_T " revision: %08x\n", st->hdr.signature, st->hdr.revision); { From 15bd333e10b236fd24d17b2b23065f14d70ce478 Mon Sep 17 00:00:00 2001 From: Stephane Rochoy Date: Sun, 22 Jun 2014 01:35:52 +0200 Subject: [PATCH 084/722] * grub-core/loader/i386/bsd.c (grub_netbsd_boot): Pass pointer to EFI system table. --- ChangeLog | 5 +++++ grub-core/loader/i386/bsd.c | 8 ++++++++ include/grub/i386/netbsd_bootinfo.h | 7 +++++++ 3 files changed, 20 insertions(+) diff --git a/ChangeLog b/ChangeLog index 1dba603ca..ee46a4dfa 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2014-06-21 Stephane Rochoy + + * grub-core/loader/i386/bsd.c (grub_netbsd_boot): Pass pointer to + EFI system table. + 2014-06-21 Stephane Rochoy * grub-core/commands/efi/lsefisystab.c (grub_cmd_lsefisystab): Show diff --git a/grub-core/loader/i386/bsd.c b/grub-core/loader/i386/bsd.c index 41ef9109e..8f691e0e2 100644 --- a/grub-core/loader/i386/bsd.c +++ b/grub-core/loader/i386/bsd.c @@ -1145,6 +1145,14 @@ grub_netbsd_boot (void) if (err) return err; +#ifdef GRUB_MACHINE_EFI + err = grub_bsd_add_meta (NETBSD_BTINFO_EFI, + &grub_efi_system_table, + sizeof (grub_efi_system_table)); + if (err) + return err; +#endif + { struct bsd_tag *tag; tag_buf_len = 0; diff --git a/include/grub/i386/netbsd_bootinfo.h b/include/grub/i386/netbsd_bootinfo.h index e48c19b40..9b4f46041 100644 --- a/include/grub/i386/netbsd_bootinfo.h +++ b/include/grub/i386/netbsd_bootinfo.h @@ -58,6 +58,8 @@ #define NETBSD_BTINFO_BOOTWEDGE 10 #define NETBSD_BTINFO_MODULES 11 #define NETBSD_BTINFO_FRAMEBUF 12 +#define NETBSD_BTINFO_USERCONFCOMMANDS 13 +#define NETBSD_BTINFO_EFI 14 struct grub_netbsd_bootinfo { @@ -146,4 +148,9 @@ struct grub_netbsd_btinfo_framebuf #define GRUB_NETBSD_MAX_ROOTDEVICE_LEN 16 +struct grub_netbsd_btinfo_efi +{ + void *pa_systbl; /* Physical address of the EFI System Table */ +}; + #endif From fa33530870839e303354ff2660baeff5356ea736 Mon Sep 17 00:00:00 2001 From: Glenn Washburn Date: Sun, 22 Jun 2014 01:45:11 +0200 Subject: [PATCH 085/722] * util/grub-install.c: Fix handling of --disk-module. --- ChangeLog | 4 ++++ util/grub-install.c | 3 +-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index ee46a4dfa..03eedb3ad 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2014-06-21 Glenn Washburn + + * util/grub-install.c: Fix handling of --disk-module. + 2014-06-21 Stephane Rochoy * grub-core/loader/i386/bsd.c (grub_netbsd_boot): Pass pointer to diff --git a/util/grub-install.c b/util/grub-install.c index e9c6a4656..7d61c32be 100644 --- a/util/grub-install.c +++ b/util/grub-install.c @@ -94,7 +94,6 @@ enum OPTION_RECHECK, OPTION_FORCE, OPTION_FORCE_FILE_ID, - OPTION_MODULE, OPTION_NO_NVRAM, OPTION_REMOVABLE, OPTION_BOOTLOADER_ID, @@ -273,7 +272,7 @@ static struct argp_option options[] = { N_("install even if problems are detected"), 2}, {"force-file-id", OPTION_FORCE_FILE_ID, 0, 0, N_("use identifier file even if UUID is available"), 2}, - {"disk-module", OPTION_MODULE, N_("MODULE"), 0, + {"disk-module", OPTION_DISK_MODULE, N_("MODULE"), 0, N_("disk module to use (biosdisk or native). " "This option is only available on BIOS target."), 2}, {"no-nvram", OPTION_NO_NVRAM, 0, 0, From 1f6af2a9f8b02a71f213b4717d8e62c8a6b14fc5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A0=D0=BE=D0=BC=D0=B0=D0=BD=20=D0=9F=D0=B5=D1=85=D0=BE?= =?UTF-8?q?=D0=B2?= Date: Sun, 22 Jun 2014 03:51:50 +0400 Subject: [PATCH 086/722] * grub-core/commands/loadenv.c (check_blocklists): Fix overlap check. --- ChangeLog | 4 ++++ grub-core/commands/loadenv.c | 13 ++----------- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index 03eedb3ad..be322d48c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2014-06-21 Роман Пехов + + * grub-core/commands/loadenv.c (check_blocklists): Fix overlap check. + 2014-06-21 Glenn Washburn * util/grub-install.c: Fix handling of --disk-module. diff --git a/grub-core/commands/loadenv.c b/grub-core/commands/loadenv.c index 6af811207..acd93d123 100644 --- a/grub-core/commands/loadenv.c +++ b/grub-core/commands/loadenv.c @@ -263,7 +263,7 @@ check_blocklists (grub_envblk_t envblk, struct blocklist *blocklists, for (q = p->next; q; q = q->next) { grub_disk_addr_t s1, s2; - grub_disk_addr_t e1, e2, t; + grub_disk_addr_t e1, e2; s1 = p->sector; e1 = s1 + ((p->length + GRUB_DISK_SECTOR_SIZE - 1) >> GRUB_DISK_SECTOR_BITS); @@ -271,16 +271,7 @@ check_blocklists (grub_envblk_t envblk, struct blocklist *blocklists, s2 = q->sector; e2 = s2 + ((q->length + GRUB_DISK_SECTOR_SIZE - 1) >> GRUB_DISK_SECTOR_BITS); - if (s2 > s1) - { - t = s2; - s2 = s1; - s1 = t; - t = e2; - e2 = e1; - e1 = t; - } - if (e1 > s2) + if (s1 < e2 && s2 < e1) { /* This might be actually valid, but it is unbelievable that any filesystem makes such a silly allocation. */ From 4250f552a6c78f5547d45c77b46ea11c5e8e394d Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Thu, 26 Jun 2014 14:20:17 +0100 Subject: [PATCH 087/722] * docs/grub-dev.texi (Finding your way around): The build system no longer uses AutoGen directly. --- ChangeLog | 5 +++++ docs/grub-dev.texi | 6 +++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index be322d48c..5109c5a61 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2014-06-26 Colin Watson + + * docs/grub-dev.texi (Finding your way around): The build system no + longer uses AutoGen directly. + 2014-06-21 Роман Пехов * grub-core/commands/loadenv.c (check_blocklists): Fix overlap check. diff --git a/docs/grub-dev.texi b/docs/grub-dev.texi index 7c6244cdb..a9f4de631 100644 --- a/docs/grub-dev.texi +++ b/docs/grub-dev.texi @@ -228,12 +228,12 @@ The opening @samp{/*} and closing @samp{*/} should be placed together on a line Here is a brief map of the GRUB code base. GRUB uses Autoconf and Automake, with most of the Automake input generated -by AutoGen. The top-level build rules are in @file{configure.ac}, +by a Python script. The top-level build rules are in @file{configure.ac}, @file{grub-core/Makefile.core.def}, and @file{Makefile.util.def}. Each block in a @file{*.def} file represents a build target, and specifies the source files used to build it on various platforms. The @file{*.def} files -are processed into AutoGen input by @file{gentpl.py} (which you only need to -look at if you are extending the build system). If you are adding a new +are processed into Automake input by @file{gentpl.py} (which you only need +to look at if you are extending the build system). If you are adding a new module which follows an existing pattern, such as a new command or a new filesystem implementation, it is usually easiest to grep @file{grub-core/Makefile.core.def} and @file{Makefile.util.def} for an From 0901e7855f922e770cbfeb58262cb8fded518190 Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Tue, 8 Jul 2014 23:54:30 +0100 Subject: [PATCH 088/722] Fix an infinite loop in grub-mkconfig * util/grub.d/10_hurd.in: Make kernel list progression not fail on kernels whose paths contain regex metacharacters. * util/grub.d/10_kfreebsd.in: Likewise. * util/grub.d/10_linux.in: Likewise. * util/grub.d/20_linux_xen.in: Likewise. Reported by: Heimo Stranner. --- ChangeLog | 10 ++++++++++ util/grub.d/10_hurd.in | 2 +- util/grub.d/10_kfreebsd.in | 2 +- util/grub.d/10_linux.in | 2 +- util/grub.d/20_linux_xen.in | 4 ++-- 5 files changed, 15 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5109c5a61..ccd8ac1f1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2014-07-08 Colin Watson + + * util/grub.d/10_hurd.in: Make kernel list progression not fail on + kernels whose paths contain regex metacharacters. + * util/grub.d/10_kfreebsd.in: Likewise. + * util/grub.d/10_linux.in: Likewise. + * util/grub.d/20_linux_xen.in: Likewise. + + Reported by: Heimo Stranner. + 2014-06-26 Colin Watson * docs/grub-dev.texi (Finding your way around): The build system no diff --git a/util/grub.d/10_hurd.in b/util/grub.d/10_hurd.in index 82dfe193f..29b455423 100644 --- a/util/grub.d/10_hurd.in +++ b/util/grub.d/10_hurd.in @@ -168,7 +168,7 @@ while [ "x$kernels" != "x" ] ; do hurd_entry "$kernel" advanced hurd_entry "$kernel" recovery - kernels=`echo $kernels | tr ' ' '\n' | grep -vx $kernel | tr '\n' ' '` + kernels=`echo $kernels | tr ' ' '\n' | fgrep -vx "$kernel" | tr '\n' ' '` done # If at least one kernel was found, then we need to diff --git a/util/grub.d/10_kfreebsd.in b/util/grub.d/10_kfreebsd.in index a524762fc..ba7175bd7 100644 --- a/util/grub.d/10_kfreebsd.in +++ b/util/grub.d/10_kfreebsd.in @@ -228,7 +228,7 @@ while [ "x$list" != "x" ] ; do kfreebsd_entry "${OS}" "${version}" recovery "-s" fi - list=`echo $list | tr ' ' '\n' | grep -vx $kfreebsd | tr '\n' ' '` + list=`echo $list | tr ' ' '\n' | fgrep -vx "$kfreebsd" | tr '\n' ' '` done # If at least one kernel was found, then we need to diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in index 00d193159..d2e2a8fd3 100644 --- a/util/grub.d/10_linux.in +++ b/util/grub.d/10_linux.in @@ -241,7 +241,7 @@ while [ "x$list" != "x" ] ; do "single ${GRUB_CMDLINE_LINUX}" fi - list=`echo $list | tr ' ' '\n' | grep -vx $linux | tr '\n' ' '` + list=`echo $list | tr ' ' '\n' | fgrep -vx "$linux" | tr '\n' ' '` done # If at least one kernel was found, then we need to diff --git a/util/grub.d/20_linux_xen.in b/util/grub.d/20_linux_xen.in index a60843500..2e777584c 100644 --- a/util/grub.d/20_linux_xen.in +++ b/util/grub.d/20_linux_xen.in @@ -255,12 +255,12 @@ while [ "x${xen_list}" != "x" ] ; do "single ${GRUB_CMDLINE_LINUX}" "${GRUB_CMDLINE_XEN}" fi - list=`echo $list | tr ' ' '\n' | grep -vx $linux | tr '\n' ' '` + list=`echo $list | tr ' ' '\n' | fgrep -vx "$linux" | tr '\n' ' '` done if [ x"$is_top_level" != xtrue ]; then echo ' }' fi - xen_list=`echo $xen_list | tr ' ' '\n' | grep -vx $current_xen | tr '\n' ' '` + xen_list=`echo $xen_list | tr ' ' '\n' | fgrep -vx "$current_xen" | tr '\n' ' '` done # If at least one kernel was found, then we need to From 33f6ce671f984465e0f8f9c96927c087b6d0c1a1 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sun, 10 Aug 2014 09:50:36 +0200 Subject: [PATCH 089/722] * grub-core/fs/cbfs.c: Don't probe disks of unknow size. Fixes hang on virtualbox. --- ChangeLog | 4 ++++ grub-core/fs/cbfs.c | 3 +++ 2 files changed, 7 insertions(+) diff --git a/ChangeLog b/ChangeLog index ccd8ac1f1..47ff3552c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2014-08-10 Vladimir Serbinenko + + * grub-core/fs/cbfs.c: Don't probe disks of unknow size. + 2014-07-08 Colin Watson * util/grub.d/10_hurd.in: Make kernel list progression not fail on diff --git a/grub-core/fs/cbfs.c b/grub-core/fs/cbfs.c index 7ad148361..35750a0e4 100644 --- a/grub-core/fs/cbfs.c +++ b/grub-core/fs/cbfs.c @@ -149,6 +149,9 @@ grub_cbfs_mount (grub_disk_t disk) grub_off_t header_off; struct cbfs_header head; + if (grub_disk_get_size (disk) == GRUB_DISK_SIZE_UNKNOWN) + goto fail; + if (grub_disk_read (disk, grub_disk_get_size (disk) - 1, GRUB_DISK_SECTOR_SIZE - sizeof (ptr), sizeof (ptr), &ptr)) From 79c80b06b80c680e584038537098b9e433415465 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sun, 10 Aug 2014 10:04:04 +0200 Subject: [PATCH 090/722] Fix Changelog --- ChangeLog | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ChangeLog b/ChangeLog index 47ff3552c..cab1427cd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,8 @@ * grub-core/fs/cbfs.c: Don't probe disks of unknow size. + Fixes hang on virtualbox. + 2014-07-08 Colin Watson * util/grub.d/10_hurd.in: Make kernel list progression not fail on From 0af3ae2d8b31e31c991eb7dd1d4b79e698907c8d Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sun, 10 Aug 2014 11:27:13 +0200 Subject: [PATCH 091/722] * grub-core/disk/i386/pc/biosdisk.c (grub_biosdisk_rw): Add safety to avoid triggerring VirtualBox bug. --- ChangeLog | 5 +++++ grub-core/disk/i386/pc/biosdisk.c | 8 ++++++++ 2 files changed, 13 insertions(+) diff --git a/ChangeLog b/ChangeLog index cab1427cd..9e159a8da 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2014-08-10 Vladimir Serbinenko + + * grub-core/disk/i386/pc/biosdisk.c (grub_biosdisk_rw): Add + safety to avoid triggerring VirtualBox bug. + 2014-08-10 Vladimir Serbinenko * grub-core/fs/cbfs.c: Don't probe disks of unknow size. diff --git a/grub-core/disk/i386/pc/biosdisk.c b/grub-core/disk/i386/pc/biosdisk.c index 1689539cd..6b2152591 100644 --- a/grub-core/disk/i386/pc/biosdisk.c +++ b/grub-core/disk/i386/pc/biosdisk.c @@ -455,6 +455,14 @@ grub_biosdisk_rw (int cmd, grub_disk_t disk, { struct grub_biosdisk_data *data = disk->data; + /* VirtualBox fails with sectors above 2T on CDs. + Since even BD-ROMS are never that big anyway, return error. */ + if ((data->flags & GRUB_BIOSDISK_FLAG_CDROM) + && (sector >> 32)) + return grub_error (GRUB_ERR_OUT_OF_RANGE, + N_("attempt to read or write outside of disk `%s'"), + disk->name); + if (data->flags & GRUB_BIOSDISK_FLAG_LBA) { struct grub_biosdisk_dap *dap; From d1224d209be3fcfa5cea7b3e637cfc429f7d2345 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sun, 10 Aug 2014 11:27:36 +0200 Subject: [PATCH 092/722] * grub-core/kern/disk_common.c: Clump disk size to 1EiB. --- ChangeLog | 4 ++++ grub-core/kern/disk_common.c | 22 ++++++++++++++++------ 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9e159a8da..6c389b010 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2014-08-10 Vladimir Serbinenko + + * grub-core/kern/disk_common.c: Clump disk size to 1EiB. + 2014-08-10 Vladimir Serbinenko * grub-core/disk/i386/pc/biosdisk.c (grub_biosdisk_rw): Add diff --git a/grub-core/kern/disk_common.c b/grub-core/kern/disk_common.c index fb19778ae..2ca12b5f8 100644 --- a/grub-core/kern/disk_common.c +++ b/grub-core/kern/disk_common.c @@ -7,6 +7,8 @@ grub_disk_adjust_range (grub_disk_t disk, grub_disk_addr_t *sector, grub_off_t *offset, grub_size_t size) { grub_partition_t part; + grub_disk_addr_t total_sectors; + *sector += *offset >> GRUB_DISK_SECTOR_BITS; *offset &= GRUB_DISK_SECTOR_SIZE - 1; @@ -27,12 +29,20 @@ grub_disk_adjust_range (grub_disk_t disk, grub_disk_addr_t *sector, *sector += start; } - if (disk->total_sectors != GRUB_DISK_SIZE_UNKNOWN - && ((disk->total_sectors << (disk->log_sector_size - GRUB_DISK_SECTOR_BITS)) <= *sector - || ((*offset + size + GRUB_DISK_SECTOR_SIZE - 1) - >> GRUB_DISK_SECTOR_BITS) > (disk->total_sectors - << (disk->log_sector_size - - GRUB_DISK_SECTOR_BITS)) - *sector)) + /* Transform total_sectors to number of 512B blocks. */ + total_sectors = disk->total_sectors << (disk->log_sector_size - GRUB_DISK_SECTOR_BITS); + + /* Some drivers have problems with disks above reasonable. + Treat unknown as 1EiB disk. While on it, clamp the size to 1EiB. + Just one condition is enough since GRUB_DISK_UNKNOWN_SIZE << ls is always + above 9EiB. + */ + if (total_sectors > (1ULL << 51)) + total_sectors = (1ULL << 51); + + if ((total_sectors <= *sector + || ((*offset + size + GRUB_DISK_SECTOR_SIZE - 1) + >> GRUB_DISK_SECTOR_BITS) > total_sectors - *sector)) return grub_error (GRUB_ERR_OUT_OF_RANGE, N_("attempt to read or write outside of disk `%s'"), disk->name); From 3c058332499f6c0185c167a7faf37afa808136b7 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Wed, 13 Aug 2014 23:04:01 +0200 Subject: [PATCH 093/722] * grub-core/term/at_keyboard.c: Retry probing keyboard if scancode setup failed. --- ChangeLog | 5 +++++ grub-core/term/at_keyboard.c | 11 +++++------ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6c389b010..22030fdfe 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2014-08-13 Vladimir Serbinenko + + * grub-core/term/at_keyboard.c: Retry probing keyboard if + scancode setup failed. + 2014-08-10 Vladimir Serbinenko * grub-core/kern/disk_common.c: Clump disk size to 1EiB. diff --git a/grub-core/term/at_keyboard.c b/grub-core/term/at_keyboard.c index b4257e84a..c234e92f2 100644 --- a/grub-core/term/at_keyboard.c +++ b/grub-core/term/at_keyboard.c @@ -226,7 +226,7 @@ static const struct {0x7d, GRUB_KEYBOARD_KEY_PPAGE}, }; -static int alive = 0, ping_sent; +static int ping_sent; static void keyboard_controller_wait_until_ready (void) @@ -373,7 +373,7 @@ set_scancodes (void) grub_dprintf ("atkeyb", "returned set %d\n", current_set); if (current_set == 1) return; - grub_printf ("No supported scancode set found\n"); + grub_dprintf ("atkeyb", "no supported scancode set found\n"); #endif } @@ -543,7 +543,7 @@ grub_keyboard_getkey (void) int grub_at_keyboard_is_alive (void) { - if (alive) + if (current_set != 0) return 1; if (ping_sent && KEYBOARD_COMMAND_ISREADY (grub_inb (KEYBOARD_REG_STATUS)) @@ -611,7 +611,6 @@ static void grub_keyboard_controller_init (void) { at_keyboard_status = 0; - alive = 1; /* Drain input buffer. */ while (1) { @@ -639,7 +638,7 @@ grub_keyboard_controller_init (void) static grub_err_t grub_keyboard_controller_fini (struct grub_term_input *term __attribute__ ((unused))) { - if (!alive) + if (current_set == 0) return GRUB_ERR_NONE; if (grub_keyboard_orig_set) write_mode (grub_keyboard_orig_set); @@ -656,7 +655,7 @@ grub_at_fini_hw (int noreturn __attribute__ ((unused))) static grub_err_t grub_at_restore_hw (void) { - if (!alive) + if (current_set == 0) return GRUB_ERR_NONE; /* Drain input buffer. */ From c291f47b2c003ef6daeafaedd458db838bad6fb8 Mon Sep 17 00:00:00 2001 From: Andrey Borzenkov Date: Thu, 14 Aug 2014 21:02:31 +0400 Subject: [PATCH 094/722] Fix typo (gettext_print instead of gettext_printf) --- ChangeLog | 5 +++++ util/grub-mkconfig.in | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 22030fdfe..a8f379b00 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2014-08-14 Andrey Borzenkov + + * util/grub-mkconfig.in: Fix typo (gettext_print instead of + gettext_printf). + 2014-08-13 Vladimir Serbinenko * grub-core/term/at_keyboard.c: Retry probing keyboard if diff --git a/util/grub-mkconfig.in b/util/grub-mkconfig.in index ca040dd77..d1fae4937 100644 --- a/util/grub-mkconfig.in +++ b/util/grub-mkconfig.in @@ -124,7 +124,7 @@ set $grub_probe dummy if test -f "$1"; then : else - gettext_print "%s: Not found.\n" "$1" 1>&2 + gettext_printf "%s: Not found.\n" "$1" 1>&2 exit 1 fi From 1de3a48098053aaebd35232bd73e3ce3f3fdf51c Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Mon, 25 Aug 2014 15:19:48 -0700 Subject: [PATCH 095/722] * grub-core/kern/mips/arc/init.c (grub_machine_get_bootlocation): Initialise pend to pacify GCC. --- ChangeLog | 5 +++++ grub-core/kern/mips/arc/init.c | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index a8f379b00..6a99e2af8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2014-08-25 Colin Watson + + * grub-core/kern/mips/arc/init.c (grub_machine_get_bootlocation): + Initialise pend to pacify GCC. + 2014-08-14 Andrey Borzenkov * util/grub-mkconfig.in: Fix typo (gettext_print instead of diff --git a/grub-core/kern/mips/arc/init.c b/grub-core/kern/mips/arc/init.c index b4f50e496..3834a1490 100644 --- a/grub-core/kern/mips/arc/init.c +++ b/grub-core/kern/mips/arc/init.c @@ -360,7 +360,7 @@ grub_machine_get_bootlocation (char **device, char **path) char *loaddev = boot_location; char *pptr, *partptr; char *dname; - grub_disk_addr_t poff = -1, pend; + grub_disk_addr_t poff = -1, pend = -1; struct get_device_name_ctx ctx; grub_disk_t parent = 0; unsigned i; From 4d94b2db58e5d6e3d6e451ab294cd9def33f7aef Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Sun, 7 Sep 2014 20:47:43 +0100 Subject: [PATCH 096/722] * configure.ac: Remove several unnecessary semicolons. --- ChangeLog | 4 ++++ configure.ac | 36 ++++++++++++++++++------------------ 2 files changed, 22 insertions(+), 18 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6a99e2af8..4e422b85a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2014-09-07 Colin Watson + + * configure.ac: Remove several unnecessary semicolons. + 2014-08-25 Colin Watson * grub-core/kern/mips/arc/init.c (grub_machine_get_bootlocation): diff --git a/configure.ac b/configure.ac index 8888c2ff2..a3610e157 100644 --- a/configure.ac +++ b/configure.ac @@ -90,18 +90,18 @@ case "$target_cpu" in amd64) target_cpu=x86_64 ;; sparc) target_cpu=sparc64 ;; mipsel|mips64el) - target_cpu=mipsel; - machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_CPU_MIPSEL=1"; + target_cpu=mipsel + machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_CPU_MIPSEL=1" ;; mips|mips64) - target_cpu=mips; - machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_CPU_MIPS=1"; + target_cpu=mips + machine_CPPFLAGS="$machine_CPPFLAGS -DGRUB_CPU_MIPS=1" ;; arm*) - target_cpu=arm; + target_cpu=arm ;; aarch64*) - target_cpu=arm64; + target_cpu=arm64 ;; esac @@ -178,7 +178,7 @@ if test x$platform != xemu ; then fi if test x"$target_cpu-$platform" = xsparc64-emu ; then - target_m64=1 ; + target_m64=1 fi case "$target_os" in @@ -742,7 +742,7 @@ if test x"$efiemu_excuse" = x ; then ]], [[]])], [flag=1], [flag=0]) if test x"$flag" = x1; then grub_cv_target_cc_efiemu64_link_format="$format" - break; + break fi done]) if test x"$grub_cv_target_cc_efiemu64_link_format" = xunknown; then @@ -775,12 +775,12 @@ if test x"$platform" = xemu ; then ;; *windows* | *cygwin* | *mingw*) if test x${target_cpu} = xi386 ; then - grub_cv_target_cc_link_format=-mi386pe; - TARGET_OBJ2ELF='./build-grub-pe2elf$(BUILD_EXEEXT)'; + grub_cv_target_cc_link_format=-mi386pe + TARGET_OBJ2ELF='./build-grub-pe2elf$(BUILD_EXEEXT)' fi if test x${target_cpu} = xx86_64 ; then - grub_cv_target_cc_link_format=-mi386pep; - TARGET_OBJ2ELF='./build-grub-pep2elf$(BUILD_EXEEXT)'; + grub_cv_target_cc_link_format=-mi386pep + TARGET_OBJ2ELF='./build-grub-pep2elf$(BUILD_EXEEXT)' fi TARGET_LDFLAGS="$TARGET_LDFLAGS -Wl,$grub_cv_target_cc_link_format" ;; @@ -806,7 +806,7 @@ elif test x"$target_cpu" = xi386 || test x"$target_cpu" = xx86_64; then ]], [[]])], [flag=1], [flag=0]) if test x"$flag" = x1; then grub_cv_target_cc_link_format="$format" - break; + break fi done]) if test x"$grub_cv_target_cc_link_format" = xunknown; then @@ -814,10 +814,10 @@ elif test x"$target_cpu" = xi386 || test x"$target_cpu" = xx86_64; then fi TARGET_LDFLAGS="$TARGET_LDFLAGS -Wl,$grub_cv_target_cc_link_format" if test x"$grub_cv_target_cc_link_format" = x-mi386pe ; then - TARGET_OBJ2ELF='./build-grub-pe2elf$(BUILD_EXEEXT)'; + TARGET_OBJ2ELF='./build-grub-pe2elf$(BUILD_EXEEXT)' fi if test x"$grub_cv_target_cc_link_format" = x-mi386pep ; then - TARGET_OBJ2ELF='./build-grub-pep2elf$(BUILD_EXEEXT)'; + TARGET_OBJ2ELF='./build-grub-pep2elf$(BUILD_EXEEXT)' fi fi @@ -995,7 +995,7 @@ if test "$target_cpu" = arm; then AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])], [flag=1], [flag=0]) if test x"$flag" = x1; then grub_cv_target_cc_strict_align="$arg" - break; + break fi done]) @@ -1416,7 +1416,7 @@ for ext in pcf pcf.gz bdf bdf.gz ttf ttf.gz; do md5="$(md5sum "$dir/unifont.$ext"|awk '{ print $1; }')" # PCF and BDF from version 6.3 isn't hanled properly by libfreetype. if test "$md5" = 0a54834d2788c83886a3e1785a6a1e61 || test "$md5" = 28f2565c7a41d8d407e2551159385edb || test "$md5" = dae5e588461b3b92b87b6ffee734f936 || test "$md5" = 4a3d687aa5bb329ed05f4263a1016791 ; then - continue; + continue fi FONT_SOURCE="$dir/unifont.$ext" break 2 @@ -1501,7 +1501,7 @@ if test x"$device_mapper_excuse" = x ; then fi if test x"$device_mapper_excuse" = x ; then - LIBDEVMAPPER="-ldevmapper"; + LIBDEVMAPPER="-ldevmapper" AC_DEFINE([HAVE_DEVICE_MAPPER], [1], [Define to 1 if you have the devmapper library.]) fi From 2a5a532c0047d4eff90175936b220b638cce1013 Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Sun, 7 Sep 2014 23:04:35 +0100 Subject: [PATCH 097/722] Support grub-emu on x32 (ILP32 but with x86-64 instruction set) * configure.ac: Remove -m64 from checks for -mcmodel=large and -mno-red-zone. These are always either unnecessary (x86_64-emu) or already in TARGET_CFLAGS at this point, and they produce incorrect results when building for x32. * grub-core/kern/x86_64/dl.c (grub_arch_dl_relocate_symbols): Cast pointers to Elf64_Xword via grub_addr_t, in order to work on x32. * include/grub/x86_64/types.h (GRUB_TARGET_SIZEOF_VOID_P, GRUB_TARGET_SIZEOF_LONG): Define to 4 on x32. --- ChangeLog | 13 +++++++++++++ configure.ac | 4 ++-- grub-core/kern/x86_64/dl.c | 4 ++-- include/grub/x86_64/types.h | 6 +++++- 4 files changed, 22 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4e422b85a..572ee50d1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2014-09-07 Colin Watson + + Support grub-emu on x32 (ILP32 but with x86-64 instruction set) + + * configure.ac: Remove -m64 from checks for -mcmodel=large and + -mno-red-zone. These are always either unnecessary (x86_64-emu) or + already in TARGET_CFLAGS at this point, and they produce incorrect + results when building for x32. + * grub-core/kern/x86_64/dl.c (grub_arch_dl_relocate_symbols): Cast + pointers to Elf64_Xword via grub_addr_t, in order to work on x32. + * include/grub/x86_64/types.h (GRUB_TARGET_SIZEOF_VOID_P, + GRUB_TARGET_SIZEOF_LONG): Define to 4 on x32. + 2014-09-07 Colin Watson * configure.ac: Remove several unnecessary semicolons. diff --git a/configure.ac b/configure.ac index a3610e157..8662bac68 100644 --- a/configure.ac +++ b/configure.ac @@ -862,7 +862,7 @@ LDFLAGS="$TARGET_LDFLAGS" if test "$target_cpu" = x86_64 || test "$target_cpu-$platform" = sparc64-emu ; then # Use large model to support 4G memory AC_CACHE_CHECK([whether option -mcmodel=large works], grub_cv_cc_mcmodel, [ - CFLAGS="$TARGET_CFLAGS -m64 -mcmodel=large" + CFLAGS="$TARGET_CFLAGS -mcmodel=large" AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])], [grub_cv_cc_mcmodel=yes], [grub_cv_cc_mcmodel=no]) @@ -877,7 +877,7 @@ fi if test "$target_cpu"-"$platform" = x86_64-efi; then # EFI writes to stack below %rsp, we must not use the red zone AC_CACHE_CHECK([whether option -mno-red-zone works], grub_cv_cc_no_red_zone, [ - CFLAGS="$TARGET_CFLAGS -m64 -mno-red-zone" + CFLAGS="$TARGET_CFLAGS -mno-red-zone" AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])], [grub_cv_cc_no_red_zone=yes], [grub_cv_cc_no_red_zone=no]) diff --git a/grub-core/kern/x86_64/dl.c b/grub-core/kern/x86_64/dl.c index 6cb88bfcc..440690673 100644 --- a/grub-core/kern/x86_64/dl.c +++ b/grub-core/kern/x86_64/dl.c @@ -73,7 +73,7 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr, { grub_int64_t value; value = ((grub_int32_t) *addr32) + rel->r_addend + sym->st_value - - (Elf64_Xword) seg->addr - rel->r_offset; + (Elf64_Xword) (grub_addr_t) seg->addr - rel->r_offset; if (value != (grub_int32_t) value) return grub_error (GRUB_ERR_BAD_MODULE, "relocation out of range"); *addr32 = value; @@ -83,7 +83,7 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr, case R_X86_64_PC64: { *addr64 += rel->r_addend + sym->st_value - - (Elf64_Xword) seg->addr - rel->r_offset; + (Elf64_Xword) (grub_addr_t) seg->addr - rel->r_offset; } break; diff --git a/include/grub/x86_64/types.h b/include/grub/x86_64/types.h index fec910952..0bbdc6d01 100644 --- a/include/grub/x86_64/types.h +++ b/include/grub/x86_64/types.h @@ -20,10 +20,14 @@ #define GRUB_TYPES_CPU_HEADER 1 /* The size of void *. */ +#ifdef __ILP32__ +#define GRUB_TARGET_SIZEOF_VOID_P 4 +#else #define GRUB_TARGET_SIZEOF_VOID_P 8 +#endif /* The size of long. */ -#ifdef __MINGW32__ +#if defined(__MINGW32__) || defined(__ILP32__) #define GRUB_TARGET_SIZEOF_LONG 4 #else #define GRUB_TARGET_SIZEOF_LONG 8 From 54bd9a061083b916d3563101d147a01e002486aa Mon Sep 17 00:00:00 2001 From: Michael Chang Date: Thu, 14 Aug 2014 18:17:45 +0800 Subject: [PATCH 098/722] Fix incorrect address reference in btrfs We encountered a weird random kernel initrd unpacking error on btrfs and finally found it was caused by incorrect address reference in range check for type GRUB_BTRFS_EXTENT_REGULAR and the entire result is unpredictable. This is a quick fix to make the address reference to the grub_btrfs_extent_data structure correctly, not the pointer variable to it. Any suggestions to this patch is welcome. --- ChangeLog | 6 ++++++ grub-core/fs/btrfs.c | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 572ee50d1..067606578 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2014-09-08 Michael Chang + + * grub-core/fs/btrfs.c (grub_btrfs_extent_read): Fix extent size + check; comparing &data->extent against addresses in the region it + points to is unpredictable. + 2014-09-07 Colin Watson Support grub-emu on x32 (ILP32 but with x86-64 instruction set) diff --git a/grub-core/fs/btrfs.c b/grub-core/fs/btrfs.c index f7b6c1520..95a8fa6b3 100644 --- a/grub-core/fs/btrfs.c +++ b/grub-core/fs/btrfs.c @@ -1051,7 +1051,7 @@ grub_btrfs_extent_read (struct grub_btrfs_data *data, data->extend = data->extstart + grub_le_to_cpu64 (data->extent->size); if (data->extent->type == GRUB_BTRFS_EXTENT_REGULAR - && (char *) &data->extent + elemsize + && (char *) data->extent + elemsize >= (char *) &data->extent->filled + sizeof (data->extent->filled)) data->extend = data->extstart + grub_le_to_cpu64 (data->extent->filled); From a276b840464629fdaecbe7e813f83a717a34993a Mon Sep 17 00:00:00 2001 From: Khem Raj Date: Wed, 3 Sep 2014 01:15:08 -0700 Subject: [PATCH 099/722] Fix build with glibc 2.20 * grub-core/kern/emu/hostfs.c: squahes below warning warning: #warning "_BSD_SOURCE and _SVID_SOURCE are deprecated, use _DEFAULT_SOURCE" Signed-off-by: Khem Raj Upstream-Status: Submitted --- ChangeLog | 4 ++++ grub-core/kern/emu/hostfs.c | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/ChangeLog b/ChangeLog index 067606578..ea011b7d3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2014-09-15 Khem Raj + * grub-core/kern/emu/hostfs.c: use _DEFAULT_SOURCE in addition to + _BSD_SOURCE to avoid warnings under glibc 2.20+. + 2014-09-08 Michael Chang * grub-core/fs/btrfs.c (grub_btrfs_extent_read): Fix extent size diff --git a/grub-core/kern/emu/hostfs.c b/grub-core/kern/emu/hostfs.c index 7e725f65f..823116da6 100644 --- a/grub-core/kern/emu/hostfs.c +++ b/grub-core/kern/emu/hostfs.c @@ -19,7 +19,11 @@ #include +/* Legacy feature macro.*/ #define _BSD_SOURCE +/* New feature macro that provides everything _BSD_SOURCE and + * _SVID_SOURCE provided and possibly more. */ +#define _DEFAULT_SOURCE #include #include #include From 60049a0e7204c267fc867ce8de31421613af0b69 Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Fri, 19 Sep 2014 14:50:51 +0100 Subject: [PATCH 100/722] Tidy up ChangeLog formatting. --- ChangeLog | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index ea011b7d3..2bbf501f5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,5 @@ -2014-09-15 Khem Raj +2014-09-15 Khem Raj + * grub-core/kern/emu/hostfs.c: use _DEFAULT_SOURCE in addition to _BSD_SOURCE to avoid warnings under glibc 2.20+. From 631a82003851ca68bfaf87e12be5c94e14cd2a91 Mon Sep 17 00:00:00 2001 From: Peter Jones Date: Wed, 17 Sep 2014 16:30:11 -0400 Subject: [PATCH 101/722] Initialized initrd_ctx so we don't free a random pointer from the stack. Currently, if "linux" fails, the "goto fail;" in grub_cmd_initrd sends us into grub_initrd_close() without grub_initrd_init() being called, and thus it never clears initrd_ctx->components. grub_initrd_close() then frees that address, which is stale data from the stack. If the stack happens to have a stale *address* there that matches a recent allocation, then you'll get a double free later. So initialize the memory up front. Signed-off-by: Peter Jones --- ChangeLog | 12 ++++++++++++ grub-core/loader/arm/linux.c | 2 +- grub-core/loader/arm64/linux.c | 2 +- grub-core/loader/i386/linux.c | 2 +- grub-core/loader/i386/pc/linux.c | 2 +- grub-core/loader/ia64/efi/linux.c | 2 +- grub-core/loader/mips/linux.c | 2 +- grub-core/loader/powerpc/ieee1275/linux.c | 2 +- grub-core/loader/sparc64/ieee1275/linux.c | 2 +- 9 files changed, 20 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2bbf501f5..1c79b7789 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2014-21-15 Peter Jones + + * grub-core/loader/arm/linux.c: Initialized initrd_ctx so + we don't free a random pointer from the stack. + * grub-core/loader/arm64/linux.c: Likewise. + * grub-core/loader/i386/linux.c: Likewise. + * grub-core/loader/i386/pc/linux.c: Likewise. + * grub-core/loader/ia64/efi/linux.c: Likewise. + * grub-core/loader/mips/linux.c: Likewise. + * grub-core/loader/powerpc/ieee1275/linux.c: Likewise. + * grub-core/loader/sparc64/ieee1275/linux.c: Likewise. + 2014-09-15 Khem Raj * grub-core/kern/emu/hostfs.c: use _DEFAULT_SOURCE in addition to diff --git a/grub-core/loader/arm/linux.c b/grub-core/loader/arm/linux.c index e6770d96d..62cbe75d3 100644 --- a/grub-core/loader/arm/linux.c +++ b/grub-core/loader/arm/linux.c @@ -396,7 +396,7 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), { grub_file_t file; grub_size_t size = 0; - struct grub_linux_initrd_context initrd_ctx; + struct grub_linux_initrd_context initrd_ctx = { 0, }; if (argc == 0) return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected")); diff --git a/grub-core/loader/arm64/linux.c b/grub-core/loader/arm64/linux.c index f1d10a164..0dc144e5d 100644 --- a/grub-core/loader/arm64/linux.c +++ b/grub-core/loader/arm64/linux.c @@ -328,7 +328,7 @@ static grub_err_t grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), int argc, char *argv[]) { - struct grub_linux_initrd_context initrd_ctx; + struct grub_linux_initrd_context initrd_ctx = { 0, }; int initrd_size, initrd_pages; void *initrd_mem = NULL; diff --git a/grub-core/loader/i386/linux.c b/grub-core/loader/i386/linux.c index 31fb91e2c..2ae176315 100644 --- a/grub-core/loader/i386/linux.c +++ b/grub-core/loader/i386/linux.c @@ -1050,7 +1050,7 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), grub_addr_t addr_min, addr_max; grub_addr_t addr; grub_err_t err; - struct grub_linux_initrd_context initrd_ctx; + struct grub_linux_initrd_context initrd_ctx = { 0, }; if (argc == 0) { diff --git a/grub-core/loader/i386/pc/linux.c b/grub-core/loader/i386/pc/linux.c index 672c013e7..b481e4668 100644 --- a/grub-core/loader/i386/pc/linux.c +++ b/grub-core/loader/i386/pc/linux.c @@ -388,7 +388,7 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), grub_uint8_t *initrd_chunk; grub_addr_t initrd_addr; grub_err_t err; - struct grub_linux_initrd_context initrd_ctx; + struct grub_linux_initrd_context initrd_ctx = { 0, }; if (argc == 0) { diff --git a/grub-core/loader/ia64/efi/linux.c b/grub-core/loader/ia64/efi/linux.c index 87ac49f8c..eb78e6e62 100644 --- a/grub-core/loader/ia64/efi/linux.c +++ b/grub-core/loader/ia64/efi/linux.c @@ -568,7 +568,7 @@ static grub_err_t grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), int argc, char *argv[]) { - struct grub_linux_initrd_context initrd_ctx; + struct grub_linux_initrd_context initrd_ctx = { 0, }; if (argc == 0) { diff --git a/grub-core/loader/mips/linux.c b/grub-core/loader/mips/linux.c index ef64a5b1d..4a3e8c5df 100644 --- a/grub-core/loader/mips/linux.c +++ b/grub-core/loader/mips/linux.c @@ -415,7 +415,7 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), void *initrd_src; grub_addr_t initrd_dest; grub_err_t err; - struct grub_linux_initrd_context initrd_ctx; + struct grub_linux_initrd_context initrd_ctx = { 0, }; if (argc == 0) return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected")); diff --git a/grub-core/loader/powerpc/ieee1275/linux.c b/grub-core/loader/powerpc/ieee1275/linux.c index 4a14f66de..787d7dc2a 100644 --- a/grub-core/loader/powerpc/ieee1275/linux.c +++ b/grub-core/loader/powerpc/ieee1275/linux.c @@ -333,7 +333,7 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), grub_size_t size = 0; grub_addr_t first_addr; grub_addr_t addr; - struct grub_linux_initrd_context initrd_ctx; + struct grub_linux_initrd_context initrd_ctx = { 0, }; if (argc == 0) { diff --git a/grub-core/loader/sparc64/ieee1275/linux.c b/grub-core/loader/sparc64/ieee1275/linux.c index de6ee2f75..c5e8dfab2 100644 --- a/grub-core/loader/sparc64/ieee1275/linux.c +++ b/grub-core/loader/sparc64/ieee1275/linux.c @@ -373,7 +373,7 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), grub_addr_t paddr; grub_addr_t addr; int ret; - struct grub_linux_initrd_context initrd_ctx; + struct grub_linux_initrd_context initrd_ctx = { 0, }; if (argc == 0) { From 0aece00c54aa6a6ac316c619a1ad31ec3190aca2 Mon Sep 17 00:00:00 2001 From: Michael Chang Date: Sun, 21 Sep 2014 17:49:13 +0200 Subject: [PATCH 102/722] * grub-core/osdep/unix/config.c: Remove extraneous comma. --- ChangeLog | 6 +++++- grub-core/commands/keylayouts.c | 4 +++- grub-core/gmodule.pl.in | 2 +- grub-core/normal/main.c | 10 +++++++--- grub-core/normal/menu.c | 2 +- grub-core/normal/menu_entry.c | 2 +- grub-core/osdep/unix/config.c | 4 ++-- grub-core/tests/cmdline_cat_test.c | 2 +- include/grub/normal.h | 2 +- 9 files changed, 22 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1c79b7789..bac248c75 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,8 @@ -2014-21-15 Peter Jones +2014-09-21 Michael Chang + + * grub-core/osdep/unix/config.c: Remove extraneous comma. + +2014-09-21 Peter Jones * grub-core/loader/arm/linux.c: Initialized initrd_ctx so we don't free a random pointer from the stack. diff --git a/grub-core/commands/keylayouts.c b/grub-core/commands/keylayouts.c index da04389e3..f4b773020 100644 --- a/grub-core/commands/keylayouts.c +++ b/grub-core/commands/keylayouts.c @@ -173,8 +173,10 @@ grub_term_map_key (grub_keyboard_key_t code, int status) key = map_key_core (code, status, &alt_gr_consumed); - if (key == 0 || key == GRUB_TERM_SHIFT) + if (key == 0 || key == GRUB_TERM_SHIFT) { grub_printf ("Unknown key 0x%x detected\n", code); + return GRUB_TERM_NO_KEY; + } if (status & GRUB_TERM_STATUS_CAPS) { diff --git a/grub-core/gmodule.pl.in b/grub-core/gmodule.pl.in index 6739a6f1c..78aa1e64e 100644 --- a/grub-core/gmodule.pl.in +++ b/grub-core/gmodule.pl.in @@ -23,7 +23,7 @@ while (<>) { } print " -s $2 $sections{$1}" - if ($sections{$1} ne '0x0'); + if ($sections{$1} ne '0x0' and $sections{$1} ne ''); }; close (READELF); print "\n"; diff --git a/grub-core/normal/main.c b/grub-core/normal/main.c index 3a926fc5f..c41f175bd 100644 --- a/grub-core/normal/main.c +++ b/grub-core/normal/main.c @@ -302,7 +302,7 @@ grub_enter_normal_mode (const char *config) nested_level++; grub_normal_execute (config, 0, 0); grub_boot_time ("Entering shell"); - grub_cmdline_run (0); + grub_cmdline_run (0, 1); nested_level--; if (grub_normal_exit_level) grub_normal_exit_level--; @@ -424,11 +424,15 @@ grub_normal_read_line (char **line, int cont, } void -grub_cmdline_run (int nested) +grub_cmdline_run (int nested, int force_auth) { grub_err_t err = GRUB_ERR_NONE; - err = grub_auth_check_authentication (NULL); + do + { + err = grub_auth_check_authentication (NULL); + } + while (err && force_auth); if (err) { diff --git a/grub-core/normal/menu.c b/grub-core/normal/menu.c index b47991aba..719e2fb1c 100644 --- a/grub-core/normal/menu.c +++ b/grub-core/normal/menu.c @@ -773,7 +773,7 @@ run_menu (grub_menu_t menu, int nested, int *auto_boot) case 'c': menu_fini (); - grub_cmdline_run (1); + grub_cmdline_run (1, 0); goto refresh; case 'e': diff --git a/grub-core/normal/menu_entry.c b/grub-core/normal/menu_entry.c index b485df821..62c7e1627 100644 --- a/grub-core/normal/menu_entry.c +++ b/grub-core/normal/menu_entry.c @@ -1396,7 +1396,7 @@ grub_menu_entry_run (grub_menu_entry_t entry) case GRUB_TERM_CTRL | 'c': case GRUB_TERM_KEY_F2: - grub_cmdline_run (1); + grub_cmdline_run (1, 0); goto refresh; case GRUB_TERM_CTRL | 'x': diff --git a/grub-core/osdep/unix/config.c b/grub-core/osdep/unix/config.c index f4b0bb466..65effa9f3 100644 --- a/grub-core/osdep/unix/config.c +++ b/grub-core/osdep/unix/config.c @@ -105,8 +105,8 @@ grub_util_load_config (struct grub_util_config *cfg) *ptr++ = *iptr; } - strcpy (ptr, "'; printf \"GRUB_ENABLE_CRYPTODISK=%s\\nGRUB_DISTRIBUTOR=%s\\n\", " - "\"$GRUB_ENABLE_CRYPTODISK\", \"$GRUB_DISTRIBUTOR\""); + strcpy (ptr, "'; printf \"GRUB_ENABLE_CRYPTODISK=%s\\nGRUB_DISTRIBUTOR=%s\\n\" " + "\"$GRUB_ENABLE_CRYPTODISK\" \"$GRUB_DISTRIBUTOR\""); argv[2] = script; argv[3] = '\0'; diff --git a/grub-core/tests/cmdline_cat_test.c b/grub-core/tests/cmdline_cat_test.c index c3de5c464..f1e21439e 100644 --- a/grub-core/tests/cmdline_cat_test.c +++ b/grub-core/tests/cmdline_cat_test.c @@ -109,7 +109,7 @@ cmdline_cat_test (void) grub_video_checksum ("cmdline_cat"); if (!grub_test_use_gfxterm ()) - grub_cmdline_run (1); + grub_cmdline_run (1, 0); grub_test_use_gfxterm_end (); diff --git a/include/grub/normal.h b/include/grub/normal.h index c4ab193b3..218cbabcc 100644 --- a/include/grub/normal.h +++ b/include/grub/normal.h @@ -66,7 +66,7 @@ void grub_menu_init_page (int nested, int edit, struct grub_term_output *term); void grub_normal_init_page (struct grub_term_output *term, int y); char *grub_file_getline (grub_file_t file); -void grub_cmdline_run (int nested); +void grub_cmdline_run (int nested, int force_auth); /* Defined in `cmdline.c'. */ char *grub_cmdline_get (const char *prompt); From 5e42618e001ab28346ee1a3f4591977afda7f2f5 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sun, 21 Sep 2014 18:18:03 +0200 Subject: [PATCH 103/722] Fix wrong commit --- grub-core/commands/keylayouts.c | 4 +--- grub-core/gmodule.pl.in | 2 +- grub-core/normal/main.c | 10 +++------- grub-core/normal/menu.c | 2 +- grub-core/normal/menu_entry.c | 2 +- grub-core/tests/cmdline_cat_test.c | 2 +- include/grub/normal.h | 2 +- 7 files changed, 9 insertions(+), 15 deletions(-) diff --git a/grub-core/commands/keylayouts.c b/grub-core/commands/keylayouts.c index f4b773020..da04389e3 100644 --- a/grub-core/commands/keylayouts.c +++ b/grub-core/commands/keylayouts.c @@ -173,10 +173,8 @@ grub_term_map_key (grub_keyboard_key_t code, int status) key = map_key_core (code, status, &alt_gr_consumed); - if (key == 0 || key == GRUB_TERM_SHIFT) { + if (key == 0 || key == GRUB_TERM_SHIFT) grub_printf ("Unknown key 0x%x detected\n", code); - return GRUB_TERM_NO_KEY; - } if (status & GRUB_TERM_STATUS_CAPS) { diff --git a/grub-core/gmodule.pl.in b/grub-core/gmodule.pl.in index 78aa1e64e..6739a6f1c 100644 --- a/grub-core/gmodule.pl.in +++ b/grub-core/gmodule.pl.in @@ -23,7 +23,7 @@ while (<>) { } print " -s $2 $sections{$1}" - if ($sections{$1} ne '0x0' and $sections{$1} ne ''); + if ($sections{$1} ne '0x0'); }; close (READELF); print "\n"; diff --git a/grub-core/normal/main.c b/grub-core/normal/main.c index c41f175bd..3a926fc5f 100644 --- a/grub-core/normal/main.c +++ b/grub-core/normal/main.c @@ -302,7 +302,7 @@ grub_enter_normal_mode (const char *config) nested_level++; grub_normal_execute (config, 0, 0); grub_boot_time ("Entering shell"); - grub_cmdline_run (0, 1); + grub_cmdline_run (0); nested_level--; if (grub_normal_exit_level) grub_normal_exit_level--; @@ -424,15 +424,11 @@ grub_normal_read_line (char **line, int cont, } void -grub_cmdline_run (int nested, int force_auth) +grub_cmdline_run (int nested) { grub_err_t err = GRUB_ERR_NONE; - do - { - err = grub_auth_check_authentication (NULL); - } - while (err && force_auth); + err = grub_auth_check_authentication (NULL); if (err) { diff --git a/grub-core/normal/menu.c b/grub-core/normal/menu.c index 719e2fb1c..b47991aba 100644 --- a/grub-core/normal/menu.c +++ b/grub-core/normal/menu.c @@ -773,7 +773,7 @@ run_menu (grub_menu_t menu, int nested, int *auto_boot) case 'c': menu_fini (); - grub_cmdline_run (1, 0); + grub_cmdline_run (1); goto refresh; case 'e': diff --git a/grub-core/normal/menu_entry.c b/grub-core/normal/menu_entry.c index 62c7e1627..b485df821 100644 --- a/grub-core/normal/menu_entry.c +++ b/grub-core/normal/menu_entry.c @@ -1396,7 +1396,7 @@ grub_menu_entry_run (grub_menu_entry_t entry) case GRUB_TERM_CTRL | 'c': case GRUB_TERM_KEY_F2: - grub_cmdline_run (1, 0); + grub_cmdline_run (1); goto refresh; case GRUB_TERM_CTRL | 'x': diff --git a/grub-core/tests/cmdline_cat_test.c b/grub-core/tests/cmdline_cat_test.c index f1e21439e..c3de5c464 100644 --- a/grub-core/tests/cmdline_cat_test.c +++ b/grub-core/tests/cmdline_cat_test.c @@ -109,7 +109,7 @@ cmdline_cat_test (void) grub_video_checksum ("cmdline_cat"); if (!grub_test_use_gfxterm ()) - grub_cmdline_run (1, 0); + grub_cmdline_run (1); grub_test_use_gfxterm_end (); diff --git a/include/grub/normal.h b/include/grub/normal.h index 218cbabcc..c4ab193b3 100644 --- a/include/grub/normal.h +++ b/include/grub/normal.h @@ -66,7 +66,7 @@ void grub_menu_init_page (int nested, int edit, struct grub_term_output *term); void grub_normal_init_page (struct grub_term_output *term, int y); char *grub_file_getline (grub_file_t file); -void grub_cmdline_run (int nested, int force_auth); +void grub_cmdline_run (int nested); /* Defined in `cmdline.c'. */ char *grub_cmdline_get (const char *prompt); From 2988a849fcf9f7b3c9fca94a4b1cd5913ca4c912 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sun, 21 Sep 2014 18:23:23 +0200 Subject: [PATCH 104/722] * grub-core/gmodule.pl.in: Accept newer binutils which output empty column rather than 0x0. --- ChangeLog | 5 +++++ grub-core/gmodule.pl.in | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index bac248c75..163265bd0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2014-09-21 Vladimir Serbinenko + + * grub-core/gmodule.pl.in: Accept newer binutils which output + empty column rather than 0x0. + 2014-09-21 Michael Chang * grub-core/osdep/unix/config.c: Remove extraneous comma. diff --git a/grub-core/gmodule.pl.in b/grub-core/gmodule.pl.in index 6739a6f1c..78aa1e64e 100644 --- a/grub-core/gmodule.pl.in +++ b/grub-core/gmodule.pl.in @@ -23,7 +23,7 @@ while (<>) { } print " -s $2 $sections{$1}" - if ($sections{$1} ne '0x0'); + if ($sections{$1} ne '0x0' and $sections{$1} ne ''); }; close (READELF); print "\n"; From 7c378c3964a19ae6da0648ca18cf37308b072629 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sun, 21 Sep 2014 18:49:49 +0200 Subject: [PATCH 105/722] * grub-core/commands/keylayouts.c: Ignore unknown keys. --- ChangeLog | 4 ++++ grub-core/commands/keylayouts.c | 4 +++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 163265bd0..6d4e29514 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2014-09-21 Vladimir Serbinenko + + * grub-core/commands/keylayouts.c: Ignore unknown keys. + 2014-09-21 Vladimir Serbinenko * grub-core/gmodule.pl.in: Accept newer binutils which output diff --git a/grub-core/commands/keylayouts.c b/grub-core/commands/keylayouts.c index da04389e3..f4b773020 100644 --- a/grub-core/commands/keylayouts.c +++ b/grub-core/commands/keylayouts.c @@ -173,8 +173,10 @@ grub_term_map_key (grub_keyboard_key_t code, int status) key = map_key_core (code, status, &alt_gr_consumed); - if (key == 0 || key == GRUB_TERM_SHIFT) + if (key == 0 || key == GRUB_TERM_SHIFT) { grub_printf ("Unknown key 0x%x detected\n", code); + return GRUB_TERM_NO_KEY; + } if (status & GRUB_TERM_STATUS_CAPS) { From 41c6f91fce842b6c9565b8a61bf6289ba0f5cd6a Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sun, 21 Sep 2014 18:51:09 +0200 Subject: [PATCH 106/722] * grub-core/normal/main.c: Don't drop to rescue console in case of password-protected prompt and no menu entries. --- ChangeLog | 5 +++++ grub-core/normal/main.c | 10 +++++++--- grub-core/normal/menu.c | 2 +- grub-core/normal/menu_entry.c | 2 +- grub-core/tests/cmdline_cat_test.c | 2 +- include/grub/normal.h | 2 +- 6 files changed, 16 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6d4e29514..002461c64 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2014-09-21 Vladimir Serbinenko + + * grub-core/normal/main.c: Don't drop to rescue console in + case of password-protected prompt and no menu entries. + 2014-09-21 Vladimir Serbinenko * grub-core/commands/keylayouts.c: Ignore unknown keys. diff --git a/grub-core/normal/main.c b/grub-core/normal/main.c index 3a926fc5f..c41f175bd 100644 --- a/grub-core/normal/main.c +++ b/grub-core/normal/main.c @@ -302,7 +302,7 @@ grub_enter_normal_mode (const char *config) nested_level++; grub_normal_execute (config, 0, 0); grub_boot_time ("Entering shell"); - grub_cmdline_run (0); + grub_cmdline_run (0, 1); nested_level--; if (grub_normal_exit_level) grub_normal_exit_level--; @@ -424,11 +424,15 @@ grub_normal_read_line (char **line, int cont, } void -grub_cmdline_run (int nested) +grub_cmdline_run (int nested, int force_auth) { grub_err_t err = GRUB_ERR_NONE; - err = grub_auth_check_authentication (NULL); + do + { + err = grub_auth_check_authentication (NULL); + } + while (err && force_auth); if (err) { diff --git a/grub-core/normal/menu.c b/grub-core/normal/menu.c index b47991aba..719e2fb1c 100644 --- a/grub-core/normal/menu.c +++ b/grub-core/normal/menu.c @@ -773,7 +773,7 @@ run_menu (grub_menu_t menu, int nested, int *auto_boot) case 'c': menu_fini (); - grub_cmdline_run (1); + grub_cmdline_run (1, 0); goto refresh; case 'e': diff --git a/grub-core/normal/menu_entry.c b/grub-core/normal/menu_entry.c index b485df821..62c7e1627 100644 --- a/grub-core/normal/menu_entry.c +++ b/grub-core/normal/menu_entry.c @@ -1396,7 +1396,7 @@ grub_menu_entry_run (grub_menu_entry_t entry) case GRUB_TERM_CTRL | 'c': case GRUB_TERM_KEY_F2: - grub_cmdline_run (1); + grub_cmdline_run (1, 0); goto refresh; case GRUB_TERM_CTRL | 'x': diff --git a/grub-core/tests/cmdline_cat_test.c b/grub-core/tests/cmdline_cat_test.c index c3de5c464..f1e21439e 100644 --- a/grub-core/tests/cmdline_cat_test.c +++ b/grub-core/tests/cmdline_cat_test.c @@ -109,7 +109,7 @@ cmdline_cat_test (void) grub_video_checksum ("cmdline_cat"); if (!grub_test_use_gfxterm ()) - grub_cmdline_run (1); + grub_cmdline_run (1, 0); grub_test_use_gfxterm_end (); diff --git a/include/grub/normal.h b/include/grub/normal.h index c4ab193b3..218cbabcc 100644 --- a/include/grub/normal.h +++ b/include/grub/normal.h @@ -66,7 +66,7 @@ void grub_menu_init_page (int nested, int edit, struct grub_term_output *term); void grub_normal_init_page (struct grub_term_output *term, int y); char *grub_file_getline (grub_file_t file); -void grub_cmdline_run (int nested); +void grub_cmdline_run (int nested, int force_auth); /* Defined in `cmdline.c'. */ char *grub_cmdline_get (const char *prompt); From 0f1f95c7b7bc72cfbeea2f6dc5986855738ad96d Mon Sep 17 00:00:00 2001 From: Valentin Dornauer Date: Sun, 21 Sep 2014 18:58:14 +0200 Subject: [PATCH 107/722] ACPIhalt: Add more ACPI opcodes. The AML parser implements only a small subset of possible AML opcodes. On the Fujitsu Lifebook E744 this and another bug in the parser (incorrect handling of TermArg data types) would lead to the laptop not turning off (_S5 not found). * grub-core/commands/acpihalt.c: Support OpAlias in the AML parser; in skip_ext_op(), handle some Type2Opcodes more correctly (TermArgs aren't always simply strings!); Add function to skip TermArgs * include/grub/acpi.h: Add new opcodes --- ChangeLog | 12 +++++++ grub-core/commands/acpihalt.c | 59 +++++++++++++++++++++++++++++++++-- include/grub/acpi.h | 19 ++++++++++- 3 files changed, 87 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 002461c64..6b35a5c2b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2014-09-21 Valentin Dornauer + + The AML parser implements only a small subset of possible AML + opcodes. On the Fujitsu Lifebook E744 this and another bug in + the parser (incorrect handling of TermArg data types) would lead + to the laptop not turning off (_S5 not found). + + * grub-core/commands/acpihalt.c: Support OpAlias in the AML parser; + in skip_ext_op(), handle some Type2Opcodes more correctly (TermArgs + aren't always simply strings!); Add function to skip TermArgs + * include/grub/acpi.h: Add new opcodes + 2014-09-21 Vladimir Serbinenko * grub-core/normal/main.c: Don't drop to rescue console in diff --git a/grub-core/commands/acpihalt.c b/grub-core/commands/acpihalt.c index 83bdfe1f2..da68b5b52 100644 --- a/grub-core/commands/acpihalt.c +++ b/grub-core/commands/acpihalt.c @@ -135,6 +135,49 @@ skip_data_ref_object (const grub_uint8_t *ptr, const grub_uint8_t *end) } } +static inline grub_uint32_t +skip_term (const grub_uint8_t *ptr, const grub_uint8_t *end) +{ + grub_uint32_t add; + const grub_uint8_t *ptr0 = ptr; + + switch(*ptr) + { + case GRUB_ACPI_OPCODE_ADD: + case GRUB_ACPI_OPCODE_AND: + case GRUB_ACPI_OPCODE_CONCAT: + case GRUB_ACPI_OPCODE_CONCATRES: + case GRUB_ACPI_OPCODE_DIVIDE: + case GRUB_ACPI_OPCODE_INDEX: + case GRUB_ACPI_OPCODE_LSHIFT: + case GRUB_ACPI_OPCODE_MOD: + case GRUB_ACPI_OPCODE_MULTIPLY: + case GRUB_ACPI_OPCODE_NAND: + case GRUB_ACPI_OPCODE_NOR: + case GRUB_ACPI_OPCODE_OR: + case GRUB_ACPI_OPCODE_RSHIFT: + case GRUB_ACPI_OPCODE_SUBTRACT: + case GRUB_ACPI_OPCODE_TOSTRING: + case GRUB_ACPI_OPCODE_XOR: + /* + * Parameters for these opcodes: TermArg, TermArg Target, see ACPI + * spec r5.0, page 828f. + */ + ptr++; + ptr += add = skip_term (ptr, end); + if (!add) + return 0; + ptr += add = skip_term (ptr, end); + if (!add) + return 0; + ptr += skip_name_string (ptr, end); + break; + default: + return skip_data_ref_object (ptr, end); + } + return ptr - ptr0; +} + static inline grub_uint32_t skip_ext_op (const grub_uint8_t *ptr, const grub_uint8_t *end) { @@ -156,10 +199,10 @@ skip_ext_op (const grub_uint8_t *ptr, const grub_uint8_t *end) ptr++; ptr += skip_name_string (ptr, end); ptr++; - ptr += add = skip_data_ref_object (ptr, end); + ptr += add = skip_term (ptr, end); if (!add) return 0; - ptr += add = skip_data_ref_object (ptr, end); + ptr += add = skip_term (ptr, end); if (!add) return 0; break; @@ -180,6 +223,7 @@ skip_ext_op (const grub_uint8_t *ptr, const grub_uint8_t *end) return ptr - ptr0; } + static int get_sleep_type (grub_uint8_t *table, grub_uint8_t *ptr, grub_uint8_t *end, grub_uint8_t *scope, int scope_len) @@ -250,6 +294,17 @@ get_sleep_type (grub_uint8_t *table, grub_uint8_t *ptr, grub_uint8_t *end, if (!add) return -1; break; + case GRUB_ACPI_OPCODE_ALIAS: + ptr++; + /* We need to skip two name strings */ + ptr += add = skip_name_string (ptr, end); + if (!add) + return -1; + ptr += add = skip_name_string (ptr, end); + if (!add) + return -1; + break; + case GRUB_ACPI_OPCODE_SCOPE: { int scope_sleep_type; diff --git a/include/grub/acpi.h b/include/grub/acpi.h index 2ac2bd6fd..f6e6a11c5 100644 --- a/include/grub/acpi.h +++ b/include/grub/acpi.h @@ -191,7 +191,8 @@ void grub_acpi_halt (void); enum { GRUB_ACPI_OPCODE_ZERO = 0, GRUB_ACPI_OPCODE_ONE = 1, - GRUB_ACPI_OPCODE_NAME = 8, GRUB_ACPI_OPCODE_BYTE_CONST = 0x0a, + GRUB_ACPI_OPCODE_NAME = 8, GRUB_ACPI_OPCODE_ALIAS = 0x06, + GRUB_ACPI_OPCODE_BYTE_CONST = 0x0a, GRUB_ACPI_OPCODE_WORD_CONST = 0x0b, GRUB_ACPI_OPCODE_DWORD_CONST = 0x0c, GRUB_ACPI_OPCODE_STRING_CONST = 0x0d, @@ -199,6 +200,22 @@ enum GRUB_ACPI_OPCODE_BUFFER = 0x11, GRUB_ACPI_OPCODE_PACKAGE = 0x12, GRUB_ACPI_OPCODE_METHOD = 0x14, GRUB_ACPI_OPCODE_EXTOP = 0x5b, + GRUB_ACPI_OPCODE_ADD = 0x72, + GRUB_ACPI_OPCODE_CONCAT = 0x73, + GRUB_ACPI_OPCODE_SUBTRACT = 0x74, + GRUB_ACPI_OPCODE_MULTIPLY = 0x77, + GRUB_ACPI_OPCODE_DIVIDE = 0x78, + GRUB_ACPI_OPCODE_LSHIFT = 0x79, + GRUB_ACPI_OPCODE_RSHIFT = 0x7a, + GRUB_ACPI_OPCODE_AND = 0x7b, + GRUB_ACPI_OPCODE_NAND = 0x7c, + GRUB_ACPI_OPCODE_OR = 0x7d, + GRUB_ACPI_OPCODE_NOR = 0x7e, + GRUB_ACPI_OPCODE_XOR = 0x7f, + GRUB_ACPI_OPCODE_CONCATRES = 0x84, + GRUB_ACPI_OPCODE_MOD = 0x85, + GRUB_ACPI_OPCODE_INDEX = 0x88, + GRUB_ACPI_OPCODE_TOSTRING = 0x9c, GRUB_ACPI_OPCODE_CREATE_WORD_FIELD = 0x8b, GRUB_ACPI_OPCODE_CREATE_BYTE_FIELD = 0x8c, GRUB_ACPI_OPCODE_IF = 0xa0, GRUB_ACPI_OPCODE_ONES = 0xff From 6d05b6383c0ea1a094cbfdbd503af31af0f6c393 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sun, 21 Sep 2014 19:02:11 +0200 Subject: [PATCH 108/722] Revert " Use -Wl,--no-relax rather than -mno-relax for uniformity." This reverts commit 063f2a04d158ec1b275a925dfbae74b124708cde. --- ChangeLog | 4 ---- conf/Makefile.common | 2 +- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6b35a5c2b..6d786baca 100644 --- a/ChangeLog +++ b/ChangeLog @@ -986,10 +986,6 @@ Allow compilation without thumb-interwork as long as no thumb is involved or only thumb2 is used. -2013-12-18 Vladimir Serbinenko - - Use -Wl,--no-relax rather than -mno-relax for uniformity. - 2013-12-18 Vladimir Serbinenko * INSTALL: Update comment as to why sparc64 clang isn't usable. diff --git a/conf/Makefile.common b/conf/Makefile.common index e4c301fb6..51fbaf99d 100644 --- a/conf/Makefile.common +++ b/conf/Makefile.common @@ -8,7 +8,7 @@ unexport LC_ALL # Platform specific options if COND_sparc64_ieee1275 CFLAGS_PLATFORM += -mno-app-regs - LDFLAGS_PLATFORM = -Wl,-melf64_sparc -Wl,--no-relax + LDFLAGS_PLATFORM = -Wl,-melf64_sparc -mno-relax endif if COND_sparc64_emu CFLAGS_PLATFORM += -mno-app-regs From 954fe77163dc12ccbb3d958b9dbb330aa59b62fe Mon Sep 17 00:00:00 2001 From: Andrey Borzenkov Date: Mon, 22 Sep 2014 20:47:10 +0400 Subject: [PATCH 109/722] cleanup: grub_cpu_to_XXX_compile_time for constants This tries to catch all cases where grub_cpu_to_XXX was used for constant expressions (including sizeof). --- ChangeLog | 4 +++ grub-core/bus/usb/ehci.c | 44 ++++++++++++++++---------------- grub-core/bus/usb/ohci.c | 8 +++--- grub-core/commands/gptsync.c | 6 ++--- grub-core/disk/mdraid_linux.c | 12 ++++----- grub-core/disk/scsi.c | 2 +- grub-core/disk/usbms.c | 4 +-- grub-core/fs/hfs.c | 2 +- grub-core/fs/reiserfs.c | 12 ++++----- grub-core/lib/fdt.c | 12 ++++----- grub-core/loader/i386/linux.c | 2 +- grub-core/loader/i386/pc/linux.c | 20 +++++++-------- grub-core/loader/i386/xen_file.c | 4 +-- grub-core/net/arp.c | 4 +-- grub-core/net/bootp.c | 4 +-- grub-core/net/ip.c | 2 +- grub-core/net/net.c | 2 +- grub-core/net/tftp.c | 8 +++--- grub-core/partmap/acorn.c | 4 +-- grub-core/partmap/bsdlabel.c | 2 +- grub-core/partmap/gpt.c | 2 +- grub-core/partmap/msdos.c | 4 +-- grub-core/tests/video_checksum.c | 6 ++--- util/grub-mkfont.c | 4 +-- util/grub-mklayout.c | 2 +- util/mkimage.c | 15 ++++++----- 26 files changed, 98 insertions(+), 93 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6d786baca..8316b8fa0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2014-09-22 Andrei Borzenkov + + Use grub_cpu_to_XXX_compile_time for constants. + 2014-09-21 Valentin Dornauer The AML parser implements only a small subset of possible AML diff --git a/grub-core/bus/usb/ehci.c b/grub-core/bus/usb/ehci.c index c0feefafe..8ece40086 100644 --- a/grub-core/bus/usb/ehci.c +++ b/grub-core/bus/usb/ehci.c @@ -670,23 +670,23 @@ grub_ehci_pci_iter (grub_pci_device_t dev, grub_pci_id_t pciid, for (i = 0; i < (GRUB_EHCI_N_TD - 1); i++) { e->td_virt[i].link_td = e->td_phys + (i + 1) * sizeof (struct grub_ehci_td); - e->td_virt[i].next_td = grub_cpu_to_le32 (GRUB_EHCI_TERMINATE); - e->td_virt[i].alt_next_td = grub_cpu_to_le32 (GRUB_EHCI_TERMINATE); + e->td_virt[i].next_td = grub_cpu_to_le32_compile_time (GRUB_EHCI_TERMINATE); + e->td_virt[i].alt_next_td = grub_cpu_to_le32_compile_time (GRUB_EHCI_TERMINATE); } e->td_virt[GRUB_EHCI_N_TD - 1].next_td = - grub_cpu_to_le32 (GRUB_EHCI_TERMINATE); + grub_cpu_to_le32_compile_time (GRUB_EHCI_TERMINATE); e->td_virt[GRUB_EHCI_N_TD - 1].alt_next_td = - grub_cpu_to_le32 (GRUB_EHCI_TERMINATE); + grub_cpu_to_le32_compile_time (GRUB_EHCI_TERMINATE); e->tdfree_virt = e->td_virt; /* Set Terminate in first QH, which is used in framelist */ - e->qh_virt[0].qh_hptr = grub_cpu_to_le32 (GRUB_EHCI_TERMINATE | GRUB_EHCI_HPTR_TYPE_QH); - e->qh_virt[0].td_overlay.next_td = grub_cpu_to_le32 (GRUB_EHCI_TERMINATE); + e->qh_virt[0].qh_hptr = grub_cpu_to_le32_compile_time (GRUB_EHCI_TERMINATE | GRUB_EHCI_HPTR_TYPE_QH); + e->qh_virt[0].td_overlay.next_td = grub_cpu_to_le32_compile_time (GRUB_EHCI_TERMINATE); e->qh_virt[0].td_overlay.alt_next_td = - grub_cpu_to_le32 (GRUB_EHCI_TERMINATE); + grub_cpu_to_le32_compile_time (GRUB_EHCI_TERMINATE); /* Also set Halted bit in token */ - e->qh_virt[0].td_overlay.token = grub_cpu_to_le32 (GRUB_EHCI_STATUS_HALTED); + e->qh_virt[0].td_overlay.token = grub_cpu_to_le32_compile_time (GRUB_EHCI_STATUS_HALTED); /* Set the H bit in first QH used for AL */ - e->qh_virt[1].ep_char = grub_cpu_to_le32 (GRUB_EHCI_H); + e->qh_virt[1].ep_char = grub_cpu_to_le32_compile_time (GRUB_EHCI_H); /* Set Terminate into TD in rest of QHs and set horizontal link * pointer to itself - these QHs will be used for asynchronous * schedule and they should have valid value in horiz. link */ @@ -697,12 +697,12 @@ grub_ehci_pci_iter (grub_pci_device_t dev, grub_pci_id_t pciid, e->qh_chunk) & GRUB_EHCI_POINTER_MASK) | GRUB_EHCI_HPTR_TYPE_QH); e->qh_virt[i].td_overlay.next_td = - grub_cpu_to_le32 (GRUB_EHCI_TERMINATE); + grub_cpu_to_le32_compile_time (GRUB_EHCI_TERMINATE); e->qh_virt[i].td_overlay.alt_next_td = - grub_cpu_to_le32 (GRUB_EHCI_TERMINATE); + grub_cpu_to_le32_compile_time (GRUB_EHCI_TERMINATE); /* Also set Halted bit in token */ e->qh_virt[i].td_overlay.token = - grub_cpu_to_le32 (GRUB_EHCI_STATUS_HALTED); + grub_cpu_to_le32_compile_time (GRUB_EHCI_STATUS_HALTED); } /* Note: QH 0 and QH 1 are reserved and must not be used anywhere. @@ -991,7 +991,7 @@ grub_ehci_find_qh (struct grub_ehci *e, grub_usb_transfer_t transfer) target = ((transfer->endpoint << GRUB_EHCI_EP_NUM_OFF) | transfer->devaddr) & GRUB_EHCI_TARGET_MASK; target = grub_cpu_to_le32 (target); - mask = grub_cpu_to_le32 (GRUB_EHCI_TARGET_MASK); + mask = grub_cpu_to_le32_compile_time (GRUB_EHCI_TARGET_MASK); /* low speed interrupt transfers are linked to the periodic */ /* schedule, everything else to the asynchronous schedule */ @@ -1200,7 +1200,7 @@ grub_ehci_transaction (struct grub_ehci *e, grub_memset ((void *) td, 0, sizeof (struct grub_ehci_td)); /* Don't point to any TD yet, just terminate. */ - td->next_td = grub_cpu_to_le32 (GRUB_EHCI_TERMINATE); + td->next_td = grub_cpu_to_le32_compile_time (GRUB_EHCI_TERMINATE); /* Set alternate pointer. When short packet occurs, alternate TD * will not be really fetched because it is not active. But don't * forget, EHCI will try to fetch alternate TD every scan of AL @@ -1325,9 +1325,9 @@ grub_ehci_setup_transfer (grub_usb_controller_t dev, /* Fill whole alternate TD by zeros (= inactive) and set * Terminate bits and Halt bit */ grub_memset ((void *) cdata->td_alt_virt, 0, sizeof (struct grub_ehci_td)); - cdata->td_alt_virt->next_td = grub_cpu_to_le32 (GRUB_EHCI_TERMINATE); - cdata->td_alt_virt->alt_next_td = grub_cpu_to_le32 (GRUB_EHCI_TERMINATE); - cdata->td_alt_virt->token = grub_cpu_to_le32 (GRUB_EHCI_STATUS_HALTED); + cdata->td_alt_virt->next_td = grub_cpu_to_le32_compile_time (GRUB_EHCI_TERMINATE); + cdata->td_alt_virt->alt_next_td = grub_cpu_to_le32_compile_time (GRUB_EHCI_TERMINATE); + cdata->td_alt_virt->token = grub_cpu_to_le32_compile_time (GRUB_EHCI_STATUS_HALTED); /* Allocate appropriate number of TDs and set */ for (i = 0; i < transfer->transcnt; i++) @@ -1364,7 +1364,7 @@ grub_ehci_setup_transfer (grub_usb_controller_t dev, cdata->td_last_virt = td; cdata->td_last_phys = grub_dma_virt2phys (td, e->td_chunk); /* Last TD should not have set alternate TD */ - cdata->td_last_virt->alt_next_td = grub_cpu_to_le32 (GRUB_EHCI_TERMINATE); + cdata->td_last_virt->alt_next_td = grub_cpu_to_le32_compile_time (GRUB_EHCI_TERMINATE); grub_dprintf ("ehci", "setup_transfer: cdata=%p, qh=%p\n", cdata,cdata->qh_virt); @@ -1377,14 +1377,14 @@ grub_ehci_setup_transfer (grub_usb_controller_t dev, /* Start transfer: */ /* Unlink possible alternate pointer in QH */ cdata->qh_virt->td_overlay.alt_next_td = - grub_cpu_to_le32 (GRUB_EHCI_TERMINATE); + grub_cpu_to_le32_compile_time (GRUB_EHCI_TERMINATE); /* Link new TDs with QH via next_td */ cdata->qh_virt->td_overlay.next_td = grub_cpu_to_le32 (grub_dma_virt2phys (cdata->td_first_virt, e->td_chunk)); /* Reset Active and Halted bits in QH to activate Advance Queue, * i.e. reset token */ - cdata->qh_virt->td_overlay.token = grub_cpu_to_le32 (0); + cdata->qh_virt->td_overlay.token = grub_cpu_to_le32_compile_time (0); /* Finito */ transfer->controller_data = cdata; @@ -1408,9 +1408,9 @@ grub_ehci_pre_finish_transfer (grub_usb_transfer_t transfer) * safely manipulate with QH TD part. */ cdata->qh_virt->td_overlay.token = (cdata->qh_virt->td_overlay.token | - grub_cpu_to_le32 + grub_cpu_to_le32_compile_time (GRUB_EHCI_STATUS_HALTED)) & - grub_cpu_to_le32 (~GRUB_EHCI_STATUS_ACTIVE); + grub_cpu_to_le32_compile_time (~GRUB_EHCI_STATUS_ACTIVE); /* Print debug data here if necessary */ diff --git a/grub-core/bus/usb/ohci.c b/grub-core/bus/usb/ohci.c index 946a4ed7d..d27bfe7fb 100644 --- a/grub-core/bus/usb/ohci.c +++ b/grub-core/bus/usb/ohci.c @@ -314,7 +314,7 @@ grub_ohci_pci_iter (grub_pci_device_t dev, grub_pci_id_t pciid, grub_memset ((void *) o->ed_ctrl, 0, sizeof (struct grub_ohci_ed) * GRUB_OHCI_CTRL_EDS); for (j=0; j < GRUB_OHCI_CTRL_EDS; j++) - o->ed_ctrl[j].target = grub_cpu_to_le32 (1 << 14); /* skip */ + o->ed_ctrl[j].target = grub_cpu_to_le32_compile_time (1 << 14); /* skip */ grub_dprintf ("ohci", "EDs-C: chunk=%p, virt=%p, phys=0x%02x\n", o->ed_ctrl_chunk, o->ed_ctrl, o->ed_ctrl_addr); @@ -329,7 +329,7 @@ grub_ohci_pci_iter (grub_pci_device_t dev, grub_pci_id_t pciid, /* Preset EDs */ grub_memset ((void*)o->ed_bulk, 0, sizeof(struct grub_ohci_ed) * GRUB_OHCI_BULK_EDS); for (j=0; j < GRUB_OHCI_BULK_EDS; j++) - o->ed_bulk[j].target = grub_cpu_to_le32 (1 << 14); /* skip */ + o->ed_bulk[j].target = grub_cpu_to_le32_compile_time (1 << 14); /* skip */ grub_dprintf ("ohci", "EDs-B: chunk=%p, virt=%p, phys=0x%02x\n", o->ed_bulk_chunk, o->ed_bulk, o->ed_bulk_addr); @@ -1349,10 +1349,10 @@ grub_ohci_fini_hw (int noreturn __attribute__ ((unused))) /* Set skip in all EDs */ if (o->ed_bulk) for (i=0; i < GRUB_OHCI_BULK_EDS; i++) - o->ed_bulk[i].target |= grub_cpu_to_le32 (1 << 14); /* skip */ + o->ed_bulk[i].target |= grub_cpu_to_le32_compile_time (1 << 14); /* skip */ if (o->ed_ctrl) for (i=0; i < GRUB_OHCI_CTRL_EDS; i++) - o->ed_ctrl[i].target |= grub_cpu_to_le32 (1 << 14); /* skip */ + o->ed_ctrl[i].target |= grub_cpu_to_le32_compile_time (1 << 14); /* skip */ /* We should wait for next SOF to be sure that all EDs are * unaccessed by OHCI. But OHCI can be non-functional, so diff --git a/grub-core/commands/gptsync.c b/grub-core/commands/gptsync.c index 3db62887b..16592e9bb 100644 --- a/grub-core/commands/gptsync.c +++ b/grub-core/commands/gptsync.c @@ -101,7 +101,7 @@ grub_cmd_gptsync (grub_command_t cmd __attribute__ ((unused)), } /* Check if it is valid. */ - if (mbr.signature != grub_cpu_to_le16 (GRUB_PC_PARTITION_SIGNATURE)) + if (mbr.signature != grub_cpu_to_le16_compile_time (GRUB_PC_PARTITION_SIGNATURE)) { grub_device_close (dev); return grub_error (GRUB_ERR_BAD_PART_TABLE, "no signature"); @@ -216,7 +216,7 @@ grub_cmd_gptsync (grub_command_t cmd __attribute__ ((unused)), first_sector--; mbr.entries[0].flag = 0; mbr.entries[0].type = GRUB_PC_PARTITION_TYPE_GPT_DISK; - mbr.entries[0].start = grub_cpu_to_le32 (1); + mbr.entries[0].start = grub_cpu_to_le32_compile_time (1); lba_to_chs (1, &(mbr.entries[0].start_sector), &(mbr.entries[0].start_cylinder), @@ -227,7 +227,7 @@ grub_cmd_gptsync (grub_command_t cmd __attribute__ ((unused)), &(mbr.entries[0].end_head)); mbr.entries[0].length = grub_cpu_to_le32 (first_sector); - mbr.signature = grub_cpu_to_le16 (GRUB_PC_PARTITION_SIGNATURE); + mbr.signature = grub_cpu_to_le16_compile_time (GRUB_PC_PARTITION_SIGNATURE); if (grub_disk_write (dev->disk, 0, 0, sizeof (mbr), &mbr)) { diff --git a/grub-core/disk/mdraid_linux.c b/grub-core/disk/mdraid_linux.c index 4aa588235..11024ae31 100644 --- a/grub-core/disk/mdraid_linux.c +++ b/grub-core/disk/mdraid_linux.c @@ -33,16 +33,16 @@ GRUB_MOD_LICENSE ("GPLv3+"); #define grub_md_to_cpu64 grub_be_to_cpu64 #define grub_md_to_cpu32 grub_be_to_cpu32 #define grub_md_to_cpu16 grub_be_to_cpu16 -#define grub_cpu_to_md64_compile_time grub_cpu_to_be64 -#define grub_cpu_to_md32_compile_time grub_cpu_to_be32 -#define grub_cpu_to_md16_compile_time grub_cpu_to_be16 +#define grub_cpu_to_md64_compile_time grub_cpu_to_be64_compile_time +#define grub_cpu_to_md32_compile_time grub_cpu_to_be32_compile_time +#define grub_cpu_to_md16_compile_time grub_cpu_to_be16_compile_time #else #define grub_md_to_cpu64 grub_le_to_cpu64 #define grub_md_to_cpu32 grub_le_to_cpu32 #define grub_md_to_cpu16 grub_le_to_cpu16 -#define grub_cpu_to_md64_compile_time grub_cpu_to_le64 -#define grub_cpu_to_md32_compile_time grub_cpu_to_le32 -#define grub_cpu_to_md16_compile_time grub_cpu_to_le16 +#define grub_cpu_to_md64_compile_time grub_cpu_to_le64_compile_time +#define grub_cpu_to_md32_compile_time grub_cpu_to_le32_compile_time +#define grub_cpu_to_md16_compile_time grub_cpu_to_le16_compile_time #endif #define RESERVED_BYTES (64 * 1024) diff --git a/grub-core/disk/scsi.c b/grub-core/disk/scsi.c index b6cb2f421..92084d0f8 100644 --- a/grub-core/disk/scsi.c +++ b/grub-core/disk/scsi.c @@ -201,7 +201,7 @@ grub_scsi_read_capacity16 (grub_scsi_t scsi) rc.opcode = grub_scsi_cmd_read_capacity16; rc.lun = (scsi->lun << GRUB_SCSI_LUN_SHIFT) | 0x10; rc.logical_block_addr = 0; - rc.alloc_len = grub_cpu_to_be32 (sizeof (rcd)); + rc.alloc_len = grub_cpu_to_be32_compile_time (sizeof (rcd)); rc.PMI = 0; rc.control = 0; diff --git a/grub-core/disk/usbms.c b/grub-core/disk/usbms.c index 2b769bdd8..380ca4c4c 100644 --- a/grub-core/disk/usbms.c +++ b/grub-core/disk/usbms.c @@ -307,7 +307,7 @@ grub_usbms_transfer_bo (struct grub_scsi *scsi, grub_size_t cmdsize, char *cmd, /* Setup the request. */ grub_memset (&cbw, 0, sizeof (cbw)); - cbw.signature = grub_cpu_to_le32 (0x43425355); + cbw.signature = grub_cpu_to_le32_compile_time (0x43425355); cbw.tag = tag; cbw.transfer_length = grub_cpu_to_le32 (size); cbw.flags = (!read_write) << GRUB_USBMS_DIRECTION_BIT; @@ -414,7 +414,7 @@ CheckCSW: /* If phase error or not valid signature, do bulk-only reset device. */ if ((status.status == 2) || - (status.signature != grub_cpu_to_le32(0x53425355))) + (status.signature != grub_cpu_to_le32_compile_time(0x53425355))) { /* Bulk-only reset device. */ grub_dprintf ("usb", "Bulk-only reset device - bad status\n"); grub_usbms_reset (dev); diff --git a/grub-core/fs/hfs.c b/grub-core/fs/hfs.c index 1e593059a..d1dc01545 100644 --- a/grub-core/fs/hfs.c +++ b/grub-core/fs/hfs.c @@ -369,7 +369,7 @@ grub_hfs_mount (grub_disk_t disk) /* Lookup the root directory node in the catalog tree using the volume name. */ - key.parent_dir = grub_cpu_to_be32 (1); + key.parent_dir = grub_cpu_to_be32_compile_time (1); key.strlen = data->sblock.volname[0]; grub_strcpy ((char *) key.str, (char *) (data->sblock.volname + 1)); diff --git a/grub-core/fs/reiserfs.c b/grub-core/fs/reiserfs.c index ac65054d3..de3d4fa3c 100644 --- a/grub-core/fs/reiserfs.c +++ b/grub-core/fs/reiserfs.c @@ -365,7 +365,7 @@ grub_reiserfs_set_key_offset (struct grub_reiserfs_key *key, key->u.v1.offset = grub_cpu_to_le32 (value); else key->u.v2.offset_type \ - = ((key->u.v2.offset_type & grub_cpu_to_le64 (15ULL << 60)) + = ((key->u.v2.offset_type & grub_cpu_to_le64_compile_time (15ULL << 60)) | grub_cpu_to_le64 (value & (~0ULL >> 4))); } @@ -412,7 +412,7 @@ grub_reiserfs_set_key_type (struct grub_reiserfs_key *key, key->u.v1.type = grub_cpu_to_le32 (type); else key->u.v2.offset_type - = ((key->u.v2.offset_type & grub_cpu_to_le64 (~0ULL >> 4)) + = ((key->u.v2.offset_type & grub_cpu_to_le64_compile_time (~0ULL >> 4)) | grub_cpu_to_le64 ((grub_uint64_t) type << 60)); assert (grub_reiserfs_get_key_type (key) == grub_type); @@ -997,8 +997,8 @@ grub_reiserfs_open (struct grub_file *file, const char *name) data = grub_reiserfs_mount (file->device->disk); if (! data) goto fail; - key.directory_id = grub_cpu_to_le32 (1); - key.object_id = grub_cpu_to_le32 (2); + key.directory_id = grub_cpu_to_le32_compile_time (1); + key.object_id = grub_cpu_to_le32_compile_time (2); key.u.v2.offset_type = 0; grub_reiserfs_set_key_type (&key, GRUB_REISERFS_DIRECTORY, 2); grub_reiserfs_set_key_offset (&key, 1); @@ -1289,8 +1289,8 @@ grub_reiserfs_dir (grub_device_t device, const char *path, data = grub_reiserfs_mount (device->disk); if (! data) goto fail; - root_key.directory_id = grub_cpu_to_le32 (1); - root_key.object_id = grub_cpu_to_le32 (2); + root_key.directory_id = grub_cpu_to_le32_compile_time (1); + root_key.object_id = grub_cpu_to_le32_compile_time (2); root_key.u.v2.offset_type = 0; grub_reiserfs_set_key_type (&root_key, GRUB_REISERFS_DIRECTORY, 2); grub_reiserfs_set_key_offset (&root_key, 1); diff --git a/grub-core/lib/fdt.c b/grub-core/lib/fdt.c index 907a7bff6..7e76dc06b 100644 --- a/grub-core/lib/fdt.c +++ b/grub-core/lib/fdt.c @@ -164,10 +164,10 @@ static int add_subnode (void *fdt, int parentoffset, const char *name) insert: grub_memmove (token + entry_size / sizeof(*token), token, (grub_addr_t) end - (grub_addr_t) token); - *token = grub_cpu_to_be32(FDT_BEGIN_NODE); + *token = grub_cpu_to_be32_compile_time(FDT_BEGIN_NODE); token[entry_size / sizeof(*token) - 2] = 0; /* padding bytes */ grub_strcpy((char *) (token + 1), name); - token[entry_size / sizeof(*token) - 1] = grub_cpu_to_be32(FDT_END_NODE); + token[entry_size / sizeof(*token) - 1] = grub_cpu_to_be32_compile_time(FDT_END_NODE); grub_fdt_set_size_dt_struct (fdt, struct_size + entry_size); return ((grub_addr_t) token - (grub_addr_t) fdt - grub_fdt_get_off_dt_struct(fdt)); @@ -377,7 +377,7 @@ int grub_fdt_set_prop (void *fdt, unsigned int nodeoffset, const char *name, prop_name_present = 1; for (i = 0; i < prop_len / sizeof(grub_uint32_t); i++) - *(prop + 3 + i) = grub_cpu_to_be32 (FDT_NOP); + *(prop + 3 + i) = grub_cpu_to_be32_compile_time (FDT_NOP); if (len > ALIGN_UP(prop_len, sizeof(grub_uint32_t))) { /* Length of new property value is greater than the space allocated @@ -385,7 +385,7 @@ int grub_fdt_set_prop (void *fdt, unsigned int nodeoffset, const char *name, nameoff field of the current entry and replace the current entry with NOP tokens. */ nameoff = grub_be_to_cpu32 (*(prop + 2)); - *prop = *(prop + 1) = *(prop + 2) = grub_cpu_to_be32 (FDT_NOP); + *prop = *(prop + 1) = *(prop + 2) = grub_cpu_to_be32_compile_time (FDT_NOP); prop = NULL; } } @@ -419,7 +419,7 @@ int grub_fdt_set_prop (void *fdt, unsigned int nodeoffset, const char *name, struct_end(fdt) - (grub_addr_t) prop); grub_fdt_set_size_dt_struct (fdt, grub_fdt_get_size_dt_struct (fdt) + prop_entry_size(len)); - *prop = grub_cpu_to_be32 (FDT_PROP); + *prop = grub_cpu_to_be32_compile_time (FDT_PROP); *(prop + 2) = grub_cpu_to_be32 (nameoff); } *(prop + 1) = grub_cpu_to_be32 (len); @@ -447,7 +447,7 @@ grub_fdt_create_empty_tree (void *fdt, unsigned int size) et->empty_node.node_end = grub_cpu_to_be32_compile_time (FDT_END_NODE); et->empty_node.node_start = grub_cpu_to_be32_compile_time (FDT_BEGIN_NODE); ((struct grub_fdt_empty_tree *) fdt)->header.off_mem_rsvmap = - grub_cpu_to_be32 (ALIGN_UP (sizeof (grub_fdt_header_t), 8)); + grub_cpu_to_be32_compile_time (ALIGN_UP (sizeof (grub_fdt_header_t), 8)); grub_fdt_set_off_dt_strings (fdt, sizeof (*et)); grub_fdt_set_off_dt_struct (fdt, diff --git a/grub-core/loader/i386/linux.c b/grub-core/loader/i386/linux.c index 2ae176315..0bd060a52 100644 --- a/grub-core/loader/i386/linux.c +++ b/grub-core/loader/i386/linux.c @@ -722,7 +722,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), /* FIXME: 2.03 is not always good enough (Linux 2.4 can be 2.03 and still not support 32-bit boot. */ - if (lh.header != grub_cpu_to_le32 (GRUB_LINUX_MAGIC_SIGNATURE) + if (lh.header != grub_cpu_to_le32_compile_time (GRUB_LINUX_MAGIC_SIGNATURE) || grub_le_to_cpu16 (lh.version) < 0x0203) { grub_error (GRUB_ERR_BAD_OS, "version too old for 32-bit boot" diff --git a/grub-core/loader/i386/pc/linux.c b/grub-core/loader/i386/pc/linux.c index b481e4668..e88341e3c 100644 --- a/grub-core/loader/i386/pc/linux.c +++ b/grub-core/loader/i386/pc/linux.c @@ -151,7 +151,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), goto fail; } - if (lh.boot_flag != grub_cpu_to_le16 (0xaa55)) + if (lh.boot_flag != grub_cpu_to_le16_compile_time (0xaa55)) { grub_error (GRUB_ERR_BAD_OS, "invalid magic number"); goto fail; @@ -169,7 +169,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), maximal_cmdline_size = 256; - if (lh.header == grub_cpu_to_le32 (GRUB_LINUX_MAGIC_SIGNATURE) + if (lh.header == grub_cpu_to_le32_compile_time (GRUB_LINUX_MAGIC_SIGNATURE) && grub_le_to_cpu16 (lh.version) >= 0x0200) { grub_linux_is_bzimage = (lh.loadflags & GRUB_LINUX_FLAG_BIG_KERNEL); @@ -188,7 +188,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), if (grub_le_to_cpu16 (lh.version) >= 0x0201) { - lh.heap_end_ptr = grub_cpu_to_le16 (GRUB_LINUX_HEAP_END_OFFSET); + lh.heap_end_ptr = grub_cpu_to_le16_compile_time (GRUB_LINUX_HEAP_END_OFFSET); lh.loadflags |= GRUB_LINUX_FLAG_CAN_USE_HEAP; } @@ -196,17 +196,17 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), lh.cmd_line_ptr = grub_linux_real_target + GRUB_LINUX_CL_OFFSET; else { - lh.cl_magic = grub_cpu_to_le16 (GRUB_LINUX_CL_MAGIC); - lh.cl_offset = grub_cpu_to_le16 (GRUB_LINUX_CL_OFFSET); - lh.setup_move_size = grub_cpu_to_le16 (GRUB_LINUX_CL_OFFSET + lh.cl_magic = grub_cpu_to_le16_compile_time (GRUB_LINUX_CL_MAGIC); + lh.cl_offset = grub_cpu_to_le16_compile_time (GRUB_LINUX_CL_OFFSET); + lh.setup_move_size = grub_cpu_to_le16_compile_time (GRUB_LINUX_CL_OFFSET + maximal_cmdline_size); } } else { /* Your kernel is quite old... */ - lh.cl_magic = grub_cpu_to_le16 (GRUB_LINUX_CL_MAGIC); - lh.cl_offset = grub_cpu_to_le16 (GRUB_LINUX_CL_OFFSET); + lh.cl_magic = grub_cpu_to_le16_compile_time (GRUB_LINUX_CL_MAGIC); + lh.cl_offset = grub_cpu_to_le16_compile_time (GRUB_LINUX_CL_OFFSET); setup_sects = GRUB_LINUX_DEFAULT_SETUP_SECTS; @@ -319,7 +319,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), goto fail; } - if (lh.header != grub_cpu_to_le32 (GRUB_LINUX_MAGIC_SIGNATURE) + if (lh.header != grub_cpu_to_le32_compile_time (GRUB_LINUX_MAGIC_SIGNATURE) || grub_le_to_cpu16 (lh.version) < 0x0200) /* Clear the heap space. */ grub_memset (grub_linux_real_chunk @@ -404,7 +404,7 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), lh = (struct linux_kernel_header *) grub_linux_real_chunk; - if (!(lh->header == grub_cpu_to_le32 (GRUB_LINUX_MAGIC_SIGNATURE) + if (!(lh->header == grub_cpu_to_le32_compile_time (GRUB_LINUX_MAGIC_SIGNATURE) && grub_le_to_cpu16 (lh->version) >= 0x0200)) { grub_error (GRUB_ERR_BAD_OS, "the kernel is too old for initrd"); diff --git a/grub-core/loader/i386/xen_file.c b/grub-core/loader/i386/xen_file.c index ff23235f0..583621890 100644 --- a/grub-core/loader/i386/xen_file.c +++ b/grub-core/loader/i386/xen_file.c @@ -38,8 +38,8 @@ grub_xen_file (grub_file_t file) if (grub_file_read (file, &lh, sizeof (lh)) != sizeof (lh)) goto fail; - if (lh.boot_flag != grub_cpu_to_le16 (0xaa55) - || lh.header != grub_cpu_to_le32 (GRUB_LINUX_MAGIC_SIGNATURE) + if (lh.boot_flag != grub_cpu_to_le16_compile_time (0xaa55) + || lh.header != grub_cpu_to_le32_compile_time (GRUB_LINUX_MAGIC_SIGNATURE) || grub_le_to_cpu16 (lh.version) < 0x0208) { grub_error (GRUB_ERR_BAD_OS, "version too old for xen boot"); diff --git a/grub-core/net/arp.c b/grub-core/net/arp.c index d62d0cc1e..8cc390b0e 100644 --- a/grub-core/net/arp.c +++ b/grub-core/net/arp.c @@ -81,11 +81,11 @@ grub_net_arp_send_request (struct grub_net_network_level_interface *inf, return err; arp_header = (struct arphdr *) nb.data; - arp_header->hrd = grub_cpu_to_be16 (GRUB_NET_ARPHRD_ETHERNET); + arp_header->hrd = grub_cpu_to_be16_compile_time (GRUB_NET_ARPHRD_ETHERNET); arp_header->hln = 6; arp_header->pro = grub_cpu_to_be16 (etherpro); arp_header->pln = addrlen; - arp_header->op = grub_cpu_to_be16 (ARP_REQUEST); + arp_header->op = grub_cpu_to_be16_compile_time (ARP_REQUEST); aux = (grub_uint8_t *) arp_header + sizeof (*arp_header); /* Sender hardware address. */ grub_memcpy (aux, &inf->hwaddress.mac, 6); diff --git a/grub-core/net/bootp.c b/grub-core/net/bootp.c index 6310ed447..613675533 100644 --- a/grub-core/net/bootp.c +++ b/grub-core/net/bootp.c @@ -522,8 +522,8 @@ grub_cmd_bootp (struct grub_command *cmd __attribute__ ((unused)), grub_netbuff_push (nb, sizeof (*udph)); udph = (struct udphdr *) nb->data; - udph->src = grub_cpu_to_be16 (68); - udph->dst = grub_cpu_to_be16 (67); + udph->src = grub_cpu_to_be16_compile_time (68); + udph->dst = grub_cpu_to_be16_compile_time (67); udph->chksum = 0; udph->len = grub_cpu_to_be16 (nb->tail - nb->data); target.type = GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV4; diff --git a/grub-core/net/ip.c b/grub-core/net/ip.c index c6971f9fc..5a6095444 100644 --- a/grub-core/net/ip.c +++ b/grub-core/net/ip.c @@ -611,7 +611,7 @@ grub_net_send_ip6_packet (struct grub_net_network_level_interface *inf, grub_netbuff_push (nb, sizeof (*iph)); iph = (struct ip6hdr *) nb->data; - iph->version_class_flow = grub_cpu_to_be32 ((6 << 28)); + iph->version_class_flow = grub_cpu_to_be32_compile_time ((6 << 28)); iph->len = grub_cpu_to_be16 (nb->tail - nb->data - sizeof (*iph)); iph->protocol = proto; iph->ttl = 0xff; diff --git a/grub-core/net/net.c b/grub-core/net/net.c index f2e723bd4..82af3a0ba 100644 --- a/grub-core/net/net.c +++ b/grub-core/net/net.c @@ -306,7 +306,7 @@ grub_net_ipv6_get_link_local (struct grub_net_card *card, return NULL; addr.type = GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV6; - addr.ipv6[0] = grub_cpu_to_be64 (0xfe80ULL << 48); + addr.ipv6[0] = grub_cpu_to_be64_compile_time (0xfe80ULL << 48); addr.ipv6[1] = grub_net_ipv6_get_id (hwaddr); FOR_NET_NETWORK_LEVEL_INTERFACES (inf) diff --git a/grub-core/net/tftp.c b/grub-core/net/tftp.c index 517361427..1319671ff 100644 --- a/grub-core/net/tftp.c +++ b/grub-core/net/tftp.c @@ -149,7 +149,7 @@ ack (tftp_data_t data, grub_uint64_t block) return err; tftph_ack = (struct tftphdr *) nb_ack.data; - tftph_ack->opcode = grub_cpu_to_be16 (TFTP_ACK); + tftph_ack->opcode = grub_cpu_to_be16_compile_time (TFTP_ACK); tftph_ack->u.ack.block = grub_cpu_to_be16 (block); err = grub_net_send_udp_packet (data->sock, &nb_ack); @@ -333,7 +333,7 @@ tftp_open (struct grub_file *file, const char *filename) rrq = (char *) tftph->u.rrq; rrqlen = 0; - tftph->opcode = grub_cpu_to_be16 (TFTP_RRQ); + tftph->opcode = grub_cpu_to_be16_compile_time (TFTP_RRQ); grub_strcpy (rrq, filename); rrqlen += grub_strlen (filename) + 1; rrq += grub_strlen (filename) + 1; @@ -443,8 +443,8 @@ tftp_close (struct grub_file *file) if (!err) { tftph = (struct tftphdr *) nb_err.data; - tftph->opcode = grub_cpu_to_be16 (TFTP_ERROR); - tftph->u.err.errcode = grub_cpu_to_be16 (TFTP_EUNDEF); + tftph->opcode = grub_cpu_to_be16_compile_time (TFTP_ERROR); + tftph->u.err.errcode = grub_cpu_to_be16_compile_time (TFTP_EUNDEF); grub_memcpy (tftph->u.err.errmsg, "closed", sizeof ("closed")); err = grub_net_send_udp_packet (data->sock, &nb_err); diff --git a/grub-core/partmap/acorn.c b/grub-core/partmap/acorn.c index 7bb93d9be..c022c61dd 100644 --- a/grub-core/partmap/acorn.c +++ b/grub-core/partmap/acorn.c @@ -25,8 +25,8 @@ GRUB_MOD_LICENSE ("GPLv3+"); -#define LINUX_NATIVE_MAGIC grub_cpu_to_le32 (0xdeafa1de) -#define LINUX_SWAP_MAGIC grub_cpu_to_le32 (0xdeafab1e) +#define LINUX_NATIVE_MAGIC grub_cpu_to_le32_compile_time (0xdeafa1de) +#define LINUX_SWAP_MAGIC grub_cpu_to_le32_compile_time (0xdeafab1e) #define LINUX_MAP_ENTRIES (512 / 12) #define NONADFS_PARTITION_TYPE_LINUX 9 diff --git a/grub-core/partmap/bsdlabel.c b/grub-core/partmap/bsdlabel.c index cf0f967c1..1d785906b 100644 --- a/grub-core/partmap/bsdlabel.c +++ b/grub-core/partmap/bsdlabel.c @@ -53,7 +53,7 @@ iterate_real (grub_disk_t disk, grub_disk_addr_t sector, int freebsd, return grub_errno; /* Check if it is valid. */ - if (label.magic != grub_cpu_to_le32 (GRUB_PC_PARTITION_BSD_LABEL_MAGIC)) + if (label.magic != grub_cpu_to_le32_compile_time (GRUB_PC_PARTITION_BSD_LABEL_MAGIC)) return grub_error (GRUB_ERR_BAD_PART_TABLE, "no signature"); /* A kludge to determine a base of be.offset. */ diff --git a/grub-core/partmap/gpt.c b/grub-core/partmap/gpt.c index 38df7b3c9..83bcba779 100644 --- a/grub-core/partmap/gpt.c +++ b/grub-core/partmap/gpt.c @@ -65,7 +65,7 @@ grub_gpt_partition_map_iterate (grub_disk_t disk, return grub_errno; /* Check if it is valid. */ - if (mbr.signature != grub_cpu_to_le16 (GRUB_PC_PARTITION_SIGNATURE)) + if (mbr.signature != grub_cpu_to_le16_compile_time (GRUB_PC_PARTITION_SIGNATURE)) return grub_error (GRUB_ERR_BAD_PART_TABLE, "no signature"); /* Make sure the MBR is a protective MBR and not a normal MBR. */ diff --git a/grub-core/partmap/msdos.c b/grub-core/partmap/msdos.c index 1d81a5357..46c406bff 100644 --- a/grub-core/partmap/msdos.c +++ b/grub-core/partmap/msdos.c @@ -162,7 +162,7 @@ grub_partition_msdos_iterate (grub_disk_t disk, lastaddr = p.offset; /* Check if it is valid. */ - if (mbr.signature != grub_cpu_to_le16 (GRUB_PC_PARTITION_SIGNATURE)) + if (mbr.signature != grub_cpu_to_le16_compile_time (GRUB_PC_PARTITION_SIGNATURE)) return grub_error (GRUB_ERR_BAD_PART_TABLE, "no signature"); for (i = 0; i < 4; i++) @@ -280,7 +280,7 @@ pc_partition_map_embed (struct grub_disk *disk, unsigned int *nsectors, lastaddr = offset; /* Check if it is valid. */ - if (mbr.signature != grub_cpu_to_le16 (GRUB_PC_PARTITION_SIGNATURE)) + if (mbr.signature != grub_cpu_to_le16_compile_time (GRUB_PC_PARTITION_SIGNATURE)) return grub_error (GRUB_ERR_BAD_PART_TABLE, "no signature"); for (i = 0; i < 4; i++) diff --git a/grub-core/tests/video_checksum.c b/grub-core/tests/video_checksum.c index 491bc5573..74d5b65e5 100644 --- a/grub-core/tests/video_checksum.c +++ b/grub-core/tests/video_checksum.c @@ -288,16 +288,16 @@ grub_video_capture_write_bmp (const char *fname, if (mode_info->mode_type & GRUB_VIDEO_MODE_TYPE_RGB) { head.filesize = grub_cpu_to_le32 (sizeof (head) + mode_info->width * mode_info->height * 3); - head.bmp_off = grub_cpu_to_le32 (sizeof (head)); + head.bmp_off = grub_cpu_to_le32_compile_time (sizeof (head)); head.bpp = grub_cpu_to_le16_compile_time (24); } else { head.filesize = grub_cpu_to_le32 (sizeof (head) + 3 * 256 + mode_info->width * mode_info->height); - head.bmp_off = grub_cpu_to_le32 (sizeof (head) + 3 * 256); + head.bmp_off = grub_cpu_to_le32_compile_time (sizeof (head) + 3 * 256); head.bpp = grub_cpu_to_le16_compile_time (8); } - head.head_size = grub_cpu_to_le32 (sizeof (head) - 14); + head.head_size = grub_cpu_to_le32_compile_time (sizeof (head) - 14); head.width = grub_cpu_to_le16 (mode_info->width); head.height = grub_cpu_to_le16 (mode_info->height); head.planes = grub_cpu_to_le16_compile_time (1); diff --git a/util/grub-mkfont.c b/util/grub-mkfont.c index e6485b40f..a0cab3a93 100644 --- a/util/grub-mkfont.c +++ b/util/grub-mkfont.c @@ -704,7 +704,7 @@ write_be16_section (const char *name, grub_uint16_t data, int* offset, { grub_uint32_t leng; - leng = grub_cpu_to_be32 (2); + leng = grub_cpu_to_be32_compile_time (2); data = grub_cpu_to_be16 (data); grub_util_write_image (name, 4, file, filename); grub_util_write_image ((char *) &leng, 4, file, filename); @@ -801,7 +801,7 @@ write_font_pf2 (struct grub_font_info *font_info, char *output_file) offset = 0; - leng = grub_cpu_to_be32 (4); + leng = grub_cpu_to_be32_compile_time (4); grub_util_write_image (FONT_FORMAT_SECTION_NAMES_FILE, sizeof(FONT_FORMAT_SECTION_NAMES_FILE) - 1, file, output_file); diff --git a/util/grub-mklayout.c b/util/grub-mklayout.c index 692f88190..1a4f1b4c8 100644 --- a/util/grub-mklayout.c +++ b/util/grub-mklayout.c @@ -329,7 +329,7 @@ write_file (FILE *out, const char *fname, struct grub_keyboard_layout *layout) grub_uint32_t version; unsigned i; - version = grub_cpu_to_le32 (GRUB_KEYBOARD_LAYOUTS_VERSION); + version = grub_cpu_to_le32_compile_time (GRUB_KEYBOARD_LAYOUTS_VERSION); for (i = 0; i < ARRAY_SIZE (layout->keyboard_map); i++) layout->keyboard_map[i] = grub_cpu_to_le32(layout->keyboard_map[i]); diff --git a/util/mkimage.c b/util/mkimage.c index 26d9816e0..e6b799fd7 100644 --- a/util/mkimage.c +++ b/util/mkimage.c @@ -1528,9 +1528,10 @@ grub_install_generate_image (const char *dir, const char *prefix, text_section->virtual_address = grub_cpu_to_le32 (header_size); text_section->raw_data_size = grub_cpu_to_le32 (exec_size); text_section->raw_data_offset = grub_cpu_to_le32 (header_size); - text_section->characteristics = grub_cpu_to_le32 (GRUB_PE32_SCN_CNT_CODE - | GRUB_PE32_SCN_MEM_EXECUTE - | GRUB_PE32_SCN_MEM_READ); + text_section->characteristics = grub_cpu_to_le32_compile_time ( + GRUB_PE32_SCN_CNT_CODE + | GRUB_PE32_SCN_MEM_EXECUTE + | GRUB_PE32_SCN_MEM_READ); data_section = text_section + 1; strcpy (data_section->name, ".data"); @@ -1539,7 +1540,7 @@ grub_install_generate_image (const char *dir, const char *prefix, data_section->raw_data_size = grub_cpu_to_le32 (kernel_size - exec_size); data_section->raw_data_offset = grub_cpu_to_le32 (header_size + exec_size); data_section->characteristics - = grub_cpu_to_le32 (GRUB_PE32_SCN_CNT_INITIALIZED_DATA + = grub_cpu_to_le32_compile_time (GRUB_PE32_SCN_CNT_INITIALIZED_DATA | GRUB_PE32_SCN_MEM_READ | GRUB_PE32_SCN_MEM_WRITE); @@ -1551,7 +1552,7 @@ grub_install_generate_image (const char *dir, const char *prefix, bss_section->raw_data_size = 0; bss_section->raw_data_offset = 0; bss_section->characteristics - = grub_cpu_to_le32 (GRUB_PE32_SCN_MEM_READ + = grub_cpu_to_le32_compile_time (GRUB_PE32_SCN_MEM_READ | GRUB_PE32_SCN_MEM_WRITE | GRUB_PE32_SCN_ALIGN_64BYTES | GRUB_PE32_SCN_CNT_INITIALIZED_DATA @@ -1565,7 +1566,7 @@ grub_install_generate_image (const char *dir, const char *prefix, mods_section->raw_data_size = grub_cpu_to_le32 (reloc_addr - kernel_size - header_size); mods_section->raw_data_offset = grub_cpu_to_le32 (header_size + kernel_size); mods_section->characteristics - = grub_cpu_to_le32 (GRUB_PE32_SCN_CNT_INITIALIZED_DATA + = grub_cpu_to_le32_compile_time (GRUB_PE32_SCN_CNT_INITIALIZED_DATA | GRUB_PE32_SCN_MEM_READ | GRUB_PE32_SCN_MEM_WRITE); @@ -1576,7 +1577,7 @@ grub_install_generate_image (const char *dir, const char *prefix, reloc_section->raw_data_size = grub_cpu_to_le32 (reloc_size); reloc_section->raw_data_offset = grub_cpu_to_le32 (reloc_addr); reloc_section->characteristics - = grub_cpu_to_le32 (GRUB_PE32_SCN_CNT_INITIALIZED_DATA + = grub_cpu_to_le32_compile_time (GRUB_PE32_SCN_CNT_INITIALIZED_DATA | GRUB_PE32_SCN_MEM_DISCARDABLE | GRUB_PE32_SCN_MEM_READ); free (core_img); From 5d90f6e533d82abf89f9e1787f90f17f2fab14aa Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Tue, 23 Sep 2014 12:06:30 +0100 Subject: [PATCH 110/722] Add a new "none" platform that only builds utilities This makes it possible to build generally-useful utilities such as grub-mount even if the rest of GRUB has not been ported to the target CPU. * configure.ac: Add "none" platform. Default to it for unsupported CPUs rather than stopping with a fatal error. Don't downgrade x86_64-none to i386. Define COND_real_platform Automake conditional if the platform is anything other than "none". Don't do any include directory linking for "none". * Makefile.am: Skip building grub-core and all bootcheck targets if !COND_real_platform. * include/grub/time.h: Don't include if GRUB_UTIL is defined. --- ChangeLog | 14 ++++++++++++++ Makefile.am | 14 +++++++++++--- configure.ac | 46 ++++++++++++++++++++++++++++----------------- include/grub/time.h | 2 +- 4 files changed, 55 insertions(+), 21 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8316b8fa0..08cc7c675 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2014-09-23 Colin Watson + + Add a new "none" platform that only builds utilities + + * configure.ac: Add "none" platform. Default to it for unsupported + CPUs rather than stopping with a fatal error. Don't downgrade + x86_64-none to i386. Define COND_real_platform Automake conditional + if the platform is anything other than "none". Don't do any include + directory linking for "none". + * Makefile.am: Skip building grub-core and all bootcheck targets if + !COND_real_platform. + * include/grub/time.h: Don't include if GRUB_UTIL + is defined. + 2014-09-22 Andrei Borzenkov Use grub_cpu_to_XXX_compile_time for constants. diff --git a/Makefile.am b/Makefile.am index f02ae0a39..cc537a2c8 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,7 +1,11 @@ AUTOMAKE_OPTIONS = subdir-objects -Wno-portability DEPDIR = .deps-util -SUBDIRS = grub-core/gnulib . grub-core po docs util/bash-completion.d +SUBDIRS = grub-core/gnulib . +if COND_real_platform +SUBDIRS += grub-core +endif +SUBDIRS += po docs util/bash-completion.d include $(top_srcdir)/conf/Makefile.common include $(top_srcdir)/conf/Makefile.extra-dist @@ -132,6 +136,8 @@ nodist_platform_HEADERS = config.h pkgdata_DATA += grub-mkconfig_lib +if COND_real_platform + if COND_i386_coreboot QEMU32=qemu-system-i386 endif @@ -383,8 +389,6 @@ if COND_powerpc_ieee1275 BOOTCHECKS = bootcheck-linux-ppc endif -EXTRA_DIST += grub-core/tests/boot/kbsd.init-i386.S grub-core/tests/boot/kbsd.init-x86_64.S grub-core/tests/boot/kbsd.spec.txt grub-core/tests/boot/kernel-8086.S grub-core/tests/boot/kernel-i386.S grub-core/tests/boot/kfreebsd-aout.cfg grub-core/tests/boot/kfreebsd.cfg grub-core/tests/boot/kfreebsd.init-i386.S grub-core/tests/boot/kfreebsd.init-x86_64.S grub-core/tests/boot/knetbsd.cfg grub-core/tests/boot/kopenbsd.cfg grub-core/tests/boot/kopenbsdlabel.txt grub-core/tests/boot/linux16.cfg grub-core/tests/boot/linux.cfg grub-core/tests/boot/linux.init-i386.S grub-core/tests/boot/linux.init-mips.S grub-core/tests/boot/linux.init-ppc.S grub-core/tests/boot/linux.init-x86_64.S grub-core/tests/boot/linux-ppc.cfg grub-core/tests/boot/multiboot2.cfg grub-core/tests/boot/multiboot.cfg grub-core/tests/boot/ntldr.cfg grub-core/tests/boot/pc-chainloader.cfg grub-core/tests/boot/qemu-shutdown-x86.S - .PHONY: bootcheck-linux-i386 bootcheck-linux-x86_64 \ bootcheck-kfreebsd-i386 bootcheck-kfreebsd-x86_64 \ bootcheck-knetbsd-i386 bootcheck-knetbsd-x86_64 \ @@ -402,6 +406,10 @@ default_payload.elf: grub-mkstandalone grub-mkimage pkgdatadir=. ./grub-mkstandalone --grub-mkimage=./grub-mkimage -O i386-coreboot -o $@ --modules='ahci pata ehci uhci ohci usb_keyboard usbms part_msdos xfs ext2 fat at_keyboard part_gpt usbserial_usbdebug cbfs' --install-modules='ls linux search configfile normal cbtime cbls memrw iorw minicmd lsmmap lspci halt reboot hexdump pcidump regexp setpci lsacpi chain test serial multiboot cbmemc linux16 gzio echo help' --fonts= --themes= --locales= -d grub-core/ /boot/grub/grub.cfg=$(srcdir)/coreboot.cfg endif +endif + +EXTRA_DIST += grub-core/tests/boot/kbsd.init-i386.S grub-core/tests/boot/kbsd.init-x86_64.S grub-core/tests/boot/kbsd.spec.txt grub-core/tests/boot/kernel-8086.S grub-core/tests/boot/kernel-i386.S grub-core/tests/boot/kfreebsd-aout.cfg grub-core/tests/boot/kfreebsd.cfg grub-core/tests/boot/kfreebsd.init-i386.S grub-core/tests/boot/kfreebsd.init-x86_64.S grub-core/tests/boot/knetbsd.cfg grub-core/tests/boot/kopenbsd.cfg grub-core/tests/boot/kopenbsdlabel.txt grub-core/tests/boot/linux16.cfg grub-core/tests/boot/linux.cfg grub-core/tests/boot/linux.init-i386.S grub-core/tests/boot/linux.init-mips.S grub-core/tests/boot/linux.init-ppc.S grub-core/tests/boot/linux.init-x86_64.S grub-core/tests/boot/linux-ppc.cfg grub-core/tests/boot/multiboot2.cfg grub-core/tests/boot/multiboot.cfg grub-core/tests/boot/ntldr.cfg grub-core/tests/boot/pc-chainloader.cfg grub-core/tests/boot/qemu-shutdown-x86.S + windowsdir=$(top_builddir)/$(PACKAGE)-$(VERSION)-for-windows windowsdir: $(PROGRAMS) $(starfield_DATA) $(platform_DATA) test -d $(windowsdir) && rm -rf $(windowsdir) || true diff --git a/configure.ac b/configure.ac index 8662bac68..fdf0fdc70 100644 --- a/configure.ac +++ b/configure.ac @@ -125,7 +125,10 @@ if test "x$with_platform" = x; then ia64-*) platform=efi ;; arm-*) platform=uboot ;; arm64-*) platform=efi ;; - *) AC_MSG_ERROR([unsupported CPU: "$target_cpu"]) ;; + *) + AC_MSG_WARN([unsupported CPU: "$target_cpu" - only building utilities]) + platform=none + ;; esac else platform="$with_platform" @@ -135,6 +138,7 @@ case "$target_cpu"-"$platform" in x86_64-efi) ;; x86_64-emu) ;; x86_64-xen) ;; + x86_64-none) ;; x86_64-*) target_cpu=i386 ;; powerpc64-ieee1275) target_cpu=powerpc ;; esac @@ -167,6 +171,7 @@ case "$target_cpu"-"$platform" in arm-efi) ;; arm64-efi) ;; *-emu) ;; + *-none) ;; *) AC_MSG_ERROR([platform "$platform" is not supported for target CPU "$target_cpu"]) ;; esac @@ -1653,6 +1658,7 @@ AC_SUBST(BUILD_LIBM) # Automake conditionals # +AM_CONDITIONAL([COND_real_platform], [test x$platform != xnone]) AM_CONDITIONAL([COND_emu], [test x$platform = xemu]) AM_CONDITIONAL([COND_clang], [test x$grub_cv_cc_target_clang = xyes]) AM_CONDITIONAL([COND_i386_pc], [test x$target_cpu = xi386 -a x$platform = xpc]) @@ -1726,24 +1732,30 @@ AC_DEFINE_UNQUOTED(GRUB_SYSCONFDIR, "$grub_sysconfdir", [Configuration dir]) # Output files. -cpudir="${target_cpu}" -if test x${cpudir} = xmipsel; then - cpudir=mips; -fi -grub_CHECK_LINK_DIR -if test x"$link_dir" = xyes ; then - AC_CONFIG_LINKS([include/grub/cpu:include/grub/$cpudir]) - if test "$platform" != emu ; then - AC_CONFIG_LINKS([include/grub/machine:include/grub/$cpudir/$platform]) +if test "$platform" != none; then + cpudir="${target_cpu}" + if test x${cpudir} = xmipsel; then + cpudir=mips; + fi + grub_CHECK_LINK_DIR + if test x"$link_dir" = xyes ; then + AC_CONFIG_LINKS([include/grub/cpu:include/grub/$cpudir]) + if test "$platform" != emu ; then + AC_CONFIG_LINKS([include/grub/machine:include/grub/$cpudir/$platform]) + fi + else + mkdir -p include/grub 2>/dev/null + rm -rf include/grub/cpu + cp -rp $srcdir/include/grub/$cpudir include/grub/cpu 2>/dev/null + if test "$platform" != emu ; then + rm -rf include/grub/machine + cp -rp $srcdir/include/grub/$cpudir/$platform include/grub/machine 2>/dev/null + fi fi else - mkdir -p include/grub 2>/dev/null - rm -rf include/grub/cpu - cp -rp $srcdir/include/grub/$cpudir include/grub/cpu 2>/dev/null - if test "$platform" != emu ; then - rm -rf include/grub/machine - cp -rp $srcdir/include/grub/$cpudir/$platform include/grub/machine 2>/dev/null - fi + # Just enough to stop the compiler failing with -I$(srcdir)/include. + mkdir -p include 2>/dev/null + rm -rf include/grub fi AC_CONFIG_FILES([Makefile]) diff --git a/include/grub/time.h b/include/grub/time.h index 64ac99a12..c919c1f0b 100644 --- a/include/grub/time.h +++ b/include/grub/time.h @@ -21,7 +21,7 @@ #include #include -#ifndef GRUB_MACHINE_EMU +#if !defined(GRUB_MACHINE_EMU) && !defined(GRUB_UTIL) #include #else static inline void From 77063f4cb672f423272db7e21ca448cf3de98dcf Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Thu, 25 Sep 2014 20:59:26 +0100 Subject: [PATCH 111/722] Fix in-tree --platform=none * configure.ac: Only remove include/grub/cpu and include/grub/machine in the --platform=none case, not all of include/grub. --- ChangeLog | 8 ++++++++ configure.ac | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 08cc7c675..192e8bca4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2014-09-25 Colin Watson + + Fix in-tree --platform=none + + * configure.ac: Only remove include/grub/cpu and + include/grub/machine in the --platform=none case, not all of + include/grub. + 2014-09-23 Colin Watson Add a new "none" platform that only builds utilities diff --git a/configure.ac b/configure.ac index fdf0fdc70..31d2b0baf 100644 --- a/configure.ac +++ b/configure.ac @@ -1755,7 +1755,7 @@ if test "$platform" != none; then else # Just enough to stop the compiler failing with -I$(srcdir)/include. mkdir -p include 2>/dev/null - rm -rf include/grub + rm -rf include/grub/cpu include/grub/machine fi AC_CONFIG_FILES([Makefile]) From 9a67e1ac8e92cd0b7521c75a734fcaf2e58523ad Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Tue, 14 Oct 2014 20:12:15 +0400 Subject: [PATCH 112/722] Use full initializer for initrd_ctx to avoid fatal warnings with older GCC struct ... foo = { 0, } is valid initializer, but older GCC emits warning which is fatal error due to -Werror=missing-field-initializer. So simply use full initializer to avoid these errors. This was fixed probably in GCC 4.7. See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=36750 --- ChangeLog | 12 ++++++++++++ grub-core/loader/arm/linux.c | 2 +- grub-core/loader/arm64/linux.c | 2 +- grub-core/loader/i386/linux.c | 2 +- grub-core/loader/i386/pc/linux.c | 2 +- grub-core/loader/ia64/efi/linux.c | 2 +- grub-core/loader/mips/linux.c | 2 +- grub-core/loader/powerpc/ieee1275/linux.c | 2 +- grub-core/loader/sparc64/ieee1275/linux.c | 2 +- 9 files changed, 20 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index 192e8bca4..190d19d9b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2014-10-14 Andrei Borzenkov + + * grub-core/loader/arm/linux.c: Use full initializer for initrd_ctx to + avoid fatal warnings with older gcc (probably before 4.7). + * grub-core/loader/arm64/linux.c: Likewise. + * grub-core/loader/i386/linux.c: Likewise. + * grub-core/loader/i386/pc/linux.c: Likewise. + * grub-core/loader/ia64/efi/linux.c: Likewise. + * grub-core/loader/mips/linux.c: Likewise. + * grub-core/loader/powerpc/ieee1275/linux.c: Likewise. + * grub-core/loader/sparc64/ieee1275/linux.c: Likewise. + 2014-09-25 Colin Watson Fix in-tree --platform=none diff --git a/grub-core/loader/arm/linux.c b/grub-core/loader/arm/linux.c index 62cbe75d3..5b39f02bb 100644 --- a/grub-core/loader/arm/linux.c +++ b/grub-core/loader/arm/linux.c @@ -396,7 +396,7 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), { grub_file_t file; grub_size_t size = 0; - struct grub_linux_initrd_context initrd_ctx = { 0, }; + struct grub_linux_initrd_context initrd_ctx = { 0, 0, 0 }; if (argc == 0) return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected")); diff --git a/grub-core/loader/arm64/linux.c b/grub-core/loader/arm64/linux.c index 0dc144e5d..564a75a80 100644 --- a/grub-core/loader/arm64/linux.c +++ b/grub-core/loader/arm64/linux.c @@ -328,7 +328,7 @@ static grub_err_t grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), int argc, char *argv[]) { - struct grub_linux_initrd_context initrd_ctx = { 0, }; + struct grub_linux_initrd_context initrd_ctx = { 0, 0, 0 }; int initrd_size, initrd_pages; void *initrd_mem = NULL; diff --git a/grub-core/loader/i386/linux.c b/grub-core/loader/i386/linux.c index 0bd060a52..291f7289f 100644 --- a/grub-core/loader/i386/linux.c +++ b/grub-core/loader/i386/linux.c @@ -1050,7 +1050,7 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), grub_addr_t addr_min, addr_max; grub_addr_t addr; grub_err_t err; - struct grub_linux_initrd_context initrd_ctx = { 0, }; + struct grub_linux_initrd_context initrd_ctx = { 0, 0, 0 }; if (argc == 0) { diff --git a/grub-core/loader/i386/pc/linux.c b/grub-core/loader/i386/pc/linux.c index e88341e3c..870992b7d 100644 --- a/grub-core/loader/i386/pc/linux.c +++ b/grub-core/loader/i386/pc/linux.c @@ -388,7 +388,7 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), grub_uint8_t *initrd_chunk; grub_addr_t initrd_addr; grub_err_t err; - struct grub_linux_initrd_context initrd_ctx = { 0, }; + struct grub_linux_initrd_context initrd_ctx = { 0, 0, 0 }; if (argc == 0) { diff --git a/grub-core/loader/ia64/efi/linux.c b/grub-core/loader/ia64/efi/linux.c index eb78e6e62..efaa42ccd 100644 --- a/grub-core/loader/ia64/efi/linux.c +++ b/grub-core/loader/ia64/efi/linux.c @@ -568,7 +568,7 @@ static grub_err_t grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), int argc, char *argv[]) { - struct grub_linux_initrd_context initrd_ctx = { 0, }; + struct grub_linux_initrd_context initrd_ctx = { 0, 0, 0 }; if (argc == 0) { diff --git a/grub-core/loader/mips/linux.c b/grub-core/loader/mips/linux.c index 4a3e8c5df..5f383be3d 100644 --- a/grub-core/loader/mips/linux.c +++ b/grub-core/loader/mips/linux.c @@ -415,7 +415,7 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), void *initrd_src; grub_addr_t initrd_dest; grub_err_t err; - struct grub_linux_initrd_context initrd_ctx = { 0, }; + struct grub_linux_initrd_context initrd_ctx = { 0, 0, 0 }; if (argc == 0) return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected")); diff --git a/grub-core/loader/powerpc/ieee1275/linux.c b/grub-core/loader/powerpc/ieee1275/linux.c index 787d7dc2a..6e814649f 100644 --- a/grub-core/loader/powerpc/ieee1275/linux.c +++ b/grub-core/loader/powerpc/ieee1275/linux.c @@ -333,7 +333,7 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), grub_size_t size = 0; grub_addr_t first_addr; grub_addr_t addr; - struct grub_linux_initrd_context initrd_ctx = { 0, }; + struct grub_linux_initrd_context initrd_ctx = { 0, 0, 0 }; if (argc == 0) { diff --git a/grub-core/loader/sparc64/ieee1275/linux.c b/grub-core/loader/sparc64/ieee1275/linux.c index c5e8dfab2..6389170e6 100644 --- a/grub-core/loader/sparc64/ieee1275/linux.c +++ b/grub-core/loader/sparc64/ieee1275/linux.c @@ -373,7 +373,7 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), grub_addr_t paddr; grub_addr_t addr; int ret; - struct grub_linux_initrd_context initrd_ctx = { 0, }; + struct grub_linux_initrd_context initrd_ctx = { 0, 0, 0 }; if (argc == 0) { From 72ec399ad8d6348b6c74ea63d80c79784c8b84ae Mon Sep 17 00:00:00 2001 From: Michael Chang Date: Mon, 3 Nov 2014 16:27:45 +0800 Subject: [PATCH 113/722] icmp6 fix no respond to neighbor solicit message The structure size used in grub_netbuff_pull to get the pointer to option header is apparently wrong, which leads to subsequent range check failed and therefore not responding to any neighbor solicit message in my testing. --- ChangeLog | 5 +++++ grub-core/net/icmp6.c | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 190d19d9b..87faadf48 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2014-11-03 Michael Chang + + * grub-core/net/icmp6.c (grub_net_recv_icmp6_packet): Fix size + of neighbor solicitation packet in grub_netbuff_pull. + 2014-10-14 Andrei Borzenkov * grub-core/loader/arm/linux.c: Use full initializer for initrd_ctx to diff --git a/grub-core/net/icmp6.c b/grub-core/net/icmp6.c index bbc902014..796d549f6 100644 --- a/grub-core/net/icmp6.c +++ b/grub-core/net/icmp6.c @@ -205,7 +205,7 @@ grub_net_recv_icmp6_packet (struct grub_net_buff *nb, if (ttl != 0xff) break; nbh = (struct neighbour_solicit *) nb->data; - err = grub_netbuff_pull (nb, sizeof (struct router_adv)); + err = grub_netbuff_pull (nb, sizeof (*nbh)); if (err) { grub_netbuff_free (nb); From 004a2b1efdd782cf946387d2060ad9250d61c435 Mon Sep 17 00:00:00 2001 From: Leif Lindholm Date: Mon, 17 Nov 2014 14:11:01 +0000 Subject: [PATCH 114/722] efi: check *path non-null before grub_strrchr The EFI version of grub_machine_get_bootlocation crops the boot image name back to the last / in order to get a directory path. However, it does not check that *name is actually set before calling grub_strrchr to do this, and neither does grub_strrchr before dereferencing a NULL pointer. Parent function, grub_set_prefix_and_root, does check the pointer before using. --- ChangeLog | 5 +++++ grub-core/kern/efi/init.c | 11 +++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 87faadf48..07d06465d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2014-01-07 Leif Lindholm + + * grub-core/kern/efi/init.c: check value of *path before + dereferencing. + 2014-11-03 Michael Chang * grub-core/net/icmp6.c (grub_net_recv_icmp6_packet): Fix size diff --git a/grub-core/kern/efi/init.c b/grub-core/kern/efi/init.c index 942ab0256..e9c85de12 100644 --- a/grub-core/kern/efi/init.c +++ b/grub-core/kern/efi/init.c @@ -63,10 +63,13 @@ grub_machine_get_bootlocation (char **device, char **path) if (!*device && grub_efi_net_config) grub_efi_net_config (image->device_handle, device, path); - /* Get the directory. */ - p = grub_strrchr (*path, '/'); - if (p) - *p = '\0'; + if (*path) + { + /* Get the directory. */ + p = grub_strrchr (*path, '/'); + if (p) + *p = '\0'; + } } void From 2ccaa3b9fdc3e71e9e2e68acfa3054233a2a30b2 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Thu, 20 Nov 2014 20:54:49 +0300 Subject: [PATCH 115/722] Fix date in last ChangeLog entry --- ChangeLog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 07d06465d..b86feea8d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,4 @@ -2014-01-07 Leif Lindholm +2014-11-07 Leif Lindholm * grub-core/kern/efi/init.c: check value of *path before dereferencing. From e2dd6daa8c33e3e7641e442dc269fcca479c6fda Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Thu, 20 Nov 2014 20:56:51 +0300 Subject: [PATCH 116/722] grub-fs-tester: consistently print output of grub ls if test fails --- ChangeLog | 5 +++++ tests/util/grub-fs-tester.in | 2 ++ 2 files changed, 7 insertions(+) diff --git a/ChangeLog b/ChangeLog index b86feea8d..6fbec061d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2014-11-20 Andrei Borzenkov + + * tests/util/grub-fs-tester.in: Consistently print output + of grub ls if test fails. + 2014-11-07 Leif Lindholm * grub-core/kern/efi/init.c: check value of *path before diff --git a/tests/util/grub-fs-tester.in b/tests/util/grub-fs-tester.in index 669527a90..565692725 100644 --- a/tests/util/grub-fs-tester.in +++ b/tests/util/grub-fs-tester.in @@ -1065,6 +1065,7 @@ for ((LOGSECSIZE=MINLOGSECSIZE;LOGSECSIZE<=MAXLOGSECSIZE;LOGSECSIZE=LOGSECSIZE + : else echo NLIST FAIL + echo "$LSROUT" TZ=UTC ls --time-style=+%Y%m%d%H%M%S.%N -lA "$MNTPOINTRO" exit 1 fi @@ -1082,6 +1083,7 @@ for ((LOGSECSIZE=MINLOGSECSIZE;LOGSECSIZE<=MAXLOGSECSIZE;LOGSECSIZE=LOGSECSIZE + : else echo LONG LIST FAIL + echo "$LSROUT" TZ=UTC ls --time-style=+%Y%m%d%H%M%S.%N -l "$MNTPOINTRO" exit 1 fi From 7c4b6b7bb476963ca7e86f79d32036e7f80d27f6 Mon Sep 17 00:00:00 2001 From: Michael Chang Date: Tue, 18 Nov 2014 16:03:08 +0800 Subject: [PATCH 117/722] send router solicitation for ipv6 address autoconf v2 Many routers have long router advertisment interval configured by default. The Neighbor Discovery protocol (RFC4861) has defined default MaxRtrAdvInterval value as 600 seconds and MinRtrAdvInterval as 0.33*MaxRtrAdvInterval. This makes net_ipv6_autoconf fails more often than not as currently it passively listens the RA message to perfom address autoconfiguration. This patch tries to send router solicitation to overcome the problem of long RA interval. v2: use cpu_to_be macro for network byte order conversion add missing error handling --- grub-core/net/icmp6.c | 83 +++++++++++++++++++++++++++++++++++++++++++ grub-core/net/net.c | 4 ++- include/grub/net/ip.h | 2 ++ 3 files changed, 88 insertions(+), 1 deletion(-) diff --git a/grub-core/net/icmp6.c b/grub-core/net/icmp6.c index 796d549f6..782239460 100644 --- a/grub-core/net/icmp6.c +++ b/grub-core/net/icmp6.c @@ -72,6 +72,11 @@ struct neighbour_advertise grub_uint64_t target[2]; } GRUB_PACKED; +struct router_solicit +{ + grub_uint32_t reserved; +} GRUB_PACKED; + enum { FLAG_SLAAC = 0x40 @@ -81,6 +86,7 @@ enum { ICMP6_ECHO = 128, ICMP6_ECHO_REPLY = 129, + ICMP6_ROUTER_SOLICIT = 133, ICMP6_ROUTER_ADVERTISE = 134, ICMP6_NEIGHBOUR_SOLICIT = 135, ICMP6_NEIGHBOUR_ADVERTISE = 136, @@ -533,3 +539,80 @@ grub_net_icmp6_send_request (struct grub_net_network_level_interface *inf, grub_netbuff_free (nb); return err; } + +grub_err_t +grub_net_icmp6_send_router_solicit (struct grub_net_network_level_interface *inf) +{ + struct grub_net_buff *nb; + grub_err_t err = GRUB_ERR_NONE; + grub_net_network_level_address_t multicast; + grub_net_link_level_address_t ll_multicast; + struct option_header *ohdr; + struct router_solicit *sol; + struct icmp_header *icmphr; + + multicast.type = GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV6; + multicast.ipv6[0] = grub_cpu_to_be64 (0xff02ULL << 48); + multicast.ipv6[1] = grub_cpu_to_be64 (0x02ULL); + + err = grub_net_link_layer_resolve (inf, &multicast, &ll_multicast); + if (err) + return err; + + nb = grub_netbuff_alloc (sizeof (struct router_solicit) + + sizeof (struct option_header) + + 6 + + sizeof (struct icmp_header) + + GRUB_NET_OUR_IPV6_HEADER_SIZE + + GRUB_NET_MAX_LINK_HEADER_SIZE); + if (!nb) + return grub_errno; + err = grub_netbuff_reserve (nb, + sizeof (struct router_solicit) + + sizeof (struct option_header) + + 6 + + sizeof (struct icmp_header) + + GRUB_NET_OUR_IPV6_HEADER_SIZE + + GRUB_NET_MAX_LINK_HEADER_SIZE); + if (err) + goto fail; + + err = grub_netbuff_push (nb, 6); + if (err) + goto fail; + + grub_memcpy (nb->data, inf->hwaddress.mac, 6); + + err = grub_netbuff_push (nb, sizeof (*ohdr)); + if (err) + goto fail; + + ohdr = (struct option_header *) nb->data; + ohdr->type = OPTION_SOURCE_LINK_LAYER_ADDRESS; + ohdr->len = 1; + + err = grub_netbuff_push (nb, sizeof (*sol)); + if (err) + goto fail; + + sol = (struct router_solicit *) nb->data; + sol->reserved = 0; + + err = grub_netbuff_push (nb, sizeof (*icmphr)); + if (err) + goto fail; + + icmphr = (struct icmp_header *) nb->data; + icmphr->type = ICMP6_ROUTER_SOLICIT; + icmphr->code = 0; + icmphr->checksum = 0; + icmphr->checksum = grub_net_ip_transport_checksum (nb, + GRUB_NET_IP_ICMPV6, + &inf->address, + &multicast); + err = grub_net_send_ip_packet (inf, &multicast, &ll_multicast, nb, + GRUB_NET_IP_ICMPV6); + fail: + grub_netbuff_free (nb); + return err; +} diff --git a/grub-core/net/net.c b/grub-core/net/net.c index 82af3a0ba..21a4e94d1 100644 --- a/grub-core/net/net.c +++ b/grub-core/net/net.c @@ -380,12 +380,14 @@ grub_cmd_ipv6_autoconf (struct grub_command *cmd __attribute__ ((unused)), for (interval = 200; interval < 10000; interval *= 2) { - /* FIXME: send router solicitation. */ int done = 1; for (j = 0; j < ncards; j++) { if (slaacs[j]->slaac_counter) continue; + err = grub_net_icmp6_send_router_solicit (ifaces[j]); + if (err) + err = GRUB_ERR_NONE; done = 0; } if (done) diff --git a/include/grub/net/ip.h b/include/grub/net/ip.h index 7a8e61479..dcceaa568 100644 --- a/include/grub/net/ip.h +++ b/include/grub/net/ip.h @@ -92,4 +92,6 @@ grub_err_t grub_net_icmp6_send_request (struct grub_net_network_level_interface *inf, const grub_net_network_level_address_t *proto_addr); +grub_err_t +grub_net_icmp6_send_router_solicit (struct grub_net_network_level_interface *inf); #endif From 478b5675209ab0263b8271764ef85d8fc1faec42 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Fri, 28 Nov 2014 20:39:22 +0300 Subject: [PATCH 118/722] grub-mkstandalone: out of bound access to tar header magic Magic size is 6 bytes and we copied 7 bytes in it. CID: 73587, 73888 Closes bug 43690 --- ChangeLog | 5 +++++ util/grub-mkstandalone.c | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6fbec061d..930ceb20c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2014-11-28 Andrei Borzenkov + + * util/grub-mkstandalone.c (add_tar_file): Fix out of bound access + to hd.magic (Coverity CID 73587, 73888, bug 43690). + 2014-11-20 Andrei Borzenkov * tests/util/grub-fs-tester.in: Consistently print output diff --git a/util/grub-mkstandalone.c b/util/grub-mkstandalone.c index 8e2a2b8c2..6017d7155 100644 --- a/util/grub-mkstandalone.c +++ b/util/grub-mkstandalone.c @@ -236,7 +236,7 @@ add_tar_file (const char *from, set_tar_value (hd.size, optr - tcn, 12); set_tar_value (hd.mtime, mtime, 12); hd.typeflag = 'L'; - memcpy (hd.magic, "ustar ", 7); + memcpy (hd.magic, MAGIC, sizeof (hd.magic)); memcpy (hd.uname, "grub", 4); memcpy (hd.gname, "grub", 4); @@ -266,7 +266,7 @@ add_tar_file (const char *from, set_tar_value (hd.size, size, 12); set_tar_value (hd.mtime, mtime, 12); hd.typeflag = '0'; - memcpy (hd.magic, "ustar ", 7); + memcpy (hd.magic, MAGIC, sizeof (hd.magic)); memcpy (hd.uname, "grub", 4); memcpy (hd.gname, "grub", 4); From 0415dbe28f3dc3520b70745b3bd78073f094fb4d Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Fri, 28 Nov 2014 20:45:27 +0300 Subject: [PATCH 119/722] grub-install-common: avoid out of bound access when read failed Check that modinfo.sh could be read successfully; abort on error. Avoids potential out-of-bound array access. CID: 73819 --- ChangeLog | 2 ++ util/grub-install-common.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/ChangeLog b/ChangeLog index 930ceb20c..e46b9995b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,7 @@ 2014-11-28 Andrei Borzenkov + * util/grub-install-common.c (grub_install_get_target): Check return + value of grub_util_fd_read (Coverity CID 73819). * util/grub-mkstandalone.c (add_tar_file): Fix out of bound access to hd.magic (Coverity CID 73587, 73888, bug 43690). diff --git a/util/grub-install-common.c b/util/grub-install-common.c index c8bedcb2e..4b5d4d486 100644 --- a/util/grub-install-common.c +++ b/util/grub-install-common.c @@ -911,6 +911,8 @@ grub_install_get_target (const char *src) grub_util_error (_("%s doesn't exist. Please specify --target or --directory"), fn); r = grub_util_fd_read (f, buf, sizeof (buf) - 1); + if (r < 0) + grub_util_error (_("cannot read `%s': %s"), fn, strerror (errno)); grub_util_fd_close (f); buf[r] = '\0'; c = strstr (buf, "grub_modinfo_target_cpu="); From ea44693fc8cbe9e8e8566f16e3dc4031c98b063a Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Fri, 28 Nov 2014 21:12:00 +0300 Subject: [PATCH 120/722] grub-core/disk/luks.c: fix use after free and memory leaks configure_ciphers: - several memory leaks where allocated ciphers were not freed. CID: 73813, 73710 - use after free. It is probably quite innocent as grub is single threaded, but could potentially be a problem with memory allocator debugger turned on. CID: 73730 luks_recover_key: - memory leak. CID: 73854 --- ChangeLog | 4 ++++ grub-core/disk/luks.c | 19 ++++++++++++++++--- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index e46b9995b..0ba21d5a5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2014-11-28 Andrei Borzenkov + * grub-core/disk/luks.c (configure_ciphers): Fix memory leaks + and use after free (Coverity CID 73813, 73710, 73730) + * grub-core/disk/luks.c (luks_recover_key): Fix memory leak (Coverity + CID 73854) * util/grub-install-common.c (grub_install_get_target): Check return value of grub_util_fd_read (Coverity CID 73819). * util/grub-mkstandalone.c (add_tar_file): Fix out of bound access diff --git a/grub-core/disk/luks.c b/grub-core/disk/luks.c index 250202947..86c50c612 100644 --- a/grub-core/disk/luks.c +++ b/grub-core/disk/luks.c @@ -143,6 +143,7 @@ configure_ciphers (grub_disk_t disk, const char *check_uuid, { grub_error (GRUB_ERR_BAD_ARGUMENT, "invalid keysize %d", grub_be_to_cpu32 (header.keyBytes)); + grub_crypto_cipher_close (cipher); return NULL; } @@ -181,9 +182,10 @@ configure_ciphers (grub_disk_t disk, const char *check_uuid, } if (cipher->cipher->blocksize != GRUB_CRYPTODISK_GF_BYTES) { - grub_crypto_cipher_close (cipher); grub_error (GRUB_ERR_BAD_ARGUMENT, "Unsupported XTS block size: %d", cipher->cipher->blocksize); + grub_crypto_cipher_close (cipher); + grub_crypto_cipher_close (secondary_cipher); return NULL; } if (secondary_cipher->cipher->blocksize != GRUB_CRYPTODISK_GF_BYTES) @@ -191,6 +193,7 @@ configure_ciphers (grub_disk_t disk, const char *check_uuid, grub_crypto_cipher_close (cipher); grub_error (GRUB_ERR_BAD_ARGUMENT, "Unsupported XTS block size: %d", secondary_cipher->cipher->blocksize); + grub_crypto_cipher_close (secondary_cipher); return NULL; } } @@ -200,9 +203,9 @@ configure_ciphers (grub_disk_t disk, const char *check_uuid, cipheriv = ciphermode + sizeof ("lrw-") - 1; if (cipher->cipher->blocksize != GRUB_CRYPTODISK_GF_BYTES) { - grub_crypto_cipher_close (cipher); grub_error (GRUB_ERR_BAD_ARGUMENT, "Unsupported LRW block size: %d", cipher->cipher->blocksize); + grub_crypto_cipher_close (cipher); return NULL; } } @@ -225,6 +228,7 @@ configure_ciphers (grub_disk_t disk, const char *check_uuid, || cipher->cipher->blocksize == 0) grub_error (GRUB_ERR_BAD_ARGUMENT, "Unsupported benbi blocksize: %d", cipher->cipher->blocksize); + /* FIXME should we return an error here? */ for (benbi_log = 0; (cipher->cipher->blocksize << benbi_log) < GRUB_DISK_SECTOR_SIZE; benbi_log++); @@ -243,6 +247,7 @@ configure_ciphers (grub_disk_t disk, const char *check_uuid, if (!essiv_hash) { grub_crypto_cipher_close (cipher); + grub_crypto_cipher_close (secondary_cipher); grub_error (GRUB_ERR_FILE_NOT_FOUND, "Couldn't load %s hash", hash_str); return NULL; @@ -251,12 +256,14 @@ configure_ciphers (grub_disk_t disk, const char *check_uuid, if (!essiv_cipher) { grub_crypto_cipher_close (cipher); + grub_crypto_cipher_close (secondary_cipher); return NULL; } } else { grub_crypto_cipher_close (cipher); + grub_crypto_cipher_close (secondary_cipher); grub_error (GRUB_ERR_BAD_ARGUMENT, "Unknown IV mode: %s", cipheriv); return NULL; @@ -276,7 +283,12 @@ configure_ciphers (grub_disk_t disk, const char *check_uuid, newdev = grub_zalloc (sizeof (struct grub_cryptodisk)); if (!newdev) - return NULL; + { + grub_crypto_cipher_close (cipher); + grub_crypto_cipher_close (essiv_cipher); + grub_crypto_cipher_close (secondary_cipher); + return NULL; + } newdev->cipher = cipher; newdev->offset = grub_be_to_cpu32 (header.payloadOffset); newdev->source_disk = NULL; @@ -451,6 +463,7 @@ luks_recover_key (grub_disk_t source, return GRUB_ERR_NONE; } + grub_free (split_key); return GRUB_ACCESS_DENIED; } From 740c08ed2ff33625bdc2e0ad9ef6264978bf32cf Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Fri, 28 Nov 2014 21:43:07 +0300 Subject: [PATCH 121/722] Use ssize_t for grub_util_fd_read result Fixes commit 0415dbe28f3dc3520b70745b3bd78073f094fb4d. --- util/grub-install-common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/grub-install-common.c b/util/grub-install-common.c index 4b5d4d486..b6dec93ea 100644 --- a/util/grub-install-common.c +++ b/util/grub-install-common.c @@ -902,7 +902,7 @@ grub_install_get_target (const char *src) char *fn; grub_util_fd_t f; char buf[2048]; - size_t r; + ssize_t r; char *c, *pl, *p; size_t i; fn = grub_util_path_concat (2, src, "modinfo.sh"); From bbbcb791ed06c75f3dd6a2671a57a67fa86bf2ca Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Fri, 28 Nov 2014 22:23:30 +0300 Subject: [PATCH 122/722] grub-core/disk/geli.c: fix memory leaks in error paths CID: 73813, 73710 --- grub-core/disk/geli.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/grub-core/disk/geli.c b/grub-core/disk/geli.c index 9025c9d46..17273416f 100644 --- a/grub-core/disk/geli.c +++ b/grub-core/disk/geli.c @@ -332,19 +332,29 @@ configure_ciphers (grub_disk_t disk, const char *check_uuid, { secondary_cipher = grub_crypto_cipher_open (ciph); if (!secondary_cipher) - return NULL; + { + grub_crypto_cipher_close (cipher); + return NULL; + } + } if (grub_le_to_cpu16 (header.keylen) > 1024) { grub_error (GRUB_ERR_BAD_ARGUMENT, "invalid keysize %d", grub_le_to_cpu16 (header.keylen)); + grub_crypto_cipher_close (cipher); + grub_crypto_cipher_close (secondary_cipher); return NULL; } newdev = grub_zalloc (sizeof (struct grub_cryptodisk)); if (!newdev) - return NULL; + { + grub_crypto_cipher_close (cipher); + grub_crypto_cipher_close (secondary_cipher); + return NULL; + } newdev->cipher = cipher; newdev->secondary_cipher = secondary_cipher; newdev->offset = 0; From f07784e8901906d47b892bc49b44dd7c832cebdd Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Fri, 28 Nov 2014 22:35:01 +0300 Subject: [PATCH 123/722] Fix ChangeLog --- ChangeLog | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ChangeLog b/ChangeLog index 0ba21d5a5..504d8292b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,7 @@ 2014-11-28 Andrei Borzenkov + * grub-core/disk/geli.c (configure_ciphers): Fix memory leaks + (Coverity CID 73813, 73710) * grub-core/disk/luks.c (configure_ciphers): Fix memory leaks and use after free (Coverity CID 73813, 73710, 73730) * grub-core/disk/luks.c (luks_recover_key): Fix memory leak (Coverity From 343dad410eaa37f4f02eff6a4a4114102d211a28 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Fri, 28 Nov 2014 22:37:00 +0300 Subject: [PATCH 124/722] grub-core/disk/lzopio.c: fix double free in error path CID: 73665 --- ChangeLog | 1 + grub-core/io/lzopio.c | 2 -- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 504d8292b..b6220de2b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,6 @@ 2014-11-28 Andrei Borzenkov + * grub-core/io/lzopio.c (test_header): Fix double free (CID 73665) * grub-core/disk/geli.c (configure_ciphers): Fix memory leaks (Coverity CID 73813, 73710) * grub-core/disk/luks.c (configure_ciphers): Fix memory leaks diff --git a/grub-core/io/lzopio.c b/grub-core/io/lzopio.c index de2ea6778..7559c6c9c 100644 --- a/grub-core/io/lzopio.c +++ b/grub-core/io/lzopio.c @@ -403,8 +403,6 @@ test_header (grub_file_t file) return 1; CORRUPTED: - grub_free(name); - return 0; } From dbbac5a04c7cec1c14026e807e998eae387ddee4 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sun, 30 Nov 2014 18:48:42 +0300 Subject: [PATCH 125/722] grub-core/lib/syslinux_parse.c: do not free array say->msg is inline array in a structure and should not be freed. CID: 73610 --- ChangeLog | 5 +++++ grub-core/lib/syslinux_parse.c | 1 - 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index b6220de2b..21434fffb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2014-11-30 Andrei Borzenkov + + * grub-core/lib/syslinux_parse.c (free_menu): Do not free + inline array (CID 73610). + 2014-11-28 Andrei Borzenkov * grub-core/io/lzopio.c (test_header): Fix double free (CID 73665) diff --git a/grub-core/lib/syslinux_parse.c b/grub-core/lib/syslinux_parse.c index 6bc504b7c..08e451cea 100644 --- a/grub-core/lib/syslinux_parse.c +++ b/grub-core/lib/syslinux_parse.c @@ -1351,7 +1351,6 @@ free_menu (struct syslinux_menu *menu) for (say = menu->say; say ; say = nsay) { nsay = say->next; - grub_free (say->msg); grub_free (say); } From 03d79a878ba04db2cfbbe05564728748de0f6a2f Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Mon, 1 Dec 2014 20:54:12 +0300 Subject: [PATCH 126/722] grub-core/fs/zfs/zfsinfo.c: memory leak in print_vdev_info CID: 73635 --- ChangeLog | 5 +++++ grub-core/fs/zfs/zfsinfo.c | 2 ++ 2 files changed, 7 insertions(+) diff --git a/ChangeLog b/ChangeLog index 21434fffb..dd44cd8a5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2014-12-01 Andrei Borzenkov + + * grub-core/fs/zfs/zfsinfo.c (print_vdev_info): Fix memory leak + (CID 73635). + 2014-11-30 Andrei Borzenkov * grub-core/lib/syslinux_parse.c (free_menu): Do not free diff --git a/grub-core/fs/zfs/zfsinfo.c b/grub-core/fs/zfs/zfsinfo.c index c96bf2183..c8a28acf5 100644 --- a/grub-core/fs/zfs/zfsinfo.c +++ b/grub-core/fs/zfs/zfsinfo.c @@ -130,10 +130,12 @@ print_vdev_info (char *nvlist, int tab) grub_free (bootpath); grub_free (devid); grub_free (path); + grub_free (type); return GRUB_ERR_NONE; } char is_mirror=(grub_strcmp(type,VDEV_TYPE_MIRROR) == 0); char is_raidz=(grub_strcmp(type,VDEV_TYPE_RAIDZ) == 0); + grub_free (type); if (is_mirror || is_raidz) { From 3173c7501ccc02e1475261404fc8b0199be6314e Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Mon, 1 Dec 2014 21:23:54 +0300 Subject: [PATCH 127/722] grub-core/loader/i386/xen_fileXX.c: memory leak in grub_xen_get_infoXX CID: 73645, 73782 --- ChangeLog | 2 ++ grub-core/loader/i386/xen_fileXX.c | 30 +++++++++++++++++++++++------- 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index dd44cd8a5..46f049d48 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,7 @@ 2014-12-01 Andrei Borzenkov + * grub-core/loader/i386/xen_fileXX.c (grub_xen_get_infoXX): Fix + memory leak (CID 73645, 73782). * grub-core/fs/zfs/zfsinfo.c (print_vdev_info): Fix memory leak (CID 73635). diff --git a/grub-core/loader/i386/xen_fileXX.c b/grub-core/loader/i386/xen_fileXX.c index 73a5f90fd..1ba5649e2 100644 --- a/grub-core/loader/i386/xen_fileXX.c +++ b/grub-core/loader/i386/xen_fileXX.c @@ -311,14 +311,19 @@ grub_xen_get_infoXX (grub_elf_t elf, struct grub_xen_file_info *xi) return grub_errno; if (grub_file_seek (elf->file, elf->ehdr.ehdrXX.e_shoff) == (grub_off_t) -1) - return grub_errno; + { + err = grub_errno; + goto cleanup; + } if (grub_file_read (elf->file, s0, shsize) != (grub_ssize_t) shsize) { if (grub_errno) - return grub_errno; - return grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"), + err = grub_errno; + else + err = grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"), elf->file->name); + goto cleanup; } s = (Elf_Shdr *) ((char *) s0 + elf->ehdr.ehdrXX.e_shstrndx * shentsize); @@ -330,18 +335,29 @@ grub_xen_get_infoXX (grub_elf_t elf, struct grub_xen_file_info *xi) char name[sizeof("__xen_guest")]; grub_memset (name, 0, sizeof (name)); if (grub_file_seek (elf->file, stroff + s->sh_name) == (grub_off_t) -1) - return grub_errno; + { + err = grub_errno; + goto cleanup; + } if (grub_file_read (elf->file, name, sizeof (name)) != (grub_ssize_t) sizeof (name)) { if (grub_errno) - return grub_errno; + { + err = grub_errno; + goto cleanup; + } continue; } if (grub_memcmp (name, "__xen_guest", sizeof("__xen_guest")) != 0) continue; - return parse_xen_guest (elf, xi, s->sh_offset, s->sh_size); + err = parse_xen_guest (elf, xi, s->sh_offset, s->sh_size); + goto cleanup; } - return grub_error (GRUB_ERR_BAD_OS, "no XEN note found"); + err = grub_error (GRUB_ERR_BAD_OS, "no XEN note found"); + +cleanup: + grub_free (s0); + return err; } From 4b94e3227b611a381e96ab41899cd4e8682f995d Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Fri, 5 Dec 2014 19:55:59 +0300 Subject: [PATCH 128/722] grub-shell: support --files also for net boot This allows running tests that require extra files using netboot as well. --- ChangeLog | 4 ++++ tests/util/grub-shell.in | 17 +++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/ChangeLog b/ChangeLog index 46f049d48..c163cd5c0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2014-12-05 Andrei Borzenkov + + * tests/util/grub-shell.in: Support --files also for netboot. + 2014-12-01 Andrei Borzenkov * grub-core/loader/i386/xen_fileXX.c (grub_xen_get_infoXX): Fix diff --git a/tests/util/grub-shell.in b/tests/util/grub-shell.in index d9a5253e2..5b66139a9 100644 --- a/tests/util/grub-shell.in +++ b/tests/util/grub-shell.in @@ -422,11 +422,28 @@ do_trim () fi } +copy_extra_files() { + _destdir="$1" + shift + + # FIXME support '=' in file names + for _file in "$@"; do + _target="${_file%=*}" + _source="${_file#*=}" + [ -n "$_source" ] || _source="$_target" + _target="$_destdir/$_target" + _targetdir="$(dirname "$_target")" + [ -d "$_targetdir" ] || mkdir -p "$_targetdir" + cp "$_source" "$_target" + done +} + if [ x$boot = xnet ]; then netdir=`mktemp -d "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"` || exit 1 pkgdatadir="@builddir@" "@builddir@/grub-mknetdir" "--grub-mkimage=${builddir}/grub-mkimage" "--directory=${builddir}/grub-core" "--net-directory=$netdir" ${mkrescue_args} > /dev/null cp "${cfgfile}" "$netdir/boot/grub/grub.cfg" cp "${source}" "$netdir/boot/grub/testcase.cfg" + [ -z "$files" ] || copy_extra_files "$netdir" $files timeout -s KILL $timeout "${qemu}" ${qemuopts} ${serial_null} -serial file:/dev/stdout -boot n -net "user,tftp=$netdir,bootfile=/boot/grub/${grub_modinfo_target_cpu}-${grub_modinfo_platform}/core.$netbootext" -net nic | cat | tr -d "\r" | do_trim elif [ x$boot = xemu ]; then grubdir="$(mktemp -d "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX")" From 272e0466da16d0f8ce782895de4189c1585de9f3 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Fri, 5 Dec 2014 20:19:58 +0300 Subject: [PATCH 129/722] add file filters tests Tests file access with all filters enabled. It does it both for local and network access, due to regression in signature checking over network. This includes all files in distribution to not depend on existence of compression tools and gpg. Test preloads all required modules to avoid having to provide signatures for them. Still not implemented is file offset filter (is not available in grub script, needs extra module) --- ChangeLog | 12 +++++ Makefile.util.def | 6 +++ conf/Makefile.extra-dist | 11 +++++ tests/file_filter/file.gz | Bin 0 -> 33 bytes tests/file_filter/file.gz.sig | Bin 0 -> 96 bytes tests/file_filter/file.lzop | Bin 0 -> 67 bytes tests/file_filter/file.lzop.sig | Bin 0 -> 96 bytes tests/file_filter/file.xz | Bin 0 -> 72 bytes tests/file_filter/file.xz.sig | Bin 0 -> 96 bytes tests/file_filter/keys | Bin 0 -> 994 bytes tests/file_filter/keys.pub | Bin 0 -> 990 bytes tests/file_filter/test.cfg | 6 +++ tests/file_filter_test.in | 76 ++++++++++++++++++++++++++++++++ 13 files changed, 111 insertions(+) create mode 100644 tests/file_filter/file.gz create mode 100644 tests/file_filter/file.gz.sig create mode 100644 tests/file_filter/file.lzop create mode 100644 tests/file_filter/file.lzop.sig create mode 100644 tests/file_filter/file.xz create mode 100644 tests/file_filter/file.xz.sig create mode 100644 tests/file_filter/keys create mode 100644 tests/file_filter/keys.pub create mode 100644 tests/file_filter/test.cfg create mode 100644 tests/file_filter_test.in diff --git a/ChangeLog b/ChangeLog index c163cd5c0..91ea81fb4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,18 @@ 2014-12-05 Andrei Borzenkov * tests/util/grub-shell.in: Support --files also for netboot. + * tests/file_filter_test.in: New file with file filters tests. + * Makefile.util.def: Add file_filter_test. + * conf/Makefile.extra-dist: ... and here. + * tests/file_filter/file.gz: Test file for file_filter_test. + * tests/file_filter/file.gz.sig: Likewise. + * tests/file_filter/file.lzop: Likewise. + * tests/file_filter/file.lzop.sig: Likewise. + * tests/file_filter/file.xz: Likewise. + * tests/file_filter/file.xz.sig: Likewise. + * tests/file_filter/keys: Likewise. + * tests/file_filter/keys.pub: Likewise. + * tests/file_filter/test.cfg: Likewise. 2014-12-01 Andrei Borzenkov diff --git a/Makefile.util.def b/Makefile.util.def index a286a89cd..fed96d864 100644 --- a/Makefile.util.def +++ b/Makefile.util.def @@ -1150,6 +1150,12 @@ script = { common = tests/grub_cmd_tr.in; }; +script = { + testcase; + name = file_filter_test; + common = tests/file_filter_test.in; +}; + program = { testcase; name = example_unit_test; diff --git a/conf/Makefile.extra-dist b/conf/Makefile.extra-dist index 51f08c1f9..1b95ccd3f 100644 --- a/conf/Makefile.extra-dist +++ b/conf/Makefile.extra-dist @@ -110,3 +110,14 @@ EXTRA_DIST += tests/dfly-mbr-mbexample.mbr.img.gz EXTRA_DIST += tests/dfly-mbr-mbexample.dfly.img.gz EXTRA_DIST += coreboot.cfg + +EXTRA_DIST += tests/file_filter/file +EXTRA_DIST += tests/file_filter/file.gz +EXTRA_DIST += tests/file_filter/file.gz.sig +EXTRA_DIST += tests/file_filter/file.lzop +EXTRA_DIST += tests/file_filter/file.lzop.sig +EXTRA_DIST += tests/file_filter/file.xz +EXTRA_DIST += tests/file_filter/file.xz.sig +EXTRA_DIST += tests/file_filter/keys +EXTRA_DIST += tests/file_filter/keys.pub +EXTRA_DIST += tests/file_filter/test.cfg diff --git a/tests/file_filter/file.gz b/tests/file_filter/file.gz new file mode 100644 index 0000000000000000000000000000000000000000..a07ffcbe0cbad415ea51ec72bbe7b54094284d3d GIT binary patch literal 33 pcmb2|=3qFtrZI$p`LoB_lP9kSYUuju20dY7FxvO)Cocm70|4R_48H&X literal 0 HcmV?d00001 diff --git a/tests/file_filter/file.gz.sig b/tests/file_filter/file.gz.sig new file mode 100644 index 0000000000000000000000000000000000000000..602e6187e22d7fc288a52ac572f38cc1066083cb GIT binary patch literal 96 zcmV-m0H6PeUIYLU2ml5J0#t#n2LK8Q5M~MT@8nv<3h9^t|7f?gmaE1LNh!Sm;mO#P zdLo*tTpkl+s!TB^f%Fh1{Q&^Tlz2`!Q4Giq Ct|zAe literal 0 HcmV?d00001 diff --git a/tests/file_filter/file.lzop b/tests/file_filter/file.lzop new file mode 100644 index 0000000000000000000000000000000000000000..5f5a97171821de55168fcbdc9b1b335316d295b9 GIT binary patch literal 67 zcmeD5iSlRQ<&xqOFi>dVbYNsjC(Bu@f@NKNp%ec7JvFb-Lz3O)* CVl0pV literal 0 HcmV?d00001 diff --git a/tests/file_filter/file.xz b/tests/file_filter/file.xz new file mode 100644 index 0000000000000000000000000000000000000000..151a98029033dd0947d54f8ddad670da85a45185 GIT binary patch literal 72 zcmexsUKJ6=z`*kC+7>q^21Q0O1_p)_{ill=8F)NWb8_-^6iSOzixjzl!VG^@7(cF= Z)UCz9sLER?d1RaXw$HVUAPJVpC;$*f6z~85 literal 0 HcmV?d00001 diff --git a/tests/file_filter/file.xz.sig b/tests/file_filter/file.xz.sig new file mode 100644 index 0000000000000000000000000000000000000000..57569242e4742cdfb929307ec19440cf91f49e9a GIT binary patch literal 96 zcmV-m0H6PeUIYLU2ml5J0#t#n3jhiU5M~MT@8nv<3OS$v{x;4Uj6+!wt^-rP*&N$| z+5zKQ7vOO`?M~+y=au4FasdGNRgV;Q;4TNc&v05)-JLjLl54~a(Q}0wbmOZ2ne0%w Ci77V# literal 0 HcmV?d00001 diff --git a/tests/file_filter/keys b/tests/file_filter/keys new file mode 100644 index 0000000000000000000000000000000000000000..1afa71382364060d08bb0c28e36a1ff98d585fe8 GIT binary patch literal 994 zcmV<810DRC11@ew%2nM8awI88}g~WvBj*BJPpr^(@>)pd~ex-<$MMPxbNPGZV|BH zWj8IQR4B@uXKc3uaPJ1=^^Zq^DT zGR)3)y_E}*oM=>(9mHp}SKbH+oTA=g$}Y_>Yo72Jn4N$d^(*k!0WN3*`c`xB4p;&y zxUni$jurte*DGtmax;-CBK;ReR-(#??6SOFAtnGFD6+^8CX~5LD{yPt|2mUMt zwJE)m>0ZFNaB_Tkn{@&~ymmqz6=oI&zK^|yp26yNF-zSkq2MW>GyFClY9q{@=2rys zhJs5IhyReW6c9&Zrk@1~&dA`O!?SH6dN^nA@=cwz&`Ezpv7R;6gk|My_?I8#%?Z*v z0G=T3S|-k)ND-11n=+U)J=DUmZ`*NlWO1qRl1d|e3jZ@ioyPN?bxzIto0ltfBGhMj z*HF^AUdvgzSm>LzM75fVG>0caAHZcq9dkq@E1ccwLg7IkAD-Uj9eRWey-8OeDLZtP zFGWnyh(8GDLvyN?Wb=5U*>gB4;O4Q~QA&IhlL~dxCca=f>yhv4IlbS9*wP37G*l-7 z68Nu9XH0V?#8Mlr_|4bivnV+Xw zydOTU@TyjupFl11F8p`)R&210tm6Y4QE*AG%aIRbg##g$XGEjNV}o~RH4hXtsdF}8 zgc#a=4BiAs$WhG?LV$*t4U}ex(o2%HHKsbzt@0q@tiFkDvxZ4j5EO=^&d${9btru+ zAB}{L36Q;49P;3xdCKCi1x(1w?GNPIz7@+G3MU121``j|n!I&1(;|JmS_t_VuMTgP z(dkfWGS@ew%2nM8awI88}g~WvBj*BJPpr^(@>)pd~ex-<$MMPxbNPGZV|BH zWj8IQR4B@uXKc3uaPJ1=^^Zq^DT zGR)3)y_E}*oM=>(9mHp}SKbH+oTA=g$}Y_>Yo72Jn4N$d^(*k!0WN3*`c`xB4p;&y zxUni$jurte*DGtmax;-CBK;ReR-(#??6SOFAtnGFD6+^8CX~5LD{yPt|2mUMt zwJE)m>0ZFNaB_Tkn{@&~ymmqz6=oI&zK^|yp26yNF-zSkq2MW>GyFClY9q{@=2rys zhJs5IhyReW6c9&Zrk@1~&dA`O!?SH6dN^nA@=cwz&`Ezpv7R;6gk|My_?I8#%?Z*v z0G=T3S|-k)ND-11n=+U)J=DUmZ`*NlWO1qRl1d|e3jZ@ioyPN?bxzIto0ltfBGhMj z*HF^AUdvgzSm>LzM75fVG>0caAHZcq9dkq@E1ccwLg7IkAD-Uj9eRWey-8OeDLZtP zFGWnyh(8GDLvyN?Wb=5U*>gB4;O4Q~QA&IhlL~dxCca=f>yhv4IlbS9*wP37G*l-7 z68Nu9XH0V?#8Mlr_|4bivnV+Xw zydOTU@TyjupFl11F8p`)R&210tm6Y4QE*AG%aIRbg##g$XGEjNV}o~RH4hXtsdF}8 zgc#a=4BiAs$WhG?LV$*t4U}ex(o2%HHKsbzt@0q@tiFkDvxZ4j5EO=^&d${9btru+ zAB}{L36Q;49P;3xdCKCi1x(1w?GNPIz7@+G3MU121``j|n!I&1(;|JmS_t_VuMTgP z(dkfWGS. + +set -e +grubshell=@builddir@/grub-shell + +. "@builddir@/grub-core/modinfo.sh" + +filters="gzio xzio lzopio verify" +modules="cat mpi" + +for mod in $(cut -d ' ' -f 2 "@builddir@/grub-core/crypto.lst" | sort -u); do + modules="$modules $mod" +done + +for file in file.gz file.xz file.lzop file.gz.sig file.xz.sig file.lzop.sig keys.pub; do + files="$files /$file=@srcdir@/tests/file_filter/$file" +done + +# GRUB cat command adds extra newline after file +result="Hello, user! + +Hello, user! + +Hello, user!" + +out="$("${grubshell}" --modules="$modules $filters" --files="$files" "@srcdir@/tests/file_filter/test.cfg")" +if [ "$out" != "$result" ]; then + echo LOCAL FAIL + echo "$out" + exit 1 +fi + +# Taken from netboot_test +case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in + # PLATFORM: emu is different + *-emu) + exit 0;; + # PLATFORM: Flash targets + i386-qemu | i386-coreboot | mips-qemu_mips | mipsel-qemu_mips) + exit 0;; + # FIXME: currently grub-shell uses only -kernel for loongson + mipsel-loongson) + exit 0;; + # FIXME: no rtl8139 support + i386-multiboot) + exit 0;; + # FIXME: We don't fully support netboot on ARC + *-arc) + exit 0;; + # FIXME: Many QEMU firmware have no netboot capability + *-efi | i386-ieee1275 | powerpc-ieee1275 | sparc64-ieee1275) + exit 0;; +esac + +out="$("${grubshell}" --boot=net --modules="$modules $filters" --files="$files" "@srcdir@/tests/file_filter/test.cfg")" +if [ "$out" != "$result" ]; then + echo NET FAIL + echo "$out" + exit 1 +fi + +exit 0 From ebb3d958aa2e1af8993c77018436bb14bec600b4 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Fri, 5 Dec 2014 21:17:08 +0300 Subject: [PATCH 130/722] fix memory corruption in pubkey filter over network grub_pubkey_open closed original file after it was read; it set io->device to NULL to prevent grub_file_close from trying to close device. But network device itself is stacked (net -> bufio); and bufio preserved original netfs file which hold reference to device. grub_file_close(io) called grub_bufio_close which called grub_file_close for original file. grub_file_close(netfs-file) now also called grub_device_close which freed file->device->net. So file structure returned by grub_pubkey_open now had device->net pointed to freed memory. When later file was closed, it was attempted to be freed again. Change grub_pubkey_open to behave like other filters - preserve original parent file and pass grub_file_close down to parent. In this way only the original file will close device. We really need to move this logic into core instead. Also plug memory leaks in error paths on the way. Reported-By: Robert Kliewer Closes: bug #43601 --- ChangeLog | 2 + grub-core/commands/verify.c | 78 ++++++++++++++++++++++++++++++------- 2 files changed, 65 insertions(+), 15 deletions(-) diff --git a/ChangeLog b/ChangeLog index 91ea81fb4..a9ed5aa46 100644 --- a/ChangeLog +++ b/ChangeLog @@ -13,6 +13,8 @@ * tests/file_filter/keys: Likewise. * tests/file_filter/keys.pub: Likewise. * tests/file_filter/test.cfg: Likewise. + * grub-core/commands/verify.c: Fix memory corruption doing + signature check for network files (closes 43601). 2014-12-01 Andrei Borzenkov diff --git a/grub-core/commands/verify.c b/grub-core/commands/verify.c index 525bdd187..d5995766b 100644 --- a/grub-core/commands/verify.c +++ b/grub-core/commands/verify.c @@ -33,6 +33,13 @@ GRUB_MOD_LICENSE ("GPLv3+"); +struct grub_verified +{ + grub_file_t file; + void *buf; +}; +typedef struct grub_verified *grub_verified_t; + enum { OPTION_SKIP_SIG = 0 @@ -802,19 +809,39 @@ grub_cmd_verify_signature (grub_extcmd_context_t ctxt, static int sec = 0; +static void +verified_free (grub_verified_t verified) +{ + if (verified) + { + grub_free (verified->buf); + grub_free (verified); + } +} + static grub_ssize_t verified_read (struct grub_file *file, char *buf, grub_size_t len) { - grub_memcpy (buf, (char *) file->data + file->offset, len); + grub_verified_t verified = file->data; + + grub_memcpy (buf, (char *) verified->buf + file->offset, len); return len; } static grub_err_t verified_close (struct grub_file *file) { - grub_free (file->data); + grub_verified_t verified = file->data; + + grub_file_close (verified->file); + verified_free (verified); file->data = 0; - return GRUB_ERR_NONE; + + /* device and name are freed by parent */ + file->device = 0; + file->name = 0; + + return grub_errno; } struct grub_fs verified_fs = @@ -832,6 +859,7 @@ grub_pubkey_open (grub_file_t io, const char *filename) grub_err_t err; grub_file_filter_t curfilt[GRUB_FILE_FILTER_MAX]; grub_file_t ret; + grub_verified_t verified; if (!sec) return io; @@ -857,7 +885,10 @@ grub_pubkey_open (grub_file_t io, const char *filename) ret = grub_malloc (sizeof (*ret)); if (!ret) - return NULL; + { + grub_file_close (sig); + return NULL; + } *ret = *io; ret->fs = &verified_fs; @@ -866,29 +897,46 @@ grub_pubkey_open (grub_file_t io, const char *filename) { grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, "big file signature isn't implemented yet"); - return NULL; - } - ret->data = grub_malloc (ret->size); - if (!ret->data) - { + grub_file_close (sig); grub_free (ret); return NULL; } - if (grub_file_read (io, ret->data, ret->size) != (grub_ssize_t) ret->size) + verified = grub_malloc (sizeof (*verified)); + if (!verified) + { + grub_file_close (sig); + grub_free (ret); + return NULL; + } + verified->buf = grub_malloc (ret->size); + if (!verified->buf) + { + grub_file_close (sig); + grub_free (verified); + grub_free (ret); + return NULL; + } + if (grub_file_read (io, verified->buf, ret->size) != (grub_ssize_t) ret->size) { if (!grub_errno) grub_error (GRUB_ERR_FILE_READ_ERROR, N_("premature end of file %s"), filename); + grub_file_close (sig); + verified_free (verified); + grub_free (ret); return NULL; } - err = grub_verify_signature_real (ret->data, ret->size, 0, sig, NULL); + err = grub_verify_signature_real (verified->buf, ret->size, 0, sig, NULL); grub_file_close (sig); if (err) - return NULL; - io->device = 0; - io->name = 0; - grub_file_close (io); + { + verified_free (verified); + grub_free (ret); + return NULL; + } + verified->file = io; + ret->data = verified; return ret; } From 06eadf5ebf21c8520d696c6438a976e5f7c218c3 Mon Sep 17 00:00:00 2001 From: Curtis Larsen Date: Sun, 7 Dec 2014 11:28:57 +0300 Subject: [PATCH 131/722] fix double free in grub_net_recv_tcp_packet Using the http module to download config files, produces memory errors, after the config file is downloaded. The error was traced to the tcp stack in grub-core/net/tcp.c. The wrong netbuff pointer was being freed in the clean up loop. Changing the code to free the correct netbuff pointer removes the runtime error. Closes 42765. --- ChangeLog | 5 +++++ grub-core/net/tcp.c | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index a9ed5aa46..e5c9fd346 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2014-12-07 Curtis Larsen + + * grub-core/net/tcp.c (grub_net_recv_tcp_packet): Fix double + free when multiple empty segments were received (closes 42765). + 2014-12-05 Andrei Borzenkov * tests/util/grub-shell.in: Support --files also for netboot. diff --git a/grub-core/net/tcp.c b/grub-core/net/tcp.c index 2077f5519..1d90f1ec5 100644 --- a/grub-core/net/tcp.c +++ b/grub-core/net/tcp.c @@ -918,7 +918,7 @@ grub_net_recv_tcp_packet (struct grub_net_buff *nb, do_ack = 1; } else - grub_netbuff_free (nb); + grub_netbuff_free (nb_top); } if (do_ack) ack (sock); From cdae5bf208f5fa6093fa34c978c5da7b5bbafc54 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sun, 7 Dec 2014 14:56:17 +0300 Subject: [PATCH 132/722] Avoid use of non-portable echo -n in grub-mkconfig util/grub-mkconfig_lib.in(version_test_gt): "echo -n" is not really needed, final newline is stripped by command substitution. util/grub.d/10_kfreebsd.in, util/grub.d/10_linux.in, util/grub.d/20_linux_xen.in: change how list is built, to avoid echo -n completely. util/grub.d/30_os-prober.in: add spaces to printed line directly Closes 43668. --- ChangeLog | 11 +++++++++++ util/grub-mkconfig_lib.in | 4 ++-- util/grub.d/10_kfreebsd.in | 9 ++++++--- util/grub.d/10_linux.in | 14 ++++++++------ util/grub.d/20_linux_xen.in | 14 ++++++++------ util/grub.d/30_os-prober.in | 3 +-- 6 files changed, 36 insertions(+), 19 deletions(-) diff --git a/ChangeLog b/ChangeLog index e5c9fd346..b23f0698d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2014-12-07 Andrei Borzenkov + + * util/grub-mkconfig_lib.in (version_test_gt): Remove redundant + non-portable '-n' echo option. + * util/grub.d/10_kfreebsd.in: Change how list is built to avoid + non-portable 'echo -n. + * util/grub.d/10_linux.in: Likewise (closes 43668). + * util/grub.d/20_linux_xen.in: Likewise. + * util/grub.d/30_os-prober.in: Print spaces directly to avoid + non-portable 'echo -n'. + 2014-12-07 Curtis Larsen * grub-core/net/tcp.c (grub_net_recv_tcp_packet): Fix double diff --git a/util/grub-mkconfig_lib.in b/util/grub-mkconfig_lib.in index 14fadbcbb..29ef865d4 100644 --- a/util/grub-mkconfig_lib.in +++ b/util/grub-mkconfig_lib.in @@ -246,8 +246,8 @@ version_test_gt () fi case "$version_test_gt_a:$version_test_gt_b" in *.old:*.old) ;; - *.old:*) version_test_gt_a="`echo -n "$version_test_gt_a" | sed -e 's/\.old$//'`" ; version_test_gt_cmp=gt ;; - *:*.old) version_test_gt_b="`echo -n "$version_test_gt_b" | sed -e 's/\.old$//'`" ; version_test_gt_cmp=ge ;; + *.old:*) version_test_gt_a="`echo "$version_test_gt_a" | sed -e 's/\.old$//'`" ; version_test_gt_cmp=gt ;; + *:*.old) version_test_gt_b="`echo "$version_test_gt_b" | sed -e 's/\.old$//'`" ; version_test_gt_cmp=ge ;; esac version_test_numeric "$version_test_gt_a" "$version_test_gt_cmp" "$version_test_gt_b" return "$?" diff --git a/util/grub.d/10_kfreebsd.in b/util/grub.d/10_kfreebsd.in index ba7175bd7..65f6c32a0 100644 --- a/util/grub.d/10_kfreebsd.in +++ b/util/grub.d/10_kfreebsd.in @@ -143,9 +143,12 @@ EOF EOF } -list=`for i in /boot/kfreebsd-* /boot/kernel/kernel ; do - if grub_file_is_not_garbage "$i" ; then echo -n "$i " ; fi - done` +list= +for i in /boot/kfreebsd-* /boot/kernel/kernel ; do + if grub_file_is_not_garbage "$i" ; then + list="$list $i" + fi +done prepare_boot_cache= boot_device_id= title_correction_code= diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in index d2e2a8fd3..a2a84dce4 100644 --- a/util/grub.d/10_linux.in +++ b/util/grub.d/10_linux.in @@ -147,13 +147,15 @@ EOF machine=`uname -m` case "x$machine" in xi?86 | xx86_64) - list=`for i in /boot/vmlinuz-* /vmlinuz-* /boot/kernel-* ; do - if grub_file_is_not_garbage "$i" ; then echo -n "$i " ; fi - done` ;; + list= + for i in /boot/vmlinuz-* /vmlinuz-* /boot/kernel-* ; do + if grub_file_is_not_garbage "$i" ; then list="$list $i" ; fi + done ;; *) - list=`for i in /boot/vmlinuz-* /boot/vmlinux-* /vmlinuz-* /vmlinux-* /boot/kernel-* ; do - if grub_file_is_not_garbage "$i" ; then echo -n "$i " ; fi - done` ;; + list= + for i in /boot/vmlinuz-* /boot/vmlinux-* /vmlinuz-* /vmlinux-* /boot/kernel-* ; do + if grub_file_is_not_garbage "$i" ; then list="$list $i" ; fi + done ;; esac case "$machine" in diff --git a/util/grub.d/20_linux_xen.in b/util/grub.d/20_linux_xen.in index 2e777584c..de34c8d73 100644 --- a/util/grub.d/20_linux_xen.in +++ b/util/grub.d/20_linux_xen.in @@ -137,7 +137,8 @@ EOF EOF } -linux_list=`for i in /boot/vmlinu[xz]-* /vmlinu[xz]-* /boot/kernel-*; do +linux_list= +for i in /boot/vmlinu[xz]-* /vmlinu[xz]-* /boot/kernel-*; do if grub_file_is_not_garbage "$i"; then basename=$(basename $i) version=$(echo $basename | sed -e "s,^[^0-9]*-,,g") @@ -149,9 +150,9 @@ linux_list=`for i in /boot/vmlinu[xz]-* /vmlinu[xz]-* /boot/kernel-*; do break fi done - if (grep -qx "CONFIG_XEN_DOM0=y" "${config}" 2> /dev/null || grep -qx "CONFIG_XEN_PRIVILEGED_GUEST=y" "${config}" 2> /dev/null); then echo -n "$i " ; fi + if (grep -qx "CONFIG_XEN_DOM0=y" "${config}" 2> /dev/null || grep -qx "CONFIG_XEN_PRIVILEGED_GUEST=y" "${config}" 2> /dev/null); then linux_list="$linux_list $i" ; fi fi - done` +done if [ "x${linux_list}" = "x" ] ; then exit 0 fi @@ -165,9 +166,10 @@ file_is_not_sym () { esac } -xen_list=`for i in /boot/xen*; do - if grub_file_is_not_garbage "$i" && file_is_not_sym "$i" ; then echo -n "$i " ; fi - done` +xen_list= +for i in /boot/xen*; do + if grub_file_is_not_garbage "$i" && file_is_not_sym "$i" ; then xen_list="$xen_list $i" ; fi +done prepare_boot_cache= boot_device_id= diff --git a/util/grub.d/30_os-prober.in b/util/grub.d/30_os-prober.in index 6f38c82a5..4ee601565 100644 --- a/util/grub.d/30_os-prober.in +++ b/util/grub.d/30_os-prober.in @@ -322,9 +322,8 @@ EOF EOF ;; *) - echo -n " " # TRANSLATORS: %s is replaced by OS name. - gettext_printf "%s is not yet supported by grub-mkconfig.\n" "${LONGNAME}" >&2 + gettext_printf "%s is not yet supported by grub-mkconfig.\n" " ${LONGNAME}" >&2 ;; esac done From 58f66137a37f3d84a8b37fbe7d5be8e49c3c5768 Mon Sep 17 00:00:00 2001 From: Peter Nelson Date: Sun, 7 Dec 2014 17:57:49 +0100 Subject: [PATCH 133/722] * grub-core/fs/ext2.c (grub_ext2_read_block): Support large sparse chunks. --- ChangeLog | 5 +++++ grub-core/fs/ext2.c | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/ChangeLog b/ChangeLog index b23f0698d..6f2924e41 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2014-12-07 Peter Nelson + + * grub-core/fs/ext2.c (grub_ext2_read_block): Support large sparse + chunks. + 2014-12-07 Andrei Borzenkov * util/grub-mkconfig_lib.in (version_test_gt): Remove redundant diff --git a/grub-core/fs/ext2.c b/grub-core/fs/ext2.c index 5f7a2b9d5..217771d02 100644 --- a/grub-core/fs/ext2.c +++ b/grub-core/fs/ext2.c @@ -484,6 +484,10 @@ grub_ext2_read_block (grub_fshelp_node_t node, grub_disk_addr_t fileblock) indirect: do { + /* If the indirect block is zero, all child blocks are absent + (i.e. filled with zeros.) */ + if (indir == 0) + return 0; if (grub_disk_read (data->disk, ((grub_disk_addr_t) grub_le_to_cpu32 (indir)) << log2_blksz, From 17328db3b33d67f2e5365fcb123d41aacc7ab16b Mon Sep 17 00:00:00 2001 From: David Kozub Date: Thu, 20 Nov 2014 21:53:14 +0100 Subject: [PATCH 134/722] grub-core/kern/arm/misc.S: fix unaligned grub_uint64_t local variable The unaligned local in __aeabi_uidivmod leads to a store to a 64bit value at an address that is not divisible by 8 (in grub_divmod64). The compiler most likely generates a STRD instruction to store it and this causes an exception. Fixes Savannah bug #43632. This includes improvements done by Leif Lindholm. --- ChangeLog | 6 ++++++ grub-core/kern/arm/misc.S | 14 +++++++------- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6f2924e41..4150810a2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2014-12-07 David Kozub + + * grub-core/kern/arm/misc.S: fix unaligned 64bit local variable + in __aeabi_uidivmod + Fixes Savannah bug #43632. + 2014-12-07 Peter Nelson * grub-core/fs/ext2.c (grub_ext2_read_block): Support large sparse diff --git a/grub-core/kern/arm/misc.S b/grub-core/kern/arm/misc.S index 8943cc302..16b6f8e60 100644 --- a/grub-core/kern/arm/misc.S +++ b/grub-core/kern/arm/misc.S @@ -60,17 +60,17 @@ FUNCTION(__aeabi_lmul) .macro division parent - stmfd sp!, {lr} - sub sp, sp, #12 + sub sp, sp, #8 @ Allocate naturally aligned 64-bit space + stmfd sp!, {r3,lr} @ Dummy r3 to maintain stack alignment + add r3, sp, #8 @ Set r3 to address of 64-bit space + str r3, [sp] @ Stack parameter, pointer to 64-bit space mov r2, r1 - add r1, sp, #4 - str r1, [sp, #0] mov r1, #0 mov r3, #0 bl \parent - ldr r1, [sp, #4] - add sp, sp, #12 - ldmfd sp!, {lr} + ldr r1, [sp, #8] @ Extract remainder + ldmfd sp!, {r3,lr} @ Pop into an unused arg/scratch register + add sp, sp, #8 bx lr .endm From bac5d1a64ab4191058a8fd4c05f6b3b339e249e7 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Tue, 9 Dec 2014 21:41:49 +0300 Subject: [PATCH 135/722] Fix serial --rtscts option processing --- ChangeLog | 5 +++++ grub-core/term/serial.c | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4150810a2..c38917bd9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2014-12-09 Andrei Borzenkov + + * grub-core/term/serial.c (grub_cmd_serial): Fix --rtscts + option processing. + 2014-12-07 David Kozub * grub-core/kern/arm/misc.S: fix unaligned 64bit local variable diff --git a/grub-core/term/serial.c b/grub-core/term/serial.c index c9b5574ae..5784bc27e 100644 --- a/grub-core/term/serial.c +++ b/grub-core/term/serial.c @@ -241,9 +241,9 @@ grub_cmd_serial (grub_extcmd_context_t ctxt, int argc, char **args) if (state[OPTION_RTSCTS].set) { - if (grub_strcmp (state[OPTION_PARITY].arg, "on") == 0) + if (grub_strcmp (state[OPTION_RTSCTS].arg, "on") == 0) config.rtscts = 1; - if (grub_strcmp (state[OPTION_PARITY].arg, "off") == 0) + else if (grub_strcmp (state[OPTION_RTSCTS].arg, "off") == 0) config.rtscts = 0; else return grub_error (GRUB_ERR_BAD_ARGUMENT, From ba3031f9963dfc5416140ceebd16d8239e22b1e4 Mon Sep 17 00:00:00 2001 From: Kris Moore Date: Mon, 19 Jan 2015 21:56:41 +0300 Subject: [PATCH 136/722] Support GELI v6 and v7 --- ChangeLog | 4 ++++ grub-core/disk/geli.c | 26 ++++++++++++++++++++------ 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index c38917bd9..854c008e1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2015-01-19 Kris Moore + + * grub-core/disk/geli.c: Support GELI v6 and v7. + 2014-12-09 Andrei Borzenkov * grub-core/term/serial.c (grub_cmd_serial): Fix --rtscts diff --git a/grub-core/disk/geli.c b/grub-core/disk/geli.c index 17273416f..4ed07bb91 100644 --- a/grub-core/disk/geli.c +++ b/grub-core/disk/geli.c @@ -225,7 +225,7 @@ grub_util_get_geli_uuid (const char *dev) /* Look for GELI magic sequence. */ if (grub_memcmp (header->magic, GELI_MAGIC, sizeof (GELI_MAGIC)) - || grub_le_to_cpu32 (header->version) > 5 + || grub_le_to_cpu32 (header->version) > 7 || grub_le_to_cpu32 (header->version) < 1) grub_util_error ("%s", _("wrong ELI magic or version")); @@ -265,7 +265,7 @@ configure_ciphers (grub_disk_t disk, const char *check_uuid, /* Look for GELI magic sequence. */ if (grub_memcmp (header.magic, GELI_MAGIC, sizeof (GELI_MAGIC)) - || grub_le_to_cpu32 (header.version) > 5 + || grub_le_to_cpu32 (header.version) > 7 || grub_le_to_cpu32 (header.version) < 1) { grub_dprintf ("geli", "wrong magic %02x\n", header.magic[0]); @@ -401,6 +401,7 @@ recover_key (grub_disk_t source, grub_cryptodisk_t dev) grub_uint8_t geomkey[GRUB_CRYPTO_MAX_MDLEN]; grub_uint8_t verify_key[GRUB_CRYPTO_MAX_MDLEN]; grub_uint8_t zero[GRUB_CRYPTO_MAX_CIPHER_BLOCKSIZE]; + grub_uint8_t geli_cipher_key[64]; char passphrase[MAX_PASSPHRASE] = ""; unsigned i; gcry_err_code_t gcry_err; @@ -524,6 +525,19 @@ recover_key (grub_disk_t source, grub_cryptodisk_t dev) continue; grub_printf_ (N_("Slot %d opened\n"), i); + if (grub_le_to_cpu32 (header.version) >= 7) + { + /* GELI >=7 uses the cipher_key */ + grub_memcpy (geli_cipher_key, candidate_key.cipher_key, + sizeof (candidate_key.cipher_key)); + } + else + { + /* GELI <=6 uses the iv_key */ + grub_memcpy (geli_cipher_key, candidate_key.iv_key, + sizeof (candidate_key.iv_key)); + } + /* Set the master key. */ if (!dev->rekey) { @@ -540,13 +554,13 @@ recover_key (grub_disk_t source, grub_cryptodisk_t dev) grub_size_t real_keysize = keysize; if (grub_le_to_cpu16 (header.alg) == 0x16) real_keysize *= 2; - /* For a reason I don't know, the IV key is used in rekeying. */ - grub_memcpy (dev->rekey_key, candidate_key.iv_key, - sizeof (candidate_key.iv_key)); + + grub_memcpy (dev->rekey_key, geli_cipher_key, + sizeof (geli_cipher_key)); dev->rekey_derived_size = real_keysize; dev->last_rekey = -1; COMPILE_TIME_ASSERT (sizeof (dev->rekey_key) - >= sizeof (candidate_key.iv_key)); + >= sizeof (geli_cipher_key)); } dev->iv_prefix_len = sizeof (candidate_key.iv_key); From 59d403659461db52e08a0bd49d418baaa2fa106b Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Tue, 20 Jan 2015 12:45:45 +0100 Subject: [PATCH 137/722] Replace explicit sizeof divisions by ARRAY_SIZE. --- ChangeLog | 4 ++++ grub-core/commands/i386/pc/sendkey.c | 10 ++++------ grub-core/kern/emu/hostdisk.c | 6 +++--- grub-core/lib/syslinux_parse.c | 4 ++-- grub-core/loader/i386/xnu.c | 4 ++-- grub-core/normal/color.c | 2 +- 6 files changed, 16 insertions(+), 14 deletions(-) diff --git a/ChangeLog b/ChangeLog index 854c008e1..326f62129 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2015-01-20 Vladimir Serbinenko + + Replace explicit sizeof divisions by ARRAY_SIZE. + 2015-01-19 Kris Moore * grub-core/disk/geli.c: Support GELI v6 and v7. diff --git a/grub-core/commands/i386/pc/sendkey.c b/grub-core/commands/i386/pc/sendkey.c index d985cb33f..26d9acd3d 100644 --- a/grub-core/commands/i386/pc/sendkey.c +++ b/grub-core/commands/i386/pc/sendkey.c @@ -292,7 +292,7 @@ find_key_code (char *key) { unsigned i; - for (i = 0; i < sizeof (keysym_table) / sizeof (keysym_table[0]); i++) + for (i = 0; i < ARRAY_SIZE(keysym_table); i++) { if (keysym_table[i].unshifted_name && grub_strcmp (key, keysym_table[i].unshifted_name) == 0) @@ -311,7 +311,7 @@ find_ascii_code (char *key) { unsigned i; - for (i = 0; i < sizeof (keysym_table) / sizeof (keysym_table[0]); i++) + for (i = 0; i < ARRAY_SIZE(keysym_table); i++) { if (keysym_table[i].unshifted_name && grub_strcmp (key, keysym_table[i].unshifted_name) == 0) @@ -352,15 +352,13 @@ grub_cmd_sendkey (grub_extcmd_context_t ctxt, int argc, char **args) { unsigned i; - for (i = 0; i < sizeof (simple_flag_offsets) - / sizeof (simple_flag_offsets[0]); i++) + for (i = 0; i < ARRAY_SIZE(simple_flag_offsets); i++) grub_sendkey_set_simple_flag (simple_flag_offsets[i], grub_sendkey_parse_op(state[i])); } /* Set noled. */ - noled = (state[sizeof (simple_flag_offsets) - / sizeof (simple_flag_offsets[0])].set); + noled = (state[ARRAY_SIZE(simple_flag_offsets)].set); return GRUB_ERR_NONE; } diff --git a/grub-core/kern/emu/hostdisk.c b/grub-core/kern/emu/hostdisk.c index 44b0fcbb1..a4ebf78a9 100644 --- a/grub-core/kern/emu/hostdisk.c +++ b/grub-core/kern/emu/hostdisk.c @@ -99,7 +99,7 @@ find_free_slot (void) { unsigned int i; - for (i = 0; i < sizeof (map) / sizeof (map[0]); i++) + for (i = 0; i < ARRAY_SIZE (map); i++) if (! map[i].drive) return i; @@ -115,7 +115,7 @@ grub_util_biosdisk_iterate (grub_disk_dev_iterate_hook_t hook, void *hook_data, if (pull != GRUB_DISK_PULL_NONE) return 0; - for (i = 0; i < sizeof (map) / sizeof (map[0]); i++) + for (i = 0; i < ARRAY_SIZE (map); i++) if (map[i].drive && hook (map[i].drive, hook_data)) return 1; @@ -581,7 +581,7 @@ grub_util_biosdisk_fini (void) { unsigned i; - for (i = 0; i < sizeof (map) / sizeof (map[0]); i++) + for (i = 0; i < ARRAY_SIZE(map); i++) { if (map[i].drive) free (map[i].drive); diff --git a/grub-core/lib/syslinux_parse.c b/grub-core/lib/syslinux_parse.c index 08e451cea..241cefe69 100644 --- a/grub-core/lib/syslinux_parse.c +++ b/grub-core/lib/syslinux_parse.c @@ -717,7 +717,7 @@ syslinux_parse_real (struct syslinux_menu *menu) for (ptr3 = ptr2; grub_isspace (*ptr3) && *ptr3; ptr3++); for (ptr4 = ptr3; !grub_isspace (*ptr4) && *ptr4; ptr4++); for (ptr5 = ptr4; grub_isspace (*ptr5) && *ptr5; ptr5++); - for (i = 0; i < sizeof (commands) / sizeof (commands[0]); i++) + for (i = 0; i < ARRAY_SIZE(commands); i++) if (grub_strlen (commands[i].name1) == (grub_size_t) (ptr2 - ptr1) && grub_strncasecmp (commands[i].name1, ptr1, ptr2 - ptr1) == 0 && (commands[i].name2 == NULL @@ -726,7 +726,7 @@ syslinux_parse_real (struct syslinux_menu *menu) && grub_strncasecmp (commands[i].name2, ptr3, ptr4 - ptr3) == 0))) break; - if (i == sizeof (commands) / sizeof (commands[0])) + if (i == ARRAY_SIZE(commands)) { if (sizeof ("text") - 1 == ptr2 - ptr1 && grub_strncasecmp ("text", ptr1, ptr2 - ptr1) == 0 diff --git a/grub-core/loader/i386/xnu.c b/grub-core/loader/i386/xnu.c index e83e1e972..94daa021e 100644 --- a/grub-core/loader/i386/xnu.c +++ b/grub-core/loader/i386/xnu.c @@ -741,10 +741,10 @@ grub_cpu_xnu_fill_devicetree (grub_uint64_t *fsbfreq_out) *((grub_uint64_t *) curval->data) = (grub_addr_t) ptr; /* Create alias. */ - for (j = 0; j < sizeof (table_aliases) / sizeof (table_aliases[0]); j++) + for (j = 0; j < ARRAY_SIZE(table_aliases); j++) if (grub_memcmp (&table_aliases[j].guid, &guid, sizeof (guid)) == 0) break; - if (j != sizeof (table_aliases) / sizeof (table_aliases[0])) + if (j != ARRAY_SIZE(table_aliases)) { curval = grub_xnu_create_value (&(curkey->first_child), "alias"); if (!curval) diff --git a/grub-core/normal/color.c b/grub-core/normal/color.c index c2654239f..d22cf903d 100644 --- a/grub-core/normal/color.c +++ b/grub-core/normal/color.c @@ -47,7 +47,7 @@ static int parse_color_name (grub_uint8_t *ret, char *name) { grub_uint8_t i; - for (i = 0; i < sizeof (color_list) / sizeof (*color_list); i++) + for (i = 0; i < ARRAY_SIZE(color_list); i++) if (! grub_strcmp (name, color_list[i])) { *ret = i; From 66ce4d1aefd54f952f809801380253c28754ed81 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Tue, 20 Jan 2015 12:53:20 +0100 Subject: [PATCH 138/722] grub_script_lexer_yywrap: Update len synchronously with line. --- ChangeLog | 5 +++++ grub-core/script/lexer.c | 1 + 2 files changed, 6 insertions(+) diff --git a/ChangeLog b/ChangeLog index 326f62129..80ef35c62 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2015-01-20 Vladimir Serbinenko + + * grub-core/script/lexer.c (grub_script_lexer_yywrap): Update len + synchronously with line. + 2015-01-20 Vladimir Serbinenko Replace explicit sizeof divisions by ARRAY_SIZE. diff --git a/grub-core/script/lexer.c b/grub-core/script/lexer.c index 128d23822..89cf67706 100644 --- a/grub-core/script/lexer.c +++ b/grub-core/script/lexer.c @@ -164,6 +164,7 @@ grub_script_lexer_yywrap (struct grub_parser_param *parserstate, { grub_free (line); line = grub_strdup ("\n"); + len = 1; } else if (len && line[len - 1] != '\n') { From af435524cd39f0967cd46e650e4312ecfeb158ed Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Tue, 20 Jan 2015 12:58:17 +0100 Subject: [PATCH 139/722] grub_fshelp_read_file: Don't attempt to read past the end of file. --- ChangeLog | 5 +++++ grub-core/fs/fshelp.c | 7 +++++++ 2 files changed, 12 insertions(+) diff --git a/ChangeLog b/ChangeLog index 80ef35c62..c18ab2da6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2015-01-20 Vladimir Serbinenko + + * grub-core/fs/fshelp.c (grub_fshelp_read_file): Don't attempt to read + past the end of file. + 2015-01-20 Vladimir Serbinenko * grub-core/script/lexer.c (grub_script_lexer_yywrap): Update len diff --git a/grub-core/fs/fshelp.c b/grub-core/fs/fshelp.c index 42bd542bb..b899bed04 100644 --- a/grub-core/fs/fshelp.c +++ b/grub-core/fs/fshelp.c @@ -252,6 +252,13 @@ grub_fshelp_read_file (grub_disk_t disk, grub_fshelp_node_t node, grub_disk_addr_t i, blockcnt; int blocksize = 1 << (log2blocksize + GRUB_DISK_SECTOR_BITS); + if (pos > filesize) + { + grub_error (GRUB_ERR_OUT_OF_RANGE, + N_("attempt to read past the end of file")); + return -1; + } + /* Adjust LEN so it we can't read past the end of the file. */ if (pos + len > filesize) len = filesize - pos; From 30e177a05bc2ba8d01c69dd587198a9b88279de1 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Tue, 20 Jan 2015 13:55:55 +0100 Subject: [PATCH 140/722] grub-core/fs/minix.c (grub_minix_read_file): Avoid reading past the end of file. --- ChangeLog | 10 ++++++++++ grub-core/bus/usb/usbtrans.c | 2 +- grub-core/fs/minix.c | 7 +++++++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index c18ab2da6..14284774f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2015-01-20 Vladimir Serbinenko + + * grub-core/bus/usb/usbtrans.c (grub_usb_bulk_maxpacket): Avoid + potentially returning 0. + +2015-01-20 Vladimir Serbinenko + + * grub-core/fs/minix.c (grub_minix_read_file): Avoid reading past + the end of file. + 2015-01-20 Vladimir Serbinenko * grub-core/fs/fshelp.c (grub_fshelp_read_file): Don't attempt to read diff --git a/grub-core/bus/usb/usbtrans.c b/grub-core/bus/usb/usbtrans.c index 557e71c2e..b614997f2 100644 --- a/grub-core/bus/usb/usbtrans.c +++ b/grub-core/bus/usb/usbtrans.c @@ -31,7 +31,7 @@ grub_usb_bulk_maxpacket (grub_usb_device_t dev, struct grub_usb_desc_endp *endpoint) { /* Use the maximum packet size given in the endpoint descriptor. */ - if (dev->initialized && endpoint) + if (dev->initialized && endpoint && (unsigned int) endpoint->maxpacket) return endpoint->maxpacket; return 64; diff --git a/grub-core/fs/minix.c b/grub-core/fs/minix.c index 98e1b71ec..6f629a12f 100644 --- a/grub-core/fs/minix.c +++ b/grub-core/fs/minix.c @@ -262,6 +262,13 @@ grub_minix_read_file (struct grub_minix_data *data, grub_uint32_t posblock; grub_uint32_t blockoff; + if (pos > GRUB_MINIX_INODE_SIZE (data)) + { + grub_error (GRUB_ERR_OUT_OF_RANGE, + N_("attempt to read past the end of file")); + return -1; + } + /* Adjust len so it we can't read past the end of the file. */ if (len + pos > GRUB_MINIX_INODE_SIZE (data)) len = GRUB_MINIX_INODE_SIZE (data) - pos; From 44461d5af23dc00bf31604fa07e191b0d4c5cb67 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Tue, 20 Jan 2015 14:11:32 +0100 Subject: [PATCH 141/722] grub_cmd_play: Avoid division by zero. --- ChangeLog | 5 +++++ grub-core/commands/i386/pc/play.c | 15 +++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/ChangeLog b/ChangeLog index 14284774f..3ae00de22 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2015-01-20 Vladimir Serbinenko + + * grub-core/commands/i386/pc/play.c (grub_cmd_play): Avoid + division by zero. + 2015-01-20 Vladimir Serbinenko * grub-core/bus/usb/usbtrans.c (grub_usb_bulk_maxpacket): Avoid diff --git a/grub-core/commands/i386/pc/play.c b/grub-core/commands/i386/pc/play.c index 40798c96c..7712e2a36 100644 --- a/grub-core/commands/i386/pc/play.c +++ b/grub-core/commands/i386/pc/play.c @@ -107,6 +107,14 @@ grub_cmd_play (grub_command_t cmd __attribute__ ((unused)), return grub_errno; } + if (!tempo) + { + grub_file_close (file); + grub_error (GRUB_ERR_BAD_ARGUMENT, N_("Invalid tempo in %s"), + args[0]); + return grub_errno; + } + tempo = grub_le_to_cpu32 (tempo); grub_dprintf ("play","tempo = %d\n", tempo); @@ -131,6 +139,13 @@ grub_cmd_play (grub_command_t cmd __attribute__ ((unused)), tempo = grub_strtoul (args[0], &end, 0); + if (!tempo) + { + grub_error (GRUB_ERR_BAD_ARGUMENT, N_("Invalid tempo in %s"), + args[0]); + return grub_errno; + } + if (*end) /* Was not a number either, assume it was supposed to be a file name. */ return grub_error (GRUB_ERR_FILE_NOT_FOUND, N_("file `%s' not found"), args[0]); From 1dfe3f973e83b33badeee1c1f7d2644401294d8c Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Tue, 20 Jan 2015 14:12:30 +0100 Subject: [PATCH 142/722] * grub-core/disk/AFSplitter.c (AF_merge): Check that mdlen is not 0. --- ChangeLog | 4 ++++ grub-core/disk/AFSplitter.c | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 3ae00de22..0c85b35b4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2015-01-20 Vladimir Serbinenko + + * grub-core/disk/AFSplitter.c (AF_merge): Check that mdlen is not 0. + 2015-01-20 Vladimir Serbinenko * grub-core/commands/i386/pc/play.c (grub_cmd_play): Avoid diff --git a/grub-core/disk/AFSplitter.c b/grub-core/disk/AFSplitter.c index d76a1c447..7e1bd5748 100644 --- a/grub-core/disk/AFSplitter.c +++ b/grub-core/disk/AFSplitter.c @@ -76,7 +76,7 @@ AF_merge (const gcry_md_spec_t * hash, grub_uint8_t * src, grub_uint8_t * dst, if (bufblock == NULL) return GPG_ERR_OUT_OF_MEMORY; - if (hash->mdlen > GRUB_CRYPTO_MAX_MDLEN) + if (hash->mdlen > GRUB_CRYPTO_MAX_MDLEN || hash->mdlen == 0) return GPG_ERR_INV_ARG; grub_memset (bufblock, 0, blocksize); From f27ccb584ccaf70bfb26b3c893b63124d8563db4 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Tue, 20 Jan 2015 14:16:22 +0100 Subject: [PATCH 143/722] grub_ata_setaddress: Check that geometry is sane when using CHS addressing. --- ChangeLog | 5 +++++ grub-core/disk/ata.c | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/ChangeLog b/ChangeLog index 0c85b35b4..575bd18be 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2015-01-20 Vladimir Serbinenko + + * grub-core/disk/ata.c (grub_ata_setaddress): Check that geometry + is sane when using CHS addressing. + 2015-01-20 Vladimir Serbinenko * grub-core/disk/AFSplitter.c (AF_merge): Check that mdlen is not 0. diff --git a/grub-core/disk/ata.c b/grub-core/disk/ata.c index 2b988490f..8ba4e5c50 100644 --- a/grub-core/disk/ata.c +++ b/grub-core/disk/ata.c @@ -216,6 +216,12 @@ grub_ata_setaddress (struct grub_ata *dev, unsigned int head; unsigned int sect; + if (dev->sectors_per_track == 0 + || dev->heads == 0) + return grub_error (GRUB_ERR_OUT_OF_RANGE, + "sector %d cannot be addressed " + "using CHS addressing", sector); + /* Calculate the sector, cylinder and head to use. */ sect = ((grub_uint32_t) sector % dev->sectors_per_track) + 1; cylinder = (((grub_uint32_t) sector / dev->sectors_per_track) From 9201cd79a33a5f802cdf78437eca91082f382d55 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Tue, 20 Jan 2015 14:27:27 +0100 Subject: [PATCH 144/722] Reject NILFS2 superblocks with over 1GiB blocks. * grub-core/fs/nilfs2.c (grub_nilfs2_valid_sb): Check that block size is <= 1GiB. --- ChangeLog | 7 +++++++ grub-core/fs/nilfs2.c | 4 ++++ 2 files changed, 11 insertions(+) diff --git a/ChangeLog b/ChangeLog index 575bd18be..454aef8ed 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2015-01-20 Vladimir Serbinenko + + Reject NILFS2 superblocks with over 1GiB blocks. + + * grub-core/fs/nilfs2.c (grub_nilfs2_valid_sb): Check that + block size is <= 1GiB. + 2015-01-20 Vladimir Serbinenko * grub-core/disk/ata.c (grub_ata_setaddress): Check that geometry diff --git a/grub-core/fs/nilfs2.c b/grub-core/fs/nilfs2.c index 388ee188e..598a2a55b 100644 --- a/grub-core/fs/nilfs2.c +++ b/grub-core/fs/nilfs2.c @@ -724,6 +724,10 @@ grub_nilfs2_valid_sb (struct grub_nilfs2_super_block *sbp) if (grub_le_to_cpu32 (sbp->s_rev_level) != NILFS_SUPORT_REV) return 0; + /* 20 already means 1GiB blocks. We don't want to deal with blocks overflowing int32. */ + if (grub_le_to_cpu32 (sbp->s_log_block_size) > 20) + return 0; + return 1; } From 245e21b2b56e787ec5953efef6ac6ffe251e136b Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Tue, 20 Jan 2015 14:30:05 +0100 Subject: [PATCH 145/722] grub_ufs_mount: Check that sblock.ino_per_group is not 0. --- ChangeLog | 5 +++++ grub-core/fs/ufs.c | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 454aef8ed..d7d5c40e6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2015-01-20 Vladimir Serbinenko + + * grub-core/fs/ufs.c (grub_ufs_mount): Check + that sblock.ino_per_group is not 0. + 2015-01-20 Vladimir Serbinenko Reject NILFS2 superblocks with over 1GiB blocks. diff --git a/grub-core/fs/ufs.c b/grub-core/fs/ufs.c index 4a2161cc7..f560ad380 100644 --- a/grub-core/fs/ufs.c +++ b/grub-core/fs/ufs.c @@ -604,7 +604,8 @@ grub_ufs_mount (grub_disk_t disk) endiannesses. */ if (data->sblock.magic == grub_cpu_to_ufs32_compile_time (GRUB_UFS_MAGIC) && data->sblock.bsize != 0 - && ((data->sblock.bsize & (data->sblock.bsize - 1)) == 0)) + && ((data->sblock.bsize & (data->sblock.bsize - 1)) == 0) + && data->sblock.ino_per_group != 0) { for (data->log2_blksz = 0; (1U << data->log2_blksz) < grub_ufs_to_cpu32 (data->sblock.bsize); From 47cd2645ddc885e7821b4a86a5ccf549dd4d5fcc Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Tue, 20 Jan 2015 14:40:27 +0100 Subject: [PATCH 146/722] * grub-core/fs/ext2.c (grub_ext2_mount): Additional checks for superblock validity. --- ChangeLog | 5 +++++ grub-core/fs/ext2.c | 7 ++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index d7d5c40e6..f69541ead 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2015-01-20 Vladimir Serbinenko + + * grub-core/fs/ext2.c (grub_ext2_mount): Additional + checks for superblock validity. + 2015-01-20 Vladimir Serbinenko * grub-core/fs/ufs.c (grub_ufs_mount): Check diff --git a/grub-core/fs/ext2.c b/grub-core/fs/ext2.c index 217771d02..44c7974e3 100644 --- a/grub-core/fs/ext2.c +++ b/grub-core/fs/ext2.c @@ -577,7 +577,12 @@ grub_ext2_mount (grub_disk_t disk) /* Make sure this is an ext2 filesystem. */ if (data->sblock.magic != grub_cpu_to_le16_compile_time (EXT2_MAGIC) - || grub_le_to_cpu32 (data->sblock.log2_block_size) >= 16) + || grub_le_to_cpu32 (data->sblock.log2_block_size) >= 16 + || data->sblock.inodes_per_group == 0 + /* 20 already means 1GiB blocks. We don't want to deal with blocks overflowing int32. */ + || grub_le_to_cpu32 (data->sblock.log2_block_size) > 20 + || EXT2_INODE_SIZE (data) == 0 + || EXT2_BLOCK_SIZE (data) / EXT2_INODE_SIZE (data) == 0) { grub_error (GRUB_ERR_BAD_FS, "not an ext2 filesystem"); goto fail; From 5ed3a5d0491f7e00d76bed0cdf4fa3cb8868ade4 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Tue, 20 Jan 2015 14:53:09 +0100 Subject: [PATCH 147/722] * grub-core/fs/minix.c: Additional filesystem sanity checks. --- ChangeLog | 5 +++++ grub-core/fs/minix.c | 34 ++++++++++++++++++---------------- 2 files changed, 23 insertions(+), 16 deletions(-) diff --git a/ChangeLog b/ChangeLog index f69541ead..a5d925a8f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2015-01-20 Vladimir Serbinenko + + * grub-core/fs/minix.c: Additional filesystem + sanity checks. + 2015-01-20 Vladimir Serbinenko * grub-core/fs/ext2.c (grub_ext2_mount): Additional diff --git a/grub-core/fs/minix.c b/grub-core/fs/minix.c index 6f629a12f..90ddd34f1 100644 --- a/grub-core/fs/minix.c +++ b/grub-core/fs/minix.c @@ -65,7 +65,6 @@ typedef grub_uint16_t grub_minix_uintn_t; #define grub_minix_to_cpu_n grub_minix_to_cpu16 #endif -#define GRUB_MINIX_INODE_BLKSZ(data) sizeof (grub_minix_uintn_t) #ifdef MODE_MINIX3 typedef grub_uint32_t grub_minix_ino_t; #define grub_minix_to_cpu_ino grub_minix_to_cpu32 @@ -87,8 +86,6 @@ typedef grub_uint16_t grub_minix_ino_t; #define GRUB_MINIX_LOG2_ZONESZ (GRUB_MINIX_LOG2_BSIZE \ + grub_minix_to_cpu16 (data->sblock.log2_zone_size)) #endif -#define GRUB_MINIX_ZONESZ ((grub_uint64_t) data->block_size << \ - (GRUB_DISK_SECTOR_BITS + grub_minix_to_cpu16 (data->sblock.log2_zone_size))) #ifdef MODE_MINIX3 #define GRUB_MINIX_ZONE2SECT(zone) ((zone) * data->block_size) @@ -172,6 +169,7 @@ struct grub_minix_data { struct grub_minix_sblock sblock; struct grub_minix_inode inode; + grub_uint32_t block_per_zone; grub_minix_ino_t ino; int linknest; grub_disk_t disk; @@ -202,8 +200,6 @@ static grub_minix_uintn_t grub_minix_get_file_block (struct grub_minix_data *data, unsigned int blk) { grub_minix_uintn_t indir; - const grub_uint32_t block_per_zone = (GRUB_MINIX_ZONESZ - / GRUB_MINIX_INODE_BLKSZ (data)); /* Direct block. */ if (blk < GRUB_MINIX_INODE_DIR_BLOCKS) @@ -211,33 +207,33 @@ grub_minix_get_file_block (struct grub_minix_data *data, unsigned int blk) /* Indirect block. */ blk -= GRUB_MINIX_INODE_DIR_BLOCKS; - if (blk < block_per_zone) + if (blk < data->block_per_zone) { indir = grub_get_indir (data, GRUB_MINIX_INODE_INDIR_ZONE (data), blk); return indir; } /* Double indirect block. */ - blk -= block_per_zone; - if (blk < block_per_zone * block_per_zone) + blk -= data->block_per_zone; + if (blk < (grub_uint64_t) data->block_per_zone * (grub_uint64_t) data->block_per_zone) { indir = grub_get_indir (data, GRUB_MINIX_INODE_DINDIR_ZONE (data), - blk / block_per_zone); + blk / data->block_per_zone); - indir = grub_get_indir (data, indir, blk % block_per_zone); + indir = grub_get_indir (data, indir, blk % data->block_per_zone); return indir; } #if defined (MODE_MINIX3) || defined (MODE_MINIX2) - blk -= block_per_zone * block_per_zone; - if (blk < ((grub_uint64_t) block_per_zone * (grub_uint64_t) block_per_zone - * (grub_uint64_t) block_per_zone)) + blk -= data->block_per_zone * data->block_per_zone; + if (blk < ((grub_uint64_t) data->block_per_zone * (grub_uint64_t) data->block_per_zone + * (grub_uint64_t) data->block_per_zone)) { indir = grub_get_indir (data, grub_minix_to_cpu_n (data->inode.triple_indir_zone), - (blk / block_per_zone) / block_per_zone); - indir = grub_get_indir (data, indir, (blk / block_per_zone) % block_per_zone); - indir = grub_get_indir (data, indir, blk % block_per_zone); + (blk / data->block_per_zone) / data->block_per_zone); + indir = grub_get_indir (data, indir, (blk / data->block_per_zone) % data->block_per_zone); + indir = grub_get_indir (data, indir, blk % data->block_per_zone); return indir; } @@ -515,6 +511,12 @@ grub_minix_mount (grub_disk_t disk) data->block_size = 2; #endif + data->block_per_zone = (((grub_uint64_t) data->block_size << \ + (GRUB_DISK_SECTOR_BITS + grub_minix_to_cpu16 (data->sblock.log2_zone_size))) + / sizeof (grub_minix_uintn_t)); + if (!data->block_per_zone) + goto fail; + return data; fail: From 98f74998d5749c7e5b8293aaeaaaea5692240073 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Tue, 20 Jan 2015 14:59:40 +0100 Subject: [PATCH 148/722] * grub-core/fs/hfs.c (grub_hfs_mount): Additional filesystem sanity checks. --- ChangeLog | 5 +++++ grub-core/fs/hfs.c | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/ChangeLog b/ChangeLog index a5d925a8f..473eb1466 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2015-01-20 Vladimir Serbinenko + + * grub-core/fs/hfs.c (grub_hfs_mount): Additional filesystem + sanity checks. + 2015-01-20 Vladimir Serbinenko * grub-core/fs/minix.c: Additional filesystem diff --git a/grub-core/fs/hfs.c b/grub-core/fs/hfs.c index d1dc01545..f46f77a94 100644 --- a/grub-core/fs/hfs.c +++ b/grub-core/fs/hfs.c @@ -330,6 +330,7 @@ grub_hfs_mount (grub_disk_t disk) /* Check if this is a HFS filesystem. */ if (grub_be_to_cpu16 (data->sblock.magic) != GRUB_HFS_MAGIC + || data->sblock.blksz == 0 || (data->sblock.blksz & grub_cpu_to_be32_compile_time (0xc00001ff))) { grub_error (GRUB_ERR_BAD_FS, "not an HFS filesystem"); @@ -367,6 +368,11 @@ grub_hfs_mount (grub_disk_t disk) data->cat_root = grub_be_to_cpu32 (treehead.head.root_node); data->cat_size = grub_be_to_cpu16 (treehead.head.node_size); + if (data->cat_size == 0 + || data->blksz < data->cat_size + || data->blksz < data->ext_size) + goto fail; + /* Lookup the root directory node in the catalog tree using the volume name. */ key.parent_dir = grub_cpu_to_be32_compile_time (1); From 935863518f3a9ec12161616a31ac40e5b78bd550 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Tue, 20 Jan 2015 15:01:58 +0100 Subject: [PATCH 149/722] grub_dmraid_nv_detect: Do not divide by zero. --- ChangeLog | 5 +++++ grub-core/disk/dmraid_nvidia.c | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/ChangeLog b/ChangeLog index 473eb1466..8661726df 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2015-01-20 Vladimir Serbinenko + + * grub-core/disk/dmraid_nvidia.c (grub_dmraid_nv_detect): Do not + divide by zero. + 2015-01-20 Vladimir Serbinenko * grub-core/fs/hfs.c (grub_hfs_mount): Additional filesystem diff --git a/grub-core/disk/dmraid_nvidia.c b/grub-core/disk/dmraid_nvidia.c index 6e6405529..fc02f5715 100644 --- a/grub-core/disk/dmraid_nvidia.c +++ b/grub-core/disk/dmraid_nvidia.c @@ -129,6 +129,9 @@ grub_dmraid_nv_detect (grub_disk_t disk, case NV_LEVEL_0: level = 0; disk_size = sb.capacity / sb.array.total_volumes; + if (sb.array.total_volumes == 0) + /* Not RAID. */ + return NULL; break; case NV_LEVEL_1: @@ -139,6 +142,9 @@ grub_dmraid_nv_detect (grub_disk_t disk, case NV_LEVEL_5: level = 5; disk_size = sb.capacity / (sb.array.total_volumes - 1); + if (sb.array.total_volumes == 0 || sb.array.total_volumes == 1) + /* Not RAID. */ + return NULL; break; default: From f1959b16957bbb49bfaa16471d04bd9efc77387f Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Tue, 20 Jan 2015 15:09:42 +0100 Subject: [PATCH 150/722] * grub-core/disk/ieee1275/nand.c (grub_nand_open): Check block size validity. --- ChangeLog | 5 +++++ grub-core/disk/ieee1275/nand.c | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/ChangeLog b/ChangeLog index 8661726df..bdd5697ab 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2015-01-20 Vladimir Serbinenko + + * grub-core/disk/ieee1275/nand.c (grub_nand_open): Check block size + validity. + 2015-01-20 Vladimir Serbinenko * grub-core/disk/dmraid_nvidia.c (grub_dmraid_nv_detect): Do not diff --git a/grub-core/disk/ieee1275/nand.c b/grub-core/disk/ieee1275/nand.c index 576e9ccc4..feffa8c4c 100644 --- a/grub-core/disk/ieee1275/nand.c +++ b/grub-core/disk/ieee1275/nand.c @@ -113,6 +113,11 @@ grub_nand_open (const char *name, grub_disk_t disk) } data->block_size = (args.size1 >> GRUB_DISK_SECTOR_BITS); + if (!data->block_size) + { + grub_error (GRUB_ERR_UNKNOWN_DEVICE, "invalid block size"); + goto fail; + } INIT_IEEE1275_COMMON (&args.common, "call-method", 2, 3); args.method = (grub_ieee1275_cell_t) "size"; From 4200ad44fe782193a397bd0f0ab72283a6d25e89 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Tue, 20 Jan 2015 15:10:34 +0100 Subject: [PATCH 151/722] * grub-core/disk/i386/pc/biosdisk.c: Check disk size sanity. --- ChangeLog | 4 ++++ grub-core/disk/i386/pc/biosdisk.c | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/ChangeLog b/ChangeLog index bdd5697ab..e8c1d6870 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2015-01-20 Vladimir Serbinenko + + * grub-core/disk/i386/pc/biosdisk.c: Check disk size sanity. + 2015-01-20 Vladimir Serbinenko * grub-core/disk/ieee1275/nand.c (grub_nand_open): Check block size diff --git a/grub-core/disk/i386/pc/biosdisk.c b/grub-core/disk/i386/pc/biosdisk.c index 6b2152591..26a4973ad 100644 --- a/grub-core/disk/i386/pc/biosdisk.c +++ b/grub-core/disk/i386/pc/biosdisk.c @@ -419,6 +419,11 @@ grub_biosdisk_open (const char *name, grub_disk_t disk) } } + if (data->sectors == 0) + data->sectors = 63; + if (data->heads == 0) + data->heads = 255; + if (! total_sectors) total_sectors = data->cylinders * data->heads * data->sectors; } From 111ab3b9cc4ffbf0901d0303872d80a7e1c08a20 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Tue, 20 Jan 2015 15:19:35 +0100 Subject: [PATCH 152/722] osdep/linux/blocklist.c (grub_install_get_blocklist): Check blocksize validity. --- ChangeLog | 5 +++++ grub-core/osdep/linux/blocklist.c | 2 ++ 2 files changed, 7 insertions(+) diff --git a/ChangeLog b/ChangeLog index e8c1d6870..87c465843 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2015-01-20 Vladimir Serbinenko + + * grub-core/osdep/linux/blocklist.c (grub_install_get_blocklist): Check + blocksize validity. + 2015-01-20 Vladimir Serbinenko * grub-core/disk/i386/pc/biosdisk.c: Check disk size sanity. diff --git a/grub-core/osdep/linux/blocklist.c b/grub-core/osdep/linux/blocklist.c index f33a7d507..10ddd11c1 100644 --- a/grub-core/osdep/linux/blocklist.c +++ b/grub-core/osdep/linux/blocklist.c @@ -82,6 +82,8 @@ grub_install_get_blocklist (grub_device_t root_dev, strerror (errno)); if (bsize & (GRUB_DISK_SECTOR_SIZE - 1)) grub_util_error ("%s", _("blocksize is not divisible by 512")); + if (!bsize) + grub_util_error ("%s", _("invalid zero blocksize")); mul = bsize >> GRUB_DISK_SECTOR_BITS; nblocks = (core_size + bsize - 1) / bsize; if (mul == 0 || nblocks == 0) From 065ed900d4865fc31062f01290560ad1bc189522 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Tue, 20 Jan 2015 15:26:09 +0100 Subject: [PATCH 153/722] grub-core/lib/pbkdf2.c (grub_crypto_pbkdf2): Check that hash len is not 0. --- ChangeLog | 4 ++++ grub-core/lib/pbkdf2.c | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 87c465843..a708ca28a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2015-01-20 Vladimir Serbinenko + + * grub-core/lib/pbkdf2.c (grub_crypto_pbkdf2): Check that hash len is not 0. + 2015-01-20 Vladimir Serbinenko * grub-core/osdep/linux/blocklist.c (grub_install_get_blocklist): Check diff --git a/grub-core/lib/pbkdf2.c b/grub-core/lib/pbkdf2.c index 2fbaa95e8..01cee3951 100644 --- a/grub-core/lib/pbkdf2.c +++ b/grub-core/lib/pbkdf2.c @@ -52,7 +52,7 @@ grub_crypto_pbkdf2 (const struct gcry_md_spec *md, grub_uint8_t *tmp; grub_size_t tmplen = Slen + 4; - if (md->mdlen > GRUB_CRYPTO_MAX_MDLEN) + if (md->mdlen > GRUB_CRYPTO_MAX_MDLEN || md->mdlen == 0) return GPG_ERR_INV_ARG; if (c == 0) From 9deb46e363a341d8c243e4c85754e673b4b68571 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Tue, 20 Jan 2015 17:36:29 +0100 Subject: [PATCH 154/722] * grub-core/fs/btrfs.c: Avoid divisions by zero. --- ChangeLog | 4 ++++ grub-core/fs/btrfs.c | 35 +++++++++++++++++++++-------------- 2 files changed, 25 insertions(+), 14 deletions(-) diff --git a/ChangeLog b/ChangeLog index a708ca28a..8e38fdd42 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2015-01-20 Vladimir Serbinenko + + * grub-core/fs/btrfs.c: Avoid divisions by zero. + 2015-01-20 Vladimir Serbinenko * grub-core/lib/pbkdf2.c (grub_crypto_pbkdf2): Check that hash len is not 0. diff --git a/grub-core/fs/btrfs.c b/grub-core/fs/btrfs.c index 95a8fa6b3..9cffa91fa 100644 --- a/grub-core/fs/btrfs.c +++ b/grub-core/fs/btrfs.c @@ -680,6 +680,8 @@ grub_btrfs_read_logical (struct grub_btrfs_data *data, grub_disk_addr_t addr, grub_uint64_t stripen; grub_uint64_t stripe_offset; grub_uint64_t off = addr - grub_le_to_cpu64 (key->offset); + grub_uint64_t chunk_stripe_length; + grub_uint16_t nstripes; unsigned redundancy = 1; unsigned i, j; @@ -690,15 +692,17 @@ grub_btrfs_read_logical (struct grub_btrfs_data *data, grub_disk_addr_t addr, "couldn't find the chunk descriptor"); } + nstripes = grub_le_to_cpu16 (chunk->nstripes) ? : 1; + chunk_stripe_length = grub_le_to_cpu64 (chunk->stripe_length) ? : 512; grub_dprintf ("btrfs", "chunk 0x%" PRIxGRUB_UINT64_T "+0x%" PRIxGRUB_UINT64_T " (%d stripes (%d substripes) of %" PRIxGRUB_UINT64_T ")\n", grub_le_to_cpu64 (key->offset), grub_le_to_cpu64 (chunk->size), - grub_le_to_cpu16 (chunk->nstripes), + nstripes, grub_le_to_cpu16 (chunk->nsubstripes), - grub_le_to_cpu64 (chunk->stripe_length)); + chunk_stripe_length); switch (grub_le_to_cpu64 (chunk->type) & ~GRUB_BTRFS_CHUNK_TYPE_BITS_DONTCARE) @@ -708,8 +712,10 @@ grub_btrfs_read_logical (struct grub_btrfs_data *data, grub_disk_addr_t addr, grub_uint64_t stripe_length; grub_dprintf ("btrfs", "single\n"); stripe_length = grub_divmod64 (grub_le_to_cpu64 (chunk->size), - grub_le_to_cpu16 (chunk->nstripes), + nstripes, NULL); + if (stripe_length == 0) + stripe_length = 512; stripen = grub_divmod64 (off, stripe_length, &stripe_offset); csize = (stripen + 1) * stripe_length - off; break; @@ -730,33 +736,34 @@ grub_btrfs_read_logical (struct grub_btrfs_data *data, grub_disk_addr_t addr, grub_uint64_t low; grub_dprintf ("btrfs", "RAID0\n"); middle = grub_divmod64 (off, - grub_le_to_cpu64 (chunk->stripe_length), + chunk_stripe_length, &low); - high = grub_divmod64 (middle, grub_le_to_cpu16 (chunk->nstripes), + high = grub_divmod64 (middle, nstripes, &stripen); stripe_offset = - low + grub_le_to_cpu64 (chunk->stripe_length) * high; - csize = grub_le_to_cpu64 (chunk->stripe_length) - low; + low + chunk_stripe_length * high; + csize = chunk_stripe_length - low; break; } case GRUB_BTRFS_CHUNK_TYPE_RAID10: { grub_uint64_t middle, high; grub_uint64_t low; + grub_uint16_t nsubstripes; + nsubstripes = grub_le_to_cpu16 (chunk->nsubstripes) ? : 1; middle = grub_divmod64 (off, - grub_le_to_cpu64 (chunk->stripe_length), + chunk_stripe_length, &low); high = grub_divmod64 (middle, - grub_le_to_cpu16 (chunk->nstripes) - / grub_le_to_cpu16 (chunk->nsubstripes), + nstripes / nsubstripes ? : 1, &stripen); - stripen *= grub_le_to_cpu16 (chunk->nsubstripes); - redundancy = grub_le_to_cpu16 (chunk->nsubstripes); - stripe_offset = low + grub_le_to_cpu64 (chunk->stripe_length) + stripen *= nsubstripes; + redundancy = nsubstripes; + stripe_offset = low + chunk_stripe_length * high; - csize = grub_le_to_cpu64 (chunk->stripe_length) - low; + csize = chunk_stripe_length - low; break; } default: From 475bffeae67fa0f6787c33147c120b40e89b1985 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Tue, 20 Jan 2015 17:46:55 +0100 Subject: [PATCH 155/722] * grub-core/fs/zfs.c: Avoid divisions by zero. --- ChangeLog | 4 ++++ grub-core/fs/zfs/zfs.c | 12 ++++++++++++ 2 files changed, 16 insertions(+) diff --git a/ChangeLog b/ChangeLog index 8e38fdd42..c60a231e2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2015-01-20 Vladimir Serbinenko + + * grub-core/fs/zfs.c: Avoid divisions by zero. + 2015-01-20 Vladimir Serbinenko * grub-core/fs/btrfs.c: Avoid divisions by zero. diff --git a/grub-core/fs/zfs/zfs.c b/grub-core/fs/zfs/zfs.c index cfb25c030..c943b5299 100644 --- a/grub-core/fs/zfs/zfs.c +++ b/grub-core/fs/zfs/zfs.c @@ -1501,6 +1501,9 @@ read_device (grub_uint64_t offset, struct grub_zfs_device_desc *desc, return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, "raidz%d is not supported", desc->nparity); + if (desc->n_children <= desc->nparity || desc->n_children < 1) + return grub_error(GRUB_ERR_BAD_FS, "too little devices for given parity"); + orig_s = (((len + (1 << desc->ashift) - 1) >> desc->ashift) + (desc->n_children - desc->nparity) - 1); s = orig_s; @@ -2804,6 +2807,9 @@ dnode_get_path (struct subvolume *subvol, const char *path_in, dnode_end_t *dn, dnode_path->dn.endian) << SPA_MINBLOCKSHIFT); + if (blksz == 0) + return grub_error(GRUB_ERR_BAD_FS, "0-sized block"); + sym_value = grub_malloc (sym_sz); if (!sym_value) return grub_errno; @@ -3798,6 +3804,12 @@ grub_zfs_read (grub_file_t file, char *buf, grub_size_t len) blksz = grub_zfs_to_cpu16 (data->dnode.dn.dn_datablkszsec, data->dnode.endian) << SPA_MINBLOCKSHIFT; + if (blksz == 0) + { + grub_error (GRUB_ERR_BAD_FS, "0-sized block"); + return -1; + } + /* * Entire Dnode is too big to fit into the space available. We * will need to read it in chunks. This could be optimized to From 1b6aaddc456961d87d98e0f342c70b874b2fb232 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Tue, 20 Jan 2015 17:55:41 +0100 Subject: [PATCH 156/722] term.h: Avoid returining 0-sized terminal as it may lead to division by zero. --- ChangeLog | 5 +++++ include/grub/term.h | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index c60a231e2..141aa0660 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2015-01-20 Vladimir Serbinenko + + * include/grub/term.h: Avoid returining 0-sized terminal + as it may lead to division by zero. + 2015-01-20 Vladimir Serbinenko * grub-core/fs/zfs.c: Avoid divisions by zero. diff --git a/include/grub/term.h b/include/grub/term.h index 98c68a5ab..5ffb38f69 100644 --- a/include/grub/term.h +++ b/include/grub/term.h @@ -334,12 +334,12 @@ void grub_term_restore_pos (struct grub_term_coordinate *pos); static inline unsigned grub_term_width (struct grub_term_output *term) { - return term->getwh(term).x; + return term->getwh(term).x ? : 80; } static inline unsigned grub_term_height (struct grub_term_output *term) { - return term->getwh(term).y; + return term->getwh(term).y ? : 24; } static inline struct grub_term_coordinate From 750f4bacd3262376ced3f837d8dc78f834ca233a Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Tue, 20 Jan 2015 19:33:20 +0100 Subject: [PATCH 157/722] * grub-core/disk/diskfilter.c: Validate volumes to avoid division by zero. --- ChangeLog | 5 ++ grub-core/disk/diskfilter.c | 123 ++++++++++++++++++++++++++++++++++-- 2 files changed, 123 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 141aa0660..fbdd560cb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2015-01-20 Vladimir Serbinenko + + * grub-core/disk/diskfilter.c: Validate volumes to avoid division + by zero. + 2015-01-20 Vladimir Serbinenko * include/grub/term.h: Avoid returining 0-sized terminal diff --git a/grub-core/disk/diskfilter.c b/grub-core/disk/diskfilter.c index e8a3bcbd1..97ca54666 100644 --- a/grub-core/disk/diskfilter.c +++ b/grub-core/disk/diskfilter.c @@ -483,6 +483,96 @@ grub_diskfilter_read_node (const struct grub_diskfilter_node *node, return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "unknown node '%s'", node->name); } + +static grub_err_t +validate_segment (struct grub_diskfilter_segment *seg); + +static grub_err_t +validate_lv (struct grub_diskfilter_lv *lv) +{ + unsigned int i; + if (!lv) + return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "unknown volume"); + + if (lv->vg->extent_size == 0) + return grub_error (GRUB_ERR_READ_ERROR, "invalid volume"); + + for (i = 0; i < lv->segment_count; i++) + { + grub_err_t err; + err = validate_segment (&lv->segments[1]); + if (err) + return err; + } + return GRUB_ERR_NONE; +} + + +static grub_err_t +validate_node (const struct grub_diskfilter_node *node) +{ + /* Check whether we actually know the physical volume we want to + read from. */ + if (node->pv) + return GRUB_ERR_NONE; + if (node->lv) + return validate_lv (node->lv); + return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "unknown node '%s'", node->name); +} + +static grub_err_t +validate_segment (struct grub_diskfilter_segment *seg) +{ + grub_err_t err; + + if (seg->stripe_size == 0 || seg->node_count == 0) + return grub_error(GRUB_ERR_BAD_FS, "invalid segment"); + + switch (seg->type) + { + case GRUB_DISKFILTER_RAID10: + { + grub_uint8_t near, far; + near = seg->layout & 0xFF; + far = (seg->layout >> 8) & 0xFF; + if ((seg->layout >> 16) == 0 && far == 0) + return grub_error(GRUB_ERR_BAD_FS, "invalid segment"); + if (near > seg->node_count) + return grub_error(GRUB_ERR_BAD_FS, "invalid segment"); + break; + } + + case GRUB_DISKFILTER_STRIPED: + case GRUB_DISKFILTER_MIRROR: + break; + + case GRUB_DISKFILTER_RAID4: + case GRUB_DISKFILTER_RAID5: + if (seg->node_count <= 1) + return grub_error(GRUB_ERR_BAD_FS, "invalid segment"); + break; + + case GRUB_DISKFILTER_RAID6: + if (seg->node_count <= 2) + return grub_error(GRUB_ERR_BAD_FS, "invalid segment"); + break; + + default: + return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, + "unsupported RAID level %d", seg->type); + } + + unsigned i; + for (i = 0; i < seg->node_count; i++) + { + err = validate_node (&seg->nodes[i]); + if (err) + return err; + } + return GRUB_ERR_NONE; + +} + static grub_err_t read_segment (struct grub_diskfilter_segment *seg, grub_disk_addr_t sector, grub_size_t size, char *buf) @@ -848,6 +938,32 @@ grub_diskfilter_vg_register (struct grub_diskfilter_vg *vg) for (lv = vg->lvs; lv; lv = lv->next) { + /* RAID 1 and single-disk RAID 0 don't use a chunksize but code assumes one so set + one. */ + for (i = 0; i < lv->segment_count; i++) + { + if (lv->segments[i].type == 1) + lv->segments[i].stripe_size = 64; + if (lv->segments[i].type == GRUB_DISKFILTER_STRIPED + && lv->segments[i].node_count == 1 + && lv->segments[i].stripe_size == 0) + lv->segments[i].stripe_size = 64; + } + } + + for (lv = vg->lvs; lv; lv = lv->next) + { + grub_err_t err; + + /* RAID 1 doesn't use a chunksize but code assumes one so set + one. */ + for (i = 0; i < lv->segment_count; i++) + if (lv->segments[i].type == 1) + lv->segments[i].stripe_size = 64; + + err = validate_lv(lv); + if (err) + return err; lv->number = lv_num++; if (lv->fullname) @@ -888,11 +1004,6 @@ grub_diskfilter_vg_register (struct grub_diskfilter_vg *vg) lv->fullname = tmp; } } - /* RAID 1 doesn't use a chunksize but code assumes one so set - one. */ - for (i = 0; i < lv->segment_count; i++) - if (lv->segments[i].type == 1) - lv->segments[i].stripe_size = 64; lv->vg = vg; } /* Add our new array to the list. */ @@ -926,6 +1037,8 @@ grub_diskfilter_make_raid (grub_size_t uuidlen, char *uuid, int nmemb, n = layout & 0xFF; if (n == 1) n = (layout >> 8) & 0xFF; + if (n == 0) + return NULL; totsize = grub_divmod64 (nmemb * disk_size, n, 0); } From 4816dcac19a05a1209822015d88903faef3d6f44 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Tue, 20 Jan 2015 19:35:49 +0100 Subject: [PATCH 158/722] * grub-core/video/readers/jpeg.c: Avoid division by zero. --- ChangeLog | 4 ++++ grub-core/video/readers/jpeg.c | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index fbdd560cb..7b34ba794 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2015-01-20 Vladimir Serbinenko + + * grub-core/video/readers/jpeg.c: Avoid sivision by zero. + 2015-01-20 Vladimir Serbinenko * grub-core/disk/diskfilter.c: Validate volumes to avoid division diff --git a/grub-core/video/readers/jpeg.c b/grub-core/video/readers/jpeg.c index 2dc2ee10e..38ea2395a 100644 --- a/grub-core/video/readers/jpeg.c +++ b/grub-core/video/readers/jpeg.c @@ -317,7 +317,7 @@ grub_jpeg_decode_sof (struct grub_jpeg_data *data) { data->vs = ss & 0xF; /* Vertical sampling. */ data->hs = ss >> 4; /* Horizontal sampling. */ - if ((data->vs > 2) || (data->hs > 2)) + if ((data->vs > 2) || (data->hs > 2) || (data->vs == 0) || (data->hs == 0)) return grub_error (GRUB_ERR_BAD_FILE_TYPE, "jpeg: sampling method not supported"); } From e95685dab1a7b7ae31b65be1ebc3fd84ebc41c34 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Tue, 20 Jan 2015 20:41:36 +0100 Subject: [PATCH 159/722] Avoid division by zero in serial. --- ChangeLog | 7 +++++++ grub-core/term/ns8250.c | 2 ++ grub-core/term/serial.c | 9 ++++++++- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 7b34ba794..7d5a651ed 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2015-01-20 Vladimir Serbinenko + + Avoid division by zero in serial. + + * grub-core/term/serial.c (grub_cmd_serial): Ensure speed is not 0. + * grub-core/term/ns8250.c (serial_get_divisor): Exit if speed is 0. + 2015-01-20 Vladimir Serbinenko * grub-core/video/readers/jpeg.c: Avoid sivision by zero. diff --git a/grub-core/term/ns8250.c b/grub-core/term/ns8250.c index 2959632a9..39809d042 100644 --- a/grub-core/term/ns8250.c +++ b/grub-core/term/ns8250.c @@ -57,6 +57,8 @@ serial_get_divisor (const struct grub_serial_port *port __attribute__ ((unused)) base_clock = config->base_clock ? (config->base_clock >> 4) : DEFAULT_BASE_CLOCK; divisor = (base_clock + (config->speed / 2)) / config->speed; + if (config->speed == 0) + return 0; if (divisor > 0xffff || divisor == 0) return 0; actual_speed = base_clock / divisor; diff --git a/grub-core/term/serial.c b/grub-core/term/serial.c index 5784bc27e..db80b3ba0 100644 --- a/grub-core/term/serial.c +++ b/grub-core/term/serial.c @@ -220,8 +220,12 @@ grub_cmd_serial (grub_extcmd_context_t ctxt, int argc, char **args) config = port->config; - if (state[OPTION_SPEED].set) + if (state[OPTION_SPEED].set) { config.speed = grub_strtoul (state[OPTION_SPEED].arg, 0, 0); + if (config.speed == 0) + return grub_error (GRUB_ERR_BAD_ARGUMENT, + N_("unsupported serial port parity")); + } if (state[OPTION_WORD].set) config.word_len = grub_strtoul (state[OPTION_WORD].arg, 0, 0); @@ -275,6 +279,9 @@ grub_cmd_serial (grub_extcmd_context_t ctxt, int argc, char **args) config.base_clock *= 1000; } + if (config.speed == 0) + config.speed = 9600; + /* Initialize with new settings. */ err = port->driver->configure (port, &config); if (err) From c453760c71282bc01a88ab80fff02a247297c62b Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Tue, 20 Jan 2015 20:50:35 +0100 Subject: [PATCH 160/722] * grub-core/term/gfxterm.c: Avoid division by zero. --- ChangeLog | 4 ++++ grub-core/term/gfxterm.c | 2 ++ 2 files changed, 6 insertions(+) diff --git a/ChangeLog b/ChangeLog index 7d5a651ed..dc882d858 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2015-01-20 Vladimir Serbinenko + + * grub-core/term/gfxterm.c: Avoid division by zero. + 2015-01-20 Vladimir Serbinenko Avoid division by zero in serial. diff --git a/grub-core/term/gfxterm.c b/grub-core/term/gfxterm.c index dc0669b35..70f10f19c 100644 --- a/grub-core/term/gfxterm.c +++ b/grub-core/term/gfxterm.c @@ -221,6 +221,8 @@ grub_virtual_screen_setup (unsigned int x, unsigned int y, calculate_normal_character_width (virtual_screen.font); virtual_screen.normal_char_height = grub_font_get_max_char_height (virtual_screen.font); + if (virtual_screen.normal_char_height == 0) + virtual_screen.normal_char_height = 16; virtual_screen.cursor_x = 0; virtual_screen.cursor_y = 0; virtual_screen.cursor_state = 1; From e360b5d176ef0a6e65cbbc3ddfffe9cf4ae7d07d Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Tue, 20 Jan 2015 20:52:41 +0100 Subject: [PATCH 161/722] * include/grub/misc.h (grub_div_roundup): Remove as it's unused. --- ChangeLog | 4 ++++ include/grub/misc.h | 7 ------- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index dc882d858..ecbe11dc5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2015-01-20 Vladimir Serbinenko + + * include/grub/misc.h (grub_div_roundup): Remove as it's unused. + 2015-01-20 Vladimir Serbinenko * grub-core/term/gfxterm.c: Avoid division by zero. diff --git a/include/grub/misc.h b/include/grub/misc.h index c6cd4564d..4b6ee06d4 100644 --- a/include/grub/misc.h +++ b/include/grub/misc.h @@ -390,13 +390,6 @@ grub_abs (int x) return (unsigned int) x; } -/* Rounded-up division */ -static inline unsigned int -grub_div_roundup (unsigned int x, unsigned int y) -{ - return (x + y - 1) / y; -} - /* Reboot the machine. */ #if defined (GRUB_MACHINE_EMU) || defined (GRUB_MACHINE_QEMU_MIPS) void EXPORT_FUNC(grub_reboot) (void) __attribute__ ((noreturn)); From 2e62352bc28bd5d3efafc1b5cbe211ff9e9987fd Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Tue, 20 Jan 2015 21:07:08 +0100 Subject: [PATCH 162/722] * grub-core/kern/i386/tsc.c (calibrate_tsc): Ensure that no division by 0 occurs. --- ChangeLog | 5 +++++ grub-core/kern/i386/tsc.c | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index ecbe11dc5..c2551db30 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2015-01-20 Vladimir Serbinenko + + * grub-core/kern/i386/tsc.c (calibrate_tsc): Ensure that + no division by 0 occurs. + 2015-01-20 Vladimir Serbinenko * include/grub/misc.h (grub_div_roundup): Remove as it's unused. diff --git a/grub-core/kern/i386/tsc.c b/grub-core/kern/i386/tsc.c index 3a4cae601..d7d1783e4 100644 --- a/grub-core/kern/i386/tsc.c +++ b/grub-core/kern/i386/tsc.c @@ -122,7 +122,11 @@ calibrate_tsc (void) grub_pit_wait (0xffff); end_tsc = grub_get_tsc (); - grub_tsc_rate = grub_divmod64 ((55ULL << 32), end_tsc - tsc_boot_time, 0); + grub_tsc_rate = 0; + if (end_tsc > tsc_boot_time) + grub_tsc_rate = grub_divmod64 ((55ULL << 32), end_tsc - tsc_boot_time, 0); + if (grub_tsc_rate == 0) + grub_tsc_rate = 5368;/* 800 MHz */ } #endif From b666e01b9cb932de5f04fece08f21f0e5f074ebd Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Tue, 20 Jan 2015 21:07:41 +0100 Subject: [PATCH 163/722] * grub-core/loader/i386/xnu.c (guessfsb): Avoid division by 0. --- ChangeLog | 4 ++++ grub-core/loader/i386/xnu.c | 8 +++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index c2551db30..03769742c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2015-01-20 Vladimir Serbinenko + + * grub-core/loader/i386/xnu.c (guessfsb): Avoid division by 0. + 2015-01-20 Vladimir Serbinenko * grub-core/kern/i386/tsc.c (calibrate_tsc): Ensure that diff --git a/grub-core/loader/i386/xnu.c b/grub-core/loader/i386/xnu.c index 94daa021e..e0506a676 100644 --- a/grub-core/loader/i386/xnu.c +++ b/grub-core/loader/i386/xnu.c @@ -126,7 +126,7 @@ guessfsb (void) { const grub_uint64_t sane_value = 100000000; grub_uint32_t manufacturer[3], max_cpuid, capabilities, msrlow; - grub_uint32_t a, b, d; + grub_uint32_t a, b, d, divisor; if (! grub_cpu_is_cpuid_supported ()) return sane_value; @@ -166,8 +166,10 @@ guessfsb (void) r = (2000ULL << 32) - v * grub_tsc_rate; v += r / grub_tsc_rate; - return grub_divmod64 (v, ((msrlow >> 7) & 0x3e) | ((msrlow >> 14) & 1), - 0); + divisor = ((msrlow >> 7) & 0x3e) | ((msrlow >> 14) & 1); + if (divisor == 0) + return sane_value; + return grub_divmod64 (v, divisor, 0); } struct property_descriptor From 4e0a25a4c03b5e91396912393d5db9871d45bde8 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Tue, 20 Jan 2015 21:10:55 +0100 Subject: [PATCH 164/722] rtc_get_time_ms.c (grub_rtc_get_time_ms): Avoid division by zero. --- ChangeLog | 5 +++++ grub-core/kern/generic/rtc_get_time_ms.c | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 03769742c..40ced5a48 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2015-01-20 Vladimir Serbinenko + + * grub-core/kern/generic/rtc_get_time_ms.c (grub_rtc_get_time_ms): Avoid + division by zero. + 2015-01-20 Vladimir Serbinenko * grub-core/loader/i386/xnu.c (guessfsb): Avoid division by 0. diff --git a/grub-core/kern/generic/rtc_get_time_ms.c b/grub-core/kern/generic/rtc_get_time_ms.c index 49f2acac9..3e39c8fe1 100644 --- a/grub-core/kern/generic/rtc_get_time_ms.c +++ b/grub-core/kern/generic/rtc_get_time_ms.c @@ -34,5 +34,5 @@ grub_rtc_get_time_ms (void) 1 s 1 T rtc ticks */ grub_uint64_t ticks_ms_per_sec = ((grub_uint64_t) 1000) * grub_get_rtc (); - return grub_divmod64 (ticks_ms_per_sec, GRUB_TICKS_PER_SECOND, 0); + return grub_divmod64 (ticks_ms_per_sec, GRUB_TICKS_PER_SECOND ? : 1000, 0); } From ac8bac2496d6ebf74f678288293d89a6b315ff5b Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Tue, 20 Jan 2015 21:12:46 +0100 Subject: [PATCH 165/722] haiku/getroot.c (grub_util_find_partition_start_os): Avoid division by zero. --- ChangeLog | 5 +++++ grub-core/osdep/haiku/getroot.c | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 40ced5a48..167056907 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2015-01-20 Vladimir Serbinenko + + * grub-core/osdep/haiku/getroot.c (grub_util_find_partition_start_os): + Avoid division by zero. + 2015-01-20 Vladimir Serbinenko * grub-core/kern/generic/rtc_get_time_ms.c (grub_rtc_get_time_ms): Avoid diff --git a/grub-core/osdep/haiku/getroot.c b/grub-core/osdep/haiku/getroot.c index 0852c5e5e..4e123c090 100644 --- a/grub-core/osdep/haiku/getroot.c +++ b/grub-core/osdep/haiku/getroot.c @@ -65,7 +65,7 @@ grub_util_find_partition_start_os (const char *dev) device_geometry geo; if (ioctl (fd, B_GET_GEOMETRY, &geo, sizeof (geo)) < 0) return 0; - ret /= geo.bytes_per_sector; + ret /= geo.bytes_per_sector ? : 512; close (fd); return ret; } From 69aee43fa64601cabf6efa9279c10d69b466662e Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Wed, 21 Jan 2015 10:17:36 +0100 Subject: [PATCH 166/722] * grub-core/kern/efi/mm.c (grub_efi_get_memory_map): Never return a descriptor_size==0 to avoid potential divisions by zero. --- ChangeLog | 5 +++++ grub-core/kern/efi/mm.c | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/ChangeLog b/ChangeLog index 167056907..f9ac59915 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2015-01-20 Vladimir Serbinenko + + * grub-core/kern/efi/mm.c (grub_efi_get_memory_map): Never return a + descriptor_size==0 to avoid potential divisions by zero. + 2015-01-20 Vladimir Serbinenko * grub-core/osdep/haiku/getroot.c (grub_util_find_partition_start_os): diff --git a/grub-core/kern/efi/mm.c b/grub-core/kern/efi/mm.c index be37afd9d..20a47aaf5 100644 --- a/grub-core/kern/efi/mm.c +++ b/grub-core/kern/efi/mm.c @@ -230,6 +230,7 @@ grub_efi_get_memory_map (grub_efi_uintn_t *memory_map_size, grub_efi_boot_services_t *b; grub_efi_uintn_t key; grub_efi_uint32_t version; + grub_efi_uintn_t size; if (grub_efi_is_finished) { @@ -259,10 +260,14 @@ grub_efi_get_memory_map (grub_efi_uintn_t *memory_map_size, map_key = &key; if (! descriptor_version) descriptor_version = &version; + if (! descriptor_size) + descriptor_size = &size; b = grub_efi_system_table->boot_services; status = efi_call_5 (b->get_memory_map, memory_map_size, memory_map, map_key, descriptor_size, descriptor_version); + if (*descriptor_size == 0) + *descriptor_size = sizeof (grub_efi_memory_descriptor_t); if (status == GRUB_EFI_SUCCESS) return 1; else if (status == GRUB_EFI_BUFFER_TOO_SMALL) From 68581b009f6e943bd6ddf3c781db1c884832fa8e Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Wed, 21 Jan 2015 10:28:52 +0100 Subject: [PATCH 167/722] unix/cputime.c: Cache sc_clk_tck and check it for sanity. --- ChangeLog | 5 +++++ grub-core/osdep/unix/cputime.c | 9 ++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index f9ac59915..4b9f9b21a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2015-01-20 Vladimir Serbinenko + + * grub-core/osdep/unix/cputime.c (grub_util_get_cpu_time_ms): Cache + sc_clk_tck and check it for sanity. + 2015-01-20 Vladimir Serbinenko * grub-core/kern/efi/mm.c (grub_efi_get_memory_map): Never return a diff --git a/grub-core/osdep/unix/cputime.c b/grub-core/osdep/unix/cputime.c index 47e3abc77..cff359a3b 100644 --- a/grub-core/osdep/unix/cputime.c +++ b/grub-core/osdep/unix/cputime.c @@ -9,7 +9,14 @@ grub_uint64_t grub_util_get_cpu_time_ms (void) { struct tms tm; + static long sc_clk_tck; + if (!sc_clk_tck) + { + sc_clk_tck = sysconf(_SC_CLK_TCK); + if (sc_clk_tck <= 0) + sc_clk_tck = 1000; + } times (&tm); - return (tm.tms_utime * 1000ULL) / sysconf(_SC_CLK_TCK); + return (tm.tms_utime * 1000ULL) / sc_clk_tck; } From 44b38e49885ffcb286e796b572f3f862f3be371a Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Wed, 21 Jan 2015 15:51:49 +0100 Subject: [PATCH 168/722] grub_menu_init_page: Avoid returning 0 geometry to avoid divisions by 0. --- ChangeLog | 5 +++++ grub-core/normal/menu_text.c | 3 +++ 2 files changed, 8 insertions(+) diff --git a/ChangeLog b/ChangeLog index 4b9f9b21a..3383d469e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2015-01-20 Vladimir Serbinenko + + * grub-core/normal/menu_text.c (grub_menu_init_page): Avoid + returning 0 geometry to avoid divisions by 0. + 2015-01-20 Vladimir Serbinenko * grub-core/osdep/unix/cputime.c (grub_util_get_cpu_time_ms): Cache diff --git a/grub-core/normal/menu_text.c b/grub-core/normal/menu_text.c index 2ff294101..e22bb91f6 100644 --- a/grub-core/normal/menu_text.c +++ b/grub-core/normal/menu_text.c @@ -369,6 +369,9 @@ grub_menu_init_page (int nested, int edit, geo->border = 0; } + if (geo->entry_width <= 0) + geo->entry_width = 1; + if (geo->num_entries - msg_num_lines < 3 && geo->timeout_lines == 2) { From 6866f2ba37aafd807a6370278b49618e348a3677 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Wed, 21 Jan 2015 15:56:53 +0100 Subject: [PATCH 169/722] Remove potential division by 0 in gfxmenu. --- ChangeLog | 4 ++ grub-core/gfxmenu/gui_circular_progress.c | 88 ++++++++++++----------- grub-core/gfxmenu/gui_list.c | 3 + grub-core/gfxmenu/gui_progress_bar.c | 12 +++- 4 files changed, 61 insertions(+), 46 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3383d469e..2d57d83fa 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2015-01-20 Vladimir Serbinenko + + Remove potential division by 0 in gfxmenu. + 2015-01-20 Vladimir Serbinenko * grub-core/normal/menu_text.c (grub_menu_init_page): Avoid diff --git a/grub-core/gfxmenu/gui_circular_progress.c b/grub-core/gfxmenu/gui_circular_progress.c index 04f68b8d3..354dd7b73 100644 --- a/grub-core/gfxmenu/gui_circular_progress.c +++ b/grub-core/gfxmenu/gui_circular_progress.c @@ -138,51 +138,53 @@ circprog_paint (void *vself, const grub_video_rect_t *region) (height - center_height) / 2, 0, 0, center_width, center_height); - int radius = grub_min (height, width) / 2 - grub_max (tick_height, tick_width) / 2 - 1; - unsigned nticks; - unsigned tick_begin; - unsigned tick_end; - if (self->end <= self->start - || self->value <= self->start) - nticks = 0; - else - nticks = ((unsigned) (self->num_ticks - * (self->value - self->start))) - / ((unsigned) (self->end - self->start)); - /* Do ticks appear or disappear as the value approached the end? */ - if (self->ticks_disappear) + if (self->num_ticks) { - tick_begin = nticks; - tick_end = self->num_ticks; + int radius = grub_min (height, width) / 2 - grub_max (tick_height, tick_width) / 2 - 1; + unsigned nticks; + unsigned tick_begin; + unsigned tick_end; + if (self->end <= self->start + || self->value <= self->start) + nticks = 0; + else + nticks = ((unsigned) (self->num_ticks + * (self->value - self->start))) + / ((unsigned) (self->end - self->start)); + /* Do ticks appear or disappear as the value approached the end? */ + if (self->ticks_disappear) + { + tick_begin = nticks; + tick_end = self->num_ticks; + } + else + { + tick_begin = 0; + tick_end = nticks; + } + + unsigned i; + for (i = tick_begin; i < tick_end; i++) + { + int x; + int y; + int angle; + + /* Calculate the location of the tick. */ + angle = self->start_angle + + i * GRUB_TRIG_ANGLE_MAX / self->num_ticks; + x = width / 2 + (grub_cos (angle) * radius / GRUB_TRIG_FRACTION_SCALE); + y = height / 2 + (grub_sin (angle) * radius / GRUB_TRIG_FRACTION_SCALE); + + /* Adjust (x,y) so the tick is centered. */ + x -= tick_width / 2; + y -= tick_height / 2; + + /* Draw the tick. */ + grub_video_blit_bitmap (self->tick_bitmap, GRUB_VIDEO_BLIT_BLEND, + x, y, 0, 0, tick_width, tick_height); + } } - else - { - tick_begin = 0; - tick_end = nticks; - } - - unsigned i; - for (i = tick_begin; i < tick_end; i++) - { - int x; - int y; - int angle; - - /* Calculate the location of the tick. */ - angle = self->start_angle - + i * GRUB_TRIG_ANGLE_MAX / self->num_ticks; - x = width / 2 + (grub_cos (angle) * radius / GRUB_TRIG_FRACTION_SCALE); - y = height / 2 + (grub_sin (angle) * radius / GRUB_TRIG_FRACTION_SCALE); - - /* Adjust (x,y) so the tick is centered. */ - x -= tick_width / 2; - y -= tick_height / 2; - - /* Draw the tick. */ - grub_video_blit_bitmap (self->tick_bitmap, GRUB_VIDEO_BLIT_BLEND, - x, y, 0, 0, tick_width, tick_height); - } - grub_gui_restore_viewport (&vpsave); } diff --git a/grub-core/gfxmenu/gui_list.c b/grub-core/gfxmenu/gui_list.c index 5d26811f9..01477cdf2 100644 --- a/grub-core/gfxmenu/gui_list.c +++ b/grub-core/gfxmenu/gui_list.c @@ -131,6 +131,9 @@ get_num_shown_items (list_impl_t self) int max_top_pad = grub_max (item_top_pad, sel_top_pad); int max_bottom_pad = grub_max (item_bottom_pad, sel_bottom_pad); + if (item_height + item_vspace <= 0) + return 1; + return (self->bounds.height + item_vspace - 2 * boxpad - max_top_pad - max_bottom_pad - box_top_pad - box_bottom_pad) / (item_height + item_vspace); diff --git a/grub-core/gfxmenu/gui_progress_bar.c b/grub-core/gfxmenu/gui_progress_bar.c index 3501b0172..b128f0866 100644 --- a/grub-core/gfxmenu/gui_progress_bar.c +++ b/grub-core/gfxmenu/gui_progress_bar.c @@ -118,9 +118,15 @@ draw_filled_rect_bar (grub_gui_progress_bar_t self) f.width + 2, f.height + 2); /* Bar background. */ - int barwidth = (f.width - * (self->value - self->start) - / (self->end - self->start)); + unsigned barwidth; + + if (self->end <= self->start + || self->value <= self->start) + barwidth = 0; + else + barwidth = (f.width + * (self->value - self->start) + / (self->end - self->start)); grub_video_fill_rect (grub_video_map_rgba_color (self->bg_color), f.x + barwidth, f.y, f.width - barwidth, f.height); From 3bac4caa2bc64db313aaee54fffb90383e118517 Mon Sep 17 00:00:00 2001 From: Felix Janda Date: Thu, 22 Jan 2015 19:54:36 +0100 Subject: [PATCH 170/722] Remove direct _llseek code and require long filesystem libc. --- ChangeLog | 4 ++++ INSTALL | 1 + configure.ac | 8 ++++++++ grub-core/osdep/unix/hostdisk.c | 24 ------------------------ 4 files changed, 13 insertions(+), 24 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2d57d83fa..024a876dd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2015-01-22 Felix Janda + + Remove direct _llseek code and require long filesystem libc. + 2015-01-20 Vladimir Serbinenko Remove potential division by 0 in gfxmenu. diff --git a/INSTALL b/INSTALL index b67cd7f34..f6f276c44 100644 --- a/INSTALL +++ b/INSTALL @@ -35,6 +35,7 @@ configuring the GRUB. * GNU binutils 2.9.1.0.23 or later * Flex 2.5.35 or later * Other standard GNU/Unix tools +* a libc with large file support (e.g. glibc 2.1 or later) On GNU/Linux, you also need: diff --git a/configure.ac b/configure.ac index 31d2b0baf..fdddbaddc 100644 --- a/configure.ac +++ b/configure.ac @@ -366,6 +366,14 @@ case "$host_os" in ;; esac +case "$host_os" in + cygwin | windows* | mingw32* | aros*) + ;; + *) + AC_CHECK_SIZEOF(off_t) + test x"$ac_cv_sizeof_off_t" = x8 || AC_MSG_ERROR([Large file support is required]);; +esac + if test x$USE_NLS = xno; then HOST_CFLAGS="$HOST_CFLAGS -fno-builtin-gettext" fi diff --git a/grub-core/osdep/unix/hostdisk.c b/grub-core/osdep/unix/hostdisk.c index 43b56ff31..b3bc0e425 100644 --- a/grub-core/osdep/unix/hostdisk.c +++ b/grub-core/osdep/unix/hostdisk.c @@ -48,11 +48,6 @@ #ifdef __linux__ # include /* ioctl */ # include -# if !defined(__GLIBC__) || \ - ((__GLIBC__ < 2) || ((__GLIBC__ == 2) && (__GLIBC_MINOR__ < 1))) -/* Maybe libc doesn't have large file support. */ -# include /* _llseek */ -# endif /* (GLIBC < 2) || ((__GLIBC__ == 2) && (__GLIBC_MINOR < 1)) */ #endif /* __linux__ */ grub_uint64_t @@ -79,24 +74,6 @@ grub_util_get_fd_size (grub_util_fd_t fd, const char *name, unsigned *log_secsiz return st.st_size; } -#if defined(__linux__) && (!defined(__GLIBC__) || \ - ((__GLIBC__ < 2) || ((__GLIBC__ == 2) && (__GLIBC_MINOR__ < 1)))) - /* Maybe libc doesn't have large file support. */ -int -grub_util_fd_seek (grub_util_fd_t fd, grub_uint64_t off) -{ - loff_t offset, result; - static int _llseek (uint filedes, ulong hi, ulong lo, - loff_t *res, uint wh); - _syscall5 (int, _llseek, uint, filedes, ulong, hi, ulong, lo, - loff_t *, res, uint, wh); - - offset = (loff_t) off; - if (_llseek (fd, offset >> 32, offset & 0xffffffff, &result, SEEK_SET)) - return -1; - return GRUB_ERR_NONE; -} -#else int grub_util_fd_seek (grub_util_fd_t fd, grub_uint64_t off) { @@ -107,7 +84,6 @@ grub_util_fd_seek (grub_util_fd_t fd, grub_uint64_t off) return 0; } -#endif /* Read LEN bytes from FD in BUF. Return less than or equal to zero if an From 2f73d2733ce8f1e60561a4f7c3a7caa3717fb174 Mon Sep 17 00:00:00 2001 From: Andrey Borzenkov Date: Fri, 23 Jan 2015 19:52:45 +0300 Subject: [PATCH 171/722] accept also hdX as alias to native Xen disk name To be compatible with legacy pv-grub, sort disks by increasing order of handle value. This allows reusing legacy pv-grub menu.lst which is using hdX names. Suggested-By: Michael Chang Closes: 44026 --- ChangeLog | 5 ++++ grub-core/disk/xen/xendisk.c | 45 ++++++++++++++++++++++++++++-------- 2 files changed, 41 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index 024a876dd..3f01f9829 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2015-01-23 Andrei Borzenkov + + * grub-core/disk/xen/xendisk.c: Accept hdX as disk names on Xen to + allow legacy menu.lst processing. + 2015-01-22 Felix Janda Remove direct _llseek code and require long filesystem libc. diff --git a/grub-core/disk/xen/xendisk.c b/grub-core/disk/xen/xendisk.c index 2b11c2a2e..b18a9238d 100644 --- a/grub-core/disk/xen/xendisk.c +++ b/grub-core/disk/xen/xendisk.c @@ -40,6 +40,7 @@ struct virtdisk grub_xen_evtchn_t evtchn; void *dma_page; grub_xen_grant_t dma_grant; + struct virtdisk *compat_next; }; #define xen_wmb() mb() @@ -47,6 +48,7 @@ struct virtdisk static struct virtdisk *virtdisks; static grub_size_t vdiskcnt; +struct virtdisk *compat_head; static int grub_virtdisk_iterate (grub_disk_dev_iterate_hook_t hook, void *hook_data, @@ -66,20 +68,32 @@ grub_virtdisk_iterate (grub_disk_dev_iterate_hook_t hook, void *hook_data, static grub_err_t grub_virtdisk_open (const char *name, grub_disk_t disk) { - grub_size_t i; + int i; grub_uint32_t secsize; char fdir[200]; char *buf; + int num = -1; + struct virtdisk *vd; - for (i = 0; i < vdiskcnt; i++) - if (grub_strcmp (name, virtdisks[i].fullname) == 0) + /* For compatibility with pv-grub legacy menu.lst accept hdX as disk name */ + if (name[0] == 'h' && name[1] == 'd' && name[2]) + { + num = grub_strtoul (name + 2, 0, 10); + if (grub_errno) + { + grub_errno = 0; + num = -1; + } + } + for (i = 0, vd = compat_head; vd; vd = vd->compat_next, i++) + if (i == num || grub_strcmp (name, vd->fullname) == 0) break; - if (i == vdiskcnt) + if (!vd) return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "not a virtdisk"); - disk->data = &virtdisks[i]; - disk->id = i; + disk->data = vd; + disk->id = vd - virtdisks; - grub_snprintf (fdir, sizeof (fdir), "%s/sectors", virtdisks[i].backend_dir); + grub_snprintf (fdir, sizeof (fdir), "%s/sectors", vd->backend_dir); buf = grub_xenstore_get_file (fdir, NULL); if (!buf) return grub_errno; @@ -87,8 +101,7 @@ grub_virtdisk_open (const char *name, grub_disk_t disk) if (grub_errno) return grub_errno; - grub_snprintf (fdir, sizeof (fdir), "%s/sector-size", - virtdisks[i].backend_dir); + grub_snprintf (fdir, sizeof (fdir), "%s/sector-size", vd->backend_dir); buf = grub_xenstore_get_file (fdir, NULL); if (!buf) return grub_errno; @@ -264,6 +277,7 @@ fill (const char *dir, void *data) grub_err_t err; void *buf; struct evtchn_alloc_unbound alloc_unbound; + struct virtdisk **prev = &compat_head, *vd = compat_head; /* Shouldn't happen unles some hotplug happened. */ if (vdiskcnt >= *ctr) @@ -374,6 +388,19 @@ fill (const char *dir, void *data) virtdisks[vdiskcnt].frontend_dir = grub_strdup (fdir); + /* For compatibility with pv-grub maintain linked list sorted by handle + value in increasing order. This allows mapping of (hdX) disk names + from legacy menu.lst */ + while (vd) + { + if (vd->handle > virtdisks[vdiskcnt].handle) + break; + prev = &vd->compat_next; + vd = vd->compat_next; + } + virtdisks[vdiskcnt].compat_next = vd; + *prev = &virtdisks[vdiskcnt]; + vdiskcnt++; return 0; From edf2db97e72916786ee87b5a7630659369e1ee97 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Fri, 23 Jan 2015 21:06:16 +0300 Subject: [PATCH 172/722] Mention platform "none" in NEWS --- NEWS | 2 ++ 1 file changed, 2 insertions(+) diff --git a/NEWS b/NEWS index a61df942a..55f09d6d7 100644 --- a/NEWS +++ b/NEWS @@ -85,6 +85,8 @@ New in 2.02: * Support for USB debug dongles. * Support for *-emu on all platforms (previously only i386/x86_64 worked). * Support *-emu on Windows. + * New platform "none" which builds only user level utilities. This is now + default if target CPU is not supported. * Security: * Add optional facility to enforce that all files read by the core image From 8acb9dc697627e4189972f15fc219581557365b6 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 23 Jan 2015 19:46:02 +0100 Subject: [PATCH 173/722] * tests/file_filter/file: Really add missing file. --- ChangeLog | 4 ++++ tests/file_filter/file | 1 + 2 files changed, 5 insertions(+) create mode 100644 tests/file_filter/file diff --git a/ChangeLog b/ChangeLog index 3f01f9829..869f6bfb8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2015-01-23 Vladimir Serbinenko + + * tests/file_filter/file: Really add missing file. + 2015-01-23 Andrei Borzenkov * grub-core/disk/xen/xendisk.c: Accept hdX as disk names on Xen to diff --git a/tests/file_filter/file b/tests/file_filter/file new file mode 100644 index 000000000..64650ac58 --- /dev/null +++ b/tests/file_filter/file @@ -0,0 +1 @@ +Hello, user! From 3bd0868364f693b17b36d592bd390ad974885ee1 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sat, 24 Jan 2015 17:29:50 +0100 Subject: [PATCH 174/722] Autogenerate ChangeLog from git changelog. Old ChangeLog is moved to ChangeLog-2015. For all changes starting from this one ChangeLog will be generated from gitlog only on explicit make invocation and make dist. --- ChangeLog => ChangeLog-2015 | 0 Makefile.am | 13 +- build-aux/gitlog-to-changelog | 432 ++++++++++++++++++++++++++++++++++ 3 files changed, 444 insertions(+), 1 deletion(-) rename ChangeLog => ChangeLog-2015 (100%) create mode 100755 build-aux/gitlog-to-changelog diff --git a/ChangeLog b/ChangeLog-2015 similarity index 100% rename from ChangeLog rename to ChangeLog-2015 diff --git a/Makefile.am b/Makefile.am index cc537a2c8..df0a7283c 100644 --- a/Makefile.am +++ b/Makefile.am @@ -392,7 +392,7 @@ endif .PHONY: bootcheck-linux-i386 bootcheck-linux-x86_64 \ bootcheck-kfreebsd-i386 bootcheck-kfreebsd-x86_64 \ bootcheck-knetbsd-i386 bootcheck-knetbsd-x86_64 \ - bootcheck-linux-mips + bootcheck-linux-mips FORCE # Randomly generated SUCCESSFUL_BOOT_STRING=3e49994fd5d82b7c9298d672d774080d @@ -439,3 +439,14 @@ windowszip: windowsdir rm -rf $(windowsdir) EXTRA_DIST += linguas.sh + +changelog_start_date = 2015-01-24 +gitlog_to_changelog = $(top_srcdir)/build-aux/gitlog-to-changelog + +ChangeLog: FORCE + if test -d $(top_srcdir)/.git; then \ + $(gitlog_to_changelog) --srcdir=$(top_srcdir) --since=$(changelog_start_date) > '$@.tmp'; \ + rm -f '$@'; mv '$@.tmp' '$@'; \ + fi + +EXTRA_DIST += ChangeLog ChangeLog-2015 diff --git a/build-aux/gitlog-to-changelog b/build-aux/gitlog-to-changelog new file mode 100755 index 000000000..78afff4e8 --- /dev/null +++ b/build-aux/gitlog-to-changelog @@ -0,0 +1,432 @@ +eval '(exit $?0)' && eval 'exec perl -wS "$0" ${1+"$@"}' + & eval 'exec perl -wS "$0" $argv:q' + if 0; +# Convert git log output to ChangeLog format. + +my $VERSION = '2012-07-29 06:11'; # UTC +# The definition above must lie within the first 8 lines in order +# for the Emacs time-stamp write hook (at end) to update it. +# If you change this file with Emacs, please let the write hook +# do its job. Otherwise, update this string manually. + +# Copyright (C) 2008-2014 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# Written by Jim Meyering + +use strict; +use warnings; +use Getopt::Long; +use POSIX qw(strftime); + +(my $ME = $0) =~ s|.*/||; + +# use File::Coda; # http://meyering.net/code/Coda/ +END { + defined fileno STDOUT or return; + close STDOUT and return; + warn "$ME: failed to close standard output: $!\n"; + $? ||= 1; +} + +sub usage ($) +{ + my ($exit_code) = @_; + my $STREAM = ($exit_code == 0 ? *STDOUT : *STDERR); + if ($exit_code != 0) + { + print $STREAM "Try '$ME --help' for more information.\n"; + } + else + { + print $STREAM < ChangeLog + $ME -- -n 5 foo > last-5-commits-to-branch-foo + +SPECIAL SYNTAX: + +The following types of strings are interpreted specially when they appear +at the beginning of a log message line. They are not copied to the output. + + Copyright-paperwork-exempt: Yes + Append the "(tiny change)" notation to the usual "date name email" + ChangeLog header to mark a change that does not require a copyright + assignment. + Co-authored-by: Joe User + List the specified name and email address on a second + ChangeLog header, denoting a co-author. + Signed-off-by: Joe User + These lines are simply elided. + +In a FILE specified via --amend, comment lines (starting with "#") are ignored. +FILE must consist of pairs where SHA is a 40-byte SHA1 (alone on +a line) referring to a commit in the current project, and CODE refers to one +or more consecutive lines of Perl code. Pairs must be separated by one or +more blank line. + +Here is sample input for use with --amend=FILE, from coreutils: + +3a169f4c5d9159283548178668d2fae6fced3030 +# fix typo in title: +s/all tile types/all file types/ + +1379ed974f1fa39b12e2ffab18b3f7a607082202 +# Due to a bug in vc-dwim, I mis-attributed a patch by Paul to myself. +# Change the author to be Paul. Note the escaped "@": +s,Jim .*>,Paul Eggert , + +EOF + } + exit $exit_code; +} + +# If the string $S is a well-behaved file name, simply return it. +# If it contains white space, quotes, etc., quote it, and return the new string. +sub shell_quote($) +{ + my ($s) = @_; + if ($s =~ m![^\w+/.,-]!) + { + # Convert each single quote to '\'' + $s =~ s/\'/\'\\\'\'/g; + # Then single quote the string. + $s = "'$s'"; + } + return $s; +} + +sub quoted_cmd(@) +{ + return join (' ', map {shell_quote $_} @_); +} + +# Parse file F. +# Comment lines (starting with "#") are ignored. +# F must consist of pairs where SHA is a 40-byte SHA1 +# (alone on a line) referring to a commit in the current project, and +# CODE refers to one or more consecutive lines of Perl code. +# Pairs must be separated by one or more blank line. +sub parse_amend_file($) +{ + my ($f) = @_; + + open F, '<', $f + or die "$ME: $f: failed to open for reading: $!\n"; + + my $fail; + my $h = {}; + my $in_code = 0; + my $sha; + while (defined (my $line = )) + { + $line =~ /^\#/ + and next; + chomp $line; + $line eq '' + and $in_code = 0, next; + + if (!$in_code) + { + $line =~ /^([0-9a-fA-F]{40})$/ + or (warn "$ME: $f:$.: invalid line; expected an SHA1\n"), + $fail = 1, next; + $sha = lc $1; + $in_code = 1; + exists $h->{$sha} + and (warn "$ME: $f:$.: duplicate SHA1\n"), + $fail = 1, next; + } + else + { + $h->{$sha} ||= ''; + $h->{$sha} .= "$line\n"; + } + } + close F; + + $fail + and exit 1; + + return $h; +} + +# git_dir_option $SRCDIR +# +# From $SRCDIR, the --git-dir option to pass to git (none if $SRCDIR +# is undef). Return as a list (0 or 1 element). +sub git_dir_option($) +{ + my ($srcdir) = @_; + my @res = (); + if (defined $srcdir) + { + my $qdir = shell_quote $srcdir; + my $cmd = "cd $qdir && git rev-parse --show-toplevel"; + my $qcmd = shell_quote $cmd; + my $git_dir = qx($cmd); + defined $git_dir + or die "$ME: cannot run $qcmd: $!\n"; + $? == 0 + or die "$ME: $qcmd had unexpected exit code or signal ($?)\n"; + chomp $git_dir; + push @res, "--git-dir=$git_dir/.git"; + } + @res; +} + +{ + my $since_date; + my $format_string = '%s%n%b%n'; + my $amend_file; + my $append_dot = 0; + my $cluster = 1; + my $strip_tab = 0; + my $strip_cherry_pick = 0; + my $srcdir; + GetOptions + ( + help => sub { usage 0 }, + version => sub { print "$ME version $VERSION\n"; exit }, + 'since=s' => \$since_date, + 'format=s' => \$format_string, + 'amend=s' => \$amend_file, + 'append-dot' => \$append_dot, + 'cluster!' => \$cluster, + 'strip-tab' => \$strip_tab, + 'strip-cherry-pick' => \$strip_cherry_pick, + 'srcdir=s' => \$srcdir, + ) or usage 1; + + defined $since_date + and unshift @ARGV, "--since=$since_date"; + + # This is a hash that maps an SHA1 to perl code (i.e., s/old/new/) + # that makes a correction in the log or attribution of that commit. + my $amend_code = defined $amend_file ? parse_amend_file $amend_file : {}; + + my @cmd = ('git', + git_dir_option $srcdir, + qw(log --log-size), + '--pretty=format:%H:%ct %an <%ae>%n%n'.$format_string, @ARGV); + open PIPE, '-|', @cmd + or die ("$ME: failed to run '". quoted_cmd (@cmd) ."': $!\n" + . "(Is your Git too old? Version 1.5.1 or later is required.)\n"); + + my $prev_multi_paragraph; + my $prev_date_line = ''; + my @prev_coauthors = (); + while (1) + { + defined (my $in = ) + or last; + $in =~ /^log size (\d+)$/ + or die "$ME:$.: Invalid line (expected log size):\n$in"; + my $log_nbytes = $1; + + my $log; + my $n_read = read PIPE, $log, $log_nbytes; + $n_read == $log_nbytes + or die "$ME:$.: unexpected EOF\n"; + + # Extract leading hash. + my ($sha, $rest) = split ':', $log, 2; + defined $sha + or die "$ME:$.: malformed log entry\n"; + $sha =~ /^[0-9a-fA-F]{40}$/ + or die "$ME:$.: invalid SHA1: $sha\n"; + + # If this commit's log requires any transformation, do it now. + my $code = $amend_code->{$sha}; + if (defined $code) + { + eval 'use Safe'; + my $s = new Safe; + # Put the unpreprocessed entry into "$_". + $_ = $rest; + + # Let $code operate on it, safely. + my $r = $s->reval("$code") + or die "$ME:$.:$sha: failed to eval \"$code\":\n$@\n"; + + # Note that we've used this entry. + delete $amend_code->{$sha}; + + # Update $rest upon success. + $rest = $_; + } + + # Remove lines inserted by "git cherry-pick". + if ($strip_cherry_pick) + { + $rest =~ s/^\s*Conflicts:\n.*//sm; + $rest =~ s/^\s*\(cherry picked from commit [\da-f]+\)\n//m; + } + + my @line = split "\n", $rest; + my $author_line = shift @line; + defined $author_line + or die "$ME:$.: unexpected EOF\n"; + $author_line =~ /^(\d+) (.*>)$/ + or die "$ME:$.: Invalid line " + . "(expected date/author/email):\n$author_line\n"; + + # Format 'Copyright-paperwork-exempt: Yes' as a standard ChangeLog + # `(tiny change)' annotation. + my $tiny = (grep (/^Copyright-paperwork-exempt:\s+[Yy]es$/, @line) + ? ' (tiny change)' : ''); + + my $date_line = sprintf "%s %s$tiny\n", + strftime ("%F", localtime ($1)), $2; + + my @coauthors = grep /^Co-authored-by:.*$/, @line; + # Omit meta-data lines we've already interpreted. + @line = grep !/^(?:Signed-off-by:[ ].*>$ + |Co-authored-by:[ ] + |Copyright-paperwork-exempt:[ ] + )/x, @line; + + # Remove leading and trailing blank lines. + if (@line) + { + while ($line[0] =~ /^\s*$/) { shift @line; } + while ($line[$#line] =~ /^\s*$/) { pop @line; } + } + + # Record whether there are two or more paragraphs. + my $multi_paragraph = grep /^\s*$/, @line; + + # Format 'Co-authored-by: A U Thor ' lines in + # standard multi-author ChangeLog format. + for (@coauthors) + { + s/^Co-authored-by:\s*/\t /; + s/\s*/ + or warn "$ME: warning: missing email address for " + . substr ($_, 5) . "\n"; + } + + # If clustering of commit messages has been disabled, if this header + # would be different from the previous date/name/email/coauthors header, + # or if this or the previous entry consists of two or more paragraphs, + # then print the header. + if ( ! $cluster + || $date_line ne $prev_date_line + || "@coauthors" ne "@prev_coauthors" + || $multi_paragraph + || $prev_multi_paragraph) + { + $prev_date_line eq '' + or print "\n"; + print $date_line; + @coauthors + and print join ("\n", @coauthors), "\n"; + } + $prev_date_line = $date_line; + @prev_coauthors = @coauthors; + $prev_multi_paragraph = $multi_paragraph; + + # If there were any lines + if (@line == 0) + { + warn "$ME: warning: empty commit message:\n $date_line\n"; + } + else + { + if ($append_dot) + { + # If the first line of the message has enough room, then + if (length $line[0] < 72) + { + # append a dot if there is no other punctuation or blank + # at the end. + $line[0] =~ /[[:punct:]\s]$/ + or $line[0] .= '.'; + } + } + + # Remove one additional leading TAB from each line. + $strip_tab + and map { s/^\t// } @line; + + # Prefix each non-empty line with a TAB. + @line = map { length $_ ? "\t$_" : '' } @line; + + print "\n", join ("\n", @line), "\n"; + } + + defined ($in = ) + or last; + $in ne "\n" + and die "$ME:$.: unexpected line:\n$in"; + } + + close PIPE + or die "$ME: error closing pipe from " . quoted_cmd (@cmd) . "\n"; + # FIXME-someday: include $PROCESS_STATUS in the diagnostic + + # Complain about any unused entry in the --amend=F specified file. + my $fail = 0; + foreach my $sha (keys %$amend_code) + { + warn "$ME:$amend_file: unused entry: $sha\n"; + $fail = 1; + } + + exit $fail; +} + +# Local Variables: +# mode: perl +# indent-tabs-mode: nil +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "my $VERSION = '" +# time-stamp-format: "%:y-%02m-%02d %02H:%02M" +# time-stamp-time-zone: "UTC" +# time-stamp-end: "'; # UTC" +# End: From 11504d523cca9206e0df1e4f128d6d7d59ac1d9a Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sat, 24 Jan 2015 17:44:19 +0100 Subject: [PATCH 175/722] conf/Makefile.common: Remove unused {LD,C}FLAGS_CPU. --- conf/Makefile.common | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/conf/Makefile.common b/conf/Makefile.common index 51fbaf99d..8c4d1483d 100644 --- a/conf/Makefile.common +++ b/conf/Makefile.common @@ -41,19 +41,19 @@ BUILD_CPPFLAGS += $(CPPFLAGS_DEFAULT) LDADD_KERNEL = $(TARGET_LIBGCC) -CFLAGS_KERNEL = $(CFLAGS_CPU) $(CFLAGS_PLATFORM) -ffreestanding -LDFLAGS_KERNEL = $(LDFLAGS_CPU) $(LDFLAGS_PLATFORM) -nostdlib $(TARGET_LDFLAGS_OLDMAGIC) $(TARGET_LDFLAGS_STATIC_LIBGCC) +CFLAGS_KERNEL = $(CFLAGS_PLATFORM) -ffreestanding +LDFLAGS_KERNEL = $(LDFLAGS_PLATFORM) -nostdlib $(TARGET_LDFLAGS_OLDMAGIC) $(TARGET_LDFLAGS_STATIC_LIBGCC) CPPFLAGS_KERNEL = $(CPPFLAGS_CPU) $(CPPFLAGS_PLATFORM) -DGRUB_KERNEL=1 CCASFLAGS_KERNEL = $(CCASFLAGS_CPU) $(CCASFLAGS_PLATFORM) STRIPFLAGS_KERNEL = -R .rel.dyn -R .reginfo -R .note -R .comment -R .drectve -R .note.gnu.gold-version -CFLAGS_MODULE = $(CFLAGS_CPU) $(CFLAGS_PLATFORM) -ffreestanding -LDFLAGS_MODULE = $(LDFLAGS_CPU) $(LDFLAGS_PLATFORM) -nostdlib $(TARGET_LDFLAGS_OLDMAGIC) -Wl,-r,-d +CFLAGS_MODULE = $(CFLAGS_PLATFORM) -ffreestanding +LDFLAGS_MODULE = $(LDFLAGS_PLATFORM) -nostdlib $(TARGET_LDFLAGS_OLDMAGIC) -Wl,-r,-d CPPFLAGS_MODULE = $(CPPFLAGS_CPU) $(CPPFLAGS_PLATFORM) CCASFLAGS_MODULE = $(CCASFLAGS_CPU) $(CCASFLAGS_PLATFORM) -CFLAGS_IMAGE = $(CFLAGS_CPU) $(CFLAGS_PLATFORM) -fno-builtin -LDFLAGS_IMAGE = $(LDFLAGS_CPU) $(LDFLAGS_PLATFORM) -nostdlib $(TARGET_LDFLAGS_OLDMAGIC) -Wl,-S +CFLAGS_IMAGE = $(CFLAGS_PLATFORM) -fno-builtin +LDFLAGS_IMAGE = $(LDFLAGS_PLATFORM) -nostdlib $(TARGET_LDFLAGS_OLDMAGIC) -Wl,-S CPPFLAGS_IMAGE = $(CPPFLAGS_CPU) $(CPPFLAGS_PLATFORM) CCASFLAGS_IMAGE = $(CCASFLAGS_CPU) $(CCASFLAGS_PLATFORM) From eeea31b2208d862a3ff50f2739e103b22dc0061b Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sat, 24 Jan 2015 17:45:16 +0100 Subject: [PATCH 176/722] util/grub-mkrescue.c: Always include part_msdos and part_gpt on EFI. When booted from stick, EFI would use GPT partition and our root device detection algortihm depends on GRUB's ability to see the same partitions. Hence include msdos and gpt partmap modules on EFI even when they're not needed to access root filesystem. --- util/grub-mkrescue.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/util/grub-mkrescue.c b/util/grub-mkrescue.c index e71983982..e02340f06 100644 --- a/util/grub-mkrescue.c +++ b/util/grub-mkrescue.c @@ -653,6 +653,9 @@ main (int argc, char *argv[]) char *efiimgfat; grub_install_mkdir_p (efidir_efi_boot); + grub_install_push_module ("part_gpt"); + grub_install_push_module ("part_msdos"); + imgname = grub_util_path_concat (2, efidir_efi_boot, "bootia64.efi"); make_image_fwdisk_abs (GRUB_INSTALL_PLATFORM_IA64_EFI, "ia64-efi", imgname); free (imgname); @@ -713,6 +716,8 @@ main (int argc, char *argv[]) free (efiimgfat); free (efidir_efi); free (efidir); + grub_install_pop_module (); + grub_install_pop_module (); } grub_install_push_module ("part_apple"); From 7d027b4d3e632b0a3a81dd1f31012a80f7746b74 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sat, 24 Jan 2015 19:53:13 +0100 Subject: [PATCH 177/722] efidisk: Return the determined root disk even if partition is unknown. --- grub-core/disk/efi/efidisk.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/grub-core/disk/efi/efidisk.c b/grub-core/disk/efi/efidisk.c index 3b12c3499..60a6d3c50 100644 --- a/grub-core/disk/efi/efidisk.c +++ b/grub-core/disk/efi/efidisk.c @@ -803,7 +803,6 @@ grub_efidisk_get_device_name (grub_efi_handle_t *handle) && (GRUB_EFI_DEVICE_PATH_SUBTYPE (ldp) == GRUB_EFI_CDROM_DEVICE_PATH_SUBTYPE || GRUB_EFI_DEVICE_PATH_SUBTYPE (ldp) == GRUB_EFI_HARD_DRIVE_DEVICE_PATH_SUBTYPE)) { - int is_cdrom = 0; struct grub_efidisk_get_device_name_ctx ctx; char *dev_name; grub_efi_device_path_t *dup_dp; @@ -824,9 +823,6 @@ grub_efidisk_get_device_name (grub_efi_handle_t *handle) || GRUB_EFI_DEVICE_PATH_SUBTYPE (dup_ldp) == GRUB_EFI_HARD_DRIVE_DEVICE_PATH_SUBTYPE))) break; - if (GRUB_EFI_DEVICE_PATH_SUBTYPE (dup_ldp) == GRUB_EFI_CDROM_DEVICE_PATH_SUBTYPE) - is_cdrom = 1; - dup_ldp->type = GRUB_EFI_END_DEVICE_PATH_TYPE; dup_ldp->subtype = GRUB_EFI_END_ENTIRE_DEVICE_PATH_SUBTYPE; dup_ldp->length = sizeof (*dup_ldp); @@ -861,10 +857,13 @@ grub_efidisk_get_device_name (grub_efi_handle_t *handle) if (! ctx.partition_name) { + /* No partition found. In most cases partition is embed in + the root path anyway, so this is not critical. + This happens only if partition is on partmap that GRUB + doesn't need to access root. + */ grub_disk_close (parent); - if (is_cdrom) - return grub_strdup (device_name); - return 0; + return grub_strdup (device_name); } dev_name = grub_xasprintf ("%s,%s", parent->name, From 14c9a720397e6674c8c46e2e0697c2bf2a7132ae Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sat, 24 Jan 2015 20:12:51 +0100 Subject: [PATCH 178/722] Makefile.am: Fix Changelog cutoff address. gitlog-to-changelog Doesn't generate entries for cutoff day, only for days after the cutoff date, adjust by one to compensate. --- Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.am b/Makefile.am index df0a7283c..a232eb1e2 100644 --- a/Makefile.am +++ b/Makefile.am @@ -440,7 +440,7 @@ windowszip: windowsdir EXTRA_DIST += linguas.sh -changelog_start_date = 2015-01-24 +changelog_start_date = 2015-01-23 gitlog_to_changelog = $(top_srcdir)/build-aux/gitlog-to-changelog ChangeLog: FORCE From b8f537199a64c7aef68ed39e037f52e9bb629cfc Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sat, 24 Jan 2015 20:14:59 +0100 Subject: [PATCH 179/722] Generate empty ChangeLog if no .git is available. When making dist from a git snapshot without repo available make dist would fail to find ChangeLog. Generate empty ChangeLog if no ChangeLog is already present and repo is not available. Reported by: Andrei Borzenkov --- Makefile.am | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Makefile.am b/Makefile.am index a232eb1e2..f702951af 100644 --- a/Makefile.am +++ b/Makefile.am @@ -447,6 +447,8 @@ ChangeLog: FORCE if test -d $(top_srcdir)/.git; then \ $(gitlog_to_changelog) --srcdir=$(top_srcdir) --since=$(changelog_start_date) > '$@.tmp'; \ rm -f '$@'; mv '$@.tmp' '$@'; \ + else \ + touch $@; \ fi EXTRA_DIST += ChangeLog ChangeLog-2015 From 3661261fe17a8fe19681073889b5b36ec1ee823d Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sat, 24 Jan 2015 20:37:08 +0100 Subject: [PATCH 180/722] Always add -msoft-float to avoid compiler generating float arithmetics. --- configure.ac | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/configure.ac b/configure.ac index fdddbaddc..b734dd0ba 100644 --- a/configure.ac +++ b/configure.ac @@ -671,6 +671,12 @@ if ( test "x$target_cpu" = xi386 || test "x$target_cpu" = xx86_64 ) && test "x$p TARGET_CFLAGS="$TARGET_CFLAGS -mno-mmx -mno-sse -mno-sse2 -mno-3dnow" fi +# GRUB doesn't use float or doubles at all. Yet some toolchains may decide +# that floats are a good fit to run instead of what's written in the code. +# Given that floating point unit is disabled (if present to begin with) +# when GRUB is running which may result in various hard crashes. +TARGET_CFLAGS="$TARGET_CFLAGS -msoft-float" + # By default, GCC 4.4 generates .eh_frame sections containing unwind # information in some cases where it previously did not. GRUB doesn't need # these and they just use up vital space. Restore the old compiler From 9ff9d5a54ead6fba080a08fcb1ff8462b8cf2497 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sat, 24 Jan 2015 20:38:12 +0100 Subject: [PATCH 181/722] uhci: Fix null pointer dereference. Found by: Coverity scan. --- grub-core/bus/usb/uhci.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/grub-core/bus/usb/uhci.c b/grub-core/bus/usb/uhci.c index a95fdfe07..7c5811fd6 100644 --- a/grub-core/bus/usb/uhci.c +++ b/grub-core/bus/usb/uhci.c @@ -625,9 +625,7 @@ grub_uhci_check_transfer (grub_usb_controller_t dev, return GRUB_USB_ERR_NONE; } - grub_dprintf ("uhci", "t status=0x%02x\n", errtd->ctrl_status); - - if (!(errtd->ctrl_status & (1 << 23))) + if (errtd && !(errtd->ctrl_status & (1 << 23))) { grub_usb_err_t err = GRUB_USB_ERR_NONE; From e902163e484523698f1cc4f06b64830f30909153 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sat, 24 Jan 2015 20:41:43 +0100 Subject: [PATCH 182/722] commands/acpi: Use ALIGN_UP rather than manual expression. Improves readability and hopefully automatic scanning. Found by: Coverity Scan. --- grub-core/commands/acpi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/grub-core/commands/acpi.c b/grub-core/commands/acpi.c index 97c2cf282..f66fa2db3 100644 --- a/grub-core/commands/acpi.c +++ b/grub-core/commands/acpi.c @@ -227,7 +227,7 @@ grub_acpi_create_ebda (void) grub_dprintf ("acpi", "Copying rsdpv2 to %p\n", target); v2inebda = target; target += v2->length; - target = (grub_uint8_t *) ((((grub_addr_t) target - 1) | 0xf) + 1); + target = (grub_uint8_t *) ALIGN_UP((grub_addr_t) target, 16); v2 = 0; break; } @@ -246,7 +246,7 @@ grub_acpi_create_ebda (void) grub_dprintf ("acpi", "Copying rsdpv1 to %p\n", target); v1inebda = target; target += sizeof (struct grub_acpi_rsdp_v10); - target = (grub_uint8_t *) ((((grub_addr_t) target - 1) | 0xf) + 1); + target = (grub_uint8_t *) ALIGN_UP((grub_addr_t) target, 16); v1 = 0; break; } From b04c6d32ce816c5d8943c767bb4cc7e56aa3c1c5 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sat, 24 Jan 2015 20:45:25 +0100 Subject: [PATCH 183/722] commands/file: Change the confusing loop stop condition. Old condition was used to zero-out header variable on exit of the loop. This is correct but confusing. Replace with in-loop logic. Found by: Coverity Scan. --- grub-core/commands/file.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/grub-core/commands/file.c b/grub-core/commands/file.c index 42d62d479..12fba99e0 100644 --- a/grub-core/commands/file.c +++ b/grub-core/commands/file.c @@ -476,8 +476,8 @@ grub_cmd_file (grub_extcmd_context_t ctxt, int argc, char **args) be at least 12 bytes and aligned on a 4-byte boundary. */ for (header = buffer; ((char *) header <= - (char *) buffer + len - (type == IS_MULTIBOOT2 ? 16 : 12)) - || (header = 0); header += step) + (char *) buffer + len - (type == IS_MULTIBOOT2 ? 16 : 12)); + header += step) { if (header[0] == magic && !(grub_le_to_cpu32 (header[0]) @@ -485,11 +485,12 @@ grub_cmd_file (grub_extcmd_context_t ctxt, int argc, char **args) + grub_le_to_cpu32 (header[2]) + (type == IS_MULTIBOOT2 ? grub_le_to_cpu32 (header[3]) : 0))) - break; + { + ret = 1; + break; + } } - if (header != 0) - ret = 1; grub_free (buffer); break; } From 95a8c9182bc8ab25cbd62424f28a32432f823698 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sat, 24 Jan 2015 20:50:35 +0100 Subject: [PATCH 184/722] commands/fileXX: Fix memory leak. Found by: Coverity Scan. --- grub-core/commands/fileXX.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/grub-core/commands/fileXX.c b/grub-core/commands/fileXX.c index 58e1094c6..7743f3e93 100644 --- a/grub-core/commands/fileXX.c +++ b/grub-core/commands/fileXX.c @@ -40,10 +40,10 @@ grub_file_check_netbsdXX (grub_elf_t elf) return 0; if (grub_file_seek (elf->file, elf->ehdr.ehdrXX.e_shoff) == (grub_off_t) -1) - return 0; + goto fail; if (grub_file_read (elf->file, s0, shsize) != (grub_ssize_t) shsize) - return 0; + goto fail; s = (Elf_Shdr *) ((char *) s0 + elf->ehdr.ehdrXX.e_shstrndx * shentsize); stroff = s->sh_offset; @@ -59,13 +59,16 @@ grub_file_check_netbsdXX (grub_elf_t elf) if (grub_file_read (elf->file, name, sizeof (name)) != (grub_ssize_t) sizeof (name)) { if (grub_errno) - return grub_errno; + goto fail; continue; } if (grub_memcmp (name, ".note.netbsd.ident", sizeof(".note.netbsd.ident")) != 0) continue; + grub_free (s0); return 1; } + fail: + grub_free (s0); return 0; } From 9d999852a223b9b00b5f417cb49d3334773408d8 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sat, 24 Jan 2015 20:52:02 +0100 Subject: [PATCH 185/722] gptsync: Add missing device_close. Found by: Coverity scan --- grub-core/commands/gptsync.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/grub-core/commands/gptsync.c b/grub-core/commands/gptsync.c index 16592e9bb..444e24874 100644 --- a/grub-core/commands/gptsync.c +++ b/grub-core/commands/gptsync.c @@ -235,6 +235,8 @@ grub_cmd_gptsync (grub_command_t cmd __attribute__ ((unused)), return grub_errno; } + grub_device_close (dev); + grub_printf_ (N_("New MBR is written to `%s'\n"), args[0]); return GRUB_ERR_NONE; From 68cf24376c531ee468615a84aa361e2a6e0406a9 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sat, 24 Jan 2015 20:55:06 +0100 Subject: [PATCH 186/722] commands/hdparm: Add missing grub_disk_close. Found by: Coverity scan. --- grub-core/commands/hdparm.c | 1 + 1 file changed, 1 insertion(+) diff --git a/grub-core/commands/hdparm.c b/grub-core/commands/hdparm.c index 3fb08912d..f6b178eae 100644 --- a/grub-core/commands/hdparm.c +++ b/grub-core/commands/hdparm.c @@ -329,6 +329,7 @@ grub_cmd_hdparm (grub_extcmd_context_t ctxt, int argc, char **args) break; } default: + grub_disk_close (disk); return grub_error (GRUB_ERR_IO, "not an ATA device"); } From 12a9c52e516b94888db0a4502946242e3b14709f Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sat, 24 Jan 2015 20:57:26 +0100 Subject: [PATCH 187/722] zfs: Fix disk-matching logic. Reported by: Tim Chase --- grub-core/fs/zfs/zfs.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/grub-core/fs/zfs/zfs.c b/grub-core/fs/zfs/zfs.c index c943b5299..c8c7b97a2 100644 --- a/grub-core/fs/zfs/zfs.c +++ b/grub-core/fs/zfs/zfs.c @@ -252,7 +252,6 @@ struct grub_zfs_data uberblock_t current_uberblock; - int mounted; grub_uint64_t guid; }; @@ -957,7 +956,7 @@ nvpair_value (const char *nvp,char **val, static grub_err_t check_pool_label (struct grub_zfs_data *data, struct grub_zfs_device_desc *diskdesc, - int *inserted) + int *inserted, int original) { grub_uint64_t pool_state, txg = 0; char *nvlist,*features; @@ -1081,11 +1080,12 @@ check_pool_label (struct grub_zfs_data *data, grub_dprintf ("zfs", "check 11 passed\n"); - if (data->mounted && data->guid != poolguid) - return grub_error (GRUB_ERR_BAD_FS, "another zpool"); - else + if (original) data->guid = poolguid; + if (data->guid != poolguid) + return grub_error (GRUB_ERR_BAD_FS, "another zpool"); + { char *nv; nv = grub_zfs_nvlist_lookup_nvlist (nvlist, ZPOOL_CONFIG_VDEV_TREE); @@ -1186,7 +1186,7 @@ scan_disk (grub_device_t dev, struct grub_zfs_data *data, } grub_dprintf ("zfs", "label ok %d\n", label); - err = check_pool_label (data, &desc, inserted); + err = check_pool_label (data, &desc, inserted, original); if (err || !*inserted) { grub_errno = GRUB_ERR_NONE; @@ -3612,8 +3612,6 @@ zfs_mount (grub_device_t dev) ub_endian) >> 63) & 1; grub_free (osp); - data->mounted = 1; - return data; } From f579f097bbf37d0ec23acb1434f2f1a38f266594 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sat, 24 Jan 2015 21:06:23 +0100 Subject: [PATCH 188/722] commands/legacycfg: Fix resource leaks. --- grub-core/commands/legacycfg.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/grub-core/commands/legacycfg.c b/grub-core/commands/legacycfg.c index 2c09fb7dd..d42d7779e 100644 --- a/grub-core/commands/legacycfg.c +++ b/grub-core/commands/legacycfg.c @@ -57,14 +57,20 @@ legacy_file (const char *filename) file = grub_file_open (filename); if (! file) - return grub_errno; + { + grub_free (suffix); + return grub_errno; + } menu = grub_env_get_menu (); if (! menu) { menu = grub_zalloc (sizeof (*menu)); if (! menu) - return grub_errno; + { + grub_free (suffix); + return grub_errno; + } grub_env_set_menu (menu); } @@ -77,6 +83,7 @@ legacy_file (const char *filename) if (!buf && grub_errno) { grub_file_close (file); + grub_free (suffix); return grub_errno; } @@ -173,6 +180,8 @@ legacy_file (const char *filename) if (!args) { grub_file_close (file); + grub_free (suffix); + grub_free (entrysrc); return grub_errno; } args[0] = entryname; @@ -376,6 +385,8 @@ grub_cmd_legacy_kernel (struct grub_command *mycmd __attribute__ ((unused)), if (part && grub_strcmp (part->partmap->name, "msdos") == 0) bsd_slice = part->number; } + if (dev) + grub_device_close (dev); } /* k*BSD didn't really work well with grub-legacy. */ From 09e84f188b6e18acf7ae2d3d82d798d92c35d7a5 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sat, 24 Jan 2015 21:08:50 +0100 Subject: [PATCH 189/722] commands/macbless: Remove incorrect grub_free. Found by: Coverity Scan --- grub-core/commands/macbless.c | 1 - 1 file changed, 1 deletion(-) diff --git a/grub-core/commands/macbless.c b/grub-core/commands/macbless.c index 4724edd77..cf90eea20 100644 --- a/grub-core/commands/macbless.c +++ b/grub-core/commands/macbless.c @@ -203,7 +203,6 @@ grub_cmd_macbless (grub_command_t cmd, int argc, char **args) grub_device_close (dev); grub_free (device_name); - grub_free (path); return grub_error (GRUB_ERR_BAD_ARGUMENT, "invalid argument"); } From e3b3e53f72647fa189ae245d73dc560166bb57d3 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sat, 24 Jan 2015 21:12:02 +0100 Subject: [PATCH 190/722] commands/macbless: Fix potential overflow. Is a minor concern as no such FS would be created under normal circumstances and failure was benign. Found by: Coverity scan. --- grub-core/commands/macbless.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/commands/macbless.c b/grub-core/commands/macbless.c index cf90eea20..f9e01b6f9 100644 --- a/grub-core/commands/macbless.c +++ b/grub-core/commands/macbless.c @@ -106,7 +106,7 @@ grub_mac_bless_inode (grub_device_t dev, grub_uint32_t inode, int is_dir, ablk_size = grub_be_to_cpu32 (volheader.hfs.blksz); ablk_start = grub_be_to_cpu16 (volheader.hfs.first_block); embedded_offset = (ablk_start - + extent_start + + ((grub_uint64_t) extent_start) * (ablk_size >> GRUB_DISK_SECTOR_BITS)); err = From 72bbd8046a55f4a7995535696f375e465ccb0237 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sat, 24 Jan 2015 21:15:14 +0100 Subject: [PATCH 191/722] commands/macbless: Handle device opening errors correctly. Wrong variable was checked for errors. Found by: Coverity scan. --- grub-core/commands/macbless.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/grub-core/commands/macbless.c b/grub-core/commands/macbless.c index f9e01b6f9..18efa1a84 100644 --- a/grub-core/commands/macbless.c +++ b/grub-core/commands/macbless.c @@ -183,7 +183,7 @@ grub_cmd_macbless (grub_command_t cmd, int argc, char **args) { char *device_name; char *path = 0; - grub_device_t dev; + grub_device_t dev = 0; grub_err_t err; if (argc != 1) @@ -197,7 +197,7 @@ grub_cmd_macbless (grub_command_t cmd, int argc, char **args) else path = path + 1; - if (!path || *path == 0 || !device_name) + if (!path || *path == 0 || !dev) { if (dev) grub_device_close (dev); From bd50aa323d30d064563c213ab7ee8b8846981609 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sat, 24 Jan 2015 21:18:36 +0100 Subject: [PATCH 192/722] commands/nativedisk: Add missing device_close. Found by: Coverity scan. --- grub-core/commands/nativedisk.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/grub-core/commands/nativedisk.c b/grub-core/commands/nativedisk.c index 33b6b99ea..b3bc4639c 100644 --- a/grub-core/commands/nativedisk.c +++ b/grub-core/commands/nativedisk.c @@ -57,6 +57,7 @@ get_uuid (const char *name, char **uuid, int getnative) if (!dev->disk) { grub_dprintf ("nativedisk", "Skipping non-disk\n"); + grub_device_close (dev); return 0; } @@ -90,6 +91,7 @@ get_uuid (const char *name, char **uuid, int getnative) case GRUB_DISK_DEVICE_MEMDISK_ID: grub_dprintf ("nativedisk", "Skipping native disk %s\n", dev->disk->name); + grub_device_close (dev); return 0; /* FIXME: those probably need special handling. */ From 4947f11b09184806cbfda7ebb2ae25df25be6693 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sat, 24 Jan 2015 21:22:02 +0100 Subject: [PATCH 193/722] commands/parttool: Add missing device close. Found by: Coverity scan. --- grub-core/commands/parttool.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/grub-core/commands/parttool.c b/grub-core/commands/parttool.c index a47ff0776..d907694dd 100644 --- a/grub-core/commands/parttool.c +++ b/grub-core/commands/parttool.c @@ -243,11 +243,19 @@ grub_cmd_parttool (grub_command_t cmd __attribute__ ((unused)), } if (argc == 1) - return show_help (dev); + { + err = show_help (dev); + grub_device_close (dev); + return err; + } for (i = 1; i < argc; i++) if (grub_strcmp (args[i], "help") == 0) - return show_help (dev); + { + err = show_help (dev); + grub_device_close (dev); + return err; + } parsed = (int *) grub_zalloc (argc * sizeof (int)); From fbae51dcea91bf5b8d1f11a436867f933d370346 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sat, 24 Jan 2015 21:23:25 +0100 Subject: [PATCH 194/722] commands/syslinux: Add missing free. Found by: Coverity scan. --- grub-core/commands/syslinuxcfg.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/grub-core/commands/syslinuxcfg.c b/grub-core/commands/syslinuxcfg.c index 00ae113c5..7be28fada 100644 --- a/grub-core/commands/syslinuxcfg.c +++ b/grub-core/commands/syslinuxcfg.c @@ -119,7 +119,10 @@ syslinux_file (grub_extcmd_context_t ctxt, const char *filename) { menu = grub_zalloc (sizeof (*menu)); if (! menu) - return grub_errno; + { + grub_free (result); + return grub_errno; + } grub_env_set_menu (menu); } From 6079e67926079d4b3ca35aa570eee2c0f4459f04 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sat, 24 Jan 2015 21:25:42 +0100 Subject: [PATCH 195/722] commands/tr: Simplify and fix missing parameter test. Found by: Coverity scan --- grub-core/commands/tr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/commands/tr.c b/grub-core/commands/tr.c index 84ad6ff8f..ef72841a2 100644 --- a/grub-core/commands/tr.c +++ b/grub-core/commands/tr.c @@ -80,7 +80,7 @@ grub_cmd_tr (grub_extcmd_context_t ctxt, int argc, char **args) } else if (argc > 3) return grub_error (GRUB_ERR_BAD_ARGUMENT, "too many parameters"); - if (argc <= 0 && (!s1 || !s2 || !input)) + if (!s1 || !s2 || !input) return grub_error (GRUB_ERR_BAD_ARGUMENT, "missing parameters"); if (grub_strlen (s1) != grub_strlen (s2)) From 37ba761b1cba6e210fa451a7f3dbd6e3dab58a65 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sat, 24 Jan 2015 21:27:10 +0100 Subject: [PATCH 196/722] commands/verify: Fix sha1 context zeroing-out. Current code doesn't zero-out context completely. It's a minor issue really as sha1 init already takes care of initing the context. --- grub-core/commands/verify.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/commands/verify.c b/grub-core/commands/verify.c index d5995766b..656939189 100644 --- a/grub-core/commands/verify.c +++ b/grub-core/commands/verify.c @@ -308,7 +308,7 @@ grub_load_public_key (grub_file_t f) if (!sk) goto fail; - grub_memset (fingerprint_context, 0, sizeof (fingerprint_context)); + grub_memset (fingerprint_context, 0, GRUB_MD_SHA1->contextsize); GRUB_MD_SHA1->init (fingerprint_context); GRUB_MD_SHA1->write (fingerprint_context, "\x99", 1); len_be = grub_cpu_to_be16 (len); From 3b1b39c08234ba856ec89748f379bac7c710e11a Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sat, 24 Jan 2015 21:29:19 +0100 Subject: [PATCH 197/722] commands/wildcard: Add missing free. Found by: Coverity scan. --- grub-core/commands/wildcard.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/grub-core/commands/wildcard.c b/grub-core/commands/wildcard.c index 2807f806b..d207acfed 100644 --- a/grub-core/commands/wildcard.c +++ b/grub-core/commands/wildcard.c @@ -245,7 +245,10 @@ match_devices_iter (const char *name, void *data) t = grub_realloc (ctx->devs, sizeof (char*) * (ctx->ndev + 2)); if (! t) - return 1; + { + grub_free (buffer); + return 1; + } ctx->devs = t; ctx->devs[ctx->ndev++] = buffer; From 7d973359427394a00d1d8778b352b67c9ff486d6 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sat, 24 Jan 2015 21:33:30 +0100 Subject: [PATCH 198/722] disk/AFsplitter: check argument validity before doing any allocs. This avoids possible memory leaks. Found by: Coverity scan. --- grub-core/disk/AFSplitter.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/grub-core/disk/AFSplitter.c b/grub-core/disk/AFSplitter.c index 7e1bd5748..f5a8ddc61 100644 --- a/grub-core/disk/AFSplitter.c +++ b/grub-core/disk/AFSplitter.c @@ -72,13 +72,13 @@ AF_merge (const gcry_md_spec_t * hash, grub_uint8_t * src, grub_uint8_t * dst, grub_size_t i; grub_uint8_t *bufblock; + if (hash->mdlen > GRUB_CRYPTO_MAX_MDLEN || hash->mdlen == 0) + return GPG_ERR_INV_ARG; + bufblock = grub_zalloc (blocksize); if (bufblock == NULL) return GPG_ERR_OUT_OF_MEMORY; - if (hash->mdlen > GRUB_CRYPTO_MAX_MDLEN || hash->mdlen == 0) - return GPG_ERR_INV_ARG; - grub_memset (bufblock, 0, blocksize); for (i = 0; i < blocknumbers - 1; i++) { From 2a8200bba8d6372fdb2ffb38240542795084f7d8 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sat, 24 Jan 2015 21:37:28 +0100 Subject: [PATCH 199/722] disk/ahci: Fix device_map_range argument. Argument is not used on x86, hence it's gone unnoticed. Found by: Coverity scan. --- grub-core/disk/ahci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/disk/ahci.c b/grub-core/disk/ahci.c index 89365cd09..d6bdbddf6 100644 --- a/grub-core/disk/ahci.c +++ b/grub-core/disk/ahci.c @@ -198,7 +198,7 @@ grub_ahci_pciinit (grub_pci_device_t dev, | GRUB_PCI_COMMAND_MEM_ENABLED); hba = grub_pci_device_map_range (dev, bar & GRUB_PCI_ADDR_MEM_MASK, - sizeof (hba)); + sizeof (*hba)); grub_dprintf ("ahci", "dev: %x:%x.%x\n", dev.bus, dev.device, dev.function); grub_dprintf ("ahci", "tfd[0]: %x\n", From 4c7337bfe9082c2a005a10ce6dd98293e707943c Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sat, 24 Jan 2015 21:38:22 +0100 Subject: [PATCH 200/722] disk/cryptodisk: Add missing error check. Found by: Coverity scan. --- grub-core/disk/cryptodisk.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/grub-core/disk/cryptodisk.c b/grub-core/disk/cryptodisk.c index f0e3a900a..376ab8326 100644 --- a/grub-core/disk/cryptodisk.c +++ b/grub-core/disk/cryptodisk.c @@ -372,11 +372,13 @@ grub_cryptodisk_endecrypt (struct grub_cryptodisk *dev, break; case GRUB_CRYPTODISK_MODE_ECB: if (do_encrypt) - grub_crypto_ecb_encrypt (dev->cipher, data + i, data + i, - (1U << dev->log_sector_size)); + err = grub_crypto_ecb_encrypt (dev->cipher, data + i, data + i, + (1U << dev->log_sector_size)); else - grub_crypto_ecb_decrypt (dev->cipher, data + i, data + i, - (1U << dev->log_sector_size)); + err = grub_crypto_ecb_decrypt (dev->cipher, data + i, data + i, + (1U << dev->log_sector_size)); + if (err) + return err; break; default: return GPG_ERR_NOT_IMPLEMENTED; From f2baeb194be2f08e9281115df514cd3ceeba6110 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sat, 24 Jan 2015 21:44:27 +0100 Subject: [PATCH 201/722] disk/diskfilter: Add missing lv presence check. Found by: Coverity scan. --- grub-core/disk/diskfilter.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/disk/diskfilter.c b/grub-core/disk/diskfilter.c index 97ca54666..612484607 100644 --- a/grub-core/disk/diskfilter.c +++ b/grub-core/disk/diskfilter.c @@ -1065,7 +1065,7 @@ grub_diskfilter_make_raid (grub_size_t uuidlen, char *uuid, int nmemb, array->lvs->segments->extent_count = totsize; } - if (array->lvs->segments + if (array->lvs && array->lvs->segments && array->lvs->segments->raid_member_size > disk_size) array->lvs->segments->raid_member_size = disk_size; From 6f43e350ed1d122a35c6b1880f6e1756455f0a6c Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sat, 24 Jan 2015 21:46:23 +0100 Subject: [PATCH 202/722] disk/geli: Add missing seek success check. Found by: Coverity scan. --- grub-core/disk/geli.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/grub-core/disk/geli.c b/grub-core/disk/geli.c index 4ed07bb91..bf73fbde8 100644 --- a/grub-core/disk/geli.c +++ b/grub-core/disk/geli.c @@ -212,7 +212,8 @@ grub_util_get_geli_uuid (const char *dev) s = grub_util_get_fd_size (fd, dev, &log_secsize); s >>= log_secsize; - grub_util_fd_seek (fd, (s << log_secsize) - 512); + if (grub_util_fd_seek (fd, (s << log_secsize) - 512) < 0) + grub_util_error ("%s", _("couldn't read ELI metadata")); uuid = xmalloc (GRUB_MD_SHA256->mdlen * 2 + 1); if (grub_util_fd_read (fd, (void *) &hdr, 512) < 0) From 7656b72b17c3bf12a3e2173fc04aebf67b286983 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sat, 24 Jan 2015 21:47:51 +0100 Subject: [PATCH 203/722] disk/geli: Add missing free. Found by: Coverity scan. --- grub-core/disk/geli.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/grub-core/disk/geli.c b/grub-core/disk/geli.c index bf73fbde8..e9d23299a 100644 --- a/grub-core/disk/geli.c +++ b/grub-core/disk/geli.c @@ -232,7 +232,10 @@ grub_util_get_geli_uuid (const char *dev) err = make_uuid ((void *) &hdr, uuid); if (err) - return NULL; + { + grub_free (uuid); + return NULL; + } return uuid; } From d1130afa5f22e4fee75ab55f11e16e0fbd98597d Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sat, 24 Jan 2015 21:50:30 +0100 Subject: [PATCH 204/722] biosdisk: Add missing cast. Found by: Coverity scan. --- grub-core/disk/i386/pc/biosdisk.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/grub-core/disk/i386/pc/biosdisk.c b/grub-core/disk/i386/pc/biosdisk.c index 26a4973ad..f0aadd111 100644 --- a/grub-core/disk/i386/pc/biosdisk.c +++ b/grub-core/disk/i386/pc/biosdisk.c @@ -382,7 +382,8 @@ grub_biosdisk_open (const char *name, grub_disk_t disk) /* Some buggy BIOSes doesn't return the total sectors correctly but returns zero. So if it is zero, compute it by C/H/S returned by the LBA BIOS call. */ - total_sectors = drp->cylinders * drp->heads * drp->sectors; + total_sectors = ((grub_uint64_t) drp->cylinders) + * drp->heads * drp->sectors; if (drp->bytes_per_sector && !(drp->bytes_per_sector & (drp->bytes_per_sector - 1)) && drp->bytes_per_sector >= 512 @@ -425,7 +426,8 @@ grub_biosdisk_open (const char *name, grub_disk_t disk) data->heads = 255; if (! total_sectors) - total_sectors = data->cylinders * data->heads * data->sectors; + total_sectors = ((grub_uint64_t) data->cylinders) + * data->heads * data->sectors; } disk->total_sectors = total_sectors; From dd430afbf874f6212742c079d72b4b9e959e0542 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sat, 24 Jan 2015 21:55:18 +0100 Subject: [PATCH 205/722] font: Add missing free. Found by: Coverity Scan. --- grub-core/font/font.c | 1 + 1 file changed, 1 insertion(+) diff --git a/grub-core/font/font.c b/grub-core/font/font.c index 14b93e172..607964b90 100644 --- a/grub-core/font/font.c +++ b/grub-core/font/font.c @@ -777,6 +777,7 @@ grub_font_get_glyph_internal (grub_font_t font, grub_uint32_t code) if (grub_file_read (font->file, glyph->bitmap, len) != len) { remove_font (font); + grub_free (glyph); return 0; } } From b6f21bcb98f03d61087b4423261bda5d6a58fb1f Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sun, 25 Jan 2015 00:00:49 +0100 Subject: [PATCH 206/722] fs/cbfs: Add missing free. Found by: Coverity scan. --- grub-core/fs/cbfs.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/grub-core/fs/cbfs.c b/grub-core/fs/cbfs.c index 35750a0e4..4ddd6832f 100644 --- a/grub-core/fs/cbfs.c +++ b/grub-core/fs/cbfs.c @@ -144,7 +144,7 @@ static struct grub_archelp_data * grub_cbfs_mount (grub_disk_t disk) { struct cbfs_file hd; - struct grub_archelp_data *data; + struct grub_archelp_data *data = NULL; grub_uint32_t ptr; grub_off_t header_off; struct cbfs_header head; @@ -196,6 +196,7 @@ grub_cbfs_mount (grub_disk_t disk) return data; fail: + grub_free (data); grub_error (GRUB_ERR_BAD_FS, "not a cbfs filesystem"); return 0; } From faad548ce3b906535acaeff95777b46836b817e6 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sun, 25 Jan 2015 00:11:59 +0100 Subject: [PATCH 207/722] fs/cpio_common: Add a sanity check on namesize. Found by: Coverity scan. --- grub-core/fs/cpio_common.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/grub-core/fs/cpio_common.c b/grub-core/fs/cpio_common.c index b0ae9f445..20230a741 100644 --- a/grub-core/fs/cpio_common.c +++ b/grub-core/fs/cpio_common.c @@ -61,6 +61,14 @@ grub_cpio_find_file (struct grub_archelp_data *data, char **name, modeval = read_number (hd.mode, ARRAY_SIZE (hd.mode)); namesize = read_number (hd.namesize, ARRAY_SIZE (hd.namesize)); + /* Don't allow negative numbers. */ + if (namesize >= 0x80000000) + { + /* Probably a corruption, don't attempt to recover. */ + *mode = GRUB_ARCHELP_ATTR_END; + return GRUB_ERR_NONE; + } + if (mode) *mode = modeval; From 83543f937a3525ef577c5a6333cb6791aadcee3d Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sun, 25 Jan 2015 01:27:44 +0100 Subject: [PATCH 208/722] fs/fat: Fix codepath to properly free on error. Found by: Coverity scan. --- grub-core/fs/fat.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/fs/fat.c b/grub-core/fs/fat.c index 79fe864d7..71537ff44 100644 --- a/grub-core/fs/fat.c +++ b/grub-core/fs/fat.c @@ -1136,7 +1136,7 @@ grub_fat_label (grub_device_t device, char **label) if (! (data->attr & GRUB_FAT_ATTR_DIRECTORY)) { grub_error (GRUB_ERR_BAD_FILE_TYPE, N_("not a directory")); - return 0; + goto fail; } err = grub_fat_iterate_init (&ctxt); From 4387ca78f0aada6ce04e4132e50f6b73fa60671f Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sun, 25 Jan 2015 01:28:17 +0100 Subject: [PATCH 209/722] fs/hfs/hfs_open: Check that mount succeeded. Found by: Coverity scan. --- grub-core/fs/hfs.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/grub-core/fs/hfs.c b/grub-core/fs/hfs.c index f46f77a94..ab472f4b0 100644 --- a/grub-core/fs/hfs.c +++ b/grub-core/fs/hfs.c @@ -1306,6 +1306,12 @@ grub_hfs_open (struct grub_file *file, const char *name) data = grub_hfs_mount (file->device->disk); + if (!data) + { + grub_dl_unref (my_mod); + return grub_errno; + } + if (grub_hfs_find_dir (data, name, &frec, 0)) { grub_free (data); From d0af2156c3b3e900956651523da17afff4969815 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sun, 25 Jan 2015 11:32:29 +0100 Subject: [PATCH 210/722] fs/hfs: Add pointer sanity checks. Found by: Coverity scan. --- grub-core/fs/hfs.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/grub-core/fs/hfs.c b/grub-core/fs/hfs.c index ab472f4b0..06cf0c7ab 100644 --- a/grub-core/fs/hfs.c +++ b/grub-core/fs/hfs.c @@ -692,6 +692,7 @@ grub_hfs_iterate_records (struct grub_hfs_data *data, int type, int idx, int i; struct grub_hfs_extent *dat; int blk; + grub_uint16_t reccnt; dat = (struct grub_hfs_extent *) (type == 0 ? (&data->sblock.catalog_recs) @@ -710,8 +711,12 @@ grub_hfs_iterate_records (struct grub_hfs_data *data, int type, int idx, return grub_errno; } + reccnt = grub_be_to_cpu16 (node->node.reccnt); + if (reccnt > (nodesize >> 1)) + reccnt = (nodesize >> 1); + /* Iterate over all records in this node. */ - for (i = 0; i < grub_be_to_cpu16 (node->node.reccnt); i++) + for (i = 0; i < reccnt; i++) { int pos = (nodesize >> 1) - 1 - i; struct pointer @@ -719,16 +724,19 @@ grub_hfs_iterate_records (struct grub_hfs_data *data, int type, int idx, grub_uint8_t keylen; grub_uint8_t key; } GRUB_PACKED *pnt; - pnt = (struct pointer *) (grub_be_to_cpu16 (node->offsets[pos]) - + node->rawnode); + grub_uint16_t off = grub_be_to_cpu16 (node->offsets[pos]); + if (off > nodesize - sizeof(*pnt)) + continue; + pnt = (struct pointer *) (off + node->rawnode); + if (nodesize < (grub_size_t) off + pnt->keylen + 1) + continue; struct grub_hfs_record rec = { &pnt->key, pnt->keylen, &pnt->key + pnt->keylen +(pnt->keylen + 1) % 2, - nodesize - grub_be_to_cpu16 (node->offsets[pos]) - - pnt->keylen - 1 + nodesize - off - pnt->keylen - 1 }; if (node_hook (&node->node, &rec, hook_arg)) From fb66b512fa241c98b44ce6032e1d285d9d9f9aa3 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sun, 25 Jan 2015 16:36:30 +0300 Subject: [PATCH 211/722] commands/fileXX: Fix remaining memory leak. Found by: Coverity Scan. --- grub-core/commands/fileXX.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/commands/fileXX.c b/grub-core/commands/fileXX.c index 7743f3e93..c17d26ce6 100644 --- a/grub-core/commands/fileXX.c +++ b/grub-core/commands/fileXX.c @@ -54,7 +54,7 @@ grub_file_check_netbsdXX (grub_elf_t elf) char name[sizeof(".note.netbsd.ident")]; grub_memset (name, 0, sizeof (name)); if (grub_file_seek (elf->file, stroff + s->sh_name) == (grub_off_t) -1) - return grub_errno; + goto fail; if (grub_file_read (elf->file, name, sizeof (name)) != (grub_ssize_t) sizeof (name)) { From ac602ce7005090a34e021f736a9ad3ac033a4cc8 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sun, 25 Jan 2015 13:19:58 +0100 Subject: [PATCH 212/722] grub_iso9660_read: Explicitly check read_node return value. Not really needed as grub_errno is already checked but is nicer. Found by: Coverity scan. --- grub-core/fs/iso9660.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/grub-core/fs/iso9660.c b/grub-core/fs/iso9660.c index 6a6677337..67a67cf40 100644 --- a/grub-core/fs/iso9660.c +++ b/grub-core/fs/iso9660.c @@ -959,14 +959,15 @@ grub_iso9660_read (grub_file_t file, char *buf, grub_size_t len) { struct grub_iso9660_data *data = (struct grub_iso9660_data *) file->data; + grub_err_t err; /* XXX: The file is stored in as a single extent. */ data->disk->read_hook = file->read_hook; data->disk->read_hook_data = file->read_hook_data; - read_node (data->node, file->offset, len, buf); + err = read_node (data->node, file->offset, len, buf); data->disk->read_hook = NULL; - if (grub_errno) + if (err || grub_errno) return -1; return len; From ca793e9c058dd1d08780e176ce5bcdeefa47a6be Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sun, 25 Jan 2015 13:21:32 +0100 Subject: [PATCH 213/722] fs/minix: Fix sector promotion to 64-bit. While on it make GRUB_MINIX_ZONE2SECT into function. Found by: Coverity scan --- grub-core/fs/minix.c | 39 +++++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/grub-core/fs/minix.c b/grub-core/fs/minix.c index 90ddd34f1..d451b3426 100644 --- a/grub-core/fs/minix.c +++ b/grub-core/fs/minix.c @@ -82,17 +82,6 @@ typedef grub_uint16_t grub_minix_ino_t; #define GRUB_MINIX_INODE_DINDIR_ZONE(data) (grub_minix_to_cpu_n \ (data->inode.double_indir_zone)) -#ifndef MODE_MINIX3 -#define GRUB_MINIX_LOG2_ZONESZ (GRUB_MINIX_LOG2_BSIZE \ - + grub_minix_to_cpu16 (data->sblock.log2_zone_size)) -#endif - -#ifdef MODE_MINIX3 -#define GRUB_MINIX_ZONE2SECT(zone) ((zone) * data->block_size) -#else -#define GRUB_MINIX_ZONE2SECT(zone) ((zone) << GRUB_MINIX_LOG2_ZONESZ) -#endif - #ifdef MODE_MINIX3 struct grub_minix_sblock @@ -182,15 +171,32 @@ static grub_dl_t my_mod; static grub_err_t grub_minix_find_file (struct grub_minix_data *data, const char *path); +#ifdef MODE_MINIX3 +static inline grub_disk_addr_t +grub_minix_zone2sect (struct grub_minix_data *data, grub_minix_uintn_t zone) +{ + return ((grub_disk_addr_t) zone) * data->block_size; +} +#else +static inline grub_disk_addr_t +grub_minix_zone2sect (struct grub_minix_data *data, grub_minix_uintn_t zone) +{ + int log2_zonesz = (GRUB_MINIX_LOG2_BSIZE + + grub_minix_to_cpu16 (data->sblock.log2_zone_size)); + return (((grub_disk_addr_t) zone) << log2_zonesz); +} +#endif + + /* Read the block pointer in ZONE, on the offset NUM. */ static grub_minix_uintn_t -grub_get_indir (struct grub_minix_data *data, +grub_get_indir (struct grub_minix_data *data, grub_minix_uintn_t zone, grub_minix_uintn_t num) { grub_minix_uintn_t indirn; grub_disk_read (data->disk, - GRUB_MINIX_ZONE2SECT(zone), + grub_minix_zone2sect(data, zone), sizeof (grub_minix_uintn_t) * num, sizeof (grub_minix_uintn_t), (char *) &indirn); return grub_minix_to_cpu_n (indirn); @@ -281,7 +287,7 @@ grub_minix_read_file (struct grub_minix_data *data, for (i = posblock; i < blockcnt; i++) { - grub_disk_addr_t blknr; + grub_minix_uintn_t blknr; grub_uint64_t blockend = data->block_size << GRUB_DISK_SECTOR_BITS; grub_off_t skipfirst = 0; @@ -310,7 +316,7 @@ grub_minix_read_file (struct grub_minix_data *data, data->disk->read_hook = read_hook; data->disk->read_hook_data = read_hook_data; grub_disk_read (data->disk, - GRUB_MINIX_ZONE2SECT(blknr), + grub_minix_zone2sect(data, blknr), skipfirst, blockend, buf); data->disk->read_hook = 0; if (grub_errno) @@ -336,7 +342,8 @@ grub_minix_read_inode (struct grub_minix_data *data, grub_minix_ino_t ino) /* The first inode in minix is inode 1. */ ino--; - block = GRUB_MINIX_ZONE2SECT (2 + grub_minix_to_cpu16 (sblock->inode_bmap_size) + block = grub_minix_zone2sect (data, + 2 + grub_minix_to_cpu16 (sblock->inode_bmap_size) + grub_minix_to_cpu16 (sblock->zone_bmap_size)); block += ino / (GRUB_DISK_SECTOR_SIZE / sizeof (struct grub_minix_inode)); int offs = (ino % (GRUB_DISK_SECTOR_SIZE From bc0ecd7104b3420964364b7a01b7dd7141081b9b Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sun, 25 Jan 2015 13:22:24 +0100 Subject: [PATCH 214/722] fs/ntfs: Add missing free. Found by: Coverity scan. --- grub-core/fs/ntfs.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/grub-core/fs/ntfs.c b/grub-core/fs/ntfs.c index d3a91f5d7..2cbcb0b78 100644 --- a/grub-core/fs/ntfs.c +++ b/grub-core/fs/ntfs.c @@ -618,7 +618,10 @@ list_file (struct grub_ntfs_file *diro, grub_uint8_t *pos, ustr = get_utf8 (np, ns); if (ustr == NULL) - return 0; + { + grub_free (fdiro); + return 0; + } if (namespace) type |= GRUB_FSHELP_CASE_INSENSITIVE; From 157f9a9cca0990bf213e5041daaf4641c1764e09 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sun, 25 Jan 2015 13:28:50 +0100 Subject: [PATCH 215/722] fs/ntfs: Add sizes sanity checks. Found by: Coverity scan. --- grub-core/fs/ntfs.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/grub-core/fs/ntfs.c b/grub-core/fs/ntfs.c index 2cbcb0b78..6f8468862 100644 --- a/grub-core/fs/ntfs.c +++ b/grub-core/fs/ntfs.c @@ -920,12 +920,16 @@ grub_ntfs_mount (grub_disk_t disk) if (bpb.clusters_per_mft > 0) data->mft_size = ((grub_disk_addr_t) bpb.clusters_per_mft) << data->log_spc; + else if (-bpb.clusters_per_mft < GRUB_NTFS_BLK_SHR || -bpb.clusters_per_mft >= 31) + goto fail; else data->mft_size = 1ULL << (-bpb.clusters_per_mft - GRUB_NTFS_BLK_SHR); if (bpb.clusters_per_index > 0) data->idx_size = (((grub_disk_addr_t) bpb.clusters_per_index) << data->log_spc); + else if (-bpb.clusters_per_index < GRUB_NTFS_BLK_SHR || -bpb.clusters_per_index >= 31) + goto fail; else data->idx_size = 1ULL << (-bpb.clusters_per_index - GRUB_NTFS_BLK_SHR); From 8c1d08668974cc59f00e0cbc1c37c2f03e1a132e Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sun, 25 Jan 2015 13:29:26 +0100 Subject: [PATCH 216/722] fs/reiserfs: Fix sector count overflow. Found by: Coverity scan. --- grub-core/fs/reiserfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/fs/reiserfs.c b/grub-core/fs/reiserfs.c index de3d4fa3c..b78166554 100644 --- a/grub-core/fs/reiserfs.c +++ b/grub-core/fs/reiserfs.c @@ -1090,7 +1090,7 @@ grub_reiserfs_read_real (struct grub_fshelp_node *node, switch (found.type) { case GRUB_REISERFS_DIRECT: - block = found.block_number * (block_size >> GRUB_DISK_SECTOR_BITS); + block = ((grub_disk_addr_t) found.block_number) * (block_size >> GRUB_DISK_SECTOR_BITS); grub_dprintf ("reiserfs_blocktype", "D: %u\n", (unsigned) block); if (initial_position < current_position + item_size) { From 66baeffc0f6373be4745a8f1941c46fc5e104392 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sun, 25 Jan 2015 13:33:03 +0100 Subject: [PATCH 217/722] fs/sfs: Fix error check and add sanity check. Found by: Coverity scan. --- grub-core/fs/sfs.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/grub-core/fs/sfs.c b/grub-core/fs/sfs.c index 6c8215048..57b8d8da6 100644 --- a/grub-core/fs/sfs.c +++ b/grub-core/fs/sfs.c @@ -173,10 +173,11 @@ grub_sfs_read_extent (struct grub_sfs_data *data, unsigned int block, struct grub_sfs_btree *tree; int i; grub_uint32_t next; + grub_size_t blocksize = GRUB_DISK_SECTOR_SIZE << data->log_blocksize; - treeblock = grub_malloc (GRUB_DISK_SECTOR_SIZE << data->log_blocksize); - if (!block) - return 0; + treeblock = grub_malloc (blocksize); + if (!treeblock) + return grub_errno; next = grub_be_to_cpu32 (data->rblock.btree); tree = (struct grub_sfs_btree *) treeblock; @@ -184,17 +185,21 @@ grub_sfs_read_extent (struct grub_sfs_data *data, unsigned int block, /* Handle this level in the btree. */ do { + grub_uint16_t nnodes; grub_disk_read (data->disk, ((grub_disk_addr_t) next) << data->log_blocksize, - 0, GRUB_DISK_SECTOR_SIZE << data->log_blocksize, - treeblock); + 0, blocksize, treeblock); if (grub_errno) { grub_free (treeblock); return grub_errno; } - for (i = grub_be_to_cpu16 (tree->nodes) - 1; i >= 0; i--) + nnodes = grub_be_to_cpu16 (tree->nodes); + if (nnodes * (grub_uint32_t) (tree)->nodesize > blocksize) + break; + + for (i = (int) nnodes - 1; i >= 0; i--) { #define EXTNODE(tree, index) \ From fc7a64bc5aa2ab9b0a9475692c6f392681525b93 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 26 Jan 2015 09:35:44 +0100 Subject: [PATCH 218/722] configure.ac: Always add -D_FILE_OFFSET_BITS=64. --- configure.ac | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index b734dd0ba..a3bca06ca 100644 --- a/configure.ac +++ b/configure.ac @@ -354,6 +354,9 @@ if test x"$target_cpu-$platform" = xsparc64-emu ; then HOST_CFLAGS="$HOST_CFLAGS -m64" fi +CPPFLAGS="$CPPFLAGS -D_FILE_OFFSET_BITS=64" +HOST_CPPFLAGS="$HOST_CPPFLAGS -D_FILE_OFFSET_BITS=64" + AC_C_BIGENDIAN AC_CHECK_SIZEOF(void *) AC_CHECK_SIZEOF(long) @@ -1477,7 +1480,7 @@ fi if test x"$grub_mount_excuse" = x ; then # Check for fuse headers. SAVED_CPPFLAGS="$CPPFLAGS" - CPPFLAGS="$CPPFLAGS -D_FILE_OFFSET_BITS=64 -DFUSE_USE_VERSION=26" + CPPFLAGS="$CPPFLAGS -DFUSE_USE_VERSION=26" AC_CHECK_HEADERS([fuse/fuse.h], [], [grub_mount_excuse=["need FUSE headers"]]) CPPFLAGS="$SAVED_CPPFLAGS" From a4e33a8b180a289ee48ab22c63e0f836adb2ade7 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 26 Jan 2015 09:36:19 +0100 Subject: [PATCH 219/722] fs/ufs: Add missing error check. Found by: Coverity scan. --- grub-core/fs/ufs.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/grub-core/fs/ufs.c b/grub-core/fs/ufs.c index f560ad380..0619d6e32 100644 --- a/grub-core/fs/ufs.c +++ b/grub-core/fs/ufs.c @@ -465,7 +465,13 @@ grub_ufs_lookup_symlink (struct grub_ufs_data *data, int ino) && INODE_SIZE (data) <= sizeof (data->inode.symlink)) grub_strcpy (symlink, (char *) data->inode.symlink); else - grub_ufs_read_file (data, 0, 0, 0, sz, symlink); + { + if (grub_ufs_read_file (data, 0, 0, 0, sz, symlink) < 0) + { + grub_free(symlink); + return grub_errno; + } + } symlink[sz] = '\0'; /* The symlink is an absolute path, go back to the root inode. */ From bd74a925e5026cd0368b3455df8ffcf0b1b4150b Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 26 Jan 2015 09:37:01 +0100 Subject: [PATCH 220/722] gfxmenu/icon_manager: Fix null pointer dereference. Found by: Coverity scan. --- grub-core/gfxmenu/icon_manager.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/grub-core/gfxmenu/icon_manager.c b/grub-core/gfxmenu/icon_manager.c index ff49ab0e0..1894682ef 100644 --- a/grub-core/gfxmenu/icon_manager.c +++ b/grub-core/gfxmenu/icon_manager.c @@ -106,8 +106,10 @@ grub_gfxmenu_icon_manager_set_theme_path (grub_gfxmenu_icon_manager_t mgr, const char *path) { /* Clear the cache if the theme path has changed. */ - if (((mgr->theme_path == 0) != (path == 0)) - || (grub_strcmp (mgr->theme_path, path) != 0)) + if (mgr->theme_path == 0 && path == 0) + return; + if (mgr->theme_path == 0 || path == 0 + || grub_strcmp (mgr->theme_path, path) != 0) grub_gfxmenu_icon_manager_clear_cache (mgr); grub_free (mgr->theme_path); From af0be976bf5bb45c0d5d5290ca0f2a83fb380785 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 26 Jan 2015 09:37:39 +0100 Subject: [PATCH 221/722] gfxmenu/theme_loader: Add missing allos error check. Found by: Coverity scan. --- grub-core/gfxmenu/theme_loader.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/grub-core/gfxmenu/theme_loader.c b/grub-core/gfxmenu/theme_loader.c index 8a7945816..1a6ed1d25 100644 --- a/grub-core/gfxmenu/theme_loader.c +++ b/grub-core/gfxmenu/theme_loader.c @@ -774,6 +774,8 @@ grub_gfxmenu_view_load_theme (grub_gfxmenu_view_t view, const char *theme_path) view->canvas->component.ops->destroy (view->canvas); view->canvas = grub_gui_canvas_new (); + if (!view->canvas) + goto fail; ((grub_gui_component_t) view->canvas) ->ops->set_bounds ((grub_gui_component_t) view->canvas, &view->screen); From 21f22c71077a4d460049107a946ceca8b514ffb3 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 26 Jan 2015 09:38:11 +0100 Subject: [PATCH 222/722] i386/pc/mmap: Fix memset size. Found by: Coverity scan. --- grub-core/kern/i386/pc/mmap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/kern/i386/pc/mmap.c b/grub-core/kern/i386/pc/mmap.c index f1375f3e1..c0c3c3585 100644 --- a/grub-core/kern/i386/pc/mmap.c +++ b/grub-core/kern/i386/pc/mmap.c @@ -148,7 +148,7 @@ grub_machine_mmap_iterate (grub_memory_hook_t hook, void *hook_data) while (1) { - grub_memset (entry, 0, sizeof (entry)); + grub_memset (entry, 0, sizeof (*entry)); cont = grub_get_mmap_entry (entry, cont); From aa64393144f0a805b191bc2c45b84606b03706a0 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 26 Jan 2015 09:40:42 +0100 Subject: [PATCH 223/722] lib/syslinux_parse: Add missing alloc check. Found by: Coverity scan. --- grub-core/lib/syslinux_parse.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/grub-core/lib/syslinux_parse.c b/grub-core/lib/syslinux_parse.c index 241cefe69..2f1f1a5a2 100644 --- a/grub-core/lib/syslinux_parse.c +++ b/grub-core/lib/syslinux_parse.c @@ -649,6 +649,8 @@ helptext (const char *line, grub_file_t file, struct syslinux_menu *menu) grub_size_t helplen, alloclen = 0; help = grub_strdup (line); + if (!help) + return grub_errno; helplen = grub_strlen (line); while ((grub_free (buf), buf = grub_file_getline (file))) { From ca7c1fd6f377bebf300d0bfcb61253c34fefc861 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 26 Jan 2015 09:41:24 +0100 Subject: [PATCH 224/722] lib/syslinux_parse: Fix memory leak. Found by: Coveriy scan. --- grub-core/lib/syslinux_parse.c | 1 + 1 file changed, 1 insertion(+) diff --git a/grub-core/lib/syslinux_parse.c b/grub-core/lib/syslinux_parse.c index 2f1f1a5a2..1927c4fda 100644 --- a/grub-core/lib/syslinux_parse.c +++ b/grub-core/lib/syslinux_parse.c @@ -684,6 +684,7 @@ helptext (const char *line, grub_file_t file, struct syslinux_menu *menu) } grub_free (buf); + grub_free (help); return grub_errno; } From 49978c5c4f5a88a8065042133e5d4b7e3c472eaa Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 26 Jan 2015 09:42:04 +0100 Subject: [PATCH 225/722] lib/syslinux_parse: Add missing error check. Found by: Coverity scan. --- grub-core/lib/syslinux_parse.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/grub-core/lib/syslinux_parse.c b/grub-core/lib/syslinux_parse.c index 1927c4fda..f6053267f 100644 --- a/grub-core/lib/syslinux_parse.c +++ b/grub-core/lib/syslinux_parse.c @@ -846,7 +846,12 @@ write_entry (struct output_buffer *outbuf, { grub_err_t err; if (curentry->comments) - print (outbuf, curentry->comments, grub_strlen (curentry->comments)); + { + err = print (outbuf, curentry->comments, + grub_strlen (curentry->comments)); + if (err) + return err; + } { struct syslinux_say *say; for (say = curentry->say; say && say->next; say = say->next); From 1e0d71837124add3adb810ebbb13607dac037635 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 26 Jan 2015 09:42:42 +0100 Subject: [PATCH 226/722] bsd: Add missing null-pointer check. Found by: Coverity scan. --- grub-core/loader/i386/bsd.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/grub-core/loader/i386/bsd.c b/grub-core/loader/i386/bsd.c index 8f691e0e2..bc377b362 100644 --- a/grub-core/loader/i386/bsd.c +++ b/grub-core/loader/i386/bsd.c @@ -234,7 +234,8 @@ grub_bsd_add_meta_ptr (grub_uint32_t type, void **ptr, grub_uint32_t len) { struct bsd_tag *p; for (p = tags; - p->type != (FREEBSD_MODINFO_METADATA | FREEBSD_MODINFOMD_KERNEND); + p && p->type != (FREEBSD_MODINFO_METADATA + | FREEBSD_MODINFOMD_KERNEND); p = p->next); if (p) From ef02b4ca933fd4c215e169a23b2b069aab712677 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 26 Jan 2015 09:43:52 +0100 Subject: [PATCH 227/722] multiboot: Simplify to avoid confusing assignment. Found by: Coverity scan. --- grub-core/loader/i386/multiboot_mbi.c | 29 +++++++++++++++--------- grub-core/loader/multiboot_mbi2.c | 32 +++++++++++++++++---------- 2 files changed, 39 insertions(+), 22 deletions(-) diff --git a/grub-core/loader/i386/multiboot_mbi.c b/grub-core/loader/i386/multiboot_mbi.c index f10c087f7..956d0e37b 100644 --- a/grub-core/loader/i386/multiboot_mbi.c +++ b/grub-core/loader/i386/multiboot_mbi.c @@ -121,6 +121,24 @@ load_kernel (grub_file_t file, const char *filename, return grub_multiboot_load_elf (file, filename, buffer); } +static struct multiboot_header * +find_header (char *buffer, grub_ssize_t len) +{ + struct multiboot_header *header; + + /* Look for the multiboot header in the buffer. The header should + be at least 12 bytes and aligned on a 4-byte boundary. */ + for (header = (struct multiboot_header *) buffer; + ((char *) header <= buffer + len - 12); + header = (struct multiboot_header *) ((char *) header + MULTIBOOT_HEADER_ALIGN)) + { + if (header->magic == MULTIBOOT_HEADER_MAGIC + && !(header->magic + header->flags + header->checksum)) + return header; + } + return NULL; +} + grub_err_t grub_multiboot_load (grub_file_t file, const char *filename) { @@ -143,16 +161,7 @@ grub_multiboot_load (grub_file_t file, const char *filename) return grub_errno; } - /* Look for the multiboot header in the buffer. The header should - be at least 12 bytes and aligned on a 4-byte boundary. */ - for (header = (struct multiboot_header *) buffer; - ((char *) header <= buffer + len - 12) || (header = 0); - header = (struct multiboot_header *) ((char *) header + MULTIBOOT_HEADER_ALIGN)) - { - if (header->magic == MULTIBOOT_HEADER_MAGIC - && !(header->magic + header->flags + header->checksum)) - break; - } + header = find_header (buffer, len); if (header == 0) { diff --git a/grub-core/loader/multiboot_mbi2.c b/grub-core/loader/multiboot_mbi2.c index 83e8919fa..6f74aeef7 100644 --- a/grub-core/loader/multiboot_mbi2.c +++ b/grub-core/loader/multiboot_mbi2.c @@ -79,6 +79,25 @@ grub_multiboot_add_elfsyms (grub_size_t num, grub_size_t entsize, elf_sections = data; } +static struct multiboot_header * +find_header (grub_properly_aligned_t *buffer, grub_ssize_t len) +{ + struct multiboot_header *header; + /* Look for the multiboot header in the buffer. The header should + be at least 12 bytes and aligned on a 4-byte boundary. */ + for (header = (struct multiboot_header *) buffer; + ((char *) header <= (char *) buffer + len - 12); + header = (struct multiboot_header *) ((grub_uint32_t *) header + MULTIBOOT_HEADER_ALIGN / 4)) + { + if (header->magic == MULTIBOOT_HEADER_MAGIC + && !(header->magic + header->architecture + + header->header_length + header->checksum) + && header->architecture == MULTIBOOT_ARCHITECTURE_CURRENT) + return header; + } + return NULL; +} + grub_err_t grub_multiboot_load (grub_file_t file, const char *filename) { @@ -107,18 +126,7 @@ grub_multiboot_load (grub_file_t file, const char *filename) COMPILE_TIME_ASSERT (MULTIBOOT_HEADER_ALIGN % 4 == 0); - /* Look for the multiboot header in the buffer. The header should - be at least 12 bytes and aligned on a 4-byte boundary. */ - for (header = (struct multiboot_header *) buffer; - ((char *) header <= (char *) buffer + len - 12) || (header = 0); - header = (struct multiboot_header *) ((grub_uint32_t *) header + MULTIBOOT_HEADER_ALIGN / 4)) - { - if (header->magic == MULTIBOOT_HEADER_MAGIC - && !(header->magic + header->architecture - + header->header_length + header->checksum) - && header->architecture == MULTIBOOT_ARCHITECTURE_CURRENT) - break; - } + header = find_header (buffer, len); if (header == 0) { From e12c3bed90221fad33c4b08ce208745dd65bd782 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 26 Jan 2015 09:44:33 +0100 Subject: [PATCH 228/722] plan9: Add missing grub_device_close. Found by: Coverity scan. --- grub-core/loader/i386/pc/plan9.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/grub-core/loader/i386/pc/plan9.c b/grub-core/loader/i386/pc/plan9.c index 0d10b1c24..814a49d50 100644 --- a/grub-core/loader/i386/pc/plan9.c +++ b/grub-core/loader/i386/pc/plan9.c @@ -342,6 +342,7 @@ fill_disk (const char *name, void *data) if (!plan9name) { grub_print_error (); + grub_device_close (dev); return 0; } if (grub_extend_alloc (fill_ctx->pmapptr + grub_strlen (plan9name) @@ -349,6 +350,7 @@ fill_disk (const char *name, void *data) &fill_ctx->pmap)) { grub_free (plan9name); + grub_device_close (dev); return 1; } grub_strcpy (fill_ctx->pmap + fill_ctx->pmapptr, plan9name); @@ -366,12 +368,19 @@ fill_disk (const char *name, void *data) fill_ctx->noslash = 1; grub_memset (fill_ctx->prefixescnt, 0, sizeof (fill_ctx->prefixescnt)); if (grub_partition_iterate (dev->disk, fill_partition, fill_ctx)) - return 1; + { + grub_device_close (dev); + return 1; + } if (grub_extend_alloc (fill_ctx->pmapptr + 1, &fill_ctx->pmapalloc, &fill_ctx->pmap)) - return 1; + { + grub_device_close (dev); + return 1; + } fill_ctx->pmap[fill_ctx->pmapptr++] = '\n'; + grub_device_close (dev); return 0; } From a05a6e6f92335236dc12339c73144ef8d03f07e8 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 26 Jan 2015 09:44:57 +0100 Subject: [PATCH 229/722] xnu: Add missing error check. Found by: Coveriy scan. --- grub-core/loader/xnu.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/grub-core/loader/xnu.c b/grub-core/loader/xnu.c index cdd9715ce..bc89cdf6c 100644 --- a/grub-core/loader/xnu.c +++ b/grub-core/loader/xnu.c @@ -1378,6 +1378,8 @@ grub_xnu_fill_devicetree (void) name[len] = 0; curvalue = grub_xnu_create_value (curkey, name); + if (!curvalue) + return grub_errno; grub_free (name); data = grub_malloc (grub_strlen (var->value) + 1); From 73b1e8383906910e9da82fb3c79c590e450d598f Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 26 Jan 2015 09:48:46 +0100 Subject: [PATCH 230/722] normal/main: Fix error handling. Found by: Coverity scan. --- grub-core/normal/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/normal/main.c b/grub-core/normal/main.c index c41f175bd..623b93ba6 100644 --- a/grub-core/normal/main.c +++ b/grub-core/normal/main.c @@ -130,7 +130,7 @@ read_config_file (const char *config) file = grub_bufio_open (rawfile, 0); if (! file) { - grub_file_close (file); + grub_file_close (rawfile); return 0; } From 6603c22f3125185077d9e6431e1004aff83a473c Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 26 Jan 2015 09:49:32 +0100 Subject: [PATCH 231/722] normal/misc: Close device on all pathes. Found by: Coverity scan. --- grub-core/normal/misc.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/grub-core/normal/misc.c b/grub-core/normal/misc.c index 34d505eda..38f91b9b9 100644 --- a/grub-core/normal/misc.c +++ b/grub-core/normal/misc.c @@ -184,10 +184,11 @@ grub_normal_print_device_info (const char *name) /* TRANSLATORS: Replace dot with appropriate decimal separator for your language. */ (grub_disk_get_size (dev->disk) & 1) ? _(".5") : ""); - - grub_device_close (dev); } + if (dev) + grub_device_close (dev); + grub_xputs ("\n"); return grub_errno; } From c14dff3ca722cc139cd9c44261aa99882d8a8ca3 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 26 Jan 2015 09:50:27 +0100 Subject: [PATCH 232/722] devmapper/getroot: Fix memory leak. Found by: Coverity scan. --- grub-core/osdep/devmapper/getroot.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/grub-core/osdep/devmapper/getroot.c b/grub-core/osdep/devmapper/getroot.c index d02386b34..0a77a04b9 100644 --- a/grub-core/osdep/devmapper/getroot.c +++ b/grub-core/osdep/devmapper/getroot.c @@ -160,7 +160,10 @@ grub_util_pull_devmapper (const char *os_dev) uuid = get_dm_uuid (os_dev); if (!grub_util_open_dm (os_dev, &tree, &node)) - return; + { + grub_free (uuid); + return; + } while ((child = dm_tree_next_child (&handle, node, 0))) { @@ -192,6 +195,7 @@ grub_util_pull_devmapper (const char *os_dev) } else dm_tree_free (tree); + grub_free (uuid); } char * @@ -253,6 +257,7 @@ grub_util_get_devmapper_grub_dev (const char *os_dev) grub_free (uuid); return grub_dev; } + grub_free (uuid); return NULL; } @@ -279,6 +284,7 @@ grub_util_get_vg_uuid (const char *os_dev) } optr--; *optr = '\0'; + grub_free (uuid); return vgid; } From 5adc6d76d3c82ed7d85fc7aaa341743f5378314c Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 26 Jan 2015 09:50:58 +0100 Subject: [PATCH 233/722] linux/blocklist: Fix memory leak. Found by: Coverity scan. --- grub-core/osdep/linux/blocklist.c | 1 + 1 file changed, 1 insertion(+) diff --git a/grub-core/osdep/linux/blocklist.c b/grub-core/osdep/linux/blocklist.c index 10ddd11c1..c77d6085c 100644 --- a/grub-core/osdep/linux/blocklist.c +++ b/grub-core/osdep/linux/blocklist.c @@ -130,6 +130,7 @@ grub_install_get_blocklist (grub_device_t root_dev, & (GRUB_DISK_SECTOR_SIZE - 1), fie2->fm_extents[i].fe_length, hook_data); } + free (fie2); } close (fd); } From cba5a85a67f879b6431833e87ceb93d44b8ac48a Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 26 Jan 2015 09:51:48 +0100 Subject: [PATCH 234/722] linux/getroot: Fix error handling. Found by: Coverity scan. --- grub-core/osdep/linux/getroot.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/grub-core/osdep/linux/getroot.c b/grub-core/osdep/linux/getroot.c index 7007193d9..f48b81aed 100644 --- a/grub-core/osdep/linux/getroot.c +++ b/grub-core/osdep/linux/getroot.c @@ -226,7 +226,7 @@ grub_find_root_devices_from_btrfs (const char *dir) char **ret; fd = open (dir, 0); - if (!fd) + if (fd < 0) return NULL; if (ioctl (fd, BTRFS_IOC_FS_INFO, &fsi) < 0) @@ -274,11 +274,11 @@ get_btrfs_fs_prefix (const char *mount_path) args.objectid = GRUB_BTRFS_TREE_ROOT_OBJECTID; if (ioctl (fd, BTRFS_IOC_INO_LOOKUP, &args) < 0) - return NULL; + goto fail; tree_id = args.treeid; if (fstat (fd, &st) < 0) - return NULL; + goto fail; inode_id = st.st_ino; while (tree_id != GRUB_BTRFS_ROOT_VOL_OBJECTID @@ -309,11 +309,11 @@ get_btrfs_fs_prefix (const char *mount_path) sargs.key.nr_items = 1; if (ioctl (fd, BTRFS_IOC_TREE_SEARCH, &sargs) < 0) - return NULL; + goto fail; if (sargs.key.nr_items == 0) - return NULL; - + goto fail; + tree_id = sargs.buf[2]; br = (struct grub_btrfs_root_backref *) (sargs.buf + 4); inode_id = br->inode_id; @@ -336,10 +336,10 @@ get_btrfs_fs_prefix (const char *mount_path) sargs.key.max_type = GRUB_BTRFS_ITEM_TYPE_INODE_REF; if (ioctl (fd, BTRFS_IOC_TREE_SEARCH, &sargs) < 0) - return NULL; + goto fail; if (sargs.key.nr_items == 0) - return NULL; + goto fail; inode_id = sargs.buf[2]; @@ -362,6 +362,10 @@ get_btrfs_fs_prefix (const char *mount_path) if (!ret) return xstrdup ("/"); return ret; + fail: + free (ret); + close (fd); + return NULL; } @@ -688,7 +692,7 @@ char * grub_util_part_to_disk (const char *os_dev, struct stat *st, int *is_part) { - char *path = xmalloc (PATH_MAX); + char *path; if (! S_ISBLK (st->st_mode)) { @@ -696,6 +700,8 @@ grub_util_part_to_disk (const char *os_dev, struct stat *st, return xstrdup (os_dev); } + path = xmalloc (PATH_MAX); + if (! realpath (os_dev, path)) return NULL; From 810254093959708aa6a260c59ad3cf3a1d250755 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 26 Jan 2015 09:53:03 +0100 Subject: [PATCH 235/722] unix/password: Fix file descriptor leak. Found by: Coverity scan. --- grub-core/osdep/unix/password.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/grub-core/osdep/unix/password.c b/grub-core/osdep/unix/password.c index 470a6ea62..4b9507bce 100644 --- a/grub-core/osdep/unix/password.c +++ b/grub-core/osdep/unix/password.c @@ -53,7 +53,10 @@ grub_password_get (char buf[], unsigned buf_size) tty_changed = 0; grub_memset (buf, 0, buf_size); if (!fgets (buf, buf_size, stdin)) - return 0; + { + fclose (in); + return 0; + } ptr = buf + strlen (buf) - 1; while (buf <= ptr && (*ptr == '\n' || *ptr == '\r')) *ptr-- = 0; @@ -64,5 +67,7 @@ grub_password_get (char buf[], unsigned buf_size) grub_xputs ("\n"); grub_refresh (); + fclose (in); + return 1; } From c4fcfd8744f320635949d62ec0df4ea60ebe60e8 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 26 Jan 2015 09:53:39 +0100 Subject: [PATCH 236/722] vbe: Fix incorrect register usage. Found by: Coverity scan. --- grub-core/video/i386/pc/vbe.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/grub-core/video/i386/pc/vbe.c b/grub-core/video/i386/pc/vbe.c index 62b5c2245..07a614a20 100644 --- a/grub-core/video/i386/pc/vbe.c +++ b/grub-core/video/i386/pc/vbe.c @@ -304,8 +304,7 @@ grub_vbe_bios_getset_dac_palette_width (int set, int *dac_mask_size) struct grub_bios_int_registers regs; regs.eax = 0x4f08; - regs.ebx = (*dac_mask_size & 0xff) >> 8; - regs.ebx = set ? 1 : 0; + regs.ebx = ((*dac_mask_size & 0xff) << 8) | (set ? 1 : 0); regs.flags = GRUB_CPU_INT_FLAGS_DEFAULT; grub_bios_interrupt (0x10, ®s); *dac_mask_size = (regs.ebx >> 8) & 0xff; From 866f469683a1cc99bb3adeee5b3eb07ec18a000c Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 26 Jan 2015 09:54:14 +0100 Subject: [PATCH 237/722] util/getroot: Add missing grub_disk_close. Found by: Coverity scan. --- util/getroot.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/util/getroot.c b/util/getroot.c index 3958105d8..345d49ba8 100644 --- a/util/getroot.c +++ b/util/getroot.c @@ -417,7 +417,10 @@ grub_util_biosdisk_get_grub_dev (const char *os_dev) name = grub_util_get_ldm (disk, ctx.start); if (name) - return name; + { + grub_disk_close (disk); + return name; + } ctx.partname = NULL; From c3f52305976ffcdee679df4229b65d5f71a53023 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 26 Jan 2015 09:54:50 +0100 Subject: [PATCH 238/722] grub-install-common: Fix sizeof usage. Found by: Coverity scan. --- util/grub-install-common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/grub-install-common.c b/util/grub-install-common.c index b6dec93ea..a4656994e 100644 --- a/util/grub-install-common.c +++ b/util/grub-install-common.c @@ -238,7 +238,7 @@ grub_install_push_module (const char *val) if (modules.n_alloc < 16) modules.n_alloc = 16; modules.entries = xrealloc (modules.entries, - modules.n_alloc * sizeof (modules.entries)); + modules.n_alloc * sizeof (*modules.entries)); } modules.entries[modules.n_entries++] = xstrdup (val); modules.entries[modules.n_entries] = NULL; From 3c6384832bb304078fcafc537195827710f9f6bf Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 26 Jan 2015 09:55:30 +0100 Subject: [PATCH 239/722] grub-install: Fix memory leak. Found by: Coverity scan. --- util/grub-install.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/util/grub-install.c b/util/grub-install.c index 7d61c32be..afbc55707 100644 --- a/util/grub-install.c +++ b/util/grub-install.c @@ -622,7 +622,10 @@ device_map_check_duplicates (const char *dev_map) fp = grub_util_fopen (dev_map, "r"); if (! fp) - return; + { + free (d); + return; + } while (fgets (buf, sizeof (buf), fp)) { From 5d61a6a6120954380a46a3c1a46a01fdf763e037 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 26 Jan 2015 09:55:58 +0100 Subject: [PATCH 240/722] grub-macbless: Fix resource leak. Found by: Coverity scan. --- util/grub-macbless.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/util/grub-macbless.c b/util/grub-macbless.c index 742353a42..e57e13d5a 100644 --- a/util/grub-macbless.c +++ b/util/grub-macbless.c @@ -92,6 +92,8 @@ bless (const char *path, int x86) free (filebuf_via_grub); free (filebuf_via_sys); free (drive_name); + free (devices); + grub_device_close (dev); } static struct argp_option options[] = { From 11eed6abce6626edecdbc81876bc7f5b91458c0b Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 26 Jan 2015 09:56:24 +0100 Subject: [PATCH 241/722] util/misc.c: Check ftello return value. Found by: Coverity scan. --- util/misc.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/util/misc.c b/util/misc.c index b0e023ecd..b8ec69108 100644 --- a/util/misc.c +++ b/util/misc.c @@ -89,6 +89,8 @@ grub_util_get_image_size (const char *path) fseeko (f, 0, SEEK_END); sz = ftello (f); + if (sz < 0) + grub_util_error (_("cannot open `%s': %s"), path, strerror (errno)); if (sz != (size_t) sz) grub_util_error (_("file `%s' is too big"), path); ret = (size_t) sz; From 6704abade6674a91d8c652a7e4596ca3421411b6 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Mon, 26 Jan 2015 21:38:40 +0300 Subject: [PATCH 242/722] linux/getroot: fix descriptor leak. Found by: Coverity scan. --- grub-core/osdep/linux/getroot.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/grub-core/osdep/linux/getroot.c b/grub-core/osdep/linux/getroot.c index f48b81aed..a2e360f52 100644 --- a/grub-core/osdep/linux/getroot.c +++ b/grub-core/osdep/linux/getroot.c @@ -360,8 +360,10 @@ get_btrfs_fs_prefix (const char *mount_path) ret[1+namelen] = '\0'; } if (!ret) - return xstrdup ("/"); + ret = xstrdup ("/"); + close (fd); return ret; + fail: free (ret); close (fd); From e2a21238da913dd834b6b656170eb295c589e65d Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Mon, 26 Jan 2015 21:41:29 +0300 Subject: [PATCH 243/722] linux/ofpath: fix various memory leaks. Found by: Coverity scan. --- grub-core/osdep/linux/ofpath.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/grub-core/osdep/linux/ofpath.c b/grub-core/osdep/linux/ofpath.c index 8f24bc9e8..4cc171cb5 100644 --- a/grub-core/osdep/linux/ofpath.c +++ b/grub-core/osdep/linux/ofpath.c @@ -128,6 +128,8 @@ find_obppath (const char *sysfs_path_orig) if (fd < 0 || fstat (fd, &st) < 0) { + if (fd >= 0) + close (fd); kill_trailing_dir(sysfs_path); if (!strcmp(sysfs_path, "/sys")) { @@ -147,6 +149,9 @@ find_obppath (const char *sysfs_path_orig) { grub_util_info (_("cannot read `%s': %s"), path, strerror (errno)); close(fd); + free (path); + free (of_path); + free (sysfs_path); return NULL; } close(fd); @@ -480,6 +485,7 @@ of_path_of_scsi(const char *sys_devname __attribute__((unused)), const char *dev snprintf(disk, sizeof (disk), "/sas/%s@%lx,%lu:%c", disk_name, sas_address, longlun, 'a' + (part - 1)); } + free (lunstr); } } strcat(of_path, disk); @@ -530,7 +536,7 @@ grub_util_devname_to_ofpath (const char *sys_devname) else { grub_util_warn (_("unknown device type %s\n"), device); - return NULL; + ofpath = NULL; } free (devnode); From 64440daa21e150337ee285674eca3dd84de20958 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Mon, 26 Jan 2015 21:07:19 +0300 Subject: [PATCH 244/722] util/setup: fix memory leak. Found by: Coverity scan. --- util/setup.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/util/setup.c b/util/setup.c index 9fb91a82f..ed4bd1113 100644 --- a/util/setup.c +++ b/util/setup.c @@ -322,7 +322,10 @@ SETUP (const char *dir, continue; try_dev = grub_device_open (drive); if (! try_dev) - continue; + { + free (drive); + continue; + } if (!found && try_dev->disk->id == dest_dev->disk->id && try_dev->disk->dev->id == dest_dev->disk->dev->id) { From 5e27fb06f22eda7d7ffd86d16c27262aaf59e132 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Mon, 26 Jan 2015 21:11:32 +0300 Subject: [PATCH 245/722] util/install: fix memory leak. Found by: Coverity scan. --- util/grub-install-common.c | 1 + 1 file changed, 1 insertion(+) diff --git a/util/grub-install-common.c b/util/grub-install-common.c index a4656994e..37c1a98b9 100644 --- a/util/grub-install-common.c +++ b/util/grub-install-common.c @@ -490,6 +490,7 @@ grub_install_make_image_wrap_file (const char *dir, const char *prefix, dir, prefix, outname, mkimage_target, compnames[compression], note ? "--note" : "", s); + free (s); tgt = grub_install_get_image_target (mkimage_target); if (!tgt) From e61f4eba1850c1c6576c0977fc1a305ad02ab0ce Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Mon, 26 Jan 2015 22:08:13 +0300 Subject: [PATCH 246/722] linux/getroot: fix memory leak. Found by: Coverity scan. --- grub-core/osdep/unix/getroot.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/grub-core/osdep/unix/getroot.c b/grub-core/osdep/unix/getroot.c index e3887cbea..10fb56a2b 100644 --- a/grub-core/osdep/unix/getroot.c +++ b/grub-core/osdep/unix/getroot.c @@ -621,7 +621,10 @@ grub_util_pull_lvm_by_command (const char *os_dev) free (vgname); if (!pid) - return; + { + free (vgid); + return; + } /* Parent. Read vgs' output. */ vgs = fdopen (fd, "r"); @@ -653,6 +656,7 @@ out: close (fd); waitpid (pid, NULL, 0); free (buf); + free (vgid); } /* ZFS has similar problems to those of btrfs (see above). */ From be0743b052d76c27cc704d94cfd38cc54e7e02b3 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Mon, 26 Jan 2015 22:17:31 +0300 Subject: [PATCH 247/722] util/grub-install: rearrange code to avoid memory leak. Found by: Coverity scan. --- util/grub-install.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/util/grub-install.c b/util/grub-install.c index afbc55707..210f4a7e3 100644 --- a/util/grub-install.c +++ b/util/grub-install.c @@ -615,17 +615,14 @@ device_map_check_duplicates (const char *dev_map) char **d; size_t i; - d = xmalloc (alloced * sizeof (d[0])); - if (dev_map[0] == '\0') return; fp = grub_util_fopen (dev_map, "r"); if (! fp) - { - free (d); - return; - } + return; + + d = xmalloc (alloced * sizeof (d[0])); while (fgets (buf, sizeof (buf), fp)) { From bd4e20eedfaa3079a2efcb13559e916772365ee1 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Mon, 26 Jan 2015 22:20:51 +0300 Subject: [PATCH 248/722] util/grub-mkstandalone: fix memory leak. Found by: Coverity scan. --- util/grub-mkstandalone.c | 1 + 1 file changed, 1 insertion(+) diff --git a/util/grub-mkstandalone.c b/util/grub-mkstandalone.c index 6017d7155..4907d44c0 100644 --- a/util/grub-mkstandalone.c +++ b/util/grub-mkstandalone.c @@ -284,6 +284,7 @@ add_tar_file (const char *from, grub_util_fd_close (in); write_pad (size); + free (tcn); } int From 1a87156e01e3cb873f3479c31c34c97fb690eb71 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Mon, 26 Jan 2015 22:24:28 +0300 Subject: [PATCH 249/722] util/grub-mount: fix descriptor leak. Found by: Coverity scan. --- util/grub-mount.c | 1 + 1 file changed, 1 insertion(+) diff --git a/util/grub-mount.c b/util/grub-mount.c index 19de2e620..4626e54ed 100644 --- a/util/grub-mount.c +++ b/util/grub-mount.c @@ -516,6 +516,7 @@ argp_parser (int key, char *arg, struct argp_state *state) return 0; } grub_zfs_add_key (buf, real_size, 0); + fclose (f); } return 0; From fe4efe0d50482b433b46de677546f796de46d5ae Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Mon, 26 Jan 2015 22:39:08 +0300 Subject: [PATCH 250/722] util/mkimage: fix memory leaks. Found by: Coverity scan. --- util/mkimage.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/util/mkimage.c b/util/mkimage.c index e6b799fd7..bccd70388 100644 --- a/util/mkimage.c +++ b/util/mkimage.c @@ -1278,6 +1278,8 @@ grub_install_generate_image (const char *dir, const char *prefix, free (core_img); core_img = full_img; core_size = full_size; + free (decompress_img); + free (decompress_path); } switch (image_target->id) @@ -1744,6 +1746,8 @@ grub_install_generate_image (const char *dir, const char *prefix, free (core_img); core_img = rom_img; core_size = rom_size; + free (boot_img); + free (boot_path); } break; case IMAGE_QEMU_MIPS_FLASH: From bd196014ec4eed6b4671cac4f4cb73621b219afa Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Mon, 26 Jan 2015 22:44:45 +0300 Subject: [PATCH 251/722] util/setup: fix memory leak. Found by: Coverity scan. --- util/setup.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/util/setup.c b/util/setup.c index ed4bd1113..b2991595b 100644 --- a/util/setup.c +++ b/util/setup.c @@ -670,15 +670,17 @@ unable_to_embed: if (dest_dev->disk->id != root_dev->disk->id || dest_dev->disk->dev->id != root_dev->disk->dev->id) { - const char *dest_ofpath; + char *dest_ofpath; dest_ofpath = grub_util_devname_to_ofpath (grub_util_biosdisk_get_osdev (root_dev->disk)); + /* FIXME handle NULL result */ grub_util_info ("dest_ofpath is `%s'", dest_ofpath); strncpy (boot_devpath, dest_ofpath, GRUB_BOOT_MACHINE_BOOT_DEVPATH_END - GRUB_BOOT_MACHINE_BOOT_DEVPATH - 1); boot_devpath[GRUB_BOOT_MACHINE_BOOT_DEVPATH_END - GRUB_BOOT_MACHINE_BOOT_DEVPATH - 1] = 0; + free (dest_ofpath); } else { From 4192f2e3d1779b71f53580a59f280af1bfda1f3b Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Tue, 27 Jan 2015 10:20:54 +0100 Subject: [PATCH 252/722] commands/acpi: Use ALIGN_UP rather than manual expression. Improves readability and hopefully automatic scanning. Found by: Coverity Scan. --- grub-core/commands/acpi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/grub-core/commands/acpi.c b/grub-core/commands/acpi.c index f66fa2db3..5507ffa08 100644 --- a/grub-core/commands/acpi.c +++ b/grub-core/commands/acpi.c @@ -265,7 +265,7 @@ grub_acpi_create_ebda (void) grub_memcpy (target, v2, v2->length); v2inebda = target; target += v2->length; - target = (grub_uint8_t *) ((((grub_addr_t) target - 1) | 0xf) + 1); + target = (grub_uint8_t *) ALIGN_UP((grub_addr_t) target, 16); v2 = 0; break; } @@ -282,7 +282,7 @@ grub_acpi_create_ebda (void) grub_memcpy (target, v1, sizeof (struct grub_acpi_rsdp_v10)); v1inebda = target; target += sizeof (struct grub_acpi_rsdp_v10); - target = (grub_uint8_t *) ((((grub_addr_t) target - 1) | 0xf) + 1); + target = (grub_uint8_t *) ALIGN_UP((grub_addr_t) target, 16); v1 = 0; break; } From 69a52e95d425502945fe43892cebf6b183290e6e Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Tue, 27 Jan 2015 10:30:43 +0100 Subject: [PATCH 253/722] fs/{cbfs,cpio}: Remove useless check if mode is NULL. Callers already ensure that it's not null. Found by: Coverity Scan. --- grub-core/fs/cbfs.c | 3 +-- grub-core/fs/cpio_common.c | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/grub-core/fs/cbfs.c b/grub-core/fs/cbfs.c index 4ddd6832f..a34eb88cb 100644 --- a/grub-core/fs/cbfs.c +++ b/grub-core/fs/cbfs.c @@ -74,8 +74,7 @@ grub_cbfs_find_file (struct grub_archelp_data *data, char **name, (void) mtime; offset = grub_be_to_cpu32 (hd.offset); - if (mode) - *mode = GRUB_ARCHELP_ATTR_FILE | GRUB_ARCHELP_ATTR_NOTIME; + *mode = GRUB_ARCHELP_ATTR_FILE | GRUB_ARCHELP_ATTR_NOTIME; namesize = offset; if (namesize >= sizeof (hd)) diff --git a/grub-core/fs/cpio_common.c b/grub-core/fs/cpio_common.c index 20230a741..50fea47d1 100644 --- a/grub-core/fs/cpio_common.c +++ b/grub-core/fs/cpio_common.c @@ -69,8 +69,7 @@ grub_cpio_find_file (struct grub_archelp_data *data, char **name, return GRUB_ERR_NONE; } - if (mode) - *mode = modeval; + *mode = modeval; *name = grub_malloc (namesize + 1); if (*name == NULL) From 0daf46fdbd37627411f3a0dd99390ee4523de1bb Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Tue, 27 Jan 2015 16:31:35 +0100 Subject: [PATCH 254/722] fs/zfs: Fix error handling. Found by: Coverity Scan. --- grub-core/fs/zfs/zfs.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/grub-core/fs/zfs/zfs.c b/grub-core/fs/zfs/zfs.c index c8c7b97a2..9edac5099 100644 --- a/grub-core/fs/zfs/zfs.c +++ b/grub-core/fs/zfs/zfs.c @@ -285,7 +285,7 @@ static const char *spa_feature_names[] = { static int check_feature(const char *name, grub_uint64_t val, struct grub_zfs_dir_ctx *ctx); -static int +static grub_err_t check_mos_features(dnode_phys_t *mosmdn_phys,grub_zfs_endian_t endian,struct grub_zfs_data* data ); static grub_err_t @@ -1975,7 +1975,7 @@ dmu_read (dnode_end_t * dn, grub_uint64_t blkid, void **buf, dn->endian) << SPA_MINBLOCKSHIFT; *buf = grub_malloc (size); - if (*buf) + if (!*buf) { err = grub_errno; break; @@ -3979,7 +3979,12 @@ iterate_zap (const char *name, grub_uint64_t val, struct grub_zfs_dir_ctx *ctx) dnode_end_t dn; grub_memset (&info, 0, sizeof (info)); - dnode_get (&(ctx->data->subvol.mdn), val, 0, &dn, ctx->data); + err = dnode_get (&(ctx->data->subvol.mdn), val, 0, &dn, ctx->data); + if (err) + { + grub_print_error (); + return 0; + } if (dn.dn.dn_bonustype == DMU_OT_SA) { @@ -4200,11 +4205,11 @@ check_feature (const char *name, grub_uint64_t val, * errnum: Failure. */ -static int +static grub_err_t check_mos_features(dnode_phys_t *mosmdn_phys,grub_zfs_endian_t endian,struct grub_zfs_data* data ) { grub_uint64_t objnum; - grub_uint8_t errnum = 0; + grub_err_t errnum = 0; dnode_end_t dn,mosmdn; mzap_phys_t* mzp; grub_zfs_endian_t endianzap; From 916733ea6ae90c56797d39bb41b72427da3e1e4f Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Tue, 27 Jan 2015 16:35:37 +0100 Subject: [PATCH 255/722] fs/zfscrypt: Add missing explicit cast. Found by: Coverity scan. --- grub-core/fs/zfs/zfscrypt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/fs/zfs/zfscrypt.c b/grub-core/fs/zfs/zfscrypt.c index 88dae72ef..91a0af64c 100644 --- a/grub-core/fs/zfs/zfscrypt.c +++ b/grub-core/fs/zfs/zfscrypt.c @@ -238,7 +238,7 @@ grub_gcm_decrypt (grub_crypto_cipher_handle_t cipher, grub_crypto_xor (out + 16 * i, in + 16 * i, mul, csize); } for (j = 0; j < 8; j++) - mac[15 - j] ^= ((psize * 8) >> (8 * j)); + mac[15 - j] ^= ((((grub_uint64_t) psize) * 8) >> (8 * j)); grub_gcm_mul (mac, h); if (mac_out) From c2fc41990a77923c44a71d616561920ae186db56 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Tue, 27 Jan 2015 16:48:53 +0100 Subject: [PATCH 256/722] linux/hostdisk: Limit strcpy size to buffer size. Found by: Coverity scan. --- grub-core/osdep/linux/hostdisk.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/grub-core/osdep/linux/hostdisk.c b/grub-core/osdep/linux/hostdisk.c index c96427a56..75cb8f55d 100644 --- a/grub-core/osdep/linux/hostdisk.c +++ b/grub-core/osdep/linux/hostdisk.c @@ -376,7 +376,7 @@ grub_util_fd_open_device (const grub_disk_t disk, grub_disk_addr_t sector, int f part_start = grub_partition_get_start (disk->partition); - strcpy (dev, grub_util_biosdisk_get_osdev (disk)); + strlcpy (dev, grub_util_biosdisk_get_osdev (disk), sizeof (dev)); if (disk->partition && strncmp (dev, "/dev/", 5) == 0) { @@ -439,7 +439,7 @@ grub_util_fd_open_device (const grub_disk_t disk, grub_disk_addr_t sector, int f if (*max == 0) *max = ~0ULL; is_partition = 0; - strcpy (dev, grub_util_biosdisk_get_osdev (disk)); + strlcpy (dev, grub_util_biosdisk_get_osdev (disk), sizeof (dev)); goto reopen; } sector -= part_start; From 8f95eae423fc7220af3c1f6150ac35e98281bb96 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Tue, 27 Jan 2015 16:49:49 +0100 Subject: [PATCH 257/722] linux/ofpath: Fix error handling. Found by: Coverity Scan. --- grub-core/osdep/linux/ofpath.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/grub-core/osdep/linux/ofpath.c b/grub-core/osdep/linux/ofpath.c index 4cc171cb5..f716fd2fc 100644 --- a/grub-core/osdep/linux/ofpath.c +++ b/grub-core/osdep/linux/ofpath.c @@ -334,7 +334,7 @@ vendor_is_ATA(const char *path) } static void -check_sas (char *sysfs_path, int *tgt, unsigned long int *sas_address) +check_sas (const char *sysfs_path, int *tgt, unsigned long int *sas_address) { char *ed = strstr (sysfs_path, "end_device"); char *p, *q, *path; @@ -346,8 +346,10 @@ check_sas (char *sysfs_path, int *tgt, unsigned long int *sas_address) return; /* SAS devices are identified using disk@$PHY_ID */ - p = strdup (sysfs_path); + p = xstrdup (sysfs_path); ed = strstr(p, "end_device"); + if (!ed) + return; q = ed; while (*q && *q != '/') From 9ee5ae1fae1d7e19f76d4758d9658af90018b0f9 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Tue, 27 Jan 2015 17:17:58 +0100 Subject: [PATCH 258/722] Document intentional fallthroughs. Found by: Coverity scan. --- grub-core/disk/diskfilter.c | 3 +++ grub-core/font/font.c | 3 ++- grub-core/fs/udf.c | 1 + grub-core/lib/legacy_parse.c | 1 + grub-core/loader/i386/pc/linux.c | 3 +++ grub-core/normal/charset.c | 1 + grub-core/video/bochs.c | 1 + grub-core/video/cirrus.c | 1 + grub-core/video/i386/pc/vbe.c | 2 ++ util/getroot.c | 1 + util/grub-install.c | 2 +- 11 files changed, 17 insertions(+), 2 deletions(-) diff --git a/grub-core/disk/diskfilter.c b/grub-core/disk/diskfilter.c index 612484607..80966ac01 100644 --- a/grub-core/disk/diskfilter.c +++ b/grub-core/disk/diskfilter.c @@ -71,10 +71,12 @@ is_lv_readable (struct grub_diskfilter_lv *lv, int easily) case GRUB_DISKFILTER_RAID6: if (!easily) need--; + /* Fallthrough. */ case GRUB_DISKFILTER_RAID4: case GRUB_DISKFILTER_RAID5: if (!easily) need--; + /* Fallthrough. */ case GRUB_DISKFILTER_STRIPED: break; @@ -584,6 +586,7 @@ read_segment (struct grub_diskfilter_segment *seg, grub_disk_addr_t sector, if (seg->node_count == 1) return grub_diskfilter_read_node (&seg->nodes[0], sector, size, buf); + /* Fallthrough. */ case GRUB_DISKFILTER_MIRROR: case GRUB_DISKFILTER_RAID10: { diff --git a/grub-core/font/font.c b/grub-core/font/font.c index 607964b90..53d76a64d 100644 --- a/grub-core/font/font.c +++ b/grub-core/font/font.c @@ -1286,7 +1286,7 @@ blit_comb (const struct grub_unicode_glyph *glyph_id, - grub_font_get_xheight (combining_glyphs[i]->font) - 1; if (space <= 0) space = 1 + (grub_font_get_xheight (main_glyph->font)) / 8; - + /* Fallthrough. */ case GRUB_UNICODE_STACK_ATTACHED_ABOVE: do_blit (combining_glyphs[i], targetx, -(ctx.bounds.height + ctx.bounds.y + space @@ -1327,6 +1327,7 @@ blit_comb (const struct grub_unicode_glyph *glyph_id, + combining_glyphs[i]->height); if (space <= 0) space = 1 + (grub_font_get_xheight (main_glyph->font)) / 8; + /* Fallthrough. */ case GRUB_UNICODE_STACK_ATTACHED_BELOW: do_blit (combining_glyphs[i], targetx, -(ctx.bounds.y - space), diff --git a/grub-core/fs/udf.c b/grub-core/fs/udf.c index fd412830c..839bff889 100644 --- a/grub-core/fs/udf.c +++ b/grub-core/fs/udf.c @@ -986,6 +986,7 @@ grub_udf_read_symlink (grub_fshelp_node_t node) case 1: if (ptr[1]) goto fail; + /* Fallthrough. */ case 2: /* in 4 bytes. out: 1 byte. */ optr = out; diff --git a/grub-core/lib/legacy_parse.c b/grub-core/lib/legacy_parse.c index 61266d95a..ef56150ac 100644 --- a/grub-core/lib/legacy_parse.c +++ b/grub-core/lib/legacy_parse.c @@ -664,6 +664,7 @@ grub_legacy_parse (const char *buf, char **entryname, char **suffix) { case TYPE_FILE_NO_CONSUME: hold_arg = 1; + /* Fallthrough. */ case TYPE_PARTITION: case TYPE_FILE: args[i] = adjust_file (curarg, curarglen); diff --git a/grub-core/loader/i386/pc/linux.c b/grub-core/loader/i386/pc/linux.c index 870992b7d..a293b17aa 100644 --- a/grub-core/loader/i386/pc/linux.c +++ b/grub-core/loader/i386/pc/linux.c @@ -280,10 +280,13 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), { case 'g': shift += 10; + /* Fallthrough. */ case 'm': shift += 10; + /* Fallthrough. */ case 'k': shift += 10; + /* Fallthrough. */ default: break; } diff --git a/grub-core/normal/charset.c b/grub-core/normal/charset.c index 3e4c337da..eeb7ec18c 100644 --- a/grub-core/normal/charset.c +++ b/grub-core/normal/charset.c @@ -929,6 +929,7 @@ grub_bidi_line_logical_to_visual (const grub_uint32_t *logical, case GRUB_BIDI_TYPE_R: case GRUB_BIDI_TYPE_AL: bidi_needed = 1; + /* Fallthrough. */ default: { if (join_state == JOIN_FORCE) diff --git a/grub-core/video/bochs.c b/grub-core/video/bochs.c index 9098f90d1..3bcfa53a9 100644 --- a/grub-core/video/bochs.c +++ b/grub-core/video/bochs.c @@ -359,6 +359,7 @@ grub_video_bochs_setup (unsigned int width, unsigned int height, case 32: framebuffer.mode_info.reserved_mask_size = 8; framebuffer.mode_info.reserved_field_pos = 24; + /* Fallthrough. */ case 24: framebuffer.mode_info.red_mask_size = 8; diff --git a/grub-core/video/cirrus.c b/grub-core/video/cirrus.c index 4913084fa..e2149e8ce 100644 --- a/grub-core/video/cirrus.c +++ b/grub-core/video/cirrus.c @@ -440,6 +440,7 @@ grub_video_cirrus_setup (unsigned int width, unsigned int height, case 32: framebuffer.mode_info.reserved_mask_size = 8; framebuffer.mode_info.reserved_field_pos = 24; + /* Fallthrough. */ case 24: framebuffer.mode_info.red_mask_size = 8; diff --git a/grub-core/video/i386/pc/vbe.c b/grub-core/video/i386/pc/vbe.c index 07a614a20..b7f911926 100644 --- a/grub-core/video/i386/pc/vbe.c +++ b/grub-core/video/i386/pc/vbe.c @@ -874,6 +874,7 @@ vbe2videoinfo (grub_uint32_t mode, /* CGA is basically 4-bit packed pixel. */ case GRUB_VBE_MEMORY_MODEL_CGA: mode_info->mode_type |= GRUB_VIDEO_MODE_TYPE_CGA; + /* Fallthrough. */ case GRUB_VBE_MEMORY_MODEL_PACKED_PIXEL: mode_info->mode_type |= GRUB_VIDEO_MODE_TYPE_INDEX_COLOR; break; @@ -886,6 +887,7 @@ vbe2videoinfo (grub_uint32_t mode, /* Non chain 4 is a special case of planar. */ case GRUB_VBE_MEMORY_MODEL_NONCHAIN4_256: mode_info->mode_type |= GRUB_VIDEO_MODE_TYPE_NONCHAIN4; + /* Fallthrough. */ case GRUB_VBE_MEMORY_MODEL_PLANAR: mode_info->mode_type |= GRUB_VIDEO_MODE_TYPE_PLANAR | GRUB_VIDEO_MODE_TYPE_INDEX_COLOR; diff --git a/util/getroot.c b/util/getroot.c index 345d49ba8..3c1f12dca 100644 --- a/util/getroot.c +++ b/util/getroot.c @@ -107,6 +107,7 @@ grub_util_pull_device (const char *os_dev) default: if (grub_util_pull_device_os (os_dev, ab)) return; + /* Fallthrough. */ case GRUB_DEV_ABSTRACTION_NONE: free (grub_util_biosdisk_get_grub_dev (os_dev)); return; diff --git a/util/grub-install.c b/util/grub-install.c index 210f4a7e3..cedc18809 100644 --- a/util/grub-install.c +++ b/util/grub-install.c @@ -1809,7 +1809,7 @@ main (int argc, char *argv[]) grub_install_copy_file (imgfile, dst, 1); free (dst); } - + /* Fallthrough. */ case GRUB_INSTALL_PLATFORM_X86_64_EFI: if (efidir_is_mac) { From 7ba137f6286dcd17a1104f1dfc6eb1f58c5ef743 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Tue, 27 Jan 2015 20:00:23 +0300 Subject: [PATCH 259/722] linux/hostdisk: use strncpy instead of strlcpy strlcpy is not available on Linux as part of standard libraries. It probably is not worth extra configure checks espicially as we need to handle missing function anyway. --- grub-core/osdep/linux/hostdisk.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/grub-core/osdep/linux/hostdisk.c b/grub-core/osdep/linux/hostdisk.c index 75cb8f55d..06179fca7 100644 --- a/grub-core/osdep/linux/hostdisk.c +++ b/grub-core/osdep/linux/hostdisk.c @@ -376,7 +376,8 @@ grub_util_fd_open_device (const grub_disk_t disk, grub_disk_addr_t sector, int f part_start = grub_partition_get_start (disk->partition); - strlcpy (dev, grub_util_biosdisk_get_osdev (disk), sizeof (dev)); + strncpy (dev, grub_util_biosdisk_get_osdev (disk), sizeof (dev) - 1); + dev[sizeof(dev) - 1] = '\0'; if (disk->partition && strncmp (dev, "/dev/", 5) == 0) { @@ -439,7 +440,8 @@ grub_util_fd_open_device (const grub_disk_t disk, grub_disk_addr_t sector, int f if (*max == 0) *max = ~0ULL; is_partition = 0; - strlcpy (dev, grub_util_biosdisk_get_osdev (disk), sizeof (dev)); + strncpy (dev, grub_util_biosdisk_get_osdev (disk), sizeof (dev) - 1); + dev[sizeof(dev) - 1] = '\0'; goto reopen; } sector -= part_start; From 637fc62699e7ae3f0057e1c56d330eb193fd40b6 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Tue, 27 Jan 2015 20:29:00 +0300 Subject: [PATCH 260/722] linux/ofpath: fix descriptor leak Found by: Coverity scan --- grub-core/osdep/linux/ofpath.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/grub-core/osdep/linux/ofpath.c b/grub-core/osdep/linux/ofpath.c index f716fd2fc..05b1ecdf8 100644 --- a/grub-core/osdep/linux/ofpath.c +++ b/grub-core/osdep/linux/ofpath.c @@ -122,6 +122,8 @@ find_obppath (const char *sysfs_path_orig) fd = open(path, O_RDONLY); if (fd < 0 || fstat (fd, &st) < 0) { + if (fd >= 0) + close (fd); snprintf(path, path_size, "%s/devspec", sysfs_path); fd = open(path, O_RDONLY); } From e871994849802889af1ad26ddde68e9a12466ba1 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Tue, 27 Jan 2015 20:52:27 +0300 Subject: [PATCH 261/722] fs/zfs/zfs.c: fix memory leak. Found by: Coverity scan. --- grub-core/fs/zfs/zfs.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/grub-core/fs/zfs/zfs.c b/grub-core/fs/zfs/zfs.c index 9edac5099..057b471e1 100644 --- a/grub-core/fs/zfs/zfs.c +++ b/grub-core/fs/zfs/zfs.c @@ -2835,6 +2835,8 @@ dnode_get_path (struct subvolume *subvol, const char *path_in, dnode_end_t *dn, if (!path_buf) { grub_free (oldpathbuf); + if (free_symval) + grub_free (sym_value); return grub_errno; } grub_memcpy (path, sym_value, sym_sz); From 3db4f05a10e98a4835ddd87f9d1ef9185e8eef84 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Tue, 27 Jan 2015 20:55:25 +0300 Subject: [PATCH 262/722] commands/parttool: fix memory leak. Found by: Coverity scan. --- grub-core/commands/parttool.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/grub-core/commands/parttool.c b/grub-core/commands/parttool.c index d907694dd..42c590e1a 100644 --- a/grub-core/commands/parttool.c +++ b/grub-core/commands/parttool.c @@ -282,8 +282,11 @@ grub_cmd_parttool (grub_command_t cmd __attribute__ ((unused)), break; } if (! cur) - return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("unknown argument `%s'"), + { + grub_device_close (dev); + return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("unknown argument `%s'"), args[i]); + } ptool = cur; pargs = (struct grub_parttool_args *) grub_zalloc (ptool->nargs * sizeof (struct grub_parttool_args)); From fa13e605270f46dc78cbfded62e4cc58a31dff50 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Tue, 27 Jan 2015 21:12:19 +0300 Subject: [PATCH 263/722] fs/zfs/zfscrypt.c: fix memory leaks. Found by: Coverity scan. --- grub-core/fs/zfs/zfscrypt.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/grub-core/fs/zfs/zfscrypt.c b/grub-core/fs/zfs/zfscrypt.c index 91a0af64c..834f858a0 100644 --- a/grub-core/fs/zfs/zfscrypt.c +++ b/grub-core/fs/zfs/zfscrypt.c @@ -354,6 +354,7 @@ grub_zfs_load_key_real (const struct grub_zfs_key *key, if (err) { grub_errno = GRUB_ERR_NONE; + grub_crypto_cipher_close (cipher); continue; } @@ -362,6 +363,7 @@ grub_zfs_load_key_real (const struct grub_zfs_key *key, if (err) { grub_errno = GRUB_ERR_NONE; + grub_crypto_cipher_close (cipher); continue; } @@ -372,6 +374,7 @@ grub_zfs_load_key_real (const struct grub_zfs_key *key, { grub_dprintf ("zfs", "key loading failed\n"); grub_errno = GRUB_ERR_NONE; + grub_crypto_cipher_close (cipher); continue; } @@ -381,12 +384,14 @@ grub_zfs_load_key_real (const struct grub_zfs_key *key, { grub_dprintf ("zfs", "key loading failed\n"); grub_errno = GRUB_ERR_NONE; + grub_crypto_cipher_close (cipher); continue; } ret = grub_crypto_cipher_open (GRUB_CIPHER_AES); if (!ret) { grub_errno = GRUB_ERR_NONE; + grub_crypto_cipher_close (cipher); continue; } err = grub_crypto_cipher_set_key (ret, decrypted, keylen); @@ -394,8 +399,10 @@ grub_zfs_load_key_real (const struct grub_zfs_key *key, { grub_errno = GRUB_ERR_NONE; grub_crypto_cipher_close (ret); + grub_crypto_cipher_close (cipher); continue; } + grub_crypto_cipher_close (cipher); return ret; } return NULL; From 3900726fa8a794869c42a0a33fbd96b5cd4ba14f Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Tue, 27 Jan 2015 21:13:10 +0300 Subject: [PATCH 264/722] fs/zfs/zfscrypt.c: fix indentation. --- grub-core/fs/zfs/zfscrypt.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/grub-core/fs/zfs/zfscrypt.c b/grub-core/fs/zfs/zfscrypt.c index 834f858a0..87eef621d 100644 --- a/grub-core/fs/zfs/zfscrypt.c +++ b/grub-core/fs/zfs/zfscrypt.c @@ -397,11 +397,11 @@ grub_zfs_load_key_real (const struct grub_zfs_key *key, err = grub_crypto_cipher_set_key (ret, decrypted, keylen); if (err) { - grub_errno = GRUB_ERR_NONE; - grub_crypto_cipher_close (ret); - grub_crypto_cipher_close (cipher); - continue; - } + grub_errno = GRUB_ERR_NONE; + grub_crypto_cipher_close (ret); + grub_crypto_cipher_close (cipher); + continue; + } grub_crypto_cipher_close (cipher); return ret; } From edc94e4b0bd026bf08861a4f4010a36bec0775cd Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Tue, 27 Jan 2015 21:19:28 +0300 Subject: [PATCH 265/722] fs/hfsplus: fix memory leak. Found by: Coverity scan. --- grub-core/fs/hfsplus.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/grub-core/fs/hfsplus.c b/grub-core/fs/hfsplus.c index 950d8a1e1..8f07f8544 100644 --- a/grub-core/fs/hfsplus.c +++ b/grub-core/fs/hfsplus.c @@ -723,7 +723,10 @@ list_nodes (void *record, void *hook_arg) /* If the name is obviously invalid, skip this node. */ if (catkey->name[i] == 0) - return 0; + { + grub_free (filename); + return 0; + } } *grub_utf16_to_utf8 ((grub_uint8_t *) filename, catkey->name, @@ -745,7 +748,10 @@ list_nodes (void *record, void *hook_arg) callback function. */ node = grub_malloc (sizeof (*node)); if (!node) - return 1; + { + grub_free (filename); + return 1; + } node->data = ctx->dir->data; node->compressed = 0; node->cbuf = 0; From 11aae26cc374d01c9bf4fa33f792bff16b444ef5 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Tue, 27 Jan 2015 21:29:55 +0300 Subject: [PATCH 266/722] util/grub-probe: fix memory leaks. Found by: Coverity scan. --- util/grub-probe.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/util/grub-probe.c b/util/grub-probe.c index ecb7b6bbd..8a0c4f35b 100644 --- a/util/grub-probe.c +++ b/util/grub-probe.c @@ -295,6 +295,7 @@ probe (const char *path, char **device_names, char delim) } printf ("%s", disk); putchar (delim); + free (disk); } return; } @@ -496,6 +497,7 @@ probe (const char *path, char **device_names, char delim) { grub_util_fprint_full_disk_name (stdout, dev->disk->name, dev); putchar (delim); + grub_device_close (dev); continue; } @@ -542,7 +544,7 @@ probe (const char *path, char **device_names, char delim) if (print == PRINT_IEEE1275_HINT) { const char *osdev = grub_util_biosdisk_get_osdev (dev->disk); - const char *ofpath = grub_util_devname_to_ofpath (osdev); + char *ofpath = grub_util_devname_to_ofpath (osdev); const char *map; map = grub_util_biosdisk_get_compatibility_hint (dev->disk); @@ -560,6 +562,7 @@ probe (const char *path, char **device_names, char delim) strcpy (p, ofpath); grub_util_fprint_full_disk_name (stdout, tmp, dev); free (tmp); + free (ofpath); putchar (delim); } From fbb4aa1c050162bef5478b5441abeeaefb4d94f2 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Tue, 27 Jan 2015 21:49:45 +0300 Subject: [PATCH 267/722] loader/xnu: fix memory leak. Foound by: Coverity scan. --- grub-core/loader/xnu.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/grub-core/loader/xnu.c b/grub-core/loader/xnu.c index bc89cdf6c..c9885b1bc 100644 --- a/grub-core/loader/xnu.c +++ b/grub-core/loader/xnu.c @@ -689,10 +689,10 @@ grub_xnu_load_driver (char *infoplistname, grub_file_t binaryfile, /* Allocate the space. */ err = grub_xnu_align_heap (GRUB_XNU_PAGESIZE); if (err) - return err; + goto fail; err = grub_xnu_heap_malloc (neededspace, &buf0, &buf_target); if (err) - return err; + goto fail; buf = buf0; exthead = (struct grub_xnu_extheader *) buf; @@ -709,10 +709,7 @@ grub_xnu_load_driver (char *infoplistname, grub_file_t binaryfile, else err = grub_macho_readfile32 (macho, filename, buf); if (err) - { - grub_macho_close (macho); - return err; - } + goto fail; grub_macho_close (macho); buf += machosize; } @@ -747,6 +744,10 @@ grub_xnu_load_driver (char *infoplistname, grub_file_t binaryfile, /* Announce to kernel */ return grub_xnu_register_memory ("Driver-", &driversnum, buf_target, neededspace); +fail: + if (macho) + grub_macho_close (macho); + return err; } /* Load mkext. */ From 1a4e47879c55390bd80e6f06bee68317b4f16cfa Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Tue, 27 Jan 2015 22:34:50 +0300 Subject: [PATCH 268/722] Change quotes to match overall style in NEWS --- NEWS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NEWS b/NEWS index 55f09d6d7..e417ebad1 100644 --- a/NEWS +++ b/NEWS @@ -85,7 +85,7 @@ New in 2.02: * Support for USB debug dongles. * Support for *-emu on all platforms (previously only i386/x86_64 worked). * Support *-emu on Windows. - * New platform "none" which builds only user level utilities. This is now + * New platform `none' which builds only user level utilities. This is now default if target CPU is not supported. * Security: From 2efab86d5a45da41adbe20ac59cc4d5b946de61e Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Wed, 28 Jan 2015 20:09:25 +0300 Subject: [PATCH 269/722] syslinux_parse: fix memory leak. Found by: Coverity scan. --- grub-core/lib/syslinux_parse.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/grub-core/lib/syslinux_parse.c b/grub-core/lib/syslinux_parse.c index f6053267f..2c874b1fa 100644 --- a/grub-core/lib/syslinux_parse.c +++ b/grub-core/lib/syslinux_parse.c @@ -922,6 +922,8 @@ write_entry (struct output_buffer *outbuf, print_string ("\n"); } + if (ptr && *ptr) + grub_free (cmdline); } break; case KERNEL_CHAINLOADER: From 9883307a527a0d0e39fe9d500c22ef3eccda83ba Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Wed, 28 Jan 2015 20:35:28 +0300 Subject: [PATCH 270/722] script/execute.c: fix memory leak. Make sure to continue loop over array after failure to free allocated strings. Found by: Coverity scan. --- grub-core/script/execute.c | 112 ++++++++++++++++++++++--------------- 1 file changed, 66 insertions(+), 46 deletions(-) diff --git a/grub-core/script/execute.c b/grub-core/script/execute.c index afd551320..bb70ebf17 100644 --- a/grub-core/script/execute.c +++ b/grub-core/script/execute.c @@ -635,57 +635,77 @@ grub_script_arglist_to_argv (struct grub_script_arglist *arglist, { case GRUB_SCRIPT_ARG_TYPE_VAR: case GRUB_SCRIPT_ARG_TYPE_DQVAR: - values = grub_script_env_get (arg->str, arg->type); - for (i = 0; values && values[i]; i++) - { - if (i != 0 && grub_script_argv_next (&result)) - goto fail; + { + int need_cleanup = 0; - if (arg->type == GRUB_SCRIPT_ARG_TYPE_VAR) - { - int len; - char ch; - char *p; - char *op; - const char *s = values[i]; + values = grub_script_env_get (arg->str, arg->type); + for (i = 0; values && values[i]; i++) + { + if (!need_cleanup) + { + if (i != 0 && grub_script_argv_next (&result)) + { + need_cleanup = 1; + goto cleanup; + } - len = grub_strlen (values[i]); - /* \? -> \\\? */ - /* \* -> \\\* */ - /* \ -> \\ */ - p = grub_malloc (len * 2 + 1); - if (! p) - goto fail; + if (arg->type == GRUB_SCRIPT_ARG_TYPE_VAR) + { + int len; + char ch; + char *p; + char *op; + const char *s = values[i]; - op = p; - while ((ch = *s++)) - { - if (ch == '\\') - { - *op++ = '\\'; - if (*s == '?' || *s == '*') - *op++ = '\\'; - } - *op++ = ch; - } - *op = '\0'; + len = grub_strlen (values[i]); + /* \? -> \\\? */ + /* \* -> \\\* */ + /* \ -> \\ */ + p = grub_malloc (len * 2 + 1); + if (! p) + { + need_cleanup = 1; + goto cleanup; + } - if (grub_script_argv_append (&result, p, op - p)) - { - grub_free (p); - goto fail; - } - } - else - { - if (append (&result, values[i], 1)) - goto fail; - } + op = p; + while ((ch = *s++)) + { + if (ch == '\\') + { + *op++ = '\\'; + if (*s == '?' || *s == '*') + *op++ = '\\'; + } + *op++ = ch; + } + *op = '\0'; - grub_free (values[i]); - } - grub_free (values); - break; + if (grub_script_argv_append (&result, p, op - p)) + { + grub_free (p); + need_cleanup = 1; + /* Fall through to cleanup */ + } + } + else + { + if (append (&result, values[i], 1)) + need_cleanup = 1; + /* Fall through to cleanup */ + } + } + +cleanup: + grub_free (values[i]); + } + grub_free (values); + + if (need_cleanup) + goto fail; + + break; + } case GRUB_SCRIPT_ARG_TYPE_BLOCK: { From 2da4171eabfe0d1b9b1be6146f628099d08aac02 Mon Sep 17 00:00:00 2001 From: Leif Lindholm Date: Wed, 28 Jan 2015 20:17:18 +0000 Subject: [PATCH 271/722] configure.ac: don't use -msoft-float for arm64 aarch64 toolchains do not support the -msoft-float option added by commit 3661261f. Insted, for arm64 use -march=armv8-a+nofp+nosimd. Reported-by: Ryan Harkin --- configure.ac | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index a3bca06ca..6d31ed01b 100644 --- a/configure.ac +++ b/configure.ac @@ -678,7 +678,11 @@ fi # that floats are a good fit to run instead of what's written in the code. # Given that floating point unit is disabled (if present to begin with) # when GRUB is running which may result in various hard crashes. -TARGET_CFLAGS="$TARGET_CFLAGS -msoft-float" +if test "x$target_cpu" = xarm64; then + TARGET_CFLAGS="$TARGET_CFLAGS -march=armv8-a+nofp+nosimd" +else + TARGET_CFLAGS="$TARGET_CFLAGS -msoft-float" +fi # By default, GCC 4.4 generates .eh_frame sections containing unwind # information in some cases where it previously did not. GRUB doesn't need From d29259b134257458a98c1ddc05d2a36c677ded37 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Fri, 30 Jan 2015 20:10:43 +0300 Subject: [PATCH 272/722] test: do not stop after first file test or closing bracket Closes: 44115 --- grub-core/commands/test.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/grub-core/commands/test.c b/grub-core/commands/test.c index c98c13d8c..f58b87c64 100644 --- a/grub-core/commands/test.c +++ b/grub-core/commands/test.c @@ -332,7 +332,7 @@ test_parse (char **args, int *argn, int argc) get_fileinfo (args[*argn + 1], &ctx); update_val (ctx.file_exists && ctx.file_info.dir, &ctx); (*argn) += 2; - return ctx.or || ctx.and; + continue; } if (grub_strcmp (args[*argn], "-e") == 0) @@ -340,7 +340,7 @@ test_parse (char **args, int *argn, int argc) get_fileinfo (args[*argn + 1], &ctx); update_val (ctx.file_exists, &ctx); (*argn) += 2; - return ctx.or || ctx.and; + continue; } if (grub_strcmp (args[*argn], "-f") == 0) @@ -349,7 +349,7 @@ test_parse (char **args, int *argn, int argc) /* FIXME: check for other types. */ update_val (ctx.file_exists && ! ctx.file_info.dir, &ctx); (*argn) += 2; - return ctx.or || ctx.and; + continue; } if (grub_strcmp (args[*argn], "-s") == 0) @@ -362,7 +362,7 @@ test_parse (char **args, int *argn, int argc) grub_file_close (file); grub_errno = GRUB_ERR_NONE; (*argn) += 2; - return ctx.or || ctx.and; + continue; } /* String tests. */ @@ -387,7 +387,7 @@ test_parse (char **args, int *argn, int argc) if (grub_strcmp (args[*argn], ")") == 0) { (*argn)++; - return ctx.or || ctx.and; + continue; } /* Recursively invoke if parenthesis. */ if (grub_strcmp (args[*argn], "(") == 0) From 958167b91cdebe55c6cccdd28ad007c554df56d7 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Fri, 30 Jan 2015 20:21:56 +0300 Subject: [PATCH 273/722] test: fix previous commit - we need to return from subexpression ( ... ) was processed recursively, we need to return from it. Revert this change. --- grub-core/commands/test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/commands/test.c b/grub-core/commands/test.c index f58b87c64..5f06642f6 100644 --- a/grub-core/commands/test.c +++ b/grub-core/commands/test.c @@ -387,7 +387,7 @@ test_parse (char **args, int *argn, int argc) if (grub_strcmp (args[*argn], ")") == 0) { (*argn)++; - continue; + return ctx.or || ctx.and; } /* Recursively invoke if parenthesis. */ if (grub_strcmp (args[*argn], "(") == 0) From f153fcb5a5863d7ce190cfc531b7dff1000316a0 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Fri, 30 Jan 2015 20:31:20 +0300 Subject: [PATCH 274/722] test: consistently use TMPDIR and same name pattern for temp files --- tests/test_sha512sum.in | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/test_sha512sum.in b/tests/test_sha512sum.in index 524c1d1c0..d5ef7f9ea 100644 --- a/tests/test_sha512sum.in +++ b/tests/test_sha512sum.in @@ -1,7 +1,7 @@ #! /bin/bash # create a randome file -file=`mktemp` +file="`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"`" || exit 1 cat >$file <$outfile1 <$outfile2 SHA1=`cat $outfile1 | tr -d '\n' | cut -f1 -d\ ` From 1e047e53aeb684a3a21a4269a99c708c381b96b5 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Fri, 30 Jan 2015 21:42:46 +0300 Subject: [PATCH 275/722] tests: add test command file tests This requires access to files in both host and grub image, so implementing as separate test unit instead of script test was more easy. --- Makefile.util.def | 6 ++++ tests/grub_cmd_test.in | 67 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 73 insertions(+) create mode 100644 tests/grub_cmd_test.in diff --git a/Makefile.util.def b/Makefile.util.def index fed96d864..378b5777a 100644 --- a/Makefile.util.def +++ b/Makefile.util.def @@ -1156,6 +1156,12 @@ script = { common = tests/file_filter_test.in; }; +script = { + testcase; + name = grub_cmd_test; + common = tests/grub_cmd_test.in; +}; + program = { testcase; name = example_unit_test; diff --git a/tests/grub_cmd_test.in b/tests/grub_cmd_test.in new file mode 100644 index 000000000..6269891c9 --- /dev/null +++ b/tests/grub_cmd_test.in @@ -0,0 +1,67 @@ +#! /bin/bash + +# create a randome file +empty="`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"`" || exit 1 +non_empty="`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"`" || exit 1 +cat >$non_empty <$outfile < /dev/null 2>&1; then + echo "GRUB test command file tests failed." + cat "$outfile" + exit 1 +else + rm -f "${outfile}" + exit 0 +fi From b40fde29a446d9fa5a6ebea7aafb34e3c958afbb Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Fri, 30 Jan 2015 22:09:51 +0300 Subject: [PATCH 276/722] net/ip: check result of grub_netbuff_push Found by: Coverity scan. --- grub-core/net/ip.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/grub-core/net/ip.c b/grub-core/net/ip.c index 5a6095444..8c56baaf7 100644 --- a/grub-core/net/ip.c +++ b/grub-core/net/ip.c @@ -191,15 +191,18 @@ grub_net_send_ip4_packet (struct grub_net_network_level_interface *inf, grub_net_ip_protocol_t proto) { struct iphdr *iph; + grub_err_t err; COMPILE_TIME_ASSERT (GRUB_NET_OUR_IPV4_HEADER_SIZE == sizeof (*iph)); if (nb->tail - nb->data + sizeof (struct iphdr) > inf->card->mtu) return send_fragmented (inf, target, nb, proto, *ll_target_addr); - grub_netbuff_push (nb, sizeof (*iph)); - iph = (struct iphdr *) nb->data; + err = grub_netbuff_push (nb, sizeof (*iph)); + if (err) + return err; + iph = (struct iphdr *) nb->data; iph->verhdrlen = ((4 << 4) | 5); iph->service = 0; iph->len = grub_cpu_to_be16 (nb->tail - nb->data); @@ -602,15 +605,18 @@ grub_net_send_ip6_packet (struct grub_net_network_level_interface *inf, grub_net_ip_protocol_t proto) { struct ip6hdr *iph; + grub_err_t err; COMPILE_TIME_ASSERT (GRUB_NET_OUR_IPV6_HEADER_SIZE == sizeof (*iph)); if (nb->tail - nb->data + sizeof (struct iphdr) > inf->card->mtu) return grub_error (GRUB_ERR_NET_PACKET_TOO_BIG, "packet too big"); - grub_netbuff_push (nb, sizeof (*iph)); - iph = (struct ip6hdr *) nb->data; + err = grub_netbuff_push (nb, sizeof (*iph)); + if (err) + return err; + iph = (struct ip6hdr *) nb->data; iph->version_class_flow = grub_cpu_to_be32_compile_time ((6 << 28)); iph->len = grub_cpu_to_be16 (nb->tail - nb->data - sizeof (*iph)); iph->protocol = proto; From 7aaed66455cc172bd9a3db1893925aa156ba2e14 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Fri, 30 Jan 2015 22:26:05 +0300 Subject: [PATCH 277/722] grub-mkimage: fix potential NULL pointer dereference Move fatal check whether symtab_section is NULL before first reference. Found by: Coverity scan. --- util/grub-mkimagexx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/util/grub-mkimagexx.c b/util/grub-mkimagexx.c index 0a1ac9e51..3c76d0708 100644 --- a/util/grub-mkimagexx.c +++ b/util/grub-mkimagexx.c @@ -1539,6 +1539,8 @@ SUFFIX (load_image) (const char *kernel_path, size_t *exec_size, symtab_section = s; break; } + if (! symtab_section) + grub_util_error ("%s", _("no symbol table")); #ifdef MKIMAGE_ELF32 if (image_target->elf_target == EM_ARM) @@ -1577,8 +1579,6 @@ SUFFIX (load_image) (const char *kernel_path, size_t *exec_size, } #endif - if (! symtab_section) - grub_util_error ("%s", _("no symbol table")); } else { From 12abe75aa03695dfa5f6963013a5eb20f656224d Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Fri, 30 Jan 2015 22:39:11 +0300 Subject: [PATCH 278/722] net/pxe: fix error condition Test return value of grub_netbuff_reserve(), buf itself cannot be NULL here. Found by: Coverity scan. --- grub-core/net/drivers/i386/pc/pxe.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/grub-core/net/drivers/i386/pc/pxe.c b/grub-core/net/drivers/i386/pc/pxe.c index e8c0b22e2..3f4152d03 100644 --- a/grub-core/net/drivers/i386/pc/pxe.c +++ b/grub-core/net/drivers/i386/pc/pxe.c @@ -218,8 +218,7 @@ grub_pxe_recv (struct grub_net_card *dev __attribute__ ((unused))) return NULL; /* Reserve 2 bytes so that 2 + 14/18 bytes of ethernet header is divisible by 4. So that IP header is aligned on 4 bytes. */ - grub_netbuff_reserve (buf, 2); - if (!buf) + if (grub_netbuff_reserve (buf, 2)) { grub_netbuff_free (buf); return NULL; From 151c19a42a8ea76395fdb579221198156da9c026 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Fri, 30 Jan 2015 22:45:58 +0300 Subject: [PATCH 279/722] grub-fstest: fix descriptor leak Found by: Coverity scan. --- util/grub-fstest.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/grub-fstest.c b/util/grub-fstest.c index 31af2a7ad..02cd3e3e2 100644 --- a/util/grub-fstest.c +++ b/util/grub-fstest.c @@ -570,12 +570,12 @@ argp_parser (int key, char *arg, struct argp_state *state) return 0; } real_size = fread (buf, 1, 1024, f); + fclose (f); if (real_size < 0) { printf (_("%s: error:"), program_name); printf (_("cannot read `%s': %s"), arg, strerror (errno)); printf ("\n"); - fclose (f); return 0; } grub_zfs_add_key (buf, real_size, 0); From 016875dd52456c38c8dee55a8390c0f9fc092afe Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Fri, 30 Jan 2015 22:57:39 +0300 Subject: [PATCH 280/722] setup: fix blocklist size calculation Found by: Coverity scan. --- util/setup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/setup.c b/util/setup.c index b2991595b..8f20e9983 100644 --- a/util/setup.c +++ b/util/setup.c @@ -529,7 +529,7 @@ SETUP (const char *dir, bl.block = bl.first_block; while (bl.block->len) { - grub_memset (bl.block, 0, sizeof (bl.block)); + grub_memset (bl.block, 0, sizeof (*bl.block)); bl.block--; From c0f529ea679bdf48cbe1c4b3dd92fb552456a1fe Mon Sep 17 00:00:00 2001 From: Leif Lindholm Date: Tue, 3 Feb 2015 21:16:36 +0000 Subject: [PATCH 281/722] arm: implement additional relocations generated by gcc 4.9 at -O3 GCC 4.9 also generates R_ARM_THM_MOVW_ABS_NC and R_ARM_THM_MOVT_ABS, as an alternative to ABS32. Signed-off-by: Leif Lindholm --- grub-core/kern/arm/dl.c | 15 +++++++++++++ grub-core/kern/arm/dl_helper.c | 39 ++++++++++++++++++++++++++++++++++ include/grub/arm/reloc.h | 5 +++++ 3 files changed, 59 insertions(+) diff --git a/grub-core/kern/arm/dl.c b/grub-core/kern/arm/dl.c index 57cac2e75..5cbd65e46 100644 --- a/grub-core/kern/arm/dl.c +++ b/grub-core/kern/arm/dl.c @@ -205,6 +205,21 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr, */ case R_ARM_V4BX: break; + case R_ARM_THM_MOVW_ABS_NC: + case R_ARM_THM_MOVT_ABS: + { + grub_uint32_t offset; + offset = grub_arm_thm_movw_movt_get_value((grub_uint16_t *) target); + offset += sym_addr; + + if (ELF_R_TYPE (rel->r_info) == R_ARM_THM_MOVT_ABS) + offset >>= 16; + else + offset &= 0xffff; + + grub_arm_thm_movw_movt_set_value((grub_uint16_t *) target, offset); + } + break; case R_ARM_THM_JUMP19: { /* Thumb instructions can be 16-bit aligned */ diff --git a/grub-core/kern/arm/dl_helper.c b/grub-core/kern/arm/dl_helper.c index 5721939c1..8a7263291 100644 --- a/grub-core/kern/arm/dl_helper.c +++ b/grub-core/kern/arm/dl_helper.c @@ -25,6 +25,20 @@ #include #include +static inline grub_uint32_t +thumb_get_instruction_word(grub_uint16_t *target) +{ + /* Extract instruction word in alignment-safe manner */ + return grub_le_to_cpu16 ((*target)) << 16 | grub_le_to_cpu16 (*(target + 1)); +} + +static inline void +thumb_set_instruction_word(grub_uint16_t *target, grub_uint32_t insword) +{ + *target = grub_cpu_to_le16 (insword >> 16); + *(target + 1) = grub_cpu_to_le16 (insword & 0xffff); +} + /* * R_ARM_ABS32 * @@ -214,3 +228,28 @@ grub_arm_jump24_set_offset (grub_uint32_t *target, *target = grub_cpu_to_le32 (insword); } + +grub_uint16_t +grub_arm_thm_movw_movt_get_value (grub_uint16_t *target) +{ + grub_uint32_t insword; + + insword = thumb_get_instruction_word (target); + + return ((insword & 0xf0000) >> 4) | ((insword & 0x04000000) >> 15) | \ + ((insword & 0x7000) >> 4) | (insword & 0xff); +} + +void +grub_arm_thm_movw_movt_set_value (grub_uint16_t *target, grub_uint16_t value) +{ + grub_uint32_t insword; + + insword = thumb_get_instruction_word (target); + insword &= 0xfbf08f00; + + insword |= ((value & 0xf000) << 4) | ((value & 0x0800) << 15) | \ + ((value & 0x0700) << 4) | (value & 0xff); + + thumb_set_instruction_word (target, insword); +} diff --git a/include/grub/arm/reloc.h b/include/grub/arm/reloc.h index b938037a0..ae92e21f1 100644 --- a/include/grub/arm/reloc.h +++ b/include/grub/arm/reloc.h @@ -43,4 +43,9 @@ void grub_arm_jump24_set_offset (grub_uint32_t *target, grub_int32_t offset); +grub_uint16_t +grub_arm_thm_movw_movt_get_value (grub_uint16_t *target); +void +grub_arm_thm_movw_movt_set_value (grub_uint16_t *target, grub_uint16_t value); + #endif From 32cd33bd19348afb77ab849846e0b6d6157ea308 Mon Sep 17 00:00:00 2001 From: Jiri Slaby Date: Thu, 12 Feb 2015 11:02:09 +0100 Subject: [PATCH 282/722] util: mkimage, fix gcc5 build failure gcc5 reports: ../util/mkimage.c: In function 'grub_install_get_image_target': ../util/mkimage.c:954:5: error: loop exit may only be reached after undefined behavior [-Werror=aggressive-loop-optimizations] && j < ARRAY_SIZE (image_targets[i].names); j++) ^ ../util/mkimage.c:953:39: note: possible undefined statement is here for (j = 0; image_targets[i].names[j] ^ Well, let's move the index 'j' test before accesing the array to: 1) make the loop obvious 2) make gcc happy Signed-off-by: Jiri Slaby --- util/mkimage.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/util/mkimage.c b/util/mkimage.c index bccd70388..7821dc5ea 100644 --- a/util/mkimage.c +++ b/util/mkimage.c @@ -937,8 +937,8 @@ grub_install_get_image_target (const char *arg) { unsigned i, j; for (i = 0; i < ARRAY_SIZE (image_targets); i++) - for (j = 0; image_targets[i].names[j] - && j < ARRAY_SIZE (image_targets[i].names); j++) + for (j = 0; j < ARRAY_SIZE (image_targets[i].names) && + image_targets[i].names[j]; j++) if (strcmp (arg, image_targets[i].names[j]) == 0) return &image_targets[i]; return NULL; From e27fdbd6866a3dc9c6ee4d777d89c861f04368e7 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sat, 14 Feb 2015 17:55:35 +0300 Subject: [PATCH 283/722] diskfilter: fix crash in validate_lv for mdraid arrays Commit 750f4bacd3262376ced3f837d8dc78f834ca233a put LV validation before actual vg assignment. Make grub_diskfilter_make_raid to assign ->vg as happens in other cases for consistency. Also clean up redundant code and add explicit NULL lv->vg check in validate_lv. Also fix segment validation in validate_lv; it became obvious when crash was fixed. Closes: 44199 --- grub-core/disk/diskfilter.c | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/grub-core/disk/diskfilter.c b/grub-core/disk/diskfilter.c index 80966ac01..ad558fa14 100644 --- a/grub-core/disk/diskfilter.c +++ b/grub-core/disk/diskfilter.c @@ -496,13 +496,13 @@ validate_lv (struct grub_diskfilter_lv *lv) if (!lv) return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "unknown volume"); - if (lv->vg->extent_size == 0) + if (!lv->vg || lv->vg->extent_size == 0) return grub_error (GRUB_ERR_READ_ERROR, "invalid volume"); for (i = 0; i < lv->segment_count; i++) { grub_err_t err; - err = validate_segment (&lv->segments[1]); + err = validate_segment (&lv->segments[i]); if (err) return err; } @@ -941,8 +941,10 @@ grub_diskfilter_vg_register (struct grub_diskfilter_vg *vg) for (lv = vg->lvs; lv; lv = lv->next) { - /* RAID 1 and single-disk RAID 0 don't use a chunksize but code assumes one so set - one. */ + grub_err_t err; + + /* RAID 1 and single-disk RAID 0 don't use a chunksize but code + assumes one so set one. */ for (i = 0; i < lv->segment_count; i++) { if (lv->segments[i].type == 1) @@ -952,17 +954,6 @@ grub_diskfilter_vg_register (struct grub_diskfilter_vg *vg) && lv->segments[i].stripe_size == 0) lv->segments[i].stripe_size = 64; } - } - - for (lv = vg->lvs; lv; lv = lv->next) - { - grub_err_t err; - - /* RAID 1 doesn't use a chunksize but code assumes one so set - one. */ - for (i = 0; i < lv->segment_count; i++) - if (lv->segments[i].type == 1) - lv->segments[i].stripe_size = 64; err = validate_lv(lv); if (err) @@ -1007,7 +998,6 @@ grub_diskfilter_vg_register (struct grub_diskfilter_vg *vg) lv->fullname = tmp; } } - lv->vg = vg; } /* Add our new array to the list. */ vg->next = array_list; @@ -1101,6 +1091,7 @@ grub_diskfilter_make_raid (grub_size_t uuidlen, char *uuid, int nmemb, array->lvs->visible = 1; array->lvs->name = array->name; array->lvs->fullname = array->name; + array->lvs->vg = array; array->lvs->idname = grub_malloc (sizeof ("mduuid/") + 2 * uuidlen); if (!array->lvs->idname) From fc535b32b9fe0cd84213724ffba43b98e2da6ab4 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sat, 14 Feb 2015 19:08:58 +0300 Subject: [PATCH 284/722] diskfilter: fix double free of lv names for mdraid Avoid micro-optimization in grub_diskfilter_make_raid and make sure name and fullname are independent strings. This avoids need to special case it everywhere else. Also fix memory leak in failure case in grub_diskfilter_make_raid. Closes: 41582 --- grub-core/disk/diskfilter.c | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/grub-core/disk/diskfilter.c b/grub-core/disk/diskfilter.c index ad558fa14..1b7464d74 100644 --- a/grub-core/disk/diskfilter.c +++ b/grub-core/disk/diskfilter.c @@ -1089,8 +1089,15 @@ grub_diskfilter_make_raid (grub_size_t uuidlen, char *uuid, int nmemb, goto fail; array->lvs->segment_count = 1; array->lvs->visible = 1; - array->lvs->name = array->name; - array->lvs->fullname = array->name; + if (array->name) + { + array->lvs->name = grub_strdup (array->name); + if (!array->lvs->name) + goto fail; + array->lvs->fullname = grub_strdup (array->name); + if (!array->lvs->fullname) + goto fail; + } array->lvs->vg = array; array->lvs->idname = grub_malloc (sizeof ("mduuid/") + 2 * uuidlen); @@ -1141,7 +1148,18 @@ grub_diskfilter_make_raid (grub_size_t uuidlen, char *uuid, int nmemb, return array; fail: - grub_free (array->lvs); + if (array->lvs) + { + grub_free (array->lvs->name); + grub_free (array->lvs->fullname); + grub_free (array->lvs->idname); + if (array->lvs->segments) + { + grub_free (array->lvs->segments->nodes); + grub_free (array->lvs->segments); + } + grub_free (array->lvs); + } while (array->pvs) { pv = array->pvs->next; @@ -1250,10 +1268,9 @@ free_array (void) { unsigned i; vg->lvs = lv->next; - if (lv->name != lv->fullname) - grub_free (lv->fullname); - if (lv->name != vg->name) - grub_free (lv->name); + grub_free (lv->fullname); + grub_free (lv->name); + grub_free (lv->idname); for (i = 0; i < lv->segment_count; i++) grub_free (lv->segments[i].nodes); grub_free (lv->segments); From 8e5bc2f4d3767485e729ed96ea943570d1cb1e45 Mon Sep 17 00:00:00 2001 From: Daniel Kiper Date: Fri, 30 Jan 2015 18:59:24 +0100 Subject: [PATCH 285/722] multiboot2: Fix information request tag size calculation Signed-off-by: Daniel Kiper --- grub-core/loader/multiboot_mbi2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/loader/multiboot_mbi2.c b/grub-core/loader/multiboot_mbi2.c index 6f74aeef7..d7c19bc99 100644 --- a/grub-core/loader/multiboot_mbi2.c +++ b/grub-core/loader/multiboot_mbi2.c @@ -150,7 +150,7 @@ grub_multiboot_load (grub_file_t file, const char *filename) = (struct multiboot_header_tag_information_request *) tag; if (request_tag->flags & MULTIBOOT_HEADER_TAG_OPTIONAL) break; - for (i = 0; i < (request_tag->size - sizeof (request_tag)) + for (i = 0; i < (request_tag->size - sizeof (*request_tag)) / sizeof (request_tag->requests[0]); i++) switch (request_tag->requests[i]) { From 2ae9457e6eb4c352051fb32bc6fc931a22528ab2 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sat, 14 Feb 2015 20:31:00 +0100 Subject: [PATCH 286/722] disk/lvm: Use zalloc to ensure that segments are initialised to sane value. Reported by: EmanueL Czirai. --- grub-core/disk/lvm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/disk/lvm.c b/grub-core/disk/lvm.c index 862a9664f..1e7f197f0 100644 --- a/grub-core/disk/lvm.c +++ b/grub-core/disk/lvm.c @@ -426,7 +426,7 @@ grub_lvm_detect (grub_disk_t disk, #endif goto lvs_fail; } - lv->segments = grub_malloc (sizeof (*seg) * lv->segment_count); + lv->segments = grub_zalloc (sizeof (*seg) * lv->segment_count); seg = lv->segments; for (i = 0; i < lv->segment_count; i++) From 8f5ebb1245446f8e26c64cf0ebbb514dfb1a8d57 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sun, 15 Feb 2015 10:10:03 +0300 Subject: [PATCH 287/722] diskfilter_make_raid: more memory leaks in failure path --- grub-core/disk/diskfilter.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/grub-core/disk/diskfilter.c b/grub-core/disk/diskfilter.c index 1b7464d74..c4f6678b6 100644 --- a/grub-core/disk/diskfilter.c +++ b/grub-core/disk/diskfilter.c @@ -1031,7 +1031,10 @@ grub_diskfilter_make_raid (grub_size_t uuidlen, char *uuid, int nmemb, if (n == 1) n = (layout >> 8) & 0xFF; if (n == 0) - return NULL; + { + grub_free (uuid); + return NULL; + } totsize = grub_divmod64 (nmemb * disk_size, n, 0); } @@ -1045,6 +1048,7 @@ grub_diskfilter_make_raid (grub_size_t uuidlen, char *uuid, int nmemb, break; default: + grub_free (uuid); return NULL; } @@ -1067,7 +1071,10 @@ grub_diskfilter_make_raid (grub_size_t uuidlen, char *uuid, int nmemb, } array = grub_zalloc (sizeof (*array)); if (!array) - return NULL; + { + grub_free (uuid); + return NULL; + } array->uuid = uuid; array->uuid_len = uuidlen; if (name) @@ -1166,6 +1173,8 @@ grub_diskfilter_make_raid (grub_size_t uuidlen, char *uuid, int nmemb, grub_free (array->pvs); array->pvs = pv; } + grub_free (array->name); + grub_free (array->uuid); grub_free (array); return NULL; } From b23635fcff62b68b6d5bfde541350095d743a13a Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 16 Feb 2015 10:54:20 +0100 Subject: [PATCH 288/722] syslinux_parse: Always output comments even if no entries are found. --- grub-core/lib/syslinux_parse.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/grub-core/lib/syslinux_parse.c b/grub-core/lib/syslinux_parse.c index 2c874b1fa..46eff1e5d 100644 --- a/grub-core/lib/syslinux_parse.c +++ b/grub-core/lib/syslinux_parse.c @@ -1430,6 +1430,13 @@ config_file (struct output_buffer *outbuf, print_string ("\n"); } + if (menu.comments) + { + err = print (outbuf, menu.comments, grub_strlen (menu.comments)); + if (err) + return err; + } + if (menu.timeout == 0 && menu.entries && menu.def) { err = print_entry (outbuf, &menu, menu.def); @@ -1446,12 +1453,6 @@ config_file (struct output_buffer *outbuf, if (err) return err; print_string ("\n"); - if (menu.comments) - { - err = print (outbuf, menu.comments, grub_strlen (menu.comments)); - if (err) - return err; - } if (menu.def) { From e29af836d02a267d6ad9bd6eba808d5bf0a96949 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 16 Feb 2015 15:56:26 +0100 Subject: [PATCH 289/722] Don't remove initrd= parameter. Based on simplified patch by Lunar. Reported by: Lunar --- grub-core/lib/syslinux_parse.c | 28 +++++++--------------------- 1 file changed, 7 insertions(+), 21 deletions(-) diff --git a/grub-core/lib/syslinux_parse.c b/grub-core/lib/syslinux_parse.c index 46eff1e5d..afc12b502 100644 --- a/grub-core/lib/syslinux_parse.c +++ b/grub-core/lib/syslinux_parse.c @@ -869,7 +869,6 @@ write_entry (struct output_buffer *outbuf, case KERNEL_LINUX: { char *ptr; - char *cmdline; char *initrd = NULL; for (ptr = curentry->append; ptr && *ptr; ptr++) if ((ptr == curentry->append || grub_isspace (ptr[-1])) @@ -879,31 +878,19 @@ write_entry (struct output_buffer *outbuf, if (ptr && *ptr) { char *ptr2; - grub_size_t totlen = grub_strlen (curentry->append); - initrd = ptr + sizeof ("initrd=") - 1; - for (ptr2 = ptr; *ptr2 && !grub_isspace (*ptr2); ptr2++); - if (*ptr2) - { - *ptr2 = 0; - ptr2++; - } - cmdline = grub_malloc (totlen + 1 - (ptr2 - ptr)); - if (!cmdline) + initrd = grub_strdup(ptr + sizeof ("initrd=") - 1); + if (!initrd) return grub_errno; - grub_memcpy (cmdline, curentry->append, ptr - curentry->append); - grub_memcpy (cmdline + (ptr - curentry->append), - ptr2, totlen - (ptr2 - curentry->append)); - *(cmdline + totlen - (ptr2 - ptr)) = 0; + for (ptr2 = initrd; *ptr2 && !grub_isspace (*ptr2); ptr2++); + *ptr2 = 0; } - else - cmdline = curentry->append; print_string (" if test x$grub_platform = xpc; then " "linux_suffix=16; else linux_suffix= ; fi\n"); print_string (" linux$linux_suffix "); print_file (outbuf, menu, curentry->kernel_file, NULL); print_string (" "); - if (cmdline) - print (outbuf, cmdline, grub_strlen (cmdline)); + if (curentry->append) + print (outbuf, curentry->append, grub_strlen (curentry->append)); print_string ("\n"); if (initrd || curentry->initrds) { @@ -922,8 +909,7 @@ write_entry (struct output_buffer *outbuf, print_string ("\n"); } - if (ptr && *ptr) - grub_free (cmdline); + grub_free (initrd); } break; case KERNEL_CHAINLOADER: From d3d2e549119477d92b506477fd923c51162b9beb Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 16 Feb 2015 15:58:59 +0100 Subject: [PATCH 290/722] Add test for syslinux converter --- Makefile.util.def | 6 + tests/syslinux/ubuntu10.04/isolinux/adtxt.cfg | 0 .../syslinux/ubuntu10.04/isolinux/dtmenu.cfg | 52 ++++ .../ubuntu10.04/isolinux/exithelp.cfg | 3 + .../syslinux/ubuntu10.04/isolinux/gfxboot.cfg | 12 + .../ubuntu10.04/isolinux/isolinux.cfg | 6 + tests/syslinux/ubuntu10.04/isolinux/menu.cfg | 23 ++ tests/syslinux/ubuntu10.04/isolinux/po4a.cfg | 3 + .../syslinux/ubuntu10.04/isolinux/prompt.cfg | 16 ++ tests/syslinux/ubuntu10.04/isolinux/rqtxt.cfg | 4 + .../syslinux/ubuntu10.04/isolinux/stdmenu.cfg | 15 ++ tests/syslinux/ubuntu10.04/isolinux/txt.cfg | 19 ++ tests/syslinux/ubuntu10.04_grub.cfg | 236 ++++++++++++++++++ tests/syslinux_test.in | 16 ++ 14 files changed, 411 insertions(+) create mode 100644 tests/syslinux/ubuntu10.04/isolinux/adtxt.cfg create mode 100644 tests/syslinux/ubuntu10.04/isolinux/dtmenu.cfg create mode 100644 tests/syslinux/ubuntu10.04/isolinux/exithelp.cfg create mode 100644 tests/syslinux/ubuntu10.04/isolinux/gfxboot.cfg create mode 100644 tests/syslinux/ubuntu10.04/isolinux/isolinux.cfg create mode 100644 tests/syslinux/ubuntu10.04/isolinux/menu.cfg create mode 100644 tests/syslinux/ubuntu10.04/isolinux/po4a.cfg create mode 100644 tests/syslinux/ubuntu10.04/isolinux/prompt.cfg create mode 100644 tests/syslinux/ubuntu10.04/isolinux/rqtxt.cfg create mode 100644 tests/syslinux/ubuntu10.04/isolinux/stdmenu.cfg create mode 100644 tests/syslinux/ubuntu10.04/isolinux/txt.cfg create mode 100644 tests/syslinux/ubuntu10.04_grub.cfg create mode 100644 tests/syslinux_test.in diff --git a/Makefile.util.def b/Makefile.util.def index 378b5777a..67dfb2976 100644 --- a/Makefile.util.def +++ b/Makefile.util.def @@ -1162,6 +1162,12 @@ script = { common = tests/grub_cmd_test.in; }; +script = { + testcase; + name = syslinux_test; + common = tests/syslinux_test.in; +}; + program = { testcase; name = example_unit_test; diff --git a/tests/syslinux/ubuntu10.04/isolinux/adtxt.cfg b/tests/syslinux/ubuntu10.04/isolinux/adtxt.cfg new file mode 100644 index 000000000..e69de29bb diff --git a/tests/syslinux/ubuntu10.04/isolinux/dtmenu.cfg b/tests/syslinux/ubuntu10.04/isolinux/dtmenu.cfg new file mode 100644 index 000000000..2e107fade --- /dev/null +++ b/tests/syslinux/ubuntu10.04/isolinux/dtmenu.cfg @@ -0,0 +1,52 @@ +menu hshift 9 +menu width 58 + +menu begin desktop + include stdmenu.cfg + menu hshift 13 + menu width 49 + menu label Alternative desktop environments + menu title Desktop environment menu + label mainmenu-kde + menu label ^Back.. + text help + Higher level options install the GNOME desktop environment + endtext + menu exit + menu begin kde-desktop + include stdmenu.cfg + menu label ^KDE + menu title KDE desktop boot menu + text help + Select the 'K Desktop Environment' for the Desktop task + endtext + label mainmenu-kde + menu label ^Back.. + menu exit + include kde/menu.cfg + menu end + menu begin lxde-desktop + include stdmenu.cfg + menu label ^LXDE + menu title LXDE desktop boot menu + text help + Select the 'Lightweight X11 Desktop Environment' for the Desktop task + endtext + label mainmenu-lxde + menu label ^Back.. + menu exit + include lxde/menu.cfg + menu end + menu begin xfce-desktop + include stdmenu.cfg + menu label ^Xfce + menu title Xfce desktop boot menu + text help + Select the 'Xfce lightweight desktop environment' for the Desktop task + endtext + label mainmenu-xfce + menu label ^Back.. + menu exit + include xfce/menu.cfg + menu end +menu end diff --git a/tests/syslinux/ubuntu10.04/isolinux/exithelp.cfg b/tests/syslinux/ubuntu10.04/isolinux/exithelp.cfg new file mode 100644 index 000000000..3119e654a --- /dev/null +++ b/tests/syslinux/ubuntu10.04/isolinux/exithelp.cfg @@ -0,0 +1,3 @@ +label menu + kernel vesamenu.c32 + config isolinux.cfg diff --git a/tests/syslinux/ubuntu10.04/isolinux/gfxboot.cfg b/tests/syslinux/ubuntu10.04/isolinux/gfxboot.cfg new file mode 100644 index 000000000..b799cb5cb --- /dev/null +++ b/tests/syslinux/ubuntu10.04/isolinux/gfxboot.cfg @@ -0,0 +1,12 @@ +foreground=0xFFFFFF +background=0x958490 +screen-colour=0x270A1E +hidden-timeout=2 +label normal=Normal +append normal= +label driverupdates=Use driver update disc +append driverupdates=debian-installer/driver-update=true +applies driverupdates=live live-install +label oem=OEM install (for manufacturers) +append oem=oem-config/enable=true +applies oem=live live-install install diff --git a/tests/syslinux/ubuntu10.04/isolinux/isolinux.cfg b/tests/syslinux/ubuntu10.04/isolinux/isolinux.cfg new file mode 100644 index 000000000..fd9c333b2 --- /dev/null +++ b/tests/syslinux/ubuntu10.04/isolinux/isolinux.cfg @@ -0,0 +1,6 @@ +# D-I config version 2.0 +include menu.cfg +default vesamenu.c32 +prompt 0 +timeout 50 +ui gfxboot bootlogo diff --git a/tests/syslinux/ubuntu10.04/isolinux/menu.cfg b/tests/syslinux/ubuntu10.04/isolinux/menu.cfg new file mode 100644 index 000000000..9f5607dea --- /dev/null +++ b/tests/syslinux/ubuntu10.04/isolinux/menu.cfg @@ -0,0 +1,23 @@ +menu hshift 13 +menu width 49 +menu margin 8 + +menu title Installer boot menu +include stdmenu.cfg +include txt.cfg +include gtk.cfg +menu begin advanced + menu title Advanced options + include stdmenu.cfg + label mainmenu + menu label ^Back.. + menu exit + include adtxt.cfg + include adgtk.cfg +menu end +label help + menu label ^Help + text help + Display help screens; type 'menu' at boot prompt to return to this menu + endtext + config prompt.cfg diff --git a/tests/syslinux/ubuntu10.04/isolinux/po4a.cfg b/tests/syslinux/ubuntu10.04/isolinux/po4a.cfg new file mode 100644 index 000000000..75f67881c --- /dev/null +++ b/tests/syslinux/ubuntu10.04/isolinux/po4a.cfg @@ -0,0 +1,3 @@ +[po4a_langs] ar bn ca cs da de es eu fi fr gl hu id it ja ka ko ku lv nb nl pl pt pt_BR ru sk sv ta tr vi zh_CN zh_TW +[po4a_paths] po/help.pot $lang:po/$lang.po +[type:docbook] help.xml diff --git a/tests/syslinux/ubuntu10.04/isolinux/prompt.cfg b/tests/syslinux/ubuntu10.04/isolinux/prompt.cfg new file mode 100644 index 000000000..f9984aedc --- /dev/null +++ b/tests/syslinux/ubuntu10.04/isolinux/prompt.cfg @@ -0,0 +1,16 @@ +prompt 1 +display f1.txt +timeout 50 +include menu.cfg +include exithelp.cfg + +f1 f1.txt +f2 f2.txt +f3 f3.txt +f4 f4.txt +f5 f5.txt +f6 f6.txt +f7 f7.txt +f8 f8.txt +f9 f9.txt +f0 f10.txt diff --git a/tests/syslinux/ubuntu10.04/isolinux/rqtxt.cfg b/tests/syslinux/ubuntu10.04/isolinux/rqtxt.cfg new file mode 100644 index 000000000..bdf6231ae --- /dev/null +++ b/tests/syslinux/ubuntu10.04/isolinux/rqtxt.cfg @@ -0,0 +1,4 @@ +label rescue + menu label ^Rescue mode + kernel /install/vmlinuz + append vga=788 initrd=/install/initrd.gz rescue/enable=true -- quiet diff --git a/tests/syslinux/ubuntu10.04/isolinux/stdmenu.cfg b/tests/syslinux/ubuntu10.04/isolinux/stdmenu.cfg new file mode 100644 index 000000000..671b16f78 --- /dev/null +++ b/tests/syslinux/ubuntu10.04/isolinux/stdmenu.cfg @@ -0,0 +1,15 @@ +menu background splash.png +menu color title * #FFFFFFFF * +menu color border * #00000000 #00000000 none +menu color sel * #ffffffff #76a1d0ff * +menu color hotsel 1;7;37;40 #ffffffff #76a1d0ff * +menu color tabmsg * #ffffffff #00000000 * +menu color help 37;40 #ffdddd00 #00000000 none +menu vshift 12 +menu rows 10 +menu helpmsgrow 15 +# The command line must be at least one line from the bottom. +menu cmdlinerow 16 +menu timeoutrow 16 +menu tabmsgrow 18 +menu tabmsg Press ENTER to boot or TAB to edit a menu entry diff --git a/tests/syslinux/ubuntu10.04/isolinux/txt.cfg b/tests/syslinux/ubuntu10.04/isolinux/txt.cfg new file mode 100644 index 000000000..860daad80 --- /dev/null +++ b/tests/syslinux/ubuntu10.04/isolinux/txt.cfg @@ -0,0 +1,19 @@ +default live +label live + menu label ^Try Ubuntu without installing + kernel /casper/vmlinuz + append file=/cdrom/preseed/ubuntu.seed boot=casper initrd=/casper/initrd.lz quiet splash -- +label live-install + menu label ^Install Ubuntu + kernel /casper/vmlinuz + append file=/cdrom/preseed/ubuntu.seed boot=casper only-ubiquity initrd=/casper/initrd.lz quiet splash -- +label check + menu label ^Check disc for defects + kernel /casper/vmlinuz + append boot=casper integrity-check initrd=/casper/initrd.lz quiet splash -- +label memtest + menu label Test ^memory + kernel /install/mt86plus +label hd + menu label ^Boot from first hard disk + localboot 0x80 diff --git a/tests/syslinux/ubuntu10.04_grub.cfg b/tests/syslinux/ubuntu10.04_grub.cfg new file mode 100644 index 000000000..e6bd82cbe --- /dev/null +++ b/tests/syslinux/ubuntu10.04_grub.cfg @@ -0,0 +1,236 @@ + background_image '/home/phcoder/grub2/git/tests/syslinux/ubuntu10.04/isolinux'/'splash.png' +# D-I config version 2.0 + # UNSUPPORTED command 'menu hshift 13' + # UNSUPPORTED command 'menu width 49' + # UNSUPPORTED command 'menu margin 8' + + # UNSUPPORTED command 'menu title Installer boot menu' + # UNSUPPORTED command 'menu color title * #FFFFFFFF *' + # UNSUPPORTED command 'menu color border * #00000000 #00000000 none' + # UNSUPPORTED command 'menu color sel * #ffffffff #76a1d0ff *' + # UNSUPPORTED command 'menu color hotsel 1;7;37;40 #ffffffff #76a1d0ff *' + # UNSUPPORTED command 'menu color tabmsg * #ffffffff #00000000 *' + # UNSUPPORTED command 'menu color help 37;40 #ffdddd00 #00000000 none' + # UNSUPPORTED command 'menu vshift 12' + # UNSUPPORTED command 'menu rows 10' + # UNSUPPORTED command 'menu helpmsgrow 15' +# The command line must be at least one line from the bottom. + # UNSUPPORTED command 'menu cmdlinerow 16' + # UNSUPPORTED command 'menu timeoutrow 16' + # UNSUPPORTED command 'menu tabmsgrow 18' + # UNSUPPORTED command 'menu tabmsg Press ENTER to boot or TAB to edit a menu entry' +set timeout=5 + default='vesamenu.c32' +menuentry 'Try Ubuntu without installing' --hotkey 't' --id 'live' { + if test x$grub_platform = xpc; then linux_suffix=16; else linux_suffix= ; fi + linux$linux_suffix '/'/'/casper/vmlinuz' file=/cdrom/preseed/ubuntu.seed boot=casper initrd=/casper/initrd.lz quiet splash -- + initrd$linux_suffix '/'/'/casper/initrd.lz' +} +menuentry 'Install Ubuntu' --hotkey 'i' --id 'live-install' { + if test x$grub_platform = xpc; then linux_suffix=16; else linux_suffix= ; fi + linux$linux_suffix '/'/'/casper/vmlinuz' file=/cdrom/preseed/ubuntu.seed boot=casper only-ubiquity initrd=/casper/initrd.lz quiet splash -- + initrd$linux_suffix '/'/'/casper/initrd.lz' +} +menuentry 'Check disc for defects' --hotkey 'c' --id 'check' { + if test x$grub_platform = xpc; then linux_suffix=16; else linux_suffix= ; fi + linux$linux_suffix '/'/'/casper/vmlinuz' boot=casper integrity-check initrd=/casper/initrd.lz quiet splash -- + initrd$linux_suffix '/'/'/casper/initrd.lz' +} +menuentry 'Test memory' --hotkey 'm' --id 'memtest' { + if test x$grub_platform = xpc; then linux_suffix=16; else linux_suffix= ; fi + linux$linux_suffix '/'/'/install/mt86plus' +} +menuentry 'Boot from first hard disk' --hotkey 'b' --id 'hd' { +# File (host)//home/phcoder/grub2/git/tests/syslinux/ubuntu10.04/isolinux/gtk.cfg not found + # UNSUPPORTED command 'menu begin advanced' + # UNSUPPORTED command 'menu title Advanced options' + # UNSUPPORTED command 'menu color title * #FFFFFFFF *' + # UNSUPPORTED command 'menu color border * #00000000 #00000000 none' + # UNSUPPORTED command 'menu color sel * #ffffffff #76a1d0ff *' + # UNSUPPORTED command 'menu color hotsel 1;7;37;40 #ffffffff #76a1d0ff *' + # UNSUPPORTED command 'menu color tabmsg * #ffffffff #00000000 *' + # UNSUPPORTED command 'menu color help 37;40 #ffdddd00 #00000000 none' + # UNSUPPORTED command 'menu vshift 12' + # UNSUPPORTED command 'menu rows 10' + # UNSUPPORTED command 'menu helpmsgrow 15' +# The command line must be at least one line from the bottom. + # UNSUPPORTED command 'menu cmdlinerow 16' + # UNSUPPORTED command 'menu timeoutrow 16' + # UNSUPPORTED command 'menu tabmsgrow 18' + # UNSUPPORTED command 'menu tabmsg Press ENTER to boot or TAB to edit a menu entry' + root=hd0; + chainloader +1; +} +menuentry 'Back..' --hotkey 'b' --id 'mainmenu' { + # UNSUPPORTED command 'menu exit' +# File (host)//home/phcoder/grub2/git/tests/syslinux/ubuntu10.04/isolinux/adgtk.cfg not found + # UNSUPPORTED command 'menu end' + # UNSUPPORTED entry type 0 +true; +} +menuentry 'Help' --hotkey 'h' --id 'help' { + # UNSUPPORTED command 'ui gfxboot bootlogo' +#'/home/phcoder/grub2/git/tests/syslinux/ubuntu10.04/isolinux'/'prompt.cfg' (host)/home/phcoder/grub2/git/tests/syslinux/ubuntu10.04/isolinux/prompt.cfg: + background_image '/home/phcoder/grub2/git/tests/syslinux/ubuntu10.04/isolinux/'/'splash.png' + # UNSUPPORTED command 'display f1.txt' + # UNSUPPORTED command 'menu hshift 13' + # UNSUPPORTED command 'menu width 49' + # UNSUPPORTED command 'menu margin 8' + + # UNSUPPORTED command 'menu title Installer boot menu' + # UNSUPPORTED command 'menu color title * #FFFFFFFF *' + # UNSUPPORTED command 'menu color border * #00000000 #00000000 none' + # UNSUPPORTED command 'menu color sel * #ffffffff #76a1d0ff *' + # UNSUPPORTED command 'menu color hotsel 1;7;37;40 #ffffffff #76a1d0ff *' + # UNSUPPORTED command 'menu color tabmsg * #ffffffff #00000000 *' + # UNSUPPORTED command 'menu color help 37;40 #ffdddd00 #00000000 none' + # UNSUPPORTED command 'menu vshift 12' + # UNSUPPORTED command 'menu rows 10' + # UNSUPPORTED command 'menu helpmsgrow 15' +# The command line must be at least one line from the bottom. + # UNSUPPORTED command 'menu cmdlinerow 16' + # UNSUPPORTED command 'menu timeoutrow 16' + # UNSUPPORTED command 'menu tabmsgrow 18' + # UNSUPPORTED command 'menu tabmsg Press ENTER to boot or TAB to edit a menu entry' +set timeout=5 + default='live' +menuentry 'Try Ubuntu without installing' --hotkey 't' --id 'live' { + if test x$grub_platform = xpc; then linux_suffix=16; else linux_suffix= ; fi + linux$linux_suffix '/'/'/casper/vmlinuz' file=/cdrom/preseed/ubuntu.seed boot=casper initrd=/casper/initrd.lz quiet splash -- + initrd$linux_suffix '/'/'/casper/initrd.lz' +} +menuentry 'Install Ubuntu' --hotkey 'i' --id 'live-install' { + if test x$grub_platform = xpc; then linux_suffix=16; else linux_suffix= ; fi + linux$linux_suffix '/'/'/casper/vmlinuz' file=/cdrom/preseed/ubuntu.seed boot=casper only-ubiquity initrd=/casper/initrd.lz quiet splash -- + initrd$linux_suffix '/'/'/casper/initrd.lz' +} +menuentry 'Check disc for defects' --hotkey 'c' --id 'check' { + if test x$grub_platform = xpc; then linux_suffix=16; else linux_suffix= ; fi + linux$linux_suffix '/'/'/casper/vmlinuz' boot=casper integrity-check initrd=/casper/initrd.lz quiet splash -- + initrd$linux_suffix '/'/'/casper/initrd.lz' +} +menuentry 'Test memory' --hotkey 'm' --id 'memtest' { + if test x$grub_platform = xpc; then linux_suffix=16; else linux_suffix= ; fi + linux$linux_suffix '/'/'/install/mt86plus' +} +menuentry 'Boot from first hard disk' --hotkey 'b' --id 'hd' { +# File (host)//home/phcoder/grub2/git/tests/syslinux/ubuntu10.04/isolinux//gtk.cfg not found + # UNSUPPORTED command 'menu begin advanced' + # UNSUPPORTED command 'menu title Advanced options' + # UNSUPPORTED command 'menu color title * #FFFFFFFF *' + # UNSUPPORTED command 'menu color border * #00000000 #00000000 none' + # UNSUPPORTED command 'menu color sel * #ffffffff #76a1d0ff *' + # UNSUPPORTED command 'menu color hotsel 1;7;37;40 #ffffffff #76a1d0ff *' + # UNSUPPORTED command 'menu color tabmsg * #ffffffff #00000000 *' + # UNSUPPORTED command 'menu color help 37;40 #ffdddd00 #00000000 none' + # UNSUPPORTED command 'menu vshift 12' + # UNSUPPORTED command 'menu rows 10' + # UNSUPPORTED command 'menu helpmsgrow 15' +# The command line must be at least one line from the bottom. + # UNSUPPORTED command 'menu cmdlinerow 16' + # UNSUPPORTED command 'menu timeoutrow 16' + # UNSUPPORTED command 'menu tabmsgrow 18' + # UNSUPPORTED command 'menu tabmsg Press ENTER to boot or TAB to edit a menu entry' + root=hd0; + chainloader +1; +} +menuentry 'Back..' --hotkey 'b' --id 'mainmenu' { + # UNSUPPORTED command 'menu exit' +# File (host)//home/phcoder/grub2/git/tests/syslinux/ubuntu10.04/isolinux//adgtk.cfg not found + # UNSUPPORTED command 'menu end' + # UNSUPPORTED entry type 0 +true; +} +menuentry 'Help' --hotkey 'h' --id 'help' { +#'/home/phcoder/grub2/git/tests/syslinux/ubuntu10.04/isolinux/'/'prompt.cfg' (host)/home/phcoder/grub2/git/tests/syslinux/ubuntu10.04/isolinux/prompt.cfg: + syslinux_configfile -r '/'/'/' -c '/home/phcoder/grub2/git/tests/syslinux/ubuntu10.04/isolinux/'/'' '/home/phcoder/grub2/git/tests/syslinux/ubuntu10.04/isolinux/'/'prompt.cfg' +} +menuentry 'menu' --id 'menu' { + # UNSUPPORTED command 'f1 f1.txt' + # UNSUPPORTED command 'f2 f2.txt' + # UNSUPPORTED command 'f3 f3.txt' + # UNSUPPORTED command 'f4 f4.txt' + # UNSUPPORTED command 'f5 f5.txt' + # UNSUPPORTED command 'f6 f6.txt' + # UNSUPPORTED command 'f7 f7.txt' + # UNSUPPORTED command 'f8 f8.txt' + # UNSUPPORTED command 'f9 f9.txt' + # UNSUPPORTED command 'f0 f10.txt' +#'/home/phcoder/grub2/git/tests/syslinux/ubuntu10.04/isolinux/'/'isolinux.cfg' (host)/home/phcoder/grub2/git/tests/syslinux/ubuntu10.04/isolinux/isolinux.cfg: + background_image '/home/phcoder/grub2/git/tests/syslinux/ubuntu10.04/isolinux//'/'splash.png' +# D-I config version 2.0 + # UNSUPPORTED command 'menu hshift 13' + # UNSUPPORTED command 'menu width 49' + # UNSUPPORTED command 'menu margin 8' + + # UNSUPPORTED command 'menu title Installer boot menu' + # UNSUPPORTED command 'menu color title * #FFFFFFFF *' + # UNSUPPORTED command 'menu color border * #00000000 #00000000 none' + # UNSUPPORTED command 'menu color sel * #ffffffff #76a1d0ff *' + # UNSUPPORTED command 'menu color hotsel 1;7;37;40 #ffffffff #76a1d0ff *' + # UNSUPPORTED command 'menu color tabmsg * #ffffffff #00000000 *' + # UNSUPPORTED command 'menu color help 37;40 #ffdddd00 #00000000 none' + # UNSUPPORTED command 'menu vshift 12' + # UNSUPPORTED command 'menu rows 10' + # UNSUPPORTED command 'menu helpmsgrow 15' +# The command line must be at least one line from the bottom. + # UNSUPPORTED command 'menu cmdlinerow 16' + # UNSUPPORTED command 'menu timeoutrow 16' + # UNSUPPORTED command 'menu tabmsgrow 18' + # UNSUPPORTED command 'menu tabmsg Press ENTER to boot or TAB to edit a menu entry' +set timeout=5 + default='vesamenu.c32' +menuentry 'Try Ubuntu without installing' --hotkey 't' --id 'live' { + if test x$grub_platform = xpc; then linux_suffix=16; else linux_suffix= ; fi + linux$linux_suffix '/'/'/casper/vmlinuz' file=/cdrom/preseed/ubuntu.seed boot=casper initrd=/casper/initrd.lz quiet splash -- + initrd$linux_suffix '/'/'/casper/initrd.lz' +} +menuentry 'Install Ubuntu' --hotkey 'i' --id 'live-install' { + if test x$grub_platform = xpc; then linux_suffix=16; else linux_suffix= ; fi + linux$linux_suffix '/'/'/casper/vmlinuz' file=/cdrom/preseed/ubuntu.seed boot=casper only-ubiquity initrd=/casper/initrd.lz quiet splash -- + initrd$linux_suffix '/'/'/casper/initrd.lz' +} +menuentry 'Check disc for defects' --hotkey 'c' --id 'check' { + if test x$grub_platform = xpc; then linux_suffix=16; else linux_suffix= ; fi + linux$linux_suffix '/'/'/casper/vmlinuz' boot=casper integrity-check initrd=/casper/initrd.lz quiet splash -- + initrd$linux_suffix '/'/'/casper/initrd.lz' +} +menuentry 'Test memory' --hotkey 'm' --id 'memtest' { + if test x$grub_platform = xpc; then linux_suffix=16; else linux_suffix= ; fi + linux$linux_suffix '/'/'/install/mt86plus' +} +menuentry 'Boot from first hard disk' --hotkey 'b' --id 'hd' { +# File (host)//home/phcoder/grub2/git/tests/syslinux/ubuntu10.04/isolinux///gtk.cfg not found + # UNSUPPORTED command 'menu begin advanced' + # UNSUPPORTED command 'menu title Advanced options' + # UNSUPPORTED command 'menu color title * #FFFFFFFF *' + # UNSUPPORTED command 'menu color border * #00000000 #00000000 none' + # UNSUPPORTED command 'menu color sel * #ffffffff #76a1d0ff *' + # UNSUPPORTED command 'menu color hotsel 1;7;37;40 #ffffffff #76a1d0ff *' + # UNSUPPORTED command 'menu color tabmsg * #ffffffff #00000000 *' + # UNSUPPORTED command 'menu color help 37;40 #ffdddd00 #00000000 none' + # UNSUPPORTED command 'menu vshift 12' + # UNSUPPORTED command 'menu rows 10' + # UNSUPPORTED command 'menu helpmsgrow 15' +# The command line must be at least one line from the bottom. + # UNSUPPORTED command 'menu cmdlinerow 16' + # UNSUPPORTED command 'menu timeoutrow 16' + # UNSUPPORTED command 'menu tabmsgrow 18' + # UNSUPPORTED command 'menu tabmsg Press ENTER to boot or TAB to edit a menu entry' + root=hd0; + chainloader +1; +} +menuentry 'Back..' --hotkey 'b' --id 'mainmenu' { + # UNSUPPORTED command 'menu exit' +# File (host)//home/phcoder/grub2/git/tests/syslinux/ubuntu10.04/isolinux///adgtk.cfg not found + # UNSUPPORTED command 'menu end' + # UNSUPPORTED entry type 0 +true; +} +menuentry 'Help' --hotkey 'h' --id 'help' { + # UNSUPPORTED command 'ui gfxboot bootlogo' +#'/home/phcoder/grub2/git/tests/syslinux/ubuntu10.04/isolinux//'/'prompt.cfg' (host)/home/phcoder/grub2/git/tests/syslinux/ubuntu10.04/isolinux/prompt.cfg: + syslinux_configfile -r '/'/'/' -c '/home/phcoder/grub2/git/tests/syslinux/ubuntu10.04/isolinux//'/'' '/home/phcoder/grub2/git/tests/syslinux/ubuntu10.04/isolinux//'/'prompt.cfg' +} +} +} diff --git a/tests/syslinux_test.in b/tests/syslinux_test.in new file mode 100644 index 000000000..08d28da08 --- /dev/null +++ b/tests/syslinux_test.in @@ -0,0 +1,16 @@ +#!/bin/sh + +set -e + +outfile="`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"`" || exit 1 + +"@builddir@/grub-syslinux2cfg" -r "@srcdir@/tests/syslinux/ubuntu10.04" "@srcdir@/tests/syslinux/ubuntu10.04/isolinux/isolinux.cfg" -o "$outfile" + +echo "$outfile" + +if ! diff -u "$outfile" "@srcdir@/tests/syslinux/ubuntu10.04_grub.cfg"; then + echo "Mismatch in ubuntu10.04" + exit 1; +fi + +exit 0 From 251ddf26dc80d1fa91ca3f242da8613bc59c930d Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Mon, 16 Feb 2015 20:31:22 +0300 Subject: [PATCH 291/722] build-sys: add syslinux test files to tarball --- conf/Makefile.extra-dist | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/conf/Makefile.extra-dist b/conf/Makefile.extra-dist index 1b95ccd3f..8a65e37a6 100644 --- a/conf/Makefile.extra-dist +++ b/conf/Makefile.extra-dist @@ -121,3 +121,15 @@ EXTRA_DIST += tests/file_filter/file.xz.sig EXTRA_DIST += tests/file_filter/keys EXTRA_DIST += tests/file_filter/keys.pub EXTRA_DIST += tests/file_filter/test.cfg +EXTRA_DIST += tests/syslinux/ubuntu10.04/isolinux/prompt.cfg +EXTRA_DIST += tests/syslinux/ubuntu10.04/isolinux/gfxboot.cfg +EXTRA_DIST += tests/syslinux/ubuntu10.04/isolinux/adtxt.cfg +EXTRA_DIST += tests/syslinux/ubuntu10.04/isolinux/isolinux.cfg +EXTRA_DIST += tests/syslinux/ubuntu10.04/isolinux/exithelp.cfg +EXTRA_DIST += tests/syslinux/ubuntu10.04/isolinux/txt.cfg +EXTRA_DIST += tests/syslinux/ubuntu10.04/isolinux/menu.cfg +EXTRA_DIST += tests/syslinux/ubuntu10.04/isolinux/stdmenu.cfg +EXTRA_DIST += tests/syslinux/ubuntu10.04/isolinux/dtmenu.cfg +EXTRA_DIST += tests/syslinux/ubuntu10.04/isolinux/po4a.cfg +EXTRA_DIST += tests/syslinux/ubuntu10.04/isolinux/rqtxt.cfg +EXTRA_DIST += tests/syslinux/ubuntu10.04_grub.cfg From 35a492e4a2c70d27bc0a7f0c567b2a3405f31599 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Mon, 16 Feb 2015 22:07:33 +0300 Subject: [PATCH 292/722] tests: remove hardcoded paths from syslinux_test abs_top_srcdir appeared in Autoconf 2.52f. Minimal grub requirement is 2.60 so we should be good here. --- Makefile.am | 6 ++++ conf/Makefile.extra-dist | 2 +- ...10.04_grub.cfg => ubuntu10.04_grub.cfg.in} | 30 +++++++++---------- tests/syslinux_test.in | 4 +-- 4 files changed, 24 insertions(+), 18 deletions(-) rename tests/syslinux/{ubuntu10.04_grub.cfg => ubuntu10.04_grub.cfg.in} (85%) diff --git a/Makefile.am b/Makefile.am index f702951af..994ebbd39 100644 --- a/Makefile.am +++ b/Makefile.am @@ -452,3 +452,9 @@ ChangeLog: FORCE fi EXTRA_DIST += ChangeLog ChangeLog-2015 + +syslinux_test: $(top_builddir)/config.status tests/syslinux/ubuntu10.04_grub.cfg + +tests/syslinux/ubuntu10.04_grub.cfg: $(top_builddir)/config.status tests/syslinux/ubuntu10.04_grub.cfg.in + (for x in tests/syslinux/ubuntu10.04_grub.cfg.in ; do cat $(srcdir)/"$$x"; done) | $(top_builddir)/config.status --file=$@:- +CLEANFILES += tests/syslinux/ubuntu10.04_grub.cfg diff --git a/conf/Makefile.extra-dist b/conf/Makefile.extra-dist index 8a65e37a6..db6cfd12e 100644 --- a/conf/Makefile.extra-dist +++ b/conf/Makefile.extra-dist @@ -132,4 +132,4 @@ EXTRA_DIST += tests/syslinux/ubuntu10.04/isolinux/stdmenu.cfg EXTRA_DIST += tests/syslinux/ubuntu10.04/isolinux/dtmenu.cfg EXTRA_DIST += tests/syslinux/ubuntu10.04/isolinux/po4a.cfg EXTRA_DIST += tests/syslinux/ubuntu10.04/isolinux/rqtxt.cfg -EXTRA_DIST += tests/syslinux/ubuntu10.04_grub.cfg +EXTRA_DIST += tests/syslinux/ubuntu10.04_grub.cfg.in diff --git a/tests/syslinux/ubuntu10.04_grub.cfg b/tests/syslinux/ubuntu10.04_grub.cfg.in similarity index 85% rename from tests/syslinux/ubuntu10.04_grub.cfg rename to tests/syslinux/ubuntu10.04_grub.cfg.in index e6bd82cbe..846e4acf0 100644 --- a/tests/syslinux/ubuntu10.04_grub.cfg +++ b/tests/syslinux/ubuntu10.04_grub.cfg.in @@ -1,4 +1,4 @@ - background_image '/home/phcoder/grub2/git/tests/syslinux/ubuntu10.04/isolinux'/'splash.png' + background_image '@abs_top_srcdir@/tests/syslinux/ubuntu10.04/isolinux'/'splash.png' # D-I config version 2.0 # UNSUPPORTED command 'menu hshift 13' # UNSUPPORTED command 'menu width 49' @@ -41,7 +41,7 @@ menuentry 'Test memory' --hotkey 'm' --id 'memtest' { linux$linux_suffix '/'/'/install/mt86plus' } menuentry 'Boot from first hard disk' --hotkey 'b' --id 'hd' { -# File (host)//home/phcoder/grub2/git/tests/syslinux/ubuntu10.04/isolinux/gtk.cfg not found +# File (host)/@abs_top_srcdir@/tests/syslinux/ubuntu10.04/isolinux/gtk.cfg not found # UNSUPPORTED command 'menu begin advanced' # UNSUPPORTED command 'menu title Advanced options' # UNSUPPORTED command 'menu color title * #FFFFFFFF *' @@ -63,15 +63,15 @@ menuentry 'Boot from first hard disk' --hotkey 'b' --id 'hd' { } menuentry 'Back..' --hotkey 'b' --id 'mainmenu' { # UNSUPPORTED command 'menu exit' -# File (host)//home/phcoder/grub2/git/tests/syslinux/ubuntu10.04/isolinux/adgtk.cfg not found +# File (host)/@abs_top_srcdir@/tests/syslinux/ubuntu10.04/isolinux/adgtk.cfg not found # UNSUPPORTED command 'menu end' # UNSUPPORTED entry type 0 true; } menuentry 'Help' --hotkey 'h' --id 'help' { # UNSUPPORTED command 'ui gfxboot bootlogo' -#'/home/phcoder/grub2/git/tests/syslinux/ubuntu10.04/isolinux'/'prompt.cfg' (host)/home/phcoder/grub2/git/tests/syslinux/ubuntu10.04/isolinux/prompt.cfg: - background_image '/home/phcoder/grub2/git/tests/syslinux/ubuntu10.04/isolinux/'/'splash.png' +#'@abs_top_srcdir@/tests/syslinux/ubuntu10.04/isolinux'/'prompt.cfg' (host)@abs_top_srcdir@/tests/syslinux/ubuntu10.04/isolinux/prompt.cfg: + background_image '@abs_top_srcdir@/tests/syslinux/ubuntu10.04/isolinux/'/'splash.png' # UNSUPPORTED command 'display f1.txt' # UNSUPPORTED command 'menu hshift 13' # UNSUPPORTED command 'menu width 49' @@ -114,7 +114,7 @@ menuentry 'Test memory' --hotkey 'm' --id 'memtest' { linux$linux_suffix '/'/'/install/mt86plus' } menuentry 'Boot from first hard disk' --hotkey 'b' --id 'hd' { -# File (host)//home/phcoder/grub2/git/tests/syslinux/ubuntu10.04/isolinux//gtk.cfg not found +# File (host)/@abs_top_srcdir@/tests/syslinux/ubuntu10.04/isolinux//gtk.cfg not found # UNSUPPORTED command 'menu begin advanced' # UNSUPPORTED command 'menu title Advanced options' # UNSUPPORTED command 'menu color title * #FFFFFFFF *' @@ -136,14 +136,14 @@ menuentry 'Boot from first hard disk' --hotkey 'b' --id 'hd' { } menuentry 'Back..' --hotkey 'b' --id 'mainmenu' { # UNSUPPORTED command 'menu exit' -# File (host)//home/phcoder/grub2/git/tests/syslinux/ubuntu10.04/isolinux//adgtk.cfg not found +# File (host)/@abs_top_srcdir@/tests/syslinux/ubuntu10.04/isolinux//adgtk.cfg not found # UNSUPPORTED command 'menu end' # UNSUPPORTED entry type 0 true; } menuentry 'Help' --hotkey 'h' --id 'help' { -#'/home/phcoder/grub2/git/tests/syslinux/ubuntu10.04/isolinux/'/'prompt.cfg' (host)/home/phcoder/grub2/git/tests/syslinux/ubuntu10.04/isolinux/prompt.cfg: - syslinux_configfile -r '/'/'/' -c '/home/phcoder/grub2/git/tests/syslinux/ubuntu10.04/isolinux/'/'' '/home/phcoder/grub2/git/tests/syslinux/ubuntu10.04/isolinux/'/'prompt.cfg' +#'@abs_top_srcdir@/tests/syslinux/ubuntu10.04/isolinux/'/'prompt.cfg' (host)@abs_top_srcdir@/tests/syslinux/ubuntu10.04/isolinux/prompt.cfg: + syslinux_configfile -r '/'/'/' -c '@abs_top_srcdir@/tests/syslinux/ubuntu10.04/isolinux/'/'' '@abs_top_srcdir@/tests/syslinux/ubuntu10.04/isolinux/'/'prompt.cfg' } menuentry 'menu' --id 'menu' { # UNSUPPORTED command 'f1 f1.txt' @@ -156,8 +156,8 @@ menuentry 'menu' --id 'menu' { # UNSUPPORTED command 'f8 f8.txt' # UNSUPPORTED command 'f9 f9.txt' # UNSUPPORTED command 'f0 f10.txt' -#'/home/phcoder/grub2/git/tests/syslinux/ubuntu10.04/isolinux/'/'isolinux.cfg' (host)/home/phcoder/grub2/git/tests/syslinux/ubuntu10.04/isolinux/isolinux.cfg: - background_image '/home/phcoder/grub2/git/tests/syslinux/ubuntu10.04/isolinux//'/'splash.png' +#'@abs_top_srcdir@/tests/syslinux/ubuntu10.04/isolinux/'/'isolinux.cfg' (host)@abs_top_srcdir@/tests/syslinux/ubuntu10.04/isolinux/isolinux.cfg: + background_image '@abs_top_srcdir@/tests/syslinux/ubuntu10.04/isolinux//'/'splash.png' # D-I config version 2.0 # UNSUPPORTED command 'menu hshift 13' # UNSUPPORTED command 'menu width 49' @@ -200,7 +200,7 @@ menuentry 'Test memory' --hotkey 'm' --id 'memtest' { linux$linux_suffix '/'/'/install/mt86plus' } menuentry 'Boot from first hard disk' --hotkey 'b' --id 'hd' { -# File (host)//home/phcoder/grub2/git/tests/syslinux/ubuntu10.04/isolinux///gtk.cfg not found +# File (host)/@abs_top_srcdir@/tests/syslinux/ubuntu10.04/isolinux///gtk.cfg not found # UNSUPPORTED command 'menu begin advanced' # UNSUPPORTED command 'menu title Advanced options' # UNSUPPORTED command 'menu color title * #FFFFFFFF *' @@ -222,15 +222,15 @@ menuentry 'Boot from first hard disk' --hotkey 'b' --id 'hd' { } menuentry 'Back..' --hotkey 'b' --id 'mainmenu' { # UNSUPPORTED command 'menu exit' -# File (host)//home/phcoder/grub2/git/tests/syslinux/ubuntu10.04/isolinux///adgtk.cfg not found +# File (host)/@abs_top_srcdir@/tests/syslinux/ubuntu10.04/isolinux///adgtk.cfg not found # UNSUPPORTED command 'menu end' # UNSUPPORTED entry type 0 true; } menuentry 'Help' --hotkey 'h' --id 'help' { # UNSUPPORTED command 'ui gfxboot bootlogo' -#'/home/phcoder/grub2/git/tests/syslinux/ubuntu10.04/isolinux//'/'prompt.cfg' (host)/home/phcoder/grub2/git/tests/syslinux/ubuntu10.04/isolinux/prompt.cfg: - syslinux_configfile -r '/'/'/' -c '/home/phcoder/grub2/git/tests/syslinux/ubuntu10.04/isolinux//'/'' '/home/phcoder/grub2/git/tests/syslinux/ubuntu10.04/isolinux//'/'prompt.cfg' +#'@abs_top_srcdir@/tests/syslinux/ubuntu10.04/isolinux//'/'prompt.cfg' (host)@abs_top_srcdir@/tests/syslinux/ubuntu10.04/isolinux/prompt.cfg: + syslinux_configfile -r '/'/'/' -c '@abs_top_srcdir@/tests/syslinux/ubuntu10.04/isolinux//'/'' '@abs_top_srcdir@/tests/syslinux/ubuntu10.04/isolinux//'/'prompt.cfg' } } } diff --git a/tests/syslinux_test.in b/tests/syslinux_test.in index 08d28da08..fc4edd8ef 100644 --- a/tests/syslinux_test.in +++ b/tests/syslinux_test.in @@ -4,11 +4,11 @@ set -e outfile="`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"`" || exit 1 -"@builddir@/grub-syslinux2cfg" -r "@srcdir@/tests/syslinux/ubuntu10.04" "@srcdir@/tests/syslinux/ubuntu10.04/isolinux/isolinux.cfg" -o "$outfile" +"@builddir@/grub-syslinux2cfg" -r "@abs_top_srcdir@/tests/syslinux/ubuntu10.04" "@abs_top_srcdir@/tests/syslinux/ubuntu10.04/isolinux/isolinux.cfg" -o "$outfile" echo "$outfile" -if ! diff -u "$outfile" "@srcdir@/tests/syslinux/ubuntu10.04_grub.cfg"; then +if ! diff -u "$outfile" "@builddir@/tests/syslinux/ubuntu10.04_grub.cfg"; then echo "Mismatch in ubuntu10.04" exit 1; fi From e20aa39ea4298011ba716087713cff26c6c52006 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 16 Feb 2015 20:53:26 +0100 Subject: [PATCH 293/722] ext2: Support META_BG. This fixes bug that system would become unbootable after ext* online resize if no resize_inode was created at ext* format time. --- grub-core/fs/ext2.c | 61 +++++++++++++++++++++++++++++++++--- tests/ext234_test.in | 1 + tests/util/grub-fs-tester.in | 6 +++- 3 files changed, 63 insertions(+), 5 deletions(-) diff --git a/grub-core/fs/ext2.c b/grub-core/fs/ext2.c index 44c7974e3..4d45edcc5 100644 --- a/grub-core/fs/ext2.c +++ b/grub-core/fs/ext2.c @@ -107,6 +107,7 @@ GRUB_MOD_LICENSE ("GPLv3+"); #define EXT2_DRIVER_SUPPORTED_INCOMPAT ( EXT2_FEATURE_INCOMPAT_FILETYPE \ | EXT4_FEATURE_INCOMPAT_EXTENTS \ | EXT4_FEATURE_INCOMPAT_FLEX_BG \ + | EXT2_FEATURE_INCOMPAT_META_BG \ | EXT4_FEATURE_INCOMPAT_64BIT) /* List of rationales for the ignored "incompatible" features: * needs_recovery: Not really back-incompatible - was added as such to forbid @@ -331,16 +332,68 @@ static grub_dl_t my_mod; +/* Check is a = b^x for some x. */ +static inline int +is_power_of (grub_uint64_t a, grub_uint32_t b) +{ + grub_uint64_t c; + /* Prevent overflow assuming b < 8. */ + if (a >= (1LL << 60)) + return 0; + for (c = 1; c <= a; c *= b); + return (c == a); +} + + +static inline int +group_has_super_block (struct grub_ext2_data *data, grub_uint64_t group) +{ + if (!(data->sblock.feature_ro_compat + & grub_cpu_to_le32_compile_time(EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER))) + return 1; + /* Algorithm looked up in Linux source. */ + if (group <= 1) + return 1; + /* Even number is never a power of odd number. */ + if (!(group & 1)) + return 0; + return (is_power_of(group, 7) || is_power_of(group, 5) || + is_power_of(group, 3)); +} + /* Read into BLKGRP the blockgroup descriptor of blockgroup GROUP of the mounted filesystem DATA. */ inline static grub_err_t -grub_ext2_blockgroup (struct grub_ext2_data *data, int group, +grub_ext2_blockgroup (struct grub_ext2_data *data, grub_uint64_t group, struct grub_ext2_block_group *blkgrp) { + grub_uint64_t full_offset = (group << data->log_group_desc_size); + grub_uint64_t block, offset; + block = (full_offset >> LOG2_BLOCK_SIZE (data)); + offset = (full_offset & ((1 << LOG2_BLOCK_SIZE (data)) - 1)); + if ((data->sblock.feature_incompat + & grub_cpu_to_le32_compile_time (EXT2_FEATURE_INCOMPAT_META_BG)) + && block >= grub_le_to_cpu32(data->sblock.first_meta_bg)) + { + grub_uint64_t first_block_group; + /* Find the first block group for which a descriptor + is stored in given block. */ + first_block_group = (block << (LOG2_BLOCK_SIZE (data) + - data->log_group_desc_size)); + + block = (first_block_group + * grub_le_to_cpu32(data->sblock.blocks_per_group)); + + if (group_has_super_block (data, first_block_group)) + block++; + } + else + /* Superblock. */ + block++; return grub_disk_read (data->disk, - ((grub_le_to_cpu32 (data->sblock.first_data_block) + 1) - << LOG2_EXT2_BLOCK_SIZE (data)), - group << data->log_group_desc_size, + ((grub_le_to_cpu32 (data->sblock.first_data_block) + + block) + << LOG2_EXT2_BLOCK_SIZE (data)), offset, sizeof (struct grub_ext2_block_group), blkgrp); } diff --git a/tests/ext234_test.in b/tests/ext234_test.in index 8910b716f..c986960a8 100644 --- a/tests/ext234_test.in +++ b/tests/ext234_test.in @@ -29,3 +29,4 @@ fi "@builddir@/grub-fs-tester" ext2 "@builddir@/grub-fs-tester" ext3 "@builddir@/grub-fs-tester" ext4 +"@builddir@/grub-fs-tester" ext4_metabg diff --git a/tests/util/grub-fs-tester.in b/tests/util/grub-fs-tester.in index 565692725..9ecbe0fd6 100644 --- a/tests/util/grub-fs-tester.in +++ b/tests/util/grub-fs-tester.in @@ -281,7 +281,7 @@ for ((LOGSECSIZE=MINLOGSECSIZE;LOGSECSIZE<=MAXLOGSECSIZE;LOGSECSIZE=LOGSECSIZE + #FSLABEL="g;/_é莭ð¯¦ðŸ˜ÐºÐ¸Ñ‚ u" ;; # FS LIMITATION: reiserfs, extN and jfs label is at most 16 UTF-8 characters - x"reiserfs_old" | x"reiserfs" | x"ext2" | xext2_old | x"ext3" | x"ext4" | x"lvm"* | x"mdraid"* | x"jfs" | x"jfs_caseins") + x"reiserfs_old" | x"reiserfs" | x"ext"* | x"lvm"* | x"mdraid"* | x"jfs" | x"jfs_caseins") FSLABEL="g;/éт 莭ðŸ˜";; # FS LIMITATION: No underscore, space, semicolon, slash or international characters in UFS* in label. Limited to 32 UTF-8 characters x"ufs1" | x"ufs1_sun" | x"ufs2") @@ -746,6 +746,10 @@ for ((LOGSECSIZE=MINLOGSECSIZE;LOGSECSIZE<=MAXLOGSECSIZE;LOGSECSIZE=LOGSECSIZE + MKE2FS_DEVICE_SECTSIZE=$SECSIZE "mkfs.ext2" -r 0 -b $BLKSIZE -L "$FSLABEL" -q "${LODEVICES[0]}" MOUNTFS=ext2 ;; + xext4_metabg) + MKE2FS_DEVICE_SECTSIZE=$SECSIZE "mkfs.ext4" -O meta_bg,^resize_inode -b $BLKSIZE -L "$FSLABEL" -q "${LODEVICES[0]}" + MOUNTFS=ext4 + ;; xext*) MKE2FS_DEVICE_SECTSIZE=$SECSIZE "mkfs.$fs" -b $BLKSIZE -L "$FSLABEL" -q "${LODEVICES[0]}" ;; xxfs) From 5537a586e0b92b94910d0170a128ae8a85787713 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 16 Feb 2015 21:08:37 +0100 Subject: [PATCH 294/722] ext2: Ignore INCOMPAT_MMP. It's not really incompatible as long as driver never writes to FS. --- grub-core/fs/ext2.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/grub-core/fs/ext2.c b/grub-core/fs/ext2.c index 4d45edcc5..5199cb0c1 100644 --- a/grub-core/fs/ext2.c +++ b/grub-core/fs/ext2.c @@ -100,6 +100,7 @@ GRUB_MOD_LICENSE ("GPLv3+"); #define EXT2_FEATURE_INCOMPAT_META_BG 0x0010 #define EXT4_FEATURE_INCOMPAT_EXTENTS 0x0040 /* Extents used */ #define EXT4_FEATURE_INCOMPAT_64BIT 0x0080 +#define EXT4_FEATURE_INCOMPAT_MMP 0x0100 #define EXT4_FEATURE_INCOMPAT_FLEX_BG 0x0200 /* The set of back-incompatible features this driver DOES support. Add (OR) @@ -115,8 +116,13 @@ GRUB_MOD_LICENSE ("GPLv3+"); * journal because they will ignore the journal, but the next * ext3 driver to mount the volume will find the journal and * replay it, potentially corrupting the metadata written by - * the ext2 drivers. Safe to ignore for this RO driver. */ -#define EXT2_DRIVER_IGNORED_INCOMPAT ( EXT3_FEATURE_INCOMPAT_RECOVER ) + * the ext2 drivers. Safe to ignore for this RO driver. + * mmp: Not really back-incompatible - was added as such to + * avoid multiple read-write mounts. Safe to ignore for this + * RO driver. + */ +#define EXT2_DRIVER_IGNORED_INCOMPAT ( EXT3_FEATURE_INCOMPAT_RECOVER \ + | EXT4_FEATURE_INCOMPAT_MMP) #define EXT3_JOURNAL_MAGIC_NUMBER 0xc03b3998U From 86f05f1491b87550d69adbd003b9975ad7222557 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 20 Feb 2015 21:29:35 +0100 Subject: [PATCH 295/722] configure: Add missing comma. --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 6d31ed01b..9f5415855 100644 --- a/configure.ac +++ b/configure.ac @@ -552,7 +552,7 @@ int main (void); TARGET_CFLAGS="$TARGET_CFLAGS $grub_cv_target_cc_w_extra_flags" -AC_CACHE_CHECK([if compiling with clang], [grub_cv_cc_target_clang] +AC_CACHE_CHECK([if compiling with clang], [grub_cv_cc_target_clang], [ CFLAGS="$TARGET_CFLAGS" AC_COMPILE_IFELSE( From b46bf3cd1c3682df0a6460dcee95ce4d9da4d1fd Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 20 Feb 2015 21:30:34 +0100 Subject: [PATCH 296/722] configure: Move adding of include options to the very end to avoid subshell. --- configure.ac | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index 9f5415855..8945afa29 100644 --- a/configure.ac +++ b/configure.ac @@ -78,12 +78,9 @@ fi # Default HOST_CPPFLAGS HOST_CPPFLAGS="$HOST_CPPFLAGS -Wall -W" -HOST_CPPFLAGS="$HOST_CPPFLAGS -I\$(top_builddir)/include" HOST_CPPFLAGS="$HOST_CPPFLAGS -DGRUB_UTIL=1" TARGET_CPPFLAGS="$TARGET_CPPFLAGS -Wall -W" -TARGET_CPPFLAGS="$TARGET_CPPFLAGS -I\$(top_srcdir)/include" -TARGET_CPPFLAGS="$TARGET_CPPFLAGS -I\$(top_builddir)/include" case "$target_cpu" in i[[3456]]86) target_cpu=i386 ;; @@ -1643,6 +1640,12 @@ fi TARGET_CPP="$TARGET_CC -E" TARGET_CCAS=$TARGET_CC +# Includes which include make-time substitutions. They must come last +# as to avoid executing top_builddir in shell. +HOST_CPPFLAGS="$HOST_CPPFLAGS -I\$(top_builddir)/include" +TARGET_CPPFLAGS="$TARGET_CPPFLAGS -I\$(top_srcdir)/include" +TARGET_CPPFLAGS="$TARGET_CPPFLAGS -I\$(top_builddir)/include" + GRUB_TARGET_CPU="${target_cpu}" GRUB_PLATFORM="${platform}" From e3c7aca76d5a3467f1bf0736dcd439a0d6f55ae9 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sat, 21 Feb 2015 16:01:53 +0100 Subject: [PATCH 297/722] Strip .MIPS.abiflags which causes compile failure --- conf/Makefile.common | 2 +- gentpl.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/conf/Makefile.common b/conf/Makefile.common index 8c4d1483d..66c9fdb21 100644 --- a/conf/Makefile.common +++ b/conf/Makefile.common @@ -45,7 +45,7 @@ CFLAGS_KERNEL = $(CFLAGS_PLATFORM) -ffreestanding LDFLAGS_KERNEL = $(LDFLAGS_PLATFORM) -nostdlib $(TARGET_LDFLAGS_OLDMAGIC) $(TARGET_LDFLAGS_STATIC_LIBGCC) CPPFLAGS_KERNEL = $(CPPFLAGS_CPU) $(CPPFLAGS_PLATFORM) -DGRUB_KERNEL=1 CCASFLAGS_KERNEL = $(CCASFLAGS_CPU) $(CCASFLAGS_PLATFORM) -STRIPFLAGS_KERNEL = -R .rel.dyn -R .reginfo -R .note -R .comment -R .drectve -R .note.gnu.gold-version +STRIPFLAGS_KERNEL = -R .rel.dyn -R .reginfo -R .note -R .comment -R .drectve -R .note.gnu.gold-version -R .MIPS.abiflags CFLAGS_MODULE = $(CFLAGS_PLATFORM) -ffreestanding LDFLAGS_MODULE = $(LDFLAGS_PLATFORM) -nostdlib $(TARGET_LDFLAGS_OLDMAGIC) -Wl,-r,-d diff --git a/gentpl.py b/gentpl.py index bdcae1a1c..c986cecb7 100644 --- a/gentpl.py +++ b/gentpl.py @@ -753,7 +753,7 @@ def image(defn, platform): if test x$(TARGET_APPLE_LINKER) = x1; then \ $(MACHO2IMG) $< $@; \ else \ - $(TARGET_OBJCOPY) $(""" + cname(defn) + """_OBJCOPYFLAGS) --strip-unneeded -R .note -R .comment -R .note.gnu.build-id -R .reginfo -R .rel.dyn -R .note.gnu.gold-version $< $@; \ + $(TARGET_OBJCOPY) $(""" + cname(defn) + """_OBJCOPYFLAGS) --strip-unneeded -R .note -R .comment -R .note.gnu.build-id -R .MIPS.abiflags -R .reginfo -R .rel.dyn -R .note.gnu.gold-version $< $@; \ fi """) From d93147abb70fba583091ac6ec0426a0bf504d697 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sat, 21 Feb 2015 16:03:11 +0100 Subject: [PATCH 298/722] INSTALL: Fix names of host flags to match actual behaviour --- INSTALL | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/INSTALL b/INSTALL index f6f276c44..05cc4430c 100644 --- a/INSTALL +++ b/INSTALL @@ -175,9 +175,9 @@ corresponding platform are not needed for the platform in question. - For host 1. --host= to autoconf name of host. 2. CC= for gcc able to compile for host - 3. CFLAGS= for C options for host. - 4. CPPFLAGS= for C preprocessor options for host. - 5. LDFLAGS= for linker options for host. + 3. HOST_CFLAGS= for C options for host. + 4. HOST_CPPFLAGS= for C preprocessor options for host. + 5. HOST_LDFLAGS= for linker options for host. 6. FREETYPE= for freetype-config for host (optional). 7. Libdevmapper if any must be in standard linker folders (-ldevmapper) (optional). 8. Libfuse if any must be in standard linker folders (-lfuse) (optional). From 2426ac36d3b42b6be507bde733c4bbd58883fe09 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sat, 21 Feb 2015 16:05:45 +0100 Subject: [PATCH 299/722] div_test: Don't try to divide by zero --- grub-core/tests/div_test.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/grub-core/tests/div_test.c b/grub-core/tests/div_test.c index 1928f8507..7bdc80b40 100644 --- a/grub-core/tests/div_test.c +++ b/grub-core/tests/div_test.c @@ -34,6 +34,8 @@ static void test32 (grub_uint32_t a, grub_uint32_t b) { grub_uint64_t q, r; + if (b == 0) + return; q = grub_divmod64 (a, b, &r); grub_test_assert (r < b, "remainder is larger than dividend: 0x%llx %% 0x%llx = 0x%llx", (long long) a, (long long) b, (long long) r); From aee2502cb54d29d7d86240be7259895bdee15d07 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sat, 21 Feb 2015 16:07:59 +0100 Subject: [PATCH 300/722] Provide __aeabi_mem{cpy,set} Fixes ARM compilation --- grub-core/kern/misc.c | 4 ++++ include/grub/misc.h | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/grub-core/kern/misc.c b/grub-core/kern/misc.c index c5c815d8d..883d35327 100644 --- a/grub-core/kern/misc.c +++ b/grub-core/kern/misc.c @@ -735,6 +735,10 @@ __ctzsi2 (grub_uint32_t x) grub_uint32_t __aeabi_uidiv (grub_uint32_t a, grub_uint32_t b) __attribute__ ((alias ("__udivsi3"))); +void *__aeabi_memcpy (void *dest, const void *src, grub_size_t n) + __attribute__ ((alias ("grub_memcpy"))); +void *__aeabi_memset (void *s, int c, grub_size_t n) + __attribute__ ((alias ("grub_memset"))); #endif #if defined (__ia64__) diff --git a/include/grub/misc.h b/include/grub/misc.h index 4b6ee06d4..e35934cbd 100644 --- a/include/grub/misc.h +++ b/include/grub/misc.h @@ -469,6 +469,11 @@ EXPORT_FUNC (__muldi3) (grub_uint64_t a, grub_uint64_t b); grub_uint64_t EXPORT_FUNC (__aeabi_lmul) (grub_uint64_t a, grub_uint64_t b); +void * +EXPORT_FUNC (__aeabi_memcpy) (void *dest, const void *src, grub_size_t n); +void * +EXPORT_FUNC(__aeabi_memset) (void *s, int c, grub_size_t n); + #endif #if defined (__ia64__) From e5851b63e0b84cc648faaeff50d6300a16f9236a Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sat, 21 Feb 2015 16:09:46 +0100 Subject: [PATCH 301/722] mips/startup_raw: Use more portable .asciz --- grub-core/boot/mips/startup_raw.S | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/grub-core/boot/mips/startup_raw.S b/grub-core/boot/mips/startup_raw.S index 29e93c17e..c169ca36a 100644 --- a/grub-core/boot/mips/startup_raw.S +++ b/grub-core/boot/mips/startup_raw.S @@ -150,18 +150,18 @@ digcont: 1: jr $ra nop -busclockstr: .asciiz "busclock=" -cpuclockstr: .asciiz "cpuclock=" -memsizestr: .asciiz "memsize=" -highmemsizestr: .asciiz "highmemsize=" -machtype_yeeloong_str1: .asciiz "machtype=8.9" -machtype_yeeloong_str2: .asciiz "machtype=lemote-yeeloong-" -machtype_fuloong2f_str: .asciiz "machtype=lemote-fuloong-2f" -machtype_fuloong2e_str: .asciiz "machtype=lemote-fuloong-2e" -pmon_yeeloong_str: .asciiz "PMON_VER=LM8" -pmon_fuloong2f_str: .asciiz "PMON_VER=LM6" -pmon_yeeloong_verstr: .asciiz "Version=LM8" -pmon_fuloong2f_verstr: .asciiz "Version=LM6" +busclockstr: .asciz "busclock=" +cpuclockstr: .asciz "cpuclock=" +memsizestr: .asciz "memsize=" +highmemsizestr: .asciz "highmemsize=" +machtype_yeeloong_str1: .asciz "machtype=8.9" +machtype_yeeloong_str2: .asciz "machtype=lemote-yeeloong-" +machtype_fuloong2f_str: .asciz "machtype=lemote-fuloong-2f" +machtype_fuloong2e_str: .asciz "machtype=lemote-fuloong-2e" +pmon_yeeloong_str: .asciz "PMON_VER=LM8" +pmon_fuloong2f_str: .asciz "PMON_VER=LM6" +pmon_yeeloong_verstr: .asciz "Version=LM8" +pmon_fuloong2f_verstr: .asciz "Version=LM6" .p2align 2 argdone: From ef7c843b443da6aac23cac6d73f90a951dff7436 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sat, 21 Feb 2015 16:13:11 +0100 Subject: [PATCH 302/722] configure: Add -msoft-float to CCASFLAGS Otherwise mismatch between API flags triggers linker failure --- configure.ac | 1 + 1 file changed, 1 insertion(+) diff --git a/configure.ac b/configure.ac index 8945afa29..4ef67f060 100644 --- a/configure.ac +++ b/configure.ac @@ -679,6 +679,7 @@ if test "x$target_cpu" = xarm64; then TARGET_CFLAGS="$TARGET_CFLAGS -march=armv8-a+nofp+nosimd" else TARGET_CFLAGS="$TARGET_CFLAGS -msoft-float" + TARGET_CCASFLAGS="$TARGET_CCASFLAGS -msoft-float" fi # By default, GCC 4.4 generates .eh_frame sections containing unwind From 967e5aa591cdd3bd462ffca4028c00e6a6dbc96d Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sat, 21 Feb 2015 16:16:48 +0100 Subject: [PATCH 303/722] ofdisk: Exclude floppies from scanning. It causes similar hang as CD on at least the qemu. --- grub-core/disk/ieee1275/ofdisk.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/grub-core/disk/ieee1275/ofdisk.c b/grub-core/disk/ieee1275/ofdisk.c index 6870b3958..5d8863782 100644 --- a/grub-core/disk/ieee1275/ofdisk.c +++ b/grub-core/disk/ieee1275/ofdisk.c @@ -34,7 +34,7 @@ struct ofdisk_hash_ent char *open_path; char *grub_devpath; int is_boot; - int is_cdrom; + int is_removable; /* Pointer to shortest available name on nodes representing canonical names, otherwise NULL. */ const char *shortest; @@ -123,7 +123,7 @@ ofdisk_hash_add_real (char *devpath) } static int -check_string_cdrom (const char *str) +check_string_removable (const char *str) { const char *ptr = grub_strrchr (str, '/'); @@ -131,7 +131,7 @@ check_string_cdrom (const char *str) ptr++; else ptr = str; - return (grub_strncmp (ptr, "cdrom", 5) == 0); + return (grub_strncmp (ptr, "cdrom", 5) == 0 || grub_strncmp (ptr, "fd", 2) == 0); } static struct ofdisk_hash_ent * @@ -147,8 +147,8 @@ ofdisk_hash_add (char *devpath, char *curcan) { p->shortest = p->devpath; p->grub_shortest = p->grub_devpath; - if (check_string_cdrom (devpath)) - p->is_cdrom = 1; + if (check_string_removable (devpath)) + p->is_removable = 1; return p; } @@ -158,8 +158,8 @@ ofdisk_hash_add (char *devpath, char *curcan) else grub_free (curcan); - if (check_string_cdrom (devpath) || check_string_cdrom (curcan)) - pcan->is_cdrom = 1; + if (check_string_removable (devpath) || check_string_removable (curcan)) + pcan->is_removable = 1; if (!pcan) grub_errno = GRUB_ERR_NONE; @@ -330,7 +330,7 @@ grub_ofdisk_iterate (grub_disk_dev_iterate_hook_t hook, void *hook_data, } } - if (!ent->is_boot && ent->is_cdrom) + if (!ent->is_boot && ent->is_removable) continue; if (hook (ent->grub_shortest, hook_data)) From ec65605af487d702577bfba214c27efd1a0d8b73 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sat, 21 Feb 2015 16:19:09 +0100 Subject: [PATCH 304/722] wildcard: Mark unused argument as such. --- grub-core/commands/wildcard.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/grub-core/commands/wildcard.c b/grub-core/commands/wildcard.c index d207acfed..9b4e72766 100644 --- a/grub-core/commands/wildcard.c +++ b/grub-core/commands/wildcard.c @@ -293,7 +293,8 @@ struct match_files_ctx /* Helper for match_files. */ static int -match_files_iter (const char *name, const struct grub_dirhook_info *info, +match_files_iter (const char *name, + const struct grub_dirhook_info *info __attribute__((unused)), void *data) { struct match_files_ctx *ctx = data; From 87a04adb6541c4bf169644bb2f84036a7c8558dd Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sat, 21 Feb 2015 16:22:01 +0100 Subject: [PATCH 305/722] zfs/mzap_lookup: Fix argument types --- grub-core/fs/zfs/zfs.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/grub-core/fs/zfs/zfs.c b/grub-core/fs/zfs/zfs.c index 057b471e1..0cbb84bb3 100644 --- a/grub-core/fs/zfs/zfs.c +++ b/grub-core/fs/zfs/zfs.c @@ -2013,12 +2013,14 @@ dmu_read (dnode_end_t * dn, grub_uint64_t blkid, void **buf, */ static grub_err_t mzap_lookup (mzap_phys_t * zapobj, grub_zfs_endian_t endian, - int objsize, const char *name, grub_uint64_t * value, + grub_uint16_t objsize, const char *name, grub_uint64_t * value, int case_insensitive) { - int i, chunks; + grub_uint16_t i, chunks; mzap_ent_phys_t *mzap_ent = zapobj->mz_chunk; + if (objsize < MZAP_ENT_LEN) + return grub_error (GRUB_ERR_FILE_NOT_FOUND, N_("file `%s' not found"), name); chunks = objsize / MZAP_ENT_LEN - 1; for (i = 0; i < chunks; i++) { @@ -2426,7 +2428,7 @@ zap_lookup (dnode_end_t * zap_dnode, const char *name, grub_uint64_t *val, struct grub_zfs_data *data, int case_insensitive) { grub_uint64_t block_type; - int size; + grub_uint16_t size; void *zapbuf; grub_err_t err; grub_zfs_endian_t endian; From 0b02bfa034be0102507fd1df56d577c9c1892df1 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sat, 21 Feb 2015 16:22:48 +0100 Subject: [PATCH 306/722] INSTALL: clarify that clang support is experimental --- INSTALL | 3 +++ 1 file changed, 3 insertions(+) diff --git a/INSTALL b/INSTALL index 05cc4430c..afbb660f3 100644 --- a/INSTALL +++ b/INSTALL @@ -13,6 +13,9 @@ configuring the GRUB. * GCC 4.1.3 or later Note: older versions may work but support is limited + + Experimental support for clang 3.3 or later (results in much bigger binaries) + for i386, x86_64, arm (except thumb), arm64, mips(el), powerpc Note: clang 3.2 or later works for i386 and x86_64 targets but results in much bigger binaries. earlier versions not tested From 065ad910f1938fb8c02a14fe020819ed28429bad Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sat, 21 Feb 2015 16:29:28 +0100 Subject: [PATCH 307/722] Test which flags make our asm compile. Previously we relied on assumption that clang always needs -no-integrated-as but it's not always true. --- asm-tests/arm.S | 20 ++++++++++++++++ asm-tests/i386.S | 10 ++++++++ asm-tests/mips.S | 11 +++++++++ asm-tests/powerpc.S | 8 +++++++ asm-tests/sparc64.S | 9 +++++++ configure.ac | 58 ++++++++++++++++++++++++--------------------- 6 files changed, 89 insertions(+), 27 deletions(-) create mode 100644 asm-tests/arm.S create mode 100644 asm-tests/i386.S create mode 100644 asm-tests/mips.S create mode 100644 asm-tests/powerpc.S create mode 100644 asm-tests/sparc64.S diff --git a/asm-tests/arm.S b/asm-tests/arm.S new file mode 100644 index 000000000..97c2546bf --- /dev/null +++ b/asm-tests/arm.S @@ -0,0 +1,20 @@ +/* on arm clang doesn't support .arch directive */ + + .text + .syntax unified + +#if !defined (__thumb2__) + .arch armv7a + .arm +#else + .arch armv7 + .thumb +#endif + mcr p15, 0, r11, c7, c14, 2 + + /* clang restricts access to dsb/isb despite .arch */ + dsb + isb + + + diff --git a/asm-tests/i386.S b/asm-tests/i386.S new file mode 100644 index 000000000..97cd32ae8 --- /dev/null +++ b/asm-tests/i386.S @@ -0,0 +1,10 @@ +/* on x86 old clang doesn't support .code16 + newer clang supports it but creates 6-byte jumps instead of 3-byte ones + which makes us go over boot sector size. */ + + .code16 + jmp far + .org 4 + .space 300 +far: + .byte 0 diff --git a/asm-tests/mips.S b/asm-tests/mips.S new file mode 100644 index 000000000..8233dfcc9 --- /dev/null +++ b/asm-tests/mips.S @@ -0,0 +1,11 @@ +/* on mips clang doesn't support privilegied instructions, doubleword store/load + and crashes with hand-written assembly + */ + + .set mips3 + sync + ld $t2, 0($t6) + +a: + addiu $t7, $s0, (b - a) +b: nop diff --git a/asm-tests/powerpc.S b/asm-tests/powerpc.S new file mode 100644 index 000000000..396a6cce9 --- /dev/null +++ b/asm-tests/powerpc.S @@ -0,0 +1,8 @@ +/* clang <= 3.3 doesn't handle most of ppc assembly, not even inline assembly + used by gcrypt */ +/* Cache invalidation loop is a fair test. */ + li 5, 0 +1: icbi 5, 3 + addi 5, 5, 32 + cmpw 5, 4 + blt 1b diff --git a/asm-tests/sparc64.S b/asm-tests/sparc64.S new file mode 100644 index 000000000..03c5fe02a --- /dev/null +++ b/asm-tests/sparc64.S @@ -0,0 +1,9 @@ + .text +1: + /* A small list of examples of what clang doesn't support. */ + clr %o0 + lduw [%o4 + 4], %o4 + and %o6, ~0xff, %o6 + stw %o5, [%o3] + bne,pt %icc, 1b + nop diff --git a/configure.ac b/configure.ac index 4ef67f060..40b732975 100644 --- a/configure.ac +++ b/configure.ac @@ -560,35 +560,39 @@ AC_COMPILE_IFELSE( ]])], [grub_cv_cc_target_clang=no], [grub_cv_cc_target_clang=yes])]) -# on x86 clang doesn't support .code16 -# on arm clang doesn't support .arch directive -# on mips clang doesn't support privilegied instructions, doubleword store/load -# and crashes with hand-written assembly -if test "x$grub_cv_cc_target_clang" = xyes && ( test "x$target_cpu" = xi386 \ - || test "x$target_cpu" = xx86_64 || test "x$target_cpu" = xarm \ - || test "x$target_cpu" = xmips || test "x$target_cpu" = xmipsel ); then - TARGET_CCASFLAGS="$TARGET_CCASFLAGS -no-integrated-as" +AC_CACHE_CHECK([for options to compile assembly], [grub_cv_cc_target_asm_compile], [ +test_program= +case "x$target_cpu" in + xmips | xmipsel) + test_program=mips + ;; + xi386 | xx86_64) + test_program=i386 + ;; + xpowerpc | xsparc64 | xarm) + test_program=$target_cpu + ;; +esac +if test x"$test_program" = x ; then + grub_cv_cc_target_asm_compile= +else + found=no + for arg in "" "-no-integrated-as"; do + cmdline="$TARGET_CC -c -o /dev/null $TARGET_CCASFLAGS $arg $TARGET_CPPFLAGS $srcdir/asm-tests/$test_program.S" + echo "Running $cmdline" >&AS_MESSAGE_LOG_FD + if $cmdline >&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD; then + grub_cv_cc_target_asm_compile="$arg" + found=yes + break + fi + done + if test x"$found" = xno ; then + AC_MSG_ERROR([could not compile assembly]) + fi fi +]) -if test "x$grub_cv_cc_target_clang" = xyes && test "x$target_cpu" = xpowerpc; then -AC_CACHE_CHECK([if clang can handle ame instruction], [grub_cv_cc_target_clang_ame] -[ -CFLAGS="$TARGET_CFLAGS" -AC_COMPILE_IFELSE( -[AC_LANG_PROGRAM([], [[ - unsigned int a = 0, b = 0; - asm volatile ("{ame|addme} %0,%1" : "=r" (a) : "r" (b)); - if (a) - return 1; -]])], -[grub_cv_cc_target_clang_ame=yes], [grub_cv_cc_target_clang_ame=no])]) - # clang <= 3.3 doesn't handle most of ppc assembly, not even inline assembly - # used by gcrypt - if test x$grub_cv_cc_target_clang_ame = xno ; then - TARGET_CCASFLAGS="$TARGET_CCASFLAGS -no-integrated-as" - TARGET_CFLAGS="$TARGET_CFLAGS -no-integrated-as" - fi -fi +TARGET_CCASFLAGS="$TARGET_CCASFLAGS $grub_cv_cc_target_asm_compile" if test "x$target_cpu" = xi386 && test "x$platform" != xemu; then TARGET_CFLAGS="$TARGET_CFLAGS -march=i386" From f571dc1af85e2044141a1dfff3af85a18c30fcd5 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sat, 21 Feb 2015 17:13:23 +0100 Subject: [PATCH 308/722] i386: Move from explicit ADDR32/DATA32 prefixes to instruction suffixes. Is more portable. Binary is unchanged (verified). --- grub-core/boot/i386/pc/startup_raw.S | 4 ++-- grub-core/boot/i386/qemu/boot.S | 2 +- grub-core/kern/i386/pc/startup.S | 2 +- grub-core/kern/i386/realmode.S | 10 +++++----- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/grub-core/boot/i386/pc/startup_raw.S b/grub-core/boot/i386/pc/startup_raw.S index 279674030..812ff5494 100644 --- a/grub-core/boot/i386/pc/startup_raw.S +++ b/grub-core/boot/i386/pc/startup_raw.S @@ -95,7 +95,7 @@ LOCAL (codestart): int $0x13 /* transition to protected mode */ - DATA32 call real_to_prot + calll real_to_prot /* The ".code32" directive takes GAS out of 16-bit mode. */ .code32 @@ -149,7 +149,7 @@ gate_a20_try_bios: movw $0x2401, %ax int $0x15 - DATA32 call real_to_prot + calll real_to_prot .code32 popl %ebp diff --git a/grub-core/boot/i386/qemu/boot.S b/grub-core/boot/i386/qemu/boot.S index bdd68c704..8d97fc18c 100644 --- a/grub-core/boot/i386/qemu/boot.S +++ b/grub-core/boot/i386/qemu/boot.S @@ -48,7 +48,7 @@ VARIABLE(grub_core_entry_addr) /* Transition to protected mode. We use pushl to force generation of a flat return address. */ pushl $1f - DATA32 jmp real_to_prot + jmpl real_to_prot .code32 /* Ensure A20 is enabled. We're in qemu, so control port A works and there is no need to wait since there is no real logic, it's diff --git a/grub-core/kern/i386/pc/startup.S b/grub-core/kern/i386/pc/startup.S index 6bb36c603..b8a9b33b4 100644 --- a/grub-core/kern/i386/pc/startup.S +++ b/grub-core/kern/i386/pc/startup.S @@ -135,7 +135,7 @@ LOCAL(prot_to_real_addr): .macro REAL_TO_PROT movl LOCAL(real_to_prot_addr), %eax - DATA32 call *%ax + calll *%eax .endm /* diff --git a/grub-core/kern/i386/realmode.S b/grub-core/kern/i386/realmode.S index 541cedc87..732697c71 100644 --- a/grub-core/kern/i386/realmode.S +++ b/grub-core/kern/i386/realmode.S @@ -54,7 +54,7 @@ protstack: .endm .macro REAL_TO_PROT - DATA32 call real_to_prot + calll real_to_prot .endm /* @@ -137,7 +137,7 @@ real_to_prot: /* load the GDT register */ xorw %ax, %ax movw %ax, %ds - DATA32 ADDR32 lgdt gdtdesc + ADDR32 lgdtl gdtdesc /* turn on protected mode */ movl %cr0, %eax @@ -145,7 +145,7 @@ real_to_prot: movl %eax, %cr0 /* jump to relocation, flush prefetch queue, and reload %cs */ - DATA32 ljmp $GRUB_MEMORY_MACHINE_PROT_MODE_CSEG, $protcseg + ljmpl $GRUB_MEMORY_MACHINE_PROT_MODE_CSEG, $protcseg .code32 protcseg: @@ -237,7 +237,7 @@ tmpcseg: movl %eax, %cr0 /* flush prefetch queue, reload %cs */ - DATA32 ljmp $0, $realcseg + ljmpl $0, $realcseg realcseg: /* we are in real mode now @@ -258,6 +258,6 @@ realcseg: #endif /* return on new stack! */ - DATA32 ret + retl .code32 From bc29c6d019c8645e6da843c78ba522f17165e808 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sat, 21 Feb 2015 17:19:01 +0100 Subject: [PATCH 309/722] Change dot assignmnet to more portable .org. Binary is unchanged (verified) --- grub-core/boot/i386/pc/boot.S | 20 ++++++++++---------- grub-core/boot/i386/pc/cdboot.S | 4 ++-- grub-core/boot/i386/pc/diskboot.S | 2 +- grub-core/boot/i386/pc/lnxboot.S | 4 ++-- grub-core/boot/i386/pc/pxeboot.S | 2 +- grub-core/boot/i386/pc/startup_raw.S | 10 +++++----- 6 files changed, 21 insertions(+), 21 deletions(-) diff --git a/grub-core/boot/i386/pc/boot.S b/grub-core/boot/i386/pc/boot.S index b4975e2d0..d17a1389e 100644 --- a/grub-core/boot/i386/pc/boot.S +++ b/grub-core/boot/i386/pc/boot.S @@ -165,8 +165,8 @@ start: * this area. */ - . = _start + GRUB_BOOT_MACHINE_BPB_START - . = _start + 4 + .org GRUB_BOOT_MACHINE_BPB_START + .org 4 #endif #ifdef HYBRID_BOOT floppy @@ -174,7 +174,7 @@ start: scratch #endif - . = _start + GRUB_BOOT_MACHINE_BPB_END + .org GRUB_BOOT_MACHINE_BPB_END /* * End of BIOS parameter block. */ @@ -183,14 +183,14 @@ kernel_address: .word GRUB_BOOT_MACHINE_KERNEL_ADDR #ifndef HYBRID_BOOT - . = _start + GRUB_BOOT_MACHINE_KERNEL_SECTOR + .org GRUB_BOOT_MACHINE_KERNEL_SECTOR kernel_sector: .long 1 kernel_sector_high: .long 0 #endif - . = _start + GRUB_BOOT_MACHINE_BOOT_DRIVE + .org GRUB_BOOT_MACHINE_BOOT_DRIVE boot_drive: .byte 0xff /* the disk to load kernel from */ /* 0xff means use the boot drive */ @@ -208,7 +208,7 @@ LOCAL(after_BPB): * possible boot drive. If GRUB is installed into a floppy, * this does nothing (only jump). */ - . = _start + GRUB_BOOT_MACHINE_DRIVE_CHECK + .org GRUB_BOOT_MACHINE_DRIVE_CHECK boot_drive_check: jmp 3f /* grub-setup may overwrite this jump */ testb $0x80, %dl @@ -511,13 +511,13 @@ LOCAL(message): */ #ifdef HYBRID_BOOT - . = _start + 0x1b0 + .org 0x1b0 kernel_sector: .long 1 kernel_sector_high: .long 0 #endif - . = _start + GRUB_BOOT_MACHINE_WINDOWS_NT_MAGIC + .org GRUB_BOOT_MACHINE_WINDOWS_NT_MAGIC nt_magic: .long 0 .word 0 @@ -528,7 +528,7 @@ nt_magic: * sneaky, huh? */ - . = _start + GRUB_BOOT_MACHINE_PART_START + .org GRUB_BOOT_MACHINE_PART_START #ifndef HYBRID_BOOT floppy @@ -536,7 +536,7 @@ nt_magic: scratch #endif - . = _start + GRUB_BOOT_MACHINE_PART_END + .org GRUB_BOOT_MACHINE_PART_END /* the last 2 bytes in the sector 0 contain the signature */ .word GRUB_BOOT_MACHINE_SIGNATURE diff --git a/grub-core/boot/i386/pc/cdboot.S b/grub-core/boot/i386/pc/cdboot.S index 92df7c76f..de4f80929 100644 --- a/grub-core/boot/i386/pc/cdboot.S +++ b/grub-core/boot/i386/pc/cdboot.S @@ -43,7 +43,7 @@ _start: LOCAL(next): jmp 1f - . = start + 8 + .org 8 bi_pvd: .long 0 /* LBA of primary volume descriptor. */ @@ -168,6 +168,6 @@ err_noboot_msg: err_cdfail_msg: .ascii "cdrom read fails\0" - . = start + 0x7FF + .org 0x7FF .byte 0 diff --git a/grub-core/boot/i386/pc/diskboot.S b/grub-core/boot/i386/pc/diskboot.S index d030a14c9..1ee4cf5b2 100644 --- a/grub-core/boot/i386/pc/diskboot.S +++ b/grub-core/boot/i386/pc/diskboot.S @@ -362,7 +362,7 @@ LOCAL(message): .word 0 .word 0 - . = _start + 0x200 - GRUB_BOOT_MACHINE_LIST_SIZE + .org 0x200 - GRUB_BOOT_MACHINE_LIST_SIZE LOCAL(firstlist): /* this label has to be before the first list entry!!! */ /* fill the first data listing with the default */ blocklist_default_start: diff --git a/grub-core/boot/i386/pc/lnxboot.S b/grub-core/boot/i386/pc/lnxboot.S index 87e56a2fd..2dda0e06b 100644 --- a/grub-core/boot/i386/pc/lnxboot.S +++ b/grub-core/boot/i386/pc/lnxboot.S @@ -41,7 +41,7 @@ data_start: xorl %ebp, %ebp jmp LOCAL(linux_next) - . = data_start + 0x1F1 + .org 0x1F1 setup_sects: .byte CODE_SECTORS @@ -292,4 +292,4 @@ LOCAL(fail): err_int15_msg: .ascii "move memory fails\0" - . = _start + CODE_SECTORS * 512 + .org (CODE_SECTORS * 512 + 512) diff --git a/grub-core/boot/i386/pc/pxeboot.S b/grub-core/boot/i386/pc/pxeboot.S index 446bfc781..b695b24d0 100644 --- a/grub-core/boot/i386/pc/pxeboot.S +++ b/grub-core/boot/i386/pc/pxeboot.S @@ -38,5 +38,5 @@ start: /* This region is a junk. Do you say that this is wasteful? But I like that the memory layout of the body is consistent among different kernels rather than scamping just for 1.5KB. */ - . = _start + 0x8200 - 0x7C00 - 0x200 - 1 + .org 0x8200 - 0x7C00 - 0x200 - 1 .byte 0 diff --git a/grub-core/boot/i386/pc/startup_raw.S b/grub-core/boot/i386/pc/startup_raw.S index 812ff5494..0f8806cd1 100644 --- a/grub-core/boot/i386/pc/startup_raw.S +++ b/grub-core/boot/i386/pc/startup_raw.S @@ -50,23 +50,23 @@ LOCAL (base): * This is a special data area. */ - . = _start + GRUB_DECOMPRESSOR_MACHINE_COMPRESSED_SIZE + .org GRUB_DECOMPRESSOR_MACHINE_COMPRESSED_SIZE LOCAL(compressed_size): .long 0 - . = _start + GRUB_DECOMPRESSOR_MACHINE_UNCOMPRESSED_SIZE + .org GRUB_DECOMPRESSOR_MACHINE_UNCOMPRESSED_SIZE LOCAL(uncompressed_size): .long 0 - . = _start + GRUB_KERNEL_I386_PC_REED_SOLOMON_REDUNDANCY + .org GRUB_KERNEL_I386_PC_REED_SOLOMON_REDUNDANCY reed_solomon_redundancy: .long 0 - . = _start + GRUB_KERNEL_I386_PC_NO_REED_SOLOMON_LENGTH + .org GRUB_KERNEL_I386_PC_NO_REED_SOLOMON_LENGTH .short (LOCAL(reed_solomon_part) - _start) /* * This is the area for all of the special variables. */ - . = _start + GRUB_DECOMPRESSOR_I386_PC_BOOT_DEVICE + .org GRUB_DECOMPRESSOR_I386_PC_BOOT_DEVICE LOCAL(boot_dev): .byte 0xFF, 0xFF, 0xFF LOCAL(boot_drive): From 1998d63688080e59abda2092ff4b58a1eeb19b90 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sat, 21 Feb 2015 17:20:10 +0100 Subject: [PATCH 310/722] i386-pc/boot: Explicitly mark kernel_address[_high] as local. Otherwise apple asm might try to make accesses relocatable. --- grub-core/boot/i386/pc/boot.S | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/grub-core/boot/i386/pc/boot.S b/grub-core/boot/i386/pc/boot.S index d17a1389e..2bd0b2d28 100644 --- a/grub-core/boot/i386/pc/boot.S +++ b/grub-core/boot/i386/pc/boot.S @@ -179,14 +179,14 @@ start: * End of BIOS parameter block. */ -kernel_address: +LOCAL(kernel_address): .word GRUB_BOOT_MACHINE_KERNEL_ADDR #ifndef HYBRID_BOOT .org GRUB_BOOT_MACHINE_KERNEL_SECTOR -kernel_sector: +LOCAL(kernel_sector): .long 1 -kernel_sector_high: +LOCAL(kernel_sector_high): .long 0 #endif @@ -275,7 +275,7 @@ real_start: andw $1, %cx jz LOCAL(chs_mode) -lba_mode: +LOCAL(lba_mode): xorw %ax, %ax movw %ax, 4(%si) @@ -290,9 +290,9 @@ lba_mode: movw $0x0010, (%si) /* the absolute address */ - movl kernel_sector, %ebx + movl LOCAL(kernel_sector), %ebx movl %ebx, 8(%si) - movl kernel_sector_high, %ebx + movl LOCAL(kernel_sector_high), %ebx movl %ebx, 12(%si) /* the segment of buffer address */ @@ -361,13 +361,13 @@ LOCAL(final_init): setup_sectors: /* load logical sector start (top half) */ - movl kernel_sector_high, %eax + movl LOCAL(kernel_sector_high), %eax orl %eax, %eax jnz LOCAL(geometry_error) /* load logical sector start (bottom half) */ - movl kernel_sector, %eax + movl LOCAL(kernel_sector), %eax /* zero %edx */ xorl %edx, %edx @@ -452,7 +452,7 @@ LOCAL(copy_buffer): popa /* boot kernel */ - jmp *(kernel_address) + jmp *(LOCAL(kernel_address)) /* END OF MAIN LOOP */ @@ -512,9 +512,9 @@ LOCAL(message): #ifdef HYBRID_BOOT .org 0x1b0 -kernel_sector: +LOCAL(kernel_sector): .long 1 -kernel_sector_high: +LOCAL(kernel_sector_high): .long 0 #endif .org GRUB_BOOT_MACHINE_WINDOWS_NT_MAGIC From 37353f0ae5b9a4123ca9fe132a2336c08f30615a Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sat, 21 Feb 2015 17:38:56 +0100 Subject: [PATCH 311/722] i386: Remove needless ADDR32 prefixes when address is known and fixed. Shaves off 6 bytes in lzma_decompress.img. --- grub-core/boot/i386/pc/startup_raw.S | 2 +- grub-core/kern/i386/realmode.S | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/grub-core/boot/i386/pc/startup_raw.S b/grub-core/boot/i386/pc/startup_raw.S index 0f8806cd1..8bce7985c 100644 --- a/grub-core/boot/i386/pc/startup_raw.S +++ b/grub-core/boot/i386/pc/startup_raw.S @@ -89,7 +89,7 @@ LOCAL (codestart): sti /* we're safe again */ /* save the boot drive */ - ADDR32 movb %dl, LOCAL(boot_drive) + movb %dl, LOCAL(boot_drive) /* reset disk system (%ah = 0) */ int $0x13 diff --git a/grub-core/kern/i386/realmode.S b/grub-core/kern/i386/realmode.S index 732697c71..1384d5220 100644 --- a/grub-core/kern/i386/realmode.S +++ b/grub-core/kern/i386/realmode.S @@ -137,7 +137,7 @@ real_to_prot: /* load the GDT register */ xorw %ax, %ax movw %ax, %ds - ADDR32 lgdtl gdtdesc + lgdtl gdtdesc /* turn on protected mode */ movl %cr0, %eax From 6505b241fd86456626dda85651f22467df8294fa Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sat, 21 Feb 2015 17:44:41 +0100 Subject: [PATCH 312/722] Remove obsolete ADDR32 and DATA32 checks. --- acinclude.m4 | 74 ----------------------------------------- config.h.in | 4 --- configure.ac | 4 --- grub-core/modinfo.sh.in | 2 -- 4 files changed, 84 deletions(-) diff --git a/acinclude.m4 b/acinclude.m4 index b2bb88d83..609c4f2f6 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -210,80 +210,6 @@ fi ]) -dnl Mass confusion! -dnl Older versions of GAS interpret `.code16' to mean ``generate 32-bit -dnl instructions, but implicitly insert addr32 and data32 bytes so -dnl that the code works in real mode''. -dnl -dnl Newer versions of GAS interpret `.code16' to mean ``generate 16-bit -dnl instructions,'' which seems right. This requires the programmer -dnl to explicitly insert addr32 and data32 instructions when they want -dnl them. -dnl -dnl We only support the newer versions, because the old versions cause -dnl major pain, by requiring manual assembly to get 16-bit instructions into -dnl asm files. -AC_DEFUN([grub_I386_ASM_ADDR32], -[AC_REQUIRE([AC_PROG_CC]) -AC_REQUIRE([grub_I386_ASM_PREFIX_REQUIREMENT]) -AC_MSG_CHECKING([for .code16 addr32 assembler support]) -AC_CACHE_VAL(grub_cv_i386_asm_addr32, -[cat > conftest.s.in <<\EOF - .code16 -l1: @ADDR32@ movb %al, l1 -EOF - -if test "x$grub_cv_i386_asm_prefix_requirement" = xyes; then - sed -e s/@ADDR32@/addr32/ < conftest.s.in > conftest.s -else - sed -e s/@ADDR32@/addr32\;/ < conftest.s.in > conftest.s -fi - -if AC_TRY_COMMAND([${CC-cc} ${TARGET_CCASFLAGS} ${CFLAGS} -c conftest.s]) && test -s conftest.o; then - grub_cv_i386_asm_addr32=yes -else - grub_cv_i386_asm_addr32=no -fi - -rm -f conftest*]) - -AC_MSG_RESULT([$grub_cv_i386_asm_addr32])]) - -dnl Later versions of GAS requires that addr32 and data32 prefixes -dnl appear in the same lines as the instructions they modify, while -dnl earlier versions requires that they appear in separate lines. -AC_DEFUN([grub_I386_ASM_PREFIX_REQUIREMENT], -[AC_REQUIRE([AC_PROG_CC]) -AC_MSG_CHECKING(dnl -[whether addr32 must be in the same line as the instruction]) -AC_CACHE_VAL(grub_cv_i386_asm_prefix_requirement, -[cat > conftest.s <<\EOF - .code16 -l1: addr32 movb %al, l1 -EOF - -if AC_TRY_COMMAND([${CC-cc} ${TARGET_CCASFLAGS} ${CFLAGS} -c conftest.s]) && test -s conftest.o; then - grub_cv_i386_asm_prefix_requirement=yes -else - grub_cv_i386_asm_prefix_requirement=no -fi - -rm -f conftest*]) - -if test "x$grub_cv_i386_asm_prefix_requirement" = xyes; then - grub_tmp_addr32="addr32" - grub_tmp_data32="data32" -else - grub_tmp_addr32="addr32;" - grub_tmp_data32="data32;" -fi - -ADDR32=$grub_tmp_addr32 -DATA32=$grub_tmp_data32 - -AC_MSG_RESULT([$grub_cv_i386_asm_prefix_requirement])]) - - dnl Check what symbol is defined as a bss start symbol. dnl Written by Michael Hohmoth and Yoshinori K. Okuji. AC_DEFUN([grub_CHECK_BSS_START_SYMBOL], diff --git a/config.h.in b/config.h.in index 4b6301441..d93b687dc 100644 --- a/config.h.in +++ b/config.h.in @@ -31,10 +31,6 @@ #define HAVE_FONT_SOURCE @HAVE_FONT_SOURCE@ /* Define if C symbols get an underscore after compilation. */ #define HAVE_ASM_USCORE @HAVE_ASM_USCORE@ -/* Define it to \"addr32\" or \"addr32;\" to make GAS happy. */ -#define ADDR32 @ADDR32@ -/* Define it to \"data32\" or \"data32;\" to make GAS happy. */ -#define DATA32 @DATA32@ /* Define it to one of __bss_start, edata and _edata. */ #define BSS_START_SYMBOL @BSS_START_SYMBOL@ /* Define it to either end or _end. */ diff --git a/configure.ac b/configure.ac index 40b732975..8ddb5d3cc 100644 --- a/configure.ac +++ b/configure.ac @@ -1096,8 +1096,6 @@ if test "x$target_cpu" = xi386; then grub_CHECK_END_SYMBOL fi CFLAGS="$TARGET_CFLAGS" - grub_I386_ASM_PREFIX_REQUIREMENT - grub_I386_ASM_ADDR32 fi grub_PROG_NM_WORKS @@ -1621,8 +1619,6 @@ AS_IF([test x$target_cpu = xi386 -a x$platform = xqemu], [AC_SUBST([GRUB_BOOT_MACHINE_LINK_ADDR], 0xffe00)]) AC_SUBST(HAVE_ASM_USCORE) -AC_SUBST(ADDR32) -AC_SUBST(DATA32) AC_SUBST(BSS_START_SYMBOL) AC_SUBST(END_SYMBOL) AC_SUBST(PACKAGE) diff --git a/grub-core/modinfo.sh.in b/grub-core/modinfo.sh.in index 69d833432..09d22f922 100644 --- a/grub-core/modinfo.sh.in +++ b/grub-core/modinfo.sh.in @@ -9,8 +9,6 @@ grub_have_font_source=@HAVE_FONT_SOURCE@ # Autodetected config grub_have_asm_uscore=@HAVE_ASM_USCORE@ -grub_i8086_addr32="@ADDR32@" -grub_i8086_data32="@DATA32@" grub_bss_start_symbol="@BSS_START_SYMBOL@" grub_end_symbol="@END_SYMBOL@" From 44ff462e836cb24bde0de184fb1e3cdeedcdd572 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sat, 21 Feb 2015 19:53:18 +0100 Subject: [PATCH 313/722] Remove realmode.S from coreboot and qemu. It's not used there. --- grub-core/kern/i386/coreboot/startup.S | 5 ----- grub-core/kern/i386/qemu/startup.S | 2 -- 2 files changed, 7 deletions(-) diff --git a/grub-core/kern/i386/coreboot/startup.S b/grub-core/kern/i386/coreboot/startup.S index 8c3283846..c8486548d 100644 --- a/grub-core/kern/i386/coreboot/startup.S +++ b/grub-core/kern/i386/coreboot/startup.S @@ -61,8 +61,3 @@ multiboot_header: /* checksum */ .long -0x1BADB002 - MULTIBOOT_MEMORY_INFO -/* - * prot_to_real and associated structures (but NOT real_to_prot, that is - * only needed for BIOS gates). - */ -#include "../realmode.S" diff --git a/grub-core/kern/i386/qemu/startup.S b/grub-core/kern/i386/qemu/startup.S index 3d47d1e4f..17aace9d4 100644 --- a/grub-core/kern/i386/qemu/startup.S +++ b/grub-core/kern/i386/qemu/startup.S @@ -73,5 +73,3 @@ codestart: 1: hlt jmp 1b - -#include "../realmode.S" From e62ca2a870ecec4d46fcc03556e8e61592e9dd18 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sat, 21 Feb 2015 19:55:53 +0100 Subject: [PATCH 314/722] qemu: Fix compilation --- grub-core/boot/i386/qemu/boot.S | 2 +- grub-core/kern/i386/realmode.S | 20 +++++++++++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/grub-core/boot/i386/qemu/boot.S b/grub-core/boot/i386/qemu/boot.S index 8d97fc18c..354436eeb 100644 --- a/grub-core/boot/i386/qemu/boot.S +++ b/grub-core/boot/i386/qemu/boot.S @@ -48,7 +48,7 @@ VARIABLE(grub_core_entry_addr) /* Transition to protected mode. We use pushl to force generation of a flat return address. */ pushl $1f - jmpl real_to_prot + jmp real_to_prot .code32 /* Ensure A20 is enabled. We're in qemu, so control port A works and there is no need to wait since there is no real logic, it's diff --git a/grub-core/kern/i386/realmode.S b/grub-core/kern/i386/realmode.S index 1384d5220..998fdc756 100644 --- a/grub-core/kern/i386/realmode.S +++ b/grub-core/kern/i386/realmode.S @@ -137,7 +137,22 @@ real_to_prot: /* load the GDT register */ xorw %ax, %ax movw %ax, %ds +#ifdef GRUB_MACHINE_QEMU + /* + qemu is special: gdtdesc is in ROM. + %cs = 0xf000 + _start + GRUB_BOOT_MACHINE_SIZE = 0x100000 + So + _start + GRUB_BOOT_MACHINE_SIZE - 0x10000 points to the same point + as %cs. + gdtdesc - (_start + GRUB_BOOT_MACHINE_SIZE - 0x10000) + = gdtdesc - _start - GRUB_BOOT_MACHINE_SIZE + 0x10000 + but the later can be computed by assembly. + */ + lgdtl %cs:(gdtdesc - _start - GRUB_BOOT_MACHINE_SIZE + 0x10000) +#else lgdtl gdtdesc +#endif /* turn on protected mode */ movl %cr0, %eax @@ -178,6 +193,9 @@ protcseg: /* return on the old (or initialized) stack! */ ret + /* prot_to_real assumes that this code is under 64K which is not + true for qemu. */ +#ifndef GRUB_MACHINE_QEMU /* * GRUB -- GRand Unified Bootloader * Copyright (C) 1999,2000,2001,2002,2003,2005,2006,2007,2009,2010 Free Software Foundation, Inc. @@ -259,5 +277,5 @@ realcseg: /* return on new stack! */ retl - +#endif .code32 From 8afd8f3b641aaa80b70bb6629ea8eecae5d359df Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sat, 21 Feb 2015 20:00:18 +0100 Subject: [PATCH 315/722] qemu: Fix GateA20 enabling. GateA20 code was inactive due to address error. --- grub-core/boot/i386/qemu/boot.S | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/boot/i386/qemu/boot.S b/grub-core/boot/i386/qemu/boot.S index 354436eeb..c5343bfb5 100644 --- a/grub-core/boot/i386/qemu/boot.S +++ b/grub-core/boot/i386/qemu/boot.S @@ -50,6 +50,7 @@ VARIABLE(grub_core_entry_addr) pushl $1f jmp real_to_prot .code32 +1: /* Ensure A20 is enabled. We're in qemu, so control port A works and there is no need to wait since there is no real logic, it's all emulated. */ @@ -57,7 +58,6 @@ VARIABLE(grub_core_entry_addr) andb $(~0x03), %al orb $0x02, %al outb $0x92 -1: movl EXT_C(grub_core_entry_addr), %edx jmp *%edx From 3c6043245e9618a499766fdb0e51c4953d5d3da9 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sat, 21 Feb 2015 20:13:58 +0100 Subject: [PATCH 316/722] qemu: Switch to more portable .org Binary is checked identical. --- grub-core/boot/i386/qemu/boot.S | 6 +++--- grub-core/kern/i386/qemu/startup.S | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/grub-core/boot/i386/qemu/boot.S b/grub-core/boot/i386/qemu/boot.S index c5343bfb5..8c3a1db71 100644 --- a/grub-core/boot/i386/qemu/boot.S +++ b/grub-core/boot/i386/qemu/boot.S @@ -31,7 +31,7 @@ _start: jmp 1f - . = _start + GRUB_BOOT_I386_QEMU_CORE_ENTRY_ADDR + .org GRUB_BOOT_I386_QEMU_CORE_ENTRY_ADDR VARIABLE(grub_core_entry_addr) .long 0 1: @@ -66,9 +66,9 @@ VARIABLE(grub_core_entry_addr) /* Intel, in its infinite wisdom, decided to put the i8086 entry point *right here* and this is why we need this kludge. */ - . = GRUB_BOOT_MACHINE_SIZE - 16 + .org GRUB_BOOT_MACHINE_SIZE - 16 .code16 jmp _start - . = GRUB_BOOT_MACHINE_SIZE + .org GRUB_BOOT_MACHINE_SIZE diff --git a/grub-core/kern/i386/qemu/startup.S b/grub-core/kern/i386/qemu/startup.S index 17aace9d4..0d89858d9 100644 --- a/grub-core/kern/i386/qemu/startup.S +++ b/grub-core/kern/i386/qemu/startup.S @@ -28,7 +28,7 @@ _start: jmp codestart - . = _start + GRUB_KERNEL_I386_QEMU_CORE_ENTRY_ADDR + .org GRUB_KERNEL_I386_QEMU_CORE_ENTRY_ADDR VARIABLE(grub_core_entry_addr) .long 0 From f16b8c04057925270d765532fa5710757119c6da Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sat, 21 Feb 2015 20:18:18 +0100 Subject: [PATCH 317/722] Relax requirements on asm for non-BIOS i386 platforms. These platforms don't have a hard limit on size of resulting code16 code, so we don't care if assembly is bigger than necessarry. --- asm-tests/i386-pc.S | 10 ++++++++++ asm-tests/i386.S | 10 ++-------- configure.ac | 11 +++++++---- 3 files changed, 19 insertions(+), 12 deletions(-) create mode 100644 asm-tests/i386-pc.S diff --git a/asm-tests/i386-pc.S b/asm-tests/i386-pc.S new file mode 100644 index 000000000..97cd32ae8 --- /dev/null +++ b/asm-tests/i386-pc.S @@ -0,0 +1,10 @@ +/* on x86 old clang doesn't support .code16 + newer clang supports it but creates 6-byte jumps instead of 3-byte ones + which makes us go over boot sector size. */ + + .code16 + jmp far + .org 4 + .space 300 +far: + .byte 0 diff --git a/asm-tests/i386.S b/asm-tests/i386.S index 97cd32ae8..30adc4fe2 100644 --- a/asm-tests/i386.S +++ b/asm-tests/i386.S @@ -1,10 +1,4 @@ -/* on x86 old clang doesn't support .code16 - newer clang supports it but creates 6-byte jumps instead of 3-byte ones - which makes us go over boot sector size. */ +/* on x86 old clang doesn't support .code16 */ .code16 - jmp far - .org 4 - .space 300 -far: - .byte 0 + movb %al, %bl diff --git a/configure.ac b/configure.ac index 8ddb5d3cc..8b94d346e 100644 --- a/configure.ac +++ b/configure.ac @@ -562,14 +562,17 @@ AC_COMPILE_IFELSE( AC_CACHE_CHECK([for options to compile assembly], [grub_cv_cc_target_asm_compile], [ test_program= -case "x$target_cpu" in - xmips | xmipsel) +case "x$target_cpu-$platform" in + xmips-* | xmipsel-*) test_program=mips ;; - xi386 | xx86_64) + xi386-pc) + test_program=i386-pc + ;; + xi386-* | xx86_64-*) test_program=i386 ;; - xpowerpc | xsparc64 | xarm) + xpowerpc-* | xsparc64-* | xarm-*) test_program=$target_cpu ;; esac From e77dc3d9a0b672d933f328fce4332a61a9f5f707 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sat, 21 Feb 2015 20:24:59 +0100 Subject: [PATCH 318/722] kernel-8086: Switch to more portable .org. --- grub-core/tests/boot/kernel-8086.S | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/grub-core/tests/boot/kernel-8086.S b/grub-core/tests/boot/kernel-8086.S index 510897c88..5ec5368ff 100644 --- a/grub-core/tests/boot/kernel-8086.S +++ b/grub-core/tests/boot/kernel-8086.S @@ -46,5 +46,5 @@ message: .ascii "Boot Test Passed Successfully\n" SUCCESSFUL_BOOT_STRING "\n" .byte 0 - . = base + 510 - .short 0xaa55 \ No newline at end of file + .org 510 + .short 0xaa55 From 49e5fcb9fb1efd1c9b9622d1bc0fe5fa23e99b81 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sat, 21 Feb 2015 20:32:03 +0100 Subject: [PATCH 319/722] sparc64: Switch to more portable .org. Binaries are unchanged. --- grub-core/boot/sparc64/ieee1275/boot.S | 8 ++++---- grub-core/boot/sparc64/ieee1275/diskboot.S | 2 +- grub-core/kern/sparc64/ieee1275/crt0.S | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/grub-core/boot/sparc64/ieee1275/boot.S b/grub-core/boot/sparc64/ieee1275/boot.S index 507367749..586efb401 100644 --- a/grub-core/boot/sparc64/ieee1275/boot.S +++ b/grub-core/boot/sparc64/ieee1275/boot.S @@ -41,9 +41,9 @@ pic_base: * After loading in that block we will execute it by jumping to the * load address plus the size of the prepended A.OUT header (32 bytes). */ - . = _start + GRUB_BOOT_MACHINE_BOOT_DEVPATH + .org GRUB_BOOT_MACHINE_BOOT_DEVPATH boot_path: - . = _start + GRUB_BOOT_MACHINE_KERNEL_BYTE + .org GRUB_BOOT_MACHINE_KERNEL_BYTE boot_path_end: kernel_byte: .xword (2 << 9) kernel_address: .word GRUB_BOOT_MACHINE_KERNEL_ADDR @@ -52,7 +52,7 @@ kernel_address: .word GRUB_BOOT_MACHINE_KERNEL_ADDR #define boot_path_end (_start + 1024) #include - . = _start + 8 + .org 8 kernel_byte: .xword (2 << 9) kernel_size: .word 512 kernel_address: .word GRUB_BOOT_SPARC64_IEEE1275_IMAGE_ADDRESS @@ -224,7 +224,7 @@ bootpath_known: #else nop #endif - . = _start + GRUB_BOOT_MACHINE_CODE_END + .org GRUB_BOOT_MACHINE_CODE_END /* the last 4 bytes in the sector 0 contain the signature */ .word GRUB_BOOT_MACHINE_SIGNATURE diff --git a/grub-core/boot/sparc64/ieee1275/diskboot.S b/grub-core/boot/sparc64/ieee1275/diskboot.S index e020f6221..35e02c1b6 100644 --- a/grub-core/boot/sparc64/ieee1275/diskboot.S +++ b/grub-core/boot/sparc64/ieee1275/diskboot.S @@ -136,7 +136,7 @@ lastlist: .word 0 .word 0 - . = _start + (0x200 - GRUB_BOOT_SPARC64_IEEE1275_LIST_SIZE) + .org (0x200 - GRUB_BOOT_SPARC64_IEEE1275_LIST_SIZE) blocklist_default_start: .word 0 .word 2 diff --git a/grub-core/kern/sparc64/ieee1275/crt0.S b/grub-core/kern/sparc64/ieee1275/crt0.S index 79b6bb325..03b916f05 100644 --- a/grub-core/kern/sparc64/ieee1275/crt0.S +++ b/grub-core/kern/sparc64/ieee1275/crt0.S @@ -27,7 +27,7 @@ _start: ba codestart mov %o4, %o0 - . = EXT_C(_start) + GRUB_KERNEL_MACHINE_TOTAL_MODULE_SIZE + .org GRUB_KERNEL_MACHINE_TOTAL_MODULE_SIZE VARIABLE(grub_total_module_size) .word 0 From da9f30b455a3d1b9e52ae6875b4724c0784c9e8a Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sat, 21 Feb 2015 20:43:57 +0100 Subject: [PATCH 320/722] mips: Switch to more portable .org Binary is unchanged. --- grub-core/boot/mips/loongson/fwstart.S | 6 +++--- grub-core/boot/mips/startup_raw.S | 6 +++--- grub-core/kern/mips/startup.S | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/grub-core/boot/mips/loongson/fwstart.S b/grub-core/boot/mips/loongson/fwstart.S index 6ae326990..71bab6dc8 100644 --- a/grub-core/boot/mips/loongson/fwstart.S +++ b/grub-core/boot/mips/loongson/fwstart.S @@ -162,7 +162,7 @@ retry_cs5536: b continue - . = start + GRUB_CPU_LOONGSON_FLASH_TLB_REFILL - GRUB_CPU_LOONGSON_FLASH_START + .org GRUB_CPU_LOONGSON_FLASH_TLB_REFILL - GRUB_CPU_LOONGSON_FLASH_START tlb_refill: mfc0 $s1, GRUB_CPU_LOONGSON_COP0_EPC mfc0 $s2, GRUB_CPU_LOONGSON_COP0_BADVADDR @@ -196,13 +196,13 @@ tlb_refill: b fatal addiu $a0, $a0, %lo(unhandled_tlb_refill) - . = start + GRUB_CPU_LOONGSON_FLASH_CACHE_ERROR - GRUB_CPU_LOONGSON_FLASH_START + .org GRUB_CPU_LOONGSON_FLASH_CACHE_ERROR - GRUB_CPU_LOONGSON_FLASH_START cache_error: lui $a0, %hi(unhandled_cache_error) b fatal addiu $a0, $a0, %lo(unhandled_cache_error) - . = start + GRUB_CPU_LOONGSON_FLASH_OTHER_EXCEPTION - GRUB_CPU_LOONGSON_FLASH_START + .org GRUB_CPU_LOONGSON_FLASH_OTHER_EXCEPTION - GRUB_CPU_LOONGSON_FLASH_START other_exception: mfc0 $s0, GRUB_CPU_LOONGSON_COP0_CAUSE mfc0 $s1, GRUB_CPU_LOONGSON_COP0_EPC diff --git a/grub-core/boot/mips/startup_raw.S b/grub-core/boot/mips/startup_raw.S index c169ca36a..ca3413bbe 100644 --- a/grub-core/boot/mips/startup_raw.S +++ b/grub-core/boot/mips/startup_raw.S @@ -39,13 +39,13 @@ start: bal codestart nop base: - . = _start + GRUB_DECOMPRESSOR_MACHINE_COMPRESSED_SIZE + .org GRUB_DECOMPRESSOR_MACHINE_COMPRESSED_SIZE compressed_size: .long 0 - . = _start + GRUB_DECOMPRESSOR_MACHINE_UNCOMPRESSED_SIZE + .org GRUB_DECOMPRESSOR_MACHINE_UNCOMPRESSED_SIZE uncompressed_size: .long 0 - . = _start + GRUB_DECOMPRESSOR_MACHINE_UNCOMPRESSED_ADDR + .org GRUB_DECOMPRESSOR_MACHINE_UNCOMPRESSED_ADDR uncompressed_addr: .long 0 codestart: diff --git a/grub-core/kern/mips/startup.S b/grub-core/kern/mips/startup.S index 709a91afa..339ab337e 100644 --- a/grub-core/kern/mips/startup.S +++ b/grub-core/kern/mips/startup.S @@ -36,7 +36,7 @@ start: bal cont nop - . = _start + GRUB_KERNEL_MACHINE_TOTAL_MODULE_SIZE + .org GRUB_KERNEL_MACHINE_TOTAL_MODULE_SIZE VARIABLE(grub_total_modules_size) .long 0 From ebe316e4dfebb83c2e1de437b316b60195470961 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sat, 21 Feb 2015 23:46:47 +0100 Subject: [PATCH 321/722] Discover which option provides soft-float on configure stage. Deals with clang needing other arguments to stop issuing floating instructions than gcc. --- configure.ac | 38 +++++++++++++++++++++++++++++++++----- 1 file changed, 33 insertions(+), 5 deletions(-) diff --git a/configure.ac b/configure.ac index 8b94d346e..10a6bf9c1 100644 --- a/configure.ac +++ b/configure.ac @@ -682,11 +682,39 @@ fi # that floats are a good fit to run instead of what's written in the code. # Given that floating point unit is disabled (if present to begin with) # when GRUB is running which may result in various hard crashes. -if test "x$target_cpu" = xarm64; then - TARGET_CFLAGS="$TARGET_CFLAGS -march=armv8-a+nofp+nosimd" -else - TARGET_CFLAGS="$TARGET_CFLAGS -msoft-float" - TARGET_CCASFLAGS="$TARGET_CCASFLAGS -msoft-float" +if test x"$platform" != xemu ; then + AC_CACHE_CHECK([for options to get soft-float], grub_cv_target_cc_soft_float, [ + grub_cv_target_cc_soft_float=no + if test "x$target_cpu" = xarm64; then + CFLAGS="$TARGET_CFLAGS -march=armv8-a+nofp+nosimd -Werror" + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])], + [grub_cv_target_cc_soft_float="-march=armv8-a+nofp+nosimd"], []) + fi + for cand in "-Xclang -msoft-float -Xclang -no-implicit-float" \ + "-Xclang -msoft-float" "-msoft-float"; do + if test x"$grub_cv_target_cc_soft_float" != xno ; then + break + fi + CFLAGS="$TARGET_CFLAGS $cand -Werror" + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])], + [grub_cv_target_cc_soft_float="$cand"], []) + done + ]) + + if test x"$grub_cv_target_cc_soft_float" = xno ; then + AC_MSG_ERROR([could not force soft-float]) + fi + + case x"$grub_cv_target_cc_soft_float" in + x"-Xclang"*) + # A trick so that clang doesn't see it on link stаge + TARGET_CPPFLAGS="$TARGET_CPPFLAGS $grub_cv_target_cc_soft_float" + ;; + *) + TARGET_CFLAGS="$TARGET_CFLAGS $grub_cv_target_cc_soft_float" + ;; + esac + TARGET_CCASFLAGS="$TARGET_CCASFLAGS $grub_cv_target_cc_soft_float" fi # By default, GCC 4.4 generates .eh_frame sections containing unwind From 155f334f5740a33948ee92432a9eacfd0bf4a398 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sun, 22 Feb 2015 01:53:00 +0100 Subject: [PATCH 322/722] Experimental support for clang for sparc64. Automatically discover command line options to make clang and gcc behave in same way. Tested with qemu. --- INSTALL | 5 +++-- conf/Makefile.common | 7 +----- configure.ac | 53 ++++++++++++++++++++++++++++++++++++++++++-- 3 files changed, 55 insertions(+), 10 deletions(-) diff --git a/INSTALL b/INSTALL index afbb660f3..846ac38df 100644 --- a/INSTALL +++ b/INSTALL @@ -15,7 +15,7 @@ configuring the GRUB. Note: older versions may work but support is limited Experimental support for clang 3.3 or later (results in much bigger binaries) - for i386, x86_64, arm (except thumb), arm64, mips(el), powerpc + for i386, x86_64, arm (except thumb), arm64, mips(el), powerpc, sparc64 Note: clang 3.2 or later works for i386 and x86_64 targets but results in much bigger binaries. earlier versions not tested @@ -29,7 +29,8 @@ configuring the GRUB. fail. Note: clang 3.2 or later works for powerpc earlier versions not tested - Note: clang doesn't support -mno-app-regs and so can't be used for sparc64 + Note: clang 3.5 or later works for sparc64 + earlier versions return "error: unable to interface with target machine" Note: clang has no support for ia64 and hence you can't compile GRUB for ia64 with clang * GNU Make diff --git a/conf/Makefile.common b/conf/Makefile.common index 66c9fdb21..8861096a5 100644 --- a/conf/Makefile.common +++ b/conf/Makefile.common @@ -7,12 +7,7 @@ unexport LC_ALL # Platform specific options if COND_sparc64_ieee1275 - CFLAGS_PLATFORM += -mno-app-regs - LDFLAGS_PLATFORM = -Wl,-melf64_sparc -mno-relax -endif -if COND_sparc64_emu - CFLAGS_PLATFORM += -mno-app-regs - LDFLAGS_PLATFORM = -Wl,--no-relax + LDFLAGS_PLATFORM = -Wl,-melf64_sparc endif if COND_arm if !COND_emu diff --git a/configure.ac b/configure.ac index 10a6bf9c1..4d59fbee0 100644 --- a/configure.ac +++ b/configure.ac @@ -717,6 +717,55 @@ if test x"$platform" != xemu ; then TARGET_CCASFLAGS="$TARGET_CCASFLAGS $grub_cv_target_cc_soft_float" fi +if test x"$target_cpu" = xsparc64 ; then + AC_CACHE_CHECK([for options to reserve application registers], grub_cv_target_cc_mno_app_regs, [ + grub_cv_target_cc_mno_app_regs=no + for cand in "-mllvm -sparc-reserve-app-registers" \ + "-mno-app-regs"; do + if test x"$grub_cv_target_cc_mno_app_regs" != xno ; then + break + fi + CFLAGS="$TARGET_CFLAGS $cand -Werror" + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])], + [grub_cv_target_cc_mno_app_regs="$cand"], []) + done + ]) + + if test x"$grub_cv_target_cc_mno_app_regs" = xno ; then + AC_MSG_ERROR([could not reserve application registers]) + fi + if test x"$grub_cv_target_cc_mno_app_regs" = x"-mllvm -sparc-reserve-app-registers" ; then + # A trick so that clang doesn't see it on link stаge + TARGET_CPPFLAGS="$TARGET_CPPFLAGS $grub_cv_target_cc_mno_app_regs" + else + TARGET_CFLAGS="$TARGET_CFLAGS $grub_cv_target_cc_mno_app_regs" + fi + + AC_CACHE_CHECK([for no-relax options], grub_cv_target_cc_mno_relax, [ + grub_cv_target_cc_mno_relax=no + for cand in "-mno-relax" "-Wl,--no-relax"; do + if test x"$grub_cv_target_cc_mno_relax" != xno ; then + break + fi + LDFLAGS="$TARGET_LDFLAGS $cand -nostdlib -static" + CFLAGS="$TARGET_CFLAGS -Werror" + AC_LINK_IFELSE([AC_LANG_PROGRAM([[ + asm (".globl start; start:"); + void __main (void); + void __main (void) {} + int main (void); + ]], [[]])], [grub_cv_target_cc_mno_relax="$cand"], []) + done + ]) + LDFLAGS="$TARGET_LDFLAGS" + CFLAGS="$TARGET_CFLAGS" + + if test x"$grub_cv_target_cc_mno_relax" = xno ; then + AC_MSG_ERROR([could not find no-relax options]) + fi + TARGET_LDFLAGS="$TARGET_LDFLAGS $grub_cv_target_cc_mno_relax" +fi + # By default, GCC 4.4 generates .eh_frame sections containing unwind # information in some cases where it previously did not. GRUB doesn't need # these and they just use up vital space. Restore the old compiler @@ -918,7 +967,7 @@ AC_SUBST(TARGET_LDFLAGS_OLDMAGIC) LDFLAGS="$TARGET_LDFLAGS" -if test "$target_cpu" = x86_64 || test "$target_cpu-$platform" = sparc64-emu ; then +if test "$target_cpu" = x86_64 || test "$target_cpu" = sparc64 ; then # Use large model to support 4G memory AC_CACHE_CHECK([whether option -mcmodel=large works], grub_cv_cc_mcmodel, [ CFLAGS="$TARGET_CFLAGS -mcmodel=large" @@ -928,7 +977,7 @@ if test "$target_cpu" = x86_64 || test "$target_cpu-$platform" = sparc64-emu ; t ]) if test "x$grub_cv_cc_mcmodel" = xyes; then TARGET_CFLAGS="$TARGET_CFLAGS -mcmodel=large" - elif test "$target_cpu-$platform" = sparc64-emu; then + elif test "$target_cpu" = sparc64; then TARGET_CFLAGS="$TARGET_CFLAGS -mcmodel=medany" fi fi From 50ebc8f5f35a322b3736c03e16de7108932126b0 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sun, 22 Feb 2015 13:12:44 +0100 Subject: [PATCH 323/722] i386/tsc: Fix unused function warning on xen. --- grub-core/kern/i386/tsc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/grub-core/kern/i386/tsc.c b/grub-core/kern/i386/tsc.c index d7d1783e4..bc441d0d3 100644 --- a/grub-core/kern/i386/tsc.c +++ b/grub-core/kern/i386/tsc.c @@ -57,6 +57,8 @@ grub_get_tsc (void) return (((grub_uint64_t) hi) << 32) | lo; } +#ifndef GRUB_MACHINE_XEN + static __inline int grub_cpu_is_tsc_supported (void) { @@ -69,8 +71,6 @@ grub_cpu_is_tsc_supported (void) return (d & (1 << 4)) != 0; } -#ifndef GRUB_MACHINE_XEN - static void grub_pit_wait (grub_uint16_t tics) { From ea39b87a8b258a0f19752f5e5607e14deec54c44 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sun, 22 Feb 2015 14:42:19 +0100 Subject: [PATCH 324/722] configure.ac: Add ia64-specific way to disable floats. --- configure.ac | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/configure.ac b/configure.ac index 4d59fbee0..94f96c47d 100644 --- a/configure.ac +++ b/configure.ac @@ -690,6 +690,11 @@ if test x"$platform" != xemu ; then AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])], [grub_cv_target_cc_soft_float="-march=armv8-a+nofp+nosimd"], []) fi + if test "x$target_cpu" = xia64; then + CFLAGS="$TARGET_CFLAGS -mno-inline-float-divide -mno-inline-sqrt -Werror" + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])], + [grub_cv_target_cc_soft_float="-mno-inline-float-divide -mno-inline-sqrt"], []) + fi for cand in "-Xclang -msoft-float -Xclang -no-implicit-float" \ "-Xclang -msoft-float" "-msoft-float"; do if test x"$grub_cv_target_cc_soft_float" != xno ; then From e1d4520bfb63aa669fc197f44623f6c9228f7757 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sun, 22 Feb 2015 14:42:43 +0100 Subject: [PATCH 325/722] acpi: Fix unused function warning. --- grub-core/commands/acpi.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/grub-core/commands/acpi.c b/grub-core/commands/acpi.c index 5507ffa08..05a6dcad4 100644 --- a/grub-core/commands/acpi.c +++ b/grub-core/commands/acpi.c @@ -131,6 +131,8 @@ grub_acpi_get_rsdpv1 (void) return grub_machine_acpi_get_rsdpv1 (); } +#if defined (__i386__) || defined (__x86_64__) + static inline int iszero (grub_uint8_t *reg, int size) { @@ -141,7 +143,6 @@ iszero (grub_uint8_t *reg, int size) return 1; } -#if defined (__i386__) || defined (__x86_64__) /* Context for grub_acpi_create_ebda. */ struct grub_acpi_create_ebda_ctx { int ebda_len; From f034fab6206173d411407fab6eb9a44c90e02dca Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sun, 22 Feb 2015 17:24:28 +0100 Subject: [PATCH 326/722] Supply signed division to fix ARM compilation. Previously we supplied only unsigned divisions on platforms that need software division. Yet compiler may itself use a signed division. A typical example would be a difference between 2 pointers which involves division by object size. --- gentpl.py | 6 +++ grub-core/Makefile.core.def | 8 ++++ grub-core/kern/arm/misc.S | 13 +++---- grub-core/kern/misc.c | 71 ++++++++++++++++++++++----------- grub-core/tests/div_test.c | 73 +++++++++++++++++++++++++++++++--- include/grub/misc.h | 78 +++++++++++++++++++++++++++++-------- 6 files changed, 198 insertions(+), 51 deletions(-) diff --git a/gentpl.py b/gentpl.py index c986cecb7..d2aa03586 100644 --- a/gentpl.py +++ b/gentpl.py @@ -76,6 +76,12 @@ for i in GROUPS["terminfoinkernel"]: GROUPS["terminfomodule"].remove(i) # Flattened Device Trees (FDT) GROUPS["fdt"] = [ "arm64_efi", "arm_uboot", "arm_efi" ] +# Needs software helpers for division +# Must match GRUB_DIVISION_IN_SOFTWARE in misc.h +GROUPS["softdiv"] = GROUPS["arm"] + ["ia64_efi"] +GROUPS["no_softdiv"] = GRUB_PLATFORMS[:] +for i in GROUPS["softdiv"]: GROUPS["no_softdiv"].remove(i) + # Miscelaneous groups schedulded to disappear in future GROUPS["i386_coreboot_multiboot_qemu"] = ["i386_coreboot", "i386_multiboot", "i386_qemu"] GROUPS["nopc"] = GRUB_PLATFORMS[:]; GROUPS["nopc"].remove("i386_pc") diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def index 42443bc00..b539ccf9d 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def @@ -159,6 +159,8 @@ kernel = { terminfoinkernel = commands/extcmd.c; terminfoinkernel = lib/arg.c; + softdiv = lib/division.c; + i386 = kern/i386/dl.c; i386_xen = kern/i386/dl.c; @@ -1969,6 +1971,12 @@ module = { enable = xen; }; +module = { + name = div; + common = lib/division.c; + enable = no_softdiv; +}; + module = { name = div_test; common = tests/div_test.c; diff --git a/grub-core/kern/arm/misc.S b/grub-core/kern/arm/misc.S index 16b6f8e60..645b42f50 100644 --- a/grub-core/kern/arm/misc.S +++ b/grub-core/kern/arm/misc.S @@ -58,15 +58,11 @@ FUNCTION(__aeabi_lmul) ldmfd sp!, {r4, fp} bx lr - .macro division parent + .macro division32 parent sub sp, sp, #8 @ Allocate naturally aligned 64-bit space stmfd sp!, {r3,lr} @ Dummy r3 to maintain stack alignment - add r3, sp, #8 @ Set r3 to address of 64-bit space - str r3, [sp] @ Stack parameter, pointer to 64-bit space - mov r2, r1 - mov r1, #0 - mov r3, #0 + add r2, sp, #8 @ Set r2 to address of 64-bit space bl \parent ldr r1, [sp, #8] @ Extract remainder ldmfd sp!, {r3,lr} @ Pop into an unused arg/scratch register @@ -75,8 +71,9 @@ FUNCTION(__aeabi_lmul) .endm FUNCTION(__aeabi_uidivmod) - division grub_divmod64 - + division32 grub_divmod32 +FUNCTION(__aeabi_idivmod) + division32 grub_divmod32s /* * Null divide-by-zero handler diff --git a/grub-core/kern/misc.c b/grub-core/kern/misc.c index 883d35327..b0347e7e2 100644 --- a/grub-core/kern/misc.c +++ b/grub-core/kern/misc.c @@ -594,10 +594,10 @@ grub_divmod64 (grub_uint64_t n, grub_uint64_t d, grub_uint64_t *r) grub_uint64_t m = 0; /* ARM and IA64 don't have a fast 32-bit division. - Using that code would just make us use libgcc routines, calling - them twice (once for modulo and once for quotient. + Using that code would just make us use software division routines, calling + ourselves indirectly and hence getting infinite recursion. */ -#if !defined (__arm__) && !defined (__ia64__) +#if !GRUB_DIVISION_IN_SOFTWARE /* Skip the slow computation if 32-bit arithmetic is possible. */ if (n < 0xffffffff && d < 0xffffffff) { @@ -633,7 +633,7 @@ grub_divmod64 (grub_uint64_t n, grub_uint64_t d, grub_uint64_t *r) #if !defined (GRUB_UTIL) && !defined (GRUB_MACHINE_EMU) -#if defined (__arm__) +#if GRUB_DIVISION_IN_SOFTWARE grub_uint32_t __udivsi3 (grub_uint32_t a, grub_uint32_t b) @@ -641,6 +641,12 @@ __udivsi3 (grub_uint32_t a, grub_uint32_t b) return grub_divmod64 (a, b, 0); } +grub_int32_t +__divsi3 (grub_int32_t a, grub_int32_t b) +{ + return grub_divmod64s (a, b, 0); +} + grub_uint32_t __umodsi3 (grub_uint32_t a, grub_uint32_t b) { @@ -649,6 +655,42 @@ __umodsi3 (grub_uint32_t a, grub_uint32_t b) return ret; } +grub_int32_t +__modsi3 (grub_int32_t a, grub_int32_t b) +{ + grub_int64_t ret; + grub_divmod64s (a, b, &ret); + return ret; +} + +grub_uint64_t +__udivdi3 (grub_uint64_t a, grub_uint64_t b) +{ + return grub_divmod64 (a, b, 0); +} + +grub_uint64_t +__umoddi3 (grub_uint64_t a, grub_uint64_t b) +{ + grub_uint64_t ret; + grub_divmod64 (a, b, &ret); + return ret; +} + +grub_int64_t +__divdi3 (grub_int64_t a, grub_int64_t b) +{ + return grub_divmod64s (a, b, 0); +} + +grub_int64_t +__moddi3 (grub_int64_t a, grub_int64_t b) +{ + grub_int64_t ret; + grub_divmod64s (a, b, &ret); + return ret; +} + #endif #ifdef NEED_CTZDI2 @@ -735,30 +777,15 @@ __ctzsi2 (grub_uint32_t x) grub_uint32_t __aeabi_uidiv (grub_uint32_t a, grub_uint32_t b) __attribute__ ((alias ("__udivsi3"))); +grub_int32_t +__aeabi_idiv (grub_int32_t a, grub_int32_t b) + __attribute__ ((alias ("__divsi3"))); void *__aeabi_memcpy (void *dest, const void *src, grub_size_t n) __attribute__ ((alias ("grub_memcpy"))); void *__aeabi_memset (void *s, int c, grub_size_t n) __attribute__ ((alias ("grub_memset"))); #endif -#if defined (__ia64__) - -grub_uint64_t -__udivdi3 (grub_uint64_t a, grub_uint64_t b) -{ - return grub_divmod64 (a, b, 0); -} - -grub_uint64_t -__umoddi3 (grub_uint64_t a, grub_uint64_t b) -{ - grub_uint64_t ret; - grub_divmod64 (a, b, &ret); - return ret; -} - -#endif - #endif /* GRUB_UTIL */ /* Convert a long long value to a string. This function avoids 64-bit diff --git a/grub-core/tests/div_test.c b/grub-core/tests/div_test.c index 7bdc80b40..9abc6d5c4 100644 --- a/grub-core/tests/div_test.c +++ b/grub-core/tests/div_test.c @@ -97,6 +97,72 @@ test64 (grub_uint64_t a, grub_uint64_t b) #endif } +static grub_int64_t +abs64(grub_int64_t a) +{ + return a > 0 ? a : -a; +} + +static void +test32s (grub_int32_t a, grub_int32_t b) +{ + grub_int64_t q, r; + if (b == 0) + return; + + q = grub_divmod64s (a, b, &r); + grub_test_assert (a > 0 ? r >= 0 : r <= 0, "remainder sign mismatch: %lld %% %lld = %lld", + (long long) a, (long long) b, (long long) r); + grub_test_assert (((a > 0) == (b > 0)) ? q >= 0 : q <= 0, "quotient sign mismatch: %lld / %lld = %lld", + (long long) a, (long long) b, (long long) q); + grub_test_assert (abs64(r) < abs64(b), "remainder is larger than dividend: %lld %% %lld = %lld", + (long long) a, (long long) b, (long long) r); + grub_test_assert (q * b + r == a, "division doesn't satisfy base property: %lld * %lld + %lld != %lld", (long long) q, (long long) b, (long long) r, + (long long) a); + if (0) { grub_test_assert (q == (a / b), + "C compiler division failure in 0x%llx, 0x%llx", (long long) a, (long long) b); + grub_test_assert (r == (a % b), + "C compiler modulo failure in 0x%llx, 0x%llx", (long long) a, (long long) b); + } +} + +static void +test64s (grub_int64_t a, grub_int64_t b) +{ + grub_int64_t q, r; + q = grub_divmod64s (a, b, &r); + + grub_test_assert (a > 0 ? r >= 0 : r <= 0, "remainder sign mismatch: %lld %% %lld = %lld", + (long long) a, (long long) b, (long long) r); + grub_test_assert (((a > 0) == (b > 0)) ? q >= 0 : q <= 0, "quotient sign mismatch: %lld / %lld = %lld", + (long long) a, (long long) b, (long long) q); + grub_test_assert (abs64(r) < abs64(b), "remainder is larger than dividend: %lld %% %lld = %lld", + (long long) a, (long long) b, (long long) r); + grub_test_assert (q * b + r == a, "division doesn't satisfy base property: 0x%llx * 0x%llx + 0x%llx != 0x%llx", (long long) q, (long long) b, (long long) r, + (long long) a); +#if GRUB_TARGET_SIZEOF_VOID_P == 8 + grub_test_assert (q == (a / b), + "C compiler division failure in 0x%llx, 0x%llx", (long long) a, (long long) b); + grub_test_assert (r == (a % b), + "C compiler modulo failure in 0x%llx, 0x%llx", (long long) a, (long long) b); +#endif +} + +static void +test_all(grub_uint64_t a, grub_uint64_t b) +{ + test64 (a, b); + test32 (a, b); + test64s (a, b); + test32s (a, b); + test64s (a, -b); + test32s (a, -b); + test64s (-a, b); + test32s (-a, b); + test64s (-a, -b); + test32s (-a, -b); +} + static void div_test (void) { @@ -105,8 +171,7 @@ div_test (void) for (i = 0; i < ARRAY_SIZE (vectors); i++) { - test64 (vectors[i][0], vectors[i][1]); - test32 (vectors[i][0], vectors[i][1]); + test_all (vectors[i][0], vectors[i][1]); } for (i = 0; i < 40000; i++) { @@ -116,9 +181,7 @@ div_test (void) b = 1; if (a == 0) a = 1; - test64 (a, b); - test32 (a, b); - + test_all (a, b); } } diff --git a/include/grub/misc.h b/include/grub/misc.h index e35934cbd..a05b3fd39 100644 --- a/include/grub/misc.h +++ b/include/grub/misc.h @@ -358,6 +358,64 @@ grub_uint64_t EXPORT_FUNC(grub_divmod64) (grub_uint64_t n, grub_uint64_t d, grub_uint64_t *r); +/* Must match softdiv group in gentpl.py. */ +#if !defined(GRUB_MACHINE_EMU) && (defined(__arm__) || defined(__ia64__)) +#define GRUB_DIVISION_IN_SOFTWARE 1 +#else +#define GRUB_DIVISION_IN_SOFTWARE 0 +#endif + +/* Some division functions need to be in kernel if compiler generates calls + to them. Otherwise we still need them for consistent tests but they go + into a separate module. */ +#if GRUB_DIVISION_IN_SOFTWARE +#define EXPORT_FUNC_IF_SOFTDIV EXPORT_FUNC +#else +#define EXPORT_FUNC_IF_SOFTDIV(x) x +#endif + +grub_int64_t +EXPORT_FUNC_IF_SOFTDIV(grub_divmod64s) (grub_int64_t n, + grub_int64_t d, + grub_int64_t *r); +grub_uint32_t +EXPORT_FUNC_IF_SOFTDIV (grub_divmod32) (grub_uint32_t n, + grub_uint32_t d, + grub_uint32_t *r); + +grub_int32_t +EXPORT_FUNC_IF_SOFTDIV (grub_divmod32s) (grub_int32_t n, + grub_int32_t d, + grub_int32_t *r); + +#if defined(GRUB_DIVISION_IN_SOFTWARE) && GRUB_DIVISION_IN_SOFTWARE + +grub_uint32_t +EXPORT_FUNC (__udivsi3) (grub_uint32_t a, grub_uint32_t b); + +grub_uint32_t +EXPORT_FUNC (__umodsi3) (grub_uint32_t a, grub_uint32_t b); + +grub_int32_t +EXPORT_FUNC (__divsi3) (grub_int32_t a, grub_int32_t b); + +grub_int32_t +EXPORT_FUNC (__modsi3) (grub_int32_t a, grub_int32_t b); + +grub_int64_t +EXPORT_FUNC (__divdi3) (grub_int64_t a, grub_int64_t b); + +grub_int64_t +EXPORT_FUNC (__moddi3) (grub_int64_t a, grub_int64_t b); + +grub_uint64_t +EXPORT_FUNC (__udivdi3) (grub_uint64_t a, grub_uint64_t b); + +grub_uint64_t +EXPORT_FUNC (__umoddi3) (grub_uint64_t a, grub_uint64_t b); + +#endif + #if (defined (__MINGW32__) || defined (__CYGWIN__)) && !defined(GRUB_UTIL) void EXPORT_FUNC (__register_frame_info) (void); void EXPORT_FUNC (__deregister_frame_info) (void); @@ -437,12 +495,6 @@ grub_error_load (const struct grub_error_saved *save) #if defined (__arm__) -grub_uint32_t -EXPORT_FUNC (__udivsi3) (grub_uint32_t a, grub_uint32_t b); - -grub_uint32_t -EXPORT_FUNC (__umodsi3) (grub_uint32_t a, grub_uint32_t b); - #endif #if defined (__sparc__) || defined (__powerpc__) @@ -460,8 +512,12 @@ EXPORT_FUNC (__ctzsi2) (grub_uint32_t x); #ifdef __arm__ grub_uint32_t EXPORT_FUNC (__aeabi_uidiv) (grub_uint32_t a, grub_uint32_t b); +grub_int32_t +EXPORT_FUNC (__aeabi_idiv) (grub_int32_t a, grub_int32_t b); grub_uint32_t EXPORT_FUNC (__aeabi_uidivmod) (grub_uint32_t a, grub_uint32_t b); +grub_int32_t +EXPORT_FUNC (__aeabi_idivmod) (grub_int32_t a, grub_int32_t b); /* Needed for allowing modules to be compiled as thumb. */ grub_uint64_t @@ -476,16 +532,6 @@ EXPORT_FUNC(__aeabi_memset) (void *s, int c, grub_size_t n); #endif -#if defined (__ia64__) - -grub_uint64_t -EXPORT_FUNC (__udivdi3) (grub_uint64_t a, grub_uint64_t b); - -grub_uint64_t -EXPORT_FUNC (__umoddi3) (grub_uint64_t a, grub_uint64_t b); - -#endif - #endif /* GRUB_UTIL */ From 345076a78a15a61e1545eec60e7661e13b2dc62f Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sun, 22 Feb 2015 17:41:12 +0100 Subject: [PATCH 327/722] arm64: Fix compilation failure. Don't supply +nosimd to asm files. Otherwise +nosimd coming from flags forbids some of instructions used in cache_flush. --- configure.ac | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 94f96c47d..35f430a0a 100644 --- a/configure.ac +++ b/configure.ac @@ -719,7 +719,16 @@ if test x"$platform" != xemu ; then TARGET_CFLAGS="$TARGET_CFLAGS $grub_cv_target_cc_soft_float" ;; esac - TARGET_CCASFLAGS="$TARGET_CCASFLAGS $grub_cv_target_cc_soft_float" + case x"$grub_cv_target_cc_soft_float" in + x"-march=armv8-a+nofp+nosimd") + # +nosimd disables also the cache opcodes that we need in asm. + TARGET_CCASFLAGS="$TARGET_CCASFLAGS -march=armv8-a+nofp" + ;; + *) + TARGET_CCASFLAGS="$TARGET_CCASFLAGS $grub_cv_target_cc_soft_float" + ;; + esac + fi if test x"$target_cpu" = xsparc64 ; then From 2066c35b3ff6e35edf2a4e903f9aa79a23b6aefe Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sun, 22 Feb 2015 17:45:30 +0100 Subject: [PATCH 328/722] Allow clang compilation for thumb with -mthumb-interwork. clang already uses -mthumb-interwork behaviour even thout it doesn't support the option. --- configure.ac | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/configure.ac b/configure.ac index 35f430a0a..8f9ab8133 100644 --- a/configure.ac +++ b/configure.ac @@ -1029,20 +1029,9 @@ if test "x$target_cpu" = xarm; then ]) if test "x$grub_cv_cc_mthumb_interwork" = xyes; then TARGET_CFLAGS="$TARGET_CFLAGS -mthumb-interwork" + # Clang defaults to thumb interworking elif test "x$grub_cv_cc_target_clang" = xno ; then AC_MSG_ERROR([your compiler doesn't support -mthumb-interwork]) - else - CFLAGS="$TARGET_CFLAGS" - AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[ -#if defined (__thumb__) && !defined (__thumb2__) -#error thumb without interworking -#endif -]])], - [no_interwork_ok=yes], - [no_interwork_ok=no]) - if test x$no_interwork_ok = xno ; then - AC_MSG_ERROR([attempt to compile to thumb with no thumb interwork]) - fi fi fi From 7ea452a142d55e80b2a33d59958eef41559fb8eb Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sun, 22 Feb 2015 19:34:46 +0100 Subject: [PATCH 329/722] Add missing grub_ prefix in memcpy invocation --- grub-core/kern/dl.c | 2 +- grub-core/loader/sparc64/ieee1275/linux.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/grub-core/kern/dl.c b/grub-core/kern/dl.c index 6850e0497..3a438e92f 100644 --- a/grub-core/kern/dl.c +++ b/grub-core/kern/dl.c @@ -340,7 +340,7 @@ grub_dl_resolve_symbols (grub_dl_t mod, Elf_Ehdr *e) mod->symtab = grub_malloc (s->sh_size); if (!mod->symtab) return grub_errno; - memcpy (mod->symtab, (char *) e + s->sh_offset, s->sh_size); + grub_memcpy (mod->symtab, (char *) e + s->sh_offset, s->sh_size); #else mod->symtab = (Elf_Sym *) ((char *) e + s->sh_offset); #endif diff --git a/grub-core/loader/sparc64/ieee1275/linux.c b/grub-core/loader/sparc64/ieee1275/linux.c index 6389170e6..63d6a1f33 100644 --- a/grub-core/loader/sparc64/ieee1275/linux.c +++ b/grub-core/loader/sparc64/ieee1275/linux.c @@ -110,7 +110,7 @@ grub_linux_boot (void) int len = grub_strlen (linux_args) + 1; if (bp->len < len) len = bp->len; - memcpy(bp->buf, linux_args, len); + grub_memcpy(bp->buf, linux_args, len); bp->buf[len-1] = '\0'; bp->valid = 1; } From 6a4ecd276ed39f66be0ad6ff0f8ff67598098605 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 23 Feb 2015 22:33:28 +0100 Subject: [PATCH 330/722] mips: Fix soft-float handling. Add -msoft-float alongside clang arguments to specify ABI. Specify ABI in asm files explicitly. This trigers asm warning due to gcc failing to propagate -msoft-float but it's tolerable. --- configure.ac | 5 +++-- grub-core/boot/mips/startup_raw.S | 2 ++ grub-core/kern/mips/cache.S | 4 +++- grub-core/kern/mips/startup.S | 2 ++ grub-core/lib/mips/relocator_asm.S | 2 ++ include/grub/mips/kernel.h | 4 ++++ 6 files changed, 16 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index 8f9ab8133..908bb81e7 100644 --- a/configure.ac +++ b/configure.ac @@ -695,7 +695,8 @@ if test x"$platform" != xemu ; then AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])], [grub_cv_target_cc_soft_float="-mno-inline-float-divide -mno-inline-sqrt"], []) fi - for cand in "-Xclang -msoft-float -Xclang -no-implicit-float" \ + for cand in "-msoft-float -Xclang -msoft-float -Xclang -no-implicit-float" \ + "-Xclang -msoft-float -Xclang -no-implicit-float" \ "-Xclang -msoft-float" "-msoft-float"; do if test x"$grub_cv_target_cc_soft_float" != xno ; then break @@ -711,7 +712,7 @@ if test x"$platform" != xemu ; then fi case x"$grub_cv_target_cc_soft_float" in - x"-Xclang"*) + x*"-Xclang"*) # A trick so that clang doesn't see it on link stаge TARGET_CPPFLAGS="$TARGET_CPPFLAGS $grub_cv_target_cc_soft_float" ;; diff --git a/grub-core/boot/mips/startup_raw.S b/grub-core/boot/mips/startup_raw.S index ca3413bbe..fd95c3134 100644 --- a/grub-core/boot/mips/startup_raw.S +++ b/grub-core/boot/mips/startup_raw.S @@ -21,6 +21,7 @@ #include #include #include +#include #include #define BASE_ADDR 8 @@ -32,6 +33,7 @@ .globl __start, _start, start .set noreorder .set nomacro + mips_attributes __start: _start: start: diff --git a/grub-core/kern/mips/cache.S b/grub-core/kern/mips/cache.S index 78e40bcea..e83960fcc 100644 --- a/grub-core/kern/mips/cache.S +++ b/grub-core/kern/mips/cache.S @@ -1,8 +1,10 @@ #include +#include .set noreorder .set nomacro + mips_attributes FUNCTION (grub_arch_sync_caches) #include "cache_flush.S" @@ -65,4 +67,4 @@ FUNCTION (grub_arch_sync_dma_caches) #endif sync_op - jr $ra \ No newline at end of file + jr $ra diff --git a/grub-core/kern/mips/startup.S b/grub-core/kern/mips/startup.S index 339ab337e..337aca914 100644 --- a/grub-core/kern/mips/startup.S +++ b/grub-core/kern/mips/startup.S @@ -21,6 +21,7 @@ #include #include #include +#include #include #define BASE_ADDR 8 @@ -28,6 +29,7 @@ .globl __start, _start, start .set noreorder .set nomacro + mips_attributes __start: _start: start: diff --git a/grub-core/lib/mips/relocator_asm.S b/grub-core/lib/mips/relocator_asm.S index 1d142a4f3..959893ca9 100644 --- a/grub-core/lib/mips/relocator_asm.S +++ b/grub-core/lib/mips/relocator_asm.S @@ -17,11 +17,13 @@ */ #include +#include .p2align 4 /* force 16-byte alignment */ .set noreorder .set nomacro + mips_attributes VARIABLE (grub_relocator_forward_start) move $a0, $9 diff --git a/include/grub/mips/kernel.h b/include/grub/mips/kernel.h index 07b08848d..d0e09ddc6 100644 --- a/include/grub/mips/kernel.h +++ b/include/grub/mips/kernel.h @@ -21,4 +21,8 @@ #include +#ifdef ASM_FILE +#define mips_attributes .gnu_attribute 4, 3 +#endif + #endif /* ! GRUB_KERNEL_MACHINE_HEADER */ From c5a4e79335cebc026684de623bdd327312139330 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Thu, 26 Feb 2015 18:11:53 +0100 Subject: [PATCH 331/722] minilzo: Skip parts tha we don't need. --- config.h.in | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/config.h.in b/config.h.in index d93b687dc..ea0f3834e 100644 --- a/config.h.in +++ b/config.h.in @@ -12,6 +12,14 @@ #define DISK_CACHE_STATS @DISK_CACHE_STATS@ #define BOOT_TIME_STATS @BOOT_TIME_STATS@ +/* We don't need those. */ +#define MINILZO_CFG_SKIP_LZO_PTR 1 +#define MINILZO_CFG_SKIP_LZO_UTIL 1 +#define MINILZO_CFG_SKIP_LZO_STRING 1 +#define MINILZO_CFG_SKIP_LZO_INIT 1 +#define MINILZO_CFG_SKIP_LZO1X_1_COMPRESS 1 +#define MINILZO_CFG_SKIP_LZO1X_DECOMPRESS 1 + #if defined (GRUB_BUILD) #undef ENABLE_NLS #define BUILD_SIZEOF_LONG @BUILD_SIZEOF_LONG@ From dd4889f727c535948fd6ab67154a52b10bc544c9 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Thu, 26 Feb 2015 18:13:36 +0100 Subject: [PATCH 332/722] bitmap_scale: Optimize by moving division out of the loop. --- grub-core/video/bitmap_scale.c | 114 ++++++++++++++++++++------------- 1 file changed, 69 insertions(+), 45 deletions(-) diff --git a/grub-core/video/bitmap_scale.c b/grub-core/video/bitmap_scale.c index 0b93d0206..70c32f029 100644 --- a/grub-core/video/bitmap_scale.c +++ b/grub-core/video/bitmap_scale.c @@ -361,35 +361,46 @@ scale_nn (struct grub_video_bitmap *dst, struct grub_video_bitmap *src) unsigned dh = dst->mode_info.height; unsigned sw = src->mode_info.width; unsigned sh = src->mode_info.height; - unsigned dstride = dst->mode_info.pitch; - unsigned sstride = src->mode_info.pitch; + int dstride = dst->mode_info.pitch; + int sstride = src->mode_info.pitch; /* bytes_per_pixel is the same for both src and dst. */ - unsigned bytes_per_pixel = dst->mode_info.bytes_per_pixel; + int bytes_per_pixel = dst->mode_info.bytes_per_pixel; + unsigned dy, sy, ystep, yfrac, yover; + unsigned sx, xstep, xfrac, xover; + grub_uint8_t *dptr, *dline_end, *sline; - unsigned dy; - for (dy = 0; dy < dh; dy++) + xstep = sw / dw; + xover = sw % dw; + ystep = sh / dh; + yover = sh % dh; + + for (dy = 0, sy = 0, yfrac = 0; dy < dh; dy++, sy += ystep, yfrac += yover) { - unsigned dx; - for (dx = 0; dx < dw; dx++) + if (yfrac >= dh) + { + yfrac -= dh; + sy++; + } + dptr = ddata + dy * dstride; + dline_end = dptr + dw * bytes_per_pixel; + sline = sdata + sy * sstride; + for (sx = 0, xfrac = 0; dptr < dline_end; sx += xstep, xfrac += xover, dptr += bytes_per_pixel) { - grub_uint8_t *dptr; grub_uint8_t *sptr; - unsigned sx; - unsigned sy; - unsigned comp; + int comp; - /* Compute the source coordinate that the destination coordinate - maps to. Note: sx/sw = dx/dw => sx = sw*dx/dw. */ - sx = sw * dx / dw; - sy = sh * dy / dh; + if (xfrac >= dw) + { + xfrac -= dw; + sx++; + } /* Get the address of the pixels in src and dst. */ - dptr = ddata + dy * dstride + dx * bytes_per_pixel; - sptr = sdata + sy * sstride + sx * bytes_per_pixel; + sptr = sline + sx * bytes_per_pixel; - /* Copy the pixel color value. */ - for (comp = 0; comp < bytes_per_pixel; comp++) - dptr[comp] = sptr[comp]; + /* Copy the pixel color value. */ + for (comp = 0; comp < bytes_per_pixel; comp++) + dptr[comp] = sptr[comp]; } } return GRUB_ERR_NONE; @@ -422,27 +433,40 @@ scale_bilinear (struct grub_video_bitmap *dst, struct grub_video_bitmap *src) int sstride = src->mode_info.pitch; /* bytes_per_pixel is the same for both src and dst. */ int bytes_per_pixel = dst->mode_info.bytes_per_pixel; + unsigned dy, syf, sy, ystep, yfrac, yover; + unsigned sxf, sx, xstep, xfrac, xover; + grub_uint8_t *dptr, *dline_end, *sline; - unsigned dy; - for (dy = 0; dy < dh; dy++) + xstep = (sw << 8) / dw; + xover = (sw << 8) % dw; + ystep = (sh << 8) / dh; + yover = (sh << 8) % dh; + + for (dy = 0, syf = 0, yfrac = 0; dy < dh; dy++, syf += ystep, yfrac += yover) { - unsigned dx; - for (dx = 0; dx < dw; dx++) + if (yfrac >= dh) + { + yfrac -= dh; + syf++; + } + sy = syf >> 8; + dptr = ddata + dy * dstride; + dline_end = dptr + dw * bytes_per_pixel; + sline = sdata + sy * sstride; + for (sxf = 0, xfrac = 0; dptr < dline_end; sxf += xstep, xfrac += xover, dptr += bytes_per_pixel) { - grub_uint8_t *dptr; grub_uint8_t *sptr; - unsigned sx; - unsigned sy; int comp; - /* Compute the source coordinate that the destination coordinate - maps to. Note: sx/sw = dx/dw => sx = sw*dx/dw. */ - sx = sw * dx / dw; - sy = sh * dy / dh; + if (xfrac >= dw) + { + xfrac -= dw; + sxf++; + } /* Get the address of the pixels in src and dst. */ - dptr = ddata + dy * dstride + dx * bytes_per_pixel; - sptr = sdata + sy * sstride + sx * bytes_per_pixel; + sx = sxf >> 8; + sptr = sline + sx * bytes_per_pixel; /* If we have enough space to do so, use bilinear interpolation. Otherwise, fall back to nearest neighbor for this pixel. */ @@ -453,27 +477,27 @@ scale_bilinear (struct grub_video_bitmap *dst, struct grub_video_bitmap *src) /* Fixed-point .8 numbers representing the fraction of the distance in the x (u) and y (v) direction within the box of 4 pixels in the source. */ - int u = (256 * sw * dx / dw) - (sx * 256); - int v = (256 * sh * dy / dh) - (sy * 256); + unsigned u = sxf & 0xff; + unsigned v = syf & 0xff; for (comp = 0; comp < bytes_per_pixel; comp++) { /* Get the component's values for the four source corner pixels. */ - int f00 = sptr[comp]; - int f10 = sptr[comp + bytes_per_pixel]; - int f01 = sptr[comp + sstride]; - int f11 = sptr[comp + sstride + bytes_per_pixel]; + unsigned f00 = sptr[comp]; + unsigned f10 = sptr[comp + bytes_per_pixel]; + unsigned f01 = sptr[comp + sstride]; + unsigned f11 = sptr[comp + sstride + bytes_per_pixel]; /* Count coeffecients. */ - int c00 = (256 - u) * (256 - v); - int c10 = u * (256 - v); - int c01 = (256 - u) * v; - int c11 = u * v; + unsigned c00 = (256 - u) * (256 - v); + unsigned c10 = u * (256 - v); + unsigned c01 = (256 - u) * v; + unsigned c11 = u * v; /* Interpolate. */ - int fxy = c00 * f00 + c01 * f01 + c10 * f10 + c11 * f11; - fxy = fxy / (256 * 256); + unsigned fxy = c00 * f00 + c01 * f01 + c10 * f10 + c11 * f11; + fxy = fxy >> 16; dptr[comp] = fxy; } From f51218bc15ff7b82894a2096ec1cdb7c8f0084f4 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Thu, 26 Feb 2015 18:14:28 +0100 Subject: [PATCH 333/722] fbblit: Optimize by replacing division with additions and shifts. --- grub-core/video/fb/fbblit.c | 71 +++++++++++++++++++++---------------- 1 file changed, 41 insertions(+), 30 deletions(-) diff --git a/grub-core/video/fb/fbblit.c b/grub-core/video/fb/fbblit.c index 3a073cea7..d55924837 100644 --- a/grub-core/video/fb/fbblit.c +++ b/grub-core/video/fb/fbblit.c @@ -1145,6 +1145,20 @@ grub_video_fbblit_replace_index_RGB888 (struct grub_video_fbblit_info *dst, } } +static inline grub_uint8_t +alpha_dilute (grub_uint8_t bg, grub_uint8_t fg, grub_uint8_t alpha) +{ + grub_uint16_t s; + grub_uint16_t h, l; + s = (fg * alpha) + (bg * (255 ^ alpha)); + /* Optimised division by 255. */ + h = s >> 8; + l = s & 0xff; + if (h + l >= 255) + h++; + return h; +} + /* Generic blending blitter. Works for every supported format. */ static void grub_video_fbblit_blend (struct grub_video_fbblit_info *dst, @@ -1190,12 +1204,9 @@ grub_video_fbblit_blend (struct grub_video_fbblit_info *dst, grub_video_fb_unmap_color_int (dst, dst_color, &dst_red, &dst_green, &dst_blue, &dst_alpha); - dst_red = (((src_red * src_alpha) - + (dst_red * (255 ^ src_alpha))) / 255U); - dst_green = (((src_green * src_alpha) - + (dst_green * (255 ^ src_alpha))) / 255U); - dst_blue = (((src_blue * src_alpha) - + (dst_blue * (255 ^ src_alpha))) / 255U); + dst_red = alpha_dilute (dst_red, src_red, src_alpha); + dst_green = alpha_dilute (dst_green, src_green, src_alpha); + dst_blue = alpha_dilute (dst_blue, src_blue, src_alpha); dst_alpha = src_alpha; dst_color = grub_video_fb_map_rgba (dst_red, dst_green, dst_blue, @@ -1270,11 +1281,11 @@ grub_video_fbblit_blend_BGRA8888_RGBA8888 (struct grub_video_fbblit_info *dst, color = *dstptr; dr = (color >> 16) & 0xFF; - dr = (dr * (255 ^ a) + sr * a) / 255U; + dr = alpha_dilute (dr, sr, a); dg = (color >> 8) & 0xFF; - dg = (dg * (255 ^ a) + sg * a) / 255U; + dg = alpha_dilute (dg, sg, a); db = (color >> 0) & 0xFF; - db = (db * (255 ^ a) + sb * a) / 255U; + db = alpha_dilute (db, sb, a); } color = (a << 24) | (dr << 16) | (dg << 8) | db; @@ -1360,9 +1371,9 @@ grub_video_fbblit_blend_BGR888_RGBA8888 (struct grub_video_fbblit_info *dst, db = dstptr[2]; #endif - db = (db * (255 ^ a) + sb * a) / 255U; - dg = (dg * (255 ^ a) + sg * a) / 255U; - dr = (dr * (255 ^ a) + sr * a) / 255U; + db = alpha_dilute (db, sb, a); + dg = alpha_dilute (dg, sg, a); + dr = alpha_dilute (dr, sr, a); } #ifndef GRUB_CPU_WORDS_BIGENDIAN @@ -1440,9 +1451,9 @@ grub_video_fbblit_blend_RGBA8888_RGBA8888 (struct grub_video_fbblit_info *dst, dg = (color >> 8) & 0xFF; db = (color >> 16) & 0xFF; - dr = (dr * (255 ^ a) + sr * a) / 255U; - dg = (dg * (255 ^ a) + sg * a) / 255U; - db = (db * (255 ^ a) + sb * a) / 255U; + dr = alpha_dilute (dr, sr, a); + dg = alpha_dilute (dg, sg, a); + db = alpha_dilute (db, sb, a); color = (a << 24) | (db << 16) | (dg << 8) | dr; @@ -1525,9 +1536,9 @@ grub_video_fbblit_blend_RGB888_RGBA8888 (struct grub_video_fbblit_info *dst, dr = dstptr[2]; #endif - dr = (dr * (255 ^ a) + sr * a) / 255U; - dg = (dg * (255 ^ a) + sg * a) / 255U; - db = (db * (255 ^ a) + sb * a) / 255U; + dr = alpha_dilute (dr, sr, a); + dg = alpha_dilute (dg, sg, a); + db = alpha_dilute (db, sb, a); #ifndef GRUB_CPU_WORDS_BIGENDIAN *dstptr++ = dr; @@ -1601,9 +1612,9 @@ grub_video_fbblit_blend_index_RGBA8888 (struct grub_video_fbblit_info *dst, grub_video_fb_unmap_color_int (dst, *dstptr, &dr, &dg, &db, &da); - dr = (dr * (255 ^ a) + sr * a) / 255U; - dg = (dg * (255 ^ a) + sg * a) / 255U; - db = (db * (255 ^ a) + sb * a) / 255U; + dr = alpha_dilute (dr, sr, a); + dg = alpha_dilute (dg, sg, a); + db = alpha_dilute (db, sb, a); color = grub_video_fb_map_rgb(dr, dg, db); @@ -1683,9 +1694,9 @@ grub_video_fbblit_blend_XXXA8888_1bit (struct grub_video_fbblit_info *dst, grub_uint8_t d2 = (*dstptr >> 8) & 0xFF; grub_uint8_t d3 = (*dstptr >> 16) & 0xFF; - d1 = (d1 * (255 ^ a) + s1 * a) / 255U; - d2 = (d2 * (255 ^ a) + s2 * a) / 255U; - d3 = (d3 * (255 ^ a) + s3 * a) / 255U; + d1 = alpha_dilute (d1, s1, a); + d2 = alpha_dilute (d2, s2, a); + d3 = alpha_dilute (d3, s3, a); *dstptr = (a << 24) | (d3 << 16) | (d2 << 8) | d1; } @@ -1791,9 +1802,9 @@ grub_video_fbblit_blend_XXX888_1bit (struct grub_video_fbblit_info *dst, grub_uint8_t d2 = (*(grub_uint32_t *) dstptr >> 8) & 0xFF; grub_uint8_t d3 = (*(grub_uint32_t *) dstptr >> 16) & 0xFF; - ((grub_uint8_t *) dstptr)[0] = (d1 * (255 ^ a) + s1 * a) / 255U; - ((grub_uint8_t *) dstptr)[1] = (d2 * (255 ^ a) + s2 * a) / 255U; - ((grub_uint8_t *) dstptr)[2] = (d3 * (255 ^ a) + s3 * a) / 255U; + ((grub_uint8_t *) dstptr)[0] = alpha_dilute (d1, s1, a); + ((grub_uint8_t *) dstptr)[1] = alpha_dilute (d2, s2, a); + ((grub_uint8_t *) dstptr)[2] = alpha_dilute (d3, s3, a); } srcmask >>= 1; @@ -1887,9 +1898,9 @@ grub_video_fbblit_blend_XXX565_1bit (struct grub_video_fbblit_info *dst, grub_uint8_t d2 = (*dstptr >> 5) & 0x3F; grub_uint8_t d3 = (*dstptr >> 11) & 0x1F; - d1 = (d1 * (255 ^ a) + s1 * a) / 255U; - d2 = (d2 * (255 ^ a) + s2 * a) / 255U; - d3 = (d3 * (255 ^ a) + s3 * a) / 255U; + d1 = alpha_dilute (d1, s1, a); + d2 = alpha_dilute (d2, s2, a); + d3 = alpha_dilute (d3, s3, a); *dstptr = (d1 & 0x1f) | ((d2 & 0x3f) << 5) | ((d3 & 0x1f) << 11); } From 80310ad07dfbd682ade52f2db2e536e0e7ccc471 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Thu, 26 Feb 2015 18:22:40 +0100 Subject: [PATCH 334/722] Add missing lib/division.c --- grub-core/lib/division.c | 73 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 grub-core/lib/division.c diff --git a/grub-core/lib/division.c b/grub-core/lib/division.c new file mode 100644 index 000000000..920a79f18 --- /dev/null +++ b/grub-core/lib/division.c @@ -0,0 +1,73 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2015 Free Software Foundation, Inc. + * + * GRUB is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GRUB is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GRUB. If not, see . + */ + +#include +#include + +GRUB_MOD_LICENSE ("GPLv3+"); + +static grub_uint64_t +abs64(grub_int64_t a) +{ + return a > 0 ? a : -a; +} + +grub_int64_t +grub_divmod64s (grub_int64_t n, + grub_int64_t d, + grub_int64_t *ro) +{ + grub_uint64_t ru; + grub_int64_t q, r; + q = grub_divmod64 (abs64(n), abs64(d), &ru); + r = ru; + /* Now: |n| = |d| * q + r */ + if (n < 0) + { + /* -|n| = |d| * (-q) + (-r) */ + q = -q; + r = -r; + } + /* Now: n = |d| * q + r */ + if (d < 0) + { + /* n = (-|d|) * (-q) + r */ + q = -q; + } + /* Now: n = d * q + r */ + *ro = r; + return q; +} + +grub_uint32_t +grub_divmod32 (grub_uint32_t n, grub_uint32_t d, grub_uint32_t *ro) +{ + grub_uint64_t q, r; + q = grub_divmod64 (n, d, &r); + *ro = r; + return q; +} + +grub_int32_t +grub_divmod32s (grub_int32_t n, grub_int32_t d, grub_int32_t *ro) +{ + grub_int64_t q, r; + q = grub_divmod64s (n, d, &r); + *ro = r; + return q; +} From 18125877eec4e6d7b0b6567b6c92eab1df946f47 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Thu, 26 Feb 2015 18:27:43 +0100 Subject: [PATCH 335/722] png: Optimize by avoiding divisions. --- grub-core/video/readers/png.c | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/grub-core/video/readers/png.c b/grub-core/video/readers/png.c index 1f03f88d3..e1a01e99f 100644 --- a/grub-core/video/readers/png.c +++ b/grub-core/video/readers/png.c @@ -227,7 +227,7 @@ grub_png_decode_image_palette (struct grub_png_data *data, { unsigned i = 0, j; - if (len == 0 || len % 3 != 0) + if (len == 0) return GRUB_ERR_NONE; for (i = 0; 3 * i < len && i < 256; i++) @@ -851,15 +851,26 @@ grub_png_convert_image (struct grub_png_data *data) int mask = (1 << data->color_bits) - 1; unsigned j; if (data->is_gray) - for (i = 0; i < (1U << data->color_bits); i++) - { - grub_uint8_t col = (0xff * i) / ((1U << data->color_bits) - 1); - palette[i][0] = col; - palette[i][1] = col; - palette[i][2] = col; - } + { + /* Generic formula is + (0xff * i) / ((1U << data->color_bits) - 1) + but for allowed bit depth of 1, 2 and for it's + equivalent to + (0xff / ((1U << data->color_bits) - 1)) * i + Precompute the multipliers to avoid division. + */ + + const grub_uint8_t multipliers[5] = { 0xff, 0xff, 0x55, 0x24, 0x11 }; + for (i = 0; i < (1U << data->color_bits); i++) + { + grub_uint8_t col = multipliers[data->color_bits] * i; + palette[i][0] = col; + palette[i][1] = col; + palette[i][2] = col; + } + } else - grub_memcpy (palette, data->palette, 16 * 3); + grub_memcpy (palette, data->palette, 3 << data->color_bits); d1c = d1; d2c = d2; for (j = 0; j < data->image_height; j++, d1c += data->image_width * 3, From 7213c1e02807e760febec06a0f19b11173abc55a Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Thu, 26 Feb 2015 21:27:32 +0100 Subject: [PATCH 336/722] jpeg: Optimise by replacing division with shifts. --- grub-core/video/readers/jpeg.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/grub-core/video/readers/jpeg.c b/grub-core/video/readers/jpeg.c index 38ea2395a..c3e0df240 100644 --- a/grub-core/video/readers/jpeg.c +++ b/grub-core/video/readers/jpeg.c @@ -94,7 +94,7 @@ struct grub_jpeg_data jpeg_data_unit_t crdu; jpeg_data_unit_t cbdu; - unsigned vs, hs; + unsigned log_vs, log_hs; int dri; unsigned r1; @@ -315,11 +315,14 @@ grub_jpeg_decode_sof (struct grub_jpeg_data *data) ss = grub_jpeg_get_byte (data); /* Sampling factor. */ if (!id) { - data->vs = ss & 0xF; /* Vertical sampling. */ - data->hs = ss >> 4; /* Horizontal sampling. */ - if ((data->vs > 2) || (data->hs > 2) || (data->vs == 0) || (data->hs == 0)) + grub_uint8_t vs, hs; + vs = ss & 0xF; /* Vertical sampling. */ + hs = ss >> 4; /* Horizontal sampling. */ + if ((vs > 2) || (hs > 2) || (vs == 0) || (hs == 0)) return grub_error (GRUB_ERR_BAD_FILE_TYPE, "jpeg: sampling method not supported"); + data->log_vs = (vs == 2); + data->log_hs = (hs == 2); } else if (ss != JPEG_SAMPLING_1x1) return grub_error (GRUB_ERR_BAD_FILE_TYPE, @@ -616,10 +619,10 @@ grub_jpeg_decode_data (struct grub_jpeg_data *data) unsigned c1, vb, hb, nr1, nc1; int rst = data->dri; - vb = data->vs * 8; - hb = data->hs * 8; - nr1 = (data->image_height + vb - 1) / vb; - nc1 = (data->image_width + hb - 1) / hb; + vb = 8 << data->log_vs; + hb = 8 << data->log_hs; + nr1 = (data->image_height + vb - 1) >> (3 + data->log_vs); + nc1 = (data->image_width + hb - 1) >> (3 + data->log_hs); for (; data->r1 < nr1 && (!data->dri || rst); data->r1++, data->bitmap_ptr += (vb * data->image_width - hb * nc1) * 3) @@ -629,8 +632,8 @@ grub_jpeg_decode_data (struct grub_jpeg_data *data) unsigned r2, c2, nr2, nc2; grub_uint8_t *ptr2; - for (r2 = 0; r2 < data->vs; r2++) - for (c2 = 0; c2 < data->hs; c2++) + for (r2 = 0; r2 < (1U << data->log_vs); r2++) + for (c2 = 0; c2 < (1U << data->log_hs); c2++) grub_jpeg_decode_du (data, 0, data->ydu[r2 * 2 + c2]); if (data->color_components >= 3) @@ -652,7 +655,7 @@ grub_jpeg_decode_data (struct grub_jpeg_data *data) unsigned i0; int yy; - i0 = (r2 / data->vs) * 8 + (c2 / data->hs); + i0 = (r2 >> data->log_vs) * 8 + (c2 >> data->log_hs); yy = data->ydu[(r2 / 8) * 2 + (c2 / 8)][(r2 % 8) * 8 + (c2 % 8)]; if (data->color_components >= 3) From 94f701a826b54e6652044bdba9a8b6a9aa2b479e Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Thu, 26 Feb 2015 22:04:40 +0100 Subject: [PATCH 337/722] crypto: restrict cipher block size to power of 2. All current ciphers have blocks which are power of 2 and it's unlikely to change. Other block length would be tricky to handle anyway. This restriction allows avoiding extra divisions. --- grub-core/disk/cryptodisk.c | 36 ++++++++++++++++++------------- grub-core/lib/crypto.c | 42 ++++++++++++++++++++++++------------- 2 files changed, 48 insertions(+), 30 deletions(-) diff --git a/grub-core/disk/cryptodisk.c b/grub-core/disk/cryptodisk.c index 376ab8326..82a3dcb63 100644 --- a/grub-core/disk/cryptodisk.c +++ b/grub-core/disk/cryptodisk.c @@ -110,20 +110,23 @@ grub_crypto_pcbc_decrypt (grub_crypto_cipher_handle_t cipher, { grub_uint8_t *inptr, *outptr, *end; grub_uint8_t ivt[GRUB_CRYPTO_MAX_CIPHER_BLOCKSIZE]; - if (cipher->cipher->blocksize > GRUB_CRYPTO_MAX_CIPHER_BLOCKSIZE) - return GPG_ERR_INV_ARG; + grub_size_t blocksize; if (!cipher->cipher->decrypt) return GPG_ERR_NOT_SUPPORTED; - if (size % cipher->cipher->blocksize != 0) + blocksize = cipher->cipher->blocksize; + if (blocksize == 0 || (((blocksize - 1) & blocksize) != 0) + || ((size & (blocksize - 1)) != 0)) + return GPG_ERR_INV_ARG; + if (blocksize > GRUB_CRYPTO_MAX_CIPHER_BLOCKSIZE) return GPG_ERR_INV_ARG; end = (grub_uint8_t *) in + size; for (inptr = in, outptr = out; inptr < end; - inptr += cipher->cipher->blocksize, outptr += cipher->cipher->blocksize) + inptr += blocksize, outptr += blocksize) { - grub_memcpy (ivt, inptr, cipher->cipher->blocksize); + grub_memcpy (ivt, inptr, blocksize); cipher->cipher->decrypt (cipher->ctx, outptr, inptr); - grub_crypto_xor (outptr, outptr, iv, cipher->cipher->blocksize); - grub_crypto_xor (iv, ivt, outptr, cipher->cipher->blocksize); + grub_crypto_xor (outptr, outptr, iv, blocksize); + grub_crypto_xor (iv, ivt, outptr, blocksize); } return GPG_ERR_NO_ERROR; } @@ -135,20 +138,23 @@ grub_crypto_pcbc_encrypt (grub_crypto_cipher_handle_t cipher, { grub_uint8_t *inptr, *outptr, *end; grub_uint8_t ivt[GRUB_CRYPTO_MAX_CIPHER_BLOCKSIZE]; - if (cipher->cipher->blocksize > GRUB_CRYPTO_MAX_CIPHER_BLOCKSIZE) - return GPG_ERR_INV_ARG; - if (!cipher->cipher->decrypt) + grub_size_t blocksize; + if (!cipher->cipher->encrypt) return GPG_ERR_NOT_SUPPORTED; - if (size % cipher->cipher->blocksize != 0) + blocksize = cipher->cipher->blocksize; + if (blocksize > GRUB_CRYPTO_MAX_CIPHER_BLOCKSIZE) + return GPG_ERR_INV_ARG; + if (blocksize == 0 || (((blocksize - 1) & blocksize) != 0) + || ((size & (blocksize - 1)) != 0)) return GPG_ERR_INV_ARG; end = (grub_uint8_t *) in + size; for (inptr = in, outptr = out; inptr < end; - inptr += cipher->cipher->blocksize, outptr += cipher->cipher->blocksize) + inptr += blocksize, outptr += blocksize) { - grub_memcpy (ivt, inptr, cipher->cipher->blocksize); - grub_crypto_xor (outptr, outptr, iv, cipher->cipher->blocksize); + grub_memcpy (ivt, inptr, blocksize); + grub_crypto_xor (outptr, outptr, iv, blocksize); cipher->cipher->encrypt (cipher->ctx, outptr, inptr); - grub_crypto_xor (iv, ivt, outptr, cipher->cipher->blocksize); + grub_crypto_xor (iv, ivt, outptr, blocksize); } return GPG_ERR_NO_ERROR; } diff --git a/grub-core/lib/crypto.c b/grub-core/lib/crypto.c index 8e8426c4a..010e550d1 100644 --- a/grub-core/lib/crypto.c +++ b/grub-core/lib/crypto.c @@ -205,13 +205,16 @@ grub_crypto_ecb_decrypt (grub_crypto_cipher_handle_t cipher, { const grub_uint8_t *inptr, *end; grub_uint8_t *outptr; + grub_size_t blocksize; if (!cipher->cipher->decrypt) return GPG_ERR_NOT_SUPPORTED; - if (size % cipher->cipher->blocksize != 0) + blocksize = cipher->cipher->blocksize; + if (blocksize == 0 || (((blocksize - 1) & blocksize) != 0) + || ((size & (blocksize - 1)) != 0)) return GPG_ERR_INV_ARG; end = (const grub_uint8_t *) in + size; for (inptr = in, outptr = out; inptr < end; - inptr += cipher->cipher->blocksize, outptr += cipher->cipher->blocksize) + inptr += blocksize, outptr += blocksize) cipher->cipher->decrypt (cipher->ctx, outptr, inptr); return GPG_ERR_NO_ERROR; } @@ -222,13 +225,16 @@ grub_crypto_ecb_encrypt (grub_crypto_cipher_handle_t cipher, { const grub_uint8_t *inptr, *end; grub_uint8_t *outptr; + grub_size_t blocksize; if (!cipher->cipher->encrypt) return GPG_ERR_NOT_SUPPORTED; - if (size % cipher->cipher->blocksize != 0) + blocksize = cipher->cipher->blocksize; + if (blocksize == 0 || (((blocksize - 1) & blocksize) != 0) + || ((size & (blocksize - 1)) != 0)) return GPG_ERR_INV_ARG; end = (const grub_uint8_t *) in + size; for (inptr = in, outptr = out; inptr < end; - inptr += cipher->cipher->blocksize, outptr += cipher->cipher->blocksize) + inptr += blocksize, outptr += blocksize) cipher->cipher->encrypt (cipher->ctx, outptr, inptr); return GPG_ERR_NO_ERROR; } @@ -241,20 +247,23 @@ grub_crypto_cbc_encrypt (grub_crypto_cipher_handle_t cipher, grub_uint8_t *outptr; const grub_uint8_t *inptr, *end; void *iv; - if (!cipher->cipher->decrypt) + grub_size_t blocksize; + if (!cipher->cipher->encrypt) return GPG_ERR_NOT_SUPPORTED; - if (size % cipher->cipher->blocksize != 0) + blocksize = cipher->cipher->blocksize; + if (blocksize == 0 || (((blocksize - 1) & blocksize) != 0) + || ((size & (blocksize - 1)) != 0)) return GPG_ERR_INV_ARG; end = (const grub_uint8_t *) in + size; iv = iv_in; for (inptr = in, outptr = out; inptr < end; - inptr += cipher->cipher->blocksize, outptr += cipher->cipher->blocksize) + inptr += blocksize, outptr += blocksize) { - grub_crypto_xor (outptr, inptr, iv, cipher->cipher->blocksize); + grub_crypto_xor (outptr, inptr, iv, blocksize); cipher->cipher->encrypt (cipher->ctx, outptr, outptr); iv = outptr; } - grub_memcpy (iv_in, iv, cipher->cipher->blocksize); + grub_memcpy (iv_in, iv, blocksize); return GPG_ERR_NO_ERROR; } @@ -266,20 +275,23 @@ grub_crypto_cbc_decrypt (grub_crypto_cipher_handle_t cipher, const grub_uint8_t *inptr, *end; grub_uint8_t *outptr; grub_uint8_t ivt[GRUB_CRYPTO_MAX_CIPHER_BLOCKSIZE]; + grub_size_t blocksize; if (!cipher->cipher->decrypt) return GPG_ERR_NOT_SUPPORTED; - if (size % cipher->cipher->blocksize != 0) + blocksize = cipher->cipher->blocksize; + if (blocksize == 0 || (((blocksize - 1) & blocksize) != 0) + || ((size & (blocksize - 1)) != 0)) return GPG_ERR_INV_ARG; - if (cipher->cipher->blocksize > GRUB_CRYPTO_MAX_CIPHER_BLOCKSIZE) + if (blocksize > GRUB_CRYPTO_MAX_CIPHER_BLOCKSIZE) return GPG_ERR_INV_ARG; end = (const grub_uint8_t *) in + size; for (inptr = in, outptr = out; inptr < end; - inptr += cipher->cipher->blocksize, outptr += cipher->cipher->blocksize) + inptr += blocksize, outptr += blocksize) { - grub_memcpy (ivt, inptr, cipher->cipher->blocksize); + grub_memcpy (ivt, inptr, blocksize); cipher->cipher->decrypt (cipher->ctx, outptr, inptr); - grub_crypto_xor (outptr, outptr, iv, cipher->cipher->blocksize); - grub_memcpy (iv, ivt, cipher->cipher->blocksize); + grub_crypto_xor (outptr, outptr, iv, blocksize); + grub_memcpy (iv, ivt, blocksize); } return GPG_ERR_NO_ERROR; } From f76c98b79eabccd1bdbd0d7c2763e09aa1e58e06 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Thu, 26 Feb 2015 22:06:19 +0100 Subject: [PATCH 338/722] dmraid_nvidia: Fix division by 0 and missing byte-swap. --- grub-core/disk/dmraid_nvidia.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/grub-core/disk/dmraid_nvidia.c b/grub-core/disk/dmraid_nvidia.c index fc02f5715..881508cf2 100644 --- a/grub-core/disk/dmraid_nvidia.c +++ b/grub-core/disk/dmraid_nvidia.c @@ -99,6 +99,8 @@ grub_dmraid_nv_detect (grub_disk_t disk, struct grub_nv_super sb; int level; grub_uint64_t disk_size; + grub_uint32_t capacity; + grub_uint8_t total_volumes; char *uuid; if (disk->partition) @@ -124,14 +126,17 @@ grub_dmraid_nv_detect (grub_disk_t disk, return NULL; } + capacity = grub_le_to_cpu32 (sb.capacity); + total_volumes = sb.array.total_volumes; + switch (sb.array.raid_level) { case NV_LEVEL_0: level = 0; - disk_size = sb.capacity / sb.array.total_volumes; - if (sb.array.total_volumes == 0) + if (total_volumes == 0) /* Not RAID. */ return NULL; + disk_size = capacity / total_volumes; break; case NV_LEVEL_1: @@ -141,10 +146,10 @@ grub_dmraid_nv_detect (grub_disk_t disk, case NV_LEVEL_5: level = 5; - disk_size = sb.capacity / (sb.array.total_volumes - 1); - if (sb.array.total_volumes == 0 || sb.array.total_volumes == 1) + if (total_volumes == 0 || total_volumes == 1) /* Not RAID. */ return NULL; + disk_size = capacity / (total_volumes - 1); break; default: From 67a6a9512a52fee34a452752787dc80577fa7838 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Thu, 26 Feb 2015 22:07:22 +0100 Subject: [PATCH 339/722] raid6: Optimize by removing division. --- grub-core/disk/raid6_recover.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/grub-core/disk/raid6_recover.c b/grub-core/disk/raid6_recover.c index f9ec632fb..aa674f6ca 100644 --- a/grub-core/disk/raid6_recover.c +++ b/grub-core/disk/raid6_recover.c @@ -63,6 +63,16 @@ grub_raid6_init_table (void) } } +static unsigned +mod_255 (unsigned x) +{ + while (x > 0xff) + x = (x >> 8) + (x & 0xff); + if (x == 0xff) + return 0; + return x; +} + static grub_err_t grub_raid6_recover (struct grub_diskfilter_segment *array, int disknr, int p, char *buf, grub_disk_addr_t sector, grub_size_t size) @@ -162,11 +172,11 @@ grub_raid6_recover (struct grub_diskfilter_segment *array, int disknr, int p, grub_crypto_xor (qbuf, qbuf, buf, size); - c = ((255 ^ bad1) - + (255 ^ powx_inv[(powx[bad2 + (bad1 ^ 255)] ^ 1)])) % 255; + c = mod_255((255 ^ bad1) + + (255 ^ powx_inv[(powx[bad2 + (bad1 ^ 255)] ^ 1)])); grub_raid_block_mulx (c, qbuf, size); - c = ((unsigned) bad2 + c) % 255; + c = mod_255((unsigned) bad2 + c); grub_raid_block_mulx (c, pbuf, size); grub_crypto_xor (pbuf, pbuf, qbuf, size); From 7ba066419a2e0f777a0c103b058fba49e1492f04 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Thu, 26 Feb 2015 22:10:09 +0100 Subject: [PATCH 340/722] gzio: Optimize by removing division. --- grub-core/io/gzio.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/grub-core/io/gzio.c b/grub-core/io/gzio.c index 129209e37..0f2ea6bd8 100644 --- a/grub-core/io/gzio.c +++ b/grub-core/io/gzio.c @@ -1161,6 +1161,19 @@ grub_gzio_open (grub_file_t io, const char *name __attribute__ ((unused))) return file; } +static grub_uint8_t +mod_31 (grub_uint16_t v) +{ + /* At most 2 iterations for any number that + we can get here. + In any case faster than real division. */ + while (v > 0x1f) + v = (v & 0x1f) + (v >> 5); + if (v == 0x1f) + return 0; + return v; +} + static int test_zlib_header (grub_gzio_t gzio) { @@ -1178,7 +1191,10 @@ test_zlib_header (grub_gzio_t gzio) return 0; } - if ((cmf * 256U + flg) % 31U) + /* Usually it would be: (cmf * 256 + flg) % 31 != 0. */ + /* But 256 == 8 (31). */ + /* By multiplying by 4 and using 32 == 1 (31). We get our formula. */ + if (mod_31 (cmf + flg * 4) != 0) { grub_error (GRUB_ERR_BAD_COMPRESSED_DATA, N_("unsupported gzip format")); return 0; From 38b7a3026900670159f299f2daa7e35957752942 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Thu, 26 Feb 2015 22:10:29 +0100 Subject: [PATCH 341/722] arm/dl: Fix handling of nonstandard relocation sizes --- grub-core/kern/arm/dl.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/grub-core/kern/arm/dl.c b/grub-core/kern/arm/dl.c index 5cbd65e46..24364e189 100644 --- a/grub-core/kern/arm/dl.c +++ b/grub-core/kern/arm/dl.c @@ -78,9 +78,9 @@ grub_arch_dl_get_tramp_got_size (const void *ehdr, grub_size_t *tramp, const Elf_Rel *rel, *max; for (rel = (const Elf_Rel *) ((grub_addr_t) e + s->sh_offset), - max = rel + s->sh_size / s->sh_entsize; - rel < max; - rel++) + max = (const Elf_Rel *) ((grub_addr_t) rel + s->sh_size); + rel + 1 <= max; + rel = (const Elf_Rel *) ((grub_addr_t) rel + s->sh_entsize)) switch (ELF_R_TYPE (rel->r_info)) { case R_ARM_CALL: From 66b0e6649b8aa169db1b026abc4dd4167bb312e8 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Thu, 26 Feb 2015 22:20:59 +0100 Subject: [PATCH 342/722] emu/cache: Change declaration of __clear_cache to match builtin declaration. Fixes compile of arm64-emu. --- grub-core/kern/emu/cache.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/kern/emu/cache.c b/grub-core/kern/emu/cache.c index 07be6756f..6f89e871a 100644 --- a/grub-core/kern/emu/cache.c +++ b/grub-core/kern/emu/cache.c @@ -8,7 +8,7 @@ #include "../ia64/cache.c" #elif defined (__arm__) || defined (__aarch64__) -void __clear_cache (char *beg, char *end); +void __clear_cache (void *beg, void *end); void grub_arch_sync_caches (void *address, grub_size_t len) From 050505ab8f695c10b3e4e768a4188688ebe5e366 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sat, 28 Feb 2015 15:13:41 +0100 Subject: [PATCH 343/722] ntfs_test: Skip is setfattr is unavailable. --- tests/ntfs_test.in | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/ntfs_test.in b/tests/ntfs_test.in index 6bf09e691..e25c6384a 100644 --- a/tests/ntfs_test.in +++ b/tests/ntfs_test.in @@ -15,5 +15,10 @@ if ! which mkfs.ntfs >/dev/null 2>&1; then exit 77 fi +if ! which setfattr >/dev/null 2>&1; then + echo "setfattr not installed; cannot test ntfs." + exit 77 +fi + "@builddir@/grub-fs-tester" ntfs -"@builddir@/grub-fs-tester" ntfscomp \ No newline at end of file +"@builddir@/grub-fs-tester" ntfscomp From ddde9ca71ac7e0c42a445f5a37085c5895098e34 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sat, 28 Feb 2015 15:14:16 +0100 Subject: [PATCH 344/722] grub-shell: Add missing --locale-directory. Fixes the language tests is no make install was done. --- tests/util/grub-shell.in | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/util/grub-shell.in b/tests/util/grub-shell.in index 5b66139a9..6d2b1327e 100644 --- a/tests/util/grub-shell.in +++ b/tests/util/grub-shell.in @@ -349,6 +349,7 @@ fi if [ x$boot != xnet ] && [ x$boot != xemu ]; then pkgdatadir="@builddir@" "@builddir@/grub-mkrescue" "--output=${isofile}" "--override-directory=${builddir}/grub-core" \ --rom-directory="${rom_directory}" \ + --locale-directory="@srcdir@/po" \ --themes-directory="@srcdir@/themes" \ $mkimage_extra_arg ${mkrescue_args} \ "/boot/grub/grub.cfg=${cfgfile}" "/boot/grub/testcase.cfg=${source}" \ From afd6b6bbaedfd7724e6ccc0401c76021a429779b Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sat, 28 Feb 2015 16:22:46 +0100 Subject: [PATCH 345/722] grub-probe: Mark a "[default=]" for translation. --- util/grub-probe.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/util/grub-probe.c b/util/grub-probe.c index 8a0c4f35b..08d477f5f 100644 --- a/util/grub-probe.c +++ b/util/grub-probe.c @@ -728,10 +728,12 @@ help_filter (int key, const char *text, void *input __attribute__ ((unused))) case 't': { - char *ret, *t = get_targets_string (); + char *ret, *t = get_targets_string (), *def; - ret = xasprintf ("%s\n%s %s [default=%s]", _("print TARGET"), - _("available targets:"), t, targets[print]); + def = xasprintf (_("[default=%s]"), targets[print]); + + ret = xasprintf ("%s\n%s %s %s", _("print TARGET"), + _("available targets:"), t, def); free (t); return ret; } From 0d6498a67d4542244c2ca183e05cfc3d858218be Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sat, 28 Feb 2015 16:23:27 +0100 Subject: [PATCH 346/722] exclude.pot: Add new technical strings --- po/exclude.pot | 311 +++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 291 insertions(+), 20 deletions(-) diff --git a/po/exclude.pot b/po/exclude.pot index 1659eb01b..ab52e9990 100644 --- a/po/exclude.pot +++ b/po/exclude.pot @@ -2296,10 +2296,6 @@ msgstr "" msgid "WEEKDAY" msgstr "" -#: grub-core/io/lzopio.c:30 -msgid "‰LZO" -msgstr "" - #: grub-core/kern/dl.c:412 msgid "grub_mod_init" msgstr "" @@ -4215,22 +4211,10 @@ msgstr "" msgid "ext*" msgstr "" -#: grub-core/partmap/msdos.c:74 -msgid "ÔA õ" -msgstr "" - -#: grub-core/partmap/msdos.c:80 -msgid "ØA õ" -msgstr "" - #: grub-core/partmap/msdos.c:86 msgid "HP Backup and Recovery Manager (?)" msgstr "" -#: grub-core/partmap/msdos.c:87 -msgid "pŠ]F5Å“®=†ý±U>à" -msgstr "" - #: grub-core/partmap/msdos.c:94 msgid "ycgl" msgstr "" @@ -4574,10 +4558,6 @@ msgstr "" msgid " failed: %ld\n" msgstr "" -#: grub-core/lib/xzembed/xz_stream.h:35 -msgid "ý7zXZ" -msgstr "" - #: grub-core/lib/xzembed/xz_stream.h:38 msgid "YZ" msgstr "" @@ -7173,3 +7153,294 @@ msgstr "" #: util/grub-mkimagexx.c:845 msgid "CALL26 Relocation out of range" msgstr "" + +#: grub-core/commands/verify.c:313 +msgid "\x99" +msgstr "" + +#: grub-core/commands/videotest.c:122 +msgid "Unicode test: happy\xE2\x98\xBA \xC2\xA3 5.00" + " \xC2\xA1\xCF\x84\xC3\xA4u! " + " \xE2\x84\xA4\xE2\x8A\x86\xE2\x84\x9D" +msgstr "" + +#: grub-core/disk/luks.c:40 +msgid "LUKS\xBA\xBE" +msgstr "" + +#: grub-core/disk/lvmparse.c:67 grub-core/disk/lvmparse.c:69 +msgid " = [" +msgstr "" + +#: grub-core/disk/lvmparse.c:115 grub-core/disk/lvmparse.c:123 +#: grub-core/disk/lvmparse.c:167 grub-core/disk/lvmparse.c:170 +msgid "id = \"" +msgstr "" + +#: grub-core/disk/lvmparse.c:127 +msgid "extent_size = " +msgstr "" + +#: grub-core/disk/lvmparse.c:143 grub-core/disk/lvmparse.c:146 +msgid "physical_volumes {" +msgstr "" + +#: grub-core/disk/lvmparse.c:174 +msgid "pe_start = " +msgstr "" + +#: grub-core/disk/lvmparse.c:199 +msgid "logical_volumes" +msgstr "" + +#: grub-core/disk/lvmparse.c:202 +msgid "logical_volumes = " +msgstr "" + +#: grub-core/disk/lvmparse.c:226 grub-core/disk/lvmparse.c:227 +msgid "status" +msgstr "" + +#: grub-core/disk/lvmparse.c:226 +msgid "VISIBLE" +msgstr "" + +#: grub-core/disk/lvmparse.c:227 +msgid "PVMOVE" +msgstr "" + +#: grub-core/disk/lvmparse.c:228 +msgid "segment_count = " +msgstr "" + +#: grub-core/disk/lvmparse.c:246 +msgid "segment" +msgstr "" + +#: grub-core/disk/lvmparse.c:255 +msgid "start_extent = " +msgstr "" + +#: grub-core/disk/lvmparse.c:263 +msgid "extent_count = " +msgstr "" + +#: grub-core/disk/lvmparse.c:272 grub-core/disk/lvmparse.c:275 +msgid "type = \"" +msgstr "" + +#: grub-core/disk/lvmparse.c:277 grub-core/disk/lvmparse.c:278 +msgid "striped\"" +msgstr "" + +#: grub-core/disk/lvmparse.c:282 +msgid "stripe_count = " +msgstr "" + +#: grub-core/disk/lvmparse.c:292 grub-core/disk/lvmparse.c:396 +msgid "stripe_size = " +msgstr "" + +#: grub-core/disk/lvmparse.c:299 grub-core/disk/lvmparse.c:307 +msgid "stripes = [" +msgstr "" + +#: grub-core/disk/lvmparse.c:332 +msgid "mirror\"" +msgstr "" + +#: grub-core/disk/lvmparse.c:336 +msgid "mirror_count = " +msgstr "" + +#: grub-core/disk/lvmparse.c:350 grub-core/disk/lvmparse.c:358 +msgid "mirrors = [" +msgstr "" + +#: grub-core/disk/lvmparse.c:375 grub-core/disk/lvmparse.c:376 +#: grub-core/disk/lvmparse.c:377 grub-core/disk/lvmparse.c:384 +msgid "raid" +msgstr "" + +#: grub-core/disk/lvmparse.c:378 +msgid "raidX" +msgstr "" + +#: grub-core/disk/lvmparse.c:386 +msgid "device_count = " +msgstr "" + +#: grub-core/disk/lvmparse.c:410 grub-core/disk/lvmparse.c:418 +msgid "raids = [" +msgstr "" + +#: grub-core/fs/cpio.c:24 +msgid "\xc7\x71" +msgstr "" + +#: grub-core/fs/cpio_be.c:23 +msgid "\x71\xc7" +msgstr "" + +#: grub-core/gfxmenu/gui_circular_progress.c:244 +msgid "\xc2\xb0" +msgstr "" + +#: grub-core/kern/ieee1275/cmain.c:88 +msgid "IBM pSeries (emulated by qemu)" +msgstr "" + +#: grub-core/lib/all_video.c:36 +msgid "/video.lst" +msgstr "" + +#: grub-core/osdep/unix/config.c:108 +#, c-format +msgid "" +"'; printf \"GRUB_ENABLE_CRYPTODISK=%s\\nGRUB_DISTRIBUTOR=%s\\n\" " +"\"$GRUB_ENABLE_CRYPTODISK\" \"$GRUB_DISTRIBUTOR\"" +msgstr "" + +#: include/grub/dl.h:141 +msgid "license" +msgstr "" + +#: util/grub-install.c:1106 +msgid "BOOTAA64.EFI" +msgstr "" + +#: util/grub-install.c:1133 +msgid "grubaa64.efi" +msgstr "" + +#: util/grub-install.c:1274 +msgid "GRUB_ENABLE_CRYPTODISK=y" +msgstr "" + +#: util/grub-mkrescue.c:656 +msgid "part_gpt" +msgstr "" + +#: util/grub-mkrescue.c:657 +msgid "part_msdos" +msgstr "" + +#: util/grub-mkrescue.c:663 util/grub-mkrescue.c:668 util/grub-mkrescue.c:723 +msgid "part_apple" +msgstr "" + +#: util/grub-mkrescue.c:677 +msgid "bootaa64.efi" +msgstr "" + +#: util/grub-probe.c:136 util/grub-probe.c:151 util/grub-probe.c:190 +#: util/grub-probe.c:247 +#, c-format +msgid "%s%c" +msgstr "" + +#: util/grub-probe.c:233 +#, c-format +msgid "lvm%c" +msgstr "" + +#: util/grub-probe.c:237 +#, c-format +msgid "ldm%c" +msgstr "" + +#: util/grub-probe.c:245 +#, c-format +msgid "diskfilter%c" +msgstr "" + +#: util/grub-probe.c:250 +#, c-format +msgid "raid5rec%c" +msgstr "" + +#: util/grub-probe.c:252 +#, c-format +msgid "raid6rec%c" +msgstr "" + +#: util/grub-mkrescue.c:136 +#, c-format +msgid "%s\n\n%s\n\n%s" +msgstr "" + +#: grub-core/kern/arm/cache.c:133 +msgid "couldn't get memory map, not enabling caches" +msgstr "" + +#: grub-core/kern/arm/cache.c:149 +#, c-format +msgid "%d crossers\n" +msgstr "" + +#: grub-core/kern/arm/cache.c:154 +msgid "couldn't allocate place for MMU table, not enabling caches" +msgstr "" + +#: grub-core/kern/arm/cache.c:212 +msgid "MMU tables generated\n" +msgstr "" + +#: grub-core/kern/arm/cache.c:216 +msgid "enabling MMU\n" +msgstr "" + +#: grub-core/kern/arm/cache.c:218 +msgid "MMU enabled\n" +msgstr "" + +#: grub-core/commands/verify.c:313 +msgid "™" +msgstr "" + +#: grub-core/commands/videotest.c:122 +msgid "Unicode test: happy☺ £ 5.00 ¡Ã„äu! ℤ⊆â„Â" +msgstr "" + +#: grub-core/disk/luks.c:40 +msgid "LUKSº¾" +msgstr "" + +#: grub-core/fs/cpio.c:24 +msgid "Çq" +msgstr "" + +#: grub-core/fs/cpio_be.c:23 +msgid "qÇ" +msgstr "" + +#: grub-core/gfxmenu/gui_circular_progress.c:244 +msgid "°" +msgstr "" + +#: grub-core/lib/xzembed/xz_stream.h:35 +msgid "ý7zXZ" +msgstr "" + +#: grub-core/partmap/msdos.c:74 +msgid "ÔA õ" +msgstr "" + +#: grub-core/partmap/msdos.c:80 +msgid "ØA õ" +msgstr "" + +#: grub-core/partmap/msdos.c:87 +msgid "pŠ]F5Ã…“®=†ý±U>à" +msgstr "" + +#: grub-core/io/lzopio.c:30 +msgid "" +"‰LZO\n" +"\n" +msgstr "" + +#: util/grub-probe.c:735 +#, c-format +msgid "%s\n%s %s %s" +msgstr "" From 018f79da6f6f0aab34ce501e62db77c89a23aca1 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sat, 28 Feb 2015 20:19:57 +0300 Subject: [PATCH 347/722] grub-probe: free temporary variable --- util/grub-probe.c | 1 + 1 file changed, 1 insertion(+) diff --git a/util/grub-probe.c b/util/grub-probe.c index 08d477f5f..8f4aa6138 100644 --- a/util/grub-probe.c +++ b/util/grub-probe.c @@ -735,6 +735,7 @@ help_filter (int key, const char *text, void *input __attribute__ ((unused))) ret = xasprintf ("%s\n%s %s %s", _("print TARGET"), _("available targets:"), t, def); free (t); + free (def); return ret; } From 87ec3b7fa9061f470616ed927fc140e995831c00 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 27 Feb 2015 14:26:00 +0100 Subject: [PATCH 348/722] Don't continue to query block-size if disk doesn't have it. Stops poluting screen with a lot of "block-size: exception -21". --- grub-core/disk/ieee1275/ofdisk.c | 62 ++++++++++++++++++++++---------- include/grub/ieee1275/ofdisk.h | 3 -- 2 files changed, 44 insertions(+), 21 deletions(-) diff --git a/grub-core/disk/ieee1275/ofdisk.c b/grub-core/disk/ieee1275/ofdisk.c index 5d8863782..331769b12 100644 --- a/grub-core/disk/ieee1275/ofdisk.c +++ b/grub-core/disk/ieee1275/ofdisk.c @@ -35,6 +35,7 @@ struct ofdisk_hash_ent char *grub_devpath; int is_boot; int is_removable; + int block_size_fails; /* Pointer to shortest available name on nodes representing canonical names, otherwise NULL. */ const char *shortest; @@ -42,6 +43,10 @@ struct ofdisk_hash_ent struct ofdisk_hash_ent *next; }; +static grub_err_t +grub_ofdisk_get_block_size (const char *device, grub_uint32_t *block_size, + struct ofdisk_hash_ent *op); + #define OFDISK_HASH_SZ 8 static struct ofdisk_hash_ent *ofdisk_hash[OFDISK_HASH_SZ]; @@ -375,6 +380,8 @@ grub_ofdisk_open (const char *name, grub_disk_t disk) /* XXX: This should be large enough for any possible case. */ char prop[64]; grub_ssize_t actual; + grub_uint32_t block_size = 0; + grub_err_t err; if (grub_strncmp (name, "ieee1275/", sizeof ("ieee1275/") - 1) != 0) return grub_error (GRUB_ERR_UNKNOWN_DEVICE, @@ -405,14 +412,6 @@ grub_ofdisk_open (const char *name, grub_disk_t disk) return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "not a block device"); } - grub_uint32_t block_size = 0; - if (grub_ofdisk_get_block_size (devpath, &block_size) == 0) - { - for (disk->log_sector_size = 0; - (1U << disk->log_sector_size) < block_size; - disk->log_sector_size++); - } - /* XXX: There is no property to read the number of blocks. There should be a property `#blocks', but it is not there. Perhaps it is possible to use seek for this. */ @@ -429,6 +428,18 @@ grub_ofdisk_open (const char *name, grub_disk_t disk) return grub_errno; disk->id = (unsigned long) op; disk->data = op->open_path; + + err = grub_ofdisk_get_block_size (devpath, &block_size, op); + if (err) + return err; + if (block_size != 0) + { + for (disk->log_sector_size = 0; + (1U << disk->log_sector_size) < block_size; + disk->log_sector_size++); + } + else + disk->log_sector_size = 9; } return 0; @@ -589,8 +600,9 @@ grub_ofdisk_init (void) grub_disk_dev_register (&grub_ofdisk_dev); } -grub_err_t -grub_ofdisk_get_block_size (const char *device, grub_uint32_t *block_size) +static grub_err_t +grub_ofdisk_get_block_size (const char *device, grub_uint32_t *block_size, + struct ofdisk_hash_ent *op) { struct size_args_ieee1275 { @@ -612,20 +624,34 @@ grub_ofdisk_get_block_size (const char *device, grub_uint32_t *block_size) if (! last_ihandle) return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "can't open device"); + *block_size = 0; + + if (op->block_size_fails >= 2) + return GRUB_ERR_NONE; + INIT_IEEE1275_COMMON (&args_ieee1275.common, "call-method", 2, 2); args_ieee1275.method = (grub_ieee1275_cell_t) "block-size"; args_ieee1275.ihandle = last_ihandle; args_ieee1275.result = 1; - *block_size = GRUB_DISK_SECTOR_SIZE; - - if ((IEEE1275_CALL_ENTRY_FN (&args_ieee1275) == -1) || (args_ieee1275.result)) - grub_dprintf ("disk", "can't get block size\n"); - else - if (args_ieee1275.size1 - && !(args_ieee1275.size1 & (args_ieee1275.size1 - 1)) - && args_ieee1275.size1 >= 512 && args_ieee1275.size1 <= 16384) + if (IEEE1275_CALL_ENTRY_FN (&args_ieee1275) == -1) + { + grub_dprintf ("disk", "can't get block size: failed call-method\n"); + op->block_size_fails++; + } + else if (args_ieee1275.result) + { + grub_dprintf ("disk", "can't get block size: %lld\n", + (long long) args_ieee1275.result); + op->block_size_fails++; + } + else if (args_ieee1275.size1 + && !(args_ieee1275.size1 & (args_ieee1275.size1 - 1)) + && args_ieee1275.size1 >= 512 && args_ieee1275.size1 <= 16384) + { + op->block_size_fails = 0; *block_size = args_ieee1275.size1; + } return 0; } diff --git a/include/grub/ieee1275/ofdisk.h b/include/grub/ieee1275/ofdisk.h index 3f5831787..2f69e3f19 100644 --- a/include/grub/ieee1275/ofdisk.h +++ b/include/grub/ieee1275/ofdisk.h @@ -22,7 +22,4 @@ extern void grub_ofdisk_init (void); extern void grub_ofdisk_fini (void); -extern grub_err_t grub_ofdisk_get_block_size (const char *device, - grub_uint32_t *block_size); - #endif /* ! GRUB_INIT_HEADER */ From aa6ccc05c10df14bc39a6a7d9d928d8180e3ef79 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Tue, 3 Mar 2015 09:07:53 +0100 Subject: [PATCH 349/722] configure.ac: Set $CPPFLAGS when checking for no_app_regs. Fixes compilation for sparc64 with clang. --- configure.ac | 1 + 1 file changed, 1 insertion(+) diff --git a/configure.ac b/configure.ac index 908bb81e7..9e24d896d 100644 --- a/configure.ac +++ b/configure.ac @@ -741,6 +741,7 @@ if test x"$target_cpu" = xsparc64 ; then break fi CFLAGS="$TARGET_CFLAGS $cand -Werror" + CPPFLAGS="$TARGET_CPPFLAGS" AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])], [grub_cv_target_cc_mno_app_regs="$cand"], []) done From 77697d14e55eaf878639a630ab45563fa9556a97 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Tue, 3 Mar 2015 09:12:10 +0100 Subject: [PATCH 350/722] types.h: Use __builtin_bswap* with clang. clang pretends to be GCC 4.2 but we use __builtin_bswap* only with GCC 4.3+. clang support __builtin_bswap*, so use it. --- include/grub/types.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/grub/types.h b/include/grub/types.h index 79f765c62..e732efb5c 100644 --- a/include/grub/types.h +++ b/include/grub/types.h @@ -179,7 +179,7 @@ static inline grub_uint16_t grub_swap_bytes16(grub_uint16_t _x) | (_x >> 56)); \ }) -#if defined(__GNUC__) && (__GNUC__ > 3) && (__GNUC__ > 4 || __GNUC_MINOR__ >= 3) +#if (defined(__GNUC__) && (__GNUC__ > 3) && (__GNUC__ > 4 || __GNUC_MINOR__ >= 3)) || defined(__clang__) static inline grub_uint32_t grub_swap_bytes32(grub_uint32_t x) { return __builtin_bswap32(x); From 064360e6671e0c5f2f47b73fd03b33be8a81f72c Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Tue, 3 Mar 2015 20:23:42 +0100 Subject: [PATCH 351/722] Remove libgcc dependency. libgcc for boot environment isn't always present and compatible. libgcc is often absent if endianness or bit-size at boot is different from running OS. libgcc may use optimised opcodes that aren't available on boot time. So instead of relying on libgcc shipped with the compiler, supply the functions in GRUB directly. Tests are present to ensure that those replacement functions behave the way compiler expects them to. --- conf/Makefile.common | 4 +- config.h.in | 1 + configure.ac | 25 +- grub-core/Makefile.am | 8 +- grub-core/Makefile.core.def | 43 +- grub-core/boot/decompressor/minilib.c | 11 +- grub-core/kern/arm/{misc.S => compiler-rt.S} | 0 grub-core/kern/compiler-rt.c | 404 +++++++++++++++++++ grub-core/kern/misc.c | 232 ----------- grub-core/kern/powerpc/compiler-rt.S | 130 ++++++ grub-core/lib/posix_wrap/string.h | 20 +- grub-core/tests/bswap_test.c | 121 ++++++ grub-core/tests/cmp_test.c | 190 +++++++++ grub-core/tests/ctz_test.c | 111 +++++ grub-core/tests/lib/functional_test.c | 5 + grub-core/tests/mul_test.c | 73 ++++ grub-core/tests/shift_test.c | 157 +++++++ include/grub/compiler-rt.h | 193 +++++++++ include/grub/libgcc.h | 91 ----- include/grub/misc.h | 99 +---- include/grub/xen.h | 2 + 21 files changed, 1441 insertions(+), 479 deletions(-) rename grub-core/kern/arm/{misc.S => compiler-rt.S} (100%) create mode 100644 grub-core/kern/compiler-rt.c create mode 100644 grub-core/kern/powerpc/compiler-rt.S create mode 100644 grub-core/tests/bswap_test.c create mode 100644 grub-core/tests/cmp_test.c create mode 100644 grub-core/tests/ctz_test.c create mode 100644 grub-core/tests/mul_test.c create mode 100644 grub-core/tests/shift_test.c create mode 100644 include/grub/compiler-rt.h delete mode 100644 include/grub/libgcc.h diff --git a/conf/Makefile.common b/conf/Makefile.common index 8861096a5..96e58c9a4 100644 --- a/conf/Makefile.common +++ b/conf/Makefile.common @@ -34,10 +34,8 @@ CPPFLAGS_DEFAULT += -I$(top_srcdir)/grub-core/lib/libgcrypt-grub/src/ CCASFLAGS_DEFAULT = $(CPPFLAGS_DEFAULT) -DASM_FILE=1 BUILD_CPPFLAGS += $(CPPFLAGS_DEFAULT) -LDADD_KERNEL = $(TARGET_LIBGCC) - CFLAGS_KERNEL = $(CFLAGS_PLATFORM) -ffreestanding -LDFLAGS_KERNEL = $(LDFLAGS_PLATFORM) -nostdlib $(TARGET_LDFLAGS_OLDMAGIC) $(TARGET_LDFLAGS_STATIC_LIBGCC) +LDFLAGS_KERNEL = $(LDFLAGS_PLATFORM) -nostdlib $(TARGET_LDFLAGS_OLDMAGIC) CPPFLAGS_KERNEL = $(CPPFLAGS_CPU) $(CPPFLAGS_PLATFORM) -DGRUB_KERNEL=1 CCASFLAGS_KERNEL = $(CCASFLAGS_CPU) $(CCASFLAGS_PLATFORM) STRIPFLAGS_KERNEL = -R .rel.dyn -R .reginfo -R .note -R .comment -R .drectve -R .note.gnu.gold-version -R .MIPS.abiflags diff --git a/config.h.in b/config.h.in index ea0f3834e..9e8f9911b 100644 --- a/config.h.in +++ b/config.h.in @@ -7,6 +7,7 @@ #endif #define GCRYPT_NO_DEPRECATED 1 +#define HAVE_MEMMOVE 1 /* Define to 1 to enable disk cache statistics. */ #define DISK_CACHE_STATS @DISK_CACHE_STATS@ diff --git a/configure.ac b/configure.ac index 9e24d896d..be980adbb 100644 --- a/configure.ac +++ b/configure.ac @@ -1131,22 +1131,17 @@ fi # Set them to their new values for the tests below. CC="$TARGET_CC" -if test "x$TARGET_APPLE_LINKER" = x1 ; then +if test x"$platform" = xemu ; then +CFLAGS="$TARGET_CFLAGS -Wno-error" +elif test "x$TARGET_APPLE_LINKER" = x1 ; then CFLAGS="$TARGET_CFLAGS -nostdlib -static -Wno-error" else CFLAGS="$TARGET_CFLAGS -nostdlib -Wno-error" fi CPPFLAGS="$TARGET_CPPFLAGS" -if test x$target_cpu = xi386 || test x$target_cpu = xx86_64 || test "x$grub_cv_cc_target_clang" = xyes ; then -TARGET_LIBGCC= -else -TARGET_LIBGCC=-lgcc -fi - -LIBS="$TARGET_LIBGCC" grub_ASM_USCORE -if test "x$TARGET_APPLE_LINKER" = x0 ; then +if test "x$TARGET_APPLE_LINKER" = x0 && test x"$platform" != xemu; then if test x$grub_cv_asm_uscore = xyes; then DEFSYM="-Wl,--defsym,_abort=_main -Wl,--defsym,__main=_main" else @@ -1156,7 +1151,9 @@ CFLAGS="$TARGET_CFLAGS -nostdlib $DEFSYM" fi # Check for libgcc symbols -AC_CHECK_FUNCS(__bswapsi2 __bswapdi2 __ashldi3 __ashrdi3 __lshrdi3 __ucmpdi2 _restgpr_14_x) +if test x"$platform" = xemu; then +AC_CHECK_FUNCS(__udivsi3 __umodsi3 __divsi3 __modsi3 __divdi3 __moddi3 __udivdi3 __umoddi3 __ctzdi2 __ctzsi2 __aeabi_uidiv __aeabi_uidivmod __aeabi_idiv __aeabi_idivmod __aeabi_ulcmp __muldi3 __aeabi_lmul __aeabi_memcpy __aeabi_memset __aeabi_lasr __aeabi_llsl __aeabi_llsr _restgpr_14_x __ucmpdi2 __ashldi3 __ashrdi3 __lshrdi3 __bswapsi2 __bswapdi2 __bzero __register_frame_info __deregister_frame_info ___chkstk_ms __chkstk_ms) +fi if test "x$TARGET_APPLE_LINKER" = x1 ; then CFLAGS="$TARGET_CFLAGS -nostdlib -static" @@ -1717,12 +1714,6 @@ if test x"$enable_werror" != xno ; then HOST_CFLAGS="$HOST_CFLAGS -Werror" fi -if test "x$grub_cv_cc_target_clang" = xno; then - TARGET_LDFLAGS_STATIC_LIBGCC="-static-libgcc" -else - TARGET_LDFLAGS_STATIC_LIBGCC= -fi - TARGET_CPP="$TARGET_CC -E" TARGET_CCAS=$TARGET_CC @@ -1739,8 +1730,6 @@ AC_SUBST(GRUB_TARGET_CPU) AC_SUBST(GRUB_PLATFORM) AC_SUBST(TARGET_OBJCONV) -AC_SUBST(TARGET_LIBGCC) -AC_SUBST(TARGET_LDFLAGS_STATIC_LIBGCC) AC_SUBST(TARGET_CPP) AC_SUBST(TARGET_CCAS) AC_SUBST(TARGET_OBJ2ELF) diff --git a/grub-core/Makefile.am b/grub-core/Makefile.am index 5c087c83b..57c0b64e7 100644 --- a/grub-core/Makefile.am +++ b/grub-core/Makefile.am @@ -76,6 +76,11 @@ KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/i18n.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/kernel.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/list.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/misc.h +if COND_emu +KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/compiler-rt-emu.h +else +KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/compiler-rt.h +endif KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/mm.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/parser.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/partition.h @@ -83,9 +88,6 @@ KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/term.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/time.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/mm_private.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/net.h -if !COND_clang -KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/libgcc.h -endif KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/memory.h if COND_i386_pc diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def index b539ccf9d..7a6fa21a4 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def @@ -132,6 +132,7 @@ kernel = { common = kern/rescue_reader.c; common = kern/term.c; + noemu = kern/compiler-rt.c; noemu = kern/mm.c; noemu = kern/time.c; noemu = kern/generic/millisleep.c; @@ -254,6 +255,7 @@ kernel = { powerpc_ieee1275 = kern/powerpc/cache.S; powerpc_ieee1275 = kern/powerpc/dl.c; + powerpc_ieee1275 = kern/powerpc/compiler-rt.S; sparc64_ieee1275 = kern/sparc64/cache.S; sparc64_ieee1275 = kern/sparc64/dl.c; @@ -265,7 +267,7 @@ kernel = { arm = kern/arm/cache_armv7.S; extra_dist = kern/arm/cache.S; arm = kern/arm/cache.c; - arm = kern/arm/misc.S; + arm = kern/arm/compiler-rt.S; arm64 = kern/arm64/cache.c; arm64 = kern/arm64/cache_flush.S; @@ -443,13 +445,13 @@ image = { common = lib/xzembed/xz_dec_bcj.c; common = lib/xzembed/xz_dec_lzma2.c; common = lib/xzembed/xz_dec_stream.c; + common = kern/compiler-rt.c; cppflags = '-I$(srcdir)/lib/posix_wrap -I$(srcdir)/lib/xzembed -DGRUB_EMBED_DECOMPRESSOR=1'; objcopyflags = '-O binary'; - mips_ldflags = '$(TARGET_LDFLAGS_STATIC_LIBGCC) -Wl,-Ttext,$(TARGET_DECOMPRESSOR_LINK_ADDR)'; - ldadd = '$(TARGET_LIBGCC)'; - cflags = '-Wno-unreachable-code $(TARGET_LDFLAGS_STATIC_LIBGCC)'; + mips_ldflags = '-Wl,-Ttext,$(TARGET_DECOMPRESSOR_LINK_ADDR)'; + cflags = '-Wno-unreachable-code'; enable = mips; }; @@ -461,9 +463,7 @@ image = { cppflags = '-DGRUB_EMBED_DECOMPRESSOR=1'; objcopyflags = '-O binary'; - mips_ldflags = '$(TARGET_LDFLAGS_STATIC_LIBGCC) -Wl,-Ttext,$(TARGET_DECOMPRESSOR_LINK_ADDR)'; - ldadd = '$(TARGET_LIBGCC)'; - cflags = '$(TARGET_LDFLAGS_STATIC_LIBGCC)'; + mips_ldflags = '-Wl,-Ttext,$(TARGET_DECOMPRESSOR_LINK_ADDR)'; enable = mips; }; @@ -481,7 +481,7 @@ image = { name = fwstart; mips_loongson = boot/mips/loongson/fwstart.S; objcopyflags = '-O binary'; - ldflags = '$(TARGET_LDFLAGS_STATIC_LIBGCC) $(TARGET_LIBGCC) -Wl,-N,-S,-Ttext,0xbfc00000,-Bstatic'; + ldflags = '-Wl,-N,-S,-Ttext,0xbfc00000,-Bstatic'; enable = mips_loongson; }; @@ -489,7 +489,7 @@ image = { name = fwstart_fuloong2f; mips_loongson = boot/mips/loongson/fuloong2f.S; objcopyflags = '-O binary'; - ldflags = '$(TARGET_LDFLAGS_STATIC_LIBGCC) $(TARGET_LIBGCC) -Wl,-N,-S,-Ttext,0xbfc00000,-Bstatic'; + ldflags = '-Wl,-N,-S,-Ttext,0xbfc00000,-Bstatic'; enable = mips_loongson; }; @@ -1982,6 +1982,31 @@ module = { common = tests/div_test.c; }; +module = { + name = mul_test; + common = tests/mul_test.c; +}; + +module = { + name = shift_test; + common = tests/shift_test.c; +}; + +module = { + name = cmp_test; + common = tests/cmp_test.c; +}; + +module = { + name = ctz_test; + common = tests/ctz_test.c; +}; + +module = { + name = bswap_test; + common = tests/bswap_test.c; +}; + module = { name = videotest_checksum; common = tests/videotest_checksum.c; diff --git a/grub-core/boot/decompressor/minilib.c b/grub-core/boot/decompressor/minilib.c index 94edfd561..fc46ee07b 100644 --- a/grub-core/boot/decompressor/minilib.c +++ b/grub-core/boot/decompressor/minilib.c @@ -21,7 +21,7 @@ #include void * -memset (void *s, int c, grub_size_t len) +grub_memset (void *s, int c, grub_size_t len) { grub_uint8_t *ptr; for (ptr = s; len; ptr++, len--) @@ -68,15 +68,6 @@ grub_memcmp (const void *s1, const void *s2, grub_size_t n) return 0; } -int memcmp (const void *s1, const void *s2, grub_size_t n) - __attribute__ ((alias ("grub_memcmp"))); - -void *memmove (void *dest, const void *src, grub_size_t n) - __attribute__ ((alias ("grub_memmove"))); - -void *memcpy (void *dest, const void *src, grub_size_t n) - __attribute__ ((alias ("grub_memmove"))); - void *grub_decompressor_scratch; void diff --git a/grub-core/kern/arm/misc.S b/grub-core/kern/arm/compiler-rt.S similarity index 100% rename from grub-core/kern/arm/misc.S rename to grub-core/kern/arm/compiler-rt.S diff --git a/grub-core/kern/compiler-rt.c b/grub-core/kern/compiler-rt.c new file mode 100644 index 000000000..d4cc15513 --- /dev/null +++ b/grub-core/kern/compiler-rt.c @@ -0,0 +1,404 @@ +/* compiler-rt.c - compiler helpers. */ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2010-2014 Free Software Foundation, Inc. + * + * GRUB is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GRUB is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GRUB. If not, see . + */ + +#include +#include + +#ifndef GRUB_EMBED_DECOMPRESSOR +void * GRUB_BUILTIN_ATTR +memcpy (void *dest, const void *src, grub_size_t n) +{ + return grub_memmove (dest, src, n); +} +void * GRUB_BUILTIN_ATTR +memmove (void *dest, const void *src, grub_size_t n) +{ + return grub_memmove (dest, src, n); +} +int GRUB_BUILTIN_ATTR +memcmp (const void *s1, const void *s2, grub_size_t n) +{ + return grub_memcmp (s1, s2, n); +} +void * GRUB_BUILTIN_ATTR +memset (void *s, int c, grub_size_t n) +{ + return grub_memset (s, c, n); +} + +#ifdef __APPLE__ + +void GRUB_BUILTIN_ATTR +__bzero (void *s, grub_size_t n) +{ + grub_memset (s, 0, n); +} + +#endif + +#if GRUB_DIVISION_IN_SOFTWARE + +grub_uint32_t +__udivsi3 (grub_uint32_t a, grub_uint32_t b) +{ + return grub_divmod64 (a, b, 0); +} + +grub_int32_t +__divsi3 (grub_int32_t a, grub_int32_t b) +{ + return grub_divmod64s (a, b, 0); +} + +grub_uint32_t +__umodsi3 (grub_uint32_t a, grub_uint32_t b) +{ + grub_uint64_t ret; + grub_divmod64 (a, b, &ret); + return ret; +} + +grub_int32_t +__modsi3 (grub_int32_t a, grub_int32_t b) +{ + grub_int64_t ret; + grub_divmod64s (a, b, &ret); + return ret; +} + +grub_uint64_t +__udivdi3 (grub_uint64_t a, grub_uint64_t b) +{ + return grub_divmod64 (a, b, 0); +} + +grub_uint64_t +__umoddi3 (grub_uint64_t a, grub_uint64_t b) +{ + grub_uint64_t ret; + grub_divmod64 (a, b, &ret); + return ret; +} + +grub_int64_t +__divdi3 (grub_int64_t a, grub_int64_t b) +{ + return grub_divmod64s (a, b, 0); +} + +grub_int64_t +__moddi3 (grub_int64_t a, grub_int64_t b) +{ + grub_int64_t ret; + grub_divmod64s (a, b, &ret); + return ret; +} + +#endif + +#endif + +#ifdef NEED_CTZDI2 + +unsigned +__ctzdi2 (grub_uint64_t x) +{ + unsigned ret = 0; + if (!x) + return 64; + if (!(x & 0xffffffff)) + { + x >>= 32; + ret |= 32; + } + if (!(x & 0xffff)) + { + x >>= 16; + ret |= 16; + } + if (!(x & 0xff)) + { + x >>= 8; + ret |= 8; + } + if (!(x & 0xf)) + { + x >>= 4; + ret |= 4; + } + if (!(x & 0x3)) + { + x >>= 2; + ret |= 2; + } + if (!(x & 0x1)) + { + x >>= 1; + ret |= 1; + } + return ret; +} +#endif + +#ifdef NEED_CTZSI2 +unsigned +__ctzsi2 (grub_uint32_t x) +{ + unsigned ret = 0; + if (!x) + return 32; + + if (!(x & 0xffff)) + { + x >>= 16; + ret |= 16; + } + if (!(x & 0xff)) + { + x >>= 8; + ret |= 8; + } + if (!(x & 0xf)) + { + x >>= 4; + ret |= 4; + } + if (!(x & 0x3)) + { + x >>= 2; + ret |= 2; + } + if (!(x & 0x1)) + { + x >>= 1; + ret |= 1; + } + return ret; +} + +#endif + + +#if defined (__clang__) && !defined(GRUB_EMBED_DECOMPRESSOR) +/* clang emits references to abort(). */ +void __attribute__ ((noreturn)) +abort (void) +{ + grub_fatal ("compiler abort"); +} +#endif + +#if (defined (__MINGW32__) || defined (__CYGWIN__)) +void __register_frame_info (void) +{ +} + +void __deregister_frame_info (void) +{ +} + +void ___chkstk_ms (void) +{ +} + +void __chkstk_ms (void) +{ +} +#endif + +union component64 +{ + grub_uint64_t full; + struct + { +#ifdef GRUB_CPU_WORDS_BIGENDIAN + grub_uint32_t high; + grub_uint32_t low; +#else + grub_uint32_t low; + grub_uint32_t high; +#endif + }; +}; + +#if defined (__powerpc__) || defined (__arm__) || defined(__mips__) + +/* Based on libgcc2.c from gcc suite. */ +grub_uint64_t +__lshrdi3 (grub_uint64_t u, int b) +{ + if (b == 0) + return u; + + const union component64 uu = {.full = u}; + const int bm = 32 - b; + union component64 w; + + if (bm <= 0) + { + w.high = 0; + w.low = (grub_uint32_t) uu.high >> -bm; + } + else + { + const grub_uint32_t carries = (grub_uint32_t) uu.high << bm; + + w.high = (grub_uint32_t) uu.high >> b; + w.low = ((grub_uint32_t) uu.low >> b) | carries; + } + + return w.full; +} + +/* Based on libgcc2.c from gcc suite. */ +grub_uint64_t +__ashrdi3 (grub_uint64_t u, int b) +{ + if (b == 0) + return u; + + const union component64 uu = {.full = u}; + const int bm = 32 - b; + union component64 w; + + if (bm <= 0) + { + /* w.high = 1..1 or 0..0 */ + w.high = ((grub_int32_t) uu.high) >> (32 - 1); + w.low = ((grub_int32_t) uu.high) >> -bm; + } + else + { + const grub_uint32_t carries = ((grub_uint32_t) uu.high) << bm; + + w.high = ((grub_int32_t) uu.high) >> b; + w.low = ((grub_uint32_t) uu.low >> b) | carries; + } + + return w.full; +} + +/* Based on libgcc2.c from gcc suite. */ +grub_uint64_t +__ashldi3 (grub_uint64_t u, int b) +{ + if (b == 0) + return u; + + const union component64 uu = {.full = u}; + const int bm = 32 - b; + union component64 w; + + if (bm <= 0) + { + w.low = 0; + w.high = (grub_uint32_t) uu.low << -bm; + } + else + { + const grub_uint32_t carries = (grub_uint32_t) uu.low >> bm; + + w.low = (grub_uint32_t) uu.low << b; + w.high = ((grub_uint32_t) uu.high << b) | carries; + } + + return w.full; +} + +/* Based on libgcc2.c from gcc suite. */ +int +__ucmpdi2 (grub_uint64_t a, grub_uint64_t b) +{ + union component64 ac, bc; + ac.full = a; + bc.full = b; + + if (ac.high < bc.high) + return 0; + else if (ac.high > bc.high) + return 2; + + if (ac.low < bc.low) + return 0; + else if (ac.low > bc.low) + return 2; + return 1; +} + +#endif + +#if defined (__powerpc__) || defined(__mips__) || defined(__sparc__) || defined(__arm__) + +/* Based on libgcc2.c from gcc suite. */ +grub_uint32_t +__bswapsi2 (grub_uint32_t u) +{ + return ((((u) & 0xff000000) >> 24) + | (((u) & 0x00ff0000) >> 8) + | (((u) & 0x0000ff00) << 8) + | (((u) & 0x000000ff) << 24)); +} + +/* Based on libgcc2.c from gcc suite. */ +grub_uint64_t +__bswapdi2 (grub_uint64_t u) +{ + return ((((u) & 0xff00000000000000ull) >> 56) + | (((u) & 0x00ff000000000000ull) >> 40) + | (((u) & 0x0000ff0000000000ull) >> 24) + | (((u) & 0x000000ff00000000ull) >> 8) + | (((u) & 0x00000000ff000000ull) << 8) + | (((u) & 0x0000000000ff0000ull) << 24) + | (((u) & 0x000000000000ff00ull) << 40) + | (((u) & 0x00000000000000ffull) << 56)); +} + + +#endif + +#ifdef __arm__ +grub_uint32_t +__aeabi_uidiv (grub_uint32_t a, grub_uint32_t b) + __attribute__ ((alias ("__udivsi3"))); +grub_int32_t +__aeabi_idiv (grub_int32_t a, grub_int32_t b) + __attribute__ ((alias ("__divsi3"))); +void *__aeabi_memcpy (void *dest, const void *src, grub_size_t n) + __attribute__ ((alias ("grub_memcpy"))); +void *__aeabi_memset (void *s, int c, grub_size_t n) + __attribute__ ((alias ("memset"))); + +int +__aeabi_ulcmp (grub_uint64_t a, grub_uint64_t b) +{ + return __ucmpdi2 (a, b) - 1; +} + +grub_uint64_t +__aeabi_lasr (grub_uint64_t u, int b) + __attribute__ ((alias ("__ashrdi3"))); +grub_uint64_t +__aeabi_llsr (grub_uint64_t u, int b) + __attribute__ ((alias ("__lshrdi3"))); + +grub_uint64_t +__aeabi_llsl (grub_uint64_t u, int b) + __attribute__ ((alias ("__ashldi3"))); + +#endif diff --git a/grub-core/kern/misc.c b/grub-core/kern/misc.c index b0347e7e2..906d2c2f7 100644 --- a/grub-core/kern/misc.c +++ b/grub-core/kern/misc.c @@ -95,25 +95,6 @@ grub_memmove (void *dest, const void *src, grub_size_t n) return dest; } -#ifndef __APPLE__ -void *memmove (void *dest, const void *src, grub_size_t n) - __attribute__ ((alias ("grub_memmove"))); -/* GCC emits references to memcpy() for struct copies etc. */ -void *memcpy (void *dest, const void *src, grub_size_t n) - __attribute__ ((alias ("grub_memmove"))); -#else -void * GRUB_BUILTIN_ATTR -memcpy (void *dest, const void *src, grub_size_t n) -{ - return grub_memmove (dest, src, n); -} -void * GRUB_BUILTIN_ATTR -memmove (void *dest, const void *src, grub_size_t n) -{ - return grub_memmove (dest, src, n); -} -#endif - char * grub_strcpy (char *dest, const char *src) { @@ -253,16 +234,6 @@ grub_memcmp (const void *s1, const void *s2, grub_size_t n) return 0; } -#ifndef __APPLE__ -int memcmp (const void *s1, const void *s2, grub_size_t n) - __attribute__ ((alias ("grub_memcmp"))); -#else -int GRUB_BUILTIN_ATTR -memcmp (const void *s1, const void *s2, grub_size_t n) -{ - return grub_memcmp (s1, s2, n); -} -#endif int grub_strcmp (const char *s1, const char *s2) @@ -532,26 +503,6 @@ grub_memset (void *s, int c, grub_size_t len) return s; } -#ifndef __APPLE__ -void *memset (void *s, int c, grub_size_t n) - __attribute__ ((alias ("grub_memset"))); -#else -void * GRUB_BUILTIN_ATTR -memset (void *s, int c, grub_size_t n) -{ - return grub_memset (s, c, n); -} - -#endif - -#if !defined(GRUB_UTIL) && defined(__APPLE__) -void GRUB_BUILTIN_ATTR -__bzero (void *s, grub_size_t n) -{ - grub_memset (s, 0, n); -} - -#endif grub_size_t grub_strlen (const char *s) @@ -631,163 +582,6 @@ grub_divmod64 (grub_uint64_t n, grub_uint64_t d, grub_uint64_t *r) return q; } -#if !defined (GRUB_UTIL) && !defined (GRUB_MACHINE_EMU) - -#if GRUB_DIVISION_IN_SOFTWARE - -grub_uint32_t -__udivsi3 (grub_uint32_t a, grub_uint32_t b) -{ - return grub_divmod64 (a, b, 0); -} - -grub_int32_t -__divsi3 (grub_int32_t a, grub_int32_t b) -{ - return grub_divmod64s (a, b, 0); -} - -grub_uint32_t -__umodsi3 (grub_uint32_t a, grub_uint32_t b) -{ - grub_uint64_t ret; - grub_divmod64 (a, b, &ret); - return ret; -} - -grub_int32_t -__modsi3 (grub_int32_t a, grub_int32_t b) -{ - grub_int64_t ret; - grub_divmod64s (a, b, &ret); - return ret; -} - -grub_uint64_t -__udivdi3 (grub_uint64_t a, grub_uint64_t b) -{ - return grub_divmod64 (a, b, 0); -} - -grub_uint64_t -__umoddi3 (grub_uint64_t a, grub_uint64_t b) -{ - grub_uint64_t ret; - grub_divmod64 (a, b, &ret); - return ret; -} - -grub_int64_t -__divdi3 (grub_int64_t a, grub_int64_t b) -{ - return grub_divmod64s (a, b, 0); -} - -grub_int64_t -__moddi3 (grub_int64_t a, grub_int64_t b) -{ - grub_int64_t ret; - grub_divmod64s (a, b, &ret); - return ret; -} - -#endif - -#ifdef NEED_CTZDI2 - -unsigned -__ctzdi2 (grub_uint64_t x) -{ - unsigned ret = 0; - if (!x) - return 64; - if (!(x & 0xffffffff)) - { - x >>= 32; - ret |= 32; - } - if (!(x & 0xffff)) - { - x >>= 16; - ret |= 16; - } - if (!(x & 0xff)) - { - x >>= 8; - ret |= 8; - } - if (!(x & 0xf)) - { - x >>= 4; - ret |= 4; - } - if (!(x & 0x3)) - { - x >>= 2; - ret |= 2; - } - if (!(x & 0x1)) - { - x >>= 1; - ret |= 1; - } - return ret; -} -#endif - -#ifdef NEED_CTZSI2 -unsigned -__ctzsi2 (grub_uint32_t x) -{ - unsigned ret = 0; - if (!x) - return 32; - - if (!(x & 0xffff)) - { - x >>= 16; - ret |= 16; - } - if (!(x & 0xff)) - { - x >>= 8; - ret |= 8; - } - if (!(x & 0xf)) - { - x >>= 4; - ret |= 4; - } - if (!(x & 0x3)) - { - x >>= 2; - ret |= 2; - } - if (!(x & 0x1)) - { - x >>= 1; - ret |= 1; - } - return ret; -} - -#endif - -#ifdef __arm__ -grub_uint32_t -__aeabi_uidiv (grub_uint32_t a, grub_uint32_t b) - __attribute__ ((alias ("__udivsi3"))); -grub_int32_t -__aeabi_idiv (grub_int32_t a, grub_int32_t b) - __attribute__ ((alias ("__divsi3"))); -void *__aeabi_memcpy (void *dest, const void *src, grub_size_t n) - __attribute__ ((alias ("grub_memcpy"))); -void *__aeabi_memset (void *s, int c, grub_size_t n) - __attribute__ ((alias ("grub_memset"))); -#endif - -#endif /* GRUB_UTIL */ - /* Convert a long long value to a string. This function avoids 64-bit modular arithmetic or divisions. */ static inline char * @@ -1296,15 +1090,6 @@ grub_abort (void) grub_exit (); } -#if defined (__clang__) && !defined (GRUB_UTIL) -/* clang emits references to abort(). */ -void __attribute__ ((noreturn)) -abort (void) -{ - grub_abort (); -} -#endif - void grub_fatal (const char *fmt, ...) { @@ -1317,23 +1102,6 @@ grub_fatal (const char *fmt, ...) grub_abort (); } -#if (defined (__MINGW32__) || defined (__CYGWIN__)) && !defined(GRUB_UTIL) -void __register_frame_info (void) -{ -} - -void __deregister_frame_info (void) -{ -} -void ___chkstk_ms (void) -{ -} - -void __chkstk_ms (void) -{ -} -#endif - #if BOOT_TIME_STATS #include diff --git a/grub-core/kern/powerpc/compiler-rt.S b/grub-core/kern/powerpc/compiler-rt.S new file mode 100644 index 000000000..b3b912db6 --- /dev/null +++ b/grub-core/kern/powerpc/compiler-rt.S @@ -0,0 +1,130 @@ +/* + * Special support for eabi and SVR4 + * + * Copyright (C) 1995-2014 Free Software Foundation, Inc. + * Written By Michael Meissner + * 64-bit support written by David Edelsohn + * + * This file is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 3, or (at your option) any + * later version. + * + * This file is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * Under Section 7 of GPL version 3, you are granted additional + * permissions described in the GCC Runtime Library Exception, version + * 3.1, as published by the Free Software Foundation. + * + * You should have received a copy of the GNU General Public License and + * a copy of the GCC Runtime Library Exception along with this program; + * see the files COPYING3 and COPYING.RUNTIME respectively. If not, see + * . + */ + +/* Do any initializations needed for the eabi environment */ + +#include +#include + + .section ".text" + +#define CFI_RESTORE(reg) .cfi_restore reg +#define CFI_OFFSET(reg, off) .cfi_offset reg, off +#define CFI_DEF_CFA_REGISTER(reg) .cfi_def_cfa_register reg +#define CFI_STARTPROC .cfi_startproc +#define CFI_ENDPROC .cfi_endproc + +/* Routines for restoring integer registers, called by the compiler. */ +/* Called with r11 pointing to the stack header word of the caller of the */ +/* function, just beyond the end of the integer restore area. */ + +CFI_STARTPROC +CFI_DEF_CFA_REGISTER (11) +CFI_OFFSET (65, 4) +CFI_OFFSET (14, -72) +CFI_OFFSET (15, -68) +CFI_OFFSET (16, -64) +CFI_OFFSET (17, -60) +CFI_OFFSET (18, -56) +CFI_OFFSET (19, -52) +CFI_OFFSET (20, -48) +CFI_OFFSET (21, -44) +CFI_OFFSET (22, -40) +CFI_OFFSET (23, -36) +CFI_OFFSET (24, -32) +CFI_OFFSET (25, -28) +CFI_OFFSET (26, -24) +CFI_OFFSET (27, -20) +CFI_OFFSET (28, -16) +CFI_OFFSET (29, -12) +CFI_OFFSET (30, -8) +CFI_OFFSET (31, -4) +FUNCTION(_restgpr_14_x) lwz 14,-72(11) /* restore gp registers */ +CFI_RESTORE (14) +FUNCTION(_restgpr_15_x) lwz 15,-68(11) +CFI_RESTORE (15) +FUNCTION(_restgpr_16_x) lwz 16,-64(11) +CFI_RESTORE (16) +FUNCTION(_restgpr_17_x) lwz 17,-60(11) +CFI_RESTORE (17) +FUNCTION(_restgpr_18_x) lwz 18,-56(11) +CFI_RESTORE (18) +FUNCTION(_restgpr_19_x) lwz 19,-52(11) +CFI_RESTORE (19) +FUNCTION(_restgpr_20_x) lwz 20,-48(11) +CFI_RESTORE (20) +FUNCTION(_restgpr_21_x) lwz 21,-44(11) +CFI_RESTORE (21) +FUNCTION(_restgpr_22_x) lwz 22,-40(11) +CFI_RESTORE (22) +FUNCTION(_restgpr_23_x) lwz 23,-36(11) +CFI_RESTORE (23) +FUNCTION(_restgpr_24_x) lwz 24,-32(11) +CFI_RESTORE (24) +FUNCTION(_restgpr_25_x) lwz 25,-28(11) +CFI_RESTORE (25) +FUNCTION(_restgpr_26_x) lwz 26,-24(11) +CFI_RESTORE (26) +FUNCTION(_restgpr_27_x) lwz 27,-20(11) +CFI_RESTORE (27) +FUNCTION(_restgpr_28_x) lwz 28,-16(11) +CFI_RESTORE (28) +FUNCTION(_restgpr_29_x) lwz 29,-12(11) +CFI_RESTORE (29) +FUNCTION(_restgpr_30_x) lwz 30,-8(11) +CFI_RESTORE (30) +FUNCTION(_restgpr_31_x) lwz 0,4(11) + lwz 31,-4(11) +CFI_RESTORE (31) + mtlr 0 +CFI_RESTORE (65) + mr 1,11 +CFI_DEF_CFA_REGISTER (1) + blr +CFI_ENDPROC + +CFI_STARTPROC +FUNCTION(_savegpr_14) stw 14,-72(11) /* save gp registers */ +FUNCTION(_savegpr_15) stw 15,-68(11) +FUNCTION(_savegpr_16) stw 16,-64(11) +FUNCTION(_savegpr_17) stw 17,-60(11) +FUNCTION(_savegpr_18) stw 18,-56(11) +FUNCTION(_savegpr_19) stw 19,-52(11) +FUNCTION(_savegpr_20) stw 20,-48(11) +FUNCTION(_savegpr_21) stw 21,-44(11) +FUNCTION(_savegpr_22) stw 22,-40(11) +FUNCTION(_savegpr_23) stw 23,-36(11) +FUNCTION(_savegpr_24) stw 24,-32(11) +FUNCTION(_savegpr_25) stw 25,-28(11) +FUNCTION(_savegpr_26) stw 26,-24(11) +FUNCTION(_savegpr_27) stw 27,-20(11) +FUNCTION(_savegpr_28) stw 28,-16(11) +FUNCTION(_savegpr_29) stw 29,-12(11) +FUNCTION(_savegpr_30) stw 30,-8(11) +FUNCTION(_savegpr_31) stw 31,-4(11) + blr +CFI_ENDPROC diff --git a/grub-core/lib/posix_wrap/string.h b/grub-core/lib/posix_wrap/string.h index c4b9bf089..7ae6eee97 100644 --- a/grub-core/lib/posix_wrap/string.h +++ b/grub-core/lib/posix_wrap/string.h @@ -42,21 +42,6 @@ strcasecmp (const char *s1, const char *s2) return grub_strcasecmp (s1, s2); } -#ifdef GRUB_UTIL -static inline void * -memcpy (void *dest, const void *src, grub_size_t n) -{ - return grub_memcpy (dest, src, n); -} - -static inline int -memcmp (const void *s1, const void *s2, grub_size_t n) -{ - return grub_memcmp (s1, s2, n); -} - -#endif - static inline void bcopy (const void *src, void *dest, grub_size_t n) { @@ -99,4 +84,9 @@ memchr (const void *s, int c, grub_size_t n) return grub_memchr (s, c, n); } +#define memcmp grub_memcmp +#define memcpy grub_memcpy +#define memmove grub_memmove +#define memset grub_memset + #endif diff --git a/grub-core/tests/bswap_test.c b/grub-core/tests/bswap_test.c new file mode 100644 index 000000000..4eb3a9814 --- /dev/null +++ b/grub-core/tests/bswap_test.c @@ -0,0 +1,121 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2015 Free Software Foundation, Inc. + * + * GRUB is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GRUB is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GRUB. If not, see . + */ + +#include +#include +#include + +GRUB_MOD_LICENSE ("GPLv3+"); + +static grub_uint64_t vectors[] = { + 0xffffffffffffffffULL, 1, 2, 0, 0x0102030405060708ULL +}; + +static void +test16 (grub_uint16_t a) +{ + grub_uint16_t b, c; + grub_uint8_t *ap, *bp; + int i; + b = grub_swap_bytes16 (a); + c = grub_swap_bytes16 (b); + grub_test_assert (a == c, "bswap not idempotent: 0x%llx, 0x%llx, 0x%llx", + (long long) a, (long long) b, (long long) c); + ap = (grub_uint8_t *) &a; + bp = (grub_uint8_t *) &b; + for (i = 0; i < 2; i++) + { + grub_test_assert (ap[i] == bp[1 - i], + "bswap bytes wrong: 0x%llx, 0x%llx", + (long long) a, (long long) b); + } +} + +static void +test32 (grub_uint32_t a) +{ + grub_uint32_t b, c; + grub_uint8_t *ap, *bp; + int i; + b = grub_swap_bytes32 (a); + c = grub_swap_bytes32 (b); + grub_test_assert (a == c, "bswap not idempotent: 0x%llx, 0x%llx, 0x%llx", + (long long) a, (long long) b, (long long) c); + ap = (grub_uint8_t *) &a; + bp = (grub_uint8_t *) &b; + for (i = 0; i < 4; i++) + { + grub_test_assert (ap[i] == bp[3 - i], + "bswap bytes wrong: 0x%llx, 0x%llx", + (long long) a, (long long) b); + } +} + +static void +test64 (grub_uint64_t a) +{ + grub_uint64_t b, c; + grub_uint8_t *ap, *bp; + int i; + b = grub_swap_bytes64 (a); + c = grub_swap_bytes64 (b); + grub_test_assert (a == c, "bswap not idempotent: 0x%llx, 0x%llx, 0x%llx", + (long long) a, (long long) b, (long long) c); + ap = (grub_uint8_t *) &a; + bp = (grub_uint8_t *) &b; + for (i = 0; i < 4; i++) + { + grub_test_assert (ap[i] == bp[7 - i], + "bswap bytes wrong: 0x%llx, 0x%llx", + (long long) a, (long long) b); + } +} + +static void +test_all(grub_uint64_t a) +{ + test64 (a); + test32 (a); + test16 (a); +} + +static void +bswap_test (void) +{ + grub_uint64_t a = 404, b = 7; + grub_size_t i; + + for (i = 0; i < ARRAY_SIZE (vectors); i++) + { + test_all (vectors[i]); + } + for (i = 0; i < 40000; i++) + { + a = 17 * a + 13 * b; + b = 23 * a + 29 * b; + if (b == 0) + b = 1; + if (a == 0) + a = 1; + test_all (a); + test_all (b); + } +} + +/* Register example_test method as a functional test. */ +GRUB_FUNCTIONAL_TEST (bswap_test, bswap_test); diff --git a/grub-core/tests/cmp_test.c b/grub-core/tests/cmp_test.c new file mode 100644 index 000000000..af5b39576 --- /dev/null +++ b/grub-core/tests/cmp_test.c @@ -0,0 +1,190 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2015 Free Software Foundation, Inc. + * + * GRUB is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GRUB is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GRUB. If not, see . + */ + +#include +#include +#include + +GRUB_MOD_LICENSE ("GPLv3+"); + +static grub_uint64_t vectors[][2] = { + { 0xffffffffffffffffULL, 1}, + { 1, 0xffffffffffffffffULL}, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL}, + { 1, 1 }, + { 2, 1 } +}; + +/* Don't change those to use shift as shift may call to compile rt + functions and we're not testing them now. + */ +static int +leading_bit64 (grub_uint64_t a) +{ + return !!(a & 0x8000000000000000LL); +} + +static int +leading_bit32 (grub_uint32_t a) +{ + return !!(a & 0x80000000); +} + +/* Computes (a < b) without involving comparison operator. */ +static int +is_less32 (grub_uint32_t a, grub_uint32_t b) +{ + if (leading_bit32(a) && !leading_bit32(b)) + return 0; + if (!leading_bit32(a) && leading_bit32(b)) + return 1; + return leading_bit32(a - b); +} + +static void +test32 (grub_uint32_t a, grub_uint32_t b) +{ + grub_test_assert ((a < b) == is_less32(a, b), "comparison result mismatch: %lld, %lld", + (long long) a, (long long) b); + grub_test_assert ((a > b) == is_less32(b, a), "comparison result mismatch: %lld, %lld", + (long long) a, (long long) b); + grub_test_assert ((b < a) == is_less32(b, a), "comparison result mismatch: %lld, %lld", + (long long) a, (long long) b); + grub_test_assert ((b > a) == is_less32(a, b), "comparison result mismatch: %lld, %lld", + (long long) a, (long long) b); + grub_test_assert (!(is_less32(a, b) && is_less32(b, a)), "comparison inconsistent: %lld, %lld", + (long long) a, (long long) b); +} + +/* Computes (a > b) without involving comparison operator. */ +static int +is_less32s (grub_int32_t a, grub_int32_t b) +{ + if (leading_bit32(a) && !leading_bit32(b)) + return 1; /* a < 0 && b >= 0. */ + if (!leading_bit32(a) && leading_bit32(b)) + return 0; /* b < 0 && a >= 0. */ + return leading_bit32(a - b); +} + +static void +test32s (grub_int32_t a, grub_int32_t b) +{ + grub_test_assert ((a < b) == is_less32s(a, b), "comparison result mismatch: %lld, %lld", + (long long) a, (long long) b); + grub_test_assert ((a > b) == is_less32s(b, a), "comparison result mismatch: %lld, %lld", + (long long) a, (long long) b); + grub_test_assert ((b < a) == is_less32s(b, a), "comparison result mismatch: %lld, %lld", + (long long) a, (long long) b); + grub_test_assert ((b > a) == is_less32s(a, b), "comparison result mismatch: %lld, %lld", + (long long) a, (long long) b); + grub_test_assert (!(is_less32s(a, b) && is_less32s(b, a)), "comparison inconsistent: %lld, %lld", + (long long) a, (long long) b); +} + +/* Computes (a > b) without involving comparison operator. */ +static int +is_less64 (grub_uint64_t a, grub_uint64_t b) +{ + if (leading_bit64(a) && !leading_bit64(b)) + return 0; + if (!leading_bit64(a) && leading_bit64(b)) + return 1; + return leading_bit64(a - b); +} + +static void +test64 (grub_uint64_t a, grub_uint64_t b) +{ + grub_test_assert ((a < b) == is_less64(a, b), "comparison result mismatch: %lld, %lld", + (long long) a, (long long) b); + grub_test_assert ((a > b) == is_less64(b, a), "comparison result mismatch: %lld, %lld", + (long long) a, (long long) b); + grub_test_assert ((b < a) == is_less64(b, a), "comparison result mismatch: %lld, %lld", + (long long) a, (long long) b); + grub_test_assert ((b > a) == is_less64(a, b), "comparison result mismatch: %lld, %lld", + (long long) a, (long long) b); + grub_test_assert (!(is_less64(a, b) && is_less64(b, a)), "comparison inconsistent: %lld, %lld", + (long long) a, (long long) b); +} + +/* Computes (a > b) without involving comparison operator. */ +static int +is_less64s (grub_int64_t a, grub_int64_t b) +{ + if (leading_bit64(a) && !leading_bit64(b)) + return 1; /* a < 0 && b >= 0. */ + if (!leading_bit64(a) && leading_bit64(b)) + return 0; /* b < 0 && a >= 0. */ + return leading_bit64(a - b); +} + +static void +test64s (grub_int64_t a, grub_int64_t b) +{ + grub_test_assert ((a < b) == is_less64s(a, b), "comparison result mismatch: %lld, %lld", + (long long) a, (long long) b); + grub_test_assert ((a > b) == is_less64s(b, a), "comparison result mismatch: %lld, %lld", + (long long) a, (long long) b); + grub_test_assert ((b < a) == is_less64s(b, a), "comparison result mismatch: %lld, %lld", + (long long) a, (long long) b); + grub_test_assert ((b > a) == is_less64s(a, b), "comparison result mismatch: %lld, %lld", + (long long) a, (long long) b); + grub_test_assert (!(is_less64s(a, b) && is_less64s(b, a)), "comparison inconsistent: %lld, %lld", + (long long) a, (long long) b); +} + +static void +test_all(grub_uint64_t a, grub_uint64_t b) +{ + test64 (a, b); + test32 (a, b); + test64s (a, b); + test32s (a, b); + test64s (a, -b); + test32s (a, -b); + test64s (-a, b); + test32s (-a, b); + test64s (-a, -b); + test32s (-a, -b); +} + +static void +cmp_test (void) +{ + grub_uint64_t a = 404, b = 7; + grub_size_t i; + + for (i = 0; i < ARRAY_SIZE (vectors); i++) + { + test_all (vectors[i][0], vectors[i][1]); + } + for (i = 0; i < 40000; i++) + { + a = 17 * a + 13 * b; + b = 23 * a + 29 * b; + if (b == 0) + b = 1; + if (a == 0) + a = 1; + test_all (a, b); + } +} + +/* Register example_test method as a functional test. */ +GRUB_FUNCTIONAL_TEST (cmp_test, cmp_test); diff --git a/grub-core/tests/ctz_test.c b/grub-core/tests/ctz_test.c new file mode 100644 index 000000000..eb7a1df38 --- /dev/null +++ b/grub-core/tests/ctz_test.c @@ -0,0 +1,111 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2013 Free Software Foundation, Inc. + * + * GRUB is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GRUB is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GRUB. If not, see . + */ + +#include +#include +#include + +GRUB_MOD_LICENSE ("GPLv3+"); + +/* ull version is not used on i386 other than in this test. + Avoid requiring extra function. + */ +#if defined (__i386__) +#define SKIP_ULL 1 +#endif + +static grub_uint64_t vectors[] = { + 0xffffffffffffffffULL, 1, 2, 0, 0x0102030405060708ULL +}; + +static void +test_ui (unsigned int a) +{ + int i; + a |= 1; + for (i = 0; i < (int) (8 * sizeof (a)); i++) + { + grub_test_assert (__builtin_ctz(a << i) == i, + "ctz mismatch: ctz(0x%llx) != 0x%x", + (long long) (a << i), __builtin_ctz(a << i)); + } +} + +static void +test_ul (unsigned long a) +{ + int i; + a |= 1; + for (i = 0; i < (int) (8 * sizeof (a)); i++) + { + grub_test_assert (__builtin_ctzl(a << i) == i, + "ctzl mismatch: ctzl(0x%llx) != 0x%x", + (long long) (a << i), __builtin_ctz(a << i)); + } +} + +#ifndef SKIP_ULL +static void +test_ull (unsigned long long a) +{ + int i; + a |= 1; + for (i = 0; i < (int) (8 * sizeof (a)); i++) + { + grub_test_assert (__builtin_ctzll(a << i) == i, + "ctzll mismatch: ctzll(0x%llx) != 0x%x", + (long long) (a << i), __builtin_ctz(a << i)); + } +} +#endif + +static void +test_all(grub_uint64_t a) +{ + test_ui (a); + test_ul (a); +#ifndef SKIP_ULL + test_ull (a); +#endif +} + +static void +ctz_test (void) +{ + grub_uint64_t a = 404, b = 7; + grub_size_t i; + + for (i = 0; i < ARRAY_SIZE (vectors); i++) + { + test_all (vectors[i]); + } + for (i = 0; i < 40000; i++) + { + a = 17 * a + 13 * b; + b = 23 * a + 29 * b; + if (b == 0) + b = 1; + if (a == 0) + a = 1; + test_all (a); + test_all (b); + } +} + +/* Register example_test method as a functional test. */ +GRUB_FUNCTIONAL_TEST (ctz_test, ctz_test); diff --git a/grub-core/tests/lib/functional_test.c b/grub-core/tests/lib/functional_test.c index 5be7a58e5..d4822a124 100644 --- a/grub-core/tests/lib/functional_test.c +++ b/grub-core/tests/lib/functional_test.c @@ -65,6 +65,11 @@ grub_functional_all_tests (grub_extcmd_context_t ctxt __attribute__ ((unused)), grub_dl_load ("pbkdf2_test"); grub_dl_load ("signature_test"); grub_dl_load ("sleep_test"); + grub_dl_load ("bswap_test"); + grub_dl_load ("ctz_test"); + grub_dl_load ("cmp_test"); + grub_dl_load ("mul_test"); + grub_dl_load ("shift_test"); FOR_LIST_ELEMENTS (test, grub_test_list) ok = !grub_test_run (test) && ok; diff --git a/grub-core/tests/mul_test.c b/grub-core/tests/mul_test.c new file mode 100644 index 000000000..cd6423192 --- /dev/null +++ b/grub-core/tests/mul_test.c @@ -0,0 +1,73 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2013 Free Software Foundation, Inc. + * + * GRUB is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GRUB is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GRUB. If not, see . + */ + +#include +#include +#include + +GRUB_MOD_LICENSE ("GPLv3+"); + +static grub_uint64_t vectors[][2] = { + { 0xffffffffffffffffULL, 1}, + { 1, 0xffffffffffffffffULL}, + { 0xffffffffffffffffULL, 0xffffffffffffffffULL}, + { 1, 1 }, + { 2, 1 } +}; + +static void +test64(grub_uint64_t a, grub_uint64_t b) +{ + grub_uint64_t r1 = a * b, r2 = 0, r3; + int i; + for (i = 0; i < 64; i++) + if ((a & (1LL << i))) + r2 += b << i; + r3 = ((grub_int64_t) a) * ((grub_int64_t) b); + grub_test_assert (r1 == r2, + "multiplication mismatch (u): 0x%llx x 0x%llx = 0x%llx != 0x%llx", + (long long) a, (long long) b, (long long) r2, (long long) r1); + grub_test_assert (r3 == r2, + "multiplication mismatch (s): 0x%llx x 0x%llx = 0x%llx != 0x%llx", + (long long) a, (long long) b, (long long) r2, (long long) r3); +} + +static void +mul_test (void) +{ + grub_uint64_t a = 404, b = 7; + grub_size_t i; + + for (i = 0; i < ARRAY_SIZE (vectors); i++) + { + test64 (vectors[i][0], vectors[i][1]); + } + for (i = 0; i < 40000; i++) + { + a = 17 * a + 13 * b; + b = 23 * a + 29 * b; + if (b == 0) + b = 1; + if (a == 0) + a = 1; + test64 (a, b); + } +} + +/* Register example_test method as a functional test. */ +GRUB_FUNCTIONAL_TEST (mul_test, mul_test); diff --git a/grub-core/tests/shift_test.c b/grub-core/tests/shift_test.c new file mode 100644 index 000000000..4120f520a --- /dev/null +++ b/grub-core/tests/shift_test.c @@ -0,0 +1,157 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2015 Free Software Foundation, Inc. + * + * GRUB is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GRUB is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GRUB. If not, see . + */ + +#include +#include +#include + +GRUB_MOD_LICENSE ("GPLv3+"); + +static grub_uint64_t vectors[] = { + 0xffffffffffffffffULL, 1, 2, 0, 0x0102030405060708ULL +}; + +/* We're testing shifts, don't replace access to this with a shift. */ +static const grub_uint8_t bitmask[] = + { 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80 }; + +typedef union { + grub_uint64_t v64; + grub_uint8_t v8[8]; +} grub_raw_u64_t; + +static int +get_bit64 (grub_uint64_t v, int b) +{ + grub_raw_u64_t vr = { .v64 = v }; + grub_uint8_t *p = vr.v8; + if (b >= 64) + return 0; +#ifdef GRUB_CPU_WORDS_BIGENDIAN + p += 7 - b / 8; +#else + p += b / 8; +#endif + return !!(*p & bitmask[b % 8]); +} + +static grub_uint64_t +set_bit64 (grub_uint64_t v, int b) +{ + grub_raw_u64_t vr = { .v64 = v }; + grub_uint8_t *p = vr.v8; + if (b >= 64) + return v; +#ifdef GRUB_CPU_WORDS_BIGENDIAN + p += 7 - b / 8; +#else + p += b / 8; +#endif + *p |= bitmask[b % 8]; + return vr.v64; +} + +static grub_uint64_t +left_shift64 (grub_uint64_t v, int s) +{ + grub_uint64_t r = 0; + int i; + for (i = 0; i + s < 64; i++) + if (get_bit64 (v, i)) + r = set_bit64 (r, i + s); + return r; +} + +static grub_uint64_t +right_shift64 (grub_uint64_t v, int s) +{ + grub_uint64_t r = 0; + int i; + for (i = s; i < 64; i++) + if (get_bit64 (v, i)) + r = set_bit64 (r, i - s); + return r; +} + +static grub_uint64_t +arithmetic_right_shift64 (grub_uint64_t v, int s) +{ + grub_uint64_t r = 0; + int i; + for (i = s; i < 64; i++) + if (get_bit64 (v, i)) + r = set_bit64 (r, i - s); + if (get_bit64 (v, 63)) + for (i -= s; i < 64; i++) + r = set_bit64 (r, i); + + return r; +} + +static void +test64 (grub_uint64_t v) +{ + int i; + for (i = 0; i < 64; i++) + { + grub_test_assert ((v << i) == left_shift64 (v, i), + "lshift wrong: 0x%llx << %d: 0x%llx, 0x%llx", + (long long) v, i, + (long long) (v << i), (long long) left_shift64 (v, i)); + grub_test_assert ((v >> i) == right_shift64 (v, i), + "rshift wrong: 0x%llx >> %d: 0x%llx, 0x%llx", + (long long) v, i, + (long long) (v >> i), (long long) right_shift64 (v, i)); + grub_test_assert ((((grub_int64_t) v) >> i) == (grub_int64_t) arithmetic_right_shift64 (v, i), + "arithmetic rshift wrong: ((grub_int64_t) 0x%llx) >> %d: 0x%llx, 0x%llx", + (long long) v, i, + (long long) (((grub_int64_t) v) >> i), (long long) arithmetic_right_shift64 (v, i)); + } +} + +static void +test_all(grub_uint64_t a) +{ + test64 (a); +} + +static void +shift_test (void) +{ + grub_uint64_t a = 404, b = 7; + grub_size_t i; + + for (i = 0; i < ARRAY_SIZE (vectors); i++) + { + test_all (vectors[i]); + } + for (i = 0; i < 4000; i++) + { + a = 17 * a + 13 * b; + b = 23 * a + 29 * b; + if (b == 0) + b = 1; + if (a == 0) + a = 1; + test_all (a); + test_all (b); + } +} + +/* Register example_test method as a functional test. */ +GRUB_FUNCTIONAL_TEST (shift_test, shift_test); diff --git a/include/grub/compiler-rt.h b/include/grub/compiler-rt.h new file mode 100644 index 000000000..9265c7e80 --- /dev/null +++ b/include/grub/compiler-rt.h @@ -0,0 +1,193 @@ +/* compiler-rt.h - prototypes for compiler helpers. */ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2002,2003,2005,2006,2007,2008,2009,2010-2014 Free Software Foundation, Inc. + * + * GRUB is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GRUB is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GRUB. If not, see . + */ + +#ifndef GRUB_COMPILER_RT_HEADER +#define GRUB_COMPILER_RT_HEADER 1 + +#include +#include +#include +#include + +#if defined(GRUB_DIVISION_IN_SOFTWARE) && GRUB_DIVISION_IN_SOFTWARE + +grub_uint32_t +EXPORT_FUNC (__udivsi3) (grub_uint32_t a, grub_uint32_t b); + +grub_uint32_t +EXPORT_FUNC (__umodsi3) (grub_uint32_t a, grub_uint32_t b); + +grub_int32_t +EXPORT_FUNC (__divsi3) (grub_int32_t a, grub_int32_t b); + +grub_int32_t +EXPORT_FUNC (__modsi3) (grub_int32_t a, grub_int32_t b); + +grub_int64_t +EXPORT_FUNC (__divdi3) (grub_int64_t a, grub_int64_t b); + +grub_int64_t +EXPORT_FUNC (__moddi3) (grub_int64_t a, grub_int64_t b); + +grub_uint64_t +EXPORT_FUNC (__udivdi3) (grub_uint64_t a, grub_uint64_t b); + +grub_uint64_t +EXPORT_FUNC (__umoddi3) (grub_uint64_t a, grub_uint64_t b); + +#endif + +#if defined (__sparc__) || defined (__powerpc__) || defined (__mips__) || defined (__arm__) +unsigned +EXPORT_FUNC (__ctzdi2) (grub_uint64_t x); +#define NEED_CTZDI2 1 +#endif + +#if defined (__mips__) || defined (__arm__) +unsigned +EXPORT_FUNC (__ctzsi2) (grub_uint32_t x); +#define NEED_CTZSI2 1 +#endif + +#ifdef __arm__ +grub_uint32_t +EXPORT_FUNC (__aeabi_uidiv) (grub_uint32_t a, grub_uint32_t b); +grub_uint32_t +EXPORT_FUNC (__aeabi_uidivmod) (grub_uint32_t a, grub_uint32_t b); + +grub_int32_t +EXPORT_FUNC (__aeabi_idiv) (grub_int32_t a, grub_int32_t b); +grub_int32_t +EXPORT_FUNC (__aeabi_idivmod) (grub_int32_t a, grub_int32_t b); + +int +EXPORT_FUNC (__aeabi_ulcmp) (grub_uint64_t a, grub_uint64_t b); + +/* Needed for allowing modules to be compiled as thumb. */ +grub_uint64_t +EXPORT_FUNC (__muldi3) (grub_uint64_t a, grub_uint64_t b); +grub_uint64_t +EXPORT_FUNC (__aeabi_lmul) (grub_uint64_t a, grub_uint64_t b); + +void * +EXPORT_FUNC (__aeabi_memcpy) (void *dest, const void *src, grub_size_t n); +void * +EXPORT_FUNC(__aeabi_memset) (void *s, int c, grub_size_t n); + +grub_uint64_t +EXPORT_FUNC (__aeabi_lasr) (grub_uint64_t u, int b); + +grub_uint64_t +EXPORT_FUNC (__aeabi_llsl) (grub_uint64_t u, int b); + +grub_uint64_t +EXPORT_FUNC (__aeabi_llsr) (grub_uint64_t u, int b); + +#endif + + +#if defined (__powerpc__) + +void EXPORT_FUNC (_restgpr_14_x) (void); +void EXPORT_FUNC (_restgpr_15_x) (void); +void EXPORT_FUNC (_restgpr_16_x) (void); +void EXPORT_FUNC (_restgpr_17_x) (void); +void EXPORT_FUNC (_restgpr_18_x) (void); +void EXPORT_FUNC (_restgpr_19_x) (void); +void EXPORT_FUNC (_restgpr_20_x) (void); +void EXPORT_FUNC (_restgpr_21_x) (void); +void EXPORT_FUNC (_restgpr_22_x) (void); +void EXPORT_FUNC (_restgpr_23_x) (void); +void EXPORT_FUNC (_restgpr_24_x) (void); +void EXPORT_FUNC (_restgpr_25_x) (void); +void EXPORT_FUNC (_restgpr_26_x) (void); +void EXPORT_FUNC (_restgpr_27_x) (void); +void EXPORT_FUNC (_restgpr_28_x) (void); +void EXPORT_FUNC (_restgpr_29_x) (void); +void EXPORT_FUNC (_restgpr_30_x) (void); +void EXPORT_FUNC (_restgpr_31_x) (void); +void EXPORT_FUNC (_savegpr_14) (void); +void EXPORT_FUNC (_savegpr_15) (void); +void EXPORT_FUNC (_savegpr_16) (void); +void EXPORT_FUNC (_savegpr_17) (void); +void EXPORT_FUNC (_savegpr_18) (void); +void EXPORT_FUNC (_savegpr_19) (void); +void EXPORT_FUNC (_savegpr_20) (void); +void EXPORT_FUNC (_savegpr_21) (void); +void EXPORT_FUNC (_savegpr_22) (void); +void EXPORT_FUNC (_savegpr_23) (void); +void EXPORT_FUNC (_savegpr_24) (void); +void EXPORT_FUNC (_savegpr_25) (void); +void EXPORT_FUNC (_savegpr_26) (void); +void EXPORT_FUNC (_savegpr_27) (void); +void EXPORT_FUNC (_savegpr_28) (void); +void EXPORT_FUNC (_savegpr_29) (void); +void EXPORT_FUNC (_savegpr_30) (void); +void EXPORT_FUNC (_savegpr_31) (void); + +#endif + +#if defined (__powerpc__) || defined(__mips__) || defined (__arm__) + +int +EXPORT_FUNC(__ucmpdi2) (grub_uint64_t a, grub_uint64_t b); + +grub_uint64_t +EXPORT_FUNC(__ashldi3) (grub_uint64_t u, int b); + +grub_uint64_t +EXPORT_FUNC(__ashrdi3) (grub_uint64_t u, int b); + +grub_uint64_t +EXPORT_FUNC (__lshrdi3) (grub_uint64_t u, int b); +#endif + +#if defined (__powerpc__) || defined(__mips__) || defined(__sparc__) || defined (__arm__) +grub_uint32_t +EXPORT_FUNC(__bswapsi2) (grub_uint32_t u); + +grub_uint64_t +EXPORT_FUNC(__bswapdi2) (grub_uint64_t u); +#endif + +#if defined (__APPLE__) && defined(__i386__) +#define GRUB_BUILTIN_ATTR __attribute__ ((regparm(0))) +#else +#define GRUB_BUILTIN_ATTR +#endif + +/* Prototypes for aliases. */ +int GRUB_BUILTIN_ATTR EXPORT_FUNC(memcmp) (const void *s1, const void *s2, grub_size_t n); +void *GRUB_BUILTIN_ATTR EXPORT_FUNC(memmove) (void *dest, const void *src, grub_size_t n); +void *GRUB_BUILTIN_ATTR EXPORT_FUNC(memcpy) (void *dest, const void *src, grub_size_t n); +void *GRUB_BUILTIN_ATTR EXPORT_FUNC(memset) (void *s, int c, grub_size_t n); + +#ifdef __APPLE__ +void GRUB_BUILTIN_ATTR EXPORT_FUNC (__bzero) (void *s, grub_size_t n); +#endif + +#if defined (__MINGW32__) || defined (__CYGWIN__) +void EXPORT_FUNC (__register_frame_info) (void); +void EXPORT_FUNC (__deregister_frame_info) (void); +void EXPORT_FUNC (___chkstk_ms) (void); +void EXPORT_FUNC (__chkstk_ms) (void); +#endif + +#endif + diff --git a/include/grub/libgcc.h b/include/grub/libgcc.h deleted file mode 100644 index 8e93b6792..000000000 --- a/include/grub/libgcc.h +++ /dev/null @@ -1,91 +0,0 @@ -/* - * GRUB -- GRand Unified Bootloader - * Copyright (C) 2004,2007,2009 Free Software Foundation, Inc. - * - * GRUB is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * GRUB is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GRUB. If not, see . - */ - -/* We need to include config-util.h.in for HAVE_*. */ -#ifndef __STDC_VERSION__ -#define __STDC_VERSION__ 0 -#endif -#include - -/* On x86 these functions aren't really needed. Save some space. */ -#if !defined (__i386__) && !defined (__x86_64__) -# ifdef HAVE___ASHLDI3 -void EXPORT_FUNC (__ashldi3) (void); -# endif -# ifdef HAVE___ASHRDI3 -void EXPORT_FUNC (__ashrdi3) (void); -# endif -# ifdef HAVE___LSHRDI3 -void EXPORT_FUNC (__lshrdi3) (void); -# endif -# ifdef HAVE___UCMPDI2 -void EXPORT_FUNC (__ucmpdi2) (void); -# endif -# ifdef HAVE___BSWAPSI2 -void EXPORT_FUNC (__bswapsi2) (void); -# endif -# ifdef HAVE___BSWAPDI2 -void EXPORT_FUNC (__bswapdi2) (void); -# endif -#endif - -#ifdef HAVE__RESTGPR_14_X -void EXPORT_FUNC (_restgpr_14_x) (void); -void EXPORT_FUNC (_restgpr_15_x) (void); -void EXPORT_FUNC (_restgpr_16_x) (void); -void EXPORT_FUNC (_restgpr_17_x) (void); -void EXPORT_FUNC (_restgpr_18_x) (void); -void EXPORT_FUNC (_restgpr_19_x) (void); -void EXPORT_FUNC (_restgpr_20_x) (void); -void EXPORT_FUNC (_restgpr_21_x) (void); -void EXPORT_FUNC (_restgpr_22_x) (void); -void EXPORT_FUNC (_restgpr_23_x) (void); -void EXPORT_FUNC (_restgpr_24_x) (void); -void EXPORT_FUNC (_restgpr_25_x) (void); -void EXPORT_FUNC (_restgpr_26_x) (void); -void EXPORT_FUNC (_restgpr_27_x) (void); -void EXPORT_FUNC (_restgpr_28_x) (void); -void EXPORT_FUNC (_restgpr_29_x) (void); -void EXPORT_FUNC (_restgpr_30_x) (void); -void EXPORT_FUNC (_restgpr_31_x) (void); -void EXPORT_FUNC (_savegpr_14) (void); -void EXPORT_FUNC (_savegpr_15) (void); -void EXPORT_FUNC (_savegpr_16) (void); -void EXPORT_FUNC (_savegpr_17) (void); -void EXPORT_FUNC (_savegpr_18) (void); -void EXPORT_FUNC (_savegpr_19) (void); -void EXPORT_FUNC (_savegpr_20) (void); -void EXPORT_FUNC (_savegpr_21) (void); -void EXPORT_FUNC (_savegpr_22) (void); -void EXPORT_FUNC (_savegpr_23) (void); -void EXPORT_FUNC (_savegpr_24) (void); -void EXPORT_FUNC (_savegpr_25) (void); -void EXPORT_FUNC (_savegpr_26) (void); -void EXPORT_FUNC (_savegpr_27) (void); -void EXPORT_FUNC (_savegpr_28) (void); -void EXPORT_FUNC (_savegpr_29) (void); -void EXPORT_FUNC (_savegpr_30) (void); -void EXPORT_FUNC (_savegpr_31) (void); -#endif - -#if defined (__arm__) -void EXPORT_FUNC (__aeabi_lasr) (void); -void EXPORT_FUNC (__aeabi_llsl) (void); -void EXPORT_FUNC (__aeabi_llsr) (void); -void EXPORT_FUNC (__aeabi_ulcmp) (void); -#endif diff --git a/include/grub/misc.h b/include/grub/misc.h index a05b3fd39..2a9f87cc2 100644 --- a/include/grub/misc.h +++ b/include/grub/misc.h @@ -71,12 +71,6 @@ grub_memcpy (void *dest, const void *src, grub_size_t n) return grub_memmove (dest, src, n); } -#if defined (__APPLE__) && defined(__i386__) && !defined (GRUB_UTIL) -#define GRUB_BUILTIN_ATTR __attribute__ ((regparm(0))) -#else -#define GRUB_BUILTIN_ATTR -#endif - #if defined(__x86_64__) && !defined (GRUB_UTIL) #if defined (__MINGW32__) || defined (__CYGWIN__) || defined (__MINGW64__) #define GRUB_ASM_ATTR __attribute__ ((sysv_abi)) @@ -85,19 +79,6 @@ grub_memcpy (void *dest, const void *src, grub_size_t n) #endif #endif -/* Prototypes for aliases. */ -#ifndef GRUB_UTIL -int GRUB_BUILTIN_ATTR EXPORT_FUNC(memcmp) (const void *s1, const void *s2, grub_size_t n); -void *GRUB_BUILTIN_ATTR EXPORT_FUNC(memmove) (void *dest, const void *src, grub_size_t n); -void *GRUB_BUILTIN_ATTR EXPORT_FUNC(memcpy) (void *dest, const void *src, grub_size_t n); -void *GRUB_BUILTIN_ATTR EXPORT_FUNC(memset) (void *s, int c, grub_size_t n); - -#ifdef __APPLE__ -void GRUB_BUILTIN_ATTR EXPORT_FUNC (__bzero) (void *s, grub_size_t n); -#endif - -#endif - int EXPORT_FUNC(grub_memcmp) (const void *s1, const void *s2, grub_size_t n); int EXPORT_FUNC(grub_strcmp) (const char *s1, const char *s2); int EXPORT_FUNC(grub_strncmp) (const char *s1, const char *s2, grub_size_t n); @@ -378,6 +359,7 @@ grub_int64_t EXPORT_FUNC_IF_SOFTDIV(grub_divmod64s) (grub_int64_t n, grub_int64_t d, grub_int64_t *r); + grub_uint32_t EXPORT_FUNC_IF_SOFTDIV (grub_divmod32) (grub_uint32_t n, grub_uint32_t d, @@ -388,41 +370,6 @@ EXPORT_FUNC_IF_SOFTDIV (grub_divmod32s) (grub_int32_t n, grub_int32_t d, grub_int32_t *r); -#if defined(GRUB_DIVISION_IN_SOFTWARE) && GRUB_DIVISION_IN_SOFTWARE - -grub_uint32_t -EXPORT_FUNC (__udivsi3) (grub_uint32_t a, grub_uint32_t b); - -grub_uint32_t -EXPORT_FUNC (__umodsi3) (grub_uint32_t a, grub_uint32_t b); - -grub_int32_t -EXPORT_FUNC (__divsi3) (grub_int32_t a, grub_int32_t b); - -grub_int32_t -EXPORT_FUNC (__modsi3) (grub_int32_t a, grub_int32_t b); - -grub_int64_t -EXPORT_FUNC (__divdi3) (grub_int64_t a, grub_int64_t b); - -grub_int64_t -EXPORT_FUNC (__moddi3) (grub_int64_t a, grub_int64_t b); - -grub_uint64_t -EXPORT_FUNC (__udivdi3) (grub_uint64_t a, grub_uint64_t b); - -grub_uint64_t -EXPORT_FUNC (__umoddi3) (grub_uint64_t a, grub_uint64_t b); - -#endif - -#if (defined (__MINGW32__) || defined (__CYGWIN__)) && !defined(GRUB_UTIL) -void EXPORT_FUNC (__register_frame_info) (void); -void EXPORT_FUNC (__deregister_frame_info) (void); -void EXPORT_FUNC (___chkstk_ms) (void); -void EXPORT_FUNC (__chkstk_ms) (void); -#endif - /* Inline functions. */ static inline char * @@ -491,50 +438,6 @@ grub_error_load (const struct grub_error_saved *save) grub_errno = save->grub_errno; } -#ifndef GRUB_UTIL - -#if defined (__arm__) - -#endif - -#if defined (__sparc__) || defined (__powerpc__) -unsigned -EXPORT_FUNC (__ctzdi2) (grub_uint64_t x); -#define NEED_CTZDI2 1 -#endif - -#if defined (__mips__) || defined (__arm__) -unsigned -EXPORT_FUNC (__ctzsi2) (grub_uint32_t x); -#define NEED_CTZSI2 1 -#endif - -#ifdef __arm__ -grub_uint32_t -EXPORT_FUNC (__aeabi_uidiv) (grub_uint32_t a, grub_uint32_t b); -grub_int32_t -EXPORT_FUNC (__aeabi_idiv) (grub_int32_t a, grub_int32_t b); -grub_uint32_t -EXPORT_FUNC (__aeabi_uidivmod) (grub_uint32_t a, grub_uint32_t b); -grub_int32_t -EXPORT_FUNC (__aeabi_idivmod) (grub_int32_t a, grub_int32_t b); - -/* Needed for allowing modules to be compiled as thumb. */ -grub_uint64_t -EXPORT_FUNC (__muldi3) (grub_uint64_t a, grub_uint64_t b); -grub_uint64_t -EXPORT_FUNC (__aeabi_lmul) (grub_uint64_t a, grub_uint64_t b); - -void * -EXPORT_FUNC (__aeabi_memcpy) (void *dest, const void *src, grub_size_t n); -void * -EXPORT_FUNC(__aeabi_memset) (void *s, int c, grub_size_t n); - -#endif - -#endif /* GRUB_UTIL */ - - #if BOOT_TIME_STATS struct grub_boot_time { diff --git a/include/grub/xen.h b/include/grub/xen.h index 6035d1a10..9ba3b8e6b 100644 --- a/include/grub/xen.h +++ b/include/grub/xen.h @@ -21,6 +21,8 @@ #define __XEN_INTERFACE_VERSION__ 0x0003020a +#define memset grub_memset + #ifdef ASM_FILE #define __ASSEMBLY__ #include From 9f95d12153098f8b3e4c34ad106c6402cd4dc0ff Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Tue, 3 Mar 2015 20:49:48 +0100 Subject: [PATCH 352/722] configure.ac: Remove unused COND_clang --- configure.ac | 1 - 1 file changed, 1 deletion(-) diff --git a/configure.ac b/configure.ac index be980adbb..16fa0da63 100644 --- a/configure.ac +++ b/configure.ac @@ -1759,7 +1759,6 @@ AC_SUBST(BUILD_LIBM) AM_CONDITIONAL([COND_real_platform], [test x$platform != xnone]) AM_CONDITIONAL([COND_emu], [test x$platform = xemu]) -AM_CONDITIONAL([COND_clang], [test x$grub_cv_cc_target_clang = xyes]) AM_CONDITIONAL([COND_i386_pc], [test x$target_cpu = xi386 -a x$platform = xpc]) AM_CONDITIONAL([COND_i386_efi], [test x$target_cpu = xi386 -a x$platform = xefi]) AM_CONDITIONAL([COND_ia64_efi], [test x$target_cpu = xia64 -a x$platform = xefi]) From 9d25b0da9a8cce9b3766f4e1b449d7936d5ba124 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Tue, 3 Mar 2015 20:59:36 +0100 Subject: [PATCH 353/722] Remove emu libusb support. It's disabled by default and has been broken for a long time. As nobody is interested in fixing and maintaining it, remove it. --- configure.ac | 44 -------- gentpl.py | 2 +- grub-core/Makefile.am | 3 - grub-core/Makefile.core.def | 14 --- grub-core/bus/usb/emu/usb.c | 203 ------------------------------------ include/grub/libusb.h | 29 ------ 6 files changed, 1 insertion(+), 294 deletions(-) delete mode 100644 grub-core/bus/usb/emu/usb.c delete mode 100644 include/grub/libusb.h diff --git a/configure.ac b/configure.ac index 16fa0da63..2200776d3 100644 --- a/configure.ac +++ b/configure.ac @@ -1255,10 +1255,6 @@ else fi AC_SUBST([BOOT_TIME_STATS]) -AC_ARG_ENABLE([grub-emu-usb], - [AS_HELP_STRING([--enable-grub-emu-usb], - [build and install the `grub-emu' debugging utility with USB support (default=guessed)])]) - AC_ARG_ENABLE([grub-emu-sdl], [AS_HELP_STRING([--enable-grub-emu-sdl], [build and install the `grub-emu' debugging utility with SDL support (default=guessed)])]) @@ -1269,34 +1265,6 @@ AC_ARG_ENABLE([grub-emu-pci], if test "$platform" = emu; then -if test x"$enable_grub_emu_usb" != xyes ; then - grub_emu_usb_excuse="not enabled" -fi - -if test x"$enable_grub_emu_pci" = xyes ; then - grub_emu_usb_excuse="conflicts with PCI support" -fi - -[if [ x"$grub_emu_usb_excuse" = x ]; then - # Check for libusb libraries.] -AC_CHECK_LIB([usb], [usb_claim_interface], [LIBUSB="-lusb"], - [grub_emu_usb_excuse=["need libusb library"]]) - AC_SUBST([LIBUSB]) -[fi] -[if [ x"$grub_emu_usb_excuse" = x ]; then - # Check for headers.] - AC_CHECK_HEADERS([usb.h], [], - [grub_emu_usb_excuse=["need libusb headers"]]) -[fi] -if test x"$enable_grub_emu_usb" = xyes && test x"$grub_emu_usb_excuse" != x ; then - AC_MSG_ERROR([USB support for grub-emu was explicitly requested but can't be compiled ($grub_emu_usb_excuse)]) -fi -if test x"$grub_emu_usb_excuse" = x ; then -enable_grub_emu_usb=yes -else -enable_grub_emu_usb=no -fi - if test x"$enable_grub_emu_sdl" = xno ; then grub_emu_sdl_excuse="explicitly disabled" fi @@ -1326,10 +1294,6 @@ if test x"$enable_grub_emu_pci" != xyes ; then grub_emu_pci_excuse="not enabled" fi -if test x"$enable_grub_emu_usb" = xyes ; then - grub_emu_pci_excuse="conflicts with USB support" -fi - [if [ x"$grub_emu_pci_excuse" = x ]; then # Check for libpci libraries.] AC_CHECK_LIB([pciaccess], [pci_system_init], [LIBPCIACCESS="-lpciaccess"], @@ -1350,14 +1314,12 @@ enable_grub_emu_pci=no fi AC_SUBST([enable_grub_emu_sdl]) -AC_SUBST([enable_grub_emu_usb]) AC_SUBST([enable_grub_emu_pci]) else # Ignore --enable-emu-* if platform is not emu enable_grub_emu_sdl=no -enable_grub_emu_usb=no enable_grub_emu_pci=no fi @@ -1793,7 +1755,6 @@ AM_CONDITIONAL([COND_HOST_XNU], [test x$host_kernel = xxnu]) AM_CONDITIONAL([COND_HOST_ILLUMOS], [test x$host_kernel = xillumos]) AM_CONDITIONAL([COND_MAN_PAGES], [test x$cross_compiling = xno -a x$HELP2MAN != x]) -AM_CONDITIONAL([COND_GRUB_EMU_USB], [test x$enable_grub_emu_usb = xyes]) AM_CONDITIONAL([COND_GRUB_EMU_SDL], [test x$enable_grub_emu_sdl = xyes]) AM_CONDITIONAL([COND_GRUB_EMU_PCI], [test x$enable_grub_emu_pci = xyes]) AM_CONDITIONAL([COND_GRUB_MKFONT], [test x$enable_grub_mkfont = xyes]) @@ -1871,11 +1832,6 @@ echo "*******************************************************" echo GRUB2 will be compiled with following components: echo Platform: "$target_cpu"-"$platform" if [ x"$platform" = xemu ]; then -if [ x"$grub_emu_usb_excuse" = x ]; then -echo USB support for grub-emu: Yes -else -echo USB support for grub-emu: No "($grub_emu_usb_excuse)" -fi if [ x"$grub_emu_sdl_excuse" = x ]; then echo SDL support for grub-emu: Yes else diff --git a/gentpl.py b/gentpl.py index d2aa03586..f177883f8 100644 --- a/gentpl.py +++ b/gentpl.py @@ -606,7 +606,7 @@ def foreach_enabled_platform(defn, closure): # enable = emu; # enable = i386; # enable = mips_loongson; -# emu_condition = COND_GRUB_EMU_USB; +# emu_condition = COND_GRUB_EMU_SDL; # }; # def under_platform_specific_conditionals(defn, platform, closure): diff --git a/grub-core/Makefile.am b/grub-core/Makefile.am index 57c0b64e7..af0c7f47c 100644 --- a/grub-core/Makefile.am +++ b/grub-core/Makefile.am @@ -250,9 +250,6 @@ KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/extcmd.h if COND_GRUB_EMU_SDL KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/sdl.h endif -if COND_GRUB_EMU_USB -KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/libusb.h -endif if COND_GRUB_EMU_PCI KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/libpciaccess.h endif diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def index 7a6fa21a4..8eaae458c 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def @@ -511,13 +511,6 @@ module = { enable = x86; }; -module = { - name = libusb; - emu = bus/usb/emu/usb.c; - enable = emu; - condition = COND_GRUB_EMU_USB; -}; - module = { name = lsspd; mips_loongson = commands/mips/loongson/lsspd.c; @@ -532,13 +525,6 @@ module = { enable = usb; }; -module = { - name = emuusb; - common = bus/usb/usb.c; - enable = emu; - condition = COND_GRUB_EMU_USB; -}; - module = { name = usbserial_common; common = bus/usb/serial/common.c; diff --git a/grub-core/bus/usb/emu/usb.c b/grub-core/bus/usb/emu/usb.c deleted file mode 100644 index 3ad2fc312..000000000 --- a/grub-core/bus/usb/emu/usb.c +++ /dev/null @@ -1,203 +0,0 @@ -/* usb.c -- libusb USB support for GRUB. */ -/* - * GRUB -- GRand Unified Bootloader - * Copyright (C) 2008 Free Software Foundation, Inc. - * - * GRUB is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * GRUB is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GRUB. If not, see . - */ - -#include -#include -#include -#include -#include -#include - -GRUB_MOD_LICENSE ("GPLv3+"); - - -static struct grub_usb_controller_dev usb_controller = -{ - .name = "libusb" -}; - -static struct grub_usb_device *grub_usb_devs[128]; - -struct usb_bus *busses; - -static grub_err_t -grub_libusb_devices (void) - -{ - struct usb_bus *bus; - int last = 0; - - busses = usb_get_busses(); - - for (bus = busses; bus; bus = bus->next) - { - struct usb_device *usbdev; - struct grub_usb_device *dev; - - for (usbdev = bus->devices; usbdev; usbdev = usbdev->next) - { - struct usb_device_descriptor *desc = &usbdev->descriptor; - grub_err_t err; - - if (! desc->bcdUSB) - continue; - - dev = grub_malloc (sizeof (*dev)); - if (! dev) - return grub_errno; - - dev->data = usbdev; - - /* Fill in all descriptors. */ - err = grub_usb_device_initialize (dev); - if (err) - { - grub_errno = GRUB_ERR_NONE; - continue; - } - - /* Register the device. */ - grub_usb_devs[last++] = dev; - } - } - - return GRUB_USB_ERR_NONE; -} - -void -grub_usb_poll_devices (void) -{ - /* TODO: recheck grub_usb_devs */ -} - - -int -grub_usb_iterate (grub_usb_iterate_hook_t hook, void *hook_data) -{ - int i; - - for (i = 0; i < 128; i++) - { - if (grub_usb_devs[i]) - { - if (hook (grub_usb_devs[i], hook_data)) - return 1; - } - } - - return 0; -} - -grub_usb_err_t -grub_usb_root_hub (grub_usb_controller_t controller __attribute__((unused))) -{ - return GRUB_USB_ERR_NONE; -} - -grub_usb_err_t -grub_usb_control_msg (grub_usb_device_t dev, grub_uint8_t reqtype, - grub_uint8_t request, grub_uint16_t value, - grub_uint16_t idx, grub_size_t size, char *data) -{ - usb_dev_handle *devh; - struct usb_device *d = dev->data; - - devh = usb_open (d); - if (usb_control_msg (devh, reqtype, request, - value, idx, data, size, 20) < 0) - { - usb_close (devh); - return GRUB_USB_ERR_STALL; - } - - usb_close (devh); - - return GRUB_USB_ERR_NONE; -} - -grub_usb_err_t -grub_usb_bulk_read (grub_usb_device_t dev, - int endpoint, grub_size_t size, char *data) -{ - usb_dev_handle *devh; - struct usb_device *d = dev->data; - - devh = usb_open (d); - if (usb_claim_interface (devh, 0) < 1) - { - usb_close (devh); - return GRUB_USB_ERR_STALL; - } - - if (usb_bulk_read (devh, endpoint, data, size, 20) < 1) - { - usb_close (devh); - return GRUB_USB_ERR_STALL; - } - - usb_release_interface (devh, 0); - usb_close (devh); - - return GRUB_USB_ERR_NONE; -} - -grub_usb_err_t -grub_usb_bulk_write (grub_usb_device_t dev, - int endpoint, grub_size_t size, char *data) -{ - usb_dev_handle *devh; - struct usb_device *d = dev->data; - - devh = usb_open (d); - if (usb_claim_interface (devh, 0) < 0) - goto fail; - - if (usb_bulk_write (devh, endpoint, data, size, 20) < 0) - goto fail; - - if (usb_release_interface (devh, 0) < 0) - goto fail; - - usb_close (devh); - - return GRUB_USB_ERR_NONE; - - fail: - usb_close (devh); - return GRUB_USB_ERR_STALL; -} - -GRUB_MOD_INIT (libusb) -{ - usb_init(); - usb_find_busses(); - usb_find_devices(); - - if (grub_libusb_devices ()) - return; - - grub_usb_controller_dev_register (&usb_controller); - - return; -} - -GRUB_MOD_FINI (libusb) -{ - return; -} diff --git a/include/grub/libusb.h b/include/grub/libusb.h deleted file mode 100644 index 26548bccb..000000000 --- a/include/grub/libusb.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - * GRUB -- GRand Unified Bootloader - * Copyright (C) 2010 Free Software Foundation, Inc. - * - * GRUB is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * GRUB is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GRUB. If not, see . - */ - -void EXPORT_FUNC (usb_bulk_write) (void); -void EXPORT_FUNC (usb_find_busses) (void); -void EXPORT_FUNC (usb_init) (void); -void EXPORT_FUNC (usb_find_devices) (void); -void EXPORT_FUNC (usb_open) (void); -void EXPORT_FUNC (usb_get_busses) (void); -void EXPORT_FUNC (usb_control_msg) (void); -void EXPORT_FUNC (usb_release_interface) (void); -void EXPORT_FUNC (usb_close) (void); -void EXPORT_FUNC (usb_bulk_read) (void); -void EXPORT_FUNC (usb_claim_interface) (void); From 27d1a67f8a99e62b0900c68198477143f5bfbaa5 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Wed, 4 Mar 2015 01:00:19 +0100 Subject: [PATCH 354/722] Fix canonicalize_file_name clash. canonicalize_file_name clashed with gnulib function. Additionally it was declared in 2 places: emu/misc.h and util/misc.h. Added grub_ prefix and removed second declaration. --- grub-core/bus/emu/pci.c | 7 ++++--- grub-core/kern/emu/hostdisk.c | 4 ++-- grub-core/osdep/aros/hostdisk.c | 2 +- grub-core/osdep/unix/getroot.c | 4 ++-- grub-core/osdep/unix/hostdisk.c | 2 +- grub-core/osdep/unix/relpath.c | 2 +- grub-core/osdep/windows/hostdisk.c | 2 +- grub-core/osdep/windows/init.c | 2 +- include/grub/emu/misc.h | 3 +-- include/grub/util/misc.h | 2 +- util/getroot.c | 2 +- util/grub-file.c | 2 +- util/grub-fstest.c | 2 +- util/grub-install.c | 4 ++-- util/grub-macbless.c | 2 +- util/grub-mount.c | 2 +- util/grub-probe.c | 2 +- util/grub-syslinux2cfg.c | 6 +++--- util/probe.c | 6 +++--- util/render-label.c | 2 +- 20 files changed, 30 insertions(+), 30 deletions(-) diff --git a/grub-core/bus/emu/pci.c b/grub-core/bus/emu/pci.c index 9d3296395..663e5540c 100644 --- a/grub-core/bus/emu/pci.c +++ b/grub-core/bus/emu/pci.c @@ -55,7 +55,8 @@ grub_pci_device_map_range (grub_pci_device_t dev, grub_addr_t base, int err; err = pci_device_map_range (dev, base, size, PCI_DEV_MAP_FLAG_WRITABLE, &addr); if (err) - grub_util_error ("mapping 0x%x failed (error %d)\n", base, err); + grub_util_error ("mapping 0x%llx failed (error %d)\n", + (unsigned long long) base, err); return addr; } @@ -66,12 +67,12 @@ grub_pci_device_unmap_range (grub_pci_device_t dev, void *mem, pci_device_unmap_range (dev, mem, size); } -GRUB_MOD_INIT (pci) +GRUB_MOD_INIT (emupci) { pci_system_init (); } -GRUB_MOD_FINI (pci) +GRUB_MOD_FINI (emupci) { pci_system_cleanup (); } diff --git a/grub-core/kern/emu/hostdisk.c b/grub-core/kern/emu/hostdisk.c index a4ebf78a9..a3b00c8f6 100644 --- a/grub-core/kern/emu/hostdisk.c +++ b/grub-core/kern/emu/hostdisk.c @@ -184,7 +184,7 @@ grub_hostdisk_os_dev_to_grub_drive (const char *os_disk, int add) unsigned int i; char *canon; - canon = canonicalize_file_name (os_disk); + canon = grub_canonicalize_file_name (os_disk); if (!canon) canon = xstrdup (os_disk); @@ -535,7 +535,7 @@ read_device_map (const char *dev_map) /* On Linux, the devfs uses symbolic links horribly, and that confuses the interface very much, so use realpath to expand symbolic links. */ - map[drive].device = canonicalize_file_name (p); + map[drive].device = grub_canonicalize_file_name (p); if (! map[drive].device) map[drive].device = xstrdup (p); diff --git a/grub-core/osdep/aros/hostdisk.c b/grub-core/osdep/aros/hostdisk.c index e1eeea7d0..7d99b54b8 100644 --- a/grub-core/osdep/aros/hostdisk.c +++ b/grub-core/osdep/aros/hostdisk.c @@ -61,7 +61,7 @@ static ULONG *bounce; char * -canonicalize_file_name (const char *path) +grub_canonicalize_file_name (const char *path) { char *ret; BPTR lck; diff --git a/grub-core/osdep/unix/getroot.c b/grub-core/osdep/unix/getroot.c index 10fb56a2b..ccee7ce16 100644 --- a/grub-core/osdep/unix/getroot.c +++ b/grub-core/osdep/unix/getroot.c @@ -491,7 +491,7 @@ grub_guess_root_devices (const char *dir_in) char **os_dev = NULL; struct stat st; dev_t dev; - char *dir = canonicalize_file_name (dir_in); + char *dir = grub_canonicalize_file_name (dir_in); if (!dir) grub_util_error (_("failed to get canonical path of `%s'"), dir_in); @@ -516,7 +516,7 @@ grub_guess_root_devices (const char *dir_in) *cur = tmp; else { - *cur = canonicalize_file_name (tmp); + *cur = grub_canonicalize_file_name (tmp); if (*cur == NULL) grub_util_error (_("failed to get canonical path of `%s'"), tmp); free (tmp); diff --git a/grub-core/osdep/unix/hostdisk.c b/grub-core/osdep/unix/hostdisk.c index b3bc0e425..2a8c5882e 100644 --- a/grub-core/osdep/unix/hostdisk.c +++ b/grub-core/osdep/unix/hostdisk.c @@ -198,7 +198,7 @@ grub_util_fd_close (grub_util_fd_t fd) } char * -canonicalize_file_name (const char *path) +grub_canonicalize_file_name (const char *path) { #if defined (PATH_MAX) char *ret; diff --git a/grub-core/osdep/unix/relpath.c b/grub-core/osdep/unix/relpath.c index 71c19d867..8fdc3a73a 100644 --- a/grub-core/osdep/unix/relpath.c +++ b/grub-core/osdep/unix/relpath.c @@ -44,7 +44,7 @@ grub_make_system_path_relative_to_its_root (const char *path) char *poolfs = NULL; /* canonicalize. */ - p = canonicalize_file_name (path); + p = grub_canonicalize_file_name (path); if (p == NULL) grub_util_error (_("failed to get canonical path of `%s'"), path); diff --git a/grub-core/osdep/windows/hostdisk.c b/grub-core/osdep/windows/hostdisk.c index d390b25fc..85507af88 100644 --- a/grub-core/osdep/windows/hostdisk.c +++ b/grub-core/osdep/windows/hostdisk.c @@ -328,7 +328,7 @@ grub_util_fd_strerror (void) } char * -canonicalize_file_name (const char *path) +grub_canonicalize_file_name (const char *path) { char *ret; LPTSTR windows_path; diff --git a/grub-core/osdep/windows/init.c b/grub-core/osdep/windows/init.c index 98c325c20..e8ffd62c6 100644 --- a/grub-core/osdep/windows/init.c +++ b/grub-core/osdep/windows/init.c @@ -170,7 +170,7 @@ grub_util_host_init (int *argc __attribute__ ((unused)), #error "Unsupported TCHAR size" #endif - grub_util_base_directory = canonicalize_file_name ((*argv)[0]); + grub_util_base_directory = grub_canonicalize_file_name ((*argv)[0]); if (!grub_util_base_directory) grub_util_base_directory = xstrdup ((*argv)[0]); for (ptr = grub_util_base_directory + strlen (grub_util_base_directory) - 1; diff --git a/include/grub/emu/misc.h b/include/grub/emu/misc.h index a588ba21d..df6085bcb 100644 --- a/include/grub/emu/misc.h +++ b/include/grub/emu/misc.h @@ -27,6 +27,7 @@ #include #include #include +#include extern int verbosity; extern const char *program_name; @@ -61,8 +62,6 @@ void EXPORT_FUNC(grub_util_error) (const char *fmt, ...) __attribute__ ((format grub_uint64_t EXPORT_FUNC (grub_util_get_cpu_time_ms) (void); -extern char * canonicalize_file_name (const char *path); - #ifdef HAVE_DEVICE_MAPPER int grub_device_mapper_supported (void); #endif diff --git a/include/grub/util/misc.h b/include/grub/util/misc.h index 192874d42..e9e0a6724 100644 --- a/include/grub/util/misc.h +++ b/include/grub/util/misc.h @@ -41,7 +41,7 @@ void grub_util_write_image_at (const void *img, size_t size, off_t offset, char *make_system_path_relative_to_its_root (const char *path); -char *canonicalize_file_name (const char *path); +char *grub_canonicalize_file_name (const char *path); void grub_util_init_nls (void); diff --git a/util/getroot.c b/util/getroot.c index 3c1f12dca..36f1730c0 100644 --- a/util/getroot.c +++ b/util/getroot.c @@ -406,7 +406,7 @@ grub_util_biosdisk_get_grub_dev (const char *os_dev) os_dev); grub_errno = GRUB_ERR_NONE; - canon = canonicalize_file_name (os_dev); + canon = grub_canonicalize_file_name (os_dev); drive = grub_hostdisk_os_dev_to_grub_drive (canon ? : os_dev, 1); if (canon) free (canon); diff --git a/util/grub-file.c b/util/grub-file.c index 9989dfe7b..50c18b683 100644 --- a/util/grub-file.c +++ b/util/grub-file.c @@ -77,7 +77,7 @@ main (int argc, char *argv[]) } if (had_file) grub_util_error ("one argument expected"); - argv2[i - 1] = canonicalize_file_name (argv[i]); + argv2[i - 1] = grub_canonicalize_file_name (argv[i]); if (!argv2[i - 1]) { grub_util_error (_("cannot open `%s': %s"), argv[i], diff --git a/util/grub-fstest.c b/util/grub-fstest.c index 02cd3e3e2..a358ae471 100644 --- a/util/grub-fstest.c +++ b/util/grub-fstest.c @@ -651,7 +651,7 @@ argp_parser (int key, char *arg, struct argp_state *state) { if (args_count == 0) images = xmalloc (num_disks * sizeof (images[0])); - images[args_count] = canonicalize_file_name (arg); + images[args_count] = grub_canonicalize_file_name (arg); args_count++; return 0; } diff --git a/util/grub-install.c b/util/grub-install.c index cedc18809..7b394c997 100644 --- a/util/grub-install.c +++ b/util/grub-install.c @@ -967,7 +967,7 @@ main (int argc, char *argv[]) { char * t = grub_util_path_concat (2, bootdir, GRUB_DIR_NAME); grub_install_mkdir_p (t); - grubdir = canonicalize_file_name (t); + grubdir = grub_canonicalize_file_name (t); if (!grubdir) grub_util_error (_("failed to get canonical path of `%s'"), t); free (t); @@ -1299,7 +1299,7 @@ main (int argc, char *argv[]) { char *t = grub_util_path_concat (2, grubdir, platname); - platdir = canonicalize_file_name (t); + platdir = grub_canonicalize_file_name (t); if (!platdir) grub_util_error (_("failed to get canonical path of `%s'"), t); diff --git a/util/grub-macbless.c b/util/grub-macbless.c index e57e13d5a..e9b15a053 100644 --- a/util/grub-macbless.c +++ b/util/grub-macbless.c @@ -64,7 +64,7 @@ bless (const char *path, int x86) grub_err_t err; struct stat st; - grub_path = canonicalize_file_name (path); + grub_path = grub_canonicalize_file_name (path); if (stat (grub_path, &st) < 0) grub_util_error (N_("cannot stat `%s': %s"), diff --git a/util/grub-mount.c b/util/grub-mount.c index 4626e54ed..0d0fea5f2 100644 --- a/util/grub-mount.c +++ b/util/grub-mount.c @@ -547,7 +547,7 @@ argp_parser (int key, char *arg, struct argp_state *state) } images = xrealloc (images, (num_disks + 1) * sizeof (images[0])); - images[num_disks] = canonicalize_file_name (arg); + images[num_disks] = grub_canonicalize_file_name (arg); num_disks++; return 0; diff --git a/util/grub-probe.c b/util/grub-probe.c index 8f4aa6138..6075cb3fc 100644 --- a/util/grub-probe.c +++ b/util/grub-probe.c @@ -262,7 +262,7 @@ probe (const char *path, char **device_names, char delim) if (path != NULL) { - grub_path = canonicalize_file_name (path); + grub_path = grub_canonicalize_file_name (path); if (! grub_path) grub_util_error (_("failed to get canonical path of `%s'"), path); device_names = grub_guess_root_devices (grub_path); diff --git a/util/grub-syslinux2cfg.c b/util/grub-syslinux2cfg.c index f4fda6db9..85fa0da14 100644 --- a/util/grub-syslinux2cfg.c +++ b/util/grub-syslinux2cfg.c @@ -175,7 +175,7 @@ main (int argc, char *argv[]) grub_host_init (); char *t, *inpfull, *rootfull, *res; - t = canonicalize_file_name (arguments.input); + t = grub_canonicalize_file_name (arguments.input); if (!t) { grub_util_error (_("cannot open `%s': %s"), arguments.input, @@ -185,7 +185,7 @@ main (int argc, char *argv[]) inpfull = xasprintf ("(host)/%s", t); free (t); - t = canonicalize_file_name (arguments.root ? : "/"); + t = grub_canonicalize_file_name (arguments.root ? : "/"); if (!t) { grub_util_error (_("cannot open `%s': %s"), arguments.root, @@ -206,7 +206,7 @@ main (int argc, char *argv[]) cwd = xstrdup ("."); } - t = canonicalize_file_name (arguments.cwd ? : cwd); + t = grub_canonicalize_file_name (arguments.cwd ? : cwd); if (!t) { grub_util_error (_("cannot open `%s': %s"), arguments.root, diff --git a/util/probe.c b/util/probe.c index c389f5dcf..fa7ca34d1 100644 --- a/util/probe.c +++ b/util/probe.c @@ -73,7 +73,7 @@ grub_util_guess_bios_drive (const char *orig_path) { char *canon; char *ptr; - canon = canonicalize_file_name (orig_path); + canon = grub_canonicalize_file_name (orig_path); if (!canon) return NULL; ptr = strrchr (orig_path, '/'); @@ -102,7 +102,7 @@ grub_util_guess_efi_drive (const char *orig_path) { char *canon; char *ptr; - canon = canonicalize_file_name (orig_path); + canon = grub_canonicalize_file_name (orig_path); if (!canon) return NULL; ptr = strrchr (orig_path, '/'); @@ -131,7 +131,7 @@ grub_util_guess_baremetal_drive (const char *orig_path) { char *canon; char *ptr; - canon = canonicalize_file_name (orig_path); + canon = grub_canonicalize_file_name (orig_path); if (!canon) return NULL; ptr = strrchr (orig_path, '/'); diff --git a/util/render-label.c b/util/render-label.c index 39663a8a7..91c080c9c 100644 --- a/util/render-label.c +++ b/util/render-label.c @@ -157,7 +157,7 @@ grub_util_render_label (const char *label_font, ieee1275_palette[cptr].a = 0xff; char * t; - t = canonicalize_file_name (label_font); + t = grub_canonicalize_file_name (label_font); if (!t) { grub_util_error (_("cannot open `%s': %s"), label_font, From 5959b15c1cf2113999968291e0723337888d4979 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Wed, 4 Mar 2015 01:01:45 +0100 Subject: [PATCH 355/722] configure.ac: Fix the name of pciaccess header. --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 2200776d3..891c14ff3 100644 --- a/configure.ac +++ b/configure.ac @@ -1302,7 +1302,7 @@ fi [fi] [if [ x"$grub_emu_pci_excuse" = x ]; then # Check for headers.] - AC_CHECK_HEADERS([pci/pci.h], [], + AC_CHECK_HEADERS([pciaccess.h], [], [grub_emu_pci_excuse=["need libpciaccess headers"]]) [fi] From dc06aa949b7ff25cec78e6c415a65b444c11d8d9 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Wed, 4 Mar 2015 14:19:29 +0100 Subject: [PATCH 356/722] syslinux_parse: Fix the case of unknown localboot. Reported by: Jordan Uggla --- grub-core/lib/syslinux_parse.c | 1 + 1 file changed, 1 insertion(+) diff --git a/grub-core/lib/syslinux_parse.c b/grub-core/lib/syslinux_parse.c index afc12b502..22389eb97 100644 --- a/grub-core/lib/syslinux_parse.c +++ b/grub-core/lib/syslinux_parse.c @@ -945,6 +945,7 @@ write_entry (struct output_buffer *outbuf, break; } print_string (" # UNSUPPORTED localboot type "); + print_string ("\ntrue;\n"); if (print_num (outbuf, n)) return grub_errno; print_string ("\n"); From 20f21d897858d827210d67c75f42d18887cbce81 Mon Sep 17 00:00:00 2001 From: Andrey Borzenkov Date: Thu, 5 Mar 2015 19:25:56 +0300 Subject: [PATCH 357/722] update m4/extern-inline.m4 to upstream version to fix compilation on FreeBSD In file included from util/grub-mkimage.c:54:0: ./grub-core/gnulib/argp.h:627:49: error: '__sbistype' is static but used in inline function '_option_is_short' which is not static [-Werror] cc1: all warnings being treated as errors gmake[2]: *** [util/grub_mkimage-grub-mkimage.o] Error 1 Update m4/extern-inline.m4 to current upstream gnulib version that contains fix for this (commit b9bfe78424b871f5b92e5ee9e7d21ef951a6801d). Reported-By: Beeblebrox --- m4/extern-inline.m4 | 71 +++++++++++++++++++++++++++++++++------------ 1 file changed, 53 insertions(+), 18 deletions(-) diff --git a/m4/extern-inline.m4 b/m4/extern-inline.m4 index 0152f2932..e74339a16 100644 --- a/m4/extern-inline.m4 +++ b/m4/extern-inline.m4 @@ -1,6 +1,6 @@ dnl 'extern inline' a la ISO C99. -dnl Copyright 2012-2013 Free Software Foundation, Inc. +dnl Copyright 2012-2015 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. @@ -8,42 +8,77 @@ dnl with or without modifications, as long as this notice is preserved. AC_DEFUN([gl_EXTERN_INLINE], [ AH_VERBATIM([extern_inline], -[/* _GL_INLINE is a portable alternative to ISO C99 plain 'inline'. - _GL_EXTERN_INLINE is a portable alternative to 'extern inline'. - _GL_INLINE_HEADER_BEGIN contains useful stuff to put - in an include file, before uses of _GL_INLINE. - It suppresses GCC's bogus "no previous prototype for 'FOO'" diagnostic, - when FOO is an inline function in the header; see - . - _GL_INLINE_HEADER_END contains useful stuff to put - in the same include file, after uses of _GL_INLINE. +[/* Please see the Gnulib manual for how to use these macros. Suppress extern inline with HP-UX cc, as it appears to be broken; see . - Suppress the use of extern inline on Apple's platforms, - as Libc-825.25 (2012-09-19) is incompatible with it; see - . - Perhaps Apple will fix this some day. */ + Suppress extern inline with Sun C in standards-conformance mode, as it + mishandles inline functions that call each other. E.g., for 'inline void f + (void) { } inline void g (void) { f (); }', c99 incorrectly complains + 'reference to static identifier "f" in extern inline function'. + This bug was observed with Sun C 5.12 SunOS_i386 2011/11/16. + + Suppress extern inline (with or without __attribute__ ((__gnu_inline__))) + on configurations that mistakenly use 'static inline' to implement + functions or macros in standard C headers like . For example, + if isdigit is mistakenly implemented via a static inline function, + a program containing an extern inline function that calls isdigit + may not work since the C standard prohibits extern inline functions + from calling static functions. This bug is known to occur on: + + OS X 10.8 and earlier; see: + http://lists.gnu.org/archive/html/bug-gnulib/2012-12/msg00023.html + + DragonFly; see + http://muscles.dragonflybsd.org/bulk/bleeding-edge-potential/latest-per-pkg/ah-tty-0.3.12.log + + FreeBSD; see: + http://lists.gnu.org/archive/html/bug-gnulib/2014-07/msg00104.html + + OS X 10.9 has a macro __header_inline indicating the bug is fixed for C and + for clang but remains for g++; see . + Assume DragonFly and FreeBSD will be similar. */ +#if (((defined __APPLE__ && defined __MACH__) \ + || defined __DragonFly__ || defined __FreeBSD__) \ + && (defined __header_inline \ + ? (defined __cplusplus && defined __GNUC_STDC_INLINE__ \ + && ! defined __clang__) \ + : ((! defined _DONT_USE_CTYPE_INLINE_ \ + && (defined __GNUC__ || defined __cplusplus)) \ + || (defined _FORTIFY_SOURCE && 0 < _FORTIFY_SOURCE \ + && defined __GNUC__ && ! defined __cplusplus)))) +# define _GL_EXTERN_INLINE_STDHEADER_BUG +#endif #if ((__GNUC__ \ ? defined __GNUC_STDC_INLINE__ && __GNUC_STDC_INLINE__ \ - : 199901L <= __STDC_VERSION__ && !defined __HP_cc) \ - && !defined __APPLE__) + : (199901L <= __STDC_VERSION__ \ + && !defined __HP_cc \ + && !(defined __SUNPRO_C && __STDC__))) \ + && !defined _GL_EXTERN_INLINE_STDHEADER_BUG) # define _GL_INLINE inline # define _GL_EXTERN_INLINE extern inline -#elif 2 < __GNUC__ + (7 <= __GNUC_MINOR__) && !defined __APPLE__ -# if __GNUC_GNU_INLINE__ +# define _GL_EXTERN_INLINE_IN_USE +#elif (2 < __GNUC__ + (7 <= __GNUC_MINOR__) && !defined __STRICT_ANSI__ \ + && !defined _GL_EXTERN_INLINE_STDHEADER_BUG) +# if defined __GNUC_GNU_INLINE__ && __GNUC_GNU_INLINE__ /* __gnu_inline__ suppresses a GCC 4.2 diagnostic. */ # define _GL_INLINE extern inline __attribute__ ((__gnu_inline__)) # else # define _GL_INLINE extern inline # endif # define _GL_EXTERN_INLINE extern +# define _GL_EXTERN_INLINE_IN_USE #else # define _GL_INLINE static _GL_UNUSED # define _GL_EXTERN_INLINE static _GL_UNUSED #endif +/* In GCC, suppress bogus "no previous prototype for 'FOO'" + and "no previous declaration for 'FOO'" diagnostics, + when FOO is an inline function in the header; see + and + . */ #if 4 < __GNUC__ + (6 <= __GNUC_MINOR__) # if defined __GNUC_STDC_INLINE__ && __GNUC_STDC_INLINE__ # define _GL_INLINE_HEADER_CONST_PRAGMA From 8842991a56f062c6bff03da9c2f7dcffa7e31492 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Thu, 5 Mar 2015 20:19:47 +0300 Subject: [PATCH 358/722] update gnulib/argp-help.c to fix garbage in grub-mknetdir --help output MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit argp_help attempts to translate empty string, which results in printing meta information about translation, like in bor@opensuse:~/build/grub> grub2-mknetdir --help ИÑпользование: grub2-mknetdir [ПÐРÐМЕТР…] Project-Id-Version: grub 2.02-pre2 Report-Msgid-Bugs-To: bug-grub@gnu.org ... Update gnulib/argp-help.c to the current version which fixes this (commit b9bfe78424b871f5b92e5ee9e7d21ef951a6801d). --- grub-core/gnulib/argp-help.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/grub-core/gnulib/argp-help.c b/grub-core/gnulib/argp-help.c index 2914f4723..b9be63f40 100644 --- a/grub-core/gnulib/argp-help.c +++ b/grub-core/gnulib/argp-help.c @@ -1,5 +1,5 @@ /* Hierarchical argument parsing help output - Copyright (C) 1995-2005, 2007, 2009-2013 Free Software Foundation, Inc. + Copyright (C) 1995-2005, 2007, 2009-2015 Free Software Foundation, Inc. This file is part of the GNU C Library. Written by Miles Bader . @@ -650,7 +650,7 @@ hol_find_entry (struct hol *hol, const char *name) return 0; } -/* If an entry with the long option NAME occurs in HOL, set it's special +/* If an entry with the long option NAME occurs in HOL, set its special sort position to GROUP. */ static void hol_set_group (struct hol *hol, const char *name, int group) @@ -1507,11 +1507,15 @@ argp_doc (const struct argp *argp, const struct argp_state *state, if (vt) { if (post) - inp_text = vt + 1; + { + inp_text = vt + 1; + if (! *inp_text) + inp_text = 0; + } else { inp_text_len = vt - argp->doc; - inp_text = __strndup (argp->doc, inp_text_len); + inp_text = inp_text_len ? __strndup (argp->doc, inp_text_len) : 0; } } else From be41c1cf11313bc433eaad4792f1e5a90d30e5b5 Mon Sep 17 00:00:00 2001 From: Jon McCune Date: Fri, 6 Mar 2015 00:33:41 +0100 Subject: [PATCH 359/722] autogen.sh: Allow overriding the python to be used by setting $PYTHON. Some installations have several python versions installed. Allow user to choose which one to use by setting $PYTHON. --- INSTALL | 3 +++ autogen.sh | 11 +++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/INSTALL b/INSTALL index 846ac38df..e5b081105 100644 --- a/INSTALL +++ b/INSTALL @@ -104,6 +104,9 @@ The simplest way to compile this package is: 3. Type `./autogen.sh'. + * autogen.sh uses python. By default invocation is "python" but can be + overriden by setting variable $PYTHON. + 4. Type `./configure' to configure the package for your system. If you're using `csh' on an old version of System V, you might need to type `sh ./configure' instead to prevent `csh' from trying diff --git a/autogen.sh b/autogen.sh index 7424428d6..5020456bc 100755 --- a/autogen.sh +++ b/autogen.sh @@ -2,6 +2,9 @@ set -e +# Set ${PYTHON} to plain 'python' if not set already +: ${PYTHON:=python} + export LC_COLLATE=C unset LC_ALL @@ -9,10 +12,10 @@ find . -iname '*.[ch]' ! -ipath './grub-core/lib/libgcrypt-grub/*' ! -ipath './b find util -iname '*.in' ! -name Makefile.in |sort > po/POTFILES-shell.in echo "Importing unicode..." -python util/import_unicode.py unicode/UnicodeData.txt unicode/BidiMirroring.txt unicode/ArabicShaping.txt grub-core/unidata.c +${PYTHON} util/import_unicode.py unicode/UnicodeData.txt unicode/BidiMirroring.txt unicode/ArabicShaping.txt grub-core/unidata.c echo "Importing libgcrypt..." -python util/import_gcry.py grub-core/lib/libgcrypt/ grub-core +${PYTHON} util/import_gcry.py grub-core/lib/libgcrypt/ grub-core sed -n -f util/import_gcrypth.sed < grub-core/lib/libgcrypt/src/gcrypt.h.in > include/grub/gcrypt/gcrypt.h if [ -f include/grub/gcrypt/g10lib.h ]; then rm include/grub/gcrypt/g10lib.h @@ -54,8 +57,8 @@ for extra in contrib/*/Makefile.core.def; do fi done -python gentpl.py $UTIL_DEFS > Makefile.util.am -python gentpl.py $CORE_DEFS > grub-core/Makefile.core.am +${PYTHON} gentpl.py $UTIL_DEFS > Makefile.util.am +${PYTHON} gentpl.py $CORE_DEFS > grub-core/Makefile.core.am for extra in contrib/*/Makefile.common; do if test -e "$extra"; then From 5fe21c996893b9ef4d22a728b40f75d4b4cd7566 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 6 Mar 2015 22:33:20 +0100 Subject: [PATCH 360/722] hfsplus: Fix potential access to uninited memory on invalid FS --- grub-core/fs/hfsplus.c | 6 ++++++ include/grub/hfsplus.h | 14 +++++++++----- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/grub-core/fs/hfsplus.c b/grub-core/fs/hfsplus.c index 8f07f8544..110d85815 100644 --- a/grub-core/fs/hfsplus.c +++ b/grub-core/fs/hfsplus.c @@ -336,6 +336,9 @@ grub_hfsplus_mount (grub_disk_t disk) data->case_sensitive = ((magic == GRUB_HFSPLUSX_MAGIC) && (header.key_compare == GRUB_HFSPLUSX_BINARYCOMPARE)); + if (data->catalog_tree.nodesize < 2) + goto fail; + if (grub_hfsplus_read_file (&data->extoverflow_tree.file, 0, 0, sizeof (struct grub_hfsplus_btnode), sizeof (header), (char *) &header) <= 0) @@ -350,6 +353,9 @@ grub_hfsplus_mount (grub_disk_t disk) data->extoverflow_tree.root = grub_be_to_cpu32 (header.root); data->extoverflow_tree.nodesize = grub_be_to_cpu16 (header.nodesize); + if (data->extoverflow_tree.nodesize < 2) + goto fail; + if (grub_hfsplus_read_file (&data->attr_tree.file, 0, 0, sizeof (struct grub_hfsplus_btnode), sizeof (header), (char *) &header) <= 0) diff --git a/include/grub/hfsplus.h b/include/grub/hfsplus.h index 8ba8f3246..117740ae2 100644 --- a/include/grub/hfsplus.h +++ b/include/grub/hfsplus.h @@ -171,7 +171,7 @@ struct grub_hfsplus_catkey grub_uint16_t keylen; grub_uint32_t parent; grub_uint16_t namelen; - grub_uint16_t name[30]; + grub_uint16_t name[0]; } GRUB_PACKED; /* The on disk layout of an extent overflow file key. */ @@ -207,12 +207,14 @@ struct grub_hfsplus_btnode /* Return the offset of the record with the index INDEX, in the node NODE which is part of the B+ tree BTREE. */ -static inline grub_off_t +static inline grub_uint16_t grub_hfsplus_btree_recoffset (struct grub_hfsplus_btree *btree, - struct grub_hfsplus_btnode *node, int index) + struct grub_hfsplus_btnode *node, unsigned index) { char *cnode = (char *) node; void *recptr; + if (btree->nodesize < index * sizeof (grub_uint16_t) + 2) + index = 0; recptr = (&cnode[btree->nodesize - index * sizeof (grub_uint16_t) - 2]); return grub_be_to_cpu16 (grub_get_unaligned16 (recptr)); } @@ -221,11 +223,13 @@ grub_hfsplus_btree_recoffset (struct grub_hfsplus_btree *btree, NODE which is part of the B+ tree BTREE. */ static inline struct grub_hfsplus_key * grub_hfsplus_btree_recptr (struct grub_hfsplus_btree *btree, - struct grub_hfsplus_btnode *node, int index) + struct grub_hfsplus_btnode *node, unsigned index) { char *cnode = (char *) node; - grub_off_t offset; + grub_uint16_t offset; offset = grub_hfsplus_btree_recoffset (btree, node, index); + if (offset > btree->nodesize - sizeof (struct grub_hfsplus_key)) + offset = 0; return (struct grub_hfsplus_key *) &cnode[offset]; } From fa07d919d1ff868b18d8a42276d094b63a58e299 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sun, 15 Mar 2015 21:06:26 +0300 Subject: [PATCH 361/722] grub-fs-tester: better estimation of filesystem time for LVM/RAID Write activity with LVM/RAID can happen after filesystem is unmounted. In my testing modification time of loop files was 15 - 20 seconds after unmount. So use time as close to unmount as possible as reference instead. --- tests/util/grub-fs-tester.in | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/util/grub-fs-tester.in b/tests/util/grub-fs-tester.in index 9ecbe0fd6..4f7f9203a 100644 --- a/tests/util/grub-fs-tester.in +++ b/tests/util/grub-fs-tester.in @@ -993,6 +993,7 @@ for ((LOGSECSIZE=MINLOGSECSIZE;LOGSECSIZE<=MAXLOGSECSIZE;LOGSECSIZE=LOGSECSIZE + fi sleep 1; done + UMOUNT_TIME=$(date -u "+%Y-%m-%d %H:%M:%S") sleep 1 vgchange -a n grub_test ;; @@ -1004,6 +1005,7 @@ for ((LOGSECSIZE=MINLOGSECSIZE;LOGSECSIZE<=MAXLOGSECSIZE;LOGSECSIZE=LOGSECSIZE + fi sleep 1; done + UMOUNT_TIME=$(date -u "+%Y-%m-%d %H:%M:%S") sleep 1 mdadm --stop /dev/md/"${fs}_$NDEVICES" ;; @@ -1214,10 +1216,15 @@ for ((LOGSECSIZE=MINLOGSECSIZE;LOGSECSIZE<=MAXLOGSECSIZE;LOGSECSIZE=LOGSECSIZE + case x$fs in xiso9660 | xziso9660 | xrockridge | xjoliet | xrockridge_joliet | xiso9660_1999 | xrockridge_1999 | xjoliet_1999 | xrockridge_joliet_1999) FSTIME="$(date -d "$(echo ${FSUUID} | awk -F - '{ print $1"-"$2"-"$3" "$4":"$5":"$6 ;}')" '+%Y-%m-%d %H:%M:%S')";; + xlvm*|xmdraid*) + # With some abstractions like mdraid flushing to disk + # may be delayed for a long time. + FSTIME="$UMOUNT_TIME";; *) FSTIME="$(TZ=UTC ls --time-style="+%Y-%m-%d_%H:%M:%S" -l -d "${FSIMAGES[0]}"|awk '{print $6; }'|sed 's,_, ,g')";; esac - # With some abstractions like mdraid it may take up to 2 seconds for the data to reach the disks after it was flushed by FS in these tests. + # With some abstractions like mdraid computing of UMOUNT_TIME + # is not precise. Account for small difference here. FSTIMEM1="$(date -d "$FSTIME UTC -1 second" -u "+%Y-%m-%d %H:%M:%S")" FSTIMEM2="$(date -d "$FSTIME UTC -2 second" -u "+%Y-%m-%d %H:%M:%S")" From 7c9309e50a124817e67de38b30c6291acecad560 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Mon, 16 Mar 2015 21:16:19 +0300 Subject: [PATCH 362/722] grub-fs-tester: explicitly set segment type for LVM mirror LVM mirror defaults to RAID1 today and can be different on different systems as set in lvm.conf. --- tests/util/grub-fs-tester.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/util/grub-fs-tester.in b/tests/util/grub-fs-tester.in index 4f7f9203a..f63ed0b08 100644 --- a/tests/util/grub-fs-tester.in +++ b/tests/util/grub-fs-tester.in @@ -729,9 +729,9 @@ for ((LOGSECSIZE=MINLOGSECSIZE;LOGSECSIZE<=MAXLOGSECSIZE;LOGSECSIZE=LOGSECSIZE + elif [ x$fs = xlvm_stripe ] ; then lvcreate -l "$((NDEVICES*7*LVMBLKMUL))" -i "$NDEVICES" -n testvol grub_test elif [ x$fs = xlvm_mirror1 ] ; then - lvcreate -m 1 -l "$((NDEVICES*2*LVMBLKMUL))" -n testvol grub_test + lvcreate -m 1 -l "$((NDEVICES*2*LVMBLKMUL))" --type mirror -n testvol grub_test elif [ x$fs = xlvm_mirrorall ] ; then - lvcreate -m "$((NDEVICES-1))" -l "$((6*LVMBLKMUL))" -n testvol grub_test + lvcreate -m "$((NDEVICES-1))" -l "$((6*LVMBLKMUL))" --type mirror -n testvol grub_test elif [ x$fs = xlvm_raid4 ] || [ x$fs = xlvm_raid5 ]; then lvcreate -l "$(((NDEVICES-1) * 5*LVMBLKMUL))" -i "$((NDEVICES-1))" --type "${fs/lvm_/}" -n testvol grub_test elif [ x$fs = xlvm_raid6 ]; then From 527eeeeee6c8d3d8e3bb1fac408d47bb1dcbec95 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Thu, 19 Mar 2015 21:30:27 +0300 Subject: [PATCH 363/722] core: add LVM RAID1 support Closes 44534. --- grub-core/disk/lvm.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/grub-core/disk/lvm.c b/grub-core/disk/lvm.c index 1e7f197f0..9b97004d8 100644 --- a/grub-core/disk/lvm.c +++ b/grub-core/disk/lvm.c @@ -577,13 +577,17 @@ grub_lvm_detect (grub_disk_t disk, if (is_pvmove) seg->node_count = 1; } - else if (grub_memcmp (p, "raid", sizeof ("raid") - 1) - == 0 && (p[sizeof ("raid") - 1] >= '4' - && p[sizeof ("raid") - 1] <= '6') + else if (grub_memcmp (p, "raid", sizeof ("raid") - 1) == 0 + && ((p[sizeof ("raid") - 1] >= '4' + && p[sizeof ("raid") - 1] <= '6') + || p[sizeof ("raid") - 1] == '1') && p[sizeof ("raidX") - 1] == '"') { switch (p[sizeof ("raid") - 1]) { + case '1': + seg->type = GRUB_DISKFILTER_MIRROR; + break; case '4': seg->type = GRUB_DISKFILTER_RAID4; seg->layout = GRUB_RAID_LAYOUT_LEFT_ASYMMETRIC; @@ -608,16 +612,18 @@ grub_lvm_detect (grub_disk_t disk, goto lvs_segment_fail; } - seg->stripe_size = grub_lvm_getvalue (&p, "stripe_size = "); - if (p == NULL) + if (seg->type != GRUB_DISKFILTER_MIRROR) { + seg->stripe_size = grub_lvm_getvalue (&p, "stripe_size = "); + if (p == NULL) + { #ifdef GRUB_UTIL - grub_util_info ("unknown stripe_size\n"); + grub_util_info ("unknown stripe_size\n"); #endif - goto lvs_segment_fail; + goto lvs_segment_fail; + } } - seg->nodes = grub_zalloc (sizeof (seg->nodes[0]) * seg->node_count); @@ -625,7 +631,7 @@ grub_lvm_detect (grub_disk_t disk, if (p == NULL) { #ifdef GRUB_UTIL - grub_util_info ("unknown mirrors\n"); + grub_util_info ("unknown raids\n"); #endif goto lvs_segment_fail2; } From 19c4156d1694e3ab82e412d280d1d6677b711d2c Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Thu, 19 Mar 2015 21:31:26 +0300 Subject: [PATCH 364/722] grub-fs-tester: add LVM RAID1 support LVM miscalculates bitmap size with small extent, so start with 16K as for other RAID types. Until version 2.02.103 LVM counts metadata segments twice when checking available space, reduce segment count by one to account for this bug. --- tests/util/grub-fs-tester.in | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/tests/util/grub-fs-tester.in b/tests/util/grub-fs-tester.in index f63ed0b08..e9e85c2a8 100644 --- a/tests/util/grub-fs-tester.in +++ b/tests/util/grub-fs-tester.in @@ -102,7 +102,7 @@ for ((LOGSECSIZE=MINLOGSECSIZE;LOGSECSIZE<=MAXLOGSECSIZE;LOGSECSIZE=LOGSECSIZE + # OS LIMITATION: Linux oopses with >=32768K MAXBLKSIZE=$((16384*1024)) ;; - x"lvm_raid4" | x"lvm_raid5" | x"lvm_raid6") + x"lvm_raid1"* | x"lvm_raid4" | x"lvm_raid5" | x"lvm_raid6") # OS LIMITATION: Linux crashes with less than 16384 MINBLKSIZE=16384 # Could go further but what's the point? @@ -166,7 +166,7 @@ for ((LOGSECSIZE=MINLOGSECSIZE;LOGSECSIZE<=MAXLOGSECSIZE;LOGSECSIZE=LOGSECSIZE + x"zfs_raidz" | x"zfs_stripe" | x"zfs_mirror" | xbtrfs_raid0 \ | xbtrfs_raid1 | x"mdraid"*"_raid4" | x"mdraid"*"_raid5" \ | x"mdraid"*"_linear" \ - | x"mdraid"*"_raid10" | xlvm_mirror1 | xlvm_mirrorall) + | x"mdraid"*"_raid10" | xlvm_raid1* | xlvm_mirror1 | xlvm_mirrorall) MINDEVICES=2 MAXDEVICES=7 ;; @@ -199,7 +199,7 @@ for ((LOGSECSIZE=MINLOGSECSIZE;LOGSECSIZE<=MAXLOGSECSIZE;LOGSECSIZE=LOGSECSIZE + case x$fs in # RAID 1 has to work with even one device of the set. - xzfs_mirror | x"mdraid"*"_raid1" | xlvm_mirrorall) + xzfs_mirror | x"mdraid"*"_raid1" | xlvm_mirrorall | xlvm_raid1all) NEED_IMAGES_N=1;; # Degrade raidz by removing 3 devices xzfs_raidz3) @@ -210,7 +210,7 @@ for ((LOGSECSIZE=MINLOGSECSIZE;LOGSECSIZE<=MAXLOGSECSIZE;LOGSECSIZE=LOGSECSIZE + # Degrade raidz and btrfs RAID1 by removing one device xbtrfs_raid1 | xbtrfs_raid10 | xzfs_raidz | x"mdraid"*"_raid4" \ | x"mdraid"*"_raid5" | x"mdraid"*"_raid10" | xlvm_mirror1 \ - | x"lvm_raid4" | x"lvm_raid5") + | x"lvm_raid1" | x"lvm_raid4" | x"lvm_raid5") NEED_IMAGES_N=$((NDEVICES-1));; *) NEED_IMAGES_N=$NDEVICES;; @@ -728,10 +728,15 @@ for ((LOGSECSIZE=MINLOGSECSIZE;LOGSECSIZE<=MAXLOGSECSIZE;LOGSECSIZE=LOGSECSIZE + lvcreate -l "$((NDEVICES*7*LVMBLKMUL))" -n testvol grub_test elif [ x$fs = xlvm_stripe ] ; then lvcreate -l "$((NDEVICES*7*LVMBLKMUL))" -i "$NDEVICES" -n testvol grub_test - elif [ x$fs = xlvm_mirror1 ] ; then - lvcreate -m 1 -l "$((NDEVICES*2*LVMBLKMUL))" --type mirror -n testvol grub_test + elif [ x$fs = xlvm_mirror1 ] || [ x$fs = xlvm_raid1 ] ; then + lvcreate -m 1 -l "$((NDEVICES*2*LVMBLKMUL))" --type "${fs/lvm_/}" -n testvol grub_test elif [ x$fs = xlvm_mirrorall ] ; then lvcreate -m "$((NDEVICES-1))" -l "$((6*LVMBLKMUL))" --type mirror -n testvol grub_test + elif [ x$fs = xlvm_raid1all ] ; then + # Until version 2.02.103 LVM counts metadata segments + # twice when checking available space. Reduce segment + # count to work around it. + lvcreate -m "$((NDEVICES-1))" -l "$((6*LVMBLKMUL - 1))" --type raid1 -n testvol grub_test elif [ x$fs = xlvm_raid4 ] || [ x$fs = xlvm_raid5 ]; then lvcreate -l "$(((NDEVICES-1) * 5*LVMBLKMUL))" -i "$((NDEVICES-1))" --type "${fs/lvm_/}" -n testvol grub_test elif [ x$fs = xlvm_raid6 ]; then From 9c07daaf917ddbcb738233aa1d3a209b179f3444 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 20 Mar 2015 11:13:58 +0100 Subject: [PATCH 365/722] cacheinfo: Add missing license information. --- grub-core/commands/cacheinfo.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/grub-core/commands/cacheinfo.c b/grub-core/commands/cacheinfo.c index ead6ff82c..d34a34696 100644 --- a/grub-core/commands/cacheinfo.c +++ b/grub-core/commands/cacheinfo.c @@ -23,6 +23,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + static grub_err_t grub_rescue_cmd_info (struct grub_command *cmd __attribute__ ((unused)), int argc __attribute__ ((unused)), From cf47a2fba5852014bc59959c5e357e8313933414 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 20 Mar 2015 12:55:27 +0100 Subject: [PATCH 366/722] grub-mkrescue: pass all unrecognized options unchanged to xorriso. --- util/grub-mkrescue.c | 103 +++++++++++++++++++++++++++++++++++++------ 1 file changed, 89 insertions(+), 14 deletions(-) diff --git a/util/grub-mkrescue.c b/util/grub-mkrescue.c index e02340f06..5d3ec0d4e 100644 --- a/util/grub-mkrescue.c +++ b/util/grub-mkrescue.c @@ -44,9 +44,6 @@ static char *label_color; static char *label_bgcolor; static char *product_name; static char *product_version; -static int xorriso_tail_argc; -static int xorriso_tail_arg_alloc; -static char **xorriso_tail_argv; static char *output_image; static char *xorriso; static char *boot_grub; @@ -215,16 +212,6 @@ argp_parser (int key, char *arg, struct argp_state *state) xorriso = xstrdup (arg); return 0; - case ARGP_KEY_ARG: - if (xorriso_tail_arg_alloc <= xorriso_tail_argc) - { - xorriso_tail_arg_alloc = 2 * (4 + xorriso_tail_argc); - xorriso_tail_argv = xrealloc (xorriso_tail_argv, - sizeof (xorriso_tail_argv[0]) - * xorriso_tail_arg_alloc); - } - xorriso_tail_argv[xorriso_tail_argc++] = xstrdup (arg); - return 0; default: return ARGP_ERR_UNKNOWN; } @@ -374,12 +361,70 @@ make_image_fwdisk (enum grub_install_plat plat, free (out); } +static int +option_is_end (const struct argp_option *opt) +{ + return !opt->key && !opt->name && !opt->doc && !opt->group; +} + + +static int +args_to_eat (const char *arg) +{ + int j; + + if (arg[0] != '-') + return 0; + + if (arg[1] == '-') + { + for (j = 0; !option_is_end(&options[j]); j++) + { + size_t len = strlen (options[j].name); + if (strncmp (arg + 2, options[j].name, len) == 0) + { + if (arg[2 + len] == '=') + return 1; + if (arg[2 + len] == '\0' && options[j].arg) + return 2; + if (arg[2 + len] == '\0') + return 1; + } + } + if (strcmp (arg, "--help") == 0) + return 1; + if (strcmp (arg, "--usage") == 0) + return 1; + if (strcmp (arg, "--version") == 0) + return 1; + return 0; + } + if (arg[2] && arg[3]) + return 0; + for (j = 0; !option_is_end(&options[j]); j++) + { + if (options[j].key > 0 && options[j].key < 128 && arg[1] == options[j].key) + { + if (options[j].arg) + return 2; + return 1; + } + if (arg[1] == '?' || arg[1] == 'V') + return 1; + } + return 0; +} + int main (int argc, char *argv[]) { char *romdir; char *sysarea_img = NULL; const char *pkgdatadir; + int argp_argc; + char **argp_argv; + int xorriso_tail_argc; + char **xorriso_tail_argv; grub_util_host_init (&argc, &argv); grub_util_disable_fd_syncs (); @@ -391,7 +436,37 @@ main (int argc, char *argv[]) xorriso = xstrdup ("xorriso"); label_font = grub_util_path_concat (2, pkgdatadir, "unicode.pf2"); - argp_parse (&argp, argc, argv, 0, 0, 0); + argp_argv = xmalloc (sizeof (argp_argv[0]) * argc); + xorriso_tail_argv = xmalloc (sizeof (argp_argv[0]) * argc); + + xorriso_tail_argc = 0; + /* Program name */ + argp_argv[0] = argv[0]; + argp_argc = 1; + + /* argp doesn't allow us to catch unknwon arguments, + so catch them before passing to argp + */ + { + int i; + for (i = 1; i < argc; i++) + { + switch (args_to_eat (argv[i])) + { + case 2: + argp_argv[argp_argc++] = argv[i++]; + /* Fallthrough */ + case 1: + argp_argv[argp_argc++] = argv[i]; + break; + case 0: + xorriso_tail_argv[xorriso_tail_argc++] = argv[i]; + break; + } + } + } + + argp_parse (&argp, argp_argc, argp_argv, 0, 0, 0); if (!output_image) grub_util_error ("%s", _("output file must be specified")); From 237510486af6e2d73fa57075f72b407d24ad8874 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 20 Mar 2015 12:58:08 +0100 Subject: [PATCH 367/722] fddboot_test: Add -no-pad to xorriso. --- tests/fddboot_test.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/fddboot_test.in b/tests/fddboot_test.in index a05eb3e75..a59645b7f 100644 --- a/tests/fddboot_test.in +++ b/tests/fddboot_test.in @@ -46,6 +46,6 @@ case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in exit 0;; esac -if [ "$(echo hello | "${grubshell}" --boot=fd --mkrescue-arg="--compress=xz --fonts= --locales= --themes=")" != "Hello World" ]; then +if [ "$(echo hello | "${grubshell}" --boot=fd --mkrescue-arg="--compress=xz --fonts= --locales= --themes= -no-pad")" != "Hello World" ]; then exit 1 fi From fe6695b7d6cd8beae55981b5efbd21f592a0afc0 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 20 Mar 2015 12:59:00 +0100 Subject: [PATCH 368/722] emunet: Fix init error checking. Otherwise emunet doesn't expose any cards. --- grub-core/net/drivers/emu/emunet.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/net/drivers/emu/emunet.c b/grub-core/net/drivers/emu/emunet.c index 7c977cd52..b19492086 100644 --- a/grub-core/net/drivers/emu/emunet.c +++ b/grub-core/net/drivers/emu/emunet.c @@ -98,7 +98,7 @@ static int registered = 0; GRUB_MOD_INIT(emunet) { - if (grub_emunet_create (&emucard.mtu)) + if (!grub_emunet_create (&emucard.mtu)) { grub_net_card_register (&emucard); registered = 1; From e9f68f1f4cc1a07d94d200f1e7bdcfb1c4d7e40d Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 20 Mar 2015 13:00:53 +0100 Subject: [PATCH 369/722] compiler-rt-emu: Add missing file. --- include/grub/compiler-rt-emu.h | 235 +++++++++++++++++++++++++++++++++ 1 file changed, 235 insertions(+) create mode 100644 include/grub/compiler-rt-emu.h diff --git a/include/grub/compiler-rt-emu.h b/include/grub/compiler-rt-emu.h new file mode 100644 index 000000000..edc82999e --- /dev/null +++ b/include/grub/compiler-rt-emu.h @@ -0,0 +1,235 @@ +/* compiler-rt-emu.h - prototypes for compiler helpers. */ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2002,2003,2005,2006,2007,2008,2009,2010-2014 Free Software Foundation, Inc. + * + * GRUB is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GRUB is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GRUB. If not, see . + */ + +#ifndef GRUB_COMPILER_RT_HEADER +#define GRUB_COMPILER_RT_HEADER 1 + +#include +#include +#include + +#ifdef HAVE___UDIVSI3 +grub_uint32_t +EXPORT_FUNC (__udivsi3) (grub_uint32_t a, grub_uint32_t b); +#endif + +#ifdef HAVE___UMODSI3 +grub_uint32_t +EXPORT_FUNC (__umodsi3) (grub_uint32_t a, grub_uint32_t b); +#endif + +#ifdef HAVE___DIVSI3 +grub_int32_t +EXPORT_FUNC (__divsi3) (grub_int32_t a, grub_int32_t b); +#endif + +#ifdef HAVE___MODSI3 +grub_int32_t +EXPORT_FUNC (__modsi3) (grub_int32_t a, grub_int32_t b); +#endif + +#ifdef HAVE___DIVDI3 +grub_int64_t +EXPORT_FUNC (__divdi3) (grub_int64_t a, grub_int64_t b); +#endif + +#ifdef HAVE___MODDI3 +grub_int64_t +EXPORT_FUNC (__moddi3) (grub_int64_t a, grub_int64_t b); +#endif + +#ifdef HAVE___UDIVDI3 +grub_uint64_t +EXPORT_FUNC (__udivdi3) (grub_uint64_t a, grub_uint64_t b); +#endif + +#ifdef HAVE___UMODDI3 +grub_uint64_t +EXPORT_FUNC (__umoddi3) (grub_uint64_t a, grub_uint64_t b); +#endif + +#ifdef HAVE___CTZDI2 +unsigned +EXPORT_FUNC (__ctzdi2) (grub_uint64_t x); +#endif + +#ifdef HAVE___CTZSI2 +unsigned +EXPORT_FUNC (__ctzsi2) (grub_uint32_t x); +#endif + +#ifdef HAVE___AEABI_UIDIV +grub_uint32_t +EXPORT_FUNC (__aeabi_uidiv) (grub_uint32_t a, grub_uint32_t b); +#endif + +#ifdef HAVE___AEABI_UIDIVMOD +grub_uint32_t +EXPORT_FUNC (__aeabi_uidivmod) (grub_uint32_t a, grub_uint32_t b); +#endif + +#ifdef HAVE___AEABI_IDIV +grub_int32_t +EXPORT_FUNC (__aeabi_idiv) (grub_int32_t a, grub_int32_t b); +#endif + +#ifdef HAVE___AEABI_IDIVMOD +grub_int32_t +EXPORT_FUNC (__aeabi_idivmod) (grub_int32_t a, grub_int32_t b); +#endif + +#ifdef HAVE___AEABI_ULCMP +int +EXPORT_FUNC (__aeabi_ulcmp) (grub_uint64_t a, grub_uint64_t b); +#endif + +/* Needed for allowing modules to be compiled as thumb. */ +#ifdef HAVE___MULDI3 +grub_uint64_t +EXPORT_FUNC (__muldi3) (grub_uint64_t a, grub_uint64_t b); +#endif + +#ifdef HAVE___AEABI_LMUL +grub_uint64_t +EXPORT_FUNC (__aeabi_lmul) (grub_uint64_t a, grub_uint64_t b); +#endif + +#ifdef HAVE___AEABI_MEMCPY +void * +EXPORT_FUNC (__aeabi_memcpy) (void *dest, const void *src, grub_size_t n); +#endif + +#ifdef HAVE___AEABI_MEMSET +void * +EXPORT_FUNC(__aeabi_memset) (void *s, int c, grub_size_t n); +#endif + +#ifdef HAVE___AEABI_LASR +grub_uint64_t +EXPORT_FUNC (__aeabi_lasr) (grub_uint64_t u, int b); +#endif + +#ifdef HAVE___AEABI_LLSL +grub_uint64_t +EXPORT_FUNC (__aeabi_llsl) (grub_uint64_t u, int b); +#endif + +#ifdef HAVE___AEABI_LLSR +grub_uint64_t +EXPORT_FUNC (__aeabi_llsr) (grub_uint64_t u, int b); +#endif + + +#ifdef HAVE__RESTGPR_14_X + +void EXPORT_FUNC (_restgpr_14_x) (void); +void EXPORT_FUNC (_restgpr_15_x) (void); +void EXPORT_FUNC (_restgpr_16_x) (void); +void EXPORT_FUNC (_restgpr_17_x) (void); +void EXPORT_FUNC (_restgpr_18_x) (void); +void EXPORT_FUNC (_restgpr_19_x) (void); +void EXPORT_FUNC (_restgpr_20_x) (void); +void EXPORT_FUNC (_restgpr_21_x) (void); +void EXPORT_FUNC (_restgpr_22_x) (void); +void EXPORT_FUNC (_restgpr_23_x) (void); +void EXPORT_FUNC (_restgpr_24_x) (void); +void EXPORT_FUNC (_restgpr_25_x) (void); +void EXPORT_FUNC (_restgpr_26_x) (void); +void EXPORT_FUNC (_restgpr_27_x) (void); +void EXPORT_FUNC (_restgpr_28_x) (void); +void EXPORT_FUNC (_restgpr_29_x) (void); +void EXPORT_FUNC (_restgpr_30_x) (void); +void EXPORT_FUNC (_restgpr_31_x) (void); +void EXPORT_FUNC (_savegpr_14) (void); +void EXPORT_FUNC (_savegpr_15) (void); +void EXPORT_FUNC (_savegpr_16) (void); +void EXPORT_FUNC (_savegpr_17) (void); +void EXPORT_FUNC (_savegpr_18) (void); +void EXPORT_FUNC (_savegpr_19) (void); +void EXPORT_FUNC (_savegpr_20) (void); +void EXPORT_FUNC (_savegpr_21) (void); +void EXPORT_FUNC (_savegpr_22) (void); +void EXPORT_FUNC (_savegpr_23) (void); +void EXPORT_FUNC (_savegpr_24) (void); +void EXPORT_FUNC (_savegpr_25) (void); +void EXPORT_FUNC (_savegpr_26) (void); +void EXPORT_FUNC (_savegpr_27) (void); +void EXPORT_FUNC (_savegpr_28) (void); +void EXPORT_FUNC (_savegpr_29) (void); +void EXPORT_FUNC (_savegpr_30) (void); +void EXPORT_FUNC (_savegpr_31) (void); + +#endif + +#ifdef HAVE___UCMPDI2 +int +EXPORT_FUNC(__ucmpdi2) (grub_uint64_t a, grub_uint64_t b); +#endif + +#ifdef HAVE___ASHLDI3 +grub_uint64_t +EXPORT_FUNC(__ashldi3) (grub_uint64_t u, int b); +#endif + +#ifdef HAVE___ASHRDI3 +grub_uint64_t +EXPORT_FUNC(__ashrdi3) (grub_uint64_t u, int b); +#endif + +#ifdef HAVE___LSHRDI3 +grub_uint64_t +EXPORT_FUNC (__lshrdi3) (grub_uint64_t u, int b); +#endif + +#ifdef HAVE___BSWAPSI2 +grub_uint32_t +EXPORT_FUNC(__bswapsi2) (grub_uint32_t u); +#endif + +#ifdef HAVE___BSWAPDI2 +grub_uint64_t +EXPORT_FUNC(__bswapdi2) (grub_uint64_t u); +#endif + +int EXPORT_FUNC(memcmp) (const void *s1, const void *s2, grub_size_t n); +void *EXPORT_FUNC(memmove) (void *dest, const void *src, grub_size_t n); +void *EXPORT_FUNC(memcpy) (void *dest, const void *src, grub_size_t n); +void *EXPORT_FUNC(memset) (void *s, int c, grub_size_t n); + +#ifdef HAVE___BZERO +void EXPORT_FUNC (__bzero) (void *s, grub_size_t n); +#endif + +#ifdef HAVE___REGISTER_FRAME_INFO +void EXPORT_FUNC (__register_frame_info) (void); +#endif + +#ifdef HAVE___DEREGISTER_FRAME_INFO +void EXPORT_FUNC (__deregister_frame_info) (void); +#endif +#ifdef HAVE____CHKSTK_MS +void EXPORT_FUNC (___chkstk_ms) (void); +#endif + +#ifdef HAVE___CHKSTK_MS +void EXPORT_FUNC (__chkstk_ms) (void); +#endif + +#endif + From 5974d4ba65fc5ad9253857bf992ffd3c635baf2a Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Mon, 23 Mar 2015 14:27:41 +0000 Subject: [PATCH 370/722] hostfs: Drop unnecessary feature test macros _BSD_SOURCE was added to allow the use of DT_DIR, but that was removed in e768b77068a0b030a07576852bd0f121c9a077eb. While adding _DEFAULT_SOURCE as well works around problems with current glibc, neither is in fact needed nowadays. --- grub-core/kern/emu/hostfs.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/grub-core/kern/emu/hostfs.c b/grub-core/kern/emu/hostfs.c index 823116da6..7b28c001f 100644 --- a/grub-core/kern/emu/hostfs.c +++ b/grub-core/kern/emu/hostfs.c @@ -19,11 +19,6 @@ #include -/* Legacy feature macro.*/ -#define _BSD_SOURCE -/* New feature macro that provides everything _BSD_SOURCE and - * _SVID_SOURCE provided and possibly more. */ -#define _DEFAULT_SOURCE #include #include #include From 63034d32612dd34f577605dfa8b417ee9144d8cb Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 20 Mar 2015 21:14:23 +0100 Subject: [PATCH 371/722] arp, icmp: Fix handling in case of oversized or invalid packets. This restrict ARP handling to MAC and IP addresses but in practice we need only this case anyway and other cases are very rar if exist at all. It makes code much simpler and less error-prone. --- grub-core/net/arp.c | 141 ++++++++++++++++++------------------- grub-core/net/icmp.c | 14 +--- grub-core/net/netbuff.c | 20 ++++++ include/grub/net/netbuff.h | 1 + 4 files changed, 90 insertions(+), 86 deletions(-) diff --git a/grub-core/net/arp.c b/grub-core/net/arp.c index 8cc390b0e..46a56e07f 100644 --- a/grub-core/net/arp.c +++ b/grub-core/net/arp.c @@ -37,12 +37,16 @@ enum GRUB_NET_ARPHRD_ETHERNET = 1 }; -struct arphdr { +struct arppkt { grub_uint16_t hrd; grub_uint16_t pro; grub_uint8_t hln; grub_uint8_t pln; grub_uint16_t op; + grub_uint8_t sender_mac[6]; + grub_uint32_t sender_ip; + grub_uint8_t recv_mac[6]; + grub_uint32_t recv_ip; } GRUB_PACKED; static int have_pending; @@ -53,21 +57,14 @@ grub_net_arp_send_request (struct grub_net_network_level_interface *inf, const grub_net_network_level_address_t *proto_addr) { struct grub_net_buff nb; - struct arphdr *arp_header; - grub_net_link_level_address_t target_hw_addr; - grub_uint8_t *aux, arp_data[128]; + struct arppkt *arp_packet; + grub_net_link_level_address_t target_mac_addr; grub_err_t err; int i; - grub_size_t addrlen; - grub_uint16_t etherpro; grub_uint8_t *nbd; + grub_uint8_t arp_data[128]; - if (proto_addr->type == GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV4) - { - addrlen = 4; - etherpro = GRUB_NET_ETHERTYPE_IP; - } - else + if (proto_addr->type != GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV4) return grub_error (GRUB_ERR_BUG, "unsupported address family"); /* Build a request packet. */ @@ -76,34 +73,26 @@ grub_net_arp_send_request (struct grub_net_network_level_interface *inf, grub_netbuff_clear (&nb); grub_netbuff_reserve (&nb, 128); - err = grub_netbuff_push (&nb, sizeof (*arp_header) + 2 * (6 + addrlen)); + err = grub_netbuff_push (&nb, sizeof (*arp_packet)); if (err) return err; - arp_header = (struct arphdr *) nb.data; - arp_header->hrd = grub_cpu_to_be16_compile_time (GRUB_NET_ARPHRD_ETHERNET); - arp_header->hln = 6; - arp_header->pro = grub_cpu_to_be16 (etherpro); - arp_header->pln = addrlen; - arp_header->op = grub_cpu_to_be16_compile_time (ARP_REQUEST); - aux = (grub_uint8_t *) arp_header + sizeof (*arp_header); + arp_packet = (struct arppkt *) nb.data; + arp_packet->hrd = grub_cpu_to_be16_compile_time (GRUB_NET_ARPHRD_ETHERNET); + arp_packet->hln = 6; + arp_packet->pro = grub_cpu_to_be16 (GRUB_NET_ETHERTYPE_IP); + arp_packet->pln = 4; + arp_packet->op = grub_cpu_to_be16_compile_time (ARP_REQUEST); /* Sender hardware address. */ - grub_memcpy (aux, &inf->hwaddress.mac, 6); - - aux += 6; - /* Sender protocol address */ - grub_memcpy (aux, &inf->address.ipv4, 4); - aux += addrlen; - /* Target hardware address */ - for (i = 0; i < 6; i++) - aux[i] = 0x00; - aux += 6; + grub_memcpy (arp_packet->sender_mac, &inf->hwaddress.mac, 6); + arp_packet->sender_ip = inf->address.ipv4; + grub_memset (arp_packet->recv_mac, 0, 6); + arp_packet->recv_ip = proto_addr->ipv4; /* Target protocol address */ - grub_memcpy (aux, &proto_addr->ipv4, 4); - grub_memset (&target_hw_addr.mac, 0xff, 6); + grub_memset (&target_mac_addr.mac, 0xff, 6); nbd = nb.data; - send_ethernet_packet (inf, &nb, target_hw_addr, GRUB_NET_ETHERTYPE_ARP); + send_ethernet_packet (inf, &nb, target_mac_addr, GRUB_NET_ETHERTYPE_ARP); for (i = 0; i < GRUB_NET_TRIES; i++) { if (grub_net_link_layer_resolve_check (inf, proto_addr)) @@ -115,7 +104,7 @@ grub_net_arp_send_request (struct grub_net_network_level_interface *inf, if (grub_net_link_layer_resolve_check (inf, proto_addr)) return GRUB_ERR_NONE; nb.data = nbd; - send_ethernet_packet (inf, &nb, target_hw_addr, GRUB_NET_ETHERTYPE_ARP); + send_ethernet_packet (inf, &nb, target_mac_addr, GRUB_NET_ETHERTYPE_ARP); } return GRUB_ERR_NONE; @@ -125,63 +114,67 @@ grub_err_t grub_net_arp_receive (struct grub_net_buff *nb, struct grub_net_card *card) { - struct arphdr *arp_header = (struct arphdr *) nb->data; - grub_uint8_t *sender_hardware_address; - grub_uint8_t *target_hardware_address; + struct arppkt *arp_packet = (struct arppkt *) nb->data; grub_net_network_level_address_t sender_addr, target_addr; - grub_net_link_level_address_t sender_hw_addr; + grub_net_link_level_address_t sender_mac_addr; struct grub_net_network_level_interface *inf; - grub_uint8_t *sender_protocol_address, *target_protocol_address; - sender_hardware_address = - (grub_uint8_t *) arp_header + sizeof (*arp_header); - sender_protocol_address = sender_hardware_address + arp_header->hln; - target_hardware_address = sender_protocol_address + arp_header->pln; - target_protocol_address = target_hardware_address + arp_header->hln; - if (grub_be_to_cpu16 (arp_header->pro) == GRUB_NET_ETHERTYPE_IP - && arp_header->pln == 4) - { - sender_addr.type = GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV4; - target_addr.type = GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV4; - grub_memcpy (&sender_addr.ipv4, sender_protocol_address, 4); - grub_memcpy (&target_addr.ipv4, target_protocol_address, 4); - if (grub_memcmp (sender_protocol_address, &pending_req, 4) == 0) - have_pending = 1; - } - else + if (arp_packet->pro != grub_cpu_to_be16_compile_time (GRUB_NET_ETHERTYPE_IP) + || arp_packet->pln != 4 || arp_packet->hln != 6 + || nb->tail - nb->data < (int) sizeof (*arp_packet)) return GRUB_ERR_NONE; - sender_hw_addr.type = GRUB_NET_LINK_LEVEL_PROTOCOL_ETHERNET; - grub_memcpy (sender_hw_addr.mac, sender_hardware_address, - sizeof (sender_hw_addr.mac)); - grub_net_link_layer_add_address (card, &sender_addr, &sender_hw_addr, 1); + sender_addr.type = GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV4; + target_addr.type = GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV4; + sender_addr.ipv4 = arp_packet->sender_ip; + target_addr.ipv4 = arp_packet->recv_ip; + if (arp_packet->sender_ip == pending_req) + have_pending = 1; + + sender_mac_addr.type = GRUB_NET_LINK_LEVEL_PROTOCOL_ETHERNET; + grub_memcpy (sender_mac_addr.mac, arp_packet->sender_mac, + sizeof (sender_mac_addr.mac)); + grub_net_link_layer_add_address (card, &sender_addr, &sender_mac_addr, 1); FOR_NET_NETWORK_LEVEL_INTERFACES (inf) { /* Am I the protocol address target? */ if (grub_net_addr_cmp (&inf->address, &target_addr) == 0 - && grub_be_to_cpu16 (arp_header->op) == ARP_REQUEST) + && arp_packet->op == grub_cpu_to_be16_compile_time (ARP_REQUEST)) { grub_net_link_level_address_t target; - /* We've already checked that pln is either 4 or 16. */ - char tmp[16]; - grub_size_t pln = arp_header->pln; + struct grub_net_buff nb_reply; + struct arppkt *arp_reply; + grub_uint8_t arp_data[128]; + grub_err_t err; - if (pln > 16) - pln = 16; + nb_reply.head = arp_data; + nb_reply.end = arp_data + sizeof (arp_data); + grub_netbuff_clear (&nb_reply); + grub_netbuff_reserve (&nb_reply, 128); + + err = grub_netbuff_push (&nb_reply, sizeof (*arp_packet)); + if (err) + return err; + + arp_reply = (struct arppkt *) nb_reply.data; + + arp_reply->hrd = grub_cpu_to_be16_compile_time (GRUB_NET_ARPHRD_ETHERNET); + arp_reply->pro = grub_cpu_to_be16_compile_time (GRUB_NET_ETHERTYPE_IP); + arp_reply->pln = 4; + arp_reply->hln = 6; + arp_reply->op = grub_cpu_to_be16_compile_time (ARP_REPLY); + arp_reply->sender_ip = arp_packet->recv_ip; + arp_reply->recv_ip = arp_packet->sender_ip; + arp_reply->hln = 6; target.type = GRUB_NET_LINK_LEVEL_PROTOCOL_ETHERNET; - grub_memcpy (target.mac, sender_hardware_address, 6); - grub_memcpy (target_hardware_address, target.mac, 6); - grub_memcpy (sender_hardware_address, inf->hwaddress.mac, 6); - - grub_memcpy (tmp, sender_protocol_address, pln); - grub_memcpy (sender_protocol_address, target_protocol_address, pln); - grub_memcpy (target_protocol_address, tmp, pln); + grub_memcpy (target.mac, arp_packet->sender_mac, 6); + grub_memcpy (arp_reply->sender_mac, inf->hwaddress.mac, 6); + grub_memcpy (arp_reply->recv_mac, arp_packet->sender_mac, 6); /* Change operation to REPLY and send packet */ - arp_header->op = grub_be_to_cpu16 (ARP_REPLY); - send_ethernet_packet (inf, nb, target, GRUB_NET_ETHERTYPE_ARP); + send_ethernet_packet (inf, &nb_reply, target, GRUB_NET_ETHERTYPE_ARP); } } return GRUB_ERR_NONE; diff --git a/grub-core/net/icmp.c b/grub-core/net/icmp.c index 28d825ba0..b1eef114e 100644 --- a/grub-core/net/icmp.c +++ b/grub-core/net/icmp.c @@ -85,22 +85,13 @@ grub_net_recv_icmp_packet (struct grub_net_buff *nb, struct icmp_header *icmphr; if (icmph->code) break; - nb_reply = grub_netbuff_alloc (nb->tail - nb->data + 512); + nb_reply = grub_netbuff_make_pkt (nb->tail - nb->data + sizeof (*icmphr)); if (!nb_reply) { grub_netbuff_free (nb); return grub_errno; } - err = grub_netbuff_reserve (nb_reply, nb->tail - nb->data + 512); - if (err) - goto ping_fail; - err = grub_netbuff_push (nb_reply, nb->tail - nb->data); - if (err) - goto ping_fail; - grub_memcpy (nb_reply->data, nb->data, nb->tail - nb->data); - err = grub_netbuff_push (nb_reply, sizeof (*icmphr)); - if (err) - goto ping_fail; + grub_memcpy (nb_reply->data + sizeof (*icmphr), nb->data, nb->tail - nb->data); icmphr = (struct icmp_header *) nb_reply->data; icmphr->type = ICMP_ECHO_REPLY; icmphr->code = 0; @@ -110,7 +101,6 @@ grub_net_recv_icmp_packet (struct grub_net_buff *nb, err = grub_net_send_ip_packet (inf, src, ll_src, nb_reply, GRUB_NET_IP_ICMP); - ping_fail: grub_netbuff_free (nb); grub_netbuff_free (nb_reply); return err; diff --git a/grub-core/net/netbuff.c b/grub-core/net/netbuff.c index e97ecd23e..dbeeefe47 100644 --- a/grub-core/net/netbuff.c +++ b/grub-core/net/netbuff.c @@ -97,6 +97,26 @@ grub_netbuff_alloc (grub_size_t len) return nb; } +struct grub_net_buff * +grub_netbuff_make_pkt (grub_size_t len) +{ + struct grub_net_buff *nb; + grub_err_t err; + nb = grub_netbuff_alloc (len + 512); + if (!nb) + return NULL; + err = grub_netbuff_reserve (nb, len + 512); + if (err) + goto fail; + err = grub_netbuff_push (nb, len); + if (err) + goto fail; + return nb; + fail: + grub_netbuff_free (nb); + return NULL; +} + void grub_netbuff_free (struct grub_net_buff *nb) { diff --git a/include/grub/net/netbuff.h b/include/grub/net/netbuff.h index 9ac168c89..1177c1220 100644 --- a/include/grub/net/netbuff.h +++ b/include/grub/net/netbuff.h @@ -25,6 +25,7 @@ grub_err_t grub_netbuff_pull (struct grub_net_buff *net_buff, grub_size_t len); grub_err_t grub_netbuff_reserve (struct grub_net_buff *net_buff, grub_size_t len); grub_err_t grub_netbuff_clear (struct grub_net_buff *net_buff); struct grub_net_buff * grub_netbuff_alloc (grub_size_t len); +struct grub_net_buff * grub_netbuff_make_pkt (grub_size_t len); void grub_netbuff_free (struct grub_net_buff *net_buff); #endif From 94222b72b53cc5fc36aa15346ff389f37302aa85 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 20 Mar 2015 21:41:17 +0100 Subject: [PATCH 372/722] Makefile.core.def: Remove obsolete LDADD_KERNEL --- grub-core/Makefile.core.def | 2 -- 1 file changed, 2 deletions(-) diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def index 8eaae458c..a6101dec7 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def @@ -83,8 +83,6 @@ kernel = { x86_64_xen_ldflags = '$(TARGET_IMG_LDFLAGS)'; x86_64_xen_ldflags = '$(TARGET_IMG_BASE_LDOPT),0'; - ldadd = '$(LDADD_KERNEL)'; - mips_loongson_ldflags = '-Wl,-Ttext,0x80200000'; powerpc_ieee1275_ldflags = '-Wl,-Ttext,0x200000'; sparc64_ieee1275_ldflags = '-Wl,-Ttext,0x4400'; From c14f8a9366517270c2171757e1b9a13fe0205dd3 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 20 Mar 2015 21:42:48 +0100 Subject: [PATCH 373/722] modinfo.sh.in: Add missing config variables. --- grub-core/modinfo.sh.in | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/grub-core/modinfo.sh.in b/grub-core/modinfo.sh.in index 09d22f922..faf0ad30e 100644 --- a/grub-core/modinfo.sh.in +++ b/grub-core/modinfo.sh.in @@ -19,11 +19,17 @@ grub_target_cflags='@TARGET_CFLAGS@' grub_target_cppflags='@TARGET_CPPFLAGS@' grub_target_ccasflags='@TARGET_CCASFLAGS@' grub_target_ldflags='@TARGET_LDFLAGS@' +grub_cflags='@CFLAGS@' +grub_cppflags='@CPPFLAGS@' +grub_ccasflags='@CCASFLAGS@' +grub_ldflags='@LDFLAGS@' grub_target_strip='@TARGET_STRIP@' grub_target_nm='@TARGET_NM@' grub_target_ranlib='@TARGET_RANLIB@' grub_target_objconf='@TARGET_OBJCONV@' grub_target_obj2elf='@TARGET_OBJ2ELF@' +grub_target_img_base_ldopt='@TARGET_IMG_BASE_LDOPT@' +grub_target_img_ldflags='@TARGET_IMG_BASE_LDFLAGS@' # Version grub_version="@VERSION@" From 85a7be2414c4718e96d81a2ebaa70d0d42152e62 Mon Sep 17 00:00:00 2001 From: Daniel Kahn Gillmor Date: Fri, 27 Mar 2015 13:26:48 +0100 Subject: [PATCH 374/722] util/mkimage: Use stable timestamp when generating binaries. --- util/mkimage.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/util/mkimage.c b/util/mkimage.c index 7821dc5ea..52265b557 100644 --- a/util/mkimage.c +++ b/util/mkimage.c @@ -55,6 +55,9 @@ #define TARGET_NO_FIELD 0xffffffff +/* use 2015-01-01T00:00:00+0000 as a stock timestamp */ +#define STABLE_EMBEDDING_TIMESTAMP 1420070400 + struct grub_install_image_target_desc { const char *dirname; @@ -1439,7 +1442,7 @@ grub_install_generate_image (const char *dir, const char *prefix, c->machine = grub_host_to_target16 (image_target->pe_target); c->num_sections = grub_host_to_target16 (4); - c->time = grub_host_to_target32 (time (0)); + c->time = grub_host_to_target32 (STABLE_EMBEDDING_TIMESTAMP); c->characteristics = grub_host_to_target16 (GRUB_PE32_EXECUTABLE_IMAGE | GRUB_PE32_LINE_NUMS_STRIPPED | ((image_target->voidp_sizeof == 4) @@ -1782,7 +1785,7 @@ grub_install_generate_image (const char *dir, const char *prefix, memset (hdr, 0, sizeof (*hdr)); hdr->ih_magic = grub_cpu_to_be32_compile_time (GRUB_UBOOT_IH_MAGIC); - hdr->ih_time = grub_cpu_to_be32 (time (0)); + hdr->ih_time = grub_cpu_to_be32 (STABLE_EMBEDDING_TIMESTAMP); hdr->ih_size = grub_cpu_to_be32 (core_size); hdr->ih_load = grub_cpu_to_be32 (image_target->link_addr); hdr->ih_ep = grub_cpu_to_be32 (image_target->link_addr); From 1f23c87c19b3002231c2939a8d03fa4b67f7bcb6 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 27 Mar 2015 14:04:41 +0100 Subject: [PATCH 375/722] Make Makefile.util.def independent of platform. --- Makefile.util.def | 1 - 1 file changed, 1 deletion(-) diff --git a/Makefile.util.def b/Makefile.util.def index 67dfb2976..3cb6b21d3 100644 --- a/Makefile.util.def +++ b/Makefile.util.def @@ -613,7 +613,6 @@ program = { common = grub-core/disk/host.c; common = util/resolve.c; - enable = noemu; common = grub-core/kern/emu/argp_common.c; common = grub-core/osdep/init.c; From cf2b4a36c408084852c44dea045331f039b895d2 Mon Sep 17 00:00:00 2001 From: Martin Wilck Date: Fri, 27 Mar 2015 14:27:56 +0100 Subject: [PATCH 376/722] efinet: Check for immediate completition. This both speeds GRUB up and workarounds unexpected EFI behaviour. --- grub-core/net/drivers/efi/efinet.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/grub-core/net/drivers/efi/efinet.c b/grub-core/net/drivers/efi/efinet.c index 2b344d6ef..f171f20bf 100644 --- a/grub-core/net/drivers/efi/efinet.c +++ b/grub-core/net/drivers/efi/efinet.c @@ -37,11 +37,12 @@ send_card_buffer (struct grub_net_card *dev, grub_efi_status_t st; grub_efi_simple_network_t *net = dev->efi_net; grub_uint64_t limit_time = grub_get_time_ms () + 4000; + void *txbuf; if (dev->txbusy) while (1) { - void *txbuf = NULL; + txbuf = NULL; st = efi_call_3 (net->get_status, net, 0, &txbuf); if (st != GRUB_EFI_SUCCESS) return grub_error (GRUB_ERR_IO, @@ -74,7 +75,18 @@ send_card_buffer (struct grub_net_card *dev, dev->txbuf, NULL, NULL, NULL); if (st != GRUB_EFI_SUCCESS) return grub_error (GRUB_ERR_IO, N_("couldn't send network packet")); - dev->txbusy = 1; + + /* + The card may have sent out the packet immediately - set txbusy + to 0 in this case. + Cases were observed where checking txbuf at the next call + of send_card_buffer() is too late: 0 is returned in txbuf and + we run in the GRUB_ERR_TIMEOUT case above. + Perhaps a timeout in the FW has discarded the recycle buffer. + */ + st = efi_call_3 (net->get_status, net, 0, &txbuf); + dev->txbusy = !(st == GRUB_EFI_SUCCESS && txbuf == dev->txbuf); + return GRUB_ERR_NONE; } From d47e8ab4b945d1dd50bc7d7ebbbf6f1f255f8f58 Mon Sep 17 00:00:00 2001 From: Leif Lindholm Date: Fri, 27 Mar 2015 14:37:16 +0100 Subject: [PATCH 377/722] dl_helper: Cleanup Use the new thumb_get_instruction_word/thumb_set_instruction_word helpers throughout. Style cleanup (missing spaces). Move Thumb MOVW/MOVT handlers into Thumb relocation section of file. --- grub-core/kern/arm/dl_helper.c | 78 +++++++++++++++------------------- 1 file changed, 34 insertions(+), 44 deletions(-) diff --git a/grub-core/kern/arm/dl_helper.c b/grub-core/kern/arm/dl_helper.c index 8a7263291..21d77f763 100644 --- a/grub-core/kern/arm/dl_helper.c +++ b/grub-core/kern/arm/dl_helper.c @@ -26,14 +26,14 @@ #include static inline grub_uint32_t -thumb_get_instruction_word(grub_uint16_t *target) +thumb_get_instruction_word (grub_uint16_t *target) { /* Extract instruction word in alignment-safe manner */ return grub_le_to_cpu16 ((*target)) << 16 | grub_le_to_cpu16 (*(target + 1)); } static inline void -thumb_set_instruction_word(grub_uint16_t *target, grub_uint32_t insword) +thumb_set_instruction_word (grub_uint16_t *target, grub_uint32_t insword) { *target = grub_cpu_to_le16 (insword >> 16); *(target + 1) = grub_cpu_to_le16 (insword & 0xffff); @@ -70,9 +70,7 @@ grub_arm_thm_call_get_offset (grub_uint16_t *target) grub_uint32_t insword; grub_int32_t offset; - /* Extract instruction word in alignment-safe manner */ - insword = (grub_le_to_cpu16 (*target) << 16) - | (grub_le_to_cpu16(*(target + 1))); + insword = thumb_get_instruction_word (target); /* Extract bitfields from instruction words */ sign = (insword >> 26) & 1; @@ -97,9 +95,7 @@ grub_arm_thm_call_set_offset (grub_uint16_t *target, grub_int32_t offset) grub_uint32_t insword; int is_blx; - /* Extract instruction word in alignment-safe manner */ - insword = (grub_le_to_cpu16 (*target) << 16) - | (grub_le_to_cpu16(*(target + 1))); + insword = thumb_get_instruction_word (target); if (((insword >> 12) & 0xd) == 0xc) is_blx = 1; @@ -122,9 +118,7 @@ grub_arm_thm_call_set_offset (grub_uint16_t *target, grub_int32_t offset) (((offset >> 12) & 0x03ff) << 16) | (j1 << 13) | (j2 << 11) | ((offset >> 1) & 0x07ff); - /* Write instruction word back in alignment-safe manner */ - *target = grub_cpu_to_le16 ((insword >> 16) & 0xffff); - *(target + 1) = grub_cpu_to_le16 (insword & 0xffff); + thumb_set_instruction_word (target, insword); grub_dprintf ("dl", " *insword = 0x%08x", insword); @@ -137,9 +131,7 @@ grub_arm_thm_jump19_get_offset (grub_uint16_t *target) grub_int32_t offset; grub_uint32_t insword; - /* Extract instruction word in alignment-safe manner */ - insword = (grub_le_to_cpu16 (*target) << 16) - | (grub_le_to_cpu16(*(target + 1))); + insword = thumb_get_instruction_word (target); /* Extract and sign extend offset */ offset = ((insword >> 26) & 1) << 19 @@ -163,9 +155,7 @@ grub_arm_thm_jump19_set_offset (grub_uint16_t *target, grub_int32_t offset) offset >>= 1; offset &= 0xfffff; - /* Extract instruction word in alignment-safe manner */ - insword = grub_le_to_cpu16 ((*target)) << 16 - | grub_le_to_cpu16 (*(target + 1)); + insword = thumb_get_instruction_word (target); /* Reassemble instruction word and write back */ insword &= insmask; @@ -174,8 +164,7 @@ grub_arm_thm_jump19_set_offset (grub_uint16_t *target, grub_int32_t offset) | ((offset >> 17) & 1) << 13 | ((offset >> 11) & 0x3f) << 16 | (offset & 0x7ff); - *target = grub_cpu_to_le16 (insword >> 16); - *(target + 1) = grub_cpu_to_le16 (insword & 0xffff); + thumb_set_instruction_word (target, insword); } int @@ -186,6 +175,32 @@ grub_arm_thm_jump19_check_offset (grub_int32_t offset) return 1; } +grub_uint16_t +grub_arm_thm_movw_movt_get_value (grub_uint16_t *target) +{ + grub_uint32_t insword; + + insword = thumb_get_instruction_word (target); + + return ((insword & 0xf0000) >> 4) | ((insword & 0x04000000) >> 15) | \ + ((insword & 0x7000) >> 4) | (insword & 0xff); +} + +void +grub_arm_thm_movw_movt_set_value (grub_uint16_t *target, grub_uint16_t value) +{ + grub_uint32_t insword; + const grub_uint32_t insmask = 0xfbf08f00; + + insword = thumb_get_instruction_word (target); + insword &= insmask; + + insword |= ((value & 0xf000) << 4) | ((value & 0x0800) << 15) | \ + ((value & 0x0700) << 4) | (value & 0xff); + + thumb_set_instruction_word (target, insword); +} + /*********************************************************** * ARM (A32) relocations: * @@ -228,28 +243,3 @@ grub_arm_jump24_set_offset (grub_uint32_t *target, *target = grub_cpu_to_le32 (insword); } - -grub_uint16_t -grub_arm_thm_movw_movt_get_value (grub_uint16_t *target) -{ - grub_uint32_t insword; - - insword = thumb_get_instruction_word (target); - - return ((insword & 0xf0000) >> 4) | ((insword & 0x04000000) >> 15) | \ - ((insword & 0x7000) >> 4) | (insword & 0xff); -} - -void -grub_arm_thm_movw_movt_set_value (grub_uint16_t *target, grub_uint16_t value) -{ - grub_uint32_t insword; - - insword = thumb_get_instruction_word (target); - insword &= 0xfbf08f00; - - insword |= ((value & 0xf000) << 4) | ((value & 0x0800) << 15) | \ - ((value & 0x0700) << 4) | (value & 0xff); - - thumb_set_instruction_word (target, insword); -} From ed07b7e1289dd00b9d6dc8ac5dd56130f3376bc9 Mon Sep 17 00:00:00 2001 From: Michael Zimmermann Date: Fri, 27 Mar 2015 14:44:41 +0100 Subject: [PATCH 378/722] Add missing initializers to silence suprious warnings. --- grub-core/commands/verify.c | 2 +- grub-core/fs/hfsplus.c | 8 ++++---- grub-core/normal/main.c | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/grub-core/commands/verify.c b/grub-core/commands/verify.c index 656939189..9620a3b4c 100644 --- a/grub-core/commands/verify.c +++ b/grub-core/commands/verify.c @@ -454,7 +454,7 @@ grub_verify_signature_real (char *buf, grub_size_t size, grub_err_t err; grub_size_t i; gcry_mpi_t mpis[10]; - grub_uint8_t type; + grub_uint8_t type = 0; err = read_packet_header (sig, &type, &len); if (err) diff --git a/grub-core/fs/hfsplus.c b/grub-core/fs/hfsplus.c index 110d85815..21159e858 100644 --- a/grub-core/fs/hfsplus.c +++ b/grub-core/fs/hfsplus.c @@ -792,8 +792,8 @@ grub_hfsplus_iterate_dir (grub_fshelp_node_t dir, }; struct grub_hfsplus_key_internal intern; - struct grub_hfsplus_btnode *node; - grub_disk_addr_t ptr; + struct grub_hfsplus_btnode *node = NULL; + grub_disk_addr_t ptr = 0; { struct grub_fshelp_node *fsnode; @@ -976,8 +976,8 @@ grub_hfsplus_label (grub_device_t device, char **label) struct grub_hfsplus_catkey *catkey; int i, label_len; struct grub_hfsplus_key_internal intern; - struct grub_hfsplus_btnode *node; - grub_disk_addr_t ptr; + struct grub_hfsplus_btnode *node = NULL; + grub_disk_addr_t ptr = 0; *label = 0; diff --git a/grub-core/normal/main.c b/grub-core/normal/main.c index 623b93ba6..78a70a8bf 100644 --- a/grub-core/normal/main.c +++ b/grub-core/normal/main.c @@ -445,7 +445,7 @@ grub_cmdline_run (int nested, int force_auth) while (1) { - char *line; + char *line = NULL; if (grub_normal_exit_level) break; From 1a33de8b5612f8d7ab344546f8a91fa814f712b5 Mon Sep 17 00:00:00 2001 From: Steve McIntyre Date: Fri, 27 Mar 2015 14:51:51 +0100 Subject: [PATCH 379/722] Recognize EFI platform even in case of mismatch between Linux and EFI. Some x86 systems might be capable of running a 64-bit Linux kernel but only use a 32-bit EFI (e.g. Intel Bay Trail systems). It's useful for grub-install to be able to recognise such systems, to set the default x86 platform correctly. To allow grub-install to know the size of the firmware rather than just the size of the kernel, there is now an extra EFI sysfs file to describe the underlying firmware. Read that if possible, otherwise fall back to the kernel type as before. Signed-off-by: Steve McIntyre --- grub-core/osdep/linux/platform.c | 39 +++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/grub-core/osdep/linux/platform.c b/grub-core/osdep/linux/platform.c index 4b9f6ef9d..775b6c031 100644 --- a/grub-core/osdep/linux/platform.c +++ b/grub-core/osdep/linux/platform.c @@ -60,6 +60,43 @@ is_64_kernel (void) return strcmp (un.machine, "x86_64") == 0; } +static int +read_platform_size (void) +{ + FILE *fp; + char *buf = NULL; + size_t len = 0; + int ret = 0; + + /* Newer kernels can tell us directly about the size of the + * underlying firmware - let's see if that interface is there. */ + fp = grub_util_fopen ("/sys/firmware/efi/fw_platform_size", "r"); + if (fp != NULL) + { + if (getline (&buf, &len, fp) >= 3) /* 2 digits plus newline */ + { + if (strncmp (buf, "32", 2) == 0) + ret = 32; + else if (strncmp (buf, "64", 2) == 0) + ret = 64; + } + free (buf); + fclose (fp); + } + + if (ret == 0) + { + /* Unrecognised - fall back to matching the kernel size + * instead */ + if (is_64_kernel ()) + ret = 64; + else + ret = 32; + } + + return ret; +} + const char * grub_install_get_default_x86_platform (void) { @@ -77,7 +114,7 @@ grub_install_get_default_x86_platform (void) if (is_not_empty_directory ("/sys/firmware/efi")) { grub_util_info ("...found"); - if (is_64_kernel ()) + if (read_platform_size() == 64) return "x86_64-efi"; else return "i386-efi"; From c9ee9bedefe71df6bb18868e47ff2189e79d821e Mon Sep 17 00:00:00 2001 From: Lunar Date: Fri, 27 Mar 2015 15:15:13 +0100 Subject: [PATCH 380/722] syslinux: Support {vesa,}menu.c32. --- grub-core/lib/syslinux_parse.c | 165 +++++++++++++++++++++------------ 1 file changed, 107 insertions(+), 58 deletions(-) diff --git a/grub-core/lib/syslinux_parse.c b/grub-core/lib/syslinux_parse.c index 22389eb97..153260b54 100644 --- a/grub-core/lib/syslinux_parse.c +++ b/grub-core/lib/syslinux_parse.c @@ -839,6 +839,82 @@ simplify_filename (char *str) *optr = '\0'; } +static grub_err_t +print_config (struct output_buffer *outbuf, + struct syslinux_menu *menu, + const char *filename, const char *basedir) +{ + struct syslinux_menu *menuptr; + grub_err_t err = GRUB_ERR_NONE; + char *new_cwd = NULL; + char *new_target_cwd = NULL; + char *newname = NULL; + int depth = 0; + + new_cwd = get_read_filename (menu, basedir); + if (!new_cwd) + { + err = grub_errno; + goto out; + } + new_target_cwd = get_target_filename (menu, basedir); + if (!new_target_cwd) + { + err = grub_errno; + goto out; + } + newname = get_read_filename (menu, filename); + if (!newname) + { + err = grub_errno; + goto out; + } + simplify_filename (newname); + + print_string ("#"); + print_file (outbuf, menu, filename, NULL); + print_string (" "); + print (outbuf, newname, grub_strlen (newname)); + print_string (":\n"); + + for (menuptr = menu; menuptr; menuptr = menuptr->parent, depth++) + if (grub_strcmp (menuptr->filename, newname) == 0 + || depth > 20) + break; + if (menuptr) + { + print_string (" syslinux_configfile -r "); + print_file (outbuf, menu, "/", NULL); + print_string (" -c "); + print_file (outbuf, menu, basedir, NULL); + print_string (" "); + print_file (outbuf, menu, filename, NULL); + print_string ("\n"); + } + else + { + err = config_file (outbuf, menu->root_read_directory, + menu->root_target_directory, new_cwd, new_target_cwd, + newname, menu, menu->flavour); + if (err == GRUB_ERR_FILE_NOT_FOUND + || err == GRUB_ERR_BAD_FILENAME) + { + grub_errno = err = GRUB_ERR_NONE; + print_string ("# File "); + err = print (outbuf, newname, grub_strlen (newname)); + if (err) + goto out; + print_string (" not found\n"); + } + } + + out: + grub_free (newname); + grub_free (new_cwd); + grub_free (new_target_cwd); + return err; +} + static grub_err_t write_entry (struct output_buffer *outbuf, struct syslinux_menu *menu, @@ -1227,6 +1303,36 @@ write_entry (struct output_buffer *outbuf, break; } + if (grub_strcasecmp (basename, "menu.c32") == 0 || + grub_strcasecmp (basename, "vesamenu.c32") == 0) + { + char *ptr; + char *end; + + ptr = curentry->append; + if (!ptr) + return grub_errno; + + while (*ptr) + { + end = ptr; + for (end = ptr; *end && !grub_isspace (*end); end++); + if (*end) + *end++ = '\0'; + + /* "~" is supposed to be current file, so let's skip it */ + if (grub_strcmp (ptr, "~") != 0) + { + err = print_config (outbuf, menu, ptr, ""); + if (err != GRUB_ERR_NONE) + break; + } + for (ptr = end; *ptr && grub_isspace (*ptr); ptr++); + } + err = GRUB_ERR_NONE; + break; + } + /* FIXME: gdb, GFXBoot, Hdt, Ifcpu, Ifplop, Kbdmap, FIXME: Linux, Lua, Meminfo, rosh, Sanbboot */ @@ -1239,70 +1345,13 @@ write_entry (struct output_buffer *outbuf, } case KERNEL_CONFIG: { - char *new_cwd, *new_target_cwd; const char *ap; ap = curentry->append; if (!ap) ap = curentry->argument; if (!ap) ap = ""; - new_cwd = get_read_filename (menu, ap); - if (!new_cwd) - return grub_errno; - new_target_cwd = get_target_filename (menu, ap); - if (!new_target_cwd) - return grub_errno; - - struct syslinux_menu *menuptr; - char *newname; - int depth = 0; - - newname = get_read_filename (menu, curentry->kernel_file); - if (!newname) - return grub_errno; - simplify_filename (newname); - - print_string ("#"); - print_file (outbuf, menu, curentry->kernel_file, NULL); - print_string (" "); - print (outbuf, newname, grub_strlen (newname)); - print_string (":\n"); - - for (menuptr = menu; menuptr; menuptr = menuptr->parent, depth++) - if (grub_strcmp (menuptr->filename, newname) == 0 - || depth > 20) - break; - if (menuptr) - { - print_string (" syslinux_configfile -r "); - print_file (outbuf, menu, "/", NULL); - print_string (" -c "); - print_file (outbuf, menu, ap, NULL); - print_string (" "); - print_file (outbuf, menu, curentry->kernel_file, NULL); - print_string ("\n"); - } - else - { - err = config_file (outbuf, menu->root_read_directory, - menu->root_target_directory, new_cwd, new_target_cwd, - newname, menu, menu->flavour); - if (err == GRUB_ERR_FILE_NOT_FOUND - || err == GRUB_ERR_BAD_FILENAME) - { - grub_errno = err = GRUB_ERR_NONE; - print_string ("# File "); - err = print (outbuf, newname, grub_strlen (newname)); - if (err) - return err; - print_string (" not found\n"); - } - if (err) - return err; - } - grub_free (newname); - grub_free (new_cwd); - grub_free (new_target_cwd); + print_config (outbuf, menu, curentry->kernel_file, ap); } break; case KERNEL_NO_KERNEL: From ebd92af8c3f8fc30c48bbf36a1875fda1246981c Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Fri, 27 Mar 2015 18:58:57 +0300 Subject: [PATCH 381/722] net: trivial grub_cpu_to_XX_compile_time cleanup --- grub-core/net/arp.c | 2 +- grub-core/net/icmp6.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/grub-core/net/arp.c b/grub-core/net/arp.c index 46a56e07f..4b68c4151 100644 --- a/grub-core/net/arp.c +++ b/grub-core/net/arp.c @@ -80,7 +80,7 @@ grub_net_arp_send_request (struct grub_net_network_level_interface *inf, arp_packet = (struct arppkt *) nb.data; arp_packet->hrd = grub_cpu_to_be16_compile_time (GRUB_NET_ARPHRD_ETHERNET); arp_packet->hln = 6; - arp_packet->pro = grub_cpu_to_be16 (GRUB_NET_ETHERTYPE_IP); + arp_packet->pro = grub_cpu_to_be16_compile_time (GRUB_NET_ETHERTYPE_IP); arp_packet->pln = 4; arp_packet->op = grub_cpu_to_be16_compile_time (ARP_REQUEST); /* Sender hardware address. */ diff --git a/grub-core/net/icmp6.c b/grub-core/net/icmp6.c index 782239460..7953e68ec 100644 --- a/grub-core/net/icmp6.c +++ b/grub-core/net/icmp6.c @@ -552,8 +552,8 @@ grub_net_icmp6_send_router_solicit (struct grub_net_network_level_interface *inf struct icmp_header *icmphr; multicast.type = GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV6; - multicast.ipv6[0] = grub_cpu_to_be64 (0xff02ULL << 48); - multicast.ipv6[1] = grub_cpu_to_be64 (0x02ULL); + multicast.ipv6[0] = grub_cpu_to_be64_compile_time (0xff02ULL << 48); + multicast.ipv6[1] = grub_cpu_to_be64_compile_time (0x02ULL); err = grub_net_link_layer_resolve (inf, &multicast, &ll_multicast); if (err) From 7d3993847466435bcc8c82267f101c5e8193f4be Mon Sep 17 00:00:00 2001 From: Sarah Newman Date: Fri, 27 Mar 2015 12:56:43 -0700 Subject: [PATCH 382/722] grub-core/loader/i386/xen.c: Initialized initrd_ctx so we don't free a random pointer from the stack. Signed-off-by: Sarah Newman --- grub-core/loader/i386/xen.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/loader/i386/xen.c b/grub-core/loader/i386/xen.c index c16b4b249..c4d9689f7 100644 --- a/grub-core/loader/i386/xen.c +++ b/grub-core/loader/i386/xen.c @@ -521,7 +521,7 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), { grub_size_t size = 0; grub_err_t err; - struct grub_linux_initrd_context initrd_ctx; + struct grub_linux_initrd_context initrd_ctx = { 0, 0, 0 }; grub_relocator_chunk_t ch; if (argc == 0) From 12bf55703940cde06448a1c1a19001556c1450f9 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sat, 28 Mar 2015 22:13:35 +0300 Subject: [PATCH 383/722] do not emit cryptomount without crypto UUID --- util/grub-mkconfig_lib.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/grub-mkconfig_lib.in b/util/grub-mkconfig_lib.in index 29ef865d4..60b31cadd 100644 --- a/util/grub-mkconfig_lib.in +++ b/util/grub-mkconfig_lib.in @@ -145,7 +145,7 @@ prepare_grub_to_access_device () done if [ x$GRUB_ENABLE_CRYPTODISK = xy ]; then - for uuid in "`"${grub_probe}" --device $@ --target=cryptodisk_uuid`"; do + for uuid in `"${grub_probe}" --device $@ --target=cryptodisk_uuid`; do echo "cryptomount -u $uuid" done fi From f11db3c7fc50b0b7de22e5ccdcb06bcbccb22a46 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Mon, 6 Apr 2015 19:25:02 +0300 Subject: [PATCH 384/722] core: avoid NULL derefrence in grub_divmod64s It can be called with NULL for third argument. grub_divmod32* for now are called only from within wrappers, so skip check. Reported-By: Michael Zimmermann --- grub-core/lib/division.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/grub-core/lib/division.c b/grub-core/lib/division.c index 920a79f18..35606fea7 100644 --- a/grub-core/lib/division.c +++ b/grub-core/lib/division.c @@ -50,7 +50,8 @@ grub_divmod64s (grub_int64_t n, q = -q; } /* Now: n = d * q + r */ - *ro = r; + if (ro) + *ro = r; return q; } From e97f5f4968c4b92c43985833604118149cbba128 Mon Sep 17 00:00:00 2001 From: Paul Menzel Date: Sat, 11 Apr 2015 21:40:50 +0200 Subject: [PATCH 385/722] docs/grub.texi: Fix spelling of cbfstool --- docs/grub.texi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/grub.texi b/docs/grub.texi index 46b9e7f8e..4af22aff8 100644 --- a/docs/grub.texi +++ b/docs/grub.texi @@ -5848,7 +5848,7 @@ Following variables must be defined: @multitable @columnfractions .30 .65 @item GRUB_PAYLOADS_DIR @tab directory containing the required kernels -@item GRUB_CBFSTOOL @tab cbfstoll from Coreboot package (for coreboot platform only) +@item GRUB_CBFSTOOL @tab cbfstool from Coreboot package (for coreboot platform only) @item GRUB_COREBOOT_ROM @tab empty Coreboot ROM @item GRUB_QEMU_OPTS @tab additional options to be supplied to QEMU @end multitable From 5b5d8666a748109a3a0175f8140382d295a7938a Mon Sep 17 00:00:00 2001 From: Toomas Soome Date: Mon, 13 Apr 2015 19:49:15 +0300 Subject: [PATCH 386/722] core/partmap: rename 'sun' to avoid clash with predefined symbol MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit the symbol “sun†is defined macro in solaris derived systems, from gcc -dM -E: and therefore can not be used as name. --- grub-core/partmap/sun.c | 14 +++++++------- grub-core/partmap/sunpc.c | 10 +++++----- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/grub-core/partmap/sun.c b/grub-core/partmap/sun.c index dae360269..aac30a320 100644 --- a/grub-core/partmap/sun.c +++ b/grub-core/partmap/sun.c @@ -91,7 +91,7 @@ sun_partition_map_iterate (grub_disk_t disk, struct grub_partition p; union { - struct grub_sun_block sun; + struct grub_sun_block sun_block; grub_uint16_t raw[0]; } block; int partnum; @@ -103,7 +103,7 @@ sun_partition_map_iterate (grub_disk_t disk, if (err) return err; - if (GRUB_PARTMAP_SUN_MAGIC != grub_be_to_cpu16 (block.sun.magic)) + if (GRUB_PARTMAP_SUN_MAGIC != grub_be_to_cpu16 (block.sun_block.magic)) return grub_error (GRUB_ERR_BAD_PART_TABLE, "not a sun partition table"); if (! grub_sun_is_valid (block.raw)) @@ -115,14 +115,14 @@ sun_partition_map_iterate (grub_disk_t disk, { struct grub_sun_partition_descriptor *desc; - if (block.sun.infos[partnum].id == 0 - || block.sun.infos[partnum].id == GRUB_PARTMAP_SUN_WHOLE_DISK_ID) + if (block.sun_block.infos[partnum].id == 0 + || block.sun_block.infos[partnum].id == GRUB_PARTMAP_SUN_WHOLE_DISK_ID) continue; - desc = &block.sun.partitions[partnum]; + desc = &block.sun_block.partitions[partnum]; p.start = ((grub_uint64_t) grub_be_to_cpu32 (desc->start_cylinder) - * grub_be_to_cpu16 (block.sun.ntrks) - * grub_be_to_cpu16 (block.sun.nsect)); + * grub_be_to_cpu16 (block.sun_block.ntrks) + * grub_be_to_cpu16 (block.sun_block.nsect)); p.len = grub_be_to_cpu32 (desc->num_sectors); p.number = p.index = partnum; if (p.len) diff --git a/grub-core/partmap/sunpc.c b/grub-core/partmap/sunpc.c index 442763ee5..73a430c14 100644 --- a/grub-core/partmap/sunpc.c +++ b/grub-core/partmap/sunpc.c @@ -74,7 +74,7 @@ sun_pc_partition_map_iterate (grub_disk_t disk, grub_partition_t p; union { - struct grub_sun_pc_block sun; + struct grub_sun_pc_block sun_block; grub_uint16_t raw[0]; } block; int partnum; @@ -92,7 +92,7 @@ sun_pc_partition_map_iterate (grub_disk_t disk, return err; } - if (GRUB_PARTMAP_SUN_PC_MAGIC != grub_le_to_cpu16 (block.sun.magic)) + if (GRUB_PARTMAP_SUN_PC_MAGIC != grub_le_to_cpu16 (block.sun_block.magic)) { grub_free (p); return grub_error (GRUB_ERR_BAD_PART_TABLE, @@ -111,12 +111,12 @@ sun_pc_partition_map_iterate (grub_disk_t disk, { struct grub_sun_pc_partition_descriptor *desc; - if (block.sun.partitions[partnum].id == 0 - || block.sun.partitions[partnum].id + if (block.sun_block.partitions[partnum].id == 0 + || block.sun_block.partitions[partnum].id == GRUB_PARTMAP_SUN_PC_WHOLE_DISK_ID) continue; - desc = &block.sun.partitions[partnum]; + desc = &block.sun_block.partitions[partnum]; p->start = grub_le_to_cpu32 (desc->start_sector); p->len = grub_le_to_cpu32 (desc->num_sectors); p->number = partnum; From 677dcaa92bdd31f38d49a4d5575f2adca8479d94 Mon Sep 17 00:00:00 2001 From: Toomas Soome Date: Mon, 13 Apr 2015 19:52:28 +0300 Subject: [PATCH 387/722] getroot: include sys/mkdev.h for makedev Solaris (like) systems need to include sys/mkdev.h for makedev() function. --- grub-core/osdep/unix/getroot.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/grub-core/osdep/unix/getroot.c b/grub-core/osdep/unix/getroot.c index ccee7ce16..b98b2dfb0 100644 --- a/grub-core/osdep/unix/getroot.c +++ b/grub-core/osdep/unix/getroot.c @@ -57,6 +57,9 @@ #endif #include +#if defined(HAVE_SYS_MKDEV_H) +#include +#endif #if defined(HAVE_LIBZFS) && defined(HAVE_LIBNVPAIR) # include From 70b002de55abbfd6b2d2f2ea4408078d93c9e0de Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 24 Apr 2015 17:52:30 +0200 Subject: [PATCH 388/722] Remove -V in grub-mkrescue.c It clashhes with -V which is alias to -volid. --- util/grub-mkrescue.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/grub-mkrescue.c b/util/grub-mkrescue.c index 5d3ec0d4e..815fc9175 100644 --- a/util/grub-mkrescue.c +++ b/util/grub-mkrescue.c @@ -409,7 +409,7 @@ args_to_eat (const char *arg) return 2; return 1; } - if (arg[1] == '?' || arg[1] == 'V') + if (arg[1] == '?') return 1; } return 0; From 104dff36eabe25dec143838167466fd6a8ddbc79 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Wed, 29 Apr 2015 19:18:54 +0300 Subject: [PATCH 389/722] grub-mkconfig: use $pkgdatadir in scripts Otherwise scripts will source wrong grub-mkconfig_lib. --- util/grub-mkconfig.in | 3 +++ util/grub.d/00_header.in | 2 +- util/grub.d/10_hurd.in | 2 +- util/grub.d/10_illumos.in | 2 +- util/grub.d/10_kfreebsd.in | 2 +- util/grub.d/10_linux.in | 2 +- util/grub.d/10_netbsd.in | 2 +- util/grub.d/10_windows.in | 2 +- util/grub.d/10_xnu.in | 2 +- util/grub.d/20_linux_xen.in | 2 +- util/grub.d/30_os-prober.in | 2 +- 11 files changed, 13 insertions(+), 10 deletions(-) diff --git a/util/grub-mkconfig.in b/util/grub-mkconfig.in index d1fae4937..3183744bf 100644 --- a/util/grub-mkconfig.in +++ b/util/grub-mkconfig.in @@ -33,6 +33,9 @@ datadir="@datadir@" if [ "x$pkgdatadir" = x ]; then pkgdatadir="${datadir}/@PACKAGE@" fi +# export it for scripts +export pkgdatadir + grub_cfg="" grub_mkconfig_dir="${sysconfdir}"/grub.d diff --git a/util/grub.d/00_header.in b/util/grub.d/00_header.in index ce2ec819d..93a90233e 100644 --- a/util/grub.d/00_header.in +++ b/util/grub.d/00_header.in @@ -25,7 +25,7 @@ grub_lang=`echo $LANG | cut -d . -f 1` export TEXTDOMAIN=@PACKAGE@ export TEXTDOMAINDIR="@localedir@" -. "@datadir@/@PACKAGE@/grub-mkconfig_lib" +. "$pkgdatadir/grub-mkconfig_lib" # Do this as early as possible, since other commands might depend on it. # (e.g. the `loadfont' command might need lvm or raid modules) diff --git a/util/grub.d/10_hurd.in b/util/grub.d/10_hurd.in index 29b455423..59a9a48a2 100644 --- a/util/grub.d/10_hurd.in +++ b/util/grub.d/10_hurd.in @@ -24,7 +24,7 @@ datarootdir="@datarootdir@" export TEXTDOMAIN=@PACKAGE@ export TEXTDOMAINDIR="@localedir@" -. "@datadir@/@PACKAGE@/grub-mkconfig_lib" +. "$pkgdatadir/grub-mkconfig_lib" CLASS="--class gnu --class os" diff --git a/util/grub.d/10_illumos.in b/util/grub.d/10_illumos.in index 0de616e89..a133e1b3f 100644 --- a/util/grub.d/10_illumos.in +++ b/util/grub.d/10_illumos.in @@ -20,7 +20,7 @@ set -e prefix="@prefix@" exec_prefix="@exec_prefix@" datarootdir="@datarootdir@" -. "@datadir@/@PACKAGE@/grub-mkconfig_lib" +. "$pkgdatadir/grub-mkconfig_lib" export TEXTDOMAIN=@PACKAGE@ export TEXTDOMAINDIR="@localedir@" diff --git a/util/grub.d/10_kfreebsd.in b/util/grub.d/10_kfreebsd.in index 65f6c32a0..9d8e8fd85 100644 --- a/util/grub.d/10_kfreebsd.in +++ b/util/grub.d/10_kfreebsd.in @@ -20,7 +20,7 @@ set -e prefix="@prefix@" exec_prefix="@exec_prefix@" datarootdir="@datarootdir@" -. "@datadir@/@PACKAGE@/grub-mkconfig_lib" +. "$pkgdatadir/grub-mkconfig_lib" export TEXTDOMAIN=@PACKAGE@ export TEXTDOMAINDIR="@localedir@" diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in index a2a84dce4..859b608f6 100644 --- a/util/grub.d/10_linux.in +++ b/util/grub.d/10_linux.in @@ -21,7 +21,7 @@ prefix="@prefix@" exec_prefix="@exec_prefix@" datarootdir="@datarootdir@" -. "@datadir@/@PACKAGE@/grub-mkconfig_lib" +. "$pkgdatadir/grub-mkconfig_lib" export TEXTDOMAIN=@PACKAGE@ export TEXTDOMAINDIR="@localedir@" diff --git a/util/grub.d/10_netbsd.in b/util/grub.d/10_netbsd.in index 9988a42bc..874f59969 100644 --- a/util/grub.d/10_netbsd.in +++ b/util/grub.d/10_netbsd.in @@ -20,7 +20,7 @@ set -e prefix="@prefix@" exec_prefix="@exec_prefix@" datarootdir="@datarootdir@" -. "@datadir@/@PACKAGE@/grub-mkconfig_lib" +. "$pkgdatadir/grub-mkconfig_lib" export TEXTDOMAIN=@PACKAGE@ export TEXTDOMAINDIR="@localedir@" diff --git a/util/grub.d/10_windows.in b/util/grub.d/10_windows.in index 48bd95546..554c5614b 100644 --- a/util/grub.d/10_windows.in +++ b/util/grub.d/10_windows.in @@ -24,7 +24,7 @@ datarootdir="@datarootdir@" export TEXTDOMAIN=@PACKAGE@ export TEXTDOMAINDIR="@localedir@" -. "@datadir@/@PACKAGE@/grub-mkconfig_lib" +. "$pkgdatadir/grub-mkconfig_lib" case "`uname 2>/dev/null`" in CYGWIN*) ;; diff --git a/util/grub.d/10_xnu.in b/util/grub.d/10_xnu.in index 4270385f3..51ee2f427 100644 --- a/util/grub.d/10_xnu.in +++ b/util/grub.d/10_xnu.in @@ -24,7 +24,7 @@ datarootdir="@datarootdir@" export TEXTDOMAIN=@PACKAGE@ export TEXTDOMAINDIR="@localedir@" -. "@datadir@/@PACKAGE@/grub-mkconfig_lib" +. "$pkgdatadir/grub-mkconfig_lib" osx_entry() { if [ x$2 = x32 ]; then diff --git a/util/grub.d/20_linux_xen.in b/util/grub.d/20_linux_xen.in index de34c8d73..f532fb98f 100644 --- a/util/grub.d/20_linux_xen.in +++ b/util/grub.d/20_linux_xen.in @@ -21,7 +21,7 @@ prefix="@prefix@" exec_prefix="@exec_prefix@" datarootdir="@datarootdir@" -. "@datadir@/@PACKAGE@/grub-mkconfig_lib" +. "$pkgdatadir/grub-mkconfig_lib" export TEXTDOMAIN=@PACKAGE@ export TEXTDOMAINDIR="@localedir@" diff --git a/util/grub.d/30_os-prober.in b/util/grub.d/30_os-prober.in index 4ee601565..5fc4f0c83 100644 --- a/util/grub.d/30_os-prober.in +++ b/util/grub.d/30_os-prober.in @@ -24,7 +24,7 @@ datarootdir="@datarootdir@" export TEXTDOMAIN=@PACKAGE@ export TEXTDOMAINDIR="@localedir@" -. "@datadir@/@PACKAGE@/grub-mkconfig_lib" +. "$pkgdatadir/grub-mkconfig_lib" if [ "x${GRUB_DISABLE_OS_PROBER}" = "xtrue" ]; then exit 0 From a1007c6af296172c788f3346ff3ad30b9020f723 Mon Sep 17 00:00:00 2001 From: Toomas Soome Date: Thu, 16 Apr 2015 08:22:08 +0300 Subject: [PATCH 390/722] zfs: com.delphix:hole_birth feature support In the past birth was always zero for holes. This feature started to make use of birth for holes as well, so change code to test for valid DVA address instead. --- grub-core/fs/zfs/zfs.c | 6 ++++-- include/grub/zfs/spa.h | 4 +++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/grub-core/fs/zfs/zfs.c b/grub-core/fs/zfs/zfs.c index 0cbb84bb3..71c155df2 100644 --- a/grub-core/fs/zfs/zfs.c +++ b/grub-core/fs/zfs/zfs.c @@ -280,7 +280,9 @@ grub_crypto_cipher_handle_t (*grub_zfs_load_key) (const struct grub_zfs_key *key */ #define MAX_SUPPORTED_FEATURE_STRLEN 50 static const char *spa_feature_names[] = { - "org.illumos:lz4_compress",NULL + "org.illumos:lz4_compress", + "com.delphix:hole_birth", + NULL }; static int @@ -1751,7 +1753,7 @@ zio_read_gang (blkptr_t * bp, grub_zfs_endian_t endian, dva_t * dva, void *buf, for (i = 0; i < SPA_GBH_NBLKPTRS; i++) { - if (zio_gb->zg_blkptr[i].blk_birth == 0) + if (BP_IS_HOLE(&zio_gb->zg_blkptr[i])) continue; err = zio_read_data (&zio_gb->zg_blkptr[i], endian, buf, data); diff --git a/include/grub/zfs/spa.h b/include/grub/zfs/spa.h index 7edb8ab7d..df43b6b32 100644 --- a/include/grub/zfs/spa.h +++ b/include/grub/zfs/spa.h @@ -279,7 +279,9 @@ typedef struct blkptr { #define BP_IDENTITY(bp) (&(bp)->blk_dva[0]) #define BP_IS_GANG(bp) DVA_GET_GANG(BP_IDENTITY(bp)) -#define BP_IS_HOLE(bp) ((bp)->blk_birth == 0) +#define DVA_IS_EMPTY(dva) ((dva)->dva_word[0] == 0ULL && \ + (dva)->dva_word[1] == 0ULL) +#define BP_IS_HOLE(bp) DVA_IS_EMPTY(BP_IDENTITY(bp)) /* BP_IS_RAIDZ(bp) assumes no block compression */ #define BP_IS_RAIDZ(bp) (DVA_GET_ASIZE(&(bp)->blk_dva[0]) > \ From 4a7ea4003bd9f39e9bf2ebadbe4ab38f8874be66 Mon Sep 17 00:00:00 2001 From: Toomas Soome Date: Thu, 16 Apr 2015 08:23:22 +0300 Subject: [PATCH 391/722] zfs: com.delphix:embedded_data feature support --- grub-core/fs/zfs/zfs.c | 84 +++++++++++++++++++++++++++++++++++------- include/grub/zfs/spa.h | 27 ++++++++++++-- 2 files changed, 93 insertions(+), 18 deletions(-) diff --git a/grub-core/fs/zfs/zfs.c b/grub-core/fs/zfs/zfs.c index 71c155df2..03d587d8c 100644 --- a/grub-core/fs/zfs/zfs.c +++ b/grub-core/fs/zfs/zfs.c @@ -282,6 +282,7 @@ grub_crypto_cipher_handle_t (*grub_zfs_load_key) (const struct grub_zfs_key *key static const char *spa_feature_names[] = { "org.illumos:lz4_compress", "com.delphix:hole_birth", + "com.delphix:embedded_data", NULL }; @@ -1802,6 +1803,39 @@ zio_read_data (blkptr_t * bp, grub_zfs_endian_t endian, void *buf, return err; } +/* + * buf must be at least BPE_GET_PSIZE(bp) bytes long (which will never be + * more than BPE_PAYLOAD_SIZE bytes). + */ +static grub_err_t +decode_embedded_bp_compressed(const blkptr_t *bp, void *buf) +{ + grub_size_t psize, i; + grub_uint8_t *buf8 = buf; + grub_uint64_t w = 0; + const grub_uint64_t *bp64 = (const grub_uint64_t *)bp; + + psize = BPE_GET_PSIZE(bp); + + /* + * Decode the words of the block pointer into the byte array. + * Low bits of first word are the first byte (little endian). + */ + for (i = 0; i < psize; i++) + { + if (i % sizeof (w) == 0) + { + /* beginning of a word */ + w = *bp64; + bp64++; + if (!BPE_IS_PAYLOADWORD(bp, bp64)) + bp64++; + } + buf8[i] = BF64_GET(w, (i % sizeof (w)) * 8, 8); + } + return GRUB_ERR_NONE; +} + /* * Read in a block of data, verify its checksum, decompress if needed, * and put the uncompressed data in buf. @@ -1820,12 +1854,26 @@ zio_read (blkptr_t *bp, grub_zfs_endian_t endian, void **buf, *buf = NULL; checksum = (grub_zfs_to_cpu64((bp)->blk_prop, endian) >> 40) & 0xff; - comp = (grub_zfs_to_cpu64((bp)->blk_prop, endian)>>32) & 0xff; + comp = (grub_zfs_to_cpu64((bp)->blk_prop, endian)>>32) & 0x7f; encrypted = ((grub_zfs_to_cpu64((bp)->blk_prop, endian) >> 60) & 3); - lsize = (BP_IS_HOLE(bp) ? 0 : - (((grub_zfs_to_cpu64 ((bp)->blk_prop, endian) & 0xffff) + 1) - << SPA_MINBLOCKSHIFT)); - psize = get_psize (bp, endian); + if (BP_IS_EMBEDDED(bp)) + { + if (BPE_GET_ETYPE(bp) != BP_EMBEDDED_TYPE_DATA) + return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, + "unsupported embedded BP (type=%u)\n", + BPE_GET_ETYPE(bp)); + lsize = BPE_GET_LSIZE(bp); + psize = BF64_GET_SB(grub_zfs_to_cpu64 ((bp)->blk_prop, endian), 25, 7, 0, 1); + } + else + { + lsize = (BP_IS_HOLE(bp) ? 0 : + (((grub_zfs_to_cpu64 ((bp)->blk_prop, endian) & 0xffff) + 1) + << SPA_MINBLOCKSHIFT)); + psize = get_psize (bp, endian); + } + grub_dprintf("zfs", "zio_read: E %d: size %" PRIdGRUB_SSIZE "/%" + PRIdGRUB_SSIZE "\n", (int)BP_IS_EMBEDDED(bp), lsize, psize); if (size) *size = lsize; @@ -1849,23 +1897,31 @@ zio_read (blkptr_t *bp, grub_zfs_endian_t endian, void **buf, compbuf = *buf = grub_malloc (lsize); grub_dprintf ("zfs", "endian = %d\n", endian); - err = zio_read_data (bp, endian, compbuf, data); + if (BP_IS_EMBEDDED(bp)) + err = decode_embedded_bp_compressed(bp, compbuf); + else + { + err = zio_read_data (bp, endian, compbuf, data); + grub_memset (compbuf, 0, ALIGN_UP (psize, 16) - psize); + } if (err) { grub_free (compbuf); *buf = NULL; return err; } - grub_memset (compbuf, 0, ALIGN_UP (psize, 16) - psize); - err = zio_checksum_verify (zc, checksum, endian, - compbuf, psize); - if (err) + if (!BP_IS_EMBEDDED(bp)) { - grub_dprintf ("zfs", "incorrect checksum\n"); - grub_free (compbuf); - *buf = NULL; - return err; + err = zio_checksum_verify (zc, checksum, endian, + compbuf, psize); + if (err) + { + grub_dprintf ("zfs", "incorrect checksum\n"); + grub_free (compbuf); + *buf = NULL; + return err; + } } if (encrypted) diff --git a/include/grub/zfs/spa.h b/include/grub/zfs/spa.h index df43b6b32..8dd1fa8e3 100644 --- a/include/grub/zfs/spa.h +++ b/include/grub/zfs/spa.h @@ -126,7 +126,7 @@ typedef struct zio_cksum { * +-------+-------+-------+-------+-------+-------+-------+-------+ * 5 |G| offset3 | * +-------+-------+-------+-------+-------+-------+-------+-------+ - * 6 |BDX|lvl| type | cksum | comp | PSIZE | LSIZE | + * 6 |BDX|lvl| type | cksum |E| comp| PSIZE | LSIZE | * +-------+-------+-------+-------+-------+-------+-------+-------+ * 7 | padding | * +-------+-------+-------+-------+-------+-------+-------+-------+ @@ -160,7 +160,8 @@ typedef struct zio_cksum { * G gang block indicator * B byteorder (endianness) * D dedup - * X unused + * X encryption + * E blkptr_t contains embedded data * lvl level of indirection * type DMU object type * phys birth txg of block allocation; zero if same as logical birth txg @@ -203,8 +204,8 @@ typedef struct blkptr { #define BP_SET_LSIZE(bp, x) \ BF64_SET_SB((bp)->blk_prop, 0, 16, SPA_MINBLOCKSHIFT, 1, x) -#define BP_GET_COMPRESS(bp) BF64_GET((bp)->blk_prop, 32, 8) -#define BP_SET_COMPRESS(bp, x) BF64_SET((bp)->blk_prop, 32, 8, x) +#define BP_GET_COMPRESS(bp) BF64_GET((bp)->blk_prop, 32, 7) +#define BP_SET_COMPRESS(bp, x) BF64_SET((bp)->blk_prop, 32, 7, x) #define BP_GET_CHECKSUM(bp) BF64_GET((bp)->blk_prop, 40, 8) #define BP_SET_CHECKSUM(bp, x) BF64_SET((bp)->blk_prop, 40, 8, x) @@ -215,6 +216,8 @@ typedef struct blkptr { #define BP_GET_LEVEL(bp) BF64_GET((bp)->blk_prop, 56, 5) #define BP_SET_LEVEL(bp, x) BF64_SET((bp)->blk_prop, 56, 5, x) +#define BP_IS_EMBEDDED(bp) BF64_GET((bp)->blk_prop, 39, 1) + #define BP_GET_PROP_BIT_61(bp) BF64_GET((bp)->blk_prop, 61, 1) #define BP_SET_PROP_BIT_61(bp, x) BF64_SET((bp)->blk_prop, 61, 1, x) @@ -277,6 +280,22 @@ typedef struct blkptr { (zcp)->zc_word[3] = w3; \ } +#define BPE_GET_ETYPE(bp) BP_GET_CHECKSUM(bp) +#define BPE_GET_LSIZE(bp) \ + BF64_GET_SB((bp)->blk_prop, 0, 25, 0, 1) +#define BPE_GET_PSIZE(bp) \ + BF64_GET_SB((bp)->blk_prop, 25, 7, 0, 1) + +typedef enum bp_embedded_type { + BP_EMBEDDED_TYPE_DATA, + NUM_BP_EMBEDDED_TYPES +} bp_embedded_type_t; + +#define BPE_NUM_WORDS 14 +#define BPE_PAYLOAD_SIZE (BPE_NUM_WORDS * sizeof(grub_uint64_t)) +#define BPE_IS_PAYLOADWORD(bp, wp) \ + ((wp) != &(bp)->blk_prop && (wp) != &(bp)->blk_birth) + #define BP_IDENTITY(bp) (&(bp)->blk_dva[0]) #define BP_IS_GANG(bp) DVA_GET_GANG(BP_IDENTITY(bp)) #define DVA_IS_EMPTY(dva) ((dva)->dva_word[0] == 0ULL && \ From 6210b8e8f7b4640711dd449ca8301d06fee62334 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sun, 3 May 2015 18:55:13 +0300 Subject: [PATCH 392/722] zfs: add missing NULL check and fix incorrect buffer overwrite grub_memset should zero out padding after data end. It is not clear why it is needed at all - ZFS block is at least 512 bytes and power of two, so it is always multiple of 16 bytes. This grub_memset apparently never did anything. --- grub-core/fs/zfs/zfs.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/grub-core/fs/zfs/zfs.c b/grub-core/fs/zfs/zfs.c index 03d587d8c..08ed453a6 100644 --- a/grub-core/fs/zfs/zfs.c +++ b/grub-core/fs/zfs/zfs.c @@ -1887,14 +1887,12 @@ zio_read (blkptr_t *bp, grub_zfs_endian_t endian, void **buf, "compression algorithm %s not supported\n", decomp_table[comp].name); if (comp != ZIO_COMPRESS_OFF) - { - /* It's not really necessary to align to 16, just for safety. */ - compbuf = grub_malloc (ALIGN_UP (psize, 16)); - if (! compbuf) - return grub_errno; - } + /* It's not really necessary to align to 16, just for safety. */ + compbuf = grub_malloc (ALIGN_UP (psize, 16)); else compbuf = *buf = grub_malloc (lsize); + if (! compbuf) + return grub_errno; grub_dprintf ("zfs", "endian = %d\n", endian); if (BP_IS_EMBEDDED(bp)) @@ -1902,7 +1900,9 @@ zio_read (blkptr_t *bp, grub_zfs_endian_t endian, void **buf, else { err = zio_read_data (bp, endian, compbuf, data); - grub_memset (compbuf, 0, ALIGN_UP (psize, 16) - psize); + /* FIXME is it really necessary? */ + if (comp != ZIO_COMPRESS_OFF) + grub_memset (compbuf + psize, 0, ALIGN_UP (psize, 16) - psize); } if (err) { From 8d3c4544ffdd0289a4b0bdeb0cdc6355f801a4b3 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Mon, 4 May 2015 08:08:57 +0300 Subject: [PATCH 393/722] efinet: memory leak on module removal --- grub-core/net/drivers/efi/efinet.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/grub-core/net/drivers/efi/efinet.c b/grub-core/net/drivers/efi/efinet.c index f171f20bf..eb1e682fa 100644 --- a/grub-core/net/drivers/efi/efinet.c +++ b/grub-core/net/drivers/efi/efinet.c @@ -278,6 +278,12 @@ GRUB_MOD_FINI(efinet) FOR_NET_CARDS_SAFE (card, next) if (card->driver == &efidriver) - grub_net_card_unregister (card); + { + grub_net_card_unregister (card); + grub_free (card->txbuf); + grub_free (card->rcvbuf); + grub_free (card->name); + grub_free (card); + } } From 47b2bee3ef0ea60fc3f5bfc37f3784e559385297 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Mon, 4 May 2015 08:39:29 +0300 Subject: [PATCH 394/722] efinet: cannot free const char * pointer --- grub-core/net/drivers/efi/efinet.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/net/drivers/efi/efinet.c b/grub-core/net/drivers/efi/efinet.c index eb1e682fa..a879decdb 100644 --- a/grub-core/net/drivers/efi/efinet.c +++ b/grub-core/net/drivers/efi/efinet.c @@ -282,7 +282,7 @@ GRUB_MOD_FINI(efinet) grub_net_card_unregister (card); grub_free (card->txbuf); grub_free (card->rcvbuf); - grub_free (card->name); + grub_free ((char *)card->name); grub_free (card); } } From cc699535e57e0d0f099090e64a63037c7834f104 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Mon, 4 May 2015 09:13:53 +0300 Subject: [PATCH 395/722] Revert "efinet: memory leak on module removal" This reverts commits 47b2bee3ef0ea60fc3f5bfc37f3784e559385297 and 8d3c4544ffdd0289a4b0bdeb0cdc6355f801a4b3. It is not safe to free allocated cards, dangling pointers main remain. Such cleanup requires more changes in net core. --- grub-core/net/drivers/efi/efinet.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/grub-core/net/drivers/efi/efinet.c b/grub-core/net/drivers/efi/efinet.c index a879decdb..f171f20bf 100644 --- a/grub-core/net/drivers/efi/efinet.c +++ b/grub-core/net/drivers/efi/efinet.c @@ -278,12 +278,6 @@ GRUB_MOD_FINI(efinet) FOR_NET_CARDS_SAFE (card, next) if (card->driver == &efidriver) - { - grub_net_card_unregister (card); - grub_free (card->txbuf); - grub_free (card->rcvbuf); - grub_free ((char *)card->name); - grub_free (card); - } + grub_net_card_unregister (card); } From f8451af8251a3866cb8b7307b9917dd5d34fbd0a Mon Sep 17 00:00:00 2001 From: Fu Wei Date: Thu, 7 May 2015 15:11:04 +0200 Subject: [PATCH 396/722] arm64: Export useful functions from linux.c Signed-off-by: Fu Wei --- gentpl.py | 2 +- grub-core/loader/arm64/linux.c | 59 +++++++++++++++++----------------- grub-core/loader/i386/linux.c | 11 +++---- grub-core/loader/linux.c | 3 +- include/grub/arm64/linux.h | 11 +++++++ 5 files changed, 49 insertions(+), 37 deletions(-) diff --git a/gentpl.py b/gentpl.py index f177883f8..0fd5ba427 100644 --- a/gentpl.py +++ b/gentpl.py @@ -759,7 +759,7 @@ def image(defn, platform): if test x$(TARGET_APPLE_LINKER) = x1; then \ $(MACHO2IMG) $< $@; \ else \ - $(TARGET_OBJCOPY) $(""" + cname(defn) + """_OBJCOPYFLAGS) --strip-unneeded -R .note -R .comment -R .note.gnu.build-id -R .MIPS.abiflags -R .reginfo -R .rel.dyn -R .note.gnu.gold-version $< $@; \ + $(TARGET_OBJCOPY) $(""" + cname(defn) + """_OBJCOPYFLAGS) --strip-unneeded -R .note -R .comment -R .note.gnu.build-id -R .MIPS.abiflags -R .reginfo -R .rel.dyn -R .note.gnu.gold-version -R .hash -R .dynsym -R .dynstr -R .rel.text $< $@; \ fi """) diff --git a/grub-core/loader/arm64/linux.c b/grub-core/loader/arm64/linux.c index 564a75a80..987f5b9ee 100644 --- a/grub-core/loader/arm64/linux.c +++ b/grub-core/loader/arm64/linux.c @@ -33,12 +33,6 @@ GRUB_MOD_LICENSE ("GPLv3+"); -#define GRUB_EFI_PAGE_SHIFT 12 -#define BYTES_TO_PAGES(bytes) (((bytes) + 0xfff) >> GRUB_EFI_PAGE_SHIFT) -#define GRUB_EFI_PE_MAGIC 0x5A4D - -static grub_efi_guid_t fdt_guid = GRUB_EFI_DEVICE_TREE_GUID; - static grub_dl_t my_mod; static int loaded; @@ -58,6 +52,7 @@ static void * get_firmware_fdt (void) { grub_efi_configuration_table_t *tables; + grub_efi_guid_t fdt_guid = GRUB_EFI_DEVICE_TREE_GUID; void *firmware_fdt = NULL; unsigned int i; @@ -75,8 +70,8 @@ get_firmware_fdt (void) return firmware_fdt; } -static void -get_fdt (void) +void * +grub_linux_get_fdt (void) { void *raw_fdt; grub_size_t size; @@ -99,7 +94,7 @@ get_fdt (void) grub_dprintf ("linux", "allocating %ld bytes for fdt\n", size); fdt = grub_efi_allocate_pages (0, BYTES_TO_PAGES (size)); if (!fdt) - return; + return NULL; if (raw_fdt) { @@ -110,10 +105,11 @@ get_fdt (void) { grub_fdt_create_empty_tree (fdt, size); } + return fdt; } -static grub_err_t -check_kernel (struct grub_arm64_linux_kernel_header *lh) +grub_err_t +grub_arm64_uefi_check_image (struct grub_arm64_linux_kernel_header * lh) { if (lh->magic != GRUB_ARM64_LINUX_MAGIC) return grub_error(GRUB_ERR_BAD_OS, "invalid magic number"); @@ -131,14 +127,14 @@ check_kernel (struct grub_arm64_linux_kernel_header *lh) } static grub_err_t -finalize_params (void) +finalize_params_linux (void) { grub_efi_boot_services_t *b; + grub_efi_guid_t fdt_guid = GRUB_EFI_DEVICE_TREE_GUID; grub_efi_status_t status; int node, retval; - get_fdt (); - if (!fdt) + if (!grub_linux_get_fdt ()) goto failure; node = grub_fdt_find_subnode (fdt, 0, "chosen"); @@ -240,21 +236,16 @@ out: return grub_errno; } -static grub_err_t -grub_linux_boot (void) +grub_err_t +grub_arm64_uefi_boot_image (grub_addr_t addr, grub_size_t size, char *args) { grub_efi_memory_mapped_device_path_t *mempath; grub_efi_handle_t image_handle; grub_efi_boot_services_t *b; grub_efi_status_t status; - grub_err_t retval; grub_efi_loaded_image_t *loaded_image; int len; - retval = finalize_params(); - if (retval != GRUB_ERR_NONE) - return retval; - mempath = grub_malloc (2 * sizeof (grub_efi_memory_mapped_device_path_t)); if (!mempath) return grub_errno; @@ -263,8 +254,8 @@ grub_linux_boot (void) mempath[0].header.subtype = GRUB_EFI_MEMORY_MAPPED_DEVICE_PATH_SUBTYPE; mempath[0].header.length = grub_cpu_to_le16_compile_time (sizeof (*mempath)); mempath[0].memory_type = GRUB_EFI_LOADER_DATA; - mempath[0].start_address = (grub_addr_t) kernel_addr; - mempath[0].end_address = (grub_addr_t) kernel_addr + kernel_size; + mempath[0].start_address = addr; + mempath[0].end_address = addr + size; mempath[1].header.type = GRUB_EFI_END_DEVICE_PATH_TYPE; mempath[1].header.subtype = GRUB_EFI_END_ENTIRE_DEVICE_PATH_SUBTYPE; @@ -273,16 +264,16 @@ grub_linux_boot (void) b = grub_efi_system_table->boot_services; status = b->load_image (0, grub_efi_image_handle, (grub_efi_device_path_t *) mempath, - kernel_addr, kernel_size, &image_handle); + (void *) addr, size, &image_handle); if (status != GRUB_EFI_SUCCESS) return grub_error (GRUB_ERR_BAD_OS, "cannot load image"); - grub_dprintf ("linux", "linux command line: '%s'\n", linux_args); + grub_dprintf ("linux", "linux command line: '%s'\n", args); /* Convert command line to UCS-2 */ loaded_image = grub_efi_get_loaded_image (image_handle); loaded_image->load_options_size = len = - (grub_strlen (linux_args) + 1) * sizeof (grub_efi_char16_t); + (grub_strlen (args) + 1) * sizeof (grub_efi_char16_t); loaded_image->load_options = grub_efi_allocate_pages (0, BYTES_TO_PAGES (loaded_image->load_options_size)); @@ -291,9 +282,9 @@ grub_linux_boot (void) loaded_image->load_options_size = 2 * grub_utf8_to_utf16 (loaded_image->load_options, len, - (grub_uint8_t *) linux_args, len, NULL); + (grub_uint8_t *) args, len, NULL); - grub_dprintf("linux", "starting image %p\n", image_handle); + grub_dprintf ("linux", "starting image %p\n", image_handle); status = b->start_image (image_handle, 0, NULL); /* When successful, not reached */ @@ -304,6 +295,16 @@ grub_linux_boot (void) return grub_errno; } +static grub_err_t +grub_linux_boot (void) +{ + if (finalize_params_linux () != GRUB_ERR_NONE) + return grub_errno; + + return (grub_arm64_uefi_boot_image((grub_addr_t)kernel_addr, + kernel_size, linux_args)); +} + static grub_err_t grub_linux_unload (void) { @@ -400,7 +401,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), if (grub_file_read (file, &lh, sizeof (lh)) < (long) sizeof (lh)) return grub_errno; - if (check_kernel (&lh) != GRUB_ERR_NONE) + if (grub_arm64_uefi_check_image (&lh) != GRUB_ERR_NONE) goto fail; grub_loader_unset(); diff --git a/grub-core/loader/i386/linux.c b/grub-core/loader/i386/linux.c index 291f7289f..fddcc461d 100644 --- a/grub-core/loader/i386/linux.c +++ b/grub-core/loader/i386/linux.c @@ -69,7 +69,6 @@ static grub_addr_t prot_mode_target; static void *initrd_mem; static grub_addr_t initrd_mem_target; static grub_size_t prot_init_space; -static grub_uint32_t initrd_pages; static struct grub_relocator *relocator = NULL; static void *efi_mmap_buf; static grub_size_t maximal_cmdline_size; @@ -1046,7 +1045,7 @@ static grub_err_t grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), int argc, char *argv[]) { - grub_size_t size = 0; + grub_size_t size = 0, aligned_size = 0; grub_addr_t addr_min, addr_max; grub_addr_t addr; grub_err_t err; @@ -1068,8 +1067,7 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), goto fail; size = grub_get_initrd_size (&initrd_ctx); - - initrd_pages = (page_align (size) >> 12); + aligned_size = ALIGN_UP (size, 4096); /* Get the highest address available for the initrd. */ if (grub_le_to_cpu16 (linux_params.version) >= 0x0203) @@ -1097,7 +1095,7 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), addr_min = (grub_addr_t) prot_mode_target + prot_init_space; /* Put the initrd as high as possible, 4KiB aligned. */ - addr = (addr_max - size) & ~0xFFF; + addr = (addr_max - aligned_size) & ~0xFFF; if (addr < addr_min) { @@ -1108,7 +1106,8 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), { grub_relocator_chunk_t ch; err = grub_relocator_alloc_chunk_align (relocator, &ch, - addr_min, addr, size, 0x1000, + addr_min, addr, aligned_size, + 0x1000, GRUB_RELOCATOR_PREFERENCE_HIGH, 1); if (err) diff --git a/grub-core/loader/linux.c b/grub-core/loader/linux.c index 117232f0c..a63a11a7f 100644 --- a/grub-core/loader/linux.c +++ b/grub-core/loader/linux.c @@ -205,7 +205,8 @@ grub_initrd_init (int argc, char *argv[], initrd_ctx->nfiles++; initrd_ctx->components[i].size = grub_file_size (initrd_ctx->components[i].file); - initrd_ctx->size += ALIGN_UP (initrd_ctx->components[i].size, 4); + if (argc != 1) + initrd_ctx->size += ALIGN_UP (initrd_ctx->components[i].size, 4); } if (newc) diff --git a/include/grub/arm64/linux.h b/include/grub/arm64/linux.h index 864e5dc36..65796d907 100644 --- a/include/grub/arm64/linux.h +++ b/include/grub/arm64/linux.h @@ -23,6 +23,10 @@ #define GRUB_ARM64_LINUX_MAGIC 0x644d5241 /* 'ARM\x64' */ +#define GRUB_EFI_PAGE_SHIFT 12 +#define BYTES_TO_PAGES(bytes) (((bytes) + 0xfff) >> GRUB_EFI_PAGE_SHIFT) +#define GRUB_EFI_PE_MAGIC 0x5A4D + /* From linux/Documentation/arm64/booting.txt */ struct grub_arm64_linux_kernel_header { @@ -38,4 +42,11 @@ struct grub_arm64_linux_kernel_header grub_uint32_t hdr_offset; /* Offset of PE/COFF header */ }; +/* Declare the functions for getting dtb and checking/booting image */ +void *grub_linux_get_fdt (void); +grub_err_t grub_arm64_uefi_check_image (struct grub_arm64_linux_kernel_header + *lh); +grub_err_t grub_arm64_uefi_boot_image (grub_addr_t addr, grub_size_t size, + char *args); + #endif /* ! GRUB_LINUX_CPU_HEADER */ From cfe2ae89360954f0cbc585f5c72e60a07eb066a2 Mon Sep 17 00:00:00 2001 From: Fu Wei Date: Thu, 7 May 2015 15:13:25 +0200 Subject: [PATCH 397/722] fdt.h: Add grub_fdt_set_reg64 macro Signed-off-by: Fu Wei --- include/grub/fdt.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/include/grub/fdt.h b/include/grub/fdt.h index 301699830..fdfca75bf 100644 --- a/include/grub/fdt.h +++ b/include/grub/fdt.h @@ -117,4 +117,16 @@ int grub_fdt_set_prop (void *fdt, unsigned int nodeoffset, const char *name, grub_fdt_set_prop ((fdt), (nodeoffset), (name), &_val, 8); \ }) +/* Setup "reg" property for + * #address-cells = <0x2> + * #size-cells = <0x2> + */ +#define grub_fdt_set_reg64(fdt, nodeoffset, addr, size) \ +({ \ + grub_uint64_t reg_64[2]; \ + reg_64[0] = grub_cpu_to_be64(addr); \ + reg_64[1] = grub_cpu_to_be64(size); \ + grub_fdt_set_prop ((fdt), (nodeoffset), "reg", reg_64, 16); \ +}) + #endif /* ! GRUB_FDT_HEADER */ From 9f731abc7f960a96a4c58d89717915e632837389 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Thu, 7 May 2015 16:21:34 +0200 Subject: [PATCH 398/722] Revert parts accidentally committed 2 commits ago. --- gentpl.py | 2 +- grub-core/loader/i386/linux.c | 11 ++++++----- grub-core/loader/linux.c | 3 +-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/gentpl.py b/gentpl.py index 0fd5ba427..f177883f8 100644 --- a/gentpl.py +++ b/gentpl.py @@ -759,7 +759,7 @@ def image(defn, platform): if test x$(TARGET_APPLE_LINKER) = x1; then \ $(MACHO2IMG) $< $@; \ else \ - $(TARGET_OBJCOPY) $(""" + cname(defn) + """_OBJCOPYFLAGS) --strip-unneeded -R .note -R .comment -R .note.gnu.build-id -R .MIPS.abiflags -R .reginfo -R .rel.dyn -R .note.gnu.gold-version -R .hash -R .dynsym -R .dynstr -R .rel.text $< $@; \ + $(TARGET_OBJCOPY) $(""" + cname(defn) + """_OBJCOPYFLAGS) --strip-unneeded -R .note -R .comment -R .note.gnu.build-id -R .MIPS.abiflags -R .reginfo -R .rel.dyn -R .note.gnu.gold-version $< $@; \ fi """) diff --git a/grub-core/loader/i386/linux.c b/grub-core/loader/i386/linux.c index fddcc461d..291f7289f 100644 --- a/grub-core/loader/i386/linux.c +++ b/grub-core/loader/i386/linux.c @@ -69,6 +69,7 @@ static grub_addr_t prot_mode_target; static void *initrd_mem; static grub_addr_t initrd_mem_target; static grub_size_t prot_init_space; +static grub_uint32_t initrd_pages; static struct grub_relocator *relocator = NULL; static void *efi_mmap_buf; static grub_size_t maximal_cmdline_size; @@ -1045,7 +1046,7 @@ static grub_err_t grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), int argc, char *argv[]) { - grub_size_t size = 0, aligned_size = 0; + grub_size_t size = 0; grub_addr_t addr_min, addr_max; grub_addr_t addr; grub_err_t err; @@ -1067,7 +1068,8 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), goto fail; size = grub_get_initrd_size (&initrd_ctx); - aligned_size = ALIGN_UP (size, 4096); + + initrd_pages = (page_align (size) >> 12); /* Get the highest address available for the initrd. */ if (grub_le_to_cpu16 (linux_params.version) >= 0x0203) @@ -1095,7 +1097,7 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), addr_min = (grub_addr_t) prot_mode_target + prot_init_space; /* Put the initrd as high as possible, 4KiB aligned. */ - addr = (addr_max - aligned_size) & ~0xFFF; + addr = (addr_max - size) & ~0xFFF; if (addr < addr_min) { @@ -1106,8 +1108,7 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), { grub_relocator_chunk_t ch; err = grub_relocator_alloc_chunk_align (relocator, &ch, - addr_min, addr, aligned_size, - 0x1000, + addr_min, addr, size, 0x1000, GRUB_RELOCATOR_PREFERENCE_HIGH, 1); if (err) diff --git a/grub-core/loader/linux.c b/grub-core/loader/linux.c index a63a11a7f..117232f0c 100644 --- a/grub-core/loader/linux.c +++ b/grub-core/loader/linux.c @@ -205,8 +205,7 @@ grub_initrd_init (int argc, char *argv[], initrd_ctx->nfiles++; initrd_ctx->components[i].size = grub_file_size (initrd_ctx->components[i].file); - if (argc != 1) - initrd_ctx->size += ALIGN_UP (initrd_ctx->components[i].size, 4); + initrd_ctx->size += ALIGN_UP (initrd_ctx->components[i].size, 4); } if (newc) From e5b4ba8c2b2cfbb84e5b8254fb7d0b15b799fe78 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Thu, 7 May 2015 16:23:39 +0200 Subject: [PATCH 399/722] linux.c: Ensure that initrd is page-aligned. --- grub-core/loader/i386/linux.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/grub-core/loader/i386/linux.c b/grub-core/loader/i386/linux.c index 291f7289f..fddcc461d 100644 --- a/grub-core/loader/i386/linux.c +++ b/grub-core/loader/i386/linux.c @@ -69,7 +69,6 @@ static grub_addr_t prot_mode_target; static void *initrd_mem; static grub_addr_t initrd_mem_target; static grub_size_t prot_init_space; -static grub_uint32_t initrd_pages; static struct grub_relocator *relocator = NULL; static void *efi_mmap_buf; static grub_size_t maximal_cmdline_size; @@ -1046,7 +1045,7 @@ static grub_err_t grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), int argc, char *argv[]) { - grub_size_t size = 0; + grub_size_t size = 0, aligned_size = 0; grub_addr_t addr_min, addr_max; grub_addr_t addr; grub_err_t err; @@ -1068,8 +1067,7 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), goto fail; size = grub_get_initrd_size (&initrd_ctx); - - initrd_pages = (page_align (size) >> 12); + aligned_size = ALIGN_UP (size, 4096); /* Get the highest address available for the initrd. */ if (grub_le_to_cpu16 (linux_params.version) >= 0x0203) @@ -1097,7 +1095,7 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), addr_min = (grub_addr_t) prot_mode_target + prot_init_space; /* Put the initrd as high as possible, 4KiB aligned. */ - addr = (addr_max - size) & ~0xFFF; + addr = (addr_max - aligned_size) & ~0xFFF; if (addr < addr_min) { @@ -1108,7 +1106,8 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), { grub_relocator_chunk_t ch; err = grub_relocator_alloc_chunk_align (relocator, &ch, - addr_min, addr, size, 0x1000, + addr_min, addr, aligned_size, + 0x1000, GRUB_RELOCATOR_PREFERENCE_HIGH, 1); if (err) From 5fd1cb980af603126b82f421417f15326b0ca38d Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Thu, 7 May 2015 16:34:34 +0200 Subject: [PATCH 400/722] grub-mkrescue: Recognize -output as an alias of --output. This helps us to be in line with xorriso -as mkisofs. Suggested by: Thomas Schmitt --- util/grub-mkrescue.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/util/grub-mkrescue.c b/util/grub-mkrescue.c index 815fc9175..5a7993fbb 100644 --- a/util/grub-mkrescue.c +++ b/util/grub-mkrescue.c @@ -451,6 +451,12 @@ main (int argc, char *argv[]) int i; for (i = 1; i < argc; i++) { + if (strcmp (argv[i], "-output") == 0) { + argp_argv[argp_argc++] = "--output"; + i++; + argp_argv[argp_argc++] = argv[i]; + continue; + } switch (args_to_eat (argv[i])) { case 2: From 9916ed6f82d12b203b61cbc6d6bb9c56af707c02 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Thu, 7 May 2015 17:09:58 +0200 Subject: [PATCH 401/722] grub-install-common: Increase buf size to 8192 as modinfo.sh is bigger. --- util/grub-install-common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/grub-install-common.c b/util/grub-install-common.c index 37c1a98b9..0364b327c 100644 --- a/util/grub-install-common.c +++ b/util/grub-install-common.c @@ -902,7 +902,7 @@ grub_install_get_target (const char *src) { char *fn; grub_util_fd_t f; - char buf[2048]; + char buf[8192]; ssize_t r; char *c, *pl, *p; size_t i; From 71783dc9780c1e1897a59ec3273e6259807f47eb Mon Sep 17 00:00:00 2001 From: Daniel Kiper Date: Thu, 7 May 2015 18:00:47 +0200 Subject: [PATCH 402/722] i386/relocator: Remove unused extern grub_relocator64_rip_addr Signed-off-by: Daniel Kiper --- grub-core/lib/i386/relocator.c | 1 - 1 file changed, 1 deletion(-) diff --git a/grub-core/lib/i386/relocator.c b/grub-core/lib/i386/relocator.c index ffaf25f08..71dd4f0ab 100644 --- a/grub-core/lib/i386/relocator.c +++ b/grub-core/lib/i386/relocator.c @@ -64,7 +64,6 @@ extern grub_uint64_t grub_relocator64_rbx; extern grub_uint64_t grub_relocator64_rcx; extern grub_uint64_t grub_relocator64_rdx; extern grub_uint64_t grub_relocator64_rip; -extern grub_uint64_t grub_relocator64_rip_addr; extern grub_uint64_t grub_relocator64_rsp; extern grub_uint64_t grub_relocator64_rsi; extern grub_addr_t grub_relocator64_cr3; From a8c473288d3f0a5e17a903a5121dea1a695dda3b Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Thu, 7 May 2015 20:24:24 +0300 Subject: [PATCH 403/722] loader/linux: do not pad initrd with zeroes at the end Syslinux memdisk is using initrd image and needs to know uncompressed size in advance. For gzip uncompressed size is at the end of compressed stream. Grub padded each input file to 4 bytes at the end, which means syslinux got wrong size. Linux initramfs loader apparently does not care about trailing alignment. So change code to align beginning of each file instead which atomatically gives us the correct size for single file. Reported-By: David Shaw --- grub-core/loader/linux.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/grub-core/loader/linux.c b/grub-core/loader/linux.c index 117232f0c..d2cd591f6 100644 --- a/grub-core/loader/linux.c +++ b/grub-core/loader/linux.c @@ -161,6 +161,9 @@ grub_initrd_init (int argc, char *argv[], for (i = 0; i < argc; i++) { const char *fname = argv[i]; + + initrd_ctx->size = ALIGN_UP (initrd_ctx->size, 4); + if (grub_memcmp (argv[i], "newc:", 5) == 0) { const char *ptr, *eptr; @@ -205,7 +208,7 @@ grub_initrd_init (int argc, char *argv[], initrd_ctx->nfiles++; initrd_ctx->components[i].size = grub_file_size (initrd_ctx->components[i].file); - initrd_ctx->size += ALIGN_UP (initrd_ctx->components[i].size, 4); + initrd_ctx->size += initrd_ctx->components[i].size; } if (newc) @@ -248,10 +251,12 @@ grub_initrd_load (struct grub_linux_initrd_context *initrd_ctx, int i; int newc = 0; struct dir *root = 0; + grub_ssize_t cursize = 0; for (i = 0; i < initrd_ctx->nfiles; i++) { - grub_ssize_t cursize; + grub_memset (ptr, 0, ALIGN_UP_OVERHEAD (cursize, 4)); + ptr += ALIGN_UP_OVERHEAD (cursize, 4); if (initrd_ctx->components[i].newc_name) { @@ -283,8 +288,6 @@ grub_initrd_load (struct grub_linux_initrd_context *initrd_ctx, return grub_errno; } ptr += cursize; - grub_memset (ptr, 0, ALIGN_UP_OVERHEAD (cursize, 4)); - ptr += ALIGN_UP_OVERHEAD (cursize, 4); } if (newc) ptr = make_header (ptr, "TRAILER!!!", sizeof ("TRAILER!!!") - 1, 0, 0); From 16a7e723ea37d4596348a76f54a6675c6e03fedc Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Thu, 7 May 2015 20:33:28 +0300 Subject: [PATCH 404/722] convert to, not from, CPU byte order in DNS receive function --- grub-core/net/dns.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/grub-core/net/dns.c b/grub-core/net/dns.c index 0b771fb10..9d0c8fcea 100644 --- a/grub-core/net/dns.c +++ b/grub-core/net/dns.c @@ -262,7 +262,7 @@ recv_hook (grub_net_udp_socket_t sock __attribute__ ((unused)), grub_netbuff_free (nb); return GRUB_ERR_NONE; } - for (i = 0; i < grub_cpu_to_be16 (head->qdcount); i++) + for (i = 0; i < grub_be_to_cpu16 (head->qdcount); i++) { if (ptr >= nb->tail) { @@ -277,7 +277,7 @@ recv_hook (grub_net_udp_socket_t sock __attribute__ ((unused)), ptr += 4; } *data->addresses = grub_malloc (sizeof ((*data->addresses)[0]) - * grub_cpu_to_be16 (head->ancount)); + * grub_be_to_cpu16 (head->ancount)); if (!*data->addresses) { grub_errno = GRUB_ERR_NONE; @@ -286,7 +286,7 @@ recv_hook (grub_net_udp_socket_t sock __attribute__ ((unused)), } reparse_ptr = ptr; reparse: - for (i = 0, ptr = reparse_ptr; i < grub_cpu_to_be16 (head->ancount); i++) + for (i = 0, ptr = reparse_ptr; i < grub_be_to_cpu16 (head->ancount); i++) { int ignored = 0; grub_uint8_t class; From 7b386b703154c0901c4616badf18ddb260954bc1 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Thu, 7 May 2015 20:37:16 +0300 Subject: [PATCH 405/722] efidisk: move device path helpers in core for efinet --- grub-core/disk/efi/efidisk.c | 61 ++++++------------------------------ grub-core/kern/efi/efi.c | 41 ++++++++++++++++++++++++ include/grub/efi/efi.h | 4 +++ 3 files changed, 55 insertions(+), 51 deletions(-) diff --git a/grub-core/disk/efi/efidisk.c b/grub-core/disk/efi/efidisk.c index 60a6d3c50..a8783a3c1 100644 --- a/grub-core/disk/efi/efidisk.c +++ b/grub-core/disk/efi/efidisk.c @@ -43,47 +43,6 @@ static struct grub_efidisk_data *fd_devices; static struct grub_efidisk_data *hd_devices; static struct grub_efidisk_data *cd_devices; -/* Duplicate a device path. */ -static grub_efi_device_path_t * -duplicate_device_path (const grub_efi_device_path_t *dp) -{ - grub_efi_device_path_t *p; - grub_size_t total_size = 0; - - for (p = (grub_efi_device_path_t *) dp; - ; - p = GRUB_EFI_NEXT_DEVICE_PATH (p)) - { - total_size += GRUB_EFI_DEVICE_PATH_LENGTH (p); - if (GRUB_EFI_END_ENTIRE_DEVICE_PATH (p)) - break; - } - - p = grub_malloc (total_size); - if (! p) - return 0; - - grub_memcpy (p, dp, total_size); - return p; -} - -/* Return the device path node right before the end node. */ -static grub_efi_device_path_t * -find_last_device_path (const grub_efi_device_path_t *dp) -{ - grub_efi_device_path_t *next, *p; - - if (GRUB_EFI_END_ENTIRE_DEVICE_PATH (dp)) - return 0; - - for (p = (grub_efi_device_path_t *) dp, next = GRUB_EFI_NEXT_DEVICE_PATH (p); - ! GRUB_EFI_END_ENTIRE_DEVICE_PATH (next); - p = next, next = GRUB_EFI_NEXT_DEVICE_PATH (next)) - ; - - return p; -} - static struct grub_efidisk_data * make_devices (void) { @@ -110,7 +69,7 @@ make_devices (void) if (! dp) continue; - ldp = find_last_device_path (dp); + ldp = grub_efi_find_last_device_path (dp); if (! ldp) /* This is empty. Why? */ continue; @@ -150,11 +109,11 @@ find_parent_device (struct grub_efidisk_data *devices, grub_efi_device_path_t *dp, *ldp; struct grub_efidisk_data *parent; - dp = duplicate_device_path (d->device_path); + dp = grub_efi_duplicate_device_path (d->device_path); if (! dp) return 0; - ldp = find_last_device_path (dp); + ldp = grub_efi_find_last_device_path (dp); ldp->type = GRUB_EFI_END_DEVICE_PATH_TYPE; ldp->subtype = GRUB_EFI_END_ENTIRE_DEVICE_PATH_SUBTYPE; ldp->length = sizeof (*ldp); @@ -180,11 +139,11 @@ is_child (struct grub_efidisk_data *child, grub_efi_device_path_t *dp, *ldp; int ret; - dp = duplicate_device_path (child->device_path); + dp = grub_efi_duplicate_device_path (child->device_path); if (! dp) return 0; - ldp = find_last_device_path (dp); + ldp = grub_efi_find_last_device_path (dp); ldp->type = GRUB_EFI_END_DEVICE_PATH_TYPE; ldp->subtype = GRUB_EFI_END_ENTIRE_DEVICE_PATH_SUBTYPE; ldp->length = sizeof (*ldp); @@ -207,8 +166,8 @@ add_device (struct grub_efidisk_data **devices, struct grub_efidisk_data *d) { int ret; - ret = grub_efi_compare_device_paths (find_last_device_path ((*p)->device_path), - find_last_device_path (d->device_path)); + ret = grub_efi_compare_device_paths (grub_efi_find_last_device_path ((*p)->device_path), + grub_efi_find_last_device_path (d->device_path)); if (ret == 0) ret = grub_efi_compare_device_paths ((*p)->device_path, d->device_path); @@ -795,7 +754,7 @@ grub_efidisk_get_device_name (grub_efi_handle_t *handle) if (! dp) return 0; - ldp = find_last_device_path (dp); + ldp = grub_efi_find_last_device_path (dp); if (! ldp) return 0; @@ -810,14 +769,14 @@ grub_efidisk_get_device_name (grub_efi_handle_t *handle) /* It is necessary to duplicate the device path so that GRUB can overwrite it. */ - dup_dp = duplicate_device_path (dp); + dup_dp = grub_efi_duplicate_device_path (dp); if (! dup_dp) return 0; while (1) { grub_efi_device_path_t *dup_ldp; - dup_ldp = find_last_device_path (dup_dp); + dup_ldp = grub_efi_find_last_device_path (dup_dp); if (!(GRUB_EFI_DEVICE_PATH_TYPE (dup_ldp) == GRUB_EFI_MEDIA_DEVICE_PATH_TYPE && (GRUB_EFI_DEVICE_PATH_SUBTYPE (dup_ldp) == GRUB_EFI_CDROM_DEVICE_PATH_SUBTYPE || GRUB_EFI_DEVICE_PATH_SUBTYPE (dup_ldp) == GRUB_EFI_HARD_DRIVE_DEVICE_PATH_SUBTYPE))) diff --git a/grub-core/kern/efi/efi.c b/grub-core/kern/efi/efi.c index b9eb1ab1e..49a150133 100644 --- a/grub-core/kern/efi/efi.c +++ b/grub-core/kern/efi/efi.c @@ -394,6 +394,47 @@ grub_efi_get_device_path (grub_efi_handle_t handle) GRUB_EFI_OPEN_PROTOCOL_GET_PROTOCOL); } +/* Return the device path node right before the end node. */ +grub_efi_device_path_t * +grub_efi_find_last_device_path (const grub_efi_device_path_t *dp) +{ + grub_efi_device_path_t *next, *p; + + if (GRUB_EFI_END_ENTIRE_DEVICE_PATH (dp)) + return 0; + + for (p = (grub_efi_device_path_t *) dp, next = GRUB_EFI_NEXT_DEVICE_PATH (p); + ! GRUB_EFI_END_ENTIRE_DEVICE_PATH (next); + p = next, next = GRUB_EFI_NEXT_DEVICE_PATH (next)) + ; + + return p; +} + +/* Duplicate a device path. */ +grub_efi_device_path_t * +grub_efi_duplicate_device_path (const grub_efi_device_path_t *dp) +{ + grub_efi_device_path_t *p; + grub_size_t total_size = 0; + + for (p = (grub_efi_device_path_t *) dp; + ; + p = GRUB_EFI_NEXT_DEVICE_PATH (p)) + { + total_size += GRUB_EFI_DEVICE_PATH_LENGTH (p); + if (GRUB_EFI_END_ENTIRE_DEVICE_PATH (p)) + break; + } + + p = grub_malloc (total_size); + if (! p) + return 0; + + grub_memcpy (p, dp, total_size); + return p; +} + static void dump_vendor_path (const char *type, grub_efi_vendor_device_path_t *vendor) { diff --git a/include/grub/efi/efi.h b/include/grub/efi/efi.h index 489cf9e6d..0e6fd86b0 100644 --- a/include/grub/efi/efi.h +++ b/include/grub/efi/efi.h @@ -53,6 +53,10 @@ void EXPORT_FUNC(grub_efi_print_device_path) (grub_efi_device_path_t *dp); char *EXPORT_FUNC(grub_efi_get_filename) (grub_efi_device_path_t *dp); grub_efi_device_path_t * EXPORT_FUNC(grub_efi_get_device_path) (grub_efi_handle_t handle); +grub_efi_device_path_t * +EXPORT_FUNC(grub_efi_find_last_device_path) (const grub_efi_device_path_t *dp); +grub_efi_device_path_t * +EXPORT_FUNC(grub_efi_duplicate_device_path) (const grub_efi_device_path_t *dp); grub_err_t EXPORT_FUNC (grub_efi_finish_boot_services) (grub_efi_uintn_t *outbuf_size, void *outbuf, grub_efi_uintn_t *map_key, grub_efi_uintn_t *efi_desc_size, From c52ae40570c3bfbcca22d2195f5e6b31009d8a3f Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Thu, 7 May 2015 20:37:17 +0300 Subject: [PATCH 406/722] efinet: skip virtual IPv4 and IPv6 devices when enumerating cards EDK2 PXE driver creates two child devices - IPv4 and IPv6 - with bound SNP instance. This means we get three cards for every physical adapter when enumerating. Not only is this confusing, this may result in grub ignoring packets that come in via the "wrong" card. Example of device hierarchy is Ctrl[91] PciRoot(0x0)/Pci(0x3,0x0) Ctrl[95] PciRoot(0x0)/Pci(0x3,0x0)/MAC(525400123456,0x1) Ctrl[B4] PciRoot(0x0)/Pci(0x3,0x0)/MAC(525400123456,0x1)/IPv4(0.0.0.0) Ctrl[BC] PciRoot(0x0)/Pci(0x3,0x0)/MAC(525400123456,0x1)/IPv6(0000:0000:0000:0000:0000:0000:0000:0000) Skip PXE created virtual devices when enumerating cards. Make sure to find real card when applying initial autoconfiguration during PXE boot, this information is associated with one of child devices. --- grub-core/net/drivers/efi/efinet.c | 51 +++++++++++++++++++++++++++++- 1 file changed, 50 insertions(+), 1 deletion(-) diff --git a/grub-core/net/drivers/efi/efinet.c b/grub-core/net/drivers/efi/efinet.c index f171f20bf..2b53e9ef6 100644 --- a/grub-core/net/drivers/efi/efinet.c +++ b/grub-core/net/drivers/efi/efinet.c @@ -174,6 +174,29 @@ grub_efinet_findcards (void) { grub_efi_simple_network_t *net; struct grub_net_card *card; + grub_efi_device_path_t *dp, *parent = NULL, *child = NULL; + + /* EDK2 UEFI PXE driver creates IPv4 and IPv6 messaging devices as + children of main MAC messaging device. We only need one device with + bound SNP per physical card, otherwise they compete with each other + when polling for incoming packets. + */ + dp = grub_efi_get_device_path (*handle); + if (!dp) + continue; + for (; ! GRUB_EFI_END_ENTIRE_DEVICE_PATH (dp); dp = GRUB_EFI_NEXT_DEVICE_PATH (dp)) + { + parent = child; + child = dp; + } + if (child + && GRUB_EFI_DEVICE_PATH_TYPE (child) == GRUB_EFI_MESSAGING_DEVICE_PATH_TYPE + && (GRUB_EFI_DEVICE_PATH_SUBTYPE (child) == GRUB_EFI_IPV4_DEVICE_PATH_SUBTYPE + || GRUB_EFI_DEVICE_PATH_SUBTYPE (child) == GRUB_EFI_IPV6_DEVICE_PATH_SUBTYPE) + && parent + && GRUB_EFI_DEVICE_PATH_TYPE (parent) == GRUB_EFI_MESSAGING_DEVICE_PATH_TYPE + && GRUB_EFI_DEVICE_PATH_SUBTYPE (parent) == GRUB_EFI_MAC_ADDRESS_DEVICE_PATH_SUBTYPE) + continue; net = grub_efi_open_protocol (*handle, &net_io_guid, GRUB_EFI_OPEN_PROTOCOL_GET_PROTOCOL); @@ -251,7 +274,33 @@ grub_efi_net_config_real (grub_efi_handle_t hnd, char **device, if (! cdp) continue; if (grub_efi_compare_device_paths (dp, cdp) != 0) - continue; + { + grub_efi_device_path_t *ldp, *dup_dp, *dup_ldp; + int match; + + /* EDK2 UEFI PXE driver creates pseudo devices with type IPv4/IPv6 + as children of Ethernet card and binds PXE and Load File protocols + to it. Loaded Image Device Path protocol will point to these pseudo + devices. We skip them when enumerating cards, so here we need to + find matching MAC device. + */ + ldp = grub_efi_find_last_device_path (dp); + if (GRUB_EFI_DEVICE_PATH_TYPE (ldp) != GRUB_EFI_MESSAGING_DEVICE_PATH_TYPE + || (GRUB_EFI_DEVICE_PATH_SUBTYPE (ldp) != GRUB_EFI_IPV4_DEVICE_PATH_SUBTYPE + && GRUB_EFI_DEVICE_PATH_SUBTYPE (ldp) != GRUB_EFI_IPV6_DEVICE_PATH_SUBTYPE)) + continue; + dup_dp = grub_efi_duplicate_device_path (dp); + if (!dup_dp) + continue; + dup_ldp = grub_efi_find_last_device_path (dup_dp); + dup_ldp->type = GRUB_EFI_END_DEVICE_PATH_TYPE; + dup_ldp->subtype = GRUB_EFI_END_ENTIRE_DEVICE_PATH_SUBTYPE; + dup_ldp->length = sizeof (*dup_ldp); + match = grub_efi_compare_device_paths (dup_dp, cdp) == 0; + grub_free (dup_dp); + if (!match) + continue; + } pxe = grub_efi_open_protocol (hnd, &pxe_io_guid, GRUB_EFI_OPEN_PROTOCOL_GET_PROTOCOL); if (! pxe) From 49426e9fd2e562c73a4f1206f32eff9e424a1a73 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Thu, 7 May 2015 20:37:17 +0300 Subject: [PATCH 407/722] efinet: open Simple Network Protocol exclusively EDK2 network stack is based on Managed Network Protocol which is layered on top of Simple Management Protocol and does background polling. This polling races with grub for received (and probably trasmitted) packets which causes either serious slowdown or complete failure to load files. Open SNP device exclusively. This destroys all child MNP instances and stops background polling. Exclusive open cannot be done when enumerating cards, as it would destroy PXE information we need to autoconfigure interface; and it cannot be done during autoconfiguration as we need to do it for non-PXE boot as well. So move SNP open to card ->open method and add matching ->close to clean up. Based on patch from Mark Salter Also-By: Mark Salter Closes: 41731 --- grub-core/net/drivers/efi/efinet.c | 46 ++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/grub-core/net/drivers/efi/efinet.c b/grub-core/net/drivers/efi/efinet.c index 2b53e9ef6..5533515fd 100644 --- a/grub-core/net/drivers/efi/efinet.c +++ b/grub-core/net/drivers/efi/efinet.c @@ -142,9 +142,55 @@ get_card_packet (struct grub_net_card *dev) return nb; } +static grub_err_t +open_card (struct grub_net_card *dev) +{ + grub_efi_simple_network_t *net; + + /* Try to reopen SNP exlusively to close any active MNP protocol instance + that may compete for packet polling + */ + net = grub_efi_open_protocol (dev->efi_handle, &net_io_guid, + GRUB_EFI_OPEN_PROTOCOL_BY_EXCLUSIVE); + if (net) + { + if (net->mode->state == GRUB_EFI_NETWORK_STOPPED + && efi_call_1 (net->start, net) != GRUB_EFI_SUCCESS) + return grub_error (GRUB_ERR_NET_NO_CARD, "%s: net start failed", + dev->name); + + if (net->mode->state == GRUB_EFI_NETWORK_STOPPED) + return grub_error (GRUB_ERR_NET_NO_CARD, "%s: card stopped", + dev->name); + + if (net->mode->state == GRUB_EFI_NETWORK_STARTED + && efi_call_3 (net->initialize, net, 0, 0) != GRUB_EFI_SUCCESS) + return grub_error (GRUB_ERR_NET_NO_CARD, "%s: net initialize failed", + dev->name); + + efi_call_4 (grub_efi_system_table->boot_services->close_protocol, + dev->efi_net, &net_io_guid, + grub_efi_image_handle, dev->efi_handle); + dev->efi_net = net; + } + + /* If it failed we just try to run as best as we can */ + return GRUB_ERR_NONE; +} + +static void +close_card (struct grub_net_card *dev) +{ + efi_call_4 (grub_efi_system_table->boot_services->close_protocol, + dev->efi_net, &net_io_guid, + grub_efi_image_handle, dev->efi_handle); +} + static struct grub_net_card_driver efidriver = { .name = "efinet", + .open = open_card, + .close = close_card, .send = send_card_buffer, .recv = get_card_packet }; From 2dcf260d899f65cd84e4f676e03d76f51ae01736 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Thu, 7 May 2015 19:45:06 +0200 Subject: [PATCH 408/722] util/grub-mkrescue: Fix compilation --- util/grub-mkrescue.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/grub-mkrescue.c b/util/grub-mkrescue.c index 5a7993fbb..451182647 100644 --- a/util/grub-mkrescue.c +++ b/util/grub-mkrescue.c @@ -452,7 +452,7 @@ main (int argc, char *argv[]) for (i = 1; i < argc; i++) { if (strcmp (argv[i], "-output") == 0) { - argp_argv[argp_argc++] = "--output"; + argp_argv[argp_argc++] = (char *) "--output"; i++; argp_argv[argp_argc++] = argv[i]; continue; From 6a5c78c8c85c890034974a297bfb009dff0954c6 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Thu, 7 May 2015 22:13:34 +0300 Subject: [PATCH 409/722] Add asm-tests to tarball --- conf/Makefile.extra-dist | 1 + 1 file changed, 1 insertion(+) diff --git a/conf/Makefile.extra-dist b/conf/Makefile.extra-dist index db6cfd12e..ea6b9df3a 100644 --- a/conf/Makefile.extra-dist +++ b/conf/Makefile.extra-dist @@ -5,6 +5,7 @@ EXTRA_DIST += gentpl.py EXTRA_DIST += Makefile.util.def EXTRA_DIST += Makefile.utilgcry.def +EXTRA_DIST += asm-tests EXTRA_DIST += unicode EXTRA_DIST += util/import_gcry.py From 07258815e96aab2c72593d0129d17051cbf68d27 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Fri, 8 May 2015 06:15:16 +0300 Subject: [PATCH 410/722] acpi: do not skip BIOS scan if EBDA length is zero EBDA layout is not standardized so we cannot assume first two bytes are length. Neither is it required by ACPI standard. HP 8710W is known to contain zeroes here. Closes: 45002 --- grub-core/commands/acpi.c | 4 ++++ grub-core/commands/i386/pc/acpi.c | 10 ++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/grub-core/commands/acpi.c b/grub-core/commands/acpi.c index 05a6dcad4..c3861f594 100644 --- a/grub-core/commands/acpi.c +++ b/grub-core/commands/acpi.c @@ -180,8 +180,10 @@ grub_acpi_create_ebda (void) struct grub_acpi_rsdp_v20 *v2; ebda = (grub_uint8_t *) (grub_addr_t) ((*((grub_uint16_t *)0x40e)) << 4); + grub_dprintf ("acpi", "EBDA @%p\n", ebda); if (ebda) ebda_kb_len = *(grub_uint16_t *) ebda; + grub_dprintf ("acpi", "EBDA length 0x%x\n", ebda_kb_len); if (ebda_kb_len > 16) ebda_kb_len = 0; ctx.ebda_len = (ebda_kb_len + 1) << 10; @@ -495,6 +497,8 @@ grub_cmd_acpi (struct grub_extcmd_context *ctxt, int argc, char **args) if (! rsdp) rsdp = grub_machine_acpi_get_rsdpv1 (); + grub_dprintf ("acpi", "RSDP @%p\n", rsdp); + if (rsdp) { grub_uint32_t *entry_ptr; diff --git a/grub-core/commands/i386/pc/acpi.c b/grub-core/commands/i386/pc/acpi.c index d415d2305..297f5d05f 100644 --- a/grub-core/commands/i386/pc/acpi.c +++ b/grub-core/commands/i386/pc/acpi.c @@ -29,14 +29,15 @@ grub_machine_acpi_get_rsdpv1 (void) grub_dprintf ("acpi", "Looking for RSDP. Scanning EBDA\n"); ebda = (grub_uint8_t *) ((* ((grub_uint16_t *) 0x40e)) << 4); ebda_len = * (grub_uint16_t *) ebda; - if (! ebda_len) - return 0; + if (! ebda_len) /* FIXME do we really need this check? */ + goto scan_bios; for (ptr = ebda; ptr < ebda + 0x400; ptr += 16) if (grub_memcmp (ptr, GRUB_RSDP_SIGNATURE, GRUB_RSDP_SIGNATURE_SIZE) == 0 && grub_byte_checksum (ptr, sizeof (struct grub_acpi_rsdp_v10)) == 0 && ((struct grub_acpi_rsdp_v10 *) ptr)->revision == 0) return (struct grub_acpi_rsdp_v10 *) ptr; +scan_bios: grub_dprintf ("acpi", "Looking for RSDP. Scanning BIOS\n"); for (ptr = (grub_uint8_t *) 0xe0000; ptr < (grub_uint8_t *) 0x100000; ptr += 16) @@ -56,8 +57,8 @@ grub_machine_acpi_get_rsdpv2 (void) grub_dprintf ("acpi", "Looking for RSDP. Scanning EBDA\n"); ebda = (grub_uint8_t *) ((* ((grub_uint16_t *) 0x40e)) << 4); ebda_len = * (grub_uint16_t *) ebda; - if (! ebda_len) - return 0; + if (! ebda_len) /* FIXME do we really need this check? */ + goto scan_bios; for (ptr = ebda; ptr < ebda + 0x400; ptr += 16) if (grub_memcmp (ptr, GRUB_RSDP_SIGNATURE, GRUB_RSDP_SIGNATURE_SIZE) == 0 && grub_byte_checksum (ptr, sizeof (struct grub_acpi_rsdp_v10)) == 0 @@ -67,6 +68,7 @@ grub_machine_acpi_get_rsdpv2 (void) == 0) return (struct grub_acpi_rsdp_v20 *) ptr; +scan_bios: grub_dprintf ("acpi", "Looking for RSDP. Scanning BIOS\n"); for (ptr = (grub_uint8_t *) 0xe0000; ptr < (grub_uint8_t *) 0x100000; ptr += 16) From 1570140f0362d9936f97a014a9fa5cecbca54f07 Mon Sep 17 00:00:00 2001 From: Jan Kara Date: Mon, 14 Jul 2014 17:21:29 +0200 Subject: [PATCH 411/722] xfs: Fix termination loop for directory iteration Directory iteration used wrong position (sizeof wrong structure) for termination of iteration inside a directory block. Luckily the position ended up being wrong by just 1 byte and directory entries are larger so things worked out fine in practice. But fix the problem anyway. Signed-off-by: Jan Kara --- grub-core/fs/xfs.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/grub-core/fs/xfs.c b/grub-core/fs/xfs.c index 16ffd3f1e..4bd52d1e0 100644 --- a/grub-core/fs/xfs.c +++ b/grub-core/fs/xfs.c @@ -603,8 +603,7 @@ grub_xfs_iterate_dir (grub_fshelp_node_t dir, - grub_be_to_cpu32 (tail->leaf_stale)); /* Iterate over all entries within this block. */ - while (pos < (dirblk_size - - (int) sizeof (struct grub_xfs_dir2_entry))) + while (pos < tail_start) { struct grub_xfs_dir2_entry *direntry; grub_uint8_t *freetag; From a139188eb559ee23f51540948ec84ef5948fb2d1 Mon Sep 17 00:00:00 2001 From: Jan Kara Date: Mon, 14 Jul 2014 17:21:30 +0200 Subject: [PATCH 412/722] xfs: Convert inode numbers to cpu endianity immediately after reading Currently XFS driver converted inode numbers to native endianity only when using them to compute inode position. Although this works, it is somewhat confusing. So convert inode numbers when reading them from disk structures as every other field. Signed-off-by: Jan Kara --- grub-core/fs/xfs.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/grub-core/fs/xfs.c b/grub-core/fs/xfs.c index 4bd52d1e0..0d704e9a4 100644 --- a/grub-core/fs/xfs.c +++ b/grub-core/fs/xfs.c @@ -180,14 +180,14 @@ static inline grub_uint64_t GRUB_XFS_INO_INOINAG (struct grub_xfs_data *data, grub_uint64_t ino) { - return (grub_be_to_cpu64 (ino) & ((1LL << GRUB_XFS_INO_AGBITS (data)) - 1)); + return (ino & ((1LL << GRUB_XFS_INO_AGBITS (data)) - 1)); } static inline grub_uint64_t GRUB_XFS_INO_AG (struct grub_xfs_data *data, grub_uint64_t ino) { - return (grub_be_to_cpu64 (ino) >> GRUB_XFS_INO_AGBITS (data)); + return (ino >> GRUB_XFS_INO_AGBITS (data)); } static inline grub_disk_addr_t @@ -506,13 +506,12 @@ grub_xfs_iterate_dir (grub_fshelp_node_t dir, if (smallino) { parent = grub_be_to_cpu32 (diro->inode.data.dir.dirhead.parent.i4); - parent = grub_cpu_to_be64 (parent); /* The header is a bit smaller than usual. */ de = (struct grub_xfs_dir_entry *) ((char *) de - 4); } else { - parent = diro->inode.data.dir.dirhead.parent.i8; + parent = grub_be_to_cpu64(diro->inode.data.dir.dirhead.parent.i8); } /* Synthesize the direntries for `.' and `..'. */ @@ -545,7 +544,6 @@ grub_xfs_iterate_dir (grub_fshelp_node_t dir, | (((grub_uint64_t) inopos[5]) << 16) | (((grub_uint64_t) inopos[6]) << 8) | (((grub_uint64_t) inopos[7]) << 0); - ino = grub_cpu_to_be64 (ino); c = de->name[de->len]; de->name[de->len] = '\0'; @@ -627,7 +625,8 @@ grub_xfs_iterate_dir (grub_fshelp_node_t dir, is not used by GRUB. So it can be overwritten. */ filename[direntry->len] = '\0'; - if (iterate_dir_call_hook (direntry->inode, filename, &ctx)) + if (iterate_dir_call_hook (grub_be_to_cpu64(direntry->inode), + filename, &ctx)) { grub_free (dirblock); return 1; @@ -689,7 +688,7 @@ grub_xfs_mount (grub_disk_t disk) goto fail; data->diropen.data = data; - data->diropen.ino = data->sblock.rootino; + data->diropen.ino = grub_be_to_cpu64(data->sblock.rootino); data->diropen.inode_read = 1; data->bsize = grub_be_to_cpu32 (data->sblock.bsize); data->agsize = grub_be_to_cpu32 (data->sblock.agsize); From 5082ea618439fe59956d071777be0c9c74fbbcf5 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Wed, 13 May 2015 09:47:17 +0300 Subject: [PATCH 413/722] remove extra newlines in grub_util_* strings grub_util_{info,warn,error} already add trailing newlines, so remove them from format strings. Also trailing full stops are already added. --- grub-core/bus/emu/pci.c | 2 +- grub-core/disk/lvm.c | 40 +++++++++++++++++----------------- grub-core/osdep/linux/ofpath.c | 2 +- util/grub-install-common.c | 2 +- util/grub-install.c | 6 ++--- util/grub-mknetdir.c | 2 +- util/grub-pe2elf.c | 2 +- util/mkimage.c | 4 ++-- 8 files changed, 30 insertions(+), 30 deletions(-) diff --git a/grub-core/bus/emu/pci.c b/grub-core/bus/emu/pci.c index 663e5540c..267f2622d 100644 --- a/grub-core/bus/emu/pci.c +++ b/grub-core/bus/emu/pci.c @@ -55,7 +55,7 @@ grub_pci_device_map_range (grub_pci_device_t dev, grub_addr_t base, int err; err = pci_device_map_range (dev, base, size, PCI_DEV_MAP_FLAG_WRITABLE, &addr); if (err) - grub_util_error ("mapping 0x%llx failed (error %d)\n", + grub_util_error ("mapping 0x%llx failed (error %d)", (unsigned long long) base, err); return addr; } diff --git a/grub-core/disk/lvm.c b/grub-core/disk/lvm.c index 9b97004d8..7b265c780 100644 --- a/grub-core/disk/lvm.c +++ b/grub-core/disk/lvm.c @@ -160,7 +160,7 @@ grub_lvm_detect (grub_disk_t disk, "we don't support multiple LVM data areas"); #ifdef GRUB_UTIL - grub_util_info ("we don't support multiple LVM data areas\n"); + grub_util_info ("we don't support multiple LVM data areas"); #endif goto fail; } @@ -189,7 +189,7 @@ grub_lvm_detect (grub_disk_t disk, grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, "unknown LVM metadata header"); #ifdef GRUB_UTIL - grub_util_info ("unknown LVM metadata header\n"); + grub_util_info ("unknown LVM metadata header"); #endif goto fail2; } @@ -213,7 +213,7 @@ grub_lvm_detect (grub_disk_t disk, if (q == metadatabuf + mda_size) { #ifdef GRUB_UTIL - grub_util_info ("error parsing metadata\n"); + grub_util_info ("error parsing metadata"); #endif goto fail2; } @@ -230,7 +230,7 @@ grub_lvm_detect (grub_disk_t disk, if (p == NULL) { #ifdef GRUB_UTIL - grub_util_info ("couldn't find ID\n"); + grub_util_info ("couldn't find ID"); #endif goto fail3; } @@ -258,7 +258,7 @@ grub_lvm_detect (grub_disk_t disk, if (p == NULL) { #ifdef GRUB_UTIL - grub_util_info ("unknown extent size\n"); + grub_util_info ("unknown extent size"); #endif goto fail4; } @@ -306,7 +306,7 @@ grub_lvm_detect (grub_disk_t disk, if (p == NULL) { #ifdef GRUB_UTIL - grub_util_info ("unknown pe_start\n"); + grub_util_info ("unknown pe_start"); #endif goto pvs_fail; } @@ -315,7 +315,7 @@ grub_lvm_detect (grub_disk_t disk, if (p == NULL) { #ifdef GRUB_UTIL - grub_util_info ("error parsing pe_start\n"); + grub_util_info ("error parsing pe_start"); #endif goto pvs_fail; } @@ -402,7 +402,7 @@ grub_lvm_detect (grub_disk_t disk, if (p == NULL) { #ifdef GRUB_UTIL - grub_util_info ("couldn't find ID\n"); + grub_util_info ("couldn't find ID"); #endif goto lvs_fail; } @@ -422,7 +422,7 @@ grub_lvm_detect (grub_disk_t disk, if (p == NULL) { #ifdef GRUB_UTIL - grub_util_info ("unknown segment_count\n"); + grub_util_info ("unknown segment_count"); #endif goto lvs_fail; } @@ -436,7 +436,7 @@ grub_lvm_detect (grub_disk_t disk, if (p == NULL) { #ifdef GRUB_UTIL - grub_util_info ("unknown segment\n"); + grub_util_info ("unknown segment"); #endif goto lvs_segment_fail; } @@ -445,7 +445,7 @@ grub_lvm_detect (grub_disk_t disk, if (p == NULL) { #ifdef GRUB_UTIL - grub_util_info ("unknown start_extent\n"); + grub_util_info ("unknown start_extent"); #endif goto lvs_segment_fail; } @@ -453,7 +453,7 @@ grub_lvm_detect (grub_disk_t disk, if (p == NULL) { #ifdef GRUB_UTIL - grub_util_info ("unknown extent_count\n"); + grub_util_info ("unknown extent_count"); #endif goto lvs_segment_fail; } @@ -475,7 +475,7 @@ grub_lvm_detect (grub_disk_t disk, if (p == NULL) { #ifdef GRUB_UTIL - grub_util_info ("unknown stripe_count\n"); + grub_util_info ("unknown stripe_count"); #endif goto lvs_segment_fail; } @@ -491,7 +491,7 @@ grub_lvm_detect (grub_disk_t disk, if (p == NULL) { #ifdef GRUB_UTIL - grub_util_info ("unknown stripes\n"); + grub_util_info ("unknown stripes"); #endif goto lvs_segment_fail2; } @@ -533,7 +533,7 @@ grub_lvm_detect (grub_disk_t disk, if (p == NULL) { #ifdef GRUB_UTIL - grub_util_info ("unknown mirror_count\n"); + grub_util_info ("unknown mirror_count"); #endif goto lvs_segment_fail; } @@ -545,7 +545,7 @@ grub_lvm_detect (grub_disk_t disk, if (p == NULL) { #ifdef GRUB_UTIL - grub_util_info ("unknown mirrors\n"); + grub_util_info ("unknown mirrors"); #endif goto lvs_segment_fail2; } @@ -607,7 +607,7 @@ grub_lvm_detect (grub_disk_t disk, if (p == NULL) { #ifdef GRUB_UTIL - grub_util_info ("unknown device_count\n"); + grub_util_info ("unknown device_count"); #endif goto lvs_segment_fail; } @@ -618,7 +618,7 @@ grub_lvm_detect (grub_disk_t disk, if (p == NULL) { #ifdef GRUB_UTIL - grub_util_info ("unknown stripe_size\n"); + grub_util_info ("unknown stripe_size"); #endif goto lvs_segment_fail; } @@ -631,7 +631,7 @@ grub_lvm_detect (grub_disk_t disk, if (p == NULL) { #ifdef GRUB_UTIL - grub_util_info ("unknown raids\n"); + grub_util_info ("unknown raids"); #endif goto lvs_segment_fail2; } @@ -678,7 +678,7 @@ grub_lvm_detect (grub_disk_t disk, p2 = grub_strchr (p, '"'); if (p2) *p2 = 0; - grub_util_info ("unknown LVM type %s\n", p); + grub_util_info ("unknown LVM type %s", p); if (p2) *p2 ='"'; #endif diff --git a/grub-core/osdep/linux/ofpath.c b/grub-core/osdep/linux/ofpath.c index 05b1ecdf8..a79682a5e 100644 --- a/grub-core/osdep/linux/ofpath.c +++ b/grub-core/osdep/linux/ofpath.c @@ -539,7 +539,7 @@ grub_util_devname_to_ofpath (const char *sys_devname) ofpath = xstrdup ("floppy"); else { - grub_util_warn (_("unknown device type %s\n"), device); + grub_util_warn (_("unknown device type %s"), device); ofpath = NULL; } diff --git a/util/grub-install-common.c b/util/grub-install-common.c index 0364b327c..25983089f 100644 --- a/util/grub-install-common.c +++ b/util/grub-install-common.c @@ -494,7 +494,7 @@ grub_install_make_image_wrap_file (const char *dir, const char *prefix, tgt = grub_install_get_image_target (mkimage_target); if (!tgt) - grub_util_error (_("unknown target format %s\n"), mkimage_target); + grub_util_error (_("unknown target format %s"), mkimage_target); grub_install_generate_image (dir, prefix, fp, outname, modules.entries, memdisk_path, diff --git a/util/grub-install.c b/util/grub-install.c index 7b394c997..566272600 100644 --- a/util/grub-install.c +++ b/util/grub-install.c @@ -773,7 +773,7 @@ bless (grub_device_t dev, const char *path, int x86) err = grub_mac_bless_inode (dev, st.st_ino, S_ISDIR (st.st_mode), x86); if (err) grub_util_error ("%s", grub_errmsg); - grub_util_info ("blessed\n"); + grub_util_info ("blessed"); } static void @@ -1070,7 +1070,7 @@ main (int argc, char *argv[]) efidir_is_mac = 1; if (!efidir_is_mac && grub_strcmp (fs->name, "fat") != 0) - grub_util_error (_("%s doesn't look like an EFI partition.\n"), efidir); + grub_util_error (_("%s doesn't look like an EFI partition"), efidir); /* The EFI specification requires that an EFI System Partition must contain an "EFI" subdirectory, and that OS loaders are stored in @@ -1271,7 +1271,7 @@ main (int argc, char *argv[]) if (!config.is_cryptodisk_enabled && have_cryptodisk) grub_util_error (_("attempt to install to encrypted disk without cryptodisk enabled. " - "Set `%s' in file `%s'."), "GRUB_ENABLE_CRYPTODISK=y", + "Set `%s' in file `%s'"), "GRUB_ENABLE_CRYPTODISK=y", grub_util_get_config_filename ()); if (disk_module && grub_strcmp (disk_module, "ata") == 0) diff --git a/util/grub-mknetdir.c b/util/grub-mknetdir.c index 8366a1121..3813e8bc0 100644 --- a/util/grub-mknetdir.c +++ b/util/grub-mknetdir.c @@ -140,7 +140,7 @@ process_input_dir (const char *input_dir, enum grub_install_plat platform) prefix = xasprintf ("/%s", subdir); if (!targets[platform].mkimage_target) - grub_util_error (_("unsupported platform %s\n"), platsub); + grub_util_error (_("unsupported platform %s"), platsub); grub_cfg = grub_util_path_concat (2, grubdir, "grub.cfg"); cfg = grub_util_fopen (grub_cfg, "wb"); diff --git a/util/grub-pe2elf.c b/util/grub-pe2elf.c index f4abf70a3..0d4084a10 100644 --- a/util/grub-pe2elf.c +++ b/util/grub-pe2elf.c @@ -279,7 +279,7 @@ write_reloc_section (FILE* fp, const char *name, char *image, break; #endif default: - grub_util_error ("unknown pe relocation type %d\n", pe_rel->type); + grub_util_error ("unknown pe relocation type %d", pe_rel->type); } if (type == diff --git a/util/mkimage.c b/util/mkimage.c index 52265b557..35df99871 100644 --- a/util/mkimage.c +++ b/util/mkimage.c @@ -823,7 +823,7 @@ compress_kernel (const struct grub_install_image_target_desc *image_target, char if (image_target->flags & PLATFORM_FLAGS_DECOMPRESSORS && (comp != GRUB_COMPRESSION_NONE)) - grub_util_error (_("unknown compression %d\n"), comp); + grub_util_error (_("unknown compression %d"), comp); *core_img = xmalloc (kernel_size); memcpy (*core_img, kernel_img, kernel_size); @@ -1234,7 +1234,7 @@ grub_install_generate_image (const char *dir, const char *prefix, name = "none_decompress.img"; break; default: - grub_util_error (_("unknown compression %d\n"), comp); + grub_util_error (_("unknown compression %d"), comp); } decompress_path = grub_util_get_path (dir, name); From 5370dcfdae66b60cff3507ad925300a679fe4117 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Thu, 14 May 2015 07:50:33 +0300 Subject: [PATCH 414/722] zfs: fix integer truncation in zap_lookup Size after shift could exceed 16 bits; use grub_unit32_t for result. Reported and tested by: Kostya Berger Closes: 44448 --- grub-core/fs/zfs/zfs.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/grub-core/fs/zfs/zfs.c b/grub-core/fs/zfs/zfs.c index 08ed453a6..aac6f2876 100644 --- a/grub-core/fs/zfs/zfs.c +++ b/grub-core/fs/zfs/zfs.c @@ -2071,10 +2071,10 @@ dmu_read (dnode_end_t * dn, grub_uint64_t blkid, void **buf, */ static grub_err_t mzap_lookup (mzap_phys_t * zapobj, grub_zfs_endian_t endian, - grub_uint16_t objsize, const char *name, grub_uint64_t * value, + grub_uint32_t objsize, const char *name, grub_uint64_t * value, int case_insensitive) { - grub_uint16_t i, chunks; + grub_uint32_t i, chunks; mzap_ent_phys_t *mzap_ent = zapobj->mz_chunk; if (objsize < MZAP_ENT_LEN) @@ -2486,7 +2486,7 @@ zap_lookup (dnode_end_t * zap_dnode, const char *name, grub_uint64_t *val, struct grub_zfs_data *data, int case_insensitive) { grub_uint64_t block_type; - grub_uint16_t size; + grub_uint32_t size; void *zapbuf; grub_err_t err; grub_zfs_endian_t endian; @@ -2494,7 +2494,7 @@ zap_lookup (dnode_end_t * zap_dnode, const char *name, grub_uint64_t *val, grub_dprintf ("zfs", "looking for '%s'\n", name); /* Read in the first block of the zap object data. */ - size = grub_zfs_to_cpu16 (zap_dnode->dn.dn_datablkszsec, + size = (grub_uint32_t) grub_zfs_to_cpu16 (zap_dnode->dn.dn_datablkszsec, zap_dnode->endian) << SPA_MINBLOCKSHIFT; err = dmu_read (zap_dnode, 0, &zapbuf, &endian, data); if (err) From 2498dc7a3aee638215ad47899031496b50633d55 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sun, 17 May 2015 14:16:36 +0300 Subject: [PATCH 415/722] hostdisk: fix crash with NULL device.map grub-macbless calls grub_util_biosdisk_init with NULL device.map. --- grub-core/kern/emu/hostdisk.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/kern/emu/hostdisk.c b/grub-core/kern/emu/hostdisk.c index a3b00c8f6..610518d0c 100644 --- a/grub-core/kern/emu/hostdisk.c +++ b/grub-core/kern/emu/hostdisk.c @@ -422,7 +422,7 @@ read_device_map (const char *dev_map) char buf[1024]; /* XXX */ int lineno = 0; - if (dev_map[0] == '\0') + if (!dev_map || dev_map[0] == '\0') { grub_util_info ("no device.map"); return; From a666c8bd18aee7bf1b202b6b8c0ffe953bd2c1b6 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sun, 17 May 2015 22:38:30 +0300 Subject: [PATCH 416/722] bootp: ignore gateway_ip (relay) field. From RFC1542: The 'giaddr' field is rather poorly named. It exists to facilitate the transfer of BOOTREQUEST messages from a client, through BOOTP relay agents, to servers on different networks than the client. Similarly, it facilitates the delivery of BOOTREPLY messages from the servers, through BOOTP relay agents, back to the client. In no case does it represent a general IP router to be used by the client. A BOOTP client MUST set the 'giaddr' field to zero (0.0.0.0) in all BOOTREQUEST messages it generates. A BOOTP client MUST NOT interpret the 'giaddr' field of a BOOTREPLY message to be the IP address of an IP router. A BOOTP client SHOULD completely ignore the contents of the 'giaddr' field in BOOTREPLY messages. Leave code ifdef'd out for the time being in case we see regression. Suggested by: Rink Springer Closes: 43396 --- docs/grub.texi | 6 ++++-- grub-core/net/bootp.c | 7 +++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/docs/grub.texi b/docs/grub.texi index 4af22aff8..88bd75f38 100644 --- a/docs/grub.texi +++ b/docs/grub.texi @@ -5162,8 +5162,10 @@ by @var{shortname} which can be used to remove it (@pxref{net_del_route}). Perform configuration of @var{card} using DHCP protocol. If no card name is specified, try to configure all existing cards. If configuration was successful, interface with name @var{card}@samp{:dhcp} and configured -address is added to @var{card}. If server provided gateway information in -DHCP ACK packet, it is added as route entry with the name @var{card}@samp{:dhcp:gw}. Additionally the following DHCP options are recognized and processed: +address is added to @var{card}. +@comment If server provided gateway information in +@comment DHCP ACK packet, it is added as route entry with the name @var{card}@samp{:dhcp:gw}. +Additionally the following DHCP options are recognized and processed: @table @samp @item 1 (Subnet Mask) diff --git a/grub-core/net/bootp.c b/grub-core/net/bootp.c index 613675533..4fdeac3ef 100644 --- a/grub-core/net/bootp.c +++ b/grub-core/net/bootp.c @@ -157,6 +157,12 @@ grub_net_configure_by_dhcp_ack (const char *name, hwaddr.type = GRUB_NET_LINK_LEVEL_PROTOCOL_ETHERNET; inter = grub_net_add_addr (name, card, &addr, &hwaddr, flags); +#if 0 + /* This is likely based on misunderstanding. gateway_ip refers to + address of BOOTP relay and should not be used after BOOTP transaction + is complete. + See RFC1542, 3.4 Interpretation of the 'giaddr' field + */ if (bp->gateway_ip) { grub_net_network_level_netaddress_t target; @@ -178,6 +184,7 @@ grub_net_configure_by_dhcp_ack (const char *name, target.ipv4.masksize = 32; grub_net_add_route (name, target, inter); } +#endif if (size > OFFSET_OF (boot_file, bp)) grub_env_set_net_property (name, "boot_file", bp->boot_file, From f4e62af000116de93f0c9d1c5f8aaf40934d5a01 Mon Sep 17 00:00:00 2001 From: Paul Menzel Date: Fri, 15 May 2015 17:35:00 +0200 Subject: [PATCH 417/722] cb_timestamps.c: Add new time stamp descriptions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add the descriptions of the “coreâ€, that means no vendorcode or payload, coreboot time stamps added up to coreboot commit a7d92441 (timestamps: You can never have enough of them!) [1]. Running `coreboot_boottime` in the GRUB command line interface now shows descriptions for all time stamps again on the ASRock E350M1. [1] http://review.coreboot.org/9608 --- grub-core/commands/i386/coreboot/cb_timestamps.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/grub-core/commands/i386/coreboot/cb_timestamps.c b/grub-core/commands/i386/coreboot/cb_timestamps.c index 07fbb0283..e72f38d6e 100644 --- a/grub-core/commands/i386/coreboot/cb_timestamps.c +++ b/grub-core/commands/i386/coreboot/cb_timestamps.c @@ -39,9 +39,17 @@ static const char *descs[] = { [2] = "before RAM init", [3] = "after RAM init", [4] = "end of romstage", + [5] = "start of verified boot", + [6] = "end of verified boot", [8] = "start of RAM copy", [9] = "end of RAM copy", [10] = "start of ramstage", + [11] = "start of bootblock", + [12] = "end of bootblock", + [13] = "starting to load romstage", + [14] = "finished loading romstage", + [15] = "starting LZMA decompress (ignore for x86)", + [16] = "finished LZMA decompress (ignore for x86)", [30] = "device enumerate", [40] = "device configure", [50] = "device enable", From 5e74a3e6dfc4e5992c423bf740a4b3604030b007 Mon Sep 17 00:00:00 2001 From: Paul Menzel Date: Sun, 24 May 2015 11:11:25 +0200 Subject: [PATCH 418/722] disk/ahci: Use defines `GRUB_ATA_STATUS_BUSY` and `GRUB_ATA_STATUS_DRQ` Instead of hard coding `0x88` use the macros defined in `disk/ata.h`. --- grub-core/disk/ahci.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/grub-core/disk/ahci.c b/grub-core/disk/ahci.c index d6bdbddf6..7f7572404 100644 --- a/grub-core/disk/ahci.c +++ b/grub-core/disk/ahci.c @@ -565,14 +565,14 @@ grub_ahci_pciinit (grub_pci_device_t dev, while (grub_get_time_ms () < endtime) { for (i = 0; i < nports; i++) - if (adevs[i] && (adevs[i]->hba->ports[adevs[i]->port].task_file_data & 0x88)) + if (adevs[i] && (adevs[i]->hba->ports[adevs[i]->port].task_file_data & (GRUB_ATA_STATUS_BUSY | GRUB_ATA_STATUS_DRQ))) break; if (i == nports) break; } for (i = 0; i < nports; i++) - if (adevs[i] && (adevs[i]->hba->ports[adevs[i]->port].task_file_data & 0x88)) + if (adevs[i] && (adevs[i]->hba->ports[adevs[i]->port].task_file_data & (GRUB_ATA_STATUS_BUSY | GRUB_ATA_STATUS_DRQ))) { grub_dprintf ("ahci", "port %d is busy\n", i); failed_adevs[i] = adevs[i]; From c856be6bca6f963a9a2c91eda954ab687bc7e573 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Wed, 27 May 2015 08:37:55 +0200 Subject: [PATCH 419/722] multiboot1: never place modules in low memory. While in theory permitted by the spec, modules rarely fit in low memory anyway and not every kernel is able to handle modules in low memory anyway. At least VMWare is known not to be able to handle modules at arbitrary locations. --- grub-core/loader/multiboot.c | 1 + 1 file changed, 1 insertion(+) diff --git a/grub-core/loader/multiboot.c b/grub-core/loader/multiboot.c index 4b71f3363..fd8f28e21 100644 --- a/grub-core/loader/multiboot.c +++ b/grub-core/loader/multiboot.c @@ -333,6 +333,7 @@ grub_cmd_module (grub_command_t cmd __attribute__ ((unused)), return grub_errno; #ifndef GRUB_USE_MULTIBOOT2 + lowest_addr = 0x100000; if (grub_multiboot_quirks & GRUB_MULTIBOOT_QUIRK_MODULES_AFTER_KERNEL) lowest_addr = ALIGN_UP (highest_load + 1048576, 4096); #endif From cad5cc0f5d3d3630ccfbe242552958b13f2120d6 Mon Sep 17 00:00:00 2001 From: Toomas Soome Date: Thu, 16 Apr 2015 08:24:38 +0300 Subject: [PATCH 420/722] zfs extensible_dataset and large_blocks feature support MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit large blocks basically use extensible dataset feature, or to be exact, setting recordsize above 128k will trigger large_block feature to be enabled and storing such blocks is using feature extensible dataset. so the extensible dataset is prerequisite. Changes implement read support extensible dataset… instead of fixed DMU types they dont specify type, making it possible to use fat zap objects from bonus area. --- grub-core/fs/zfs/zfs.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/grub-core/fs/zfs/zfs.c b/grub-core/fs/zfs/zfs.c index aac6f2876..f9ca0e75e 100644 --- a/grub-core/fs/zfs/zfs.c +++ b/grub-core/fs/zfs/zfs.c @@ -283,6 +283,8 @@ static const char *spa_feature_names[] = { "org.illumos:lz4_compress", "com.delphix:hole_birth", "com.delphix:embedded_data", + "com.delphix:extensible_dataset", + "org.open-zfs:large_blocks", NULL }; @@ -3080,7 +3082,7 @@ get_filesystem_dnode (dnode_end_t * mosmdn, char *fsname, grub_dprintf ("zfs", "alive\n"); - err = dnode_get (mosmdn, objnum, DMU_OT_DSL_DIR, mdn, data); + err = dnode_get (mosmdn, objnum, 0, mdn, data); if (err) return err; @@ -3113,7 +3115,7 @@ get_filesystem_dnode (dnode_end_t * mosmdn, char *fsname, if (err) return err; - err = dnode_get (mosmdn, objnum, DMU_OT_DSL_DIR, mdn, data); + err = dnode_get (mosmdn, objnum, 0, mdn, data); if (err) return err; @@ -3268,8 +3270,7 @@ dnode_get_fullpath (const char *fullpath, struct subvolume *subvol, grub_dprintf ("zfs", "endian = %d\n", subvol->mdn.endian); - err = dnode_get (&(data->mos), headobj, DMU_OT_DSL_DATASET, &subvol->mdn, - data); + err = dnode_get (&(data->mos), headobj, 0, &subvol->mdn, data); if (err) { grub_free (fsname); @@ -3665,8 +3666,11 @@ zfs_mount (grub_device_t dev) if (ub->ub_version >= SPA_VERSION_FEATURES && check_mos_features(&((objset_phys_t *) osp)->os_meta_dnode,ub_endian, data) != 0) - return NULL; - + { + grub_error (GRUB_ERR_BAD_FS, "Unsupported features in pool"); + return NULL; + } + /* Got the MOS. Save it at the memory addr MOS. */ grub_memmove (&(data->mos.dn), &((objset_phys_t *) osp)->os_meta_dnode, DNODE_SIZE); @@ -3963,7 +3967,7 @@ fill_fs_info (struct grub_dirhook_info *info, { headobj = grub_zfs_to_cpu64 (((dsl_dir_phys_t *) DN_BONUS (&mdn.dn))->dd_head_dataset_obj, mdn.endian); - err = dnode_get (&(data->mos), headobj, DMU_OT_DSL_DATASET, &mdn, data); + err = dnode_get (&(data->mos), headobj, 0, &mdn, data); if (err) { grub_dprintf ("zfs", "failed here\n"); From fd73b3d00881abae3daf820fe0009434edf2e3d4 Mon Sep 17 00:00:00 2001 From: Paul Menzel Date: Sun, 24 May 2015 23:27:46 +0200 Subject: [PATCH 421/722] Correct spelling of *scheduled* Run the command below $ git grep -l schedulded | xargs sed -i 's/schedulded/scheduled/g' and revert the change in `ChangeLog-2015`. Including "miscellaneous" spelling fix noted by richardvoigt@gmail.com --- gentpl.py | 2 +- grub-core/disk/ahci.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gentpl.py b/gentpl.py index f177883f8..37b1f45bf 100644 --- a/gentpl.py +++ b/gentpl.py @@ -82,7 +82,7 @@ GROUPS["softdiv"] = GROUPS["arm"] + ["ia64_efi"] GROUPS["no_softdiv"] = GRUB_PLATFORMS[:] for i in GROUPS["softdiv"]: GROUPS["no_softdiv"].remove(i) -# Miscelaneous groups schedulded to disappear in future +# Miscellaneous groups scheduled to disappear in future GROUPS["i386_coreboot_multiboot_qemu"] = ["i386_coreboot", "i386_multiboot", "i386_qemu"] GROUPS["nopc"] = GRUB_PLATFORMS[:]; GROUPS["nopc"].remove("i386_pc") diff --git a/grub-core/disk/ahci.c b/grub-core/disk/ahci.c index 7f7572404..4e8619ce3 100644 --- a/grub-core/disk/ahci.c +++ b/grub-core/disk/ahci.c @@ -1002,7 +1002,7 @@ grub_ahci_readwrite_real (struct grub_ahci_device *dev, if (parms->write) grub_memcpy ((char *) grub_dma_get_virt (bufc), parms->buffer, parms->size); - grub_dprintf ("ahci", "AHCI command schedulded\n"); + grub_dprintf ("ahci", "AHCI command scheduled\n"); grub_dprintf ("ahci", "AHCI tfd = %x\n", dev->hba->ports[dev->port].task_file_data); grub_dprintf ("ahci", "AHCI inten = %x\n", From dec7718878f8a4566cd2894ab8970e1bec19dbb9 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sat, 30 May 2015 19:36:41 +0300 Subject: [PATCH 422/722] Clarify use of superusers variable and menu entry access superusers controls both CLI and editing. Also explicitly mention that empty superusers disables them. "Access to menuentry" is a bit vague - change to "execute menuentry" to make it obvious, what access is granted. --- docs/grub.texi | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/docs/grub.texi b/docs/grub.texi index 88bd75f38..b9f41a73e 100644 --- a/docs/grub.texi +++ b/docs/grub.texi @@ -5428,10 +5428,12 @@ In order to enable authentication support, the @samp{superusers} environment variable must be set to a list of usernames, separated by any of spaces, commas, semicolons, pipes, or ampersands. Superusers are permitted to use the GRUB command line, edit menu entries, and execute any menu entry. If -@samp{superusers} is set, then use of the command line is automatically -restricted to superusers. +@samp{superusers} is set, then use of the command line and editing of menu +entries are automatically restricted to superusers. Setting @samp{superusers} +to empty string effectively disables both access to CLI and editing of menu +entries. -Other users may be given access to specific menu entries by giving a list of +Other users may be allowed to execute specific menu entries by giving a list of usernames (as above) using the @option{--users} option to the @samp{menuentry} command (@pxref{menuentry}). If the @option{--unrestricted} option is used for a menu entry, then that entry is unrestricted. From ca59c24bd0e2a90db764065e24829775aa2b363c Mon Sep 17 00:00:00 2001 From: Paul Menzel Date: Wed, 27 May 2015 22:48:57 +0200 Subject: [PATCH 423/722] disk/ahci.c: Add port number to port debug messages Currently, some messages cannot be mapped to the port they belong to as the port number is missing from the output. So add `port: n` to the debug messages. --- grub-core/disk/ahci.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/grub-core/disk/ahci.c b/grub-core/disk/ahci.c index 4e8619ce3..da5fead26 100644 --- a/grub-core/disk/ahci.c +++ b/grub-core/disk/ahci.c @@ -355,7 +355,7 @@ grub_ahci_pciinit (grub_pci_device_t dev, if (adevs[i]) { adevs[i]->hba->ports[adevs[i]->port].sata_error = adevs[i]->hba->ports[adevs[i]->port].sata_error; - grub_dprintf ("ahci", "err: %x\n", + grub_dprintf ("ahci", "port: %d, err: %x\n", adevs[i]->port, adevs[i]->hba->ports[adevs[i]->port].sata_error); adevs[i]->command_list_chunk = grub_memalign_dma32 (1024, sizeof (struct grub_ahci_cmd_head) * 32); @@ -440,7 +440,7 @@ grub_ahci_pciinit (grub_pci_device_t dev, adevs[i]->hba->ports[adevs[i]->port].intstatus = ~0; // adevs[i]->hba->ports[adevs[i]->port].fbs = 0; - grub_dprintf ("ahci", "err: %x\n", + grub_dprintf ("ahci", "port: %d, err: %x\n", adevs[i]->port, adevs[i]->hba->ports[adevs[i]->port].sata_error); adevs[i]->rfis = grub_memalign_dma32 (4096, @@ -480,7 +480,7 @@ grub_ahci_pciinit (grub_pci_device_t dev, for (i = 0; i < nports; i++) if (adevs[i]) { - grub_dprintf ("ahci", "err: %x\n", + grub_dprintf ("ahci", "port: %d, err: %x\n", adevs[i]->port, adevs[i]->hba->ports[adevs[i]->port].sata_error); fr_running |= (1 << i); @@ -488,7 +488,7 @@ grub_ahci_pciinit (grub_pci_device_t dev, adevs[i]->hba->ports[adevs[i]->port].command |= GRUB_AHCI_HBA_PORT_CMD_POWER_ON; adevs[i]->hba->ports[adevs[i]->port].command |= 1 << 28; - grub_dprintf ("ahci", "err: %x\n", + grub_dprintf ("ahci", "port: %d, err: %x\n", adevs[i]->port, adevs[i]->hba->ports[adevs[i]->port].sata_error); } @@ -515,26 +515,26 @@ grub_ahci_pciinit (grub_pci_device_t dev, for (i = 0; i < nports; i++) if (adevs[i]) { - grub_dprintf ("ahci", "err: %x\n", + grub_dprintf ("ahci", "port %d, err: %x\n", adevs[i]->port, adevs[i]->hba->ports[adevs[i]->port].sata_error); adevs[i]->hba->ports[adevs[i]->port].command |= GRUB_AHCI_HBA_PORT_CMD_POWER_ON; adevs[i]->hba->ports[adevs[i]->port].command |= GRUB_AHCI_HBA_PORT_CMD_SPIN_UP; - grub_dprintf ("ahci", "err: %x\n", + grub_dprintf ("ahci", "port %d, err: %x\n", adevs[i]->port, adevs[i]->hba->ports[adevs[i]->port].sata_error); adevs[i]->hba->ports[adevs[i]->port].sata_error = ~0; - grub_dprintf ("ahci", "err: %x\n", + grub_dprintf ("ahci", "port %d, err: %x\n", adevs[i]->port, adevs[i]->hba->ports[adevs[i]->port].sata_error); - grub_dprintf ("ahci", "offset: %x, tfd:%x, CMD: %x\n", + grub_dprintf ("ahci", "port %d, offset: %x, tfd:%x, CMD: %x\n", adevs[i]->port, (int) ((char *) &adevs[i]->hba->ports[adevs[i]->port].task_file_data - (char *) adevs[i]->hba), adevs[i]->hba->ports[adevs[i]->port].task_file_data, adevs[i]->hba->ports[adevs[i]->port].command); - grub_dprintf ("ahci", "err: %x\n", + grub_dprintf ("ahci", "port %d, err: %x\n", adevs[i]->port, adevs[i]->hba->ports[adevs[i]->port].sata_error); } @@ -542,13 +542,13 @@ grub_ahci_pciinit (grub_pci_device_t dev, for (i = 0; i < nports; i++) if (adevs[i]) { - grub_dprintf ("ahci", "offset: %x, tfd:%x, CMD: %x\n", + grub_dprintf ("ahci", "port %d, offset: %x, tfd:%x, CMD: %x\n", adevs[i]->port, (int) ((char *) &adevs[i]->hba->ports[adevs[i]->port].task_file_data - (char *) adevs[i]->hba), adevs[i]->hba->ports[adevs[i]->port].task_file_data, adevs[i]->hba->ports[adevs[i]->port].command); - grub_dprintf ("ahci", "err: %x\n", + grub_dprintf ("ahci", "port: %d, err: %x\n", adevs[i]->port, adevs[i]->hba->ports[adevs[i]->port].sata_error); adevs[i]->hba->ports[adevs[i]->port].command From 3ac342205dc81293bb8e2d91b8c5ebe124b4ad35 Mon Sep 17 00:00:00 2001 From: dann frazier Date: Thu, 21 May 2015 10:28:48 -0600 Subject: [PATCH 424/722] arm64/setjmp: Add missing license macro Including the setjmp module in an arm64-efi image will cause it to immediately exit with an "incompatible license" error. The source file includes a GPLv3+ boilerplate, so fix this by declaring a GPLv3+ license using the GRUB_MOD_LICENSE macro. Signed-off-by: dann frazier --- grub-core/lib/arm64/setjmp.S | 2 ++ 1 file changed, 2 insertions(+) diff --git a/grub-core/lib/arm64/setjmp.S b/grub-core/lib/arm64/setjmp.S index adaafe40f..eabfd99b2 100644 --- a/grub-core/lib/arm64/setjmp.S +++ b/grub-core/lib/arm64/setjmp.S @@ -17,8 +17,10 @@ */ #include +#include .file "setjmp.S" +GRUB_MOD_LICENSE "GPLv3+" .text /* From 43d4231432838821cabe4f6aea4f0f50e87af9c4 Mon Sep 17 00:00:00 2001 From: Leif Lindholm Date: Tue, 2 Jun 2015 15:41:09 +0100 Subject: [PATCH 425/722] configure.ac: clean up arm64 soft-float handling Fix compilation with gcc 5.1 (avoid internal compiler error), by replacing explicit -march +nofp+nosimd options with -mgeneral-regs-only. This also enables the removal of some further conditional build flag setting. --- configure.ac | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/configure.ac b/configure.ac index 891c14ff3..fd8a62ead 100644 --- a/configure.ac +++ b/configure.ac @@ -686,9 +686,9 @@ if test x"$platform" != xemu ; then AC_CACHE_CHECK([for options to get soft-float], grub_cv_target_cc_soft_float, [ grub_cv_target_cc_soft_float=no if test "x$target_cpu" = xarm64; then - CFLAGS="$TARGET_CFLAGS -march=armv8-a+nofp+nosimd -Werror" + CFLAGS="$TARGET_CFLAGS -mgeneral-regs-only -Werror" AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])], - [grub_cv_target_cc_soft_float="-march=armv8-a+nofp+nosimd"], []) + [grub_cv_target_cc_soft_float="-mgeneral-regs-only"], []) fi if test "x$target_cpu" = xia64; then CFLAGS="$TARGET_CFLAGS -mno-inline-float-divide -mno-inline-sqrt -Werror" @@ -720,15 +720,7 @@ if test x"$platform" != xemu ; then TARGET_CFLAGS="$TARGET_CFLAGS $grub_cv_target_cc_soft_float" ;; esac - case x"$grub_cv_target_cc_soft_float" in - x"-march=armv8-a+nofp+nosimd") - # +nosimd disables also the cache opcodes that we need in asm. - TARGET_CCASFLAGS="$TARGET_CCASFLAGS -march=armv8-a+nofp" - ;; - *) - TARGET_CCASFLAGS="$TARGET_CCASFLAGS $grub_cv_target_cc_soft_float" - ;; - esac + TARGET_CCASFLAGS="$TARGET_CCASFLAGS $grub_cv_target_cc_soft_float" fi From 697eceff6a168e8712fb7b784b333e0aeb925958 Mon Sep 17 00:00:00 2001 From: Toomas Soome Date: Thu, 4 Jun 2015 19:41:54 +0300 Subject: [PATCH 426/722] multiboot_header_tag_module_align fix to confirm multiboot specification --- include/multiboot2.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/include/multiboot2.h b/include/multiboot2.h index 3ccff15fc..9d4862759 100644 --- a/include/multiboot2.h +++ b/include/multiboot2.h @@ -156,9 +156,6 @@ struct multiboot_header_tag_module_align multiboot_uint16_t type; multiboot_uint16_t flags; multiboot_uint32_t size; - multiboot_uint32_t width; - multiboot_uint32_t height; - multiboot_uint32_t depth; }; struct multiboot_color From d3ffeb9a9a54148af610cd122028783217d30699 Mon Sep 17 00:00:00 2001 From: Jan Kara Date: Mon, 1 Jun 2015 14:28:45 +0200 Subject: [PATCH 427/722] xfs: Add helpers for inode size Add helpers to return size of XFS inode on disk and when loaded in memory. Signed-off-by: Jan Kara --- grub-core/fs/xfs.c | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/grub-core/fs/xfs.c b/grub-core/fs/xfs.c index 0d704e9a4..26d8147a9 100644 --- a/grub-core/fs/xfs.c +++ b/grub-core/fs/xfs.c @@ -255,6 +255,24 @@ grub_xfs_inode_offset (struct grub_xfs_data *data, data->sblock.log2_inode); } +static inline grub_size_t +grub_xfs_inode_size(struct grub_xfs_data *data) +{ + return 1 << data->sblock.log2_inode; +} + +/* + * Returns size occupied by XFS inode stored in memory - we store struct + * grub_fshelp_node there but on disk inode size may be actually larger than + * struct grub_xfs_inode so we need to account for that so that we can read + * from disk directly into in-memory structure. + */ +static inline grub_size_t +grub_xfs_fshelp_size(struct grub_xfs_data *data) +{ + return sizeof (struct grub_fshelp_node) - sizeof (struct grub_xfs_inode) + + grub_xfs_inode_size(data); +} static grub_err_t grub_xfs_read_inode (struct grub_xfs_data *data, grub_uint64_t ino, @@ -264,8 +282,8 @@ grub_xfs_read_inode (struct grub_xfs_data *data, grub_uint64_t ino, int offset = grub_xfs_inode_offset (data, ino); /* Read the inode. */ - if (grub_disk_read (data->disk, block, offset, - 1 << data->sblock.log2_inode, inode)) + if (grub_disk_read (data->disk, block, offset, grub_xfs_inode_size(data), + inode)) return grub_errno; if (grub_strncmp ((char *) inode->magic, "IN", 2)) @@ -297,7 +315,7 @@ grub_xfs_read_block (grub_fshelp_node_t node, grub_disk_addr_t fileblock) if (node->inode.fork_offset) recoffset = (node->inode.fork_offset - 1) / 2; else - recoffset = ((1 << node->data->sblock.log2_inode) + recoffset = (grub_xfs_inode_size(node->data) - ((char *) &node->inode.data.btree.keys - (char *) &node->inode)) / (2 * sizeof (grub_uint64_t)); @@ -456,9 +474,7 @@ static int iterate_dir_call_hook (grub_uint64_t ino, const char *filename, struct grub_fshelp_node *fdiro; grub_err_t err; - fdiro = grub_malloc (sizeof (struct grub_fshelp_node) - - sizeof (struct grub_xfs_inode) - + (1 << ctx->diro->data->sblock.log2_inode) + 1); + fdiro = grub_malloc (grub_xfs_fshelp_size(ctx->diro->data) + 1); if (!fdiro) { grub_print_error (); @@ -682,7 +698,7 @@ grub_xfs_mount (grub_disk_t disk) data = grub_realloc (data, sizeof (struct grub_xfs_data) - sizeof (struct grub_xfs_inode) - + (1 << data->sblock.log2_inode) + 1); + + grub_xfs_inode_size(data) + 1); if (! data) goto fail; @@ -797,10 +813,7 @@ grub_xfs_open (struct grub_file *file, const char *name) if (fdiro != &data->diropen) { - grub_memcpy (&data->diropen, fdiro, - sizeof (struct grub_fshelp_node) - - sizeof (struct grub_xfs_inode) - + (1 << data->sblock.log2_inode)); + grub_memcpy (&data->diropen, fdiro, grub_xfs_fshelp_size(data)); grub_free (fdiro); } From b6e80c7778b708c1632d957d00507aad60d9e255 Mon Sep 17 00:00:00 2001 From: Jan Kara Date: Mon, 1 Jun 2015 14:28:46 +0200 Subject: [PATCH 428/722] xfs: V5 filesystem format support Add support for new XFS on disk format. We have to handle optional filetype fields in directory entries, additional CRC, LSN, UUID entries in some structures, etc. Signed-off-by: Jan Kara --- grub-core/fs/xfs.c | 332 ++++++++++++++++++++++++++++++++++----------- 1 file changed, 252 insertions(+), 80 deletions(-) diff --git a/grub-core/fs/xfs.c b/grub-core/fs/xfs.c index 26d8147a9..f00e43e7d 100644 --- a/grub-core/fs/xfs.c +++ b/grub-core/fs/xfs.c @@ -34,6 +34,50 @@ GRUB_MOD_LICENSE ("GPLv3+"); #define XFS_INODE_FORMAT_EXT 2 #define XFS_INODE_FORMAT_BTREE 3 +/* Superblock version field flags */ +#define XFS_SB_VERSION_NUMBITS 0x000f +#define XFS_SB_VERSION_ATTRBIT 0x0010 +#define XFS_SB_VERSION_NLINKBIT 0x0020 +#define XFS_SB_VERSION_QUOTABIT 0x0040 +#define XFS_SB_VERSION_ALIGNBIT 0x0080 +#define XFS_SB_VERSION_DALIGNBIT 0x0100 +#define XFS_SB_VERSION_LOGV2BIT 0x0400 +#define XFS_SB_VERSION_SECTORBIT 0x0800 +#define XFS_SB_VERSION_EXTFLGBIT 0x1000 +#define XFS_SB_VERSION_DIRV2BIT 0x2000 +#define XFS_SB_VERSION_MOREBITSBIT 0x8000 +#define XFS_SB_VERSION_BITS_SUPPORTED \ + (XFS_SB_VERSION_NUMBITS | \ + XFS_SB_VERSION_ATTRBIT | \ + XFS_SB_VERSION_NLINKBIT | \ + XFS_SB_VERSION_QUOTABIT | \ + XFS_SB_VERSION_ALIGNBIT | \ + XFS_SB_VERSION_DALIGNBIT | \ + XFS_SB_VERSION_LOGV2BIT | \ + XFS_SB_VERSION_SECTORBIT | \ + XFS_SB_VERSION_EXTFLGBIT | \ + XFS_SB_VERSION_DIRV2BIT | \ + XFS_SB_VERSION_MOREBITSBIT) + +/* Recognized xfs format versions */ +#define XFS_SB_VERSION_4 4 /* Good old XFS filesystem */ +#define XFS_SB_VERSION_5 5 /* CRC enabled filesystem */ + +/* features2 field flags */ +#define XFS_SB_VERSION2_LAZYSBCOUNTBIT 0x00000002 /* Superblk counters */ +#define XFS_SB_VERSION2_ATTR2BIT 0x00000008 /* Inline attr rework */ +#define XFS_SB_VERSION2_PROJID32BIT 0x00000080 /* 32-bit project ids */ +#define XFS_SB_VERSION2_FTYPE 0x00000200 /* inode type in dir */ +#define XFS_SB_VERSION2_BITS_SUPPORTED \ + (XFS_SB_VERSION2_LAZYSBCOUNTBIT | \ + XFS_SB_VERSION2_ATTR2BIT | \ + XFS_SB_VERSION2_PROJID32BIT | \ + XFS_SB_VERSION2_FTYPE) + +/* incompat feature flags */ +#define XFS_SB_FEAT_INCOMPAT_FTYPE (1 << 0) /* filetype in dirent */ +#define XFS_SB_FEAT_INCOMPAT_SUPPORTED \ + (XFS_SB_FEAT_INCOMPAT_FTYPE) struct grub_xfs_sblock { @@ -45,7 +89,9 @@ struct grub_xfs_sblock grub_uint64_t rootino; grub_uint8_t unused3[20]; grub_uint32_t agsize; - grub_uint8_t unused4[20]; + grub_uint8_t unused4[12]; + grub_uint16_t version; + grub_uint8_t unused5[6]; grub_uint8_t label[12]; grub_uint8_t log2_bsize; grub_uint8_t log2_sect; @@ -54,12 +100,19 @@ struct grub_xfs_sblock grub_uint8_t log2_agblk; grub_uint8_t unused6[67]; grub_uint8_t log2_dirblk; + grub_uint8_t unused7[7]; + grub_uint32_t features2; + grub_uint8_t unused8[4]; + grub_uint32_t sb_features_compat; + grub_uint32_t sb_features_ro_compat; + grub_uint32_t sb_features_incompat; + grub_uint32_t sb_features_log_incompat; } GRUB_PACKED; struct grub_xfs_dir_header { grub_uint8_t count; - grub_uint8_t smallino; + grub_uint8_t largeino; union { grub_uint32_t i4; @@ -67,14 +120,16 @@ struct grub_xfs_dir_header } GRUB_PACKED parent; } GRUB_PACKED; +/* Structure for directory entry inlined in the inode */ struct grub_xfs_dir_entry { grub_uint8_t len; grub_uint16_t offset; char name[1]; - /* Inode number follows, 32 bits. */ + /* Inode number follows, 32 / 64 bits. */ } GRUB_PACKED; +/* Structure for directory entry in a block */ struct grub_xfs_dir2_entry { grub_uint64_t inode; @@ -90,7 +145,8 @@ struct grub_xfs_btree_node grub_uint16_t numrecs; grub_uint64_t left; grub_uint64_t right; - grub_uint64_t keys[1]; + /* In V5 here follow crc, uuid, etc. */ + /* Then follow keys and block pointers */ } GRUB_PACKED; struct grub_xfs_btree_root @@ -123,19 +179,11 @@ struct grub_xfs_inode grub_uint16_t unused3; grub_uint8_t fork_offset; grub_uint8_t unused4[17]; - union - { - char raw[156]; - struct dir - { - struct grub_xfs_dir_header dirhead; - struct grub_xfs_dir_entry direntry[1]; - } dir; - grub_xfs_extent extents[XFS_INODE_EXTENTS]; - struct grub_xfs_btree_root btree; - } GRUB_PACKED data; } GRUB_PACKED; +#define XFS_V2_INODE_SIZE sizeof(struct grub_xfs_inode) +#define XFS_V3_INODE_SIZE (XFS_V2_INODE_SIZE + 76) + struct grub_xfs_dirblock_tail { grub_uint32_t leaf_count; @@ -157,6 +205,8 @@ struct grub_xfs_data int pos; int bsize; grub_uint32_t agsize; + unsigned int hasftype:1; + unsigned int hascrc:1; struct grub_fshelp_node diropen; }; @@ -164,6 +214,71 @@ static grub_dl_t my_mod; +static int grub_xfs_sb_hascrc(struct grub_xfs_data *data) +{ + return (data->sblock.version & grub_cpu_to_be16_compile_time(XFS_SB_VERSION_NUMBITS)) == + grub_cpu_to_be16_compile_time(XFS_SB_VERSION_5); +} + +static int grub_xfs_sb_hasftype(struct grub_xfs_data *data) +{ + if ((data->sblock.version & grub_cpu_to_be16_compile_time(XFS_SB_VERSION_NUMBITS)) == + grub_cpu_to_be16_compile_time(XFS_SB_VERSION_5) && + data->sblock.sb_features_incompat & grub_cpu_to_be32_compile_time(XFS_SB_FEAT_INCOMPAT_FTYPE)) + return 1; + if (data->sblock.version & grub_cpu_to_be16_compile_time(XFS_SB_VERSION_MOREBITSBIT) && + data->sblock.features2 & grub_cpu_to_be32_compile_time(XFS_SB_VERSION2_FTYPE)) + return 1; + return 0; +} + +static int grub_xfs_sb_valid(struct grub_xfs_data *data) +{ + grub_dprintf("xfs", "Validating superblock\n"); + if (grub_strncmp ((char *) (data->sblock.magic), "XFSB", 4) + || data->sblock.log2_bsize < GRUB_DISK_SECTOR_BITS + || ((int) data->sblock.log2_bsize + + (int) data->sblock.log2_dirblk) >= 27) + { + grub_error (GRUB_ERR_BAD_FS, "not a XFS filesystem"); + return 0; + } + if ((data->sblock.version & grub_cpu_to_be16_compile_time(XFS_SB_VERSION_NUMBITS)) == + grub_cpu_to_be16_compile_time(XFS_SB_VERSION_5)) + { + grub_dprintf("xfs", "XFS v5 superblock detected\n"); + if (data->sblock.sb_features_incompat & + grub_cpu_to_be32_compile_time(~XFS_SB_FEAT_INCOMPAT_SUPPORTED)) + { + grub_error (GRUB_ERR_BAD_FS, "XFS filesystem has unsupported " + "incompatible features"); + return 0; + } + return 1; + } + else if ((data->sblock.version & grub_cpu_to_be16_compile_time(XFS_SB_VERSION_NUMBITS)) == + grub_cpu_to_be16_compile_time(XFS_SB_VERSION_4)) + { + grub_dprintf("xfs", "XFS v4 superblock detected\n"); + if (!(data->sblock.version & grub_cpu_to_be16_compile_time(XFS_SB_VERSION_DIRV2BIT))) + { + grub_error (GRUB_ERR_BAD_FS, "XFS filesystem without V2 directories " + "is unsupported"); + return 0; + } + if (data->sblock.version & grub_cpu_to_be16_compile_time(~XFS_SB_VERSION_BITS_SUPPORTED) || + (data->sblock.version & grub_cpu_to_be16_compile_time(XFS_SB_VERSION_MOREBITSBIT) && + data->sblock.features2 & grub_cpu_to_be16_compile_time(~XFS_SB_VERSION2_BITS_SUPPORTED))) + { + grub_error (GRUB_ERR_BAD_FS, "XFS filesystem has unsupported version " + "bits"); + return 0; + } + return 1; + } + return 0; +} + /* Filetype information as used in inodes. */ #define FILETYPE_INO_MASK 0170000 #define FILETYPE_INO_REG 0100000 @@ -219,18 +334,6 @@ GRUB_XFS_EXTENT_SIZE (grub_xfs_extent *exts, int ex) return (grub_be_to_cpu32 (exts[ex][3]) & ((1 << 21) - 1)); } -static inline int -GRUB_XFS_ROUND_TO_DIRENT (int pos) -{ - return ((((pos) + 8 - 1) / 8) * 8); -} - -static inline int -GRUB_XFS_NEXT_DIRENT (int pos, int len) -{ - return (pos) + GRUB_XFS_ROUND_TO_DIRENT (8 + 1 + len + 2); -} - static inline grub_uint64_t grub_xfs_inode_block (struct grub_xfs_data *data, @@ -274,6 +377,85 @@ grub_xfs_fshelp_size(struct grub_xfs_data *data) + grub_xfs_inode_size(data); } +static void * +grub_xfs_inode_data(struct grub_xfs_inode *inode) +{ + if (inode->version <= 2) + return ((char *)inode) + XFS_V2_INODE_SIZE; + return ((char *)inode) + XFS_V3_INODE_SIZE; +} + +static struct grub_xfs_dir_entry * +grub_xfs_inline_de(struct grub_xfs_dir_header *head) +{ + /* + * With small inode numbers the header is 4 bytes smaller because of + * smaller parent pointer + */ + return (void *)(((char *)head) + sizeof(struct grub_xfs_dir_header) - + (head->largeino ? 0 : sizeof(grub_uint32_t))); +} + +static grub_uint8_t * +grub_xfs_inline_de_inopos(struct grub_xfs_data *data, + struct grub_xfs_dir_entry *de) +{ + return ((grub_uint8_t *)(de + 1)) + de->len - 1 + + (data->hasftype ? 1 : 0); +} + +static struct grub_xfs_dir_entry * +grub_xfs_inline_next_de(struct grub_xfs_data *data, + struct grub_xfs_dir_header *head, + struct grub_xfs_dir_entry *de) +{ + char *p = (char *)de + sizeof(struct grub_xfs_dir_entry) - 1 + de->len; + + p += head->largeino ? sizeof(grub_uint64_t) : sizeof(grub_uint32_t); + if (data->hasftype) + p++; + + return (struct grub_xfs_dir_entry *)p; +} + +static struct grub_xfs_dirblock_tail * +grub_xfs_dir_tail(struct grub_xfs_data *data, void *dirblock) +{ + int dirblksize = 1 << (data->sblock.log2_bsize + data->sblock.log2_dirblk); + + return (struct grub_xfs_dirblock_tail *) + ((char *)dirblock + dirblksize - sizeof (struct grub_xfs_dirblock_tail)); +} + +static struct grub_xfs_dir2_entry * +grub_xfs_first_de(struct grub_xfs_data *data, void *dirblock) +{ + if (data->hascrc) + return (struct grub_xfs_dir2_entry *)((char *)dirblock + 64); + return (struct grub_xfs_dir2_entry *)((char *)dirblock + 16); +} + +static struct grub_xfs_dir2_entry * +grub_xfs_next_de(struct grub_xfs_data *data, struct grub_xfs_dir2_entry *de) +{ + int size = sizeof (struct grub_xfs_dir2_entry) + de->len + 2 /* Tag */; + + if (data->hasftype) + size++; /* File type */ + return (struct grub_xfs_dir2_entry *)(((char *)de) + ALIGN_UP(size, 8)); +} + +static grub_uint64_t * +grub_xfs_btree_keys(struct grub_xfs_data *data, + struct grub_xfs_btree_node *leaf) +{ + grub_uint64_t *keys = (grub_uint64_t *)(leaf + 1); + + if (data->hascrc) + keys += 6; /* skip crc, uuid, ... */ + return keys; +} + static grub_err_t grub_xfs_read_inode (struct grub_xfs_data *data, grub_uint64_t ino, struct grub_xfs_inode *inode) @@ -281,6 +463,8 @@ grub_xfs_read_inode (struct grub_xfs_data *data, grub_uint64_t ino, grub_uint64_t block = grub_xfs_inode_block (data, ino); int offset = grub_xfs_inode_offset (data, ino); + grub_dprintf("xfs", "Reading inode (%"PRIuGRUB_UINT64_T") - %"PRIuGRUB_UINT64_T", %d\n", + ino, block, offset); /* Read the inode. */ if (grub_disk_read (data->disk, block, offset, grub_xfs_inode_size(data), inode)) @@ -303,6 +487,7 @@ grub_xfs_read_block (grub_fshelp_node_t node, grub_disk_addr_t fileblock) if (node->inode.format == XFS_INODE_FORMAT_BTREE) { + struct grub_xfs_btree_root *root; const grub_uint64_t *keys; int recoffset; @@ -310,15 +495,15 @@ grub_xfs_read_block (grub_fshelp_node_t node, grub_disk_addr_t fileblock) if (leaf == 0) return 0; - nrec = grub_be_to_cpu16 (node->inode.data.btree.numrecs); - keys = &node->inode.data.btree.keys[0]; + root = grub_xfs_inode_data(&node->inode); + nrec = grub_be_to_cpu16 (root->numrecs); + keys = &root->keys[0]; if (node->inode.fork_offset) recoffset = (node->inode.fork_offset - 1) / 2; else recoffset = (grub_xfs_inode_size(node->data) - - ((char *) &node->inode.data.btree.keys - - (char *) &node->inode)) - / (2 * sizeof (grub_uint64_t)); + - ((char *) keys - (char *) &node->inode)) + / (2 * sizeof (grub_uint64_t)); do { int i; @@ -340,7 +525,10 @@ grub_xfs_read_block (grub_fshelp_node_t node, grub_disk_addr_t fileblock) 0, node->data->bsize, leaf)) return 0; - if (grub_strncmp ((char *) leaf->magic, "BMAP", 4)) + if ((!node->data->hascrc && + grub_strncmp ((char *) leaf->magic, "BMAP", 4)) || + (node->data->hascrc && + grub_strncmp ((char *) leaf->magic, "BMA3", 4))) { grub_free (leaf); grub_error (GRUB_ERR_BAD_FS, "not a correct XFS BMAP node"); @@ -348,8 +536,8 @@ grub_xfs_read_block (grub_fshelp_node_t node, grub_disk_addr_t fileblock) } nrec = grub_be_to_cpu16 (leaf->numrecs); - keys = &leaf->keys[0]; - recoffset = ((node->data->bsize - ((char *) &leaf->keys + keys = grub_xfs_btree_keys(node->data, leaf); + recoffset = ((node->data->bsize - ((char *) keys - (char *) leaf)) / (2 * sizeof (grub_uint64_t))); } @@ -359,7 +547,7 @@ grub_xfs_read_block (grub_fshelp_node_t node, grub_disk_addr_t fileblock) else if (node->inode.format == XFS_INODE_FORMAT_EXT) { nrec = grub_be_to_cpu32 (node->inode.nextents); - exts = &node->inode.data.extents[0]; + exts = grub_xfs_inode_data(&node->inode); } else { @@ -417,7 +605,7 @@ grub_xfs_read_symlink (grub_fshelp_node_t node) switch (node->inode.format) { case XFS_INODE_FORMAT_INO: - return grub_strndup (node->inode.data.raw, size); + return grub_strndup (grub_xfs_inode_data(&node->inode), size); case XFS_INODE_FORMAT_EXT: { @@ -512,23 +700,18 @@ grub_xfs_iterate_dir (grub_fshelp_node_t dir, { case XFS_INODE_FORMAT_INO: { - struct grub_xfs_dir_entry *de = &diro->inode.data.dir.direntry[0]; - int smallino = !diro->inode.data.dir.dirhead.smallino; + struct grub_xfs_dir_header *head = grub_xfs_inode_data(&diro->inode); + struct grub_xfs_dir_entry *de = grub_xfs_inline_de(head); + int smallino = !head->largeino; int i; grub_uint64_t parent; /* If small inode numbers are used to pack the direntry, the parent inode number is small too. */ if (smallino) - { - parent = grub_be_to_cpu32 (diro->inode.data.dir.dirhead.parent.i4); - /* The header is a bit smaller than usual. */ - de = (struct grub_xfs_dir_entry *) ((char *) de - 4); - } + parent = grub_be_to_cpu32 (head->parent.i4); else - { - parent = grub_be_to_cpu64(diro->inode.data.dir.dirhead.parent.i8); - } + parent = grub_be_to_cpu64 (head->parent.i8); /* Synthesize the direntries for `.' and `..'. */ if (iterate_dir_call_hook (diro->ino, ".", &ctx)) @@ -537,12 +720,10 @@ grub_xfs_iterate_dir (grub_fshelp_node_t dir, if (iterate_dir_call_hook (parent, "..", &ctx)) return 1; - for (i = 0; i < diro->inode.data.dir.dirhead.count; i++) + for (i = 0; i < head->count; i++) { grub_uint64_t ino; - grub_uint8_t *inopos = (((grub_uint8_t *) de) - + sizeof (struct grub_xfs_dir_entry) - + de->len - 1); + grub_uint8_t *inopos = grub_xfs_inline_de_inopos(dir->data, de); grub_uint8_t c; /* inopos might be unaligned. */ @@ -567,10 +748,7 @@ grub_xfs_iterate_dir (grub_fshelp_node_t dir, return 1; de->name[de->len] = c; - de = ((struct grub_xfs_dir_entry *) - (((char *) de)+ sizeof (struct grub_xfs_dir_entry) + de->len - + ((smallino ? sizeof (grub_uint32_t) - : sizeof (grub_uint64_t))) - 1)); + de = grub_xfs_inline_next_de(dir->data, head, de); } break; } @@ -597,15 +775,11 @@ grub_xfs_iterate_dir (grub_fshelp_node_t dir, >> dirblk_log2); blk++) { - /* The header is skipped, the first direntry is stored - from byte 16. */ - int pos = 16; + struct grub_xfs_dir2_entry *direntry = + grub_xfs_first_de(dir->data, dirblock); int entries; - int tail_start = (dirblk_size - - sizeof (struct grub_xfs_dirblock_tail)); - - struct grub_xfs_dirblock_tail *tail; - tail = (struct grub_xfs_dirblock_tail *) &dirblock[tail_start]; + struct grub_xfs_dirblock_tail *tail = + grub_xfs_dir_tail(dir->data, dirblock); numread = grub_xfs_read_file (dir, 0, 0, blk << dirblk_log2, @@ -617,13 +791,11 @@ grub_xfs_iterate_dir (grub_fshelp_node_t dir, - grub_be_to_cpu32 (tail->leaf_stale)); /* Iterate over all entries within this block. */ - while (pos < tail_start) + while ((char *)direntry < (char *)tail) { - struct grub_xfs_dir2_entry *direntry; grub_uint8_t *freetag; char *filename; - direntry = (struct grub_xfs_dir2_entry *) &dirblock[pos]; freetag = (grub_uint8_t *) direntry; if (grub_get_unaligned16 (freetag) == 0XFFFF) @@ -631,14 +803,16 @@ grub_xfs_iterate_dir (grub_fshelp_node_t dir, grub_uint8_t *skip = (freetag + sizeof (grub_uint16_t)); /* This entry is not used, go to the next one. */ - pos += grub_be_to_cpu16 (grub_get_unaligned16 (skip)); + direntry = (struct grub_xfs_dir2_entry *) + (((char *)direntry) + + grub_be_to_cpu16 (grub_get_unaligned16 (skip))); continue; } - filename = &dirblock[pos + sizeof (*direntry)]; - /* The byte after the filename is for the tag, which - is not used by GRUB. So it can be overwritten. */ + filename = (char *)(direntry + 1); + /* The byte after the filename is for the filetype, padding, or + tag, which is not used by GRUB. So it can be overwritten. */ filename[direntry->len] = '\0'; if (iterate_dir_call_hook (grub_be_to_cpu64(direntry->inode), @@ -655,8 +829,7 @@ grub_xfs_iterate_dir (grub_fshelp_node_t dir, break; /* Select the next directory entry. */ - pos = GRUB_XFS_NEXT_DIRENT (pos, direntry->len); - pos = GRUB_XFS_ROUND_TO_DIRENT (pos); + direntry = grub_xfs_next_de(dir->data, direntry); } } grub_free (dirblock); @@ -681,19 +854,14 @@ grub_xfs_mount (grub_disk_t disk) if (!data) return 0; + grub_dprintf("xfs", "Reading sb\n"); /* Read the superblock. */ if (grub_disk_read (disk, 0, 0, sizeof (struct grub_xfs_sblock), &data->sblock)) goto fail; - if (grub_strncmp ((char *) (data->sblock.magic), "XFSB", 4) - || data->sblock.log2_bsize < GRUB_DISK_SECTOR_BITS - || ((int) data->sblock.log2_bsize - + (int) data->sblock.log2_dirblk) >= 27) - { - grub_error (GRUB_ERR_BAD_FS, "not a XFS filesystem"); - goto fail; - } + if (!grub_xfs_sb_valid(data)) + goto fail; data = grub_realloc (data, sizeof (struct grub_xfs_data) @@ -708,9 +876,13 @@ grub_xfs_mount (grub_disk_t disk) data->diropen.inode_read = 1; data->bsize = grub_be_to_cpu32 (data->sblock.bsize); data->agsize = grub_be_to_cpu32 (data->sblock.agsize); + data->hasftype = grub_xfs_sb_hasftype(data); + data->hascrc = grub_xfs_sb_hascrc(data); data->disk = disk; data->pos = 0; + grub_dprintf("xfs", "Reading root ino %"PRIuGRUB_UINT64_T"\n", + grub_cpu_to_be64(data->sblock.rootino)); grub_xfs_read_inode (data, data->diropen.ino, &data->diropen.inode); From df2aaf94b8d76b1ff7479ad5dc990f3efa30e419 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Fri, 12 Jun 2015 09:40:00 +0300 Subject: [PATCH 429/722] NEWS: XFS v5 support --- NEWS | 1 + 1 file changed, 1 insertion(+) diff --git a/NEWS b/NEWS index e417ebad1..ad572ffe1 100644 --- a/NEWS +++ b/NEWS @@ -17,6 +17,7 @@ New in 2.02: files. * ZFS features support. * ZFS LZ4 support. + * XFS V5 format support. * New/improved terminal and video support: * Monochrome text (matching `hercules' in GRUB Legacy). From f4b1b48a837a034748a103adc7e9fd719a39ce42 Mon Sep 17 00:00:00 2001 From: Paul Menzel Date: Thu, 28 May 2015 19:14:19 +0200 Subject: [PATCH 430/722] disk/ahci.c: Use defines `GRUB_AHCI_HBA_PORT_CMD_SPIN_UP` and `GRUB_AHCI_HBA_PORT_CMD_POWER_ON` Instead of hard coding `2` and `4` use the macros defined already at the top of the file. As a consequence, wrap the now too long line. --- grub-core/disk/ahci.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/grub-core/disk/ahci.c b/grub-core/disk/ahci.c index da5fead26..f4725e8c1 100644 --- a/grub-core/disk/ahci.c +++ b/grub-core/disk/ahci.c @@ -552,7 +552,9 @@ grub_ahci_pciinit (grub_pci_device_t dev, adevs[i]->hba->ports[adevs[i]->port].sata_error); adevs[i]->hba->ports[adevs[i]->port].command - = (adevs[i]->hba->ports[adevs[i]->port].command & 0x0fffffff) | (1 << 28) | 2 | 4; + = (adevs[i]->hba->ports[adevs[i]->port].command & 0x0fffffff) | (1 << 28) + | GRUB_AHCI_HBA_PORT_CMD_SPIN_UP + | GRUB_AHCI_HBA_PORT_CMD_POWER_ON; /* struct grub_disk_ata_pass_through_parms parms2; grub_memset (&parms2, 0, sizeof (parms2)); From c945ca75c3b2b900040b905323b1226cb60a1166 Mon Sep 17 00:00:00 2001 From: Mark Salter Date: Fri, 15 Aug 2014 12:22:43 -0400 Subject: [PATCH 431/722] Fix exit to EFI firmware The current code for EFI grub_exit() calls grub_efi_fini() before returning to firmware. In the case of ARM, this leaves a timer event running which could lead to a firmware crash. This patch changes this so that grub_machine_fini() is called with a NORETURN flag. This allows machine-specific shutdown to happen as well as the shutdown done by grub_efi_fini(). Signed-off-by: Mark Salter --- grub-core/kern/arm/efi/init.c | 2 +- grub-core/kern/efi/efi.c | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/grub-core/kern/arm/efi/init.c b/grub-core/kern/arm/efi/init.c index a6ae03475..2572ca8b7 100644 --- a/grub-core/kern/arm/efi/init.c +++ b/grub-core/kern/arm/efi/init.c @@ -67,7 +67,7 @@ grub_machine_fini (int flags) b = grub_efi_system_table->boot_services; - efi_call_3 (b->set_timer, tmr_evt, GRUB_EFI_TIMER_PERIODIC, 0); + efi_call_3 (b->set_timer, tmr_evt, GRUB_EFI_TIMER_CANCEL, 0); efi_call_1 (b->close_event, tmr_evt); grub_efi_fini (); diff --git a/grub-core/kern/efi/efi.c b/grub-core/kern/efi/efi.c index 49a150133..2e7783468 100644 --- a/grub-core/kern/efi/efi.c +++ b/grub-core/kern/efi/efi.c @@ -27,6 +27,7 @@ #include #include #include +#include /* The handle of GRUB itself. Filled in by the startup code. */ grub_efi_handle_t grub_efi_image_handle; @@ -156,7 +157,7 @@ grub_efi_get_loaded_image (grub_efi_handle_t image_handle) void grub_exit (void) { - grub_efi_fini (); + grub_machine_fini (GRUB_LOADER_FLAG_NORETURN); efi_call_4 (grub_efi_system_table->boot_services->exit, grub_efi_image_handle, GRUB_EFI_SUCCESS, 0, 0); for (;;) ; From afd0f21b2027310fda52b00ac1b964041d39a363 Mon Sep 17 00:00:00 2001 From: Paulo Flabiano Smorigo Date: Mon, 15 Jun 2015 09:10:19 -0300 Subject: [PATCH 432/722] Add flag for powerpc ieee1275 to avoid unneeded optimizations --- conf/Makefile.common | 3 +++ 1 file changed, 3 insertions(+) diff --git a/conf/Makefile.common b/conf/Makefile.common index 96e58c9a4..fcb8d2e1c 100644 --- a/conf/Makefile.common +++ b/conf/Makefile.common @@ -17,6 +17,9 @@ endif if COND_arm64 CFLAGS_PLATFORM += -mcmodel=large endif +if COND_powerpc_ieee1275 + CFLAGS_PLATFORM += -mcpu=powerpc +endif #FIXME: discover and check XEN headers CPPFLAGS_XEN = -I/usr/include From b27af387ea56123bfb101f2129490fa2df704d22 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Tue, 16 Jun 2015 19:49:32 +0300 Subject: [PATCH 433/722] NEWS: mention libgcc removal --- NEWS | 3 +++ 1 file changed, 3 insertions(+) diff --git a/NEWS b/NEWS index ad572ffe1..6e33909de 100644 --- a/NEWS +++ b/NEWS @@ -146,6 +146,9 @@ New in 2.02: Python 2.6. * modinfo.sh contains build information now. * Added many new tests to improve robustness. + * Target is built without libgcc now. Necessary builtins are reimplemented + directly. This removes requirement for target-specific runtime on build + system. * Revision control moved to git. From f348aee7b33dd85e7da62b497a96a7319a0bf9dd Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Tue, 16 Jun 2015 19:52:45 +0300 Subject: [PATCH 434/722] efinet: enable hardware filters when opening interface Exclusive open on SNP will close all existing protocol instances which may disable all receive filters on interface. Reinstall them after we opened protocol exclusively. Also follow UEFI specification recommendation and stop interfaces when closing them: Unexpected system errors, reboots and hangs can occur if an OS is loaded and the network devices are not Shutdown() and Stopped(). Also by: Mark Salter Closes: 45204 --- grub-core/net/drivers/efi/efinet.c | 25 +++++++++++++++++++++++++ include/grub/efi/api.h | 20 +++++++++++++++++--- 2 files changed, 42 insertions(+), 3 deletions(-) diff --git a/grub-core/net/drivers/efi/efinet.c b/grub-core/net/drivers/efi/efinet.c index 5533515fd..70b26af94 100644 --- a/grub-core/net/drivers/efi/efinet.c +++ b/grub-core/net/drivers/efi/efinet.c @@ -168,6 +168,29 @@ open_card (struct grub_net_card *dev) return grub_error (GRUB_ERR_NET_NO_CARD, "%s: net initialize failed", dev->name); + /* Enable hardware receive filters if driver declares support for it. + We need unicast and broadcast and additionaly all nodes and + solicited multicast for IPv6. Solicited multicast is per-IPv6 + address and we currently do not have API to do it so simply + try to enable receive of all multicast packets or evertyhing in + the worst case (i386 PXE driver always enables promiscuous too). + + This does trust firmware to do what it claims to do. + */ + if (net->mode->receive_filter_mask) + { + grub_uint32_t filters = GRUB_EFI_SIMPLE_NETWORK_RECEIVE_UNICAST | + GRUB_EFI_SIMPLE_NETWORK_RECEIVE_BROADCAST | + GRUB_EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS_MULTICAST; + + filters &= net->mode->receive_filter_mask; + if (!(filters & GRUB_EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS_MULTICAST)) + filters |= (net->mode->receive_filter_mask & + GRUB_EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS); + + efi_call_6 (net->receive_filters, net, filters, 0, 0, 0, NULL); + } + efi_call_4 (grub_efi_system_table->boot_services->close_protocol, dev->efi_net, &net_io_guid, grub_efi_image_handle, dev->efi_handle); @@ -181,6 +204,8 @@ open_card (struct grub_net_card *dev) static void close_card (struct grub_net_card *dev) { + efi_call_1 (dev->efi_net->shutdown, dev->efi_net); + efi_call_1 (dev->efi_net->stop, dev->efi_net); efi_call_4 (grub_efi_system_table->boot_services->close_protocol, dev->efi_net, &net_io_guid, grub_efi_image_handle, dev->efi_handle); diff --git a/include/grub/efi/api.h b/include/grub/efi/api.h index e5dd543a8..1a5e38c1e 100644 --- a/include/grub/efi/api.h +++ b/include/grub/efi/api.h @@ -1501,17 +1501,31 @@ enum GRUB_EFI_NETWORK_INITIALIZED, }; +enum + { + GRUB_EFI_SIMPLE_NETWORK_RECEIVE_UNICAST = 0x01, + GRUB_EFI_SIMPLE_NETWORK_RECEIVE_MULTICAST = 0x02, + GRUB_EFI_SIMPLE_NETWORK_RECEIVE_BROADCAST = 0x04, + GRUB_EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS = 0x08, + GRUB_EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS_MULTICAST = 0x10, + }; + struct grub_efi_simple_network { grub_uint64_t revision; grub_efi_status_t (*start) (struct grub_efi_simple_network *this); - void (*stop) (void); + grub_efi_status_t (*stop) (struct grub_efi_simple_network *this); grub_efi_status_t (*initialize) (struct grub_efi_simple_network *this, grub_efi_uintn_t extra_rx, grub_efi_uintn_t extra_tx); void (*reset) (void); - void (*shutdown) (void); - void (*receive_filters) (void); + grub_efi_status_t (*shutdown) (struct grub_efi_simple_network *this); + grub_efi_status_t (*receive_filters) (struct grub_efi_simple_network *this, + grub_uint32_t enable, + grub_uint32_t disable, + grub_efi_boolean_t reset_mcast_filter, + grub_efi_uintn_t mcast_filter_count, + grub_efi_mac_address_t *mcast_filter); void (*station_address) (void); void (*statistics) (void); void (*mcastiptomac) (void); From 7af839a108857714b04cfc9384afa0b6d34c10c2 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Thu, 18 Jun 2015 20:09:47 +0300 Subject: [PATCH 435/722] tests: regression tests for "." and ".." directory entries --- tests/util/grub-fs-tester.in | 60 ++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/tests/util/grub-fs-tester.in b/tests/util/grub-fs-tester.in index e9e85c2a8..5107ca17a 100644 --- a/tests/util/grub-fs-tester.in +++ b/tests/util/grub-fs-tester.in @@ -1121,6 +1121,36 @@ for ((LOGSECSIZE=MINLOGSECSIZE;LOGSECSIZE<=MAXLOGSECSIZE;LOGSECSIZE=LOGSECSIZE + fi fi + case x"$fs" in + x"zfs"*) + LSROUT=$(run_grubfstest ls -- -la "($GRUBDEVICE)/grub fs@/.");; + *) + LSROUT=$(run_grubfstest ls -- -la "($GRUBDEVICE)/.");; + esac + if echo "$LSROUT" | grep -F " $BASEFILE" | grep "$BLOCKCNT" > /dev/null; then + : + else + echo DOT IN ROOTDIR FAIL + echo "$LSROUT" + TZ=UTC ls --time-style=+%Y%m%d%H%M%S.%N -l "$MNTPOINTRO" + exit 1 + fi + + case x"$fs" in + x"zfs"*) + LSROUT=$(run_grubfstest ls -- -la "($GRUBDEVICE)/grub fs@/..");; + *) + LSROUT=$(run_grubfstest ls -- -la "($GRUBDEVICE)/..");; + esac + if echo "$LSROUT" | grep -F " $BASEFILE" | grep "$BLOCKCNT" > /dev/null; then + : + else + echo DOTDOT IN ROOTDIR FAIL + echo "$LSROUT" + TZ=UTC ls --time-style=+%Y%m%d%H%M%S.%N -l "$MNTPOINTRO" + exit 1 + fi + case x"$fs" in x"zfs"*) LSROUT=$(run_grubfstest ls -- -l "($GRUBDEVICE)/grub fs@/////sdir");; @@ -1151,6 +1181,36 @@ for ((LOGSECSIZE=MINLOGSECSIZE;LOGSECSIZE<=MAXLOGSECSIZE;LOGSECSIZE=LOGSECSIZE + exit 1 fi + case x"$fs" in + x"zfs"*) + LSROUT=$(run_grubfstest ls -- -l "($GRUBDEVICE)/grub fs@/sdir/.");; + *) + LSROUT=$(run_grubfstest ls -- -l "($GRUBDEVICE)/sdir/.");; + esac + if echo "$LSROUT" | grep -F " 2.img" | grep $BLOCKCNT > /dev/null; then + : + else + echo DOT IN SUBDIR FAIL + echo "$LSROUT" + TZ=UTC ls --time-style=+%Y%m%d%H%M%S.%N -l "$MNTPOINTRO/$OSDIR/sdir" + exit 1 + fi + + case x"$fs" in + x"zfs"*) + LSROUT=$(run_grubfstest ls -- -l "($GRUBDEVICE)/grub fs@/sdir/../sdir");; + *) + LSROUT=$(run_grubfstest ls -- -l "($GRUBDEVICE)/sdir/../sdir");; + esac + if echo "$LSROUT" | grep -F " 2.img" | grep $BLOCKCNT > /dev/null; then + : + else + echo DOTDOT IN SUBDIR FAIL + echo "$LSROUT" + TZ=UTC ls --time-style=+%Y%m%d%H%M%S.%N -l "$MNTPOINTRO/$OSDIR/ssdir" + exit 1 + fi + LSOUT=`run_grubfstest ls -- -l "($GRUBDEVICE)"` if [ x"$NOFSLABEL" = xy ]; then : From 7bb7140df2b6fd5c1fee6c47488724bc256e957a Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Thu, 18 Jun 2015 20:09:47 +0300 Subject: [PATCH 436/722] fat: fix handling of "." and ".." directory entries Emulate dot and dotdot in root directory. For other directories do not add separator between name and extension for these two special entries. Closes: 45335 --- grub-core/fs/fat.c | 35 +++++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/grub-core/fs/fat.c b/grub-core/fs/fat.c index 71537ff44..827708c18 100644 --- a/grub-core/fs/fat.c +++ b/grub-core/fs/fat.c @@ -829,7 +829,9 @@ grub_fat_iterate_dir_next (grub_disk_t disk, struct grub_fat_data *data, i--; } - *filep++ = '.'; + /* XXX should we check that dir position is 0 or 1? */ + if (i > 2 || filep[0] != '.' || (i == 2 && filep[1] != '.')) + *filep++ = '.'; for (i = 8; i < 11 && ctxt->dir.name[i]; i++) *filep++ = grub_tolower (ctxt->dir.name[i]); @@ -871,9 +873,31 @@ grub_fat_find_dir (grub_disk_t disk, struct grub_fat_data *data, return 0; } - /* Extract a directory name. */ - while (*path == '/') - path++; + do + { + /* Extract a directory name. */ + while (*path == '/') + path++; + + /* Emulate special "." and ".." entries in root directory */ + if (data->file_cluster == data->root_cluster) + { + if (*path != '.') + break; + if (!path[1] || path[1] == '/') + { + path++; + continue; + } + if (path[1] == '.' && (!path[2] || path[2] == '/')) + { + path += 2; + continue; + } + } + break; + } + while (1); dirp = grub_strchr (path, '/'); if (dirp) @@ -935,6 +959,9 @@ grub_fat_find_dir (grub_disk_t disk, struct grub_fat_data *data, data->file_size = grub_le_to_cpu32 (ctxt.dir.file_size); data->file_cluster = ((grub_le_to_cpu16 (ctxt.dir.first_cluster_high) << 16) | grub_le_to_cpu16 (ctxt.dir.first_cluster_low)); + /* If directory points to root, starting cluster is 0 */ + if (!data->file_cluster) + data->file_cluster = data->root_cluster; #endif data->cur_cluster_num = ~0U; From 8067fe28edcedacf2507132baaab65dc3c4bb3d5 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Fri, 19 Jun 2015 17:35:17 +0300 Subject: [PATCH 437/722] syslinux_parse: make print_escaped actually stop before `to' The only current user is mboot.c32 which unfortunately is not covered by regression tests. --- grub-core/lib/syslinux_parse.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/lib/syslinux_parse.c b/grub-core/lib/syslinux_parse.c index 153260b54..ba71a4831 100644 --- a/grub-core/lib/syslinux_parse.c +++ b/grub-core/lib/syslinux_parse.c @@ -772,7 +772,7 @@ print_escaped (struct output_buffer *outbuf, if (err) return err; outbuf->buf[outbuf->ptr++] = '\''; - for (ptr = from; *ptr; ptr++) + for (ptr = from; *ptr && ptr < to; ptr++) { if (*ptr == '\'') { From 48cd9dc104082d4106ccd81fa3feec0d514ddd08 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Fri, 19 Jun 2015 18:38:25 +0300 Subject: [PATCH 438/722] syslinux_parse: assorted issues found by Coverity 1. Remove unneeded NULL check CID: 96607 2. Do not allocate storage for initrd, copy it directly from input buffer. Avoids memory leak in failure path. CID: 96604 3. Unchecked error return from print() CID: 96601, 73595 --- grub-core/lib/syslinux_parse.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/grub-core/lib/syslinux_parse.c b/grub-core/lib/syslinux_parse.c index ba71a4831..28ba3aef0 100644 --- a/grub-core/lib/syslinux_parse.c +++ b/grub-core/lib/syslinux_parse.c @@ -874,7 +874,9 @@ print_config (struct output_buffer *outbuf, print_string ("#"); print_file (outbuf, menu, filename, NULL); print_string (" "); - print (outbuf, newname, grub_strlen (newname)); + err = print (outbuf, newname, grub_strlen (newname)); + if (err) + return err; print_string (":\n"); for (menuptr = menu; menuptr; menuptr = menuptr->parent, depth++) @@ -944,8 +946,8 @@ write_entry (struct output_buffer *outbuf, { case KERNEL_LINUX: { - char *ptr; - char *initrd = NULL; + const char *ptr; + const char *initrd = NULL, *initrde= NULL; for (ptr = curentry->append; ptr && *ptr; ptr++) if ((ptr == curentry->append || grub_isspace (ptr[-1])) && grub_strncasecmp (ptr, "initrd=", sizeof ("initrd=") - 1) @@ -953,12 +955,8 @@ write_entry (struct output_buffer *outbuf, break; if (ptr && *ptr) { - char *ptr2; - initrd = grub_strdup(ptr + sizeof ("initrd=") - 1); - if (!initrd) - return grub_errno; - for (ptr2 = initrd; *ptr2 && !grub_isspace (*ptr2); ptr2++); - *ptr2 = 0; + initrd = ptr + sizeof ("initrd=") - 1; + for (initrde = initrd; *initrde && !grub_isspace (*initrde); initrde++); } print_string (" if test x$grub_platform = xpc; then " "linux_suffix=16; else linux_suffix= ; fi\n"); @@ -966,7 +964,11 @@ write_entry (struct output_buffer *outbuf, print_file (outbuf, menu, curentry->kernel_file, NULL); print_string (" "); if (curentry->append) - print (outbuf, curentry->append, grub_strlen (curentry->append)); + { + err = print (outbuf, curentry->append, grub_strlen (curentry->append)); + if (err) + return err; + } print_string ("\n"); if (initrd || curentry->initrds) { @@ -974,7 +976,7 @@ write_entry (struct output_buffer *outbuf, print_string (" initrd$linux_suffix "); if (initrd) { - print_file (outbuf, menu, initrd, NULL); + print_file (outbuf, menu, initrd, initrde); print_string (" "); } for (lst = curentry->initrds; lst; lst = lst->next) @@ -985,7 +987,6 @@ write_entry (struct output_buffer *outbuf, print_string ("\n"); } - grub_free (initrd); } break; case KERNEL_CHAINLOADER: @@ -1197,8 +1198,7 @@ write_entry (struct output_buffer *outbuf, ptr++; i386e = ptr; } - if (lme) - *lme = '\0'; + *lme = '\0'; if (paee) *paee = '\0'; if (i386e) From 10a6d2d91562231d3b21fb0c64adf88805a6fbec Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Fri, 19 Jun 2015 18:38:25 +0300 Subject: [PATCH 439/722] unix/relpath: memory leak Found by Coverity scan. CID: 96606 --- grub-core/osdep/unix/relpath.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/grub-core/osdep/unix/relpath.c b/grub-core/osdep/unix/relpath.c index 8fdc3a73a..f719950fd 100644 --- a/grub-core/osdep/unix/relpath.c +++ b/grub-core/osdep/unix/relpath.c @@ -51,7 +51,10 @@ grub_make_system_path_relative_to_its_root (const char *path) #ifdef __linux__ ret = grub_make_system_path_relative_to_its_root_os (p); if (ret) - return ret; + { + free (p); + return ret; + } #endif /* For ZFS sub-pool filesystems. */ From 5d0ee3d7a1a1381cb75111f2992d5d97b301894f Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Fri, 19 Jun 2015 18:38:25 +0300 Subject: [PATCH 440/722] unix/getroot: memory leak Found by Coverity scan. CID: 96605 --- grub-core/osdep/unix/getroot.c | 1 + 1 file changed, 1 insertion(+) diff --git a/grub-core/osdep/unix/getroot.c b/grub-core/osdep/unix/getroot.c index b98b2dfb0..14d483fb1 100644 --- a/grub-core/osdep/unix/getroot.c +++ b/grub-core/osdep/unix/getroot.c @@ -544,6 +544,7 @@ grub_guess_root_devices (const char *dir_in) if (stat (dir, &st) < 0) grub_util_error (_("cannot stat `%s': %s"), dir, strerror (errno)); + free (dir); dev = st.st_dev; From 15ba6a40be2ce73f89d781ffdfc0e19e43a4d80f Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Fri, 19 Jun 2015 18:38:25 +0300 Subject: [PATCH 441/722] zfs: memory leak Found by Coverity scan. CID: 96603 --- grub-core/fs/zfs/zfs.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/grub-core/fs/zfs/zfs.c b/grub-core/fs/zfs/zfs.c index f9ca0e75e..252cefdc6 100644 --- a/grub-core/fs/zfs/zfs.c +++ b/grub-core/fs/zfs/zfs.c @@ -3668,6 +3668,8 @@ zfs_mount (grub_device_t dev) data) != 0) { grub_error (GRUB_ERR_BAD_FS, "Unsupported features in pool"); + grub_free (osp); + zfs_unmount (data); return NULL; } From 4db569ca6a471aff9f2669d6e3a2fbb33f563425 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Fri, 19 Jun 2015 18:38:25 +0300 Subject: [PATCH 442/722] xfs: silence Coverity overflow warning inode size cannot really overflow integer, but Coverity does not know it. CID: 96602 --- grub-core/fs/xfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/fs/xfs.c b/grub-core/fs/xfs.c index f00e43e7d..724929155 100644 --- a/grub-core/fs/xfs.c +++ b/grub-core/fs/xfs.c @@ -361,7 +361,7 @@ grub_xfs_inode_offset (struct grub_xfs_data *data, static inline grub_size_t grub_xfs_inode_size(struct grub_xfs_data *data) { - return 1 << data->sblock.log2_inode; + return (grub_size_t)1 << data->sblock.log2_inode; } /* From fbdd37e7f947ae39208ce0b6f0dd17e958cd5b8e Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Fri, 19 Jun 2015 20:47:43 +0300 Subject: [PATCH 443/722] zfs: fix memory leak Found by: Coverity scan. CID: 73647 --- grub-core/fs/zfs/zfs.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/grub-core/fs/zfs/zfs.c b/grub-core/fs/zfs/zfs.c index 252cefdc6..c4ead29fb 100644 --- a/grub-core/fs/zfs/zfs.c +++ b/grub-core/fs/zfs/zfs.c @@ -2882,7 +2882,10 @@ dnode_get_path (struct subvolume *subvol, const char *path_in, dnode_end_t *dn, err = dmu_read (&(dnode_path->dn), block, &t, 0, data); if (err) - return err; + { + grub_free (sym_value); + return err; + } movesize = sym_sz - block * blksz; if (movesize > blksz) From 03f1f24e37d59e79b6c011cb51bab215cc7ec9cd Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Fri, 19 Jun 2015 20:47:43 +0300 Subject: [PATCH 444/722] grub-probe: restructure code to make static analysis easier Current code in probe() could not be verified to not contain memory leaks. Restructure code and ensure grub_device_close is always called at the end of loop. Calms down Coverity scan. CID: 73739 --- util/grub-probe.c | 86 ++++++++++++++--------------------------------- 1 file changed, 25 insertions(+), 61 deletions(-) diff --git a/util/grub-probe.c b/util/grub-probe.c index 6075cb3fc..4013229cb 100644 --- a/util/grub-probe.c +++ b/util/grub-probe.c @@ -485,23 +485,18 @@ probe (const char *path, char **device_names, char delim) printf (" "); else printf ("\n"); - - grub_device_close (dev); - continue; } - if ((print == PRINT_COMPATIBILITY_HINT || print == PRINT_BIOS_HINT + else if ((print == PRINT_COMPATIBILITY_HINT || print == PRINT_BIOS_HINT || print == PRINT_IEEE1275_HINT || print == PRINT_BAREMETAL_HINT || print == PRINT_EFI_HINT || print == PRINT_ARC_HINT) && dev->disk->dev->id != GRUB_DISK_DEVICE_HOSTDISK_ID) { grub_util_fprint_full_disk_name (stdout, dev->disk->name, dev); putchar (delim); - grub_device_close (dev); - continue; } - if (print == PRINT_COMPATIBILITY_HINT) + else if (print == PRINT_COMPATIBILITY_HINT) { const char *map; char *biosname; @@ -519,16 +514,14 @@ probe (const char *path, char **device_names, char delim) { grub_util_fprint_full_disk_name (stdout, biosname, dev); putchar (delim); + free (biosname); + /* Compatibility hint is one device only. */ + grub_device_close (dev); + break; } - free (biosname); - grub_device_close (dev); - /* Compatibility hint is one device only. */ - if (biosname) - break; - continue; } - if (print == PRINT_BIOS_HINT) + else if (print == PRINT_BIOS_HINT) { char *biosname; biosname = grub_util_guess_bios_drive (*curdev); @@ -536,12 +529,10 @@ probe (const char *path, char **device_names, char delim) { grub_util_fprint_full_disk_name (stdout, biosname, dev); putchar (delim); + free (biosname); } - free (biosname); - grub_device_close (dev); - continue; } - if (print == PRINT_IEEE1275_HINT) + else if (print == PRINT_IEEE1275_HINT) { const char *osdev = grub_util_biosdisk_get_osdev (dev->disk); char *ofpath = grub_util_devname_to_ofpath (osdev); @@ -565,11 +556,8 @@ probe (const char *path, char **device_names, char delim) free (ofpath); putchar (delim); } - - grub_device_close (dev); - continue; } - if (print == PRINT_EFI_HINT) + else if (print == PRINT_EFI_HINT) { char *biosname; const char *map; @@ -585,14 +573,11 @@ probe (const char *path, char **device_names, char delim) { grub_util_fprint_full_disk_name (stdout, biosname, dev); putchar (delim); + free (biosname); } - - free (biosname); - grub_device_close (dev); - continue; } - if (print == PRINT_BAREMETAL_HINT) + else if (print == PRINT_BAREMETAL_HINT) { char *biosname; const char *map; @@ -609,14 +594,11 @@ probe (const char *path, char **device_names, char delim) { grub_util_fprint_full_disk_name (stdout, biosname, dev); putchar (delim); + free (biosname); } - - free (biosname); - grub_device_close (dev); - continue; } - if (print == PRINT_ARC_HINT) + else if (print == PRINT_ARC_HINT) { const char *map; @@ -626,46 +608,28 @@ probe (const char *path, char **device_names, char delim) grub_util_fprint_full_disk_name (stdout, map, dev); putchar (delim); } - - /* FIXME */ - grub_device_close (dev); - continue; } - if (print == PRINT_ABSTRACTION) - { - probe_abstraction (dev->disk, delim); - grub_device_close (dev); - continue; - } + else if (print == PRINT_ABSTRACTION) + probe_abstraction (dev->disk, delim); - if (print == PRINT_CRYPTODISK_UUID) - { - probe_cryptodisk_uuid (dev->disk, delim); - grub_device_close (dev); - continue; - } + else if (print == PRINT_CRYPTODISK_UUID) + probe_cryptodisk_uuid (dev->disk, delim); - if (print == PRINT_PARTMAP) - { - /* Check if dev->disk itself is contained in a partmap. */ - probe_partmap (dev->disk, delim); - grub_device_close (dev); - continue; - } + else if (print == PRINT_PARTMAP) + /* Check if dev->disk itself is contained in a partmap. */ + probe_partmap (dev->disk, delim); - if (print == PRINT_MSDOS_PARTTYPE) + else if (print == PRINT_MSDOS_PARTTYPE) { if (dev->disk->partition && strcmp(dev->disk->partition->partmap->name, "msdos") == 0) printf ("%02x", dev->disk->partition->msdostype); putchar (delim); - grub_device_close (dev); - continue; } - if (print == PRINT_GPT_PARTTYPE) + else if (print == PRINT_GPT_PARTTYPE) { if (dev->disk->partition && strcmp (dev->disk->partition->partmap->name, "gpt") == 0) @@ -694,9 +658,9 @@ probe (const char *path, char **device_names, char delim) dev->disk->partition = p; } putchar (delim); - grub_device_close (dev); - continue; } + + grub_device_close (dev); } end: From 4358e0c81ec506ad9400f053b3f1f41597285833 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Fri, 19 Jun 2015 20:47:44 +0300 Subject: [PATCH 445/722] grub-probe: fix memory leak in probe (ofpath) Found by: Coverity scan. CID: 73772 --- util/grub-probe.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/util/grub-probe.c b/util/grub-probe.c index 4013229cb..b1f533626 100644 --- a/util/grub-probe.c +++ b/util/grub-probe.c @@ -429,7 +429,7 @@ probe (const char *path, char **device_names, char delim) if (print == PRINT_HINT_STR) { const char *osdev = grub_util_biosdisk_get_osdev (dev->disk); - const char *ofpath = osdev ? grub_util_devname_to_ofpath (osdev) : 0; + char *ofpath = osdev ? grub_util_devname_to_ofpath (osdev) : 0; char *biosname, *bare, *efi; const char *map; @@ -443,6 +443,7 @@ probe (const char *path, char **device_names, char delim) grub_util_fprint_full_disk_name (stdout, tmp, dev); printf ("' "); free (tmp); + free (ofpath); } biosname = grub_util_guess_bios_drive (*curdev); From 72ccf92c3937fda8f101b62e6ec8eb389aa8a915 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sat, 20 Jun 2015 09:23:43 +0300 Subject: [PATCH 446/722] NEWS: emu libusb support removed --- NEWS | 1 + 1 file changed, 1 insertion(+) diff --git a/NEWS b/NEWS index 6e33909de..4abd873de 100644 --- a/NEWS +++ b/NEWS @@ -149,6 +149,7 @@ New in 2.02: * Target is built without libgcc now. Necessary builtins are reimplemented directly. This removes requirement for target-specific runtime on build system. + * emu libusb support removed (was broken and unmaintained). * Revision control moved to git. From 0fb886cde97b8b65eceece62440194523530737a Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sat, 20 Jun 2015 23:38:17 +0300 Subject: [PATCH 447/722] search: fix use after free Found by: Coverity scan. CID: 96715 --- grub-core/commands/search.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/commands/search.c b/grub-core/commands/search.c index 16143a34c..440303a4e 100644 --- a/grub-core/commands/search.c +++ b/grub-core/commands/search.c @@ -210,10 +210,10 @@ try (struct search_ctx *ctx) /* Cache entry was outdated. Remove it. */ if (!ctx->count) { + *prev = cache_ent->next; grub_free (cache_ent->key); grub_free (cache_ent->value); grub_free (cache_ent); - *prev = cache_ent->next; } } From c069460259b0a3ed77c4035267250dc2b82f1cb4 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sat, 20 Jun 2015 23:38:17 +0300 Subject: [PATCH 448/722] efi/chainloader: fix use after free Found by: Coverity scan. CID: 96714 --- grub-core/loader/efi/chainloader.c | 1 + 1 file changed, 1 insertion(+) diff --git a/grub-core/loader/efi/chainloader.c b/grub-core/loader/efi/chainloader.c index 233237018..ec23cf4ed 100644 --- a/grub-core/loader/efi/chainloader.c +++ b/grub-core/loader/efi/chainloader.c @@ -351,6 +351,7 @@ grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)), loaded_image->device_handle = dev_handle; grub_file_close (file); + file = NULL; if (argc > 1) { From cd816bd23683de5fecc0aeafaed9e2b850b70dd8 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sat, 20 Jun 2015 23:38:18 +0300 Subject: [PATCH 449/722] disk/scsi: fix use after free Found by: Coverity scan. CID: 96713 --- grub-core/disk/scsi.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/grub-core/disk/scsi.c b/grub-core/disk/scsi.c index 92084d0f8..4c6923f8b 100644 --- a/grub-core/disk/scsi.c +++ b/grub-core/disk/scsi.c @@ -615,9 +615,10 @@ grub_scsi_open (const char *name, grub_disk_t disk) if (scsi->blocksize & (scsi->blocksize - 1) || !scsi->blocksize) { + grub_error (GRUB_ERR_IO, "invalid sector size %d", + scsi->blocksize); grub_free (scsi); - return grub_error (GRUB_ERR_IO, "invalid sector size %d", - scsi->blocksize); + return grub_errno; } for (disk->log_sector_size = 0; (1U << disk->log_sector_size) < scsi->blocksize; From e261fcf4c6c3381691875e02549c5723ca06da7d Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sat, 20 Jun 2015 23:38:18 +0300 Subject: [PATCH 450/722] xnu: fix use after free Found by: Coverity scan. CID: 96706 --- grub-core/loader/i386/xnu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/loader/i386/xnu.c b/grub-core/loader/i386/xnu.c index e0506a676..2fe1fdc1f 100644 --- a/grub-core/loader/i386/xnu.c +++ b/grub-core/loader/i386/xnu.c @@ -269,9 +269,9 @@ grub_xnu_devprop_add_property (struct grub_xnu_devprop_device_descriptor *dev, prop->data = grub_malloc (prop->length); if (!prop->data) { - grub_free (prop); grub_free (prop->name); grub_free (prop->name16); + grub_free (prop); return grub_errno; } grub_memcpy (prop->data, data, prop->length); From cf0b0306d818e1b79745420b2bdca449ba881130 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sat, 20 Jun 2015 23:38:18 +0300 Subject: [PATCH 451/722] usb: fix use after free Found by: Coverity scan. CID: 96704 --- grub-core/bus/usb/usbtrans.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/bus/usb/usbtrans.c b/grub-core/bus/usb/usbtrans.c index b614997f2..ee8680853 100644 --- a/grub-core/bus/usb/usbtrans.c +++ b/grub-core/bus/usb/usbtrans.c @@ -311,8 +311,8 @@ grub_usb_bulk_finish_readwrite (grub_usb_transfer_t transfer) transfer->size + 1); grub_free (transfer->transactions); - grub_free (transfer); grub_dma_free (transfer->data_chunk); + grub_free (transfer); } static grub_usb_err_t From a6f7d1abce848da5593ccc39492ef5c1df11a33c Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sat, 20 Jun 2015 23:38:18 +0300 Subject: [PATCH 452/722] reed_solomon: fix memory leak Found by: Coverity scan. CID: 96688 --- grub-core/lib/reed_solomon.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/grub-core/lib/reed_solomon.c b/grub-core/lib/reed_solomon.c index 7263cbc04..ee9fa7b4f 100644 --- a/grub-core/lib/reed_solomon.c +++ b/grub-core/lib/reed_solomon.c @@ -362,7 +362,7 @@ grub_reed_solomon_add_redundancy (void *buffer, grub_size_t data_size, /* Nothing to do. */ if (!rs) - return; + goto exit; init_powx (); @@ -388,6 +388,7 @@ grub_reed_solomon_add_redundancy (void *buffer, grub_size_t data_size, #ifndef TEST assert (grub_memcmp (tmp, buffer, data_size) == 0); #endif +exit: free (tmp); } #endif From 20211c0077a6eb9a0949fe9cb5778c7f69d28894 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sat, 20 Jun 2015 23:38:18 +0300 Subject: [PATCH 453/722] loader/bsd: fix memory leak Found by: Coverity scan. CID: 96686 --- grub-core/loader/i386/bsdXX.c | 40 +++++++++++++++++++++++++---------- 1 file changed, 29 insertions(+), 11 deletions(-) diff --git a/grub-core/loader/i386/bsdXX.c b/grub-core/loader/i386/bsdXX.c index 9e36cd4b6..cfb44c080 100644 --- a/grub-core/loader/i386/bsdXX.c +++ b/grub-core/loader/i386/bsdXX.c @@ -417,7 +417,10 @@ SUFFIX (grub_netbsd_load_elf_meta) (struct grub_relocator *relocator, err = read_headers (file, filename, &e, &shdr); if (err) - return err; + { + grub_free (shdr); + return grub_errno; + } for (s = (Elf_Shdr *) shdr; s < (Elf_Shdr *) (shdr + e.e_shnum * e.e_shentsize); @@ -426,7 +429,10 @@ SUFFIX (grub_netbsd_load_elf_meta) (struct grub_relocator *relocator, break; if (s >= (Elf_Shdr *) ((char *) shdr + e.e_shnum * e.e_shentsize)) - return GRUB_ERR_NONE; + { + grub_free (shdr); + return GRUB_ERR_NONE; + } symsize = s->sh_size; symsh = s; s = (Elf_Shdr *) (shdr + e.e_shentsize * s->sh_link); @@ -443,7 +449,7 @@ SUFFIX (grub_netbsd_load_elf_meta) (struct grub_relocator *relocator, err = grub_relocator_alloc_chunk_addr (relocator, &ch, symtarget, chunk_size); if (err) - return err; + goto out; sym_chunk = get_virtual_current_address (ch); } @@ -482,29 +488,41 @@ SUFFIX (grub_netbsd_load_elf_meta) (struct grub_relocator *relocator, } if (grub_file_seek (file, symsh->sh_offset) == (grub_off_t) -1) - return grub_errno; + { + err = grub_errno; + goto out; + } if (grub_file_read (file, curload, symsize) != (grub_ssize_t) symsize) { if (! grub_errno) - return grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"), - filename); - return grub_errno; + err = grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"), + filename); + else + err = grub_errno; + goto out; } curload += ALIGN_UP (symsize, sizeof (grub_freebsd_addr_t)); if (grub_file_seek (file, strsh->sh_offset) == (grub_off_t) -1) - return grub_errno; + { + err = grub_errno; + goto out; + } if (grub_file_read (file, curload, strsize) != (grub_ssize_t) strsize) { if (! grub_errno) - return grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"), - filename); - return grub_errno; + err = grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"), + filename); + else + err = grub_errno; + goto out; } err = grub_bsd_add_meta (NETBSD_BTINFO_SYMTAB, &symtab, sizeof (symtab)); +out: + grub_free (shdr); if (err) return err; From 2a3ebf94283171f919fee5a0e35e497d800816fb Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sat, 20 Jun 2015 23:38:18 +0300 Subject: [PATCH 454/722] normal: fix memory leak Found by: Coverity scan. CID: 96685 --- grub-core/normal/cmdline.c | 1 + 1 file changed, 1 insertion(+) diff --git a/grub-core/normal/cmdline.c b/grub-core/normal/cmdline.c index 204d15a4b..a36180d75 100644 --- a/grub-core/normal/cmdline.c +++ b/grub-core/normal/cmdline.c @@ -389,6 +389,7 @@ grub_cmdline_get (const char *prompt_translated) if (!unicode_msg) { grub_free (buf); + grub_free (cl_terms); return 0; } msg_len = grub_utf8_to_ucs4 (unicode_msg, msg_len - 1, From eb33e61b31902a5493468895aaf83fa0b4f5f59d Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sat, 20 Jun 2015 23:38:18 +0300 Subject: [PATCH 455/722] multiboot: fix memory leak Found by: Coverity scan. CID: 96684 --- grub-core/loader/multiboot_elfxx.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/grub-core/loader/multiboot_elfxx.c b/grub-core/loader/multiboot_elfxx.c index 9dc21a1ba..6a220bdc1 100644 --- a/grub-core/loader/multiboot_elfxx.c +++ b/grub-core/loader/multiboot_elfxx.c @@ -169,7 +169,10 @@ CONCAT(grub_multiboot_load_elf, XX) (grub_file_t file, const char *filename, voi return grub_errno; if (grub_file_seek (file, ehdr->e_shoff) == (grub_off_t) -1) - return grub_errno; + { + grub_free (shdr); + return grub_errno; + } if (grub_file_read (file, shdr, ehdr->e_shnum * ehdr->e_shentsize) != (grub_ssize_t) ehdr->e_shnum * ehdr->e_shentsize) From 4a857e63c189a756e7c6099306faa41cf173ad28 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sat, 20 Jun 2015 23:38:18 +0300 Subject: [PATCH 456/722] loader/bsd: free memory leaks Found by: Coverity scan. CID: 96682 --- grub-core/loader/i386/bsdXX.c | 43 +++++++++++++++++++++++------------ 1 file changed, 29 insertions(+), 14 deletions(-) diff --git a/grub-core/loader/i386/bsdXX.c b/grub-core/loader/i386/bsdXX.c index cfb44c080..53ae37c1e 100644 --- a/grub-core/loader/i386/bsdXX.c +++ b/grub-core/loader/i386/bsdXX.c @@ -292,13 +292,13 @@ SUFFIX (grub_freebsd_load_elf_meta) (struct grub_relocator *relocator, err = read_headers (file, filename, &e, &shdr); if (err) - return err; + goto out; err = grub_bsd_add_meta (FREEBSD_MODINFO_METADATA | FREEBSD_MODINFOMD_ELFHDR, &e, sizeof (e)); if (err) - return err; + goto out; for (s = (Elf_Shdr *) shdr; s < (Elf_Shdr *) (shdr + e.e_shnum * e.e_shentsize); @@ -307,7 +307,10 @@ SUFFIX (grub_freebsd_load_elf_meta) (struct grub_relocator *relocator, break; if (s >= (Elf_Shdr *) ((char *) shdr + e.e_shnum * e.e_shentsize)) - return grub_error (GRUB_ERR_BAD_OS, N_("no symbol table")); + { + err = grub_error (GRUB_ERR_BAD_OS, N_("no symbol table")); + goto out; + } symoff = s->sh_offset; symsize = s->sh_size; symentsize = s->sh_entsize; @@ -325,7 +328,7 @@ SUFFIX (grub_freebsd_load_elf_meta) (struct grub_relocator *relocator, err = grub_relocator_alloc_chunk_addr (relocator, &ch, symtarget, chunk_size); if (err) - return err; + goto out; sym_chunk = get_virtual_current_address (ch); } @@ -337,28 +340,38 @@ SUFFIX (grub_freebsd_load_elf_meta) (struct grub_relocator *relocator, curload += sizeof (grub_freebsd_addr_t); if (grub_file_seek (file, symoff) == (grub_off_t) -1) - return grub_errno; + { + err = grub_errno; + goto out; + } sym = (Elf_Sym *) curload; if (grub_file_read (file, curload, symsize) != (grub_ssize_t) symsize) { if (! grub_errno) - return grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"), - filename); - return grub_errno; + err = grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"), + filename); + else + err = grub_errno; + goto out; } curload += symsize; *((grub_freebsd_addr_t *) curload) = strsize; curload += sizeof (grub_freebsd_addr_t); if (grub_file_seek (file, stroff) == (grub_off_t) -1) - return grub_errno; + { + err = grub_errno; + goto out; + } str = (char *) curload; if (grub_file_read (file, curload, strsize) != (grub_ssize_t) strsize) { if (! grub_errno) - return grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"), - filename); - return grub_errno; + err = grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"), + filename); + else + err = grub_errno; + goto out; } for (i = 0; @@ -378,18 +391,20 @@ SUFFIX (grub_freebsd_load_elf_meta) (struct grub_relocator *relocator, FREEBSD_MODINFOMD_DYNAMIC, &dynamic, sizeof (dynamic)); if (err) - return err; + goto out; } err = grub_bsd_add_meta (FREEBSD_MODINFO_METADATA | FREEBSD_MODINFOMD_SSYM, &symstart, sizeof (symstart)); if (err) - return err; + goto out; err = grub_bsd_add_meta (FREEBSD_MODINFO_METADATA | FREEBSD_MODINFOMD_ESYM, &symend, sizeof (symend)); +out: + grub_free (shdr); if (err) return err; From 47490ada3ddc24a323a654cef7828f604d9b871a Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sat, 20 Jun 2015 23:38:19 +0300 Subject: [PATCH 457/722] ohci: fix memory leak Found by: Coverity scan. CID: 96679 --- grub-core/bus/usb/ohci.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/grub-core/bus/usb/ohci.c b/grub-core/bus/usb/ohci.c index d27bfe7fb..f0be533d4 100644 --- a/grub-core/bus/usb/ohci.c +++ b/grub-core/bus/usb/ohci.c @@ -750,7 +750,10 @@ grub_ohci_setup_transfer (grub_usb_controller_t dev, { cdata->td_head_virt = grub_ohci_alloc_td (o); if (!cdata->td_head_virt) - return GRUB_USB_ERR_INTERNAL; /* We don't need de-allocate ED */ + { + grub_free (cdata); + return GRUB_USB_ERR_INTERNAL; /* We don't need de-allocate ED */ + } /* We can set td_head only when ED is not active, i.e. * when it is newly allocated. */ cdata->ed_virt->td_head From e7e05cae8d4bd48fb3221297fe3b388aeab47f37 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sat, 20 Jun 2015 23:38:19 +0300 Subject: [PATCH 458/722] efi/serial: fix memory leak Found by: Coverity scan. CID: 96678 --- grub-core/term/efi/serial.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/grub-core/term/efi/serial.c b/grub-core/term/efi/serial.c index c0911ad7b..4c94723c5 100644 --- a/grub-core/term/efi/serial.c +++ b/grub-core/term/efi/serial.c @@ -173,7 +173,10 @@ grub_efiserial_init (void) port->name = grub_malloc (sizeof ("efiXXXXXXXXXXXXXXXXXXXX")); if (!port->name) - return; + { + grub_free (port); + return; + } grub_snprintf (port->name, sizeof ("efiXXXXXXXXXXXXXXXXXXXX"), "efi%d", num_serial++); From 152695d0faefe763b2198048e6f3e905a8c0c786 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sat, 20 Jun 2015 23:38:19 +0300 Subject: [PATCH 459/722] normal: fix memory leak Found by: Coverity scan. CID: 96677 --- grub-core/normal/context.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/grub-core/normal/context.c b/grub-core/normal/context.c index 7e0a696f3..ee53d4a68 100644 --- a/grub-core/normal/context.c +++ b/grub-core/normal/context.c @@ -64,7 +64,10 @@ grub_env_new_context (int export_all) return grub_errno; menu = grub_zalloc (sizeof (*menu)); if (! menu) - return grub_errno; + { + grub_free (context); + return grub_errno; + } context->prev = grub_current_context; grub_current_context = context; From 2f01f08103aac50878c8ed704df5bfddf7443c5a Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sat, 20 Jun 2015 23:38:19 +0300 Subject: [PATCH 460/722] password_pbkdf2: fix memory leak Found by: Coverity scan. CID: 96676 --- grub-core/commands/password_pbkdf2.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/grub-core/commands/password_pbkdf2.c b/grub-core/commands/password_pbkdf2.c index 0dd1aef3d..c6a77c8c5 100644 --- a/grub-core/commands/password_pbkdf2.c +++ b/grub-core/commands/password_pbkdf2.c @@ -104,7 +104,10 @@ grub_cmd_password (grub_command_t cmd __attribute__ ((unused)), pass->c = grub_strtoul (ptr, &ptr, 0); if (grub_errno) - return grub_errno; + { + grub_free (pass); + return grub_errno; + } if (*ptr != '.') { grub_free (pass); From 5af859bb77c80583d4412a44929b33bb344b05f3 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sat, 20 Jun 2015 23:38:19 +0300 Subject: [PATCH 461/722] search_wrap: fix memory leak Found by: Coverity scan. CID: 96675 --- grub-core/commands/search_wrap.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/grub-core/commands/search_wrap.c b/grub-core/commands/search_wrap.c index 3f75fecdf..d7fd26b94 100644 --- a/grub-core/commands/search_wrap.c +++ b/grub-core/commands/search_wrap.c @@ -175,7 +175,10 @@ grub_cmd_search (grub_extcmd_context_t ctxt, int argc, char **args) var = "root"; } else - return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("one argument expected")); + { + grub_error (GRUB_ERR_BAD_ARGUMENT, N_("one argument expected")); + goto out; + } if (state[SEARCH_LABEL].set) grub_search_label (id, var, state[SEARCH_NO_FLOPPY].set, @@ -187,8 +190,10 @@ grub_cmd_search (grub_extcmd_context_t ctxt, int argc, char **args) grub_search_fs_file (id, var, state[SEARCH_NO_FLOPPY].set, hints, nhints); else - return grub_error (GRUB_ERR_INVALID_COMMAND, "unspecified search type"); + grub_error (GRUB_ERR_INVALID_COMMAND, "unspecified search type"); +out: + grub_free (hints); return grub_errno; } From 867c9b7bec3446daa6a14a553c404ea26548242b Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sat, 20 Jun 2015 23:38:19 +0300 Subject: [PATCH 462/722] loader/bsd: free memory leaks Found by: Coverity scan. CID: 96671, 96658, 96653 --- grub-core/loader/i386/bsdXX.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/grub-core/loader/i386/bsdXX.c b/grub-core/loader/i386/bsdXX.c index 53ae37c1e..051ff06b5 100644 --- a/grub-core/loader/i386/bsdXX.c +++ b/grub-core/loader/i386/bsdXX.c @@ -563,7 +563,10 @@ SUFFIX(grub_openbsd_find_ramdisk) (grub_file_t file, err = read_headers (file, filename, &e, &shdr); if (err) - return err; + { + grub_free (shdr); + return err; + } for (s = (Elf_Shdr *) shdr; s < (Elf_Shdr *) (shdr + e.e_shnum * e.e_shentsize); @@ -616,7 +619,11 @@ SUFFIX(grub_openbsd_find_ramdisk) (grub_file_t file, } if (grub_file_seek (file, stroff) == (grub_off_t) -1) - return grub_errno; + { + grub_free (syms); + grub_free (strs); + return grub_errno; + } if (grub_file_read (file, strs, strsize) != (grub_ssize_t) strsize) { grub_free (syms); From 806bb7999dab556ffa12db976480a129a43e8a68 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Fri, 26 Jun 2015 09:25:30 +0300 Subject: [PATCH 463/722] loader/bsd: fix memory leak Found by: Coverity scan. CID: 96662, 96665 --- grub-core/loader/i386/bsdXX.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/grub-core/loader/i386/bsdXX.c b/grub-core/loader/i386/bsdXX.c index 051ff06b5..9f57cfa82 100644 --- a/grub-core/loader/i386/bsdXX.c +++ b/grub-core/loader/i386/bsdXX.c @@ -84,11 +84,11 @@ SUFFIX (grub_freebsd_load_elfmodule_obj) (struct grub_relocator *relocator, grub_size_t chunk_size = 0; void *chunk_src; + curload = module = ALIGN_PAGE (*kern_end); + err = read_headers (file, argv[0], &e, &shdr); if (err) - return err; - - curload = module = ALIGN_PAGE (*kern_end); + goto out; for (s = (Elf_Shdr *) shdr; s < (Elf_Shdr *) ((char *) shdr + e.e_shnum * e.e_shentsize); @@ -109,7 +109,7 @@ SUFFIX (grub_freebsd_load_elfmodule_obj) (struct grub_relocator *relocator, err = grub_relocator_alloc_chunk_addr (relocator, &ch, module, chunk_size); if (err) - return err; + goto out; chunk_src = get_virtual_current_address (ch); } @@ -135,7 +135,7 @@ SUFFIX (grub_freebsd_load_elfmodule_obj) (struct grub_relocator *relocator, err = load (file, argv[0], (grub_uint8_t *) chunk_src + curload - *kern_end, s->sh_offset, s->sh_size); if (err) - return err; + goto out; break; case SHT_NOBITS: grub_memset ((grub_uint8_t *) chunk_src + curload - *kern_end, 0, @@ -159,6 +159,8 @@ SUFFIX (grub_freebsd_load_elfmodule_obj) (struct grub_relocator *relocator, | FREEBSD_MODINFOMD_SHDR, shdr, e.e_shnum * e.e_shentsize); +out: + grub_free (shdr); return err; } @@ -177,11 +179,11 @@ SUFFIX (grub_freebsd_load_elfmodule) (struct grub_relocator *relocator, grub_size_t chunk_size = 0; void *chunk_src; + curload = module = ALIGN_PAGE (*kern_end); + err = read_headers (file, argv[0], &e, &shdr); if (err) - return err; - - curload = module = ALIGN_PAGE (*kern_end); + goto out; for (s = (Elf_Shdr *) shdr; s < (Elf_Shdr *) ((char *) shdr + e.e_shnum * e.e_shentsize); @@ -207,7 +209,7 @@ SUFFIX (grub_freebsd_load_elfmodule) (struct grub_relocator *relocator, err = grub_relocator_alloc_chunk_addr (relocator, &ch, module, chunk_size); if (err) - return err; + goto out; chunk_src = get_virtual_current_address (ch); } @@ -235,7 +237,7 @@ SUFFIX (grub_freebsd_load_elfmodule) (struct grub_relocator *relocator, + s->sh_addr - *kern_end, s->sh_offset, s->sh_size); if (err) - return err; + goto out; break; case SHT_NOBITS: grub_memset ((grub_uint8_t *) chunk_src + module @@ -265,6 +267,10 @@ SUFFIX (grub_freebsd_load_elfmodule) (struct grub_relocator *relocator, grub_freebsd_add_meta_module (argv[0], FREEBSD_MODTYPE_ELF_MODULE, argc - 1, argv + 1, module, curload - module); +out: + grub_free (shdr); + if (err) + return err; return SUFFIX (grub_freebsd_load_elf_meta) (relocator, file, argv[0], kern_end); } From c058e85615fde15d9593ff0377cf3de94a906fac Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Fri, 26 Jun 2015 09:25:30 +0300 Subject: [PATCH 464/722] chainloader: fix resoource leak Found by: Coverity scan. CID: 96651 --- grub-core/loader/efi/chainloader.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/grub-core/loader/efi/chainloader.c b/grub-core/loader/efi/chainloader.c index ec23cf4ed..522a716e3 100644 --- a/grub-core/loader/efi/chainloader.c +++ b/grub-core/loader/efi/chainloader.c @@ -350,9 +350,6 @@ grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)), } loaded_image->device_handle = dev_handle; - grub_file_close (file); - file = NULL; - if (argc > 1) { int i, len; @@ -382,6 +379,9 @@ grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)), loaded_image->load_options_size = len; } + grub_file_close (file); + grub_device_close (dev); + grub_loader_set (grub_chainloader_boot, grub_chainloader_unload, 0); return 0; From 7a210304ebfd6d704b4fc08fe496a0c417441879 Mon Sep 17 00:00:00 2001 From: Michael Chang Date: Mon, 22 Jun 2015 16:45:27 +0800 Subject: [PATCH 465/722] Fix missing byte order conversion in get_btrfs_fs_prefix function Since btrfs on-disk format uses little-endian, the searched item types (ROOT_REF, INODE_REF) need converting the byte order in order to function properly on big-endian systems. --- grub-core/osdep/linux/getroot.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/grub-core/osdep/linux/getroot.c b/grub-core/osdep/linux/getroot.c index a2e360f52..3978c7114 100644 --- a/grub-core/osdep/linux/getroot.c +++ b/grub-core/osdep/linux/getroot.c @@ -316,9 +316,9 @@ get_btrfs_fs_prefix (const char *mount_path) tree_id = sargs.buf[2]; br = (struct grub_btrfs_root_backref *) (sargs.buf + 4); - inode_id = br->inode_id; + inode_id = grub_le_to_cpu64 (br->inode_id); name = br->name; - namelen = br->n; + namelen = grub_le_to_cpu16 (br->n); } else { @@ -345,7 +345,7 @@ get_btrfs_fs_prefix (const char *mount_path) ir = (struct grub_btrfs_inode_ref *) (sargs.buf + 4); name = ir->name; - namelen = ir->n; + namelen = grub_le_to_cpu16 (ir->n); } old = ret; ret = xmalloc (namelen + (old ? strlen (old) : 0) + 2); From 0d7c7f751dc5a8338497bef8b38f78153c4f0464 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sun, 5 Jul 2015 08:21:38 +0300 Subject: [PATCH 466/722] use TARGET_LDFLAGS in grub_PROG_OBJCOPY_ABSOLUTE That's what Makefile will use and it is required if unusual flags must be passed to linker (e.g. to build ppc32 code on ppc64le with clang). --- acinclude.m4 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/acinclude.m4 b/acinclude.m4 index 609c4f2f6..526f97a3a 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -93,7 +93,7 @@ else fi grub_cv_prog_objcopy_absolute=yes for link_addr in 0x2000 0x8000 0x7C00; do - if AC_TRY_COMMAND([${CC-cc} ${CFLAGS} -nostdlib ${TARGET_IMG_LDFLAGS_AC} ${TARGET_IMG_BASE_LDOPT},$link_addr conftest.o -o conftest.exec]); then : + if AC_TRY_COMMAND([${CC-cc} ${TARGET_CFLAGS} ${TARGET_LDFLAGS} -nostdlib ${TARGET_IMG_LDFLAGS_AC} ${TARGET_IMG_BASE_LDOPT},$link_addr conftest.o -o conftest.exec]); then : else AC_MSG_ERROR([${CC-cc} cannot link at address $link_addr]) fi From 54e7dbbcb93b913514e3e9f8f29e6372ea34ff32 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Thu, 16 Jul 2015 10:59:33 +0200 Subject: [PATCH 467/722] grub_ext2_read_block: Fix return type on error. --- grub-core/fs/ext2.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/grub-core/fs/ext2.c b/grub-core/fs/ext2.c index 5199cb0c1..cdce63bcc 100644 --- a/grub-core/fs/ext2.c +++ b/grub-core/fs/ext2.c @@ -538,8 +538,9 @@ grub_ext2_read_block (grub_fshelp_node_t node, grub_disk_addr_t fileblock) shift = 2; goto indirect; } - return grub_error (GRUB_ERR_BAD_FS, - "ext2fs doesn't support quadruple indirect blocks"); + grub_error (GRUB_ERR_BAD_FS, + "ext2fs doesn't support quadruple indirect blocks"); + return -1; indirect: do { @@ -554,7 +555,7 @@ indirect: & ((1 << log_perblock) - 1)) * sizeof (indir), sizeof (indir), &indir)) - return grub_errno; + return -1; } while (shift--); return grub_le_to_cpu32 (indir); From ff3c2007ef22b4385ff189b60aaf1f9de3dff24b Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Thu, 16 Jul 2015 12:46:02 +0200 Subject: [PATCH 468/722] XFS: Fix wrong alignment treatment. --- grub-core/fs/xfs.c | 87 ++++++++++++++++++++++++++++------------------ 1 file changed, 53 insertions(+), 34 deletions(-) diff --git a/grub-core/fs/xfs.c b/grub-core/fs/xfs.c index 724929155..46de6aff3 100644 --- a/grub-core/fs/xfs.c +++ b/grub-core/fs/xfs.c @@ -136,7 +136,13 @@ struct grub_xfs_dir2_entry grub_uint8_t len; } GRUB_PACKED; -typedef grub_uint32_t grub_xfs_extent[4]; +struct grub_xfs_extent +{ + /* This should be a bitfield but bietfields are unportable, so just have + a raw array and functions extracting useful info from it. + */ + grub_uint32_t raw[4]; +} GRUB_PACKED; struct grub_xfs_btree_node { @@ -147,20 +153,20 @@ struct grub_xfs_btree_node grub_uint64_t right; /* In V5 here follow crc, uuid, etc. */ /* Then follow keys and block pointers */ -} GRUB_PACKED; +} GRUB_PACKED; struct grub_xfs_btree_root { grub_uint16_t level; grub_uint16_t numrecs; grub_uint64_t keys[1]; -} GRUB_PACKED; +} GRUB_PACKED; struct grub_xfs_time { grub_uint32_t sec; grub_uint32_t nanosec; -} GRUB_PACKED; +} GRUB_PACKED; struct grub_xfs_inode { @@ -313,25 +319,25 @@ GRUB_XFS_FSB_TO_BLOCK (struct grub_xfs_data *data, grub_disk_addr_t fsb) } static inline grub_uint64_t -GRUB_XFS_EXTENT_OFFSET (grub_xfs_extent *exts, int ex) +GRUB_XFS_EXTENT_OFFSET (struct grub_xfs_extent *exts, int ex) { - return ((grub_be_to_cpu32 (exts[ex][0]) & ~(1 << 31)) << 23 - | grub_be_to_cpu32 (exts[ex][1]) >> 9); + return ((grub_be_to_cpu32 (exts[ex].raw[0]) & ~(1 << 31)) << 23 + | grub_be_to_cpu32 (exts[ex].raw[1]) >> 9); } static inline grub_uint64_t -GRUB_XFS_EXTENT_BLOCK (grub_xfs_extent *exts, int ex) +GRUB_XFS_EXTENT_BLOCK (struct grub_xfs_extent *exts, int ex) { - return ((grub_uint64_t) (grub_be_to_cpu32 (exts[ex][1]) + return ((grub_uint64_t) (grub_be_to_cpu32 (exts[ex].raw[1]) & (0x1ff)) << 43 - | (grub_uint64_t) grub_be_to_cpu32 (exts[ex][2]) << 11 - | grub_be_to_cpu32 (exts[ex][3]) >> 21); + | (grub_uint64_t) grub_be_to_cpu32 (exts[ex].raw[2]) << 11 + | grub_be_to_cpu32 (exts[ex].raw[3]) >> 21); } static inline grub_uint64_t -GRUB_XFS_EXTENT_SIZE (grub_xfs_extent *exts, int ex) +GRUB_XFS_EXTENT_SIZE (struct grub_xfs_extent *exts, int ex) { - return (grub_be_to_cpu32 (exts[ex][3]) & ((1 << 21) - 1)); + return (grub_be_to_cpu32 (exts[ex].raw[3]) & ((1 << 21) - 1)); } @@ -377,7 +383,10 @@ grub_xfs_fshelp_size(struct grub_xfs_data *data) + grub_xfs_inode_size(data); } -static void * +/* This should return void * but XFS code is error-prone with alignment, so + return char to retain cast-align. + */ +static char * grub_xfs_inode_data(struct grub_xfs_inode *inode) { if (inode->version <= 2) @@ -388,20 +397,20 @@ grub_xfs_inode_data(struct grub_xfs_inode *inode) static struct grub_xfs_dir_entry * grub_xfs_inline_de(struct grub_xfs_dir_header *head) { - /* - * With small inode numbers the header is 4 bytes smaller because of - * smaller parent pointer - */ - return (void *)(((char *)head) + sizeof(struct grub_xfs_dir_header) - - (head->largeino ? 0 : sizeof(grub_uint32_t))); + /* + With small inode numbers the header is 4 bytes smaller because of + smaller parent pointer + */ + return (struct grub_xfs_dir_entry *) + (((char *) head) + sizeof(struct grub_xfs_dir_header) - + (head->largeino ? 0 : sizeof(grub_uint32_t))); } static grub_uint8_t * grub_xfs_inline_de_inopos(struct grub_xfs_data *data, struct grub_xfs_dir_entry *de) { - return ((grub_uint8_t *)(de + 1)) + de->len - 1 + - (data->hasftype ? 1 : 0); + return ((grub_uint8_t *)(de + 1)) + de->len - 1 + (data->hasftype ? 1 : 0); } static struct grub_xfs_dir_entry * @@ -445,14 +454,17 @@ grub_xfs_next_de(struct grub_xfs_data *data, struct grub_xfs_dir2_entry *de) return (struct grub_xfs_dir2_entry *)(((char *)de) + ALIGN_UP(size, 8)); } -static grub_uint64_t * +/* This should return void * but XFS code is error-prone with alignment, so + return char to retain cast-align. + */ +static char * grub_xfs_btree_keys(struct grub_xfs_data *data, struct grub_xfs_btree_node *leaf) { - grub_uint64_t *keys = (grub_uint64_t *)(leaf + 1); + char *keys = (char *)(leaf + 1); if (data->hascrc) - keys += 6; /* skip crc, uuid, ... */ + keys += 48; /* skip crc, uuid, ... */ return keys; } @@ -476,28 +488,34 @@ grub_xfs_read_inode (struct grub_xfs_data *data, grub_uint64_t ino, return 0; } +static grub_uint64_t +get_fsb (const void *keys, int idx) +{ + const char *p = (const char *) keys + sizeof(grub_uint64_t) * idx; + return grub_be_to_cpu64 (grub_get_unaligned64 (p)); +} static grub_disk_addr_t grub_xfs_read_block (grub_fshelp_node_t node, grub_disk_addr_t fileblock) { struct grub_xfs_btree_node *leaf = 0; int ex, nrec; - grub_xfs_extent *exts; + struct grub_xfs_extent *exts; grub_uint64_t ret = 0; if (node->inode.format == XFS_INODE_FORMAT_BTREE) { struct grub_xfs_btree_root *root; - const grub_uint64_t *keys; + const char *keys; int recoffset; leaf = grub_malloc (node->data->bsize); if (leaf == 0) return 0; - root = grub_xfs_inode_data(&node->inode); + root = (struct grub_xfs_btree_root *) grub_xfs_inode_data(&node->inode); nrec = grub_be_to_cpu16 (root->numrecs); - keys = &root->keys[0]; + keys = (char *) &root->keys[0]; if (node->inode.fork_offset) recoffset = (node->inode.fork_offset - 1) / 2; else @@ -510,7 +528,7 @@ grub_xfs_read_block (grub_fshelp_node_t node, grub_disk_addr_t fileblock) for (i = 0; i < nrec; i++) { - if (fileblock < grub_be_to_cpu64 (keys[i])) + if (fileblock < get_fsb(keys, i)) break; } @@ -520,8 +538,9 @@ grub_xfs_read_block (grub_fshelp_node_t node, grub_disk_addr_t fileblock) grub_free (leaf); return 0; } + if (grub_disk_read (node->data->disk, - GRUB_XFS_FSB_TO_BLOCK (node->data, grub_be_to_cpu64 (keys[i - 1 + recoffset])) << (node->data->sblock.log2_bsize - GRUB_DISK_SECTOR_BITS), + GRUB_XFS_FSB_TO_BLOCK (node->data, get_fsb (keys, i - 1 + recoffset)) << (node->data->sblock.log2_bsize - GRUB_DISK_SECTOR_BITS), 0, node->data->bsize, leaf)) return 0; @@ -542,12 +561,12 @@ grub_xfs_read_block (grub_fshelp_node_t node, grub_disk_addr_t fileblock) / (2 * sizeof (grub_uint64_t))); } while (leaf->level); - exts = (grub_xfs_extent *) keys; + exts = (struct grub_xfs_extent *) keys; } else if (node->inode.format == XFS_INODE_FORMAT_EXT) { nrec = grub_be_to_cpu32 (node->inode.nextents); - exts = grub_xfs_inode_data(&node->inode); + exts = (struct grub_xfs_extent *) grub_xfs_inode_data(&node->inode); } else { @@ -700,7 +719,7 @@ grub_xfs_iterate_dir (grub_fshelp_node_t dir, { case XFS_INODE_FORMAT_INO: { - struct grub_xfs_dir_header *head = grub_xfs_inode_data(&diro->inode); + struct grub_xfs_dir_header *head = (struct grub_xfs_dir_header *) grub_xfs_inode_data(&diro->inode); struct grub_xfs_dir_entry *de = grub_xfs_inline_de(head); int smallino = !head->largeino; int i; From 61c778f6402d540a2da7b2d034de7a920ca38c1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bernhard=20=C3=9Cbelacker?= Date: Mon, 20 Jul 2015 14:06:45 +0200 Subject: [PATCH 469/722] loader/linux: Make trailer initrd entry aligned again. Regression from commit: loader/linux: do not pad initrd with zeroes at the end a8c473288d3f0a5e17a903a5121dea1a695dda3b Wimboot fails since the change above because it expects the "trailer" initrd element on an aligned address. This issue shows only when newc_name is used and the last initrd entry has a not aligned size. --- grub-core/loader/linux.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/grub-core/loader/linux.c b/grub-core/loader/linux.c index d2cd591f6..be6fa0f4d 100644 --- a/grub-core/loader/linux.c +++ b/grub-core/loader/linux.c @@ -213,6 +213,7 @@ grub_initrd_init (int argc, char *argv[], if (newc) { + initrd_ctx->size = ALIGN_UP (initrd_ctx->size, 4); initrd_ctx->size += ALIGN_UP (sizeof (struct newc_head) + sizeof ("TRAILER!!!") - 1, 4); free_dir (root); @@ -290,7 +291,11 @@ grub_initrd_load (struct grub_linux_initrd_context *initrd_ctx, ptr += cursize; } if (newc) - ptr = make_header (ptr, "TRAILER!!!", sizeof ("TRAILER!!!") - 1, 0, 0); + { + grub_memset (ptr, 0, ALIGN_UP_OVERHEAD (cursize, 4)); + ptr += ALIGN_UP_OVERHEAD (cursize, 4); + ptr = make_header (ptr, "TRAILER!!!", sizeof ("TRAILER!!!") - 1, 0, 0); + } free_dir (root); root = 0; return GRUB_ERR_NONE; From 5c46165a7cefe8b5319bdc10839a3bc5dee40826 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Wed, 22 Jul 2015 01:54:59 +0200 Subject: [PATCH 470/722] configure.ac: Handle powerpc64le compiler Also-by: Paulo Flabiano Smorigo --- configure.ac | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/configure.ac b/configure.ac index fd8a62ead..e54b9df12 100644 --- a/configure.ac +++ b/configure.ac @@ -116,6 +116,7 @@ if test "x$with_platform" = x; then x86_64-*) platform=pc ;; powerpc-*) platform=ieee1275 ;; powerpc64-*) platform=ieee1275 ;; + powerpc64le-*) platform=ieee1275 ;; sparc64-*) platform=ieee1275 ;; mipsel-*) platform=loongson ;; mips-*) platform=arc ;; @@ -138,6 +139,7 @@ case "$target_cpu"-"$platform" in x86_64-none) ;; x86_64-*) target_cpu=i386 ;; powerpc64-ieee1275) target_cpu=powerpc ;; + powerpc64le-ieee1275) target_cpu=powerpc ;; esac # Check if the platform is supported, make final adjustments. @@ -560,6 +562,41 @@ AC_COMPILE_IFELSE( ]])], [grub_cv_cc_target_clang=no], [grub_cv_cc_target_clang=yes])]) +if test x$target_cpu = xpowerpc; then + AC_CACHE_CHECK([for options to get big-endian compilation], grub_cv_target_cc_big_endian, [ + grub_cv_target_cc_big_endian=no + for cand in "-target powerpc -Wl,-EB" "-target powerpc" \ + "-target powerpc-linux-gnu -Wl,-EB" "-target powerpc-linux-gnu" \ + "-mbig-endian"; do + if test x"$grub_cv_target_cc_big_endian" != xno ; then + break + fi + CFLAGS="$TARGET_CFLAGS $cand -Werror" + AC_LINK_IFELSE([AC_LANG_PROGRAM([[ +#if defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) && (__ORDER_BIG_ENDIAN__ != __BYTE_ORDER__) +#error still little endian +#endif +asm (".globl start; start:"); +void __main (void); +void __main (void) {} +int main (void); +]], [[]])], + [grub_cv_target_cc_big_endian="$cand"], []) + done + ]) + + if test x"$grub_cv_target_cc_big_endian" = xno ; then + AC_MSG_ERROR([could not force big-endian]) + fi + + skip_linkflags="$(echo "$grub_cv_target_cc_big_endian"|sed 's@-Wl,-EB@@')" + + TARGET_CFLAGS="$TARGET_CFLAGS $skip_linkflags" + TARGET_CPPFLAGS="$TARGET_CPPFLAGS $skip_linkflags" + TARGET_CCASFLAGS="$TARGET_CCASFLAGS $skip_linkflags" + TARGET_LDFLAGS="$TARGET_LDFLAGS $grub_cv_target_cc_big_endian" +fi + AC_CACHE_CHECK([for options to compile assembly], [grub_cv_cc_target_asm_compile], [ test_program= case "x$target_cpu-$platform" in From 9f27f9f69163bf6b41d8b4dc959f1baefa6f674e Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Wed, 22 Jul 2015 01:57:40 +0200 Subject: [PATCH 471/722] dmraid_nvidia: Set a name to usable value to avoid null dereference. Reported by: Andrei Borzenkov --- grub-core/disk/dmraid_nvidia.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/disk/dmraid_nvidia.c b/grub-core/disk/dmraid_nvidia.c index 881508cf2..060279124 100644 --- a/grub-core/disk/dmraid_nvidia.c +++ b/grub-core/disk/dmraid_nvidia.c @@ -172,7 +172,7 @@ grub_dmraid_nv_detect (grub_disk_t disk, return grub_diskfilter_make_raid (sizeof (sb.array.signature), uuid, sb.array.total_volumes, - NULL, disk_size, + "nv", disk_size, sb.array.stripe_block_size, GRUB_RAID_LAYOUT_LEFT_ASYMMETRIC, level); From 389d509df0d59445b0efcc7c6138d743ad573765 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Wed, 22 Jul 2015 20:39:14 +0200 Subject: [PATCH 472/722] diskfilter: Make name a const char to fix compilation error. --- grub-core/disk/diskfilter.c | 2 +- include/grub/diskfilter.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/grub-core/disk/diskfilter.c b/grub-core/disk/diskfilter.c index c4f6678b6..6f901c0ad 100644 --- a/grub-core/disk/diskfilter.c +++ b/grub-core/disk/diskfilter.c @@ -1007,7 +1007,7 @@ grub_diskfilter_vg_register (struct grub_diskfilter_vg *vg) struct grub_diskfilter_vg * grub_diskfilter_make_raid (grub_size_t uuidlen, char *uuid, int nmemb, - char *name, grub_uint64_t disk_size, + const char *name, grub_uint64_t disk_size, grub_uint64_t stripe_size, int layout, int level) { diff --git a/include/grub/diskfilter.h b/include/grub/diskfilter.h index 1aedcd3df..d89273c1b 100644 --- a/include/grub/diskfilter.h +++ b/include/grub/diskfilter.h @@ -172,7 +172,7 @@ grub_diskfilter_unregister (grub_diskfilter_t diskfilter) struct grub_diskfilter_vg * grub_diskfilter_make_raid (grub_size_t uuidlen, char *uuid, int nmemb, - char *name, grub_uint64_t disk_size, + const char *name, grub_uint64_t disk_size, grub_uint64_t stripe_size, int layout, int level); From f250c337f1a5ab648709c899d14fcf086f5c3aff Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Wed, 22 Jul 2015 20:40:13 +0200 Subject: [PATCH 473/722] ARM: provide __aeabi_memclr* and __aeabi_memcpy* symbols Fixes compilation with recent clang. --- grub-core/kern/compiler-rt.c | 15 +++++++++++++++ include/grub/compiler-rt.h | 7 +++++++ 2 files changed, 22 insertions(+) diff --git a/grub-core/kern/compiler-rt.c b/grub-core/kern/compiler-rt.c index d4cc15513..5cfcb3907 100644 --- a/grub-core/kern/compiler-rt.c +++ b/grub-core/kern/compiler-rt.c @@ -381,9 +381,24 @@ __aeabi_idiv (grub_int32_t a, grub_int32_t b) __attribute__ ((alias ("__divsi3"))); void *__aeabi_memcpy (void *dest, const void *src, grub_size_t n) __attribute__ ((alias ("grub_memcpy"))); +void *__aeabi_memcpy4 (void *dest, const void *src, grub_size_t n) + __attribute__ ((alias ("grub_memcpy"))); +void *__aeabi_memcpy8 (void *dest, const void *src, grub_size_t n) + __attribute__ ((alias ("grub_memcpy"))); void *__aeabi_memset (void *s, int c, grub_size_t n) __attribute__ ((alias ("memset"))); +void +__aeabi_memclr (void *s, grub_size_t n) +{ + grub_memset (s, 0, n); +} + +void __aeabi_memclr4 (void *s, grub_size_t n) + __attribute__ ((alias ("__aeabi_memclr"))); +void __aeabi_memclr8 (void *s, grub_size_t n) + __attribute__ ((alias ("__aeabi_memclr"))); + int __aeabi_ulcmp (grub_uint64_t a, grub_uint64_t b) { diff --git a/include/grub/compiler-rt.h b/include/grub/compiler-rt.h index 9265c7e80..dc73649a5 100644 --- a/include/grub/compiler-rt.h +++ b/include/grub/compiler-rt.h @@ -88,7 +88,14 @@ EXPORT_FUNC (__aeabi_lmul) (grub_uint64_t a, grub_uint64_t b); void * EXPORT_FUNC (__aeabi_memcpy) (void *dest, const void *src, grub_size_t n); void * +EXPORT_FUNC (__aeabi_memcpy4) (void *dest, const void *src, grub_size_t n); +void * +EXPORT_FUNC (__aeabi_memcpy8) (void *dest, const void *src, grub_size_t n); +void * EXPORT_FUNC(__aeabi_memset) (void *s, int c, grub_size_t n); +void EXPORT_FUNC(__aeabi_memclr) (void *s, grub_size_t n); +void EXPORT_FUNC(__aeabi_memclr4) (void *s, grub_size_t n); +void EXPORT_FUNC(__aeabi_memclr8) (void *s, grub_size_t n); grub_uint64_t EXPORT_FUNC (__aeabi_lasr) (grub_uint64_t u, int b); From eecdbebc8416467c029ab05d1c457901c4701c26 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Wed, 22 Jul 2015 20:47:56 +0200 Subject: [PATCH 474/722] Remove mips_attributes. mips_attributes was introduced to work around clang problems with -msoft-float. Those problems are now fixed and moreover .gnu_attributes itself is unportable and creates problem with clang. Revert "mips: Fix soft-float handling." This partially reverts commit 6a4ecd276ed39f66be0ad6ff0f8ff67598098605. --- grub-core/boot/mips/startup_raw.S | 2 -- grub-core/kern/mips/cache.S | 2 -- grub-core/kern/mips/startup.S | 2 -- grub-core/lib/mips/relocator_asm.S | 2 -- include/grub/mips/kernel.h | 4 ---- 5 files changed, 12 deletions(-) diff --git a/grub-core/boot/mips/startup_raw.S b/grub-core/boot/mips/startup_raw.S index fd95c3134..ca3413bbe 100644 --- a/grub-core/boot/mips/startup_raw.S +++ b/grub-core/boot/mips/startup_raw.S @@ -21,7 +21,6 @@ #include #include #include -#include #include #define BASE_ADDR 8 @@ -33,7 +32,6 @@ .globl __start, _start, start .set noreorder .set nomacro - mips_attributes __start: _start: start: diff --git a/grub-core/kern/mips/cache.S b/grub-core/kern/mips/cache.S index e83960fcc..fa6897e14 100644 --- a/grub-core/kern/mips/cache.S +++ b/grub-core/kern/mips/cache.S @@ -1,10 +1,8 @@ #include -#include .set noreorder .set nomacro - mips_attributes FUNCTION (grub_arch_sync_caches) #include "cache_flush.S" diff --git a/grub-core/kern/mips/startup.S b/grub-core/kern/mips/startup.S index 337aca914..339ab337e 100644 --- a/grub-core/kern/mips/startup.S +++ b/grub-core/kern/mips/startup.S @@ -21,7 +21,6 @@ #include #include #include -#include #include #define BASE_ADDR 8 @@ -29,7 +28,6 @@ .globl __start, _start, start .set noreorder .set nomacro - mips_attributes __start: _start: start: diff --git a/grub-core/lib/mips/relocator_asm.S b/grub-core/lib/mips/relocator_asm.S index 959893ca9..1d142a4f3 100644 --- a/grub-core/lib/mips/relocator_asm.S +++ b/grub-core/lib/mips/relocator_asm.S @@ -17,13 +17,11 @@ */ #include -#include .p2align 4 /* force 16-byte alignment */ .set noreorder .set nomacro - mips_attributes VARIABLE (grub_relocator_forward_start) move $a0, $9 diff --git a/include/grub/mips/kernel.h b/include/grub/mips/kernel.h index d0e09ddc6..07b08848d 100644 --- a/include/grub/mips/kernel.h +++ b/include/grub/mips/kernel.h @@ -21,8 +21,4 @@ #include -#ifdef ASM_FILE -#define mips_attributes .gnu_attribute 4, 3 -#endif - #endif /* ! GRUB_KERNEL_MACHINE_HEADER */ From 80783ea646b98b263df30cb3c75cef773729a1b2 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Wed, 22 Jul 2015 21:40:55 +0200 Subject: [PATCH 475/722] fwstart: Replace blt with bltz. blt A, $zero, B and bltz A, B are equivalent but clang recognizes only later, so use it. Resulting binary is unchanged. --- grub-core/boot/mips/loongson/fwstart.S | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/boot/mips/loongson/fwstart.S b/grub-core/boot/mips/loongson/fwstart.S index 71bab6dc8..c95b38ac0 100644 --- a/grub-core/boot/mips/loongson/fwstart.S +++ b/grub-core/boot/mips/loongson/fwstart.S @@ -344,7 +344,7 @@ printhex: nop srl $t1, $a0, 28 addiu $t1, $t1, -10 - blt $t1, $zero, 2f + bltz $t1, 2f sll $a0, $a0, 4 addiu $t1, $t1, 'A'-10-'0' 2: addiu $t1, $t1, '0'+10 From 63411b14be3da8d376d9d52a06c08c8ae36761da Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Wed, 22 Jul 2015 21:41:58 +0200 Subject: [PATCH 476/722] fwstart: Add missing argument to p2align. Resulting binary is unchanged as it happens we were already aligned by chance. --- grub-core/boot/mips/loongson/fwstart.S | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/boot/mips/loongson/fwstart.S b/grub-core/boot/mips/loongson/fwstart.S index c95b38ac0..921dbd1f1 100644 --- a/grub-core/boot/mips/loongson/fwstart.S +++ b/grub-core/boot/mips/loongson/fwstart.S @@ -547,7 +547,7 @@ gpio_dump: #endif gpio_dump_end: - .p2align + .p2align 3 write_dumpreg: ld $t2, 0($t6) From 248bc1d0fcdd7729ee225de9e8a293b61d9a3de0 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Wed, 22 Jul 2015 21:42:41 +0200 Subject: [PATCH 477/722] fwstart: Fix loading of address of read_spd_fail. --- grub-core/boot/mips/loongson/fwstart.S | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/boot/mips/loongson/fwstart.S b/grub-core/boot/mips/loongson/fwstart.S index 921dbd1f1..28c634614 100644 --- a/grub-core/boot/mips/loongson/fwstart.S +++ b/grub-core/boot/mips/loongson/fwstart.S @@ -398,7 +398,7 @@ read_spd: move $t2, $a0 move $t3, $ra lui $a0, %hi(read_spd_fail) - addiu $a0, $a0, %hi(read_spd_fail) + addiu $a0, $a0, %lo(read_spd_fail) /* Send START. */ lui $t0, %hi(GRUB_CS5536_LBAR_SMBUS + GRUB_CS5536_SMB_REG_CTRL1 + GRUB_MACHINE_PCI_IO_BASE_2F) From ca73ae446c426661a8f05196df279e8b973fead9 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Thu, 23 Jul 2015 02:15:46 +0200 Subject: [PATCH 478/722] arm-emu: Add __aeabi_memcpy* and __aeabi_memclr* symbols. Fixes compilation with clang. --- configure.ac | 2 +- include/grub/compiler-rt-emu.h | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index e54b9df12..c864311f7 100644 --- a/configure.ac +++ b/configure.ac @@ -1181,7 +1181,7 @@ fi # Check for libgcc symbols if test x"$platform" = xemu; then -AC_CHECK_FUNCS(__udivsi3 __umodsi3 __divsi3 __modsi3 __divdi3 __moddi3 __udivdi3 __umoddi3 __ctzdi2 __ctzsi2 __aeabi_uidiv __aeabi_uidivmod __aeabi_idiv __aeabi_idivmod __aeabi_ulcmp __muldi3 __aeabi_lmul __aeabi_memcpy __aeabi_memset __aeabi_lasr __aeabi_llsl __aeabi_llsr _restgpr_14_x __ucmpdi2 __ashldi3 __ashrdi3 __lshrdi3 __bswapsi2 __bswapdi2 __bzero __register_frame_info __deregister_frame_info ___chkstk_ms __chkstk_ms) +AC_CHECK_FUNCS(__udivsi3 __umodsi3 __divsi3 __modsi3 __divdi3 __moddi3 __udivdi3 __umoddi3 __ctzdi2 __ctzsi2 __aeabi_uidiv __aeabi_uidivmod __aeabi_idiv __aeabi_idivmod __aeabi_ulcmp __muldi3 __aeabi_lmul __aeabi_memcpy __aeabi_memcpy4 __aeabi_memcpy8 __aeabi_memclr __aeabi_memclr4 __aeabi_memclr8 __aeabi_memset __aeabi_lasr __aeabi_llsl __aeabi_llsr _restgpr_14_x __ucmpdi2 __ashldi3 __ashrdi3 __lshrdi3 __bswapsi2 __bswapdi2 __bzero __register_frame_info __deregister_frame_info ___chkstk_ms __chkstk_ms) fi if test "x$TARGET_APPLE_LINKER" = x1 ; then diff --git a/include/grub/compiler-rt-emu.h b/include/grub/compiler-rt-emu.h index edc82999e..b21425d9e 100644 --- a/include/grub/compiler-rt-emu.h +++ b/include/grub/compiler-rt-emu.h @@ -115,11 +115,36 @@ void * EXPORT_FUNC (__aeabi_memcpy) (void *dest, const void *src, grub_size_t n); #endif +#ifdef HAVE___AEABI_MEMCPY4 +void * +EXPORT_FUNC (__aeabi_memcpy4) (void *dest, const void *src, grub_size_t n); +#endif + +#ifdef HAVE___AEABI_MEMCPY8 +void * +EXPORT_FUNC (__aeabi_memcpy8) (void *dest, const void *src, grub_size_t n); +#endif + #ifdef HAVE___AEABI_MEMSET void * EXPORT_FUNC(__aeabi_memset) (void *s, int c, grub_size_t n); #endif +#ifdef HAVE___AEABI_MEMCLR +void * +EXPORT_FUNC(__aeabi_memclr) (void *s, grub_size_t n); +#endif + +#ifdef HAVE___AEABI_MEMCLR4 +void * +EXPORT_FUNC(__aeabi_memclr4) (void *s, grub_size_t n); +#endif + +#ifdef HAVE___AEABI_MEMCLR8 +void * +EXPORT_FUNC(__aeabi_memclr8) (void *s, grub_size_t n); +#endif + #ifdef HAVE___AEABI_LASR grub_uint64_t EXPORT_FUNC (__aeabi_lasr) (grub_uint64_t u, int b); From f34a42208153e520d5239be1cea2ca1fbfced9e0 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Thu, 23 Jul 2015 19:01:00 +0200 Subject: [PATCH 479/722] archelp: Fix handling of dot and dotdot at the end of the name. Fixes cpio_test and tar_test. --- grub-core/fs/archelp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/grub-core/fs/archelp.c b/grub-core/fs/archelp.c index c85cbfac2..707f9a658 100644 --- a/grub-core/fs/archelp.c +++ b/grub-core/fs/archelp.c @@ -34,12 +34,12 @@ canonicalize (char *name) iptr++; if (iptr[0] == '.' && (iptr[1] == '/' || iptr[1] == 0)) { - iptr += 2; + iptr++; continue; } if (iptr[0] == '.' && iptr[1] == '.' && (iptr[2] == '/' || iptr[2] == 0)) { - iptr += 3; + iptr += 2; if (optr == name) continue; for (optr -= 2; optr >= name && *optr != '/'; optr--); From d0d90d78485f9b53c80962faa617c30d55380032 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Thu, 23 Jul 2015 19:04:55 +0200 Subject: [PATCH 480/722] exclude.pot: Add missing blacklisted strings. --- po/exclude.pot | 54 ++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 52 insertions(+), 2 deletions(-) diff --git a/po/exclude.pot b/po/exclude.pot index ab52e9990..0a9b215ea 100644 --- a/po/exclude.pot +++ b/po/exclude.pot @@ -7440,7 +7440,57 @@ msgid "" "\n" msgstr "" -#: util/grub-probe.c:735 +#: grub-core/bus/emu/pci.c:58 #, c-format -msgid "%s\n%s %s %s" +msgid "mapping 0x%llx failed (error %d)" +msgstr "" + +#: grub-core/disk/dmraid_nvidia.c:175 +msgid "nv" +msgstr "" + +#: grub-core/fs/xfs.c:478 +msgid ") - %" +msgstr "" + +#: grub-core/fs/xfs.c:478 +#, c-format +msgid ", %d +" +msgstr "" + +#: grub-core/fs/xfs.c:550 +msgid "BMA3" +msgstr "" + +#: grub-core/fs/zfs/zfs.c:284 +msgid "com.delphix:hole_birth" +msgstr "" + +#: grub-core/fs/zfs/zfs.c:285 +msgid "com.delphix:embedded_data" +msgstr "" + +#: grub-core/fs/zfs/zfs.c:286 +msgid "com.delphix:extensible_dataset" +msgstr "" + +#: grub-core/fs/zfs/zfs.c:287 +msgid "org.open-zfs:large_blocks" +msgstr "" + +#: grub-core/fs/zfs/zfs.c:1877 +msgid "/%" +msgstr "" + +#: grub-core/osdep/linux/platform.c:73 +msgid "/sys/firmware/efi/fw_platform_size" +msgstr "" + +#: util/grub-mkrescue.c:454 +msgid "-output" +msgstr "" + +#: util/grub-mkrescue.c:455 +msgid "--output" msgstr "" From 81ca24a59cdab59503a8f13586da3b62a52d7460 Mon Sep 17 00:00:00 2001 From: Ignat Korchagin Date: Thu, 23 Jul 2015 21:13:09 +0300 Subject: [PATCH 481/722] efi: fix memory leak in variable handling --- grub-core/kern/efi/efi.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/grub-core/kern/efi/efi.c b/grub-core/kern/efi/efi.c index 2e7783468..490edefe5 100644 --- a/grub-core/kern/efi/efi.c +++ b/grub-core/kern/efi/efi.c @@ -206,6 +206,7 @@ grub_efi_set_variable(const char *var, const grub_efi_guid_t *guid, | GRUB_EFI_VARIABLE_BOOTSERVICE_ACCESS | GRUB_EFI_VARIABLE_RUNTIME_ACCESS), datasize, data); + grub_free (var16); if (status == GRUB_EFI_SUCCESS) return GRUB_ERR_NONE; @@ -237,8 +238,11 @@ grub_efi_get_variable (const char *var, const grub_efi_guid_t *guid, status = efi_call_5 (r->get_variable, var16, guid, NULL, &datasize, NULL); - if (!datasize) - return NULL; + if (status != GRUB_EFI_SUCCESS || !datasize) + { + grub_free (var16); + return NULL; + } data = grub_malloc (datasize); if (!data) From 02a249005fe5e53905fd809a74f65d1b1333a0e0 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 24 Jul 2015 01:13:27 +0200 Subject: [PATCH 482/722] reiserfs: Fix handling of first entry in the directory. Fixes garbage being added to "." filename. --- grub-core/fs/reiserfs.c | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/grub-core/fs/reiserfs.c b/grub-core/fs/reiserfs.c index b78166554..39736f63c 100644 --- a/grub-core/fs/reiserfs.c +++ b/grub-core/fs/reiserfs.c @@ -783,12 +783,30 @@ grub_reiserfs_iterate_dir (grub_fshelp_node_t item, struct grub_reiserfs_key entry_key; enum grub_fshelp_filetype entry_type; char *entry_name; + char *entry_name_end = 0; + char c; if (!(entry_state & GRUB_REISERFS_VISIBLE_MASK)) continue; entry_name = (((char *) directory_headers) + grub_le_to_cpu16 (directory_header->location)); + if (entry_number == 0) + { + entry_name_end = (char *) block_header + + grub_le_to_cpu16 (item_headers[block_position].item_location) + + grub_le_to_cpu16 (item_headers[block_position].item_size); + } + else + { + entry_name_end = (((char *) directory_headers) + + grub_le_to_cpu16 (directory_headers[entry_number - 1].location)); + } + if (entry_name_end < entry_name || entry_name_end > (char *) block_header + block_size) + { + entry_name_end = (char *) block_header + block_size; + } + entry_key.directory_id = directory_header->directory_id; entry_key.object_id = directory_header->object_id; entry_key.u.v2.offset_type = 0; @@ -935,7 +953,7 @@ grub_reiserfs_iterate_dir (grub_fshelp_node_t item, else { /* Pseudo file ".." never has stat block. */ - if (grub_strcmp (entry_name, "..")) + if (entry_name_end == entry_name + 2 && grub_memcmp (entry_name, "..", 2) != 0) grub_dprintf ("reiserfs", "Warning : %s has no stat block !\n", entry_name); @@ -943,18 +961,21 @@ grub_reiserfs_iterate_dir (grub_fshelp_node_t item, goto next; } } + + c = *entry_name_end; + *entry_name_end = 0; if (hook (entry_name, entry_type, entry_item, hook_data)) { + *entry_name_end = c; grub_dprintf ("reiserfs", "Found : %s, type=%d\n", entry_name, entry_type); ret = 1; goto found; } + *entry_name_end = c; next: - *entry_name = 0; /* Make sure next entry name (which is just - before this one in disk order) stops before - the current one. */ + ; } if (next_offset == 0) From 049dcfa03c2217f3af9f108d3f41229b8155c534 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 24 Jul 2015 01:15:32 +0200 Subject: [PATCH 483/722] xfs: Fix handling of symlink with crc-enabled filesystem. --- grub-core/fs/xfs.c | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/grub-core/fs/xfs.c b/grub-core/fs/xfs.c index 46de6aff3..a03526b32 100644 --- a/grub-core/fs/xfs.c +++ b/grub-core/fs/xfs.c @@ -604,13 +604,13 @@ grub_xfs_read_block (grub_fshelp_node_t node, grub_disk_addr_t fileblock) POS. Return the amount of read bytes in READ. */ static grub_ssize_t grub_xfs_read_file (grub_fshelp_node_t node, - grub_disk_read_hook_t read_hook, void *read_hook_data, - grub_off_t pos, grub_size_t len, char *buf) + grub_disk_read_hook_t read_hook, void *read_hook_data, + grub_off_t pos, grub_size_t len, char *buf, grub_uint32_t header_size) { return grub_fshelp_read_file (node->data->disk, node, read_hook, read_hook_data, pos, len, buf, grub_xfs_read_block, - grub_be_to_cpu64 (node->inode.size), + grub_be_to_cpu64 (node->inode.size) + header_size, node->data->sblock.log2_bsize - GRUB_DISK_SECTOR_BITS, 0); } @@ -619,7 +619,13 @@ grub_xfs_read_file (grub_fshelp_node_t node, static char * grub_xfs_read_symlink (grub_fshelp_node_t node) { - int size = grub_be_to_cpu64 (node->inode.size); + grub_ssize_t size = grub_be_to_cpu64 (node->inode.size); + + if (size < 0) + { + grub_error (GRUB_ERR_BAD_FS, "invalid symlink"); + return 0; + } switch (node->inode.format) { @@ -630,12 +636,17 @@ grub_xfs_read_symlink (grub_fshelp_node_t node) { char *symlink; grub_ssize_t numread; + int off = 0; + + if (node->data->hascrc) + off = 56; symlink = grub_malloc (size + 1); if (!symlink) return 0; - numread = grub_xfs_read_file (node, 0, 0, 0, size, symlink); + node->inode.size = grub_be_to_cpu64 (size + off); + numread = grub_xfs_read_file (node, 0, 0, off, size, symlink, off); if (numread != size) { grub_free (symlink); @@ -802,7 +813,7 @@ grub_xfs_iterate_dir (grub_fshelp_node_t dir, numread = grub_xfs_read_file (dir, 0, 0, blk << dirblk_log2, - dirblk_size, dirblock); + dirblk_size, dirblock, 0); if (numread != dirblk_size) return 0; @@ -1034,7 +1045,7 @@ grub_xfs_read (grub_file_t file, char *buf, grub_size_t len) return grub_xfs_read_file (&data->diropen, file->read_hook, file->read_hook_data, - file->offset, len, buf); + file->offset, len, buf, 0); } From 900fca88ac7dd8a4767cd1edc71b8ee6737eaa75 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 24 Jul 2015 01:16:30 +0200 Subject: [PATCH 484/722] xfs_test: Test both crc and non-crc filesystems. --- tests/util/grub-fs-tester.in | 17 ++++++++++++++--- tests/xfs_test.in | 1 + 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/tests/util/grub-fs-tester.in b/tests/util/grub-fs-tester.in index 5107ca17a..6fcac31c3 100644 --- a/tests/util/grub-fs-tester.in +++ b/tests/util/grub-fs-tester.in @@ -40,6 +40,10 @@ case x"$fs" in MINLOGSECSIZE=9 # OS LIMITATION: GNU/Linux doesn't accept > 4096 MAXLOGSECSIZE=12;; + xxfs_crc) + MINLOGSECSIZE=9 + # OS LIMITATION: GNU/Linux doesn't accept > 1024 + MAXLOGSECSIZE=10;; xzfs*) # OS LIMITATION: zfs-fuse hangs when creating zpool with sectors <=256B. MINLOGSECSIZE=9 @@ -142,6 +146,10 @@ for ((LOGSECSIZE=MINLOGSECSIZE;LOGSECSIZE<=MAXLOGSECSIZE;LOGSECSIZE=LOGSECSIZE + MINBLKSIZE=$SECSIZE # OS Limitation: GNU/Linux doesn't accept > 4096 MAXBLKSIZE=4096;; + xxfs_crc) + # OS Limitation: GNU/Linux doesn't accept != 1024 + MINBLKSIZE=1024 + MAXBLKSIZE=1024;; xudf) MINBLKSIZE=1024 MAXBLKSIZE=4096;; @@ -287,7 +295,7 @@ for ((LOGSECSIZE=MINLOGSECSIZE;LOGSECSIZE<=MAXLOGSECSIZE;LOGSECSIZE=LOGSECSIZE + x"ufs1" | x"ufs1_sun" | x"ufs2") FSLABEL="grubtest""ieurrucnenreeiurueurewf";; # FS LIMITATION: XFS label is at most 12 UTF-8 characters - x"xfs") + x"xfs"|x"xfs_crc") FSLABEL="géт ðŸ˜Ðº";; # FS LIMITATION: FAT labels limited to 11 characters, no international characters or lowercase x"vfat"* | xmsdos*) @@ -465,7 +473,7 @@ for ((LOGSECSIZE=MINLOGSECSIZE;LOGSECSIZE<=MAXLOGSECSIZE;LOGSECSIZE=LOGSECSIZE + case x"$fs" in # FIXME: Not sure about BtrFS, NTFS, JFS, AFS, UDF and SFS. Check it. # FS LIMITATION: as far as I know those FS don't store their last modification date. - x"jfs_caseins" | x"jfs" | x"xfs"| x"btrfs"* | x"reiserfs_old" | x"reiserfs" \ + x"jfs_caseins" | x"jfs" | x"xfs" | x"xfs_crc" | x"btrfs"* | x"reiserfs_old" | x"reiserfs" \ | x"bfs" | x"afs" \ | x"tarfs" | x"cpio_"* | x"minix" | x"minix2" \ | x"minix3" | x"ntfs"* | x"udf" | x"sfs"*) @@ -758,7 +766,10 @@ for ((LOGSECSIZE=MINLOGSECSIZE;LOGSECSIZE<=MAXLOGSECSIZE;LOGSECSIZE=LOGSECSIZE + xext*) MKE2FS_DEVICE_SECTSIZE=$SECSIZE "mkfs.$fs" -b $BLKSIZE -L "$FSLABEL" -q "${LODEVICES[0]}" ;; xxfs) - "mkfs.xfs" -b size=$BLKSIZE -s size=$SECSIZE -L "$FSLABEL" -q "${LODEVICES[0]}" ;; + "mkfs.xfs" -m crc=0 -b size=$BLKSIZE -s size=$SECSIZE -L "$FSLABEL" -q "${LODEVICES[0]}" ;; + xxfs_crc) + MOUNTFS="xfs" + "mkfs.xfs" -m crc=1 -b size=$BLKSIZE -s size=$SECSIZE -L "$FSLABEL" -q "${LODEVICES[0]}" ;; *) echo "Add appropriate mkfs command here" exit 1 diff --git a/tests/xfs_test.in b/tests/xfs_test.in index 173b1cfe6..3807e2e5c 100644 --- a/tests/xfs_test.in +++ b/tests/xfs_test.in @@ -16,4 +16,5 @@ if ! which mkfs.xfs >/dev/null 2>&1; then fi +"@builddir@/grub-fs-tester" xfs_crc "@builddir@/grub-fs-tester" xfs From 333855c6469d52a7a555ea55834182603981ea0e Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 24 Jul 2015 01:17:04 +0200 Subject: [PATCH 485/722] zfs_test: Skip dotdot in volume root test. Given special semantics of ZFS it's far from clear what the expected result is. Just skip it for now --- tests/util/grub-fs-tester.in | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/tests/util/grub-fs-tester.in b/tests/util/grub-fs-tester.in index 6fcac31c3..29ae69153 100644 --- a/tests/util/grub-fs-tester.in +++ b/tests/util/grub-fs-tester.in @@ -1149,18 +1149,19 @@ for ((LOGSECSIZE=MINLOGSECSIZE;LOGSECSIZE<=MAXLOGSECSIZE;LOGSECSIZE=LOGSECSIZE + case x"$fs" in x"zfs"*) - LSROUT=$(run_grubfstest ls -- -la "($GRUBDEVICE)/grub fs@/..");; + ;; *) - LSROUT=$(run_grubfstest ls -- -la "($GRUBDEVICE)/..");; + LSROUT=$(run_grubfstest ls -- -la "($GRUBDEVICE)/.."); + if echo "$LSROUT" | grep -F " $BASEFILE" | grep "$BLOCKCNT" > /dev/null; then + : + else + echo DOTDOT IN ROOTDIR FAIL + echo "$LSROUT" + TZ=UTC ls --time-style=+%Y%m%d%H%M%S.%N -l "$MNTPOINTRO" + exit 1 + fi + ;; esac - if echo "$LSROUT" | grep -F " $BASEFILE" | grep "$BLOCKCNT" > /dev/null; then - : - else - echo DOTDOT IN ROOTDIR FAIL - echo "$LSROUT" - TZ=UTC ls --time-style=+%Y%m%d%H%M%S.%N -l "$MNTPOINTRO" - exit 1 - fi case x"$fs" in x"zfs"*) From d5847bf59443ef54c838fe5be1ecd47443c7807b Mon Sep 17 00:00:00 2001 From: Ignat Korchagin Date: Fri, 24 Jul 2015 20:46:02 +0300 Subject: [PATCH 486/722] efi: fix GetVariable return status check in 81ca24a GetVariable should return EFI_BUFFER_TOO_SMALL if given buffer of size zero; commit incorrectly checked for EFI_SUCCESS. --- grub-core/kern/efi/efi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/kern/efi/efi.c b/grub-core/kern/efi/efi.c index 490edefe5..caf9bcc41 100644 --- a/grub-core/kern/efi/efi.c +++ b/grub-core/kern/efi/efi.c @@ -238,7 +238,7 @@ grub_efi_get_variable (const char *var, const grub_efi_guid_t *guid, status = efi_call_5 (r->get_variable, var16, guid, NULL, &datasize, NULL); - if (status != GRUB_EFI_SUCCESS || !datasize) + if (status != GRUB_EFI_BUFFER_TOO_SMALL || !datasize) { grub_free (var16); return NULL; From 368ecfc3a031bd3b03bcaae776d6f276f79af157 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 27 Jul 2015 12:39:41 +0200 Subject: [PATCH 487/722] Add transform_data as a variant of data with substitutions. This fixrs name mismatch for grub.chrp with transform_program_name='s,grub,grub2,g' --- gentpl.py | 15 +++++++++++++++ grub-core/Makefile.core.def | 14 +++++++------- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/gentpl.py b/gentpl.py index 37b1f45bf..76971d3ce 100644 --- a/gentpl.py +++ b/gentpl.py @@ -834,6 +834,20 @@ def data(defn, platform): var_add("dist_" + installdir(defn) + "_DATA", platform_sources(defn, platform)) gvar_add("dist_noinst_DATA", extra_dist(defn)) +def transform_data(defn, platform): + name = defn['name'] + + var_add(installdir(defn) + "_DATA", name) + + rule(name, "$(top_builddir)/config.status " + platform_sources(defn, platform) + platform_dependencies(defn, platform), """ +(for x in """ + platform_sources(defn, platform) + """; do cat $(srcdir)/"$$x"; done) | $(top_builddir)/config.status --file=$@:- +chmod a+x """ + name + """ +""") + + gvar_add("CLEANFILES", name) + gvar_add("EXTRA_DIST", extra_dist(defn)) + gvar_add("dist_noinst_DATA", platform_sources(defn, platform)) + def script(defn, platform): name = defn['name'] @@ -881,6 +895,7 @@ rules("library", library) rules("program", program) rules("script", script) rules("data", data) +rules("transform_data", transform_data) write_output(section='decl') write_output() diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def index a6101dec7..9764cd235 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def @@ -1,43 +1,43 @@ AutoGen definitions Makefile.tpl; -script = { +transform_data = { installdir = noinst; name = gensyminfo.sh; common = gensyminfo.sh.in; }; -script = { +transform_data = { installdir = noinst; name = genmod.sh; common = genmod.sh.in; }; -script = { +transform_data = { installdir = noinst; name = modinfo.sh; common = modinfo.sh.in; }; -script = { +transform_data = { installdir = platform; name = gmodule.pl; common = gmodule.pl.in; }; -script = { +transform_data = { installdir = platform; name = gdb_grub; common = gdb_grub.in; }; -script = { +transform_data = { installdir = platform; name = grub.chrp; common = boot/powerpc/grub.chrp.in; enable = powerpc_ieee1275; }; -script = { +transform_data = { installdir = platform; name = bootinfo.txt; common = boot/powerpc/bootinfo.txt.in; From a2721778e5234fc87af7c3bf2b7cfdaca3abfa60 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 27 Jul 2015 12:42:47 +0200 Subject: [PATCH 488/722] grub-install: Use a+ in fopen rather than r+. r+ does not create a file if none exists. --- util/grub-install.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/grub-install.c b/util/grub-install.c index 566272600..df5c7e520 100644 --- a/util/grub-install.c +++ b/util/grub-install.c @@ -1727,7 +1727,7 @@ main (int argc, char *argv[]) grub_elf = grub_util_path_concat (2, core_services, "grub.elf"); grub_install_copy_file (imgfile, grub_elf, 1); - f = grub_util_fopen (mach_kernel, "r+"); + f = grub_util_fopen (mach_kernel, "a+"); if (!f) grub_util_error (_("Can't create file: %s"), strerror (errno)); fclose (f); From 4622f4e1ee569d5841bf8bb080430dc28b1c5665 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 27 Jul 2015 12:44:19 +0200 Subject: [PATCH 489/722] Switch procfs to use archelp. This fixes handling of "." and "..". --- Makefile.util.def | 2 +- grub-core/fs/proc.c | 84 ++++++++++++++++++++++++++++++--------------- 2 files changed, 58 insertions(+), 28 deletions(-) diff --git a/Makefile.util.def b/Makefile.util.def index 3cb6b21d3..db7e8ec2a 100644 --- a/Makefile.util.def +++ b/Makefile.util.def @@ -48,6 +48,7 @@ library = { common = grub-core/partmap/gpt.c; common = grub-core/partmap/msdos.c; common = grub-core/fs/proc.c; + common = grub-core/fs/archelp.c; }; library = { @@ -91,7 +92,6 @@ library = { common = grub-core/fs/bfs.c; common = grub-core/fs/btrfs.c; common = grub-core/fs/cbfs.c; - common = grub-core/fs/archelp.c; common = grub-core/fs/cpio.c; common = grub-core/fs/cpio_be.c; common = grub-core/fs/odc.c; diff --git a/grub-core/fs/proc.c b/grub-core/fs/proc.c index a03469ec6..31f3aa9a4 100644 --- a/grub-core/fs/proc.c +++ b/grub-core/fs/proc.c @@ -22,6 +22,7 @@ #include #include #include +#include GRUB_MOD_LICENSE ("GPLv3+"); @@ -74,6 +75,44 @@ grub_procdev_write (grub_disk_t disk __attribute ((unused)), return GRUB_ERR_OUT_OF_RANGE; } +struct grub_archelp_data +{ + struct grub_procfs_entry *entry, *next_entry; +}; + +static void +grub_procfs_rewind (struct grub_archelp_data *data) +{ + data->entry = NULL; + data->next_entry = grub_procfs_entries; +} + +static grub_err_t +grub_procfs_find_file (struct grub_archelp_data *data, char **name, + grub_int32_t *mtime, + grub_uint32_t *mode) +{ + data->entry = data->next_entry; + if (!data->entry) + { + *mode = GRUB_ARCHELP_ATTR_END; + return GRUB_ERR_NONE; + } + data->next_entry = data->entry->next; + *mode = GRUB_ARCHELP_ATTR_FILE | GRUB_ARCHELP_ATTR_NOTIME; + *name = grub_strdup (data->entry->name); + *mtime = 0; + if (!*name) + return grub_errno; + return GRUB_ERR_NONE; +} + +static struct grub_archelp_ops arcops = + { + .find_file = grub_procfs_find_file, + .rewind = grub_procfs_rewind + }; + static grub_ssize_t grub_procfs_read (grub_file_t file, char *buf, grub_size_t len) { @@ -99,44 +138,35 @@ static grub_err_t grub_procfs_dir (grub_device_t device, const char *path, grub_fs_dir_hook_t hook, void *hook_data) { - const char *ptr; - struct grub_dirhook_info info; - struct grub_procfs_entry *entry; - - grub_memset (&info, 0, sizeof (info)); + struct grub_archelp_data data; /* Check if the disk is our dummy disk. */ if (grub_strcmp (device->disk->name, "proc")) return grub_error (GRUB_ERR_BAD_FS, "not a procfs"); - for (ptr = path; *ptr == '/'; ptr++); - if (*ptr) - return 0; - FOR_LIST_ELEMENTS((entry), (grub_procfs_entries)) - if (hook (entry->name, &info, hook_data)) - return 0; - return 0; + + grub_procfs_rewind (&data); + + return grub_archelp_dir (&data, &arcops, + path, hook, hook_data); } static grub_err_t grub_procfs_open (struct grub_file *file, const char *path) { - const char *pathptr; - struct grub_procfs_entry *entry; + grub_err_t err; + struct grub_archelp_data data; + grub_size_t sz; - for (pathptr = path; *pathptr == '/'; pathptr++); + grub_procfs_rewind (&data); - FOR_LIST_ELEMENTS((entry), (grub_procfs_entries)) - if (grub_strcmp (pathptr, entry->name) == 0) - { - grub_size_t sz; - file->data = entry->get_contents (&sz); - if (!file->data) - return grub_errno; - file->size = sz; - return GRUB_ERR_NONE; - } - - return grub_error (GRUB_ERR_FILE_NOT_FOUND, N_("file `%s' not found"), path); + err = grub_archelp_open (&data, &arcops, path); + if (err) + return err; + file->data = data.entry->get_contents (&sz); + if (!file->data) + return grub_errno; + file->size = sz; + return GRUB_ERR_NONE; } static struct grub_disk_dev grub_procfs_dev = { From fa93b0e4f5dd8d218da1c32c71c2bffd48eab89b Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 27 Jul 2015 12:45:35 +0200 Subject: [PATCH 490/722] fshelp: Add handling of "." and ".." and grub_fshelp_find_file_lookup. Recent tests have discovered that many of our filesystems have flawed handling of "." and "..". Rather than attempting to fix it in filesystems themselves, make the common code fshelp aware of "." and ".." and handle them in this layer. Add grub_fshelp_find_file_lookup for easy conversion of BFS, HFS and exFAT which have the same problem and don't use fshelp. --- grub-core/fs/fshelp.c | 324 ++++++++++++++++++++++++++++-------------- include/grub/fshelp.h | 11 ++ 2 files changed, 228 insertions(+), 107 deletions(-) diff --git a/grub-core/fs/fshelp.c b/grub-core/fs/fshelp.c index b899bed04..4c902adf3 100644 --- a/grub-core/fs/fshelp.c +++ b/grub-core/fs/fshelp.c @@ -30,169 +30,287 @@ GRUB_MOD_LICENSE ("GPLv3+"); typedef int (*iterate_dir_func) (grub_fshelp_node_t dir, grub_fshelp_iterate_dir_hook_t hook, void *data); +typedef grub_err_t (*lookup_file_func) (grub_fshelp_node_t dir, + const char *name, + grub_fshelp_node_t *foundnode, + enum grub_fshelp_filetype *foundtype); typedef char *(*read_symlink_func) (grub_fshelp_node_t node); +struct stack_element { + struct stack_element *parent; + grub_fshelp_node_t node; + enum grub_fshelp_filetype type; +}; + /* Context for grub_fshelp_find_file. */ struct grub_fshelp_find_file_ctx { + /* Inputs. */ const char *path; - grub_fshelp_node_t rootnode, currroot, currnode, oldnode; - enum grub_fshelp_filetype foundtype; + grub_fshelp_node_t rootnode; + + /* Global options. */ int symlinknest; - const char *name; - const char *next; - enum grub_fshelp_filetype type; + + /* Current file being traversed and its parents. */ + struct stack_element *currnode; }; /* Helper for find_file_iter. */ static void free_node (grub_fshelp_node_t node, struct grub_fshelp_find_file_ctx *ctx) { - if (node != ctx->rootnode && node != ctx->currroot) + if (node != ctx->rootnode) grub_free (node); } +static void +pop_element (struct grub_fshelp_find_file_ctx *ctx) +{ + struct stack_element *el; + el = ctx->currnode; + ctx->currnode = el->parent; + free_node (el->node, ctx); + grub_free (el); +} + +static void +free_stack (struct grub_fshelp_find_file_ctx *ctx) +{ + while (ctx->currnode) + pop_element (ctx); +} + +static void +go_up_a_level (struct grub_fshelp_find_file_ctx *ctx) +{ + if (!ctx->currnode->parent) + return; + pop_element (ctx); +} + +static grub_err_t +push_node (struct grub_fshelp_find_file_ctx *ctx, grub_fshelp_node_t node, enum grub_fshelp_filetype filetype) +{ + struct stack_element *nst; + nst = grub_malloc (sizeof (*nst)); + if (!nst) + return grub_errno; + nst->node = node; + nst->type = filetype & ~GRUB_FSHELP_CASE_INSENSITIVE; + nst->parent = ctx->currnode; + ctx->currnode = nst; + return GRUB_ERR_NONE; +} + +static grub_err_t +go_to_root (struct grub_fshelp_find_file_ctx *ctx) +{ + free_stack (ctx); + return push_node (ctx, ctx->rootnode, GRUB_FSHELP_DIR); +} + +struct grub_fshelp_find_file_iter_ctx +{ + const char *name; + grub_fshelp_node_t *foundnode; + enum grub_fshelp_filetype *foundtype; +}; + /* Helper for grub_fshelp_find_file. */ static int find_file_iter (const char *filename, enum grub_fshelp_filetype filetype, grub_fshelp_node_t node, void *data) { - struct grub_fshelp_find_file_ctx *ctx = data; + struct grub_fshelp_find_file_iter_ctx *ctx = data; if (filetype == GRUB_FSHELP_UNKNOWN || ((filetype & GRUB_FSHELP_CASE_INSENSITIVE) - ? grub_strncasecmp (ctx->name, filename, ctx->next - ctx->name) - : grub_strncmp (ctx->name, filename, ctx->next - ctx->name)) - || filename[ctx->next - ctx->name]) + ? grub_strcasecmp (ctx->name, filename) + : grub_strcmp (ctx->name, filename))) { grub_free (node); return 0; } /* The node is found, stop iterating over the nodes. */ - ctx->type = filetype & ~GRUB_FSHELP_CASE_INSENSITIVE; - ctx->oldnode = ctx->currnode; - ctx->currnode = node; - + *ctx->foundnode = node; + *ctx->foundtype = filetype; return 1; } static grub_err_t -find_file (const char *currpath, grub_fshelp_node_t currroot, - grub_fshelp_node_t *currfound, - iterate_dir_func iterate_dir, read_symlink_func read_symlink, +directory_find_file (grub_fshelp_node_t node, const char *name, grub_fshelp_node_t *foundnode, + enum grub_fshelp_filetype *foundtype, iterate_dir_func iterate_dir) +{ + int found; + struct grub_fshelp_find_file_iter_ctx ctx = { + .foundnode = foundnode, + .foundtype = foundtype, + .name = name + }; + found = iterate_dir (node, find_file_iter, &ctx); + if (! found) + { + if (grub_errno) + return grub_errno; + } + return GRUB_ERR_NONE; +} + +static grub_err_t +find_file (char *currpath, + iterate_dir_func iterate_dir, lookup_file_func lookup_file, + read_symlink_func read_symlink, struct grub_fshelp_find_file_ctx *ctx) { - ctx->currroot = currroot; - ctx->name = currpath; - ctx->type = GRUB_FSHELP_DIR; - ctx->currnode = currroot; - ctx->oldnode = currroot; - - for (;;) + char *name, *next; + grub_err_t err; + for (name = currpath; ; name = next) { - int found; + char c; + grub_fshelp_node_t foundnode = NULL; + enum grub_fshelp_filetype foundtype = 0; /* Remove all leading slashes. */ - while (*ctx->name == '/') - ctx->name++; + while (*name == '/') + name++; /* Found the node! */ - if (! *ctx->name) - { - *currfound = ctx->currnode; - ctx->foundtype = ctx->type; - return 0; - } + if (! *name) + return 0; /* Extract the actual part from the pathname. */ - for (ctx->next = ctx->name; *ctx->next && *ctx->next != '/'; ctx->next++); + for (next = name; *next && *next != '/'; next++); /* At this point it is expected that the current node is a directory, check if this is true. */ - if (ctx->type != GRUB_FSHELP_DIR) + if (ctx->currnode->type != GRUB_FSHELP_DIR) + return grub_error (GRUB_ERR_BAD_FILE_TYPE, N_("not a directory")); + + /* Don't rely on fs providing actual . in the listing. */ + if (next - name == 1 && name[0] == '.') + continue; + + /* Don't rely on fs providing actual .. in the listing. */ + if (next - name == 2 && name[0] == '.' && name[1] == '.') { - free_node (ctx->currnode, ctx); - ctx->currnode = 0; - return grub_error (GRUB_ERR_BAD_FILE_TYPE, N_("not a directory")); + go_up_a_level (ctx); + continue; } /* Iterate over the directory. */ - found = iterate_dir (ctx->currnode, find_file_iter, ctx); - if (! found) - { - free_node (ctx->currnode, ctx); - ctx->currnode = 0; - if (grub_errno) - return grub_errno; + c = *next; + *next = '\0'; + if (lookup_file) + err = lookup_file (ctx->currnode->node, name, &foundnode, &foundtype); + else + err = directory_find_file (ctx->currnode->node, name, &foundnode, &foundtype, iterate_dir); + *next = c; - break; - } + if (err) + return err; + if (!foundnode) + break; + + push_node (ctx, foundnode, foundtype); + /* Read in the symlink and follow it. */ - if (ctx->type == GRUB_FSHELP_SYMLINK) + if (ctx->currnode->type == GRUB_FSHELP_SYMLINK) { char *symlink; - const char *next; /* Test if the symlink does not loop. */ if (++ctx->symlinknest == 8) - { - free_node (ctx->currnode, ctx); - free_node (ctx->oldnode, ctx); - ctx->currnode = 0; - ctx->oldnode = 0; - return grub_error (GRUB_ERR_SYMLINK_LOOP, - N_("too deep nesting of symlinks")); - } + return grub_error (GRUB_ERR_SYMLINK_LOOP, + N_("too deep nesting of symlinks")); - symlink = read_symlink (ctx->currnode); - free_node (ctx->currnode, ctx); - ctx->currnode = 0; + symlink = read_symlink (ctx->currnode->node); if (!symlink) - { - free_node (ctx->oldnode, ctx); - ctx->oldnode = 0; - return grub_errno; - } + return grub_errno; /* The symlink is an absolute path, go back to the root inode. */ if (symlink[0] == '/') { - free_node (ctx->oldnode, ctx); - ctx->oldnode = ctx->rootnode; + err = go_to_root (ctx); + if (err) + return err; + } + else + { + /* Get from symlink to containing directory. */ + go_up_a_level (ctx); } + /* Lookup the node the symlink points to. */ - next = ctx->next; - find_file (symlink, ctx->oldnode, &ctx->currnode, - iterate_dir, read_symlink, ctx); - ctx->next = next; - ctx->type = ctx->foundtype; + find_file (symlink, iterate_dir, lookup_file, read_symlink, ctx); grub_free (symlink); if (grub_errno) - { - free_node (ctx->oldnode, ctx); - ctx->oldnode = 0; - return grub_errno; - } + return grub_errno; } - - if (ctx->oldnode != ctx->currnode) - { - free_node (ctx->oldnode, ctx); - ctx->oldnode = 0; - } - - ctx->name = ctx->next; } return grub_error (GRUB_ERR_FILE_NOT_FOUND, N_("file `%s' not found"), ctx->path); } +static grub_err_t +grub_fshelp_find_file_real (const char *path, grub_fshelp_node_t rootnode, + grub_fshelp_node_t *foundnode, + iterate_dir_func iterate_dir, + lookup_file_func lookup_file, + read_symlink_func read_symlink, + enum grub_fshelp_filetype expecttype) +{ + struct grub_fshelp_find_file_ctx ctx = { + .path = path, + .rootnode = rootnode, + .symlinknest = 0, + .currnode = 0 + }; + grub_err_t err; + enum grub_fshelp_filetype foundtype; + char *duppath; + + if (!path || path[0] != '/') + { + return grub_error (GRUB_ERR_BAD_FILENAME, N_("invalid file name `%s'"), path); + } + + err = go_to_root (&ctx); + if (err) + return err; + + duppath = grub_strdup (path); + if (!duppath) + return grub_errno; + err = find_file (duppath, iterate_dir, lookup_file, read_symlink, &ctx); + grub_free (duppath); + if (err) + { + free_stack (&ctx); + return err; + } + + *foundnode = ctx.currnode->node; + foundtype = ctx.currnode->type; + /* Avoid the node being freed. */ + ctx.currnode->node = 0; + free_stack (&ctx); + + /* Check if the node that was found was of the expected type. */ + if (expecttype == GRUB_FSHELP_REG && foundtype != expecttype) + return grub_error (GRUB_ERR_BAD_FILE_TYPE, N_("not a regular file")); + else if (expecttype == GRUB_FSHELP_DIR && foundtype != expecttype) + return grub_error (GRUB_ERR_BAD_FILE_TYPE, N_("not a directory")); + + return 0; +} + /* Lookup the node PATH. The node ROOTNODE describes the root of the directory tree. The node found is returned in FOUNDNODE, which is either a ROOTNODE or a new malloc'ed node. ITERATE_DIR is used to @@ -207,31 +325,23 @@ grub_fshelp_find_file (const char *path, grub_fshelp_node_t rootnode, read_symlink_func read_symlink, enum grub_fshelp_filetype expecttype) { - struct grub_fshelp_find_file_ctx ctx = { - .path = path, - .rootnode = rootnode, - .foundtype = GRUB_FSHELP_DIR, - .symlinknest = 0 - }; - grub_err_t err; + return grub_fshelp_find_file_real (path, rootnode, foundnode, + iterate_dir, NULL, + read_symlink, expecttype); - if (!path || path[0] != '/') - { - grub_error (GRUB_ERR_BAD_FILENAME, N_("invalid file name `%s'"), path); - return grub_errno; - } +} - err = find_file (path, rootnode, foundnode, iterate_dir, read_symlink, &ctx); - if (err) - return err; +grub_err_t +grub_fshelp_find_file_lookup (const char *path, grub_fshelp_node_t rootnode, + grub_fshelp_node_t *foundnode, + lookup_file_func lookup_file, + read_symlink_func read_symlink, + enum grub_fshelp_filetype expecttype) +{ + return grub_fshelp_find_file_real (path, rootnode, foundnode, + NULL, lookup_file, + read_symlink, expecttype); - /* Check if the node that was found was of the expected type. */ - if (expecttype == GRUB_FSHELP_REG && ctx.foundtype != expecttype) - return grub_error (GRUB_ERR_BAD_FILE_TYPE, N_("not a regular file")); - else if (expecttype == GRUB_FSHELP_DIR && ctx.foundtype != expecttype) - return grub_error (GRUB_ERR_BAD_FILE_TYPE, N_("not a directory")); - - return 0; } /* Read LEN bytes from the file NODE on disk DISK into the buffer BUF, diff --git a/include/grub/fshelp.h b/include/grub/fshelp.h index 38923044c..eb1ba4f6c 100644 --- a/include/grub/fshelp.h +++ b/include/grub/fshelp.h @@ -62,6 +62,17 @@ EXPORT_FUNC(grub_fshelp_find_file) (const char *path, enum grub_fshelp_filetype expect); +grub_err_t +EXPORT_FUNC(grub_fshelp_find_file_lookup) (const char *path, + grub_fshelp_node_t rootnode, + grub_fshelp_node_t *foundnode, + grub_err_t (*lookup_file) (grub_fshelp_node_t dir, + const char *name, + grub_fshelp_node_t *foundnode, + enum grub_fshelp_filetype *foundtype), + char *(*read_symlink) (grub_fshelp_node_t node), + enum grub_fshelp_filetype expect); + /* Read LEN bytes from the file NODE on disk DISK into the buffer BUF, beginning with the block POS. READ_HOOK should be set before reading a block from the file. GET_BLOCK is used to translate file From d1d3a60b713f4075d7ed337a6cd942fad690f004 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 27 Jul 2015 12:48:38 +0200 Subject: [PATCH 491/722] BFS: Convert to fshelp. BFS doesn't handle ".." correctly, so convert it to fshelp to reuse the logic. --- grub-core/fs/bfs.c | 221 +++++++++++++++++++++------------------------ 1 file changed, 104 insertions(+), 117 deletions(-) diff --git a/grub-core/fs/bfs.c b/grub-core/fs/bfs.c index 145e77186..d2b490bce 100644 --- a/grub-core/fs/bfs.c +++ b/grub-core/fs/bfs.c @@ -29,6 +29,7 @@ #include #include #include +#include GRUB_MOD_LICENSE ("GPLv3+"); @@ -561,10 +562,10 @@ iterate_in_b_tree (grub_disk_t disk, } static int -bfs_strcmp (const char *a, const char *b, grub_size_t alen, grub_size_t blen) +bfs_strcmp (const char *a, const char *b, grub_size_t alen) { char ac, bc; - while (blen && alen) + while (*b && alen) { if (*a != *b) break; @@ -572,11 +573,10 @@ bfs_strcmp (const char *a, const char *b, grub_size_t alen, grub_size_t blen) a++; b++; alen--; - blen--; } ac = alen ? *a : 0; - bc = blen ? *b : 0; + bc = *b; #ifdef MODE_AFS return (int) (grub_int8_t) ac - (int) (grub_int8_t) bc; @@ -589,7 +589,6 @@ static grub_err_t find_in_b_tree (grub_disk_t disk, const struct grub_bfs_superblock *sb, const struct grub_bfs_inode *ino, const char *name, - grub_size_t name_len, grub_uint64_t * res) { struct grub_bfs_btree_header head; @@ -637,7 +636,7 @@ find_in_b_tree (grub_disk_t disk, end = grub_bfs_to_cpu16 (keylen_idx[(i | (1 << j))]); if (grub_bfs_to_cpu_treehead (node->total_key_len) <= end) end = grub_bfs_to_cpu_treehead (node->total_key_len); - cmp = bfs_strcmp (key_data + start, name, end - start, name_len); + cmp = bfs_strcmp (key_data + start, name, end - start); if (cmp == 0 && level == 0) { *res = grub_bfs_to_cpu64 (key_values[i | (1 << j)].val); @@ -658,7 +657,7 @@ find_in_b_tree (grub_disk_t disk, end = grub_bfs_to_cpu16 (keylen_idx[0]); if (grub_bfs_to_cpu_treehead (node->total_key_len) <= end) end = grub_bfs_to_cpu_treehead (node->total_key_len); - cmp = bfs_strcmp (key_data, name, end, name_len); + cmp = bfs_strcmp (key_data, name, end); if (cmp == 0 && level == 0) { *res = grub_bfs_to_cpu64 (key_values[0].val); @@ -707,127 +706,119 @@ find_in_b_tree (grub_disk_t disk, } } +struct grub_fshelp_node +{ + grub_disk_t disk; + const struct grub_bfs_superblock *sb; + struct grub_bfs_inode ino; +}; + static grub_err_t -hop_level (grub_disk_t disk, - const struct grub_bfs_superblock *sb, - struct grub_bfs_inode *ino, const char *name, - const char *name_end) +lookup_file (grub_fshelp_node_t dir, + const char *name, + grub_fshelp_node_t *foundnode, + enum grub_fshelp_filetype *foundtype) { grub_err_t err; + struct grub_bfs_inode *new_ino; grub_uint64_t res = 0; - if (((grub_bfs_to_cpu32 (ino->mode) & ATTR_TYPE) != ATTR_DIR)) - return grub_error (GRUB_ERR_BAD_FILE_TYPE, N_("not a directory")); - - err = find_in_b_tree (disk, sb, ino, name, name_end - name, &res); + err = find_in_b_tree (dir->disk, dir->sb, &dir->ino, name, &res); if (err) return err; - return grub_disk_read (disk, res - << (grub_bfs_to_cpu32 (sb->log2_bsize) - - GRUB_DISK_SECTOR_BITS), 0, - sizeof (*ino), (char *) ino); + *foundnode = grub_malloc (sizeof (struct grub_fshelp_node)); + if (!*foundnode) + return grub_errno; + + (*foundnode)->disk = dir->disk; + (*foundnode)->sb = dir->sb; + new_ino = &(*foundnode)->ino; + + if (grub_disk_read (dir->disk, res + << (grub_bfs_to_cpu32 (dir->sb->log2_bsize) + - GRUB_DISK_SECTOR_BITS), 0, + sizeof (*new_ino), (char *) new_ino)) + { + grub_free (*foundnode); + return grub_errno; + } + switch (grub_bfs_to_cpu32 (new_ino->mode) & ATTR_TYPE) + { + default: + case ATTR_REG: + *foundtype = GRUB_FSHELP_REG; + break; + case ATTR_DIR: + *foundtype = GRUB_FSHELP_DIR; + break; + case ATTR_LNK: + *foundtype = GRUB_FSHELP_SYMLINK; + break; + } + return GRUB_ERR_NONE; +} + +static char * +read_symlink (grub_fshelp_node_t node) +{ + char *alloc = NULL; + grub_err_t err; + +#ifndef MODE_AFS + if (!(grub_bfs_to_cpu32 (node->ino.flags) & LONG_SYMLINK)) + { + alloc = grub_malloc (sizeof (node->ino.inplace_link) + 1); + if (!alloc) + { + return NULL; + } + grub_memcpy (alloc, node->ino.inplace_link, + sizeof (node->ino.inplace_link)); + alloc[sizeof (node->ino.inplace_link)] = 0; + } + else +#endif + { + grub_size_t symsize = grub_bfs_to_cpu64 (node->ino.size); + alloc = grub_malloc (symsize + 1); + if (!alloc) + return NULL; + err = read_bfs_file (node->disk, node->sb, &node->ino, 0, alloc, symsize, 0, 0); + if (err) + { + grub_free (alloc); + return NULL; + } + alloc[symsize] = 0; + } + + return alloc; } static grub_err_t find_file (const char *path, grub_disk_t disk, - const struct grub_bfs_superblock *sb, struct grub_bfs_inode *ino) + const struct grub_bfs_superblock *sb, struct grub_bfs_inode *ino, + enum grub_fshelp_filetype exptype) { - const char *ptr, *next = path; - char *alloc = NULL; - char *wptr; grub_err_t err; - struct grub_bfs_inode old_ino; - unsigned symlinks_max = 32; + struct grub_fshelp_node root = { + .disk = disk, + .sb = sb, + }; + struct grub_fshelp_node *found; - err = read_extent (disk, sb, &sb->root_dir, 0, 0, ino, - sizeof (*ino)); + err = read_extent (disk, sb, &sb->root_dir, 0, 0, &root.ino, + sizeof (root.ino)); if (err) return err; + err = grub_fshelp_find_file_lookup (path, &root, &found, lookup_file, read_symlink, exptype); + if (!err) + grub_memcpy (ino, &found->ino, sizeof (*ino)); - while (1) - { - ptr = next; - while (*ptr == '/') - ptr++; - if (*ptr == 0) - { - grub_free (alloc); - return GRUB_ERR_NONE; - } - for (next = ptr; *next && *next != '/'; next++); - grub_memcpy (&old_ino, ino, sizeof (old_ino)); - err = hop_level (disk, sb, ino, ptr, next); - if (err) - return err; - - if (((grub_bfs_to_cpu32 (ino->mode) & ATTR_TYPE) == ATTR_LNK)) - { - char *old_alloc = alloc; - if (--symlinks_max == 0) - { - grub_free (alloc); - return grub_error (GRUB_ERR_SYMLINK_LOOP, - N_("too deep nesting of symlinks")); - } - -#ifndef MODE_AFS - if (grub_bfs_to_cpu32 (ino->flags) & LONG_SYMLINK) -#endif - { - grub_size_t symsize = grub_bfs_to_cpu64 (ino->size); - alloc = grub_malloc (grub_strlen (next) - + symsize + 1); - if (!alloc) - { - grub_free (alloc); - return grub_errno; - } - grub_free (old_alloc); - err = read_bfs_file (disk, sb, ino, 0, alloc, symsize, 0, 0); - if (err) - { - grub_free (alloc); - return err; - } - alloc[symsize] = 0; - } -#ifndef MODE_AFS - else - { - alloc = grub_malloc (grub_strlen (next) - + sizeof (ino->inplace_link) + 1); - if (!alloc) - { - grub_free (alloc); - return grub_errno; - } - grub_free (old_alloc); - grub_memcpy (alloc, ino->inplace_link, - sizeof (ino->inplace_link)); - alloc[sizeof (ino->inplace_link)] = 0; - } -#endif - if (alloc[0] == '/') - { - err = read_extent (disk, sb, &sb->root_dir, 0, 0, ino, - sizeof (*ino)); - if (err) - { - grub_free (alloc); - return err; - } - } - else - grub_memcpy (ino, &old_ino, sizeof (old_ino)); - wptr = alloc + grub_strlen (alloc); - if (next) - wptr = grub_stpcpy (wptr, next); - *wptr = 0; - next = alloc; - continue; - } - } + if (&root != found) + grub_free (found); + return err; } static grub_err_t @@ -909,11 +900,9 @@ grub_bfs_dir (grub_device_t device, const char *path, { struct grub_bfs_inode ino; - err = find_file (path, device->disk, &ctx.sb, &ino); + err = find_file (path, device->disk, &ctx.sb, &ino, GRUB_FSHELP_DIR); if (err) return err; - if (((grub_bfs_to_cpu32 (ino.mode) & ATTR_TYPE) != ATTR_DIR)) - return grub_error (GRUB_ERR_BAD_FILE_TYPE, N_("not a directory")); iterate_in_b_tree (device->disk, &ctx.sb, &ino, grub_bfs_dir_iter, &ctx); } @@ -934,11 +923,9 @@ grub_bfs_open (struct grub_file *file, const char *name) { struct grub_bfs_inode ino; struct grub_bfs_data *data; - err = find_file (name, file->device->disk, &sb, &ino); + err = find_file (name, file->device->disk, &sb, &ino, GRUB_FSHELP_REG); if (err) return err; - if (((grub_bfs_to_cpu32 (ino.mode) & ATTR_TYPE) != ATTR_REG)) - return grub_error (GRUB_ERR_BAD_FILE_TYPE, N_("not a regular file")); data = grub_zalloc (sizeof (struct grub_bfs_data)); if (!data) @@ -1034,7 +1021,7 @@ read_bfs_attr (grub_disk_t disk, if (err) return -1; - err = find_in_b_tree (disk, sb, ino, name, grub_strlen (name), &res); + err = find_in_b_tree (disk, sb, ino, name, &res); if (err) return -1; grub_disk_read (disk, res From bfb5b33e968f4bc4bb45d4f4c6724967b8abefdb Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 27 Jul 2015 12:49:26 +0200 Subject: [PATCH 492/722] FAT: Convert to fshelp. exFAT doesn't handle "." and ".." correctly, convert it to fshelp to reuse the same logic. --- grub-core/fs/fat.c | 363 +++++++++++++++++++++------------------------ 1 file changed, 170 insertions(+), 193 deletions(-) diff --git a/grub-core/fs/fat.c b/grub-core/fs/fat.c index 827708c18..aa2145cf2 100644 --- a/grub-core/fs/fat.c +++ b/grub-core/fs/fat.c @@ -31,6 +31,7 @@ #else #include #endif +#include #include GRUB_MOD_LICENSE ("GPLv3+"); @@ -173,8 +174,6 @@ struct grub_fat_data #ifndef MODE_EXFAT grub_uint32_t root_sector; grub_uint32_t num_root_sectors; -#else - int is_contiguous; #endif int cluster_bits; @@ -182,13 +181,22 @@ struct grub_fat_data grub_uint32_t cluster_sector; grub_uint32_t num_clusters; + grub_uint32_t uuid; +}; + +struct grub_fshelp_node { + grub_disk_t disk; + struct grub_fat_data *data; + grub_uint8_t attr; grub_ssize_t file_size; grub_uint32_t file_cluster; grub_uint32_t cur_cluster_num; grub_uint32_t cur_cluster; - grub_uint32_t uuid; +#ifdef MODE_EXFAT + int is_contiguous; +#endif }; static grub_dl_t my_mod; @@ -427,13 +435,6 @@ grub_fat_mount (grub_disk_t disk) (void) magic; #endif - /* Start from the root directory. */ - data->file_cluster = data->root_cluster; - data->cur_cluster_num = ~0U; - data->attr = GRUB_FAT_ATTR_DIRECTORY; -#ifdef MODE_EXFAT - data->is_contiguous = 0; -#endif return data; fail: @@ -444,7 +445,7 @@ grub_fat_mount (grub_disk_t disk) } static grub_ssize_t -grub_fat_read_data (grub_disk_t disk, struct grub_fat_data *data, +grub_fat_read_data (grub_disk_t disk, grub_fshelp_node_t node, grub_disk_read_hook_t read_hook, void *read_hook_data, grub_off_t offset, grub_size_t len, char *buf) { @@ -457,13 +458,13 @@ grub_fat_read_data (grub_disk_t disk, struct grub_fat_data *data, #ifndef MODE_EXFAT /* This is a special case. FAT12 and FAT16 doesn't have the root directory in clusters. */ - if (data->file_cluster == ~0U) + if (node->file_cluster == ~0U) { - size = (data->num_root_sectors << GRUB_DISK_SECTOR_BITS) - offset; + size = (node->data->num_root_sectors << GRUB_DISK_SECTOR_BITS) - offset; if (size > len) size = len; - if (grub_disk_read (disk, data->root_sector, offset, size, buf)) + if (grub_disk_read (disk, node->data->root_sector, offset, size, buf)) return -1; return size; @@ -471,12 +472,12 @@ grub_fat_read_data (grub_disk_t disk, struct grub_fat_data *data, #endif #ifdef MODE_EXFAT - if (data->is_contiguous) + if (node->is_contiguous) { /* Read the data here. */ - sector = (data->cluster_sector - + ((data->file_cluster - 2) - << data->cluster_bits)); + sector = (node->data->cluster_sector + + ((node->file_cluster - 2) + << node->data->cluster_bits)); disk->read_hook = read_hook; disk->read_hook_data = read_hook_data; @@ -491,53 +492,53 @@ grub_fat_read_data (grub_disk_t disk, struct grub_fat_data *data, #endif /* Calculate the logical cluster number and offset. */ - logical_cluster_bits = (data->cluster_bits + logical_cluster_bits = (node->data->cluster_bits + GRUB_DISK_SECTOR_BITS); logical_cluster = offset >> logical_cluster_bits; offset &= (1ULL << logical_cluster_bits) - 1; - if (logical_cluster < data->cur_cluster_num) + if (logical_cluster < node->cur_cluster_num) { - data->cur_cluster_num = 0; - data->cur_cluster = data->file_cluster; + node->cur_cluster_num = 0; + node->cur_cluster = node->file_cluster; } while (len) { - while (logical_cluster > data->cur_cluster_num) + while (logical_cluster > node->cur_cluster_num) { /* Find next cluster. */ grub_uint32_t next_cluster; grub_uint32_t fat_offset; - switch (data->fat_size) + switch (node->data->fat_size) { case 32: - fat_offset = data->cur_cluster << 2; + fat_offset = node->cur_cluster << 2; break; case 16: - fat_offset = data->cur_cluster << 1; + fat_offset = node->cur_cluster << 1; break; default: /* case 12: */ - fat_offset = data->cur_cluster + (data->cur_cluster >> 1); + fat_offset = node->cur_cluster + (node->cur_cluster >> 1); break; } /* Read the FAT. */ - if (grub_disk_read (disk, data->fat_sector, fat_offset, - (data->fat_size + 7) >> 3, + if (grub_disk_read (disk, node->data->fat_sector, fat_offset, + (node->data->fat_size + 7) >> 3, (char *) &next_cluster)) return -1; next_cluster = grub_le_to_cpu32 (next_cluster); - switch (data->fat_size) + switch (node->data->fat_size) { case 16: next_cluster &= 0xFFFF; break; case 12: - if (data->cur_cluster & 1) + if (node->cur_cluster & 1) next_cluster >>= 4; next_cluster &= 0x0FFF; @@ -545,27 +546,27 @@ grub_fat_read_data (grub_disk_t disk, struct grub_fat_data *data, } grub_dprintf ("fat", "fat_size=%d, next_cluster=%u\n", - data->fat_size, next_cluster); + node->data->fat_size, next_cluster); /* Check the end. */ - if (next_cluster >= data->cluster_eof_mark) + if (next_cluster >= node->data->cluster_eof_mark) return ret; - if (next_cluster < 2 || next_cluster >= data->num_clusters) + if (next_cluster < 2 || next_cluster >= node->data->num_clusters) { grub_error (GRUB_ERR_BAD_FS, "invalid cluster %u", next_cluster); return -1; } - data->cur_cluster = next_cluster; - data->cur_cluster_num++; + node->cur_cluster = next_cluster; + node->cur_cluster_num++; } /* Read the data here. */ - sector = (data->cluster_sector - + ((data->cur_cluster - 2) - << data->cluster_bits)); + sector = (node->data->cluster_sector + + ((node->cur_cluster - 2) + << node->data->cluster_bits)); size = (1 << logical_cluster_bits) - offset; if (size > len) size = len; @@ -631,7 +632,7 @@ grub_fat_iterate_fini (struct grub_fat_iterate_context *ctxt) #ifdef MODE_EXFAT static grub_err_t -grub_fat_iterate_dir_next (grub_disk_t disk, struct grub_fat_data *data, +grub_fat_iterate_dir_next (grub_fshelp_node_t node, struct grub_fat_iterate_context *ctxt) { grub_memset (&ctxt->dir, 0, sizeof (ctxt->dir)); @@ -641,7 +642,7 @@ grub_fat_iterate_dir_next (grub_disk_t disk, struct grub_fat_data *data, ctxt->offset += sizeof (dir); - if (grub_fat_read_data (disk, data, 0, 0, ctxt->offset, sizeof (dir), + if (grub_fat_read_data (node->disk, node, 0, 0, ctxt->offset, sizeof (dir), (char *) &dir) != sizeof (dir)) break; @@ -663,7 +664,7 @@ grub_fat_iterate_dir_next (grub_disk_t disk, struct grub_fat_data *data, { struct grub_fat_dir_entry sec; ctxt->offset += sizeof (sec); - if (grub_fat_read_data (disk, data, 0, 0, + if (grub_fat_read_data (node->disk, node, 0, 0, ctxt->offset, sizeof (sec), (char *) &sec) != sizeof (sec)) break; @@ -727,7 +728,7 @@ grub_fat_iterate_dir_next (grub_disk_t disk, struct grub_fat_data *data, #else static grub_err_t -grub_fat_iterate_dir_next (grub_disk_t disk, struct grub_fat_data *data, +grub_fat_iterate_dir_next (grub_fshelp_node_t node, struct grub_fat_iterate_context *ctxt) { char *filep = 0; @@ -742,7 +743,7 @@ grub_fat_iterate_dir_next (grub_disk_t disk, struct grub_fat_data *data, ctxt->offset += sizeof (ctxt->dir); /* Read a directory entry. */ - if (grub_fat_read_data (disk, data, 0, 0, + if (grub_fat_read_data (node->disk, node, 0, 0, ctxt->offset, sizeof (ctxt->dir), (char *) &ctxt->dir) != sizeof (ctxt->dir) || ctxt->dir.name[0] == 0) @@ -853,84 +854,20 @@ grub_fat_iterate_dir_next (grub_disk_t disk, struct grub_fat_data *data, #endif -/* Find the underlying directory or file in PATH and return the - next path. If there is no next path or an error occurs, return NULL. - If HOOK is specified, call it with each file name. */ -static char * -grub_fat_find_dir (grub_disk_t disk, struct grub_fat_data *data, - const char *path, const char *origpath, - grub_fs_dir_hook_t hook, void *hook_data) +static grub_err_t lookup_file (grub_fshelp_node_t node, + const char *name, + grub_fshelp_node_t *foundnode, + enum grub_fshelp_filetype *foundtype) { - char *dirname, *dirp; - int call_hook; - int found = 0; - struct grub_fat_iterate_context ctxt; grub_err_t err; - - if (! (data->attr & GRUB_FAT_ATTR_DIRECTORY)) - { - grub_error (GRUB_ERR_BAD_FILE_TYPE, N_("not a directory")); - return 0; - } - - do - { - /* Extract a directory name. */ - while (*path == '/') - path++; - - /* Emulate special "." and ".." entries in root directory */ - if (data->file_cluster == data->root_cluster) - { - if (*path != '.') - break; - if (!path[1] || path[1] == '/') - { - path++; - continue; - } - if (path[1] == '.' && (!path[2] || path[2] == '/')) - { - path += 2; - continue; - } - } - break; - } - while (1); - - dirp = grub_strchr (path, '/'); - if (dirp) - { - unsigned len = dirp - path; - - dirname = grub_malloc (len + 1); - if (! dirname) - goto fail; - - grub_memcpy (dirname, path, len); - dirname[len] = '\0'; - } - else - /* This is actually a file. */ - dirname = grub_strdup (path); - - call_hook = (! dirp && hook); + struct grub_fat_iterate_context ctxt; err = grub_fat_iterate_init (&ctxt); if (err) - { - grub_free (dirname); - return 0; - } + return err; - while (!(err = grub_fat_iterate_dir_next (disk, data, &ctxt))) + while (!(err = grub_fat_iterate_dir_next (node, &ctxt))) { - struct grub_dirhook_info info; - grub_memset (&info, 0, sizeof (info)); - - info.dir = !! (ctxt.dir.attr & GRUB_FAT_ATTR_DIRECTORY); - info.case_insensitive = 1; #ifdef MODE_EXFAT if (!ctxt.dir.have_stream) @@ -939,36 +876,33 @@ grub_fat_find_dir (grub_disk_t disk, struct grub_fat_data *data, if (ctxt.dir.attr & GRUB_FAT_ATTR_VOLUME_ID) continue; #endif - if (*dirname == '\0' && call_hook) - { - if (hook (ctxt.filename, &info, hook_data)) - break; - else - continue; - } - if (grub_strcasecmp (dirname, ctxt.filename) == 0) + if (grub_strcasecmp (name, ctxt.filename) == 0) { - found = 1; - data->attr = ctxt.dir.attr; + *foundnode = grub_malloc (sizeof (struct grub_fshelp_node)); + if (!*foundnode) + return grub_errno; + (*foundnode)->attr = ctxt.dir.attr; #ifdef MODE_EXFAT - data->file_size = ctxt.dir.file_size; - data->file_cluster = ctxt.dir.first_cluster; - data->is_contiguous = ctxt.dir.is_contiguous; + (*foundnode)->file_size = ctxt.dir.file_size; + (*foundnode)->file_cluster = ctxt.dir.first_cluster; + (*foundnode)->is_contiguous = ctxt.dir.is_contiguous; #else - data->file_size = grub_le_to_cpu32 (ctxt.dir.file_size); - data->file_cluster = ((grub_le_to_cpu16 (ctxt.dir.first_cluster_high) << 16) + (*foundnode)->file_size = grub_le_to_cpu32 (ctxt.dir.file_size); + (*foundnode)->file_cluster = ((grub_le_to_cpu16 (ctxt.dir.first_cluster_high) << 16) | grub_le_to_cpu16 (ctxt.dir.first_cluster_low)); /* If directory points to root, starting cluster is 0 */ - if (!data->file_cluster) - data->file_cluster = data->root_cluster; + if (!(*foundnode)->file_cluster) + (*foundnode)->file_cluster = node->data->root_cluster; #endif - data->cur_cluster_num = ~0U; + (*foundnode)->cur_cluster_num = ~0U; + (*foundnode)->data = node->data; + (*foundnode)->disk = node->disk; - if (call_hook) - hook (ctxt.filename, &info, hook_data); + *foundtype = ((*foundnode)->attr & GRUB_FAT_ATTR_DIRECTORY) ? GRUB_FSHELP_DIR : GRUB_FSHELP_REG; - break; + grub_fat_iterate_fini (&ctxt); + return GRUB_ERR_NONE; } } @@ -976,13 +910,8 @@ grub_fat_find_dir (grub_disk_t disk, struct grub_fat_data *data, if (err == GRUB_ERR_EOF) err = 0; - if (grub_errno == GRUB_ERR_NONE && ! found && !call_hook) - grub_error (GRUB_ERR_FILE_NOT_FOUND, N_("file `%s' not found"), origpath); + return err; - fail: - grub_free (dirname); - - return found ? dirp : 0; } static grub_err_t @@ -991,9 +920,9 @@ grub_fat_dir (grub_device_t device, const char *path, grub_fs_dir_hook_t hook, { struct grub_fat_data *data = 0; grub_disk_t disk = device->disk; - grub_size_t len; - char *dirname = 0; - char *p; + grub_fshelp_node_t found = NULL; + grub_err_t err; + struct grub_fat_iterate_context ctxt; grub_dl_ref (my_mod); @@ -1001,27 +930,53 @@ grub_fat_dir (grub_device_t device, const char *path, grub_fs_dir_hook_t hook, if (! data) goto fail; - /* Make sure that DIRNAME terminates with '/'. */ - len = grub_strlen (path); - dirname = grub_malloc (len + 1 + 1); - if (! dirname) - goto fail; - grub_memcpy (dirname, path, len); - p = dirname + len; - if (path[len - 1] != '/') - *p++ = '/'; - *p = '\0'; - p = dirname; + struct grub_fshelp_node root = { + .data = data, + .disk = disk, + .attr = GRUB_FAT_ATTR_DIRECTORY, + .file_size = 0, + .file_cluster = data->root_cluster, + .cur_cluster_num = ~0U, + .cur_cluster = 0, +#ifdef MODE_EXFAT + .is_contiguous = 0, +#endif + }; - do + err = grub_fshelp_find_file_lookup (path, &root, &found, lookup_file, NULL, GRUB_FSHELP_DIR); + if (err) + goto fail; + + err = grub_fat_iterate_init (&ctxt); + if (err) + goto fail; + + while (!(err = grub_fat_iterate_dir_next (found, &ctxt))) { - p = grub_fat_find_dir (disk, data, p, path, hook, hook_data); + struct grub_dirhook_info info; + grub_memset (&info, 0, sizeof (info)); + + info.dir = !! (ctxt.dir.attr & GRUB_FAT_ATTR_DIRECTORY); + info.case_insensitive = 1; +#ifdef MODE_EXFAT + if (!ctxt.dir.have_stream) + continue; +#else + if (ctxt.dir.attr & GRUB_FAT_ATTR_VOLUME_ID) + continue; +#endif + + if (hook (ctxt.filename, &info, hook_data)) + break; } - while (p && grub_errno == GRUB_ERR_NONE); + grub_fat_iterate_fini (&ctxt); + if (err == GRUB_ERR_EOF) + err = 0; fail: + if (found != &root) + grub_free (found); - grub_free (dirname); grub_free (data); grub_dl_unref (my_mod); @@ -1033,35 +988,43 @@ static grub_err_t grub_fat_open (grub_file_t file, const char *name) { struct grub_fat_data *data = 0; - char *p = (char *) name; + grub_fshelp_node_t found = NULL; + grub_err_t err; + grub_disk_t disk = file->device->disk; grub_dl_ref (my_mod); - data = grub_fat_mount (file->device->disk); + data = grub_fat_mount (disk); if (! data) goto fail; - do - { - p = grub_fat_find_dir (file->device->disk, data, p, name, 0, 0); - if (grub_errno != GRUB_ERR_NONE) - goto fail; - } - while (p); + struct grub_fshelp_node root = { + .data = data, + .disk = disk, + .attr = GRUB_FAT_ATTR_DIRECTORY, + .file_size = 0, + .file_cluster = data->root_cluster, + .cur_cluster_num = ~0U, + .cur_cluster = 0, +#ifdef MODE_EXFAT + .is_contiguous = 0, +#endif + }; - if (data->attr & GRUB_FAT_ATTR_DIRECTORY) - { - grub_error (GRUB_ERR_BAD_FILE_TYPE, N_("not a regular file")); - goto fail; - } + err = grub_fshelp_find_file_lookup (name, &root, &found, lookup_file, NULL, GRUB_FSHELP_REG); + if (err) + goto fail; - file->data = data; - file->size = data->file_size; + file->data = found; + file->size = found->file_size; return GRUB_ERR_NONE; fail: + if (found != &root) + grub_free (found); + grub_free (data); grub_dl_unref (my_mod); @@ -1080,7 +1043,10 @@ grub_fat_read (grub_file_t file, char *buf, grub_size_t len) static grub_err_t grub_fat_close (grub_file_t file) { - grub_free (file->data); + grub_fshelp_node_t node = file->data; + + grub_free (node->data); + grub_free (node); grub_dl_unref (my_mod); @@ -1093,20 +1059,29 @@ grub_fat_label (grub_device_t device, char **label) { struct grub_fat_dir_entry dir; grub_ssize_t offset = -sizeof(dir); - struct grub_fat_data *data; grub_disk_t disk = device->disk; + struct grub_fshelp_node root = { + .disk = disk, + .attr = GRUB_FAT_ATTR_DIRECTORY, + .file_size = 0, + .cur_cluster_num = ~0U, + .cur_cluster = 0, + .is_contiguous = 0, + }; - data = grub_fat_mount (disk); - if (! data) + root.data = grub_fat_mount (disk); + if (! root.data) return grub_errno; + root.file_cluster = root.data->root_cluster; + *label = NULL; while (1) { offset += sizeof (dir); - if (grub_fat_read_data (disk, data, 0, 0, + if (grub_fat_read_data (disk, &root, 0, 0, offset, sizeof (dir), (char *) &dir) != sizeof (dir)) break; @@ -1126,7 +1101,7 @@ grub_fat_label (grub_device_t device, char **label) * GRUB_MAX_UTF8_PER_UTF16 + 1); if (!*label) { - grub_free (data); + grub_free (root.data); return grub_errno; } chc = dir.type_specific.volume_label.character_count; @@ -1138,7 +1113,7 @@ grub_fat_label (grub_device_t device, char **label) } } - grub_free (data); + grub_free (root.data); return grub_errno; } @@ -1147,30 +1122,32 @@ grub_fat_label (grub_device_t device, char **label) static grub_err_t grub_fat_label (grub_device_t device, char **label) { - struct grub_fat_data *data; grub_disk_t disk = device->disk; grub_err_t err; struct grub_fat_iterate_context ctxt; + struct grub_fshelp_node root = { + .disk = disk, + .attr = GRUB_FAT_ATTR_DIRECTORY, + .file_size = 0, + .cur_cluster_num = ~0U, + .cur_cluster = 0, + }; *label = 0; grub_dl_ref (my_mod); - data = grub_fat_mount (disk); - if (! data) + root.data = grub_fat_mount (disk); + if (! root.data) goto fail; - if (! (data->attr & GRUB_FAT_ATTR_DIRECTORY)) - { - grub_error (GRUB_ERR_BAD_FILE_TYPE, N_("not a directory")); - goto fail; - } + root.file_cluster = root.data->root_cluster; err = grub_fat_iterate_init (&ctxt); if (err) goto fail; - while (!(err = grub_fat_iterate_dir_next (disk, data, &ctxt))) + while (!(err = grub_fat_iterate_dir_next (&root, &ctxt))) if ((ctxt.dir.attr & ~GRUB_FAT_ATTR_ARCHIVE) == GRUB_FAT_ATTR_VOLUME_ID) { *label = grub_strdup (ctxt.filename); @@ -1183,7 +1160,7 @@ grub_fat_label (grub_device_t device, char **label) grub_dl_unref (my_mod); - grub_free (data); + grub_free (root.data); return grub_errno; } From 5fb1e859f71c33bec25d7a7f5926e80e0019b37c Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 27 Jul 2015 12:50:22 +0200 Subject: [PATCH 493/722] HFS: Convert to fshelp. HFS doesn't handle "." and ".." properly. Convert it to fshelp to reuse the logic. --- grub-core/fs/hfs.c | 177 ++++++++++++++++++++------------------------- 1 file changed, 78 insertions(+), 99 deletions(-) diff --git a/grub-core/fs/hfs.c b/grub-core/fs/hfs.c index 06cf0c7ab..0ebc71b62 100644 --- a/grub-core/fs/hfs.c +++ b/grub-core/fs/hfs.c @@ -29,6 +29,7 @@ #include #include #include +#include GRUB_MOD_LICENSE ("GPLv3+"); @@ -1125,90 +1126,81 @@ utf8_to_macroman (grub_uint8_t *to, const char *from) return optr - to; } +union grub_hfs_anyrec { + struct grub_hfs_filerec frec; + struct grub_hfs_dirrec dir; +}; + +struct grub_fshelp_node +{ + struct grub_hfs_data *data; + union grub_hfs_anyrec fdrec; + grub_uint32_t inode; +}; + +static grub_err_t +lookup_file (grub_fshelp_node_t dir, + const char *name, + grub_fshelp_node_t *foundnode, + enum grub_fshelp_filetype *foundtype) +{ + struct grub_hfs_catalog_key key; + grub_ssize_t slen; + union grub_hfs_anyrec fdrec; + + key.parent_dir = grub_cpu_to_be32 (dir->inode); + slen = utf8_to_macroman (key.str, name); + if (slen < 0) + /* Not found */ + return GRUB_ERR_NONE; + key.strlen = slen; + + /* Lookup this node. */ + if (! grub_hfs_find_node (dir->data, (char *) &key, dir->data->cat_root, + 0, (char *) &fdrec.frec, sizeof (fdrec.frec))) + /* Not found */ + return GRUB_ERR_NONE; + + *foundnode = grub_malloc (sizeof (struct grub_fshelp_node)); + if (!*foundnode) + return grub_errno; + + (*foundnode)->inode = grub_be_to_cpu32 (fdrec.dir.dirid); + (*foundnode)->fdrec = fdrec; + (*foundnode)->data = dir->data; + *foundtype = (fdrec.frec.type == GRUB_HFS_FILETYPE_DIR) ? GRUB_FSHELP_DIR : GRUB_FSHELP_REG; + return GRUB_ERR_NONE; +} /* Find a file or directory with the pathname PATH in the filesystem DATA. Return the file record in RETDATA when it is non-zero. Return the directory number in RETINODE when it is non-zero. */ static grub_err_t grub_hfs_find_dir (struct grub_hfs_data *data, const char *path, - struct grub_hfs_filerec *retdata, int *retinode) + grub_fshelp_node_t *found, + enum grub_fshelp_filetype exptype) { - int inode = data->rootdir; - char *next; - char *origpath; - union { - struct grub_hfs_filerec frec; - struct grub_hfs_dirrec dir; - } fdrec; - - fdrec.frec.type = GRUB_HFS_FILETYPE_DIR; - - if (path[0] != '/') - { - grub_error (GRUB_ERR_BAD_FILENAME, N_("invalid file name `%s'"), path); - return 0; + struct grub_fshelp_node root = { + .data = data, + .inode = data->rootdir, + .fdrec = { + .frec = { + .type = GRUB_HFS_FILETYPE_DIR + } } + }; + grub_err_t err; - origpath = grub_strdup (path); - if (!origpath) - return grub_errno; + err = grub_fshelp_find_file_lookup (path, &root, found, lookup_file, NULL, exptype); - path = origpath; - while (*path == '/') - path++; - - while (path && grub_strlen (path)) + if (&root == *found) { - grub_ssize_t slen; - if (fdrec.frec.type != GRUB_HFS_FILETYPE_DIR) - { - grub_error (GRUB_ERR_BAD_FILE_TYPE, N_("not a directory")); - goto fail; - } - - /* Isolate a part of the path. */ - next = grub_strchr (path, '/'); - if (next) - { - while (*next == '/') - *(next++) = '\0'; - } - - struct grub_hfs_catalog_key key; - - key.parent_dir = grub_cpu_to_be32 (inode); - slen = utf8_to_macroman (key.str, path); - if (slen < 0) - { - grub_error (GRUB_ERR_FILE_NOT_FOUND, N_("file `%s' not found"), path); - goto fail; - } - key.strlen = slen; - - /* Lookup this node. */ - if (! grub_hfs_find_node (data, (char *) &key, data->cat_root, - 0, (char *) &fdrec.frec, sizeof (fdrec.frec))) - { - grub_error (GRUB_ERR_FILE_NOT_FOUND, N_("file `%s' not found"), origpath); - goto fail; - } - - if (grub_errno) - goto fail; - - inode = grub_be_to_cpu32 (fdrec.dir.dirid); - path = next; + *found = grub_malloc (sizeof (root)); + if (!*found) + return grub_errno; + grub_memcpy (*found, &root, sizeof (root)); } - - if (retdata) - grub_memcpy (retdata, &fdrec.frec, sizeof (fdrec.frec)); - - if (retinode) - *retinode = inode; - - fail: - grub_free (origpath); - return grub_errno; + return err; } struct grub_hfs_dir_hook_ctx @@ -1266,16 +1258,14 @@ static grub_err_t grub_hfs_dir (grub_device_t device, const char *path, grub_fs_dir_hook_t hook, void *hook_data) { - int inode; - struct grub_hfs_data *data; - struct grub_hfs_filerec frec; struct grub_hfs_dir_hook_ctx ctx = { .hook = hook, .hook_data = hook_data }; - + grub_fshelp_node_t found = NULL; + grub_dl_ref (my_mod); data = grub_hfs_mount (device->disk); @@ -1283,18 +1273,13 @@ grub_hfs_dir (grub_device_t device, const char *path, grub_fs_dir_hook_t hook, goto fail; /* First the directory ID for the directory. */ - if (grub_hfs_find_dir (data, path, &frec, &inode)) + if (grub_hfs_find_dir (data, path, &found, GRUB_FSHELP_DIR)) goto fail; - if (frec.type != GRUB_HFS_FILETYPE_DIR) - { - grub_error (GRUB_ERR_BAD_FILE_TYPE, N_("not a directory")); - goto fail; - } - - grub_hfs_iterate_dir (data, data->cat_root, inode, grub_hfs_dir_hook, &ctx); + grub_hfs_iterate_dir (data, data->cat_root, found->inode, grub_hfs_dir_hook, &ctx); fail: + grub_free (found); grub_free (data); grub_dl_unref (my_mod); @@ -1308,8 +1293,8 @@ static grub_err_t grub_hfs_open (struct grub_file *file, const char *name) { struct grub_hfs_data *data; - struct grub_hfs_filerec frec; - + grub_fshelp_node_t found = NULL; + grub_dl_ref (my_mod); data = grub_hfs_mount (file->device->disk); @@ -1320,29 +1305,23 @@ grub_hfs_open (struct grub_file *file, const char *name) return grub_errno; } - if (grub_hfs_find_dir (data, name, &frec, 0)) + if (grub_hfs_find_dir (data, name, &found, GRUB_FSHELP_REG)) { grub_free (data); grub_dl_unref (my_mod); return grub_errno; } - if (frec.type != GRUB_HFS_FILETYPE_FILE) - { - grub_free (data); - grub_error (GRUB_ERR_BAD_FILE_TYPE, N_("not a regular file")); - grub_dl_unref (my_mod); - return grub_errno; - } - - grub_memcpy (data->extents, frec.extents, sizeof (grub_hfs_datarecord_t)); - file->size = grub_be_to_cpu32 (frec.size); - data->size = grub_be_to_cpu32 (frec.size); - data->fileid = grub_be_to_cpu32 (frec.fileid); + grub_memcpy (data->extents, found->fdrec.frec.extents, sizeof (grub_hfs_datarecord_t)); + file->size = grub_be_to_cpu32 (found->fdrec.frec.size); + data->size = grub_be_to_cpu32 (found->fdrec.frec.size); + data->fileid = grub_be_to_cpu32 (found->fdrec.frec.fileid); file->offset = 0; file->data = data; + grub_free (found); + return 0; } From d3b464a7c0a9acb7d0f7202a7fa45ac29a014692 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 27 Jul 2015 13:19:02 +0200 Subject: [PATCH 494/722] archelp: Never pass NULL as mtime. Moves complexity from fs code (NULL check) to common code (passing non-NULL). --- grub-core/fs/archelp.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/grub-core/fs/archelp.c b/grub-core/fs/archelp.c index 707f9a658..0cf544f6f 100644 --- a/grub-core/fs/archelp.c +++ b/grub-core/fs/archelp.c @@ -249,9 +249,10 @@ grub_archelp_open (struct grub_archelp_data *data, while (1) { grub_uint32_t mode; + grub_int32_t mtime; int restart; - if (arcops->find_file (data, &fn, NULL, &mode)) + if (arcops->find_file (data, &fn, &mtime, &mode)) goto fail; if (mode == GRUB_ARCHELP_ATTR_END) From 72fc110d95129410443b898e931ff7a1db75312e Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Tue, 28 Jul 2015 01:51:14 +0200 Subject: [PATCH 495/722] ahci: Ensure that bus mastering is set. Fixes ahci_test failing on several platforms. --- grub-core/disk/ahci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/disk/ahci.c b/grub-core/disk/ahci.c index f4725e8c1..fc640d5d4 100644 --- a/grub-core/disk/ahci.c +++ b/grub-core/disk/ahci.c @@ -195,7 +195,7 @@ grub_ahci_pciinit (grub_pci_device_t dev, addr = grub_pci_make_address (dev, GRUB_PCI_REG_COMMAND); grub_pci_write_word (addr, grub_pci_read_word (addr) - | GRUB_PCI_COMMAND_MEM_ENABLED); + | GRUB_PCI_COMMAND_MEM_ENABLED | GRUB_PCI_COMMAND_BUS_MASTER); hba = grub_pci_device_map_range (dev, bar & GRUB_PCI_ADDR_MEM_MASK, sizeof (*hba)); From d7a85e69e0c00a6a2ddb2fca2261e0aed8b1d724 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sun, 9 Aug 2015 16:28:12 +0300 Subject: [PATCH 496/722] linguas.sh: fix error when removing non-existing autogenerated files --- linguas.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/linguas.sh b/linguas.sh index 1de42ba2d..e57f50dc6 100755 --- a/linguas.sh +++ b/linguas.sh @@ -6,7 +6,7 @@ autogenerated="en@quot en@hebrew de@hebrew en@cyrillic en@greek en@arabic en@pig for x in $autogenerated; do - rm "po/$x.po"; + rm -f "po/$x.po"; done From 4fe8e6d4a1279b1840171d8e797d911cd8443333 Mon Sep 17 00:00:00 2001 From: Josef Bacik Date: Thu, 6 Aug 2015 10:49:46 -0700 Subject: [PATCH 497/722] efinet: handle get_status() on buggy firmware properly The EFI spec indicates that get_status() should return the address of the buffer we passed into transmit to indicate the the buffer was transmitted. However we have boxes where the firmware returns some arbitrary address instead, which makes grub think that we've not sent anything. So since we have the SNP stuff opened in exclusive mode just assume any non-NULL txbuf means that our transmit occurred properly. This makes grub able to do its networking stuff properly on our broken firmware. Thanks, cc: Peter Jones Signed-off-by: Josef Bacik --- grub-core/net/drivers/efi/efinet.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/grub-core/net/drivers/efi/efinet.c b/grub-core/net/drivers/efi/efinet.c index 70b26af94..5388f952b 100644 --- a/grub-core/net/drivers/efi/efinet.c +++ b/grub-core/net/drivers/efi/efinet.c @@ -47,19 +47,19 @@ send_card_buffer (struct grub_net_card *dev, if (st != GRUB_EFI_SUCCESS) return grub_error (GRUB_ERR_IO, N_("couldn't send network packet")); - if (txbuf == dev->txbuf) + /* + Some buggy firmware could return an arbitrary address instead of the + txbuf address we trasmitted, so just check that txbuf is non NULL + for success. This is ok because we open the SNP protocol in + exclusive mode so we know we're the only ones transmitting on this + box and since we only transmit one packet at a time we know our + transmit was successfull. + */ + if (txbuf) { dev->txbusy = 0; break; } - if (txbuf) - { - st = efi_call_7 (net->transmit, net, 0, dev->last_pkt_size, - dev->txbuf, NULL, NULL, NULL); - if (st != GRUB_EFI_SUCCESS) - return grub_error (GRUB_ERR_IO, - N_("couldn't send network packet")); - } if (limit_time < grub_get_time_ms ()) return grub_error (GRUB_ERR_TIMEOUT, N_("couldn't send network packet")); @@ -84,8 +84,9 @@ send_card_buffer (struct grub_net_card *dev, we run in the GRUB_ERR_TIMEOUT case above. Perhaps a timeout in the FW has discarded the recycle buffer. */ + txbuf = NULL; st = efi_call_3 (net->get_status, net, 0, &txbuf); - dev->txbusy = !(st == GRUB_EFI_SUCCESS && txbuf == dev->txbuf); + dev->txbusy = !(st == GRUB_EFI_SUCCESS && txbuf); return GRUB_ERR_NONE; } From ba218c1c10833092b14177896c10e48715c836fe Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Thu, 13 Aug 2015 20:20:39 +0300 Subject: [PATCH 498/722] net: do not try to load protocol module via itself Otherwise we get infinite recursion. Closes: 45729 --- grub-core/net/net.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/grub-core/net/net.c b/grub-core/net/net.c index 21a4e94d1..a0472d5d4 100644 --- a/grub-core/net/net.c +++ b/grub-core/net/net.c @@ -1341,6 +1341,43 @@ grub_net_open_real (const char *name) } if (try == 0) { + const char *prefix, *root; + char *prefdev, *comma; + int skip = 0; + grub_size_t devlen; + + /* Do not attempt to load module if it requires protocol provided + by this module - it results in infinite recursion. Just continue, + fail and cleanup on next iteration. + */ + prefix = grub_env_get ("prefix"); + if (!prefix) + continue; + + prefdev = grub_file_get_device_name (prefix); + if (!prefdev) + { + root = grub_env_get ("root"); + if (!root) + continue; + prefdev = grub_strdup (root); + if (!prefdev) + continue; + } + + comma = grub_strchr (prefdev, ','); + if (comma) + *comma = '\0'; + devlen = grub_strlen (prefdev); + + if (protnamelen == devlen && grub_memcmp (prefdev, protname, devlen) == 0) + skip = 1; + + grub_free (prefdev); + + if (skip) + continue; + if (sizeof ("http") - 1 == protnamelen && grub_memcmp ("http", protname, protnamelen) == 0) { From 8e3d2c80ed1b9c2d150910cf3611d7ecb7d3dc6f Mon Sep 17 00:00:00 2001 From: Felix Zielcke Date: Sat, 22 Aug 2015 21:22:41 +0200 Subject: [PATCH 499/722] disk/ldm, partmap/msdos.c: fix spelling error --- grub-core/disk/ldm.c | 2 +- grub-core/partmap/msdos.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/grub-core/disk/ldm.c b/grub-core/disk/ldm.c index 8075f2a9e..0f978ad05 100644 --- a/grub-core/disk/ldm.c +++ b/grub-core/disk/ldm.c @@ -963,7 +963,7 @@ grub_util_ldm_embed (struct grub_disk *disk, unsigned int *nsectors, if (embed_type != GRUB_EMBED_PCBIOS) return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, - "LDM curently supports only PC-BIOS embedding"); + "LDM currently supports only PC-BIOS embedding"); if (disk->partition) return grub_error (GRUB_ERR_BUG, "disk isn't LDM"); pv = grub_diskfilter_get_pv_from_disk (disk, &vg); diff --git a/grub-core/partmap/msdos.c b/grub-core/partmap/msdos.c index 46c406bff..6d4b455a1 100644 --- a/grub-core/partmap/msdos.c +++ b/grub-core/partmap/msdos.c @@ -249,7 +249,7 @@ pc_partition_map_embed (struct grub_disk *disk, unsigned int *nsectors, if (embed_type != GRUB_EMBED_PCBIOS) return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, - "PC-style partitions curently support " + "PC-style partitions currently support " "only PC-BIOS embedding"); if (disk->partition) From c93d3e694713b8230fa2cf88414fabe005b56782 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sun, 13 Sep 2015 20:12:31 +0300 Subject: [PATCH 500/722] cryptodisk: strip parenthesis from backing device name Otherwise subsequent disk open fails. Reported-By: Klemens Nanni --- grub-core/disk/cryptodisk.c | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/grub-core/disk/cryptodisk.c b/grub-core/disk/cryptodisk.c index 82a3dcb63..85d68e3b6 100644 --- a/grub-core/disk/cryptodisk.c +++ b/grub-core/disk/cryptodisk.c @@ -964,33 +964,43 @@ grub_cmd_cryptomount (grub_extcmd_context_t ctxt, int argc, char **args) grub_disk_t disk; grub_cryptodisk_t dev; char *diskname; - char *disklast; + char *disklast = NULL; + grub_size_t len; search_uuid = NULL; check_boot = state[2].set; diskname = args[0]; - if (diskname[0] == '(' && *(disklast = &diskname[grub_strlen (diskname) - 1]) == ')') + len = grub_strlen (diskname); + if (len && diskname[0] == '(' && diskname[len - 1] == ')') { + disklast = &diskname[len - 1]; *disklast = '\0'; - disk = grub_disk_open (diskname + 1); - *disklast = ')'; + diskname++; } - else - disk = grub_disk_open (diskname); + + disk = grub_disk_open (diskname); if (!disk) - return grub_errno; + { + if (disklast) + *disklast = ')'; + return grub_errno; + } dev = grub_cryptodisk_get_by_source_disk (disk); if (dev) { grub_dprintf ("cryptodisk", "already mounted as crypto%lu\n", dev->id); grub_disk_close (disk); + if (disklast) + *disklast = ')'; return GRUB_ERR_NONE; } - err = grub_cryptodisk_scan_device_real (args[0], disk); + err = grub_cryptodisk_scan_device_real (diskname, disk); grub_disk_close (disk); + if (disklast) + *disklast = ')'; return err; } From 8cb4c4edbe84fe455455dd26d5763541c2824098 Mon Sep 17 00:00:00 2001 From: Eric Snowberg Date: Tue, 6 Oct 2015 13:21:43 -0400 Subject: [PATCH 501/722] sparc64 - use correct drive name within grub_util_sparc_setup Incorrect drive name was being passed into grub_util_sparc_setup, causing the grub-install to fail. Signed-off-by: Eric Snowberg --- util/grub-install.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/grub-install.c b/util/grub-install.c index df5c7e520..eabd6de4d 100644 --- a/util/grub-install.c +++ b/util/grub-install.c @@ -1698,7 +1698,7 @@ main (int argc, char *argv[]) /* Now perform the installation. */ if (install_bootsector) grub_util_sparc_setup (platdir, "boot.img", "core.img", - install_device, force, + install_drive, force, fs_probe, allow_floppy, 0 /* unused */ ); break; From ee67bcf31ec946848b2a186676f18786c45b4035 Mon Sep 17 00:00:00 2001 From: Stanislav Kholmanskikh Date: Mon, 7 Sep 2015 14:13:11 +0300 Subject: [PATCH 502/722] ofnet: Do not set SUFFIX for sun4v network devices sun4v vnet devices do not implement the support of duplex and speed instance attributes. An attempt to open such a device with the attributes will fail: ok select net:speed=auto,duplex=auto Unknown key 'speed' Unknown key 'duplex' Manual Configuration: Host IP, boot server and filename must be specified WARNING: /virtual-devices@100/channel-devices@200/network@0: Can't open OBP standard TFTP package Can't open device ok Therefore, let's not set SUFFIX for such devices. Signed-off-by: Stanislav Kholmanskikh --- grub-core/net/drivers/ieee1275/ofnet.c | 41 ++++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 2 deletions(-) diff --git a/grub-core/net/drivers/ieee1275/ofnet.c b/grub-core/net/drivers/ieee1275/ofnet.c index eea8e71d3..eff9085ed 100644 --- a/grub-core/net/drivers/ieee1275/ofnet.c +++ b/grub-core/net/drivers/ieee1275/ofnet.c @@ -305,6 +305,7 @@ search_net_devices (struct grub_ieee1275_devalias *alias) grub_uint64_t prop; grub_uint8_t *pprop; char *shortname; + char need_suffix = 1; if (grub_strcmp (alias->type, "network") != 0) return 0; @@ -325,7 +326,43 @@ search_net_devices (struct grub_ieee1275_devalias *alias) #define SUFFIX ":speed=auto,duplex=auto,1.1.1.1,dummy,1.1.1.1,1.1.1.1,5,5,1.1.1.1,512" - if (!grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_NO_OFNET_SUFFIX)) + if (grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_NO_OFNET_SUFFIX)) + need_suffix = 0; + + /* sun4v vnet devices do not support setting duplex/speed */ + { + char *ptr; + + grub_ieee1275_finddevice (alias->path, &devhandle); + + grub_ieee1275_get_property_length (devhandle, "compatible", &prop_size); + if (prop_size > 0) + { + pprop = grub_malloc (prop_size); + if (!pprop) + { + grub_free (card); + grub_free (ofdata); + grub_print_error (); + return 1; + } + + if (!grub_ieee1275_get_property (devhandle, "compatible", + pprop, prop_size, NULL)) + { + for (ptr = (char *) pprop; ptr - (char *) pprop < prop_size; + ptr += grub_strlen (ptr) + 1) + { + if (!grub_strcmp(ptr, "SUNW,sun4v-network")) + need_suffix = 0; + } + } + + grub_free (pprop); + } + } + + if (need_suffix) ofdata->path = grub_malloc (grub_strlen (alias->path) + sizeof (SUFFIX)); else ofdata->path = grub_malloc (grub_strlen (alias->path) + 1); @@ -335,7 +372,7 @@ search_net_devices (struct grub_ieee1275_devalias *alias) return 0; } ofdata->suffix = grub_stpcpy (ofdata->path, alias->path); - if (!grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_NO_OFNET_SUFFIX)) + if (need_suffix) grub_memcpy (ofdata->suffix, SUFFIX, sizeof (SUFFIX)); else *ofdata->suffix = '\0'; From f188a86064c4d58f697c25174ea851429203b414 Mon Sep 17 00:00:00 2001 From: Alexander Bluhm Date: Fri, 9 Oct 2015 13:35:40 +0200 Subject: [PATCH 503/722] ufs: Fix parameters to grub_memset. len = 0 made simply no sense. Fix parameters to be in line with read. --- grub-core/fs/ufs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/fs/ufs.c b/grub-core/fs/ufs.c index 0619d6e32..293f027aa 100644 --- a/grub-core/fs/ufs.c +++ b/grub-core/fs/ufs.c @@ -394,7 +394,7 @@ grub_ufs_read_file (struct grub_ufs_data *data, return -1; } else - grub_memset (buf, UFS_BLKSZ (sblock) - skipfirst, 0); + grub_memset (buf, 0, blockend); buf += UFS_BLKSZ (sblock) - skipfirst; } From f59b83fce67fffcdc2414081debf50913dc6b010 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 9 Oct 2015 23:30:53 +0200 Subject: [PATCH 504/722] gfxmenu/model: Delete empty file. --- grub-core/Makefile.core.def | 1 - grub-core/gfxmenu/model.c | 0 2 files changed, 1 deletion(-) delete mode 100644 grub-core/gfxmenu/model.c diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def index 9764cd235..abf5ac1bf 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def @@ -1448,7 +1448,6 @@ module = { module = { name = gfxmenu; common = gfxmenu/gfxmenu.c; - common = gfxmenu/model.c; common = gfxmenu/view.c; common = gfxmenu/font.c; common = gfxmenu/icon_manager.c; diff --git a/grub-core/gfxmenu/model.c b/grub-core/gfxmenu/model.c deleted file mode 100644 index e69de29bb..000000000 From c2443e49bc2a165744dab596b4a9d1b04f52da83 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 9 Oct 2015 23:32:06 +0200 Subject: [PATCH 505/722] mips/dl: Handle addend in RELA entries. --- grub-core/kern/mips/dl.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/grub-core/kern/mips/dl.c b/grub-core/kern/mips/dl.c index 8c057e01d..e320a4ee7 100644 --- a/grub-core/kern/mips/dl.c +++ b/grub-core/kern/mips/dl.c @@ -138,6 +138,10 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr, sym = (Elf_Sym *) ((char *) mod->symtab + mod->symsize * ELF_R_SYM (rel->r_info)); sym_value = sym->st_value; + if (s->sh_type == SHT_RELA) + { + sym_value += ((Elf_Rela *) rel)->r_addend; + } if (sym_value == (grub_addr_t) &__gnu_local_gp_dummy) sym_value = (grub_addr_t) mod->got; else if (sym_value == (grub_addr_t) &_gp_disp_dummy) From d31321835e9e0b2e1c792b8834840eb148cdd29f Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sat, 10 Oct 2015 10:02:20 +0300 Subject: [PATCH 506/722] file: ignore host disk in blocklist check It cannot work anyway because host disk cannot be read. This fixes hostfs access on native Windows build where filenames start with '\' or do not have initial separator at all (d:\foo). Issue was observed when running grub-fstest on Windows. On UNIX image name is canonicalized to always start with `/' so this was not noticed. This has side effect of allowing relative path names on host, but this already was the case with `ls' command, so it just extends it to all commands. Reported-By: Arch Stack Also-By: Arch Stack --- grub-core/kern/file.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/grub-core/kern/file.c b/grub-core/kern/file.c index 24da12bb9..3367485fb 100644 --- a/grub-core/kern/file.c +++ b/grub-core/kern/file.c @@ -89,7 +89,11 @@ grub_file_open (const char *name) file->device = device; - if (device->disk && file_name[0] != '/') + if (device->disk && file_name[0] != '/' +#if defined(GRUB_UTIL) || defined(GRUB_MACHINE_EMU) + && grub_strcmp (device->disk->name, "host") +#endif + ) /* This is a block list. */ file->fs = &grub_fs_blocklist; else From 6e211958901168957f9c2f71041f2871756c5b65 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sat, 10 Oct 2015 11:44:14 +0300 Subject: [PATCH 507/722] progress: avoid NULL dereference for net files From original patch by dann frazier : grub_net_fs_open() saves off a copy of the file structure it gets passed and uses it to create a bufio structure. It then overwrites the passed in file structure with this new bufio structure. Since file->name doesn't get set until we return back to grub_file_open(), it means that only the bufio structure gets a valid file->name. The "real" file's name is left uninitialized. This leads to a crash when the progress module hook is called on it. grub_net_fs_open() already saved copy of file name as ->net->name, so change progress module to use it. Also, grub_file_open may leave file->name as NULL if grub_strdup fails. Check for it. Also-By: dann frazier --- grub-core/lib/progress.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/grub-core/lib/progress.c b/grub-core/lib/progress.c index 63a0767d6..95a4a6281 100644 --- a/grub-core/lib/progress.c +++ b/grub-core/lib/progress.c @@ -23,6 +23,7 @@ #include #include #include +#include GRUB_MOD_LICENSE ("GPLv3+"); @@ -70,7 +71,15 @@ grub_file_progress_hook_real (grub_disk_addr_t sector __attribute__ ((unused)), percent = grub_divmod64 (100 * file->progress_offset, file->size, 0); - partial_file_name = grub_strrchr (file->name, '/'); + /* grub_net_fs_open() saves off partial file structure before name is initialized. + It already saves passed file name in net structure so just use it in this case. + */ + if (file->device->net) + partial_file_name = grub_strrchr (file->device->net->name, '/'); + else if (file->name) /* grub_file_open() may leave it as NULL */ + partial_file_name = grub_strrchr (file->name, '/'); + else + partial_file_name = NULL; if (partial_file_name) partial_file_name++; else From 285540e44869f7d463eb97e56141f6c19c2af67d Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sat, 10 Oct 2015 10:34:55 +0200 Subject: [PATCH 508/722] mips: Make the assembly-code N32-compatible. There are no $t4 or $t5 in N32 but there are $a4 and $a5. --- asm-tests/mips.S | 4 ++-- grub-core/boot/mips/startup_raw.S | 37 ++++++++++++++++--------------- grub-core/kern/mips/startup.S | 5 +++-- include/grub/mips/asm.h | 11 +++++++++ 4 files changed, 35 insertions(+), 22 deletions(-) create mode 100644 include/grub/mips/asm.h diff --git a/asm-tests/mips.S b/asm-tests/mips.S index 8233dfcc9..1312d47d5 100644 --- a/asm-tests/mips.S +++ b/asm-tests/mips.S @@ -4,8 +4,8 @@ .set mips3 sync - ld $t2, 0($t6) + ld $t2, 0($t1) a: - addiu $t7, $s0, (b - a) + addiu $t1, $s0, (b - a) b: nop diff --git a/grub-core/boot/mips/startup_raw.S b/grub-core/boot/mips/startup_raw.S index ca3413bbe..6a81b3733 100644 --- a/grub-core/boot/mips/startup_raw.S +++ b/grub-core/boot/mips/startup_raw.S @@ -22,6 +22,7 @@ #include #include #include +#include #define BASE_ADDR 8 @@ -118,32 +119,32 @@ parsestr: move $v0, $zero move $t3, $t1 3: - lb $t4, 0($t2) - lb $t5, 0($t3) + lb GRUB_ASM_T4, 0($t2) + lb GRUB_ASM_T5, 0($t3) addiu $t2, $t2, 1 addiu $t3, $t3, 1 - beq $t5, $zero, 1f + beq GRUB_ASM_T5, $zero, 1f nop - beq $t5, $t4, 3b + beq GRUB_ASM_T5, GRUB_ASM_T4, 3b nop - bne $t4, $zero, 1f + bne GRUB_ASM_T4, $zero, 1f nop addiu $t3, $t3, 0xffff digcont: - lb $t5, 0($t3) + lb GRUB_ASM_T5, 0($t3) /* Substract '0' from digit. */ - addiu $t5, $t5, 0xffd0 - bltz $t5, 1f + addiu GRUB_ASM_T5, GRUB_ASM_T5, 0xffd0 + bltz GRUB_ASM_T5, 1f nop - addiu $t4, $t5, 0xfff7 - bgtz $t4, 1f + addiu GRUB_ASM_T4, GRUB_ASM_T5, 0xfff7 + bgtz GRUB_ASM_T4, 1f nop /* Multiply $v0 by 10 with bitshifts. */ sll $v0, $v0, 1 - sll $t4, $v0, 2 - addu $v0, $v0, $t4 - addu $v0, $v0, $t5 + sll GRUB_ASM_T4, $v0, 2 + addu $v0, $v0, GRUB_ASM_T4 + addu $v0, $v0, GRUB_ASM_T5 addiu $t3, $t3, 1 b digcont nop @@ -182,10 +183,10 @@ argdone: b argdone addiu $a1, $a1, 4 do_check: - lb $t4, 0($t7) - beq $t4, $zero, 1f + lb GRUB_ASM_T4, 0($t7) + beq GRUB_ASM_T4, $zero, 1f lb $t3, 0($t6) - bne $t3, $t4, 2f + bne $t3, GRUB_ASM_T4, 2f addiu $t6, $t6, 1 b do_check addiu $t7, $t7, 1 @@ -222,8 +223,8 @@ cmdlinedone: 1: beq $t1, $t3, 2f - lb $t4, 0($t2) - sb $t4, 0($t1) + lb GRUB_ASM_T4, 0($t2) + sb GRUB_ASM_T4, 0($t1) addiu $t1, $t1, 1 b 1b addiu $t2, $t2, 1 diff --git a/grub-core/kern/mips/startup.S b/grub-core/kern/mips/startup.S index 339ab337e..1fdb58aca 100644 --- a/grub-core/kern/mips/startup.S +++ b/grub-core/kern/mips/startup.S @@ -22,6 +22,7 @@ #include #include #include +#include #define BASE_ADDR 8 @@ -95,8 +96,8 @@ cont: modulesmovcont: beq $t3, $0, modulesmovdone nop - lb $t4, 0($t2) - sb $t4, 0($t1) + lb GRUB_ASM_T4, 0($t2) + sb GRUB_ASM_T4, 0($t1) addiu $t2, $t2, -1 addiu $t1, $t1, -1 b modulesmovcont diff --git a/include/grub/mips/asm.h b/include/grub/mips/asm.h new file mode 100644 index 000000000..ad2f71abe --- /dev/null +++ b/include/grub/mips/asm.h @@ -0,0 +1,11 @@ +#ifndef GRUB_MIPS_ASM_HEADER +#define GRUB_MIPS_ASM_HEADER 1 + +#if defined(_MIPS_SIM) && defined(_ABIN32) && _MIPS_SIM == _ABIN32 +#define GRUB_ASM_T4 $a4 +#define GRUB_ASM_T5 $a5 +#else +#define GRUB_ASM_T4 $t4 +#define GRUB_ASM_T5 $t5 +#endif +#endif From cfabe05cc6ab88fc7c7a48c9bc0072770b7ad101 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sun, 11 Oct 2015 13:15:50 +0200 Subject: [PATCH 509/722] mips: Make setjmp code N32-compliant. --- grub-core/lib/mips/setjmp.S | 51 ++++++++++++++++++++----------------- include/grub/mips/asm.h | 7 +++++ include/grub/mips/setjmp.h | 2 +- 3 files changed, 35 insertions(+), 25 deletions(-) diff --git a/grub-core/lib/mips/setjmp.S b/grub-core/lib/mips/setjmp.S index f01294518..895235b78 100644 --- a/grub-core/lib/mips/setjmp.S +++ b/grub-core/lib/mips/setjmp.S @@ -18,6 +18,7 @@ #include #include +#include .file "setjmp.S" @@ -29,40 +30,42 @@ GRUB_MOD_LICENSE "GPLv3+" * int grub_setjmp (grub_jmp_buf env) */ FUNCTION(grub_setjmp) - sw $s0, 0($a0) - sw $s1, 4($a0) - sw $s2, 8($a0) - sw $s3, 12($a0) - sw $s4, 16($a0) - sw $s5, 20($a0) - sw $s6, 24($a0) - sw $s7, 28($a0) - sw $s8, 32($a0) - sw $gp, 36($a0) - sw $sp, 40($a0) - sw $ra, 44($a0) + GRUB_ASM_REG_S $s0, 0($a0) + GRUB_ASM_REG_S $s1, 8($a0) + GRUB_ASM_REG_S $s2, 16($a0) + GRUB_ASM_REG_S $s3, 24($a0) + GRUB_ASM_REG_S $s4, 32($a0) + GRUB_ASM_REG_S $s5, 40($a0) + GRUB_ASM_REG_S $s6, 48($a0) + GRUB_ASM_REG_S $s7, 56($a0) + GRUB_ASM_REG_S $s8, 64($a0) + GRUB_ASM_REG_S $gp, 72($a0) + GRUB_ASM_REG_S $sp, 80($a0) + GRUB_ASM_REG_S $ra, 88($a0) move $v0, $zero move $v1, $zero jr $ra + nop /* * int grub_longjmp (grub_jmp_buf env, int val) */ FUNCTION(grub_longjmp) - lw $s0, 0($a0) - lw $s1, 4($a0) - lw $s2, 8($a0) - lw $s3, 12($a0) - lw $s4, 16($a0) - lw $s5, 20($a0) - lw $s6, 24($a0) - lw $s7, 28($a0) - lw $s8, 32($a0) - lw $gp, 36($a0) - lw $sp, 40($a0) - lw $ra, 44($a0) + GRUB_ASM_REG_L $s0, 0($a0) + GRUB_ASM_REG_L $s1, 8($a0) + GRUB_ASM_REG_L $s2, 16($a0) + GRUB_ASM_REG_L $s3, 24($a0) + GRUB_ASM_REG_L $s4, 32($a0) + GRUB_ASM_REG_L $s5, 40($a0) + GRUB_ASM_REG_L $s6, 48($a0) + GRUB_ASM_REG_L $s7, 56($a0) + GRUB_ASM_REG_L $s8, 64($a0) + GRUB_ASM_REG_L $gp, 72($a0) + GRUB_ASM_REG_L $sp, 80($a0) + GRUB_ASM_REG_L $ra, 88($a0) move $v0, $a1 bne $v0, $zero, 1f addiu $v0, $v0, 1 1: move $v1, $zero jr $ra + nop diff --git a/include/grub/mips/asm.h b/include/grub/mips/asm.h index ad2f71abe..4c397f4a0 100644 --- a/include/grub/mips/asm.h +++ b/include/grub/mips/asm.h @@ -4,8 +4,15 @@ #if defined(_MIPS_SIM) && defined(_ABIN32) && _MIPS_SIM == _ABIN32 #define GRUB_ASM_T4 $a4 #define GRUB_ASM_T5 $a5 +#define GRUB_ASM_SZREG 8 +#define GRUB_ASM_REG_S sd +#define GRUB_ASM_REG_L ld #else #define GRUB_ASM_T4 $t4 #define GRUB_ASM_T5 $t5 +#define GRUB_ASM_SZREG 4 +#define GRUB_ASM_REG_S sw +#define GRUB_ASM_REG_L lw #endif + #endif diff --git a/include/grub/mips/setjmp.h b/include/grub/mips/setjmp.h index a99dde9ef..f8f6517ac 100644 --- a/include/grub/mips/setjmp.h +++ b/include/grub/mips/setjmp.h @@ -19,7 +19,7 @@ #ifndef GRUB_SETJMP_CPU_HEADER #define GRUB_SETJMP_CPU_HEADER 1 -typedef unsigned long grub_jmp_buf[12]; +typedef grub_uint64_t grub_jmp_buf[12]; int grub_setjmp (grub_jmp_buf env) RETURNS_TWICE; void grub_longjmp (grub_jmp_buf env, int val) __attribute__ ((noreturn)); From 76197d9be648adef902a86181493b297b3edce88 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sun, 11 Oct 2015 21:17:37 +0300 Subject: [PATCH 510/722] install: --compress argument is not optional Fixes crash if argument is not specified. Also use `|' to separate choices in list of compression methods to align it with --core-compress. --- include/grub/util/install.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/grub/util/install.h b/include/grub/util/install.h index aedcd29f9..5ca4811cd 100644 --- a/include/grub/util/install.h +++ b/include/grub/util/install.h @@ -39,7 +39,7 @@ { "locales", GRUB_INSTALL_OPTIONS_INSTALL_LOCALES, N_("LOCALES"),\ 0, N_("install only LOCALES [default=all]"), 1 }, \ { "compress", GRUB_INSTALL_OPTIONS_INSTALL_COMPRESS, \ - "no,xz,gz,lzo", OPTION_ARG_OPTIONAL, \ + "no|xz|gz|lzo", 0, \ N_("compress GRUB files [optional]"), 1 }, \ {"core-compress", GRUB_INSTALL_OPTIONS_INSTALL_CORE_COMPRESS, \ "xz|none|auto", \ From a01ab69848257a3df705e524c4acafe795e05cc9 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Mon, 12 Oct 2015 23:16:23 +0300 Subject: [PATCH 511/722] net: avoid closing NULL socket in DNS lookup Refactor code so that we do not store NULL pointers in array of in-flight DNS servers. Reported-By: Josef Bacik --- grub-core/net/dns.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/grub-core/net/dns.c b/grub-core/net/dns.c index 9d0c8fcea..953f3bedd 100644 --- a/grub-core/net/dns.c +++ b/grub-core/net/dns.c @@ -437,7 +437,7 @@ grub_net_dns_lookup (const char *name, struct recv_data data = {naddresses, addresses, cache, grub_cpu_to_be16 (id++), 0, 0, name, 0}; grub_uint8_t *nbd; - int have_server = 0; + grub_size_t try_server = 0; if (!servers) { @@ -543,33 +543,31 @@ grub_net_dns_lookup (const char *name, for (i = 0; i < n_servers * 4; i++) { /* Connect to a next server. */ - while (!(i & 1) && send_servers < n_servers) + while (!(i & 1) && try_server < n_servers) { - sockets[send_servers] = grub_net_udp_open (servers[send_servers], + sockets[send_servers] = grub_net_udp_open (servers[try_server++], DNS_PORT, recv_hook, &data); - send_servers++; - if (!sockets[send_servers - 1]) + if (!sockets[send_servers]) { err = grub_errno; grub_errno = GRUB_ERR_NONE; } else { - have_server = 1; + send_servers++; break; } } - if (!have_server) + if (!send_servers) goto out; if (*data.naddresses) goto out; for (j = 0; j < send_servers; j++) { grub_err_t err2; - if (!sockets[j]) - continue; + nb->data = nbd; grub_size_t t = 0; From be25d92196fe31e307ac0b8996ba7f059332ffe3 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Wed, 14 Oct 2015 00:39:15 +0200 Subject: [PATCH 512/722] configure: force o32 ABI on MIPS GRUB code expects O32 or N32. N32 is less tested than O32, so we prefer to compile with O32. Some systems (e.g. GNU Guix) default to using newer n64 or n32 ABI. Try to find suitable options to force o32. For GCC this is simply -mabi=32. While clang supports this option as well, o32 ABI is valid for MIPS target and n32/64 ABI are valid for MIPS64 target only, so use "-target mips/mipsel -mabi=32". Reported-By: Mark H Weaver Also-By: Mark H Weaver --- configure.ac | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/configure.ac b/configure.ac index c864311f7..7bac86560 100644 --- a/configure.ac +++ b/configure.ac @@ -597,6 +597,40 @@ int main (void); TARGET_LDFLAGS="$TARGET_LDFLAGS $grub_cv_target_cc_big_endian" fi +# GRUB code is N32-compliant but it's experimental and we would prefer to +# avoid having too much variety when it doesn't result in any real improvement. +# Moreover N64 isn't supported. +if test "x$target_cpu" = xmips || test "x$target_cpu" = xmipsel ; then + AC_CACHE_CHECK([for options to force MIPS o32 ABI], grub_cv_target_cc_mips_o32_abi, [ + grub_cv_target_cc_mips_o32_abi=no + for arg in "" "-mabi=32" "-target $target_cpu -mabi=32" ; do + if test x"$grub_cv_target_cc_mips_o32_abi" != xno ; then + break + fi + CFLAGS="$TARGET_CFLAGS $arg -Werror" + AC_LINK_IFELSE([AC_LANG_PROGRAM([[ +#if !defined(_ABIO32) || !defined(_MIPS_SIM) || (_MIPS_SIM != _ABIO32) +#error not o32 ABI +#endif +asm (".globl start; start:"); +asm (".globl _start; _start:"); +asm (".globl __start; __start:"); +void __main (void); +void __main (void) {} +int main (void); +]], [[]])], + [grub_cv_target_cc_mips_o32_abi="$arg"], []) + done + ]) + + if test x"$grub_cv_target_cc_mips_o32_abi" = xno ; then + AC_MSG_ERROR([could not force MIPS o32 ABI]) + fi + + TARGET_CFLAGS="$TARGET_CFLAGS $grub_cv_target_cc_mips_o32_abi" + TARGET_CCASFLAGS="$TARGET_CCASFLAGS $grub_cv_target_cc_mips_o32_abi" +fi + AC_CACHE_CHECK([for options to compile assembly], [grub_cv_cc_target_asm_compile], [ test_program= case "x$target_cpu-$platform" in From a3645c1240a0b89c3b51593bd3efc14fe66d67cf Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Wed, 14 Oct 2015 00:42:14 +0200 Subject: [PATCH 513/722] configure: find options to force endian on MIPS --- configure.ac | 45 +++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 41 insertions(+), 4 deletions(-) diff --git a/configure.ac b/configure.ac index 7bac86560..21691c15c 100644 --- a/configure.ac +++ b/configure.ac @@ -562,12 +562,12 @@ AC_COMPILE_IFELSE( ]])], [grub_cv_cc_target_clang=no], [grub_cv_cc_target_clang=yes])]) -if test x$target_cpu = xpowerpc; then +if test x$target_cpu = xpowerpc -o x$target_cpu = xmips; then AC_CACHE_CHECK([for options to get big-endian compilation], grub_cv_target_cc_big_endian, [ grub_cv_target_cc_big_endian=no - for cand in "-target powerpc -Wl,-EB" "-target powerpc" \ - "-target powerpc-linux-gnu -Wl,-EB" "-target powerpc-linux-gnu" \ - "-mbig-endian"; do + for cand in "-target $target_cpu -Wl,-EB" "-target $target_cpu" \ + "-target $target_cpu-linux-gnu -Wl,-EB" "-target $target_cpu-linux-gnu" \ + "-EB" "-mbig-endian"; do if test x"$grub_cv_target_cc_big_endian" != xno ; then break fi @@ -577,6 +577,8 @@ if test x$target_cpu = xpowerpc; then #error still little endian #endif asm (".globl start; start:"); +asm (".globl _start; _start:"); +asm (".globl __start; __start:"); void __main (void); void __main (void) {} int main (void); @@ -595,6 +597,41 @@ int main (void); TARGET_CPPFLAGS="$TARGET_CPPFLAGS $skip_linkflags" TARGET_CCASFLAGS="$TARGET_CCASFLAGS $skip_linkflags" TARGET_LDFLAGS="$TARGET_LDFLAGS $grub_cv_target_cc_big_endian" +elif test x$target_cpu = xmipsel; then + AC_CACHE_CHECK([for options to get little-endian compilation], grub_cv_target_cc_little_endian, [ + grub_cv_target_cc_little_endian=no + for cand in "-target $target_cpu -Wl,-EL" "-target $target_cpu" \ + "-target $target_cpu-linux-gnu -Wl,-EL" "-target $target_cpu-linux-gnu" \ + "-EL"; do + if test x"$grub_cv_target_cc_little_endian" != xno ; then + break + fi + CFLAGS="$TARGET_CFLAGS $cand -Werror" + AC_LINK_IFELSE([AC_LANG_PROGRAM([[ +#if defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) && (__ORDER_BIG_ENDIAN__ == __BYTE_ORDER__) +#error still big endian +#endif +asm (".globl start; start:"); +asm (".globl _start; _start:"); +asm (".globl __start; __start:"); +void __main (void); +void __main (void) {} +int main (void); +]], [[]])], + [grub_cv_target_cc_little_endian="$cand"], []) + done + ]) + + if test x"$grub_cv_target_cc_little_endian" = xno ; then + AC_MSG_ERROR([could not force little-endian]) + fi + + skip_linkflags="$(echo "$grub_cv_target_cc_little_endian"|sed 's@-Wl,-EL@@')" + + TARGET_CFLAGS="$TARGET_CFLAGS $skip_linkflags" + TARGET_CPPFLAGS="$TARGET_CPPFLAGS $skip_linkflags" + TARGET_CCASFLAGS="$TARGET_CCASFLAGS $skip_linkflags" + TARGET_LDFLAGS="$TARGET_LDFLAGS $grub_cv_target_cc_little_endian" fi # GRUB code is N32-compliant but it's experimental and we would prefer to From 9e5f70174ec960a0077f20bb74cb9f4da9b57e7b Mon Sep 17 00:00:00 2001 From: Peter Jones Date: Sun, 25 Oct 2015 16:36:28 +0100 Subject: [PATCH 514/722] Use EFI_SIMPLE_TEXT_INPUT_EX to support key combinations. --- grub-core/term/efi/console.c | 120 +++++++++++++++++++++++++++++------ include/grub/efi/api.h | 65 ++++++++++++++++++- 2 files changed, 163 insertions(+), 22 deletions(-) diff --git a/grub-core/term/efi/console.c b/grub-core/term/efi/console.c index a37eb841c..8b2096f19 100644 --- a/grub-core/term/efi/console.c +++ b/grub-core/term/efi/console.c @@ -104,26 +104,12 @@ const unsigned efi_codes[] = GRUB_TERM_KEY_DC, GRUB_TERM_KEY_PPAGE, GRUB_TERM_KEY_NPAGE, GRUB_TERM_KEY_F1, GRUB_TERM_KEY_F2, GRUB_TERM_KEY_F3, GRUB_TERM_KEY_F4, GRUB_TERM_KEY_F5, GRUB_TERM_KEY_F6, GRUB_TERM_KEY_F7, GRUB_TERM_KEY_F8, GRUB_TERM_KEY_F9, - GRUB_TERM_KEY_F10, 0, 0, '\e' + GRUB_TERM_KEY_F10, GRUB_TERM_KEY_F11, GRUB_TERM_KEY_F12, '\e' }; - static int -grub_console_getkey (struct grub_term_input *term __attribute__ ((unused))) +grub_efi_translate_key (grub_efi_input_key_t key) { - grub_efi_simple_input_interface_t *i; - grub_efi_input_key_t key; - grub_efi_status_t status; - - if (grub_efi_is_finished) - return 0; - - i = grub_efi_system_table->con_in; - status = efi_call_2 (i->read_key_stroke, i, &key); - - if (status != GRUB_EFI_SUCCESS) - return GRUB_TERM_NO_KEY; - if (key.scan_code == 0) { /* Some firmware implementations use VT100-style codes against the spec. @@ -139,9 +125,100 @@ grub_console_getkey (struct grub_term_input *term __attribute__ ((unused))) else if (key.scan_code < ARRAY_SIZE (efi_codes)) return efi_codes[key.scan_code]; + if (key.unicode_char >= 0x20 && key.unicode_char <= 0x7f + || key.unicode_char == '\t' || key.unicode_char == '\b' + || key.unicode_char == '\n' || key.unicode_char == '\r') + return key.unicode_char; + return GRUB_TERM_NO_KEY; } +static int +grub_console_getkey_con (struct grub_term_input *term __attribute__ ((unused))) +{ + grub_efi_simple_input_interface_t *i; + grub_efi_input_key_t key; + grub_efi_status_t status; + + i = grub_efi_system_table->con_in; + status = efi_call_2 (i->read_key_stroke, i, &key); + + if (status != GRUB_EFI_SUCCESS) + return GRUB_TERM_NO_KEY; + + return grub_efi_translate_key(key); +} + +static int +grub_console_getkey_ex(struct grub_term_input *term) +{ + grub_efi_key_data_t key_data; + grub_efi_status_t status; + grub_efi_uint32_t kss; + int key = -1; + + grub_efi_simple_text_input_ex_interface_t *text_input = term->data; + + status = efi_call_2 (text_input->read_key_stroke, text_input, &key_data); + + if (status != GRUB_EFI_SUCCESS) + return GRUB_TERM_NO_KEY; + + kss = key_data.key_state.key_shift_state; + key = grub_efi_translate_key(key_data.key); + + if (key == GRUB_TERM_NO_KEY) + return GRUB_TERM_NO_KEY; + + if (kss & GRUB_EFI_SHIFT_STATE_VALID) + { + if ((kss & GRUB_EFI_LEFT_SHIFT_PRESSED + || kss & GRUB_EFI_RIGHT_SHIFT_PRESSED) + && (key & GRUB_TERM_EXTENDED)) + key |= GRUB_TERM_SHIFT; + if (kss & GRUB_EFI_LEFT_ALT_PRESSED || kss & GRUB_EFI_RIGHT_ALT_PRESSED) + key |= GRUB_TERM_ALT; + if (kss & GRUB_EFI_LEFT_CONTROL_PRESSED + || kss & GRUB_EFI_RIGHT_CONTROL_PRESSED) + key |= GRUB_TERM_CTRL; + } + + return key; +} + +static grub_err_t +grub_efi_console_input_init (struct grub_term_input *term) +{ + grub_efi_guid_t text_input_ex_guid = + GRUB_EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL_GUID; + + if (grub_efi_is_finished) + return 0; + + grub_efi_simple_text_input_ex_interface_t *text_input = term->data; + if (text_input) + return 0; + + text_input = grub_efi_open_protocol(grub_efi_system_table->console_in_handler, + &text_input_ex_guid, + GRUB_EFI_OPEN_PROTOCOL_GET_PROTOCOL); + term->data = (void *)text_input; + + return 0; +} + +static int +grub_console_getkey (struct grub_term_input *term) +{ + if (grub_efi_is_finished) + return 0; + + if (term->data) + return grub_console_getkey_ex(term); + else + return grub_console_getkey_con(term); +} + static struct grub_term_coordinate grub_console_getwh (struct grub_term_output *term __attribute__ ((unused))) { @@ -243,7 +320,7 @@ grub_console_setcursor (struct grub_term_output *term __attribute__ ((unused)), } static grub_err_t -grub_efi_console_init (struct grub_term_output *term) +grub_efi_console_output_init (struct grub_term_output *term) { grub_efi_set_text_mode (1); grub_console_setcursor (term, 1); @@ -251,7 +328,7 @@ grub_efi_console_init (struct grub_term_output *term) } static grub_err_t -grub_efi_console_fini (struct grub_term_output *term) +grub_efi_console_output_fini (struct grub_term_output *term) { grub_console_setcursor (term, 0); grub_efi_set_text_mode (0); @@ -262,13 +339,14 @@ static struct grub_term_input grub_console_term_input = { .name = "console", .getkey = grub_console_getkey, + .init = grub_efi_console_input_init, }; static struct grub_term_output grub_console_term_output = { .name = "console", - .init = grub_efi_console_init, - .fini = grub_efi_console_fini, + .init = grub_efi_console_output_init, + .fini = grub_efi_console_output_fini, .putchar = grub_console_putchar, .getwh = grub_console_getwh, .getxy = grub_console_getxy, @@ -291,8 +369,8 @@ grub_console_init (void) return; } - grub_term_register_input ("console", &grub_console_term_input); grub_term_register_output ("console", &grub_console_term_output); + grub_term_register_input ("console", &grub_console_term_input); } void diff --git a/include/grub/efi/api.h b/include/grub/efi/api.h index 1a5e38c1e..029ee92f5 100644 --- a/include/grub/efi/api.h +++ b/include/grub/efi/api.h @@ -111,7 +111,7 @@ { 0x8e, 0x39, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b } \ } -#define EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL_GUID \ +#define GRUB_EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL_GUID \ { 0xdd9e7534, 0x7762, 0x4698, \ { 0x8c, 0x14, 0xf5, 0x85, 0x17, 0xa6, 0x25, 0xaa } \ } @@ -952,6 +952,32 @@ struct grub_efi_input_key }; typedef struct grub_efi_input_key grub_efi_input_key_t; +typedef grub_efi_uint8_t grub_efi_key_toggle_state_t; +struct grub_efi_key_state +{ + grub_efi_uint32_t key_shift_state; + grub_efi_key_toggle_state_t key_toggle_state; +}; +typedef struct grub_efi_key_state grub_efi_key_state_t; + +#define GRUB_EFI_SHIFT_STATE_VALID 0x80000000 +#define GRUB_EFI_RIGHT_SHIFT_PRESSED 0x00000001 +#define GRUB_EFI_LEFT_SHIFT_PRESSED 0x00000002 +#define GRUB_EFI_RIGHT_CONTROL_PRESSED 0x00000004 +#define GRUB_EFI_LEFT_CONTROL_PRESSED 0x00000008 +#define GRUB_EFI_RIGHT_ALT_PRESSED 0x00000010 +#define GRUB_EFI_LEFT_ALT_PRESSED 0x00000020 +#define GRUB_EFI_RIGHT_LOGO_PRESSED 0x00000040 +#define GRUB_EFI_LEFT_LOGO_PRESSED 0x00000080 +#define GRUB_EFI_MENU_KEY_PRESSED 0x00000100 +#define GRUB_EFI_SYS_REQ_PRESSED 0x00000200 + +#define GRUB_EFI_TOGGLE_STATE_VALID 0x80 +#define GRUB_EFI_KEY_STATE_EXPOSED 0x40 +#define GRUB_EFI_SCROLL_LOCK_ACTIVE 0x01 +#define GRUB_EFI_NUM_LOCK_ACTIVE 0x02 +#define GRUB_EFI_CAPS_LOCK_ACTIVE 0x04 + struct grub_efi_simple_text_output_mode { grub_efi_int32_t max_mode; @@ -1294,6 +1320,43 @@ struct grub_efi_simple_input_interface }; typedef struct grub_efi_simple_input_interface grub_efi_simple_input_interface_t; +struct grub_efi_key_data { + grub_efi_input_key_t key; + grub_efi_key_state_t key_state; +}; +typedef struct grub_efi_key_data grub_efi_key_data_t; + +typedef grub_efi_status_t (*grub_efi_key_notify_function_t) ( + grub_efi_key_data_t *key_data + ); + +struct grub_efi_simple_text_input_ex_interface +{ + grub_efi_status_t + (*reset) (struct grub_efi_simple_text_input_ex_interface *this, + grub_efi_boolean_t extended_verification); + + grub_efi_status_t + (*read_key_stroke) (struct grub_efi_simple_text_input_ex_interface *this, + grub_efi_key_data_t *key_data); + + grub_efi_event_t wait_for_key; + + grub_efi_status_t + (*set_state) (struct grub_efi_simple_text_input_ex_interface *this, + grub_efi_key_toggle_state_t *key_toggle_state); + + grub_efi_status_t + (*register_key_notify) (struct grub_efi_simple_text_input_ex_interface *this, + grub_efi_key_data_t *key_data, + grub_efi_key_notify_function_t key_notification_function); + + grub_efi_status_t + (*unregister_key_notify) (struct grub_efi_simple_text_input_ex_interface *this, + void *notification_handle); +}; +typedef struct grub_efi_simple_text_input_ex_interface grub_efi_simple_text_input_ex_interface_t; + struct grub_efi_simple_text_output_interface { grub_efi_status_t From bf3df4070f4c0530366e9d6f518785f57c5df8b3 Mon Sep 17 00:00:00 2001 From: Paulo Flabiano Smorigo Date: Mon, 26 Oct 2015 22:07:26 +0100 Subject: [PATCH 515/722] Implement cross-endian ELF load for powerpc --- grub-core/kern/elf.c | 56 ++++++++++++++++++++++++++++++++++++++++-- grub-core/kern/elfXX.c | 51 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 105 insertions(+), 2 deletions(-) diff --git a/grub-core/kern/elf.c b/grub-core/kern/elf.c index 5f99c43cc..00de36984 100644 --- a/grub-core/kern/elf.c +++ b/grub-core/kern/elf.c @@ -28,6 +28,23 @@ GRUB_MOD_LICENSE ("GPLv3+"); +#if defined(__powerpc__) && defined(GRUB_MACHINE_IEEE1275) +#define GRUB_ELF_ENABLE_BI_ENDIAN 1 +#else +#define GRUB_ELF_ENABLE_BI_ENDIAN 0 +#endif + +#if defined(GRUB_CPU_WORDS_BIGENDIAN) +#define GRUB_ELF_NATIVE_ENDIANNESS ELFDATA2MSB +#define GRUB_ELF_OPPOSITE_ENDIANNESS ELFDATA2LSB +#else +#define GRUB_ELF_NATIVE_ENDIANNESS ELFDATA2LSB +#define GRUB_ELF_OPPOSITE_ENDIANNESS ELFDATA2MSB +#endif + +static int grub_elf32_check_endianess_and_bswap_ehdr (grub_elf_t elf); +static int grub_elf64_check_endianess_and_bswap_ehdr (grub_elf_t elf); + /* Check if EHDR is a valid ELF header. */ static grub_err_t grub_elf_check_header (grub_elf_t elf) @@ -38,8 +55,25 @@ grub_elf_check_header (grub_elf_t elf) || e->e_ident[EI_MAG1] != ELFMAG1 || e->e_ident[EI_MAG2] != ELFMAG2 || e->e_ident[EI_MAG3] != ELFMAG3 - || e->e_ident[EI_VERSION] != EV_CURRENT - || e->e_version != EV_CURRENT) + || e->e_ident[EI_VERSION] != EV_CURRENT) + return grub_error (GRUB_ERR_BAD_OS, N_("invalid arch-independent ELF magic")); + + if (grub_elf_is_elf32 (elf)) + { + if (!grub_elf32_check_endianess_and_bswap_ehdr (elf)) { + return grub_error (GRUB_ERR_BAD_OS, "invalid ELF endianness magic"); + } + } + else if (grub_elf_is_elf64 (elf)) + { + if (!grub_elf64_check_endianess_and_bswap_ehdr (elf)) { + return grub_error (GRUB_ERR_BAD_OS, "invalid ELF endianness magic"); + } + } + else + return grub_error (GRUB_ERR_BAD_OS, "unknown ELF class"); + + if (e->e_version != EV_CURRENT) return grub_error (GRUB_ERR_BAD_OS, N_("invalid arch-independent ELF magic")); return GRUB_ERR_NONE; @@ -117,6 +151,9 @@ grub_elf_open (const char *name) } +#define grub_swap_bytes_halfXX grub_swap_bytes16 +#define grub_swap_bytes_wordXX grub_swap_bytes32 + /* 32-bit */ #define ehdrXX ehdr32 #define ELFCLASSXX ELFCLASS32 @@ -127,7 +164,12 @@ grub_elf_open (const char *name) #define grub_elf_is_elfXX grub_elf_is_elf32 #define grub_elfXX_load_phdrs grub_elf32_load_phdrs #define ElfXX_Phdr Elf32_Phdr +#define ElfXX_Ehdr Elf32_Ehdr #define grub_uintXX_t grub_uint32_t +#define grub_swap_bytes_addrXX grub_swap_bytes32 +#define grub_swap_bytes_offXX grub_swap_bytes32 +#define grub_swap_bytes_XwordXX grub_swap_bytes32 +#define grub_elfXX_check_endianess_and_bswap_ehdr grub_elf32_check_endianess_and_bswap_ehdr #include "elfXX.c" @@ -140,7 +182,12 @@ grub_elf_open (const char *name) #undef grub_elf_is_elfXX #undef grub_elfXX_load_phdrs #undef ElfXX_Phdr +#undef ElfXX_Ehdr #undef grub_uintXX_t +#undef grub_swap_bytes_addrXX +#undef grub_swap_bytes_offXX +#undef grub_swap_bytes_XwordXX +#undef grub_elfXX_check_endianess_and_bswap_ehdr /* 64-bit */ @@ -153,6 +200,11 @@ grub_elf_open (const char *name) #define grub_elf_is_elfXX grub_elf_is_elf64 #define grub_elfXX_load_phdrs grub_elf64_load_phdrs #define ElfXX_Phdr Elf64_Phdr +#define ElfXX_Ehdr Elf64_Ehdr #define grub_uintXX_t grub_uint64_t +#define grub_swap_bytes_addrXX grub_swap_bytes64 +#define grub_swap_bytes_offXX grub_swap_bytes64 +#define grub_swap_bytes_XwordXX grub_swap_bytes64 +#define grub_elfXX_check_endianess_and_bswap_ehdr grub_elf64_check_endianess_and_bswap_ehdr #include "elfXX.c" diff --git a/grub-core/kern/elfXX.c b/grub-core/kern/elfXX.c index 1d0997186..b91c39d9e 100644 --- a/grub-core/kern/elfXX.c +++ b/grub-core/kern/elfXX.c @@ -31,6 +31,25 @@ grub_elfXX_load_phdrs (grub_elf_t elf) return grub_errno; } +#if GRUB_ELF_ENABLE_BI_ENDIAN + if (elf->ehdr.ehdrXX.e_ident[EI_DATA] == GRUB_ELF_OPPOSITE_ENDIANNESS) + { + ElfXX_Phdr *phdr; + for (phdr = elf->phdrs; (char *) phdr < (char *) elf->phdrs + phdrs_size; + phdr = (ElfXX_Phdr *) ((char *) phdr + elf->ehdr.ehdrXX.e_phentsize)) + { + phdr->p_type = grub_swap_bytes_wordXX (phdr->p_type); + phdr->p_flags = grub_swap_bytes_wordXX (phdr->p_flags); + phdr->p_offset = grub_swap_bytes_offXX (phdr->p_offset); + phdr->p_vaddr = grub_swap_bytes_addrXX (phdr->p_vaddr); + phdr->p_paddr = grub_swap_bytes_addrXX (phdr->p_paddr); + phdr->p_filesz = grub_swap_bytes_XwordXX (phdr->p_filesz); + phdr->p_memsz = grub_swap_bytes_XwordXX (phdr->p_memsz); + phdr->p_align = grub_swap_bytes_XwordXX (phdr->p_align); + } + } +#endif /* GRUB_ELF_ENABLE_BI_ENDIAN */ + return GRUB_ERR_NONE; } @@ -154,3 +173,35 @@ grub_elfXX_load (grub_elf_t elf, const char *filename, return grub_errno; } + +static int +grub_elfXX_check_endianess_and_bswap_ehdr (grub_elf_t elf) +{ + ElfXX_Ehdr *e = &(elf->ehdr.ehdrXX); + if (e->e_ident[EI_DATA] == GRUB_ELF_NATIVE_ENDIANNESS) + { + return 1; + } + +#if GRUB_ELF_ENABLE_BI_ENDIAN + if (e->e_ident[EI_DATA] == GRUB_ELF_OPPOSITE_ENDIANNESS) + { + e->e_type = grub_swap_bytes_halfXX (e->e_type); + e->e_machine = grub_swap_bytes_halfXX (e->e_machine); + e->e_version = grub_swap_bytes_wordXX (e->e_version); + e->e_entry = grub_swap_bytes_addrXX (e->e_entry); + e->e_phoff = grub_swap_bytes_offXX (e->e_phoff); + e->e_shoff = grub_swap_bytes_offXX (e->e_shoff); + e->e_flags = grub_swap_bytes_wordXX (e->e_flags); + e->e_ehsize = grub_swap_bytes_halfXX (e->e_ehsize); + e->e_phentsize = grub_swap_bytes_halfXX (e->e_phentsize); + e->e_phnum = grub_swap_bytes_halfXX (e->e_phnum); + e->e_shentsize = grub_swap_bytes_halfXX (e->e_shentsize); + e->e_shnum = grub_swap_bytes_halfXX (e->e_shnum); + e->e_shstrndx = grub_swap_bytes_halfXX (e->e_shstrndx); + return 1; + } +#endif /* GRUB_ELF_ENABLE_BI_ENDIAN */ + + return 0; +} From 0b72543afdfee193597911c8a427f88adacb3fbe Mon Sep 17 00:00:00 2001 From: Eric Snowberg Date: Mon, 26 Oct 2015 23:03:06 +0100 Subject: [PATCH 516/722] ofdisk: Fix devpath freeing logic. --- grub-core/disk/ieee1275/ofdisk.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/grub-core/disk/ieee1275/ofdisk.c b/grub-core/disk/ieee1275/ofdisk.c index 331769b12..297f058ee 100644 --- a/grub-core/disk/ieee1275/ofdisk.c +++ b/grub-core/disk/ieee1275/ofdisk.c @@ -422,16 +422,20 @@ grub_ofdisk_open (const char *name, grub_disk_t disk) op = ofdisk_hash_find (devpath); if (!op) op = ofdisk_hash_add (devpath, NULL); - else - grub_free (devpath); if (!op) - return grub_errno; + { + grub_free (devpath); + return grub_errno; + } disk->id = (unsigned long) op; disk->data = op->open_path; err = grub_ofdisk_get_block_size (devpath, &block_size, op); if (err) - return err; + { + grub_free (devpath); + return err; + } if (block_size != 0) { for (disk->log_sector_size = 0; @@ -442,6 +446,7 @@ grub_ofdisk_open (const char *name, grub_disk_t disk) disk->log_sector_size = 9; } + grub_free (devpath); return 0; } From 5fcde03bf1e8cf74c186bcef6d705734f2d002c5 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Tue, 27 Oct 2015 23:30:54 +0300 Subject: [PATCH 517/722] efi: fix warnings with recent GCC ../../grub-core/term/efi/console.c:128:32: error: suggest parentheses around '&&' within '||' [-Werror=parentheses] if (key.unicode_char >= 0x20 && key.unicode_char <= 0x7f --- grub-core/term/efi/console.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/term/efi/console.c b/grub-core/term/efi/console.c index 8b2096f19..7d31095b1 100644 --- a/grub-core/term/efi/console.c +++ b/grub-core/term/efi/console.c @@ -125,7 +125,7 @@ grub_efi_translate_key (grub_efi_input_key_t key) else if (key.scan_code < ARRAY_SIZE (efi_codes)) return efi_codes[key.scan_code]; - if (key.unicode_char >= 0x20 && key.unicode_char <= 0x7f + if ((key.unicode_char >= 0x20 && key.unicode_char <= 0x7f) || key.unicode_char == '\t' || key.unicode_char == '\b' || key.unicode_char == '\n' || key.unicode_char == '\r') return key.unicode_char; From 4d0cb755387d6f109b901386ed4d3d475df239fe Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Thu, 29 Oct 2015 13:31:30 +0100 Subject: [PATCH 518/722] arm64: Move FDT functions to separate module --- grub-core/Makefile.core.def | 6 ++ grub-core/loader/arm64/fdt.c | 185 +++++++++++++++++++++++++++++++++ grub-core/loader/arm64/linux.c | 170 ++++-------------------------- include/grub/arm64/fdtload.h | 35 +++++++ include/grub/arm64/linux.h | 4 - 5 files changed, 244 insertions(+), 156 deletions(-) create mode 100644 grub-core/loader/arm64/fdt.c create mode 100644 include/grub/arm64/fdtload.h diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def index abf5ac1bf..19ed47362 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def @@ -1664,6 +1664,12 @@ module = { enable = noemu; }; +module = { + name = fdt; + arm64 = loader/arm64/fdt.c; + enable = arm64; +}; + module = { name = xnu; x86 = loader/xnu_resume.c; diff --git a/grub-core/loader/arm64/fdt.c b/grub-core/loader/arm64/fdt.c new file mode 100644 index 000000000..5202c14e0 --- /dev/null +++ b/grub-core/loader/arm64/fdt.c @@ -0,0 +1,185 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2013-2015 Free Software Foundation, Inc. + * + * GRUB is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GRUB is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GRUB. If not, see . + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +static void *loaded_fdt; +static void *fdt; + +static void * +get_firmware_fdt (void) +{ + grub_efi_configuration_table_t *tables; + grub_efi_guid_t fdt_guid = GRUB_EFI_DEVICE_TREE_GUID; + void *firmware_fdt = NULL; + unsigned int i; + + /* Look for FDT in UEFI config tables. */ + tables = grub_efi_system_table->configuration_table; + + for (i = 0; i < grub_efi_system_table->num_table_entries; i++) + if (grub_memcmp (&tables[i].vendor_guid, &fdt_guid, sizeof (fdt_guid)) == 0) + { + firmware_fdt = tables[i].vendor_table; + grub_dprintf ("linux", "found registered FDT @ %p\n", firmware_fdt); + break; + } + + return firmware_fdt; +} + +void * +grub_fdt_load (grub_size_t additional_size) +{ + void *raw_fdt; + grub_size_t size; + + if (fdt) + { + size = GRUB_EFI_BYTES_TO_PAGES (grub_fdt_get_totalsize (fdt)); + grub_efi_free_pages ((grub_efi_physical_address_t) fdt, size); + } + + if (loaded_fdt) + raw_fdt = loaded_fdt; + else + raw_fdt = get_firmware_fdt(); + + size = + raw_fdt ? grub_fdt_get_totalsize (raw_fdt) : GRUB_FDT_EMPTY_TREE_SZ; + size += additional_size; + + grub_dprintf ("linux", "allocating %ld bytes for fdt\n", size); + fdt = grub_efi_allocate_pages (0, GRUB_EFI_BYTES_TO_PAGES (size)); + if (!fdt) + return NULL; + + if (raw_fdt) + { + grub_memmove (fdt, raw_fdt, size); + grub_fdt_set_totalsize (fdt, size); + } + else + { + grub_fdt_create_empty_tree (fdt, size); + } + return fdt; +} + +grub_err_t +grub_fdt_install (void) +{ + grub_efi_boot_services_t *b; + grub_efi_guid_t fdt_guid = GRUB_EFI_DEVICE_TREE_GUID; + grub_efi_status_t status; + + b = grub_efi_system_table->boot_services; + status = b->install_configuration_table (&fdt_guid, fdt); + if (status != GRUB_EFI_SUCCESS) + return grub_error (GRUB_ERR_IO, "failed to install FDT"); + + grub_dprintf ("fdt", "Installed/updated FDT configuration table @ %p\n", + fdt); + return GRUB_ERR_NONE; +} + +void +grub_fdt_unload (void) { + if (!fdt) { + return; + } + grub_efi_free_pages ((grub_efi_physical_address_t) fdt, + GRUB_EFI_BYTES_TO_PAGES (grub_fdt_get_totalsize (fdt))); + fdt = NULL; +} + +static grub_err_t +grub_cmd_devicetree (grub_command_t cmd __attribute__ ((unused)), + int argc, char *argv[]) +{ + grub_file_t dtb; + void *blob = NULL; + int size; + + if (loaded_fdt) + grub_free (loaded_fdt); + loaded_fdt = NULL; + + /* No arguments means "use firmware FDT". */ + if (argc == 0) + { + return GRUB_ERR_NONE; + } + + dtb = grub_file_open (argv[0]); + if (!dtb) + goto out; + + size = grub_file_size (dtb); + blob = grub_malloc (size); + if (!blob) + goto out; + + if (grub_file_read (dtb, blob, size) < size) + { + if (!grub_errno) + grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"), argv[0]); + goto out; + } + + if (grub_fdt_check_header (blob, size) != 0) + { + grub_error (GRUB_ERR_BAD_OS, N_("invalid device tree")); + goto out; + } + +out: + if (dtb) + grub_file_close (dtb); + + if (blob) + { + if (grub_errno == GRUB_ERR_NONE) + loaded_fdt = blob; + else + grub_free (blob); + } + + return grub_errno; +} + +static grub_command_t cmd_devicetree; + +GRUB_MOD_INIT (fdt) +{ + cmd_devicetree = + grub_register_command ("devicetree", grub_cmd_devicetree, 0, + N_("Load DTB file.")); +} + +GRUB_MOD_FINI (fdt) +{ + grub_unregister_command (cmd_devicetree); +} diff --git a/grub-core/loader/arm64/linux.c b/grub-core/loader/arm64/linux.c index 987f5b9ee..9519d2e4d 100644 --- a/grub-core/loader/arm64/linux.c +++ b/grub-core/loader/arm64/linux.c @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -45,69 +46,6 @@ static grub_uint32_t cmdline_size; static grub_addr_t initrd_start; static grub_addr_t initrd_end; -static void *loaded_fdt; -static void *fdt; - -static void * -get_firmware_fdt (void) -{ - grub_efi_configuration_table_t *tables; - grub_efi_guid_t fdt_guid = GRUB_EFI_DEVICE_TREE_GUID; - void *firmware_fdt = NULL; - unsigned int i; - - /* Look for FDT in UEFI config tables. */ - tables = grub_efi_system_table->configuration_table; - - for (i = 0; i < grub_efi_system_table->num_table_entries; i++) - if (grub_memcmp (&tables[i].vendor_guid, &fdt_guid, sizeof (fdt_guid)) == 0) - { - firmware_fdt = tables[i].vendor_table; - grub_dprintf ("linux", "found registered FDT @ %p\n", firmware_fdt); - break; - } - - return firmware_fdt; -} - -void * -grub_linux_get_fdt (void) -{ - void *raw_fdt; - grub_size_t size; - - if (fdt) - { - size = BYTES_TO_PAGES (grub_fdt_get_totalsize (fdt)); - grub_efi_free_pages ((grub_efi_physical_address_t) fdt, size); - } - - if (loaded_fdt) - raw_fdt = loaded_fdt; - else - raw_fdt = get_firmware_fdt(); - - size = - raw_fdt ? grub_fdt_get_totalsize (raw_fdt) : GRUB_FDT_EMPTY_TREE_SZ; - size += 0x400; - - grub_dprintf ("linux", "allocating %ld bytes for fdt\n", size); - fdt = grub_efi_allocate_pages (0, BYTES_TO_PAGES (size)); - if (!fdt) - return NULL; - - if (raw_fdt) - { - grub_memmove (fdt, raw_fdt, size); - grub_fdt_set_totalsize (fdt, size); - } - else - { - grub_fdt_create_empty_tree (fdt, size); - } - return fdt; -} - grub_err_t grub_arm64_uefi_check_image (struct grub_arm64_linux_kernel_header * lh) { @@ -129,12 +67,13 @@ grub_arm64_uefi_check_image (struct grub_arm64_linux_kernel_header * lh) static grub_err_t finalize_params_linux (void) { - grub_efi_boot_services_t *b; - grub_efi_guid_t fdt_guid = GRUB_EFI_DEVICE_TREE_GUID; - grub_efi_status_t status; int node, retval; - if (!grub_linux_get_fdt ()) + void *fdt; + + fdt = grub_fdt_load (0x400); + + if (!fdt) goto failure; node = grub_fdt_find_subnode (fdt, 0, "chosen"); @@ -160,82 +99,16 @@ finalize_params_linux (void) goto failure; } - b = grub_efi_system_table->boot_services; - status = b->install_configuration_table (&fdt_guid, fdt); - if (status != GRUB_EFI_SUCCESS) + if (grub_fdt_install() != GRUB_ERR_NONE) goto failure; - grub_dprintf ("linux", "Installed/updated FDT configuration table @ %p\n", - fdt); - return GRUB_ERR_NONE; failure: - grub_efi_free_pages ((grub_efi_physical_address_t) fdt, - BYTES_TO_PAGES (grub_fdt_get_totalsize (fdt))); - fdt = NULL; + grub_fdt_unload(); return grub_error(GRUB_ERR_BAD_OS, "failed to install/update FDT"); } -static grub_err_t -grub_cmd_devicetree (grub_command_t cmd __attribute__ ((unused)), - int argc, char *argv[]) -{ - grub_file_t dtb; - void *blob = NULL; - int size; - - if (!loaded) - { - grub_error (GRUB_ERR_BAD_ARGUMENT, - N_("you need to load the kernel first")); - return GRUB_ERR_BAD_OS; - } - - if (argc != 1) - return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected")); - - if (loaded_fdt) - grub_free (loaded_fdt); - loaded_fdt = NULL; - - dtb = grub_file_open (argv[0]); - if (!dtb) - goto out; - - size = grub_file_size (dtb); - blob = grub_malloc (size); - if (!blob) - goto out; - - if (grub_file_read (dtb, blob, size) < size) - { - if (!grub_errno) - grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"), argv[0]); - goto out; - } - - if (grub_fdt_check_header (blob, size) != 0) - { - grub_error (GRUB_ERR_BAD_OS, N_("invalid device tree")); - goto out; - } - -out: - if (dtb) - grub_file_close (dtb); - - if (blob) - { - if (grub_errno == GRUB_ERR_NONE) - loaded_fdt = blob; - else - grub_free (blob); - } - - return grub_errno; -} - grub_err_t grub_arm64_uefi_boot_image (grub_addr_t addr, grub_size_t size, char *args) { @@ -276,7 +149,7 @@ grub_arm64_uefi_boot_image (grub_addr_t addr, grub_size_t size, char *args) (grub_strlen (args) + 1) * sizeof (grub_efi_char16_t); loaded_image->load_options = grub_efi_allocate_pages (0, - BYTES_TO_PAGES (loaded_image->load_options_size)); + GRUB_EFI_BYTES_TO_PAGES (loaded_image->load_options_size)); if (!loaded_image->load_options) return grub_errno; @@ -290,7 +163,7 @@ grub_arm64_uefi_boot_image (grub_addr_t addr, grub_size_t size, char *args) /* When successful, not reached */ b->unload_image (image_handle); grub_efi_free_pages ((grub_efi_physical_address_t) loaded_image->load_options, - BYTES_TO_PAGES (loaded_image->load_options_size)); + GRUB_EFI_BYTES_TO_PAGES (loaded_image->load_options_size)); return grub_errno; } @@ -312,16 +185,13 @@ grub_linux_unload (void) loaded = 0; if (initrd_start) grub_efi_free_pages ((grub_efi_physical_address_t) initrd_start, - BYTES_TO_PAGES (initrd_end - initrd_start)); + GRUB_EFI_BYTES_TO_PAGES (initrd_end - initrd_start)); initrd_start = initrd_end = 0; grub_free (linux_args); if (kernel_addr) grub_efi_free_pages ((grub_efi_physical_address_t) kernel_addr, - BYTES_TO_PAGES (kernel_size)); - if (fdt) - grub_efi_free_pages ((grub_efi_physical_address_t) fdt, - BYTES_TO_PAGES (grub_fdt_get_totalsize (fdt))); - + GRUB_EFI_BYTES_TO_PAGES (kernel_size)); + grub_fdt_unload (); return GRUB_ERR_NONE; } @@ -352,7 +222,7 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), initrd_size = grub_get_initrd_size (&initrd_ctx); grub_dprintf ("linux", "Loading initrd\n"); - initrd_pages = (BYTES_TO_PAGES (initrd_size)); + initrd_pages = (GRUB_EFI_BYTES_TO_PAGES (initrd_size)); initrd_mem = grub_efi_allocate_pages (0, initrd_pages); if (!initrd_mem) { @@ -407,9 +277,9 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), grub_loader_unset(); grub_dprintf ("linux", "kernel file size: %lld\n", (long long) kernel_size); - kernel_addr = grub_efi_allocate_pages (0, BYTES_TO_PAGES (kernel_size)); + kernel_addr = grub_efi_allocate_pages (0, GRUB_EFI_BYTES_TO_PAGES (kernel_size)); grub_dprintf ("linux", "kernel numpages: %lld\n", - (long long) BYTES_TO_PAGES (kernel_size)); + (long long) GRUB_EFI_BYTES_TO_PAGES (kernel_size)); if (!kernel_addr) { grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("out of memory")); @@ -460,13 +330,13 @@ fail: if (kernel_addr && !loaded) grub_efi_free_pages ((grub_efi_physical_address_t) kernel_addr, - BYTES_TO_PAGES (kernel_size)); + GRUB_EFI_BYTES_TO_PAGES (kernel_size)); return grub_errno; } -static grub_command_t cmd_linux, cmd_initrd, cmd_devicetree; +static grub_command_t cmd_linux, cmd_initrd; GRUB_MOD_INIT (linux) { @@ -474,9 +344,6 @@ GRUB_MOD_INIT (linux) N_("Load Linux.")); cmd_initrd = grub_register_command ("initrd", grub_cmd_initrd, 0, N_("Load initrd.")); - cmd_devicetree = - grub_register_command ("devicetree", grub_cmd_devicetree, 0, - N_("Load DTB file.")); my_mod = mod; } @@ -484,5 +351,4 @@ GRUB_MOD_FINI (linux) { grub_unregister_command (cmd_linux); grub_unregister_command (cmd_initrd); - grub_unregister_command (cmd_devicetree); } diff --git a/include/grub/arm64/fdtload.h b/include/grub/arm64/fdtload.h new file mode 100644 index 000000000..7b9ddba91 --- /dev/null +++ b/include/grub/arm64/fdtload.h @@ -0,0 +1,35 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2013-2015 Free Software Foundation, Inc. + * + * GRUB is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GRUB is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GRUB. If not, see . + */ + +#ifndef GRUB_FDTLOAD_CPU_HEADER +#define GRUB_FDTLOAD_CPU_HEADER 1 + +#include +#include + +void * +grub_fdt_load (grub_size_t additional_size); +void +grub_fdt_unload (void); +grub_err_t +grub_fdt_install (void); + +#define GRUB_EFI_PAGE_SHIFT 12 +#define GRUB_EFI_BYTES_TO_PAGES(bytes) (((bytes) + 0xfff) >> GRUB_EFI_PAGE_SHIFT) + +#endif diff --git a/include/grub/arm64/linux.h b/include/grub/arm64/linux.h index 65796d907..1ea23696e 100644 --- a/include/grub/arm64/linux.h +++ b/include/grub/arm64/linux.h @@ -23,8 +23,6 @@ #define GRUB_ARM64_LINUX_MAGIC 0x644d5241 /* 'ARM\x64' */ -#define GRUB_EFI_PAGE_SHIFT 12 -#define BYTES_TO_PAGES(bytes) (((bytes) + 0xfff) >> GRUB_EFI_PAGE_SHIFT) #define GRUB_EFI_PE_MAGIC 0x5A4D /* From linux/Documentation/arm64/booting.txt */ @@ -42,8 +40,6 @@ struct grub_arm64_linux_kernel_header grub_uint32_t hdr_offset; /* Offset of PE/COFF header */ }; -/* Declare the functions for getting dtb and checking/booting image */ -void *grub_linux_get_fdt (void); grub_err_t grub_arm64_uefi_check_image (struct grub_arm64_linux_kernel_header *lh); grub_err_t grub_arm64_uefi_boot_image (grub_addr_t addr, grub_size_t size, From 83cb45e98261a2159e20a430f761c533b1cf3b05 Mon Sep 17 00:00:00 2001 From: Fu Wei Date: Thu, 29 Oct 2015 15:24:20 +0100 Subject: [PATCH 519/722] arm64: Add support for xen boot protocol. --- grub-core/Makefile.core.def | 7 + grub-core/loader/arm64/xen_boot.c | 596 ++++++++++++++++++++++++++++++ 2 files changed, 603 insertions(+) create mode 100644 grub-core/loader/arm64/xen_boot.c diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def index 19ed47362..2ef10d1af 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def @@ -1646,6 +1646,13 @@ module = { enable = x86; }; +module = { + name = xen_boot; + common = lib/cmdline.c; + arm64 = loader/arm64/xen_boot.c; + enable = arm64; +}; + module = { name = linux; x86 = loader/i386/linux.c; diff --git a/grub-core/loader/arm64/xen_boot.c b/grub-core/loader/arm64/xen_boot.c new file mode 100644 index 000000000..fc5bb0c86 --- /dev/null +++ b/grub-core/loader/arm64/xen_boot.c @@ -0,0 +1,596 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2014 Free Software Foundation, Inc. + * + * GRUB is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GRUB is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GRUB. If not, see . + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include /* required by struct xen_hypervisor_header */ +#include +#include + +GRUB_MOD_LICENSE ("GPLv3+"); + +#define XEN_HYPERVISOR_NAME "xen_hypervisor" + +#define MODULE_DEFAULT_ALIGN (0x0) +#define MODULE_IMAGE_MIN_ALIGN MODULE_DEFAULT_ALIGN +#define MODULE_INITRD_MIN_ALIGN MODULE_DEFAULT_ALIGN +#define MODULE_XSM_MIN_ALIGN MODULE_DEFAULT_ALIGN +#define MODULE_CUSTOM_MIN_ALIGN MODULE_DEFAULT_ALIGN + +#define MODULE_IMAGE_COMPATIBLE "multiboot,kernel\0multiboot,module" +#define MODULE_INITRD_COMPATIBLE "multiboot,ramdisk\0multiboot,module" +#define MODULE_XSM_COMPATIBLE "xen,xsm-policy\0multiboot,module" +#define MODULE_CUSTOM_COMPATIBLE "multiboot,module" + +/* This maximum size is defined in Power.org ePAPR V1.1 + * https://www.power.org/documentation/epapr-version-1-1/ + * 2.2.1.1 Node Name Requirements + * node-name@unit-address + * 31 + 1(@) + 16(64bit address in hex format) + 1(\0) = 49 + */ +#define FDT_NODE_NAME_MAX_SIZE (49) + +struct compat_string_struct +{ + grub_size_t size; + const char *compat_string; +}; +typedef struct compat_string_struct compat_string_struct_t; +#define FDT_COMPATIBLE(x) {.size = sizeof(x), .compat_string = (x)} + +enum module_type +{ + MODULE_IMAGE, + MODULE_INITRD, + MODULE_XSM, + MODULE_CUSTOM +}; +typedef enum module_type module_type_t; + +struct fdt_node_info +{ + module_type_t type; + + const char *compat_string; + grub_size_t compat_string_size; +}; + +struct xen_hypervisor_header +{ + struct grub_arm64_linux_kernel_header efi_head; + + /* This is always PE\0\0. */ + grub_uint8_t signature[GRUB_PE32_SIGNATURE_SIZE]; + /* The COFF file header. */ + struct grub_pe32_coff_header coff_header; + /* The Optional header. */ + struct grub_pe64_optional_header optional_header; +}; + +struct xen_boot_binary +{ + struct xen_boot_binary *next; + struct xen_boot_binary **prev; + const char *name; + + grub_addr_t start; + grub_size_t size; + grub_size_t align; + + char *cmdline; + int cmdline_size; + + struct fdt_node_info node_info; +}; + +static grub_dl_t my_mod; + +static int loaded; + +static struct xen_boot_binary *xen_hypervisor; +static struct xen_boot_binary *module_head; +static const grub_size_t module_default_align[] = { + MODULE_IMAGE_MIN_ALIGN, + MODULE_INITRD_MIN_ALIGN, + MODULE_XSM_MIN_ALIGN, + MODULE_CUSTOM_MIN_ALIGN +}; + +static const compat_string_struct_t default_compat_string[] = { + FDT_COMPATIBLE (MODULE_IMAGE_COMPATIBLE), + FDT_COMPATIBLE (MODULE_INITRD_COMPATIBLE), + FDT_COMPATIBLE (MODULE_XSM_COMPATIBLE), + FDT_COMPATIBLE (MODULE_CUSTOM_COMPATIBLE) +}; + +static __inline grub_addr_t +xen_boot_address_align (grub_addr_t start, grub_size_t align) +{ + return (align ? (ALIGN_UP (start, align)) : start); +} + +/* Parse the option of xen_module command. For now, we support + (1) --type + We also set up the type of module in this function. + If there are some "--type" options in the command line, + we make a custom compatible stream in this function. */ +static grub_err_t +set_module_type (grub_command_t cmd, struct xen_boot_binary *module, int *file_name_index) +{ + *file_name_index = 0; + + if (!grub_strcmp (cmd->name, "xen_linux")) + module->node_info.type = MODULE_IMAGE; + else if (!grub_strcmp (cmd->name, "xen_initrd")) + module->node_info.type = MODULE_INITRD; + else if (!grub_strcmp (cmd->name, "xen_xsm")) + module->node_info.type = MODULE_XSM; + + return GRUB_ERR_NONE; +} + +static grub_err_t +prepare_xen_hypervisor_params (void *xen_boot_fdt) +{ + int chosen_node = 0; + int retval; + + chosen_node = grub_fdt_find_subnode (xen_boot_fdt, 0, "chosen"); + if (chosen_node < 0) + chosen_node = grub_fdt_add_subnode (xen_boot_fdt, 0, "chosen"); + if (chosen_node < 1) + return grub_error (GRUB_ERR_IO, "failed to get chosen node in FDT"); + + grub_dprintf ("xen_loader", + "Xen Hypervisor cmdline : %s @ %p size:%d\n", + xen_hypervisor->cmdline, xen_hypervisor->cmdline, + xen_hypervisor->cmdline_size); + + retval = grub_fdt_set_prop (xen_boot_fdt, chosen_node, "bootargs", + xen_hypervisor->cmdline, + xen_hypervisor->cmdline_size); + if (retval) + return grub_error (GRUB_ERR_IO, "failed to install/update FDT"); + + return GRUB_ERR_NONE; +} + +static grub_err_t +prepare_xen_module_params (struct xen_boot_binary *module, void *xen_boot_fdt) +{ + int retval, chosen_node = 0, module_node = 0; + char module_name[FDT_NODE_NAME_MAX_SIZE]; + + retval = grub_snprintf (module_name, FDT_NODE_NAME_MAX_SIZE, "module@%lx", + xen_boot_address_align (module->start, + module->align)); + grub_dprintf ("xen_loader", "Module node name %s \n", module_name); + + if (retval < (int) sizeof ("module@")) + return grub_error (GRUB_ERR_IO, N_("failed to get FDT")); + + chosen_node = grub_fdt_find_subnode (xen_boot_fdt, 0, "chosen"); + if (chosen_node < 0) + chosen_node = grub_fdt_add_subnode (xen_boot_fdt, 0, "chosen"); + if (chosen_node < 1) + return grub_error (GRUB_ERR_IO, "failed to get chosen node in FDT"); + + module_node = + grub_fdt_find_subnode (xen_boot_fdt, chosen_node, module_name); + if (module_node < 0) + module_node = + grub_fdt_add_subnode (xen_boot_fdt, chosen_node, module_name); + + retval = grub_fdt_set_prop (xen_boot_fdt, module_node, "compatible", + module->node_info.compat_string, + (grub_uint32_t) module-> + node_info.compat_string_size); + if (retval) + return grub_error (GRUB_ERR_IO, "failed to update FDT"); + + grub_dprintf ("xen_loader", "Module %s compatible = %s size = 0x%lx\n", + module->name, module->node_info.compat_string, + module->node_info.compat_string_size); + + retval = grub_fdt_set_reg64 (xen_boot_fdt, module_node, + xen_boot_address_align (module->start, + module->align), + module->size); + if (retval) + return grub_error (GRUB_ERR_IO, "failed to update FDT"); + + if (module->cmdline && module->cmdline_size > 0) + { + grub_dprintf ("xen_loader", + "Module %s cmdline : %s @ %p size:%d\n", module->name, + module->cmdline, module->cmdline, module->cmdline_size); + + retval = grub_fdt_set_prop (xen_boot_fdt, module_node, "bootargs", + module->cmdline, module->cmdline_size + 1); + if (retval) + return grub_error (GRUB_ERR_IO, "failed to update FDT"); + } + else + { + grub_dprintf ("xen_loader", "Module %s has not bootargs!\n", + module->name); + } + + return GRUB_ERR_NONE; +} + +static grub_err_t +finalize_params_xen_boot (void) +{ + struct xen_boot_binary *module; + void *xen_boot_fdt; + grub_size_t additional_size = 0x1000; + + /* Hypervisor. */ + additional_size += FDT_NODE_NAME_MAX_SIZE + xen_hypervisor->cmdline_size; + FOR_LIST_ELEMENTS (module, module_head) + { + additional_size += 6 * FDT_NODE_NAME_MAX_SIZE + module-> + node_info.compat_string_size + module->cmdline_size; + } + + xen_boot_fdt = grub_fdt_load (additional_size); + if (!xen_boot_fdt) + return grub_error (GRUB_ERR_IO, "failed to get FDT"); + + if (xen_hypervisor) + { + if (prepare_xen_hypervisor_params (xen_boot_fdt) != GRUB_ERR_NONE) + goto fail; + } + else + { + grub_dprintf ("xen_loader", "Failed to get Xen Hypervisor info!\n"); + goto fail; + } + + /* Set module params info */ + FOR_LIST_ELEMENTS (module, module_head) + { + if (module->start && module->size > 0) + { + grub_dprintf ("xen_loader", "Module %s @ 0x%lx size:0x%lx\n", + module->name, + xen_boot_address_align (module->start, module->align), + module->size); + if (prepare_xen_module_params (module, xen_boot_fdt) != GRUB_ERR_NONE) + goto fail; + } + else + { + grub_dprintf ("xen_loader", "Module info error: %s!\n", module->name); + goto fail; + } + } + + if (grub_fdt_install() == GRUB_ERR_NONE) + return GRUB_ERR_NONE; + +fail: + grub_fdt_unload (); + + return grub_error (GRUB_ERR_IO, "failed to install/update FDT"); +} + + +static grub_err_t +xen_boot (void) +{ + grub_err_t err = finalize_params_xen_boot (); + if (err) + return err; + + return grub_arm64_uefi_boot_image (xen_hypervisor->start, + xen_hypervisor->size, + xen_hypervisor->cmdline); +} + +static void +single_binary_unload (struct xen_boot_binary *binary) +{ + if (!binary) + return; + + if (binary->start && binary->size > 0) + { + grub_efi_free_pages ((grub_efi_physical_address_t) binary->start, + GRUB_EFI_BYTES_TO_PAGES (binary->size + binary->align)); + } + + if (binary->cmdline && binary->cmdline_size > 0) + { + grub_free (binary->cmdline); + grub_dprintf ("xen_loader", + "Module %s cmdline memory free @ %p size: %d\n", + binary->name, binary->cmdline, binary->cmdline_size); + } + + if (binary->node_info.type == MODULE_CUSTOM) + grub_free ((void *) binary->node_info.compat_string); + + if (grub_strcmp (binary->name, XEN_HYPERVISOR_NAME)) + grub_list_remove (GRUB_AS_LIST (binary)); + + grub_dprintf ("xen_loader", + "Module %s struct memory free @ %p size: 0x%lx\n", + binary->name, binary, sizeof (binary)); + grub_free (binary); + + return; +} + +static void +all_binaries_unload (void) +{ + struct xen_boot_binary *binary; + + FOR_LIST_ELEMENTS (binary, module_head) + { + single_binary_unload (binary); + } + + if (xen_hypervisor) + single_binary_unload (xen_hypervisor); + + return; +} + +static grub_err_t +xen_unload (void) +{ + loaded = 0; + all_binaries_unload (); + grub_fdt_unload (); + grub_dl_unref (my_mod); + + return GRUB_ERR_NONE; +} + +static void +xen_boot_binary_load (struct xen_boot_binary *binary, grub_file_t file, + int argc, char *argv[]) +{ + binary->size = grub_file_size (file); + grub_dprintf ("xen_loader", "Xen_boot %s file size: 0x%lx\n", + binary->name, binary->size); + + binary->start + = (grub_addr_t) grub_efi_allocate_pages (0, + GRUB_EFI_BYTES_TO_PAGES + (binary->size + + binary->align)); + if (!binary->start) + { + grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("out of memory")); + return; + } + + grub_dprintf ("xen_loader", "Xen_boot %s numpages: 0x%lx\n", + binary->name, GRUB_EFI_BYTES_TO_PAGES (binary->size + binary->align)); + + if (grub_file_read (file, (void *) xen_boot_address_align (binary->start, + binary->align), + binary->size) != (grub_ssize_t) binary->size) + { + single_binary_unload (binary); + grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"), argv[0]); + return; + } + + if (argc > 1) + { + binary->cmdline_size = grub_loader_cmdline_size (argc - 1, argv + 1); + binary->cmdline = grub_zalloc (binary->cmdline_size); + if (!binary->cmdline) + { + single_binary_unload (binary); + grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("out of memory")); + return; + } + grub_create_loader_cmdline (argc - 1, argv + 1, binary->cmdline, + binary->cmdline_size); + grub_dprintf ("xen_loader", + "Xen_boot %s cmdline @ %p %s, size: %d\n", binary->name, + binary->cmdline, binary->cmdline, binary->cmdline_size); + } + else + { + binary->cmdline_size = 0; + binary->cmdline = NULL; + } + + grub_errno = GRUB_ERR_NONE; + return; +} + +static grub_err_t +grub_cmd_xen_module (grub_command_t cmd, int argc, char *argv[]) +{ + + struct xen_boot_binary *module = NULL; + int file_name_index = 0; + grub_file_t file = 0; + + if (!argc) + { + grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected")); + goto fail; + } + + if (!loaded) + { + grub_error (GRUB_ERR_BAD_ARGUMENT, + N_("you need to load the Xen Hypervisor first")); + goto fail; + } + + module = + (struct xen_boot_binary *) grub_zalloc (sizeof (struct xen_boot_binary)); + if (!module) + return grub_errno; + + /* process all the options and get module type */ + if (set_module_type (cmd, module, &file_name_index) != + GRUB_ERR_NONE) + goto fail; + switch (module->node_info.type) + { + case MODULE_IMAGE: + case MODULE_INITRD: + case MODULE_XSM: + module->node_info.compat_string = + default_compat_string[module->node_info.type].compat_string; + module->node_info.compat_string_size = + default_compat_string[module->node_info.type].size; + break; + + case MODULE_CUSTOM: + /* we have set the node_info in set_module_type */ + break; + + default: + return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("invalid argument")); + } + module->name = module->node_info.compat_string; + module->align = module_default_align[module->node_info.type]; + + grub_dprintf ("xen_loader", "Init %s module and node info:\n" + "compatible %s\ncompat_string_size 0x%lx\n", + module->name, module->node_info.compat_string, + module->node_info.compat_string_size); + + file = grub_file_open (argv[file_name_index]); + if (!file) + goto fail; + + xen_boot_binary_load (module, file, argc - file_name_index, + argv + file_name_index); + if (grub_errno == GRUB_ERR_NONE) + grub_list_push (GRUB_AS_LIST_P (&module_head), GRUB_AS_LIST (module)); + +fail: + if (file) + grub_file_close (file); + if (grub_errno != GRUB_ERR_NONE) + single_binary_unload (module); + + return grub_errno; +} + +static grub_err_t +grub_cmd_xen_hypervisor (grub_command_t cmd __attribute__ ((unused)), + int argc, char *argv[]) +{ + struct xen_hypervisor_header sh; + grub_file_t file = NULL; + + grub_dl_ref (my_mod); + + if (!argc) + { + grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected")); + goto fail; + } + + file = grub_file_open (argv[0]); + if (!file) + goto fail; + + if (grub_file_read (file, &sh, sizeof (sh)) != (long) sizeof (sh)) + goto fail; + if (grub_arm64_uefi_check_image + ((struct grub_arm64_linux_kernel_header *) &sh) != GRUB_ERR_NONE) + goto fail; + grub_file_seek (file, 0); + + /* if another module has called grub_loader_set, + we need to make sure that another module is unloaded properly */ + grub_loader_unset (); + + xen_hypervisor = + (struct xen_boot_binary *) grub_zalloc (sizeof (struct xen_boot_binary)); + if (!xen_hypervisor) + return grub_errno; + + xen_hypervisor->name = XEN_HYPERVISOR_NAME; + xen_hypervisor->align = (grub_size_t) sh.optional_header.section_alignment; + + xen_boot_binary_load (xen_hypervisor, file, argc, argv); + if (grub_errno == GRUB_ERR_NONE) + { + grub_loader_set (xen_boot, xen_unload, 0); + loaded = 1; + } + +fail: + if (file) + grub_file_close (file); + if (grub_errno != GRUB_ERR_NONE) + { + loaded = 0; + all_binaries_unload (); + grub_dl_unref (my_mod); + } + + return grub_errno; +} + +static grub_command_t cmd_xen_hypervisor; +static grub_command_t cmd_xen_linux, cmd_xen_initrd, cmd_xen_xsm; + +GRUB_MOD_INIT (xen_boot) +{ + cmd_xen_hypervisor = + grub_register_command ("xen_hypervisor", grub_cmd_xen_hypervisor, 0, + N_("Load a xen hypervisor.")); + cmd_xen_linux = + grub_register_command ("xen_linux", grub_cmd_xen_module, 0, + N_("Load a xen linux kernel for dom0.")); + cmd_xen_initrd = + grub_register_command ("xen_initrd", grub_cmd_xen_module, 0, + N_("Load a xen initrd for dom0.")); + cmd_xen_xsm = + grub_register_command ("xen_xsm", grub_cmd_xen_module, 0, + N_("Load a xen security module.")); + my_mod = mod; +} + +GRUB_MOD_FINI (xen_boot) +{ + grub_unregister_command (cmd_xen_hypervisor); + grub_unregister_command (cmd_xen_linux); + grub_unregister_command (cmd_xen_initrd); + grub_unregister_command (cmd_xen_xsm); +} From 43c83102440f193847005598c6f51b6c95642a90 Mon Sep 17 00:00:00 2001 From: Ignat Korchagin Date: Thu, 29 Oct 2015 16:30:28 +0100 Subject: [PATCH 520/722] tcp: Fix uninited mac address when accepting connection. --- grub-core/net/tcp.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/grub-core/net/tcp.c b/grub-core/net/tcp.c index 1d90f1ec5..9e81a0a85 100644 --- a/grub-core/net/tcp.c +++ b/grub-core/net/tcp.c @@ -498,11 +498,22 @@ grub_net_tcp_accept (grub_net_tcp_socket_t sock, struct grub_net_buff *nb_ack; struct tcphdr *tcph; grub_err_t err; + grub_net_network_level_address_t gateway; + struct grub_net_network_level_interface *inf; sock->recv_hook = recv_hook; sock->error_hook = error_hook; sock->fin_hook = fin_hook; sock->hook_data = hook_data; + + err = grub_net_route_address (sock->out_nla, &gateway, &inf); + if (err) + return err; + + err = grub_net_link_layer_resolve (sock->inf, &gateway, &(sock->ll_target_addr)); + if (err) + return err; + nb_ack = grub_netbuff_alloc (sizeof (*tcph) + GRUB_NET_OUR_MAX_IP_HEADER_SIZE + GRUB_NET_MAX_LINK_HEADER_SIZE); From 33b1103e303a6112315257ddad9d771088ba813f Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Thu, 29 Oct 2015 21:29:12 +0300 Subject: [PATCH 521/722] NEWS: mention powerpc64le support --- NEWS | 2 ++ 1 file changed, 2 insertions(+) diff --git a/NEWS b/NEWS index 4abd873de..2db2f87a9 100644 --- a/NEWS +++ b/NEWS @@ -88,6 +88,7 @@ New in 2.02: * Support *-emu on Windows. * New platform `none' which builds only user level utilities. This is now default if target CPU is not supported. + * Support for booting little-endian Linux kernel on powerpc. * Security: * Add optional facility to enforce that all files read by the core image @@ -150,6 +151,7 @@ New in 2.02: directly. This removes requirement for target-specific runtime on build system. * emu libusb support removed (was broken and unmaintained). + * powerpc64le compile support. * Revision control moved to git. From 5b7b4d97812e9f539265f3f98bf5cfb83dfeb3d0 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 6 Nov 2015 04:31:23 +0100 Subject: [PATCH 522/722] README: Remove dead link to the wiki --- README | 2 -- 1 file changed, 2 deletions(-) diff --git a/README b/README index b30a4b68b..685b01657 100644 --- a/README +++ b/README @@ -12,8 +12,6 @@ The URL is . More extensive documentation is available in the Info manual, accessible using 'info grub' after building and installing GRUB 2. -Please look at the GRUB Wiki for testing -procedures. There are a number of important user-visible differences from the first version of GRUB, now known as GRUB Legacy. For a summary, please From cd6d79cda2487b3cc1a2955116a65746b669878b Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 6 Nov 2015 04:32:34 +0100 Subject: [PATCH 523/722] configure.ac: Explicitly add -mno-sse3 on x86. --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 21691c15c..9e8a606a6 100644 --- a/configure.ac +++ b/configure.ac @@ -783,7 +783,7 @@ fi if ( test "x$target_cpu" = xi386 || test "x$target_cpu" = xx86_64 ) && test "x$platform" != xemu; then # Some toolchains enable these features by default, but they need # registers that aren't set up properly in GRUB. - TARGET_CFLAGS="$TARGET_CFLAGS -mno-mmx -mno-sse -mno-sse2 -mno-3dnow" + TARGET_CFLAGS="$TARGET_CFLAGS -mno-mmx -mno-sse -mno-sse2 -mno-sse3 -mno-3dnow" fi # GRUB doesn't use float or doubles at all. Yet some toolchains may decide From 1018e91dce8bd5c60c073c16209b979b033460a7 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Fri, 6 Nov 2015 21:33:28 +0300 Subject: [PATCH 524/722] mkimage: zero fill alignment space This did not cause real problem but is good for reproducible builds. I hit it with recent bootinfoscript that displays embedded config; I was puzzled by random garbage at the end. Prezero memory buffer used to assemble core.img. This makes individual memset redundant. Also ensure buffer is filled with zeroes in several other places. Also remove redundant zeroing code where we fill in the whole memory block anyway. --- util/grub-mkimagexx.c | 3 ++- util/mkimage.c | 30 +++++++++--------------------- 2 files changed, 11 insertions(+), 22 deletions(-) diff --git a/util/grub-mkimagexx.c b/util/grub-mkimagexx.c index 3c76d0708..a1ddc6269 100644 --- a/util/grub-mkimagexx.c +++ b/util/grub-mkimagexx.c @@ -101,7 +101,7 @@ SUFFIX (generate_elf) (const struct grub_install_image_target_desc *image_target program_size = ALIGN_ADDR (*core_size); elf_img = xmalloc (program_size + header_size + footer_size); - memset (elf_img, 0, program_size + header_size); + memset (elf_img, 0, program_size + header_size + footer_size); memcpy (elf_img + header_size, *core_img, *core_size); ehdr = (void *) elf_img; phdr = (void *) (elf_img + sizeof (*ehdr)); @@ -1587,6 +1587,7 @@ SUFFIX (load_image) (const char *kernel_path, size_t *exec_size, } out_img = xmalloc (*kernel_sz + total_module_size); + memset (out_img, 0, *kernel_sz + total_module_size); if (image_target->id == IMAGE_EFI) { diff --git a/util/mkimage.c b/util/mkimage.c index 35df99871..dc4046185 100644 --- a/util/mkimage.c +++ b/util/mkimage.c @@ -992,7 +992,7 @@ grub_install_generate_image (const char *dir, const char *prefix, { char *kernel_img, *core_img; size_t kernel_size, total_module_size, core_size, exec_size; - size_t memdisk_size = 0, config_size = 0, config_size_pure = 0; + size_t memdisk_size = 0, config_size = 0; size_t prefix_size = 0; char *kernel_path; size_t offset; @@ -1043,8 +1043,7 @@ grub_install_generate_image (const char *dir, const char *prefix, if (config_path) { - config_size_pure = grub_util_get_image_size (config_path) + 1; - config_size = ALIGN_ADDR (config_size_pure); + config_size = ALIGN_ADDR (grub_util_get_image_size (config_path) + 1); grub_util_info ("the size of config file is 0x%" GRUB_HOST_PRIxLONG_LONG, (unsigned long long) config_size); total_module_size += config_size + sizeof (struct grub_module_header); @@ -1080,7 +1079,10 @@ grub_install_generate_image (const char *dir, const char *prefix, = grub_host_to_target32 (total_module_size); if (image_target->flags & PLATFORM_FLAGS_MODULES_BEFORE_KERNEL) - memmove (kernel_img + total_module_size, kernel_img, kernel_size); + { + memmove (kernel_img + total_module_size, kernel_img, kernel_size); + memset (kernel_img, 0, total_module_size); + } if (image_target->voidp_sizeof == 8) { @@ -1090,7 +1092,6 @@ grub_install_generate_image (const char *dir, const char *prefix, modinfo = (struct grub_module_info64 *) kernel_img; else modinfo = (struct grub_module_info64 *) (kernel_img + kernel_size); - memset (modinfo, 0, sizeof (struct grub_module_info64)); modinfo->magic = grub_host_to_target32 (GRUB_MODULE_MAGIC); modinfo->offset = grub_host_to_target_addr (sizeof (struct grub_module_info64)); modinfo->size = grub_host_to_target_addr (total_module_size); @@ -1107,7 +1108,6 @@ grub_install_generate_image (const char *dir, const char *prefix, modinfo = (struct grub_module_info32 *) kernel_img; else modinfo = (struct grub_module_info32 *) (kernel_img + kernel_size); - memset (modinfo, 0, sizeof (struct grub_module_info32)); modinfo->magic = grub_host_to_target32 (GRUB_MODULE_MAGIC); modinfo->offset = grub_host_to_target_addr (sizeof (struct grub_module_info32)); modinfo->size = grub_host_to_target_addr (total_module_size); @@ -1120,17 +1120,14 @@ grub_install_generate_image (const char *dir, const char *prefix, for (p = path_list; p; p = p->next) { struct grub_module_header *header; - size_t mod_size, orig_size; + size_t mod_size; - orig_size = grub_util_get_image_size (p->name); - mod_size = ALIGN_ADDR (orig_size); + mod_size = ALIGN_ADDR (grub_util_get_image_size (p->name)); header = (struct grub_module_header *) (kernel_img + offset); - memset (header, 0, sizeof (struct grub_module_header)); header->type = grub_host_to_target32 (OBJ_TYPE_ELF); header->size = grub_host_to_target32 (mod_size + sizeof (*header)); offset += sizeof (*header); - memset (kernel_img + offset + orig_size, 0, mod_size - orig_size); grub_util_load_image (p->name, kernel_img + offset); offset += mod_size; @@ -1146,7 +1143,6 @@ grub_install_generate_image (const char *dir, const char *prefix, curs = grub_util_get_image_size (pubkey_paths[i]); header = (struct grub_module_header *) (kernel_img + offset); - memset (header, 0, sizeof (struct grub_module_header)); header->type = grub_host_to_target32 (OBJ_TYPE_PUBKEY); header->size = grub_host_to_target32 (curs + sizeof (*header)); offset += sizeof (*header); @@ -1161,7 +1157,6 @@ grub_install_generate_image (const char *dir, const char *prefix, struct grub_module_header *header; header = (struct grub_module_header *) (kernel_img + offset); - memset (header, 0, sizeof (struct grub_module_header)); header->type = grub_host_to_target32 (OBJ_TYPE_MEMDISK); header->size = grub_host_to_target32 (memdisk_size + sizeof (*header)); offset += sizeof (*header); @@ -1175,13 +1170,11 @@ grub_install_generate_image (const char *dir, const char *prefix, struct grub_module_header *header; header = (struct grub_module_header *) (kernel_img + offset); - memset (header, 0, sizeof (struct grub_module_header)); header->type = grub_host_to_target32 (OBJ_TYPE_CONFIG); header->size = grub_host_to_target32 (config_size + sizeof (*header)); offset += sizeof (*header); grub_util_load_image (config_path, kernel_img + offset); - *(kernel_img + offset + config_size_pure - 1) = 0; offset += config_size; } @@ -1190,12 +1183,10 @@ grub_install_generate_image (const char *dir, const char *prefix, struct grub_module_header *header; header = (struct grub_module_header *) (kernel_img + offset); - memset (header, 0, sizeof (struct grub_module_header)); header->type = grub_host_to_target32 (OBJ_TYPE_PREFIX); header->size = grub_host_to_target32 (prefix_size + sizeof (*header)); offset += sizeof (*header); - grub_memset (kernel_img + offset, 0, prefix_size); grub_strcpy (kernel_img + offset, prefix); offset += prefix_size; } @@ -1269,15 +1260,11 @@ grub_install_generate_image (const char *dir, const char *prefix, full_size = core_size + decompress_size; full_img = xmalloc (full_size); - memset (full_img, 0, full_size); memcpy (full_img, decompress_img, decompress_size); memcpy (full_img + decompress_size, core_img, core_size); - memset (full_img + decompress_size + core_size, 0, - full_size - (decompress_size + core_size)); - free (core_img); core_img = full_img; core_size = full_size; @@ -1428,6 +1415,7 @@ grub_install_generate_image (const char *dir, const char *prefix, pe_img = xmalloc (reloc_addr + reloc_size); memset (pe_img, 0, header_size); memcpy ((char *) pe_img + header_size, core_img, core_size); + memset ((char *) pe_img + header_size + core_size, 0, reloc_addr - (header_size + core_size)); memcpy ((char *) pe_img + reloc_addr, rel_section, reloc_size); header = pe_img; From 349a381df0ce2e809506f7b166bf952f97407330 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sat, 7 Nov 2015 09:46:46 +0300 Subject: [PATCH 525/722] devmapper/getroot: use makedev instead of direct shift Fixes device detection with large number of devices. Reported by Tim Wallberg --- grub-core/osdep/devmapper/getroot.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/grub-core/osdep/devmapper/getroot.c b/grub-core/osdep/devmapper/getroot.c index 0a77a04b9..64419f678 100644 --- a/grub-core/osdep/devmapper/getroot.c +++ b/grub-core/osdep/devmapper/getroot.c @@ -208,8 +208,7 @@ grub_util_devmapper_part_to_disk (struct stat *st, &major, &minor, 0)) { *is_part = 1; - return grub_find_device ("/dev", - (major << 8) | minor); + return grub_find_device ("/dev", makedev (major, minor)); } *is_part = 0; return xstrdup (path); From c1fbc262032ede5d59d0db8fa7ff24dd1fcd062a Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sat, 7 Nov 2015 13:01:23 +0300 Subject: [PATCH 526/722] Add comments to code for commit d313218 --- grub-core/kern/file.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/grub-core/kern/file.c b/grub-core/kern/file.c index 3367485fb..668f8930b 100644 --- a/grub-core/kern/file.c +++ b/grub-core/kern/file.c @@ -89,6 +89,11 @@ grub_file_open (const char *name) file->device = device; + /* In case of relative pathnames and non-Unix systems (like Windows) + * name of host files may not start with `/'. Blocklists for host files + * are meaningless as well (for a start, host disk does not allow any direct + * access - it is just a marker). So skip host disk in this case. + */ if (device->disk && file_name[0] != '/' #if defined(GRUB_UTIL) || defined(GRUB_MACHINE_EMU) && grub_strcmp (device->disk->name, "host") From dff8d0e3f59c1f1888527078c3a04f863ce33e64 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sat, 7 Nov 2015 17:02:21 +0300 Subject: [PATCH 527/722] unix/getroot: remove unused MAJOR definition We use major() everywhere, these definitions just add to confusion. --- grub-core/osdep/unix/getroot.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/grub-core/osdep/unix/getroot.c b/grub-core/osdep/unix/getroot.c index 14d483fb1..1079a919d 100644 --- a/grub-core/osdep/unix/getroot.c +++ b/grub-core/osdep/unix/getroot.c @@ -45,12 +45,6 @@ #ifdef __linux__ #include /* ioctl */ #include -#ifndef MAJOR -# ifndef MINORBITS -# define MINORBITS 8 -# endif /* ! MINORBITS */ -# define MAJOR(dev) ((unsigned) ((dev) >> MINORBITS)) -#endif /* ! MAJOR */ #ifndef FLOPPY_MAJOR # define FLOPPY_MAJOR 2 #endif /* ! FLOPPY_MAJOR */ @@ -73,7 +67,6 @@ #include #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) -# define MAJOR(dev) major(dev) # define FLOPPY_MAJOR 2 #endif @@ -90,7 +83,6 @@ #endif /* defined(__NetBSD__) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__) */ #if defined(__NetBSD__) || defined(__OpenBSD__) -# define MAJOR(dev) major(dev) # ifdef HAVE_GETRAWPARTITION # include /* getrawpartition */ # endif /* HAVE_GETRAWPARTITION */ From bcf8c5814d8499bebe913ddc1f9c6a85bc45a02e Mon Sep 17 00:00:00 2001 From: Andrey Borzenkov Date: Sat, 7 Nov 2015 17:03:38 +0300 Subject: [PATCH 528/722] doc: document config_directory and config_file variables --- docs/grub.texi | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/docs/grub.texi b/docs/grub.texi index b9f41a73e..db765a3b5 100644 --- a/docs/grub.texi +++ b/docs/grub.texi @@ -3038,6 +3038,8 @@ These variables have special meaning to GRUB. * cmdpath:: * color_highlight:: * color_normal:: +* config_directory:: +* config_file:: * debug:: * default:: * fallback:: @@ -3180,6 +3182,22 @@ matching colors of first half. to support whole rgb24 palette but currently there is no compelling reason to go beyond the current 16 colors. + +@node config_directory +@subsection config_directory + +This variable is automatically set by GRUB to the directory part of +current configuration file name (@pxref{config_file}). + + +@node config_file +@subsection config_file + +This variable is automatically set by GRUB to the name of configuration file that is being +processed by commands @command{configfile} (@pxref{configfile}) or @command{normal} +(@pxref{normal}). It is restored to the previous value when command completes. + + @node debug @subsection debug From c7f93a20c47f712d45cd97fdfd43e0715ae855e3 Mon Sep 17 00:00:00 2001 From: "grub-devel@iam.tj" Date: Sat, 7 Nov 2015 18:52:59 +0300 Subject: [PATCH 529/722] cryptodisk: teach grub_cryptodisk_insert() about partitions (bug #45889) It is not possible to configure encrypted containers on multiple partitions of the same disk; after the first one all subsequent fail with disk/cryptodisk.c:978: already mounted as crypto0 Store partition offset in cryptomount descriptor to distinguish between them. --- grub-core/disk/cryptodisk.c | 7 ++++++- include/grub/cryptodisk.h | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/grub-core/disk/cryptodisk.c b/grub-core/disk/cryptodisk.c index 85d68e3b6..1e03a091c 100644 --- a/grub-core/disk/cryptodisk.c +++ b/grub-core/disk/cryptodisk.c @@ -25,6 +25,7 @@ #include #include #include +#include #ifdef GRUB_UTIL #include @@ -718,6 +719,7 @@ grub_cryptodisk_insert (grub_cryptodisk_t newdev, const char *name, newdev->id = last_cryptodisk_id++; newdev->source_id = source->id; newdev->source_dev_id = source->dev->id; + newdev->partition_start = grub_partition_get_start (source->partition); newdev->next = cryptodisk_list; cryptodisk_list = newdev; @@ -740,7 +742,9 @@ grub_cryptodisk_get_by_source_disk (grub_disk_t disk) grub_cryptodisk_t dev; for (dev = cryptodisk_list; dev != NULL; dev = dev->next) if (dev->source_id == disk->id && dev->source_dev_id == disk->dev->id) - return dev; + if ((disk->partition && grub_partition_get_start (disk->partition) == dev->partition_start) || + (!disk->partition && dev->partition_start == 0)) + return dev; return NULL; } @@ -761,6 +765,7 @@ grub_cryptodisk_cheat_insert (grub_cryptodisk_t newdev, const char *name, newdev->cheat_fd = GRUB_UTIL_FD_INVALID; newdev->source_id = source->id; newdev->source_dev_id = source->dev->id; + newdev->partition_start = grub_partition_get_start (source->partition); newdev->id = last_cryptodisk_id++; newdev->next = cryptodisk_list; cryptodisk_list = newdev; diff --git a/include/grub/cryptodisk.h b/include/grub/cryptodisk.h index f2ad2a79a..32f564ae0 100644 --- a/include/grub/cryptodisk.h +++ b/include/grub/cryptodisk.h @@ -97,6 +97,7 @@ struct grub_cryptodisk grub_uint8_t rekey_key[64]; grub_uint64_t last_rekey; int rekey_derived_size; + grub_disk_addr_t partition_start; }; typedef struct grub_cryptodisk *grub_cryptodisk_t; From c054020581c3cf998930cc021cd7a569691bcf9f Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sat, 7 Nov 2015 23:42:35 +0300 Subject: [PATCH 530/722] partmap_test: check that parted is available Skip test if parted is unavailable instead of returning false failure. --- tests/partmap_test.in | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/partmap_test.in b/tests/partmap_test.in index 7786ccfbc..4230ba228 100644 --- a/tests/partmap_test.in +++ b/tests/partmap_test.in @@ -92,6 +92,12 @@ case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in disk=hd0 ;; esac + +if ! which parted >/dev/null 2>&1; then + echo "parted not installed; cannot test partmap" + exit 77 +fi + imgfile="`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"`" || exit 1 outfile="`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"`" || exit 1 From ae66efc63b4ec8d536aaf1da667db71e72f1556b Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sun, 8 Nov 2015 18:45:57 +0100 Subject: [PATCH 531/722] autogen: Use cp instead of ln -s. libgcrypt-grub shouldn't be modified directly anyway. With this patch tarball without contrib can be unpacked on FAT and stay usable for out-of-tree compile on full POSIX FS (compile on FAT not tested). --- autogen.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/autogen.sh b/autogen.sh index 5020456bc..7537561ad 100755 --- a/autogen.sh +++ b/autogen.sh @@ -23,14 +23,14 @@ fi if [ -d grub-core/lib/libgcrypt-grub/mpi/generic ]; then rm -rf grub-core/lib/libgcrypt-grub/mpi/generic fi -ln -s ../../../grub-core/lib/libgcrypt-grub/src/g10lib.h include/grub/gcrypt/g10lib.h +cp grub-core/lib/libgcrypt-grub/src/g10lib.h include/grub/gcrypt/g10lib.h cp -R grub-core/lib/libgcrypt/mpi/generic grub-core/lib/libgcrypt-grub/mpi/generic for x in mpi-asm-defs.h mpih-add1.c mpih-sub1.c mpih-mul1.c mpih-mul2.c mpih-mul3.c mpih-lshift.c mpih-rshift.c; do if [ -h grub-core/lib/libgcrypt-grub/mpi/"$x" ] || [ -f grub-core/lib/libgcrypt-grub/mpi/"$x" ]; then rm grub-core/lib/libgcrypt-grub/mpi/"$x" fi - ln -s generic/"$x" grub-core/lib/libgcrypt-grub/mpi/"$x" + cp grub-core/lib/libgcrypt-grub/mpi/generic/"$x" grub-core/lib/libgcrypt-grub/mpi/"$x" done echo "Generating Automake input..." From 7cc27aeda92846f7c3587f2b465730ccf38c08cb Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sun, 8 Nov 2015 18:47:53 +0100 Subject: [PATCH 532/722] Makefile.core.def: Break circular dependency on arm64. --- grub-core/Makefile.core.def | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def index 2ef10d1af..03e04ab39 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def @@ -1665,7 +1665,6 @@ module = { ia64_efi = loader/ia64/efi/linux.c; arm = loader/arm/linux.c; arm64 = loader/arm64/linux.c; - fdt = lib/fdt.c; common = loader/linux.c; common = lib/cmdline.c; enable = noemu; @@ -1674,7 +1673,8 @@ module = { module = { name = fdt; arm64 = loader/arm64/fdt.c; - enable = arm64; + common = lib/fdt.c; + enable = fdt; }; module = { From db97faec91e63678cb1e9fa57af18948c33cce38 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sun, 8 Nov 2015 20:00:27 +0100 Subject: [PATCH 533/722] genmoddep.awk: Add a test that we have no circular dependencies --- grub-core/genmoddep.awk | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/grub-core/genmoddep.awk b/grub-core/genmoddep.awk index 2f32465c4..bd98d84cd 100644 --- a/grub-core/genmoddep.awk +++ b/grub-core/genmoddep.awk @@ -29,7 +29,7 @@ BEGIN { } } else { - printf "error: %u: unrecognized input format\n", NR; + printf "error: %u: unrecognized input format\n", NR >"/dev/stderr"; error++; } } @@ -39,6 +39,8 @@ END { if (error >= 1) exit 1; + total_depcount = 0 + for (mod in modtab) { # Remove duplications. split(modtab[mod], depmods, " "); @@ -52,14 +54,42 @@ END { uniqmods[depmod] = 1; } modlist = "" + depcount[mod] = 0 for (depmod in uniqmods) { modlist = modlist " " depmod; + inverse_dependencies[depmod] = inverse_dependencies[depmod] " " mod + depcount[mod]++ + total_depcount++ } if (mod == "all_video") { continue; } printf "%s:%s\n", mod, modlist; } + + # Check that we have no dependency circles + while (total_depcount != 0) { + something_done = 0 + for (mod in depcount) { + if (depcount[mod] == 0) { + delete depcount[mod] + split(inverse_dependencies[mod], inv_depmods, " "); + for (ctr in inv_depmods) { + depcount[inv_depmods[ctr]]-- + total_depcount-- + } + delete inverse_dependencies[mod] + something_done = 1 + } + } + if (something_done == 0) { + for (mod in depcount) { + circle = circle " " mod + } + printf "error: modules %s form a dependency circle\n", circle >"/dev/stderr"; + exit 1 + } + } modlist = "" while (getline <"video.lst") { modlist = modlist " " $1; From a39137aefeaec4a6510b166d0ac8c1663627bfdb Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sun, 8 Nov 2015 20:23:15 +0100 Subject: [PATCH 534/722] Remove reliance C.UTF-8 --- po/Rules-translit | 10 +++--- po/cyrillic.sed | 80 +++++++++++++++++++++++++++++++++++++++++++++-- po/greek.sed | 80 +++++++++++++++++++++++++++++++++++++++++++++-- 3 files changed, 161 insertions(+), 9 deletions(-) diff --git a/po/Rules-translit b/po/Rules-translit index 4f9176d30..ab84a5f1f 100644 --- a/po/Rules-translit +++ b/po/Rules-translit @@ -1,16 +1,16 @@ DISTFILES.common.extra4 = hebrew.sed cyrillic.sed greek.sed arabic.sed Rules-translit de@hebrew.po-create: de.po hebrew.sed - LC_ALL=C.UTF-8 $(MSGFILTER) -i $< -o $(srcdir)/de@hebrew.po sed -f $(srcdir)/hebrew.sed + LC_ALL=C $(MSGFILTER) -i $< -o $(srcdir)/de@hebrew.po sed -f $(srcdir)/hebrew.sed en@hebrew.po-create: $(DOMAIN).pot hebrew.sed - LC_ALL=C.UTF-8 $(MSGINIT) -i $(srcdir)/$(DOMAIN).pot --no-translator -l en@hebrew -o - 2>/dev/null | LC_ALL=C.UTF-8 $(MSGCONV) -t UTF-8 | LC_ALL=C.UTF-8 $(MSGFILTER) -o $(srcdir)/en@hebrew.po -i - sed -f $(srcdir)/hebrew.sed + LC_ALL=C $(MSGINIT) -i $(srcdir)/$(DOMAIN).pot --no-translator -l en@hebrew -o - 2>/dev/null | LC_ALL=C $(MSGCONV) -t UTF-8 | LC_ALL=C $(MSGFILTER) -o $(srcdir)/en@hebrew.po -i - sed -f $(srcdir)/hebrew.sed en@cyrillic.po-create: $(DOMAIN).pot cyrillic.sed - LC_ALL=C.UTF-8 $(MSGINIT) -i $(srcdir)/$(DOMAIN).pot --no-translator -l en@cyrillic -o - 2>/dev/null | LC_ALL=C.UTF-8 $(MSGCONV) -t UTF-8 | LC_ALL=C.UTF-8 $(MSGFILTER) -o $(srcdir)/en@cyrillic.po -i - sed -f $(srcdir)/cyrillic.sed + LC_ALL=C $(MSGINIT) -i $(srcdir)/$(DOMAIN).pot --no-translator -l en@cyrillic -o - 2>/dev/null | LC_ALL=C $(MSGCONV) -t UTF-8 | LC_ALL=C $(MSGFILTER) -o $(srcdir)/en@cyrillic.po -i - sed -f $(srcdir)/cyrillic.sed en@greek.po-create: $(DOMAIN).pot greek.sed - LC_ALL=C.UTF-8 $(MSGINIT) -i $(srcdir)/$(DOMAIN).pot --no-translator -l en@greek -o - 2>/dev/null | LC_ALL=C.UTF-8 $(MSGCONV) -t UTF-8 | LC_ALL=C.UTF-8 $(MSGFILTER) -o $(srcdir)/en@greek.po -i - sed -f $(srcdir)/greek.sed + LC_ALL=C $(MSGINIT) -i $(srcdir)/$(DOMAIN).pot --no-translator -l en@greek -o - 2>/dev/null | LC_ALL=C $(MSGCONV) -t UTF-8 | LC_ALL=C $(MSGFILTER) -o $(srcdir)/en@greek.po -i - sed -f $(srcdir)/greek.sed en@arabic.po-create: $(DOMAIN).pot arabic.sed - LC_ALL=C.UTF-8 $(MSGINIT) -i $(srcdir)/$(DOMAIN).pot --no-translator -l en@arabic -o - 2>/dev/null | LC_ALL=C.UTF-8 $(MSGCONV) -t UTF-8 | LC_ALL=C.UTF-8 $(MSGFILTER) -o $(srcdir)/en@arabic.po -i - sed -f $(srcdir)/arabic.sed + LC_ALL=C $(MSGINIT) -i $(srcdir)/$(DOMAIN).pot --no-translator -l en@arabic -o - 2>/dev/null | LC_ALL=C $(MSGCONV) -t UTF-8 | LC_ALL=C $(MSGFILTER) -o $(srcdir)/en@arabic.po -i - sed -f $(srcdir)/arabic.sed diff --git a/po/cyrillic.sed b/po/cyrillic.sed index 46ddaec6e..ffad0ed8c 100644 --- a/po/cyrillic.sed +++ b/po/cyrillic.sed @@ -10,8 +10,84 @@ /^Content-Transfer-Encoding:/ b /^Plural-Forms:/ b -y,abcdefghijklmnopqrstuvwxyz,абцдефгхийклмнопќрÑтувўѯÑз, -y,ABCDEFGHIJKLMNOPQRSTUVWXYZ,ÐБЦДЕФГХИЙКЛМÐОПЌРСТУВЎѮÐЗ, +s,a,а,g +s,b,б,g +s,c,ц,g +s,d,д,g +s,e,е,g +s,f,Ñ„,g +s,g,г,g +s,h,Ñ…,g +s,i,и,g +s,j,й,g +s,k,к,g +s,l,л,g +s,m,м,g +s,n,н,g +s,o,о,g +s,p,п,g +s,q,Ñœ,g +s,r,Ñ€,g +s,s,Ñ,g +s,t,Ñ‚,g +s,u,у,g +s,v,в,g +s,w,Ñž,g +s,x,ѯ,g +s,y,Ñ,g +s,z,з,g +s,A,Ð,g +s,B,Б,g +s,C,Ц,g +s,D,Д,g +s,E,Е,g +s,F,Ф,g +s,G,Г,g +s,H,Ð¥,g +s,I,И,g +s,J,Й,g +s,K,К,g +s,L,Л,g +s,M,М,g +s,N,Ð,g +s,O,О,g +s,P,П,g +s,Q,ÐŒ,g +s,R,Р,g +s,S,С,g +s,T,Т,g +s,U,У,g +s,V,Ð’,g +s,W,ÐŽ,g +s,X,Ñ®,g +s,Y,Ð,g +s,Z,З,g +s,Ð,Ð,g +s,Б,Б,g +s,Ц,Ц,g +s,Д,Д,g +s,Е,Е,g +s,Ф,Ф,g +s,Г,Г,g +s,Ð¥,Ð¥,g +s,И,И,g +s,Й,Й,g +s,К,К,g +s,Л,Л,g +s,М,М,g +s,Ð,Ð,g +s,О,О,g +s,П,П,g +s,ÐŒ,ÐŒ,g +s,Р,Р,g +s,С,С,g +s,Т,Т,g +s,У,У,g +s,Ð’,Ð’,g +s,ÐŽ,ÐŽ,g +s,Ñ®,Ñ®,g +s,Ð,Ð,g +s,З,З,g s,%\([0-9]*\)Ц,%\1C,g s,%\([0-9]*\)ц,%\1c,g diff --git a/po/greek.sed b/po/greek.sed index 17e4b0468..93556c386 100644 --- a/po/greek.sed +++ b/po/greek.sed @@ -12,8 +12,84 @@ s,%\([0-9]*\)C,%\1#,g -y,abcdefghijklmnopqrstuvwxyz,αϭϲδεφγχιϊκλμνοπϗÏστυβωξϋζ, -y,ABCDEFGHIJKLMNOPQRSTUVWXYZ,ΑϬϲΔΕΦΓΧΙΪΚΛΜÎΟΠÏΡΣΤΥΒΩΞΫΖ, +s,a,α,g +s,b,Ï­,g +s,c,ϲ,g +s,d,δ,g +s,e,ε,g +s,f,φ,g +s,g,γ,g +s,h,χ,g +s,i,ι,g +s,j,ÏŠ,g +s,k,κ,g +s,l,λ,g +s,m,μ,g +s,n,ν,g +s,o,ο,g +s,p,Ï€,g +s,q,Ï—,g +s,r,Ï,g +s,s,σ,g +s,t,Ï„,g +s,u,Ï…,g +s,v,β,g +s,w,ω,g +s,x,ξ,g +s,y,Ï‹,g +s,z,ζ,g +s,A,Α,g +s,B,Ϭ,g +s,C,ϲ,g +s,D,Δ,g +s,E,Ε,g +s,F,Φ,g +s,G,Γ,g +s,H,Χ,g +s,I,Ι,g +s,J,Ϊ,g +s,K,Κ,g +s,L,Λ,g +s,M,Μ,g +s,N,Î,g +s,O,Ο,g +s,P,Π,g +s,Q,Ï,g +s,R,Ρ,g +s,S,Σ,g +s,T,Τ,g +s,U,Î¥,g +s,V,Î’,g +s,W,Ω,g +s,X,Ξ,g +s,Y,Ϋ,g +s,Z,Ζ,g +s,Ð,Ð,g +s,Б,Б,g +s,Ц,Ц,g +s,Д,Д,g +s,Е,Е,g +s,Ф,Ф,g +s,Г,Г,g +s,Ð¥,Ð¥,g +s,И,И,g +s,Й,Й,g +s,К,К,g +s,Л,Л,g +s,М,М,g +s,Ð,Ð,g +s,О,О,g +s,П,П,g +s,ÐŒ,ÐŒ,g +s,Р,Р,g +s,С,С,g +s,Т,Т,g +s,У,У,g +s,Ð’,Ð’,g +s,ÐŽ,ÐŽ,g +s,Ñ®,Ñ®,g +s,Ð,Ð,g +s,З,З,g s,%\([0-9]*\)#,%\1C,g s,%\([0-9]*\)ϲ,%\1c,g From 855fe6869cc4407569513a231f2a01cb8215e77f Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sun, 8 Nov 2015 20:34:30 +0100 Subject: [PATCH 535/722] cbfs: Check for ptr range sanity. Triaged by Andrei and enhanced with suggestions by Aaron Durbin Also-By: Andrei Borzenkov --- grub-core/fs/cbfs.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/grub-core/fs/cbfs.c b/grub-core/fs/cbfs.c index a34eb88cb..5fc9c0147 100644 --- a/grub-core/fs/cbfs.c +++ b/grub-core/fs/cbfs.c @@ -344,8 +344,16 @@ init_cbfsdisk (void) ptr = *(grub_uint32_t *) 0xfffffffc; head = (struct cbfs_header *) (grub_addr_t) ptr; + grub_dprintf ("cbfs", "head=%p\n", head); - if (!validate_head (head)) + /* coreboot current supports only ROMs <= 16 MiB. Bigger ROMs will + have problems as RCBA is 18 MiB below end of 32-bit typically, + so either memory map would have to be rearranged or we'd need to support + reading ROMs through controller directly. + */ + if (ptr < 0xff000000 + || 0xffffffff - ptr < sizeof (*head) + 0x10 + || !validate_head (head)) return; cbfsdisk_size = ALIGN_UP (grub_be_to_cpu32 (head->romsize), From e07badcc31babb24ace4f96444bc484502427d3a Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sun, 8 Nov 2015 21:23:52 +0100 Subject: [PATCH 536/722] Import xen headers directly into GRUB --- include/xen/arch-x86/xen-x86_32.h | 171 ++++++ include/xen/arch-x86/xen-x86_64.h | 202 +++++++ include/xen/arch-x86/xen.h | 273 +++++++++ include/xen/event_channel.h | 381 +++++++++++++ include/xen/grant_table.h | 662 ++++++++++++++++++++++ include/xen/io/blkif.h | 608 ++++++++++++++++++++ include/xen/io/console.h | 51 ++ include/xen/io/protocols.h | 40 ++ include/xen/io/ring.h | 312 +++++++++++ include/xen/io/xenbus.h | 80 +++ include/xen/io/xs_wire.h | 138 +++++ include/xen/sched.h | 174 ++++++ include/xen/xen-compat.h | 44 ++ include/xen/xen.h | 899 ++++++++++++++++++++++++++++++ 14 files changed, 4035 insertions(+) create mode 100644 include/xen/arch-x86/xen-x86_32.h create mode 100644 include/xen/arch-x86/xen-x86_64.h create mode 100644 include/xen/arch-x86/xen.h create mode 100644 include/xen/event_channel.h create mode 100644 include/xen/grant_table.h create mode 100644 include/xen/io/blkif.h create mode 100644 include/xen/io/console.h create mode 100644 include/xen/io/protocols.h create mode 100644 include/xen/io/ring.h create mode 100644 include/xen/io/xenbus.h create mode 100644 include/xen/io/xs_wire.h create mode 100644 include/xen/sched.h create mode 100644 include/xen/xen-compat.h create mode 100644 include/xen/xen.h diff --git a/include/xen/arch-x86/xen-x86_32.h b/include/xen/arch-x86/xen-x86_32.h new file mode 100644 index 000000000..15041911e --- /dev/null +++ b/include/xen/arch-x86/xen-x86_32.h @@ -0,0 +1,171 @@ +/****************************************************************************** + * xen-x86_32.h + * + * Guest OS interface to x86 32-bit Xen. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + * Copyright (c) 2004-2007, K A Fraser + */ + +#ifndef __XEN_PUBLIC_ARCH_X86_XEN_X86_32_H__ +#define __XEN_PUBLIC_ARCH_X86_XEN_X86_32_H__ + +/* + * Hypercall interface: + * Input: %ebx, %ecx, %edx, %esi, %edi, %ebp (arguments 1-6) + * Output: %eax + * Access is via hypercall page (set up by guest loader or via a Xen MSR): + * call hypercall_page + hypercall-number * 32 + * Clobbered: Argument registers (e.g., 2-arg hypercall clobbers %ebx,%ecx) + */ + +/* + * These flat segments are in the Xen-private section of every GDT. Since these + * are also present in the initial GDT, many OSes will be able to avoid + * installing their own GDT. + */ +#define FLAT_RING1_CS 0xe019 /* GDT index 259 */ +#define FLAT_RING1_DS 0xe021 /* GDT index 260 */ +#define FLAT_RING1_SS 0xe021 /* GDT index 260 */ +#define FLAT_RING3_CS 0xe02b /* GDT index 261 */ +#define FLAT_RING3_DS 0xe033 /* GDT index 262 */ +#define FLAT_RING3_SS 0xe033 /* GDT index 262 */ + +#define FLAT_KERNEL_CS FLAT_RING1_CS +#define FLAT_KERNEL_DS FLAT_RING1_DS +#define FLAT_KERNEL_SS FLAT_RING1_SS +#define FLAT_USER_CS FLAT_RING3_CS +#define FLAT_USER_DS FLAT_RING3_DS +#define FLAT_USER_SS FLAT_RING3_SS + +#define __HYPERVISOR_VIRT_START_PAE 0xF5800000 +#define __MACH2PHYS_VIRT_START_PAE 0xF5800000 +#define __MACH2PHYS_VIRT_END_PAE 0xF6800000 +#define HYPERVISOR_VIRT_START_PAE \ + mk_unsigned_long(__HYPERVISOR_VIRT_START_PAE) +#define MACH2PHYS_VIRT_START_PAE \ + mk_unsigned_long(__MACH2PHYS_VIRT_START_PAE) +#define MACH2PHYS_VIRT_END_PAE \ + mk_unsigned_long(__MACH2PHYS_VIRT_END_PAE) + +/* Non-PAE bounds are obsolete. */ +#define __HYPERVISOR_VIRT_START_NONPAE 0xFC000000 +#define __MACH2PHYS_VIRT_START_NONPAE 0xFC000000 +#define __MACH2PHYS_VIRT_END_NONPAE 0xFC400000 +#define HYPERVISOR_VIRT_START_NONPAE \ + mk_unsigned_long(__HYPERVISOR_VIRT_START_NONPAE) +#define MACH2PHYS_VIRT_START_NONPAE \ + mk_unsigned_long(__MACH2PHYS_VIRT_START_NONPAE) +#define MACH2PHYS_VIRT_END_NONPAE \ + mk_unsigned_long(__MACH2PHYS_VIRT_END_NONPAE) + +#define __HYPERVISOR_VIRT_START __HYPERVISOR_VIRT_START_PAE +#define __MACH2PHYS_VIRT_START __MACH2PHYS_VIRT_START_PAE +#define __MACH2PHYS_VIRT_END __MACH2PHYS_VIRT_END_PAE + +#ifndef HYPERVISOR_VIRT_START +#define HYPERVISOR_VIRT_START mk_unsigned_long(__HYPERVISOR_VIRT_START) +#endif + +#define MACH2PHYS_VIRT_START mk_unsigned_long(__MACH2PHYS_VIRT_START) +#define MACH2PHYS_VIRT_END mk_unsigned_long(__MACH2PHYS_VIRT_END) +#define MACH2PHYS_NR_ENTRIES ((MACH2PHYS_VIRT_END-MACH2PHYS_VIRT_START)>>2) +#ifndef machine_to_phys_mapping +#define machine_to_phys_mapping ((unsigned long *)MACH2PHYS_VIRT_START) +#endif + +/* 32-/64-bit invariability for control interfaces (domctl/sysctl). */ +#if defined(__XEN__) || defined(__XEN_TOOLS__) +#undef ___DEFINE_XEN_GUEST_HANDLE +#define ___DEFINE_XEN_GUEST_HANDLE(name, type) \ + typedef struct { type *p; } \ + __guest_handle_ ## name; \ + typedef struct { union { type *p; uint64_aligned_t q; }; } \ + __guest_handle_64_ ## name +#undef set_xen_guest_handle_raw +#define set_xen_guest_handle_raw(hnd, val) \ + do { if ( sizeof(hnd) == 8 ) *(uint64_t *)&(hnd) = 0; \ + (hnd).p = val; \ + } while ( 0 ) +#define uint64_aligned_t uint64_t __attribute__((aligned(8))) +#define __XEN_GUEST_HANDLE_64(name) __guest_handle_64_ ## name +#define XEN_GUEST_HANDLE_64(name) __XEN_GUEST_HANDLE_64(name) +#endif + +#ifndef __ASSEMBLY__ + +struct cpu_user_regs { + uint32_t ebx; + uint32_t ecx; + uint32_t edx; + uint32_t esi; + uint32_t edi; + uint32_t ebp; + uint32_t eax; + uint16_t error_code; /* private */ + uint16_t entry_vector; /* private */ + uint32_t eip; + uint16_t cs; + uint8_t saved_upcall_mask; + uint8_t _pad0; + uint32_t eflags; /* eflags.IF == !saved_upcall_mask */ + uint32_t esp; + uint16_t ss, _pad1; + uint16_t es, _pad2; + uint16_t ds, _pad3; + uint16_t fs, _pad4; + uint16_t gs, _pad5; +}; +typedef struct cpu_user_regs cpu_user_regs_t; +DEFINE_XEN_GUEST_HANDLE(cpu_user_regs_t); + +/* + * Page-directory addresses above 4GB do not fit into architectural %cr3. + * When accessing %cr3, or equivalent field in vcpu_guest_context, guests + * must use the following accessor macros to pack/unpack valid MFNs. + */ +#define xen_pfn_to_cr3(pfn) (((unsigned)(pfn) << 12) | ((unsigned)(pfn) >> 20)) +#define xen_cr3_to_pfn(cr3) (((unsigned)(cr3) >> 12) | ((unsigned)(cr3) << 20)) + +struct arch_vcpu_info { + unsigned long cr2; + unsigned long pad[5]; /* sizeof(vcpu_info_t) == 64 */ +}; +typedef struct arch_vcpu_info arch_vcpu_info_t; + +struct xen_callback { + unsigned long cs; + unsigned long eip; +}; +typedef struct xen_callback xen_callback_t; + +#endif /* !__ASSEMBLY__ */ + +#endif /* __XEN_PUBLIC_ARCH_X86_XEN_X86_32_H__ */ + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * tab-width: 4 + * indent-tabs-mode: nil + * End: + */ diff --git a/include/xen/arch-x86/xen-x86_64.h b/include/xen/arch-x86/xen-x86_64.h new file mode 100644 index 000000000..1c4e1590f --- /dev/null +++ b/include/xen/arch-x86/xen-x86_64.h @@ -0,0 +1,202 @@ +/****************************************************************************** + * xen-x86_64.h + * + * Guest OS interface to x86 64-bit Xen. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + * Copyright (c) 2004-2006, K A Fraser + */ + +#ifndef __XEN_PUBLIC_ARCH_X86_XEN_X86_64_H__ +#define __XEN_PUBLIC_ARCH_X86_XEN_X86_64_H__ + +/* + * Hypercall interface: + * Input: %rdi, %rsi, %rdx, %r10, %r8, %r9 (arguments 1-6) + * Output: %rax + * Access is via hypercall page (set up by guest loader or via a Xen MSR): + * call hypercall_page + hypercall-number * 32 + * Clobbered: argument registers (e.g., 2-arg hypercall clobbers %rdi,%rsi) + */ + +/* + * 64-bit segment selectors + * These flat segments are in the Xen-private section of every GDT. Since these + * are also present in the initial GDT, many OSes will be able to avoid + * installing their own GDT. + */ + +#define FLAT_RING3_CS32 0xe023 /* GDT index 260 */ +#define FLAT_RING3_CS64 0xe033 /* GDT index 261 */ +#define FLAT_RING3_DS32 0xe02b /* GDT index 262 */ +#define FLAT_RING3_DS64 0x0000 /* NULL selector */ +#define FLAT_RING3_SS32 0xe02b /* GDT index 262 */ +#define FLAT_RING3_SS64 0xe02b /* GDT index 262 */ + +#define FLAT_KERNEL_DS64 FLAT_RING3_DS64 +#define FLAT_KERNEL_DS32 FLAT_RING3_DS32 +#define FLAT_KERNEL_DS FLAT_KERNEL_DS64 +#define FLAT_KERNEL_CS64 FLAT_RING3_CS64 +#define FLAT_KERNEL_CS32 FLAT_RING3_CS32 +#define FLAT_KERNEL_CS FLAT_KERNEL_CS64 +#define FLAT_KERNEL_SS64 FLAT_RING3_SS64 +#define FLAT_KERNEL_SS32 FLAT_RING3_SS32 +#define FLAT_KERNEL_SS FLAT_KERNEL_SS64 + +#define FLAT_USER_DS64 FLAT_RING3_DS64 +#define FLAT_USER_DS32 FLAT_RING3_DS32 +#define FLAT_USER_DS FLAT_USER_DS64 +#define FLAT_USER_CS64 FLAT_RING3_CS64 +#define FLAT_USER_CS32 FLAT_RING3_CS32 +#define FLAT_USER_CS FLAT_USER_CS64 +#define FLAT_USER_SS64 FLAT_RING3_SS64 +#define FLAT_USER_SS32 FLAT_RING3_SS32 +#define FLAT_USER_SS FLAT_USER_SS64 + +#define __HYPERVISOR_VIRT_START 0xFFFF800000000000 +#define __HYPERVISOR_VIRT_END 0xFFFF880000000000 +#define __MACH2PHYS_VIRT_START 0xFFFF800000000000 +#define __MACH2PHYS_VIRT_END 0xFFFF804000000000 + +#ifndef HYPERVISOR_VIRT_START +#define HYPERVISOR_VIRT_START mk_unsigned_long(__HYPERVISOR_VIRT_START) +#define HYPERVISOR_VIRT_END mk_unsigned_long(__HYPERVISOR_VIRT_END) +#endif + +#define MACH2PHYS_VIRT_START mk_unsigned_long(__MACH2PHYS_VIRT_START) +#define MACH2PHYS_VIRT_END mk_unsigned_long(__MACH2PHYS_VIRT_END) +#define MACH2PHYS_NR_ENTRIES ((MACH2PHYS_VIRT_END-MACH2PHYS_VIRT_START)>>3) +#ifndef machine_to_phys_mapping +#define machine_to_phys_mapping ((unsigned long *)HYPERVISOR_VIRT_START) +#endif + +/* + * int HYPERVISOR_set_segment_base(unsigned int which, unsigned long base) + * @which == SEGBASE_* ; @base == 64-bit base address + * Returns 0 on success. + */ +#define SEGBASE_FS 0 +#define SEGBASE_GS_USER 1 +#define SEGBASE_GS_KERNEL 2 +#define SEGBASE_GS_USER_SEL 3 /* Set user %gs specified in base[15:0] */ + +/* + * int HYPERVISOR_iret(void) + * All arguments are on the kernel stack, in the following format. + * Never returns if successful. Current kernel context is lost. + * The saved CS is mapped as follows: + * RING0 -> RING3 kernel mode. + * RING1 -> RING3 kernel mode. + * RING2 -> RING3 kernel mode. + * RING3 -> RING3 user mode. + * However RING0 indicates that the guest kernel should return to iteself + * directly with + * orb $3,1*8(%rsp) + * iretq + * If flags contains VGCF_in_syscall: + * Restore RAX, RIP, RFLAGS, RSP. + * Discard R11, RCX, CS, SS. + * Otherwise: + * Restore RAX, R11, RCX, CS:RIP, RFLAGS, SS:RSP. + * All other registers are saved on hypercall entry and restored to user. + */ +/* Guest exited in SYSCALL context? Return to guest with SYSRET? */ +#define _VGCF_in_syscall 8 +#define VGCF_in_syscall (1<<_VGCF_in_syscall) +#define VGCF_IN_SYSCALL VGCF_in_syscall + +#ifndef __ASSEMBLY__ + +struct iret_context { + /* Top of stack (%rsp at point of hypercall). */ + uint64_t rax, r11, rcx, flags, rip, cs, rflags, rsp, ss; + /* Bottom of iret stack frame. */ +}; + +#if defined(__GNUC__) && !defined(__STRICT_ANSI__) +/* Anonymous union includes both 32- and 64-bit names (e.g., eax/rax). */ +#define __DECL_REG(name) union { \ + uint64_t r ## name, e ## name; \ + uint32_t _e ## name; \ +} +#else +/* Non-gcc sources must always use the proper 64-bit name (e.g., rax). */ +#define __DECL_REG(name) uint64_t r ## name +#endif + +struct cpu_user_regs { + uint64_t r15; + uint64_t r14; + uint64_t r13; + uint64_t r12; + __DECL_REG(bp); + __DECL_REG(bx); + uint64_t r11; + uint64_t r10; + uint64_t r9; + uint64_t r8; + __DECL_REG(ax); + __DECL_REG(cx); + __DECL_REG(dx); + __DECL_REG(si); + __DECL_REG(di); + uint32_t error_code; /* private */ + uint32_t entry_vector; /* private */ + __DECL_REG(ip); + uint16_t cs, _pad0[1]; + uint8_t saved_upcall_mask; + uint8_t _pad1[3]; + __DECL_REG(flags); /* rflags.IF == !saved_upcall_mask */ + __DECL_REG(sp); + uint16_t ss, _pad2[3]; + uint16_t es, _pad3[3]; + uint16_t ds, _pad4[3]; + uint16_t fs, _pad5[3]; /* Non-zero => takes precedence over fs_base. */ + uint16_t gs, _pad6[3]; /* Non-zero => takes precedence over gs_base_usr. */ +}; +typedef struct cpu_user_regs cpu_user_regs_t; +DEFINE_XEN_GUEST_HANDLE(cpu_user_regs_t); + +#undef __DECL_REG + +#define xen_pfn_to_cr3(pfn) ((unsigned long)(pfn) << 12) +#define xen_cr3_to_pfn(cr3) ((unsigned long)(cr3) >> 12) + +struct arch_vcpu_info { + unsigned long cr2; + unsigned long pad; /* sizeof(vcpu_info_t) == 64 */ +}; +typedef struct arch_vcpu_info arch_vcpu_info_t; + +typedef unsigned long xen_callback_t; + +#endif /* !__ASSEMBLY__ */ + +#endif /* __XEN_PUBLIC_ARCH_X86_XEN_X86_64_H__ */ + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * tab-width: 4 + * indent-tabs-mode: nil + * End: + */ diff --git a/include/xen/arch-x86/xen.h b/include/xen/arch-x86/xen.h new file mode 100644 index 000000000..f35804b88 --- /dev/null +++ b/include/xen/arch-x86/xen.h @@ -0,0 +1,273 @@ +/****************************************************************************** + * arch-x86/xen.h + * + * Guest OS interface to x86 Xen. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + * Copyright (c) 2004-2006, K A Fraser + */ + +#include "../xen.h" + +#ifndef __XEN_PUBLIC_ARCH_X86_XEN_H__ +#define __XEN_PUBLIC_ARCH_X86_XEN_H__ + +/* Structural guest handles introduced in 0x00030201. */ +#if __XEN_INTERFACE_VERSION__ >= 0x00030201 +#define ___DEFINE_XEN_GUEST_HANDLE(name, type) \ + typedef struct { type *p; } __guest_handle_ ## name +#else +#define ___DEFINE_XEN_GUEST_HANDLE(name, type) \ + typedef type * __guest_handle_ ## name +#endif + +/* + * XEN_GUEST_HANDLE represents a guest pointer, when passed as a field + * in a struct in memory. + * XEN_GUEST_HANDLE_PARAM represent a guest pointer, when passed as an + * hypercall argument. + * XEN_GUEST_HANDLE_PARAM and XEN_GUEST_HANDLE are the same on X86 but + * they might not be on other architectures. + */ +#define __DEFINE_XEN_GUEST_HANDLE(name, type) \ + ___DEFINE_XEN_GUEST_HANDLE(name, type); \ + ___DEFINE_XEN_GUEST_HANDLE(const_##name, const type) +#define DEFINE_XEN_GUEST_HANDLE(name) __DEFINE_XEN_GUEST_HANDLE(name, name) +#define __XEN_GUEST_HANDLE(name) __guest_handle_ ## name +#define XEN_GUEST_HANDLE(name) __XEN_GUEST_HANDLE(name) +#define XEN_GUEST_HANDLE_PARAM(name) XEN_GUEST_HANDLE(name) +#define set_xen_guest_handle_raw(hnd, val) do { (hnd).p = val; } while (0) +#ifdef __XEN_TOOLS__ +#define get_xen_guest_handle(val, hnd) do { val = (hnd).p; } while (0) +#endif +#define set_xen_guest_handle(hnd, val) set_xen_guest_handle_raw(hnd, val) + +#if defined(__i386__) +#include "xen-x86_32.h" +#elif defined(__x86_64__) +#include "xen-x86_64.h" +#endif + +#ifndef __ASSEMBLY__ +typedef unsigned long xen_pfn_t; +#define PRI_xen_pfn "lx" +#endif + +#define XEN_HAVE_PV_GUEST_ENTRY 1 + +#define XEN_HAVE_PV_UPCALL_MASK 1 + +/* + * `incontents 200 segdesc Segment Descriptor Tables + */ +/* + * ` enum neg_errnoval + * ` HYPERVISOR_set_gdt(const xen_pfn_t frames[], unsigned int entries); + * ` + */ +/* + * A number of GDT entries are reserved by Xen. These are not situated at the + * start of the GDT because some stupid OSes export hard-coded selector values + * in their ABI. These hard-coded values are always near the start of the GDT, + * so Xen places itself out of the way, at the far end of the GDT. + * + * NB The LDT is set using the MMUEXT_SET_LDT op of HYPERVISOR_mmuext_op + */ +#define FIRST_RESERVED_GDT_PAGE 14 +#define FIRST_RESERVED_GDT_BYTE (FIRST_RESERVED_GDT_PAGE * 4096) +#define FIRST_RESERVED_GDT_ENTRY (FIRST_RESERVED_GDT_BYTE / 8) + + +/* + * ` enum neg_errnoval + * ` HYPERVISOR_update_descriptor(u64 pa, u64 desc); + * ` + * ` @pa The machine physical address of the descriptor to + * ` update. Must be either a descriptor page or writable. + * ` @desc The descriptor value to update, in the same format as a + * ` native descriptor table entry. + */ + +/* Maximum number of virtual CPUs in legacy multi-processor guests. */ +#define XEN_LEGACY_MAX_VCPUS 32 + +#ifndef __ASSEMBLY__ + +typedef unsigned long xen_ulong_t; +#define PRI_xen_ulong "lx" + +/* + * ` enum neg_errnoval + * ` HYPERVISOR_stack_switch(unsigned long ss, unsigned long esp); + * ` + * Sets the stack segment and pointer for the current vcpu. + */ + +/* + * ` enum neg_errnoval + * ` HYPERVISOR_set_trap_table(const struct trap_info traps[]); + * ` + */ +/* + * Send an array of these to HYPERVISOR_set_trap_table(). + * Terminate the array with a sentinel entry, with traps[].address==0. + * The privilege level specifies which modes may enter a trap via a software + * interrupt. On x86/64, since rings 1 and 2 are unavailable, we allocate + * privilege levels as follows: + * Level == 0: Noone may enter + * Level == 1: Kernel may enter + * Level == 2: Kernel may enter + * Level == 3: Everyone may enter + */ +#define TI_GET_DPL(_ti) ((_ti)->flags & 3) +#define TI_GET_IF(_ti) ((_ti)->flags & 4) +#define TI_SET_DPL(_ti,_dpl) ((_ti)->flags |= (_dpl)) +#define TI_SET_IF(_ti,_if) ((_ti)->flags |= ((!!(_if))<<2)) +struct trap_info { + uint8_t vector; /* exception vector */ + uint8_t flags; /* 0-3: privilege level; 4: clear event enable? */ + uint16_t cs; /* code selector */ + unsigned long address; /* code offset */ +}; +typedef struct trap_info trap_info_t; +DEFINE_XEN_GUEST_HANDLE(trap_info_t); + +typedef uint64_t tsc_timestamp_t; /* RDTSC timestamp */ + +/* + * The following is all CPU context. Note that the fpu_ctxt block is filled + * in by FXSAVE if the CPU has feature FXSR; otherwise FSAVE is used. + * + * Also note that when calling DOMCTL_setvcpucontext and VCPU_initialise + * for HVM and PVH guests, not all information in this structure is updated: + * + * - For HVM guests, the structures read include: fpu_ctxt (if + * VGCT_I387_VALID is set), flags, user_regs, debugreg[*] + * + * - PVH guests are the same as HVM guests, but additionally use ctrlreg[3] to + * set cr3. All other fields not used should be set to 0. + */ +struct vcpu_guest_context { + /* FPU registers come first so they can be aligned for FXSAVE/FXRSTOR. */ + struct { char x[512]; } fpu_ctxt; /* User-level FPU registers */ +#define VGCF_I387_VALID (1<<0) +#define VGCF_IN_KERNEL (1<<2) +#define _VGCF_i387_valid 0 +#define VGCF_i387_valid (1<<_VGCF_i387_valid) +#define _VGCF_in_kernel 2 +#define VGCF_in_kernel (1<<_VGCF_in_kernel) +#define _VGCF_failsafe_disables_events 3 +#define VGCF_failsafe_disables_events (1<<_VGCF_failsafe_disables_events) +#define _VGCF_syscall_disables_events 4 +#define VGCF_syscall_disables_events (1<<_VGCF_syscall_disables_events) +#define _VGCF_online 5 +#define VGCF_online (1<<_VGCF_online) + unsigned long flags; /* VGCF_* flags */ + struct cpu_user_regs user_regs; /* User-level CPU registers */ + struct trap_info trap_ctxt[256]; /* Virtual IDT */ + unsigned long ldt_base, ldt_ents; /* LDT (linear address, # ents) */ + unsigned long gdt_frames[16], gdt_ents; /* GDT (machine frames, # ents) */ + unsigned long kernel_ss, kernel_sp; /* Virtual TSS (only SS1/SP1) */ + /* NB. User pagetable on x86/64 is placed in ctrlreg[1]. */ + unsigned long ctrlreg[8]; /* CR0-CR7 (control registers) */ + unsigned long debugreg[8]; /* DB0-DB7 (debug registers) */ +#ifdef __i386__ + unsigned long event_callback_cs; /* CS:EIP of event callback */ + unsigned long event_callback_eip; + unsigned long failsafe_callback_cs; /* CS:EIP of failsafe callback */ + unsigned long failsafe_callback_eip; +#else + unsigned long event_callback_eip; + unsigned long failsafe_callback_eip; +#ifdef __XEN__ + union { + unsigned long syscall_callback_eip; + struct { + unsigned int event_callback_cs; /* compat CS of event cb */ + unsigned int failsafe_callback_cs; /* compat CS of failsafe cb */ + }; + }; +#else + unsigned long syscall_callback_eip; +#endif +#endif + unsigned long vm_assist; /* VMASST_TYPE_* bitmap */ +#ifdef __x86_64__ + /* Segment base addresses. */ + uint64_t fs_base; + uint64_t gs_base_kernel; + uint64_t gs_base_user; +#endif +}; +typedef struct vcpu_guest_context vcpu_guest_context_t; +DEFINE_XEN_GUEST_HANDLE(vcpu_guest_context_t); + +struct arch_shared_info { + unsigned long max_pfn; /* max pfn that appears in table */ + /* Frame containing list of mfns containing list of mfns containing p2m. */ + xen_pfn_t pfn_to_mfn_frame_list_list; + unsigned long nmi_reason; + uint64_t pad[32]; +}; +typedef struct arch_shared_info arch_shared_info_t; + +#endif /* !__ASSEMBLY__ */ + +/* + * ` enum neg_errnoval + * ` HYPERVISOR_fpu_taskswitch(int set); + * ` + * Sets (if set!=0) or clears (if set==0) CR0.TS. + */ + +/* + * ` enum neg_errnoval + * ` HYPERVISOR_set_debugreg(int regno, unsigned long value); + * + * ` unsigned long + * ` HYPERVISOR_get_debugreg(int regno); + * For 0<=reg<=7, returns the debug register value. + * For other values of reg, returns ((unsigned long)-EINVAL). + * (Unfortunately, this interface is defective.) + */ + +/* + * Prefix forces emulation of some non-trapping instructions. + * Currently only CPUID. + */ +#ifdef __ASSEMBLY__ +#define XEN_EMULATE_PREFIX .byte 0x0f,0x0b,0x78,0x65,0x6e ; +#define XEN_CPUID XEN_EMULATE_PREFIX cpuid +#else +#define XEN_EMULATE_PREFIX ".byte 0x0f,0x0b,0x78,0x65,0x6e ; " +#define XEN_CPUID XEN_EMULATE_PREFIX "cpuid" +#endif + +#endif /* __XEN_PUBLIC_ARCH_X86_XEN_H__ */ + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * tab-width: 4 + * indent-tabs-mode: nil + * End: + */ diff --git a/include/xen/event_channel.h b/include/xen/event_channel.h new file mode 100644 index 000000000..49ac8cca5 --- /dev/null +++ b/include/xen/event_channel.h @@ -0,0 +1,381 @@ +/****************************************************************************** + * event_channel.h + * + * Event channels between domains. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + * Copyright (c) 2003-2004, K A Fraser. + */ + +#ifndef __XEN_PUBLIC_EVENT_CHANNEL_H__ +#define __XEN_PUBLIC_EVENT_CHANNEL_H__ + +#include "xen.h" + +/* + * `incontents 150 evtchn Event Channels + * + * Event channels are the basic primitive provided by Xen for event + * notifications. An event is the Xen equivalent of a hardware + * interrupt. They essentially store one bit of information, the event + * of interest is signalled by transitioning this bit from 0 to 1. + * + * Notifications are received by a guest via an upcall from Xen, + * indicating when an event arrives (setting the bit). Further + * notifications are masked until the bit is cleared again (therefore, + * guests must check the value of the bit after re-enabling event + * delivery to ensure no missed notifications). + * + * Event notifications can be masked by setting a flag; this is + * equivalent to disabling interrupts and can be used to ensure + * atomicity of certain operations in the guest kernel. + * + * Event channels are represented by the evtchn_* fields in + * struct shared_info and struct vcpu_info. + */ + +/* + * ` enum neg_errnoval + * ` HYPERVISOR_event_channel_op(enum event_channel_op cmd, void *args) + * ` + * @cmd == EVTCHNOP_* (event-channel operation). + * @args == struct evtchn_* Operation-specific extra arguments (NULL if none). + */ + +/* ` enum event_channel_op { // EVTCHNOP_* => struct evtchn_* */ +#define EVTCHNOP_bind_interdomain 0 +#define EVTCHNOP_bind_virq 1 +#define EVTCHNOP_bind_pirq 2 +#define EVTCHNOP_close 3 +#define EVTCHNOP_send 4 +#define EVTCHNOP_status 5 +#define EVTCHNOP_alloc_unbound 6 +#define EVTCHNOP_bind_ipi 7 +#define EVTCHNOP_bind_vcpu 8 +#define EVTCHNOP_unmask 9 +#define EVTCHNOP_reset 10 +#define EVTCHNOP_init_control 11 +#define EVTCHNOP_expand_array 12 +#define EVTCHNOP_set_priority 13 +/* ` } */ + +typedef uint32_t evtchn_port_t; +DEFINE_XEN_GUEST_HANDLE(evtchn_port_t); + +/* + * EVTCHNOP_alloc_unbound: Allocate a port in domain and mark as + * accepting interdomain bindings from domain . A fresh port + * is allocated in and returned as . + * NOTES: + * 1. If the caller is unprivileged then must be DOMID_SELF. + * 2. may be DOMID_SELF, allowing loopback connections. + */ +struct evtchn_alloc_unbound { + /* IN parameters */ + domid_t dom, remote_dom; + /* OUT parameters */ + evtchn_port_t port; +}; +typedef struct evtchn_alloc_unbound evtchn_alloc_unbound_t; + +/* + * EVTCHNOP_bind_interdomain: Construct an interdomain event channel between + * the calling domain and . must identify + * a port that is unbound and marked as accepting bindings from the calling + * domain. A fresh port is allocated in the calling domain and returned as + * . + * + * In case the peer domain has already tried to set our event channel + * pending, before it was bound, EVTCHNOP_bind_interdomain always sets + * the local event channel pending. + * + * The usual pattern of use, in the guest's upcall (or subsequent + * handler) is as follows: (Re-enable the event channel for subsequent + * signalling and then) check for the existence of whatever condition + * is being waited for by other means, and take whatever action is + * needed (if any). + * + * NOTES: + * 1. may be DOMID_SELF, allowing loopback connections. + */ +struct evtchn_bind_interdomain { + /* IN parameters. */ + domid_t remote_dom; + evtchn_port_t remote_port; + /* OUT parameters. */ + evtchn_port_t local_port; +}; +typedef struct evtchn_bind_interdomain evtchn_bind_interdomain_t; + +/* + * EVTCHNOP_bind_virq: Bind a local event channel to VIRQ on specified + * vcpu. + * NOTES: + * 1. Virtual IRQs are classified as per-vcpu or global. See the VIRQ list + * in xen.h for the classification of each VIRQ. + * 2. Global VIRQs must be allocated on VCPU0 but can subsequently be + * re-bound via EVTCHNOP_bind_vcpu. + * 3. Per-vcpu VIRQs may be bound to at most one event channel per vcpu. + * The allocated event channel is bound to the specified vcpu and the + * binding cannot be changed. + */ +struct evtchn_bind_virq { + /* IN parameters. */ + uint32_t virq; /* enum virq */ + uint32_t vcpu; + /* OUT parameters. */ + evtchn_port_t port; +}; +typedef struct evtchn_bind_virq evtchn_bind_virq_t; + +/* + * EVTCHNOP_bind_pirq: Bind a local event channel to a real IRQ (PIRQ ). + * NOTES: + * 1. A physical IRQ may be bound to at most one event channel per domain. + * 2. Only a sufficiently-privileged domain may bind to a physical IRQ. + */ +struct evtchn_bind_pirq { + /* IN parameters. */ + uint32_t pirq; +#define BIND_PIRQ__WILL_SHARE 1 + uint32_t flags; /* BIND_PIRQ__* */ + /* OUT parameters. */ + evtchn_port_t port; +}; +typedef struct evtchn_bind_pirq evtchn_bind_pirq_t; + +/* + * EVTCHNOP_bind_ipi: Bind a local event channel to receive events. + * NOTES: + * 1. The allocated event channel is bound to the specified vcpu. The binding + * may not be changed. + */ +struct evtchn_bind_ipi { + uint32_t vcpu; + /* OUT parameters. */ + evtchn_port_t port; +}; +typedef struct evtchn_bind_ipi evtchn_bind_ipi_t; + +/* + * EVTCHNOP_close: Close a local event channel . If the channel is + * interdomain then the remote end is placed in the unbound state + * (EVTCHNSTAT_unbound), awaiting a new connection. + */ +struct evtchn_close { + /* IN parameters. */ + evtchn_port_t port; +}; +typedef struct evtchn_close evtchn_close_t; + +/* + * EVTCHNOP_send: Send an event to the remote end of the channel whose local + * endpoint is . + */ +struct evtchn_send { + /* IN parameters. */ + evtchn_port_t port; +}; +typedef struct evtchn_send evtchn_send_t; + +/* + * EVTCHNOP_status: Get the current status of the communication channel which + * has an endpoint at . + * NOTES: + * 1. may be specified as DOMID_SELF. + * 2. Only a sufficiently-privileged domain may obtain the status of an event + * channel for which is not DOMID_SELF. + */ +struct evtchn_status { + /* IN parameters */ + domid_t dom; + evtchn_port_t port; + /* OUT parameters */ +#define EVTCHNSTAT_closed 0 /* Channel is not in use. */ +#define EVTCHNSTAT_unbound 1 /* Channel is waiting interdom connection.*/ +#define EVTCHNSTAT_interdomain 2 /* Channel is connected to remote domain. */ +#define EVTCHNSTAT_pirq 3 /* Channel is bound to a phys IRQ line. */ +#define EVTCHNSTAT_virq 4 /* Channel is bound to a virtual IRQ line */ +#define EVTCHNSTAT_ipi 5 /* Channel is bound to a virtual IPI line */ + uint32_t status; + uint32_t vcpu; /* VCPU to which this channel is bound. */ + union { + struct { + domid_t dom; + } unbound; /* EVTCHNSTAT_unbound */ + struct { + domid_t dom; + evtchn_port_t port; + } interdomain; /* EVTCHNSTAT_interdomain */ + uint32_t pirq; /* EVTCHNSTAT_pirq */ + uint32_t virq; /* EVTCHNSTAT_virq */ + } u; +}; +typedef struct evtchn_status evtchn_status_t; + +/* + * EVTCHNOP_bind_vcpu: Specify which vcpu a channel should notify when an + * event is pending. + * NOTES: + * 1. IPI-bound channels always notify the vcpu specified at bind time. + * This binding cannot be changed. + * 2. Per-VCPU VIRQ channels always notify the vcpu specified at bind time. + * This binding cannot be changed. + * 3. All other channels notify vcpu0 by default. This default is set when + * the channel is allocated (a port that is freed and subsequently reused + * has its binding reset to vcpu0). + */ +struct evtchn_bind_vcpu { + /* IN parameters. */ + evtchn_port_t port; + uint32_t vcpu; +}; +typedef struct evtchn_bind_vcpu evtchn_bind_vcpu_t; + +/* + * EVTCHNOP_unmask: Unmask the specified local event-channel port and deliver + * a notification to the appropriate VCPU if an event is pending. + */ +struct evtchn_unmask { + /* IN parameters. */ + evtchn_port_t port; +}; +typedef struct evtchn_unmask evtchn_unmask_t; + +/* + * EVTCHNOP_reset: Close all event channels associated with specified domain. + * NOTES: + * 1. may be specified as DOMID_SELF. + * 2. Only a sufficiently-privileged domain may specify other than DOMID_SELF. + */ +struct evtchn_reset { + /* IN parameters. */ + domid_t dom; +}; +typedef struct evtchn_reset evtchn_reset_t; + +/* + * EVTCHNOP_init_control: initialize the control block for the FIFO ABI. + * + * Note: any events that are currently pending will not be resent and + * will be lost. Guests should call this before binding any event to + * avoid losing any events. + */ +struct evtchn_init_control { + /* IN parameters. */ + uint64_t control_gfn; + uint32_t offset; + uint32_t vcpu; + /* OUT parameters. */ + uint8_t link_bits; + uint8_t _pad[7]; +}; +typedef struct evtchn_init_control evtchn_init_control_t; + +/* + * EVTCHNOP_expand_array: add an additional page to the event array. + */ +struct evtchn_expand_array { + /* IN parameters. */ + uint64_t array_gfn; +}; +typedef struct evtchn_expand_array evtchn_expand_array_t; + +/* + * EVTCHNOP_set_priority: set the priority for an event channel. + */ +struct evtchn_set_priority { + /* IN parameters. */ + uint32_t port; + uint32_t priority; +}; +typedef struct evtchn_set_priority evtchn_set_priority_t; + +/* + * ` enum neg_errnoval + * ` HYPERVISOR_event_channel_op_compat(struct evtchn_op *op) + * ` + * Superceded by new event_channel_op() hypercall since 0x00030202. + */ +struct evtchn_op { + uint32_t cmd; /* enum event_channel_op */ + union { + struct evtchn_alloc_unbound alloc_unbound; + struct evtchn_bind_interdomain bind_interdomain; + struct evtchn_bind_virq bind_virq; + struct evtchn_bind_pirq bind_pirq; + struct evtchn_bind_ipi bind_ipi; + struct evtchn_close close; + struct evtchn_send send; + struct evtchn_status status; + struct evtchn_bind_vcpu bind_vcpu; + struct evtchn_unmask unmask; + } u; +}; +typedef struct evtchn_op evtchn_op_t; +DEFINE_XEN_GUEST_HANDLE(evtchn_op_t); + +/* + * 2-level ABI + */ + +#define EVTCHN_2L_NR_CHANNELS (sizeof(xen_ulong_t) * sizeof(xen_ulong_t) * 64) + +/* + * FIFO ABI + */ + +/* Events may have priorities from 0 (highest) to 15 (lowest). */ +#define EVTCHN_FIFO_PRIORITY_MAX 0 +#define EVTCHN_FIFO_PRIORITY_DEFAULT 7 +#define EVTCHN_FIFO_PRIORITY_MIN 15 + +#define EVTCHN_FIFO_MAX_QUEUES (EVTCHN_FIFO_PRIORITY_MIN + 1) + +typedef uint32_t event_word_t; + +#define EVTCHN_FIFO_PENDING 31 +#define EVTCHN_FIFO_MASKED 30 +#define EVTCHN_FIFO_LINKED 29 +#define EVTCHN_FIFO_BUSY 28 + +#define EVTCHN_FIFO_LINK_BITS 17 +#define EVTCHN_FIFO_LINK_MASK ((1 << EVTCHN_FIFO_LINK_BITS) - 1) + +#define EVTCHN_FIFO_NR_CHANNELS (1 << EVTCHN_FIFO_LINK_BITS) + +struct evtchn_fifo_control_block { + uint32_t ready; + uint32_t _rsvd; + uint32_t head[EVTCHN_FIFO_MAX_QUEUES]; +}; +typedef struct evtchn_fifo_control_block evtchn_fifo_control_block_t; + +#endif /* __XEN_PUBLIC_EVENT_CHANNEL_H__ */ + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * tab-width: 4 + * indent-tabs-mode: nil + * End: + */ diff --git a/include/xen/grant_table.h b/include/xen/grant_table.h new file mode 100644 index 000000000..b8a3d6ceb --- /dev/null +++ b/include/xen/grant_table.h @@ -0,0 +1,662 @@ +/****************************************************************************** + * grant_table.h + * + * Interface for granting foreign access to page frames, and receiving + * page-ownership transfers. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + * Copyright (c) 2004, K A Fraser + */ + +#ifndef __XEN_PUBLIC_GRANT_TABLE_H__ +#define __XEN_PUBLIC_GRANT_TABLE_H__ + +#include "xen.h" + +/* + * `incontents 150 gnttab Grant Tables + * + * Xen's grant tables provide a generic mechanism to memory sharing + * between domains. This shared memory interface underpins the split + * device drivers for block and network IO. + * + * Each domain has its own grant table. This is a data structure that + * is shared with Xen; it allows the domain to tell Xen what kind of + * permissions other domains have on its pages. Entries in the grant + * table are identified by grant references. A grant reference is an + * integer, which indexes into the grant table. It acts as a + * capability which the grantee can use to perform operations on the + * granter’s memory. + * + * This capability-based system allows shared-memory communications + * between unprivileged domains. A grant reference also encapsulates + * the details of a shared page, removing the need for a domain to + * know the real machine address of a page it is sharing. This makes + * it possible to share memory correctly with domains running in + * fully virtualised memory. + */ + +/*********************************** + * GRANT TABLE REPRESENTATION + */ + +/* Some rough guidelines on accessing and updating grant-table entries + * in a concurrency-safe manner. For more information, Linux contains a + * reference implementation for guest OSes (drivers/xen/grant_table.c, see + * http://git.kernel.org/?p=linux/kernel/git/torvalds/linux.git;a=blob;f=drivers/xen/grant-table.c;hb=HEAD + * + * NB. WMB is a no-op on current-generation x86 processors. However, a + * compiler barrier will still be required. + * + * Introducing a valid entry into the grant table: + * 1. Write ent->domid. + * 2. Write ent->frame: + * GTF_permit_access: Frame to which access is permitted. + * GTF_accept_transfer: Pseudo-phys frame slot being filled by new + * frame, or zero if none. + * 3. Write memory barrier (WMB). + * 4. Write ent->flags, inc. valid type. + * + * Invalidating an unused GTF_permit_access entry: + * 1. flags = ent->flags. + * 2. Observe that !(flags & (GTF_reading|GTF_writing)). + * 3. Check result of SMP-safe CMPXCHG(&ent->flags, flags, 0). + * NB. No need for WMB as reuse of entry is control-dependent on success of + * step 3, and all architectures guarantee ordering of ctrl-dep writes. + * + * Invalidating an in-use GTF_permit_access entry: + * This cannot be done directly. Request assistance from the domain controller + * which can set a timeout on the use of a grant entry and take necessary + * action. (NB. This is not yet implemented!). + * + * Invalidating an unused GTF_accept_transfer entry: + * 1. flags = ent->flags. + * 2. Observe that !(flags & GTF_transfer_committed). [*] + * 3. Check result of SMP-safe CMPXCHG(&ent->flags, flags, 0). + * NB. No need for WMB as reuse of entry is control-dependent on success of + * step 3, and all architectures guarantee ordering of ctrl-dep writes. + * [*] If GTF_transfer_committed is set then the grant entry is 'committed'. + * The guest must /not/ modify the grant entry until the address of the + * transferred frame is written. It is safe for the guest to spin waiting + * for this to occur (detect by observing GTF_transfer_completed in + * ent->flags). + * + * Invalidating a committed GTF_accept_transfer entry: + * 1. Wait for (ent->flags & GTF_transfer_completed). + * + * Changing a GTF_permit_access from writable to read-only: + * Use SMP-safe CMPXCHG to set GTF_readonly, while checking !GTF_writing. + * + * Changing a GTF_permit_access from read-only to writable: + * Use SMP-safe bit-setting instruction. + */ + +/* + * Reference to a grant entry in a specified domain's grant table. + */ +typedef uint32_t grant_ref_t; + +/* + * A grant table comprises a packed array of grant entries in one or more + * page frames shared between Xen and a guest. + * [XEN]: This field is written by Xen and read by the sharing guest. + * [GST]: This field is written by the guest and read by Xen. + */ + +/* + * Version 1 of the grant table entry structure is maintained purely + * for backwards compatibility. New guests should use version 2. + */ +#if __XEN_INTERFACE_VERSION__ < 0x0003020a +#define grant_entry_v1 grant_entry +#define grant_entry_v1_t grant_entry_t +#endif +struct grant_entry_v1 { + /* GTF_xxx: various type and flag information. [XEN,GST] */ + uint16_t flags; + /* The domain being granted foreign privileges. [GST] */ + domid_t domid; + /* + * GTF_permit_access: Frame that @domid is allowed to map and access. [GST] + * GTF_accept_transfer: Frame whose ownership transferred by @domid. [XEN] + */ + uint32_t frame; +}; +typedef struct grant_entry_v1 grant_entry_v1_t; + +/* The first few grant table entries will be preserved across grant table + * version changes and may be pre-populated at domain creation by tools. + */ +#define GNTTAB_NR_RESERVED_ENTRIES 8 +#define GNTTAB_RESERVED_CONSOLE 0 +#define GNTTAB_RESERVED_XENSTORE 1 + +/* + * Type of grant entry. + * GTF_invalid: This grant entry grants no privileges. + * GTF_permit_access: Allow @domid to map/access @frame. + * GTF_accept_transfer: Allow @domid to transfer ownership of one page frame + * to this guest. Xen writes the page number to @frame. + * GTF_transitive: Allow @domid to transitively access a subrange of + * @trans_grant in @trans_domid. No mappings are allowed. + */ +#define GTF_invalid (0U<<0) +#define GTF_permit_access (1U<<0) +#define GTF_accept_transfer (2U<<0) +#define GTF_transitive (3U<<0) +#define GTF_type_mask (3U<<0) + +/* + * Subflags for GTF_permit_access. + * GTF_readonly: Restrict @domid to read-only mappings and accesses. [GST] + * GTF_reading: Grant entry is currently mapped for reading by @domid. [XEN] + * GTF_writing: Grant entry is currently mapped for writing by @domid. [XEN] + * GTF_PAT, GTF_PWT, GTF_PCD: (x86) cache attribute flags for the grant [GST] + * GTF_sub_page: Grant access to only a subrange of the page. @domid + * will only be allowed to copy from the grant, and not + * map it. [GST] + */ +#define _GTF_readonly (2) +#define GTF_readonly (1U<<_GTF_readonly) +#define _GTF_reading (3) +#define GTF_reading (1U<<_GTF_reading) +#define _GTF_writing (4) +#define GTF_writing (1U<<_GTF_writing) +#define _GTF_PWT (5) +#define GTF_PWT (1U<<_GTF_PWT) +#define _GTF_PCD (6) +#define GTF_PCD (1U<<_GTF_PCD) +#define _GTF_PAT (7) +#define GTF_PAT (1U<<_GTF_PAT) +#define _GTF_sub_page (8) +#define GTF_sub_page (1U<<_GTF_sub_page) + +/* + * Subflags for GTF_accept_transfer: + * GTF_transfer_committed: Xen sets this flag to indicate that it is committed + * to transferring ownership of a page frame. When a guest sees this flag + * it must /not/ modify the grant entry until GTF_transfer_completed is + * set by Xen. + * GTF_transfer_completed: It is safe for the guest to spin-wait on this flag + * after reading GTF_transfer_committed. Xen will always write the frame + * address, followed by ORing this flag, in a timely manner. + */ +#define _GTF_transfer_committed (2) +#define GTF_transfer_committed (1U<<_GTF_transfer_committed) +#define _GTF_transfer_completed (3) +#define GTF_transfer_completed (1U<<_GTF_transfer_completed) + +/* + * Version 2 grant table entries. These fulfil the same role as + * version 1 entries, but can represent more complicated operations. + * Any given domain will have either a version 1 or a version 2 table, + * and every entry in the table will be the same version. + * + * The interface by which domains use grant references does not depend + * on the grant table version in use by the other domain. + */ +#if __XEN_INTERFACE_VERSION__ >= 0x0003020a +/* + * Version 1 and version 2 grant entries share a common prefix. The + * fields of the prefix are documented as part of struct + * grant_entry_v1. + */ +struct grant_entry_header { + uint16_t flags; + domid_t domid; +}; +typedef struct grant_entry_header grant_entry_header_t; + +/* + * Version 2 of the grant entry structure. + */ +union grant_entry_v2 { + grant_entry_header_t hdr; + + /* + * This member is used for V1-style full page grants, where either: + * + * -- hdr.type is GTF_accept_transfer, or + * -- hdr.type is GTF_permit_access and GTF_sub_page is not set. + * + * In that case, the frame field has the same semantics as the + * field of the same name in the V1 entry structure. + */ + struct { + grant_entry_header_t hdr; + uint32_t pad0; + uint64_t frame; + } full_page; + + /* + * If the grant type is GTF_grant_access and GTF_sub_page is set, + * @domid is allowed to access bytes [@page_off,@page_off+@length) + * in frame @frame. + */ + struct { + grant_entry_header_t hdr; + uint16_t page_off; + uint16_t length; + uint64_t frame; + } sub_page; + + /* + * If the grant is GTF_transitive, @domid is allowed to use the + * grant @gref in domain @trans_domid, as if it was the local + * domain. Obviously, the transitive access must be compatible + * with the original grant. + * + * The current version of Xen does not allow transitive grants + * to be mapped. + */ + struct { + grant_entry_header_t hdr; + domid_t trans_domid; + uint16_t pad0; + grant_ref_t gref; + } transitive; + + uint32_t __spacer[4]; /* Pad to a power of two */ +}; +typedef union grant_entry_v2 grant_entry_v2_t; + +typedef uint16_t grant_status_t; + +#endif /* __XEN_INTERFACE_VERSION__ */ + +/*********************************** + * GRANT TABLE QUERIES AND USES + */ + +/* ` enum neg_errnoval + * ` HYPERVISOR_grant_table_op(enum grant_table_op cmd, + * ` void *args, + * ` unsigned int count) + * ` + * + * @args points to an array of a per-command data structure. The array + * has @count members + */ + +/* ` enum grant_table_op { // GNTTABOP_* => struct gnttab_* */ +#define GNTTABOP_map_grant_ref 0 +#define GNTTABOP_unmap_grant_ref 1 +#define GNTTABOP_setup_table 2 +#define GNTTABOP_dump_table 3 +#define GNTTABOP_transfer 4 +#define GNTTABOP_copy 5 +#define GNTTABOP_query_size 6 +#define GNTTABOP_unmap_and_replace 7 +#if __XEN_INTERFACE_VERSION__ >= 0x0003020a +#define GNTTABOP_set_version 8 +#define GNTTABOP_get_status_frames 9 +#define GNTTABOP_get_version 10 +#define GNTTABOP_swap_grant_ref 11 +#endif /* __XEN_INTERFACE_VERSION__ */ +/* ` } */ + +/* + * Handle to track a mapping created via a grant reference. + */ +typedef uint32_t grant_handle_t; + +/* + * GNTTABOP_map_grant_ref: Map the grant entry (,) for access + * by devices and/or host CPUs. If successful, is a tracking number + * that must be presented later to destroy the mapping(s). On error, + * is a negative status code. + * NOTES: + * 1. If GNTMAP_device_map is specified then is the address + * via which I/O devices may access the granted frame. + * 2. If GNTMAP_host_map is specified then a mapping will be added at + * either a host virtual address in the current address space, or at + * a PTE at the specified machine address. The type of mapping to + * perform is selected through the GNTMAP_contains_pte flag, and the + * address is specified in . + * 3. Mappings should only be destroyed via GNTTABOP_unmap_grant_ref. If a + * host mapping is destroyed by other means then it is *NOT* guaranteed + * to be accounted to the correct grant reference! + */ +struct gnttab_map_grant_ref { + /* IN parameters. */ + uint64_t host_addr; + uint32_t flags; /* GNTMAP_* */ + grant_ref_t ref; + domid_t dom; + /* OUT parameters. */ + int16_t status; /* => enum grant_status */ + grant_handle_t handle; + uint64_t dev_bus_addr; +}; +typedef struct gnttab_map_grant_ref gnttab_map_grant_ref_t; +DEFINE_XEN_GUEST_HANDLE(gnttab_map_grant_ref_t); + +/* + * GNTTABOP_unmap_grant_ref: Destroy one or more grant-reference mappings + * tracked by . If or is zero, that + * field is ignored. If non-zero, they must refer to a device/host mapping + * that is tracked by + * NOTES: + * 1. The call may fail in an undefined manner if either mapping is not + * tracked by . + * 3. After executing a batch of unmaps, it is guaranteed that no stale + * mappings will remain in the device or host TLBs. + */ +struct gnttab_unmap_grant_ref { + /* IN parameters. */ + uint64_t host_addr; + uint64_t dev_bus_addr; + grant_handle_t handle; + /* OUT parameters. */ + int16_t status; /* => enum grant_status */ +}; +typedef struct gnttab_unmap_grant_ref gnttab_unmap_grant_ref_t; +DEFINE_XEN_GUEST_HANDLE(gnttab_unmap_grant_ref_t); + +/* + * GNTTABOP_setup_table: Set up a grant table for comprising at least + * pages. The frame addresses are written to the . + * Only addresses are written, even if the table is larger. + * NOTES: + * 1. may be specified as DOMID_SELF. + * 2. Only a sufficiently-privileged domain may specify != DOMID_SELF. + * 3. Xen may not support more than a single grant-table page per domain. + */ +struct gnttab_setup_table { + /* IN parameters. */ + domid_t dom; + uint32_t nr_frames; + /* OUT parameters. */ + int16_t status; /* => enum grant_status */ +#if __XEN_INTERFACE_VERSION__ < 0x00040300 + XEN_GUEST_HANDLE(ulong) frame_list; +#else + XEN_GUEST_HANDLE(xen_pfn_t) frame_list; +#endif +}; +typedef struct gnttab_setup_table gnttab_setup_table_t; +DEFINE_XEN_GUEST_HANDLE(gnttab_setup_table_t); + +/* + * GNTTABOP_dump_table: Dump the contents of the grant table to the + * xen console. Debugging use only. + */ +struct gnttab_dump_table { + /* IN parameters. */ + domid_t dom; + /* OUT parameters. */ + int16_t status; /* => enum grant_status */ +}; +typedef struct gnttab_dump_table gnttab_dump_table_t; +DEFINE_XEN_GUEST_HANDLE(gnttab_dump_table_t); + +/* + * GNTTABOP_transfer_grant_ref: Transfer to a foreign domain. The + * foreign domain has previously registered its interest in the transfer via + * . + * + * Note that, even if the transfer fails, the specified page no longer belongs + * to the calling domain *unless* the error is GNTST_bad_page. + */ +struct gnttab_transfer { + /* IN parameters. */ + xen_pfn_t mfn; + domid_t domid; + grant_ref_t ref; + /* OUT parameters. */ + int16_t status; +}; +typedef struct gnttab_transfer gnttab_transfer_t; +DEFINE_XEN_GUEST_HANDLE(gnttab_transfer_t); + + +/* + * GNTTABOP_copy: Hypervisor based copy + * source and destinations can be eithers MFNs or, for foreign domains, + * grant references. the foreign domain has to grant read/write access + * in its grant table. + * + * The flags specify what type source and destinations are (either MFN + * or grant reference). + * + * Note that this can also be used to copy data between two domains + * via a third party if the source and destination domains had previously + * grant appropriate access to their pages to the third party. + * + * source_offset specifies an offset in the source frame, dest_offset + * the offset in the target frame and len specifies the number of + * bytes to be copied. + */ + +#define _GNTCOPY_source_gref (0) +#define GNTCOPY_source_gref (1<<_GNTCOPY_source_gref) +#define _GNTCOPY_dest_gref (1) +#define GNTCOPY_dest_gref (1<<_GNTCOPY_dest_gref) + +struct gnttab_copy { + /* IN parameters. */ + struct { + union { + grant_ref_t ref; + xen_pfn_t gmfn; + } u; + domid_t domid; + uint16_t offset; + } source, dest; + uint16_t len; + uint16_t flags; /* GNTCOPY_* */ + /* OUT parameters. */ + int16_t status; +}; +typedef struct gnttab_copy gnttab_copy_t; +DEFINE_XEN_GUEST_HANDLE(gnttab_copy_t); + +/* + * GNTTABOP_query_size: Query the current and maximum sizes of the shared + * grant table. + * NOTES: + * 1. may be specified as DOMID_SELF. + * 2. Only a sufficiently-privileged domain may specify != DOMID_SELF. + */ +struct gnttab_query_size { + /* IN parameters. */ + domid_t dom; + /* OUT parameters. */ + uint32_t nr_frames; + uint32_t max_nr_frames; + int16_t status; /* => enum grant_status */ +}; +typedef struct gnttab_query_size gnttab_query_size_t; +DEFINE_XEN_GUEST_HANDLE(gnttab_query_size_t); + +/* + * GNTTABOP_unmap_and_replace: Destroy one or more grant-reference mappings + * tracked by but atomically replace the page table entry with one + * pointing to the machine address under . will be + * redirected to the null entry. + * NOTES: + * 1. The call may fail in an undefined manner if either mapping is not + * tracked by . + * 2. After executing a batch of unmaps, it is guaranteed that no stale + * mappings will remain in the device or host TLBs. + */ +struct gnttab_unmap_and_replace { + /* IN parameters. */ + uint64_t host_addr; + uint64_t new_addr; + grant_handle_t handle; + /* OUT parameters. */ + int16_t status; /* => enum grant_status */ +}; +typedef struct gnttab_unmap_and_replace gnttab_unmap_and_replace_t; +DEFINE_XEN_GUEST_HANDLE(gnttab_unmap_and_replace_t); + +#if __XEN_INTERFACE_VERSION__ >= 0x0003020a +/* + * GNTTABOP_set_version: Request a particular version of the grant + * table shared table structure. This operation can only be performed + * once in any given domain. It must be performed before any grants + * are activated; otherwise, the domain will be stuck with version 1. + * The only defined versions are 1 and 2. + */ +struct gnttab_set_version { + /* IN/OUT parameters */ + uint32_t version; +}; +typedef struct gnttab_set_version gnttab_set_version_t; +DEFINE_XEN_GUEST_HANDLE(gnttab_set_version_t); + + +/* + * GNTTABOP_get_status_frames: Get the list of frames used to store grant + * status for . In grant format version 2, the status is separated + * from the other shared grant fields to allow more efficient synchronization + * using barriers instead of atomic cmpexch operations. + * specify the size of vector . + * The frame addresses are returned in the . + * Only addresses are returned, even if the table is larger. + * NOTES: + * 1. may be specified as DOMID_SELF. + * 2. Only a sufficiently-privileged domain may specify != DOMID_SELF. + */ +struct gnttab_get_status_frames { + /* IN parameters. */ + uint32_t nr_frames; + domid_t dom; + /* OUT parameters. */ + int16_t status; /* => enum grant_status */ + XEN_GUEST_HANDLE(uint64_t) frame_list; +}; +typedef struct gnttab_get_status_frames gnttab_get_status_frames_t; +DEFINE_XEN_GUEST_HANDLE(gnttab_get_status_frames_t); + +/* + * GNTTABOP_get_version: Get the grant table version which is in + * effect for domain . + */ +struct gnttab_get_version { + /* IN parameters */ + domid_t dom; + uint16_t pad; + /* OUT parameters */ + uint32_t version; +}; +typedef struct gnttab_get_version gnttab_get_version_t; +DEFINE_XEN_GUEST_HANDLE(gnttab_get_version_t); + +/* + * GNTTABOP_swap_grant_ref: Swap the contents of two grant entries. + */ +struct gnttab_swap_grant_ref { + /* IN parameters */ + grant_ref_t ref_a; + grant_ref_t ref_b; + /* OUT parameters */ + int16_t status; /* => enum grant_status */ +}; +typedef struct gnttab_swap_grant_ref gnttab_swap_grant_ref_t; +DEFINE_XEN_GUEST_HANDLE(gnttab_swap_grant_ref_t); + +#endif /* __XEN_INTERFACE_VERSION__ */ + +/* + * Bitfield values for gnttab_map_grant_ref.flags. + */ + /* Map the grant entry for access by I/O devices. */ +#define _GNTMAP_device_map (0) +#define GNTMAP_device_map (1<<_GNTMAP_device_map) + /* Map the grant entry for access by host CPUs. */ +#define _GNTMAP_host_map (1) +#define GNTMAP_host_map (1<<_GNTMAP_host_map) + /* Accesses to the granted frame will be restricted to read-only access. */ +#define _GNTMAP_readonly (2) +#define GNTMAP_readonly (1<<_GNTMAP_readonly) + /* + * GNTMAP_host_map subflag: + * 0 => The host mapping is usable only by the guest OS. + * 1 => The host mapping is usable by guest OS + current application. + */ +#define _GNTMAP_application_map (3) +#define GNTMAP_application_map (1<<_GNTMAP_application_map) + + /* + * GNTMAP_contains_pte subflag: + * 0 => This map request contains a host virtual address. + * 1 => This map request contains the machine addess of the PTE to update. + */ +#define _GNTMAP_contains_pte (4) +#define GNTMAP_contains_pte (1<<_GNTMAP_contains_pte) + +#define _GNTMAP_can_fail (5) +#define GNTMAP_can_fail (1<<_GNTMAP_can_fail) + +/* + * Bits to be placed in guest kernel available PTE bits (architecture + * dependent; only supported when XENFEAT_gnttab_map_avail_bits is set). + */ +#define _GNTMAP_guest_avail0 (16) +#define GNTMAP_guest_avail_mask ((uint32_t)~0 << _GNTMAP_guest_avail0) + +/* + * Values for error status returns. All errors are -ve. + */ +/* ` enum grant_status { */ +#define GNTST_okay (0) /* Normal return. */ +#define GNTST_general_error (-1) /* General undefined error. */ +#define GNTST_bad_domain (-2) /* Unrecognsed domain id. */ +#define GNTST_bad_gntref (-3) /* Unrecognised or inappropriate gntref. */ +#define GNTST_bad_handle (-4) /* Unrecognised or inappropriate handle. */ +#define GNTST_bad_virt_addr (-5) /* Inappropriate virtual address to map. */ +#define GNTST_bad_dev_addr (-6) /* Inappropriate device address to unmap.*/ +#define GNTST_no_device_space (-7) /* Out of space in I/O MMU. */ +#define GNTST_permission_denied (-8) /* Not enough privilege for operation. */ +#define GNTST_bad_page (-9) /* Specified page was invalid for op. */ +#define GNTST_bad_copy_arg (-10) /* copy arguments cross page boundary. */ +#define GNTST_address_too_big (-11) /* transfer page address too large. */ +#define GNTST_eagain (-12) /* Operation not done; try again. */ +/* ` } */ + +#define GNTTABOP_error_msgs { \ + "okay", \ + "undefined error", \ + "unrecognised domain id", \ + "invalid grant reference", \ + "invalid mapping handle", \ + "invalid virtual address", \ + "invalid device address", \ + "no spare translation slot in the I/O MMU", \ + "permission denied", \ + "bad page", \ + "copy arguments cross page boundary", \ + "page address size too large", \ + "operation not done; try again" \ +} + +#endif /* __XEN_PUBLIC_GRANT_TABLE_H__ */ + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * tab-width: 4 + * indent-tabs-mode: nil + * End: + */ diff --git a/include/xen/io/blkif.h b/include/xen/io/blkif.h new file mode 100644 index 000000000..c3e169ce2 --- /dev/null +++ b/include/xen/io/blkif.h @@ -0,0 +1,608 @@ +/****************************************************************************** + * blkif.h + * + * Unified block-device I/O interface for Xen guest OSes. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + * Copyright (c) 2003-2004, Keir Fraser + * Copyright (c) 2012, Spectra Logic Corporation + */ + +#ifndef __XEN_PUBLIC_IO_BLKIF_H__ +#define __XEN_PUBLIC_IO_BLKIF_H__ + +#include "ring.h" +#include "../grant_table.h" + +/* + * Front->back notifications: When enqueuing a new request, sending a + * notification can be made conditional on req_event (i.e., the generic + * hold-off mechanism provided by the ring macros). Backends must set + * req_event appropriately (e.g., using RING_FINAL_CHECK_FOR_REQUESTS()). + * + * Back->front notifications: When enqueuing a new response, sending a + * notification can be made conditional on rsp_event (i.e., the generic + * hold-off mechanism provided by the ring macros). Frontends must set + * rsp_event appropriately (e.g., using RING_FINAL_CHECK_FOR_RESPONSES()). + */ + +#ifndef blkif_vdev_t +#define blkif_vdev_t uint16_t +#endif +#define blkif_sector_t uint64_t + +/* + * Feature and Parameter Negotiation + * ================================= + * The two halves of a Xen block driver utilize nodes within the XenStore to + * communicate capabilities and to negotiate operating parameters. This + * section enumerates these nodes which reside in the respective front and + * backend portions of the XenStore, following the XenBus convention. + * + * All data in the XenStore is stored as strings. Nodes specifying numeric + * values are encoded in decimal. Integer value ranges listed below are + * expressed as fixed sized integer types capable of storing the conversion + * of a properly formated node string, without loss of information. + * + * Any specified default value is in effect if the corresponding XenBus node + * is not present in the XenStore. + * + * XenStore nodes in sections marked "PRIVATE" are solely for use by the + * driver side whose XenBus tree contains them. + * + * XenStore nodes marked "DEPRECATED" in their notes section should only be + * used to provide interoperability with legacy implementations. + * + * See the XenBus state transition diagram below for details on when XenBus + * nodes must be published and when they can be queried. + * + ***************************************************************************** + * Backend XenBus Nodes + ***************************************************************************** + * + *------------------ Backend Device Identification (PRIVATE) ------------------ + * + * mode + * Values: "r" (read only), "w" (writable) + * + * The read or write access permissions to the backing store to be + * granted to the frontend. + * + * params + * Values: string + * + * A free formatted string providing sufficient information for the + * backend driver to open the backing device. (e.g. the path to the + * file or block device representing the backing store.) + * + * type + * Values: "file", "phy", "tap" + * + * The type of the backing device/object. + * + *--------------------------------- Features --------------------------------- + * + * feature-barrier + * Values: 0/1 (boolean) + * Default Value: 0 + * + * A value of "1" indicates that the backend can process requests + * containing the BLKIF_OP_WRITE_BARRIER request opcode. Requests + * of this type may still be returned at any time with the + * BLKIF_RSP_EOPNOTSUPP result code. + * + * feature-flush-cache + * Values: 0/1 (boolean) + * Default Value: 0 + * + * A value of "1" indicates that the backend can process requests + * containing the BLKIF_OP_FLUSH_DISKCACHE request opcode. Requests + * of this type may still be returned at any time with the + * BLKIF_RSP_EOPNOTSUPP result code. + * + * feature-discard + * Values: 0/1 (boolean) + * Default Value: 0 + * + * A value of "1" indicates that the backend can process requests + * containing the BLKIF_OP_DISCARD request opcode. Requests + * of this type may still be returned at any time with the + * BLKIF_RSP_EOPNOTSUPP result code. + * + * feature-persistent + * Values: 0/1 (boolean) + * Default Value: 0 + * Notes: 7 + * + * A value of "1" indicates that the backend can keep the grants used + * by the frontend driver mapped, so the same set of grants should be + * used in all transactions. The maximum number of grants the backend + * can map persistently depends on the implementation, but ideally it + * should be RING_SIZE * BLKIF_MAX_SEGMENTS_PER_REQUEST. Using this + * feature the backend doesn't need to unmap each grant, preventing + * costly TLB flushes. The backend driver should only map grants + * persistently if the frontend supports it. If a backend driver chooses + * to use the persistent protocol when the frontend doesn't support it, + * it will probably hit the maximum number of persistently mapped grants + * (due to the fact that the frontend won't be reusing the same grants), + * and fall back to non-persistent mode. Backend implementations may + * shrink or expand the number of persistently mapped grants without + * notifying the frontend depending on memory constraints (this might + * cause a performance degradation). + * + * If a backend driver wants to limit the maximum number of persistently + * mapped grants to a value less than RING_SIZE * + * BLKIF_MAX_SEGMENTS_PER_REQUEST a LRU strategy should be used to + * discard the grants that are less commonly used. Using a LRU in the + * backend driver paired with a LIFO queue in the frontend will + * allow us to have better performance in this scenario. + * + *----------------------- Request Transport Parameters ------------------------ + * + * max-ring-page-order + * Values: + * Default Value: 0 + * Notes: 1, 3 + * + * The maximum supported size of the request ring buffer in units of + * lb(machine pages). (e.g. 0 == 1 page, 1 = 2 pages, 2 == 4 pages, + * etc.). + * + * max-ring-pages + * Values: + * Default Value: 1 + * Notes: DEPRECATED, 2, 3 + * + * The maximum supported size of the request ring buffer in units of + * machine pages. The value must be a power of 2. + * + *------------------------- Backend Device Properties ------------------------- + * + * discard-alignment + * Values: + * Default Value: 0 + * Notes: 4, 5 + * + * The offset, in bytes from the beginning of the virtual block device, + * to the first, addressable, discard extent on the underlying device. + * + * discard-granularity + * Values: + * Default Value: <"sector-size"> + * Notes: 4 + * + * The size, in bytes, of the individually addressable discard extents + * of the underlying device. + * + * discard-secure + * Values: 0/1 (boolean) + * Default Value: 0 + * Notes: 10 + * + * A value of "1" indicates that the backend can process BLKIF_OP_DISCARD + * requests with the BLKIF_DISCARD_SECURE flag set. + * + * info + * Values: (bitmap) + * + * A collection of bit flags describing attributes of the backing + * device. The VDISK_* macros define the meaning of each bit + * location. + * + * sector-size + * Values: + * + * The logical sector size, in bytes, of the backend device. + * + * physical-sector-size + * Values: + * + * The physical sector size, in bytes, of the backend device. + * + * sectors + * Values: + * + * The size of the backend device, expressed in units of its logical + * sector size ("sector-size"). + * + ***************************************************************************** + * Frontend XenBus Nodes + ***************************************************************************** + * + *----------------------- Request Transport Parameters ----------------------- + * + * event-channel + * Values: + * + * The identifier of the Xen event channel used to signal activity + * in the ring buffer. + * + * ring-ref + * Values: + * Notes: 6 + * + * The Xen grant reference granting permission for the backend to map + * the sole page in a single page sized ring buffer. + * + * ring-ref%u + * Values: + * Notes: 6 + * + * For a frontend providing a multi-page ring, a "number of ring pages" + * sized list of nodes, each containing a Xen grant reference granting + * permission for the backend to map the page of the ring located + * at page index "%u". Page indexes are zero based. + * + * protocol + * Values: string (XEN_IO_PROTO_ABI_*) + * Default Value: XEN_IO_PROTO_ABI_NATIVE + * + * The machine ABI rules governing the format of all ring request and + * response structures. + * + * ring-page-order + * Values: + * Default Value: 0 + * Maximum Value: MAX(ffs(max-ring-pages) - 1, max-ring-page-order) + * Notes: 1, 3 + * + * The size of the frontend allocated request ring buffer in units + * of lb(machine pages). (e.g. 0 == 1 page, 1 = 2 pages, 2 == 4 pages, + * etc.). + * + * num-ring-pages + * Values: + * Default Value: 1 + * Maximum Value: MAX(max-ring-pages,(0x1 << max-ring-page-order)) + * Notes: DEPRECATED, 2, 3 + * + * The size of the frontend allocated request ring buffer in units of + * machine pages. The value must be a power of 2. + * + * feature-persistent + * Values: 0/1 (boolean) + * Default Value: 0 + * Notes: 7, 8, 9 + * + * A value of "1" indicates that the frontend will reuse the same grants + * for all transactions, allowing the backend to map them with write + * access (even when it should be read-only). If the frontend hits the + * maximum number of allowed persistently mapped grants, it can fallback + * to non persistent mode. This will cause a performance degradation, + * since the the backend driver will still try to map those grants + * persistently. Since the persistent grants protocol is compatible with + * the previous protocol, a frontend driver can choose to work in + * persistent mode even when the backend doesn't support it. + * + * It is recommended that the frontend driver stores the persistently + * mapped grants in a LIFO queue, so a subset of all persistently mapped + * grants gets used commonly. This is done in case the backend driver + * decides to limit the maximum number of persistently mapped grants + * to a value less than RING_SIZE * BLKIF_MAX_SEGMENTS_PER_REQUEST. + * + *------------------------- Virtual Device Properties ------------------------- + * + * device-type + * Values: "disk", "cdrom", "floppy", etc. + * + * virtual-device + * Values: + * + * A value indicating the physical device to virtualize within the + * frontend's domain. (e.g. "The first ATA disk", "The third SCSI + * disk", etc.) + * + * See docs/misc/vbd-interface.txt for details on the format of this + * value. + * + * Notes + * ----- + * (1) Multi-page ring buffer scheme first developed in the Citrix XenServer + * PV drivers. + * (2) Multi-page ring buffer scheme first used in some RedHat distributions + * including a distribution deployed on certain nodes of the Amazon + * EC2 cluster. + * (3) Support for multi-page ring buffers was implemented independently, + * in slightly different forms, by both Citrix and RedHat/Amazon. + * For full interoperability, block front and backends should publish + * identical ring parameters, adjusted for unit differences, to the + * XenStore nodes used in both schemes. + * (4) Devices that support discard functionality may internally allocate space + * (discardable extents) in units that are larger than the exported logical + * block size. If the backing device has such discardable extents the + * backend should provide both discard-granularity and discard-alignment. + * Providing just one of the two may be considered an error by the frontend. + * Backends supporting discard should include discard-granularity and + * discard-alignment even if it supports discarding individual sectors. + * Frontends should assume discard-alignment == 0 and discard-granularity + * == sector size if these keys are missing. + * (5) The discard-alignment parameter allows a physical device to be + * partitioned into virtual devices that do not necessarily begin or + * end on a discardable extent boundary. + * (6) When there is only a single page allocated to the request ring, + * 'ring-ref' is used to communicate the grant reference for this + * page to the backend. When using a multi-page ring, the 'ring-ref' + * node is not created. Instead 'ring-ref0' - 'ring-refN' are used. + * (7) When using persistent grants data has to be copied from/to the page + * where the grant is currently mapped. The overhead of doing this copy + * however doesn't suppress the speed improvement of not having to unmap + * the grants. + * (8) The frontend driver has to allow the backend driver to map all grants + * with write access, even when they should be mapped read-only, since + * further requests may reuse these grants and require write permissions. + * (9) Linux implementation doesn't have a limit on the maximum number of + * grants that can be persistently mapped in the frontend driver, but + * due to the frontent driver implementation it should never be bigger + * than RING_SIZE * BLKIF_MAX_SEGMENTS_PER_REQUEST. + *(10) The discard-secure property may be present and will be set to 1 if the + * backing device supports secure discard. + */ + +/* + * STATE DIAGRAMS + * + ***************************************************************************** + * Startup * + ***************************************************************************** + * + * Tool stack creates front and back nodes with state XenbusStateInitialising. + * + * Front Back + * ================================= ===================================== + * XenbusStateInitialising XenbusStateInitialising + * o Query virtual device o Query backend device identification + * properties. data. + * o Setup OS device instance. o Open and validate backend device. + * o Publish backend features and + * transport parameters. + * | + * | + * V + * XenbusStateInitWait + * + * o Query backend features and + * transport parameters. + * o Allocate and initialize the + * request ring. + * o Publish transport parameters + * that will be in effect during + * this connection. + * | + * | + * V + * XenbusStateInitialised + * + * o Query frontend transport parameters. + * o Connect to the request ring and + * event channel. + * o Publish backend device properties. + * | + * | + * V + * XenbusStateConnected + * + * o Query backend device properties. + * o Finalize OS virtual device + * instance. + * | + * | + * V + * XenbusStateConnected + * + * Note: Drivers that do not support any optional features, or the negotiation + * of transport parameters, can skip certain states in the state machine: + * + * o A frontend may transition to XenbusStateInitialised without + * waiting for the backend to enter XenbusStateInitWait. In this + * case, default transport parameters are in effect and any + * transport parameters published by the frontend must contain + * their default values. + * + * o A backend may transition to XenbusStateInitialised, bypassing + * XenbusStateInitWait, without waiting for the frontend to first + * enter the XenbusStateInitialised state. In this case, default + * transport parameters are in effect and any transport parameters + * published by the backend must contain their default values. + * + * Drivers that support optional features and/or transport parameter + * negotiation must tolerate these additional state transition paths. + * In general this means performing the work of any skipped state + * transition, if it has not already been performed, in addition to the + * work associated with entry into the current state. + */ + +/* + * REQUEST CODES. + */ +#define BLKIF_OP_READ 0 +#define BLKIF_OP_WRITE 1 +/* + * All writes issued prior to a request with the BLKIF_OP_WRITE_BARRIER + * operation code ("barrier request") must be completed prior to the + * execution of the barrier request. All writes issued after the barrier + * request must not execute until after the completion of the barrier request. + * + * Optional. See "feature-barrier" XenBus node documentation above. + */ +#define BLKIF_OP_WRITE_BARRIER 2 +/* + * Commit any uncommitted contents of the backing device's volatile cache + * to stable storage. + * + * Optional. See "feature-flush-cache" XenBus node documentation above. + */ +#define BLKIF_OP_FLUSH_DISKCACHE 3 +/* + * Used in SLES sources for device specific command packet + * contained within the request. Reserved for that purpose. + */ +#define BLKIF_OP_RESERVED_1 4 +/* + * Indicate to the backend device that a region of storage is no longer in + * use, and may be discarded at any time without impact to the client. If + * the BLKIF_DISCARD_SECURE flag is set on the request, all copies of the + * discarded region on the device must be rendered unrecoverable before the + * command returns. + * + * This operation is analogous to performing a trim (ATA) or unamp (SCSI), + * command on a native device. + * + * More information about trim/unmap operations can be found at: + * http://t13.org/Documents/UploadedDocuments/docs2008/ + * e07154r6-Data_Set_Management_Proposal_for_ATA-ACS2.doc + * http://www.seagate.com/staticfiles/support/disc/manuals/ + * Interface%20manuals/100293068c.pdf + * + * Optional. See "feature-discard", "discard-alignment", + * "discard-granularity", and "discard-secure" in the XenBus node + * documentation above. + */ +#define BLKIF_OP_DISCARD 5 + +/* + * Recognized if "feature-max-indirect-segments" in present in the backend + * xenbus info. The "feature-max-indirect-segments" node contains the maximum + * number of segments allowed by the backend per request. If the node is + * present, the frontend might use blkif_request_indirect structs in order to + * issue requests with more than BLKIF_MAX_SEGMENTS_PER_REQUEST (11). The + * maximum number of indirect segments is fixed by the backend, but the + * frontend can issue requests with any number of indirect segments as long as + * it's less than the number provided by the backend. The indirect_grefs field + * in blkif_request_indirect should be filled by the frontend with the + * grant references of the pages that are holding the indirect segments. + * These pages are filled with an array of blkif_request_segment that hold the + * information about the segments. The number of indirect pages to use is + * determined by the number of segments an indirect request contains. Every + * indirect page can contain a maximum of + * (PAGE_SIZE / sizeof(struct blkif_request_segment)) segments, so to + * calculate the number of indirect pages to use we have to do + * ceil(indirect_segments / (PAGE_SIZE / sizeof(struct blkif_request_segment))). + * + * If a backend does not recognize BLKIF_OP_INDIRECT, it should *not* + * create the "feature-max-indirect-segments" node! + */ +#define BLKIF_OP_INDIRECT 6 + +/* + * Maximum scatter/gather segments per request. + * This is carefully chosen so that sizeof(blkif_ring_t) <= PAGE_SIZE. + * NB. This could be 12 if the ring indexes weren't stored in the same page. + */ +#define BLKIF_MAX_SEGMENTS_PER_REQUEST 11 + +/* + * Maximum number of indirect pages to use per request. + */ +#define BLKIF_MAX_INDIRECT_PAGES_PER_REQUEST 8 + +/* + * NB. first_sect and last_sect in blkif_request_segment, as well as + * sector_number in blkif_request, are always expressed in 512-byte units. + * However they must be properly aligned to the real sector size of the + * physical disk, which is reported in the "physical-sector-size" node in + * the backend xenbus info. Also the xenbus "sectors" node is expressed in + * 512-byte units. + */ +struct blkif_request_segment { + grant_ref_t gref; /* reference to I/O buffer frame */ + /* @first_sect: first sector in frame to transfer (inclusive). */ + /* @last_sect: last sector in frame to transfer (inclusive). */ + uint8_t first_sect, last_sect; +}; + +/* + * Starting ring element for any I/O request. + */ +struct blkif_request { + uint8_t operation; /* BLKIF_OP_??? */ + uint8_t nr_segments; /* number of segments */ + blkif_vdev_t handle; /* only for read/write requests */ + uint64_t id; /* private guest value, echoed in resp */ + blkif_sector_t sector_number;/* start sector idx on disk (r/w only) */ + struct blkif_request_segment seg[BLKIF_MAX_SEGMENTS_PER_REQUEST]; +}; +typedef struct blkif_request blkif_request_t; + +/* + * Cast to this structure when blkif_request.operation == BLKIF_OP_DISCARD + * sizeof(struct blkif_request_discard) <= sizeof(struct blkif_request) + */ +struct blkif_request_discard { + uint8_t operation; /* BLKIF_OP_DISCARD */ + uint8_t flag; /* BLKIF_DISCARD_SECURE or zero */ +#define BLKIF_DISCARD_SECURE (1<<0) /* ignored if discard-secure=0 */ + blkif_vdev_t handle; /* same as for read/write requests */ + uint64_t id; /* private guest value, echoed in resp */ + blkif_sector_t sector_number;/* start sector idx on disk */ + uint64_t nr_sectors; /* number of contiguous sectors to discard*/ +}; +typedef struct blkif_request_discard blkif_request_discard_t; + +struct blkif_request_indirect { + uint8_t operation; /* BLKIF_OP_INDIRECT */ + uint8_t indirect_op; /* BLKIF_OP_{READ/WRITE} */ + uint16_t nr_segments; /* number of segments */ + uint64_t id; /* private guest value, echoed in resp */ + blkif_sector_t sector_number;/* start sector idx on disk (r/w only) */ + blkif_vdev_t handle; /* same as for read/write requests */ + grant_ref_t indirect_grefs[BLKIF_MAX_INDIRECT_PAGES_PER_REQUEST]; +#ifdef __i386__ + uint64_t pad; /* Make it 64 byte aligned on i386 */ +#endif +}; +typedef struct blkif_request_indirect blkif_request_indirect_t; + +struct blkif_response { + uint64_t id; /* copied from request */ + uint8_t operation; /* copied from request */ + int16_t status; /* BLKIF_RSP_??? */ +}; +typedef struct blkif_response blkif_response_t; + +/* + * STATUS RETURN CODES. + */ + /* Operation not supported (only happens on barrier writes). */ +#define BLKIF_RSP_EOPNOTSUPP -2 + /* Operation failed for some unspecified reason (-EIO). */ +#define BLKIF_RSP_ERROR -1 + /* Operation completed successfully. */ +#define BLKIF_RSP_OKAY 0 + +/* + * Generate blkif ring structures and types. + */ +DEFINE_RING_TYPES(blkif, struct blkif_request, struct blkif_response); + +#define VDISK_CDROM 0x1 +#define VDISK_REMOVABLE 0x2 +#define VDISK_READONLY 0x4 + +#endif /* __XEN_PUBLIC_IO_BLKIF_H__ */ + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * tab-width: 4 + * indent-tabs-mode: nil + * End: + */ diff --git a/include/xen/io/console.h b/include/xen/io/console.h new file mode 100644 index 000000000..e2cd97f77 --- /dev/null +++ b/include/xen/io/console.h @@ -0,0 +1,51 @@ +/****************************************************************************** + * console.h + * + * Console I/O interface for Xen guest OSes. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + * Copyright (c) 2005, Keir Fraser + */ + +#ifndef __XEN_PUBLIC_IO_CONSOLE_H__ +#define __XEN_PUBLIC_IO_CONSOLE_H__ + +typedef uint32_t XENCONS_RING_IDX; + +#define MASK_XENCONS_IDX(idx, ring) ((idx) & (sizeof(ring)-1)) + +struct xencons_interface { + char in[1024]; + char out[2048]; + XENCONS_RING_IDX in_cons, in_prod; + XENCONS_RING_IDX out_cons, out_prod; +}; + +#endif /* __XEN_PUBLIC_IO_CONSOLE_H__ */ + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * tab-width: 4 + * indent-tabs-mode: nil + * End: + */ diff --git a/include/xen/io/protocols.h b/include/xen/io/protocols.h new file mode 100644 index 000000000..80b196bc3 --- /dev/null +++ b/include/xen/io/protocols.h @@ -0,0 +1,40 @@ +/****************************************************************************** + * protocols.h + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#ifndef __XEN_PROTOCOLS_H__ +#define __XEN_PROTOCOLS_H__ + +#define XEN_IO_PROTO_ABI_X86_32 "x86_32-abi" +#define XEN_IO_PROTO_ABI_X86_64 "x86_64-abi" +#define XEN_IO_PROTO_ABI_ARM "arm-abi" + +#if defined(__i386__) +# define XEN_IO_PROTO_ABI_NATIVE XEN_IO_PROTO_ABI_X86_32 +#elif defined(__x86_64__) +# define XEN_IO_PROTO_ABI_NATIVE XEN_IO_PROTO_ABI_X86_64 +#elif defined(__arm__) || defined(__aarch64__) +# define XEN_IO_PROTO_ABI_NATIVE XEN_IO_PROTO_ABI_ARM +#else +# error arch fixup needed here +#endif + +#endif diff --git a/include/xen/io/ring.h b/include/xen/io/ring.h new file mode 100644 index 000000000..73e13d7ae --- /dev/null +++ b/include/xen/io/ring.h @@ -0,0 +1,312 @@ +/****************************************************************************** + * ring.h + * + * Shared producer-consumer ring macros. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + * Tim Deegan and Andrew Warfield November 2004. + */ + +#ifndef __XEN_PUBLIC_IO_RING_H__ +#define __XEN_PUBLIC_IO_RING_H__ + +#include "../xen-compat.h" + +#if __XEN_INTERFACE_VERSION__ < 0x00030208 +#define xen_mb() mb() +#define xen_rmb() rmb() +#define xen_wmb() wmb() +#endif + +typedef unsigned int RING_IDX; + +/* Round a 32-bit unsigned constant down to the nearest power of two. */ +#define __RD2(_x) (((_x) & 0x00000002) ? 0x2 : ((_x) & 0x1)) +#define __RD4(_x) (((_x) & 0x0000000c) ? __RD2((_x)>>2)<<2 : __RD2(_x)) +#define __RD8(_x) (((_x) & 0x000000f0) ? __RD4((_x)>>4)<<4 : __RD4(_x)) +#define __RD16(_x) (((_x) & 0x0000ff00) ? __RD8((_x)>>8)<<8 : __RD8(_x)) +#define __RD32(_x) (((_x) & 0xffff0000) ? __RD16((_x)>>16)<<16 : __RD16(_x)) + +/* + * Calculate size of a shared ring, given the total available space for the + * ring and indexes (_sz), and the name tag of the request/response structure. + * A ring contains as many entries as will fit, rounded down to the nearest + * power of two (so we can mask with (size-1) to loop around). + */ +#define __CONST_RING_SIZE(_s, _sz) \ + (__RD32(((_sz) - offsetof(struct _s##_sring, ring)) / \ + sizeof(((struct _s##_sring *)0)->ring[0]))) +/* + * The same for passing in an actual pointer instead of a name tag. + */ +#define __RING_SIZE(_s, _sz) \ + (__RD32(((_sz) - (long)(_s)->ring + (long)(_s)) / sizeof((_s)->ring[0]))) + +/* + * Macros to make the correct C datatypes for a new kind of ring. + * + * To make a new ring datatype, you need to have two message structures, + * let's say request_t, and response_t already defined. + * + * In a header where you want the ring datatype declared, you then do: + * + * DEFINE_RING_TYPES(mytag, request_t, response_t); + * + * These expand out to give you a set of types, as you can see below. + * The most important of these are: + * + * mytag_sring_t - The shared ring. + * mytag_front_ring_t - The 'front' half of the ring. + * mytag_back_ring_t - The 'back' half of the ring. + * + * To initialize a ring in your code you need to know the location and size + * of the shared memory area (PAGE_SIZE, for instance). To initialise + * the front half: + * + * mytag_front_ring_t front_ring; + * SHARED_RING_INIT((mytag_sring_t *)shared_page); + * FRONT_RING_INIT(&front_ring, (mytag_sring_t *)shared_page, PAGE_SIZE); + * + * Initializing the back follows similarly (note that only the front + * initializes the shared ring): + * + * mytag_back_ring_t back_ring; + * BACK_RING_INIT(&back_ring, (mytag_sring_t *)shared_page, PAGE_SIZE); + */ + +#define DEFINE_RING_TYPES(__name, __req_t, __rsp_t) \ + \ +/* Shared ring entry */ \ +union __name##_sring_entry { \ + __req_t req; \ + __rsp_t rsp; \ +}; \ + \ +/* Shared ring page */ \ +struct __name##_sring { \ + RING_IDX req_prod, req_event; \ + RING_IDX rsp_prod, rsp_event; \ + union { \ + struct { \ + uint8_t smartpoll_active; \ + } netif; \ + struct { \ + uint8_t msg; \ + } tapif_user; \ + uint8_t pvt_pad[4]; \ + } private; \ + uint8_t __pad[44]; \ + union __name##_sring_entry ring[1]; /* variable-length */ \ +}; \ + \ +/* "Front" end's private variables */ \ +struct __name##_front_ring { \ + RING_IDX req_prod_pvt; \ + RING_IDX rsp_cons; \ + unsigned int nr_ents; \ + struct __name##_sring *sring; \ +}; \ + \ +/* "Back" end's private variables */ \ +struct __name##_back_ring { \ + RING_IDX rsp_prod_pvt; \ + RING_IDX req_cons; \ + unsigned int nr_ents; \ + struct __name##_sring *sring; \ +}; \ + \ +/* Syntactic sugar */ \ +typedef struct __name##_sring __name##_sring_t; \ +typedef struct __name##_front_ring __name##_front_ring_t; \ +typedef struct __name##_back_ring __name##_back_ring_t + +/* + * Macros for manipulating rings. + * + * FRONT_RING_whatever works on the "front end" of a ring: here + * requests are pushed on to the ring and responses taken off it. + * + * BACK_RING_whatever works on the "back end" of a ring: here + * requests are taken off the ring and responses put on. + * + * N.B. these macros do NO INTERLOCKS OR FLOW CONTROL. + * This is OK in 1-for-1 request-response situations where the + * requestor (front end) never has more than RING_SIZE()-1 + * outstanding requests. + */ + +/* Initialising empty rings */ +#define SHARED_RING_INIT(_s) do { \ + (_s)->req_prod = (_s)->rsp_prod = 0; \ + (_s)->req_event = (_s)->rsp_event = 1; \ + (void)memset((_s)->private.pvt_pad, 0, sizeof((_s)->private.pvt_pad)); \ + (void)memset((_s)->__pad, 0, sizeof((_s)->__pad)); \ +} while(0) + +#define FRONT_RING_INIT(_r, _s, __size) do { \ + (_r)->req_prod_pvt = 0; \ + (_r)->rsp_cons = 0; \ + (_r)->nr_ents = __RING_SIZE(_s, __size); \ + (_r)->sring = (_s); \ +} while (0) + +#define BACK_RING_INIT(_r, _s, __size) do { \ + (_r)->rsp_prod_pvt = 0; \ + (_r)->req_cons = 0; \ + (_r)->nr_ents = __RING_SIZE(_s, __size); \ + (_r)->sring = (_s); \ +} while (0) + +/* How big is this ring? */ +#define RING_SIZE(_r) \ + ((_r)->nr_ents) + +/* Number of free requests (for use on front side only). */ +#define RING_FREE_REQUESTS(_r) \ + (RING_SIZE(_r) - ((_r)->req_prod_pvt - (_r)->rsp_cons)) + +/* Test if there is an empty slot available on the front ring. + * (This is only meaningful from the front. ) + */ +#define RING_FULL(_r) \ + (RING_FREE_REQUESTS(_r) == 0) + +/* Test if there are outstanding messages to be processed on a ring. */ +#define RING_HAS_UNCONSUMED_RESPONSES(_r) \ + ((_r)->sring->rsp_prod - (_r)->rsp_cons) + +#ifdef __GNUC__ +#define RING_HAS_UNCONSUMED_REQUESTS(_r) ({ \ + unsigned int req = (_r)->sring->req_prod - (_r)->req_cons; \ + unsigned int rsp = RING_SIZE(_r) - \ + ((_r)->req_cons - (_r)->rsp_prod_pvt); \ + req < rsp ? req : rsp; \ +}) +#else +/* Same as above, but without the nice GCC ({ ... }) syntax. */ +#define RING_HAS_UNCONSUMED_REQUESTS(_r) \ + ((((_r)->sring->req_prod - (_r)->req_cons) < \ + (RING_SIZE(_r) - ((_r)->req_cons - (_r)->rsp_prod_pvt))) ? \ + ((_r)->sring->req_prod - (_r)->req_cons) : \ + (RING_SIZE(_r) - ((_r)->req_cons - (_r)->rsp_prod_pvt))) +#endif + +/* Direct access to individual ring elements, by index. */ +#define RING_GET_REQUEST(_r, _idx) \ + (&((_r)->sring->ring[((_idx) & (RING_SIZE(_r) - 1))].req)) + +#define RING_GET_RESPONSE(_r, _idx) \ + (&((_r)->sring->ring[((_idx) & (RING_SIZE(_r) - 1))].rsp)) + +/* Loop termination condition: Would the specified index overflow the ring? */ +#define RING_REQUEST_CONS_OVERFLOW(_r, _cons) \ + (((_cons) - (_r)->rsp_prod_pvt) >= RING_SIZE(_r)) + +/* Ill-behaved frontend determination: Can there be this many requests? */ +#define RING_REQUEST_PROD_OVERFLOW(_r, _prod) \ + (((_prod) - (_r)->rsp_prod_pvt) > RING_SIZE(_r)) + +#define RING_PUSH_REQUESTS(_r) do { \ + xen_wmb(); /* back sees requests /before/ updated producer index */ \ + (_r)->sring->req_prod = (_r)->req_prod_pvt; \ +} while (0) + +#define RING_PUSH_RESPONSES(_r) do { \ + xen_wmb(); /* front sees resps /before/ updated producer index */ \ + (_r)->sring->rsp_prod = (_r)->rsp_prod_pvt; \ +} while (0) + +/* + * Notification hold-off (req_event and rsp_event): + * + * When queueing requests or responses on a shared ring, it may not always be + * necessary to notify the remote end. For example, if requests are in flight + * in a backend, the front may be able to queue further requests without + * notifying the back (if the back checks for new requests when it queues + * responses). + * + * When enqueuing requests or responses: + * + * Use RING_PUSH_{REQUESTS,RESPONSES}_AND_CHECK_NOTIFY(). The second argument + * is a boolean return value. True indicates that the receiver requires an + * asynchronous notification. + * + * After dequeuing requests or responses (before sleeping the connection): + * + * Use RING_FINAL_CHECK_FOR_REQUESTS() or RING_FINAL_CHECK_FOR_RESPONSES(). + * The second argument is a boolean return value. True indicates that there + * are pending messages on the ring (i.e., the connection should not be put + * to sleep). + * + * These macros will set the req_event/rsp_event field to trigger a + * notification on the very next message that is enqueued. If you want to + * create batches of work (i.e., only receive a notification after several + * messages have been enqueued) then you will need to create a customised + * version of the FINAL_CHECK macro in your own code, which sets the event + * field appropriately. + */ + +#define RING_PUSH_REQUESTS_AND_CHECK_NOTIFY(_r, _notify) do { \ + RING_IDX __old = (_r)->sring->req_prod; \ + RING_IDX __new = (_r)->req_prod_pvt; \ + xen_wmb(); /* back sees requests /before/ updated producer index */ \ + (_r)->sring->req_prod = __new; \ + xen_mb(); /* back sees new requests /before/ we check req_event */ \ + (_notify) = ((RING_IDX)(__new - (_r)->sring->req_event) < \ + (RING_IDX)(__new - __old)); \ +} while (0) + +#define RING_PUSH_RESPONSES_AND_CHECK_NOTIFY(_r, _notify) do { \ + RING_IDX __old = (_r)->sring->rsp_prod; \ + RING_IDX __new = (_r)->rsp_prod_pvt; \ + xen_wmb(); /* front sees resps /before/ updated producer index */ \ + (_r)->sring->rsp_prod = __new; \ + xen_mb(); /* front sees new resps /before/ we check rsp_event */ \ + (_notify) = ((RING_IDX)(__new - (_r)->sring->rsp_event) < \ + (RING_IDX)(__new - __old)); \ +} while (0) + +#define RING_FINAL_CHECK_FOR_REQUESTS(_r, _work_to_do) do { \ + (_work_to_do) = RING_HAS_UNCONSUMED_REQUESTS(_r); \ + if (_work_to_do) break; \ + (_r)->sring->req_event = (_r)->req_cons + 1; \ + xen_mb(); \ + (_work_to_do) = RING_HAS_UNCONSUMED_REQUESTS(_r); \ +} while (0) + +#define RING_FINAL_CHECK_FOR_RESPONSES(_r, _work_to_do) do { \ + (_work_to_do) = RING_HAS_UNCONSUMED_RESPONSES(_r); \ + if (_work_to_do) break; \ + (_r)->sring->rsp_event = (_r)->rsp_cons + 1; \ + xen_mb(); \ + (_work_to_do) = RING_HAS_UNCONSUMED_RESPONSES(_r); \ +} while (0) + +#endif /* __XEN_PUBLIC_IO_RING_H__ */ + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * tab-width: 4 + * indent-tabs-mode: nil + * End: + */ diff --git a/include/xen/io/xenbus.h b/include/xen/io/xenbus.h new file mode 100644 index 000000000..927f9db55 --- /dev/null +++ b/include/xen/io/xenbus.h @@ -0,0 +1,80 @@ +/***************************************************************************** + * xenbus.h + * + * Xenbus protocol details. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + * Copyright (C) 2005 XenSource Ltd. + */ + +#ifndef _XEN_PUBLIC_IO_XENBUS_H +#define _XEN_PUBLIC_IO_XENBUS_H + +/* + * The state of either end of the Xenbus, i.e. the current communication + * status of initialisation across the bus. States here imply nothing about + * the state of the connection between the driver and the kernel's device + * layers. + */ +enum xenbus_state { + XenbusStateUnknown = 0, + + XenbusStateInitialising = 1, + + /* + * InitWait: Finished early initialisation but waiting for information + * from the peer or hotplug scripts. + */ + XenbusStateInitWait = 2, + + /* + * Initialised: Waiting for a connection from the peer. + */ + XenbusStateInitialised = 3, + + XenbusStateConnected = 4, + + /* + * Closing: The device is being closed due to an error or an unplug event. + */ + XenbusStateClosing = 5, + + XenbusStateClosed = 6, + + /* + * Reconfiguring: The device is being reconfigured. + */ + XenbusStateReconfiguring = 7, + + XenbusStateReconfigured = 8 +}; +typedef enum xenbus_state XenbusState; + +#endif /* _XEN_PUBLIC_IO_XENBUS_H */ + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * tab-width: 4 + * indent-tabs-mode: nil + * End: + */ diff --git a/include/xen/io/xs_wire.h b/include/xen/io/xs_wire.h new file mode 100644 index 000000000..585f0c8f5 --- /dev/null +++ b/include/xen/io/xs_wire.h @@ -0,0 +1,138 @@ +/* + * Details of the "wire" protocol between Xen Store Daemon and client + * library or guest kernel. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + * Copyright (C) 2005 Rusty Russell IBM Corporation + */ + +#ifndef _XS_WIRE_H +#define _XS_WIRE_H + +enum xsd_sockmsg_type +{ + XS_DEBUG, + XS_DIRECTORY, + XS_READ, + XS_GET_PERMS, + XS_WATCH, + XS_UNWATCH, + XS_TRANSACTION_START, + XS_TRANSACTION_END, + XS_INTRODUCE, + XS_RELEASE, + XS_GET_DOMAIN_PATH, + XS_WRITE, + XS_MKDIR, + XS_RM, + XS_SET_PERMS, + XS_WATCH_EVENT, + XS_ERROR, + XS_IS_DOMAIN_INTRODUCED, + XS_RESUME, + XS_SET_TARGET, + XS_RESTRICT, + XS_RESET_WATCHES +}; + +#define XS_WRITE_NONE "NONE" +#define XS_WRITE_CREATE "CREATE" +#define XS_WRITE_CREATE_EXCL "CREATE|EXCL" + +/* We hand errors as strings, for portability. */ +struct xsd_errors +{ + int errnum; + const char *errstring; +}; +#ifdef EINVAL +#define XSD_ERROR(x) { x, #x } +/* LINTED: static unused */ +static struct xsd_errors xsd_errors[] +#if defined(__GNUC__) +__attribute__((unused)) +#endif + = { + XSD_ERROR(EINVAL), + XSD_ERROR(EACCES), + XSD_ERROR(EEXIST), + XSD_ERROR(EISDIR), + XSD_ERROR(ENOENT), + XSD_ERROR(ENOMEM), + XSD_ERROR(ENOSPC), + XSD_ERROR(EIO), + XSD_ERROR(ENOTEMPTY), + XSD_ERROR(ENOSYS), + XSD_ERROR(EROFS), + XSD_ERROR(EBUSY), + XSD_ERROR(EAGAIN), + XSD_ERROR(EISCONN), + XSD_ERROR(E2BIG) +}; +#endif + +struct xsd_sockmsg +{ + uint32_t type; /* XS_??? */ + uint32_t req_id;/* Request identifier, echoed in daemon's response. */ + uint32_t tx_id; /* Transaction id (0 if not related to a transaction). */ + uint32_t len; /* Length of data following this. */ + + /* Generally followed by nul-terminated string(s). */ +}; + +enum xs_watch_type +{ + XS_WATCH_PATH = 0, + XS_WATCH_TOKEN +}; + +/* + * `incontents 150 xenstore_struct XenStore wire protocol. + * + * Inter-domain shared memory communications. */ +#define XENSTORE_RING_SIZE 1024 +typedef uint32_t XENSTORE_RING_IDX; +#define MASK_XENSTORE_IDX(idx) ((idx) & (XENSTORE_RING_SIZE-1)) +struct xenstore_domain_interface { + char req[XENSTORE_RING_SIZE]; /* Requests to xenstore daemon. */ + char rsp[XENSTORE_RING_SIZE]; /* Replies and async watch events. */ + XENSTORE_RING_IDX req_cons, req_prod; + XENSTORE_RING_IDX rsp_cons, rsp_prod; +}; + +/* Violating this is very bad. See docs/misc/xenstore.txt. */ +#define XENSTORE_PAYLOAD_MAX 4096 + +/* Violating these just gets you an error back */ +#define XENSTORE_ABS_PATH_MAX 3072 +#define XENSTORE_REL_PATH_MAX 2048 + +#endif /* _XS_WIRE_H */ + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * tab-width: 4 + * indent-tabs-mode: nil + * End: + */ diff --git a/include/xen/sched.h b/include/xen/sched.h new file mode 100644 index 000000000..a30b11d96 --- /dev/null +++ b/include/xen/sched.h @@ -0,0 +1,174 @@ +/****************************************************************************** + * sched.h + * + * Scheduler state interactions + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + * Copyright (c) 2005, Keir Fraser + */ + +#ifndef __XEN_PUBLIC_SCHED_H__ +#define __XEN_PUBLIC_SCHED_H__ + +#include "event_channel.h" + +/* + * `incontents 150 sched Guest Scheduler Operations + * + * The SCHEDOP interface provides mechanisms for a guest to interact + * with the scheduler, including yield, blocking and shutting itself + * down. + */ + +/* + * The prototype for this hypercall is: + * ` long HYPERVISOR_sched_op(enum sched_op cmd, void *arg, ...) + * + * @cmd == SCHEDOP_??? (scheduler operation). + * @arg == Operation-specific extra argument(s), as described below. + * ... == Additional Operation-specific extra arguments, described below. + * + * Versions of Xen prior to 3.0.2 provided only the following legacy version + * of this hypercall, supporting only the commands yield, block and shutdown: + * long sched_op(int cmd, unsigned long arg) + * @cmd == SCHEDOP_??? (scheduler operation). + * @arg == 0 (SCHEDOP_yield and SCHEDOP_block) + * == SHUTDOWN_* code (SCHEDOP_shutdown) + * + * This legacy version is available to new guests as: + * ` long HYPERVISOR_sched_op_compat(enum sched_op cmd, unsigned long arg) + */ + +/* ` enum sched_op { // SCHEDOP_* => struct sched_* */ +/* + * Voluntarily yield the CPU. + * @arg == NULL. + */ +#define SCHEDOP_yield 0 + +/* + * Block execution of this VCPU until an event is received for processing. + * If called with event upcalls masked, this operation will atomically + * reenable event delivery and check for pending events before blocking the + * VCPU. This avoids a "wakeup waiting" race. + * @arg == NULL. + */ +#define SCHEDOP_block 1 + +/* + * Halt execution of this domain (all VCPUs) and notify the system controller. + * @arg == pointer to sched_shutdown_t structure. + * + * If the sched_shutdown_t reason is SHUTDOWN_suspend then this + * hypercall takes an additional extra argument which should be the + * MFN of the guest's start_info_t. + * + * In addition, which reason is SHUTDOWN_suspend this hypercall + * returns 1 if suspend was cancelled or the domain was merely + * checkpointed, and 0 if it is resuming in a new domain. + */ +#define SCHEDOP_shutdown 2 + +/* + * Poll a set of event-channel ports. Return when one or more are pending. An + * optional timeout may be specified. + * @arg == pointer to sched_poll_t structure. + */ +#define SCHEDOP_poll 3 + +/* + * Declare a shutdown for another domain. The main use of this function is + * in interpreting shutdown requests and reasons for fully-virtualized + * domains. A para-virtualized domain may use SCHEDOP_shutdown directly. + * @arg == pointer to sched_remote_shutdown_t structure. + */ +#define SCHEDOP_remote_shutdown 4 + +/* + * Latch a shutdown code, so that when the domain later shuts down it + * reports this code to the control tools. + * @arg == sched_shutdown_t, as for SCHEDOP_shutdown. + */ +#define SCHEDOP_shutdown_code 5 + +/* + * Setup, poke and destroy a domain watchdog timer. + * @arg == pointer to sched_watchdog_t structure. + * With id == 0, setup a domain watchdog timer to cause domain shutdown + * after timeout, returns watchdog id. + * With id != 0 and timeout == 0, destroy domain watchdog timer. + * With id != 0 and timeout != 0, poke watchdog timer and set new timeout. + */ +#define SCHEDOP_watchdog 6 +/* ` } */ + +struct sched_shutdown { + unsigned int reason; /* SHUTDOWN_* => enum sched_shutdown_reason */ +}; +typedef struct sched_shutdown sched_shutdown_t; +DEFINE_XEN_GUEST_HANDLE(sched_shutdown_t); + +struct sched_poll { + XEN_GUEST_HANDLE(evtchn_port_t) ports; + unsigned int nr_ports; + uint64_t timeout; +}; +typedef struct sched_poll sched_poll_t; +DEFINE_XEN_GUEST_HANDLE(sched_poll_t); + +struct sched_remote_shutdown { + domid_t domain_id; /* Remote domain ID */ + unsigned int reason; /* SHUTDOWN_* => enum sched_shutdown_reason */ +}; +typedef struct sched_remote_shutdown sched_remote_shutdown_t; +DEFINE_XEN_GUEST_HANDLE(sched_remote_shutdown_t); + +struct sched_watchdog { + uint32_t id; /* watchdog ID */ + uint32_t timeout; /* timeout */ +}; +typedef struct sched_watchdog sched_watchdog_t; +DEFINE_XEN_GUEST_HANDLE(sched_watchdog_t); + +/* + * Reason codes for SCHEDOP_shutdown. These may be interpreted by control + * software to determine the appropriate action. For the most part, Xen does + * not care about the shutdown code. + */ +/* ` enum sched_shutdown_reason { */ +#define SHUTDOWN_poweroff 0 /* Domain exited normally. Clean up and kill. */ +#define SHUTDOWN_reboot 1 /* Clean up, kill, and then restart. */ +#define SHUTDOWN_suspend 2 /* Clean up, save suspend info, kill. */ +#define SHUTDOWN_crash 3 /* Tell controller we've crashed. */ +#define SHUTDOWN_watchdog 4 /* Restart because watchdog time expired. */ +#define SHUTDOWN_MAX 4 /* Maximum valid shutdown reason. */ +/* ` } */ + +#endif /* __XEN_PUBLIC_SCHED_H__ */ + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * tab-width: 4 + * indent-tabs-mode: nil + * End: + */ diff --git a/include/xen/xen-compat.h b/include/xen/xen-compat.h new file mode 100644 index 000000000..3eb80a02d --- /dev/null +++ b/include/xen/xen-compat.h @@ -0,0 +1,44 @@ +/****************************************************************************** + * xen-compat.h + * + * Guest OS interface to Xen. Compatibility layer. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + * Copyright (c) 2006, Christian Limpach + */ + +#ifndef __XEN_PUBLIC_XEN_COMPAT_H__ +#define __XEN_PUBLIC_XEN_COMPAT_H__ + +#define __XEN_LATEST_INTERFACE_VERSION__ 0x00040400 + +#if defined(__XEN__) || defined(__XEN_TOOLS__) +/* Xen is built with matching headers and implements the latest interface. */ +#define __XEN_INTERFACE_VERSION__ __XEN_LATEST_INTERFACE_VERSION__ +#elif !defined(__XEN_INTERFACE_VERSION__) +/* Guests which do not specify a version get the legacy interface. */ +#define __XEN_INTERFACE_VERSION__ 0x00000000 +#endif + +#if __XEN_INTERFACE_VERSION__ > __XEN_LATEST_INTERFACE_VERSION__ +#error "These header files do not support the requested interface version." +#endif + +#endif /* __XEN_PUBLIC_XEN_COMPAT_H__ */ diff --git a/include/xen/xen.h b/include/xen/xen.h new file mode 100644 index 000000000..a6a20926a --- /dev/null +++ b/include/xen/xen.h @@ -0,0 +1,899 @@ +/****************************************************************************** + * xen.h + * + * Guest OS interface to Xen. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + * Copyright (c) 2004, K A Fraser + */ + +#ifndef __XEN_PUBLIC_XEN_H__ +#define __XEN_PUBLIC_XEN_H__ + +#include "xen-compat.h" + +#if defined(__i386__) || defined(__x86_64__) +#include "arch-x86/xen.h" +#elif defined(__arm__) || defined (__aarch64__) +#include "arch-arm.h" +#else +#error "Unsupported architecture" +#endif + +#ifndef __ASSEMBLY__ +/* Guest handles for primitive C types. */ +DEFINE_XEN_GUEST_HANDLE(char); +__DEFINE_XEN_GUEST_HANDLE(uchar, unsigned char); +DEFINE_XEN_GUEST_HANDLE(int); +__DEFINE_XEN_GUEST_HANDLE(uint, unsigned int); +#if __XEN_INTERFACE_VERSION__ < 0x00040300 +DEFINE_XEN_GUEST_HANDLE(long); +__DEFINE_XEN_GUEST_HANDLE(ulong, unsigned long); +#endif +DEFINE_XEN_GUEST_HANDLE(void); + +DEFINE_XEN_GUEST_HANDLE(uint64_t); +DEFINE_XEN_GUEST_HANDLE(xen_pfn_t); +DEFINE_XEN_GUEST_HANDLE(xen_ulong_t); +#endif + +/* + * HYPERCALLS + */ + +/* `incontents 100 hcalls List of hypercalls + * ` enum hypercall_num { // __HYPERVISOR_* => HYPERVISOR_*() + */ + +#define __HYPERVISOR_set_trap_table 0 +#define __HYPERVISOR_mmu_update 1 +#define __HYPERVISOR_set_gdt 2 +#define __HYPERVISOR_stack_switch 3 +#define __HYPERVISOR_set_callbacks 4 +#define __HYPERVISOR_fpu_taskswitch 5 +#define __HYPERVISOR_sched_op_compat 6 /* compat since 0x00030101 */ +#define __HYPERVISOR_platform_op 7 +#define __HYPERVISOR_set_debugreg 8 +#define __HYPERVISOR_get_debugreg 9 +#define __HYPERVISOR_update_descriptor 10 +#define __HYPERVISOR_memory_op 12 +#define __HYPERVISOR_multicall 13 +#define __HYPERVISOR_update_va_mapping 14 +#define __HYPERVISOR_set_timer_op 15 +#define __HYPERVISOR_event_channel_op_compat 16 /* compat since 0x00030202 */ +#define __HYPERVISOR_xen_version 17 +#define __HYPERVISOR_console_io 18 +#define __HYPERVISOR_physdev_op_compat 19 /* compat since 0x00030202 */ +#define __HYPERVISOR_grant_table_op 20 +#define __HYPERVISOR_vm_assist 21 +#define __HYPERVISOR_update_va_mapping_otherdomain 22 +#define __HYPERVISOR_iret 23 /* x86 only */ +#define __HYPERVISOR_vcpu_op 24 +#define __HYPERVISOR_set_segment_base 25 /* x86/64 only */ +#define __HYPERVISOR_mmuext_op 26 +#define __HYPERVISOR_xsm_op 27 +#define __HYPERVISOR_nmi_op 28 +#define __HYPERVISOR_sched_op 29 +#define __HYPERVISOR_callback_op 30 +#define __HYPERVISOR_xenoprof_op 31 +#define __HYPERVISOR_event_channel_op 32 +#define __HYPERVISOR_physdev_op 33 +#define __HYPERVISOR_hvm_op 34 +#define __HYPERVISOR_sysctl 35 +#define __HYPERVISOR_domctl 36 +#define __HYPERVISOR_kexec_op 37 +#define __HYPERVISOR_tmem_op 38 +#define __HYPERVISOR_xc_reserved_op 39 /* reserved for XenClient */ + +/* Architecture-specific hypercall definitions. */ +#define __HYPERVISOR_arch_0 48 +#define __HYPERVISOR_arch_1 49 +#define __HYPERVISOR_arch_2 50 +#define __HYPERVISOR_arch_3 51 +#define __HYPERVISOR_arch_4 52 +#define __HYPERVISOR_arch_5 53 +#define __HYPERVISOR_arch_6 54 +#define __HYPERVISOR_arch_7 55 + +/* ` } */ + +/* + * HYPERCALL COMPATIBILITY. + */ + +/* New sched_op hypercall introduced in 0x00030101. */ +#if __XEN_INTERFACE_VERSION__ < 0x00030101 +#undef __HYPERVISOR_sched_op +#define __HYPERVISOR_sched_op __HYPERVISOR_sched_op_compat +#endif + +/* New event-channel and physdev hypercalls introduced in 0x00030202. */ +#if __XEN_INTERFACE_VERSION__ < 0x00030202 +#undef __HYPERVISOR_event_channel_op +#define __HYPERVISOR_event_channel_op __HYPERVISOR_event_channel_op_compat +#undef __HYPERVISOR_physdev_op +#define __HYPERVISOR_physdev_op __HYPERVISOR_physdev_op_compat +#endif + +/* New platform_op hypercall introduced in 0x00030204. */ +#if __XEN_INTERFACE_VERSION__ < 0x00030204 +#define __HYPERVISOR_dom0_op __HYPERVISOR_platform_op +#endif + +/* + * VIRTUAL INTERRUPTS + * + * Virtual interrupts that a guest OS may receive from Xen. + * + * In the side comments, 'V.' denotes a per-VCPU VIRQ while 'G.' denotes a + * global VIRQ. The former can be bound once per VCPU and cannot be re-bound. + * The latter can be allocated only once per guest: they must initially be + * allocated to VCPU0 but can subsequently be re-bound. + */ +/* ` enum virq { */ +#define VIRQ_TIMER 0 /* V. Timebase update, and/or requested timeout. */ +#define VIRQ_DEBUG 1 /* V. Request guest to dump debug info. */ +#define VIRQ_CONSOLE 2 /* G. (DOM0) Bytes received on emergency console. */ +#define VIRQ_DOM_EXC 3 /* G. (DOM0) Exceptional event for some domain. */ +#define VIRQ_TBUF 4 /* G. (DOM0) Trace buffer has records available. */ +#define VIRQ_DEBUGGER 6 /* G. (DOM0) A domain has paused for debugging. */ +#define VIRQ_XENOPROF 7 /* V. XenOprofile interrupt: new sample available */ +#define VIRQ_CON_RING 8 /* G. (DOM0) Bytes received on console */ +#define VIRQ_PCPU_STATE 9 /* G. (DOM0) PCPU state changed */ +#define VIRQ_MEM_EVENT 10 /* G. (DOM0) A memory event has occured */ +#define VIRQ_XC_RESERVED 11 /* G. Reserved for XenClient */ +#define VIRQ_ENOMEM 12 /* G. (DOM0) Low on heap memory */ + +/* Architecture-specific VIRQ definitions. */ +#define VIRQ_ARCH_0 16 +#define VIRQ_ARCH_1 17 +#define VIRQ_ARCH_2 18 +#define VIRQ_ARCH_3 19 +#define VIRQ_ARCH_4 20 +#define VIRQ_ARCH_5 21 +#define VIRQ_ARCH_6 22 +#define VIRQ_ARCH_7 23 +/* ` } */ + +#define NR_VIRQS 24 + +/* + * ` enum neg_errnoval + * ` HYPERVISOR_mmu_update(const struct mmu_update reqs[], + * ` unsigned count, unsigned *done_out, + * ` unsigned foreigndom) + * ` + * @reqs is an array of mmu_update_t structures ((ptr, val) pairs). + * @count is the length of the above array. + * @pdone is an output parameter indicating number of completed operations + * @foreigndom[15:0]: FD, the expected owner of data pages referenced in this + * hypercall invocation. Can be DOMID_SELF. + * @foreigndom[31:16]: PFD, the expected owner of pagetable pages referenced + * in this hypercall invocation. The value of this field + * (x) encodes the PFD as follows: + * x == 0 => PFD == DOMID_SELF + * x != 0 => PFD == x - 1 + * + * Sub-commands: ptr[1:0] specifies the appropriate MMU_* command. + * ------------- + * ptr[1:0] == MMU_NORMAL_PT_UPDATE: + * Updates an entry in a page table belonging to PFD. If updating an L1 table, + * and the new table entry is valid/present, the mapped frame must belong to + * FD. If attempting to map an I/O page then the caller assumes the privilege + * of the FD. + * FD == DOMID_IO: Permit /only/ I/O mappings, at the priv level of the caller. + * FD == DOMID_XEN: Map restricted areas of Xen's heap space. + * ptr[:2] -- Machine address of the page-table entry to modify. + * val -- Value to write. + * + * There also certain implicit requirements when using this hypercall. The + * pages that make up a pagetable must be mapped read-only in the guest. + * This prevents uncontrolled guest updates to the pagetable. Xen strictly + * enforces this, and will disallow any pagetable update which will end up + * mapping pagetable page RW, and will disallow using any writable page as a + * pagetable. In practice it means that when constructing a page table for a + * process, thread, etc, we MUST be very dilligient in following these rules: + * 1). Start with top-level page (PGD or in Xen language: L4). Fill out + * the entries. + * 2). Keep on going, filling out the upper (PUD or L3), and middle (PMD + * or L2). + * 3). Start filling out the PTE table (L1) with the PTE entries. Once + * done, make sure to set each of those entries to RO (so writeable bit + * is unset). Once that has been completed, set the PMD (L2) for this + * PTE table as RO. + * 4). When completed with all of the PMD (L2) entries, and all of them have + * been set to RO, make sure to set RO the PUD (L3). Do the same + * operation on PGD (L4) pagetable entries that have a PUD (L3) entry. + * 5). Now before you can use those pages (so setting the cr3), you MUST also + * pin them so that the hypervisor can verify the entries. This is done + * via the HYPERVISOR_mmuext_op(MMUEXT_PIN_L4_TABLE, guest physical frame + * number of the PGD (L4)). And this point the HYPERVISOR_mmuext_op( + * MMUEXT_NEW_BASEPTR, guest physical frame number of the PGD (L4)) can be + * issued. + * For 32-bit guests, the L4 is not used (as there is less pagetables), so + * instead use L3. + * At this point the pagetables can be modified using the MMU_NORMAL_PT_UPDATE + * hypercall. Also if so desired the OS can also try to write to the PTE + * and be trapped by the hypervisor (as the PTE entry is RO). + * + * To deallocate the pages, the operations are the reverse of the steps + * mentioned above. The argument is MMUEXT_UNPIN_TABLE for all levels and the + * pagetable MUST not be in use (meaning that the cr3 is not set to it). + * + * ptr[1:0] == MMU_MACHPHYS_UPDATE: + * Updates an entry in the machine->pseudo-physical mapping table. + * ptr[:2] -- Machine address within the frame whose mapping to modify. + * The frame must belong to the FD, if one is specified. + * val -- Value to write into the mapping entry. + * + * ptr[1:0] == MMU_PT_UPDATE_PRESERVE_AD: + * As MMU_NORMAL_PT_UPDATE above, but A/D bits currently in the PTE are ORed + * with those in @val. + * + * @val is usually the machine frame number along with some attributes. + * The attributes by default follow the architecture defined bits. Meaning that + * if this is a X86_64 machine and four page table layout is used, the layout + * of val is: + * - 63 if set means No execute (NX) + * - 46-13 the machine frame number + * - 12 available for guest + * - 11 available for guest + * - 10 available for guest + * - 9 available for guest + * - 8 global + * - 7 PAT (PSE is disabled, must use hypercall to make 4MB or 2MB pages) + * - 6 dirty + * - 5 accessed + * - 4 page cached disabled + * - 3 page write through + * - 2 userspace accessible + * - 1 writeable + * - 0 present + * + * The one bits that does not fit with the default layout is the PAGE_PSE + * also called PAGE_PAT). The MMUEXT_[UN]MARK_SUPER arguments to the + * HYPERVISOR_mmuext_op serve as mechanism to set a pagetable to be 4MB + * (or 2MB) instead of using the PAGE_PSE bit. + * + * The reason that the PAGE_PSE (bit 7) is not being utilized is due to Xen + * using it as the Page Attribute Table (PAT) bit - for details on it please + * refer to Intel SDM 10.12. The PAT allows to set the caching attributes of + * pages instead of using MTRRs. + * + * The PAT MSR is as follows (it is a 64-bit value, each entry is 8 bits): + * PAT4 PAT0 + * +-----+-----+----+----+----+-----+----+----+ + * | UC | UC- | WC | WB | UC | UC- | WC | WB | <= Linux + * +-----+-----+----+----+----+-----+----+----+ + * | UC | UC- | WT | WB | UC | UC- | WT | WB | <= BIOS (default when machine boots) + * +-----+-----+----+----+----+-----+----+----+ + * | rsv | rsv | WP | WC | UC | UC- | WT | WB | <= Xen + * +-----+-----+----+----+----+-----+----+----+ + * + * The lookup of this index table translates to looking up + * Bit 7, Bit 4, and Bit 3 of val entry: + * + * PAT/PSE (bit 7) ... PCD (bit 4) .. PWT (bit 3). + * + * If all bits are off, then we are using PAT0. If bit 3 turned on, + * then we are using PAT1, if bit 3 and bit 4, then PAT2.. + * + * As you can see, the Linux PAT1 translates to PAT4 under Xen. Which means + * that if a guest that follows Linux's PAT setup and would like to set Write + * Combined on pages it MUST use PAT4 entry. Meaning that Bit 7 (PAGE_PAT) is + * set. For example, under Linux it only uses PAT0, PAT1, and PAT2 for the + * caching as: + * + * WB = none (so PAT0) + * WC = PWT (bit 3 on) + * UC = PWT | PCD (bit 3 and 4 are on). + * + * To make it work with Xen, it needs to translate the WC bit as so: + * + * PWT (so bit 3 on) --> PAT (so bit 7 is on) and clear bit 3 + * + * And to translate back it would: + * + * PAT (bit 7 on) --> PWT (bit 3 on) and clear bit 7. + */ +#define MMU_NORMAL_PT_UPDATE 0 /* checked '*ptr = val'. ptr is MA. */ +#define MMU_MACHPHYS_UPDATE 1 /* ptr = MA of frame to modify entry for */ +#define MMU_PT_UPDATE_PRESERVE_AD 2 /* atomically: *ptr = val | (*ptr&(A|D)) */ + +/* + * MMU EXTENDED OPERATIONS + * + * ` enum neg_errnoval + * ` HYPERVISOR_mmuext_op(mmuext_op_t uops[], + * ` unsigned int count, + * ` unsigned int *pdone, + * ` unsigned int foreigndom) + */ +/* HYPERVISOR_mmuext_op() accepts a list of mmuext_op structures. + * A foreigndom (FD) can be specified (or DOMID_SELF for none). + * Where the FD has some effect, it is described below. + * + * cmd: MMUEXT_(UN)PIN_*_TABLE + * mfn: Machine frame number to be (un)pinned as a p.t. page. + * The frame must belong to the FD, if one is specified. + * + * cmd: MMUEXT_NEW_BASEPTR + * mfn: Machine frame number of new page-table base to install in MMU. + * + * cmd: MMUEXT_NEW_USER_BASEPTR [x86/64 only] + * mfn: Machine frame number of new page-table base to install in MMU + * when in user space. + * + * cmd: MMUEXT_TLB_FLUSH_LOCAL + * No additional arguments. Flushes local TLB. + * + * cmd: MMUEXT_INVLPG_LOCAL + * linear_addr: Linear address to be flushed from the local TLB. + * + * cmd: MMUEXT_TLB_FLUSH_MULTI + * vcpumask: Pointer to bitmap of VCPUs to be flushed. + * + * cmd: MMUEXT_INVLPG_MULTI + * linear_addr: Linear address to be flushed. + * vcpumask: Pointer to bitmap of VCPUs to be flushed. + * + * cmd: MMUEXT_TLB_FLUSH_ALL + * No additional arguments. Flushes all VCPUs' TLBs. + * + * cmd: MMUEXT_INVLPG_ALL + * linear_addr: Linear address to be flushed from all VCPUs' TLBs. + * + * cmd: MMUEXT_FLUSH_CACHE + * No additional arguments. Writes back and flushes cache contents. + * + * cmd: MMUEXT_FLUSH_CACHE_GLOBAL + * No additional arguments. Writes back and flushes cache contents + * on all CPUs in the system. + * + * cmd: MMUEXT_SET_LDT + * linear_addr: Linear address of LDT base (NB. must be page-aligned). + * nr_ents: Number of entries in LDT. + * + * cmd: MMUEXT_CLEAR_PAGE + * mfn: Machine frame number to be cleared. + * + * cmd: MMUEXT_COPY_PAGE + * mfn: Machine frame number of the destination page. + * src_mfn: Machine frame number of the source page. + * + * cmd: MMUEXT_[UN]MARK_SUPER + * mfn: Machine frame number of head of superpage to be [un]marked. + */ +/* ` enum mmuext_cmd { */ +#define MMUEXT_PIN_L1_TABLE 0 +#define MMUEXT_PIN_L2_TABLE 1 +#define MMUEXT_PIN_L3_TABLE 2 +#define MMUEXT_PIN_L4_TABLE 3 +#define MMUEXT_UNPIN_TABLE 4 +#define MMUEXT_NEW_BASEPTR 5 +#define MMUEXT_TLB_FLUSH_LOCAL 6 +#define MMUEXT_INVLPG_LOCAL 7 +#define MMUEXT_TLB_FLUSH_MULTI 8 +#define MMUEXT_INVLPG_MULTI 9 +#define MMUEXT_TLB_FLUSH_ALL 10 +#define MMUEXT_INVLPG_ALL 11 +#define MMUEXT_FLUSH_CACHE 12 +#define MMUEXT_SET_LDT 13 +#define MMUEXT_NEW_USER_BASEPTR 15 +#define MMUEXT_CLEAR_PAGE 16 +#define MMUEXT_COPY_PAGE 17 +#define MMUEXT_FLUSH_CACHE_GLOBAL 18 +#define MMUEXT_MARK_SUPER 19 +#define MMUEXT_UNMARK_SUPER 20 +/* ` } */ + +#ifndef __ASSEMBLY__ +struct mmuext_op { + unsigned int cmd; /* => enum mmuext_cmd */ + union { + /* [UN]PIN_TABLE, NEW_BASEPTR, NEW_USER_BASEPTR + * CLEAR_PAGE, COPY_PAGE, [UN]MARK_SUPER */ + xen_pfn_t mfn; + /* INVLPG_LOCAL, INVLPG_ALL, SET_LDT */ + unsigned long linear_addr; + } arg1; + union { + /* SET_LDT */ + unsigned int nr_ents; + /* TLB_FLUSH_MULTI, INVLPG_MULTI */ +#if __XEN_INTERFACE_VERSION__ >= 0x00030205 + XEN_GUEST_HANDLE(const_void) vcpumask; +#else + const void *vcpumask; +#endif + /* COPY_PAGE */ + xen_pfn_t src_mfn; + } arg2; +}; +typedef struct mmuext_op mmuext_op_t; +DEFINE_XEN_GUEST_HANDLE(mmuext_op_t); +#endif + +/* + * ` enum neg_errnoval + * ` HYPERVISOR_update_va_mapping(unsigned long va, u64 val, + * ` enum uvm_flags flags) + * ` + * ` enum neg_errnoval + * ` HYPERVISOR_update_va_mapping_otherdomain(unsigned long va, u64 val, + * ` enum uvm_flags flags, + * ` domid_t domid) + * ` + * ` @va: The virtual address whose mapping we want to change + * ` @val: The new page table entry, must contain a machine address + * ` @flags: Control TLB flushes + */ +/* These are passed as 'flags' to update_va_mapping. They can be ORed. */ +/* When specifying UVMF_MULTI, also OR in a pointer to a CPU bitmap. */ +/* UVMF_LOCAL is merely UVMF_MULTI with a NULL bitmap pointer. */ +/* ` enum uvm_flags { */ +#define UVMF_NONE (0UL<<0) /* No flushing at all. */ +#define UVMF_TLB_FLUSH (1UL<<0) /* Flush entire TLB(s). */ +#define UVMF_INVLPG (2UL<<0) /* Flush only one entry. */ +#define UVMF_FLUSHTYPE_MASK (3UL<<0) +#define UVMF_MULTI (0UL<<2) /* Flush subset of TLBs. */ +#define UVMF_LOCAL (0UL<<2) /* Flush local TLB. */ +#define UVMF_ALL (1UL<<2) /* Flush all TLBs. */ +/* ` } */ + +/* + * Commands to HYPERVISOR_console_io(). + */ +#define CONSOLEIO_write 0 +#define CONSOLEIO_read 1 + +/* + * Commands to HYPERVISOR_vm_assist(). + */ +#define VMASST_CMD_enable 0 +#define VMASST_CMD_disable 1 + +/* x86/32 guests: simulate full 4GB segment limits. */ +#define VMASST_TYPE_4gb_segments 0 + +/* x86/32 guests: trap (vector 15) whenever above vmassist is used. */ +#define VMASST_TYPE_4gb_segments_notify 1 + +/* + * x86 guests: support writes to bottom-level PTEs. + * NB1. Page-directory entries cannot be written. + * NB2. Guest must continue to remove all writable mappings of PTEs. + */ +#define VMASST_TYPE_writable_pagetables 2 + +/* x86/PAE guests: support PDPTs above 4GB. */ +#define VMASST_TYPE_pae_extended_cr3 3 + +#define MAX_VMASST_TYPE 3 + +#ifndef __ASSEMBLY__ + +typedef uint16_t domid_t; + +/* Domain ids >= DOMID_FIRST_RESERVED cannot be used for ordinary domains. */ +#define DOMID_FIRST_RESERVED (0x7FF0U) + +/* DOMID_SELF is used in certain contexts to refer to oneself. */ +#define DOMID_SELF (0x7FF0U) + +/* + * DOMID_IO is used to restrict page-table updates to mapping I/O memory. + * Although no Foreign Domain need be specified to map I/O pages, DOMID_IO + * is useful to ensure that no mappings to the OS's own heap are accidentally + * installed. (e.g., in Linux this could cause havoc as reference counts + * aren't adjusted on the I/O-mapping code path). + * This only makes sense in MMUEXT_SET_FOREIGNDOM, but in that context can + * be specified by any calling domain. + */ +#define DOMID_IO (0x7FF1U) + +/* + * DOMID_XEN is used to allow privileged domains to map restricted parts of + * Xen's heap space (e.g., the machine_to_phys table). + * This only makes sense in MMUEXT_SET_FOREIGNDOM, and is only permitted if + * the caller is privileged. + */ +#define DOMID_XEN (0x7FF2U) + +/* + * DOMID_COW is used as the owner of sharable pages */ +#define DOMID_COW (0x7FF3U) + +/* DOMID_INVALID is used to identify pages with unknown owner. */ +#define DOMID_INVALID (0x7FF4U) + +/* Idle domain. */ +#define DOMID_IDLE (0x7FFFU) + +/* + * Send an array of these to HYPERVISOR_mmu_update(). + * NB. The fields are natural pointer/address size for this architecture. + */ +struct mmu_update { + uint64_t ptr; /* Machine address of PTE. */ + uint64_t val; /* New contents of PTE. */ +}; +typedef struct mmu_update mmu_update_t; +DEFINE_XEN_GUEST_HANDLE(mmu_update_t); + +/* + * ` enum neg_errnoval + * ` HYPERVISOR_multicall(multicall_entry_t call_list[], + * ` uint32_t nr_calls); + * + * NB. The fields are logically the natural register size for this + * architecture. In cases where xen_ulong_t is larger than this then + * any unused bits in the upper portion must be zero. + */ +struct multicall_entry { + xen_ulong_t op, result; + xen_ulong_t args[6]; +}; +typedef struct multicall_entry multicall_entry_t; +DEFINE_XEN_GUEST_HANDLE(multicall_entry_t); + +#if __XEN_INTERFACE_VERSION__ < 0x00040400 +/* + * Event channel endpoints per domain (when using the 2-level ABI): + * 1024 if a long is 32 bits; 4096 if a long is 64 bits. + */ +#define NR_EVENT_CHANNELS EVTCHN_2L_NR_CHANNELS +#endif + +struct vcpu_time_info { + /* + * Updates to the following values are preceded and followed by an + * increment of 'version'. The guest can therefore detect updates by + * looking for changes to 'version'. If the least-significant bit of + * the version number is set then an update is in progress and the guest + * must wait to read a consistent set of values. + * The correct way to interact with the version number is similar to + * Linux's seqlock: see the implementations of read_seqbegin/read_seqretry. + */ + uint32_t version; + uint32_t pad0; + uint64_t tsc_timestamp; /* TSC at last update of time vals. */ + uint64_t system_time; /* Time, in nanosecs, since boot. */ + /* + * Current system time: + * system_time + + * ((((tsc - tsc_timestamp) << tsc_shift) * tsc_to_system_mul) >> 32) + * CPU frequency (Hz): + * ((10^9 << 32) / tsc_to_system_mul) >> tsc_shift + */ + uint32_t tsc_to_system_mul; + int8_t tsc_shift; + int8_t pad1[3]; +}; /* 32 bytes */ +typedef struct vcpu_time_info vcpu_time_info_t; + +struct vcpu_info { + /* + * 'evtchn_upcall_pending' is written non-zero by Xen to indicate + * a pending notification for a particular VCPU. It is then cleared + * by the guest OS /before/ checking for pending work, thus avoiding + * a set-and-check race. Note that the mask is only accessed by Xen + * on the CPU that is currently hosting the VCPU. This means that the + * pending and mask flags can be updated by the guest without special + * synchronisation (i.e., no need for the x86 LOCK prefix). + * This may seem suboptimal because if the pending flag is set by + * a different CPU then an IPI may be scheduled even when the mask + * is set. However, note: + * 1. The task of 'interrupt holdoff' is covered by the per-event- + * channel mask bits. A 'noisy' event that is continually being + * triggered can be masked at source at this very precise + * granularity. + * 2. The main purpose of the per-VCPU mask is therefore to restrict + * reentrant execution: whether for concurrency control, or to + * prevent unbounded stack usage. Whatever the purpose, we expect + * that the mask will be asserted only for short periods at a time, + * and so the likelihood of a 'spurious' IPI is suitably small. + * The mask is read before making an event upcall to the guest: a + * non-zero mask therefore guarantees that the VCPU will not receive + * an upcall activation. The mask is cleared when the VCPU requests + * to block: this avoids wakeup-waiting races. + */ + uint8_t evtchn_upcall_pending; +#ifdef XEN_HAVE_PV_UPCALL_MASK + uint8_t evtchn_upcall_mask; +#else /* XEN_HAVE_PV_UPCALL_MASK */ + uint8_t pad0; +#endif /* XEN_HAVE_PV_UPCALL_MASK */ + xen_ulong_t evtchn_pending_sel; + struct arch_vcpu_info arch; + struct vcpu_time_info time; +}; /* 64 bytes (x86) */ +#ifndef __XEN__ +typedef struct vcpu_info vcpu_info_t; +#endif + +/* + * `incontents 200 startofday_shared Start-of-day shared data structure + * Xen/kernel shared data -- pointer provided in start_info. + * + * This structure is defined to be both smaller than a page, and the + * only data on the shared page, but may vary in actual size even within + * compatible Xen versions; guests should not rely on the size + * of this structure remaining constant. + */ +struct shared_info { + struct vcpu_info vcpu_info[XEN_LEGACY_MAX_VCPUS]; + + /* + * A domain can create "event channels" on which it can send and receive + * asynchronous event notifications. There are three classes of event that + * are delivered by this mechanism: + * 1. Bi-directional inter- and intra-domain connections. Domains must + * arrange out-of-band to set up a connection (usually by allocating + * an unbound 'listener' port and avertising that via a storage service + * such as xenstore). + * 2. Physical interrupts. A domain with suitable hardware-access + * privileges can bind an event-channel port to a physical interrupt + * source. + * 3. Virtual interrupts ('events'). A domain can bind an event-channel + * port to a virtual interrupt source, such as the virtual-timer + * device or the emergency console. + * + * Event channels are addressed by a "port index". Each channel is + * associated with two bits of information: + * 1. PENDING -- notifies the domain that there is a pending notification + * to be processed. This bit is cleared by the guest. + * 2. MASK -- if this bit is clear then a 0->1 transition of PENDING + * will cause an asynchronous upcall to be scheduled. This bit is only + * updated by the guest. It is read-only within Xen. If a channel + * becomes pending while the channel is masked then the 'edge' is lost + * (i.e., when the channel is unmasked, the guest must manually handle + * pending notifications as no upcall will be scheduled by Xen). + * + * To expedite scanning of pending notifications, any 0->1 pending + * transition on an unmasked channel causes a corresponding bit in a + * per-vcpu selector word to be set. Each bit in the selector covers a + * 'C long' in the PENDING bitfield array. + */ + xen_ulong_t evtchn_pending[sizeof(xen_ulong_t) * 8]; + xen_ulong_t evtchn_mask[sizeof(xen_ulong_t) * 8]; + + /* + * Wallclock time: updated only by control software. Guests should base + * their gettimeofday() syscall on this wallclock-base value. + */ + uint32_t wc_version; /* Version counter: see vcpu_time_info_t. */ + uint32_t wc_sec; /* Secs 00:00:00 UTC, Jan 1, 1970. */ + uint32_t wc_nsec; /* Nsecs 00:00:00 UTC, Jan 1, 1970. */ + + struct arch_shared_info arch; + +}; +#ifndef __XEN__ +typedef struct shared_info shared_info_t; +#endif + +/* + * `incontents 200 startofday Start-of-day memory layout + * + * 1. The domain is started within contiguous virtual-memory region. + * 2. The contiguous region ends on an aligned 4MB boundary. + * 3. This the order of bootstrap elements in the initial virtual region: + * a. relocated kernel image + * b. initial ram disk [mod_start, mod_len] + * c. list of allocated page frames [mfn_list, nr_pages] + * (unless relocated due to XEN_ELFNOTE_INIT_P2M) + * d. start_info_t structure [register ESI (x86)] + * e. bootstrap page tables [pt_base and CR3 (x86)] + * f. bootstrap stack [register ESP (x86)] + * 4. Bootstrap elements are packed together, but each is 4kB-aligned. + * 5. The initial ram disk may be omitted. + * 6. The list of page frames forms a contiguous 'pseudo-physical' memory + * layout for the domain. In particular, the bootstrap virtual-memory + * region is a 1:1 mapping to the first section of the pseudo-physical map. + * 7. All bootstrap elements are mapped read-writable for the guest OS. The + * only exception is the bootstrap page table, which is mapped read-only. + * 8. There is guaranteed to be at least 512kB padding after the final + * bootstrap element. If necessary, the bootstrap virtual region is + * extended by an extra 4MB to ensure this. + * + * Note: Prior to 25833:bb85bbccb1c9. ("x86/32-on-64 adjust Dom0 initial page + * table layout") a bug caused the pt_base (3.e above) and cr3 to not point + * to the start of the guest page tables (it was offset by two pages). + * This only manifested itself on 32-on-64 dom0 kernels and not 32-on-64 domU + * or 64-bit kernels of any colour. The page tables for a 32-on-64 dom0 got + * allocated in the order: 'first L1','first L2', 'first L3', so the offset + * to the page table base is by two pages back. The initial domain if it is + * 32-bit and runs under a 64-bit hypervisor should _NOT_ use two of the + * pages preceding pt_base and mark them as reserved/unused. + */ +#ifdef XEN_HAVE_PV_GUEST_ENTRY +struct start_info { + /* THE FOLLOWING ARE FILLED IN BOTH ON INITIAL BOOT AND ON RESUME. */ + char magic[32]; /* "xen--". */ + unsigned long nr_pages; /* Total pages allocated to this domain. */ + unsigned long shared_info; /* MACHINE address of shared info struct. */ + uint32_t flags; /* SIF_xxx flags. */ + xen_pfn_t store_mfn; /* MACHINE page number of shared page. */ + uint32_t store_evtchn; /* Event channel for store communication. */ + union { + struct { + xen_pfn_t mfn; /* MACHINE page number of console page. */ + uint32_t evtchn; /* Event channel for console page. */ + } domU; + struct { + uint32_t info_off; /* Offset of console_info struct. */ + uint32_t info_size; /* Size of console_info struct from start.*/ + } dom0; + } console; + /* THE FOLLOWING ARE ONLY FILLED IN ON INITIAL BOOT (NOT RESUME). */ + unsigned long pt_base; /* VIRTUAL address of page directory. */ + unsigned long nr_pt_frames; /* Number of bootstrap p.t. frames. */ + unsigned long mfn_list; /* VIRTUAL address of page-frame list. */ + unsigned long mod_start; /* VIRTUAL address of pre-loaded module */ + /* (PFN of pre-loaded module if */ + /* SIF_MOD_START_PFN set in flags). */ + unsigned long mod_len; /* Size (bytes) of pre-loaded module. */ +#define MAX_GUEST_CMDLINE 1024 + int8_t cmd_line[MAX_GUEST_CMDLINE]; + /* The pfn range here covers both page table and p->m table frames. */ + unsigned long first_p2m_pfn;/* 1st pfn forming initial P->M table. */ + unsigned long nr_p2m_frames;/* # of pfns forming initial P->M table. */ +}; +typedef struct start_info start_info_t; + +/* New console union for dom0 introduced in 0x00030203. */ +#if __XEN_INTERFACE_VERSION__ < 0x00030203 +#define console_mfn console.domU.mfn +#define console_evtchn console.domU.evtchn +#endif +#endif /* XEN_HAVE_PV_GUEST_ENTRY */ + +/* These flags are passed in the 'flags' field of start_info_t. */ +#define SIF_PRIVILEGED (1<<0) /* Is the domain privileged? */ +#define SIF_INITDOMAIN (1<<1) /* Is this the initial control domain? */ +#define SIF_MULTIBOOT_MOD (1<<2) /* Is mod_start a multiboot module? */ +#define SIF_MOD_START_PFN (1<<3) /* Is mod_start a PFN? */ +#define SIF_PM_MASK (0xFF<<8) /* reserve 1 byte for xen-pm options */ + +/* + * A multiboot module is a package containing modules very similar to a + * multiboot module array. The only differences are: + * - the array of module descriptors is by convention simply at the beginning + * of the multiboot module, + * - addresses in the module descriptors are based on the beginning of the + * multiboot module, + * - the number of modules is determined by a termination descriptor that has + * mod_start == 0. + * + * This permits to both build it statically and reference it in a configuration + * file, and let the PV guest easily rebase the addresses to virtual addresses + * and at the same time count the number of modules. + */ +struct xen_multiboot_mod_list +{ + /* Address of first byte of the module */ + uint32_t mod_start; + /* Address of last byte of the module (inclusive) */ + uint32_t mod_end; + /* Address of zero-terminated command line */ + uint32_t cmdline; + /* Unused, must be zero */ + uint32_t pad; +}; +/* + * `incontents 200 startofday_dom0_console Dom0_console + * + * The console structure in start_info.console.dom0 + * + * This structure includes a variety of information required to + * have a working VGA/VESA console. + */ +typedef struct dom0_vga_console_info { + uint8_t video_type; /* DOM0_VGA_CONSOLE_??? */ +#define XEN_VGATYPE_TEXT_MODE_3 0x03 +#define XEN_VGATYPE_VESA_LFB 0x23 +#define XEN_VGATYPE_EFI_LFB 0x70 + + union { + struct { + /* Font height, in pixels. */ + uint16_t font_height; + /* Cursor location (column, row). */ + uint16_t cursor_x, cursor_y; + /* Number of rows and columns (dimensions in characters). */ + uint16_t rows, columns; + } text_mode_3; + + struct { + /* Width and height, in pixels. */ + uint16_t width, height; + /* Bytes per scan line. */ + uint16_t bytes_per_line; + /* Bits per pixel. */ + uint16_t bits_per_pixel; + /* LFB physical address, and size (in units of 64kB). */ + uint32_t lfb_base; + uint32_t lfb_size; + /* RGB mask offsets and sizes, as defined by VBE 1.2+ */ + uint8_t red_pos, red_size; + uint8_t green_pos, green_size; + uint8_t blue_pos, blue_size; + uint8_t rsvd_pos, rsvd_size; +#if __XEN_INTERFACE_VERSION__ >= 0x00030206 + /* VESA capabilities (offset 0xa, VESA command 0x4f00). */ + uint32_t gbl_caps; + /* Mode attributes (offset 0x0, VESA command 0x4f01). */ + uint16_t mode_attrs; +#endif + } vesa_lfb; + } u; +} dom0_vga_console_info_t; +#define xen_vga_console_info dom0_vga_console_info +#define xen_vga_console_info_t dom0_vga_console_info_t + +typedef uint8_t xen_domain_handle_t[16]; + +/* Turn a plain number into a C unsigned long constant. */ +#define __mk_unsigned_long(x) x ## UL +#define mk_unsigned_long(x) __mk_unsigned_long(x) + +__DEFINE_XEN_GUEST_HANDLE(uint8, uint8_t); +__DEFINE_XEN_GUEST_HANDLE(uint16, uint16_t); +__DEFINE_XEN_GUEST_HANDLE(uint32, uint32_t); +__DEFINE_XEN_GUEST_HANDLE(uint64, uint64_t); + +#else /* __ASSEMBLY__ */ + +/* In assembly code we cannot use C numeric constant suffixes. */ +#define mk_unsigned_long(x) x + +#endif /* !__ASSEMBLY__ */ + +/* Default definitions for macros used by domctl/sysctl. */ +#if defined(__XEN__) || defined(__XEN_TOOLS__) + +#ifndef uint64_aligned_t +#define uint64_aligned_t uint64_t +#endif +#ifndef XEN_GUEST_HANDLE_64 +#define XEN_GUEST_HANDLE_64(name) XEN_GUEST_HANDLE(name) +#endif + +#ifndef __ASSEMBLY__ +struct xenctl_bitmap { + XEN_GUEST_HANDLE_64(uint8) bitmap; + uint32_t nr_bits; +}; +#endif + +#endif /* defined(__XEN__) || defined(__XEN_TOOLS__) */ + +#endif /* __XEN_PUBLIC_XEN_H__ */ + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * tab-width: 4 + * indent-tabs-mode: nil + * End: + */ From b2fc9acdc9674de2b930ee92229917881843ba92 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sun, 8 Nov 2015 21:24:18 +0100 Subject: [PATCH 537/722] Adapt build-system to use imported xen headers. --- conf/Makefile.common | 3 --- grub-core/Makefile.core.def | 9 --------- include/grub/xen.h | 7 ++++++- 3 files changed, 6 insertions(+), 13 deletions(-) diff --git a/conf/Makefile.common b/conf/Makefile.common index fcb8d2e1c..5083d5f1e 100644 --- a/conf/Makefile.common +++ b/conf/Makefile.common @@ -21,9 +21,6 @@ if COND_powerpc_ieee1275 CFLAGS_PLATFORM += -mcpu=powerpc endif -#FIXME: discover and check XEN headers -CPPFLAGS_XEN = -I/usr/include - # Other options CPPFLAGS_DEFAULT = -DGRUB_FILE=\"$(subst $(srcdir)/,,$<)\" diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def index 03e04ab39..d9fa0e339 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def @@ -59,9 +59,6 @@ kernel = { ia64_efi_ldflags = '-Wl,-r,-d'; ia64_efi_stripflags = '--strip-unneeded -K start -R .note -R .comment -R .note.gnu.gold-version'; - x86_64_xen_cppflags = '$(CPPFLAGS_XEN)'; - i386_xen_cppflags = '$(CPPFLAGS_XEN)'; - arm_efi_ldflags = '-Wl,-r,-d'; arm_efi_stripflags = '--strip-unneeded -K start -R .note -R .comment -R .note.gnu.gold-version'; @@ -604,7 +601,6 @@ module = { module = { name = lsxen; common = commands/xen/lsxen.c; - cppflags = '$(CPPFLAGS_XEN)'; enable = xen; }; @@ -825,7 +821,6 @@ module = { i386_coreboot = lib/i386/halt.c; i386_qemu = lib/i386/halt.c; xen = lib/xen/halt.c; - xen_cppflags = '$(CPPFLAGS_XEN)'; efi = lib/efi/halt.c; ieee1275 = lib/ieee1275/halt.c; emu = lib/emu/halt.c; @@ -846,7 +841,6 @@ module = { mips_loongson = lib/mips/loongson/reboot.c; mips_qemu_mips = lib/mips/qemu_mips/reboot.c; xen = lib/xen/reboot.c; - xen_cppflags = '$(CPPFLAGS_XEN)'; uboot = lib/uboot/reboot.c; common = commands/reboot.c; }; @@ -1526,7 +1520,6 @@ module = { i386_xen = lib/i386/xen/relocator.S; x86_64_xen = lib/x86_64/xen/relocator.S; xen = lib/i386/relocator_common_c.c; - xen_cppflags = '$(CPPFLAGS_XEN)'; extra_dist = lib/i386/relocator_common.S; extra_dist = kern/powerpc/cache_flush.S; @@ -1547,7 +1540,6 @@ module = { sparc64_ieee1275 = lib/ieee1275/cmos.c; powerpc_ieee1275 = lib/ieee1275/cmos.c; xen = lib/xen/datetime.c; - xen_cppflags = '$(CPPFLAGS_XEN)'; mips_arc = lib/arc/datetime.c; enable = noemu; @@ -1657,7 +1649,6 @@ module = { name = linux; x86 = loader/i386/linux.c; xen = loader/i386/xen.c; - xen_cppflags = '$(CPPFLAGS_XEN)'; i386_pc = lib/i386/pc/vesa_modes_table.c; mips = loader/mips/linux.c; powerpc_ieee1275 = loader/powerpc/ieee1275/linux.c; diff --git a/include/grub/xen.h b/include/grub/xen.h index 9ba3b8e6b..c31cc10c7 100644 --- a/include/grub/xen.h +++ b/include/grub/xen.h @@ -33,7 +33,12 @@ #include #ifndef GRUB_SYMBOL_GENERATOR -#include +typedef grub_int8_t int8_t; +typedef grub_int16_t int16_t; +typedef grub_uint8_t uint8_t; +typedef grub_uint16_t uint16_t; +typedef grub_uint32_t uint32_t; +typedef grub_uint64_t uint64_t; #include #include From 4656ced41c8fa61d462b92d28878d9cdb8493120 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sun, 8 Nov 2015 22:39:36 +0100 Subject: [PATCH 538/722] fstester: Enforce LC_ALL=C --- tests/util/grub-fs-tester.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/util/grub-fs-tester.in b/tests/util/grub-fs-tester.in index 29ae69153..424de2267 100644 --- a/tests/util/grub-fs-tester.in +++ b/tests/util/grub-fs-tester.in @@ -10,7 +10,7 @@ tempdir=`mktemp -d "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"` || exit 1 # This wrapper is to ease insertion of valgrind or time statistics run_it () { - "$GRUBFSTEST" "$@" + LC_ALL=C "$GRUBFSTEST" "$@" } run_grubfstest () { From cb28250cfce1da059d94b57eee54cb250bb786fe Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 9 Nov 2015 03:24:04 +0100 Subject: [PATCH 539/722] cbfs: Fix corner case and compilation with recdent gcc Accept the header to touch the jump address at 0xfffffff0. Fix compilation for 64-bit EFI with recent GCC. --- grub-core/fs/cbfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/fs/cbfs.c b/grub-core/fs/cbfs.c index 5fc9c0147..0842701a6 100644 --- a/grub-core/fs/cbfs.c +++ b/grub-core/fs/cbfs.c @@ -352,7 +352,7 @@ init_cbfsdisk (void) reading ROMs through controller directly. */ if (ptr < 0xff000000 - || 0xffffffff - ptr < sizeof (*head) + 0x10 + || 0xffffffff - ptr < (grub_uint32_t) sizeof (*head) + 0xf || !validate_head (head)) return; From 254f92815b6e4a862ce6d91afe542f0abefd27e7 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 9 Nov 2015 11:39:30 +0100 Subject: [PATCH 540/722] kern/elf: Ignore cast-align warnings --- grub-core/kern/elf.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/grub-core/kern/elf.c b/grub-core/kern/elf.c index 00de36984..4f282c9cf 100644 --- a/grub-core/kern/elf.c +++ b/grub-core/kern/elf.c @@ -28,6 +28,8 @@ GRUB_MOD_LICENSE ("GPLv3+"); +#pragma GCC diagnostic ignored "-Wcast-align" + #if defined(__powerpc__) && defined(GRUB_MACHINE_IEEE1275) #define GRUB_ELF_ENABLE_BI_ENDIAN 1 #else From 372400b4199228c9db15b914c1614fa3ec869722 Mon Sep 17 00:00:00 2001 From: Fu Wei Date: Mon, 9 Nov 2015 15:27:59 +0100 Subject: [PATCH 541/722] fdt.mod: Add missing license tag. --- grub-core/loader/arm64/fdt.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/grub-core/loader/arm64/fdt.c b/grub-core/loader/arm64/fdt.c index 5202c14e0..901bd7b68 100644 --- a/grub-core/loader/arm64/fdt.c +++ b/grub-core/loader/arm64/fdt.c @@ -25,6 +25,8 @@ #include #include +GRUB_MOD_LICENSE ("GPLv3+"); + static void *loaded_fdt; static void *fdt; From 25a9b8f208653ee288c74d2cdccfc33446a0d30f Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 9 Nov 2015 16:15:30 +0100 Subject: [PATCH 542/722] fdt.mod: Move license tag to the right file. --- grub-core/lib/fdt.c | 3 +++ grub-core/loader/arm64/fdt.c | 2 -- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/grub-core/lib/fdt.c b/grub-core/lib/fdt.c index 7e76dc06b..b5d520f20 100644 --- a/grub-core/lib/fdt.c +++ b/grub-core/lib/fdt.c @@ -19,6 +19,9 @@ #include #include #include +#include + +GRUB_MOD_LICENSE ("GPLv3+"); #define FDT_SUPPORTED_VERSION 17 diff --git a/grub-core/loader/arm64/fdt.c b/grub-core/loader/arm64/fdt.c index 901bd7b68..5202c14e0 100644 --- a/grub-core/loader/arm64/fdt.c +++ b/grub-core/loader/arm64/fdt.c @@ -25,8 +25,6 @@ #include #include -GRUB_MOD_LICENSE ("GPLv3+"); - static void *loaded_fdt; static void *fdt; From a50dbb743e53e5e643f27daa84261e6e9d7747c1 Mon Sep 17 00:00:00 2001 From: Paulo Flabiano Smorigo Date: Tue, 10 Nov 2015 21:20:20 -0200 Subject: [PATCH 543/722] ofdisk: add a comment about vscsi method --- grub-core/disk/ieee1275/ofdisk.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/grub-core/disk/ieee1275/ofdisk.c b/grub-core/disk/ieee1275/ofdisk.c index 297f058ee..0efe59a66 100644 --- a/grub-core/disk/ieee1275/ofdisk.c +++ b/grub-core/disk/ieee1275/ofdisk.c @@ -227,7 +227,10 @@ dev_iterate (const struct grub_ieee1275_devalias *alias) if (grub_ieee1275_open (alias->path, &ihandle)) return; - + + /* This method doesn't need memory allocation for the table. Open + firmware takes care of all memory management and the result table + stays in memory and is never freed. */ INIT_IEEE1275_COMMON (&args.common, "call-method", 2, 3); args.method = (grub_ieee1275_cell_t) "vscsi-report-luns"; args.ihandle = ihandle; From 323ef2bdc358b90f0894223a6424df036c6dfe02 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Wed, 11 Nov 2015 18:58:57 +0100 Subject: [PATCH 544/722] asm-tests/i386-pc: Check that near jumps are 2 bytes. We already check that jump over 300 bytes gap is 3 bytes in code16-mode. Some clang versions generate 3-byte opcode for short jumps which makes boot.img blow over 512-byte limit. Enforce -no-integrated-as in such cases --- asm-tests/i386-pc.S | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/asm-tests/i386-pc.S b/asm-tests/i386-pc.S index 97cd32ae8..f6f9a88be 100644 --- a/asm-tests/i386-pc.S +++ b/asm-tests/i386-pc.S @@ -5,6 +5,10 @@ .code16 jmp far .org 4 - .space 300 + jmp nearer + .org 6 + .space 100 +nearer: + .space 200 far: .byte 0 From fb94736fe87353de1b99fe6c88887171559eca50 Mon Sep 17 00:00:00 2001 From: Fu Wei Date: Thu, 12 Nov 2015 11:32:01 +0100 Subject: [PATCH 545/722] Document ARM64 xen commands --- docs/grub.texi | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/docs/grub.texi b/docs/grub.texi index db765a3b5..1df3db260 100644 --- a/docs/grub.texi +++ b/docs/grub.texi @@ -3857,6 +3857,11 @@ you forget a command, you can run the command @command{help} @comment * vbeinfo:: List available video modes * verify_detached:: Verify detached digital signature * videoinfo:: List available video modes +@comment * xen_*:: Xen boot commands +* xen_hypervisor:: Load xen hypervisor binary +* xen_linux:: Load dom0 kernel for xen hypervisor +* xen_initrd:: Load dom0 initrd for dom0 kernel +* xen_xsm:: Load xen security module for xen hypervisor @end menu @@ -5120,6 +5125,39 @@ successfully. If validation fails, it is set to a non-zero value. List available video modes. If resolution is given, show only matching modes. @end deffn +@node xen_hypervisor +@subsection xen_hypervisor + +@deffn Command xen_hypervisor file [arguments] @dots{} +Load a Xen hypervisor binary from @var{file}. The rest of the line is passed +verbatim as the @dfn{kernel command-line}. Any other binaries must be +reloaded after using this command. +@end deffn + +@node xen_linux +@subsection xen_linux + +@deffn Command xen_linux file [arguments] +Load a dom0 kernel image for xen hypervisor at the booting process of xen. +The rest of the line is passed verbatim as the module command line. +@end deffn + +@node xen_initrd +@subsection xen_initrd + +@deffn Command xen_initrd file +Load a initrd image for dom0 kernel at the booting process of xen. +@end deffn + +@node xen_xsm +@subsection xen_xsm + +@deffn Command xen_xsm file +Load a xen security module for xen hypervisor at the booting process of xen. +See @uref{http://wiki.xen.org/wiki/XSM} for more detail. +@end deffn + + @node Networking commands @section The list of networking commands From a771a7b9f61653dbcff684e8ab62bc8e0daf5844 Mon Sep 17 00:00:00 2001 From: Fu Wei Date: Thu, 12 Nov 2015 11:33:55 +0100 Subject: [PATCH 546/722] xen_boot: Remove useless file_name_index variable. --- grub-core/loader/arm64/xen_boot.c | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/grub-core/loader/arm64/xen_boot.c b/grub-core/loader/arm64/xen_boot.c index fc5bb0c86..d1a218929 100644 --- a/grub-core/loader/arm64/xen_boot.c +++ b/grub-core/loader/arm64/xen_boot.c @@ -136,16 +136,10 @@ xen_boot_address_align (grub_addr_t start, grub_size_t align) return (align ? (ALIGN_UP (start, align)) : start); } -/* Parse the option of xen_module command. For now, we support - (1) --type - We also set up the type of module in this function. - If there are some "--type" options in the command line, - we make a custom compatible stream in this function. */ +/* set module type according to command name. */ static grub_err_t -set_module_type (grub_command_t cmd, struct xen_boot_binary *module, int *file_name_index) +set_module_type (grub_command_t cmd, struct xen_boot_binary *module) { - *file_name_index = 0; - if (!grub_strcmp (cmd->name, "xen_linux")) module->node_info.type = MODULE_IMAGE; else if (!grub_strcmp (cmd->name, "xen_initrd")) @@ -440,7 +434,6 @@ grub_cmd_xen_module (grub_command_t cmd, int argc, char *argv[]) { struct xen_boot_binary *module = NULL; - int file_name_index = 0; grub_file_t file = 0; if (!argc) @@ -462,8 +455,7 @@ grub_cmd_xen_module (grub_command_t cmd, int argc, char *argv[]) return grub_errno; /* process all the options and get module type */ - if (set_module_type (cmd, module, &file_name_index) != - GRUB_ERR_NONE) + if (set_module_type (cmd, module) != GRUB_ERR_NONE) goto fail; switch (module->node_info.type) { @@ -491,12 +483,11 @@ grub_cmd_xen_module (grub_command_t cmd, int argc, char *argv[]) module->name, module->node_info.compat_string, module->node_info.compat_string_size); - file = grub_file_open (argv[file_name_index]); + file = grub_file_open (argv[0]); if (!file) goto fail; - xen_boot_binary_load (module, file, argc - file_name_index, - argv + file_name_index); + xen_boot_binary_load (module, file, argc, argv); if (grub_errno == GRUB_ERR_NONE) grub_list_push (GRUB_AS_LIST_P (&module_head), GRUB_AS_LIST (module)); From 95ba04606f940d17b51c74175ae874b192c44b9f Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Thu, 12 Nov 2015 11:54:13 +0100 Subject: [PATCH 547/722] multiboot_mbi: Fix handling of --quirk-bad-kludge. --- grub-core/loader/i386/multiboot_mbi.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/grub-core/loader/i386/multiboot_mbi.c b/grub-core/loader/i386/multiboot_mbi.c index 956d0e37b..f60b70234 100644 --- a/grub-core/loader/i386/multiboot_mbi.c +++ b/grub-core/loader/i386/multiboot_mbi.c @@ -73,6 +73,9 @@ load_kernel (grub_file_t file, const char *filename, if (grub_multiboot_quirks & GRUB_MULTIBOOT_QUIRK_BAD_KLUDGE) { err = grub_multiboot_load_elf (file, filename, buffer); + if (err == GRUB_ERR_NONE) { + return GRUB_ERR_NONE; + } if (err == GRUB_ERR_UNKNOWN_OS && (header->flags & MULTIBOOT_AOUT_KLUDGE)) grub_errno = err = GRUB_ERR_NONE; } From e0bd66c3141f61749c599a190ecae17903a1d7ec Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Thu, 12 Nov 2015 11:54:38 +0100 Subject: [PATCH 548/722] multiboot: Don't rely on particular ordering of options. --- grub-core/loader/multiboot.c | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/grub-core/loader/multiboot.c b/grub-core/loader/multiboot.c index fd8f28e21..73aa0aa12 100644 --- a/grub-core/loader/multiboot.c +++ b/grub-core/loader/multiboot.c @@ -240,20 +240,27 @@ grub_cmd_multiboot (grub_command_t cmd __attribute__ ((unused)), #ifndef GRUB_USE_MULTIBOOT2 grub_multiboot_quirks = GRUB_MULTIBOOT_QUIRKS_NONE; + int option_found = 0; - if (argc != 0 && grub_strcmp (argv[0], "--quirk-bad-kludge") == 0) + do { - argc--; - argv++; - grub_multiboot_quirks |= GRUB_MULTIBOOT_QUIRK_BAD_KLUDGE; - } + option_found = 0; + if (argc != 0 && grub_strcmp (argv[0], "--quirk-bad-kludge") == 0) + { + argc--; + argv++; + option_found = 1; + grub_multiboot_quirks |= GRUB_MULTIBOOT_QUIRK_BAD_KLUDGE; + } - if (argc != 0 && grub_strcmp (argv[0], "--quirk-modules-after-kernel") == 0) - { - argc--; - argv++; - grub_multiboot_quirks |= GRUB_MULTIBOOT_QUIRK_MODULES_AFTER_KERNEL; - } + if (argc != 0 && grub_strcmp (argv[0], "--quirk-modules-after-kernel") == 0) + { + argc--; + argv++; + option_found = 1; + grub_multiboot_quirks |= GRUB_MULTIBOOT_QUIRK_MODULES_AFTER_KERNEL; + } + } while (option_found); #endif if (argc == 0) From c899d9f42c543939abc92d79c9729d429740492e Mon Sep 17 00:00:00 2001 From: Paulo Flabiano Smorigo Date: Sun, 8 Nov 2015 21:52:22 -0200 Subject: [PATCH 549/722] ofdisk: add sas disks to the device list --- grub-core/disk/ieee1275/ofdisk.c | 76 ++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) diff --git a/grub-core/disk/ieee1275/ofdisk.c b/grub-core/disk/ieee1275/ofdisk.c index 0efe59a66..235c0fe2c 100644 --- a/grub-core/disk/ieee1275/ofdisk.c +++ b/grub-core/disk/ieee1275/ofdisk.c @@ -263,6 +263,82 @@ dev_iterate (const struct grub_ieee1275_devalias *alias) grub_free (buf); return; } + else if (grub_strcmp (alias->type, "sas_ioa") == 0) + { + /* The method returns the number of disks and a table where + * each ID is 64-bit long. Example of sas paths: + * /pci@80000002000001f/pci1014,034A@0/sas/disk@c05db70800 + * /pci@80000002000001f/pci1014,034A@0/sas/disk@a05db70800 + * /pci@80000002000001f/pci1014,034A@0/sas/disk@805db70800 */ + + struct sas_children + { + struct grub_ieee1275_common_hdr common; + grub_ieee1275_cell_t method; + grub_ieee1275_cell_t ihandle; + grub_ieee1275_cell_t max; + grub_ieee1275_cell_t table; + grub_ieee1275_cell_t catch_result; + grub_ieee1275_cell_t nentries; + } + args; + char *buf, *bufptr; + unsigned i; + grub_uint64_t *table; + grub_uint16_t table_size; + grub_ieee1275_ihandle_t ihandle; + + buf = grub_malloc (grub_strlen (alias->path) + + sizeof ("/disk@7766554433221100")); + if (!buf) + return; + bufptr = grub_stpcpy (buf, alias->path); + + /* Power machines documentation specify 672 as maximum SAS disks in + one system. Using a slightly larger value to be safe. */ + table_size = 768; + table = grub_malloc (table_size * sizeof (grub_uint64_t)); + + if (!table) + { + grub_free (buf); + return; + } + + if (grub_ieee1275_open (alias->path, &ihandle)) + { + grub_free (buf); + grub_free (table); + return; + } + + INIT_IEEE1275_COMMON (&args.common, "call-method", 4, 2); + args.method = (grub_ieee1275_cell_t) "get-sas-children"; + args.ihandle = ihandle; + args.max = table_size; + args.table = (grub_ieee1275_cell_t) table; + args.catch_result = 0; + args.nentries = 0; + + if (IEEE1275_CALL_ENTRY_FN (&args) == -1) + { + grub_ieee1275_close (ihandle); + grub_free (table); + grub_free (buf); + return; + } + + for (i = 0; i < args.nentries; i++) + { + grub_snprintf (bufptr, sizeof ("/disk@7766554433221100"), + "/disk@%" PRIxGRUB_UINT64_T, table[i]); + dev_iterate_real (buf, buf); + } + + grub_ieee1275_close (ihandle); + grub_free (table); + grub_free (buf); + } if (!grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_NO_TREE_SCANNING_FOR_DISKS) && grub_strcmp (alias->type, "block") == 0) From 5646e03dbaa63f38488cc76b642458ff696ee687 Mon Sep 17 00:00:00 2001 From: Konstantin Vlasov Date: Fri, 13 Nov 2015 21:54:19 +0300 Subject: [PATCH 550/722] gfxterm: fix calculation of terminal-top and terminal-height They used screen width, not height. --- grub-core/gfxmenu/theme_loader.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/grub-core/gfxmenu/theme_loader.c b/grub-core/gfxmenu/theme_loader.c index 1a6ed1d25..02978392c 100644 --- a/grub-core/gfxmenu/theme_loader.c +++ b/grub-core/gfxmenu/theme_loader.c @@ -255,7 +255,7 @@ theme_set_string (grub_gfxmenu_view_t view, { unsigned int tmp; int err = theme_get_unsigned_int_from_proportional (value, - view->screen.width, + view->screen.height, &tmp); if (err != GRUB_ERR_NONE) return err; @@ -275,7 +275,7 @@ theme_set_string (grub_gfxmenu_view_t view, { unsigned int tmp; int err = theme_get_unsigned_int_from_proportional (value, - view->screen.width, + view->screen.height, &tmp); if (err != GRUB_ERR_NONE) return err; From 7994077ab9da775a11df8a79aa766c400ac8ef28 Mon Sep 17 00:00:00 2001 From: Pavel Bludov Date: Wed, 11 Nov 2015 15:21:52 +0800 Subject: [PATCH 551/722] Add some UUIDs found in the hardware --- grub-core/commands/efi/lsefisystab.c | 14 +++++++-- include/grub/efi/api.h | 45 ++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+), 2 deletions(-) diff --git a/grub-core/commands/efi/lsefisystab.c b/grub-core/commands/efi/lsefisystab.c index 8717db91e..c84cea613 100644 --- a/grub-core/commands/efi/lsefisystab.c +++ b/grub-core/commands/efi/lsefisystab.c @@ -37,10 +37,20 @@ static const struct guid_mapping guid_mappings[] = { { GRUB_EFI_ACPI_20_TABLE_GUID, "ACPI-2.0"}, { GRUB_EFI_ACPI_TABLE_GUID, "ACPI-1.0"}, + { GRUB_EFI_CRC32_GUIDED_SECTION_EXTRACTION_GUID, + "CRC32 GUIDED SECTION EXTRACTION"}, + { GRUB_EFI_DEBUG_IMAGE_INFO_TABLE_GUID, "DEBUG IMAGE INFO"}, + { GRUB_EFI_DXE_SERVICES_TABLE_GUID, "DXE SERVICES"}, + { GRUB_EFI_HCDP_TABLE_GUID, "HCDP"} + { GRUB_EFI_HOB_LIST_GUID, "HOB LIST"}, + { GRUB_EFI_LZMA_CUSTOM_DECOMPRESS_GUID, "LZMA CUSTOM DECOMPRESS"}, + { GRUB_EFI_MEMORY_TYPE_INFORMATION_GUID, "MEMORY TYPE INFO"}, + { GRUB_EFI_MPS_TABLE_GUID, "MPS"}, { GRUB_EFI_SAL_TABLE_GUID, "SAL"}, { GRUB_EFI_SMBIOS_TABLE_GUID, "SMBIOS"}, - { GRUB_EFI_MPS_TABLE_GUID, "MPS"}, - { GRUB_EFI_HCDP_TABLE_GUID, "HCDP"} + { GRUB_EFI_SYSTEM_RESOURCE_TABLE_GUID, "SYSTEM RESOURCE TABLE"}, + { GRUB_EFI_TIANO_CUSTOM_DECOMPRESS_GUID, "TIANO CUSTOM DECOMPRESS"}, + { GRUB_EFI_TSC_FREQUENCY_GUID, "TSC FREQUENCY"}, }; static grub_err_t diff --git a/include/grub/efi/api.h b/include/grub/efi/api.h index 029ee92f5..24a05c5f6 100644 --- a/include/grub/efi/api.h +++ b/include/grub/efi/api.h @@ -246,6 +246,51 @@ { 0x8E, 0x8B, 0xBB, 0xA2, 0x0B, 0x1B, 0x5B, 0x75 } \ } +#define GRUB_EFI_TIANO_CUSTOM_DECOMPRESS_GUID \ + { 0xa31280ad, 0x481e, 0x41b6, \ + { 0x95, 0xe8, 0x12, 0x7f, 0x4c, 0x98, 0x47, 0x79 } \ + } + +#define GRUB_EFI_CRC32_GUIDED_SECTION_EXTRACTION_GUID \ + { 0xfc1bcdb0, 0x7d31, 0x49aa, \ + { 0x93, 0x6a, 0xa4, 0x60, 0x0d, 0x9d, 0xd0, 0x83 } \ + } + +#define GRUB_EFI_LZMA_CUSTOM_DECOMPRESS_GUID \ + { 0xee4e5898, 0x3914, 0x4259, \ + { 0x9d, 0x6e, 0xdc, 0x7b, 0xd7, 0x94, 0x03, 0xcf } \ + } + +#define GRUB_EFI_TSC_FREQUENCY_GUID \ + { 0xdba6a7e3, 0xbb57, 0x4be7, \ + { 0x8a, 0xf8, 0xd5, 0x78, 0xdb, 0x7e, 0x56, 0x87 } \ + } + +#define GRUB_EFI_SYSTEM_RESOURCE_TABLE_GUID \ + { 0xb122a263, 0x3661, 0x4f68, \ + { 0x99, 0x29, 0x78, 0xf8, 0xb0, 0xd6, 0x21, 0x80 } \ + } + +#define GRUB_EFI_DXE_SERVICES_TABLE_GUID \ + { 0x05ad34ba, 0x6f02, 0x4214, \ + { 0x95, 0x2e, 0x4d, 0xa0, 0x39, 0x8e, 0x2b, 0xb9 } \ + } + +#define GRUB_EFI_HOB_LIST_GUID \ + { 0x7739f24c, 0x93d7, 0x11d4, \ + { 0x9a, 0x3a, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d } \ + } + +#define GRUB_EFI_MEMORY_TYPE_INFORMATION_GUID \ + { 0x4c19049f, 0x4137, 0x4dd3, \ + { 0x9c, 0x10, 0x8b, 0x97, 0xa8, 0x3f, 0xfd, 0xfa } \ + } + +#define GRUB_EFI_DEBUG_IMAGE_INFO_TABLE_GUID \ + { 0x49152e77, 0x1ada, 0x4764, \ + { 0xb7, 0xa2, 0x7a, 0xfe, 0xfe, 0xd9, 0x5e, 0x8b } \ + } + #define GRUB_EFI_MPS_TABLE_GUID \ { 0xeb9d2d2f, 0x2d88, 0x11d3, \ { 0x9a, 0x16, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d } \ From 50d6f38febe80d4d3088dae1ee639b341787ab71 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Tue, 17 Nov 2015 06:27:17 +0300 Subject: [PATCH 552/722] lsefisystab: add missing comma after 7994077 --- grub-core/commands/efi/lsefisystab.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/commands/efi/lsefisystab.c b/grub-core/commands/efi/lsefisystab.c index c84cea613..df1030221 100644 --- a/grub-core/commands/efi/lsefisystab.c +++ b/grub-core/commands/efi/lsefisystab.c @@ -41,7 +41,7 @@ static const struct guid_mapping guid_mappings[] = "CRC32 GUIDED SECTION EXTRACTION"}, { GRUB_EFI_DEBUG_IMAGE_INFO_TABLE_GUID, "DEBUG IMAGE INFO"}, { GRUB_EFI_DXE_SERVICES_TABLE_GUID, "DXE SERVICES"}, - { GRUB_EFI_HCDP_TABLE_GUID, "HCDP"} + { GRUB_EFI_HCDP_TABLE_GUID, "HCDP"}, { GRUB_EFI_HOB_LIST_GUID, "HOB LIST"}, { GRUB_EFI_LZMA_CUSTOM_DECOMPRESS_GUID, "LZMA CUSTOM DECOMPRESS"}, { GRUB_EFI_MEMORY_TYPE_INFORMATION_GUID, "MEMORY TYPE INFO"}, From 6a46cbcc5c1c746562fd7181bf0f2337db065201 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Wed, 18 Nov 2015 22:23:58 +0300 Subject: [PATCH 553/722] unix: do not close stdin in grub_passwd_get This makes it impossible to read from stdin without controlling tty: 10:/mnt # echo -e passwd\\npasswd | setsid ./grub-mkpasswd-pbkdf2 Enter password: Reenter password: ./grub-mkpasswd-pbkdf2: error: failure to read password. 10:/mnt --- grub-core/osdep/unix/password.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/grub-core/osdep/unix/password.c b/grub-core/osdep/unix/password.c index 4b9507bce..9996b244b 100644 --- a/grub-core/osdep/unix/password.c +++ b/grub-core/osdep/unix/password.c @@ -54,7 +54,8 @@ grub_password_get (char buf[], unsigned buf_size) grub_memset (buf, 0, buf_size); if (!fgets (buf, buf_size, stdin)) { - fclose (in); + if (in != stdin) + fclose (in); return 0; } ptr = buf + strlen (buf) - 1; @@ -67,7 +68,8 @@ grub_password_get (char buf[], unsigned buf_size) grub_xputs ("\n"); grub_refresh (); - fclose (in); + if (in != stdin) + fclose (in); return 1; } From f9d1b4422efb2c06e5472fb2c304712e2029796b Mon Sep 17 00:00:00 2001 From: Josef Bacik Date: Tue, 24 Nov 2015 12:41:35 -0500 Subject: [PATCH 554/722] net: reset nb->data per dns record lookup loop We were resetting nb->data every time we tried a new server, but we need to do it every time we try for a different record, otherwise we don't end up falling back to the A record properly. Thanks, Signed-off-by: Josef Bacik --- grub-core/net/dns.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/grub-core/net/dns.c b/grub-core/net/dns.c index 953f3bedd..89741dd7d 100644 --- a/grub-core/net/dns.c +++ b/grub-core/net/dns.c @@ -568,11 +568,10 @@ grub_net_dns_lookup (const char *name, { grub_err_t err2; - nb->data = nbd; - grub_size_t t = 0; do { + nb->data = nbd; if (servers[j].option == DNS_OPTION_IPV4 || ((servers[j].option == DNS_OPTION_PREFER_IPV4) && (t++ == 0)) || ((servers[j].option == DNS_OPTION_PREFER_IPV6) && (t++ == 1))) From 3d2c8048da7db334fd6d57b27304ac765fd4cd67 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Thu, 26 Nov 2015 19:50:42 +0300 Subject: [PATCH 555/722] efi: really mark memory of unknown type as reserved 9be4c45dbe3c877d1f4856e99ee15133c6cd2261 added switch case between fall through cases, causing all memory regions of unknown type to be marked as available. Move default case into its own block and add explicit FALLTHROUGH annotation. Reported by Elliott, Robert (Persistent Memory) --- grub-core/mmap/efi/mmap.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/grub-core/mmap/efi/mmap.c b/grub-core/mmap/efi/mmap.c index a77efe81d..900a4d659 100644 --- a/grub-core/mmap/efi/mmap.c +++ b/grub-core/mmap/efi/mmap.c @@ -73,6 +73,7 @@ grub_efi_mmap_iterate (grub_memory_hook_t hook, void *hook_data, GRUB_MEMORY_AVAILABLE, hook_data); break; } + /* FALLTHROUGH */ case GRUB_EFI_RUNTIME_SERVICES_CODE: hook (desc->physical_start, desc->num_pages * 4096, GRUB_MEMORY_CODE, hook_data); @@ -83,10 +84,6 @@ grub_efi_mmap_iterate (grub_memory_hook_t hook, void *hook_data, GRUB_MEMORY_BADRAM, hook_data); break; - default: - grub_printf ("Unknown memory type %d, considering reserved\n", - desc->type); - case GRUB_EFI_BOOT_SERVICES_DATA: if (!avoid_efi_boot_services) { @@ -94,6 +91,7 @@ grub_efi_mmap_iterate (grub_memory_hook_t hook, void *hook_data, GRUB_MEMORY_AVAILABLE, hook_data); break; } + /* FALLTHROUGH */ case GRUB_EFI_RESERVED_MEMORY_TYPE: case GRUB_EFI_RUNTIME_SERVICES_DATA: case GRUB_EFI_MEMORY_MAPPED_IO: @@ -119,6 +117,13 @@ grub_efi_mmap_iterate (grub_memory_hook_t hook, void *hook_data, hook (desc->physical_start, desc->num_pages * 4096, GRUB_MEMORY_NVS, hook_data); break; + + default: + grub_printf ("Unknown memory type %d, considering reserved\n", + desc->type); + hook (desc->physical_start, desc->num_pages * 4096, + GRUB_MEMORY_RESERVED, hook_data); + break; } } From d43a5ee65143f384357fbfdcace4258e3537c214 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 13 Nov 2015 16:14:53 +0100 Subject: [PATCH 556/722] tsc: Use alternative delay sources whenever appropriate. PIT isn't available on some of new hardware including Hyper-V. So use pmtimer for calibration. Moreover pmtimer calibration is faster, so use it on coreboor where booting time is important. Based on patch by Michael Chang. --- grub-core/Makefile.am | 7 + grub-core/Makefile.core.def | 19 ++- grub-core/commands/acpi.c | 12 -- grub-core/kern/acpi.c | 34 +++++ grub-core/{commands => kern}/efi/acpi.c | 0 grub-core/kern/i386/efi/tsc.c | 40 +++++ grub-core/{commands => kern}/i386/pc/acpi.c | 0 grub-core/kern/i386/tsc.c | 133 ++++------------ grub-core/kern/i386/tsc_pit.c | 84 ++++++++++ grub-core/kern/i386/tsc_pmtimer.c | 160 ++++++++++++++++++++ grub-core/kern/i386/xen/tsc.c | 40 +++++ include/grub/acpi.h | 17 ++- include/grub/i386/tsc.h | 26 ++++ 13 files changed, 451 insertions(+), 121 deletions(-) create mode 100644 grub-core/kern/acpi.c rename grub-core/{commands => kern}/efi/acpi.c (100%) create mode 100644 grub-core/kern/i386/efi/tsc.c rename grub-core/{commands => kern}/i386/pc/acpi.c (100%) create mode 100644 grub-core/kern/i386/tsc_pit.c create mode 100644 grub-core/kern/i386/tsc_pmtimer.c create mode 100644 grub-core/kern/i386/xen/tsc.c diff --git a/grub-core/Makefile.am b/grub-core/Makefile.am index af0c7f47c..c671aed4b 100644 --- a/grub-core/Makefile.am +++ b/grub-core/Makefile.am @@ -101,6 +101,7 @@ if COND_i386_efi KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/efi.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/disk.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/i386/tsc.h +KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/acpi.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/pci.h endif @@ -112,10 +113,12 @@ KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/video_fb.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/gfxterm.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/font.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/bufio.h +KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/acpi.h endif if COND_i386_multiboot KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/i386/tsc.h +KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/acpi.h endif if COND_i386_qemu @@ -154,11 +157,13 @@ KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/efi.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/disk.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/i386/tsc.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/pci.h +KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/acpi.h endif if COND_ia64_efi KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/efi.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/disk.h +KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/acpi.h endif if COND_mips @@ -233,11 +238,13 @@ KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/arm/efi/loader.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/efi.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/disk.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/arm/system.h +KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/acpi.h endif if COND_arm64_efi KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/efi.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/disk.h +KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/acpi.h endif if COND_emu diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def index d9fa0e339..0cc40bb2b 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def @@ -171,8 +171,20 @@ kernel = { efi = kern/efi/init.c; efi = kern/efi/mm.c; efi = term/efi/console.c; + efi = kern/acpi.c; + efi = kern/efi/acpi.c; + i386_coreboot = kern/i386/pc/acpi.c; + i386_multiboot = kern/i386/pc/acpi.c; + i386_coreboot = kern/acpi.c; + i386_multiboot = kern/acpi.c; x86 = kern/i386/tsc.c; + x86 = kern/i386/tsc_pit.c; + i386_efi = kern/i386/efi/tsc.c; + x86_64_efi = kern/i386/efi/tsc.c; + i386_efi = kern/i386/tsc_pmtimer.c; + i386_coreboot = kern/i386/tsc_pmtimer.c; + x86_64_efi = kern/i386/tsc_pmtimer.c; i386_efi = kern/i386/efi/init.c; i386_efi = bus/pci.c; @@ -184,6 +196,7 @@ kernel = { x86_64_efi = bus/pci.c; xen = kern/i386/tsc.c; + xen = kern/i386/xen/tsc.c; x86_64_xen = kern/x86_64/xen/hypercall.S; i386_xen = kern/i386/xen/hypercall.S; xen = kern/xen/init.c; @@ -665,10 +678,8 @@ module = { name = acpi; common = commands/acpi.c; - efi = commands/efi/acpi.c; - i386_pc = commands/i386/pc/acpi.c; - i386_coreboot = commands/i386/pc/acpi.c; - i386_multiboot = commands/i386/pc/acpi.c; + i386_pc = kern/acpi.c; + i386_pc = kern/i386/pc/acpi.c; enable = efi; enable = i386_pc; diff --git a/grub-core/commands/acpi.c b/grub-core/commands/acpi.c index c3861f594..ece49b4a9 100644 --- a/grub-core/commands/acpi.c +++ b/grub-core/commands/acpi.c @@ -61,18 +61,6 @@ static const struct grub_arg_option options[] = { {0, 0, 0, 0, 0, 0} }; -/* Simple checksum by summing all bytes. Used by ACPI and SMBIOS. */ -grub_uint8_t -grub_byte_checksum (void *base, grub_size_t size) -{ - grub_uint8_t *ptr; - grub_uint8_t ret = 0; - for (ptr = (grub_uint8_t *) base; ptr < ((grub_uint8_t *) base) + size; - ptr++) - ret += *ptr; - return ret; -} - /* rev1 is 1 if ACPIv1 is to be generated, 0 otherwise. rev2 contains the revision of ACPIv2+ to generate or 0 if none. */ static int rev1, rev2; diff --git a/grub-core/kern/acpi.c b/grub-core/kern/acpi.c new file mode 100644 index 000000000..02c1f4f6f --- /dev/null +++ b/grub-core/kern/acpi.c @@ -0,0 +1,34 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2012 Free Software Foundation, Inc. + * + * GRUB is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GRUB is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GRUB. If not, see . + */ + +#include +#include +#include +#include + +/* Simple checksum by summing all bytes. Used by ACPI and SMBIOS. */ +grub_uint8_t +grub_byte_checksum (void *base, grub_size_t size) +{ + grub_uint8_t *ptr; + grub_uint8_t ret = 0; + for (ptr = (grub_uint8_t *) base; ptr < ((grub_uint8_t *) base) + size; + ptr++) + ret += *ptr; + return ret; +} diff --git a/grub-core/commands/efi/acpi.c b/grub-core/kern/efi/acpi.c similarity index 100% rename from grub-core/commands/efi/acpi.c rename to grub-core/kern/efi/acpi.c diff --git a/grub-core/kern/i386/efi/tsc.c b/grub-core/kern/i386/efi/tsc.c new file mode 100644 index 000000000..4b93ba8e1 --- /dev/null +++ b/grub-core/kern/i386/efi/tsc.c @@ -0,0 +1,40 @@ +/* kern/i386/tsc.c - x86 TSC time source implementation + * Requires Pentium or better x86 CPU that supports the RDTSC instruction. + * This module uses the PIT to calibrate the TSC to + * real time. + * + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2008 Free Software Foundation, Inc. + * + * GRUB is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GRUB is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GRUB. If not, see . + */ + +#include +#include +#include +#include +#include +#include + +int +grub_tsc_calibrate_from_efi (void) +{ + grub_uint64_t start_tsc, end_tsc; + /* Use EFI Time Service to calibrate TSC */ + start_tsc = grub_get_tsc (); + efi_call_1 (grub_efi_system_table->boot_services->stall, 1000); + end_tsc = grub_get_tsc (); + grub_tsc_rate = grub_divmod64 ((1ULL << 32), end_tsc - start_tsc, 0); + return 1; +} diff --git a/grub-core/commands/i386/pc/acpi.c b/grub-core/kern/i386/pc/acpi.c similarity index 100% rename from grub-core/commands/i386/pc/acpi.c rename to grub-core/kern/i386/pc/acpi.c diff --git a/grub-core/kern/i386/tsc.c b/grub-core/kern/i386/tsc.c index bc441d0d3..82cdea491 100644 --- a/grub-core/kern/i386/tsc.c +++ b/grub-core/kern/i386/tsc.c @@ -1,7 +1,6 @@ /* kern/i386/tsc.c - x86 TSC time source implementation * Requires Pentium or better x86 CPU that supports the RDTSC instruction. - * This module uses the RTC (via grub_get_rtc()) to calibrate the TSC to - * real time. + * This module calibrates the TSC to real time. * * GRUB -- GRand Unified Bootloader * Copyright (C) 2008 Free Software Foundation, Inc. @@ -25,12 +24,6 @@ #include #include #include -#ifdef GRUB_MACHINE_XEN -#include -#else -#include -#endif -#include /* This defines the value TSC had at the epoch (that is, when we calibrated it). */ static grub_uint64_t tsc_boot_time; @@ -40,66 +33,6 @@ static grub_uint64_t tsc_boot_time; in 32-bit. */ grub_uint32_t grub_tsc_rate; -/* Read the TSC value, which increments with each CPU clock cycle. */ -static __inline grub_uint64_t -grub_get_tsc (void) -{ - grub_uint32_t lo, hi; - grub_uint32_t a,b,c,d; - - /* The CPUID instruction is a 'serializing' instruction, and - avoids out-of-order execution of the RDTSC instruction. */ - grub_cpuid (0,a,b,c,d); - /* Read TSC value. We cannot use "=A", since this would use - %rax on x86_64. */ - __asm__ __volatile__ ("rdtsc":"=a" (lo), "=d" (hi)); - - return (((grub_uint64_t) hi) << 32) | lo; -} - -#ifndef GRUB_MACHINE_XEN - -static __inline int -grub_cpu_is_tsc_supported (void) -{ - grub_uint32_t a,b,c,d; - if (! grub_cpu_is_cpuid_supported ()) - return 0; - - grub_cpuid(1,a,b,c,d); - - return (d & (1 << 4)) != 0; -} - -static void -grub_pit_wait (grub_uint16_t tics) -{ - /* Disable timer2 gate and speaker. */ - grub_outb (grub_inb (GRUB_PIT_SPEAKER_PORT) - & ~ (GRUB_PIT_SPK_DATA | GRUB_PIT_SPK_TMR2), - GRUB_PIT_SPEAKER_PORT); - - /* Set tics. */ - grub_outb (GRUB_PIT_CTRL_SELECT_2 | GRUB_PIT_CTRL_READLOAD_WORD, - GRUB_PIT_CTRL); - grub_outb (tics & 0xff, GRUB_PIT_COUNTER_2); - grub_outb (tics >> 8, GRUB_PIT_COUNTER_2); - - /* Enable timer2 gate, keep speaker disabled. */ - grub_outb ((grub_inb (GRUB_PIT_SPEAKER_PORT) & ~ GRUB_PIT_SPK_DATA) - | GRUB_PIT_SPK_TMR2, - GRUB_PIT_SPEAKER_PORT); - - /* Wait. */ - while ((grub_inb (GRUB_PIT_SPEAKER_PORT) & GRUB_PIT_SPK_TMR2_LATCH) == 0x00); - - /* Disable timer2 gate and speaker. */ - grub_outb (grub_inb (GRUB_PIT_SPEAKER_PORT) - & ~ (GRUB_PIT_SPK_DATA | GRUB_PIT_SPK_TMR2), - GRUB_PIT_SPEAKER_PORT); -} -#endif - static grub_uint64_t grub_tsc_get_time_ms (void) { @@ -110,52 +43,52 @@ grub_tsc_get_time_ms (void) return ((al * grub_tsc_rate) >> 32) + ah * grub_tsc_rate; } -#ifndef GRUB_MACHINE_XEN -/* Calibrate the TSC based on the RTC. */ -static void -calibrate_tsc (void) +static __inline int +grub_cpu_is_tsc_supported (void) { - /* First calibrate the TSC rate (relative, not absolute time). */ - grub_uint64_t end_tsc; +#ifndef GRUB_MACHINE_XEN + grub_uint32_t a,b,c,d; + if (! grub_cpu_is_cpuid_supported ()) + return 0; - tsc_boot_time = grub_get_tsc (); - grub_pit_wait (0xffff); - end_tsc = grub_get_tsc (); + grub_cpuid(1,a,b,c,d); - grub_tsc_rate = 0; - if (end_tsc > tsc_boot_time) - grub_tsc_rate = grub_divmod64 ((55ULL << 32), end_tsc - tsc_boot_time, 0); - if (grub_tsc_rate == 0) - grub_tsc_rate = 5368;/* 800 MHz */ -} + return (d & (1 << 4)) != 0; +#else + return 1; #endif +} + +static int +calibrate_tsc_hardcode (void) +{ + grub_tsc_rate = 5368;/* 800 MHz */ + return 1; +} void grub_tsc_init (void) { -#ifdef GRUB_MACHINE_XEN - grub_uint64_t t; - tsc_boot_time = grub_get_tsc (); - t = grub_xen_shared_info->vcpu_info[0].time.tsc_to_system_mul; - if (grub_xen_shared_info->vcpu_info[0].time.tsc_shift > 0) - t <<= grub_xen_shared_info->vcpu_info[0].time.tsc_shift; - else - t >>= -grub_xen_shared_info->vcpu_info[0].time.tsc_shift; - grub_tsc_rate = grub_divmod64 (t, 1000000, 0); - grub_install_get_time_ms (grub_tsc_get_time_ms); -#else - if (grub_cpu_is_tsc_supported ()) - { - calibrate_tsc (); - grub_install_get_time_ms (grub_tsc_get_time_ms); - } - else + if (!grub_cpu_is_tsc_supported ()) { #if defined (GRUB_MACHINE_PCBIOS) || defined (GRUB_MACHINE_IEEE1275) grub_install_get_time_ms (grub_rtc_get_time_ms); #else grub_fatal ("no TSC found"); #endif + return; } + + tsc_boot_time = grub_get_tsc (); + +#ifdef GRUB_MACHINE_XEN + (void) (grub_tsc_calibrate_from_xen () || calibrate_tsc_hardcode()); +#elif defined (GRUB_MACHINE_EFI) + (void) (grub_tsc_calibrate_from_pit () || grub_tsc_calibrate_from_pmtimer () || grub_tsc_calibrate_from_efi() || calibrate_tsc_hardcode()); +#elif defined (GRUB_MACHINE_COREBOOT) + (void) (grub_tsc_calibrate_from_pmtimer () || grub_tsc_calibrate_from_pit () || calibrate_tsc_hardcode()); +#else + (void) (grub_tsc_calibrate_from_pit () || calibrate_tsc_hardcode()); #endif + grub_install_get_time_ms (grub_tsc_get_time_ms); } diff --git a/grub-core/kern/i386/tsc_pit.c b/grub-core/kern/i386/tsc_pit.c new file mode 100644 index 000000000..0c0488c1b --- /dev/null +++ b/grub-core/kern/i386/tsc_pit.c @@ -0,0 +1,84 @@ +/* kern/i386/tsc.c - x86 TSC time source implementation + * Requires Pentium or better x86 CPU that supports the RDTSC instruction. + * This module uses the PIT to calibrate the TSC to + * real time. + * + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2008 Free Software Foundation, Inc. + * + * GRUB is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GRUB is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GRUB. If not, see . + */ + +#include +#include +#include +#include +#include +#include + +static int +grub_pit_wait (void) +{ + int ret = 0; + + /* Disable timer2 gate and speaker. */ + grub_outb (grub_inb (GRUB_PIT_SPEAKER_PORT) + & ~ (GRUB_PIT_SPK_DATA | GRUB_PIT_SPK_TMR2), + GRUB_PIT_SPEAKER_PORT); + + /* Set tics. */ + grub_outb (GRUB_PIT_CTRL_SELECT_2 | GRUB_PIT_CTRL_READLOAD_WORD, + GRUB_PIT_CTRL); + /* 0xffff ticks: 55ms. */ + grub_outb (0xff, GRUB_PIT_COUNTER_2); + grub_outb (0xff, GRUB_PIT_COUNTER_2); + + /* Enable timer2 gate, keep speaker disabled. */ + grub_outb ((grub_inb (GRUB_PIT_SPEAKER_PORT) & ~ GRUB_PIT_SPK_DATA) + | GRUB_PIT_SPK_TMR2, + GRUB_PIT_SPEAKER_PORT); + + if ((grub_inb (GRUB_PIT_SPEAKER_PORT) & GRUB_PIT_SPK_TMR2_LATCH)) { + ret = 1; + /* Wait. */ + while ((grub_inb (GRUB_PIT_SPEAKER_PORT) & GRUB_PIT_SPK_TMR2_LATCH) == 0x00); + } + + /* Disable timer2 gate and speaker. */ + grub_outb (grub_inb (GRUB_PIT_SPEAKER_PORT) + & ~ (GRUB_PIT_SPK_DATA | GRUB_PIT_SPK_TMR2), + GRUB_PIT_SPEAKER_PORT); + + return ret; +} + +/* Calibrate the TSC based on the RTC. */ +int +grub_tsc_calibrate_from_pit (void) +{ + /* First calibrate the TSC rate (relative, not absolute time). */ + grub_uint64_t start_tsc, end_tsc; + + start_tsc = grub_get_tsc (); + if (!grub_pit_wait ()) + return 0; + end_tsc = grub_get_tsc (); + + grub_tsc_rate = 0; + if (end_tsc > start_tsc) + grub_tsc_rate = grub_divmod64 ((55ULL << 32), end_tsc - start_tsc, 0); + if (grub_tsc_rate == 0) + return 0; + return 1; +} diff --git a/grub-core/kern/i386/tsc_pmtimer.c b/grub-core/kern/i386/tsc_pmtimer.c new file mode 100644 index 000000000..6a47ab7be --- /dev/null +++ b/grub-core/kern/i386/tsc_pmtimer.c @@ -0,0 +1,160 @@ +/* kern/i386/tsc.c - x86 TSC time source implementation + * Requires Pentium or better x86 CPU that supports the RDTSC instruction. + * This module uses the PIT to calibrate the TSC to + * real time. + * + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2008 Free Software Foundation, Inc. + * + * GRUB is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GRUB is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GRUB. If not, see . + */ + +#include +#include +#include +#include +#include +#include + +static void * +grub_acpi_rsdt_find_table (struct grub_acpi_table_header *rsdt, const char *sig) +{ + grub_size_t s; + grub_uint32_t *ptr; + + if (!rsdt) + return 0; + + if (grub_memcmp (rsdt->signature, "RSDT", 4) != 0) + return 0; + + ptr = (grub_uint32_t *) (rsdt + 1); + s = (rsdt->length - sizeof (*rsdt)) / sizeof (grub_uint32_t); + for (; s; s--, ptr++) + { + struct grub_acpi_table_header *tbl; + tbl = (struct grub_acpi_table_header *) (grub_addr_t) *ptr; + if (grub_memcmp (tbl->signature, sig, 4) == 0) + return tbl; + } + return 0; +} + +static void * +grub_acpi_xsdt_find_table (struct grub_acpi_table_header *xsdt, const char *sig) +{ + grub_size_t s; + grub_uint64_t *ptr; + + if (!xsdt) + return 0; + + if (grub_memcmp (xsdt->signature, "XSDT", 4) != 0) + return 0; + + ptr = (grub_uint64_t *) (xsdt + 1); + s = (xsdt->length - sizeof (*xsdt)) / sizeof (grub_uint32_t); + for (; s; s--, ptr++) + { + struct grub_acpi_table_header *tbl; +#if GRUB_CPU_SIZEOF_VOID_P != 8 + if (*ptr >> 32) + continue; +#endif + tbl = (struct grub_acpi_table_header *) (grub_addr_t) *ptr; + if (grub_memcmp (tbl->signature, sig, 4) == 0) + return tbl; + } + return 0; +} + +struct grub_acpi_fadt * +grub_acpi_find_fadt (void) +{ + struct grub_acpi_fadt *fadt = 0; + struct grub_acpi_rsdp_v10 *rsdpv1; + struct grub_acpi_rsdp_v20 *rsdpv2; + rsdpv1 = grub_machine_acpi_get_rsdpv1 (); + if (rsdpv1) + fadt = grub_acpi_rsdt_find_table ((struct grub_acpi_table_header *) + (grub_addr_t) rsdpv1->rsdt_addr, + GRUB_ACPI_FADT_SIGNATURE); + if (fadt) + return fadt; + rsdpv2 = grub_machine_acpi_get_rsdpv2 (); + if (rsdpv2) + fadt = grub_acpi_rsdt_find_table ((struct grub_acpi_table_header *) + (grub_addr_t) rsdpv2->rsdpv1.rsdt_addr, + GRUB_ACPI_FADT_SIGNATURE); + if (fadt) + return fadt; + if (rsdpv2 +#if GRUB_CPU_SIZEOF_VOID_P != 8 + && !(rsdpv2->xsdt_addr >> 32) +#endif + ) + fadt = grub_acpi_xsdt_find_table ((struct grub_acpi_table_header *) + (grub_addr_t) rsdpv2->xsdt_addr, + GRUB_ACPI_FADT_SIGNATURE); + if (fadt) + return fadt; + return 0; +} + +int +grub_tsc_calibrate_from_pmtimer (void) +{ + grub_uint32_t start; + grub_uint32_t last; + grub_uint32_t cur, end; + struct grub_acpi_fadt *fadt; + grub_port_t p; + grub_uint64_t start_tsc; + grub_uint64_t end_tsc; + int num_iter = 0; + + fadt = grub_acpi_find_fadt (); + if (!fadt) + return 0; + p = fadt->pmtimer; + if (!p) + return 0; + + start = grub_inl (p) & 0xffffff; + last = start; + /* It's 3.579545 MHz clock. Wait 1 ms. */ + end = start + 3580; + start_tsc = grub_get_tsc (); + while (1) + { + cur = grub_inl (p) & 0xffffff; + if (cur < last) + cur |= 0x1000000; + num_iter++; + if (cur >= end) + { + end_tsc = grub_get_tsc (); + grub_tsc_rate = grub_divmod64 ((1ULL << 32), end_tsc - start_tsc, 0); + return 1; + } + /* Check for broken PM timer. + 50000000 TSCs is between 5 ms (10GHz) and 200 ms (250 MHz) + if after this time we still don't have 1 ms on pmtimer, then + pmtimer is broken. + */ + if ((num_iter & 0xffffff) == 0 && grub_get_tsc () - start_tsc > 5000000) { + return 0; + } + } +} diff --git a/grub-core/kern/i386/xen/tsc.c b/grub-core/kern/i386/xen/tsc.c new file mode 100644 index 000000000..8792b308d --- /dev/null +++ b/grub-core/kern/i386/xen/tsc.c @@ -0,0 +1,40 @@ +/* kern/i386/tsc.c - x86 TSC time source implementation + * Requires Pentium or better x86 CPU that supports the RDTSC instruction. + * This module uses the PIT to calibrate the TSC to + * real time. + * + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2008 Free Software Foundation, Inc. + * + * GRUB is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GRUB is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GRUB. If not, see . + */ + +#include +#include +#include +#include +#include + +int +grub_tsc_calibrate_from_xen (void) +{ + grub_uint64_t t; + t = grub_xen_shared_info->vcpu_info[0].time.tsc_to_system_mul; + if (grub_xen_shared_info->vcpu_info[0].time.tsc_shift > 0) + t <<= grub_xen_shared_info->vcpu_info[0].time.tsc_shift; + else + t >>= -grub_xen_shared_info->vcpu_info[0].time.tsc_shift; + grub_tsc_rate = grub_divmod64 (t, 1000000, 0); + return 1; +} diff --git a/include/grub/acpi.h b/include/grub/acpi.h index f6e6a11c5..8a8110241 100644 --- a/include/grub/acpi.h +++ b/include/grub/acpi.h @@ -67,10 +67,14 @@ struct grub_acpi_fadt grub_uint32_t dsdt_addr; grub_uint8_t somefields1[20]; grub_uint32_t pm1a; - grub_uint8_t somefields2[64]; + grub_uint8_t somefields2[8]; + grub_uint32_t pmtimer; + grub_uint8_t somefields3[32]; + grub_uint32_t flags; + grub_uint8_t somefields4[16]; grub_uint64_t facs_xaddr; grub_uint64_t dsdt_xaddr; - grub_uint8_t somefields3[96]; + grub_uint8_t somefields5[96]; } GRUB_PACKED; #define GRUB_ACPI_MADT_SIGNATURE "APIC" @@ -176,9 +180,9 @@ enum #ifndef GRUB_DSDT_TEST struct grub_acpi_rsdp_v10 *grub_acpi_get_rsdpv1 (void); struct grub_acpi_rsdp_v20 *grub_acpi_get_rsdpv2 (void); -struct grub_acpi_rsdp_v10 *grub_machine_acpi_get_rsdpv1 (void); -struct grub_acpi_rsdp_v20 *grub_machine_acpi_get_rsdpv2 (void); -grub_uint8_t grub_byte_checksum (void *base, grub_size_t size); +struct grub_acpi_rsdp_v10 *EXPORT_FUNC(grub_machine_acpi_get_rsdpv1) (void); +struct grub_acpi_rsdp_v20 *EXPORT_FUNC(grub_machine_acpi_get_rsdpv2) (void); +grub_uint8_t EXPORT_FUNC(grub_byte_checksum) (void *base, grub_size_t size); grub_err_t grub_acpi_create_ebda (void); @@ -234,4 +238,7 @@ enum GRUB_ACPI_EXTOPCODE_BANK_FIELD_OP = 0x87, }; +struct grub_acpi_fadt * +grub_acpi_find_fadt (void); + #endif /* ! GRUB_ACPI_HEADER */ diff --git a/include/grub/i386/tsc.h b/include/grub/i386/tsc.h index 71b32e6b8..71fa7ca2f 100644 --- a/include/grub/i386/tsc.h +++ b/include/grub/i386/tsc.h @@ -20,9 +20,35 @@ #define KERNEL_CPU_TSC_HEADER 1 #include +#include void grub_tsc_init (void); /* In ms per 2^32 ticks. */ extern grub_uint32_t EXPORT_VAR(grub_tsc_rate); +int +grub_tsc_calibrate_from_xen (void); +int +grub_tsc_calibrate_from_efi (void); +int +grub_tsc_calibrate_from_pmtimer (void); +int +grub_tsc_calibrate_from_pit (void); + +/* Read the TSC value, which increments with each CPU clock cycle. */ +static __inline grub_uint64_t +grub_get_tsc (void) +{ + grub_uint32_t lo, hi; + grub_uint32_t a,b,c,d; + + /* The CPUID instruction is a 'serializing' instruction, and + avoids out-of-order execution of the RDTSC instruction. */ + grub_cpuid (0,a,b,c,d); + /* Read TSC value. We cannot use "=A", since this would use + %rax on x86_64. */ + __asm__ __volatile__ ("rdtsc":"=a" (lo), "=d" (hi)); + + return (((grub_uint64_t) hi) << 32) | lo; +} #endif /* ! KERNEL_CPU_TSC_HEADER */ From a2618427857c7013a6d3107eb3b9be2d526a69ed Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Fri, 27 Nov 2015 19:42:23 +0300 Subject: [PATCH 557/722] configure: fix macports flex version detection Macports add extra information after version itself: $flex --version flex 2.5.35 Apple(flex-31) We require at least felx 2.5.35 so do not need to care about prehistoric "flex version n.n.n"; just use second field always. Reported by Peter Cheung --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 9e8a606a6..3300545e0 100644 --- a/configure.ac +++ b/configure.ac @@ -315,7 +315,7 @@ AC_PROG_LN_S if test "x$LEX" = "x:"; then AC_MSG_ERROR([flex is not found]) else - version=`$LEX --version | $AWK '{ split($NF,x,"."); print x[[1]]*10000+x[[2]]*100+x[[3]]; }'` + version=`$LEX --version | $AWK '{ split($2,x,"."); print x[[1]]*10000+x[[2]]*100+x[[3]]; }'` if test -n "$version" -a "$version" -ge 20535; then : else From f4c143789afaf54b4afaf67eef91c7550282da36 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Fri, 27 Nov 2015 19:52:16 +0300 Subject: [PATCH 558/722] Replace numbers with grub_memory_type_t enums --- grub-core/kern/ieee1275/init.c | 2 +- grub-core/loader/sparc64/ieee1275/linux.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/grub-core/kern/ieee1275/init.c b/grub-core/kern/ieee1275/init.c index d5bd74d35..4303509f2 100644 --- a/grub-core/kern/ieee1275/init.c +++ b/grub-core/kern/ieee1275/init.c @@ -166,7 +166,7 @@ heap_init (grub_uint64_t addr, grub_uint64_t len, grub_memory_type_t type, { unsigned long *total = data; - if (type != 1) + if (type != GRUB_MEMORY_AVAILABLE) return 0; if (grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_NO_PRE1_5M_CLAIM)) diff --git a/grub-core/loader/sparc64/ieee1275/linux.c b/grub-core/loader/sparc64/ieee1275/linux.c index 63d6a1f33..346d9538e 100644 --- a/grub-core/loader/sparc64/ieee1275/linux.c +++ b/grub-core/loader/sparc64/ieee1275/linux.c @@ -196,7 +196,7 @@ alloc_phys_choose (grub_uint64_t addr, grub_uint64_t len, struct alloc_phys_ctx *ctx = data; grub_addr_t end = addr + len; - if (type != 1) + if (type != GRUB_MEMORY_AVAILABLE) return 0; addr = ALIGN_UP (addr, FOUR_MB); @@ -430,7 +430,7 @@ static int get_physbase (grub_uint64_t addr, grub_uint64_t len __attribute__ ((unused)), grub_memory_type_t type, void *data __attribute__ ((unused))) { - if (type != 1) + if (type != GRUB_MEMORY_AVAILABLE) return 0; if (addr < phys_base) phys_base = addr; From 346a494d7c92fe7c2a89f01be84a7be67bcfbfe7 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sat, 28 Nov 2015 21:11:34 +0300 Subject: [PATCH 559/722] Do not include generated gnulib headers in tarball gnulib files are already handled by recursive make distdir invocation. Including all generated headers (after make completed) causes build failure if target system is different (different compile version etc). --- conf/Makefile.extra-dist | 1 - 1 file changed, 1 deletion(-) diff --git a/conf/Makefile.extra-dist b/conf/Makefile.extra-dist index ea6b9df3a..9dd64fdca 100644 --- a/conf/Makefile.extra-dist +++ b/conf/Makefile.extra-dist @@ -37,7 +37,6 @@ EXTRA_DIST += grub-core/lib/libgcrypt EXTRA_DIST += grub-core/lib/libgcrypt-grub/mpi/generic EXTRA_DIST += $(shell find $(top_srcdir)/include -name '*.h') EXTRA_DIST += $(shell find $(top_srcdir)/grub-core/lib -name '*.h') -EXTRA_DIST += $(shell find $(top_srcdir)/grub-core/gnulib -name '*.h') EXTRA_DIST += grub-core/efiemu/runtime/config.h EXTRA_DIST += grub-core/lib/LzmaDec.c From a03c1034f6062e69075056c8f31b90e159ce5244 Mon Sep 17 00:00:00 2001 From: Michael Chang Date: Tue, 1 Dec 2015 18:49:38 +0300 Subject: [PATCH 560/722] i386: fix TSC calibration using PIT Condition was accidentally reversed, so PIT calibration always failed when PIT was present and always succeeded when PIT was missing, but in the latter case resulted in absurdly fast clock. Reported and tested by Vitaly Kuznetsov --- grub-core/kern/i386/tsc_pit.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/kern/i386/tsc_pit.c b/grub-core/kern/i386/tsc_pit.c index 0c0488c1b..67990bfa6 100644 --- a/grub-core/kern/i386/tsc_pit.c +++ b/grub-core/kern/i386/tsc_pit.c @@ -49,7 +49,7 @@ grub_pit_wait (void) | GRUB_PIT_SPK_TMR2, GRUB_PIT_SPEAKER_PORT); - if ((grub_inb (GRUB_PIT_SPEAKER_PORT) & GRUB_PIT_SPK_TMR2_LATCH)) { + if ((grub_inb (GRUB_PIT_SPEAKER_PORT) & GRUB_PIT_SPK_TMR2_LATCH) == 0x00) { ret = 1; /* Wait. */ while ((grub_inb (GRUB_PIT_SPEAKER_PORT) & GRUB_PIT_SPK_TMR2_LATCH) == 0x00); From fb478079182f3b21603834eaeb9026e051f88c33 Mon Sep 17 00:00:00 2001 From: Josef Bacik Date: Wed, 12 Aug 2015 08:16:22 -0700 Subject: [PATCH 561/722] tcp: ack when we get an OOO/lost packet While adding tcp window scaling support I was finding that I'd get some packet loss or reordering when transferring from large distances and grub would just timeout. This is because we weren't ack'ing when we got our OOO packet, so the sender didn't know it needed to retransmit anything, so eventually it would fill the window and stop transmitting, and we'd time out. Fix this by ACK'ing when we don't find our next sequence numbered packet. With this fix I no longer time out. Thanks, Signed-off-by: Josef Bacik --- grub-core/net/tcp.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/grub-core/net/tcp.c b/grub-core/net/tcp.c index 9e81a0a85..576f68498 100644 --- a/grub-core/net/tcp.c +++ b/grub-core/net/tcp.c @@ -893,7 +893,10 @@ grub_net_recv_tcp_packet (struct grub_net_buff *nb, grub_priority_queue_pop (sock->pq); } if (grub_be_to_cpu32 (tcph->seqnr) != sock->their_cur_seq) - return GRUB_ERR_NONE; + { + ack (sock); + return GRUB_ERR_NONE; + } while (1) { nb_top_p = grub_priority_queue_top (sock->pq); From 4803db51ff031890f7fc81ee2667e88422817f31 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 14 Dec 2015 16:21:24 +0100 Subject: [PATCH 562/722] Document bootlocation discovery limitations and xen platform limitations --- docs/grub.texi | 44 +++++++++++++++++++++++++++++--------------- 1 file changed, 29 insertions(+), 15 deletions(-) diff --git a/docs/grub.texi b/docs/grub.texi index 1df3db260..9a25a0bdb 100644 --- a/docs/grub.texi +++ b/docs/grub.texi @@ -5669,6 +5669,16 @@ BadRAM is the ability to mark some of the RAM as ``bad''. Note: due to protocol limitations mips-loongson (with Linux protocol) and mips-qemu_mips can use only memory up to first hole. +Bootlocation is ability of GRUB to automatically detect where it boots from. +``disk'' means the detection is limited to detecting the disk with partition +being discovered on install time. ``partition'' means that disk and partiton +can be automatically discovered. ``file'' means that boot image file name as +well as disk and partition can be discovered. For consistency default install ignores +partition and relies solely on disk detection. If no bootlocation discovery is available +or boot and grub-root disks are different, UUID is used instead. On ARC if no device +to install to is specified, UUID is used instead as well. + + @multitable @columnfractions .20 .20 .20 .20 .20 @item @tab BIOS @tab Coreboot @tab Multiboot @tab Qemu @item video @tab yes @tab yes @tab yes @tab yes @@ -5685,6 +5695,7 @@ and mips-qemu_mips can use only memory up to first hole. @item badram @tab yes @tab yes @tab yes @tab yes @item compression @tab always @tab pointless @tab no @tab no @item exit @tab yes @tab no @tab no @tab no +@item bootlocation @tab disk @tab no @tab no @tab no @end multitable @multitable @columnfractions .20 .20 .20 .20 .20 @@ -5703,6 +5714,7 @@ and mips-qemu_mips can use only memory up to first hole. @item badram @tab yes @tab yes @tab no @tab yes @item compression @tab no @tab no @tab no @tab no @item exit @tab yes @tab yes @tab yes @tab yes +@item bootlocation @tab file @tab file @tab file, ignored @tab file @end multitable @multitable @columnfractions .20 .20 .20 .20 .20 @@ -5721,24 +5733,26 @@ and mips-qemu_mips can use only memory up to first hole. @item badram @tab yes (*) @tab no @tab no @tab no @item compression @tab configurable @tab no @tab no @tab configurable @item exit @tab no @tab yes @tab yes @tab yes +@item bootlocation @tab no @tab partition @tab file @tab file (*) @end multitable @multitable @columnfractions .20 .20 .20 .20 .20 -@item @tab MIPS qemu @tab emu -@item video @tab no @tab yes -@item console charset @tab CP437 @tab Unicode (*) -@item network @tab no @tab yes -@item ATA/AHCI @tab yes @tab no -@item AT keyboard @tab yes @tab no -@item Speaker @tab no @tab no -@item USB @tab N/A @tab yes -@item chainloader @tab yes @tab no -@item cpuid @tab no @tab no -@item hints @tab guess @tab no -@item PCI @tab no @tab no -@item badram @tab yes (*) @tab no -@item compression @tab configurable @tab no -@item exit @tab no @tab yes +@item @tab MIPS qemu @tab emu @tab xen +@item video @tab no @tab yes @tab no +@item console charset @tab CP437 @tab Unicode (*) @tab ASCII +@item network @tab no @tab yes @tab no +@item ATA/AHCI @tab yes @tab no @tab no +@item AT keyboard @tab yes @tab no @tab no +@item Speaker @tab no @tab no @tab no +@item USB @tab N/A @tab yes @tab no +@item chainloader @tab yes @tab no @tab yes +@item cpuid @tab no @tab no @tab yes +@item hints @tab guess @tab no @tab no +@item PCI @tab no @tab no @tab no +@item badram @tab yes (*) @tab no @tab no +@item compression @tab configurable @tab no @tab no +@item exit @tab no @tab yes @tab no +@item bootlocation @tab no @tab file @tab no @end multitable @node Platform-specific operations From 76ce1de740f202985ffd7b2e980cf34c75a2dac3 Mon Sep 17 00:00:00 2001 From: Robert Elliott Date: Thu, 3 Dec 2015 11:38:36 -0600 Subject: [PATCH 563/722] Translate UEFI persistent memory type MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Define * GRUB_EFI_PERSISTENT_MEMORY (UEFI memory map type 14) per UEFI 2.5 * GRUB_MEMORY_PERSISTENT (E820 type 7) per ACPI 3.0 * GRUB_MEMORY_PERSISTENT_LEGACY (E820 unofficial type 12) per ACPI 3.0 and translate GRUB_EFI_PERSISTENT_MEMORY to GRUB_MEMORY_PERSISTENT in grub_efi_mmap_iterate(). Includes * adding the E820 names to lsmmap * handling the E820 types in make_efi_memtype() Suggested-by: Vladimir 'φ-coder/phcoder' Serbinenko Suggested-by: Andrei Borzenkov --- grub-core/commands/lsmmap.c | 2 ++ grub-core/mmap/efi/mmap.c | 12 ++++++++++++ include/grub/efi/api.h | 1 + include/grub/memory.h | 2 ++ 4 files changed, 17 insertions(+) diff --git a/grub-core/commands/lsmmap.c b/grub-core/commands/lsmmap.c index 4b504fd28..816ee47d1 100644 --- a/grub-core/commands/lsmmap.c +++ b/grub-core/commands/lsmmap.c @@ -37,6 +37,8 @@ static const char *names[] = is required to save accross hibernations. */ [GRUB_MEMORY_NVS] = N_("ACPI non-volatile storage RAM"), [GRUB_MEMORY_BADRAM] = N_("faulty RAM (BadRAM)"), + [GRUB_MEMORY_PERSISTENT] = N_("persistent RAM"), + [GRUB_MEMORY_PERSISTENT_LEGACY] = N_("persistent RAM (legacy)"), [GRUB_MEMORY_COREBOOT_TABLES] = N_("RAM holding coreboot tables"), [GRUB_MEMORY_CODE] = N_("RAM holding firmware code") }; diff --git a/grub-core/mmap/efi/mmap.c b/grub-core/mmap/efi/mmap.c index 900a4d659..bd495a184 100644 --- a/grub-core/mmap/efi/mmap.c +++ b/grub-core/mmap/efi/mmap.c @@ -118,6 +118,11 @@ grub_efi_mmap_iterate (grub_memory_hook_t hook, void *hook_data, GRUB_MEMORY_NVS, hook_data); break; + case GRUB_EFI_PERSISTENT_MEMORY: + hook (desc->physical_start, desc->num_pages * 4096, + GRUB_MEMORY_PERSISTENT, hook_data); + break; + default: grub_printf ("Unknown memory type %d, considering reserved\n", desc->type); @@ -147,6 +152,13 @@ make_efi_memtype (int type) /* No way to remove a chunk of memory from EFI mmap. So mark it as unusable. */ case GRUB_MEMORY_HOLE: + /* + * AllocatePages() does not support GRUB_EFI_PERSISTENT_MEMORY, + * so no translation for GRUB_MEMORY_PERSISTENT or + * GRUB_MEMORY_PERSISTENT_LEGACY. + */ + case GRUB_MEMORY_PERSISTENT: + case GRUB_MEMORY_PERSISTENT_LEGACY: case GRUB_MEMORY_RESERVED: return GRUB_EFI_UNUSABLE_MEMORY; diff --git a/include/grub/efi/api.h b/include/grub/efi/api.h index 24a05c5f6..2bbfe344c 100644 --- a/include/grub/efi/api.h +++ b/include/grub/efi/api.h @@ -476,6 +476,7 @@ enum grub_efi_memory_type GRUB_EFI_MEMORY_MAPPED_IO, GRUB_EFI_MEMORY_MAPPED_IO_PORT_SPACE, GRUB_EFI_PAL_CODE, + GRUB_EFI_PERSISTENT_MEMORY, GRUB_EFI_MAX_MEMORY_TYPE }; typedef enum grub_efi_memory_type grub_efi_memory_type_t; diff --git a/include/grub/memory.h b/include/grub/memory.h index 083cfb680..6da114a1b 100644 --- a/include/grub/memory.h +++ b/include/grub/memory.h @@ -30,6 +30,8 @@ typedef enum grub_memory_type GRUB_MEMORY_ACPI = 3, GRUB_MEMORY_NVS = 4, GRUB_MEMORY_BADRAM = 5, + GRUB_MEMORY_PERSISTENT = 7, + GRUB_MEMORY_PERSISTENT_LEGACY = 12, GRUB_MEMORY_COREBOOT_TABLES = 16, GRUB_MEMORY_CODE = 20, /* This one is special: it's used internally but is never reported From ff5726b878a485d36bab43898ee528b5a63d38b0 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Tue, 15 Dec 2015 10:41:01 +0300 Subject: [PATCH 564/722] NEWS: more additions Also-By: Robert Elliott --- NEWS | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/NEWS b/NEWS index 2db2f87a9..c9a975219 100644 --- a/NEWS +++ b/NEWS @@ -59,6 +59,7 @@ New in 2.02: * Command for inspecting coreboot tables (`lscoreboot'). * New target default_payload.elf. * Increased maximal core size. + * Prefer pmtimer for TSC calibration. * New/improved platform support: * New `efifwsetup' and `lsefi' commands on EFI platforms. @@ -89,6 +90,12 @@ New in 2.02: * New platform `none' which builds only user level utilities. This is now default if target CPU is not supported. * Support for booting little-endian Linux kernel on powerpc. + * Support network boot with Oracle sun4v vnet devices. + * Added SAS disks to the IEEE 1275 Open Firmware device list. + * Try multiple methods for TSC (timestamp counter) calibration - PIT, pmtimer, + EFI Stall. If everything fails, use hardcoded frequency 800MHz. + * Support Hyper-V Gen2 platforms which lack PIT for TSC calibration. + * Map UEFI Persistent Memory to E820 persistent memory. * Security: * Add optional facility to enforce that all files read by the core image @@ -152,6 +159,7 @@ New in 2.02: system. * emu libusb support removed (was broken and unmaintained). * powerpc64le compile support. + * Use fixed timestamp when generating GRUB image for reproducible builds. * Revision control moved to git. From 451d80e52d851432e109771bb8febafca7a5f1f2 Mon Sep 17 00:00:00 2001 From: Hector Marco-Gisbert Date: Wed, 16 Dec 2015 07:57:18 +0300 Subject: [PATCH 565/722] Fix security issue when reading username and password This patch fixes two integer underflows at: * grub-core/lib/crypto.c * grub-core/normal/auth.c CVE-2015-8370 Signed-off-by: Hector Marco-Gisbert Signed-off-by: Ismael Ripoll-Ripoll Also-By: Andrey Borzenkov --- grub-core/lib/crypto.c | 3 ++- grub-core/normal/auth.c | 7 +++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/grub-core/lib/crypto.c b/grub-core/lib/crypto.c index 010e550d1..683a8aaa7 100644 --- a/grub-core/lib/crypto.c +++ b/grub-core/lib/crypto.c @@ -470,7 +470,8 @@ grub_password_get (char buf[], unsigned buf_size) if (key == '\b') { - cur_len--; + if (cur_len) + cur_len--; continue; } diff --git a/grub-core/normal/auth.c b/grub-core/normal/auth.c index c6bd96e28..8615c48c3 100644 --- a/grub-core/normal/auth.c +++ b/grub-core/normal/auth.c @@ -174,8 +174,11 @@ grub_username_get (char buf[], unsigned buf_size) if (key == '\b') { - cur_len--; - grub_printf ("\b"); + if (cur_len) + { + cur_len--; + grub_printf ("\b"); + } continue; } From 7136b545c1f3a471766b34a38afd370d4b0915d8 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Wed, 16 Dec 2015 19:20:10 +0300 Subject: [PATCH 566/722] Erase backspaced character in grub_username_get It probably does not work across linefeed, but hopefully user names are not that long (and nobody is using terminal that small). --- grub-core/normal/auth.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/normal/auth.c b/grub-core/normal/auth.c index 8615c48c3..7338f8245 100644 --- a/grub-core/normal/auth.c +++ b/grub-core/normal/auth.c @@ -177,7 +177,7 @@ grub_username_get (char buf[], unsigned buf_size) if (cur_len) { cur_len--; - grub_printf ("\b"); + grub_printf ("\b \b"); } continue; } From 609c049dcc318fae3af1ba29f0ceb348172769f0 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Wed, 16 Dec 2015 21:20:30 +0300 Subject: [PATCH 567/722] kernel: print and reset grub_errno after each embedded config line Otherwise it causes subsequent file open to fail, because grub_file_open misinterprets set grub_errno for grub_file_get_device_name failure. Closes: 46540 --- grub-core/kern/parser.c | 1 + 1 file changed, 1 insertion(+) diff --git a/grub-core/kern/parser.c b/grub-core/kern/parser.c index b9bd12352..78175aac2 100644 --- a/grub-core/kern/parser.c +++ b/grub-core/kern/parser.c @@ -268,6 +268,7 @@ grub_parser_execute (char *source) grub_parser_execute_getline (&line, 0, &source); grub_rescue_parse_line (line, grub_parser_execute_getline, &source); grub_free (line); + grub_print_error (); } return grub_errno; From c79c59f1295df8ea660f8a858f9532d76a5f67b7 Mon Sep 17 00:00:00 2001 From: Robert Elliott Date: Thu, 17 Dec 2015 10:53:32 -0600 Subject: [PATCH 568/722] lsefimmap: support persistent memory and other UEFI 2.5 features This should accompany 76ce1de740 Translate UEFI persistent memory type 1. Add a string for the EfiPersistentMemory type 14 that was added in UEFI 2.5. 2. Decode the memory attributes that were added in UEFI 2.5: * NV (non-volatile) * MORE_RELIABLE (higher reliable, e.g., mirrored memory in a system with partial memory mirroring) * RO (read-only) 3. Use proper IEC binary units (KiB, MiB, etc.) for power-of-two values rather than misusing SI power-of-ten units (KB, MB, etc.) 4. The lsmmap command only decodes memory ranges sizes up to GiB scale units. Persistent memory ranges will reach into the TiB scale. Since 64-bit size field supports TiB, PiB, and EiB, decode all of them for completeness. 5. In the lsefimmap command, rewrite the print statements to * avoid rounding * avoid a big nested if/else tree. For example: In the sixth entry below, the value of 309MB implies 316416KB but is really reporting 316436KB. Widen the size column to 6 digits to accommodate typical cases. The worst case value would require 14 digits; if that happens, let the columns get out of sync. Old format: Type Physical start - end #Pages Size Attributes conv-mem 0000000000000000-0000000000092fff 00000093 588KB UC WC WT WB reserved 0000000000093000-0000000000093fff 00000001 4KB UC WC WT WB conv-mem 0000000000094000-000000000009ffff 0000000c 48KB UC WC WT WB conv-mem 0000000000100000-000000000fffffff 0000ff00 255MB UC WC WT WB BS-code 0000000010000000-0000000010048fff 00000049 292KB UC WC WT WB conv-mem 0000000010049000-000000002354dfff 00013505 309MB UC WC WT WB ldr-data 000000002354e000-000000003ecfffff 0001b7b2 439MB UC WC WT WB BS-data 000000003ed00000-000000003ed7ffff 00000080 512KB UC WC WT WB conv-mem 000000003ed80000-000000006af5ffff 0002c1e0 705MB UC WC WT WB reserved 000000006af60000-000000006b55ffff 00000600 6MB UC WC WT WB BS-data 000000006b560000-000000006b560fff 00000001 4KB UC WC WT WB RT-data 000000006b561000-000000006b5e1fff 00000081 516KB RT UC WC WT WB BS-data 000000006b5e2000-000000006ecfafff 00003719 55MB UC WC WT WB BS-code 000000006ecfb000-000000006ecfbfff 00000001 4KB UC WC WT WB conv-mem 000000006ecfc000-00000000711fafff 000024ff 36MB UC WC WT WB BS-data 00000000711fb000-000000007128dfff 00000093 588KB UC WC WT WB Unk 0d 0000000880000000-0000000e7fffffff 00600000 24GB UC WC WT WB NV reserved 0000001680000000-0000001c7fffffff 00600000 24GB UC WC WT WB NV New format: Type Physical start - end #Pages Size Attributes conv-mem 0000000000000000-0000000000092fff 00000093 588KiB UC WC WT WB reserved 0000000000093000-0000000000093fff 00000001 4KiB UC WC WT WB conv-mem 0000000000094000-000000000009ffff 0000000c 48KiB UC WC WT WB conv-mem 0000000000100000-000000000fffffff 0000ff00 255MiB UC WC WT WB BS-code 0000000010000000-0000000010048fff 00000049 292KiB UC WC WT WB conv-mem 0000000010049000-000000002354dfff 00013505 316436KiB UC WC WT WB ldr-data 000000002354e000-000000003ecfffff 0001b7b2 450248KiB UC WC WT WB BS-data 000000003ed00000-000000003ed7ffff 00000080 512KiB UC WC WT WB conv-mem 000000003ed80000-000000006af5ffff 0002c1e0 722816KiB UC WC WT WB reserved 000000006af60000-000000006b55ffff 00000600 6MiB UC WC WT WB BS-data 000000006b560000-000000006b560fff 00000001 4KiB UC WC WT WB RT-data 000000006b561000-000000006b5e1fff 00000081 516KiB RT UC WC WT WB BS-data 000000006b5e2000-000000006ecfafff 00003719 56420KiB UC WC WT WB BS-code 000000006ecfb000-000000006ecfbfff 00000001 4KiB UC WC WT WB conv-mem 000000006ecfc000-0000000071222fff 00002527 38044KiB UC WC WT WB BS-data 0000000071223000-00000000712ddfff 000000bb 748KiB UC WC WT WB persist 0000000880000000-0000000e7fffffff 00600000 24GiB UC WC WT WB NV reserved 0000001680000000-0000001c7fffffff 00600000 24GiB UC WC WT WB NV --- grub-core/commands/efi/lsefimmap.c | 47 ++++++++++++++++++++---------- include/grub/efi/api.h | 3 ++ 2 files changed, 34 insertions(+), 16 deletions(-) diff --git a/grub-core/commands/efi/lsefimmap.c b/grub-core/commands/efi/lsefimmap.c index 215b45bff..c85ff7f36 100644 --- a/grub-core/commands/efi/lsefimmap.c +++ b/grub-core/commands/efi/lsefimmap.c @@ -51,7 +51,7 @@ grub_cmd_lsefimmap (grub_command_t cmd __attribute__ ((unused)), grub_printf ("Type Physical start - end #Pages " - " Size Attributes\n"); + " Size Attributes\n"); memory_map_end = ADD_MEMORY_DESCRIPTOR (memory_map, map_size); for (desc = memory_map; desc < memory_map_end; @@ -74,7 +74,8 @@ grub_cmd_lsefimmap (grub_command_t cmd __attribute__ ((unused)), "ACPI-nvs", "MMIO ", "IO-ports", - "PAL-code" + "PAL-code", + "persist ", }; if (desc->type < ARRAY_SIZE (types_str)) grub_printf ("%s ", types_str[desc->type]); @@ -87,21 +88,29 @@ grub_cmd_lsefimmap (grub_command_t cmd __attribute__ ((unused)), desc->physical_start + (desc->num_pages << 12) - 1, desc->num_pages); - size = desc->num_pages; - size <<= (12 - 10); - if (size < 1024) - grub_printf (" %4" PRIuGRUB_UINT64_T "KB", size); + size = desc->num_pages << 12; /* 4 KiB page size */ + /* + * Since size is a multiple of 4 KiB, no need to handle units + * of just Bytes (which would use a mask of 0x3ff). + * + * 14 characters would support the largest possible number of 4 KiB + * pages that are not a multiple of larger units (e.g., MiB): + * 17592186044415 (0xffffff_fffff000), but that uses a lot of + * whitespace for a rare case. 6 characters usually suffices; + * columns will be off if not, but this is preferable to rounding. + */ + if (size & 0xfffff) + grub_printf (" %6" PRIuGRUB_UINT64_T "KiB", size >> 10); + else if (size & 0x3fffffff) + grub_printf (" %6" PRIuGRUB_UINT64_T "MiB", size >> 20); + else if (size & 0xffffffffff) + grub_printf (" %6" PRIuGRUB_UINT64_T "GiB", size >> 30); + else if (size & 0x3ffffffffffff) + grub_printf (" %6" PRIuGRUB_UINT64_T "TiB", size >> 40); + else if (size & 0xfffffffffffffff) + grub_printf (" %6" PRIuGRUB_UINT64_T "PiB", size >> 50); else - { - size /= 1024; - if (size < 1024) - grub_printf (" %4" PRIuGRUB_UINT64_T "MB", size); - else - { - size /= 1024; - grub_printf (" %4" PRIuGRUB_UINT64_T "GB", size); - } - } + grub_printf (" %6" PRIuGRUB_UINT64_T "EiB", size >> 60); attr = desc->attribute; if (attr & GRUB_EFI_MEMORY_RUNTIME) @@ -122,6 +131,12 @@ grub_cmd_lsefimmap (grub_command_t cmd __attribute__ ((unused)), grub_printf (" RP"); if (attr & GRUB_EFI_MEMORY_XP) grub_printf (" XP"); + if (attr & GRUB_EFI_MEMORY_NV) + grub_printf (" NV"); + if (attr & GRUB_EFI_MEMORY_MORE_RELIABLE) + grub_printf (" MR"); + if (attr & GRUB_EFI_MEMORY_RO) + grub_printf (" RO"); grub_printf ("\n"); } diff --git a/include/grub/efi/api.h b/include/grub/efi/api.h index 2bbfe344c..c7c9f0e1d 100644 --- a/include/grub/efi/api.h +++ b/include/grub/efi/api.h @@ -49,6 +49,9 @@ #define GRUB_EFI_MEMORY_WP 0x0000000000001000LL #define GRUB_EFI_MEMORY_RP 0x0000000000002000LL #define GRUB_EFI_MEMORY_XP 0x0000000000004000LL +#define GRUB_EFI_MEMORY_NV 0x0000000000008000LL +#define GRUB_EFI_MEMORY_MORE_RELIABLE 0x0000000000010000LL +#define GRUB_EFI_MEMORY_RO 0x0000000000020000LL #define GRUB_EFI_MEMORY_RUNTIME 0x8000000000000000LL #define GRUB_EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL 0x00000001 From a9399f2e1e5819fdd9bd2a4d35d32420dd6cc679 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sat, 19 Dec 2015 11:32:26 +0300 Subject: [PATCH 569/722] windows: correct LBA in generated EFI HDD media paths GRUB keeps partition offset and size in units of 512B sectors. Media paths are defined in terms of LBA which are presumed to match HDD sector size. This is probably cosmetic (EFI requires that partition is searched by GUID) and still incorrect if GPT was created using different logical block size. But current code is obviously wrong and new has better chances to be correct. --- grub-core/osdep/windows/platform.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/grub-core/osdep/windows/platform.c b/grub-core/osdep/windows/platform.c index d217efe17..912269191 100644 --- a/grub-core/osdep/windows/platform.c +++ b/grub-core/osdep/windows/platform.c @@ -370,9 +370,9 @@ grub_install_register_efi (grub_device_t efidir_grub_dev, } hddp->partition_start = grub_partition_get_start (efidir_grub_dev->disk->partition) - << (efidir_grub_dev->disk->log_sector_size - GRUB_DISK_SECTOR_BITS); + >> (efidir_grub_dev->disk->log_sector_size - GRUB_DISK_SECTOR_BITS); hddp->partition_size = grub_disk_get_size (efidir_grub_dev->disk) - << (efidir_grub_dev->disk->log_sector_size - GRUB_DISK_SECTOR_BITS); + >> (efidir_grub_dev->disk->log_sector_size - GRUB_DISK_SECTOR_BITS); pathptr = hddp + 1; filep = pathptr; From 3bca85b4184f74995a7cc2791e432173fde26d34 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sat, 26 Dec 2015 21:45:22 +0300 Subject: [PATCH 570/722] devmapper: check for valid device abstraction in get_grub_dev This was lost when code was refactored. Patch restores previous behavior. It is still not clear whether this is the right one. Due to the way we detect DM abstraction, partitions on DM are skipped, we fall through to generic detection which ends up in assuming parent device is BIOS disk. It is useful to install GRUB on VM disk from the host. But it also means that GRUB will mistakenly allow install on real system as well. For now let's fix regression; future behavior needs to be discussed. Closes: 45163 --- grub-core/osdep/devmapper/getroot.c | 33 +++++++++++++++++------------ grub-core/osdep/linux/getroot.c | 2 +- 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/grub-core/osdep/devmapper/getroot.c b/grub-core/osdep/devmapper/getroot.c index 64419f678..05eda500a 100644 --- a/grub-core/osdep/devmapper/getroot.c +++ b/grub-core/osdep/devmapper/getroot.c @@ -223,11 +223,14 @@ grub_util_get_devmapper_grub_dev (const char *os_dev) uuid = get_dm_uuid (os_dev); if (!uuid) return NULL; - - if (strncmp (uuid, "LVM-", sizeof ("LVM-") - 1) == 0) + + switch (grub_util_get_dev_abstraction (os_dev)) { + case GRUB_DEV_ABSTRACTION_LVM: + { unsigned i; int dashes[] = { 0, 6, 10, 14, 18, 22, 26, 32, 38, 42, 46, 50, 54, 58}; + grub_dev = xmalloc (grub_strlen (uuid) + 40); optr = grub_stpcpy (grub_dev, "lvmid/"); for (i = 0; i < ARRAY_SIZE (dashes) - 1; i++) @@ -245,19 +248,23 @@ grub_util_get_devmapper_grub_dev (const char *os_dev) return grub_dev; } - if (strncmp (uuid, "CRYPT-LUKS1-", sizeof ("CRYPT-LUKS1-") - 1) == 0) - { - char *dash; - dash = grub_strchr (uuid + sizeof ("CRYPT-LUKS1-") - 1, '-'); - if (dash) - *dash = 0; - grub_dev = grub_xasprintf ("cryptouuid/%s", - uuid + sizeof ("CRYPT-LUKS1-") - 1); + case GRUB_DEV_ABSTRACTION_LUKS: + { + char *dash; + + dash = grub_strchr (uuid + sizeof ("CRYPT-LUKS1-") - 1, '-'); + if (dash) + *dash = 0; + grub_dev = grub_xasprintf ("cryptouuid/%s", + uuid + sizeof ("CRYPT-LUKS1-") - 1); + grub_free (uuid); + return grub_dev; + } + + default: grub_free (uuid); - return grub_dev; + return NULL; } - grub_free (uuid); - return NULL; } char * diff --git a/grub-core/osdep/linux/getroot.c b/grub-core/osdep/linux/getroot.c index 3978c7114..10480b646 100644 --- a/grub-core/osdep/linux/getroot.c +++ b/grub-core/osdep/linux/getroot.c @@ -1075,7 +1075,7 @@ grub_util_get_grub_dev_os (const char *os_dev) switch (grub_util_get_dev_abstraction (os_dev)) { /* Fallback for non-devmapper build. In devmapper-builds LVM is handled - in rub_util_get_devmapper_grub_dev and this point isn't reached. + in grub_util_get_devmapper_grub_dev and this point isn't reached. */ case GRUB_DEV_ABSTRACTION_LVM: { From ca7bb46d5c3b8c3db6577f1f7d5cdc8d0e104264 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Tue, 29 Dec 2015 17:42:25 +0100 Subject: [PATCH 571/722] exfat: Fix stream extension flag parsing. --- grub-core/fs/fat.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/fs/fat.c b/grub-core/fs/fat.c index aa2145cf2..635c2c425 100644 --- a/grub-core/fs/fat.c +++ b/grub-core/fs/fat.c @@ -681,7 +681,7 @@ grub_fat_iterate_dir_next (grub_fshelp_node_t node, ctxt->dir.file_size = grub_cpu_to_le64 (sec.type_specific.stream_extension.file_size); ctxt->dir.have_stream = 1; - ctxt->dir.is_contiguous = !!(dir.type_specific.stream_extension.flags + ctxt->dir.is_contiguous = !!(sec.type_specific.stream_extension.flags & grub_cpu_to_le16_compile_time (FLAG_CONTIGUOUS)); break; case 0xc1: From 4111882828597cbf68ae6f9429b68d0210dc2d41 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Tue, 29 Dec 2015 17:43:05 +0100 Subject: [PATCH 572/722] grub-mount: Fix oath parsing. Brackets detection was copied from somewhere else and makes no sense in case of grub-mount and prevents user from accessing and files with ) in them. --- util/grub-mount.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/util/grub-mount.c b/util/grub-mount.c index 0d0fea5f2..aca5f82e3 100644 --- a/util/grub-mount.c +++ b/util/grub-mount.c @@ -151,7 +151,6 @@ fuse_getattr (const char *path, struct stat *st) { struct fuse_getattr_ctx ctx; char *pathname, *path2; - const char *pathname_t; if (path[0] == '/' && path[1] == 0) { @@ -170,12 +169,7 @@ fuse_getattr (const char *path, struct stat *st) ctx.file_exists = 0; - pathname_t = grub_strchr (path, ')'); - if (! pathname_t) - pathname_t = path; - else - pathname_t++; - pathname = xstrdup (pathname_t); + pathname = xstrdup (path); /* Remove trailing '/'. */ while (*pathname && pathname[grub_strlen (pathname) - 1] == '/') From dbab354157fed01841317ae0927cbccc622c3c03 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Tue, 29 Dec 2015 17:48:34 +0100 Subject: [PATCH 573/722] grub-mkrescue: Delete temporary file Reported by: Thomas Schmitt --- util/grub-mkrescue.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/util/grub-mkrescue.c b/util/grub-mkrescue.c index 451182647..da0dc021a 100644 --- a/util/grub-mkrescue.c +++ b/util/grub-mkrescue.c @@ -310,6 +310,7 @@ make_image_fwdisk_abs (enum grub_install_plat plat, grub_install_make_image_wrap (source_dirs[plat], "()/boot/grub", output, 0, load_cfg, mkimage_target, 0); grub_install_pop_module (); + grub_util_unlink (load_cfg); } static int @@ -647,6 +648,7 @@ main (int argc, char *argv[]) } grub_install_pop_module (); grub_install_pop_module (); + grub_util_unlink (load_cfg); } /** build multiboot core.img */ From 93ecc3f1f8372e43101301866eea87aa9257a9e0 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Wed, 30 Dec 2015 06:20:51 +0300 Subject: [PATCH 574/722] menu: fix line count calculation for long lines It gave one extra screen line if length was exactly equal to screen width. Reported by Michael Chang. Also-By: Michael Chang --- grub-core/normal/menu_entry.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/grub-core/normal/menu_entry.c b/grub-core/normal/menu_entry.c index 62c7e1627..2b732250d 100644 --- a/grub-core/normal/menu_entry.c +++ b/grub-core/normal/menu_entry.c @@ -126,9 +126,13 @@ ensure_space (struct line *linep, int extra) static int get_logical_num_lines (struct line *linep, struct per_term_screen *term_screen) { - return (grub_getstringwidth (linep->buf, linep->buf + linep->len, - term_screen->term) - / (unsigned) term_screen->geo.entry_width) + 1; + grub_size_t width = grub_getstringwidth (linep->buf, linep->buf + linep->len, + term_screen->term); + + /* Empty line still consumes space on screen */ + return width ? (width + (unsigned) term_screen->geo.entry_width - 1) / + (unsigned) term_screen->geo.entry_width + : 1; } static void From 79cfad6fbeafcfa9b8a664643024e897123927c7 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Wed, 30 Dec 2015 18:19:44 +0100 Subject: [PATCH 575/722] backtrace: Remove assembly assumption that grub_backtrace_pointer is under 4G --- grub-core/lib/i386/backtrace.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/grub-core/lib/i386/backtrace.c b/grub-core/lib/i386/backtrace.c index 7a7796a12..d76a46a23 100644 --- a/grub-core/lib/i386/backtrace.c +++ b/grub-core/lib/i386/backtrace.c @@ -56,11 +56,11 @@ void grub_backtrace (void) { #ifdef __x86_64__ - asm volatile ("movq %rbp, %rdi\n" - "call " EXT_C("grub_backtrace_pointer")); + asm volatile ("movq %%rbp, %%rdi\n" + "call %%rax": :"a"(grub_backtrace_pointer)); #else - asm volatile ("movl %ebp, %eax\n" - "call " EXT_C("grub_backtrace_pointer")); + asm volatile ("movl %%ebp, %%eax\n" + "call %%ecx": :"c"(grub_backtrace_pointer)); #endif } From 2333a83baa3caf7efb0c6b94f0d9f9914682cf87 Mon Sep 17 00:00:00 2001 From: Andrey Borzenkov Date: Wed, 30 Dec 2015 22:30:16 +0300 Subject: [PATCH 576/722] 30_os-prober: derive --class from os-prober generated label Currently only Windows gets distinguished icons, everything else is displayed using the same generic one. Add additional --class based on os-prober returned label, which usually is expected to match primary distribution name. Also use it for Windows as well - chainloader prober may actually return different strings (Windows, MS-DOS, Windows9xME). --- util/grub.d/30_os-prober.in | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/util/grub.d/30_os-prober.in b/util/grub.d/30_os-prober.in index 5fc4f0c83..5604ce2b6 100644 --- a/util/grub.d/30_os-prober.in +++ b/util/grub.d/30_os-prober.in @@ -135,6 +135,9 @@ for OS in ${OSPROBED} ; do LONGNAME="${LABEL}" fi + # os-prober returns text string followed by optional counter + CLASS="--class $(echo "${LABEL}" | LC_ALL=C sed 's,[[:digit:]]*$,,' | cut -d' ' -f1 | tr 'A-Z' 'a-z' | LC_ALL=C sed 's,[^[:alnum:]_],_,g')" + gettext_printf "Found %s on %s\n" "${LONGNAME}" "${DEVICE}" >&2 case ${BOOT} in @@ -142,7 +145,7 @@ for OS in ${OSPROBED} ; do onstr="$(gettext_printf "(on %s)" "${DEVICE}")" cat << EOF -menuentry '$(echo "${LONGNAME} $onstr" | grub_quote)' --class windows --class os \$menuentry_id_option 'osprober-chain-$(grub_get_device_id "${DEVICE}")' { +menuentry '$(echo "${LONGNAME} $onstr" | grub_quote)' $CLASS --class os \$menuentry_id_option 'osprober-chain-$(grub_get_device_id "${DEVICE}")' { EOF save_default_entry | grub_add_tab prepare_grub_to_access_device ${DEVICE} | grub_add_tab @@ -174,7 +177,7 @@ EOF DEVICE=${DEVICE%@*} onstr="$(gettext_printf "(on %s)" "${DEVICE}")" cat << EOF -menuentry '$(echo "${LONGNAME} $onstr" | grub_quote)' --class windows --class os \$menuentry_id_option 'osprober-efi-$(grub_get_device_id "${DEVICE}")' { +menuentry '$(echo "${LONGNAME} $onstr" | grub_quote)' $CLASS --class os \$menuentry_id_option 'osprober-efi-$(grub_get_device_id "${DEVICE}")' { EOF save_default_entry | sed -e "s/^/\t/" prepare_grub_to_access_device ${DEVICE} | sed -e "s/^/\t/" @@ -230,7 +233,7 @@ EOF if [ "x$is_top_level" = xtrue ] && [ "x${GRUB_DISABLE_SUBMENU}" != xy ]; then cat << EOF -menuentry '$(echo "$OS $onstr" | grub_quote)' --class gnu-linux --class gnu --class os \$menuentry_id_option 'osprober-gnulinux-simple-$boot_device_id' { +menuentry '$(echo "$OS $onstr" | grub_quote)' $CLASS --class gnu-linux --class gnu --class os \$menuentry_id_option 'osprober-gnulinux-simple-$boot_device_id' { EOF save_default_entry | grub_add_tab printf '%s\n' "${prepare_boot_cache}" From 5919626c907a2d141bfeffa4ec04d71e521fbbaa Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Thu, 31 Dec 2015 13:07:16 +0100 Subject: [PATCH 577/722] sparc64: Fix assembly to let compiler to fill in memory references. This fixes the use of not fully relocatable (they assume that variables are under 4G limit in virtual memory) references. --- grub-core/loader/sparc64/ieee1275/linux.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/grub-core/loader/sparc64/ieee1275/linux.c b/grub-core/loader/sparc64/ieee1275/linux.c index 346d9538e..d44d7a113 100644 --- a/grub-core/loader/sparc64/ieee1275/linux.c +++ b/grub-core/loader/sparc64/ieee1275/linux.c @@ -140,17 +140,17 @@ grub_linux_boot (void) grub_dprintf ("loader", "Jumping to Linux...\n"); /* Boot the kernel. */ - asm volatile ("sethi %hi(grub_ieee1275_entry_fn), %o1\n" - "ldx [%o1 + %lo(grub_ieee1275_entry_fn)], %o4\n" - "sethi %hi(grub_ieee1275_original_stack), %o1\n" - "ldx [%o1 + %lo(grub_ieee1275_original_stack)], %o6\n" - "sethi %hi(linux_addr), %o1\n" - "ldx [%o1 + %lo(linux_addr)], %o5\n" - "mov %g0, %o0\n" - "mov %g0, %o2\n" - "mov %g0, %o3\n" - "jmp %o5\n" - "mov %g0, %o1\n"); + asm volatile ("ldx %0, %%o4\n" + "ldx %1, %%o6\n" + "ldx %2, %%o5\n" + "mov %%g0, %%o0\n" + "mov %%g0, %%o2\n" + "mov %%g0, %%o3\n" + "jmp %%o5\n" + "mov %%g0, %%o1\n": : + "m"(grub_ieee1275_entry_fn), + "m"(grub_ieee1275_original_stack), + "m"(linux_addr)); return GRUB_ERR_NONE; } From a7cf8b1e235fbbc8a460510615c7ff85f21c2d05 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Thu, 31 Dec 2015 13:09:15 +0100 Subject: [PATCH 578/722] Verify modules on build-time rather than failing in runtime. --- grub-core/Makefile.am | 6 +- grub-core/genmod.sh.in | 5 +- include/grub/module_verifier.h | 19 ++ util/grub-module-verifier.c | 122 +++++++++++++ util/grub-module-verifier32.c | 2 + util/grub-module-verifier64.c | 2 + util/grub-module-verifierXX.c | 315 +++++++++++++++++++++++++++++++++ 7 files changed, 468 insertions(+), 3 deletions(-) create mode 100644 include/grub/module_verifier.h create mode 100644 util/grub-module-verifier.c create mode 100644 util/grub-module-verifier32.c create mode 100644 util/grub-module-verifier64.c create mode 100644 util/grub-module-verifierXX.c diff --git a/grub-core/Makefile.am b/grub-core/Makefile.am index c671aed4b..508e86bcd 100644 --- a/grub-core/Makefile.am +++ b/grub-core/Makefile.am @@ -39,6 +39,10 @@ gentrigtables$(BUILD_EXEEXT): gentrigtables.c $(BUILD_CC) -o $@ -I$(top_srcdir)/include $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) $(BUILD_LDFLAGS) $< $(BUILD_LIBM) CLEANFILES += gentrigtables$(BUILD_EXEEXT) +build-grub-module-verifier$(BUILD_EXEEXT): $(top_srcdir)/util/grub-module-verifier.c $(top_srcdir)/util/grub-module-verifier32.c $(top_srcdir)/util/grub-module-verifier64.c $(top_srcdir)/grub-core/kern/emu/misc.c $(top_srcdir)/util/misc.c + $(BUILD_CC) -o $@ -I$(top_srcdir)/include $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) $(BUILD_LDFLAGS) -DGRUB_BUILD=1 -DGRUB_UTIL=1 -DGRUB_BUILD_PROGRAM_NAME=\"build-grub-module-verifier\" $^ +CLEANFILES += build-grub-module-verifier$(BUILD_EXEEXT) + # trigtables.c trigtables.c: gentrigtables$(BUILD_EXEEXT) gentrigtables.c $(top_srcdir)/configure.ac ./gentrigtables$(BUILD_EXEEXT) > $@ @@ -390,7 +394,7 @@ moddep.lst: syminfo.lst genmoddep.awk video.lst platform_DATA += moddep.lst CLEANFILES += config.log syminfo.lst moddep.lst -$(MOD_FILES): %.mod : genmod.sh moddep.lst %.module$(EXEEXT) +$(MOD_FILES): %.mod : genmod.sh moddep.lst %.module$(EXEEXT) build-grub-module-verifier TARGET_OBJ2ELF=@TARGET_OBJ2ELF@ sh $^ $@ platform_DATA += $(MOD_FILES) platform_DATA += modinfo.sh diff --git a/grub-core/genmod.sh.in b/grub-core/genmod.sh.in index 789732b10..7dcafd9d3 100644 --- a/grub-core/genmod.sh.in +++ b/grub-core/genmod.sh.in @@ -15,12 +15,12 @@ set -e # # Example: # -# genmod.sh moddep.lst normal.module normal.mod +# genmod.sh moddep.lst normal.module build-grub-module-verifier normal.mod # moddep=$1 infile=$2 -outfile=$3 +outfile=$4 tmpfile=${outfile}.tmp modname=`echo $infile | sed -e 's@\.module.*$@@'` @@ -93,4 +93,5 @@ else -wd1106 -nu -nd $tmpfile.bin $tmpfile || exit 1 rm -f $name.bin fi +./build-grub-module-verifier $tmpfile @target_cpu@ mv $tmpfile $outfile diff --git a/include/grub/module_verifier.h b/include/grub/module_verifier.h new file mode 100644 index 000000000..9e3a2ba72 --- /dev/null +++ b/include/grub/module_verifier.h @@ -0,0 +1,19 @@ +#include +#include + +#include + +#define GRUB_MODULE_VERIFY_SUPPORTS_REL 1 +#define GRUB_MODULE_VERIFY_SUPPORTS_RELA 2 + +struct grub_module_verifier_arch { + const char *name; + int voidp_sizeof; + int bigendian; + int machine; + int flags; + const int *supported_relocations; +}; + +void grub_module_verify64(void *module_img, size_t module_size, const struct grub_module_verifier_arch *arch); +void grub_module_verify32(void *module_img, size_t module_size, const struct grub_module_verifier_arch *arch); diff --git a/util/grub-module-verifier.c b/util/grub-module-verifier.c new file mode 100644 index 000000000..d2d698403 --- /dev/null +++ b/util/grub-module-verifier.c @@ -0,0 +1,122 @@ +#include +#include + +#include +#include +#include +#include + +struct grub_module_verifier_arch archs[] = { + { "i386", 4, 0, EM_386, GRUB_MODULE_VERIFY_SUPPORTS_REL, (int[]){ + R_386_32, + R_386_PC32, + -1 + } }, + { "x86_64", 8, 0, EM_X86_64, GRUB_MODULE_VERIFY_SUPPORTS_RELA, (int[]){ + R_X86_64_64, + R_X86_64_PC64, + /* R_X86_64_32, R_X86_64_32S, R_X86_64_PC32 are supported but shouldn't be used because of their limited range. */ + -1 + } }, + { "powerpc", 4, 1, EM_PPC, GRUB_MODULE_VERIFY_SUPPORTS_RELA, (int[]){ + GRUB_ELF_R_PPC_ADDR16_LO, + GRUB_ELF_R_PPC_REL24, /* It has limited range but GRUB adds trampolines when necessarry. */ + GRUB_ELF_R_PPC_ADDR16_HA, + GRUB_ELF_R_PPC_ADDR32, + GRUB_ELF_R_PPC_REL32, + -1 + } }, + { "sparc64", 8, 1, EM_SPARCV9, GRUB_MODULE_VERIFY_SUPPORTS_RELA, (int[]){ + R_SPARC_WDISP30, /* It has limited range but GRUB adds trampolines when necessarry. */ + R_SPARC_HH22, + R_SPARC_HM10, + R_SPARC_LM22, + R_SPARC_LO10, + R_SPARC_64, + R_SPARC_OLO10, + /* R_SPARC_32, R_SPARC_HI22 are supported but shouldn't be used because of their limited range. */ + -1 + } }, + { "ia64", 8, 0, EM_IA_64, GRUB_MODULE_VERIFY_SUPPORTS_RELA, (int[]){ + R_IA64_PCREL21B, /* We should verify that it's pointing either + to a function or to a section in the same module. */ + R_IA64_SEGREL64LSB, + R_IA64_FPTR64LSB, + R_IA64_DIR64LSB, + R_IA64_PCREL64LSB, + R_IA64_GPREL22, /* We should verify that it's pointing to a section in the same module. */ + R_IA64_LTOFF22X, + R_IA64_LTOFF22, + R_IA64_LTOFF_FPTR22, + R_IA64_LDXMOV, + -1 + } }, + { "mipsel", 4, 0, EM_MIPS, GRUB_MODULE_VERIFY_SUPPORTS_REL | GRUB_MODULE_VERIFY_SUPPORTS_RELA, (int[]){ + R_MIPS_HI16, + R_MIPS_LO16, + R_MIPS_32, + R_MIPS_GPREL32, + R_MIPS_26, + R_MIPS_GOT16, + R_MIPS_CALL16, + R_MIPS_JALR, + -1 + } }, + { "mips", 4, 1, EM_MIPS, GRUB_MODULE_VERIFY_SUPPORTS_REL | GRUB_MODULE_VERIFY_SUPPORTS_RELA, (int[]){ + R_MIPS_HI16, + R_MIPS_LO16, + R_MIPS_32, + R_MIPS_GPREL32, + R_MIPS_26, + R_MIPS_GOT16, + R_MIPS_CALL16, + R_MIPS_JALR, + -1 + } }, + { "arm", 4, 0, EM_ARM, GRUB_MODULE_VERIFY_SUPPORTS_REL, (int[]){ + /* Some relocations are range-limited but trampolines are added when necessarry. */ + R_ARM_ABS32, + R_ARM_CALL, + R_ARM_JUMP24, + R_ARM_THM_CALL, + R_ARM_THM_JUMP24, + R_ARM_V4BX, + R_ARM_THM_MOVW_ABS_NC, + R_ARM_THM_MOVT_ABS, + R_ARM_THM_JUMP19, + -1 + } }, + { "arm64", 8, 0, EM_AARCH64, GRUB_MODULE_VERIFY_SUPPORTS_REL | GRUB_MODULE_VERIFY_SUPPORTS_RELA, (int[]){ + R_AARCH64_ABS64, + R_AARCH64_CALL26, + R_AARCH64_JUMP26, + -1 + } }, +}; + + +int +main (int argc, char **argv) +{ + size_t module_size; + unsigned arch; + char *module_img; + if (argc != 3) { + fprintf (stderr, "usage: %s FILE ARCH\n", argv[0]); + return 1; + } + + for (arch = 0; arch < ARRAY_SIZE(archs); arch++) + if (strcmp(archs[arch].name, argv[2]) == 0) + break; + if (arch == ARRAY_SIZE(archs)) + grub_util_error("unknown arch: %s", argv[2]); + + module_size = grub_util_get_image_size (argv[1]); + module_img = grub_util_read_image (argv[1]); + if (archs[arch].voidp_sizeof == 8) + grub_module_verify64(module_img, module_size, &archs[arch]); + else + grub_module_verify32(module_img, module_size, &archs[arch]); + return 0; +} diff --git a/util/grub-module-verifier32.c b/util/grub-module-verifier32.c new file mode 100644 index 000000000..257229f8f --- /dev/null +++ b/util/grub-module-verifier32.c @@ -0,0 +1,2 @@ +#define MODULEVERIFIER_ELF32 1 +#include "grub-module-verifierXX.c" diff --git a/util/grub-module-verifier64.c b/util/grub-module-verifier64.c new file mode 100644 index 000000000..4db6b4bed --- /dev/null +++ b/util/grub-module-verifier64.c @@ -0,0 +1,2 @@ +#define MODULEVERIFIER_ELF64 1 +#include "grub-module-verifierXX.c" diff --git a/util/grub-module-verifierXX.c b/util/grub-module-verifierXX.c new file mode 100644 index 000000000..904be27d3 --- /dev/null +++ b/util/grub-module-verifierXX.c @@ -0,0 +1,315 @@ +#include + +#include +#include +#include + +#if defined(MODULEVERIFIER_ELF32) +# define SUFFIX(x) x ## 32 +# define ELFCLASSXX ELFCLASS32 +# define Elf_Ehdr Elf32_Ehdr +# define Elf_Phdr Elf32_Phdr +# define Elf_Nhdr Elf32_Nhdr +# define Elf_Addr Elf32_Addr +# define Elf_Sym Elf32_Sym +# define Elf_Off Elf32_Off +# define Elf_Shdr Elf32_Shdr +# define Elf_Rela Elf32_Rela +# define Elf_Rel Elf32_Rel +# define Elf_Word Elf32_Word +# define Elf_Half Elf32_Half +# define Elf_Section Elf32_Section +# define ELF_R_SYM(val) ELF32_R_SYM(val) +# define ELF_R_TYPE(val) ELF32_R_TYPE(val) +# define ELF_ST_TYPE(val) ELF32_ST_TYPE(val) +#elif defined(MODULEVERIFIER_ELF64) +# define SUFFIX(x) x ## 64 +# define ELFCLASSXX ELFCLASS64 +# define Elf_Ehdr Elf64_Ehdr +# define Elf_Phdr Elf64_Phdr +# define Elf_Nhdr Elf64_Nhdr +# define Elf_Addr Elf64_Addr +# define Elf_Sym Elf64_Sym +# define Elf_Off Elf64_Off +# define Elf_Shdr Elf64_Shdr +# define Elf_Rela Elf64_Rela +# define Elf_Rel Elf64_Rel +# define Elf_Word Elf64_Word +# define Elf_Half Elf64_Half +# define Elf_Section Elf64_Section +# define ELF_R_SYM(val) ELF64_R_SYM(val) +# define ELF_R_TYPE(val) ELF64_R_TYPE(val) +# define ELF_ST_TYPE(val) ELF64_ST_TYPE(val) +#else +#error "I'm confused" +#endif + +#define grub_target_to_host32(x) (grub_target_to_host32_real (arch, (x))) +#define grub_host_to_target32(x) (grub_host_to_target32_real (arch, (x))) +#define grub_target_to_host64(x) (grub_target_to_host64_real (arch, (x))) +#define grub_host_to_target64(x) (grub_host_to_target64_real (arch, (x))) +#define grub_host_to_target_addr(x) (grub_host_to_target_addr_real (arch, (x))) +#define grub_target_to_host16(x) (grub_target_to_host16_real (arch, (x))) +#define grub_host_to_target16(x) (grub_host_to_target16_real (arch, (x))) +#define grub_target_to_host(val) grub_target_to_host_real(arch, (val)) + +static inline grub_uint32_t +grub_target_to_host32_real (const struct grub_module_verifier_arch *arch, + grub_uint32_t in) +{ + if (arch->bigendian) + return grub_be_to_cpu32 (in); + else + return grub_le_to_cpu32 (in); +} + +static inline grub_uint64_t +grub_target_to_host64_real (const struct grub_module_verifier_arch *arch, + grub_uint64_t in) +{ + if (arch->bigendian) + return grub_be_to_cpu64 (in); + else + return grub_le_to_cpu64 (in); +} + +static inline grub_uint64_t +grub_host_to_target64_real (const struct grub_module_verifier_arch *arch, + grub_uint64_t in) +{ + if (arch->bigendian) + return grub_cpu_to_be64 (in); + else + return grub_cpu_to_le64 (in); +} + +static inline grub_uint32_t +grub_host_to_target32_real (const struct grub_module_verifier_arch *arch, + grub_uint32_t in) +{ + if (arch->bigendian) + return grub_cpu_to_be32 (in); + else + return grub_cpu_to_le32 (in); +} + +static inline grub_uint16_t +grub_target_to_host16_real (const struct grub_module_verifier_arch *arch, + grub_uint16_t in) +{ + if (arch->bigendian) + return grub_be_to_cpu16 (in); + else + return grub_le_to_cpu16 (in); +} + +static inline grub_uint16_t +grub_host_to_target16_real (const struct grub_module_verifier_arch *arch, + grub_uint16_t in) +{ + if (arch->bigendian) + return grub_cpu_to_be16 (in); + else + return grub_cpu_to_le16 (in); +} + +static inline grub_uint64_t +grub_host_to_target_addr_real (const struct grub_module_verifier_arch *arch, grub_uint64_t in) +{ + if (arch->voidp_sizeof == 8) + return grub_host_to_target64_real (arch, in); + else + return grub_host_to_target32_real (arch, in); +} + +static inline grub_uint64_t +grub_target_to_host_real (const struct grub_module_verifier_arch *arch, grub_uint64_t in) +{ + if (arch->voidp_sizeof == 8) + return grub_target_to_host64_real (arch, in); + else + return grub_target_to_host32_real (arch, in); +} + + +static Elf_Shdr * +find_section (const struct grub_module_verifier_arch *arch, Elf_Ehdr *e, const char *name) +{ + Elf_Shdr *s; + const char *str; + unsigned i; + + s = (Elf_Shdr *) ((char *) e + grub_target_to_host (e->e_shoff) + grub_target_to_host16 (e->e_shstrndx) * grub_target_to_host16 (e->e_shentsize)); + str = (char *) e + grub_target_to_host (s->sh_offset); + + for (i = 0, s = (Elf_Shdr *) ((char *) e + grub_target_to_host (e->e_shoff)); + i < grub_target_to_host16 (e->e_shnum); + i++, s = (Elf_Shdr *) ((char *) s + grub_target_to_host16 (e->e_shentsize))) + if (strcmp (str + grub_target_to_host32 (s->sh_name), name) == 0) + return s; + return NULL; +} + +static void +check_license (const struct grub_module_verifier_arch *arch, Elf_Ehdr *e) +{ + Elf_Shdr *s = find_section (arch, e, ".module_license"); + if (s && (strcmp ((char *) e + grub_target_to_host(s->sh_offset), "LICENSE=GPLv3") == 0 + || strcmp ((char *) e + grub_target_to_host(s->sh_offset), "LICENSE=GPLv3+") == 0 + || strcmp ((char *) e + grub_target_to_host(s->sh_offset), "LICENSE=GPLv2+") == 0)) + return; + grub_util_error ("incompatible license"); +} + +static void +check_symbols (const struct grub_module_verifier_arch *arch, Elf_Ehdr *e) +{ + unsigned i; + Elf_Shdr *s, *sections; + Elf_Sym *sym; + const char *str; + Elf_Word size, entsize; + + sections = (Elf_Shdr *) ((char *) e + grub_target_to_host (e->e_shoff)); + for (i = 0, s = sections; + i < grub_target_to_host16 (e->e_shnum); + i++, s = (Elf_Shdr *) ((char *) s + grub_target_to_host16 (e->e_shentsize))) + if (grub_target_to_host32 (s->sh_type) == SHT_SYMTAB) + break; + + if (i == grub_target_to_host16 (e->e_shnum)) + grub_util_error ("no symbol table"); + + sym = (Elf_Sym *) ((char *) e + grub_target_to_host (s->sh_offset)); + size = grub_target_to_host (s->sh_size); + entsize = grub_target_to_host (s->sh_entsize); + + s = (Elf_Shdr *) ((char *) sections + grub_target_to_host16 (e->e_shentsize) * grub_target_to_host32 (s->sh_link)); + str = (char *) e + grub_target_to_host (s->sh_offset); + + for (i = 0; + i < size / entsize; + i++, sym = (Elf_Sym *) ((char *) sym + entsize)) + { + unsigned char type = ELF_ST_TYPE (sym->st_info); + + switch (type) + { + case STT_NOTYPE: + case STT_OBJECT: + case STT_FUNC: + case STT_SECTION: + case STT_FILE: + break; + + default: + return grub_util_error ("unknown symbol type `%d'", (int) type); + } + } +} + +/* Relocate symbols. */ +static void +section_check_relocations (const struct grub_module_verifier_arch *arch, void *ehdr, + Elf_Shdr *s, size_t target_seg_size) +{ + Elf_Rel *rel, *max; + + for (rel = (Elf_Rel *) ((char *) ehdr + grub_target_to_host (s->sh_offset)), + max = (Elf_Rel *) ((char *) rel + grub_target_to_host (s->sh_size)); + rel < max; + rel = (Elf_Rel *) ((char *) rel + grub_target_to_host (s->sh_entsize))) + { + Elf_Word *addr; + Elf_Sym *sym; + unsigned i; + + if (target_seg_size < grub_target_to_host (rel->r_offset)) + grub_util_error ("reloc offset is out of the segment"); + + grub_uint32_t type = ELF_R_TYPE (grub_target_to_host (rel->r_info)); + + if (arch->machine == EM_SPARCV9) + type &= 0xff; + + for (i = 0; arch->supported_relocations[i] != -1; i++) + if (type == arch->supported_relocations[i]) + break; + if (arch->supported_relocations[i] == -1) + grub_util_error ("unsupported relocation 0x%x", type); + } +} + +static void +check_relocations (const struct grub_module_verifier_arch *arch, Elf_Ehdr *e) +{ + Elf_Shdr *s; + unsigned i; + + for (i = 0, s = (Elf_Shdr *) ((char *) e + grub_target_to_host (e->e_shoff)); + i < grub_target_to_host16 (e->e_shnum); + i++, s = (Elf_Shdr *) ((char *) s + grub_target_to_host16 (e->e_shentsize))) + if (grub_target_to_host32 (s->sh_type) == SHT_REL || grub_target_to_host32 (s->sh_type) == SHT_RELA) + { + Elf_Shdr *ts; + + if (grub_target_to_host32 (s->sh_type) == SHT_REL && !(arch->flags & GRUB_MODULE_VERIFY_SUPPORTS_REL)) + grub_util_error ("unsupported SHT_REL"); + if (grub_target_to_host32 (s->sh_type) == SHT_RELA && !(arch->flags & GRUB_MODULE_VERIFY_SUPPORTS_RELA)) + grub_util_error ("unsupported SHT_RELA"); + + /* Find the target segment. */ + if (grub_target_to_host32 (s->sh_info) >= grub_target_to_host16 (e->e_shnum)) + grub_util_error ("orphaned reloc section"); + ts = (Elf_Shdr *) ((char *) e + grub_target_to_host (e->e_shoff) + grub_target_to_host32 (s->sh_info) * grub_target_to_host16 (e->e_shentsize)); + + section_check_relocations (arch, e, s, grub_target_to_host (ts->sh_size)); + } +} + +void +SUFFIX(grub_module_verify) (void *module_img, size_t size, const struct grub_module_verifier_arch *arch) +{ + Elf_Ehdr *e = module_img; + + /* Check the header size. */ + if (size < sizeof (Elf_Ehdr)) + grub_util_error ("ELF header smaller than expected"); + + /* Check the magic numbers. */ + if (e->e_ident[EI_MAG0] != ELFMAG0 + || e->e_ident[EI_MAG1] != ELFMAG1 + || e->e_ident[EI_MAG2] != ELFMAG2 + || e->e_ident[EI_MAG3] != ELFMAG3 + || e->e_ident[EI_VERSION] != EV_CURRENT + || grub_target_to_host32 (e->e_version) != EV_CURRENT) + grub_util_error ("invalid arch-independent ELF magic"); + + if (e->e_ident[EI_CLASS] != ELFCLASSXX + || e->e_ident[EI_DATA] != (arch->bigendian ? ELFDATA2MSB : ELFDATA2LSB) + || grub_target_to_host16 (e->e_machine) != arch->machine) + grub_util_error ("invalid arch-dependent ELF magic"); + + if (grub_target_to_host16 (e->e_type) != ET_REL) + { + grub_util_error ("this ELF file is not of the right type"); + } + + /* Make sure that every section is within the core. */ + if (size < grub_target_to_host (e->e_shoff) + + grub_target_to_host16 (e->e_shentsize) * grub_target_to_host16(e->e_shnum)) + { + grub_util_error ("ELF sections outside core"); + } + + check_license (arch, e); + + Elf_Shdr *s; + + s = find_section (arch, e, ".modname"); + if (!s) + grub_util_error ("no module name found"); + + check_symbols(arch, e); + check_relocations(arch, e); +} From 60ae5821428433945b62a79f6a1f71f14f8dfb19 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Thu, 31 Dec 2015 14:54:48 +0100 Subject: [PATCH 579/722] backtrace: Fix register call syntax --- grub-core/lib/i386/backtrace.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/grub-core/lib/i386/backtrace.c b/grub-core/lib/i386/backtrace.c index d76a46a23..c3e03c727 100644 --- a/grub-core/lib/i386/backtrace.c +++ b/grub-core/lib/i386/backtrace.c @@ -57,10 +57,10 @@ grub_backtrace (void) { #ifdef __x86_64__ asm volatile ("movq %%rbp, %%rdi\n" - "call %%rax": :"a"(grub_backtrace_pointer)); + "callq *%%rax": :"a"(grub_backtrace_pointer)); #else asm volatile ("movl %%ebp, %%eax\n" - "call %%ecx": :"c"(grub_backtrace_pointer)); + "calll *%%ecx": :"c"(grub_backtrace_pointer)); #endif } From 76588d1319cccde6c3e68279db2a4dcdf2ce7562 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Thu, 31 Dec 2015 14:54:56 +0100 Subject: [PATCH 580/722] xen/relocator: Use local symbol to ensure that code is relocation-free. --- grub-core/lib/x86_64/xen/relocator.S | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/grub-core/lib/x86_64/xen/relocator.S b/grub-core/lib/x86_64/xen/relocator.S index 78c123350..92e9e72a9 100644 --- a/grub-core/lib/x86_64/xen/relocator.S +++ b/grub-core/lib/x86_64/xen/relocator.S @@ -89,7 +89,7 @@ VARIABLE(grub_relocator_xen_mfn_list) loop 1b - leaq EXT_C(grub_relocator_xen_mmu_op) (%rip), %rdi + leaq LOCAL(mmu_op) (%rip), %rdi movq $3, %rsi movq $0, %rdx movq $0x7FF0, %r10 @@ -104,6 +104,7 @@ VARIABLE(grub_relocator_xen_remap_continue) jmp *%rax +LOCAL(mmu_op): VARIABLE(grub_relocator_xen_mmu_op) .space 256 From e1b2b9bf1d1cb3b411b5ae45046e4002091f6f5f Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Thu, 31 Dec 2015 15:29:28 +0100 Subject: [PATCH 581/722] module-verifier: Check range-limited relative relocations. Check that they point to the same module, so will end up in the same chunk of memory. --- include/grub/module_verifier.h | 1 + util/grub-module-verifier.c | 19 ++++++++--- util/grub-module-verifierXX.c | 62 ++++++++++++++++++++++++++++------ 3 files changed, 67 insertions(+), 15 deletions(-) diff --git a/include/grub/module_verifier.h b/include/grub/module_verifier.h index 9e3a2ba72..6cddff30f 100644 --- a/include/grub/module_verifier.h +++ b/include/grub/module_verifier.h @@ -13,6 +13,7 @@ struct grub_module_verifier_arch { int machine; int flags; const int *supported_relocations; + const int *short_relocations; }; void grub_module_verify64(void *module_img, size_t module_size, const struct grub_module_verifier_arch *arch); diff --git a/util/grub-module-verifier.c b/util/grub-module-verifier.c index d2d698403..c027f0a0f 100644 --- a/util/grub-module-verifier.c +++ b/util/grub-module-verifier.c @@ -15,9 +15,13 @@ struct grub_module_verifier_arch archs[] = { { "x86_64", 8, 0, EM_X86_64, GRUB_MODULE_VERIFY_SUPPORTS_RELA, (int[]){ R_X86_64_64, R_X86_64_PC64, - /* R_X86_64_32, R_X86_64_32S, R_X86_64_PC32 are supported but shouldn't be used because of their limited range. */ + /* R_X86_64_32, R_X86_64_32S are supported but shouldn't be used because of their limited range. */ -1 - } }, + }, (int[]){ + R_X86_64_PC32, + -1 + } + }, { "powerpc", 4, 1, EM_PPC, GRUB_MODULE_VERIFY_SUPPORTS_RELA, (int[]){ GRUB_ELF_R_PPC_ADDR16_LO, GRUB_ELF_R_PPC_REL24, /* It has limited range but GRUB adds trampolines when necessarry. */ @@ -39,17 +43,24 @@ struct grub_module_verifier_arch archs[] = { } }, { "ia64", 8, 0, EM_IA_64, GRUB_MODULE_VERIFY_SUPPORTS_RELA, (int[]){ R_IA64_PCREL21B, /* We should verify that it's pointing either - to a function or to a section in the same module. */ + to a function or to a section in the same module. + Checking that external symbol is a function is + non-trivial and I have never seen this relocation used + for anything else, so assume that it always points to a + function. + */ R_IA64_SEGREL64LSB, R_IA64_FPTR64LSB, R_IA64_DIR64LSB, R_IA64_PCREL64LSB, - R_IA64_GPREL22, /* We should verify that it's pointing to a section in the same module. */ R_IA64_LTOFF22X, R_IA64_LTOFF22, R_IA64_LTOFF_FPTR22, R_IA64_LDXMOV, -1 + }, (int[]){ + R_IA64_GPREL22, + -1 } }, { "mipsel", 4, 0, EM_MIPS, GRUB_MODULE_VERIFY_SUPPORTS_REL | GRUB_MODULE_VERIFY_SUPPORTS_RELA, (int[]){ R_MIPS_HI16, diff --git a/util/grub-module-verifierXX.c b/util/grub-module-verifierXX.c index 904be27d3..25988ebc2 100644 --- a/util/grub-module-verifierXX.c +++ b/util/grub-module-verifierXX.c @@ -161,14 +161,12 @@ check_license (const struct grub_module_verifier_arch *arch, Elf_Ehdr *e) grub_util_error ("incompatible license"); } -static void -check_symbols (const struct grub_module_verifier_arch *arch, Elf_Ehdr *e) +static Elf_Sym * +get_symtab (const struct grub_module_verifier_arch *arch, Elf_Ehdr *e, Elf_Word *size, Elf_Word *entsize) { unsigned i; Elf_Shdr *s, *sections; Elf_Sym *sym; - const char *str; - Elf_Word size, entsize; sections = (Elf_Shdr *) ((char *) e + grub_target_to_host (e->e_shoff)); for (i = 0, s = sections; @@ -181,11 +179,19 @@ check_symbols (const struct grub_module_verifier_arch *arch, Elf_Ehdr *e) grub_util_error ("no symbol table"); sym = (Elf_Sym *) ((char *) e + grub_target_to_host (s->sh_offset)); - size = grub_target_to_host (s->sh_size); - entsize = grub_target_to_host (s->sh_entsize); + *size = grub_target_to_host (s->sh_size); + *entsize = grub_target_to_host (s->sh_entsize); + return sym; +} - s = (Elf_Shdr *) ((char *) sections + grub_target_to_host16 (e->e_shentsize) * grub_target_to_host32 (s->sh_link)); - str = (char *) e + grub_target_to_host (s->sh_offset); +static void +check_symbols (const struct grub_module_verifier_arch *arch, Elf_Ehdr *e) +{ + Elf_Sym *sym; + Elf_Word size, entsize; + unsigned i; + + sym = get_symtab (arch, e, &size, &entsize); for (i = 0; i < size / entsize; @@ -208,19 +214,41 @@ check_symbols (const struct grub_module_verifier_arch *arch, Elf_Ehdr *e) } } -/* Relocate symbols. */ +static int +is_symbol_local(Elf_Sym *sym) +{ + switch (ELF_ST_TYPE (sym->st_info)) + { + case STT_NOTYPE: + case STT_OBJECT: + if (sym->st_name != 0 && sym->st_shndx == 0) + return 0; + return 1; + + case STT_FUNC: + case STT_SECTION: + return 1; + + default: + return 0; + } +} + static void section_check_relocations (const struct grub_module_verifier_arch *arch, void *ehdr, Elf_Shdr *s, size_t target_seg_size) { Elf_Rel *rel, *max; + Elf_Sym *symtab; + Elf_Word symtabsize, symtabentsize; + + symtab = get_symtab (arch, ehdr, &symtabsize, &symtabentsize); for (rel = (Elf_Rel *) ((char *) ehdr + grub_target_to_host (s->sh_offset)), max = (Elf_Rel *) ((char *) rel + grub_target_to_host (s->sh_size)); rel < max; rel = (Elf_Rel *) ((char *) rel + grub_target_to_host (s->sh_entsize))) { - Elf_Word *addr; Elf_Sym *sym; unsigned i; @@ -235,8 +263,20 @@ section_check_relocations (const struct grub_module_verifier_arch *arch, void *e for (i = 0; arch->supported_relocations[i] != -1; i++) if (type == arch->supported_relocations[i]) break; - if (arch->supported_relocations[i] == -1) + if (arch->supported_relocations[i] != -1) + continue; + if (!arch->short_relocations) grub_util_error ("unsupported relocation 0x%x", type); + for (i = 0; arch->short_relocations[i] != -1; i++) + if (type == arch->short_relocations[i]) + break; + if (arch->short_relocations[i] == -1) + grub_util_error ("unsupported relocation 0x%x", type); + sym = (Elf_Sym *) ((char *) symtab + symtabentsize * ELF_R_SYM (grub_target_to_host (rel->r_info))); + + if (is_symbol_local (sym)) + continue; + grub_util_error ("relocation 0x%x is not module-local", type); } } From 68e158dffde328d5b961518fe23504cc534744ce Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Thu, 31 Dec 2015 18:13:59 +0100 Subject: [PATCH 582/722] Strip .ARM.exidx This section is generated by clang and is useful only for debugging. It contains exotic relocations, so strip them to avoid them interferring with module loading. --- conf/Makefile.common | 2 +- gentpl.py | 2 +- grub-core/genmod.sh.in | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/conf/Makefile.common b/conf/Makefile.common index 5083d5f1e..11296b550 100644 --- a/conf/Makefile.common +++ b/conf/Makefile.common @@ -38,7 +38,7 @@ CFLAGS_KERNEL = $(CFLAGS_PLATFORM) -ffreestanding LDFLAGS_KERNEL = $(LDFLAGS_PLATFORM) -nostdlib $(TARGET_LDFLAGS_OLDMAGIC) CPPFLAGS_KERNEL = $(CPPFLAGS_CPU) $(CPPFLAGS_PLATFORM) -DGRUB_KERNEL=1 CCASFLAGS_KERNEL = $(CCASFLAGS_CPU) $(CCASFLAGS_PLATFORM) -STRIPFLAGS_KERNEL = -R .rel.dyn -R .reginfo -R .note -R .comment -R .drectve -R .note.gnu.gold-version -R .MIPS.abiflags +STRIPFLAGS_KERNEL = -R .rel.dyn -R .reginfo -R .note -R .comment -R .drectve -R .note.gnu.gold-version -R .MIPS.abiflags -R .ARM.exidx CFLAGS_MODULE = $(CFLAGS_PLATFORM) -ffreestanding LDFLAGS_MODULE = $(LDFLAGS_PLATFORM) -nostdlib $(TARGET_LDFLAGS_OLDMAGIC) -Wl,-r,-d diff --git a/gentpl.py b/gentpl.py index 76971d3ce..0782e447d 100644 --- a/gentpl.py +++ b/gentpl.py @@ -759,7 +759,7 @@ def image(defn, platform): if test x$(TARGET_APPLE_LINKER) = x1; then \ $(MACHO2IMG) $< $@; \ else \ - $(TARGET_OBJCOPY) $(""" + cname(defn) + """_OBJCOPYFLAGS) --strip-unneeded -R .note -R .comment -R .note.gnu.build-id -R .MIPS.abiflags -R .reginfo -R .rel.dyn -R .note.gnu.gold-version $< $@; \ + $(TARGET_OBJCOPY) $(""" + cname(defn) + """_OBJCOPYFLAGS) --strip-unneeded -R .note -R .comment -R .note.gnu.build-id -R .MIPS.abiflags -R .reginfo -R .rel.dyn -R .note.gnu.gold-version -R .ARM.exidx $< $@; \ fi """) diff --git a/grub-core/genmod.sh.in b/grub-core/genmod.sh.in index 7dcafd9d3..005cb1985 100644 --- a/grub-core/genmod.sh.in +++ b/grub-core/genmod.sh.in @@ -58,7 +58,7 @@ if test x@TARGET_APPLE_LINKER@ != x1; then -K grub_mod_init -K grub_mod_fini \ -K _grub_mod_init -K _grub_mod_fini \ -R .note.gnu.gold-version -R .note.GNU-stack \ - -R .note -R .comment $tmpfile || exit 1 + -R .note -R .comment -R .ARM.exidx $tmpfile || exit 1 fi if ! test -z "${TARGET_OBJ2ELF}"; then "${TARGET_OBJ2ELF}" $tmpfile || exit 1 From f1b352538556711dc3f9e8b9bf5bf2e4abea8e25 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Thu, 31 Dec 2015 18:15:49 +0100 Subject: [PATCH 583/722] Add -mno-stack-arg-probe on mingw. This argument disables generation of calls to __chkstk_ms. Those calls are useless on GRUB as function is dummy. Yet they increase module size and use limited-range relocations which may not work under some memory layouts. We currently don't use such layouts on concerned platforms but lt's correct this. --- configure.ac | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/configure.ac b/configure.ac index 3300545e0..f662e200e 100644 --- a/configure.ac +++ b/configure.ac @@ -910,6 +910,18 @@ if test x"$target_os" = xcygwin && test "x$grub_cv_cc_no_reorder_functions" = xy TARGET_CFLAGS="$TARGET_CFLAGS -fno-reorder-functions" fi +AC_CACHE_CHECK([whether -mno-stack-arg-probe works], [grub_cv_cc_mno_stack_arg_probe], [ + CFLAGS="$TARGET_CFLAGS -mno-stack-arg-probe" + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])], + [grub_cv_cc_mno_stack_arg_probe=yes], + [grub_cv_cc_mno_stack_arg_probe=no]) +]) + +if test "x$grub_cv_cc_mno_stack_arg_probe" = xyes; then + TARGET_CFLAGS="$TARGET_CFLAGS -mno-stack-arg-probe" +fi + + # By default, GCC 4.6 generates .eh_frame sections containing unwind # information in some cases where it previously did not. GRUB doesn't need # these and they just use up vital space. Restore the old compiler From 5ae590b32d2fa535050399193d21a2305bd008a7 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Thu, 31 Dec 2015 18:19:15 +0100 Subject: [PATCH 584/722] configure: Fix grub_cv_cc_fno_unwind_tables check. Check tries -fno-dwarf2-cfi-asm but adds -fno-asynchronous-unwind-tables to TARGET_CFLAGS. Fix this. --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index f662e200e..ada6068d9 100644 --- a/configure.ac +++ b/configure.ac @@ -927,7 +927,7 @@ fi # these and they just use up vital space. Restore the old compiler # behaviour. AC_CACHE_CHECK([whether -fno-asynchronous-unwind-tables works], [grub_cv_cc_fno_asynchronous_unwind_tables], [ - CFLAGS="$TARGET_CFLAGS -fno-dwarf2-cfi-asm" + CFLAGS="$TARGET_CFLAGS -fno-asynchronous-unwind-tables" AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])], [grub_cv_cc_fno_asynchronous_unwind_tables=yes], [grub_cv_cc_fno_asynchronous_unwind_tables=no]) From 3b21499506b633494cccb1cdb3fc757594ef0ef0 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Thu, 31 Dec 2015 18:20:11 +0100 Subject: [PATCH 585/722] Disable build-time module check on emu. On emu some checks can be laxer like check for relocation range. Additionally module loading in emu is rarely used. So skip this check rather than making it laxer for all platforms. In ideal we may want to have slightly different check for emu but for now this is good enough. --- grub-core/genmod.sh.in | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/grub-core/genmod.sh.in b/grub-core/genmod.sh.in index 005cb1985..f74edd551 100644 --- a/grub-core/genmod.sh.in +++ b/grub-core/genmod.sh.in @@ -93,5 +93,7 @@ else -wd1106 -nu -nd $tmpfile.bin $tmpfile || exit 1 rm -f $name.bin fi -./build-grub-module-verifier $tmpfile @target_cpu@ +if test x@platform@ != xemu; then + ./build-grub-module-verifier $tmpfile @target_cpu@ +fi mv $tmpfile $outfile From dcc499aaf034a5ee2f1ae11c7ec6f990ab9aea3c Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Thu, 31 Dec 2015 18:30:39 +0100 Subject: [PATCH 586/722] module-verifier: allow limited-range relocations on sparc64. clang as incomplete mcmodel=large support. As we don't currently need full mcmodel=large support for sparc64, relax those checks. --- util/grub-module-verifier.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/util/grub-module-verifier.c b/util/grub-module-verifier.c index c027f0a0f..e217dcddc 100644 --- a/util/grub-module-verifier.c +++ b/util/grub-module-verifier.c @@ -38,7 +38,12 @@ struct grub_module_verifier_arch archs[] = { R_SPARC_LO10, R_SPARC_64, R_SPARC_OLO10, - /* R_SPARC_32, R_SPARC_HI22 are supported but shouldn't be used because of their limited range. */ + /* Following 2 relocations have limited range but unfortunately + clang generates them, as it doesn't implement mcmodel=large properly. + At least our heap and core are under 4G, so it's not a problem + usually. */ + R_SPARC_HI22, + R_SPARC_32, -1 } }, { "ia64", 8, 0, EM_IA_64, GRUB_MODULE_VERIFY_SUPPORTS_RELA, (int[]){ From 40051fedc33f2ec10924d66ae1371940dce2ca8a Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Thu, 31 Dec 2015 19:20:03 +0100 Subject: [PATCH 587/722] configure: Add -fno-unwind-tables if supported. Unwind tables are useless for us bt consume space if present. Ensure that they are not. --- configure.ac | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/configure.ac b/configure.ac index ada6068d9..2e656dbea 100644 --- a/configure.ac +++ b/configure.ac @@ -937,6 +937,17 @@ if test "x$grub_cv_cc_fno_asynchronous_unwind_tables" = xyes; then TARGET_CFLAGS="$TARGET_CFLAGS -fno-asynchronous-unwind-tables" fi +AC_CACHE_CHECK([whether -fno-unwind-tables works], [grub_cv_cc_fno_unwind_tables], [ + CFLAGS="$TARGET_CFLAGS -fno-unwind-tables" + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])], + [grub_cv_cc_fno_unwind_tables=yes], + [grub_cv_cc_fno_unwind_tables=no]) +]) + +if test "x$grub_cv_cc_fno_unwind_tables" = xyes; then + TARGET_CFLAGS="$TARGET_CFLAGS -fno-unwind-tables" +fi + AC_ARG_ENABLE([efiemu], [AS_HELP_STRING([--enable-efiemu], [build and install the efiemu runtimes (default=guessed)])]) From c67025fad5104fe48daa24115a16373413cddbf4 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Thu, 31 Dec 2015 21:35:11 +0300 Subject: [PATCH 588/722] Add grub-module-verifier files to EXTRA_DIST --- conf/Makefile.extra-dist | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/conf/Makefile.extra-dist b/conf/Makefile.extra-dist index 9dd64fdca..b16bd9253 100644 --- a/conf/Makefile.extra-dist +++ b/conf/Makefile.extra-dist @@ -50,8 +50,13 @@ EXTRA_DIST += util/import_gcrypth.sed EXTRA_DIST += util/bin2h.c EXTRA_DIST += util/grub-gen-asciih.c EXTRA_DIST += util/grub-gen-widthspec.c +EXTRA_DIST += util/grub-module-verifier.c +EXTRA_DIST += util/grub-module-verifier32.c +EXTRA_DIST += util/grub-module-verifier64.c +EXTRA_DIST += util/grub-module-verifierXX.c EXTRA_DIST += util/grub-pe2elf.c + EXTRA_DIST += m4/gnulib-cache.m4 EXTRA_DIST += m4/glibc2.m4 EXTRA_DIST += m4/gnulib-tool.m4 From af23303cbd551c8b1d70701530916f221a0b47e4 Mon Sep 17 00:00:00 2001 From: Andrey Borzenkov Date: Thu, 31 Dec 2015 22:23:12 +0300 Subject: [PATCH 589/722] add dejavu built fonts to cleanfiles --- Makefile.am | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Makefile.am b/Makefile.am index 994ebbd39..b8423b08d 100644 --- a/Makefile.am +++ b/Makefile.am @@ -91,14 +91,19 @@ if COND_STARFIELD starfield_DATA = dejavu_10.pf2 dejavu_12.pf2 dejavu_bold_14.pf2 dejavu_14.pf2 dejavu_16.pf2 $(starfield_theme_files) dejavu_10.pf2: $(DJVU_FONT_SOURCE) build-grub-mkfont ./build-grub-mkfont -s 10 -o $@ $(DJVU_FONT_SOURCE) +CLEANFILES += dejavu_10.pf2 dejavu_12.pf2: $(DJVU_FONT_SOURCE) build-grub-mkfont ./build-grub-mkfont -s 12 -o $@ $(DJVU_FONT_SOURCE) +CLEANFILES += dejavu_12.pf2 dejavu_14.pf2: $(DJVU_FONT_SOURCE) build-grub-mkfont ./build-grub-mkfont -s 14 -o $@ $(DJVU_FONT_SOURCE) +CLEANFILES += dejavu_14.pf2 dejavu_bold_14.pf2: $(DJVU_FONT_SOURCE) build-grub-mkfont ./build-grub-mkfont -b -s 14 -o $@ $(DJVU_FONT_SOURCE) +CLEANFILES += dejavu_bold_14.pf2 dejavu_16.pf2: $(DJVU_FONT_SOURCE) build-grub-mkfont ./build-grub-mkfont -s 16 -o $@ $(DJVU_FONT_SOURCE) +CLEANFILES += dejavu_16.pf2 else starfield_DATA = endif From 4d6e9c8a92ce1b1b88980e31f9dd1e8ab78f3888 Mon Sep 17 00:00:00 2001 From: Andrey Borzenkov Date: Thu, 31 Dec 2015 23:00:25 +0300 Subject: [PATCH 590/722] remove temporary .bin files (kernel and modules) --- gentpl.py | 2 ++ grub-core/genmod.sh.in | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/gentpl.py b/gentpl.py index 0782e447d..f08bcc404 100644 --- a/gentpl.py +++ b/gentpl.py @@ -729,9 +729,11 @@ def kernel(defn, platform): """if test x$(TARGET_APPLE_LINKER) = x1; then \ $(TARGET_STRIP) -S -x $(""" + cname(defn) + """) -o $@.bin $<; \ $(TARGET_OBJCONV) -f$(TARGET_MODULE_FORMAT) -nr:_grub_mod_init:grub_mod_init -nr:_grub_mod_fini:grub_mod_fini -ed2022 -ed2016 -wd1106 -nu -nd $@.bin $@; \ + rm -f $@.bin; \ elif test ! -z '$(TARGET_OBJ2ELF)'; then \ """ + "$(TARGET_STRIP) $(" + cname(defn) + "_STRIPFLAGS) -o $@.bin $< && \ $(TARGET_OBJ2ELF) $@.bin $@ || (rm -f $@; rm -f $@.bin; exit 1); \ + rm -f $@.bin; \ else """ + "$(TARGET_STRIP) $(" + cname(defn) + "_STRIPFLAGS) -o $@ $<; \ fi""")) diff --git a/grub-core/genmod.sh.in b/grub-core/genmod.sh.in index f74edd551..ca2e59d5c 100644 --- a/grub-core/genmod.sh.in +++ b/grub-core/genmod.sh.in @@ -91,7 +91,7 @@ else -nr:_grub_mod_init:grub_mod_init \ -nr:_grub_mod_fini:grub_mod_fini \ -wd1106 -nu -nd $tmpfile.bin $tmpfile || exit 1 - rm -f $name.bin + rm -f $tmpfile.bin fi if test x@platform@ != xemu; then ./build-grub-module-verifier $tmpfile @target_cpu@ From 80fdaf1d012fa0403f7b75568df926735f070c3c Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Thu, 31 Dec 2015 22:34:26 +0100 Subject: [PATCH 591/722] configure.ac: Reorder efiemu check to after link format check. efiemu is supposed to be disabled when compiling through exe format. Unfortunately format was determined only after efiemu check. Reorder to fix the problem --- configure.ac | 127 +++++++++++++++++++++++++++------------------------ 1 file changed, 67 insertions(+), 60 deletions(-) diff --git a/configure.ac b/configure.ac index 2e656dbea..26d2f33c7 100644 --- a/configure.ac +++ b/configure.ac @@ -948,66 +948,6 @@ if test "x$grub_cv_cc_fno_unwind_tables" = xyes; then TARGET_CFLAGS="$TARGET_CFLAGS -fno-unwind-tables" fi -AC_ARG_ENABLE([efiemu], - [AS_HELP_STRING([--enable-efiemu], - [build and install the efiemu runtimes (default=guessed)])]) -if test x"$enable_efiemu" = xno ; then - efiemu_excuse="explicitly disabled" -fi -if test x"$grub_cv_target_cc_link_format" = x-mi386pe || test x"$grub_cv_target_cc_link_format" = x-mi386pep ; then - efiemu_excuse="not available on cygwin" -fi -if test x"$target_cpu" != xi386 ; then - efiemu_excuse="only available on i386" -fi -if test x"$platform" = xefi ; then - efiemu_excuse="not available on efi" -fi -if test x"$efiemu_excuse" = x ; then - AC_CACHE_CHECK([whether options required for efiemu work], grub_cv_cc_efiemu, [ - CFLAGS="-m64 -nostdlib -O2 -mcmodel=large -mno-red-zone" - AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])], - [grub_cv_cc_efiemu=yes], - [grub_cv_cc_efiemu=no]) - ]) - if test x$grub_cv_cc_efiemu = xno; then - efiemu_excuse="cannot compile with -m64 -mcmodel=large -mno-red-zone -nostdlib" - fi -fi -if test x"$efiemu_excuse" = x ; then - AC_CACHE_CHECK([for efiemu64 linking format], [grub_cv_target_cc_efiemu64_link_format], [ - grub_cv_target_cc_efiemu64_link_format=unknown - for format in -melf_x86_64 -melf_x86_64_fbsd -melf_x86_64_obsd -melf_x86_64_haiku -arch,x86_64; do - CFLAGS="-m64 -nostdlib -O2 -mcmodel=large -mno-red-zone" - LDFLAGS="-m64 -Wl,$format -nostdlib -static" - AC_LINK_IFELSE([AC_LANG_PROGRAM([[ - asm (".globl start; start:"); - asm (".globl _start; _start:"); - asm (".globl __start; __start:"); - void __main (void); - void __main (void) {} - ]], [[]])], [flag=1], [flag=0]) - if test x"$flag" = x1; then - grub_cv_target_cc_efiemu64_link_format="$format" - break - fi - done]) - if test x"$grub_cv_target_cc_efiemu64_link_format" = xunknown; then - efiemu_excuse="no suitable link format for efiemu64 found" - else - EFIEMU64_LINK_FORMAT="-Wl,$grub_cv_target_cc_efiemu64_link_format" - fi -fi -if test x"$enable_efiemu" = xyes && test x"$efiemu_excuse" != x ; then - AC_MSG_ERROR([efiemu runtime was explicitly requested but can't be compiled ($efiemu_excuse)]) -fi -if test x"$efiemu_excuse" = x ; then -enable_efiemu=yes -else -enable_efiemu=no -fi -AC_SUBST([enable_efiemu]) -AC_SUBST([EFIEMU64_LINK_FORMAT]) CFLAGS="$TARGET_CFLAGS" @@ -1101,6 +1041,73 @@ else TARGET_IMG_CFLAGS= fi +CFLAGS="$TARGET_CFLAGS" + +AC_ARG_ENABLE([efiemu], + [AS_HELP_STRING([--enable-efiemu], + [build and install the efiemu runtimes (default=guessed)])]) +if test x"$enable_efiemu" = xno ; then + efiemu_excuse="explicitly disabled" +fi + +if test x"$grub_cv_target_cc_link_format" = x-mi386pe || test x"$grub_cv_target_cc_link_format" = x-mi386pep ; then + efiemu_excuse="not available on cygwin" +fi +if test x"$target_cpu" != xi386 ; then + efiemu_excuse="only available on i386" +fi +if test x"$platform" = xefi ; then + efiemu_excuse="not available on efi" +fi + +if test x"$efiemu_excuse" = x ; then + AC_CACHE_CHECK([whether options required for efiemu work], grub_cv_cc_efiemu, [ + CFLAGS="-m64 -nostdlib -O2 -mcmodel=large -mno-red-zone" + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])], + [grub_cv_cc_efiemu=yes], + [grub_cv_cc_efiemu=no]) + ]) + if test x$grub_cv_cc_efiemu = xno; then + efiemu_excuse="cannot compile with -m64 -mcmodel=large -mno-red-zone -nostdlib" + fi +fi +if test x"$efiemu_excuse" = x ; then + AC_CACHE_CHECK([for efiemu64 linking format], [grub_cv_target_cc_efiemu64_link_format], [ + grub_cv_target_cc_efiemu64_link_format=unknown + for format in -melf_x86_64 -melf_x86_64_fbsd -melf_x86_64_obsd -melf_x86_64_haiku -arch,x86_64; do + CFLAGS="-m64 -nostdlib -O2 -mcmodel=large -mno-red-zone" + LDFLAGS="-m64 -Wl,$format -nostdlib -static" + AC_LINK_IFELSE([AC_LANG_PROGRAM([[ + asm (".globl start; start:"); + asm (".globl _start; _start:"); + asm (".globl __start; __start:"); + void __main (void); + void __main (void) {} + ]], [[]])], [flag=1], [flag=0]) + if test x"$flag" = x1; then + grub_cv_target_cc_efiemu64_link_format="$format" + break + fi + done]) + if test x"$grub_cv_target_cc_efiemu64_link_format" = xunknown; then + efiemu_excuse="no suitable link format for efiemu64 found" + else + EFIEMU64_LINK_FORMAT="-Wl,$grub_cv_target_cc_efiemu64_link_format" + fi +fi +if test x"$enable_efiemu" = xyes && test x"$efiemu_excuse" != x ; then + AC_MSG_ERROR([efiemu runtime was explicitly requested but can't be compiled ($efiemu_excuse)]) +fi +if test x"$efiemu_excuse" = x ; then +enable_efiemu=yes +else +enable_efiemu=no +fi +AC_SUBST([enable_efiemu]) +AC_SUBST([EFIEMU64_LINK_FORMAT]) + +CFLAGS="$TARGET_CFLAGS" + AC_SUBST(TARGET_LDFLAGS_OLDMAGIC) From ba83ed1538b8765227bcdfbfe6fa013816f85be7 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Fri, 1 Jan 2016 11:13:54 +0300 Subject: [PATCH 592/722] Add missing BUILD_EXEEXT --- Makefile.am | 40 ++++++++++++++++++++-------------------- grub-core/Makefile.am | 2 +- grub-core/genmod.sh.in | 2 +- 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/Makefile.am b/Makefile.am index b8423b08d..3872b220c 100644 --- a/Makefile.am +++ b/Makefile.am @@ -89,20 +89,20 @@ CLEANFILES += build-grub-gen-widthspec$(BUILD_EXEEXT) if COND_STARFIELD starfield_DATA = dejavu_10.pf2 dejavu_12.pf2 dejavu_bold_14.pf2 dejavu_14.pf2 dejavu_16.pf2 $(starfield_theme_files) -dejavu_10.pf2: $(DJVU_FONT_SOURCE) build-grub-mkfont - ./build-grub-mkfont -s 10 -o $@ $(DJVU_FONT_SOURCE) +dejavu_10.pf2: $(DJVU_FONT_SOURCE) build-grub-mkfont$(BUILD_EXEEXT) + ./build-grub-mkfont$(BUILD_EXEEXT) -s 10 -o $@ $(DJVU_FONT_SOURCE) CLEANFILES += dejavu_10.pf2 -dejavu_12.pf2: $(DJVU_FONT_SOURCE) build-grub-mkfont - ./build-grub-mkfont -s 12 -o $@ $(DJVU_FONT_SOURCE) +dejavu_12.pf2: $(DJVU_FONT_SOURCE) build-grub-mkfont$(BUILD_EXEEXT) + ./build-grub-mkfont$(BUILD_EXEEXT) -s 12 -o $@ $(DJVU_FONT_SOURCE) CLEANFILES += dejavu_12.pf2 -dejavu_14.pf2: $(DJVU_FONT_SOURCE) build-grub-mkfont - ./build-grub-mkfont -s 14 -o $@ $(DJVU_FONT_SOURCE) +dejavu_14.pf2: $(DJVU_FONT_SOURCE) build-grub-mkfont$(BUILD_EXEEXT) + ./build-grub-mkfont$(BUILD_EXEEXT) -s 14 -o $@ $(DJVU_FONT_SOURCE) CLEANFILES += dejavu_14.pf2 -dejavu_bold_14.pf2: $(DJVU_FONT_SOURCE) build-grub-mkfont - ./build-grub-mkfont -b -s 14 -o $@ $(DJVU_FONT_SOURCE) +dejavu_bold_14.pf2: $(DJVU_FONT_SOURCE) build-grub-mkfont$(BUILD_EXEEXT) + ./build-grub-mkfont$(BUILD_EXEEXT) -b -s 14 -o $@ $(DJVU_FONT_SOURCE) CLEANFILES += dejavu_bold_14.pf2 -dejavu_16.pf2: $(DJVU_FONT_SOURCE) build-grub-mkfont - ./build-grub-mkfont -s 16 -o $@ $(DJVU_FONT_SOURCE) +dejavu_16.pf2: $(DJVU_FONT_SOURCE) build-grub-mkfont$(BUILD_EXEEXT) + ./build-grub-mkfont$(BUILD_EXEEXT) -s 16 -o $@ $(DJVU_FONT_SOURCE) CLEANFILES += dejavu_16.pf2 else starfield_DATA = @@ -111,28 +111,28 @@ endif EXTRA_DIST += $(starfield_theme_files) EXTRA_DIST += $(srcdir)/themes/starfield/src/slider_s.xcf $(srcdir)/themes/starfield/src/slider_n.xcf $(srcdir)/themes/starfield/src/slider_c.xcf $(srcdir)/themes/starfield/src/blob_nw.xcf $(srcdir)/themes/starfield/src/bootmenu/center.xcf $(srcdir)/themes/starfield/src/bootmenu/corner.xcf $(srcdir)/themes/starfield/src/bootmenu/side.xcf $(srcdir)/themes/starfield/src/terminalbox/side.xcf $(srcdir)/themes/starfield/src/terminalbox/corner.xcf $(srcdir)/themes/starfield/src/terminalbox/center.xcf -unicode.pf2: $(FONT_SOURCE) build-grub-mkfont - ./build-grub-mkfont -o $@ $(FONT_SOURCE) || (rm -f $@; exit 1) +unicode.pf2: $(FONT_SOURCE) build-grub-mkfont$(BUILD_EXEEXT) + ./build-grub-mkfont$(BUILD_EXEEXT) -o $@ $(FONT_SOURCE) || (rm -f $@; exit 1) CLEANFILES += unicode.pf2 # Arrows and lines are needed to draw the menu, so always include them UNICODE_ARROWS=0x2190-0x2193 UNICODE_LINES=0x2501-0x251B -ascii.pf2: $(FONT_SOURCE) build-grub-mkfont - ./build-grub-mkfont -o $@ $(FONT_SOURCE) -r 0x0-0x7f,$(UNICODE_ARROWS),$(UNICODE_LINES) || (rm -f $@; exit 1) +ascii.pf2: $(FONT_SOURCE) build-grub-mkfont$(BUILD_EXEEXT) + ./build-grub-mkfont$(BUILD_EXEEXT) -o $@ $(FONT_SOURCE) -r 0x0-0x7f,$(UNICODE_ARROWS),$(UNICODE_LINES) || (rm -f $@; exit 1) CLEANFILES += ascii.pf2 -euro.pf2: $(FONT_SOURCE) build-grub-mkfont - ./build-grub-mkfont -o $@ $(FONT_SOURCE) -r 0x0-0x4ff,0x1e00-0x1fff,$(UNICODE_ARROWS),$(UNICODE_LINES) || (rm -f $@; exit 1) +euro.pf2: $(FONT_SOURCE) build-grub-mkfont$(BUILD_EXEEXT) + ./build-grub-mkfont$(BUILD_EXEEXT) -o $@ $(FONT_SOURCE) -r 0x0-0x4ff,0x1e00-0x1fff,$(UNICODE_ARROWS),$(UNICODE_LINES) || (rm -f $@; exit 1) CLEANFILES += euro.pf2 -ascii.h: $(FONT_SOURCE) build-grub-gen-asciih - ./build-grub-gen-asciih $(FONT_SOURCE) $@ || (rm -f $@; exit 1) +ascii.h: $(FONT_SOURCE) build-grub-gen-asciih$(BUILD_EXEEXT) + ./build-grub-gen-asciih$(BUILD_EXEEXT) $(FONT_SOURCE) $@ || (rm -f $@; exit 1) CLEANFILES += ascii.h -widthspec.h: $(FONT_SOURCE) build-grub-gen-widthspec - ./build-grub-gen-widthspec $(FONT_SOURCE) $@ || (rm -f $@; exit 1) +widthspec.h: $(FONT_SOURCE) build-grub-gen-widthspec$(BUILD_EXEEXT) + ./build-grub-gen-widthspec$(BUILD_EXEEXT) $(FONT_SOURCE) $@ || (rm -f $@; exit 1) CLEANFILES += widthspec.h # Install config.h into platformdir diff --git a/grub-core/Makefile.am b/grub-core/Makefile.am index 508e86bcd..90502cb1e 100644 --- a/grub-core/Makefile.am +++ b/grub-core/Makefile.am @@ -394,7 +394,7 @@ moddep.lst: syminfo.lst genmoddep.awk video.lst platform_DATA += moddep.lst CLEANFILES += config.log syminfo.lst moddep.lst -$(MOD_FILES): %.mod : genmod.sh moddep.lst %.module$(EXEEXT) build-grub-module-verifier +$(MOD_FILES): %.mod : genmod.sh moddep.lst %.module$(EXEEXT) build-grub-module-verifier$(BUILD_EXEEXT) TARGET_OBJ2ELF=@TARGET_OBJ2ELF@ sh $^ $@ platform_DATA += $(MOD_FILES) platform_DATA += modinfo.sh diff --git a/grub-core/genmod.sh.in b/grub-core/genmod.sh.in index ca2e59d5c..045817b15 100644 --- a/grub-core/genmod.sh.in +++ b/grub-core/genmod.sh.in @@ -94,6 +94,6 @@ else rm -f $tmpfile.bin fi if test x@platform@ != xemu; then - ./build-grub-module-verifier $tmpfile @target_cpu@ + ./build-grub-module-verifier@BUILD_EXEEXT@ $tmpfile @target_cpu@ fi mv $tmpfile $outfile From 19554a6034edfc333143fd7dc4842429a64bbd2d Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sat, 2 Jan 2016 19:02:19 +0300 Subject: [PATCH 593/722] acpihalt: fix GRUB_DSDT_TEST compilation --- grub-core/commands/acpihalt.c | 2 ++ include/grub/acpi.h | 2 ++ 2 files changed, 4 insertions(+) diff --git a/grub-core/commands/acpihalt.c b/grub-core/commands/acpihalt.c index da68b5b52..412a9c9ac 100644 --- a/grub-core/commands/acpihalt.c +++ b/grub-core/commands/acpihalt.c @@ -26,6 +26,8 @@ #define grub_dprintf(cond, args...) printf ( args ) #define grub_printf printf +#define grub_util_fopen fopen +#define grub_memcmp memcmp typedef uint64_t grub_uint64_t; typedef uint32_t grub_uint32_t; typedef uint16_t grub_uint16_t; diff --git a/include/grub/acpi.h b/include/grub/acpi.h index 8a8110241..10bfbd2cd 100644 --- a/include/grub/acpi.h +++ b/include/grub/acpi.h @@ -22,6 +22,8 @@ #ifndef GRUB_DSDT_TEST #include #include +#else +#define GRUB_PACKED __attribute__ ((packed)) #endif #define GRUB_RSDP_SIGNATURE "RSD PTR " From aa7bb4607bb799b2790ea008bcfd8d6ca0a6d752 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sat, 2 Jan 2016 21:33:18 +0300 Subject: [PATCH 594/722] acpihalt: add GRUB_ACPI_OPCODE_CREATE_DWORD_FIELD (0x8a) Fixes ACPI halt on ASUSTeK P8B75-V, Bios: American Megatrends v: 0414 date: 04/24/2012 Reported-By: Goh Lip --- grub-core/commands/acpihalt.c | 1 + include/grub/acpi.h | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/grub-core/commands/acpihalt.c b/grub-core/commands/acpihalt.c index 412a9c9ac..9cc7f18e3 100644 --- a/grub-core/commands/acpihalt.c +++ b/grub-core/commands/acpihalt.c @@ -248,6 +248,7 @@ get_sleep_type (grub_uint8_t *table, grub_uint8_t *ptr, grub_uint8_t *end, if (!add) return -1; break; + case GRUB_ACPI_OPCODE_CREATE_DWORD_FIELD: case GRUB_ACPI_OPCODE_CREATE_WORD_FIELD: case GRUB_ACPI_OPCODE_CREATE_BYTE_FIELD: { diff --git a/include/grub/acpi.h b/include/grub/acpi.h index 10bfbd2cd..a4224e046 100644 --- a/include/grub/acpi.h +++ b/include/grub/acpi.h @@ -221,9 +221,10 @@ enum GRUB_ACPI_OPCODE_CONCATRES = 0x84, GRUB_ACPI_OPCODE_MOD = 0x85, GRUB_ACPI_OPCODE_INDEX = 0x88, - GRUB_ACPI_OPCODE_TOSTRING = 0x9c, + GRUB_ACPI_OPCODE_CREATE_DWORD_FIELD = 0x8a, GRUB_ACPI_OPCODE_CREATE_WORD_FIELD = 0x8b, GRUB_ACPI_OPCODE_CREATE_BYTE_FIELD = 0x8c, + GRUB_ACPI_OPCODE_TOSTRING = 0x9c, GRUB_ACPI_OPCODE_IF = 0xa0, GRUB_ACPI_OPCODE_ONES = 0xff }; enum From 300be005a88930e1b9273c7eec7c239b6cf7beae Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Tue, 5 Jan 2016 11:54:39 +0100 Subject: [PATCH 595/722] Update checksums --- grub-core/tests/checksums.h | 594 ++++++++---------------------------- 1 file changed, 129 insertions(+), 465 deletions(-) diff --git a/grub-core/tests/checksums.h b/grub-core/tests/checksums.h index c9807a0dc..b42d63d25 100644 --- a/grub-core/tests/checksums.h +++ b/grub-core/tests/checksums.h @@ -1,465 +1,129 @@ - { "cmdline_cat", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x7dbff368, 0x7dbff368, 0x5a5bdc8d, 0x5a5bdc8d, 0x79753177, 0x79753177, 0xd01ede5b, 0xd01ede5b, 0x13708a73, 0x13708a73, 0x90186de3, 0x90186de3, 0xe63d02a2, 0xe63d02a2, 0x2c9dc262, 0x2c9dc262, 0x3eebd7b, 0x3eebd7b, 0xe8f3a5d8, 0xe8f3a5d8, 0xd38ecfe3, 0xd38ecfe3, 0x51878485, 0x51878485, 0xcbdb6d67, 0xcbdb6d67, 0xca25582, 0xca25582, 0x5bea0484, 0x5bea0484, 0x9ec5f71d, 0x9ec5f71d, 0x3f0bd7bc, 0x3f0bd7bc, 0xdbb0a5d2, 0xdbb0a5d2, 0xea710e2f, 0xea710e2f, 0xd14933fe, 0xd14933fe, 0x4906b783, 0xffd1d04b, 0xa159bdf9, 0xa159bdf9, }, 45 }, - { "cmdline_cat", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0xf1546749, 0xf1546749, 0x95d30576, 0x95d30576, 0x77f13935, 0x77f13935, 0xcc296836, 0xcc296836, 0x9af42bc7, 0x9af42bc7, 0x84c23709, 0x84c23709, 0x26b5a3c5, 0x26b5a3c5, 0x52d943fb, 0x52d943fb, 0x38beda82, 0x38beda82, 0xc12306b1, 0xc12306b1, 0xed251115, 0xed251115, 0xe0099a2f, 0xe0099a2f, 0xee929157, 0xee929157, 0xd96a1169, 0xd96a1169, 0x42fac799, 0x42fac799, 0x635af416, 0x635af416, 0x8e90342f, 0x8e90342f, 0xed467cbf, 0xed467cbf, 0x999fc60b, 0x999fc60b, 0xb45d2b1f, 0xb45d2b1f, 0x7e23ccef, 0x8e988beb, 0x8783fdf8, 0x8783fdf8, }, 45 }, - { "cmdline_cat", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x50b82239, 0x50b82239, 0x82c36c12, 0x82c36c12, 0x6311208d, 0x6311208d, 0x816bd4b3, 0x816bd4b3, 0xc9281fd0, 0xc9281fd0, 0x75767bac, 0x75767bac, 0x52edeac, 0x52edeac, 0xfdb551f7, 0xfdb551f7, 0xba21cd3, 0xba21cd3, 0xf2b3468a, 0xf2b3468a, 0xd5560323, 0xd5560323, 0x12c650f6, 0x12c650f6, 0x3d6c5861, 0x3d6c5861, 0x50062423, 0x50062423, 0x2ce22983, 0x2ce22983, 0x4996bc4d, 0x4996bc4d, 0x50450525, 0x50450525, 0xe1c94312, 0xe1c94312, 0x21224aac, 0x21224aac, 0x94cbe214, 0x94cbe214, 0x4578c664, 0x38a9dbd2, 0xa9eb4c48, 0xa9eb4c48, }, 45 }, - { "cmdline_cat", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0xbb687653, 0xbb687653, 0xa81427a7, 0xa81427a7, 0x71d7f3b, 0x71d7f3b, 0x25fea6ca, 0x25fea6ca, 0x17c19d74, 0x17c19d74, 0x4779bf48, 0x4779bf48, 0xe424e759, 0xe424e759, 0xb57fb5ae, 0xb57fb5ae, 0xd877002b, 0xd877002b, 0xdd8d7442, 0xdd8d7442, 0xe2536fde, 0xe2536fde, 0x1ebba341, 0x1ebba341, 0xef042176, 0xef042176, 0x6137f228, 0x6137f228, 0xf04a8558, 0xf04a8558, 0xff72172d, 0xff72172d, 0x5f26278f, 0x5f26278f, 0x3ed777c, 0x3ed777c, 0xb1d686e, 0xb1d686e, 0x5cead249, 0x5cead249, 0x271487f6, 0x9b7201b9, 0x6c2f147d, 0x6c2f147d, }, 45 }, - { "cmdline_cat", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x378dc141, 0x378dc141, 0xc7564497, 0xc7564497, 0xd20e9dba, 0xd20e9dba, 0xf84e8efb, 0xf84e8efb, 0x620d984, 0x620d984, 0x509042b4, 0x509042b4, 0x2bf32e11, 0x2bf32e11, 0x7c6fe3a0, 0x7c6fe3a0, 0x18106e6f, 0x18106e6f, 0xba983948, 0xba983948, 0xd85321cc, 0xd85321cc, 0xc22777cd, 0xc22777cd, 0x85b737c8, 0x85b737c8, 0x55590c10, 0x55590c10, 0x371ba701, 0x371ba701, 0x2da6264, 0x2da6264, 0x77c1ff46, 0x77c1ff46, 0xf2485577, 0xf2485577, 0x93e9eeeb, 0x93e9eeeb, 0x1460059, 0x1460059, 0xfbbbaa1, 0xa03c490a, 0x234dcb08, 0x234dcb08, }, 45 }, - { "cmdline_cat", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xd803b53b, 0xd803b53b, 0x70b7ae8b, 0x70b7ae8b, 0xa20d9a15, 0xa20d9a15, 0x6113d33b, 0x6113d33b, 0xfd38d301, 0xfd38d301, 0x8b04db4, 0x8b04db4, 0xdae859df, 0xdae859df, 0x80cf138b, 0x80cf138b, 0xdfa6ef9, 0xdfa6ef9, 0x856adaf0, 0x856adaf0, 0x7023cc2d, 0x7023cc2d, 0xad7e7d54, 0xad7e7d54, 0xde8eff49, 0xde8eff49, 0x34355cc3, 0x34355cc3, 0x25adccda, 0x25adccda, 0x6d6c350d, 0x6d6c350d, 0x1c49b499, 0x1c49b499, 0x8188f1b4, 0x8188f1b4, 0x5556dc0c, 0x5556dc0c, 0xbd9ef1f5, 0xbd9ef1f5, 0x5176575b, 0x19da9ee1, 0x6e2f07c, 0x6e2f07c, }, 45 }, - { "cmdline_cat", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0xed7d2809, 0xed7d2809, 0x52c14224, 0x52c14224, 0xec52d912, 0xec52d912, 0x63276ae2, 0x63276ae2, 0xeeb4bfa4, 0xeeb4bfa4, 0xdf0f1ff0, 0xdf0f1ff0, 0xe2021708, 0xe2021708, 0x67c17085, 0x67c17085, 0x646e4d78, 0x646e4d78, 0x3b15f4b6, 0x3b15f4b6, 0xf4945ac5, 0xf4945ac5, 0x6cf60c00, 0x6cf60c00, 0x126648cd, 0x126648cd, 0xe7b8e348, 0xe7b8e348, 0x1626e35f, 0x1626e35f, 0x8022976c, 0x8022976c, 0xbc7e6d22, 0xbc7e6d22, 0xa2d50ad6, 0xa2d50ad6, 0x5072fea, 0x5072fea, 0x8481a563, 0x8481a563, 0x60a95143, 0x12fda168, 0xc8fe0549, 0xc8fe0549, }, 45 }, - { "cmdline_cat", 640, 480, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi256 */, (grub_uint32_t []) { 0x59c36f00, 0x7dbff368, 0x7dbff368, 0x5a5bdc8d, 0x5a5bdc8d, 0x79753177, 0x79753177, 0xd01ede5b, 0xd01ede5b, 0x13708a73, 0x13708a73, 0x90186de3, 0x90186de3, 0xe63d02a2, 0xe63d02a2, 0x2c9dc262, 0x2c9dc262, 0x3eebd7b, 0x3eebd7b, 0xe8f3a5d8, 0xe8f3a5d8, 0xd38ecfe3, 0xd38ecfe3, 0x51878485, 0x51878485, 0xcbdb6d67, 0xcbdb6d67, 0xca25582, 0xca25582, 0x5bea0484, 0x5bea0484, 0x9ec5f71d, 0x9ec5f71d, 0x3f0bd7bc, 0x3f0bd7bc, 0xdbb0a5d2, 0xdbb0a5d2, 0xea710e2f, 0xea710e2f, 0xd14933fe, 0xd14933fe, 0x4906b783, 0xffd1d04b, 0xa159bdf9, 0xa159bdf9, }, 45 }, - { "cmdline_cat", 800, 600, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi256 */, (grub_uint32_t []) { 0xaa4593fe, 0xf1546749, 0xf1546749, 0x95d30576, 0x95d30576, 0x77f13935, 0x77f13935, 0xcc296836, 0xcc296836, 0x9af42bc7, 0x9af42bc7, 0x84c23709, 0x84c23709, 0x26b5a3c5, 0x26b5a3c5, 0x52d943fb, 0x52d943fb, 0x38beda82, 0x38beda82, 0xc12306b1, 0xc12306b1, 0xed251115, 0xed251115, 0xe0099a2f, 0xe0099a2f, 0xee929157, 0xee929157, 0xd96a1169, 0xd96a1169, 0x42fac799, 0x42fac799, 0x635af416, 0x635af416, 0x8e90342f, 0x8e90342f, 0xed467cbf, 0xed467cbf, 0x999fc60b, 0x999fc60b, 0xb45d2b1f, 0xb45d2b1f, 0x7e23ccef, 0x8e988beb, 0x8783fdf8, 0x8783fdf8, }, 45 }, - { "cmdline_cat", 1024, 768, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi256 */, (grub_uint32_t []) { 0xc9cbf769, 0x50b82239, 0x50b82239, 0x82c36c12, 0x82c36c12, 0x6311208d, 0x6311208d, 0x816bd4b3, 0x816bd4b3, 0xc9281fd0, 0xc9281fd0, 0x75767bac, 0x75767bac, 0x52edeac, 0x52edeac, 0xfdb551f7, 0xfdb551f7, 0xba21cd3, 0xba21cd3, 0xf2b3468a, 0xf2b3468a, 0xd5560323, 0xd5560323, 0x12c650f6, 0x12c650f6, 0x3d6c5861, 0x3d6c5861, 0x50062423, 0x50062423, 0x2ce22983, 0x2ce22983, 0x4996bc4d, 0x4996bc4d, 0x50450525, 0x50450525, 0xe1c94312, 0xe1c94312, 0x21224aac, 0x21224aac, 0x94cbe214, 0x94cbe214, 0x4578c664, 0x38a9dbd2, 0xa9eb4c48, 0xa9eb4c48, }, 45 }, - { "cmdline_cat", 640, 480, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 640x480xrgba5550 */, (grub_uint32_t []) { 0x5387d57f, 0x93fbd3a3, 0x93fbd3a3, 0x1617bee0, 0x1617bee0, 0x4bfbae7f, 0x4bfbae7f, 0xa3558248, 0xa3558248, 0xaf468a11, 0xaf468a11, 0x68ac5986, 0x68ac5986, 0xd8065600, 0xd8065600, 0xef6c6222, 0xef6c6222, 0x1a04371, 0x1a04371, 0xc92981b6, 0xc92981b6, 0x53f9bfc8, 0x53f9bfc8, 0xfef01300, 0xfef01300, 0xce753805, 0xce753805, 0x858f6540, 0x858f6540, 0x6429dae4, 0x6429dae4, 0x19222aa5, 0x19222aa5, 0x3f9a0303, 0x3f9a0303, 0x978a47da, 0x978a47da, 0x6bf7f199, 0x6bf7f199, 0x97dab6d, 0x97dab6d, 0xeb643dbd, 0x9fe6a006, 0x2b7a0b5b, 0x2b7a0b5b, }, 45 }, - { "cmdline_cat", 800, 600, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 800x600xrgba5550 */, (grub_uint32_t []) { 0xf83ee7aa, 0xe8381636, 0xe8381636, 0x977b32f5, 0x977b32f5, 0x54bb62c1, 0x54bb62c1, 0xe26211f2, 0xe26211f2, 0xb0d0aca3, 0xb0d0aca3, 0x8d1f7491, 0x8d1f7491, 0x261a3820, 0x261a3820, 0x571c16d3, 0x571c16d3, 0xdc5fb880, 0xdc5fb880, 0xc8b086fe, 0xc8b086fe, 0x55b07770, 0x55b07770, 0x1d5e160, 0x1d5e160, 0x5e5dddc8, 0x5e5dddc8, 0xceeaa332, 0xceeaa332, 0x81c9d3f3, 0x81c9d3f3, 0xa6bbab67, 0xa6bbab67, 0x9366a264, 0x9366a264, 0x4bcbc84c, 0x4bcbc84c, 0x8aacda73, 0x8aacda73, 0x356159d0, 0x356159d0, 0x74872545, 0x5a28a86f, 0x3a1f5494, 0x3a1f5494, }, 45 }, - { "cmdline_cat", 1024, 768, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 1024x768xrgba5550 */, (grub_uint32_t []) { 0x724366e5, 0xccbd401, 0xccbd401, 0x35859629, 0x35859629, 0x269f013b, 0x269f013b, 0xe8c8196, 0xe8c8196, 0x95e2849c, 0x95e2849c, 0xb2019543, 0xb2019543, 0xf739b6c9, 0xf739b6c9, 0xd8227519, 0xd8227519, 0x6b1ae8cf, 0x6b1ae8cf, 0x84fbe9b2, 0x84fbe9b2, 0xed69a305, 0xed69a305, 0x15f4f0cf, 0x15f4f0cf, 0x57ce0973, 0x57ce0973, 0x3f5b0b97, 0x3f5b0b97, 0xc3e87bef, 0xc3e87bef, 0x3ac7584b, 0x3ac7584b, 0xdb95f2c7, 0xdb95f2c7, 0xc1942d4c, 0xc1942d4c, 0x17e9634e, 0x17e9634e, 0xd8dd41a3, 0xd8dd41a3, 0x927a8a2f, 0x339d3240, 0x398e6a2a, 0x398e6a2a, }, 45 }, - { "cmdline_cat", 640, 480, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 640x480xrgba5650 */, (grub_uint32_t []) { 0x5387d57f, 0xa06498a0, 0xa06498a0, 0xd1336ad7, 0xd1336ad7, 0x68c888e0, 0x68c888e0, 0xf01fb74, 0xf01fb74, 0x6b743235, 0x6b743235, 0xe7b71a49, 0xe7b71a49, 0x798da4d7, 0x798da4d7, 0x5398f44b, 0x5398f44b, 0x4794ee5e, 0x4794ee5e, 0x61c2cb0d, 0x61c2cb0d, 0xad3fcef3, 0xad3fcef3, 0xd9b6f291, 0xd9b6f291, 0xbaf0962d, 0xbaf0962d, 0x11848b9e, 0x11848b9e, 0xb8f3d2bf, 0xb8f3d2bf, 0x3f9978, 0x3f9978, 0xafd76c24, 0xafd76c24, 0xee0b9b9e, 0xee0b9b9e, 0x1f80451e, 0x1f80451e, 0x817e030a, 0x817e030a, 0x64ee9a5d, 0x1d187aed, 0xb2c05a4a, 0xb2c05a4a, }, 45 }, - { "cmdline_cat", 800, 600, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 800x600xrgba5650 */, (grub_uint32_t []) { 0xf83ee7aa, 0x95c83b7d, 0x95c83b7d, 0xb8cac2b5, 0xb8cac2b5, 0xf0ef977f, 0xf0ef977f, 0xc4640770, 0xc4640770, 0x8ea8595e, 0x8ea8595e, 0xc7d26302, 0xc7d26302, 0x6f756fbc, 0x6f756fbc, 0x68bc6258, 0x68bc6258, 0xe77cff10, 0xe77cff10, 0x835ae8e5, 0x835ae8e5, 0x622cfc05, 0x622cfc05, 0xe192499f, 0xe192499f, 0x3b976218, 0x3b976218, 0xe2dcd75, 0xe2dcd75, 0xed05eae8, 0xed05eae8, 0xc0b8ee9a, 0xc0b8ee9a, 0x255ec66a, 0x255ec66a, 0x3391d9b6, 0x3391d9b6, 0x779834b3, 0x779834b3, 0xdf77a37f, 0xdf77a37f, 0xd3cc8a1d, 0xfec30b6e, 0x884fa360, 0x884fa360, }, 45 }, - { "cmdline_cat", 1024, 768, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 1024x768xrgba5650 */, (grub_uint32_t []) { 0x724366e5, 0x698515fa, 0x698515fa, 0xc313ebe6, 0xc313ebe6, 0x32b9228f, 0x32b9228f, 0xa58d78e8, 0xa58d78e8, 0xf41d5153, 0xf41d5153, 0xdfa3af16, 0xdfa3af16, 0xd4a68422, 0xd4a68422, 0xa7ea67e0, 0xa7ea67e0, 0xaee4c8f6, 0xaee4c8f6, 0x78ddd8aa, 0x78ddd8aa, 0xe662b827, 0xe662b827, 0x190ab892, 0x190ab892, 0x7c1e04ab, 0x7c1e04ab, 0xae4e2ed2, 0xae4e2ed2, 0x9ac52f8d, 0x9ac52f8d, 0x7e7b6776, 0x7e7b6776, 0x21c37700, 0x21c37700, 0x4fc11e7c, 0x4fc11e7c, 0x612a17d, 0x612a17d, 0x1f549440, 0x1f549440, 0xd6ce5af0, 0x2751d45f, 0x41e24797, 0x41e24797, }, 45 }, - { "cmdline_cat", 640, 480, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 640x480xrgba8880 */, (grub_uint32_t []) { 0x1c955882, 0x7a06e04b, 0x7a06e04b, 0x122f59ab, 0x122f59ab, 0x993a50b9, 0x993a50b9, 0x5545f8f, 0x5545f8f, 0xcdd2b587, 0xcdd2b587, 0x18bec138, 0x18bec138, 0xa9b4345d, 0xa9b4345d, 0x92c6eb1c, 0x92c6eb1c, 0x2aa44d63, 0x2aa44d63, 0xc9e7b549, 0xc9e7b549, 0x24732d85, 0x24732d85, 0xeedce06, 0xeedce06, 0x69a732a1, 0x69a732a1, 0xc53906e5, 0xc53906e5, 0x306e0f4b, 0x306e0f4b, 0x895e6f09, 0x895e6f09, 0x27f1c24e, 0x27f1c24e, 0x76a2b606, 0x76a2b606, 0x9fdd1ff3, 0x9fdd1ff3, 0x408d0a19, 0x408d0a19, 0xc9b3f877, 0xce19a637, 0x8cfd7321, 0x8cfd7321, }, 45 }, - { "cmdline_cat", 800, 600, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 800x600xrgba8880 */, (grub_uint32_t []) { 0x4d266f7a, 0x9fa21cbe, 0x9fa21cbe, 0xa9ad84e6, 0xa9ad84e6, 0x4f4ccbc, 0x4f4ccbc, 0x6a4f5fda, 0x6a4f5fda, 0x4d4ccb50, 0x4d4ccb50, 0xb854236c, 0xb854236c, 0x990a5b4a, 0x990a5b4a, 0xa9dba8c8, 0xa9dba8c8, 0xe12b4ca1, 0xe12b4ca1, 0x4200ebc0, 0x4200ebc0, 0x86a931cf, 0x86a931cf, 0xda3a178, 0xda3a178, 0x2739917d, 0x2739917d, 0x48005e41, 0x48005e41, 0x550a94ac, 0x550a94ac, 0x73f363b6, 0x73f363b6, 0x4811082a, 0x4811082a, 0xdc025f10, 0xdc025f10, 0x4f18937e, 0x4f18937e, 0xa3749fd8, 0xa3749fd8, 0x93ce5c0b, 0xdddd4de6, 0x97f43654, 0x97f43654, }, 45 }, - { "cmdline_cat", 1024, 768, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 1024x768xrgba8880 */, (grub_uint32_t []) { 0x1ed9d731, 0x7d9b5dd7, 0x7d9b5dd7, 0x42e1176a, 0x42e1176a, 0x7e2da576, 0x7e2da576, 0xd5a8afa, 0xd5a8afa, 0x3eb2146b, 0x3eb2146b, 0x60d9b3, 0x60d9b3, 0xb893f5ca, 0xb893f5ca, 0xd431b2bf, 0xd431b2bf, 0x8ea1b6a6, 0x8ea1b6a6, 0x4d730ad0, 0x4d730ad0, 0x28d1888b, 0x28d1888b, 0x6d8c3672, 0x6d8c3672, 0x65dec2dd, 0x65dec2dd, 0x9d7c6d99, 0x9d7c6d99, 0xdfcd1eba, 0xdfcd1eba, 0xed4fb650, 0xed4fb650, 0xd9f1574c, 0xd9f1574c, 0x2b05a17e, 0x2b05a17e, 0x64e652f5, 0x64e652f5, 0x5f83fdb1, 0x5f83fdb1, 0x7918b180, 0xf54e3c4a, 0xe26cf2de, 0xe26cf2de, }, 45 }, - { "cmdline_cat", 640, 480, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 640x480xbgra5550 */, (grub_uint32_t []) { 0x5387d57f, 0x93fbd3a3, 0x93fbd3a3, 0x1617bee0, 0x1617bee0, 0x4bfbae7f, 0x4bfbae7f, 0xa3558248, 0xa3558248, 0xaf468a11, 0xaf468a11, 0x68ac5986, 0x68ac5986, 0xd8065600, 0xd8065600, 0xef6c6222, 0xef6c6222, 0x1a04371, 0x1a04371, 0xc92981b6, 0xc92981b6, 0x53f9bfc8, 0x53f9bfc8, 0xfef01300, 0xfef01300, 0xce753805, 0xce753805, 0x858f6540, 0x858f6540, 0x6429dae4, 0x6429dae4, 0x19222aa5, 0x19222aa5, 0x3f9a0303, 0x3f9a0303, 0x978a47da, 0x978a47da, 0x6bf7f199, 0x6bf7f199, 0x97dab6d, 0x97dab6d, 0xeb643dbd, 0x9fe6a006, 0x2b7a0b5b, 0x2b7a0b5b, }, 45 }, - { "cmdline_cat", 800, 600, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 800x600xbgra5550 */, (grub_uint32_t []) { 0xf83ee7aa, 0xe8381636, 0xe8381636, 0x977b32f5, 0x977b32f5, 0x54bb62c1, 0x54bb62c1, 0xe26211f2, 0xe26211f2, 0xb0d0aca3, 0xb0d0aca3, 0x8d1f7491, 0x8d1f7491, 0x261a3820, 0x261a3820, 0x571c16d3, 0x571c16d3, 0xdc5fb880, 0xdc5fb880, 0xc8b086fe, 0xc8b086fe, 0x55b07770, 0x55b07770, 0x1d5e160, 0x1d5e160, 0x5e5dddc8, 0x5e5dddc8, 0xceeaa332, 0xceeaa332, 0x81c9d3f3, 0x81c9d3f3, 0xa6bbab67, 0xa6bbab67, 0x9366a264, 0x9366a264, 0x4bcbc84c, 0x4bcbc84c, 0x8aacda73, 0x8aacda73, 0x356159d0, 0x356159d0, 0x74872545, 0x5a28a86f, 0x3a1f5494, 0x3a1f5494, }, 45 }, - { "cmdline_cat", 1024, 768, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 1024x768xbgra5550 */, (grub_uint32_t []) { 0x724366e5, 0xccbd401, 0xccbd401, 0x35859629, 0x35859629, 0x269f013b, 0x269f013b, 0xe8c8196, 0xe8c8196, 0x95e2849c, 0x95e2849c, 0xb2019543, 0xb2019543, 0xf739b6c9, 0xf739b6c9, 0xd8227519, 0xd8227519, 0x6b1ae8cf, 0x6b1ae8cf, 0x84fbe9b2, 0x84fbe9b2, 0xed69a305, 0xed69a305, 0x15f4f0cf, 0x15f4f0cf, 0x57ce0973, 0x57ce0973, 0x3f5b0b97, 0x3f5b0b97, 0xc3e87bef, 0xc3e87bef, 0x3ac7584b, 0x3ac7584b, 0xdb95f2c7, 0xdb95f2c7, 0xc1942d4c, 0xc1942d4c, 0x17e9634e, 0x17e9634e, 0xd8dd41a3, 0xd8dd41a3, 0x927a8a2f, 0x339d3240, 0x398e6a2a, 0x398e6a2a, }, 45 }, - { "cmdline_cat", 640, 480, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 640x480xbgra5650 */, (grub_uint32_t []) { 0x5387d57f, 0xa06498a0, 0xa06498a0, 0xd1336ad7, 0xd1336ad7, 0x68c888e0, 0x68c888e0, 0xf01fb74, 0xf01fb74, 0x6b743235, 0x6b743235, 0xe7b71a49, 0xe7b71a49, 0x798da4d7, 0x798da4d7, 0x5398f44b, 0x5398f44b, 0x4794ee5e, 0x4794ee5e, 0x61c2cb0d, 0x61c2cb0d, 0xad3fcef3, 0xad3fcef3, 0xd9b6f291, 0xd9b6f291, 0xbaf0962d, 0xbaf0962d, 0x11848b9e, 0x11848b9e, 0xb8f3d2bf, 0xb8f3d2bf, 0x3f9978, 0x3f9978, 0xafd76c24, 0xafd76c24, 0xee0b9b9e, 0xee0b9b9e, 0x1f80451e, 0x1f80451e, 0x817e030a, 0x817e030a, 0x64ee9a5d, 0x1d187aed, 0xb2c05a4a, 0xb2c05a4a, }, 45 }, - { "cmdline_cat", 800, 600, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 800x600xbgra5650 */, (grub_uint32_t []) { 0xf83ee7aa, 0x95c83b7d, 0x95c83b7d, 0xb8cac2b5, 0xb8cac2b5, 0xf0ef977f, 0xf0ef977f, 0xc4640770, 0xc4640770, 0x8ea8595e, 0x8ea8595e, 0xc7d26302, 0xc7d26302, 0x6f756fbc, 0x6f756fbc, 0x68bc6258, 0x68bc6258, 0xe77cff10, 0xe77cff10, 0x835ae8e5, 0x835ae8e5, 0x622cfc05, 0x622cfc05, 0xe192499f, 0xe192499f, 0x3b976218, 0x3b976218, 0xe2dcd75, 0xe2dcd75, 0xed05eae8, 0xed05eae8, 0xc0b8ee9a, 0xc0b8ee9a, 0x255ec66a, 0x255ec66a, 0x3391d9b6, 0x3391d9b6, 0x779834b3, 0x779834b3, 0xdf77a37f, 0xdf77a37f, 0xd3cc8a1d, 0xfec30b6e, 0x884fa360, 0x884fa360, }, 45 }, - { "cmdline_cat", 1024, 768, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 1024x768xbgra5650 */, (grub_uint32_t []) { 0x724366e5, 0x698515fa, 0x698515fa, 0xc313ebe6, 0xc313ebe6, 0x32b9228f, 0x32b9228f, 0xa58d78e8, 0xa58d78e8, 0xf41d5153, 0xf41d5153, 0xdfa3af16, 0xdfa3af16, 0xd4a68422, 0xd4a68422, 0xa7ea67e0, 0xa7ea67e0, 0xaee4c8f6, 0xaee4c8f6, 0x78ddd8aa, 0x78ddd8aa, 0xe662b827, 0xe662b827, 0x190ab892, 0x190ab892, 0x7c1e04ab, 0x7c1e04ab, 0xae4e2ed2, 0xae4e2ed2, 0x9ac52f8d, 0x9ac52f8d, 0x7e7b6776, 0x7e7b6776, 0x21c37700, 0x21c37700, 0x4fc11e7c, 0x4fc11e7c, 0x612a17d, 0x612a17d, 0x1f549440, 0x1f549440, 0xd6ce5af0, 0x2751d45f, 0x41e24797, 0x41e24797, }, 45 }, - { "cmdline_cat", 640, 480, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 640x480xbgra8880 */, (grub_uint32_t []) { 0x1c955882, 0x7a06e04b, 0x7a06e04b, 0x122f59ab, 0x122f59ab, 0x993a50b9, 0x993a50b9, 0x5545f8f, 0x5545f8f, 0xcdd2b587, 0xcdd2b587, 0x18bec138, 0x18bec138, 0xa9b4345d, 0xa9b4345d, 0x92c6eb1c, 0x92c6eb1c, 0x2aa44d63, 0x2aa44d63, 0xc9e7b549, 0xc9e7b549, 0x24732d85, 0x24732d85, 0xeedce06, 0xeedce06, 0x69a732a1, 0x69a732a1, 0xc53906e5, 0xc53906e5, 0x306e0f4b, 0x306e0f4b, 0x895e6f09, 0x895e6f09, 0x27f1c24e, 0x27f1c24e, 0x76a2b606, 0x76a2b606, 0x9fdd1ff3, 0x9fdd1ff3, 0x408d0a19, 0x408d0a19, 0xc9b3f877, 0xce19a637, 0x8cfd7321, 0x8cfd7321, }, 45 }, - { "cmdline_cat", 800, 600, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 800x600xbgra8880 */, (grub_uint32_t []) { 0x4d266f7a, 0x9fa21cbe, 0x9fa21cbe, 0xa9ad84e6, 0xa9ad84e6, 0x4f4ccbc, 0x4f4ccbc, 0x6a4f5fda, 0x6a4f5fda, 0x4d4ccb50, 0x4d4ccb50, 0xb854236c, 0xb854236c, 0x990a5b4a, 0x990a5b4a, 0xa9dba8c8, 0xa9dba8c8, 0xe12b4ca1, 0xe12b4ca1, 0x4200ebc0, 0x4200ebc0, 0x86a931cf, 0x86a931cf, 0xda3a178, 0xda3a178, 0x2739917d, 0x2739917d, 0x48005e41, 0x48005e41, 0x550a94ac, 0x550a94ac, 0x73f363b6, 0x73f363b6, 0x4811082a, 0x4811082a, 0xdc025f10, 0xdc025f10, 0x4f18937e, 0x4f18937e, 0xa3749fd8, 0xa3749fd8, 0x93ce5c0b, 0xdddd4de6, 0x97f43654, 0x97f43654, }, 45 }, - { "cmdline_cat", 1024, 768, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 1024x768xbgra8880 */, (grub_uint32_t []) { 0x1ed9d731, 0x7d9b5dd7, 0x7d9b5dd7, 0x42e1176a, 0x42e1176a, 0x7e2da576, 0x7e2da576, 0xd5a8afa, 0xd5a8afa, 0x3eb2146b, 0x3eb2146b, 0x60d9b3, 0x60d9b3, 0xb893f5ca, 0xb893f5ca, 0xd431b2bf, 0xd431b2bf, 0x8ea1b6a6, 0x8ea1b6a6, 0x4d730ad0, 0x4d730ad0, 0x28d1888b, 0x28d1888b, 0x6d8c3672, 0x6d8c3672, 0x65dec2dd, 0x65dec2dd, 0x9d7c6d99, 0x9d7c6d99, 0xdfcd1eba, 0xdfcd1eba, 0xed4fb650, 0xed4fb650, 0xd9f1574c, 0xd9f1574c, 0x2b05a17e, 0x2b05a17e, 0x64e652f5, 0x64e652f5, 0x5f83fdb1, 0x5f83fdb1, 0x7918b180, 0xf54e3c4a, 0xe26cf2de, 0xe26cf2de, }, 45 }, - { "cmdline_cat", 640, 480, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 640x480xbgra8888 */, (grub_uint32_t []) { 0x9813a416, 0xbb687653, 0xbb687653, 0xa81427a7, 0xa81427a7, 0x71d7f3b, 0x71d7f3b, 0x25fea6ca, 0x25fea6ca, 0x17c19d74, 0x17c19d74, 0x4779bf48, 0x4779bf48, 0xe424e759, 0xe424e759, 0xb57fb5ae, 0xb57fb5ae, 0xd877002b, 0xd877002b, 0xdd8d7442, 0xdd8d7442, 0xe2536fde, 0xe2536fde, 0x1ebba341, 0x1ebba341, 0xef042176, 0xef042176, 0x6137f228, 0x6137f228, 0xf04a8558, 0xf04a8558, 0xff72172d, 0xff72172d, 0x5f26278f, 0x5f26278f, 0x3ed777c, 0x3ed777c, 0xb1d686e, 0xb1d686e, 0x5cead249, 0x5cead249, 0x271487f6, 0x9b7201b9, 0x6c2f147d, 0x6c2f147d, }, 45 }, - { "cmdline_cat", 800, 600, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 800x600xbgra8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x378dc141, 0x378dc141, 0xc7564497, 0xc7564497, 0xd20e9dba, 0xd20e9dba, 0xf84e8efb, 0xf84e8efb, 0x620d984, 0x620d984, 0x509042b4, 0x509042b4, 0x2bf32e11, 0x2bf32e11, 0x7c6fe3a0, 0x7c6fe3a0, 0x18106e6f, 0x18106e6f, 0xba983948, 0xba983948, 0xd85321cc, 0xd85321cc, 0xc22777cd, 0xc22777cd, 0x85b737c8, 0x85b737c8, 0x55590c10, 0x55590c10, 0x371ba701, 0x371ba701, 0x2da6264, 0x2da6264, 0x77c1ff46, 0x77c1ff46, 0xf2485577, 0xf2485577, 0x93e9eeeb, 0x93e9eeeb, 0x1460059, 0x1460059, 0xfbbbaa1, 0xa03c490a, 0x234dcb08, 0x234dcb08, }, 45 }, - { "cmdline_cat", 1024, 768, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 1024x768xbgra8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xd803b53b, 0xd803b53b, 0x70b7ae8b, 0x70b7ae8b, 0xa20d9a15, 0xa20d9a15, 0x6113d33b, 0x6113d33b, 0xfd38d301, 0xfd38d301, 0x8b04db4, 0x8b04db4, 0xdae859df, 0xdae859df, 0x80cf138b, 0x80cf138b, 0xdfa6ef9, 0xdfa6ef9, 0x856adaf0, 0x856adaf0, 0x7023cc2d, 0x7023cc2d, 0xad7e7d54, 0xad7e7d54, 0xde8eff49, 0xde8eff49, 0x34355cc3, 0x34355cc3, 0x25adccda, 0x25adccda, 0x6d6c350d, 0x6d6c350d, 0x1c49b499, 0x1c49b499, 0x8188f1b4, 0x8188f1b4, 0x5556dc0c, 0x5556dc0c, 0xbd9ef1f5, 0xbd9ef1f5, 0x5176575b, 0x19da9ee1, 0x6e2f07c, 0x6e2f07c, }, 45 }, - { "gfxterm_menu", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0xc5faf369, 0x64eb297a, 0xc5faf369, 0x860c3e2e, 0x59c36f00, 0x59c36f00, 0xc8b88a82, 0xc8b88a82, 0xc8b88a82, 0xb638e7e4, 0xb638e7e4, 0xb638e7e4, 0x751ada29, 0x751ada29, 0x751ada29, 0x59c36f00, 0x860c3e2e, 0x860c3e2e, 0x59c36f00, }, 20 }, - { "gfxterm_menu", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0xd50b0276, 0x23b87c98, 0xd50b0276, 0xfb0e8709, 0xaa4593fe, 0xaa4593fe, 0x8b63f19d, 0x8b63f19d, 0x8b63f19d, 0x2d96fcfa, 0x2d96fcfa, 0x2d96fcfa, 0xaf311e91, 0xaf311e91, 0xaf311e91, 0xaa4593fe, 0xfb0e8709, 0xfb0e8709, 0xaa4593fe, }, 20 }, - { "gfxterm_menu", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x353bd15d, 0x79836ff2, 0x353bd15d, 0x682cbcd9, 0xc9cbf769, 0xc9cbf769, 0xec23555f, 0xec23555f, 0xec23555f, 0x12fb9493, 0x12fb9493, 0x12fb9493, 0xfaad3b9f, 0xfaad3b9f, 0xfaad3b9f, 0xc9cbf769, 0x682cbcd9, 0x682cbcd9, 0xc9cbf769, }, 20 }, - { "gfxterm_menu", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x22bcc2fc, 0xc6c23ab4, 0x22bcc2fc, 0x72a46652, 0x9813a416, 0x9813a416, 0xc10419e0, 0xc10419e0, 0xc10419e0, 0x50df9fd3, 0x50df9fd3, 0x50df9fd3, 0xccaa6a11, 0xccaa6a11, 0xccaa6a11, 0x9813a416, 0x72a46652, 0x72a46652, 0x9813a416, }, 20 }, - { "gfxterm_menu", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x3afb9165, 0x767dd6a7, 0x3afb9165, 0x31409f, 0x5fcf013d, 0x5fcf013d, 0x77ba65ab, 0x77ba65ab, 0x77ba65ab, 0xa5aa7ddd, 0xa5aa7ddd, 0xa5aa7ddd, 0xba81fc20, 0xba81fc20, 0xba81fc20, 0x5fcf013d, 0x31409f, 0x31409f, 0x5fcf013d, }, 20 }, - { "gfxterm_menu", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xe13f0039, 0xb5783cd1, 0xe13f0039, 0x814ca453, 0xdd28f52b, 0xdd28f52b, 0xbc36f156, 0xbc36f156, 0xbc36f156, 0x9d0a08b2, 0x9d0a08b2, 0x9d0a08b2, 0x877b6b23, 0x877b6b23, 0x877b6b23, 0xdd28f52b, 0x814ca453, 0x814ca453, 0xdd28f52b, }, 20 }, - { "gfxterm_menu", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x154ac813, 0x5c191673, 0x154ac813, 0xeb0cc57e, 0x43d1f34, 0x43d1f34, 0xd204ac75, 0xd204ac75, 0xd204ac75, 0xad0e05dd, 0xad0e05dd, 0xad0e05dd, 0x452e3cf4, 0x452e3cf4, 0x452e3cf4, 0x43d1f34, 0xeb0cc57e, 0xeb0cc57e, 0x43d1f34, }, 20 }, - { "gfxterm_menu", 640, 480, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi256 */, (grub_uint32_t []) { 0x59c36f00, 0xc5faf369, 0x64eb297a, 0xc5faf369, 0x860c3e2e, 0x59c36f00, 0x59c36f00, 0xc8b88a82, 0xc8b88a82, 0xc8b88a82, 0xb638e7e4, 0xb638e7e4, 0xb638e7e4, 0x751ada29, 0x751ada29, 0x751ada29, 0x59c36f00, 0x860c3e2e, 0x860c3e2e, 0x59c36f00, }, 20 }, - { "gfxterm_menu", 800, 600, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi256 */, (grub_uint32_t []) { 0xaa4593fe, 0xd50b0276, 0x23b87c98, 0xd50b0276, 0xfb0e8709, 0xaa4593fe, 0xaa4593fe, 0x8b63f19d, 0x8b63f19d, 0x8b63f19d, 0x2d96fcfa, 0x2d96fcfa, 0x2d96fcfa, 0xaf311e91, 0xaf311e91, 0xaf311e91, 0xaa4593fe, 0xfb0e8709, 0xfb0e8709, 0xaa4593fe, }, 20 }, - { "gfxterm_menu", 1024, 768, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi256 */, (grub_uint32_t []) { 0xc9cbf769, 0x353bd15d, 0x79836ff2, 0x353bd15d, 0x682cbcd9, 0xc9cbf769, 0xc9cbf769, 0xec23555f, 0xec23555f, 0xec23555f, 0x12fb9493, 0x12fb9493, 0x12fb9493, 0xfaad3b9f, 0xfaad3b9f, 0xfaad3b9f, 0xc9cbf769, 0x682cbcd9, 0x682cbcd9, 0xc9cbf769, }, 20 }, - { "gfxterm_menu", 640, 480, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 640x480xrgba5550 */, (grub_uint32_t []) { 0x5387d57f, 0xe967dfb6, 0x7fedccee, 0xe967dfb6, 0xad6c250a, 0x5387d57f, 0x5387d57f, 0x71381c6, 0x71381c6, 0x71381c6, 0xc74aed0a, 0xc74aed0a, 0xc74aed0a, 0x20946f9c, 0x20946f9c, 0x20946f9c, 0x5387d57f, 0xad6c250a, 0xad6c250a, 0x5387d57f, }, 20 }, - { "gfxterm_menu", 800, 600, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 800x600xrgba5550 */, (grub_uint32_t []) { 0xf83ee7aa, 0x985bd9b5, 0xd5604814, 0x985bd9b5, 0x2233942a, 0xf83ee7aa, 0xf83ee7aa, 0x610deea9, 0x610deea9, 0x610deea9, 0xfd743e5a, 0xfd743e5a, 0xfd743e5a, 0xc5c795f2, 0xc5c795f2, 0xc5c795f2, 0xf83ee7aa, 0x2233942a, 0x2233942a, 0xf83ee7aa, }, 20 }, - { "gfxterm_menu", 1024, 768, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 1024x768xrgba5550 */, (grub_uint32_t []) { 0x724366e5, 0x928c0a8e, 0xd25dcf03, 0x928c0a8e, 0x83f9bfdb, 0x724366e5, 0x724366e5, 0xdbb2f05a, 0xdbb2f05a, 0xdbb2f05a, 0x9c8bb2a0, 0x9c8bb2a0, 0x9c8bb2a0, 0xf1a595ea, 0xf1a595ea, 0xf1a595ea, 0x724366e5, 0x83f9bfdb, 0x83f9bfdb, 0x724366e5, }, 20 }, - { "gfxterm_menu", 640, 480, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 640x480xrgba5650 */, (grub_uint32_t []) { 0x5387d57f, 0x116c0258, 0xed7d4786, 0x116c0258, 0xfef8bf61, 0x5387d57f, 0x5387d57f, 0x23c74007, 0x23c74007, 0x23c74007, 0xfd090fda, 0xfd090fda, 0xfd090fda, 0x6e8a9dc4, 0x6e8a9dc4, 0x6e8a9dc4, 0x5387d57f, 0xfef8bf61, 0xfef8bf61, 0x5387d57f, }, 20 }, - { "gfxterm_menu", 800, 600, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 800x600xrgba5650 */, (grub_uint32_t []) { 0xf83ee7aa, 0xd49b1c35, 0x37f70b09, 0xd49b1c35, 0xa55122d9, 0xf83ee7aa, 0xf83ee7aa, 0xa5fd8afa, 0xa5fd8afa, 0xa5fd8afa, 0xd72799ca, 0xd72799ca, 0xd72799ca, 0xe6b2c80c, 0xe6b2c80c, 0xe6b2c80c, 0xf83ee7aa, 0xa55122d9, 0xa55122d9, 0xf83ee7aa, }, 20 }, - { "gfxterm_menu", 1024, 768, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 1024x768xrgba5650 */, (grub_uint32_t []) { 0x724366e5, 0x2b3f0273, 0x6da0f134, 0x2b3f0273, 0xd9ed8903, 0x724366e5, 0x724366e5, 0xd0002838, 0xd0002838, 0xd0002838, 0x8990db68, 0x8990db68, 0x8990db68, 0x4127b52a, 0x4127b52a, 0x4127b52a, 0x724366e5, 0xd9ed8903, 0xd9ed8903, 0x724366e5, }, 20 }, - { "gfxterm_menu", 640, 480, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 640x480xrgba8880 */, (grub_uint32_t []) { 0x1c955882, 0x1e6b0284, 0x18f0ad39, 0x1e6b0284, 0x1e0bba22, 0x1c955882, 0x1c955882, 0x727420bf, 0x727420bf, 0x727420bf, 0xbd836d28, 0xbd836d28, 0xbd836d28, 0x43ea613d, 0x43ea613d, 0x43ea613d, 0x1c955882, 0x1e0bba22, 0x1e0bba22, 0x1c955882, }, 20 }, - { "gfxterm_menu", 800, 600, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 800x600xrgba8880 */, (grub_uint32_t []) { 0x4d266f7a, 0x1f279ca1, 0x976cb6e3, 0x1f279ca1, 0xdb3505a5, 0x4d266f7a, 0x4d266f7a, 0xc23ec599, 0xc23ec599, 0xc23ec599, 0x2449de26, 0x2449de26, 0x2449de26, 0xbc708ab6, 0xbc708ab6, 0xbc708ab6, 0x4d266f7a, 0xdb3505a5, 0xdb3505a5, 0x4d266f7a, }, 20 }, - { "gfxterm_menu", 1024, 768, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 1024x768xrgba8880 */, (grub_uint32_t []) { 0x1ed9d731, 0x21235dde, 0x13b8b442, 0x21235dde, 0xbdd75c39, 0x1ed9d731, 0x1ed9d731, 0x6ea8026e, 0x6ea8026e, 0x6ea8026e, 0xc0cc1cab, 0xc0cc1cab, 0xc0cc1cab, 0xe3a50d1d, 0xe3a50d1d, 0xe3a50d1d, 0x1ed9d731, 0xbdd75c39, 0xbdd75c39, 0x1ed9d731, }, 20 }, - { "gfxterm_menu", 640, 480, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 640x480xbgra5550 */, (grub_uint32_t []) { 0x5387d57f, 0xe967dfb6, 0x7fedccee, 0xe967dfb6, 0xad6c250a, 0x5387d57f, 0x5387d57f, 0x71381c6, 0x71381c6, 0x71381c6, 0xc74aed0a, 0xc74aed0a, 0xc74aed0a, 0x20946f9c, 0x20946f9c, 0x20946f9c, 0x5387d57f, 0xad6c250a, 0xad6c250a, 0x5387d57f, }, 20 }, - { "gfxterm_menu", 800, 600, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 800x600xbgra5550 */, (grub_uint32_t []) { 0xf83ee7aa, 0x985bd9b5, 0xd5604814, 0x985bd9b5, 0x2233942a, 0xf83ee7aa, 0xf83ee7aa, 0x610deea9, 0x610deea9, 0x610deea9, 0xfd743e5a, 0xfd743e5a, 0xfd743e5a, 0xc5c795f2, 0xc5c795f2, 0xc5c795f2, 0xf83ee7aa, 0x2233942a, 0x2233942a, 0xf83ee7aa, }, 20 }, - { "gfxterm_menu", 1024, 768, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 1024x768xbgra5550 */, (grub_uint32_t []) { 0x724366e5, 0x928c0a8e, 0xd25dcf03, 0x928c0a8e, 0x83f9bfdb, 0x724366e5, 0x724366e5, 0xdbb2f05a, 0xdbb2f05a, 0xdbb2f05a, 0x9c8bb2a0, 0x9c8bb2a0, 0x9c8bb2a0, 0xf1a595ea, 0xf1a595ea, 0xf1a595ea, 0x724366e5, 0x83f9bfdb, 0x83f9bfdb, 0x724366e5, }, 20 }, - { "gfxterm_menu", 640, 480, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 640x480xbgra5650 */, (grub_uint32_t []) { 0x5387d57f, 0x116c0258, 0xed7d4786, 0x116c0258, 0xfef8bf61, 0x5387d57f, 0x5387d57f, 0x23c74007, 0x23c74007, 0x23c74007, 0xfd090fda, 0xfd090fda, 0xfd090fda, 0x6e8a9dc4, 0x6e8a9dc4, 0x6e8a9dc4, 0x5387d57f, 0xfef8bf61, 0xfef8bf61, 0x5387d57f, }, 20 }, - { "gfxterm_menu", 800, 600, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 800x600xbgra5650 */, (grub_uint32_t []) { 0xf83ee7aa, 0xd49b1c35, 0x37f70b09, 0xd49b1c35, 0xa55122d9, 0xf83ee7aa, 0xf83ee7aa, 0xa5fd8afa, 0xa5fd8afa, 0xa5fd8afa, 0xd72799ca, 0xd72799ca, 0xd72799ca, 0xe6b2c80c, 0xe6b2c80c, 0xe6b2c80c, 0xf83ee7aa, 0xa55122d9, 0xa55122d9, 0xf83ee7aa, }, 20 }, - { "gfxterm_menu", 1024, 768, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 1024x768xbgra5650 */, (grub_uint32_t []) { 0x724366e5, 0x2b3f0273, 0x6da0f134, 0x2b3f0273, 0xd9ed8903, 0x724366e5, 0x724366e5, 0xd0002838, 0xd0002838, 0xd0002838, 0x8990db68, 0x8990db68, 0x8990db68, 0x4127b52a, 0x4127b52a, 0x4127b52a, 0x724366e5, 0xd9ed8903, 0xd9ed8903, 0x724366e5, }, 20 }, - { "gfxterm_menu", 640, 480, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 640x480xbgra8880 */, (grub_uint32_t []) { 0x1c955882, 0x1e6b0284, 0x18f0ad39, 0x1e6b0284, 0x1e0bba22, 0x1c955882, 0x1c955882, 0x727420bf, 0x727420bf, 0x727420bf, 0xbd836d28, 0xbd836d28, 0xbd836d28, 0x43ea613d, 0x43ea613d, 0x43ea613d, 0x1c955882, 0x1e0bba22, 0x1e0bba22, 0x1c955882, }, 20 }, - { "gfxterm_menu", 800, 600, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 800x600xbgra8880 */, (grub_uint32_t []) { 0x4d266f7a, 0x1f279ca1, 0x976cb6e3, 0x1f279ca1, 0xdb3505a5, 0x4d266f7a, 0x4d266f7a, 0xc23ec599, 0xc23ec599, 0xc23ec599, 0x2449de26, 0x2449de26, 0x2449de26, 0xbc708ab6, 0xbc708ab6, 0xbc708ab6, 0x4d266f7a, 0xdb3505a5, 0xdb3505a5, 0x4d266f7a, }, 20 }, - { "gfxterm_menu", 1024, 768, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 1024x768xbgra8880 */, (grub_uint32_t []) { 0x1ed9d731, 0x21235dde, 0x13b8b442, 0x21235dde, 0xbdd75c39, 0x1ed9d731, 0x1ed9d731, 0x6ea8026e, 0x6ea8026e, 0x6ea8026e, 0xc0cc1cab, 0xc0cc1cab, 0xc0cc1cab, 0xe3a50d1d, 0xe3a50d1d, 0xe3a50d1d, 0x1ed9d731, 0xbdd75c39, 0xbdd75c39, 0x1ed9d731, }, 20 }, - { "gfxterm_menu", 640, 480, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 640x480xbgra8888 */, (grub_uint32_t []) { 0x9813a416, 0x22bcc2fc, 0xc6c23ab4, 0x22bcc2fc, 0x72a46652, 0x9813a416, 0x9813a416, 0xc10419e0, 0xc10419e0, 0xc10419e0, 0x50df9fd3, 0x50df9fd3, 0x50df9fd3, 0xccaa6a11, 0xccaa6a11, 0xccaa6a11, 0x9813a416, 0x72a46652, 0x72a46652, 0x9813a416, }, 20 }, - { "gfxterm_menu", 800, 600, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 800x600xbgra8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x3afb9165, 0x767dd6a7, 0x3afb9165, 0x31409f, 0x5fcf013d, 0x5fcf013d, 0x77ba65ab, 0x77ba65ab, 0x77ba65ab, 0xa5aa7ddd, 0xa5aa7ddd, 0xa5aa7ddd, 0xba81fc20, 0xba81fc20, 0xba81fc20, 0x5fcf013d, 0x31409f, 0x31409f, 0x5fcf013d, }, 20 }, - { "gfxterm_menu", 1024, 768, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 1024x768xbgra8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xe13f0039, 0xb5783cd1, 0xe13f0039, 0x814ca453, 0xdd28f52b, 0xdd28f52b, 0xbc36f156, 0xbc36f156, 0xbc36f156, 0x9d0a08b2, 0x9d0a08b2, 0x9d0a08b2, 0x877b6b23, 0x877b6b23, 0x877b6b23, 0xdd28f52b, 0x814ca453, 0x814ca453, 0xdd28f52b, }, 20 }, - { "gfxmenu", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x28e6b07d, 0xf54b3d6a, 0x28e6b07d, 0x7d0bdbfb, 0x9a2e0d26, 0xb22b0963, 0xb22b0963, 0xb22b0963, 0xeef3ffa3, 0xeef3ffa3, 0xeef3ffa3, 0x36f73b6, 0x36f73b6, 0x36f73b6, 0x59c36f00, 0x7d0bdbfb, 0x7d0bdbfb, }, 18 }, - { "gfxmenu", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x15bb581c, 0x7da084c6, 0x15bb581c, 0xcedba42f, 0xbc06c96d, 0xb3a8a15b, 0xb3a8a15b, 0xb3a8a15b, 0xe6f70b51, 0xe6f70b51, 0xe6f70b51, 0x8ce38109, 0x8ce38109, 0x8ce38109, 0xaa4593fe, 0xcedba42f, 0xcedba42f, }, 18 }, - { "gfxmenu", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x817e5fe2, 0x134e87ff, 0x817e5fe2, 0xb83ddd98, 0xdcd8c986, 0x79244533, 0x79244533, 0x79244533, 0x69ae3a7, 0x69ae3a7, 0x69ae3a7, 0xfc10b74f, 0xfc10b74f, 0xfc10b74f, 0xc9cbf769, 0xb83ddd98, 0xb83ddd98, }, 18 }, - { "gfxmenu", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x1c3742c9, 0x95048302, 0x9f5bac7c, 0x95048302, 0x28413b7c, 0x740d78cf, 0x620e8524, 0x620e8524, 0x620e8524, 0x89ab6f58, 0x89ab6f58, 0x89ab6f58, 0x90218e3d, 0x90218e3d, 0x90218e3d, 0x1c3742c9, 0x28413b7c, 0x28413b7c, }, 18 }, - { "gfxmenu", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0xcc5a7bed, 0x6cf38a7e, 0x35fcd6e8, 0x6cf38a7e, 0x618c203c, 0xe925e70d, 0xff9c8a81, 0xff9c8a81, 0xff9c8a81, 0x90d55690, 0x90d55690, 0x90d55690, 0xd3df13a0, 0xd3df13a0, 0xd3df13a0, 0xcc5a7bed, 0x618c203c, 0x618c203c, }, 18 }, - { "gfxmenu", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xef4a3312, 0xd610d630, 0x98774981, 0xd610d630, 0x4469957c, 0x9869130b, 0xfb592a0d, 0xfb592a0d, 0xfb592a0d, 0x3deb6e13, 0x3deb6e13, 0x3deb6e13, 0xeaf96ec4, 0xeaf96ec4, 0xeaf96ec4, 0xef4a3312, 0x4469957c, 0x4469957c, }, 18 }, - { "gfxmenu", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x54e48d80, 0xf5c7a904, 0xaf9e8139, 0xf5c7a904, 0xf108ef6b, 0x91c7d0fe, 0xb57ab567, 0xb57ab567, 0xb57ab567, 0x348943b6, 0x348943b6, 0x348943b6, 0x9b076791, 0x9b076791, 0x9b076791, 0x54e48d80, 0xf108ef6b, 0xf108ef6b, }, 18 }, - { "gfxmenu", 640, 480, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi256 */, (grub_uint32_t []) { 0x59c36f00, 0xff8ab96b, 0x72a93e7f, 0xff8ab96b, 0x47d54a82, 0x42b837cf, 0x6abd338a, 0x6abd338a, 0x6abd338a, 0x3665c54a, 0x3665c54a, 0x3665c54a, 0xdbf9495f, 0xdbf9495f, 0xdbf9495f, 0x59c36f00, 0x47d54a82, 0x47d54a82, }, 18 }, - { "gfxmenu", 800, 600, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi256 */, (grub_uint32_t []) { 0xaa4593fe, 0x73ad05f, 0x8434d91c, 0x73ad05f, 0x5316d3c6, 0xd7e75590, 0xd8493da6, 0xd8493da6, 0xd8493da6, 0x8d1697ac, 0x8d1697ac, 0x8d1697ac, 0xe7021df4, 0xe7021df4, 0xe7021df4, 0xaa4593fe, 0x5316d3c6, 0x5316d3c6, }, 18 }, - { "gfxmenu", 1024, 768, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi256 */, (grub_uint32_t []) { 0xc9cbf769, 0x83e29007, 0xd4329e28, 0x83e29007, 0x8c37fac6, 0x97d4f246, 0x32287ef3, 0x32287ef3, 0x32287ef3, 0x4d96d867, 0x4d96d867, 0x4d96d867, 0xb71c8c8f, 0xb71c8c8f, 0xb71c8c8f, 0xc9cbf769, 0x8c37fac6, 0x8c37fac6, }, 18 }, - { "gfxmenu", 640, 480, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 640x480xrgba5550 */, (grub_uint32_t []) { 0x5387d57f, 0xe535f843, 0x39fb9c6c, 0xe535f843, 0x2fbd1b9, 0x7c892c8d, 0x3a8a1482, 0x3a8a1482, 0x3a8a1482, 0x2d7a2495, 0x2d7a2495, 0x2d7a2495, 0x84d821d, 0x84d821d, 0x84d821d, 0x5387d57f, 0x2fbd1b9, 0x2fbd1b9, }, 18 }, - { "gfxmenu", 800, 600, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 800x600xrgba5550 */, (grub_uint32_t []) { 0xf83ee7aa, 0x8f8338d3, 0xdcad6ccd, 0x8f8338d3, 0x30c612d8, 0x36353d2b, 0xa9546353, 0xa9546353, 0xa9546353, 0x960ace5a, 0x960ace5a, 0x960ace5a, 0x62e43bb9, 0x62e43bb9, 0x62e43bb9, 0xf83ee7aa, 0x30c612d8, 0x30c612d8, }, 18 }, - { "gfxmenu", 1024, 768, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 1024x768xrgba5550 */, (grub_uint32_t []) { 0x724366e5, 0xb7a13882, 0x68141e3a, 0xb7a13882, 0x65f6d15, 0x3101c32f, 0xc2b93e36, 0xc2b93e36, 0xc2b93e36, 0x1bee651a, 0x1bee651a, 0x1bee651a, 0xf7d3f08f, 0xf7d3f08f, 0xf7d3f08f, 0x724366e5, 0x65f6d15, 0x65f6d15, }, 18 }, - { "gfxmenu", 640, 480, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 640x480xrgba5650 */, (grub_uint32_t []) { 0x5387d57f, 0x88a3c3aa, 0x8eade265, 0x88a3c3aa, 0xa5bf47d6, 0x9f8ae196, 0x56e34121, 0x56e34121, 0x56e34121, 0x2ccef01f, 0x2ccef01f, 0x2ccef01f, 0x7d1eee3b, 0x7d1eee3b, 0x7d1eee3b, 0x5387d57f, 0xa5bf47d6, 0xa5bf47d6, }, 18 }, - { "gfxmenu", 800, 600, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 800x600xrgba5650 */, (grub_uint32_t []) { 0xf83ee7aa, 0x8452c39c, 0x65759f4c, 0x8452c39c, 0x7459c042, 0xf9023dca, 0xe78b8902, 0xe78b8902, 0xe78b8902, 0xf0960107, 0xf0960107, 0xf0960107, 0xd52b2285, 0xd52b2285, 0xd52b2285, 0xf83ee7aa, 0x7459c042, 0x7459c042, }, 18 }, - { "gfxmenu", 1024, 768, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 1024x768xrgba5650 */, (grub_uint32_t []) { 0x724366e5, 0x938d42a2, 0x709bc8ab, 0x938d42a2, 0x4db0e2de, 0xd710f4c, 0x4e9cc80d, 0x4e9cc80d, 0x4e9cc80d, 0x9bc8a372, 0x9bc8a372, 0x9bc8a372, 0xbac90ac7, 0xbac90ac7, 0xbac90ac7, 0x724366e5, 0x4db0e2de, 0x4db0e2de, }, 18 }, - { "gfxmenu", 640, 480, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 640x480xrgba8880 */, (grub_uint32_t []) { 0x1c955882, 0xc060102b, 0x960bef0c, 0xc060102b, 0x1589677a, 0xe97d0978, 0xc795e31, 0xc795e31, 0xc795e31, 0xab33090, 0xab33090, 0xab33090, 0xbeea3971, 0xbeea3971, 0xbeea3971, 0x1c955882, 0x1589677a, 0x1589677a, }, 18 }, - { "gfxmenu", 800, 600, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 800x600xrgba8880 */, (grub_uint32_t []) { 0x4d266f7a, 0x6a4b2b8d, 0x274440b, 0x6a4b2b8d, 0xdef115d2, 0xed0808ad, 0x8d8ebcbb, 0x8d8ebcbb, 0x8d8ebcbb, 0x2b9b5d26, 0x2b9b5d26, 0x2b9b5d26, 0x790e10e2, 0x790e10e2, 0x790e10e2, 0x4d266f7a, 0xdef115d2, 0xdef115d2, }, 18 }, - { "gfxmenu", 1024, 768, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 1024x768xrgba8880 */, (grub_uint32_t []) { 0x1ed9d731, 0xdb8085be, 0x51d897c7, 0xdb8085be, 0xa3ce0221, 0x30fbd5f9, 0x12d25f5, 0x12d25f5, 0x12d25f5, 0xa4a480cb, 0xa4a480cb, 0xa4a480cb, 0xf3adca34, 0xf3adca34, 0xf3adca34, 0x1ed9d731, 0xa3ce0221, 0xa3ce0221, }, 18 }, - { "gfxmenu", 640, 480, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 640x480xbgra5550 */, (grub_uint32_t []) { 0x5387d57f, 0x475beaa4, 0xa62db977, 0x475beaa4, 0x3a62be0, 0x311b5810, 0x7718601f, 0x7718601f, 0x7718601f, 0x60e85008, 0x60e85008, 0x60e85008, 0x45dff680, 0x45dff680, 0x45dff680, 0x5387d57f, 0x3a62be0, 0x3a62be0, }, 18 }, - { "gfxmenu", 800, 600, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 800x600xbgra5550 */, (grub_uint32_t []) { 0xf83ee7aa, 0x5788a7ac, 0xd4336209, 0x5788a7ac, 0x354678e9, 0x783d77de, 0xe75c29a6, 0xe75c29a6, 0xe75c29a6, 0xd80284af, 0xd80284af, 0xd80284af, 0x2cec714c, 0x2cec714c, 0x2cec714c, 0xf83ee7aa, 0x354678e9, 0x354678e9, }, 18 }, - { "gfxmenu", 1024, 768, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 1024x768xbgra5550 */, (grub_uint32_t []) { 0x724366e5, 0xd1f64ea0, 0x4abd595a, 0xd1f64ea0, 0x97a6bea1, 0xf22a4cdb, 0x192b1c2, 0x192b1c2, 0x192b1c2, 0xd8c5eaee, 0xd8c5eaee, 0xd8c5eaee, 0x34f87f7b, 0x34f87f7b, 0x34f87f7b, 0x724366e5, 0x97a6bea1, 0x97a6bea1, }, 18 }, - { "gfxmenu", 640, 480, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 640x480xbgra5650 */, (grub_uint32_t []) { 0x5387d57f, 0xfcd5f4bb, 0x36d1826d, 0xfcd5f4bb, 0x43d7de40, 0x84467c83, 0x4d2fdc34, 0x4d2fdc34, 0x4d2fdc34, 0x37026d0a, 0x37026d0a, 0x37026d0a, 0x66d2732e, 0x66d2732e, 0x66d2732e, 0x5387d57f, 0x43d7de40, 0x43d7de40, }, 18 }, - { "gfxmenu", 800, 600, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 800x600xbgra5650 */, (grub_uint32_t []) { 0xf83ee7aa, 0x21e820a3, 0x2f9bf273, 0x21e820a3, 0xaa229449, 0x61b241cd, 0x7f3bf505, 0x7f3bf505, 0x7f3bf505, 0x68267d00, 0x68267d00, 0x68267d00, 0x4d9b5e82, 0x4d9b5e82, 0x4d9b5e82, 0xf83ee7aa, 0xaa229449, 0xaa229449, }, 18 }, - { "gfxmenu", 1024, 768, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 1024x768xbgra5650 */, (grub_uint32_t []) { 0x724366e5, 0x6fe66840, 0x64229598, 0x6fe66840, 0xedc02d98, 0x7131f7aa, 0x32dc30eb, 0x32dc30eb, 0x32dc30eb, 0xe7885b94, 0xe7885b94, 0xe7885b94, 0xc689f221, 0xc689f221, 0xc689f221, 0x724366e5, 0xedc02d98, 0xedc02d98, }, 18 }, - { "gfxmenu", 640, 480, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 640x480xbgra8880 */, (grub_uint32_t []) { 0x1c955882, 0xdb159e45, 0x9b1475c9, 0xdb159e45, 0xaee6597b, 0x573454, 0xe553631d, 0xe553631d, 0xe553631d, 0xe3990dbc, 0xe3990dbc, 0xe3990dbc, 0x57c0045d, 0x57c0045d, 0x57c0045d, 0x1c955882, 0xaee6597b, 0xaee6597b, }, 18 }, - { "gfxmenu", 800, 600, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 800x600xbgra8880 */, (grub_uint32_t []) { 0x4d266f7a, 0x9a43dfc6, 0x67153087, 0x9a43dfc6, 0xe9bd482c, 0xe763cddd, 0x87e579cb, 0x87e579cb, 0x87e579cb, 0x21f09856, 0x21f09856, 0x21f09856, 0x7365d592, 0x7365d592, 0x7365d592, 0x4d266f7a, 0xe9bd482c, 0xe9bd482c, }, 18 }, - { "gfxmenu", 1024, 768, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 1024x768xbgra8880 */, (grub_uint32_t []) { 0x1ed9d731, 0x78bf287, 0x8e68ddb4, 0x78bf287, 0xb2b0d4a4, 0xcb49fd6e, 0xfa9f0d62, 0xfa9f0d62, 0xfa9f0d62, 0x5f16a85c, 0x5f16a85c, 0x5f16a85c, 0x81fe2a3, 0x81fe2a3, 0x81fe2a3, 0x1ed9d731, 0xb2b0d4a4, 0xb2b0d4a4, }, 18 }, - { "gfxmenu", 640, 480, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 640x480xbgra8888 */, (grub_uint32_t []) { 0x1c3742c9, 0xb7ccf7ca, 0xfe517937, 0xb7ccf7ca, 0xfa1f93fd, 0x83d93b90, 0x95dac67b, 0x95dac67b, 0x95dac67b, 0x7e7f2c07, 0x7e7f2c07, 0x7e7f2c07, 0x67f5cd62, 0x67f5cd62, 0x67f5cd62, 0x1c3742c9, 0xfa1f93fd, 0xfa1f93fd, }, 18 }, - { "gfxmenu", 800, 600, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 800x600xbgra8888 */, (grub_uint32_t []) { 0xcc5a7bed, 0x663d292a, 0xa008c39, 0x663d292a, 0xcd82113f, 0x1c0b0f02, 0xab2628e, 0xab2628e, 0xab2628e, 0x65fbbe9f, 0x65fbbe9f, 0x65fbbe9f, 0x26f1fbaf, 0x26f1fbaf, 0x26f1fbaf, 0xcc5a7bed, 0xcd82113f, 0xcd82113f, }, 18 }, - { "gfxmenu", 1024, 768, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 1024x768xbgra8888 */, (grub_uint32_t []) { 0xef4a3312, 0xfc2f0ab1, 0x6861f25e, 0xfc2f0ab1, 0x11b6b6f7, 0xcd618f3f, 0xae51b639, 0xae51b639, 0xae51b639, 0x68e3f227, 0x68e3f227, 0x68e3f227, 0xbff1f2f0, 0xbff1f2f0, 0xbff1f2f0, 0xef4a3312, 0x11b6b6f7, 0x11b6b6f7, }, 18 }, - { "gfxterm_ar", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0xe0b5a23e, 0xee551fa6, 0xe0b5a23e, 0xa3436f79, 0x59c36f00, 0x59c36f00, 0x5e67c1f2, 0x5e67c1f2, 0x5e67c1f2, 0x20e7ac94, 0x20e7ac94, 0x20e7ac94, 0xe3c59159, 0xe3c59159, 0xe3c59159, 0x59c36f00, 0xa3436f79, 0xa3436f79, 0x59c36f00, }, 20 }, - { "gfxterm_ar", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x2bb3c18d, 0xdfae36a1, 0x2bb3c18d, 0x5b644f2, 0xaa4593fe, 0xaa4593fe, 0xccb764da, 0xccb764da, 0xccb764da, 0x6a4269bd, 0x6a4269bd, 0x6a4269bd, 0xe8e58bd6, 0xe8e58bd6, 0xe8e58bd6, 0xaa4593fe, 0x5b644f2, 0x5b644f2, 0xaa4593fe, }, 20 }, - { "gfxterm_ar", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xdae90963, 0xc865b2ee, 0xdae90963, 0x87fe64e7, 0xc9cbf769, 0xc9cbf769, 0xbdb21287, 0xbdb21287, 0xbdb21287, 0x436ad34b, 0x436ad34b, 0x436ad34b, 0xab3c7c47, 0xab3c7c47, 0xab3c7c47, 0xc9cbf769, 0x87fe64e7, 0x87fe64e7, 0xc9cbf769, }, 20 }, - { "gfxterm_ar", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0xd5ca4355, 0xc8fbf114, 0xd5ca4355, 0x85d2e7fb, 0x9813a416, 0x9813a416, 0x4a1e101b, 0x4a1e101b, 0x4a1e101b, 0xdbc59628, 0xdbc59628, 0xdbc59628, 0x47b063ea, 0x47b063ea, 0x47b063ea, 0x9813a416, 0x85d2e7fb, 0x85d2e7fb, 0x9813a416, }, 20 }, - { "gfxterm_ar", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x722a297e, 0xb34f27df, 0x722a297e, 0x48e0f884, 0x5fcf013d, 0x5fcf013d, 0xee9e0d69, 0xee9e0d69, 0xee9e0d69, 0x3c8e151f, 0x3c8e151f, 0x3c8e151f, 0x23a594e2, 0x23a594e2, 0x23a594e2, 0x5fcf013d, 0x48e0f884, 0x48e0f884, 0x5fcf013d, }, 20 }, - { "gfxterm_ar", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x87be67c4, 0x484106d9, 0x87be67c4, 0xe7cdc3ae, 0xdd28f52b, 0xdd28f52b, 0x2063d7c8, 0x2063d7c8, 0x2063d7c8, 0x15f2e2c, 0x15f2e2c, 0x15f2e2c, 0x1b2e4dbd, 0x1b2e4dbd, 0x1b2e4dbd, 0xdd28f52b, 0xe7cdc3ae, 0xe7cdc3ae, 0xdd28f52b, }, 20 }, - { "gfxterm_ar", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0xbf799219, 0xcec61405, 0xbf799219, 0x413f9f74, 0x43d1f34, 0x43d1f34, 0x9dc6a6fb, 0x9dc6a6fb, 0x9dc6a6fb, 0xe2cc0f53, 0xe2cc0f53, 0xe2cc0f53, 0xaec367a, 0xaec367a, 0xaec367a, 0x43d1f34, 0x413f9f74, 0x413f9f74, 0x43d1f34, }, 20 }, - { "gfxterm_ar", 640, 480, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi256 */, (grub_uint32_t []) { 0x59c36f00, 0xe0b5a23e, 0xee551fa6, 0xe0b5a23e, 0xa3436f79, 0x59c36f00, 0x59c36f00, 0x5e67c1f2, 0x5e67c1f2, 0x5e67c1f2, 0x20e7ac94, 0x20e7ac94, 0x20e7ac94, 0xe3c59159, 0xe3c59159, 0xe3c59159, 0x59c36f00, 0xa3436f79, 0xa3436f79, 0x59c36f00, }, 20 }, - { "gfxterm_ar", 800, 600, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi256 */, (grub_uint32_t []) { 0xaa4593fe, 0x2bb3c18d, 0xdfae36a1, 0x2bb3c18d, 0x5b644f2, 0xaa4593fe, 0xaa4593fe, 0xccb764da, 0xccb764da, 0xccb764da, 0x6a4269bd, 0x6a4269bd, 0x6a4269bd, 0xe8e58bd6, 0xe8e58bd6, 0xe8e58bd6, 0xaa4593fe, 0x5b644f2, 0x5b644f2, 0xaa4593fe, }, 20 }, - { "gfxterm_ar", 1024, 768, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi256 */, (grub_uint32_t []) { 0xc9cbf769, 0xdae90963, 0xc865b2ee, 0xdae90963, 0x87fe64e7, 0xc9cbf769, 0xc9cbf769, 0xbdb21287, 0xbdb21287, 0xbdb21287, 0x436ad34b, 0x436ad34b, 0x436ad34b, 0xab3c7c47, 0xab3c7c47, 0xab3c7c47, 0xc9cbf769, 0x87fe64e7, 0x87fe64e7, 0xc9cbf769, }, 20 }, - { "gfxterm_ar", 640, 480, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 640x480xrgba5550 */, (grub_uint32_t []) { 0x5387d57f, 0x3b1768ca, 0xf9e5eedd, 0x3b1768ca, 0x7f1c9276, 0x5387d57f, 0x5387d57f, 0x927c1c5d, 0x927c1c5d, 0x927c1c5d, 0x52257091, 0x52257091, 0x52257091, 0xb5fbf207, 0xb5fbf207, 0xb5fbf207, 0x5387d57f, 0x7f1c9276, 0x7f1c9276, 0x5387d57f, }, 20 }, - { "gfxterm_ar", 800, 600, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 800x600xrgba5550 */, (grub_uint32_t []) { 0xf83ee7aa, 0x54190c0f, 0xb6b42319, 0x54190c0f, 0xee714190, 0xf83ee7aa, 0xf83ee7aa, 0x1cbd869f, 0x1cbd869f, 0x1cbd869f, 0x80c4566c, 0x80c4566c, 0x80c4566c, 0xb877fdc4, 0xb877fdc4, 0xb877fdc4, 0xf83ee7aa, 0xee714190, 0xee714190, 0xf83ee7aa, }, 20 }, - { "gfxterm_ar", 1024, 768, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 1024x768xrgba5550 */, (grub_uint32_t []) { 0x724366e5, 0x25774ca3, 0x3d74e13a, 0x25774ca3, 0x3402f9f6, 0x724366e5, 0x724366e5, 0x447ccdbb, 0x447ccdbb, 0x447ccdbb, 0x3458f41, 0x3458f41, 0x3458f41, 0x6e6ba80b, 0x6e6ba80b, 0x6e6ba80b, 0x724366e5, 0x3402f9f6, 0x3402f9f6, 0x724366e5, }, 20 }, - { "gfxterm_ar", 640, 480, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 640x480xrgba5650 */, (grub_uint32_t []) { 0x5387d57f, 0x9143e2a6, 0x6e596cd4, 0x9143e2a6, 0x7ed75f9f, 0x5387d57f, 0x5387d57f, 0x86a0aae, 0x86a0aae, 0x86a0aae, 0xd6a44573, 0xd6a44573, 0xd6a44573, 0x4527d76d, 0x4527d76d, 0x4527d76d, 0x5387d57f, 0x7ed75f9f, 0x7ed75f9f, 0x5387d57f, }, 20 }, - { "gfxterm_ar", 800, 600, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 800x600xrgba5650 */, (grub_uint32_t []) { 0xf83ee7aa, 0xf943d873, 0xced7704, 0xf943d873, 0x8889e69f, 0xf83ee7aa, 0xf83ee7aa, 0x82576edb, 0x82576edb, 0x82576edb, 0xf08d7deb, 0xf08d7deb, 0xf08d7deb, 0xc1182c2d, 0xc1182c2d, 0xc1182c2d, 0xf83ee7aa, 0x8889e69f, 0x8889e69f, 0xf83ee7aa, }, 20 }, - { "gfxterm_ar", 1024, 768, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 1024x768xrgba5650 */, (grub_uint32_t []) { 0x724366e5, 0x63bd59d2, 0xf34f52d5, 0x63bd59d2, 0x916fd2a2, 0x724366e5, 0x724366e5, 0x11262bd6, 0x11262bd6, 0x11262bd6, 0x48b6d886, 0x48b6d886, 0x48b6d886, 0x8001b6c4, 0x8001b6c4, 0x8001b6c4, 0x724366e5, 0x916fd2a2, 0x916fd2a2, 0x724366e5, }, 20 }, - { "gfxterm_ar", 640, 480, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 640x480xrgba8880 */, (grub_uint32_t []) { 0x1c955882, 0xed6af547, 0x9ff43eec, 0xed6af547, 0xed0a4de1, 0x1c955882, 0x1c955882, 0xa9dce4cb, 0xa9dce4cb, 0xa9dce4cb, 0x662ba95c, 0x662ba95c, 0x662ba95c, 0x9842a549, 0x9842a549, 0x9842a549, 0x1c955882, 0xed0a4de1, 0xed0a4de1, 0x1c955882, }, 20 }, - { "gfxterm_ar", 800, 600, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 800x600xrgba8880 */, (grub_uint32_t []) { 0x4d266f7a, 0xbda49d55, 0xf5b57989, 0xbda49d55, 0x79b60451, 0x4d266f7a, 0x4d266f7a, 0xeb1807b5, 0xeb1807b5, 0xeb1807b5, 0xd6f1c0a, 0xd6f1c0a, 0xd6f1c0a, 0x9556489a, 0x9556489a, 0x9556489a, 0x4d266f7a, 0x79b60451, 0x79b60451, 0x4d266f7a, }, 20 }, - { "gfxterm_ar", 1024, 768, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 1024x768xrgba8880 */, (grub_uint32_t []) { 0x1ed9d731, 0x90b1e6bc, 0xabcab9fe, 0x90b1e6bc, 0xc45e75b, 0x1ed9d731, 0x1ed9d731, 0xa6ac3ed0, 0xa6ac3ed0, 0xa6ac3ed0, 0x8c82015, 0x8c82015, 0x8c82015, 0x2ba131a3, 0x2ba131a3, 0x2ba131a3, 0x1ed9d731, 0xc45e75b, 0xc45e75b, 0x1ed9d731, }, 20 }, - { "gfxterm_ar", 640, 480, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 640x480xbgra5550 */, (grub_uint32_t []) { 0x5387d57f, 0x3b1768ca, 0xf9e5eedd, 0x3b1768ca, 0x7f1c9276, 0x5387d57f, 0x5387d57f, 0x927c1c5d, 0x927c1c5d, 0x927c1c5d, 0x52257091, 0x52257091, 0x52257091, 0xb5fbf207, 0xb5fbf207, 0xb5fbf207, 0x5387d57f, 0x7f1c9276, 0x7f1c9276, 0x5387d57f, }, 20 }, - { "gfxterm_ar", 800, 600, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 800x600xbgra5550 */, (grub_uint32_t []) { 0xf83ee7aa, 0x54190c0f, 0xb6b42319, 0x54190c0f, 0xee714190, 0xf83ee7aa, 0xf83ee7aa, 0x1cbd869f, 0x1cbd869f, 0x1cbd869f, 0x80c4566c, 0x80c4566c, 0x80c4566c, 0xb877fdc4, 0xb877fdc4, 0xb877fdc4, 0xf83ee7aa, 0xee714190, 0xee714190, 0xf83ee7aa, }, 20 }, - { "gfxterm_ar", 1024, 768, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 1024x768xbgra5550 */, (grub_uint32_t []) { 0x724366e5, 0x25774ca3, 0x3d74e13a, 0x25774ca3, 0x3402f9f6, 0x724366e5, 0x724366e5, 0x447ccdbb, 0x447ccdbb, 0x447ccdbb, 0x3458f41, 0x3458f41, 0x3458f41, 0x6e6ba80b, 0x6e6ba80b, 0x6e6ba80b, 0x724366e5, 0x3402f9f6, 0x3402f9f6, 0x724366e5, }, 20 }, - { "gfxterm_ar", 640, 480, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 640x480xbgra5650 */, (grub_uint32_t []) { 0x5387d57f, 0x9143e2a6, 0x6e596cd4, 0x9143e2a6, 0x7ed75f9f, 0x5387d57f, 0x5387d57f, 0x86a0aae, 0x86a0aae, 0x86a0aae, 0xd6a44573, 0xd6a44573, 0xd6a44573, 0x4527d76d, 0x4527d76d, 0x4527d76d, 0x5387d57f, 0x7ed75f9f, 0x7ed75f9f, 0x5387d57f, }, 20 }, - { "gfxterm_ar", 800, 600, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 800x600xbgra5650 */, (grub_uint32_t []) { 0xf83ee7aa, 0xf943d873, 0xced7704, 0xf943d873, 0x8889e69f, 0xf83ee7aa, 0xf83ee7aa, 0x82576edb, 0x82576edb, 0x82576edb, 0xf08d7deb, 0xf08d7deb, 0xf08d7deb, 0xc1182c2d, 0xc1182c2d, 0xc1182c2d, 0xf83ee7aa, 0x8889e69f, 0x8889e69f, 0xf83ee7aa, }, 20 }, - { "gfxterm_ar", 1024, 768, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 1024x768xbgra5650 */, (grub_uint32_t []) { 0x724366e5, 0x63bd59d2, 0xf34f52d5, 0x63bd59d2, 0x916fd2a2, 0x724366e5, 0x724366e5, 0x11262bd6, 0x11262bd6, 0x11262bd6, 0x48b6d886, 0x48b6d886, 0x48b6d886, 0x8001b6c4, 0x8001b6c4, 0x8001b6c4, 0x724366e5, 0x916fd2a2, 0x916fd2a2, 0x724366e5, }, 20 }, - { "gfxterm_ar", 640, 480, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 640x480xbgra8880 */, (grub_uint32_t []) { 0x1c955882, 0xed6af547, 0x9ff43eec, 0xed6af547, 0xed0a4de1, 0x1c955882, 0x1c955882, 0xa9dce4cb, 0xa9dce4cb, 0xa9dce4cb, 0x662ba95c, 0x662ba95c, 0x662ba95c, 0x9842a549, 0x9842a549, 0x9842a549, 0x1c955882, 0xed0a4de1, 0xed0a4de1, 0x1c955882, }, 20 }, - { "gfxterm_ar", 800, 600, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 800x600xbgra8880 */, (grub_uint32_t []) { 0x4d266f7a, 0xbda49d55, 0xf5b57989, 0xbda49d55, 0x79b60451, 0x4d266f7a, 0x4d266f7a, 0xeb1807b5, 0xeb1807b5, 0xeb1807b5, 0xd6f1c0a, 0xd6f1c0a, 0xd6f1c0a, 0x9556489a, 0x9556489a, 0x9556489a, 0x4d266f7a, 0x79b60451, 0x79b60451, 0x4d266f7a, }, 20 }, - { "gfxterm_ar", 1024, 768, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 1024x768xbgra8880 */, (grub_uint32_t []) { 0x1ed9d731, 0x90b1e6bc, 0xabcab9fe, 0x90b1e6bc, 0xc45e75b, 0x1ed9d731, 0x1ed9d731, 0xa6ac3ed0, 0xa6ac3ed0, 0xa6ac3ed0, 0x8c82015, 0x8c82015, 0x8c82015, 0x2ba131a3, 0x2ba131a3, 0x2ba131a3, 0x1ed9d731, 0xc45e75b, 0xc45e75b, 0x1ed9d731, }, 20 }, - { "gfxterm_ar", 640, 480, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 640x480xbgra8888 */, (grub_uint32_t []) { 0x9813a416, 0xd5ca4355, 0xc8fbf114, 0xd5ca4355, 0x85d2e7fb, 0x9813a416, 0x9813a416, 0x4a1e101b, 0x4a1e101b, 0x4a1e101b, 0xdbc59628, 0xdbc59628, 0xdbc59628, 0x47b063ea, 0x47b063ea, 0x47b063ea, 0x9813a416, 0x85d2e7fb, 0x85d2e7fb, 0x9813a416, }, 20 }, - { "gfxterm_ar", 800, 600, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 800x600xbgra8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x722a297e, 0xb34f27df, 0x722a297e, 0x48e0f884, 0x5fcf013d, 0x5fcf013d, 0xee9e0d69, 0xee9e0d69, 0xee9e0d69, 0x3c8e151f, 0x3c8e151f, 0x3c8e151f, 0x23a594e2, 0x23a594e2, 0x23a594e2, 0x5fcf013d, 0x48e0f884, 0x48e0f884, 0x5fcf013d, }, 20 }, - { "gfxterm_ar", 1024, 768, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 1024x768xbgra8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x87be67c4, 0x484106d9, 0x87be67c4, 0xe7cdc3ae, 0xdd28f52b, 0xdd28f52b, 0x2063d7c8, 0x2063d7c8, 0x2063d7c8, 0x15f2e2c, 0x15f2e2c, 0x15f2e2c, 0x1b2e4dbd, 0x1b2e4dbd, 0x1b2e4dbd, 0xdd28f52b, 0xe7cdc3ae, 0xe7cdc3ae, 0xdd28f52b, }, 20 }, - { "gfxterm_cyr", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x36622078, 0x979da8f3, 0x36622078, 0x7594ed3f, 0x59c36f00, 0x59c36f00, 0xe5e5cf13, 0xe5e5cf13, 0xe5e5cf13, 0x9b65a275, 0x9b65a275, 0x9b65a275, 0x58479fb8, 0x58479fb8, 0x58479fb8, 0x59c36f00, 0x7594ed3f, 0x7594ed3f, 0x59c36f00, }, 20 }, - { "gfxterm_cyr", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x48ee0ceb, 0xc6eb6d53, 0x48ee0ceb, 0x66eb8994, 0xaa4593fe, 0xaa4593fe, 0x86ac5984, 0x86ac5984, 0x86ac5984, 0x205954e3, 0x205954e3, 0x205954e3, 0xa2feb688, 0xa2feb688, 0xa2feb688, 0xaa4593fe, 0x66eb8994, 0x66eb8994, 0xaa4593fe, }, 20 }, - { "gfxterm_cyr", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xfa53f185, 0xaf8fa3eb, 0xfa53f185, 0xa7449c01, 0xc9cbf769, 0xc9cbf769, 0x50b94b47, 0x50b94b47, 0x50b94b47, 0xae618a8b, 0xae618a8b, 0xae618a8b, 0x46372587, 0x46372587, 0x46372587, 0xc9cbf769, 0xa7449c01, 0xa7449c01, 0xc9cbf769, }, 20 }, - { "gfxterm_cyr", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0xc6eb6e6e, 0xc5217d5b, 0xc6eb6e6e, 0x96f3cac0, 0x9813a416, 0x9813a416, 0x5752c3fe, 0x5752c3fe, 0x5752c3fe, 0xc68945cd, 0xc68945cd, 0xc68945cd, 0x5afcb00f, 0x5afcb00f, 0x5afcb00f, 0x9813a416, 0x96f3cac0, 0x96f3cac0, 0x9813a416, }, 20 }, - { "gfxterm_cyr", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x7fd1def2, 0x98a2e53a, 0x7fd1def2, 0x451b0f08, 0x5fcf013d, 0x5fcf013d, 0x9f19ac09, 0x9f19ac09, 0x9f19ac09, 0x4d09b47f, 0x4d09b47f, 0x4d09b47f, 0x52223582, 0x52223582, 0x52223582, 0x5fcf013d, 0x451b0f08, 0x451b0f08, 0x5fcf013d, }, 20 }, - { "gfxterm_cyr", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xaac2ae55, 0x3e7a25f, 0xaac2ae55, 0xcab10a3f, 0xdd28f52b, 0xdd28f52b, 0x5f2b8179, 0x5f2b8179, 0x5f2b8179, 0x7e17789d, 0x7e17789d, 0x7e17789d, 0x64661b0c, 0x64661b0c, 0x64661b0c, 0xdd28f52b, 0xcab10a3f, 0xcab10a3f, 0xdd28f52b, }, 20 }, - { "gfxterm_cyr", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0xfbdee88, 0x812f047f, 0xfbdee88, 0xf1fbe3e5, 0x43d1f34, 0x43d1f34, 0x6694d5e, 0x6694d5e, 0x6694d5e, 0x7963e4f6, 0x7963e4f6, 0x7963e4f6, 0x9143dddf, 0x9143dddf, 0x9143dddf, 0x43d1f34, 0xf1fbe3e5, 0xf1fbe3e5, 0x43d1f34, }, 20 }, - { "gfxterm_cyr", 640, 480, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi256 */, (grub_uint32_t []) { 0x59c36f00, 0x36622078, 0x979da8f3, 0x36622078, 0x7594ed3f, 0x59c36f00, 0x59c36f00, 0xe5e5cf13, 0xe5e5cf13, 0xe5e5cf13, 0x9b65a275, 0x9b65a275, 0x9b65a275, 0x58479fb8, 0x58479fb8, 0x58479fb8, 0x59c36f00, 0x7594ed3f, 0x7594ed3f, 0x59c36f00, }, 20 }, - { "gfxterm_cyr", 800, 600, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi256 */, (grub_uint32_t []) { 0xaa4593fe, 0x48ee0ceb, 0xc6eb6d53, 0x48ee0ceb, 0x66eb8994, 0xaa4593fe, 0xaa4593fe, 0x86ac5984, 0x86ac5984, 0x86ac5984, 0x205954e3, 0x205954e3, 0x205954e3, 0xa2feb688, 0xa2feb688, 0xa2feb688, 0xaa4593fe, 0x66eb8994, 0x66eb8994, 0xaa4593fe, }, 20 }, - { "gfxterm_cyr", 1024, 768, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi256 */, (grub_uint32_t []) { 0xc9cbf769, 0xfa53f185, 0xaf8fa3eb, 0xfa53f185, 0xa7449c01, 0xc9cbf769, 0xc9cbf769, 0x50b94b47, 0x50b94b47, 0x50b94b47, 0xae618a8b, 0xae618a8b, 0xae618a8b, 0x46372587, 0x46372587, 0x46372587, 0xc9cbf769, 0xa7449c01, 0xa7449c01, 0xc9cbf769, }, 20 }, - { "gfxterm_cyr", 640, 480, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 640x480xrgba5550 */, (grub_uint32_t []) { 0x5387d57f, 0xd8d870b3, 0x9128b01a, 0xd8d870b3, 0x9cd38a0f, 0x5387d57f, 0x5387d57f, 0x136cad2, 0x136cad2, 0x136cad2, 0xc16fa61e, 0xc16fa61e, 0xc16fa61e, 0x26b12488, 0x26b12488, 0x26b12488, 0x5387d57f, 0x9cd38a0f, 0x9cd38a0f, 0x5387d57f, }, 20 }, - { "gfxterm_cyr", 800, 600, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 800x600xrgba5550 */, (grub_uint32_t []) { 0xf83ee7aa, 0xeaeda16f, 0x36d21de0, 0xeaeda16f, 0x5085ecf0, 0xf83ee7aa, 0xf83ee7aa, 0x3eac591b, 0x3eac591b, 0x3eac591b, 0xa2d589e8, 0xa2d589e8, 0xa2d589e8, 0x9a662240, 0x9a662240, 0x9a662240, 0xf83ee7aa, 0x5085ecf0, 0x5085ecf0, 0xf83ee7aa, }, 20 }, - { "gfxterm_cyr", 1024, 768, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 1024x768xrgba5550 */, (grub_uint32_t []) { 0x724366e5, 0x333a0d08, 0x47d0c238, 0x333a0d08, 0x224fb85d, 0x724366e5, 0x724366e5, 0xf4044671, 0xf4044671, 0xf4044671, 0xb33d048b, 0xb33d048b, 0xb33d048b, 0xde1323c1, 0xde1323c1, 0xde1323c1, 0x724366e5, 0x224fb85d, 0x224fb85d, 0x724366e5, }, 20 }, - { "gfxterm_cyr", 640, 480, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 640x480xrgba5650 */, (grub_uint32_t []) { 0x5387d57f, 0x4a43c1c8, 0xe019a943, 0x4a43c1c8, 0xa5d77cf1, 0x5387d57f, 0x5387d57f, 0x8171a604, 0x8171a604, 0x8171a604, 0x5fbfe9d9, 0x5fbfe9d9, 0x5fbfe9d9, 0xcc3c7bc7, 0xcc3c7bc7, 0xcc3c7bc7, 0x5387d57f, 0xa5d77cf1, 0xa5d77cf1, 0x5387d57f, }, 20 }, - { "gfxterm_cyr", 800, 600, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 800x600xrgba5650 */, (grub_uint32_t []) { 0xf83ee7aa, 0xb770c3fe, 0x50b21ef7, 0xb770c3fe, 0xc6bafd12, 0xf83ee7aa, 0xf83ee7aa, 0x8df53a5d, 0x8df53a5d, 0x8df53a5d, 0xff2f296d, 0xff2f296d, 0xff2f296d, 0xceba78ab, 0xceba78ab, 0xceba78ab, 0xf83ee7aa, 0xc6bafd12, 0xc6bafd12, 0xf83ee7aa, }, 20 }, - { "gfxterm_cyr", 1024, 768, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 1024x768xrgba5650 */, (grub_uint32_t []) { 0x724366e5, 0xe8f75cfb, 0x402c0692, 0xe8f75cfb, 0x1a25d78b, 0x724366e5, 0x724366e5, 0xaf01e304, 0xaf01e304, 0xaf01e304, 0xf6911054, 0xf6911054, 0xf6911054, 0x3e267e16, 0x3e267e16, 0x3e267e16, 0x724366e5, 0x1a25d78b, 0x1a25d78b, 0x724366e5, }, 20 }, - { "gfxterm_cyr", 640, 480, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 640x480xrgba8880 */, (grub_uint32_t []) { 0x1c955882, 0x89f843d3, 0xc27ae37d, 0x89f843d3, 0x8998fb75, 0x1c955882, 0x1c955882, 0x698caa77, 0x698caa77, 0x698caa77, 0xa67be7e0, 0xa67be7e0, 0xa67be7e0, 0x5812ebf5, 0x5812ebf5, 0x5812ebf5, 0x1c955882, 0x8998fb75, 0x8998fb75, 0x1c955882, }, 20 }, - { "gfxterm_cyr", 800, 600, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 800x600xrgba8880 */, (grub_uint32_t []) { 0x4d266f7a, 0xa10c24e6, 0x12eeef09, 0xa10c24e6, 0x651ebde2, 0x4d266f7a, 0x4d266f7a, 0x8ed47731, 0x8ed47731, 0x8ed47731, 0x68a36c8e, 0x68a36c8e, 0x68a36c8e, 0xf09a381e, 0xf09a381e, 0xf09a381e, 0x4d266f7a, 0x651ebde2, 0x651ebde2, 0x4d266f7a, }, 20 }, - { "gfxterm_cyr", 1024, 768, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 1024x768xrgba8880 */, (grub_uint32_t []) { 0x1ed9d731, 0x85a30869, 0xbaa08e30, 0x85a30869, 0x1957098e, 0x1ed9d731, 0x1ed9d731, 0x4ffc007b, 0x4ffc007b, 0x4ffc007b, 0xe1981ebe, 0xe1981ebe, 0xe1981ebe, 0xc2f10f08, 0xc2f10f08, 0xc2f10f08, 0x1ed9d731, 0x1957098e, 0x1957098e, 0x1ed9d731, }, 20 }, - { "gfxterm_cyr", 640, 480, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 640x480xbgra5550 */, (grub_uint32_t []) { 0x5387d57f, 0xd8d870b3, 0x9128b01a, 0xd8d870b3, 0x9cd38a0f, 0x5387d57f, 0x5387d57f, 0x136cad2, 0x136cad2, 0x136cad2, 0xc16fa61e, 0xc16fa61e, 0xc16fa61e, 0x26b12488, 0x26b12488, 0x26b12488, 0x5387d57f, 0x9cd38a0f, 0x9cd38a0f, 0x5387d57f, }, 20 }, - { "gfxterm_cyr", 800, 600, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 800x600xbgra5550 */, (grub_uint32_t []) { 0xf83ee7aa, 0xeaeda16f, 0x36d21de0, 0xeaeda16f, 0x5085ecf0, 0xf83ee7aa, 0xf83ee7aa, 0x3eac591b, 0x3eac591b, 0x3eac591b, 0xa2d589e8, 0xa2d589e8, 0xa2d589e8, 0x9a662240, 0x9a662240, 0x9a662240, 0xf83ee7aa, 0x5085ecf0, 0x5085ecf0, 0xf83ee7aa, }, 20 }, - { "gfxterm_cyr", 1024, 768, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 1024x768xbgra5550 */, (grub_uint32_t []) { 0x724366e5, 0x333a0d08, 0x47d0c238, 0x333a0d08, 0x224fb85d, 0x724366e5, 0x724366e5, 0xf4044671, 0xf4044671, 0xf4044671, 0xb33d048b, 0xb33d048b, 0xb33d048b, 0xde1323c1, 0xde1323c1, 0xde1323c1, 0x724366e5, 0x224fb85d, 0x224fb85d, 0x724366e5, }, 20 }, - { "gfxterm_cyr", 640, 480, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 640x480xbgra5650 */, (grub_uint32_t []) { 0x5387d57f, 0x4a43c1c8, 0xe019a943, 0x4a43c1c8, 0xa5d77cf1, 0x5387d57f, 0x5387d57f, 0x8171a604, 0x8171a604, 0x8171a604, 0x5fbfe9d9, 0x5fbfe9d9, 0x5fbfe9d9, 0xcc3c7bc7, 0xcc3c7bc7, 0xcc3c7bc7, 0x5387d57f, 0xa5d77cf1, 0xa5d77cf1, 0x5387d57f, }, 20 }, - { "gfxterm_cyr", 800, 600, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 800x600xbgra5650 */, (grub_uint32_t []) { 0xf83ee7aa, 0xb770c3fe, 0x50b21ef7, 0xb770c3fe, 0xc6bafd12, 0xf83ee7aa, 0xf83ee7aa, 0x8df53a5d, 0x8df53a5d, 0x8df53a5d, 0xff2f296d, 0xff2f296d, 0xff2f296d, 0xceba78ab, 0xceba78ab, 0xceba78ab, 0xf83ee7aa, 0xc6bafd12, 0xc6bafd12, 0xf83ee7aa, }, 20 }, - { "gfxterm_cyr", 1024, 768, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 1024x768xbgra5650 */, (grub_uint32_t []) { 0x724366e5, 0xe8f75cfb, 0x402c0692, 0xe8f75cfb, 0x1a25d78b, 0x724366e5, 0x724366e5, 0xaf01e304, 0xaf01e304, 0xaf01e304, 0xf6911054, 0xf6911054, 0xf6911054, 0x3e267e16, 0x3e267e16, 0x3e267e16, 0x724366e5, 0x1a25d78b, 0x1a25d78b, 0x724366e5, }, 20 }, - { "gfxterm_cyr", 640, 480, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 640x480xbgra8880 */, (grub_uint32_t []) { 0x1c955882, 0x89f843d3, 0xc27ae37d, 0x89f843d3, 0x8998fb75, 0x1c955882, 0x1c955882, 0x698caa77, 0x698caa77, 0x698caa77, 0xa67be7e0, 0xa67be7e0, 0xa67be7e0, 0x5812ebf5, 0x5812ebf5, 0x5812ebf5, 0x1c955882, 0x8998fb75, 0x8998fb75, 0x1c955882, }, 20 }, - { "gfxterm_cyr", 800, 600, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 800x600xbgra8880 */, (grub_uint32_t []) { 0x4d266f7a, 0xa10c24e6, 0x12eeef09, 0xa10c24e6, 0x651ebde2, 0x4d266f7a, 0x4d266f7a, 0x8ed47731, 0x8ed47731, 0x8ed47731, 0x68a36c8e, 0x68a36c8e, 0x68a36c8e, 0xf09a381e, 0xf09a381e, 0xf09a381e, 0x4d266f7a, 0x651ebde2, 0x651ebde2, 0x4d266f7a, }, 20 }, - { "gfxterm_cyr", 1024, 768, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 1024x768xbgra8880 */, (grub_uint32_t []) { 0x1ed9d731, 0x85a30869, 0xbaa08e30, 0x85a30869, 0x1957098e, 0x1ed9d731, 0x1ed9d731, 0x4ffc007b, 0x4ffc007b, 0x4ffc007b, 0xe1981ebe, 0xe1981ebe, 0xe1981ebe, 0xc2f10f08, 0xc2f10f08, 0xc2f10f08, 0x1ed9d731, 0x1957098e, 0x1957098e, 0x1ed9d731, }, 20 }, - { "gfxterm_cyr", 640, 480, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 640x480xbgra8888 */, (grub_uint32_t []) { 0x9813a416, 0xc6eb6e6e, 0xc5217d5b, 0xc6eb6e6e, 0x96f3cac0, 0x9813a416, 0x9813a416, 0x5752c3fe, 0x5752c3fe, 0x5752c3fe, 0xc68945cd, 0xc68945cd, 0xc68945cd, 0x5afcb00f, 0x5afcb00f, 0x5afcb00f, 0x9813a416, 0x96f3cac0, 0x96f3cac0, 0x9813a416, }, 20 }, - { "gfxterm_cyr", 800, 600, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 800x600xbgra8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x7fd1def2, 0x98a2e53a, 0x7fd1def2, 0x451b0f08, 0x5fcf013d, 0x5fcf013d, 0x9f19ac09, 0x9f19ac09, 0x9f19ac09, 0x4d09b47f, 0x4d09b47f, 0x4d09b47f, 0x52223582, 0x52223582, 0x52223582, 0x5fcf013d, 0x451b0f08, 0x451b0f08, 0x5fcf013d, }, 20 }, - { "gfxterm_cyr", 1024, 768, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 1024x768xbgra8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xaac2ae55, 0x3e7a25f, 0xaac2ae55, 0xcab10a3f, 0xdd28f52b, 0xdd28f52b, 0x5f2b8179, 0x5f2b8179, 0x5f2b8179, 0x7e17789d, 0x7e17789d, 0x7e17789d, 0x64661b0c, 0x64661b0c, 0x64661b0c, 0xdd28f52b, 0xcab10a3f, 0xcab10a3f, 0xdd28f52b, }, 20 }, - { "gfxterm_heb", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x99e53699, 0x9b30b9b8, 0x99e53699, 0xda13fbde, 0x59c36f00, 0x59c36f00, 0xc6c80006, 0xc6c80006, 0xc6c80006, 0xb8486d60, 0xb8486d60, 0xb8486d60, 0x7b6a50ad, 0x7b6a50ad, 0x7b6a50ad, 0x59c36f00, 0xda13fbde, 0xda13fbde, 0x59c36f00, }, 20 }, - { "gfxterm_heb", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x5596d8c4, 0xe6c08467, 0x5596d8c4, 0x7b935dbb, 0xaa4593fe, 0xaa4593fe, 0xb2094db6, 0xb2094db6, 0xb2094db6, 0x14fc40d1, 0x14fc40d1, 0x14fc40d1, 0x965ba2ba, 0x965ba2ba, 0x965ba2ba, 0xaa4593fe, 0x7b935dbb, 0x7b935dbb, 0xaa4593fe, }, 20 }, - { "gfxterm_heb", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x8b963803, 0x3a329278, 0x8b963803, 0xd6815587, 0xc9cbf769, 0xc9cbf769, 0x85733bd7, 0x85733bd7, 0x85733bd7, 0x7babfa1b, 0x7babfa1b, 0x7babfa1b, 0x93fd5517, 0x93fd5517, 0x93fd5517, 0xc9cbf769, 0xd6815587, 0xd6815587, 0xc9cbf769, }, 20 }, - { "gfxterm_heb", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x27813091, 0xd32064ba, 0x27813091, 0x7799943f, 0x9813a416, 0x9813a416, 0x5cfa5159, 0x5cfa5159, 0x5cfa5159, 0xcd21d76a, 0xcd21d76a, 0xcd21d76a, 0x515422a8, 0x515422a8, 0x515422a8, 0x9813a416, 0x7799943f, 0x7799943f, 0x9813a416, }, 20 }, - { "gfxterm_heb", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0xf107273d, 0xd1d8f23b, 0xf107273d, 0xcbcdf6c7, 0x5fcf013d, 0x5fcf013d, 0x164d5584, 0x164d5584, 0x164d5584, 0xc45d4df2, 0xc45d4df2, 0xc45d4df2, 0xdb76cc0f, 0xdb76cc0f, 0xdb76cc0f, 0x5fcf013d, 0xcbcdf6c7, 0xcbcdf6c7, 0x5fcf013d, }, 20 }, - { "gfxterm_heb", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xa54fb200, 0x92d6596f, 0xa54fb200, 0xc53c166a, 0xdd28f52b, 0xdd28f52b, 0x97b266c9, 0x97b266c9, 0x97b266c9, 0xb68e9f2d, 0xb68e9f2d, 0xb68e9f2d, 0xacfffcbc, 0xacfffcbc, 0xacfffcbc, 0xdd28f52b, 0xc53c166a, 0xc53c166a, 0xdd28f52b, }, 20 }, - { "gfxterm_heb", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x6d1ede55, 0x4bb31527, 0x6d1ede55, 0x9358d338, 0x43d1f34, 0x43d1f34, 0xa3f91b32, 0xa3f91b32, 0xa3f91b32, 0xdcf3b29a, 0xdcf3b29a, 0xdcf3b29a, 0x34d38bb3, 0x34d38bb3, 0x34d38bb3, 0x43d1f34, 0x9358d338, 0x9358d338, 0x43d1f34, }, 20 }, - { "gfxterm_heb", 640, 480, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi256 */, (grub_uint32_t []) { 0x59c36f00, 0x99e53699, 0x9b30b9b8, 0x99e53699, 0xda13fbde, 0x59c36f00, 0x59c36f00, 0xc6c80006, 0xc6c80006, 0xc6c80006, 0xb8486d60, 0xb8486d60, 0xb8486d60, 0x7b6a50ad, 0x7b6a50ad, 0x7b6a50ad, 0x59c36f00, 0xda13fbde, 0xda13fbde, 0x59c36f00, }, 20 }, - { "gfxterm_heb", 800, 600, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi256 */, (grub_uint32_t []) { 0xaa4593fe, 0x5596d8c4, 0xe6c08467, 0x5596d8c4, 0x7b935dbb, 0xaa4593fe, 0xaa4593fe, 0xb2094db6, 0xb2094db6, 0xb2094db6, 0x14fc40d1, 0x14fc40d1, 0x14fc40d1, 0x965ba2ba, 0x965ba2ba, 0x965ba2ba, 0xaa4593fe, 0x7b935dbb, 0x7b935dbb, 0xaa4593fe, }, 20 }, - { "gfxterm_heb", 1024, 768, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi256 */, (grub_uint32_t []) { 0xc9cbf769, 0x8b963803, 0x3a329278, 0x8b963803, 0xd6815587, 0xc9cbf769, 0xc9cbf769, 0x85733bd7, 0x85733bd7, 0x85733bd7, 0x7babfa1b, 0x7babfa1b, 0x7babfa1b, 0x93fd5517, 0x93fd5517, 0x93fd5517, 0xc9cbf769, 0xd6815587, 0xd6815587, 0xc9cbf769, }, 20 }, - { "gfxterm_heb", 640, 480, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 640x480xrgba5550 */, (grub_uint32_t []) { 0x5387d57f, 0xeada5358, 0xa5081c9c, 0xeada5358, 0xaed1a9e4, 0x5387d57f, 0x5387d57f, 0xe7380617, 0xe7380617, 0xe7380617, 0x27616adb, 0x27616adb, 0x27616adb, 0xc0bfe84d, 0xc0bfe84d, 0xc0bfe84d, 0x5387d57f, 0xaed1a9e4, 0xaed1a9e4, 0x5387d57f, }, 20 }, - { "gfxterm_heb", 800, 600, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 800x600xrgba5550 */, (grub_uint32_t []) { 0xf83ee7aa, 0x167e9ac0, 0xc5a57b5f, 0x167e9ac0, 0xac16d75f, 0xf83ee7aa, 0xf83ee7aa, 0xb47ab0cb, 0xb47ab0cb, 0xb47ab0cb, 0x28036038, 0x28036038, 0x28036038, 0x10b0cb90, 0x10b0cb90, 0x10b0cb90, 0xf83ee7aa, 0xac16d75f, 0xac16d75f, 0xf83ee7aa, }, 20 }, - { "gfxterm_heb", 1024, 768, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 1024x768xrgba5550 */, (grub_uint32_t []) { 0x724366e5, 0xfd0449a3, 0xb946b16a, 0xfd0449a3, 0xec71fcf6, 0x724366e5, 0x724366e5, 0xab4d15ce, 0xab4d15ce, 0xab4d15ce, 0xec745734, 0xec745734, 0xec745734, 0x815a707e, 0x815a707e, 0x815a707e, 0x724366e5, 0xec71fcf6, 0xec71fcf6, 0x724366e5, }, 20 }, - { "gfxterm_heb", 640, 480, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 640x480xrgba5650 */, (grub_uint32_t []) { 0x5387d57f, 0x1eb746a, 0x74afe43, 0x1eb746a, 0xee7fc953, 0x5387d57f, 0x5387d57f, 0x704981d6, 0x704981d6, 0x704981d6, 0xae87ce0b, 0xae87ce0b, 0xae87ce0b, 0x3d045c15, 0x3d045c15, 0x3d045c15, 0x5387d57f, 0xee7fc953, 0xee7fc953, 0x5387d57f, }, 20 }, - { "gfxterm_heb", 800, 600, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 800x600xrgba5650 */, (grub_uint32_t []) { 0xf83ee7aa, 0xb9fa44c, 0xff4e04c7, 0xb9fa44c, 0x7a559aa0, 0xf83ee7aa, 0xf83ee7aa, 0xfccbce43, 0xfccbce43, 0xfccbce43, 0x8e11dd73, 0x8e11dd73, 0x8e11dd73, 0xbf848cb5, 0xbf848cb5, 0xbf848cb5, 0xf83ee7aa, 0x7a559aa0, 0x7a559aa0, 0xf83ee7aa, }, 20 }, - { "gfxterm_heb", 1024, 768, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 1024x768xrgba5650 */, (grub_uint32_t []) { 0x724366e5, 0xcc83dbb8, 0x7fa3d9db, 0xcc83dbb8, 0x3e5150c8, 0x724366e5, 0x724366e5, 0x3d838d1c, 0x3d838d1c, 0x3d838d1c, 0x64137e4c, 0x64137e4c, 0x64137e4c, 0xaca4100e, 0xaca4100e, 0xaca4100e, 0x724366e5, 0x3e5150c8, 0x3e5150c8, 0x724366e5, }, 20 }, - { "gfxterm_heb", 640, 480, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 640x480xrgba8880 */, (grub_uint32_t []) { 0x1c955882, 0x2a9a3393, 0xc249bea, 0x2a9a3393, 0x2afa8b35, 0x1c955882, 0x1c955882, 0x9c6441e2, 0x9c6441e2, 0x9c6441e2, 0x53930c75, 0x53930c75, 0x53930c75, 0xadfa0060, 0xadfa0060, 0xadfa0060, 0x1c955882, 0x2afa8b35, 0x2afa8b35, 0x1c955882, }, 20 }, - { "gfxterm_heb", 800, 600, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 800x600xrgba8880 */, (grub_uint32_t []) { 0x4d266f7a, 0xcf807eaa, 0x4af8ad98, 0xcf807eaa, 0xb92e7ae, 0x4d266f7a, 0x4d266f7a, 0x15d955c1, 0x15d955c1, 0x15d955c1, 0xf3ae4e7e, 0xf3ae4e7e, 0xf3ae4e7e, 0x6b971aee, 0x6b971aee, 0x6b971aee, 0x4d266f7a, 0xb92e7ae, 0xb92e7ae, 0x4d266f7a, }, 20 }, - { "gfxterm_heb", 1024, 768, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 1024x768xrgba8880 */, (grub_uint32_t []) { 0x1ed9d731, 0x98e40974, 0xf0ed7ac2, 0x98e40974, 0x4100893, 0x1ed9d731, 0x1ed9d731, 0x7d102c2f, 0x7d102c2f, 0x7d102c2f, 0xd37432ea, 0xd37432ea, 0xd37432ea, 0xf01d235c, 0xf01d235c, 0xf01d235c, 0x1ed9d731, 0x4100893, 0x4100893, 0x1ed9d731, }, 20 }, - { "gfxterm_heb", 640, 480, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 640x480xbgra5550 */, (grub_uint32_t []) { 0x5387d57f, 0xeada5358, 0xa5081c9c, 0xeada5358, 0xaed1a9e4, 0x5387d57f, 0x5387d57f, 0xe7380617, 0xe7380617, 0xe7380617, 0x27616adb, 0x27616adb, 0x27616adb, 0xc0bfe84d, 0xc0bfe84d, 0xc0bfe84d, 0x5387d57f, 0xaed1a9e4, 0xaed1a9e4, 0x5387d57f, }, 20 }, - { "gfxterm_heb", 800, 600, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 800x600xbgra5550 */, (grub_uint32_t []) { 0xf83ee7aa, 0x167e9ac0, 0xc5a57b5f, 0x167e9ac0, 0xac16d75f, 0xf83ee7aa, 0xf83ee7aa, 0xb47ab0cb, 0xb47ab0cb, 0xb47ab0cb, 0x28036038, 0x28036038, 0x28036038, 0x10b0cb90, 0x10b0cb90, 0x10b0cb90, 0xf83ee7aa, 0xac16d75f, 0xac16d75f, 0xf83ee7aa, }, 20 }, - { "gfxterm_heb", 1024, 768, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 1024x768xbgra5550 */, (grub_uint32_t []) { 0x724366e5, 0xfd0449a3, 0xb946b16a, 0xfd0449a3, 0xec71fcf6, 0x724366e5, 0x724366e5, 0xab4d15ce, 0xab4d15ce, 0xab4d15ce, 0xec745734, 0xec745734, 0xec745734, 0x815a707e, 0x815a707e, 0x815a707e, 0x724366e5, 0xec71fcf6, 0xec71fcf6, 0x724366e5, }, 20 }, - { "gfxterm_heb", 640, 480, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 640x480xbgra5650 */, (grub_uint32_t []) { 0x5387d57f, 0x1eb746a, 0x74afe43, 0x1eb746a, 0xee7fc953, 0x5387d57f, 0x5387d57f, 0x704981d6, 0x704981d6, 0x704981d6, 0xae87ce0b, 0xae87ce0b, 0xae87ce0b, 0x3d045c15, 0x3d045c15, 0x3d045c15, 0x5387d57f, 0xee7fc953, 0xee7fc953, 0x5387d57f, }, 20 }, - { "gfxterm_heb", 800, 600, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 800x600xbgra5650 */, (grub_uint32_t []) { 0xf83ee7aa, 0xb9fa44c, 0xff4e04c7, 0xb9fa44c, 0x7a559aa0, 0xf83ee7aa, 0xf83ee7aa, 0xfccbce43, 0xfccbce43, 0xfccbce43, 0x8e11dd73, 0x8e11dd73, 0x8e11dd73, 0xbf848cb5, 0xbf848cb5, 0xbf848cb5, 0xf83ee7aa, 0x7a559aa0, 0x7a559aa0, 0xf83ee7aa, }, 20 }, - { "gfxterm_heb", 1024, 768, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 1024x768xbgra5650 */, (grub_uint32_t []) { 0x724366e5, 0xcc83dbb8, 0x7fa3d9db, 0xcc83dbb8, 0x3e5150c8, 0x724366e5, 0x724366e5, 0x3d838d1c, 0x3d838d1c, 0x3d838d1c, 0x64137e4c, 0x64137e4c, 0x64137e4c, 0xaca4100e, 0xaca4100e, 0xaca4100e, 0x724366e5, 0x3e5150c8, 0x3e5150c8, 0x724366e5, }, 20 }, - { "gfxterm_heb", 640, 480, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 640x480xbgra8880 */, (grub_uint32_t []) { 0x1c955882, 0x2a9a3393, 0xc249bea, 0x2a9a3393, 0x2afa8b35, 0x1c955882, 0x1c955882, 0x9c6441e2, 0x9c6441e2, 0x9c6441e2, 0x53930c75, 0x53930c75, 0x53930c75, 0xadfa0060, 0xadfa0060, 0xadfa0060, 0x1c955882, 0x2afa8b35, 0x2afa8b35, 0x1c955882, }, 20 }, - { "gfxterm_heb", 800, 600, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 800x600xbgra8880 */, (grub_uint32_t []) { 0x4d266f7a, 0xcf807eaa, 0x4af8ad98, 0xcf807eaa, 0xb92e7ae, 0x4d266f7a, 0x4d266f7a, 0x15d955c1, 0x15d955c1, 0x15d955c1, 0xf3ae4e7e, 0xf3ae4e7e, 0xf3ae4e7e, 0x6b971aee, 0x6b971aee, 0x6b971aee, 0x4d266f7a, 0xb92e7ae, 0xb92e7ae, 0x4d266f7a, }, 20 }, - { "gfxterm_heb", 1024, 768, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 1024x768xbgra8880 */, (grub_uint32_t []) { 0x1ed9d731, 0x98e40974, 0xf0ed7ac2, 0x98e40974, 0x4100893, 0x1ed9d731, 0x1ed9d731, 0x7d102c2f, 0x7d102c2f, 0x7d102c2f, 0xd37432ea, 0xd37432ea, 0xd37432ea, 0xf01d235c, 0xf01d235c, 0xf01d235c, 0x1ed9d731, 0x4100893, 0x4100893, 0x1ed9d731, }, 20 }, - { "gfxterm_heb", 640, 480, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 640x480xbgra8888 */, (grub_uint32_t []) { 0x9813a416, 0x27813091, 0xd32064ba, 0x27813091, 0x7799943f, 0x9813a416, 0x9813a416, 0x5cfa5159, 0x5cfa5159, 0x5cfa5159, 0xcd21d76a, 0xcd21d76a, 0xcd21d76a, 0x515422a8, 0x515422a8, 0x515422a8, 0x9813a416, 0x7799943f, 0x7799943f, 0x9813a416, }, 20 }, - { "gfxterm_heb", 800, 600, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 800x600xbgra8888 */, (grub_uint32_t []) { 0x5fcf013d, 0xf107273d, 0xd1d8f23b, 0xf107273d, 0xcbcdf6c7, 0x5fcf013d, 0x5fcf013d, 0x164d5584, 0x164d5584, 0x164d5584, 0xc45d4df2, 0xc45d4df2, 0xc45d4df2, 0xdb76cc0f, 0xdb76cc0f, 0xdb76cc0f, 0x5fcf013d, 0xcbcdf6c7, 0xcbcdf6c7, 0x5fcf013d, }, 20 }, - { "gfxterm_heb", 1024, 768, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 1024x768xbgra8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xa54fb200, 0x92d6596f, 0xa54fb200, 0xc53c166a, 0xdd28f52b, 0xdd28f52b, 0x97b266c9, 0x97b266c9, 0x97b266c9, 0xb68e9f2d, 0xb68e9f2d, 0xb68e9f2d, 0xacfffcbc, 0xacfffcbc, 0xacfffcbc, 0xdd28f52b, 0xc53c166a, 0xc53c166a, 0xdd28f52b, }, 20 }, - { "gfxterm_gre", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0xfe511789, 0x421405b3, 0xfe511789, 0xbda7dace, 0x59c36f00, 0x59c36f00, 0x2a367884, 0x2a367884, 0x2a367884, 0x54b615e2, 0x54b615e2, 0x54b615e2, 0x9794282f, 0x9794282f, 0x9794282f, 0x59c36f00, 0xbda7dace, 0xbda7dace, 0x59c36f00, }, 20 }, - { "gfxterm_gre", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x2616eaaf, 0xd0263182, 0x2616eaaf, 0x8136fd0, 0xaa4593fe, 0xaa4593fe, 0x5b85b7a8, 0x5b85b7a8, 0x5b85b7a8, 0xfd70bacf, 0xfd70bacf, 0xfd70bacf, 0x7fd758a4, 0x7fd758a4, 0x7fd758a4, 0xaa4593fe, 0x8136fd0, 0x8136fd0, 0xaa4593fe, }, 20 }, - { "gfxterm_gre", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x9214e205, 0x211e70db, 0x9214e205, 0xcf038f81, 0xc9cbf769, 0xc9cbf769, 0x5a304c, 0x5a304c, 0x5a304c, 0xfe82f180, 0xfe82f180, 0xfe82f180, 0x16d45e8c, 0x16d45e8c, 0x16d45e8c, 0xc9cbf769, 0xcf038f81, 0xcf038f81, 0xc9cbf769, }, 20 }, - { "gfxterm_gre", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x8bbe1e38, 0xfef8974b, 0x8bbe1e38, 0xdba6ba96, 0x9813a416, 0x9813a416, 0xdf1a19a3, 0xdf1a19a3, 0xdf1a19a3, 0x4ec19f90, 0x4ec19f90, 0x4ec19f90, 0xd2b46a52, 0xd2b46a52, 0xd2b46a52, 0x9813a416, 0xdba6ba96, 0xdba6ba96, 0x9813a416, }, 20 }, - { "gfxterm_gre", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0xda045c37, 0xb8ae26e3, 0xda045c37, 0xe0ce8dcd, 0x5fcf013d, 0x5fcf013d, 0xee7a1c7, 0xee7a1c7, 0xee7a1c7, 0xdcf7b9b1, 0xdcf7b9b1, 0xdcf7b9b1, 0xc3dc384c, 0xc3dc384c, 0xc3dc384c, 0x5fcf013d, 0xe0ce8dcd, 0xe0ce8dcd, 0x5fcf013d, }, 20 }, - { "gfxterm_gre", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x2e35339d, 0x798918b, 0x2e35339d, 0x4e4697f7, 0xdd28f52b, 0xdd28f52b, 0x92c68d60, 0x92c68d60, 0x92c68d60, 0xb3fa7484, 0xb3fa7484, 0xb3fa7484, 0xa98b1715, 0xa98b1715, 0xa98b1715, 0xdd28f52b, 0x4e4697f7, 0x4e4697f7, 0xdd28f52b, }, 20 }, - { "gfxterm_gre", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0xb5c5482e, 0xeec9616, 0xb5c5482e, 0x4b834543, 0x43d1f34, 0x43d1f34, 0xd4fadab2, 0xd4fadab2, 0xd4fadab2, 0xabf0731a, 0xabf0731a, 0xabf0731a, 0x43d04a33, 0x43d04a33, 0x43d04a33, 0x43d1f34, 0x4b834543, 0x4b834543, 0x43d1f34, }, 20 }, - { "gfxterm_gre", 640, 480, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi256 */, (grub_uint32_t []) { 0x59c36f00, 0xfe511789, 0x421405b3, 0xfe511789, 0xbda7dace, 0x59c36f00, 0x59c36f00, 0x2a367884, 0x2a367884, 0x2a367884, 0x54b615e2, 0x54b615e2, 0x54b615e2, 0x9794282f, 0x9794282f, 0x9794282f, 0x59c36f00, 0xbda7dace, 0xbda7dace, 0x59c36f00, }, 20 }, - { "gfxterm_gre", 800, 600, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi256 */, (grub_uint32_t []) { 0xaa4593fe, 0x2616eaaf, 0xd0263182, 0x2616eaaf, 0x8136fd0, 0xaa4593fe, 0xaa4593fe, 0x5b85b7a8, 0x5b85b7a8, 0x5b85b7a8, 0xfd70bacf, 0xfd70bacf, 0xfd70bacf, 0x7fd758a4, 0x7fd758a4, 0x7fd758a4, 0xaa4593fe, 0x8136fd0, 0x8136fd0, 0xaa4593fe, }, 20 }, - { "gfxterm_gre", 1024, 768, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi256 */, (grub_uint32_t []) { 0xc9cbf769, 0x9214e205, 0x211e70db, 0x9214e205, 0xcf038f81, 0xc9cbf769, 0xc9cbf769, 0x5a304c, 0x5a304c, 0x5a304c, 0xfe82f180, 0xfe82f180, 0xfe82f180, 0x16d45e8c, 0x16d45e8c, 0x16d45e8c, 0xc9cbf769, 0xcf038f81, 0xcf038f81, 0xc9cbf769, }, 20 }, - { "gfxterm_gre", 640, 480, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 640x480xrgba5550 */, (grub_uint32_t []) { 0x5387d57f, 0xa841a245, 0x7c4a37aa, 0xa841a245, 0xec4a58f9, 0x5387d57f, 0x5387d57f, 0x8670fc38, 0x8670fc38, 0x8670fc38, 0x462990f4, 0x462990f4, 0x462990f4, 0xa1f71262, 0xa1f71262, 0xa1f71262, 0x5387d57f, 0xec4a58f9, 0xec4a58f9, 0x5387d57f, }, 20 }, - { "gfxterm_gre", 800, 600, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 800x600xrgba5550 */, (grub_uint32_t []) { 0xf83ee7aa, 0xc589c63a, 0xda1b2d71, 0xc589c63a, 0x7fe18ba5, 0xf83ee7aa, 0xf83ee7aa, 0x74883fe5, 0x74883fe5, 0x74883fe5, 0xe8f1ef16, 0xe8f1ef16, 0xe8f1ef16, 0xd04244be, 0xd04244be, 0xd04244be, 0xf83ee7aa, 0x7fe18ba5, 0x7fe18ba5, 0xf83ee7aa, }, 20 }, - { "gfxterm_gre", 1024, 768, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 1024x768xrgba5550 */, (grub_uint32_t []) { 0x724366e5, 0x5df86da, 0x97465d78, 0x5df86da, 0x14aa338f, 0x724366e5, 0x724366e5, 0x60829227, 0x60829227, 0x60829227, 0x27bbd0dd, 0x27bbd0dd, 0x27bbd0dd, 0x4a95f797, 0x4a95f797, 0x4a95f797, 0x724366e5, 0x14aa338f, 0x14aa338f, 0x724366e5, }, 20 }, - { "gfxterm_gre", 640, 480, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 640x480xrgba5650 */, (grub_uint32_t []) { 0x5387d57f, 0xebf6bdc1, 0xaf2c370b, 0xebf6bdc1, 0x46200f8, 0x5387d57f, 0x5387d57f, 0x81cd0740, 0x81cd0740, 0x81cd0740, 0x5f03489d, 0x5f03489d, 0x5f03489d, 0xcc80da83, 0xcc80da83, 0xcc80da83, 0x5387d57f, 0x46200f8, 0x46200f8, 0x5387d57f, }, 20 }, - { "gfxterm_gre", 800, 600, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 800x600xrgba5650 */, (grub_uint32_t []) { 0xf83ee7aa, 0x5455b923, 0x93681ea, 0x5455b923, 0x259f87cf, 0xf83ee7aa, 0xf83ee7aa, 0xf5cd3d43, 0xf5cd3d43, 0xf5cd3d43, 0x87172e73, 0x87172e73, 0x87172e73, 0xb6827fb5, 0xb6827fb5, 0xb6827fb5, 0xf83ee7aa, 0x259f87cf, 0x259f87cf, 0xf83ee7aa, }, 20 }, - { "gfxterm_gre", 1024, 768, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 1024x768xrgba5650 */, (grub_uint32_t []) { 0x724366e5, 0xec9a1f85, 0x74e0a22a, 0xec9a1f85, 0x1e4894f5, 0x724366e5, 0x724366e5, 0xa74db0e6, 0xa74db0e6, 0xa74db0e6, 0xfedd43b6, 0xfedd43b6, 0xfedd43b6, 0x366a2df4, 0x366a2df4, 0x366a2df4, 0x724366e5, 0x1e4894f5, 0x1e4894f5, 0x724366e5, }, 20 }, - { "gfxterm_gre", 640, 480, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 640x480xrgba8880 */, (grub_uint32_t []) { 0x1c955882, 0x8cac1ee1, 0x7824cfba, 0x8cac1ee1, 0x8ccca647, 0x1c955882, 0x1c955882, 0xec40c88e, 0xec40c88e, 0xec40c88e, 0x23b78519, 0x23b78519, 0x23b78519, 0xddde890c, 0xddde890c, 0xddde890c, 0x1c955882, 0x8ccca647, 0x8ccca647, 0x1c955882, }, 20 }, - { "gfxterm_gre", 800, 600, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 800x600xrgba8880 */, (grub_uint32_t []) { 0x4d266f7a, 0xccb8f998, 0x89af656f, 0xccb8f998, 0x8aa609c, 0x4d266f7a, 0x4d266f7a, 0x863eb372, 0x863eb372, 0x863eb372, 0x6049a8cd, 0x6049a8cd, 0x6049a8cd, 0xf870fc5d, 0xf870fc5d, 0xf870fc5d, 0x4d266f7a, 0x8aa609c, 0x8aa609c, 0x4d266f7a, }, 20 }, - { "gfxterm_gre", 1024, 768, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 1024x768xrgba8880 */, (grub_uint32_t []) { 0x1ed9d731, 0xa3bd882a, 0x5adc164, 0xa3bd882a, 0x3f4989cd, 0x1ed9d731, 0x1ed9d731, 0x46a1472c, 0x46a1472c, 0x46a1472c, 0xe8c559e9, 0xe8c559e9, 0xe8c559e9, 0xcbac485f, 0xcbac485f, 0xcbac485f, 0x1ed9d731, 0x3f4989cd, 0x3f4989cd, 0x1ed9d731, }, 20 }, - { "gfxterm_gre", 640, 480, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 640x480xbgra5550 */, (grub_uint32_t []) { 0x5387d57f, 0xa841a245, 0x7c4a37aa, 0xa841a245, 0xec4a58f9, 0x5387d57f, 0x5387d57f, 0x8670fc38, 0x8670fc38, 0x8670fc38, 0x462990f4, 0x462990f4, 0x462990f4, 0xa1f71262, 0xa1f71262, 0xa1f71262, 0x5387d57f, 0xec4a58f9, 0xec4a58f9, 0x5387d57f, }, 20 }, - { "gfxterm_gre", 800, 600, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 800x600xbgra5550 */, (grub_uint32_t []) { 0xf83ee7aa, 0xc589c63a, 0xda1b2d71, 0xc589c63a, 0x7fe18ba5, 0xf83ee7aa, 0xf83ee7aa, 0x74883fe5, 0x74883fe5, 0x74883fe5, 0xe8f1ef16, 0xe8f1ef16, 0xe8f1ef16, 0xd04244be, 0xd04244be, 0xd04244be, 0xf83ee7aa, 0x7fe18ba5, 0x7fe18ba5, 0xf83ee7aa, }, 20 }, - { "gfxterm_gre", 1024, 768, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 1024x768xbgra5550 */, (grub_uint32_t []) { 0x724366e5, 0x5df86da, 0x97465d78, 0x5df86da, 0x14aa338f, 0x724366e5, 0x724366e5, 0x60829227, 0x60829227, 0x60829227, 0x27bbd0dd, 0x27bbd0dd, 0x27bbd0dd, 0x4a95f797, 0x4a95f797, 0x4a95f797, 0x724366e5, 0x14aa338f, 0x14aa338f, 0x724366e5, }, 20 }, - { "gfxterm_gre", 640, 480, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 640x480xbgra5650 */, (grub_uint32_t []) { 0x5387d57f, 0xebf6bdc1, 0xaf2c370b, 0xebf6bdc1, 0x46200f8, 0x5387d57f, 0x5387d57f, 0x81cd0740, 0x81cd0740, 0x81cd0740, 0x5f03489d, 0x5f03489d, 0x5f03489d, 0xcc80da83, 0xcc80da83, 0xcc80da83, 0x5387d57f, 0x46200f8, 0x46200f8, 0x5387d57f, }, 20 }, - { "gfxterm_gre", 800, 600, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 800x600xbgra5650 */, (grub_uint32_t []) { 0xf83ee7aa, 0x5455b923, 0x93681ea, 0x5455b923, 0x259f87cf, 0xf83ee7aa, 0xf83ee7aa, 0xf5cd3d43, 0xf5cd3d43, 0xf5cd3d43, 0x87172e73, 0x87172e73, 0x87172e73, 0xb6827fb5, 0xb6827fb5, 0xb6827fb5, 0xf83ee7aa, 0x259f87cf, 0x259f87cf, 0xf83ee7aa, }, 20 }, - { "gfxterm_gre", 1024, 768, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 1024x768xbgra5650 */, (grub_uint32_t []) { 0x724366e5, 0xec9a1f85, 0x74e0a22a, 0xec9a1f85, 0x1e4894f5, 0x724366e5, 0x724366e5, 0xa74db0e6, 0xa74db0e6, 0xa74db0e6, 0xfedd43b6, 0xfedd43b6, 0xfedd43b6, 0x366a2df4, 0x366a2df4, 0x366a2df4, 0x724366e5, 0x1e4894f5, 0x1e4894f5, 0x724366e5, }, 20 }, - { "gfxterm_gre", 640, 480, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 640x480xbgra8880 */, (grub_uint32_t []) { 0x1c955882, 0x8cac1ee1, 0x7824cfba, 0x8cac1ee1, 0x8ccca647, 0x1c955882, 0x1c955882, 0xec40c88e, 0xec40c88e, 0xec40c88e, 0x23b78519, 0x23b78519, 0x23b78519, 0xddde890c, 0xddde890c, 0xddde890c, 0x1c955882, 0x8ccca647, 0x8ccca647, 0x1c955882, }, 20 }, - { "gfxterm_gre", 800, 600, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 800x600xbgra8880 */, (grub_uint32_t []) { 0x4d266f7a, 0xccb8f998, 0x89af656f, 0xccb8f998, 0x8aa609c, 0x4d266f7a, 0x4d266f7a, 0x863eb372, 0x863eb372, 0x863eb372, 0x6049a8cd, 0x6049a8cd, 0x6049a8cd, 0xf870fc5d, 0xf870fc5d, 0xf870fc5d, 0x4d266f7a, 0x8aa609c, 0x8aa609c, 0x4d266f7a, }, 20 }, - { "gfxterm_gre", 1024, 768, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 1024x768xbgra8880 */, (grub_uint32_t []) { 0x1ed9d731, 0xa3bd882a, 0x5adc164, 0xa3bd882a, 0x3f4989cd, 0x1ed9d731, 0x1ed9d731, 0x46a1472c, 0x46a1472c, 0x46a1472c, 0xe8c559e9, 0xe8c559e9, 0xe8c559e9, 0xcbac485f, 0xcbac485f, 0xcbac485f, 0x1ed9d731, 0x3f4989cd, 0x3f4989cd, 0x1ed9d731, }, 20 }, - { "gfxterm_gre", 640, 480, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 640x480xbgra8888 */, (grub_uint32_t []) { 0x9813a416, 0x8bbe1e38, 0xfef8974b, 0x8bbe1e38, 0xdba6ba96, 0x9813a416, 0x9813a416, 0xdf1a19a3, 0xdf1a19a3, 0xdf1a19a3, 0x4ec19f90, 0x4ec19f90, 0x4ec19f90, 0xd2b46a52, 0xd2b46a52, 0xd2b46a52, 0x9813a416, 0xdba6ba96, 0xdba6ba96, 0x9813a416, }, 20 }, - { "gfxterm_gre", 800, 600, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 800x600xbgra8888 */, (grub_uint32_t []) { 0x5fcf013d, 0xda045c37, 0xb8ae26e3, 0xda045c37, 0xe0ce8dcd, 0x5fcf013d, 0x5fcf013d, 0xee7a1c7, 0xee7a1c7, 0xee7a1c7, 0xdcf7b9b1, 0xdcf7b9b1, 0xdcf7b9b1, 0xc3dc384c, 0xc3dc384c, 0xc3dc384c, 0x5fcf013d, 0xe0ce8dcd, 0xe0ce8dcd, 0x5fcf013d, }, 20 }, - { "gfxterm_gre", 1024, 768, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 1024x768xbgra8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x2e35339d, 0x798918b, 0x2e35339d, 0x4e4697f7, 0xdd28f52b, 0xdd28f52b, 0x92c68d60, 0x92c68d60, 0x92c68d60, 0xb3fa7484, 0xb3fa7484, 0xb3fa7484, 0xa98b1715, 0xa98b1715, 0xa98b1715, 0xdd28f52b, 0x4e4697f7, 0x4e4697f7, 0xdd28f52b, }, 20 }, - { "gfxterm_ru", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0xef4073b7, 0x7c0ec717, 0xef4073b7, 0xacb6bef0, 0x59c36f00, 0x59c36f00, 0x1b206d14, 0x1b206d14, 0x1b206d14, 0x65a00072, 0x65a00072, 0x65a00072, 0xa6823dbf, 0xa6823dbf, 0xa6823dbf, 0x59c36f00, 0xacb6bef0, 0xacb6bef0, 0x59c36f00, }, 20 }, - { "gfxterm_ru", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x439c3f9c, 0xb979a570, 0x439c3f9c, 0x6d99bae3, 0xaa4593fe, 0xaa4593fe, 0x7c7873ca, 0x7c7873ca, 0x7c7873ca, 0xda8d7ead, 0xda8d7ead, 0xda8d7ead, 0x582a9cc6, 0x582a9cc6, 0x582a9cc6, 0xaa4593fe, 0x6d99bae3, 0x6d99bae3, 0xaa4593fe, }, 20 }, - { "gfxterm_ru", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x5ba2c945, 0x8734093, 0x5ba2c945, 0x6b5a4c1, 0xc9cbf769, 0xc9cbf769, 0xa3843a5a, 0xa3843a5a, 0xa3843a5a, 0x5d5cfb96, 0x5d5cfb96, 0x5d5cfb96, 0xb50a549a, 0xb50a549a, 0xb50a549a, 0xc9cbf769, 0x6b5a4c1, 0x6b5a4c1, 0xc9cbf769, }, 20 }, - { "gfxterm_ru", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x1d557c7b, 0x8d172abd, 0x1d557c7b, 0x4d4dd8d5, 0x9813a416, 0x9813a416, 0xae45df54, 0xae45df54, 0xae45df54, 0x3f9e5967, 0x3f9e5967, 0x3f9e5967, 0xa3ebaca5, 0xa3ebaca5, 0xa3ebaca5, 0x9813a416, 0x4d4dd8d5, 0x4d4dd8d5, 0x9813a416, }, 20 }, - { "gfxterm_ru", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x75e8bbc6, 0x79f972a, 0x75e8bbc6, 0x4f226a3c, 0x5fcf013d, 0x5fcf013d, 0xe1849dd3, 0xe1849dd3, 0xe1849dd3, 0x339485a5, 0x339485a5, 0x339485a5, 0x2cbf0458, 0x2cbf0458, 0x2cbf0458, 0x5fcf013d, 0x4f226a3c, 0x4f226a3c, 0x5fcf013d, }, 20 }, - { "gfxterm_ru", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x7391ddfb, 0x7d352e1, 0x7391ddfb, 0x13e27991, 0xdd28f52b, 0xdd28f52b, 0x25591550, 0x25591550, 0x25591550, 0x465ecb4, 0x465ecb4, 0x465ecb4, 0x1e148f25, 0x1e148f25, 0x1e148f25, 0xdd28f52b, 0x13e27991, 0x13e27991, 0xdd28f52b, }, 20 }, - { "gfxterm_ru", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0xc009461b, 0xbaf1821c, 0xc009461b, 0x3e4f4b76, 0x43d1f34, 0x43d1f34, 0x19165017, 0x19165017, 0x19165017, 0x661cf9bf, 0x661cf9bf, 0x661cf9bf, 0x8e3cc096, 0x8e3cc096, 0x8e3cc096, 0x43d1f34, 0x3e4f4b76, 0x3e4f4b76, 0x43d1f34, }, 20 }, - { "gfxterm_ru", 640, 480, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi256 */, (grub_uint32_t []) { 0x59c36f00, 0xef4073b7, 0x7c0ec717, 0xef4073b7, 0xacb6bef0, 0x59c36f00, 0x59c36f00, 0x1b206d14, 0x1b206d14, 0x1b206d14, 0x65a00072, 0x65a00072, 0x65a00072, 0xa6823dbf, 0xa6823dbf, 0xa6823dbf, 0x59c36f00, 0xacb6bef0, 0xacb6bef0, 0x59c36f00, }, 20 }, - { "gfxterm_ru", 800, 600, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi256 */, (grub_uint32_t []) { 0xaa4593fe, 0x439c3f9c, 0xb979a570, 0x439c3f9c, 0x6d99bae3, 0xaa4593fe, 0xaa4593fe, 0x7c7873ca, 0x7c7873ca, 0x7c7873ca, 0xda8d7ead, 0xda8d7ead, 0xda8d7ead, 0x582a9cc6, 0x582a9cc6, 0x582a9cc6, 0xaa4593fe, 0x6d99bae3, 0x6d99bae3, 0xaa4593fe, }, 20 }, - { "gfxterm_ru", 1024, 768, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi256 */, (grub_uint32_t []) { 0xc9cbf769, 0x5ba2c945, 0x8734093, 0x5ba2c945, 0x6b5a4c1, 0xc9cbf769, 0xc9cbf769, 0xa3843a5a, 0xa3843a5a, 0xa3843a5a, 0x5d5cfb96, 0x5d5cfb96, 0x5d5cfb96, 0xb50a549a, 0xb50a549a, 0xb50a549a, 0xc9cbf769, 0x6b5a4c1, 0x6b5a4c1, 0xc9cbf769, }, 20 }, - { "gfxterm_ru", 640, 480, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 640x480xrgba5550 */, (grub_uint32_t []) { 0x5387d57f, 0xb36b0c97, 0x8089853c, 0xb36b0c97, 0xf760f62b, 0x5387d57f, 0x5387d57f, 0x26a49a0, 0x26a49a0, 0x26a49a0, 0xc233256c, 0xc233256c, 0xc233256c, 0x25eda7fa, 0x25eda7fa, 0x25eda7fa, 0x5387d57f, 0xf760f62b, 0xf760f62b, 0x5387d57f, }, 20 }, - { "gfxterm_ru", 800, 600, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 800x600xrgba5550 */, (grub_uint32_t []) { 0xf83ee7aa, 0x73036285, 0xc9508972, 0x73036285, 0xc96b2f1a, 0xf83ee7aa, 0xf83ee7aa, 0xd1a3be96, 0xd1a3be96, 0xd1a3be96, 0x4dda6e65, 0x4dda6e65, 0x4dda6e65, 0x7569c5cd, 0x7569c5cd, 0x7569c5cd, 0xf83ee7aa, 0xc96b2f1a, 0xc96b2f1a, 0xf83ee7aa, }, 20 }, - { "gfxterm_ru", 1024, 768, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 1024x768xrgba5550 */, (grub_uint32_t []) { 0x724366e5, 0x2f903fa3, 0xb074c7d0, 0x2f903fa3, 0x3ee58af6, 0x724366e5, 0x724366e5, 0xd7d194f8, 0xd7d194f8, 0xd7d194f8, 0x90e8d602, 0x90e8d602, 0x90e8d602, 0xfdc6f148, 0xfdc6f148, 0xfdc6f148, 0x724366e5, 0x3ee58af6, 0x3ee58af6, 0x724366e5, }, 20 }, - { "gfxterm_ru", 640, 480, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 640x480xrgba5650 */, (grub_uint32_t []) { 0x5387d57f, 0xa54ffd19, 0xf7cc7ac2, 0xa54ffd19, 0x4adb4020, 0x5387d57f, 0x5387d57f, 0x5dbc1d5, 0x5dbc1d5, 0x5dbc1d5, 0xdb158e08, 0xdb158e08, 0xdb158e08, 0x48961c16, 0x48961c16, 0x48961c16, 0x5387d57f, 0x4adb4020, 0x4adb4020, 0x5387d57f, }, 20 }, - { "gfxterm_ru", 800, 600, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 800x600xrgba5650 */, (grub_uint32_t []) { 0xf83ee7aa, 0xc66fad35, 0x8aac8190, 0xc66fad35, 0xb7a593d9, 0xf83ee7aa, 0xf83ee7aa, 0xb36d8105, 0xb36d8105, 0xb36d8105, 0xc1b79235, 0xc1b79235, 0xc1b79235, 0xf022c3f3, 0xf022c3f3, 0xf022c3f3, 0xf83ee7aa, 0xb7a593d9, 0xb7a593d9, 0xf83ee7aa, }, 20 }, - { "gfxterm_ru", 1024, 768, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 1024x768xrgba5650 */, (grub_uint32_t []) { 0x724366e5, 0x7f916214, 0x1c80967c, 0x7f916214, 0x8d43e964, 0x724366e5, 0x724366e5, 0xe456696, 0xe456696, 0xe456696, 0x57d595c6, 0x57d595c6, 0x57d595c6, 0x9f62fb84, 0x9f62fb84, 0x9f62fb84, 0x724366e5, 0x8d43e964, 0x8d43e964, 0x724366e5, }, 20 }, - { "gfxterm_ru", 640, 480, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 640x480xrgba8880 */, (grub_uint32_t []) { 0x1c955882, 0x4aeca683, 0xffbbb38e, 0x4aeca683, 0x4a8c1e25, 0x1c955882, 0x1c955882, 0xa0d2f3f6, 0xa0d2f3f6, 0xa0d2f3f6, 0x6f25be61, 0x6f25be61, 0x6f25be61, 0x914cb274, 0x914cb274, 0x914cb274, 0x1c955882, 0x4a8c1e25, 0x4a8c1e25, 0x1c955882, }, 20 }, - { "gfxterm_ru", 800, 600, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 800x600xrgba8880 */, (grub_uint32_t []) { 0x4d266f7a, 0xb44532a7, 0x73b09a92, 0xb44532a7, 0x7057aba3, 0x4d266f7a, 0x4d266f7a, 0x83606d88, 0x83606d88, 0x83606d88, 0x65177637, 0x65177637, 0x65177637, 0xfd2e22a7, 0xfd2e22a7, 0xfd2e22a7, 0x4d266f7a, 0x7057aba3, 0x7057aba3, 0x4d266f7a, }, 20 }, - { "gfxterm_ru", 1024, 768, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 1024x768xrgba8880 */, (grub_uint32_t []) { 0x1ed9d731, 0x62257381, 0xd5d910, 0x62257381, 0xfed17266, 0x1ed9d731, 0x1ed9d731, 0x12670373, 0x12670373, 0x12670373, 0xbc031db6, 0xbc031db6, 0xbc031db6, 0x9f6a0c00, 0x9f6a0c00, 0x9f6a0c00, 0x1ed9d731, 0xfed17266, 0xfed17266, 0x1ed9d731, }, 20 }, - { "gfxterm_ru", 640, 480, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 640x480xbgra5550 */, (grub_uint32_t []) { 0x5387d57f, 0xb36b0c97, 0x8089853c, 0xb36b0c97, 0xf760f62b, 0x5387d57f, 0x5387d57f, 0x26a49a0, 0x26a49a0, 0x26a49a0, 0xc233256c, 0xc233256c, 0xc233256c, 0x25eda7fa, 0x25eda7fa, 0x25eda7fa, 0x5387d57f, 0xf760f62b, 0xf760f62b, 0x5387d57f, }, 20 }, - { "gfxterm_ru", 800, 600, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 800x600xbgra5550 */, (grub_uint32_t []) { 0xf83ee7aa, 0x73036285, 0xc9508972, 0x73036285, 0xc96b2f1a, 0xf83ee7aa, 0xf83ee7aa, 0xd1a3be96, 0xd1a3be96, 0xd1a3be96, 0x4dda6e65, 0x4dda6e65, 0x4dda6e65, 0x7569c5cd, 0x7569c5cd, 0x7569c5cd, 0xf83ee7aa, 0xc96b2f1a, 0xc96b2f1a, 0xf83ee7aa, }, 20 }, - { "gfxterm_ru", 1024, 768, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 1024x768xbgra5550 */, (grub_uint32_t []) { 0x724366e5, 0x2f903fa3, 0xb074c7d0, 0x2f903fa3, 0x3ee58af6, 0x724366e5, 0x724366e5, 0xd7d194f8, 0xd7d194f8, 0xd7d194f8, 0x90e8d602, 0x90e8d602, 0x90e8d602, 0xfdc6f148, 0xfdc6f148, 0xfdc6f148, 0x724366e5, 0x3ee58af6, 0x3ee58af6, 0x724366e5, }, 20 }, - { "gfxterm_ru", 640, 480, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 640x480xbgra5650 */, (grub_uint32_t []) { 0x5387d57f, 0xa54ffd19, 0xf7cc7ac2, 0xa54ffd19, 0x4adb4020, 0x5387d57f, 0x5387d57f, 0x5dbc1d5, 0x5dbc1d5, 0x5dbc1d5, 0xdb158e08, 0xdb158e08, 0xdb158e08, 0x48961c16, 0x48961c16, 0x48961c16, 0x5387d57f, 0x4adb4020, 0x4adb4020, 0x5387d57f, }, 20 }, - { "gfxterm_ru", 800, 600, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 800x600xbgra5650 */, (grub_uint32_t []) { 0xf83ee7aa, 0xc66fad35, 0x8aac8190, 0xc66fad35, 0xb7a593d9, 0xf83ee7aa, 0xf83ee7aa, 0xb36d8105, 0xb36d8105, 0xb36d8105, 0xc1b79235, 0xc1b79235, 0xc1b79235, 0xf022c3f3, 0xf022c3f3, 0xf022c3f3, 0xf83ee7aa, 0xb7a593d9, 0xb7a593d9, 0xf83ee7aa, }, 20 }, - { "gfxterm_ru", 1024, 768, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 1024x768xbgra5650 */, (grub_uint32_t []) { 0x724366e5, 0x7f916214, 0x1c80967c, 0x7f916214, 0x8d43e964, 0x724366e5, 0x724366e5, 0xe456696, 0xe456696, 0xe456696, 0x57d595c6, 0x57d595c6, 0x57d595c6, 0x9f62fb84, 0x9f62fb84, 0x9f62fb84, 0x724366e5, 0x8d43e964, 0x8d43e964, 0x724366e5, }, 20 }, - { "gfxterm_ru", 640, 480, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 640x480xbgra8880 */, (grub_uint32_t []) { 0x1c955882, 0x4aeca683, 0xffbbb38e, 0x4aeca683, 0x4a8c1e25, 0x1c955882, 0x1c955882, 0xa0d2f3f6, 0xa0d2f3f6, 0xa0d2f3f6, 0x6f25be61, 0x6f25be61, 0x6f25be61, 0x914cb274, 0x914cb274, 0x914cb274, 0x1c955882, 0x4a8c1e25, 0x4a8c1e25, 0x1c955882, }, 20 }, - { "gfxterm_ru", 800, 600, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 800x600xbgra8880 */, (grub_uint32_t []) { 0x4d266f7a, 0xb44532a7, 0x73b09a92, 0xb44532a7, 0x7057aba3, 0x4d266f7a, 0x4d266f7a, 0x83606d88, 0x83606d88, 0x83606d88, 0x65177637, 0x65177637, 0x65177637, 0xfd2e22a7, 0xfd2e22a7, 0xfd2e22a7, 0x4d266f7a, 0x7057aba3, 0x7057aba3, 0x4d266f7a, }, 20 }, - { "gfxterm_ru", 1024, 768, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 1024x768xbgra8880 */, (grub_uint32_t []) { 0x1ed9d731, 0x62257381, 0xd5d910, 0x62257381, 0xfed17266, 0x1ed9d731, 0x1ed9d731, 0x12670373, 0x12670373, 0x12670373, 0xbc031db6, 0xbc031db6, 0xbc031db6, 0x9f6a0c00, 0x9f6a0c00, 0x9f6a0c00, 0x1ed9d731, 0xfed17266, 0xfed17266, 0x1ed9d731, }, 20 }, - { "gfxterm_ru", 640, 480, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 640x480xbgra8888 */, (grub_uint32_t []) { 0x9813a416, 0x1d557c7b, 0x8d172abd, 0x1d557c7b, 0x4d4dd8d5, 0x9813a416, 0x9813a416, 0xae45df54, 0xae45df54, 0xae45df54, 0x3f9e5967, 0x3f9e5967, 0x3f9e5967, 0xa3ebaca5, 0xa3ebaca5, 0xa3ebaca5, 0x9813a416, 0x4d4dd8d5, 0x4d4dd8d5, 0x9813a416, }, 20 }, - { "gfxterm_ru", 800, 600, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 800x600xbgra8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x75e8bbc6, 0x79f972a, 0x75e8bbc6, 0x4f226a3c, 0x5fcf013d, 0x5fcf013d, 0xe1849dd3, 0xe1849dd3, 0xe1849dd3, 0x339485a5, 0x339485a5, 0x339485a5, 0x2cbf0458, 0x2cbf0458, 0x2cbf0458, 0x5fcf013d, 0x4f226a3c, 0x4f226a3c, 0x5fcf013d, }, 20 }, - { "gfxterm_ru", 1024, 768, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 1024x768xbgra8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x7391ddfb, 0x7d352e1, 0x7391ddfb, 0x13e27991, 0xdd28f52b, 0xdd28f52b, 0x25591550, 0x25591550, 0x25591550, 0x465ecb4, 0x465ecb4, 0x465ecb4, 0x1e148f25, 0x1e148f25, 0x1e148f25, 0xdd28f52b, 0x13e27991, 0x13e27991, 0xdd28f52b, }, 20 }, - { "gfxterm_fr", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x371337c9, 0x8aa416bc, 0x371337c9, 0x74e5fa8e, 0x59c36f00, 0x59c36f00, 0xb169e11b, 0xb169e11b, 0xb169e11b, 0xcfe98c7d, 0xcfe98c7d, 0xcfe98c7d, 0xccbb1b0, 0xccbb1b0, 0xccbb1b0, 0x59c36f00, 0x74e5fa8e, 0x74e5fa8e, 0x59c36f00, }, 20 }, - { "gfxterm_fr", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x38692869, 0xefb9c2f4, 0x38692869, 0x166cad16, 0xaa4593fe, 0xaa4593fe, 0xe4f03f82, 0xe4f03f82, 0xe4f03f82, 0x420532e5, 0x420532e5, 0x420532e5, 0xc0a2d08e, 0xc0a2d08e, 0xc0a2d08e, 0xaa4593fe, 0x166cad16, 0x166cad16, 0xaa4593fe, }, 20 }, - { "gfxterm_fr", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x7eb7ddfd, 0x19db9bb1, 0x7eb7ddfd, 0x23a0b079, 0xc9cbf769, 0xc9cbf769, 0x4500ac91, 0x4500ac91, 0x4500ac91, 0xbbd86d5d, 0xbbd86d5d, 0xbbd86d5d, 0x538ec251, 0x538ec251, 0x538ec251, 0xc9cbf769, 0x23a0b079, 0x23a0b079, 0xc9cbf769, }, 20 }, - { "gfxterm_fr", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x35512c6d, 0xe29deaf0, 0x35512c6d, 0x654988c3, 0x9813a416, 0x9813a416, 0xc6920c94, 0xc6920c94, 0xc6920c94, 0x57498aa7, 0x57498aa7, 0x57498aa7, 0xcb3c7f65, 0xcb3c7f65, 0xcb3c7f65, 0x9813a416, 0x654988c3, 0x654988c3, 0x9813a416, }, 20 }, - { "gfxterm_fr", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x73ff9071, 0x72b83f24, 0x73ff9071, 0x4935418b, 0x5fcf013d, 0x5fcf013d, 0x9963ff63, 0x9963ff63, 0x9963ff63, 0x4b73e715, 0x4b73e715, 0x4b73e715, 0x545866e8, 0x545866e8, 0x545866e8, 0x5fcf013d, 0x4935418b, 0x4935418b, 0x5fcf013d, }, 20 }, - { "gfxterm_fr", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x46811b4e, 0xa463f7aa, 0x46811b4e, 0x26f2bf24, 0xdd28f52b, 0xdd28f52b, 0x452cf740, 0x452cf740, 0x452cf740, 0x64100ea4, 0x64100ea4, 0x64100ea4, 0x7e616d35, 0x7e616d35, 0x7e616d35, 0xdd28f52b, 0x26f2bf24, 0x26f2bf24, 0xdd28f52b, }, 20 }, - { "gfxterm_fr", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0xd89b7256, 0xe60a4e85, 0xd89b7256, 0x26dd7f3b, 0x43d1f34, 0x43d1f34, 0x55b946c0, 0x55b946c0, 0x55b946c0, 0x2ab3ef68, 0x2ab3ef68, 0x2ab3ef68, 0xc293d641, 0xc293d641, 0xc293d641, 0x43d1f34, 0x26dd7f3b, 0x26dd7f3b, 0x43d1f34, }, 20 }, - { "gfxterm_fr", 640, 480, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi256 */, (grub_uint32_t []) { 0x59c36f00, 0x371337c9, 0x8aa416bc, 0x371337c9, 0x74e5fa8e, 0x59c36f00, 0x59c36f00, 0xb169e11b, 0xb169e11b, 0xb169e11b, 0xcfe98c7d, 0xcfe98c7d, 0xcfe98c7d, 0xccbb1b0, 0xccbb1b0, 0xccbb1b0, 0x59c36f00, 0x74e5fa8e, 0x74e5fa8e, 0x59c36f00, }, 20 }, - { "gfxterm_fr", 800, 600, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi256 */, (grub_uint32_t []) { 0xaa4593fe, 0x38692869, 0xefb9c2f4, 0x38692869, 0x166cad16, 0xaa4593fe, 0xaa4593fe, 0xe4f03f82, 0xe4f03f82, 0xe4f03f82, 0x420532e5, 0x420532e5, 0x420532e5, 0xc0a2d08e, 0xc0a2d08e, 0xc0a2d08e, 0xaa4593fe, 0x166cad16, 0x166cad16, 0xaa4593fe, }, 20 }, - { "gfxterm_fr", 1024, 768, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi256 */, (grub_uint32_t []) { 0xc9cbf769, 0x7eb7ddfd, 0x19db9bb1, 0x7eb7ddfd, 0x23a0b079, 0xc9cbf769, 0xc9cbf769, 0x4500ac91, 0x4500ac91, 0x4500ac91, 0xbbd86d5d, 0xbbd86d5d, 0xbbd86d5d, 0x538ec251, 0x538ec251, 0x538ec251, 0xc9cbf769, 0x23a0b079, 0x23a0b079, 0xc9cbf769, }, 20 }, - { "gfxterm_fr", 640, 480, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 640x480xrgba5550 */, (grub_uint32_t []) { 0x5387d57f, 0x60f63dde, 0xcb069f7a, 0x60f63dde, 0x24fdc762, 0x5387d57f, 0x5387d57f, 0xf5998b00, 0xf5998b00, 0xf5998b00, 0x35c0e7cc, 0x35c0e7cc, 0x35c0e7cc, 0xd21e655a, 0xd21e655a, 0xd21e655a, 0x5387d57f, 0x24fdc762, 0x24fdc762, 0x5387d57f, }, 20 }, - { "gfxterm_fr", 800, 600, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 800x600xrgba5550 */, (grub_uint32_t []) { 0xf83ee7aa, 0x8fa5f86d, 0xed066d2c, 0x8fa5f86d, 0x35cdb5f2, 0xf83ee7aa, 0xf83ee7aa, 0x26e9dc45, 0x26e9dc45, 0x26e9dc45, 0xba900cb6, 0xba900cb6, 0xba900cb6, 0x8223a71e, 0x8223a71e, 0x8223a71e, 0xf83ee7aa, 0x35cdb5f2, 0x35cdb5f2, 0xf83ee7aa, }, 20 }, - { "gfxterm_fr", 1024, 768, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 1024x768xrgba5550 */, (grub_uint32_t []) { 0x724366e5, 0xf3ebce27, 0x64821e83, 0xf3ebce27, 0xe29e7b72, 0x724366e5, 0x724366e5, 0xf2920fc5, 0xf2920fc5, 0xf2920fc5, 0xb5ab4d3f, 0xb5ab4d3f, 0xb5ab4d3f, 0xd8856a75, 0xd8856a75, 0xd8856a75, 0x724366e5, 0xe29e7b72, 0xe29e7b72, 0x724366e5, }, 20 }, - { "gfxterm_fr", 640, 480, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 640x480xrgba5650 */, (grub_uint32_t []) { 0x5387d57f, 0xda2165d2, 0x5f811c6d, 0xda2165d2, 0x35b5d8eb, 0x5387d57f, 0x5387d57f, 0xe5a2fdfd, 0xe5a2fdfd, 0xe5a2fdfd, 0x3b6cb220, 0x3b6cb220, 0x3b6cb220, 0xa8ef203e, 0xa8ef203e, 0xa8ef203e, 0x5387d57f, 0x35b5d8eb, 0x35b5d8eb, 0x5387d57f, }, 20 }, - { "gfxterm_fr", 800, 600, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 800x600xrgba5650 */, (grub_uint32_t []) { 0xf83ee7aa, 0xf52ba155, 0x4866b5cd, 0xf52ba155, 0x84e19fb9, 0xf83ee7aa, 0xf83ee7aa, 0xc1a44e99, 0xc1a44e99, 0xc1a44e99, 0xb37e5da9, 0xb37e5da9, 0xb37e5da9, 0x82eb0c6f, 0x82eb0c6f, 0x82eb0c6f, 0xf83ee7aa, 0x84e19fb9, 0x84e19fb9, 0xf83ee7aa, }, 20 }, - { "gfxterm_fr", 1024, 768, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 1024x768xrgba5650 */, (grub_uint32_t []) { 0x724366e5, 0x16d37834, 0x72eb8d00, 0x16d37834, 0xe401f344, 0x724366e5, 0x724366e5, 0xc80f0332, 0xc80f0332, 0xc80f0332, 0x919ff062, 0x919ff062, 0x919ff062, 0x59289e20, 0x59289e20, 0x59289e20, 0x724366e5, 0xe401f344, 0xe401f344, 0x724366e5, }, 20 }, - { "gfxterm_fr", 640, 480, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 640x480xrgba8880 */, (grub_uint32_t []) { 0x1c955882, 0x501ed137, 0x3eb913d3, 0x501ed137, 0x507e6991, 0x1c955882, 0x1c955882, 0xc988465d, 0xc988465d, 0xc988465d, 0x67f0bca, 0x67f0bca, 0x67f0bca, 0xf81607df, 0xf81607df, 0xf81607df, 0x1c955882, 0x507e6991, 0x507e6991, 0x1c955882, }, 20 }, - { "gfxterm_fr", 800, 600, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 800x600xrgba8880 */, (grub_uint32_t []) { 0x4d266f7a, 0xdbf45ff0, 0x4b12f903, 0xdbf45ff0, 0x1fe6c6f4, 0x4d266f7a, 0x4d266f7a, 0xee77b36d, 0xee77b36d, 0xee77b36d, 0x800a8d2, 0x800a8d2, 0x800a8d2, 0x9039fc42, 0x9039fc42, 0x9039fc42, 0x4d266f7a, 0x1fe6c6f4, 0x1fe6c6f4, 0x4d266f7a, }, 20 }, - { "gfxterm_fr", 1024, 768, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 1024x768xrgba8880 */, (grub_uint32_t []) { 0x1ed9d731, 0x6c3a9814, 0xaa19882a, 0x6c3a9814, 0xf0ce99f3, 0x1ed9d731, 0x1ed9d731, 0x5819ad52, 0x5819ad52, 0x5819ad52, 0xf67db397, 0xf67db397, 0xf67db397, 0xd514a221, 0xd514a221, 0xd514a221, 0x1ed9d731, 0xf0ce99f3, 0xf0ce99f3, 0x1ed9d731, }, 20 }, - { "gfxterm_fr", 640, 480, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 640x480xbgra5550 */, (grub_uint32_t []) { 0x5387d57f, 0x60f63dde, 0xcb069f7a, 0x60f63dde, 0x24fdc762, 0x5387d57f, 0x5387d57f, 0xf5998b00, 0xf5998b00, 0xf5998b00, 0x35c0e7cc, 0x35c0e7cc, 0x35c0e7cc, 0xd21e655a, 0xd21e655a, 0xd21e655a, 0x5387d57f, 0x24fdc762, 0x24fdc762, 0x5387d57f, }, 20 }, - { "gfxterm_fr", 800, 600, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 800x600xbgra5550 */, (grub_uint32_t []) { 0xf83ee7aa, 0x8fa5f86d, 0xed066d2c, 0x8fa5f86d, 0x35cdb5f2, 0xf83ee7aa, 0xf83ee7aa, 0x26e9dc45, 0x26e9dc45, 0x26e9dc45, 0xba900cb6, 0xba900cb6, 0xba900cb6, 0x8223a71e, 0x8223a71e, 0x8223a71e, 0xf83ee7aa, 0x35cdb5f2, 0x35cdb5f2, 0xf83ee7aa, }, 20 }, - { "gfxterm_fr", 1024, 768, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 1024x768xbgra5550 */, (grub_uint32_t []) { 0x724366e5, 0xf3ebce27, 0x64821e83, 0xf3ebce27, 0xe29e7b72, 0x724366e5, 0x724366e5, 0xf2920fc5, 0xf2920fc5, 0xf2920fc5, 0xb5ab4d3f, 0xb5ab4d3f, 0xb5ab4d3f, 0xd8856a75, 0xd8856a75, 0xd8856a75, 0x724366e5, 0xe29e7b72, 0xe29e7b72, 0x724366e5, }, 20 }, - { "gfxterm_fr", 640, 480, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 640x480xbgra5650 */, (grub_uint32_t []) { 0x5387d57f, 0xda2165d2, 0x5f811c6d, 0xda2165d2, 0x35b5d8eb, 0x5387d57f, 0x5387d57f, 0xe5a2fdfd, 0xe5a2fdfd, 0xe5a2fdfd, 0x3b6cb220, 0x3b6cb220, 0x3b6cb220, 0xa8ef203e, 0xa8ef203e, 0xa8ef203e, 0x5387d57f, 0x35b5d8eb, 0x35b5d8eb, 0x5387d57f, }, 20 }, - { "gfxterm_fr", 800, 600, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 800x600xbgra5650 */, (grub_uint32_t []) { 0xf83ee7aa, 0xf52ba155, 0x4866b5cd, 0xf52ba155, 0x84e19fb9, 0xf83ee7aa, 0xf83ee7aa, 0xc1a44e99, 0xc1a44e99, 0xc1a44e99, 0xb37e5da9, 0xb37e5da9, 0xb37e5da9, 0x82eb0c6f, 0x82eb0c6f, 0x82eb0c6f, 0xf83ee7aa, 0x84e19fb9, 0x84e19fb9, 0xf83ee7aa, }, 20 }, - { "gfxterm_fr", 1024, 768, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 1024x768xbgra5650 */, (grub_uint32_t []) { 0x724366e5, 0x16d37834, 0x72eb8d00, 0x16d37834, 0xe401f344, 0x724366e5, 0x724366e5, 0xc80f0332, 0xc80f0332, 0xc80f0332, 0x919ff062, 0x919ff062, 0x919ff062, 0x59289e20, 0x59289e20, 0x59289e20, 0x724366e5, 0xe401f344, 0xe401f344, 0x724366e5, }, 20 }, - { "gfxterm_fr", 640, 480, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 640x480xbgra8880 */, (grub_uint32_t []) { 0x1c955882, 0x501ed137, 0x3eb913d3, 0x501ed137, 0x507e6991, 0x1c955882, 0x1c955882, 0xc988465d, 0xc988465d, 0xc988465d, 0x67f0bca, 0x67f0bca, 0x67f0bca, 0xf81607df, 0xf81607df, 0xf81607df, 0x1c955882, 0x507e6991, 0x507e6991, 0x1c955882, }, 20 }, - { "gfxterm_fr", 800, 600, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 800x600xbgra8880 */, (grub_uint32_t []) { 0x4d266f7a, 0xdbf45ff0, 0x4b12f903, 0xdbf45ff0, 0x1fe6c6f4, 0x4d266f7a, 0x4d266f7a, 0xee77b36d, 0xee77b36d, 0xee77b36d, 0x800a8d2, 0x800a8d2, 0x800a8d2, 0x9039fc42, 0x9039fc42, 0x9039fc42, 0x4d266f7a, 0x1fe6c6f4, 0x1fe6c6f4, 0x4d266f7a, }, 20 }, - { "gfxterm_fr", 1024, 768, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 1024x768xbgra8880 */, (grub_uint32_t []) { 0x1ed9d731, 0x6c3a9814, 0xaa19882a, 0x6c3a9814, 0xf0ce99f3, 0x1ed9d731, 0x1ed9d731, 0x5819ad52, 0x5819ad52, 0x5819ad52, 0xf67db397, 0xf67db397, 0xf67db397, 0xd514a221, 0xd514a221, 0xd514a221, 0x1ed9d731, 0xf0ce99f3, 0xf0ce99f3, 0x1ed9d731, }, 20 }, - { "gfxterm_fr", 640, 480, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 640x480xbgra8888 */, (grub_uint32_t []) { 0x9813a416, 0x35512c6d, 0xe29deaf0, 0x35512c6d, 0x654988c3, 0x9813a416, 0x9813a416, 0xc6920c94, 0xc6920c94, 0xc6920c94, 0x57498aa7, 0x57498aa7, 0x57498aa7, 0xcb3c7f65, 0xcb3c7f65, 0xcb3c7f65, 0x9813a416, 0x654988c3, 0x654988c3, 0x9813a416, }, 20 }, - { "gfxterm_fr", 800, 600, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 800x600xbgra8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x73ff9071, 0x72b83f24, 0x73ff9071, 0x4935418b, 0x5fcf013d, 0x5fcf013d, 0x9963ff63, 0x9963ff63, 0x9963ff63, 0x4b73e715, 0x4b73e715, 0x4b73e715, 0x545866e8, 0x545866e8, 0x545866e8, 0x5fcf013d, 0x4935418b, 0x4935418b, 0x5fcf013d, }, 20 }, - { "gfxterm_fr", 1024, 768, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 1024x768xbgra8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x46811b4e, 0xa463f7aa, 0x46811b4e, 0x26f2bf24, 0xdd28f52b, 0xdd28f52b, 0x452cf740, 0x452cf740, 0x452cf740, 0x64100ea4, 0x64100ea4, 0x64100ea4, 0x7e616d35, 0x7e616d35, 0x7e616d35, 0xdd28f52b, 0x26f2bf24, 0x26f2bf24, 0xdd28f52b, }, 20 }, - { "gfxterm_quot", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x791b97c6, 0xd80a4dd5, 0x791b97c6, 0x3aed5a81, 0x59c36f00, 0x59c36f00, 0xc8b88a82, 0xc8b88a82, 0xc8b88a82, 0xb638e7e4, 0xb638e7e4, 0xb638e7e4, 0x751ada29, 0x751ada29, 0x751ada29, 0x59c36f00, 0x3aed5a81, 0x3aed5a81, 0x59c36f00, }, 20 }, - { "gfxterm_quot", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x6c6b27f2, 0x9ad8591c, 0x6c6b27f2, 0x426ea28d, 0xaa4593fe, 0xaa4593fe, 0x8b63f19d, 0x8b63f19d, 0x8b63f19d, 0x2d96fcfa, 0x2d96fcfa, 0x2d96fcfa, 0xaf311e91, 0xaf311e91, 0xaf311e91, 0xaa4593fe, 0x426ea28d, 0x426ea28d, 0xaa4593fe, }, 20 }, - { "gfxterm_quot", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xb553210b, 0xf9eb9fa4, 0xb553210b, 0xe8444c8f, 0xc9cbf769, 0xc9cbf769, 0xec23555f, 0xec23555f, 0xec23555f, 0x12fb9493, 0x12fb9493, 0x12fb9493, 0xfaad3b9f, 0xfaad3b9f, 0xfaad3b9f, 0xc9cbf769, 0xe8444c8f, 0xe8444c8f, 0xc9cbf769, }, 20 }, - { "gfxterm_quot", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x979d71de, 0x73e38996, 0x979d71de, 0xc785d570, 0x9813a416, 0x9813a416, 0xc10419e0, 0xc10419e0, 0xc10419e0, 0x50df9fd3, 0x50df9fd3, 0x50df9fd3, 0xccaa6a11, 0xccaa6a11, 0xccaa6a11, 0x9813a416, 0xc785d570, 0xc785d570, 0x9813a416, }, 20 }, - { "gfxterm_quot", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x78d87f9d, 0x345e385f, 0x78d87f9d, 0x4212ae67, 0x5fcf013d, 0x5fcf013d, 0x77ba65ab, 0x77ba65ab, 0x77ba65ab, 0xa5aa7ddd, 0xa5aa7ddd, 0xa5aa7ddd, 0xba81fc20, 0xba81fc20, 0xba81fc20, 0x5fcf013d, 0x4212ae67, 0x4212ae67, 0x5fcf013d, }, 20 }, - { "gfxterm_quot", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x750f8146, 0x2148bdae, 0x750f8146, 0x157c252c, 0xdd28f52b, 0xdd28f52b, 0xbc36f156, 0xbc36f156, 0xbc36f156, 0x9d0a08b2, 0x9d0a08b2, 0x9d0a08b2, 0x877b6b23, 0x877b6b23, 0x877b6b23, 0xdd28f52b, 0x157c252c, 0x157c252c, 0xdd28f52b, }, 20 }, - { "gfxterm_quot", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x58828a1e, 0x11d1547e, 0x58828a1e, 0xa6c48773, 0x43d1f34, 0x43d1f34, 0xd204ac75, 0xd204ac75, 0xd204ac75, 0xad0e05dd, 0xad0e05dd, 0xad0e05dd, 0x452e3cf4, 0x452e3cf4, 0x452e3cf4, 0x43d1f34, 0xa6c48773, 0xa6c48773, 0x43d1f34, }, 20 }, - { "gfxterm_quot", 640, 480, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi256 */, (grub_uint32_t []) { 0x59c36f00, 0x791b97c6, 0xd80a4dd5, 0x791b97c6, 0x3aed5a81, 0x59c36f00, 0x59c36f00, 0xc8b88a82, 0xc8b88a82, 0xc8b88a82, 0xb638e7e4, 0xb638e7e4, 0xb638e7e4, 0x751ada29, 0x751ada29, 0x751ada29, 0x59c36f00, 0x3aed5a81, 0x3aed5a81, 0x59c36f00, }, 20 }, - { "gfxterm_quot", 800, 600, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi256 */, (grub_uint32_t []) { 0xaa4593fe, 0x6c6b27f2, 0x9ad8591c, 0x6c6b27f2, 0x426ea28d, 0xaa4593fe, 0xaa4593fe, 0x8b63f19d, 0x8b63f19d, 0x8b63f19d, 0x2d96fcfa, 0x2d96fcfa, 0x2d96fcfa, 0xaf311e91, 0xaf311e91, 0xaf311e91, 0xaa4593fe, 0x426ea28d, 0x426ea28d, 0xaa4593fe, }, 20 }, - { "gfxterm_quot", 1024, 768, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi256 */, (grub_uint32_t []) { 0xc9cbf769, 0xb553210b, 0xf9eb9fa4, 0xb553210b, 0xe8444c8f, 0xc9cbf769, 0xc9cbf769, 0xec23555f, 0xec23555f, 0xec23555f, 0x12fb9493, 0x12fb9493, 0x12fb9493, 0xfaad3b9f, 0xfaad3b9f, 0xfaad3b9f, 0xc9cbf769, 0xe8444c8f, 0xe8444c8f, 0xc9cbf769, }, 20 }, - { "gfxterm_quot", 640, 480, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 640x480xrgba5550 */, (grub_uint32_t []) { 0x5387d57f, 0xe0300e88, 0x76ba1dd0, 0xe0300e88, 0xa43bf434, 0x5387d57f, 0x5387d57f, 0x71381c6, 0x71381c6, 0x71381c6, 0xc74aed0a, 0xc74aed0a, 0xc74aed0a, 0x20946f9c, 0x20946f9c, 0x20946f9c, 0x5387d57f, 0xa43bf434, 0xa43bf434, 0x5387d57f, }, 20 }, - { "gfxterm_quot", 800, 600, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 800x600xrgba5550 */, (grub_uint32_t []) { 0xf83ee7aa, 0xa26081d9, 0xef5b1078, 0xa26081d9, 0x1808cc46, 0xf83ee7aa, 0xf83ee7aa, 0x610deea9, 0x610deea9, 0x610deea9, 0xfd743e5a, 0xfd743e5a, 0xfd743e5a, 0xc5c795f2, 0xc5c795f2, 0xc5c795f2, 0xf83ee7aa, 0x1808cc46, 0x1808cc46, 0xf83ee7aa, }, 20 }, - { "gfxterm_quot", 1024, 768, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 1024x768xrgba5550 */, (grub_uint32_t []) { 0x724366e5, 0x6f16d50f, 0x2fc71082, 0x6f16d50f, 0x7e63605a, 0x724366e5, 0x724366e5, 0xdbb2f05a, 0xdbb2f05a, 0xdbb2f05a, 0x9c8bb2a0, 0x9c8bb2a0, 0x9c8bb2a0, 0xf1a595ea, 0xf1a595ea, 0xf1a595ea, 0x724366e5, 0x7e63605a, 0x7e63605a, 0x724366e5, }, 20 }, - { "gfxterm_quot", 640, 480, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 640x480xrgba5650 */, (grub_uint32_t []) { 0x5387d57f, 0xc959920b, 0x3548d7d5, 0xc959920b, 0x26cd2f32, 0x5387d57f, 0x5387d57f, 0x23c74007, 0x23c74007, 0x23c74007, 0xfd090fda, 0xfd090fda, 0xfd090fda, 0x6e8a9dc4, 0x6e8a9dc4, 0x6e8a9dc4, 0x5387d57f, 0x26cd2f32, 0x26cd2f32, 0x5387d57f, }, 20 }, - { "gfxterm_quot", 800, 600, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 800x600xrgba5650 */, (grub_uint32_t []) { 0xf83ee7aa, 0x93c26040, 0x70ae777c, 0x93c26040, 0xe2085eac, 0xf83ee7aa, 0xf83ee7aa, 0xa5fd8afa, 0xa5fd8afa, 0xa5fd8afa, 0xd72799ca, 0xd72799ca, 0xd72799ca, 0xe6b2c80c, 0xe6b2c80c, 0xe6b2c80c, 0xf83ee7aa, 0xe2085eac, 0xe2085eac, 0xf83ee7aa, }, 20 }, - { "gfxterm_quot", 1024, 768, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 1024x768xrgba5650 */, (grub_uint32_t []) { 0x724366e5, 0x73b37a76, 0x352c8931, 0x73b37a76, 0x8161f106, 0x724366e5, 0x724366e5, 0xd0002838, 0xd0002838, 0xd0002838, 0x8990db68, 0x8990db68, 0x8990db68, 0x4127b52a, 0x4127b52a, 0x4127b52a, 0x724366e5, 0x8161f106, 0x8161f106, 0x724366e5, }, 20 }, - { "gfxterm_quot", 640, 480, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 640x480xrgba8880 */, (grub_uint32_t []) { 0x1c955882, 0xe12eaf27, 0xe7b5009a, 0xe12eaf27, 0xe14e1781, 0x1c955882, 0x1c955882, 0x727420bf, 0x727420bf, 0x727420bf, 0xbd836d28, 0xbd836d28, 0xbd836d28, 0x43ea613d, 0x43ea613d, 0x43ea613d, 0x1c955882, 0xe14e1781, 0xe14e1781, 0x1c955882, }, 20 }, - { "gfxterm_quot", 800, 600, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 800x600xrgba8880 */, (grub_uint32_t []) { 0x4d266f7a, 0x5a376c04, 0xd27c4646, 0x5a376c04, 0x9e25f500, 0x4d266f7a, 0x4d266f7a, 0xc23ec599, 0xc23ec599, 0xc23ec599, 0x2449de26, 0x2449de26, 0x2449de26, 0xbc708ab6, 0xbc708ab6, 0xbc708ab6, 0x4d266f7a, 0x9e25f500, 0x9e25f500, 0x4d266f7a, }, 20 }, - { "gfxterm_quot", 1024, 768, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 1024x768xrgba8880 */, (grub_uint32_t []) { 0x1ed9d731, 0x3f02033b, 0xd99eaa7, 0x3f02033b, 0xa3f602dc, 0x1ed9d731, 0x1ed9d731, 0x6ea8026e, 0x6ea8026e, 0x6ea8026e, 0xc0cc1cab, 0xc0cc1cab, 0xc0cc1cab, 0xe3a50d1d, 0xe3a50d1d, 0xe3a50d1d, 0x1ed9d731, 0xa3f602dc, 0xa3f602dc, 0x1ed9d731, }, 20 }, - { "gfxterm_quot", 640, 480, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 640x480xbgra5550 */, (grub_uint32_t []) { 0x5387d57f, 0xe0300e88, 0x76ba1dd0, 0xe0300e88, 0xa43bf434, 0x5387d57f, 0x5387d57f, 0x71381c6, 0x71381c6, 0x71381c6, 0xc74aed0a, 0xc74aed0a, 0xc74aed0a, 0x20946f9c, 0x20946f9c, 0x20946f9c, 0x5387d57f, 0xa43bf434, 0xa43bf434, 0x5387d57f, }, 20 }, - { "gfxterm_quot", 800, 600, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 800x600xbgra5550 */, (grub_uint32_t []) { 0xf83ee7aa, 0xa26081d9, 0xef5b1078, 0xa26081d9, 0x1808cc46, 0xf83ee7aa, 0xf83ee7aa, 0x610deea9, 0x610deea9, 0x610deea9, 0xfd743e5a, 0xfd743e5a, 0xfd743e5a, 0xc5c795f2, 0xc5c795f2, 0xc5c795f2, 0xf83ee7aa, 0x1808cc46, 0x1808cc46, 0xf83ee7aa, }, 20 }, - { "gfxterm_quot", 1024, 768, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 1024x768xbgra5550 */, (grub_uint32_t []) { 0x724366e5, 0x6f16d50f, 0x2fc71082, 0x6f16d50f, 0x7e63605a, 0x724366e5, 0x724366e5, 0xdbb2f05a, 0xdbb2f05a, 0xdbb2f05a, 0x9c8bb2a0, 0x9c8bb2a0, 0x9c8bb2a0, 0xf1a595ea, 0xf1a595ea, 0xf1a595ea, 0x724366e5, 0x7e63605a, 0x7e63605a, 0x724366e5, }, 20 }, - { "gfxterm_quot", 640, 480, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 640x480xbgra5650 */, (grub_uint32_t []) { 0x5387d57f, 0xc959920b, 0x3548d7d5, 0xc959920b, 0x26cd2f32, 0x5387d57f, 0x5387d57f, 0x23c74007, 0x23c74007, 0x23c74007, 0xfd090fda, 0xfd090fda, 0xfd090fda, 0x6e8a9dc4, 0x6e8a9dc4, 0x6e8a9dc4, 0x5387d57f, 0x26cd2f32, 0x26cd2f32, 0x5387d57f, }, 20 }, - { "gfxterm_quot", 800, 600, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 800x600xbgra5650 */, (grub_uint32_t []) { 0xf83ee7aa, 0x93c26040, 0x70ae777c, 0x93c26040, 0xe2085eac, 0xf83ee7aa, 0xf83ee7aa, 0xa5fd8afa, 0xa5fd8afa, 0xa5fd8afa, 0xd72799ca, 0xd72799ca, 0xd72799ca, 0xe6b2c80c, 0xe6b2c80c, 0xe6b2c80c, 0xf83ee7aa, 0xe2085eac, 0xe2085eac, 0xf83ee7aa, }, 20 }, - { "gfxterm_quot", 1024, 768, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 1024x768xbgra5650 */, (grub_uint32_t []) { 0x724366e5, 0x73b37a76, 0x352c8931, 0x73b37a76, 0x8161f106, 0x724366e5, 0x724366e5, 0xd0002838, 0xd0002838, 0xd0002838, 0x8990db68, 0x8990db68, 0x8990db68, 0x4127b52a, 0x4127b52a, 0x4127b52a, 0x724366e5, 0x8161f106, 0x8161f106, 0x724366e5, }, 20 }, - { "gfxterm_quot", 640, 480, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 640x480xbgra8880 */, (grub_uint32_t []) { 0x1c955882, 0xe12eaf27, 0xe7b5009a, 0xe12eaf27, 0xe14e1781, 0x1c955882, 0x1c955882, 0x727420bf, 0x727420bf, 0x727420bf, 0xbd836d28, 0xbd836d28, 0xbd836d28, 0x43ea613d, 0x43ea613d, 0x43ea613d, 0x1c955882, 0xe14e1781, 0xe14e1781, 0x1c955882, }, 20 }, - { "gfxterm_quot", 800, 600, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 800x600xbgra8880 */, (grub_uint32_t []) { 0x4d266f7a, 0x5a376c04, 0xd27c4646, 0x5a376c04, 0x9e25f500, 0x4d266f7a, 0x4d266f7a, 0xc23ec599, 0xc23ec599, 0xc23ec599, 0x2449de26, 0x2449de26, 0x2449de26, 0xbc708ab6, 0xbc708ab6, 0xbc708ab6, 0x4d266f7a, 0x9e25f500, 0x9e25f500, 0x4d266f7a, }, 20 }, - { "gfxterm_quot", 1024, 768, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 1024x768xbgra8880 */, (grub_uint32_t []) { 0x1ed9d731, 0x3f02033b, 0xd99eaa7, 0x3f02033b, 0xa3f602dc, 0x1ed9d731, 0x1ed9d731, 0x6ea8026e, 0x6ea8026e, 0x6ea8026e, 0xc0cc1cab, 0xc0cc1cab, 0xc0cc1cab, 0xe3a50d1d, 0xe3a50d1d, 0xe3a50d1d, 0x1ed9d731, 0xa3f602dc, 0xa3f602dc, 0x1ed9d731, }, 20 }, - { "gfxterm_quot", 640, 480, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 640x480xbgra8888 */, (grub_uint32_t []) { 0x9813a416, 0x979d71de, 0x73e38996, 0x979d71de, 0xc785d570, 0x9813a416, 0x9813a416, 0xc10419e0, 0xc10419e0, 0xc10419e0, 0x50df9fd3, 0x50df9fd3, 0x50df9fd3, 0xccaa6a11, 0xccaa6a11, 0xccaa6a11, 0x9813a416, 0xc785d570, 0xc785d570, 0x9813a416, }, 20 }, - { "gfxterm_quot", 800, 600, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 800x600xbgra8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x78d87f9d, 0x345e385f, 0x78d87f9d, 0x4212ae67, 0x5fcf013d, 0x5fcf013d, 0x77ba65ab, 0x77ba65ab, 0x77ba65ab, 0xa5aa7ddd, 0xa5aa7ddd, 0xa5aa7ddd, 0xba81fc20, 0xba81fc20, 0xba81fc20, 0x5fcf013d, 0x4212ae67, 0x4212ae67, 0x5fcf013d, }, 20 }, - { "gfxterm_quot", 1024, 768, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 1024x768xbgra8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x750f8146, 0x2148bdae, 0x750f8146, 0x157c252c, 0xdd28f52b, 0xdd28f52b, 0xbc36f156, 0xbc36f156, 0xbc36f156, 0x9d0a08b2, 0x9d0a08b2, 0x9d0a08b2, 0x877b6b23, 0x877b6b23, 0x877b6b23, 0xdd28f52b, 0x157c252c, 0x157c252c, 0xdd28f52b, }, 20 }, - { "gfxterm_piglatin", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0xaabbbcdc, 0x5f5dabb0, 0xaabbbcdc, 0xe94d719b, 0x59c36f00, 0x59c36f00, 0x18f47430, 0x18f47430, 0x18f47430, 0x66741956, 0x66741956, 0x66741956, 0xa556249b, 0xa556249b, 0xa556249b, 0x59c36f00, 0xe94d719b, 0xe94d719b, 0x59c36f00, }, 20 }, - { "gfxterm_piglatin", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0xb6fa31f0, 0xc274fbe9, 0xb6fa31f0, 0x98ffb48f, 0xaa4593fe, 0xaa4593fe, 0x4fb2120a, 0x4fb2120a, 0x4fb2120a, 0xe9471f6d, 0xe9471f6d, 0xe9471f6d, 0x6be0fd06, 0x6be0fd06, 0x6be0fd06, 0xaa4593fe, 0x98ffb48f, 0x98ffb48f, 0xaa4593fe, }, 20 }, - { "gfxterm_piglatin", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x9c83aa67, 0x67876bdc, 0x9c83aa67, 0xc194c7e3, 0xc9cbf769, 0xc9cbf769, 0xd6fd9f4a, 0xd6fd9f4a, 0xd6fd9f4a, 0x28255e86, 0x28255e86, 0x28255e86, 0xc073f18a, 0xc073f18a, 0xc073f18a, 0xc9cbf769, 0xc194c7e3, 0xc194c7e3, 0xc9cbf769, }, 20 }, - { "gfxterm_piglatin", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x4878468, 0x58d7f660, 0x4878468, 0x549f20c6, 0x9813a416, 0x9813a416, 0x7c4d228e, 0x7c4d228e, 0x7c4d228e, 0xed96a4bd, 0xed96a4bd, 0xed96a4bd, 0x71e3517f, 0x71e3517f, 0x71e3517f, 0x9813a416, 0x549f20c6, 0x549f20c6, 0x9813a416, }, 20 }, - { "gfxterm_piglatin", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0xc24f3617, 0xe92e5f60, 0xc24f3617, 0xf885e7ed, 0x5fcf013d, 0x5fcf013d, 0x9a58adbf, 0x9a58adbf, 0x9a58adbf, 0x4848b5c9, 0x4848b5c9, 0x4848b5c9, 0x57633434, 0x57633434, 0x57633434, 0x5fcf013d, 0xf885e7ed, 0xf885e7ed, 0x5fcf013d, }, 20 }, - { "gfxterm_piglatin", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xe0056f23, 0xe723a6de, 0xe0056f23, 0x8076cb49, 0xdd28f52b, 0xdd28f52b, 0x7cf3620d, 0x7cf3620d, 0x7cf3620d, 0x5dcf9be9, 0x5dcf9be9, 0x5dcf9be9, 0x47bef878, 0x47bef878, 0x47bef878, 0xdd28f52b, 0x8076cb49, 0x8076cb49, 0xdd28f52b, }, 20 }, - { "gfxterm_piglatin", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x74a1734e, 0x3152f141, 0x74a1734e, 0x8ae77e23, 0x43d1f34, 0x43d1f34, 0x83c19830, 0x83c19830, 0x83c19830, 0xfccb3198, 0xfccb3198, 0xfccb3198, 0x14eb08b1, 0x14eb08b1, 0x14eb08b1, 0x43d1f34, 0x8ae77e23, 0x8ae77e23, 0x43d1f34, }, 20 }, - { "gfxterm_piglatin", 640, 480, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi256 */, (grub_uint32_t []) { 0x59c36f00, 0xaabbbcdc, 0x5f5dabb0, 0xaabbbcdc, 0xe94d719b, 0x59c36f00, 0x59c36f00, 0x18f47430, 0x18f47430, 0x18f47430, 0x66741956, 0x66741956, 0x66741956, 0xa556249b, 0xa556249b, 0xa556249b, 0x59c36f00, 0xe94d719b, 0xe94d719b, 0x59c36f00, }, 20 }, - { "gfxterm_piglatin", 800, 600, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi256 */, (grub_uint32_t []) { 0xaa4593fe, 0xb6fa31f0, 0xc274fbe9, 0xb6fa31f0, 0x98ffb48f, 0xaa4593fe, 0xaa4593fe, 0x4fb2120a, 0x4fb2120a, 0x4fb2120a, 0xe9471f6d, 0xe9471f6d, 0xe9471f6d, 0x6be0fd06, 0x6be0fd06, 0x6be0fd06, 0xaa4593fe, 0x98ffb48f, 0x98ffb48f, 0xaa4593fe, }, 20 }, - { "gfxterm_piglatin", 1024, 768, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi256 */, (grub_uint32_t []) { 0xc9cbf769, 0x9c83aa67, 0x67876bdc, 0x9c83aa67, 0xc194c7e3, 0xc9cbf769, 0xc9cbf769, 0xd6fd9f4a, 0xd6fd9f4a, 0xd6fd9f4a, 0x28255e86, 0x28255e86, 0x28255e86, 0xc073f18a, 0xc073f18a, 0xc073f18a, 0xc9cbf769, 0xc194c7e3, 0xc194c7e3, 0xc9cbf769, }, 20 }, - { "gfxterm_piglatin", 640, 480, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 640x480xrgba5550 */, (grub_uint32_t []) { 0x5387d57f, 0xd63f83a3, 0x3dc5a0b4, 0xd63f83a3, 0x9234791f, 0x5387d57f, 0x5387d57f, 0x4cb03e4e, 0x4cb03e4e, 0x4cb03e4e, 0x8ce95282, 0x8ce95282, 0x8ce95282, 0x6b37d014, 0x6b37d014, 0x6b37d014, 0x5387d57f, 0x9234791f, 0x9234791f, 0x5387d57f, }, 20 }, - { "gfxterm_piglatin", 800, 600, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 800x600xrgba5550 */, (grub_uint32_t []) { 0xf83ee7aa, 0x89626ffa, 0xb4d6175c, 0x89626ffa, 0x330a2265, 0xf83ee7aa, 0xf83ee7aa, 0xbbfb89b5, 0xbbfb89b5, 0xbbfb89b5, 0x27825946, 0x27825946, 0x27825946, 0x1f31f2ee, 0x1f31f2ee, 0x1f31f2ee, 0xf83ee7aa, 0x330a2265, 0x330a2265, 0xf83ee7aa, }, 20 }, - { "gfxterm_piglatin", 1024, 768, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 1024x768xrgba5550 */, (grub_uint32_t []) { 0x724366e5, 0x3df87fc2, 0x8c55d02c, 0x3df87fc2, 0x2c8dca97, 0x724366e5, 0x724366e5, 0x3f06ba55, 0x3f06ba55, 0x3f06ba55, 0x783ff8af, 0x783ff8af, 0x783ff8af, 0x1511dfe5, 0x1511dfe5, 0x1511dfe5, 0x724366e5, 0x2c8dca97, 0x2c8dca97, 0x724366e5, }, 20 }, - { "gfxterm_piglatin", 640, 480, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 640x480xrgba5650 */, (grub_uint32_t []) { 0x5387d57f, 0xe39cde76, 0x443930df, 0xe39cde76, 0xc08634f, 0x5387d57f, 0x5387d57f, 0x44754e5f, 0x44754e5f, 0x44754e5f, 0x9abb0182, 0x9abb0182, 0x9abb0182, 0x938939c, 0x938939c, 0x938939c, 0x5387d57f, 0xc08634f, 0xc08634f, 0x5387d57f, }, 20 }, - { "gfxterm_piglatin", 800, 600, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 800x600xrgba5650 */, (grub_uint32_t []) { 0xf83ee7aa, 0xa0b7c23d, 0x8cd3be29, 0xa0b7c23d, 0xd17dfcd1, 0xf83ee7aa, 0xf83ee7aa, 0x5feda75, 0x5feda75, 0x5feda75, 0x7724c945, 0x7724c945, 0x7724c945, 0x46b19883, 0x46b19883, 0x46b19883, 0xf83ee7aa, 0xd17dfcd1, 0xd17dfcd1, 0xf83ee7aa, }, 20 }, - { "gfxterm_piglatin", 1024, 768, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 1024x768xrgba5650 */, (grub_uint32_t []) { 0x724366e5, 0xa994524d, 0xc1900d08, 0xa994524d, 0x5b46d93d, 0x724366e5, 0x724366e5, 0x6d0a4799, 0x6d0a4799, 0x6d0a4799, 0x349ab4c9, 0x349ab4c9, 0x349ab4c9, 0xfc2dda8b, 0xfc2dda8b, 0xfc2dda8b, 0x724366e5, 0x5b46d93d, 0x5b46d93d, 0x724366e5, }, 20 }, - { "gfxterm_piglatin", 640, 480, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 640x480xrgba8880 */, (grub_uint32_t []) { 0x1c955882, 0x41755bc6, 0xf207b232, 0x41755bc6, 0x4115e360, 0x1c955882, 0x1c955882, 0x428d20f6, 0x428d20f6, 0x428d20f6, 0x8d7a6d61, 0x8d7a6d61, 0x8d7a6d61, 0x73136174, 0x73136174, 0x73136174, 0x1c955882, 0x4115e360, 0x4115e360, 0x1c955882, }, 20 }, - { "gfxterm_piglatin", 800, 600, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 800x600xrgba8880 */, (grub_uint32_t []) { 0x4d266f7a, 0xe47ded44, 0x862f2131, 0xe47ded44, 0x206f7440, 0x4d266f7a, 0x4d266f7a, 0x95d7f079, 0x95d7f079, 0x95d7f079, 0x73a0ebc6, 0x73a0ebc6, 0x73a0ebc6, 0xeb99bf56, 0xeb99bf56, 0xeb99bf56, 0x4d266f7a, 0x206f7440, 0x206f7440, 0x4d266f7a, }, 20 }, - { "gfxterm_piglatin", 1024, 768, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 1024x768xrgba8880 */, (grub_uint32_t []) { 0x1ed9d731, 0x946b2f62, 0x30dad54, 0x946b2f62, 0x89f2e85, 0x1ed9d731, 0x1ed9d731, 0xf20ee132, 0xf20ee132, 0xf20ee132, 0x5c6afff7, 0x5c6afff7, 0x5c6afff7, 0x7f03ee41, 0x7f03ee41, 0x7f03ee41, 0x1ed9d731, 0x89f2e85, 0x89f2e85, 0x1ed9d731, }, 20 }, - { "gfxterm_piglatin", 640, 480, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 640x480xbgra5550 */, (grub_uint32_t []) { 0x5387d57f, 0xd63f83a3, 0x3dc5a0b4, 0xd63f83a3, 0x9234791f, 0x5387d57f, 0x5387d57f, 0x4cb03e4e, 0x4cb03e4e, 0x4cb03e4e, 0x8ce95282, 0x8ce95282, 0x8ce95282, 0x6b37d014, 0x6b37d014, 0x6b37d014, 0x5387d57f, 0x9234791f, 0x9234791f, 0x5387d57f, }, 20 }, - { "gfxterm_piglatin", 800, 600, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 800x600xbgra5550 */, (grub_uint32_t []) { 0xf83ee7aa, 0x89626ffa, 0xb4d6175c, 0x89626ffa, 0x330a2265, 0xf83ee7aa, 0xf83ee7aa, 0xbbfb89b5, 0xbbfb89b5, 0xbbfb89b5, 0x27825946, 0x27825946, 0x27825946, 0x1f31f2ee, 0x1f31f2ee, 0x1f31f2ee, 0xf83ee7aa, 0x330a2265, 0x330a2265, 0xf83ee7aa, }, 20 }, - { "gfxterm_piglatin", 1024, 768, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 1024x768xbgra5550 */, (grub_uint32_t []) { 0x724366e5, 0x3df87fc2, 0x8c55d02c, 0x3df87fc2, 0x2c8dca97, 0x724366e5, 0x724366e5, 0x3f06ba55, 0x3f06ba55, 0x3f06ba55, 0x783ff8af, 0x783ff8af, 0x783ff8af, 0x1511dfe5, 0x1511dfe5, 0x1511dfe5, 0x724366e5, 0x2c8dca97, 0x2c8dca97, 0x724366e5, }, 20 }, - { "gfxterm_piglatin", 640, 480, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 640x480xbgra5650 */, (grub_uint32_t []) { 0x5387d57f, 0xe39cde76, 0x443930df, 0xe39cde76, 0xc08634f, 0x5387d57f, 0x5387d57f, 0x44754e5f, 0x44754e5f, 0x44754e5f, 0x9abb0182, 0x9abb0182, 0x9abb0182, 0x938939c, 0x938939c, 0x938939c, 0x5387d57f, 0xc08634f, 0xc08634f, 0x5387d57f, }, 20 }, - { "gfxterm_piglatin", 800, 600, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 800x600xbgra5650 */, (grub_uint32_t []) { 0xf83ee7aa, 0xa0b7c23d, 0x8cd3be29, 0xa0b7c23d, 0xd17dfcd1, 0xf83ee7aa, 0xf83ee7aa, 0x5feda75, 0x5feda75, 0x5feda75, 0x7724c945, 0x7724c945, 0x7724c945, 0x46b19883, 0x46b19883, 0x46b19883, 0xf83ee7aa, 0xd17dfcd1, 0xd17dfcd1, 0xf83ee7aa, }, 20 }, - { "gfxterm_piglatin", 1024, 768, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 1024x768xbgra5650 */, (grub_uint32_t []) { 0x724366e5, 0xa994524d, 0xc1900d08, 0xa994524d, 0x5b46d93d, 0x724366e5, 0x724366e5, 0x6d0a4799, 0x6d0a4799, 0x6d0a4799, 0x349ab4c9, 0x349ab4c9, 0x349ab4c9, 0xfc2dda8b, 0xfc2dda8b, 0xfc2dda8b, 0x724366e5, 0x5b46d93d, 0x5b46d93d, 0x724366e5, }, 20 }, - { "gfxterm_piglatin", 640, 480, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 640x480xbgra8880 */, (grub_uint32_t []) { 0x1c955882, 0x41755bc6, 0xf207b232, 0x41755bc6, 0x4115e360, 0x1c955882, 0x1c955882, 0x428d20f6, 0x428d20f6, 0x428d20f6, 0x8d7a6d61, 0x8d7a6d61, 0x8d7a6d61, 0x73136174, 0x73136174, 0x73136174, 0x1c955882, 0x4115e360, 0x4115e360, 0x1c955882, }, 20 }, - { "gfxterm_piglatin", 800, 600, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 800x600xbgra8880 */, (grub_uint32_t []) { 0x4d266f7a, 0xe47ded44, 0x862f2131, 0xe47ded44, 0x206f7440, 0x4d266f7a, 0x4d266f7a, 0x95d7f079, 0x95d7f079, 0x95d7f079, 0x73a0ebc6, 0x73a0ebc6, 0x73a0ebc6, 0xeb99bf56, 0xeb99bf56, 0xeb99bf56, 0x4d266f7a, 0x206f7440, 0x206f7440, 0x4d266f7a, }, 20 }, - { "gfxterm_piglatin", 1024, 768, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 1024x768xbgra8880 */, (grub_uint32_t []) { 0x1ed9d731, 0x946b2f62, 0x30dad54, 0x946b2f62, 0x89f2e85, 0x1ed9d731, 0x1ed9d731, 0xf20ee132, 0xf20ee132, 0xf20ee132, 0x5c6afff7, 0x5c6afff7, 0x5c6afff7, 0x7f03ee41, 0x7f03ee41, 0x7f03ee41, 0x1ed9d731, 0x89f2e85, 0x89f2e85, 0x1ed9d731, }, 20 }, - { "gfxterm_piglatin", 640, 480, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 640x480xbgra8888 */, (grub_uint32_t []) { 0x9813a416, 0x4878468, 0x58d7f660, 0x4878468, 0x549f20c6, 0x9813a416, 0x9813a416, 0x7c4d228e, 0x7c4d228e, 0x7c4d228e, 0xed96a4bd, 0xed96a4bd, 0xed96a4bd, 0x71e3517f, 0x71e3517f, 0x71e3517f, 0x9813a416, 0x549f20c6, 0x549f20c6, 0x9813a416, }, 20 }, - { "gfxterm_piglatin", 800, 600, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 800x600xbgra8888 */, (grub_uint32_t []) { 0x5fcf013d, 0xc24f3617, 0xe92e5f60, 0xc24f3617, 0xf885e7ed, 0x5fcf013d, 0x5fcf013d, 0x9a58adbf, 0x9a58adbf, 0x9a58adbf, 0x4848b5c9, 0x4848b5c9, 0x4848b5c9, 0x57633434, 0x57633434, 0x57633434, 0x5fcf013d, 0xf885e7ed, 0xf885e7ed, 0x5fcf013d, }, 20 }, - { "gfxterm_piglatin", 1024, 768, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 1024x768xbgra8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xe0056f23, 0xe723a6de, 0xe0056f23, 0x8076cb49, 0xdd28f52b, 0xdd28f52b, 0x7cf3620d, 0x7cf3620d, 0x7cf3620d, 0x5dcf9be9, 0x5dcf9be9, 0x5dcf9be9, 0x47bef878, 0x47bef878, 0x47bef878, 0xdd28f52b, 0x8076cb49, 0x8076cb49, 0xdd28f52b, }, 20 }, - { "gfxterm_ch", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x5ee30ef2, 0xcb34e9e1, 0x5ee30ef2, 0x1d15c3b5, 0x59c36f00, 0x59c36f00, 0x201d9661, 0x201d9661, 0x201d9661, 0x5e9dfb07, 0x5e9dfb07, 0x5e9dfb07, 0x9dbfc6ca, 0x9dbfc6ca, 0x9dbfc6ca, 0x59c36f00, 0x1d15c3b5, 0x1d15c3b5, 0x59c36f00, }, 20 }, - { "gfxterm_ch", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x8f30caea, 0xabe72645, 0x8f30caea, 0xa1354f95, 0xaa4593fe, 0xaa4593fe, 0xe17bf494, 0xe17bf494, 0xe17bf494, 0x478ef9f3, 0x478ef9f3, 0x478ef9f3, 0xc5291b98, 0xc5291b98, 0xc5291b98, 0xaa4593fe, 0xa1354f95, 0xa1354f95, 0xaa4593fe, }, 20 }, - { "gfxterm_ch", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x3a734c3, 0x18bd52c, 0x3a734c3, 0x5eb05947, 0xc9cbf769, 0xc9cbf769, 0x128d62c1, 0x128d62c1, 0x128d62c1, 0xec55a30d, 0xec55a30d, 0xec55a30d, 0x4030c01, 0x4030c01, 0x4030c01, 0xc9cbf769, 0x5eb05947, 0x5eb05947, 0xc9cbf769, }, 20 }, - { "gfxterm_ch", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x34a86f24, 0xfae0384, 0x34a86f24, 0x64b0cb8a, 0x9813a416, 0x9813a416, 0x13b7fe00, 0x13b7fe00, 0x13b7fe00, 0x826c7833, 0x826c7833, 0x826c7833, 0x1e198df1, 0x1e198df1, 0x1e198df1, 0x9813a416, 0x64b0cb8a, 0x64b0cb8a, 0x9813a416, }, 20 }, - { "gfxterm_ch", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x7cf1a92b, 0x413f2fa3, 0x7cf1a92b, 0x463b78d1, 0x5fcf013d, 0x5fcf013d, 0x4f98bcd5, 0x4f98bcd5, 0x4f98bcd5, 0x9d88a4a3, 0x9d88a4a3, 0x9d88a4a3, 0x82a3255e, 0x82a3255e, 0x82a3255e, 0x5fcf013d, 0x463b78d1, 0x463b78d1, 0x5fcf013d, }, 20 }, - { "gfxterm_ch", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x7d24f50c, 0x85834892, 0x7d24f50c, 0x1d575166, 0xdd28f52b, 0xdd28f52b, 0x167fd4de, 0x167fd4de, 0x167fd4de, 0x37432d3a, 0x37432d3a, 0x37432d3a, 0x2d324eab, 0x2d324eab, 0x2d324eab, 0xdd28f52b, 0x1d575166, 0x1d575166, 0xdd28f52b, }, 20 }, - { "gfxterm_ch", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x505523f2, 0x24d00e51, 0x505523f2, 0xae132e9f, 0x43d1f34, 0x43d1f34, 0xcaaadc5e, 0xcaaadc5e, 0xcaaadc5e, 0xb5a075f6, 0xb5a075f6, 0xb5a075f6, 0x5d804cdf, 0x5d804cdf, 0x5d804cdf, 0x43d1f34, 0xae132e9f, 0xae132e9f, 0x43d1f34, }, 20 }, - { "gfxterm_ch", 640, 480, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi256 */, (grub_uint32_t []) { 0x59c36f00, 0x5ee30ef2, 0xcb34e9e1, 0x5ee30ef2, 0x1d15c3b5, 0x59c36f00, 0x59c36f00, 0x201d9661, 0x201d9661, 0x201d9661, 0x5e9dfb07, 0x5e9dfb07, 0x5e9dfb07, 0x9dbfc6ca, 0x9dbfc6ca, 0x9dbfc6ca, 0x59c36f00, 0x1d15c3b5, 0x1d15c3b5, 0x59c36f00, }, 20 }, - { "gfxterm_ch", 800, 600, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi256 */, (grub_uint32_t []) { 0xaa4593fe, 0x8f30caea, 0xabe72645, 0x8f30caea, 0xa1354f95, 0xaa4593fe, 0xaa4593fe, 0xe17bf494, 0xe17bf494, 0xe17bf494, 0x478ef9f3, 0x478ef9f3, 0x478ef9f3, 0xc5291b98, 0xc5291b98, 0xc5291b98, 0xaa4593fe, 0xa1354f95, 0xa1354f95, 0xaa4593fe, }, 20 }, - { "gfxterm_ch", 1024, 768, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi256 */, (grub_uint32_t []) { 0xc9cbf769, 0x3a734c3, 0x18bd52c, 0x3a734c3, 0x5eb05947, 0xc9cbf769, 0xc9cbf769, 0x128d62c1, 0x128d62c1, 0x128d62c1, 0xec55a30d, 0xec55a30d, 0xec55a30d, 0x4030c01, 0x4030c01, 0x4030c01, 0xc9cbf769, 0x5eb05947, 0x5eb05947, 0xc9cbf769, }, 20 }, - { "gfxterm_ch", 640, 480, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 640x480xrgba5550 */, (grub_uint32_t []) { 0x5387d57f, 0xeba6cfbb, 0xcfb5c41c, 0xeba6cfbb, 0xafad3507, 0x5387d57f, 0x5387d57f, 0x71f3f018, 0x71f3f018, 0x71f3f018, 0xb1aa9cd4, 0xb1aa9cd4, 0xb1aa9cd4, 0x56741e42, 0x56741e42, 0x56741e42, 0x5387d57f, 0xafad3507, 0xafad3507, 0x5387d57f, }, 20 }, - { "gfxterm_ch", 800, 600, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 800x600xrgba5550 */, (grub_uint32_t []) { 0xf83ee7aa, 0x9003ad29, 0xb92d2c38, 0x9003ad29, 0x2a6be0b6, 0xf83ee7aa, 0xf83ee7aa, 0x49d26800, 0x49d26800, 0x49d26800, 0xd5abb8f3, 0xd5abb8f3, 0xd5abb8f3, 0xed18135b, 0xed18135b, 0xed18135b, 0xf83ee7aa, 0x2a6be0b6, 0x2a6be0b6, 0xf83ee7aa, }, 20 }, - { "gfxterm_ch", 1024, 768, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 1024x768xrgba5550 */, (grub_uint32_t []) { 0x724366e5, 0x238c7b12, 0x2eefc892, 0x238c7b12, 0x32f9ce47, 0x724366e5, 0x724366e5, 0x3d1942f9, 0x3d1942f9, 0x3d1942f9, 0x7a200003, 0x7a200003, 0x7a200003, 0x170e2749, 0x170e2749, 0x170e2749, 0x724366e5, 0x32f9ce47, 0x32f9ce47, 0x724366e5, }, 20 }, - { "gfxterm_ch", 640, 480, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 640x480xrgba5650 */, (grub_uint32_t []) { 0x5387d57f, 0x9e1c123, 0xa92b0ab6, 0x9e1c123, 0xe6757c1a, 0x5387d57f, 0x5387d57f, 0xa443a74a, 0xa443a74a, 0xa443a74a, 0x7a8de897, 0x7a8de897, 0x7a8de897, 0xe90e7a89, 0xe90e7a89, 0xe90e7a89, 0x5387d57f, 0xe6757c1a, 0xe6757c1a, 0x5387d57f, }, 20 }, - { "gfxterm_ch", 800, 600, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 800x600xrgba5650 */, (grub_uint32_t []) { 0xf83ee7aa, 0xabb151dd, 0xfa21aa13, 0xabb151dd, 0xda7b6f31, 0xf83ee7aa, 0xf83ee7aa, 0x9d6ae4fd, 0x9d6ae4fd, 0x9d6ae4fd, 0xefb0f7cd, 0xefb0f7cd, 0xefb0f7cd, 0xde25a60b, 0xde25a60b, 0xde25a60b, 0xf83ee7aa, 0xda7b6f31, 0xda7b6f31, 0xf83ee7aa, }, 20 }, - { "gfxterm_ch", 1024, 768, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 1024x768xrgba5650 */, (grub_uint32_t []) { 0x724366e5, 0x6dd9406d, 0xde872977, 0x6dd9406d, 0x9f0bcb1d, 0x724366e5, 0x724366e5, 0x8b3051ad, 0x8b3051ad, 0x8b3051ad, 0xd2a0a2fd, 0xd2a0a2fd, 0xd2a0a2fd, 0x1a17ccbf, 0x1a17ccbf, 0x1a17ccbf, 0x724366e5, 0x9f0bcb1d, 0x9f0bcb1d, 0x724366e5, }, 20 }, - { "gfxterm_ch", 640, 480, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 640x480xrgba8880 */, (grub_uint32_t []) { 0x1c955882, 0x397d3da2, 0xeb896cf, 0x397d3da2, 0x391d8504, 0x1c955882, 0x1c955882, 0x16aa0778, 0x16aa0778, 0x16aa0778, 0xd95d4aef, 0xd95d4aef, 0xd95d4aef, 0x273446fa, 0x273446fa, 0x273446fa, 0x1c955882, 0x391d8504, 0x391d8504, 0x1c955882, }, 20 }, - { "gfxterm_ch", 800, 600, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 800x600xrgba8880 */, (grub_uint32_t []) { 0x4d266f7a, 0xb4b2e2fa, 0x74314de8, 0xb4b2e2fa, 0x70a07bfe, 0x4d266f7a, 0x4d266f7a, 0xe69c42f4, 0xe69c42f4, 0xe69c42f4, 0xeb594b, 0xeb594b, 0xeb594b, 0x98d20ddb, 0x98d20ddb, 0x98d20ddb, 0x4d266f7a, 0x70a07bfe, 0x70a07bfe, 0x4d266f7a, }, 20 }, - { "gfxterm_ch", 1024, 768, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 1024x768xrgba8880 */, (grub_uint32_t []) { 0x1ed9d731, 0xd2db665c, 0xcb12d20c, 0xd2db665c, 0x4e2f67bb, 0x1ed9d731, 0x1ed9d731, 0x1952ab15, 0x1952ab15, 0x1952ab15, 0xb736b5d0, 0xb736b5d0, 0xb736b5d0, 0x945fa466, 0x945fa466, 0x945fa466, 0x1ed9d731, 0x4e2f67bb, 0x4e2f67bb, 0x1ed9d731, }, 20 }, - { "gfxterm_ch", 640, 480, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 640x480xbgra5550 */, (grub_uint32_t []) { 0x5387d57f, 0xeba6cfbb, 0xcfb5c41c, 0xeba6cfbb, 0xafad3507, 0x5387d57f, 0x5387d57f, 0x71f3f018, 0x71f3f018, 0x71f3f018, 0xb1aa9cd4, 0xb1aa9cd4, 0xb1aa9cd4, 0x56741e42, 0x56741e42, 0x56741e42, 0x5387d57f, 0xafad3507, 0xafad3507, 0x5387d57f, }, 20 }, - { "gfxterm_ch", 800, 600, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 800x600xbgra5550 */, (grub_uint32_t []) { 0xf83ee7aa, 0x9003ad29, 0xb92d2c38, 0x9003ad29, 0x2a6be0b6, 0xf83ee7aa, 0xf83ee7aa, 0x49d26800, 0x49d26800, 0x49d26800, 0xd5abb8f3, 0xd5abb8f3, 0xd5abb8f3, 0xed18135b, 0xed18135b, 0xed18135b, 0xf83ee7aa, 0x2a6be0b6, 0x2a6be0b6, 0xf83ee7aa, }, 20 }, - { "gfxterm_ch", 1024, 768, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 1024x768xbgra5550 */, (grub_uint32_t []) { 0x724366e5, 0x238c7b12, 0x2eefc892, 0x238c7b12, 0x32f9ce47, 0x724366e5, 0x724366e5, 0x3d1942f9, 0x3d1942f9, 0x3d1942f9, 0x7a200003, 0x7a200003, 0x7a200003, 0x170e2749, 0x170e2749, 0x170e2749, 0x724366e5, 0x32f9ce47, 0x32f9ce47, 0x724366e5, }, 20 }, - { "gfxterm_ch", 640, 480, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 640x480xbgra5650 */, (grub_uint32_t []) { 0x5387d57f, 0x9e1c123, 0xa92b0ab6, 0x9e1c123, 0xe6757c1a, 0x5387d57f, 0x5387d57f, 0xa443a74a, 0xa443a74a, 0xa443a74a, 0x7a8de897, 0x7a8de897, 0x7a8de897, 0xe90e7a89, 0xe90e7a89, 0xe90e7a89, 0x5387d57f, 0xe6757c1a, 0xe6757c1a, 0x5387d57f, }, 20 }, - { "gfxterm_ch", 800, 600, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 800x600xbgra5650 */, (grub_uint32_t []) { 0xf83ee7aa, 0xabb151dd, 0xfa21aa13, 0xabb151dd, 0xda7b6f31, 0xf83ee7aa, 0xf83ee7aa, 0x9d6ae4fd, 0x9d6ae4fd, 0x9d6ae4fd, 0xefb0f7cd, 0xefb0f7cd, 0xefb0f7cd, 0xde25a60b, 0xde25a60b, 0xde25a60b, 0xf83ee7aa, 0xda7b6f31, 0xda7b6f31, 0xf83ee7aa, }, 20 }, - { "gfxterm_ch", 1024, 768, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 1024x768xbgra5650 */, (grub_uint32_t []) { 0x724366e5, 0x6dd9406d, 0xde872977, 0x6dd9406d, 0x9f0bcb1d, 0x724366e5, 0x724366e5, 0x8b3051ad, 0x8b3051ad, 0x8b3051ad, 0xd2a0a2fd, 0xd2a0a2fd, 0xd2a0a2fd, 0x1a17ccbf, 0x1a17ccbf, 0x1a17ccbf, 0x724366e5, 0x9f0bcb1d, 0x9f0bcb1d, 0x724366e5, }, 20 }, - { "gfxterm_ch", 640, 480, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 640x480xbgra8880 */, (grub_uint32_t []) { 0x1c955882, 0x397d3da2, 0xeb896cf, 0x397d3da2, 0x391d8504, 0x1c955882, 0x1c955882, 0x16aa0778, 0x16aa0778, 0x16aa0778, 0xd95d4aef, 0xd95d4aef, 0xd95d4aef, 0x273446fa, 0x273446fa, 0x273446fa, 0x1c955882, 0x391d8504, 0x391d8504, 0x1c955882, }, 20 }, - { "gfxterm_ch", 800, 600, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 800x600xbgra8880 */, (grub_uint32_t []) { 0x4d266f7a, 0xb4b2e2fa, 0x74314de8, 0xb4b2e2fa, 0x70a07bfe, 0x4d266f7a, 0x4d266f7a, 0xe69c42f4, 0xe69c42f4, 0xe69c42f4, 0xeb594b, 0xeb594b, 0xeb594b, 0x98d20ddb, 0x98d20ddb, 0x98d20ddb, 0x4d266f7a, 0x70a07bfe, 0x70a07bfe, 0x4d266f7a, }, 20 }, - { "gfxterm_ch", 1024, 768, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 1024x768xbgra8880 */, (grub_uint32_t []) { 0x1ed9d731, 0xd2db665c, 0xcb12d20c, 0xd2db665c, 0x4e2f67bb, 0x1ed9d731, 0x1ed9d731, 0x1952ab15, 0x1952ab15, 0x1952ab15, 0xb736b5d0, 0xb736b5d0, 0xb736b5d0, 0x945fa466, 0x945fa466, 0x945fa466, 0x1ed9d731, 0x4e2f67bb, 0x4e2f67bb, 0x1ed9d731, }, 20 }, - { "gfxterm_ch", 640, 480, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 640x480xbgra8888 */, (grub_uint32_t []) { 0x9813a416, 0x34a86f24, 0xfae0384, 0x34a86f24, 0x64b0cb8a, 0x9813a416, 0x9813a416, 0x13b7fe00, 0x13b7fe00, 0x13b7fe00, 0x826c7833, 0x826c7833, 0x826c7833, 0x1e198df1, 0x1e198df1, 0x1e198df1, 0x9813a416, 0x64b0cb8a, 0x64b0cb8a, 0x9813a416, }, 20 }, - { "gfxterm_ch", 800, 600, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 800x600xbgra8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x7cf1a92b, 0x413f2fa3, 0x7cf1a92b, 0x463b78d1, 0x5fcf013d, 0x5fcf013d, 0x4f98bcd5, 0x4f98bcd5, 0x4f98bcd5, 0x9d88a4a3, 0x9d88a4a3, 0x9d88a4a3, 0x82a3255e, 0x82a3255e, 0x82a3255e, 0x5fcf013d, 0x463b78d1, 0x463b78d1, 0x5fcf013d, }, 20 }, - { "gfxterm_ch", 1024, 768, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 1024x768xbgra8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x7d24f50c, 0x85834892, 0x7d24f50c, 0x1d575166, 0xdd28f52b, 0xdd28f52b, 0x167fd4de, 0x167fd4de, 0x167fd4de, 0x37432d3a, 0x37432d3a, 0x37432d3a, 0x2d324eab, 0x2d324eab, 0x2d324eab, 0xdd28f52b, 0x1d575166, 0x1d575166, 0xdd28f52b, }, 20 }, - { "gfxterm_red", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0xa64abc46, 0x75b6655, 0xa64abc46, 0x8ab5be58, 0x59c36f00, 0x59c36f00, 0xa119c4f4, 0xa119c4f4, 0xa119c4f4, 0xdf99a992, 0xdf99a992, 0xdf99a992, 0x1cbb945f, 0x1cbb945f, 0x1cbb945f, 0x59c36f00, 0x8ab5be58, 0x8ab5be58, 0x59c36f00, }, 20 }, - { "gfxterm_red", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x58be41e7, 0xae0d3f09, 0x58be41e7, 0xda7a6cbf, 0xaa4593fe, 0xaa4593fe, 0x794b67, 0x794b67, 0x794b67, 0xa68c4600, 0xa68c4600, 0xa68c4600, 0x242ba46b, 0x242ba46b, 0x242ba46b, 0xaa4593fe, 0xda7a6cbf, 0xda7a6cbf, 0xaa4593fe, }, 20 }, - { "gfxterm_red", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xaaa4d3ad, 0xe61c6d02, 0xaaa4d3ad, 0xff557024, 0xc9cbf769, 0xc9cbf769, 0x780542e8, 0x780542e8, 0x780542e8, 0x86dd8324, 0x86dd8324, 0x86dd8324, 0x6e8b2c28, 0x6e8b2c28, 0x6e8b2c28, 0xc9cbf769, 0xff557024, 0xff557024, 0xc9cbf769, }, 20 }, - { "gfxterm_red", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0xf168f0ba, 0x151608f2, 0xf168f0ba, 0x1f8e266b, 0x9813a416, 0x9813a416, 0x358d1fb0, 0x358d1fb0, 0x358d1fb0, 0xa4569983, 0xa4569983, 0xa4569983, 0x38236c41, 0x38236c41, 0x38236c41, 0x9813a416, 0x1f8e266b, 0x1f8e266b, 0x9813a416, }, 20 }, - { "gfxterm_red", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x927c4cf9, 0xdefa0b3b, 0x927c4cf9, 0x64636a93, 0x5fcf013d, 0x5fcf013d, 0xae2ee3eb, 0xae2ee3eb, 0xae2ee3eb, 0x7c3efb9d, 0x7c3efb9d, 0x7c3efb9d, 0x63157a60, 0x63157a60, 0x63157a60, 0x5fcf013d, 0x64636a93, 0x64636a93, 0x5fcf013d, }, 20 }, - { "gfxterm_red", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x2d254926, 0x796275ce, 0x2d254926, 0x17c0c9cb, 0xdd28f52b, 0xdd28f52b, 0x79439443, 0x79439443, 0x79439443, 0x587f6da7, 0x587f6da7, 0x587f6da7, 0x420e0e36, 0x420e0e36, 0x420e0e36, 0xdd28f52b, 0x17c0c9cb, 0x17c0c9cb, 0xdd28f52b, }, 20 }, - { "gfxterm_red", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x755377f, 0x4e06e91f, 0x755377f, 0xe42f3a5, 0x43d1f34, 0x43d1f34, 0x3ac2d7b5, 0x3ac2d7b5, 0x3ac2d7b5, 0x45c87e1d, 0x45c87e1d, 0x45c87e1d, 0xade84734, 0xade84734, 0xade84734, 0x43d1f34, 0xe42f3a5, 0xe42f3a5, 0x43d1f34, }, 20 }, - { "gfxterm_red", 640, 480, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi256 */, (grub_uint32_t []) { 0x59c36f00, 0xa64abc46, 0x75b6655, 0xa64abc46, 0x8ab5be58, 0x59c36f00, 0x59c36f00, 0xa119c4f4, 0xa119c4f4, 0xa119c4f4, 0xdf99a992, 0xdf99a992, 0xdf99a992, 0x1cbb945f, 0x1cbb945f, 0x1cbb945f, 0x59c36f00, 0x8ab5be58, 0x8ab5be58, 0x59c36f00, }, 20 }, - { "gfxterm_red", 800, 600, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi256 */, (grub_uint32_t []) { 0xaa4593fe, 0x58be41e7, 0xae0d3f09, 0x58be41e7, 0xda7a6cbf, 0xaa4593fe, 0xaa4593fe, 0x794b67, 0x794b67, 0x794b67, 0xa68c4600, 0xa68c4600, 0xa68c4600, 0x242ba46b, 0x242ba46b, 0x242ba46b, 0xaa4593fe, 0xda7a6cbf, 0xda7a6cbf, 0xaa4593fe, }, 20 }, - { "gfxterm_red", 1024, 768, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi256 */, (grub_uint32_t []) { 0xc9cbf769, 0xaaa4d3ad, 0xe61c6d02, 0xaaa4d3ad, 0xff557024, 0xc9cbf769, 0xc9cbf769, 0x780542e8, 0x780542e8, 0x780542e8, 0x86dd8324, 0x86dd8324, 0x86dd8324, 0x6e8b2c28, 0x6e8b2c28, 0x6e8b2c28, 0xc9cbf769, 0xff557024, 0xff557024, 0xc9cbf769, }, 20 }, - { "gfxterm_red", 640, 480, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 640x480xrgba5550 */, (grub_uint32_t []) { 0x5387d57f, 0xcffd463e, 0x59775566, 0xcffd463e, 0xb4e87140, 0x5387d57f, 0x5387d57f, 0xc2a27e06, 0xc2a27e06, 0xc2a27e06, 0x2fb12ca, 0x2fb12ca, 0x2fb12ca, 0xe525905c, 0xe525905c, 0xe525905c, 0x5387d57f, 0xb4e87140, 0xb4e87140, 0x5387d57f, }, 20 }, - { "gfxterm_red", 800, 600, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 800x600xrgba5550 */, (grub_uint32_t []) { 0xf83ee7aa, 0x91d12daf, 0xdceabc0e, 0x91d12daf, 0xf372b81f, 0xf83ee7aa, 0xf83ee7aa, 0x85a69692, 0x85a69692, 0x85a69692, 0x19df4661, 0x19df4661, 0x19df4661, 0x216cedc9, 0x216cedc9, 0x216cedc9, 0xf83ee7aa, 0xf372b81f, 0xf372b81f, 0xf83ee7aa, }, 20 }, - { "gfxterm_red", 1024, 768, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 1024x768xrgba5550 */, (grub_uint32_t []) { 0x724366e5, 0x5f5953b3, 0x1f88963e, 0x5f5953b3, 0x6aeb9112, 0x724366e5, 0x724366e5, 0xc5da2432, 0xc5da2432, 0xc5da2432, 0x82e366c8, 0x82e366c8, 0x82e366c8, 0xefcd4182, 0xefcd4182, 0xefcd4182, 0x724366e5, 0x6aeb9112, 0x6aeb9112, 0x724366e5, }, 20 }, - { "gfxterm_red", 640, 480, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 640x480xrgba5650 */, (grub_uint32_t []) { 0x5387d57f, 0x1227533e, 0xee3616e0, 0x1227533e, 0xc32db32e, 0x5387d57f, 0x5387d57f, 0xa347c834, 0xa347c834, 0xa347c834, 0x7d8987e9, 0x7d8987e9, 0x7d8987e9, 0xee0a15f7, 0xee0a15f7, 0xee0a15f7, 0x5387d57f, 0xc32db32e, 0xc32db32e, 0x5387d57f, }, 20 }, - { "gfxterm_red", 800, 600, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 800x600xrgba5650 */, (grub_uint32_t []) { 0xf83ee7aa, 0xc548a908, 0x2624be34, 0xc548a908, 0x1745599, 0xf83ee7aa, 0xf83ee7aa, 0xaaaf7e14, 0xaaaf7e14, 0xaaaf7e14, 0xd8756d24, 0xd8756d24, 0xd8756d24, 0xe9e03ce2, 0xe9e03ce2, 0xe9e03ce2, 0xf83ee7aa, 0x1745599, 0x1745599, 0xf83ee7aa, }, 20 }, - { "gfxterm_red", 1024, 768, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 1024x768xrgba5650 */, (grub_uint32_t []) { 0x724366e5, 0x30506e44, 0x76cf9d03, 0x30506e44, 0x33485d71, 0x724366e5, 0x724366e5, 0xd12bc953, 0xd12bc953, 0xd12bc953, 0x88bb3a03, 0x88bb3a03, 0x88bb3a03, 0x400c5441, 0x400c5441, 0x400c5441, 0x724366e5, 0x33485d71, 0x33485d71, 0x724366e5, }, 20 }, - { "gfxterm_red", 640, 480, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 640x480xrgba8880 */, (grub_uint32_t []) { 0x1c955882, 0xa3238023, 0xa5b82f9e, 0xa3238023, 0x93f8a252, 0x1c955882, 0x1c955882, 0x205b041f, 0x205b041f, 0x205b041f, 0xefac4988, 0xefac4988, 0xefac4988, 0x11c5459d, 0x11c5459d, 0x11c5459d, 0x1c955882, 0x93f8a252, 0x93f8a252, 0x1c955882, }, 20 }, - { "gfxterm_red", 800, 600, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 800x600xrgba8880 */, (grub_uint32_t []) { 0x4d266f7a, 0xf651c995, 0x7e1ae3d7, 0xf651c995, 0xdab860af, 0x4d266f7a, 0x4d266f7a, 0x6272be10, 0x6272be10, 0x6272be10, 0x8405a5af, 0x8405a5af, 0x8405a5af, 0x1c3cf13f, 0x1c3cf13f, 0x1c3cf13f, 0x4d266f7a, 0xdab860af, 0xdab860af, 0x4d266f7a, }, 20 }, - { "gfxterm_red", 1024, 768, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 1024x768xrgba8880 */, (grub_uint32_t []) { 0x1ed9d731, 0x2fa6119, 0x30618885, 0x2fa6119, 0xbfbe1b6a, 0x1ed9d731, 0x1ed9d731, 0x11353cf5, 0x11353cf5, 0x11353cf5, 0xbf512230, 0xbf512230, 0xbf512230, 0x9c383386, 0x9c383386, 0x9c383386, 0x1ed9d731, 0xbfbe1b6a, 0xbfbe1b6a, 0x1ed9d731, }, 20 }, - { "gfxterm_red", 640, 480, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 640x480xbgra5550 */, (grub_uint32_t []) { 0x5387d57f, 0x4caf1997, 0xda250acf, 0x4caf1997, 0x2183903f, 0x5387d57f, 0x5387d57f, 0x6be656ff, 0x6be656ff, 0x6be656ff, 0xabbf3a33, 0xabbf3a33, 0xabbf3a33, 0x4c61b8a5, 0x4c61b8a5, 0x4c61b8a5, 0x5387d57f, 0x2183903f, 0x2183903f, 0x5387d57f, }, 20 }, - { "gfxterm_red", 800, 600, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 800x600xbgra5550 */, (grub_uint32_t []) { 0xf83ee7aa, 0x7b29cc8e, 0x36125d2f, 0x7b29cc8e, 0x1277092, 0xf83ee7aa, 0xf83ee7aa, 0x4830d5b5, 0x4830d5b5, 0x4830d5b5, 0xd4490546, 0xd4490546, 0xd4490546, 0xecfaaeee, 0xecfaaeee, 0xecfaaeee, 0xf83ee7aa, 0x1277092, 0x1277092, 0xf83ee7aa, }, 20 }, - { "gfxterm_red", 1024, 768, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 1024x768xbgra5550 */, (grub_uint32_t []) { 0x724366e5, 0x2e644de2, 0x6eb5886f, 0x2e644de2, 0x3d66c6af, 0x724366e5, 0x724366e5, 0x5d800f18, 0x5d800f18, 0x5d800f18, 0x1ab94de2, 0x1ab94de2, 0x1ab94de2, 0x77976aa8, 0x77976aa8, 0x77976aa8, 0x724366e5, 0x3d66c6af, 0x3d66c6af, 0x724366e5, }, 20 }, - { "gfxterm_red", 640, 480, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 640x480xbgra5650 */, (grub_uint32_t []) { 0x5387d57f, 0x5f11f8eb, 0xa300bd35, 0x5f11f8eb, 0xe2cba3fa, 0x5387d57f, 0x5387d57f, 0xfa2cee75, 0xfa2cee75, 0xfa2cee75, 0x24e2a1a8, 0x24e2a1a8, 0x24e2a1a8, 0xb76133b6, 0xb76133b6, 0xb76133b6, 0x5387d57f, 0xe2cba3fa, 0xe2cba3fa, 0x5387d57f, }, 20 }, - { "gfxterm_red", 800, 600, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 800x600xbgra5650 */, (grub_uint32_t []) { 0xf83ee7aa, 0x179340b2, 0xf4ff578e, 0x179340b2, 0xe378eba9, 0xf83ee7aa, 0xf83ee7aa, 0xf787fcc2, 0xf787fcc2, 0xf787fcc2, 0x855deff2, 0x855deff2, 0x855deff2, 0xb4c8be34, 0xb4c8be34, 0xb4c8be34, 0xf83ee7aa, 0xe378eba9, 0xe378eba9, 0xf83ee7aa, }, 20 }, - { "gfxterm_red", 1024, 768, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 1024x768xbgra5650 */, (grub_uint32_t []) { 0x724366e5, 0x5703fa5a, 0x119c091d, 0x5703fa5a, 0xa13f0d1a, 0x724366e5, 0x724366e5, 0xd989a04d, 0xd989a04d, 0xd989a04d, 0x8019531d, 0x8019531d, 0x8019531d, 0x48ae3d5f, 0x48ae3d5f, 0x48ae3d5f, 0x724366e5, 0xa13f0d1a, 0xa13f0d1a, 0x724366e5, }, 20 }, - { "gfxterm_red", 640, 480, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 640x480xbgra8880 */, (grub_uint32_t []) { 0x1c955882, 0xf38c2b36, 0xf517848b, 0xf38c2b36, 0xa2621779, 0x1c955882, 0x1c955882, 0x153777fa, 0x153777fa, 0x153777fa, 0xdac03a6d, 0xdac03a6d, 0xdac03a6d, 0x24a93678, 0x24a93678, 0x24a93678, 0x1c955882, 0xa2621779, 0xa2621779, 0x1c955882, }, 20 }, - { "gfxterm_red", 800, 600, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 800x600xbgra8880 */, (grub_uint32_t []) { 0x4d266f7a, 0xb8253868, 0x306e122a, 0xb8253868, 0x83b58e9b, 0x4d266f7a, 0x4d266f7a, 0x98183444, 0x98183444, 0x98183444, 0x7e6f2ffb, 0x7e6f2ffb, 0x7e6f2ffb, 0xe6567b6b, 0xe6567b6b, 0xe6567b6b, 0x4d266f7a, 0x83b58e9b, 0x83b58e9b, 0x4d266f7a, }, 20 }, - { "gfxterm_red", 1024, 768, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 1024x768xbgra8880 */, (grub_uint32_t []) { 0x1ed9d731, 0x40c62f40, 0x725dc6dc, 0x40c62f40, 0x50dfba34, 0x1ed9d731, 0x1ed9d731, 0x32e89a68, 0x32e89a68, 0x32e89a68, 0x9c8c84ad, 0x9c8c84ad, 0x9c8c84ad, 0xbfe5951b, 0xbfe5951b, 0xbfe5951b, 0x1ed9d731, 0x50dfba34, 0x50dfba34, 0x1ed9d731, }, 20 }, - { "gfxterm_red", 640, 480, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 640x480xbgra8888 */, (grub_uint32_t []) { 0x9813a416, 0xfaeb56f1, 0x1e95aeb9, 0xfaeb56f1, 0xe4ddf18b, 0x9813a416, 0x9813a416, 0x5da5926f, 0x5da5926f, 0x5da5926f, 0xcc7e145c, 0xcc7e145c, 0xcc7e145c, 0x500be19e, 0x500be19e, 0x500be19e, 0x9813a416, 0xe4ddf18b, 0xe4ddf18b, 0x9813a416, }, 20 }, - { "gfxterm_red", 800, 600, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 800x600xbgra8888 */, (grub_uint32_t []) { 0x5fcf013d, 0xa11f0307, 0xed9944c5, 0xa11f0307, 0x93a8828e, 0x5fcf013d, 0x5fcf013d, 0xeabf61dc, 0xeabf61dc, 0xeabf61dc, 0x38af79aa, 0x38af79aa, 0x38af79aa, 0x2784f857, 0x2784f857, 0x2784f857, 0x5fcf013d, 0x93a8828e, 0x93a8828e, 0x5fcf013d, }, 20 }, - { "gfxterm_red", 1024, 768, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 1024x768xbgra8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xeedd0ec5, 0xba9a322d, 0xeedd0ec5, 0x32205338, 0xdd28f52b, 0xdd28f52b, 0x14854a2b, 0x14854a2b, 0x14854a2b, 0x35b9b3cf, 0x35b9b3cf, 0x35b9b3cf, 0x2fc8d05e, 0x2fc8d05e, 0x2fc8d05e, 0xdd28f52b, 0x32205338, 0x32205338, 0xdd28f52b, }, 20 }, - { "gfxterm_high", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0xe7baf88f, 0x46ab229c, 0xe7baf88f, 0x2422eb85, 0x59c36f00, 0x59c36f00, 0xc8b88a82, 0xc8b88a82, 0xc8b88a82, 0xb638e7e4, 0xb638e7e4, 0xb638e7e4, 0x751ada29, 0x751ada29, 0x751ada29, 0x59c36f00, 0x2422eb85, 0x2422eb85, 0x59c36f00, }, 20 }, - { "gfxterm_high", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x86184b5, 0xfed2fa5b, 0x86184b5, 0xf984bb34, 0xaa4593fe, 0xaa4593fe, 0x8b63f19d, 0x8b63f19d, 0x8b63f19d, 0x2d96fcfa, 0x2d96fcfa, 0x2d96fcfa, 0xaf311e91, 0xaf311e91, 0xaf311e91, 0xaa4593fe, 0xf984bb34, 0xf984bb34, 0xaa4593fe, }, 20 }, - { "gfxterm_high", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x2dda8793, 0x6162393c, 0x2dda8793, 0x2a6bc689, 0xc9cbf769, 0xc9cbf769, 0xec23555f, 0xec23555f, 0xec23555f, 0x12fb9493, 0x12fb9493, 0x12fb9493, 0xfaad3b9f, 0xfaad3b9f, 0xfaad3b9f, 0xc9cbf769, 0x2a6bc689, 0x2a6bc689, 0xc9cbf769, }, 20 }, - { "gfxterm_high", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0xf2b1715, 0xeb55ef5d, 0xf2b1715, 0x61e172d4, 0x9813a416, 0x9813a416, 0xc10419e0, 0xc10419e0, 0xc10419e0, 0x50df9fd3, 0x50df9fd3, 0x50df9fd3, 0xccaa6a11, 0xccaa6a11, 0xccaa6a11, 0x9813a416, 0x61e172d4, 0x61e172d4, 0x9813a416, }, 20 }, - { "gfxterm_high", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x2a517b4, 0x4e235076, 0x2a517b4, 0x85b73555, 0x5fcf013d, 0x5fcf013d, 0x77ba65ab, 0x77ba65ab, 0x77ba65ab, 0xa5aa7ddd, 0xa5aa7ddd, 0xa5aa7ddd, 0xba81fc20, 0xba81fc20, 0xba81fc20, 0x5fcf013d, 0x85b73555, 0x85b73555, 0x5fcf013d, }, 20 }, - { "gfxterm_high", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x53e34b0f, 0x7a477e7, 0x53e34b0f, 0x7b92ba0b, 0xdd28f52b, 0xdd28f52b, 0xbc36f156, 0xbc36f156, 0xbc36f156, 0x9d0a08b2, 0x9d0a08b2, 0x9d0a08b2, 0x877b6b23, 0x877b6b23, 0x877b6b23, 0xdd28f52b, 0x7b92ba0b, 0x7b92ba0b, 0xdd28f52b, }, 20 }, - { "gfxterm_high", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0xcccbb8c0, 0x859866a0, 0xcccbb8c0, 0x2bf5b2f8, 0x43d1f34, 0x43d1f34, 0xd204ac75, 0xd204ac75, 0xd204ac75, 0xad0e05dd, 0xad0e05dd, 0xad0e05dd, 0x452e3cf4, 0x452e3cf4, 0x452e3cf4, 0x43d1f34, 0x2bf5b2f8, 0x2bf5b2f8, 0x43d1f34, }, 20 }, - { "gfxterm_high", 640, 480, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi256 */, (grub_uint32_t []) { 0x59c36f00, 0xe7baf88f, 0x46ab229c, 0xe7baf88f, 0x2422eb85, 0x59c36f00, 0x59c36f00, 0xc8b88a82, 0xc8b88a82, 0xc8b88a82, 0xb638e7e4, 0xb638e7e4, 0xb638e7e4, 0x751ada29, 0x751ada29, 0x751ada29, 0x59c36f00, 0x2422eb85, 0x2422eb85, 0x59c36f00, }, 20 }, - { "gfxterm_high", 800, 600, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi256 */, (grub_uint32_t []) { 0xaa4593fe, 0x86184b5, 0xfed2fa5b, 0x86184b5, 0xf984bb34, 0xaa4593fe, 0xaa4593fe, 0x8b63f19d, 0x8b63f19d, 0x8b63f19d, 0x2d96fcfa, 0x2d96fcfa, 0x2d96fcfa, 0xaf311e91, 0xaf311e91, 0xaf311e91, 0xaa4593fe, 0xf984bb34, 0xf984bb34, 0xaa4593fe, }, 20 }, - { "gfxterm_high", 1024, 768, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi256 */, (grub_uint32_t []) { 0xc9cbf769, 0x2dda8793, 0x6162393c, 0x2dda8793, 0x2a6bc689, 0xc9cbf769, 0xc9cbf769, 0xec23555f, 0xec23555f, 0xec23555f, 0x12fb9493, 0x12fb9493, 0x12fb9493, 0xfaad3b9f, 0xfaad3b9f, 0xfaad3b9f, 0xc9cbf769, 0x2a6bc689, 0x2a6bc689, 0xc9cbf769, }, 20 }, - { "gfxterm_high", 640, 480, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 640x480xrgba5550 */, (grub_uint32_t []) { 0x5387d57f, 0xc2dae336, 0x5450f06e, 0xc2dae336, 0x2fd25c3, 0x5387d57f, 0x5387d57f, 0x71381c6, 0x71381c6, 0x71381c6, 0xc74aed0a, 0xc74aed0a, 0xc74aed0a, 0x20946f9c, 0x20946f9c, 0x20946f9c, 0x5387d57f, 0x2fd25c3, 0x2fd25c3, 0x5387d57f, }, 20 }, - { "gfxterm_high", 800, 600, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 800x600xrgba5550 */, (grub_uint32_t []) { 0xf83ee7aa, 0xf910eb1d, 0xb42b7abc, 0xf910eb1d, 0x6d5e8f22, 0xf83ee7aa, 0xf83ee7aa, 0x610deea9, 0x610deea9, 0x610deea9, 0xfd743e5a, 0xfd743e5a, 0xfd743e5a, 0xc5c795f2, 0xc5c795f2, 0xc5c795f2, 0xf83ee7aa, 0x6d5e8f22, 0x6d5e8f22, 0xf83ee7aa, }, 20 }, - { "gfxterm_high", 1024, 768, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 1024x768xrgba5550 */, (grub_uint32_t []) { 0x724366e5, 0xa038bbb4, 0xe0e97e39, 0xa038bbb4, 0x4211aeac, 0x724366e5, 0x724366e5, 0xdbb2f05a, 0xdbb2f05a, 0xdbb2f05a, 0x9c8bb2a0, 0x9c8bb2a0, 0x9c8bb2a0, 0xf1a595ea, 0xf1a595ea, 0xf1a595ea, 0x724366e5, 0x4211aeac, 0x4211aeac, 0x724366e5, }, 20 }, - { "gfxterm_high", 640, 480, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 640x480xrgba5650 */, (grub_uint32_t []) { 0x5387d57f, 0x4a2dd1b7, 0xb63c9469, 0x4a2dd1b7, 0xe8aea440, 0x5387d57f, 0x5387d57f, 0x23c74007, 0x23c74007, 0x23c74007, 0xfd090fda, 0xfd090fda, 0xfd090fda, 0x6e8a9dc4, 0x6e8a9dc4, 0x6e8a9dc4, 0x5387d57f, 0xe8aea440, 0xe8aea440, 0x5387d57f, }, 20 }, - { "gfxterm_high", 800, 600, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 800x600xrgba5650 */, (grub_uint32_t []) { 0xf83ee7aa, 0x8597e648, 0x66fbf174, 0x8597e648, 0xa99c8f36, 0xf83ee7aa, 0xf83ee7aa, 0xa5fd8afa, 0xa5fd8afa, 0xa5fd8afa, 0xd72799ca, 0xd72799ca, 0xd72799ca, 0xe6b2c80c, 0xe6b2c80c, 0xe6b2c80c, 0xf83ee7aa, 0xa99c8f36, 0xa99c8f36, 0xf83ee7aa, }, 20 }, - { "gfxterm_high", 1024, 768, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 1024x768xrgba5650 */, (grub_uint32_t []) { 0x724366e5, 0x7c1b6088, 0x3a8493cf, 0x7c1b6088, 0xd5d88a3e, 0x724366e5, 0x724366e5, 0xd0002838, 0xd0002838, 0xd0002838, 0x8990db68, 0x8990db68, 0x8990db68, 0x4127b52a, 0x4127b52a, 0x4127b52a, 0x724366e5, 0xd5d88a3e, 0xd5d88a3e, 0x724366e5, }, 20 }, - { "gfxterm_high", 640, 480, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 640x480xrgba8880 */, (grub_uint32_t []) { 0x1c955882, 0x9f45f149, 0x99de5ef4, 0x9f45f149, 0x84437bc3, 0x1c955882, 0x1c955882, 0x727420bf, 0x727420bf, 0x727420bf, 0xbd836d28, 0xbd836d28, 0xbd836d28, 0x43ea613d, 0x43ea613d, 0x43ea613d, 0x1c955882, 0x84437bc3, 0x84437bc3, 0x1c955882, }, 20 }, - { "gfxterm_high", 800, 600, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 800x600xrgba8880 */, (grub_uint32_t []) { 0x4d266f7a, 0x60f3276d, 0xe8b80d2f, 0x60f3276d, 0x1d7bae65, 0x4d266f7a, 0x4d266f7a, 0xc23ec599, 0xc23ec599, 0xc23ec599, 0x2449de26, 0x2449de26, 0x2449de26, 0xbc708ab6, 0xbc708ab6, 0xbc708ab6, 0x4d266f7a, 0x1d7bae65, 0x1d7bae65, 0x4d266f7a, }, 20 }, - { "gfxterm_high", 1024, 768, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 1024x768xrgba8880 */, (grub_uint32_t []) { 0x1ed9d731, 0x66a98ee6, 0x5432677a, 0x66a98ee6, 0x691b88fb, 0x1ed9d731, 0x1ed9d731, 0x6ea8026e, 0x6ea8026e, 0x6ea8026e, 0xc0cc1cab, 0xc0cc1cab, 0xc0cc1cab, 0xe3a50d1d, 0xe3a50d1d, 0xe3a50d1d, 0x1ed9d731, 0x691b88fb, 0x691b88fb, 0x1ed9d731, }, 20 }, - { "gfxterm_high", 640, 480, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 640x480xbgra5550 */, (grub_uint32_t []) { 0x5387d57f, 0xc26d8183, 0x54e792db, 0xc26d8183, 0x1473f9a0, 0x5387d57f, 0x5387d57f, 0x71381c6, 0x71381c6, 0x71381c6, 0xc74aed0a, 0xc74aed0a, 0xc74aed0a, 0x20946f9c, 0x20946f9c, 0x20946f9c, 0x5387d57f, 0x1473f9a0, 0x1473f9a0, 0x5387d57f, }, 20 }, - { "gfxterm_high", 800, 600, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 800x600xbgra5550 */, (grub_uint32_t []) { 0xf83ee7aa, 0x3ed65cd5, 0x73edcd74, 0x3ed65cd5, 0xb2351146, 0xf83ee7aa, 0xf83ee7aa, 0x610deea9, 0x610deea9, 0x610deea9, 0xfd743e5a, 0xfd743e5a, 0xfd743e5a, 0xc5c795f2, 0xc5c795f2, 0xc5c795f2, 0xf83ee7aa, 0xb2351146, 0xb2351146, 0xf83ee7aa, }, 20 }, - { "gfxterm_high", 1024, 768, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 1024x768xbgra5550 */, (grub_uint32_t []) { 0x724366e5, 0xc576da57, 0x85a71fda, 0xc576da57, 0x1ef86a3, 0x724366e5, 0x724366e5, 0xdbb2f05a, 0xdbb2f05a, 0xdbb2f05a, 0x9c8bb2a0, 0x9c8bb2a0, 0x9c8bb2a0, 0xf1a595ea, 0xf1a595ea, 0xf1a595ea, 0x724366e5, 0x1ef86a3, 0x1ef86a3, 0x724366e5, }, 20 }, - { "gfxterm_high", 640, 480, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 640x480xbgra5650 */, (grub_uint32_t []) { 0x5387d57f, 0x4778be32, 0xbb69fbec, 0x4778be32, 0x892b70c4, 0x5387d57f, 0x5387d57f, 0x23c74007, 0x23c74007, 0x23c74007, 0xfd090fda, 0xfd090fda, 0xfd090fda, 0x6e8a9dc4, 0x6e8a9dc4, 0x6e8a9dc4, 0x5387d57f, 0x892b70c4, 0x892b70c4, 0x5387d57f, }, 20 }, - { "gfxterm_high", 800, 600, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 800x600xbgra5650 */, (grub_uint32_t []) { 0xf83ee7aa, 0x9c6c6004, 0x7f007738, 0x9c6c6004, 0x80b05ef0, 0xf83ee7aa, 0xf83ee7aa, 0xa5fd8afa, 0xa5fd8afa, 0xa5fd8afa, 0xd72799ca, 0xd72799ca, 0xd72799ca, 0xe6b2c80c, 0xe6b2c80c, 0xe6b2c80c, 0xf83ee7aa, 0x80b05ef0, 0x80b05ef0, 0xf83ee7aa, }, 20 }, - { "gfxterm_high", 1024, 768, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 1024x768xbgra5650 */, (grub_uint32_t []) { 0x724366e5, 0x84caa3c1, 0xc2555086, 0x84caa3c1, 0xd82d8d02, 0x724366e5, 0x724366e5, 0xd0002838, 0xd0002838, 0xd0002838, 0x8990db68, 0x8990db68, 0x8990db68, 0x4127b52a, 0x4127b52a, 0x4127b52a, 0x724366e5, 0xd82d8d02, 0xd82d8d02, 0x724366e5, }, 20 }, - { "gfxterm_high", 640, 480, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 640x480xbgra8880 */, (grub_uint32_t []) { 0x1c955882, 0xe4dec6e6, 0xe245695b, 0xe4dec6e6, 0x9eed5252, 0x1c955882, 0x1c955882, 0x727420bf, 0x727420bf, 0x727420bf, 0xbd836d28, 0xbd836d28, 0xbd836d28, 0x43ea613d, 0x43ea613d, 0x43ea613d, 0x1c955882, 0x9eed5252, 0x9eed5252, 0x1c955882, }, 20 }, - { "gfxterm_high", 800, 600, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 800x600xbgra8880 */, (grub_uint32_t []) { 0x4d266f7a, 0x19a935eb, 0x91e21fa9, 0x19a935eb, 0x7358a32a, 0x4d266f7a, 0x4d266f7a, 0xc23ec599, 0xc23ec599, 0xc23ec599, 0x2449de26, 0x2449de26, 0x2449de26, 0xbc708ab6, 0xbc708ab6, 0xbc708ab6, 0x4d266f7a, 0x7358a32a, 0x7358a32a, 0x4d266f7a, }, 20 }, - { "gfxterm_high", 1024, 768, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 1024x768xbgra8880 */, (grub_uint32_t []) { 0x1ed9d731, 0xb2b10aa1, 0x802ae33d, 0xb2b10aa1, 0x105ee3bb, 0x1ed9d731, 0x1ed9d731, 0x6ea8026e, 0x6ea8026e, 0x6ea8026e, 0xc0cc1cab, 0xc0cc1cab, 0xc0cc1cab, 0xe3a50d1d, 0xe3a50d1d, 0xe3a50d1d, 0x1ed9d731, 0x105ee3bb, 0x105ee3bb, 0x1ed9d731, }, 20 }, - { "gfxterm_high", 640, 480, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 640x480xbgra8888 */, (grub_uint32_t []) { 0x9813a416, 0xeedf19a8, 0xaa1e1e0, 0xeedf19a8, 0x70c50dc2, 0x9813a416, 0x9813a416, 0xc10419e0, 0xc10419e0, 0xc10419e0, 0x50df9fd3, 0x50df9fd3, 0x50df9fd3, 0xccaa6a11, 0xccaa6a11, 0xccaa6a11, 0x9813a416, 0x70c50dc2, 0x70c50dc2, 0x9813a416, }, 20 }, - { "gfxterm_high", 800, 600, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 800x600xbgra8888 */, (grub_uint32_t []) { 0x5fcf013d, 0xa474246a, 0xe8f263a8, 0xa474246a, 0xe7cea168, 0x5fcf013d, 0x5fcf013d, 0x77ba65ab, 0x77ba65ab, 0x77ba65ab, 0xa5aa7ddd, 0xa5aa7ddd, 0xa5aa7ddd, 0xba81fc20, 0xba81fc20, 0xba81fc20, 0x5fcf013d, 0xe7cea168, 0xe7cea168, 0x5fcf013d, }, 20 }, - { "gfxterm_high", 1024, 768, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 1024x768xbgra8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x653aabb4, 0x317d975c, 0x653aabb4, 0xab5387a0, 0xdd28f52b, 0xdd28f52b, 0xbc36f156, 0xbc36f156, 0xbc36f156, 0x9d0a08b2, 0x9d0a08b2, 0x9d0a08b2, 0x877b6b23, 0x877b6b23, 0x877b6b23, 0xdd28f52b, 0xab5387a0, 0xab5387a0, 0xdd28f52b, }, 20 }, - { "videotest", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x7f1853ba, 0x7f1853ba, 0x7f1853ba, 0x7f1853ba, 0x7f1853ba, }, 5 }, - { "videotest", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xff1957f0, 0xff1957f0, 0xff1957f0, 0xff1957f0, 0xff1957f0, }, 5 }, - { "videotest", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xcb45d8c5, 0xcb45d8c5, 0xcb45d8c5, 0xcb45d8c5, 0xcb45d8c5, }, 5 }, - { "videotest", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x2b154617, 0x692e98df, 0xaf62fb87, 0xed59254f, 0x26164bc6, }, 5 }, - { "videotest", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x3b0fbc56, 0xd9d57c0e, 0xfb564a17, 0x198c8a4f, 0xbe502625, }, 5 }, - { "videotest", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0x6e6c9b36, 0x4ae9f137, 0x27664f34, 0x3e32535, 0xfc793332, }, 5 }, - { "videotest", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x91692eef, 0x89773091, 0xa1551213, 0xb94b0c6d, 0xf1115717, }, 5 }, - { "videotest", 640, 480, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi256 */, (grub_uint32_t []) { 0x2d1b122b, 0x2d1b122b, 0x2d1b122b, 0x2d1b122b, 0x2d1b122b, }, 5 }, - { "videotest", 800, 600, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi256 */, (grub_uint32_t []) { 0x327d1082, 0x327d1082, 0x327d1082, 0x327d1082, 0x327d1082, }, 5 }, - { "videotest", 1024, 768, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi256 */, (grub_uint32_t []) { 0xadd0f186, 0xadd0f186, 0xadd0f186, 0xadd0f186, 0xadd0f186, }, 5 }, - { "videotest", 640, 480, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 640x480xrgba5550 */, (grub_uint32_t []) { 0x2c97569c, 0x2c97569c, 0x2c97569c, 0x2c97569c, 0x2c97569c, }, 5 }, - { "videotest", 800, 600, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 800x600xrgba5550 */, (grub_uint32_t []) { 0x9bd7a3ac, 0x9bd7a3ac, 0x9bd7a3ac, 0x9bd7a3ac, 0x9bd7a3ac, }, 5 }, - { "videotest", 1024, 768, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 1024x768xrgba5550 */, (grub_uint32_t []) { 0xedbceb9c, 0xedbceb9c, 0xedbceb9c, 0xedbceb9c, 0xedbceb9c, }, 5 }, - { "videotest", 640, 480, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 640x480xrgba5650 */, (grub_uint32_t []) { 0x3c2a42f1, 0x3c2a42f1, 0x3c2a42f1, 0x3c2a42f1, 0x3c2a42f1, }, 5 }, - { "videotest", 800, 600, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 800x600xrgba5650 */, (grub_uint32_t []) { 0xb25ce62a, 0xb25ce62a, 0xb25ce62a, 0xb25ce62a, 0xb25ce62a, }, 5 }, - { "videotest", 1024, 768, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 1024x768xrgba5650 */, (grub_uint32_t []) { 0x66cee14c, 0x66cee14c, 0x66cee14c, 0x66cee14c, 0x66cee14c, }, 5 }, - { "videotest", 640, 480, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 640x480xrgba8880 */, (grub_uint32_t []) { 0x61db45b7, 0x1d867efe, 0x99613325, 0xe53c086c, 0x9543de62, }, 5 }, - { "videotest", 800, 600, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 800x600xrgba8880 */, (grub_uint32_t []) { 0xa46eb37f, 0xd2a59656, 0x49f8f92d, 0x3f33dc04, 0x7aae512a, }, 5 }, - { "videotest", 1024, 768, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 1024x768xrgba8880 */, (grub_uint32_t []) { 0xb864a496, 0x6c22313b, 0x1505f93d, 0xc1436c90, 0xe74a6931, }, 5 }, - { "videotest", 640, 480, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 640x480xbgra5550 */, (grub_uint32_t []) { 0x9056f776, 0x9056f776, 0x9056f776, 0x9056f776, 0x9056f776, }, 5 }, - { "videotest", 800, 600, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 800x600xbgra5550 */, (grub_uint32_t []) { 0x2bde3c67, 0x2bde3c67, 0x2bde3c67, 0x2bde3c67, 0x2bde3c67, }, 5 }, - { "videotest", 1024, 768, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 1024x768xbgra5550 */, (grub_uint32_t []) { 0xb04615f3, 0xb04615f3, 0xb04615f3, 0xb04615f3, 0xb04615f3, }, 5 }, - { "videotest", 640, 480, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 640x480xbgra5650 */, (grub_uint32_t []) { 0xba8df8dd, 0xba8df8dd, 0xba8df8dd, 0xba8df8dd, 0xba8df8dd, }, 5 }, - { "videotest", 800, 600, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 800x600xbgra5650 */, (grub_uint32_t []) { 0x84ac1329, 0x84ac1329, 0x84ac1329, 0x84ac1329, 0x84ac1329, }, 5 }, - { "videotest", 1024, 768, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 1024x768xbgra5650 */, (grub_uint32_t []) { 0x145ad698, 0x145ad698, 0x145ad698, 0x145ad698, 0x145ad698, }, 5 }, - { "videotest", 640, 480, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 640x480xbgra8880 */, (grub_uint32_t []) { 0x4af6b480, 0x923db79c, 0xfe8cc449, 0x2647c755, 0x27ee23e3, }, 5 }, - { "videotest", 800, 600, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 800x600xbgra8880 */, (grub_uint32_t []) { 0x121d5e29, 0xf66c0aed, 0xdf138150, 0x3b62d594, 0x8dec962a, }, 5 }, - { "videotest", 1024, 768, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 1024x768xbgra8880 */, (grub_uint32_t []) { 0xae86a12c, 0x4dabbe89, 0x6d30e897, 0x8e1df732, 0x2c0644ab, }, 5 }, - { "videotest", 640, 480, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 640x480xbgra8888 */, (grub_uint32_t []) { 0x2605d280, 0xc06e3172, 0xef3e6395, 0x9558067, 0xb19ec65b, }, 5 }, - { "videotest", 800, 600, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 800x600xbgra8888 */, (grub_uint32_t []) { 0x9404ef3b, 0xa4fdf18, 0xad7ef98c, 0x3335c9af, 0xe6f0c255, }, 5 }, - { "videotest", 1024, 768, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 1024x768xbgra8888 */, (grub_uint32_t []) { 0xa008b770, 0xb98eb0d8, 0x9304b820, 0x8a82bf88, 0xc610a9d0, }, 5 }, + { "cmdline_cat", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x24dc7bce, 0x24dc7bce, 0x338542b, 0x338542b, 0x2016b9d1, 0x2016b9d1, 0xc2619a36, 0xc2619a36, 0x10fce1e, 0x10fce1e, 0x8267298e, 0x8267298e, 0xf44246cf, 0xf44246cf, 0x3ee2860f, 0x3ee2860f, 0x1191f916, 0x1191f916, 0xfa8ce1b5, 0xfa8ce1b5, 0xc1f18b8e, 0xc1f18b8e, 0x43f8c0e8, 0x43f8c0e8, 0xbc0d166a, 0xbc0d166a, 0x7b742e8f, 0x7b742e8f, 0x2c3c7f89, 0x2c3c7f89, 0x80148a7e, 0x80148a7e, 0x21daaadf, 0x21daaadf, 0x15e97fa9, 0x15e97fa9, 0x2428d454, 0x2428d454, 0xb12b0f78, 0xb12b0f78, 0x29648b05, 0x8ce36e6f, 0xd26b03dd, 0xd26b03dd, }, 45 }, + { "cmdline_cat", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0xd09d4d28, 0xd09d4d28, 0xb41a2f17, 0xb41a2f17, 0x56381354, 0x56381354, 0xf2c5615f, 0xf2c5615f, 0xa41822ae, 0xa41822ae, 0xba2e3e60, 0xba2e3e60, 0x1859aaac, 0x1859aaac, 0x6c354a92, 0x6c354a92, 0x652d3eb, 0x652d3eb, 0xffcf0fd8, 0xffcf0fd8, 0xd3c9187c, 0xd3c9187c, 0xdee59346, 0xdee59346, 0x950f6354, 0x950f6354, 0xa2f7e36a, 0xa2f7e36a, 0x3967359a, 0x3967359a, 0x12738c9a, 0x12738c9a, 0xffb94ca3, 0xffb94ca3, 0xd9384791, 0xd9384791, 0xade1fd25, 0xade1fd25, 0xca109ebe, 0xca109ebe, 0x6e794e, 0x20d769cf, 0x29cc1fdc, 0x29cc1fdc, }, 45 }, + { "cmdline_cat", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x6cfe9089, 0x6cfe9089, 0xbe85dea2, 0xbe85dea2, 0x5f57923d, 0x5f57923d, 0xd28ad04b, 0xd28ad04b, 0x9ac91b28, 0x9ac91b28, 0x26977f54, 0x26977f54, 0x56cfda54, 0x56cfda54, 0xae54550f, 0xae54550f, 0x5843182b, 0x5843182b, 0xa1524272, 0xa1524272, 0x86b707db, 0x86b707db, 0x4127540e, 0x4127540e, 0xe89ea08e, 0xe89ea08e, 0x85f4dccc, 0x85f4dccc, 0xf910d16c, 0xf910d16c, 0xd43ff6b8, 0xd43ff6b8, 0xcdec4fd0, 0xcdec4fd0, 0xad650879, 0xad650879, 0x6d8e01c7, 0x6d8e01c7, 0x3ce7c69f, 0x3ce7c69f, 0xed54e2ef, 0x141319e, 0x9003a604, 0x9003a604, }, 45 }, + { "cmdline_cat", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x37f1b28e, 0x37f1b28e, 0x248de37a, 0x248de37a, 0x8b84bbe6, 0x8b84bbe6, 0x62efb943, 0x62efb943, 0x50d082fd, 0x50d082fd, 0x68a0c1, 0x68a0c1, 0xa335f8d0, 0xa335f8d0, 0xf26eaa27, 0xf26eaa27, 0x9f661fa2, 0x9f661fa2, 0x9a9c6bcb, 0x9a9c6bcb, 0xa5427057, 0xa5427057, 0x59aabcc8, 0x59aabcc8, 0xd1563970, 0xd1563970, 0x5f65ea2e, 0x5f65ea2e, 0xce189d5e, 0xce189d5e, 0xa0ac6e61, 0xa0ac6e61, 0xf85ec3, 0xf85ec3, 0xa6a5bea8, 0xa6a5bea8, 0xae55a1ba, 0xae55a1ba, 0x23f4e9e3, 0x23f4e9e3, 0x580abc5c, 0x58b54e7f, 0xafe85bbb, 0xafe85bbb, }, 45 }, + { "cmdline_cat", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x6d4812ec, 0x6d4812ec, 0x9d93973a, 0x9d93973a, 0x88cb4e17, 0x88cb4e17, 0x81f14f0a, 0x81f14f0a, 0x7f9f1875, 0x7f9f1875, 0x292f8345, 0x292f8345, 0x524cefe0, 0x524cefe0, 0x5d02251, 0x5d02251, 0x61afaf9e, 0x61afaf9e, 0xc327f8b9, 0xc327f8b9, 0xa1ece03d, 0xa1ece03d, 0xbb98b63c, 0xbb98b63c, 0x61b920db, 0x61b920db, 0xb1571b03, 0xb1571b03, 0xd315b012, 0xd315b012, 0xee77780c, 0xee77780c, 0x9b6ce52e, 0x9b6ce52e, 0x3b18a467, 0x3b18a467, 0x5ab91ffb, 0x5ab91ffb, 0x9255edea, 0x9255edea, 0x9ca85712, 0xa249a7fa, 0x213825f8, 0x213825f8, }, 45 }, + { "cmdline_cat", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x10bc4224, 0x10bc4224, 0xb8085994, 0xb8085994, 0x6ab26d0a, 0x6ab26d0a, 0xde71396c, 0xde71396c, 0x425a3956, 0x425a3956, 0xb7d2a7e3, 0xb7d2a7e3, 0x658ab388, 0x658ab388, 0x3fadf9dc, 0x3fadf9dc, 0xb29884ae, 0xb29884ae, 0x3a0830a7, 0x3a0830a7, 0xcf41267a, 0xcf41267a, 0x121c9703, 0x121c9703, 0xd126f87c, 0xd126f87c, 0x3b9d5bf6, 0x3b9d5bf6, 0x2a05cbef, 0x2a05cbef, 0x9ad41c2c, 0x9ad41c2c, 0xebf19db8, 0xebf19db8, 0x79f1b335, 0x79f1b335, 0xad2f9e8d, 0xad2f9e8d, 0x99596c48, 0x99596c48, 0x75b1cae6, 0x3cd081b2, 0x23e8ef2f, 0x23e8ef2f, }, 45 }, + { "cmdline_cat", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x8920d2ff, 0x8920d2ff, 0x369cb8d2, 0x369cb8d2, 0x880f23e4, 0x880f23e4, 0xf4a02ce2, 0xf4a02ce2, 0x7933f9a4, 0x7933f9a4, 0x488859f0, 0x488859f0, 0x75855108, 0x75855108, 0xf0463685, 0xf0463685, 0xf3e90b78, 0xf3e90b78, 0xac92b2b6, 0xac92b2b6, 0x63131cc5, 0x63131cc5, 0xfb714a00, 0xfb714a00, 0xc495c9a0, 0xc495c9a0, 0x314b6225, 0x314b6225, 0xc0d56232, 0xc0d56232, 0xa051d312, 0xa051d312, 0x9c0d295c, 0x9c0d295c, 0x3f234b5, 0x3f234b5, 0xa4201189, 0xa4201189, 0x23af1b2f, 0x23af1b2f, 0xc787ef0f, 0x2a3c46f8, 0xf03fe2d9, 0xf03fe2d9, }, 45 }, + { "gfxterm_menu", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0xdff707ef, 0xb938eb6c, 0xdff707ef, 0x9c01caa8, 0x59c36f00, 0x59c36f00, 0xd3548a15, 0xd3548a15, 0xd3548a15, 0xadd4e773, 0xadd4e773, 0xadd4e773, 0xcf22f2a1, 0xcf22f2a1, 0xcf22f2a1, 0x59c36f00, 0x9c01caa8, 0x9c01caa8, 0x59c36f00, }, 20 }, + { "gfxterm_menu", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x59f141e3, 0xfddbc65b, 0x59f141e3, 0x77f4c49c, 0xaa4593fe, 0xaa4593fe, 0x7d5e4ea7, 0x7d5e4ea7, 0x7d5e4ea7, 0xdbab43c0, 0xdbab43c0, 0xdbab43c0, 0xf693e8b8, 0xf693e8b8, 0xf693e8b8, 0xaa4593fe, 0x77f4c49c, 0x77f4c49c, 0xaa4593fe, }, 20 }, + { "gfxterm_menu", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x9ac56bc2, 0x2049341a, 0x9ac56bc2, 0xc7d20646, 0xc9cbf769, 0xc9cbf769, 0x7c3c68c, 0x7c3c68c, 0x7c3c68c, 0xf91b0740, 0xf91b0740, 0xf91b0740, 0x1051b848, 0x1051b848, 0x1051b848, 0xc9cbf769, 0xc7d20646, 0xc7d20646, 0xc9cbf769, }, 20 }, + { "gfxterm_menu", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0xd50b603, 0xbef0bf34, 0xd50b603, 0xa306ffdb, 0x9813a416, 0x9813a416, 0x60ef8d73, 0x60ef8d73, 0x60ef8d73, 0xf1340b40, 0xf1340b40, 0xf1340b40, 0xe88e3690, 0xe88e3690, 0xe88e3690, 0x9813a416, 0xa306ffdb, 0xa306ffdb, 0x9813a416, }, 20 }, + { "gfxterm_menu", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x9408bd4d, 0x84fea62c, 0x9408bd4d, 0xe2ae88fe, 0x5fcf013d, 0x5fcf013d, 0x6f5971e2, 0x6f5971e2, 0x6f5971e2, 0xbd496994, 0xbd496994, 0xbd496994, 0xab3a560b, 0xab3a560b, 0xab3a560b, 0x5fcf013d, 0xe2ae88fe, 0xe2ae88fe, 0x5fcf013d, }, 20 }, + { "gfxterm_menu", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x8460b76a, 0xd01813b4, 0x8460b76a, 0x9f656d6d, 0xdd28f52b, 0xdd28f52b, 0xda805056, 0xda805056, 0xda805056, 0xfbbca9b2, 0xfbbca9b2, 0xfbbca9b2, 0x8604623e, 0x8604623e, 0x8604623e, 0xdd28f52b, 0x9f656d6d, 0x9f656d6d, 0xdd28f52b, }, 20 }, + { "gfxterm_menu", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x115542af, 0xbac49512, 0x115542af, 0xeeea592f, 0x43d1f34, 0x43d1f34, 0x9a133a7f, 0x9a133a7f, 0x9a133a7f, 0xe51993d7, 0xe51993d7, 0xe51993d7, 0x7c489651, 0x7c489651, 0x7c489651, 0x43d1f34, 0xeeea592f, 0xeeea592f, 0x43d1f34, }, 20 }, + { "gfxmenu", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x60e56714, 0x14275a99, 0x60e56714, 0x35080c92, 0x9a2e0d26, 0x35f491f9, 0x35f491f9, 0x35f491f9, 0x692c6739, 0x692c6739, 0x692c6739, 0x40b4a9ab, 0x40b4a9ab, 0x40b4a9ab, 0x59c36f00, 0x35080c92, 0x35080c92, }, 18 }, + { "gfxmenu", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x33d94a8c, 0x7b789e53, 0x33d94a8c, 0xe8b9b6bf, 0xa9d58ccd, 0xeee84c5, 0xeee84c5, 0xeee84c5, 0x5bb12ecf, 0x5bb12ecf, 0x5bb12ecf, 0x3282e686, 0x3282e686, 0x3282e686, 0xaa4593fe, 0xe8b9b6bf, 0xe8b9b6bf, }, 18 }, + { "gfxmenu", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xe4669404, 0x9afa8e99, 0xe4669404, 0xdd25167e, 0x5411be8b, 0x2cf5262a, 0x2cf5262a, 0x2cf5262a, 0x534b80be, 0x534b80be, 0x534b80be, 0x113fe0c6, 0x113fe0c6, 0x113fe0c6, 0xc9cbf769, 0xdd25167e, 0xdd25167e, }, 18 }, + { "gfxmenu", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x1c3742c9, 0x37ed1568, 0x12f55eef, 0x37ed1568, 0x8aa8ad16, 0x740d78cf, 0x7bd2e3a3, 0x7bd2e3a3, 0x7bd2e3a3, 0x907709df, 0x907709df, 0x907709df, 0x963c092f, 0x963c092f, 0x963c092f, 0x1c3742c9, 0x8aa8ad16, 0x8aa8ad16, }, 18 }, + { "gfxmenu", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0xcc5a7bed, 0xc5315ac9, 0x7dece9d3, 0xc5315ac9, 0xc84ef08b, 0xbcda144c, 0xd45c93dc, 0xd45c93dc, 0xd45c93dc, 0xbb154fcd, 0xbb154fcd, 0xbb154fcd, 0xb6e3d1ce, 0xb6e3d1ce, 0xb6e3d1ce, 0xcc5a7bed, 0xc84ef08b, 0xc84ef08b, }, 18 }, + { "gfxmenu", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xef4a3312, 0x40a72ecd, 0x2304571f, 0x40a72ecd, 0xd2de6d81, 0x5d55a141, 0x304db662, 0x304db662, 0x304db662, 0xf6fff27c, 0xf6fff27c, 0xf6fff27c, 0xe29a22c3, 0xe29a22c3, 0xe29a22c3, 0xef4a3312, 0xd2de6d81, 0xd2de6d81, }, 18 }, + { "gfxmenu", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x54e48d80, 0xe6143ead, 0x19816f75, 0xe6143ead, 0xe2db78c2, 0xa992f629, 0xe0ddd143, 0xe0ddd143, 0xe0ddd143, 0x612e2792, 0x612e2792, 0x612e2792, 0xf78a9efd, 0xf78a9efd, 0xf78a9efd, 0x54e48d80, 0xe2db78c2, 0xe2db78c2, }, 18 }, + { "gfxterm_ar", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x3d69d4f7, 0x5b2df52e, 0x3d69d4f7, 0x7e9f19b0, 0x59c36f00, 0x59c36f00, 0xaa418d14, 0xaa418d14, 0xaa418d14, 0xd4c1e072, 0xd4c1e072, 0xd4c1e072, 0xb637f5a0, 0xb637f5a0, 0xb637f5a0, 0x59c36f00, 0x7e9f19b0, 0x7e9f19b0, 0x59c36f00, }, 20 }, + { "gfxterm_ar", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0xea153935, 0xadda68ff, 0xea153935, 0xc410bc4a, 0xaa4593fe, 0xaa4593fe, 0x63090f39, 0x63090f39, 0x63090f39, 0xc5fc025e, 0xc5fc025e, 0xc5fc025e, 0xe8c4a926, 0xe8c4a926, 0xe8c4a926, 0xaa4593fe, 0xc410bc4a, 0xc410bc4a, 0xaa4593fe, }, 20 }, + { "gfxterm_ar", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xe677248f, 0x9a146b56, 0xe677248f, 0xbb60490b, 0xc9cbf769, 0xc9cbf769, 0xebd87b6a, 0xebd87b6a, 0xebd87b6a, 0x1500baa6, 0x1500baa6, 0x1500baa6, 0xfc4a05ae, 0xfc4a05ae, 0xfc4a05ae, 0xc9cbf769, 0xbb60490b, 0xbb60490b, 0xc9cbf769, }, 20 }, + { "gfxterm_ar", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x2fe1d8b3, 0x344dc22f, 0x2fe1d8b3, 0x81b7916b, 0x9813a416, 0x9813a416, 0xb42009b, 0xb42009b, 0xb42009b, 0x9a9986a8, 0x9a9986a8, 0x9a9986a8, 0x8323bb78, 0x8323bb78, 0x8323bb78, 0x9813a416, 0x81b7916b, 0x81b7916b, 0x9813a416, }, 20 }, + { "gfxterm_ar", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x2f2ab760, 0x373afa93, 0x2f2ab760, 0x598c82d3, 0x5fcf013d, 0x5fcf013d, 0x8a9a15e2, 0x8a9a15e2, 0x8a9a15e2, 0x588a0d94, 0x588a0d94, 0x588a0d94, 0x4ef9320b, 0x4ef9320b, 0x4ef9320b, 0x5fcf013d, 0x598c82d3, 0x598c82d3, 0x5fcf013d, }, 20 }, + { "gfxterm_ar", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xb9de66a8, 0x2b705981, 0xb9de66a8, 0xa2dbbcaf, 0xdd28f52b, 0xdd28f52b, 0x971eb98b, 0x971eb98b, 0x971eb98b, 0xb622406f, 0xb622406f, 0xb622406f, 0xcb9a8be3, 0xcb9a8be3, 0xcb9a8be3, 0xdd28f52b, 0xa2dbbcaf, 0xa2dbbcaf, 0xdd28f52b, }, 20 }, + { "gfxterm_ar", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x84029f68, 0x7385ec77, 0x84029f68, 0x7bbd84e8, 0x43d1f34, 0x43d1f34, 0x73cb201f, 0x73cb201f, 0x73cb201f, 0xcc189b7, 0xcc189b7, 0xcc189b7, 0x95908c31, 0x95908c31, 0x95908c31, 0x43d1f34, 0x7bbd84e8, 0x7bbd84e8, 0x43d1f34, }, 20 }, + { "gfxterm_cyr", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0xb2446469, 0xca75968f, 0xb2446469, 0xf1b2a92e, 0x59c36f00, 0x59c36f00, 0xc0eac671, 0xc0eac671, 0xc0eac671, 0xbe6aab17, 0xbe6aab17, 0xbe6aab17, 0xdc9cbec5, 0xdc9cbec5, 0xdc9cbec5, 0x59c36f00, 0xf1b2a92e, 0xf1b2a92e, 0x59c36f00, }, 20 }, + { "gfxterm_cyr", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0xe219612c, 0x41ad1120, 0xe219612c, 0xcc1ce453, 0xaa4593fe, 0xaa4593fe, 0x1f05167, 0x1f05167, 0x1f05167, 0xa7055c00, 0xa7055c00, 0xa7055c00, 0x8a3df778, 0x8a3df778, 0x8a3df778, 0xaa4593fe, 0xcc1ce453, 0xcc1ce453, 0xaa4593fe, }, 20 }, + { "gfxterm_cyr", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x9f3ca4a3, 0x3df9621e, 0x9f3ca4a3, 0xc22bc927, 0xc9cbf769, 0xc9cbf769, 0x8f0b71ba, 0x8f0b71ba, 0x8f0b71ba, 0x71d3b076, 0x71d3b076, 0x71d3b076, 0x98990f7e, 0x98990f7e, 0x98990f7e, 0xc9cbf769, 0xc22bc927, 0xc22bc927, 0xc9cbf769, }, 20 }, + { "gfxterm_cyr", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x6b1e7755, 0x4532973e, 0x6b1e7755, 0xc5483e8d, 0x9813a416, 0x9813a416, 0xa279dbc8, 0xa279dbc8, 0xa279dbc8, 0x33a25dfb, 0x33a25dfb, 0x33a25dfb, 0x2a18602b, 0x2a18602b, 0x2a18602b, 0x9813a416, 0xc5483e8d, 0xc5483e8d, 0x9813a416, }, 20 }, + { "gfxterm_cyr", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0xa3774c63, 0x38dffb0e, 0xa3774c63, 0xd5d179d0, 0x5fcf013d, 0x5fcf013d, 0x28872666, 0x28872666, 0x28872666, 0xfa973e10, 0xfa973e10, 0xfa973e10, 0xece4018f, 0xece4018f, 0xece4018f, 0x5fcf013d, 0xd5d179d0, 0xd5d179d0, 0x5fcf013d, }, 20 }, + { "gfxterm_cyr", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xe9556aa5, 0x77425030, 0xe9556aa5, 0xf250b0a2, 0xdd28f52b, 0xdd28f52b, 0x938cfa6a, 0x938cfa6a, 0x938cfa6a, 0xb2b0038e, 0xb2b0038e, 0xb2b0038e, 0xcf08c802, 0xcf08c802, 0xcf08c802, 0xdd28f52b, 0xf250b0a2, 0xf250b0a2, 0xdd28f52b, }, 20 }, + { "gfxterm_cyr", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x9adc43d0, 0xd8ac5204, 0x9adc43d0, 0x65635850, 0x43d1f34, 0x43d1f34, 0xc182db12, 0xc182db12, 0xc182db12, 0xbe8872ba, 0xbe8872ba, 0xbe8872ba, 0x27d9773c, 0x27d9773c, 0x27d9773c, 0x43d1f34, 0x65635850, 0x65635850, 0x43d1f34, }, 20 }, + { "gfxterm_heb", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x7fd0187d, 0x7d05975c, 0x7fd0187d, 0x3c26d53a, 0x59c36f00, 0x59c36f00, 0xb4fad8de, 0xb4fad8de, 0xb4fad8de, 0xca7ab5b8, 0xca7ab5b8, 0xca7ab5b8, 0xa88ca06a, 0xa88ca06a, 0xa88ca06a, 0x59c36f00, 0x3c26d53a, 0x3c26d53a, 0x59c36f00, }, 20 }, + { "gfxterm_heb", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x54f3fad9, 0xe7a5a67a, 0x54f3fad9, 0x7af67fa6, 0xaa4593fe, 0xaa4593fe, 0xcae58c6a, 0xcae58c6a, 0xcae58c6a, 0x6c10810d, 0x6c10810d, 0x6c10810d, 0x41282a75, 0x41282a75, 0x41282a75, 0xaa4593fe, 0x7af67fa6, 0x7af67fa6, 0xaa4593fe, }, 20 }, + { "gfxterm_heb", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x869916b8, 0x373dbcc3, 0x869916b8, 0xdb8e7b3c, 0xc9cbf769, 0xc9cbf769, 0xaa0c75c1, 0xaa0c75c1, 0xaa0c75c1, 0x54d4b40d, 0x54d4b40d, 0x54d4b40d, 0xbd9e0b05, 0xbd9e0b05, 0xbd9e0b05, 0xc9cbf769, 0xdb8e7b3c, 0xdb8e7b3c, 0xc9cbf769, }, 20 }, + { "gfxterm_heb", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0xb2f32f4, 0xff8e66df, 0xb2f32f4, 0xa5797b2c, 0x9813a416, 0x9813a416, 0x9fc65347, 0x9fc65347, 0x9fc65347, 0xe1dd574, 0xe1dd574, 0xe1dd574, 0x17a7e8a4, 0x17a7e8a4, 0x17a7e8a4, 0x9813a416, 0xa5797b2c, 0xa5797b2c, 0x9813a416, }, 20 }, + { "gfxterm_heb", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x26280874, 0x6f7dd72, 0x26280874, 0x508e3dc7, 0x5fcf013d, 0x5fcf013d, 0x197943fe, 0x197943fe, 0x197943fe, 0xcb695b88, 0xcb695b88, 0xcb695b88, 0xdd1a6417, 0xdd1a6417, 0xdd1a6417, 0x5fcf013d, 0x508e3dc7, 0x508e3dc7, 0x5fcf013d, }, 20 }, + { "gfxterm_heb", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xd23ae631, 0xe5a30d5e, 0xd23ae631, 0xc93f3c36, 0xdd28f52b, 0xdd28f52b, 0x7042f8c, 0x7042f8c, 0x7042f8c, 0x2638d668, 0x2638d668, 0x2638d668, 0x5b801de4, 0x5b801de4, 0x5b801de4, 0xdd28f52b, 0xc93f3c36, 0xc93f3c36, 0xdd28f52b, }, 20 }, + { "gfxterm_heb", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x8d469c0b, 0xabeb5779, 0x8d469c0b, 0x72f9878b, 0x43d1f34, 0x43d1f34, 0xd8397828, 0xd8397828, 0xd8397828, 0xa733d180, 0xa733d180, 0xa733d180, 0x3e62d406, 0x3e62d406, 0x3e62d406, 0x43d1f34, 0x72f9878b, 0x72f9878b, 0x43d1f34, }, 20 }, + { "gfxterm_gre", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0xd668f275, 0x6a2de04f, 0xd668f275, 0x959e3f32, 0x59c36f00, 0x59c36f00, 0xc43520a0, 0xc43520a0, 0xc43520a0, 0xbab54dc6, 0xbab54dc6, 0xbab54dc6, 0xd8435814, 0xd8435814, 0xd8435814, 0x59c36f00, 0x959e3f32, 0x959e3f32, 0x59c36f00, }, 20 }, + { "gfxterm_gre", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0xe170ffb5, 0x17402498, 0xe170ffb5, 0xcf757aca, 0xaa4593fe, 0xaa4593fe, 0x4ec32c62, 0x4ec32c62, 0x4ec32c62, 0xe8362105, 0xe8362105, 0xe8362105, 0xc50e8a7d, 0xc50e8a7d, 0xc50e8a7d, 0xaa4593fe, 0xcf757aca, 0xcf757aca, 0xaa4593fe, }, 20 }, + { "gfxterm_gre", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xf4aef2d6, 0x47a46008, 0xf4aef2d6, 0xa9b99f52, 0xc9cbf769, 0xc9cbf769, 0x4f1a5666, 0x4f1a5666, 0x4f1a5666, 0xb1c297aa, 0xb1c297aa, 0xb1c297aa, 0x588828a2, 0x588828a2, 0x588828a2, 0xc9cbf769, 0xa9b99f52, 0xa9b99f52, 0xc9cbf769, }, 20 }, + { "gfxterm_gre", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0xc2ed8f74, 0xb7ab0607, 0xc2ed8f74, 0x6cbbc6ac, 0x9813a416, 0x9813a416, 0x535e7ba8, 0x535e7ba8, 0x535e7ba8, 0xc285fd9b, 0xc285fd9b, 0xc285fd9b, 0xdb3fc04b, 0xdb3fc04b, 0xdb3fc04b, 0x9813a416, 0x6cbbc6ac, 0x6cbbc6ac, 0x9813a416, }, 20 }, + { "gfxterm_gre", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0xf62383d8, 0x9489f90c, 0xf62383d8, 0x8085b66b, 0x5fcf013d, 0x5fcf013d, 0xb7f78bc2, 0xb7f78bc2, 0xb7f78bc2, 0x65e793b4, 0x65e793b4, 0x65e793b4, 0x7394ac2b, 0x7394ac2b, 0x7394ac2b, 0x5fcf013d, 0x8085b66b, 0x8085b66b, 0x5fcf013d, }, 20 }, + { "gfxterm_gre", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x753d8bc0, 0x5c9029d6, 0x753d8bc0, 0x6e3851c7, 0xdd28f52b, 0xdd28f52b, 0x1a40e22e, 0x1a40e22e, 0x1a40e22e, 0x3b7c1bca, 0x3b7c1bca, 0x3b7c1bca, 0x46c4d046, 0x46c4d046, 0x46c4d046, 0xdd28f52b, 0x6e3851c7, 0x6e3851c7, 0xdd28f52b, }, 20 }, + { "gfxterm_gre", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x62a774, 0xbb4b794c, 0x62a774, 0xffddbcf4, 0x43d1f34, 0x43d1f34, 0x83fede87, 0x83fede87, 0x83fede87, 0xfcf4772f, 0xfcf4772f, 0xfcf4772f, 0x65a572a9, 0x65a572a9, 0x65a572a9, 0x43d1f34, 0xffddbcf4, 0xffddbcf4, 0x43d1f34, }, 20 }, + { "gfxterm_ru", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x2edc6dc9, 0x166a6552, 0x2edc6dc9, 0x6d2aa08e, 0x59c36f00, 0x59c36f00, 0xd214e1a2, 0xd214e1a2, 0xd214e1a2, 0xac948cc4, 0xac948cc4, 0xac948cc4, 0xce629916, 0xce629916, 0xce629916, 0x59c36f00, 0x6d2aa08e, 0x6d2aa08e, 0x59c36f00, }, 20 }, + { "gfxterm_ru", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0xc12e1a21, 0x1e6e7468, 0xc12e1a21, 0xef2b9f5e, 0xaa4593fe, 0xaa4593fe, 0x1c792d02, 0x1c792d02, 0x1c792d02, 0xba8c2065, 0xba8c2065, 0xba8c2065, 0x97b48b1d, 0x97b48b1d, 0x97b48b1d, 0xaa4593fe, 0xef2b9f5e, 0xef2b9f5e, 0xaa4593fe, }, 20 }, + { "gfxterm_ru", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x510524f7, 0x7f9806b4, 0x510524f7, 0xc124973, 0xc9cbf769, 0xc9cbf769, 0x1a561d55, 0x1a561d55, 0x1a561d55, 0xe48edc99, 0xe48edc99, 0xe48edc99, 0xdc46391, 0xdc46391, 0xdc46391, 0xc9cbf769, 0xc124973, 0xc124973, 0xc9cbf769, }, 20 }, + { "gfxterm_ru", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0xa1ee6604, 0xd307a4d9, 0xa1ee6604, 0xfb82fdc, 0x9813a416, 0x9813a416, 0x5b7ed439, 0x5b7ed439, 0x5b7ed439, 0xcaa5520a, 0xcaa5520a, 0xcaa5520a, 0xd31f6fda, 0xd31f6fda, 0xd31f6fda, 0x9813a416, 0xfb82fdc, 0xfb82fdc, 0x9813a416, }, 20 }, + { "gfxterm_ru", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x4e2bb6a8, 0x67c92bf4, 0x4e2bb6a8, 0x388d831b, 0x5fcf013d, 0x5fcf013d, 0xe69beaed, 0xe69beaed, 0xe69beaed, 0x348bf29b, 0x348bf29b, 0x348bf29b, 0x22f8cd04, 0x22f8cd04, 0x22f8cd04, 0x5fcf013d, 0x388d831b, 0x388d831b, 0x5fcf013d, }, 20 }, + { "gfxterm_ru", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xeb6b461d, 0x679ed094, 0xeb6b461d, 0xf06e9c1a, 0xdd28f52b, 0xdd28f52b, 0xdf34624d, 0xdf34624d, 0xdf34624d, 0xfe089ba9, 0xfe089ba9, 0xfe089ba9, 0x83b05025, 0x83b05025, 0x83b05025, 0xdd28f52b, 0xf06e9c1a, 0xf06e9c1a, 0xdd28f52b, }, 20 }, + { "gfxterm_ru", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0xc486143c, 0x7b487645, 0xc486143c, 0x3b390fbc, 0x43d1f34, 0x43d1f34, 0x9576cd6b, 0x9576cd6b, 0x9576cd6b, 0xea7c64c3, 0xea7c64c3, 0xea7c64c3, 0x732d6145, 0x732d6145, 0x732d6145, 0x43d1f34, 0x3b390fbc, 0x3b390fbc, 0x43d1f34, }, 20 }, + { "gfxterm_fr", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0xa024d435, 0x8bc3f107, 0xa024d435, 0xe3d21972, 0x59c36f00, 0x59c36f00, 0x9412860d, 0x9412860d, 0x9412860d, 0xea92eb6b, 0xea92eb6b, 0xea92eb6b, 0x8864feb9, 0x8864feb9, 0x8864feb9, 0x59c36f00, 0xe3d21972, 0xe3d21972, 0x59c36f00, }, 20 }, + { "gfxterm_fr", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0xbf89b975, 0x481e2ecc, 0xbf89b975, 0x918c3c0a, 0xaa4593fe, 0xaa4593fe, 0xa8509e2c, 0xa8509e2c, 0xa8509e2c, 0xea5934b, 0xea5934b, 0xea5934b, 0x239d3833, 0x239d3833, 0x239d3833, 0xaa4593fe, 0x918c3c0a, 0x918c3c0a, 0xaa4593fe, }, 20 }, + { "gfxterm_fr", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x4d84ea04, 0xd1029f5b, 0x4d84ea04, 0x10938780, 0xc9cbf769, 0xc9cbf769, 0x3677fab0, 0x3677fab0, 0x3677fab0, 0xc8af3b7c, 0xc8af3b7c, 0xc8af3b7c, 0x21e58474, 0x21e58474, 0x21e58474, 0xc9cbf769, 0x10938780, 0x10938780, 0xc9cbf769, }, 20 }, + { "gfxterm_fr", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x9e5f6ab3, 0xda3fae82, 0x9e5f6ab3, 0x3009236b, 0x9813a416, 0x9813a416, 0x5710fb5f, 0x5710fb5f, 0x5710fb5f, 0xc6cb7d6c, 0xc6cb7d6c, 0xc6cb7d6c, 0xdf7140bc, 0xdf7140bc, 0xdf7140bc, 0x9813a416, 0x3009236b, 0x3009236b, 0x9813a416, }, 20 }, + { "gfxterm_fr", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x28f46625, 0xf4bfdc80, 0x28f46625, 0x5e525396, 0x5fcf013d, 0x5fcf013d, 0xb3f9b24b, 0xb3f9b24b, 0xb3f9b24b, 0x61e9aa3d, 0x61e9aa3d, 0x61e9aa3d, 0x779a95a2, 0x779a95a2, 0x779a95a2, 0x5fcf013d, 0x5e525396, 0x5e525396, 0x5fcf013d, }, 20 }, + { "gfxterm_fr", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x8c12e300, 0xa71b83e7, 0x8c12e300, 0x97173907, 0xdd28f52b, 0xdd28f52b, 0x2f660f28, 0x2f660f28, 0x2f660f28, 0xe5af6cc, 0xe5af6cc, 0xe5af6cc, 0x73e23d40, 0x73e23d40, 0x73e23d40, 0xdd28f52b, 0x97173907, 0x97173907, 0xdd28f52b, }, 20 }, + { "gfxterm_fr", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0xbaaaeec4, 0x7f7cd53b, 0xbaaaeec4, 0x4515f544, 0x43d1f34, 0x43d1f34, 0xd254254f, 0xd254254f, 0xd254254f, 0xad5e8ce7, 0xad5e8ce7, 0xad5e8ce7, 0x340f8961, 0x340f8961, 0x340f8961, 0x43d1f34, 0x4515f544, 0x4515f544, 0x43d1f34, }, 20 }, + { "gfxterm_quot", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x63166340, 0x5d98fc3, 0x63166340, 0x20e0ae07, 0x59c36f00, 0x59c36f00, 0xd3548a15, 0xd3548a15, 0xd3548a15, 0xadd4e773, 0xadd4e773, 0xadd4e773, 0xcf22f2a1, 0xcf22f2a1, 0xcf22f2a1, 0x59c36f00, 0x20e0ae07, 0x20e0ae07, 0x59c36f00, }, 20 }, + { "gfxterm_quot", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0xe0916467, 0x44bbe3df, 0xe0916467, 0xce94e118, 0xaa4593fe, 0xaa4593fe, 0x7d5e4ea7, 0x7d5e4ea7, 0x7d5e4ea7, 0xdbab43c0, 0xdbab43c0, 0xdbab43c0, 0xf693e8b8, 0xf693e8b8, 0xf693e8b8, 0xaa4593fe, 0xce94e118, 0xce94e118, 0xaa4593fe, }, 20 }, + { "gfxterm_quot", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x1aad9b94, 0xa021c44c, 0x1aad9b94, 0x47baf610, 0xc9cbf769, 0xc9cbf769, 0x7c3c68c, 0x7c3c68c, 0x7c3c68c, 0xf91b0740, 0xf91b0740, 0xf91b0740, 0x1051b848, 0x1051b848, 0x1051b848, 0xc9cbf769, 0x47baf610, 0x47baf610, 0xc9cbf769, }, 20 }, + { "gfxterm_quot", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0xb8710521, 0xbd10c16, 0xb8710521, 0x16274cf9, 0x9813a416, 0x9813a416, 0x60ef8d73, 0x60ef8d73, 0x60ef8d73, 0xf1340b40, 0xf1340b40, 0xf1340b40, 0xe88e3690, 0xe88e3690, 0xe88e3690, 0x9813a416, 0x16274cf9, 0x16274cf9, 0x9813a416, }, 20 }, + { "gfxterm_quot", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0xd62b53b5, 0xc6dd48d4, 0xd62b53b5, 0xa08d6606, 0x5fcf013d, 0x5fcf013d, 0x6f5971e2, 0x6f5971e2, 0x6f5971e2, 0xbd496994, 0xbd496994, 0xbd496994, 0xab3a560b, 0xab3a560b, 0xab3a560b, 0x5fcf013d, 0xa08d6606, 0xa08d6606, 0x5fcf013d, }, 20 }, + { "gfxterm_quot", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x10503615, 0x442892cb, 0x10503615, 0xb55ec12, 0xdd28f52b, 0xdd28f52b, 0xda805056, 0xda805056, 0xda805056, 0xfbbca9b2, 0xfbbca9b2, 0xfbbca9b2, 0x8604623e, 0x8604623e, 0x8604623e, 0xdd28f52b, 0xb55ec12, 0xb55ec12, 0xdd28f52b, }, 20 }, + { "gfxterm_quot", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x5c9d00a2, 0xf70cd71f, 0x5c9d00a2, 0xa3221b22, 0x43d1f34, 0x43d1f34, 0x9a133a7f, 0x9a133a7f, 0x9a133a7f, 0xe51993d7, 0xe51993d7, 0xe51993d7, 0x7c489651, 0x7c489651, 0x7c489651, 0x43d1f34, 0xa3221b22, 0xa3221b22, 0x43d1f34, }, 20 }, + { "gfxterm_piglatin", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0xbc89067b, 0xf339b29f, 0xbc89067b, 0xff7fcb3c, 0x59c36f00, 0x59c36f00, 0x5915b839, 0x5915b839, 0x5915b839, 0x2795d55f, 0x2795d55f, 0x2795d55f, 0x4563c08d, 0x4563c08d, 0x4563c08d, 0x59c36f00, 0xff7fcb3c, 0xff7fcb3c, 0x59c36f00, }, 20 }, + { "gfxterm_piglatin", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0xb19b98f6, 0xb8ffac95, 0xb19b98f6, 0x9f9e1d89, 0xaa4593fe, 0xaa4593fe, 0x6cb5454, 0x6cb5454, 0x6cb5454, 0xa03e5933, 0xa03e5933, 0xa03e5933, 0x8d06f24b, 0x8d06f24b, 0x8d06f24b, 0xaa4593fe, 0x9f9e1d89, 0x9f9e1d89, 0xaa4593fe, }, 20 }, + { "gfxterm_piglatin", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x133d7c3b, 0xd26c8a26, 0x133d7c3b, 0x4e2a11bf, 0xc9cbf769, 0xc9cbf769, 0x36504e54, 0x36504e54, 0x36504e54, 0xc8888f98, 0xc8888f98, 0xc8888f98, 0x21c23090, 0x21c23090, 0x21c23090, 0xc9cbf769, 0x4e2a11bf, 0x4e2a11bf, 0xc9cbf769, }, 20 }, + { "gfxterm_piglatin", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0xbfc94fbe, 0xe32be512, 0xbfc94fbe, 0x119f0666, 0x9813a416, 0x9813a416, 0x8350694d, 0x8350694d, 0x8350694d, 0x128bef7e, 0x128bef7e, 0x128bef7e, 0xb31d2ae, 0xb31d2ae, 0xb31d2ae, 0x9813a416, 0x119f0666, 0x119f0666, 0x9813a416, }, 20 }, + { "gfxterm_piglatin", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x9cf25061, 0xe5e2b458, 0x9cf25061, 0xea5465d2, 0x5fcf013d, 0x5fcf013d, 0xa5bfba08, 0xa5bfba08, 0xa5bfba08, 0x77afa27e, 0x77afa27e, 0x77afa27e, 0x61dc9de1, 0x61dc9de1, 0x61dc9de1, 0x5fcf013d, 0xea5465d2, 0xea5465d2, 0x5fcf013d, }, 20 }, + { "gfxterm_piglatin", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xc968ecc5, 0xa3105cfb, 0xc968ecc5, 0xd26d36c2, 0xdd28f52b, 0xdd28f52b, 0xff2fd4b8, 0xff2fd4b8, 0xff2fd4b8, 0xde132d5c, 0xde132d5c, 0xde132d5c, 0xa3abe6d0, 0xa3abe6d0, 0xa3abe6d0, 0xdd28f52b, 0xd26d36c2, 0xd26d36c2, 0xdd28f52b, }, 20 }, + { "gfxterm_piglatin", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0xf17f3c, 0xf3672115, 0xf17f3c, 0xff4e64bc, 0x43d1f34, 0x43d1f34, 0x6ec799ab, 0x6ec799ab, 0x6ec799ab, 0x11cd3003, 0x11cd3003, 0x11cd3003, 0x889c3585, 0x889c3585, 0x889c3585, 0x43d1f34, 0xff4e64bc, 0xff4e64bc, 0x43d1f34, }, 20 }, + { "gfxterm_ch", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x20f2a62b, 0x12808b5f, 0x20f2a62b, 0x63046b6c, 0x59c36f00, 0x59c36f00, 0x23e6cac6, 0x23e6cac6, 0x23e6cac6, 0x5d66a7a0, 0x5d66a7a0, 0x5d66a7a0, 0x3f90b272, 0x3f90b272, 0x3f90b272, 0x59c36f00, 0x63046b6c, 0x63046b6c, 0x59c36f00, }, 20 }, + { "gfxterm_ch", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x52fcbd8f, 0x7119870a, 0x52fcbd8f, 0x7cf938f0, 0xaa4593fe, 0xaa4593fe, 0x4bb9a19, 0x4bb9a19, 0x4bb9a19, 0xa24e977e, 0xa24e977e, 0xa24e977e, 0x8f763c06, 0x8f763c06, 0x8f763c06, 0xaa4593fe, 0x7cf938f0, 0x7cf938f0, 0xaa4593fe, }, 20 }, + { "gfxterm_ch", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xe4d74d3f, 0xd2dab4f0, 0xe4d74d3f, 0xb9c020bb, 0xc9cbf769, 0xc9cbf769, 0xa4955f92, 0xa4955f92, 0xa4955f92, 0x5a4d9e5e, 0x5a4d9e5e, 0x5a4d9e5e, 0xb3072156, 0xb3072156, 0xb3072156, 0xc9cbf769, 0xb9c020bb, 0xb9c020bb, 0xc9cbf769, }, 20 }, + { "gfxterm_ch", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0xa1c2b9ec, 0x34038c40, 0xa1c2b9ec, 0xf94f034, 0x9813a416, 0x9813a416, 0x438820a6, 0x438820a6, 0x438820a6, 0xd253a695, 0xd253a695, 0xd253a695, 0xcbe99b45, 0xcbe99b45, 0xcbe99b45, 0x9813a416, 0xf94f034, 0xf94f034, 0x9813a416, }, 20 }, + { "gfxterm_ch", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x339cc65f, 0xe46f6cec, 0x339cc65f, 0x453af3ec, 0x5fcf013d, 0x5fcf013d, 0xad75b235, 0xad75b235, 0xad75b235, 0x7f65aa43, 0x7f65aa43, 0x7f65aa43, 0x691695dc, 0x691695dc, 0x691695dc, 0x5fcf013d, 0x453af3ec, 0x453af3ec, 0x5fcf013d, }, 20 }, + { "gfxterm_ch", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x1c229a1a, 0x83752c05, 0x1c229a1a, 0x727401d, 0xdd28f52b, 0xdd28f52b, 0x4b4f5d0, 0x4b4f5d0, 0x4b4f5d0, 0x25880c34, 0x25880c34, 0x25880c34, 0x5830c7b8, 0x5830c7b8, 0x5830c7b8, 0xdd28f52b, 0x727401d, 0x727401d, 0xdd28f52b, }, 20 }, + { "gfxterm_ch", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x4d69e76c, 0x11e8d41f, 0x4d69e76c, 0xb2d6fcec, 0x43d1f34, 0x43d1f34, 0x15b4256, 0x15b4256, 0x15b4256, 0x7e51ebfe, 0x7e51ebfe, 0x7e51ebfe, 0xe700ee78, 0xe700ee78, 0xe700ee78, 0x43d1f34, 0xb2d6fcec, 0xb2d6fcec, 0x43d1f34, }, 20 }, + { "gfxterm_red", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0xecc0313, 0x6803ef90, 0xecc0313, 0x59e1bdcd, 0x59c36f00, 0x59c36f00, 0xbaf5c463, 0xbaf5c463, 0xbaf5c463, 0xc475a905, 0xc475a905, 0xc475a905, 0xa683bcd7, 0xa683bcd7, 0xa683bcd7, 0x59c36f00, 0x59e1bdcd, 0x59e1bdcd, 0x59c36f00, }, 20 }, + { "gfxterm_red", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0xfb839522, 0x5fa9129a, 0xfb839522, 0x4b244f74, 0xaa4593fe, 0xaa4593fe, 0xf644f45d, 0xf644f45d, 0xf644f45d, 0x50b1f93a, 0x50b1f93a, 0x50b1f93a, 0x7d895242, 0x7d895242, 0x7d895242, 0xaa4593fe, 0x4b244f74, 0x4b244f74, 0xaa4593fe, }, 20 }, + { "gfxterm_red", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xf84fee63, 0x42c3b1bb, 0xf84fee63, 0xe86af0cd, 0xc9cbf769, 0xc9cbf769, 0x93e5d13b, 0x93e5d13b, 0x93e5d13b, 0x6d3d10f7, 0x6d3d10f7, 0x6d3d10f7, 0x8477afff, 0x8477afff, 0x8477afff, 0xc9cbf769, 0xe86af0cd, 0xe86af0cd, 0xc9cbf769, }, 20 }, + { "gfxterm_red", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0xcbed2522, 0x784d2c15, 0xcbed2522, 0xfb9cd90d, 0x9813a416, 0x9813a416, 0x94668b23, 0x94668b23, 0x94668b23, 0x5bd0d10, 0x5bd0d10, 0x5bd0d10, 0x1c0730c0, 0x1c0730c0, 0x1c0730c0, 0x9813a416, 0xfb9cd90d, 0xfb9cd90d, 0x9813a416, }, 20 }, + { "gfxterm_red", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0xc1ca0a91, 0xd13c11f0, 0xc1ca0a91, 0x6fcde564, 0x5fcf013d, 0x5fcf013d, 0xb6cdf7a2, 0xb6cdf7a2, 0xb6cdf7a2, 0x64ddefd4, 0x64ddefd4, 0x64ddefd4, 0x72aed04b, 0x72aed04b, 0x72aed04b, 0x5fcf013d, 0x6fcde564, 0x6fcde564, 0x5fcf013d, }, 20 }, + { "gfxterm_red", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xca477228, 0x9e3fd6f6, 0xca477228, 0x4423b9f2, 0xdd28f52b, 0xdd28f52b, 0x1ff53543, 0x1ff53543, 0x1ff53543, 0x3ec9cca7, 0x3ec9cca7, 0x3ec9cca7, 0x4371072b, 0x4371072b, 0x4371072b, 0xdd28f52b, 0x4423b9f2, 0x4423b9f2, 0xdd28f52b, }, 20 }, + { "gfxterm_red", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0xfe345ca6, 0x55a58b1b, 0xfe345ca6, 0x696cda06, 0x43d1f34, 0x43d1f34, 0x72d541bf, 0x72d541bf, 0x72d541bf, 0xddfe817, 0xddfe817, 0xddfe817, 0x948eed91, 0x948eed91, 0x948eed91, 0x43d1f34, 0x696cda06, 0x696cda06, 0x43d1f34, }, 20 }, + { "gfxterm_high", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x4cfdf9ab, 0x2a321528, 0x4cfdf9ab, 0xf4b75661, 0x59c36f00, 0x59c36f00, 0xd3548a15, 0xd3548a15, 0xd3548a15, 0xadd4e773, 0xadd4e773, 0xadd4e773, 0xcf22f2a1, 0xcf22f2a1, 0xcf22f2a1, 0x59c36f00, 0xf4b75661, 0xf4b75661, 0x59c36f00, }, 20 }, + { "gfxterm_high", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x287ff948, 0x8c557ef0, 0x287ff948, 0xebf931c7, 0xaa4593fe, 0xaa4593fe, 0x7d5e4ea7, 0x7d5e4ea7, 0x7d5e4ea7, 0xdbab43c0, 0xdbab43c0, 0xdbab43c0, 0xf693e8b8, 0xf693e8b8, 0xf693e8b8, 0xaa4593fe, 0xebf931c7, 0xebf931c7, 0xaa4593fe, }, 20 }, + { "gfxterm_high", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x5ecea36b, 0xe442fcb3, 0x5ecea36b, 0x1cab5f56, 0xc9cbf769, 0xc9cbf769, 0x7c3c68c, 0x7c3c68c, 0x7c3c68c, 0xf91b0740, 0xf91b0740, 0xf91b0740, 0x1051b848, 0x1051b848, 0x1051b848, 0xc9cbf769, 0x1cab5f56, 0x1cab5f56, 0xc9cbf769, }, 20 }, + { "gfxterm_high", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0xf6c7d73a, 0x4567de0d, 0xf6c7d73a, 0xb8d47573, 0x9813a416, 0x9813a416, 0x60ef8d73, 0x60ef8d73, 0x60ef8d73, 0xf1340b40, 0xf1340b40, 0xf1340b40, 0xe88e3690, 0xe88e3690, 0xe88e3690, 0x9813a416, 0xb8d47573, 0xb8d47573, 0x9813a416, }, 20 }, + { "gfxterm_high", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x56e3bddb, 0x4615a6ba, 0x56e3bddb, 0xc585b2ec, 0x5fcf013d, 0x5fcf013d, 0x6f5971e2, 0x6f5971e2, 0x6f5971e2, 0xbd496994, 0xbd496994, 0xbd496994, 0xab3a560b, 0xab3a560b, 0xab3a560b, 0x5fcf013d, 0xc585b2ec, 0xc585b2ec, 0x5fcf013d, }, 20 }, + { "gfxterm_high", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x5ebfa46, 0x51935e98, 0x5ebfa46, 0xe26d3e18, 0xdd28f52b, 0xdd28f52b, 0xda805056, 0xda805056, 0xda805056, 0xfbbca9b2, 0xfbbca9b2, 0xfbbca9b2, 0x8604623e, 0x8604623e, 0x8604623e, 0xdd28f52b, 0xe26d3e18, 0xe26d3e18, 0xdd28f52b, }, 20 }, + { "gfxterm_high", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x4995beac, 0xe2046911, 0x4995beac, 0x311de003, 0x43d1f34, 0x43d1f34, 0x9a133a7f, 0x9a133a7f, 0x9a133a7f, 0xe51993d7, 0xe51993d7, 0xe51993d7, 0x7c489651, 0x7c489651, 0x7c489651, 0x43d1f34, 0x311de003, 0x311de003, 0x43d1f34, }, 20 }, + { "videotest", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x1368a483, 0x1368a483, 0x1368a483, 0x1368a483, 0x1368a483, }, 5 }, + { "videotest", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0x7033079c, 0x7033079c, 0x7033079c, 0x7033079c, 0x7033079c, }, 5 }, + { "videotest", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xff583fbf, 0xff583fbf, 0xff583fbf, 0xff583fbf, 0xff583fbf, }, 5 }, + { "videotest", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x4c2cef83, 0x1b215a88, 0xe2378595, 0xb53a309e, 0x15f64d5e, }, 5 }, + { "videotest", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x758f388c, 0xd4442397, 0x33f5784b, 0x923e6350, 0xf97bb902, }, 5 }, + { "videotest", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xb9f6f52a, 0x4e24e8b7, 0x53beb8e1, 0xa46ca57c, 0x688a184d, }, 5 }, + { "videotest", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x5bd98ce3, 0x15df7962, 0xc7d467e1, 0x89d29260, 0x662e2c16, }, 5 }, + { "videotest", 640, 480, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi256 */, (grub_uint32_t []) { 0xf9847b65, 0xf9847b65, 0xf9847b65, 0xf9847b65, 0xf9847b65, }, 5 }, + { "videotest", 800, 600, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi256 */, (grub_uint32_t []) { 0xc421716d, 0xc421716d, 0xc421716d, 0xc421716d, 0xc421716d, }, 5 }, + { "videotest", 1024, 768, 0x2, 256, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi256 */, (grub_uint32_t []) { 0x5d46f2a8, 0x5d46f2a8, 0x5d46f2a8, 0x5d46f2a8, 0x5d46f2a8, }, 5 }, + { "videotest", 640, 480, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 640x480xrgba5550 */, (grub_uint32_t []) { 0x25690db2, 0x25690db2, 0x25690db2, 0x25690db2, 0x25690db2, }, 5 }, + { "videotest", 800, 600, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 800x600xrgba5550 */, (grub_uint32_t []) { 0x7333f220, 0x7333f220, 0x7333f220, 0x7333f220, 0x7333f220, }, 5 }, + { "videotest", 1024, 768, 0x1, 256, 15, 2, 10, 5, 5, 5, 0, 5, 0, 0 /* 1024x768xrgba5550 */, (grub_uint32_t []) { 0xac52d537, 0xac52d537, 0xac52d537, 0xac52d537, 0xac52d537, }, 5 }, + { "videotest", 640, 480, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 640x480xrgba5650 */, (grub_uint32_t []) { 0xd4cbcd66, 0xd4cbcd66, 0xd4cbcd66, 0xd4cbcd66, 0xd4cbcd66, }, 5 }, + { "videotest", 800, 600, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 800x600xrgba5650 */, (grub_uint32_t []) { 0x9d23f9d1, 0x9d23f9d1, 0x9d23f9d1, 0x9d23f9d1, 0x9d23f9d1, }, 5 }, + { "videotest", 1024, 768, 0x1, 256, 16, 2, 11, 5, 5, 6, 0, 5, 0, 0 /* 1024x768xrgba5650 */, (grub_uint32_t []) { 0x89acbf88, 0x89acbf88, 0x89acbf88, 0x89acbf88, 0x89acbf88, }, 5 }, + { "videotest", 640, 480, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 640x480xrgba8880 */, (grub_uint32_t []) { 0x335fadcb, 0x1f517b5c, 0x6b4200e5, 0x474cd672, 0x8364f797, }, 5 }, + { "videotest", 800, 600, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 800x600xrgba8880 */, (grub_uint32_t []) { 0xcf9985f8, 0x1d92c7fc, 0x6e637701, 0xbc683505, 0x898016fb, }, 5 }, + { "videotest", 1024, 768, 0x1, 256, 24, 3, 16, 8, 8, 8, 0, 8, 0, 0 /* 1024x768xrgba8880 */, (grub_uint32_t []) { 0xdb824190, 0x378d05dc, 0x670bff9, 0xea7ffbb5, 0x658bcbb3, }, 5 }, + { "videotest", 640, 480, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 640x480xbgra5550 */, (grub_uint32_t []) { 0x18ed532e, 0x18ed532e, 0x18ed532e, 0x18ed532e, 0x18ed532e, }, 5 }, + { "videotest", 800, 600, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 800x600xbgra5550 */, (grub_uint32_t []) { 0x2b35b09f, 0x2b35b09f, 0x2b35b09f, 0x2b35b09f, 0x2b35b09f, }, 5 }, + { "videotest", 1024, 768, 0x1, 256, 15, 2, 0, 5, 5, 5, 10, 5, 0, 0 /* 1024x768xbgra5550 */, (grub_uint32_t []) { 0xa24c4d98, 0xa24c4d98, 0xa24c4d98, 0xa24c4d98, 0xa24c4d98, }, 5 }, + { "videotest", 640, 480, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 640x480xbgra5650 */, (grub_uint32_t []) { 0xc07dde33, 0xc07dde33, 0xc07dde33, 0xc07dde33, 0xc07dde33, }, 5 }, + { "videotest", 800, 600, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 800x600xbgra5650 */, (grub_uint32_t []) { 0x7e6ed757, 0x7e6ed757, 0x7e6ed757, 0x7e6ed757, 0x7e6ed757, }, 5 }, + { "videotest", 1024, 768, 0x1, 256, 16, 2, 0, 5, 5, 6, 11, 5, 0, 0 /* 1024x768xbgra5650 */, (grub_uint32_t []) { 0x700255dd, 0x700255dd, 0x700255dd, 0x700255dd, 0x700255dd, }, 5 }, + { "videotest", 640, 480, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 640x480xbgra8880 */, (grub_uint32_t []) { 0x157232bd, 0x5e6bdacd, 0x8341e25d, 0xc8580a2d, 0x3cf9e58c, }, 5 }, + { "videotest", 800, 600, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 800x600xbgra8880 */, (grub_uint32_t []) { 0xbfafd7cd, 0x51650951, 0x67d61c04, 0x891cc298, 0xab036ae, }, 5 }, + { "videotest", 1024, 768, 0x1, 256, 24, 3, 0, 8, 8, 8, 16, 8, 0, 0 /* 1024x768xbgra8880 */, (grub_uint32_t []) { 0x760580c9, 0xdc6d8205, 0x2739f3a0, 0x8d51f16c, 0xd47d661b, }, 5 }, + { "videotest", 640, 480, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 640x480xbgra8888 */, (grub_uint32_t []) { 0xada3b5f, 0x24cd61a6, 0x56f48ead, 0x78e3d454, 0xb28750bb, }, 5 }, + { "videotest", 800, 600, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 800x600xbgra8888 */, (grub_uint32_t []) { 0x827694e2, 0x9d97c3dd, 0xbdb43a9c, 0xa2556da3, 0xfdf3c81e, }, 5 }, + { "videotest", 1024, 768, 0x1, 256, 32, 4, 0, 8, 8, 8, 16, 8, 24, 8 /* 1024x768xbgra8888 */, (grub_uint32_t []) { 0x664534a5, 0xcd0979a0, 0x3531d85e, 0x9e7d955b, 0xc0aced53, }, 5 }, From f2b54835f2e0aa068f82fec99edad671d5f46c08 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Tue, 5 Jan 2016 12:47:30 +0100 Subject: [PATCH 596/722] Disable progress indicator in grub-shell. This disables progress indicator for tests. This in turn fixes test flakiness as they ended up timing-dependent. --- grub-core/lib/progress.c | 6 ++++++ tests/util/grub-shell.in | 2 ++ 2 files changed, 8 insertions(+) diff --git a/grub-core/lib/progress.c b/grub-core/lib/progress.c index 95a4a6281..4b7cbbca6 100644 --- a/grub-core/lib/progress.c +++ b/grub-core/lib/progress.c @@ -38,11 +38,17 @@ grub_file_progress_hook_real (grub_disk_addr_t sector __attribute__ ((unused)), grub_uint64_t now; static grub_uint64_t last_progress_update_time; grub_file_t file = data; + const char *e; file->progress_offset += length; if (call_depth) return; + e = grub_env_get ("enable_progress_indicator"); + if (e && e[0] == '0') { + return; + } + call_depth = 1; now = grub_get_time_ms (); diff --git a/tests/util/grub-shell.in b/tests/util/grub-shell.in index 6d2b1327e..31a1f294d 100644 --- a/tests/util/grub-shell.in +++ b/tests/util/grub-shell.in @@ -289,6 +289,8 @@ fi cfgfile=`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"` || exit 1 cat <${cfgfile} grubshell=yes +enable_progress_indicator=0 +export enable_progress_indicator EOF From 3f430a0126ae36ec0750125bd498194fa56cc615 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Tue, 5 Jan 2016 12:49:12 +0100 Subject: [PATCH 597/722] Move file loading functions to grub-emu. So that we can use it in grub-emu as well as utils. --- grub-core/kern/emu/misc.c | 48 +++++++++++++++++++++++++++++++++++++++ util/misc.c | 48 --------------------------------------- 2 files changed, 48 insertions(+), 48 deletions(-) diff --git a/grub-core/kern/emu/misc.c b/grub-core/kern/emu/misc.c index bb606da28..06985013d 100644 --- a/grub-core/kern/emu/misc.c +++ b/grub-core/kern/emu/misc.c @@ -149,3 +149,51 @@ grub_get_time_ms (void) return (tv.tv_sec * 1000 + tv.tv_usec / 1000); } + +size_t +grub_util_get_image_size (const char *path) +{ + FILE *f; + size_t ret; + off_t sz; + + f = grub_util_fopen (path, "rb"); + + if (!f) + grub_util_error (_("cannot open `%s': %s"), path, strerror (errno)); + + fseeko (f, 0, SEEK_END); + + sz = ftello (f); + if (sz < 0) + grub_util_error (_("cannot open `%s': %s"), path, strerror (errno)); + if (sz != (size_t) sz) + grub_util_error (_("file `%s' is too big"), path); + ret = (size_t) sz; + + fclose (f); + + return ret; +} + +void +grub_util_load_image (const char *path, char *buf) +{ + FILE *fp; + size_t size; + + grub_util_info ("reading %s", path); + + size = grub_util_get_image_size (path); + + fp = grub_util_fopen (path, "rb"); + if (! fp) + grub_util_error (_("cannot open `%s': %s"), path, + strerror (errno)); + + if (fread (buf, 1, size, fp) != size) + grub_util_error (_("cannot read `%s': %s"), path, + strerror (errno)); + + fclose (fp); +} diff --git a/util/misc.c b/util/misc.c index b8ec69108..d545212d9 100644 --- a/util/misc.c +++ b/util/misc.c @@ -74,32 +74,6 @@ grub_util_get_path (const char *dir, const char *file) return path; } -size_t -grub_util_get_image_size (const char *path) -{ - FILE *f; - size_t ret; - off_t sz; - - f = grub_util_fopen (path, "rb"); - - if (!f) - grub_util_error (_("cannot open `%s': %s"), path, strerror (errno)); - - fseeko (f, 0, SEEK_END); - - sz = ftello (f); - if (sz < 0) - grub_util_error (_("cannot open `%s': %s"), path, strerror (errno)); - if (sz != (size_t) sz) - grub_util_error (_("file `%s' is too big"), path); - ret = (size_t) sz; - - fclose (f); - - return ret; -} - char * grub_util_read_image (const char *path) { @@ -126,28 +100,6 @@ grub_util_read_image (const char *path) return img; } -void -grub_util_load_image (const char *path, char *buf) -{ - FILE *fp; - size_t size; - - grub_util_info ("reading %s", path); - - size = grub_util_get_image_size (path); - - fp = grub_util_fopen (path, "rb"); - if (! fp) - grub_util_error (_("cannot open `%s': %s"), path, - strerror (errno)); - - if (fread (buf, 1, size, fp) != size) - grub_util_error (_("cannot read `%s': %s"), path, - strerror (errno)); - - fclose (fp); -} - void grub_util_write_image_at (const void *img, size_t size, off_t offset, FILE *out, const char *name) From f86fd54cf08cc5d0fb62766f98cc86e3ae4c741e Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Tue, 5 Jan 2016 12:59:44 +0100 Subject: [PATCH 598/722] Add memdisk support to grub-emu. Use it to add custom files, so that tests which need them work. --- grub-core/kern/emu/main.c | 42 ++++++++++++++++++++++++++++++++++++++- tests/util/grub-shell.in | 11 +++++++--- 2 files changed, 49 insertions(+), 4 deletions(-) diff --git a/grub-core/kern/emu/main.c b/grub-core/kern/emu/main.c index 4b509139c..51e8a5715 100644 --- a/grub-core/kern/emu/main.c +++ b/grub-core/kern/emu/main.c @@ -86,11 +86,16 @@ grub_machine_fini (int flags) +#define OPT_MEMDISK 257 + static struct argp_option options[] = { {"root", 'r', N_("DEVICE_NAME"), 0, N_("Set root device."), 2}, {"device-map", 'm', N_("FILE"), 0, /* TRANSLATORS: There are many devices in device map. */ N_("use FILE as the device map [default=%s]"), 0}, + {"memdisk", OPT_MEMDISK, N_("FILE"), 0, + /* TRANSLATORS: There are many devices in device map. */ + N_("use FILE as memdisk"), 0}, {"directory", 'd', N_("DIR"), 0, N_("use GRUB files in the directory DIR [default=%s]"), 0}, {"verbose", 'v', 0, 0, N_("print verbose messages."), 0}, @@ -119,6 +124,7 @@ help_filter (int key, const char *text, void *input __attribute__ ((unused))) struct arguments { const char *dev_map; + const char *mem_disk; int hold; }; @@ -131,6 +137,9 @@ argp_parser (int key, char *arg, struct argp_state *state) switch (key) { + case OPT_MEMDISK: + arguments->mem_disk = arg; + break; case 'r': free (root_dev); root_dev = xstrdup (arg); @@ -180,9 +189,13 @@ main (int argc, char *argv[]) struct arguments arguments = { .dev_map = DEFAULT_DEVICE_MAP, - .hold = 0 + .hold = 0, + .mem_disk = 0, }; volatile int hold = 0; + size_t total_module_size = sizeof (struct grub_module_info), memdisk_size = 0; + struct grub_module_info *modinfo; + char *mods; grub_util_host_init (&argc, &argv); @@ -194,6 +207,33 @@ main (int argc, char *argv[]) exit(1); } + if (arguments.mem_disk) + { + memdisk_size = ALIGN_UP(grub_util_get_image_size (arguments.mem_disk), 512); + total_module_size += memdisk_size + sizeof (struct grub_module_header); + } + + mods = xmalloc (total_module_size); + modinfo = grub_memset (mods, 0, total_module_size); + mods = (char *) (modinfo + 1); + + modinfo->magic = GRUB_MODULE_MAGIC; + modinfo->offset = sizeof (struct grub_module_info); + modinfo->size = total_module_size; + + if (arguments.mem_disk) + { + struct grub_module_header *header = (struct grub_module_header *) mods; + header->type = OBJ_TYPE_MEMDISK; + header->size = memdisk_size + sizeof (*header); + mods += sizeof (*header); + + grub_util_load_image (arguments.mem_disk, mods); + mods += memdisk_size; + } + + grub_modbase = (grub_addr_t) modinfo; + hold = arguments.hold; /* Wait until the ARGS.HOLD variable is cleared by an attached debugger. */ if (hold && verbosity > 0) diff --git a/tests/util/grub-shell.in b/tests/util/grub-shell.in index 31a1f294d..884c823d8 100644 --- a/tests/util/grub-shell.in +++ b/tests/util/grub-shell.in @@ -449,7 +449,8 @@ if [ x$boot = xnet ]; then [ -z "$files" ] || copy_extra_files "$netdir" $files timeout -s KILL $timeout "${qemu}" ${qemuopts} ${serial_null} -serial file:/dev/stdout -boot n -net "user,tftp=$netdir,bootfile=/boot/grub/${grub_modinfo_target_cpu}-${grub_modinfo_platform}/core.$netbootext" -net nic | cat | tr -d "\r" | do_trim elif [ x$boot = xemu ]; then - grubdir="$(mktemp -d "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX")" + rootdir="$(mktemp -d "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX")" + grubdir="$rootdir/boot/grub" mkdir -p "$grubdir/fonts" mkdir -p "$grubdir/themes" mkdir -p "$grubdir/locale" @@ -462,8 +463,12 @@ elif [ x$boot = xemu ]; then done cp "${cfgfile}" "$grubdir/grub.cfg" cp "${source}" "$grubdir/testcase.cfg" - @builddir@/grub-core/grub-emu -m "$device_map" -d "$grubdir" | tr -d "\r" | do_trim - rm -rf "$grubdir" + [ -z "$files" ] || copy_extra_files "$rootdir" $files + roottar="$(mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX")" + (cd "$rootdir"; tar cf "$roottar" .) + @builddir@/grub-core/grub-emu -m "$device_map" --memdisk "$roottar" -r memdisk -d "/boot/grub" | tr -d "\r" | do_trim + test -n "$debug" || rm -rf "$rootdir" + test -n "$debug" || rm -f "$roottar" else timeout -s KILL $timeout "${qemu}" ${qemuopts} ${serial_null} -serial file:/dev/stdout -${device}"${isofile}" ${bootdev} | cat | tr -d "\r" | do_trim fi From 9f8f9e62afc4f14802d6bd6bb69719bbc245a8c2 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Tue, 5 Jan 2016 16:36:21 +0100 Subject: [PATCH 599/722] minixfs_test: Check if mkfs.minixfs supports -B option. --- tests/minixfs_test.in | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/minixfs_test.in b/tests/minixfs_test.in index 8075ba890..1784b1261 100644 --- a/tests/minixfs_test.in +++ b/tests/minixfs_test.in @@ -16,10 +16,20 @@ if ! which mkfs.minix >/dev/null 2>&1; then fi if ! mkfs.minix -h | grep -- -v > /dev/null; then + echo "mkfs.minix doesn't support minix2fs; cannot test minix*fs." + exit 77 +fi + +if ! mkfs.minix -h | grep -- -3 > /dev/null; then echo "mkfs.minix doesn't support minix3fs; cannot test minix*fs." exit 77 fi +if ! mkfs.minix -h | grep -- -B > /dev/null; then + echo "mkfs.minix doesn't support variable block size; cannot test minix*fs." + exit 77 +fi + "@builddir@/grub-fs-tester" minix "@builddir@/grub-fs-tester" minix2 "@builddir@/grub-fs-tester" minix3 From 716c9f2675e27949fb9ff13a76736d9330503b32 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Thu, 7 Jan 2016 15:51:03 +0100 Subject: [PATCH 600/722] Adjust bootcheck tests for multiboot/coreboot/qemu to match real support. coreboot has ACPI while 2 others don't. *BSD need ACPI and have trouble without it. Don't even attempt to boot *BSD on multiboot or qemu targets. On coreboot boot all *BSD except 32-bit NetBSD which apparently does some early BIOS calls. --- Makefile.am | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/Makefile.am b/Makefile.am index 3872b220c..a3719458e 100644 --- a/Makefile.am +++ b/Makefile.am @@ -353,25 +353,25 @@ BOOTCHECKS = bootcheck-kfreebsd-aout bootcheck-kopenbsd-i386 bootcheck-kopenbsd- endif if COND_i386_multiboot -# FreeBSD requires ACPI -BOOTCHECKS = bootcheck-kfreebsd-aout bootcheck-kopenbsd-i386 bootcheck-kopenbsd-x86_64 bootcheck-multiboot bootcheck-multiboot2 bootcheck-linux-i386 bootcheck-linux-x86_64 bootcheck-knetbsd-x86_64 +# *BSD requires ACPI +BOOTCHECKS = bootcheck-kfreebsd-aout bootcheck-multiboot bootcheck-multiboot2 bootcheck-linux-i386 bootcheck-linux-x86_64 +endif + + +if COND_i386_qemu +# *BSD requires ACPI +BOOTCHECKS = bootcheck-kfreebsd-aout bootcheck-multiboot bootcheck-multiboot2 bootcheck-linux-i386 bootcheck-linux-x86_64 endif if COND_i386_coreboot -# Freebsd requires ACPI -BOOTCHECKS = bootcheck-kfreebsd-aout bootcheck-kopenbsd-i386 bootcheck-kopenbsd-x86_64 bootcheck-multiboot bootcheck-multiboot2 bootcheck-linux-i386 bootcheck-linux-x86_64 bootcheck-knetbsd-x86_64 -endif - -if COND_i386_qemu -# FreeBSD requires ACPI -BOOTCHECKS = bootcheck-kfreebsd-aout bootcheck-kopenbsd-i386 bootcheck-kopenbsd-x86_64 bootcheck-multiboot bootcheck-multiboot2 bootcheck-linux-i386 bootcheck-linux-x86_64 bootcheck-knetbsd-x86_64 +BOOTCHECKS = bootcheck-kfreebsd-aout bootcheck-kopenbsd-i386 bootcheck-kopenbsd-x86_64 bootcheck-multiboot bootcheck-multiboot2 bootcheck-linux-i386 bootcheck-linux-x86_64 bootcheck-knetbsd-x86_64 bootcheck-kfreebsd-x86_64 bootcheck-kfreebsd-i386 endif if COND_i386_pc #pc chainloader by definition is only for i386-pc #ntldr and bootmgr require BIOS. -#legacy protocol makes early BIOS calls. -# NetBSD crashes early on non-BIOS +#legacy protocol (linux16) makes early BIOS calls. +# 32-bit NetBSD crashes early on non-BIOS BOOTCHECKS = bootcheck-kfreebsd-aout bootcheck-kopenbsd-i386 bootcheck-kopenbsd-x86_64 bootcheck-multiboot bootcheck-multiboot2 bootcheck-linux-i386 bootcheck-linux-x86_64 bootcheck-knetbsd-x86_64 bootcheck-kfreebsd-x86_64 bootcheck-kfreebsd-i386 bootcheck-pc-chainloader bootcheck-ntldr bootcheck-linux16-i386 bootcheck-linux16-x86_64 bootcheck-knetbsd-i386 endif From 607d66116a67e5a13eb0d46076f26dedc988e6a4 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Thu, 7 Jan 2016 15:53:42 +0100 Subject: [PATCH 601/722] iee1275/datetime: Fix off-by-1 error. --- grub-core/lib/ieee1275/datetime.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/grub-core/lib/ieee1275/datetime.c b/grub-core/lib/ieee1275/datetime.c index 74578f15a..b81fba2ed 100644 --- a/grub-core/lib/ieee1275/datetime.c +++ b/grub-core/lib/ieee1275/datetime.c @@ -95,7 +95,7 @@ grub_get_datetime (struct grub_datetime *datetime) datetime->year = args.year; datetime->month = args.month; - datetime->day = args.day; + datetime->day = args.day + 1; datetime->hour = args.hour; datetime->minute = args.minute; datetime->second = args.second; @@ -140,7 +140,7 @@ grub_set_datetime (struct grub_datetime *datetime) args.year = datetime->year; args.month = datetime->month; - args.day = datetime->day; + args.day = datetime->day - 1; args.hour = datetime->hour; args.minute = datetime->minute; args.second = datetime->second; From 86e3b4ba1af430c8d58598876b714eb99c5f535f Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Thu, 7 Jan 2016 15:54:06 +0100 Subject: [PATCH 602/722] hddboot_test: reenable on OVMF OVMF now supports booting from disks. --- tests/hddboot_test.in | 3 --- 1 file changed, 3 deletions(-) diff --git a/tests/hddboot_test.in b/tests/hddboot_test.in index 2cbbf97ec..c229716a6 100644 --- a/tests/hddboot_test.in +++ b/tests/hddboot_test.in @@ -29,9 +29,6 @@ case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in # FIXME: currently grub-shell uses only -kernel for loongson mipsel-loongson) exit 0;; - # FIXME: OVMF skips HDDs for automatic boot and has no USB support - *-efi) - exit 0;; esac if [ "$(echo hello | "${grubshell}" --boot=hd)" != "Hello World" ]; then From 44876dd64e75b47f99d574bc3db1c87db670645c Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Thu, 7 Jan 2016 15:54:42 +0100 Subject: [PATCH 603/722] grub-shell: On i386-ieee1275 don't try to switch to console. console goes to serial as well, so this doesn't stop garbage from going to serial. But it creates garbage itself. --- tests/util/grub-shell.in | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/util/grub-shell.in b/tests/util/grub-shell.in index 884c823d8..040ef04cd 100644 --- a/tests/util/grub-shell.in +++ b/tests/util/grub-shell.in @@ -331,7 +331,8 @@ cat <>${cfgfile} source "\$prefix/testcase.cfg" # Stop serial output to suppress "ACPI shutdown failed" error. EOF -if [ x$console != x ]; then +# Attempt to switch to console on i386-ieee1275 causes "screen not found" message +if [ x$console != x ] && [ x"${grub_modinfo_target_cpu}-${grub_modinfo_platform}" != xi386-ieee1275 ]; then echo "terminal_output $console" >>${cfgfile} fi echo "${halt_cmd}" >>${cfgfile} From db5eb6225dddaaa90e2e54642f31ca14fadf145b Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Thu, 7 Jan 2016 15:55:45 +0100 Subject: [PATCH 604/722] grub-shell: Use new cbfstool syntax. --- tests/util/grub-shell.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/util/grub-shell.in b/tests/util/grub-shell.in index 040ef04cd..8f475cd58 100644 --- a/tests/util/grub-shell.in +++ b/tests/util/grub-shell.in @@ -402,7 +402,7 @@ fi if [ x$boot = xcoreboot ]; then imgfile=`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"` || exit 1 cp "${GRUB_COREBOOT_ROM}" "${imgfile}" - "${GRUB_CBFSTOOL}" "${imgfile}" add-payload "${rom_directory}/coreboot.elf" fallback/payload + "${GRUB_CBFSTOOL}" "${imgfile}" add-payload -f "${rom_directory}/coreboot.elf" -n fallback/payload bootdev="-bios ${imgfile}" device="cdrom " test -z "$debug" || echo "Coreboot image: ${imgfile}" >&2 From 06c94739a57f9241868fe76d8e0a797eb547540a Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Thu, 7 Jan 2016 19:26:45 +0100 Subject: [PATCH 605/722] Disable NetBSD bootcheck on EFI until it supports ACPI on EFI. --- Makefile.am | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Makefile.am b/Makefile.am index a3719458e..70a8af873 100644 --- a/Makefile.am +++ b/Makefile.am @@ -345,11 +345,13 @@ bootcheck-ntldr: ntldr.bin $(srcdir)/grub-core/tests/boot/ntldr.cfg grub-shell ./grub-shell --timeout=$(BOOTCHECK_TIMEOUT) --qemu=$(QEMU32) --files=/ntldr.bin=ntldr.bin $(srcdir)/grub-core/tests/boot/ntldr.cfg | grep $(SUCCESSFUL_BOOT_STRING) > /dev/null if COND_i386_efi -BOOTCHECKS = bootcheck-kfreebsd-aout bootcheck-kopenbsd-i386 bootcheck-kopenbsd-x86_64 bootcheck-multiboot bootcheck-multiboot2 bootcheck-linux-i386 bootcheck-linux-x86_64 bootcheck-knetbsd-x86_64 bootcheck-kfreebsd-x86_64 bootcheck-kfreebsd-i386 +# NetBSD has no support for finding ACPI on EFI +BOOTCHECKS = bootcheck-kfreebsd-aout bootcheck-kopenbsd-i386 bootcheck-kopenbsd-x86_64 bootcheck-multiboot bootcheck-multiboot2 bootcheck-linux-i386 bootcheck-linux-x86_64 bootcheck-kfreebsd-x86_64 bootcheck-kfreebsd-i386 endif if COND_x86_64_efi -BOOTCHECKS = bootcheck-kfreebsd-aout bootcheck-kopenbsd-i386 bootcheck-kopenbsd-x86_64 bootcheck-multiboot bootcheck-multiboot2 bootcheck-linux-i386 bootcheck-linux-x86_64 bootcheck-knetbsd-x86_64 bootcheck-kfreebsd-x86_64 bootcheck-kfreebsd-i386 +# NetBSD has no support for finding ACPI on EFI +BOOTCHECKS = bootcheck-kfreebsd-aout bootcheck-kopenbsd-i386 bootcheck-kopenbsd-x86_64 bootcheck-multiboot bootcheck-multiboot2 bootcheck-linux-i386 bootcheck-linux-x86_64 bootcheck-kfreebsd-x86_64 bootcheck-kfreebsd-i386 endif if COND_i386_multiboot From 6e4174f6f9197619baa41ddc7d718f3c634f0aab Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Thu, 7 Jan 2016 19:27:56 +0100 Subject: [PATCH 606/722] arm64: Disable tests that need native drivers. --- tests/ahci_test.in | 2 +- tests/ehci_test.in | 2 +- tests/ohci_test.in | 2 +- tests/pata_test.in | 2 +- tests/uhci_test.in | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/ahci_test.in b/tests/ahci_test.in index e7d26ac07..40441768e 100644 --- a/tests/ahci_test.in +++ b/tests/ahci_test.in @@ -30,7 +30,7 @@ case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in mips*-arc | mips*-qemu_mips) exit 0;; # FIXME: No native drivers are available for those - powerpc-ieee1275 | sparc64-ieee1275) + powerpc-ieee1275 | sparc64-ieee1275 | arm64-efi) exit 0;; esac diff --git a/tests/ehci_test.in b/tests/ehci_test.in index 5cfe726df..8de56ee98 100644 --- a/tests/ehci_test.in +++ b/tests/ehci_test.in @@ -30,7 +30,7 @@ case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in mips*-arc | mips*-qemu_mips) exit 0;; # FIXME: No native drivers are available for those - powerpc-ieee1275 | sparc64-ieee1275) + powerpc-ieee1275 | sparc64-ieee1275 | arm64-efi) exit 0;; esac diff --git a/tests/ohci_test.in b/tests/ohci_test.in index f841bd25c..da517629f 100644 --- a/tests/ohci_test.in +++ b/tests/ohci_test.in @@ -30,7 +30,7 @@ case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in mips*-arc | mips*-qemu_mips) exit 0;; # FIXME: No native drivers are available for those - powerpc-ieee1275 | sparc64-ieee1275) + powerpc-ieee1275 | sparc64-ieee1275 | arm64-efi) exit 0;; esac diff --git a/tests/pata_test.in b/tests/pata_test.in index 07d17b781..4bf644fe6 100644 --- a/tests/pata_test.in +++ b/tests/pata_test.in @@ -30,7 +30,7 @@ case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in *-arc) exit 0;; # FIXME: No native drivers are available for those - powerpc-ieee1275 | sparc64-ieee1275) + powerpc-ieee1275 | sparc64-ieee1275 | arm64-efi) exit 0;; i386-ieee1275) disk=hdb diff --git a/tests/uhci_test.in b/tests/uhci_test.in index 3dea51c01..5ec503033 100644 --- a/tests/uhci_test.in +++ b/tests/uhci_test.in @@ -30,7 +30,7 @@ case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in mips*-arc | mips*-qemu_mips) exit 0;; # FIXME: No native drivers are available for those - powerpc-ieee1275 | sparc64-ieee1275) + powerpc-ieee1275 | sparc64-ieee1275 | arm64-efi) exit 0;; esac From 62328a95c9825fff749cd79a7ccc1060986ca7b2 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Thu, 7 Jan 2016 19:28:47 +0100 Subject: [PATCH 607/722] Allow GRUB_QEMU_OPTS to override machine. --- tests/util/grub-shell.in | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/util/grub-shell.in b/tests/util/grub-shell.in index 8f475cd58..c52c8c7eb 100644 --- a/tests/util/grub-shell.in +++ b/tests/util/grub-shell.in @@ -97,13 +97,13 @@ case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in mips-qemu_mips) boot=mips_qemu qemu=qemu-system-mips - qemuopts="$qemuopts -M mips" + qemuopts="-M mips $qemuopts" console=vga_text ;; mips-arc) boot=cd qemu=qemu-system-mips64 - qemuopts="$qemuopts -M indy" + qemuopts="-M indy $qemuopts" serial_port=arc/serial0/line0 console= trim=1 @@ -111,7 +111,7 @@ case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in mipsel-arc) boot=cd qemu=qemu-system-mips64el - qemuopts="$qemuopts -M magnum -no-reboot" + qemuopts="-M magnum $qemuopts -no-reboot" serial_port=arc/multi0/serial0 console=console halt_cmd=reboot @@ -120,13 +120,13 @@ case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in mipsel-qemu_mips) boot=mipsel_qemu qemu=qemu-system-mipsel - qemuopts="$qemuopts -M mips" + qemuopts="-M mips $qemuopts" console=vga_text ;; mipsel-loongson) boot=mipsel_fulong2e qemu=qemu-system-mips64el - qemuopts="$qemuopts -M fulong2e" + qemuopts="-M fulong2e $qemuopts" console= trim=1 ;; From a2dcab70f8df956c15bf13e7cc1b815b751b8c12 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Thu, 7 Jan 2016 19:29:53 +0100 Subject: [PATCH 608/722] x86_64-efi: Automatically add -bios OVMF.fd to qemu in tests. --- tests/util/grub-shell.in | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/util/grub-shell.in b/tests/util/grub-shell.in index c52c8c7eb..59061677d 100644 --- a/tests/util/grub-shell.in +++ b/tests/util/grub-shell.in @@ -170,6 +170,7 @@ case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in boot=cd console=console trim=1 + qemuopts="-bios OVMF.fd $qemuopts" ;; *) boot=hd From 7eb27a49e92623587f400ff58de3e9b1a31ba894 Mon Sep 17 00:00:00 2001 From: Mark Salter Date: Thu, 7 Jan 2016 20:53:41 +0100 Subject: [PATCH 609/722] arm-efi: Reduce timer event frequency by 10 Timer event to keep grub msec counter was running at 1000HZ. This was too fast for UEFI timer driver and resulted in a 10x slowdown in grub time versus wallclock. Reduce the timer event frequency and increase tick increment accordingly to keep better time. --- grub-core/kern/arm/efi/init.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/grub-core/kern/arm/efi/init.c b/grub-core/kern/arm/efi/init.c index 2572ca8b7..06df60e2f 100644 --- a/grub-core/kern/arm/efi/init.c +++ b/grub-core/kern/arm/efi/init.c @@ -38,7 +38,7 @@ static void increment_timer (grub_efi_event_t event __attribute__ ((unused)), void *context __attribute__ ((unused))) { - tmr++; + tmr += 10; } void @@ -52,7 +52,7 @@ grub_machine_init (void) efi_call_5 (b->create_event, GRUB_EFI_EVT_TIMER | GRUB_EFI_EVT_NOTIFY_SIGNAL, GRUB_EFI_TPL_CALLBACK, increment_timer, NULL, &tmr_evt); - efi_call_3 (b->set_timer, tmr_evt, GRUB_EFI_TIMER_PERIODIC, 10000); + efi_call_3 (b->set_timer, tmr_evt, GRUB_EFI_TIMER_PERIODIC, 100000); grub_install_get_time_ms (grub_efi_get_time_ms); } From 9efd79f376a873af14e380b7143efd2343bde24c Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Thu, 7 Jan 2016 21:02:53 +0100 Subject: [PATCH 610/722] grub-shell: Support arm64-efi --- tests/util/grub-shell.in | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/tests/util/grub-shell.in b/tests/util/grub-shell.in index 59061677d..cff597ea1 100644 --- a/tests/util/grub-shell.in +++ b/tests/util/grub-shell.in @@ -65,7 +65,7 @@ serial_port=com0 serial_null= halt_cmd=halt pseries=n -disk=hda +disk="hda " case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in *-emu) device_map=`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"` || exit 1 @@ -145,7 +145,7 @@ case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in qemu=qemu-system-i386 console=console trim=1 - disk=hdb + disk="hdb " ;; i386-qemu) boot=qemu @@ -164,6 +164,7 @@ case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in boot=cd console=console trim=1 + qemuopts="-bios OVMF32.fd $qemuopts" ;; x86_64-efi) qemu=qemu-system-x86_64 @@ -172,6 +173,15 @@ case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in trim=1 qemuopts="-bios OVMF.fd $qemuopts" ;; + arm64-efi) + qemu=qemu-system-aarch64 + boot=hd + console=console + trim=1 + qemuopts="-machine virt -cpu cortex-a57 -bios /usr/share/qemu-efi/QEMU_EFI.fd $qemuopts" + disk="device virtio-blk-device,drive=hd1 -drive if=none,id=hd1,file=" + serial_port=efi0 + ;; *) boot=hd qemu=qemu-system-i386 @@ -227,13 +237,13 @@ for option in "$@"; do echo "Too many disks" 1>&2 exit 1; fi - qemuopts="$qemuopts -$disk $dsk" - if [ "$disk" = hda ]; then - disk=hdb; - elif [ "$disk" = hdb ]; then + qemuopts="$qemuopts -$disk$dsk" + if [ "$disk" = "hda " ]; then + disk="hdb "; + elif [ "$disk" = "hdb " ]; then # CDROM is hdc - disk=hdd - elif [ "$disk" = hdd ]; then + disk="hdd " + elif [ "$disk" = "hdd " ]; then # CDROM is hdc disk=error fi @@ -360,7 +370,9 @@ if [ x$boot != xnet ] && [ x$boot != xemu ]; then ${files} >/dev/null 2>&1 fi if [ x$boot = xhd ]; then - if [ "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" = mips-arc ]; then + if [ "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" = arm64-efi ]; then + device="device virtio-blk-device,drive=hd0 -drive if=none,id=hd0,file=" + elif [ "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" = mips-arc ]; then device="hdb " else device="hda " @@ -368,7 +380,9 @@ if [ x$boot = xhd ]; then bootdev="-boot c" fi if [ x$boot = xcd ]; then - if [ "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" = powerpc-ieee1275 ] && [ x$pseries != xy ] ; then + if [ "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" = arm64-efi ]; then + device="device virtio-blk-device,drive=cd0 -drive if=none,id=cd0,media=cdrom,file=" + elif [ "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" = powerpc-ieee1275 ] && [ x$pseries != xy ] ; then device="-drive if=ide,media=cdrom,file=" else device="cdrom " From e4c49cab9b5d4ba77881b3829402b8b7fdb84382 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Thu, 7 Jan 2016 21:10:05 +0100 Subject: [PATCH 611/722] arm64/setjmp: Add missing move for arg1 == 0 case. --- grub-core/lib/arm64/setjmp.S | 1 + 1 file changed, 1 insertion(+) diff --git a/grub-core/lib/arm64/setjmp.S b/grub-core/lib/arm64/setjmp.S index eabfd99b2..ffcabf6e4 100644 --- a/grub-core/lib/arm64/setjmp.S +++ b/grub-core/lib/arm64/setjmp.S @@ -50,6 +50,7 @@ FUNCTION(grub_longjmp) ldp x29, x30, [x0], #16 ldr x2, [x0] mov sp, x2 + mov x0, #1 cmp x1, #0 csel x0, x1, x0, ne ret From b4787552b02c7a3a124f1d2178309383c36f5c03 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 8 Jan 2016 09:49:08 +0100 Subject: [PATCH 612/722] Tests: Support arm-efi --- tests/ahci_test.in | 2 +- tests/ehci_test.in | 2 +- tests/ohci_test.in | 2 +- tests/partmap_test.in | 3 +++ tests/pata_test.in | 2 +- tests/uhci_test.in | 2 +- tests/util/grub-shell.in | 15 ++++++++++++--- 7 files changed, 20 insertions(+), 8 deletions(-) diff --git a/tests/ahci_test.in b/tests/ahci_test.in index 40441768e..1d01d1f59 100644 --- a/tests/ahci_test.in +++ b/tests/ahci_test.in @@ -30,7 +30,7 @@ case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in mips*-arc | mips*-qemu_mips) exit 0;; # FIXME: No native drivers are available for those - powerpc-ieee1275 | sparc64-ieee1275 | arm64-efi) + powerpc-ieee1275 | sparc64-ieee1275 | arm*-efi) exit 0;; esac diff --git a/tests/ehci_test.in b/tests/ehci_test.in index 8de56ee98..7dd8d3e8f 100644 --- a/tests/ehci_test.in +++ b/tests/ehci_test.in @@ -30,7 +30,7 @@ case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in mips*-arc | mips*-qemu_mips) exit 0;; # FIXME: No native drivers are available for those - powerpc-ieee1275 | sparc64-ieee1275 | arm64-efi) + powerpc-ieee1275 | sparc64-ieee1275 | arm*-efi) exit 0;; esac diff --git a/tests/ohci_test.in b/tests/ohci_test.in index da517629f..7fede6f26 100644 --- a/tests/ohci_test.in +++ b/tests/ohci_test.in @@ -30,7 +30,7 @@ case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in mips*-arc | mips*-qemu_mips) exit 0;; # FIXME: No native drivers are available for those - powerpc-ieee1275 | sparc64-ieee1275 | arm64-efi) + powerpc-ieee1275 | sparc64-ieee1275 | arm*-efi) exit 0;; esac diff --git a/tests/partmap_test.in b/tests/partmap_test.in index 4230ba228..f8dc456fb 100644 --- a/tests/partmap_test.in +++ b/tests/partmap_test.in @@ -88,6 +88,9 @@ case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in mipsel-arc) disk=arc/scsi0/disk0/rdisk0 ;; + arm*-efi) + disk=hd3 + ;; *) disk=hd0 ;; diff --git a/tests/pata_test.in b/tests/pata_test.in index 4bf644fe6..c1d0f63ea 100644 --- a/tests/pata_test.in +++ b/tests/pata_test.in @@ -30,7 +30,7 @@ case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in *-arc) exit 0;; # FIXME: No native drivers are available for those - powerpc-ieee1275 | sparc64-ieee1275 | arm64-efi) + powerpc-ieee1275 | sparc64-ieee1275 | arm*-efi) exit 0;; i386-ieee1275) disk=hdb diff --git a/tests/uhci_test.in b/tests/uhci_test.in index 5ec503033..89e2c1805 100644 --- a/tests/uhci_test.in +++ b/tests/uhci_test.in @@ -30,7 +30,7 @@ case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in mips*-arc | mips*-qemu_mips) exit 0;; # FIXME: No native drivers are available for those - powerpc-ieee1275 | sparc64-ieee1275 | arm64-efi) + powerpc-ieee1275 | sparc64-ieee1275 | arm*-efi) exit 0;; esac diff --git a/tests/util/grub-shell.in b/tests/util/grub-shell.in index cff597ea1..5ba2c299c 100644 --- a/tests/util/grub-shell.in +++ b/tests/util/grub-shell.in @@ -182,6 +182,15 @@ case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in disk="device virtio-blk-device,drive=hd1 -drive if=none,id=hd1,file=" serial_port=efi0 ;; + arm-efi) + qemu=qemu-system-arm + boot=hd + console=console + trim=1 + qemuopts="-machine virt -bios /usr/share/ovmf-arm/QEMU_EFI.fd $qemuopts" + disk="device virtio-blk-device,drive=hd1 -drive if=none,id=hd1,file=" + serial_port=efi0 + ;; *) boot=hd qemu=qemu-system-i386 @@ -233,7 +242,7 @@ for option in "$@"; do echo "(hd$disk) $dsk" >> "$device_map" disk="$((disk+1))" else - if [ $disk = error ]; then + if [ "$disk" = error ]; then echo "Too many disks" 1>&2 exit 1; fi @@ -370,7 +379,7 @@ if [ x$boot != xnet ] && [ x$boot != xemu ]; then ${files} >/dev/null 2>&1 fi if [ x$boot = xhd ]; then - if [ "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" = arm64-efi ]; then + if [ "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" = arm64-efi ] || [ "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" = arm-efi ]; then device="device virtio-blk-device,drive=hd0 -drive if=none,id=hd0,file=" elif [ "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" = mips-arc ]; then device="hdb " @@ -380,7 +389,7 @@ if [ x$boot = xhd ]; then bootdev="-boot c" fi if [ x$boot = xcd ]; then - if [ "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" = arm64-efi ]; then + if [ "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" = arm64-efi ] || [ "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" = arm-efi ]; then device="device virtio-blk-device,drive=cd0 -drive if=none,id=cd0,media=cdrom,file=" elif [ "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" = powerpc-ieee1275 ] && [ x$pseries != xy ] ; then device="-drive if=ide,media=cdrom,file=" From efc04d65c74912972b00b1ebf15312685e317a05 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Fri, 8 Jan 2016 11:05:16 +0300 Subject: [PATCH 613/722] grub-module-verifier: fix unintended sign extension Found by: Coverity scan. CID: 156533, 156532 --- util/grub-module-verifierXX.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/grub-module-verifierXX.c b/util/grub-module-verifierXX.c index 25988ebc2..f612d51f3 100644 --- a/util/grub-module-verifierXX.c +++ b/util/grub-module-verifierXX.c @@ -337,7 +337,7 @@ SUFFIX(grub_module_verify) (void *module_img, size_t size, const struct grub_mod /* Make sure that every section is within the core. */ if (size < grub_target_to_host (e->e_shoff) - + grub_target_to_host16 (e->e_shentsize) * grub_target_to_host16(e->e_shnum)) + + (grub_uint32_t) grub_target_to_host16 (e->e_shentsize) * grub_target_to_host16(e->e_shnum)) { grub_util_error ("ELF sections outside core"); } From 8ab2675ede4313ea62cf88c22fa2760de2020423 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Fri, 8 Jan 2016 11:16:56 +0300 Subject: [PATCH 614/722] hfs: fix memory leak Found by: Coverity scan. CID: 156531 --- grub-core/fs/hfs.c | 1 + 1 file changed, 1 insertion(+) diff --git a/grub-core/fs/hfs.c b/grub-core/fs/hfs.c index 0ebc71b62..fc3683178 100644 --- a/grub-core/fs/hfs.c +++ b/grub-core/fs/hfs.c @@ -1308,6 +1308,7 @@ grub_hfs_open (struct grub_file *file, const char *name) if (grub_hfs_find_dir (data, name, &found, GRUB_FSHELP_REG)) { grub_free (data); + grub_free (found); grub_dl_unref (my_mod); return grub_errno; } From 97c41e121620796a77f04965a0c839f87eb50290 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sat, 9 Jan 2016 10:53:31 +0300 Subject: [PATCH 615/722] efiemu: fix unintended sign extension Found by: Coverity scan. CID: 73883, 73637 --- grub-core/efiemu/loadcore.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/efiemu/loadcore.c b/grub-core/efiemu/loadcore.c index 6968b3719..e68e7e4d1 100644 --- a/grub-core/efiemu/loadcore.c +++ b/grub-core/efiemu/loadcore.c @@ -343,7 +343,7 @@ SUFFIX (grub_efiemu_loadcore_init) (void *core, const char *filename, return grub_error (GRUB_ERR_BAD_MODULE, N_("this ELF file is not of the right type")); /* Make sure that every section is within the core. */ - if ((grub_size_t) core_size < e->e_shoff + e->e_shentsize * e->e_shnum) + if ((grub_size_t) core_size < e->e_shoff + (grub_uint32_t) e->e_shentsize * e->e_shnum) return grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"), filename); From 12bf87466f80cbc2b81d64ff46b8db9d76fcbaf6 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sat, 9 Jan 2016 10:59:51 +0300 Subject: [PATCH 616/722] efiemu: change code to avoid Coverity false positive CID: 73623 --- grub-core/efiemu/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/efiemu/main.c b/grub-core/efiemu/main.c index f2140ad29..f6813b1ed 100644 --- a/grub-core/efiemu/main.c +++ b/grub-core/efiemu/main.c @@ -196,7 +196,7 @@ grub_efiemu_load_file (const char *filename) { grub_file_close (file); grub_efiemu_unload (); - return grub_errno; + return err; } grub_dprintf ("efiemu", "mm initialized\n"); From 67d9ce82acce5caa62f45cbd47b6008b76cc6e4a Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sat, 9 Jan 2016 11:05:33 +0300 Subject: [PATCH 617/722] efiemu: check return value of grub_efiemu_write_value Found by: Coverity scan. CID: 73590 --- grub-core/efiemu/prepare.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/grub-core/efiemu/prepare.c b/grub-core/efiemu/prepare.c index 84c3368a8..99ddb5abb 100644 --- a/grub-core/efiemu/prepare.c +++ b/grub-core/efiemu/prepare.c @@ -83,10 +83,16 @@ SUFFIX (grub_efiemu_prepare) (struct grub_efiemu_prepare_hook *prepare_hooks, ((grub_uint8_t *) grub_efiemu_mm_obtain_request (handle) + off); /* Put pointer to the list of configuration tables in system table */ - grub_efiemu_write_value - (&(SUFFIX (grub_efiemu_system_table)->configuration_table), 0, - conftable_handle, 0, 1, - sizeof (SUFFIX (grub_efiemu_system_table)->configuration_table)); + err = grub_efiemu_write_value + (&(SUFFIX (grub_efiemu_system_table)->configuration_table), 0, + conftable_handle, 0, 1, + sizeof (SUFFIX (grub_efiemu_system_table)->configuration_table)); + if (err) + { + grub_efiemu_unload (); + return err; + } + SUFFIX(grub_efiemu_system_table)->num_table_entries = cntconftables; /* Fill the list of configuration tables */ From 57e7f1b775f6c152eff1dd88a8c1399799828112 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sat, 9 Jan 2016 13:10:10 +0300 Subject: [PATCH 618/722] setup: fix memory leak Found by: Coverity scan. CID: 73680, 73715 --- util/setup.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/util/setup.c b/util/setup.c index 8f20e9983..d74567d0a 100644 --- a/util/setup.c +++ b/util/setup.c @@ -353,6 +353,10 @@ SETUP (const char *dir, } grub_util_info ("guessed root_dev `%s' from " "dir `%s'", root_dev->disk->name, dir); + + for (cur = root_devices; *cur; cur++) + free (*cur); + free (root_devices); } grub_util_info ("setting the root device to `%s'", root); From 0e075ac3856cb14d722504e1386ebf73cd170fe9 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sat, 9 Jan 2016 13:28:42 +0300 Subject: [PATCH 619/722] util/setup: fix grub_util_path_list leak Add helper grub_util_free_path_list and use it where appropriate. Found by: Coverity scan. CID: 73727 --- include/grub/util/resolve.h | 1 + util/grub-install-common.c | 2 ++ util/mkimage.c | 10 ++-------- util/resolve.c | 14 ++++++++++++++ 4 files changed, 19 insertions(+), 8 deletions(-) diff --git a/include/grub/util/resolve.h b/include/grub/util/resolve.h index f42df32f9..8923a6e6c 100644 --- a/include/grub/util/resolve.h +++ b/include/grub/util/resolve.h @@ -31,5 +31,6 @@ struct grub_util_path_list * grub_util_resolve_dependencies (const char *prefix, const char *dep_list_file, char *modules[]); +void grub_util_free_path_list (struct grub_util_path_list *path_list); #endif /* ! GRUB_UTIL_RESOLVE_HEADER */ diff --git a/util/grub-install-common.c b/util/grub-install-common.c index 25983089f..452b230da 100644 --- a/util/grub-install-common.c +++ b/util/grub-install-common.c @@ -765,6 +765,8 @@ grub_install_copy_files (const char *src, grub_install_compress_file (srcf, dstf, 1); free (dstf); } + + grub_util_free_path_list (path_list); } const char *pkglib_DATA[] = {"efiemu32.o", "efiemu64.o", diff --git a/util/mkimage.c b/util/mkimage.c index dc4046185..c3365bbbd 100644 --- a/util/mkimage.c +++ b/util/mkimage.c @@ -996,7 +996,7 @@ grub_install_generate_image (const char *dir, const char *prefix, size_t prefix_size = 0; char *kernel_path; size_t offset; - struct grub_util_path_list *path_list, *p, *next; + struct grub_util_path_list *path_list, *p; size_t bss_size; grub_uint64_t start_address; void *rel_section = 0; @@ -1904,11 +1904,5 @@ grub_install_generate_image (const char *dir, const char *prefix, free (kernel_path); free (rel_section); - while (path_list) - { - next = path_list->next; - free ((void *) path_list->name); - free (path_list); - path_list = next; - } + grub_util_free_path_list (path_list); } diff --git a/util/resolve.c b/util/resolve.c index 002bfbd72..3e887d2ff 100644 --- a/util/resolve.c +++ b/util/resolve.c @@ -271,3 +271,17 @@ grub_util_resolve_dependencies (const char *prefix, return prev; } } + +void +grub_util_free_path_list (struct grub_util_path_list *path_list) +{ + struct grub_util_path_list *next; + + while (path_list) + { + next = path_list->next; + free ((void *) path_list->name); + free (path_list); + path_list = next; + } +} From fa2af21ec8fd4410f6a9bb7412c6402e1b6565ca Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sat, 9 Jan 2016 13:43:04 +0300 Subject: [PATCH 620/722] gfxmenu: fix memory leak Found by: Coverity scan. CID: 73766 --- grub-core/gfxmenu/font.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/grub-core/gfxmenu/font.c b/grub-core/gfxmenu/font.c index 64d52670b..756c24f20 100644 --- a/grub-core/gfxmenu/font.c +++ b/grub-core/gfxmenu/font.c @@ -45,6 +45,7 @@ grub_font_draw_string (const char *str, grub_font_t font, grub_uint32_t *logical; grub_ssize_t logical_len, visual_len; struct grub_unicode_glyph *visual, *ptr; + grub_err_t err; logical_len = grub_utf8_to_ucs4_alloc (str, &logical, 0); if (logical_len < 0) @@ -56,24 +57,28 @@ grub_font_draw_string (const char *str, grub_font_t font, if (visual_len < 0) return grub_errno; + err = GRUB_ERR_NONE; for (ptr = visual, x = left_x; ptr < visual + visual_len; ptr++) { - grub_err_t err; struct grub_font_glyph *glyph; glyph = grub_font_construct_glyph (font, ptr); if (!glyph) - return grub_errno; + { + err = grub_errno; + goto out; + } err = grub_font_draw_glyph (glyph, color, x, baseline_y); - x += glyph->device_width; if (err) - return err; + goto out; + x += glyph->device_width; } +out: for (ptr = visual; ptr < visual + visual_len; ptr++) grub_unicode_destroy_glyph (ptr); grub_free (visual); - return GRUB_ERR_NONE; + return err; } /* Get the width in pixels of the specified UTF-8 string, when rendered in From d5cc487d3963a65e87ac7d816b390afcd3ffabf0 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sat, 9 Jan 2016 13:49:37 +0300 Subject: [PATCH 621/722] grub-probe: fix memory leak Found by: Coverity scan. CID: 73783 --- util/grub-probe.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/util/grub-probe.c b/util/grub-probe.c index b1f533626..36b7f8bcb 100644 --- a/util/grub-probe.c +++ b/util/grub-probe.c @@ -668,6 +668,13 @@ probe (const char *path, char **device_names, char delim) for (curdrive = drives_names; *curdrive; curdrive++) free (*curdrive); free (drives_names); + + if (path != NULL) + { + for (curdev = device_names; *curdev; curdev++) + free (*curdev); + free (device_names); + } } static struct argp_option options[] = { From 725548a2855e357cd5cd243dddef355295e63110 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sat, 9 Jan 2016 14:13:36 +0300 Subject: [PATCH 622/722] grub-mklayout: check subscript bounds Found by: Coverity scan. CID: 73686 --- util/grub-mklayout.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/util/grub-mklayout.c b/util/grub-mklayout.c index 1a4f1b4c8..d171c2700 100644 --- a/util/grub-mklayout.c +++ b/util/grub-mklayout.c @@ -384,6 +384,13 @@ write_keymaps (FILE *in, FILE *out, const char *out_filename) sscanf (line, "keycode %u = %60s %60s %60s %60s", &keycode_linux, normal, shift, normalalt, shiftalt); + if (keycode_linux >= ARRAY_SIZE (linux_to_usb_map)) + { + /* TRANSLATORS: scan code is keyboard key numeric identifier. */ + fprintf (stderr, _("Unknown keyboard scan code 0x%02x\n"), keycode_linux); + continue; + } + /* Not used. */ if (keycode_linux == 0x77 /* Pause */ /* Some obscure keys */ From bd60f5a207f9d8e594520d32f909aafdb4f5fffb Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sat, 9 Jan 2016 18:15:27 +0300 Subject: [PATCH 623/722] rescue_parser: restructure code to avoid Coverity false positive If line contains single word, line and argv[0] are aliases, so no NULL dereference is possible, but Coverity does not know it. Change code to avoid ambiguity and also remove redundant call to grub_strchr. CID: 86725 --- grub-core/kern/rescue_parser.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/grub-core/kern/rescue_parser.c b/grub-core/kern/rescue_parser.c index ab3d04160..633836699 100644 --- a/grub-core/kern/rescue_parser.c +++ b/grub-core/kern/rescue_parser.c @@ -43,13 +43,17 @@ grub_rescue_parse_line (char *line, /* In case of an assignment set the environment accordingly instead of calling a function. */ - if (n == 1 && grub_strchr (line, '=')) + if (n == 1) { char *val = grub_strchr (args[0], '='); - val[0] = 0; - grub_env_set (args[0], val + 1); - val[0] = '='; - goto quit; + + if (val) + { + val[0] = 0; + grub_env_set (args[0], val + 1); + val[0] = '='; + goto quit; + } } /* Get the command name. */ @@ -72,6 +76,7 @@ grub_rescue_parse_line (char *line, } quit: + /* Arguments are returned in single memory chunk separated by zeroes */ grub_free (args[0]); grub_free (args); From aafd205c926df01b039e588134e3798913bcbe3f Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sat, 9 Jan 2016 18:55:55 +0300 Subject: [PATCH 624/722] xfs: fix possible inode corruption in directory scan grub_xfs_iterate_dir did not restore first character after inline name when match was found. Dependning on XFS format this character could be inode number and we could return to the same node later in find_file if processing cycled symlinks. CID: 86724 --- grub-core/fs/xfs.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/grub-core/fs/xfs.c b/grub-core/fs/xfs.c index a03526b32..ca9c0c37a 100644 --- a/grub-core/fs/xfs.c +++ b/grub-core/fs/xfs.c @@ -775,7 +775,10 @@ grub_xfs_iterate_dir (grub_fshelp_node_t dir, c = de->name[de->len]; de->name[de->len] = '\0'; if (iterate_dir_call_hook (ino, de->name, &ctx)) - return 1; + { + de->name[de->len] = c; + return 1; + } de->name[de->len] = c; de = grub_xfs_inline_next_de(dir->data, head, de); From 9fecb0588ee9a8059a75fb3ec9acf3948b54e4f9 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sat, 9 Jan 2016 19:41:26 +0300 Subject: [PATCH 625/722] kern/elf: fix unintended sign extension Found by: Coverity scan. CID: 73729, 73735, 73758, 73760 --- grub-core/kern/elfXX.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/kern/elfXX.c b/grub-core/kern/elfXX.c index b91c39d9e..1859d1880 100644 --- a/grub-core/kern/elfXX.c +++ b/grub-core/kern/elfXX.c @@ -12,7 +12,7 @@ grub_elfXX_load_phdrs (grub_elf_t elf) if (elf->phdrs) return GRUB_ERR_NONE; - phdrs_size = elf->ehdr.ehdrXX.e_phnum * elf->ehdr.ehdrXX.e_phentsize; + phdrs_size = (grub_uint32_t) elf->ehdr.ehdrXX.e_phnum * elf->ehdr.ehdrXX.e_phentsize; grub_dprintf ("elf", "Loading program headers at 0x%llx, size 0x%lx.\n", (unsigned long long) elf->ehdr.ehdrXX.e_phoff, From 31f6506c57b976148fd1d3d4e72943712b6e0c8d Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sat, 9 Jan 2016 19:58:51 +0300 Subject: [PATCH 626/722] loader/multiboot: fix unintended sign extension Found by: Coveruty scan. CID: 73700, 73763 --- grub-core/loader/multiboot_elfxx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/loader/multiboot_elfxx.c b/grub-core/loader/multiboot_elfxx.c index 6a220bdc1..a7bebcb3c 100644 --- a/grub-core/loader/multiboot_elfxx.c +++ b/grub-core/loader/multiboot_elfxx.c @@ -72,7 +72,7 @@ CONCAT(grub_multiboot_load_elf, XX) (grub_file_t file, const char *filename, voi return grub_error (GRUB_ERR_UNKNOWN_OS, N_("this ELF file is not of the right type")); /* FIXME: Should we support program headers at strange locations? */ - if (ehdr->e_phoff + ehdr->e_phnum * ehdr->e_phentsize > MULTIBOOT_SEARCH) + if (ehdr->e_phoff + (grub_uint32_t) ehdr->e_phnum * ehdr->e_phentsize > MULTIBOOT_SEARCH) return grub_error (GRUB_ERR_BAD_OS, "program header at a too high offset"); phdr_base = (char *) buffer + ehdr->e_phoff; From dc27d254f2cb7f4b0fef52fb8c9e9f89881b1f4c Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sat, 9 Jan 2016 20:54:54 +0300 Subject: [PATCH 627/722] util/getroot: delete dead code is_part cannot be non-zero at this point. Found by: Coveruty scan. CID: 73838 --- util/getroot.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/util/getroot.c b/util/getroot.c index 36f1730c0..92c0d709b 100644 --- a/util/getroot.c +++ b/util/getroot.c @@ -383,9 +383,6 @@ grub_util_biosdisk_get_grub_dev (const char *os_dev) grub_util_info ("%s starts from %" GRUB_HOST_PRIuLONG_LONG, os_dev, (unsigned long long) ctx.start); - if (ctx.start == 0 && !is_part) - return name; - grub_util_info ("opening the device %s", name); disk = grub_disk_open (name); free (name); From 670c43af27dee281bb61e2a50855b61f96b7e1fa Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sat, 9 Jan 2016 21:05:44 +0300 Subject: [PATCH 628/722] mkimage: fix unintended sign extension Found by: Coverity scan. CID: 73691, 73717 --- util/grub-mkimagexx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/grub-mkimagexx.c b/util/grub-mkimagexx.c index a1ddc6269..0e0c6f7a1 100644 --- a/util/grub-mkimagexx.c +++ b/util/grub-mkimagexx.c @@ -1465,7 +1465,7 @@ SUFFIX (load_image) (const char *kernel_path, size_t *exec_size, section_entsize = grub_target_to_host16 (e->e_shentsize); num_sections = grub_target_to_host16 (e->e_shnum); - if (kernel_size < section_offset + section_entsize * num_sections) + if (kernel_size < section_offset + (grub_uint32_t) section_entsize * num_sections) grub_util_error (_("premature end of file %s"), kernel_path); sections = (Elf_Shdr *) (kernel_img + section_offset); From 5a5a3c69630ea117f54c07e891007fe3374581ba Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sat, 9 Jan 2016 21:25:22 +0300 Subject: [PATCH 629/722] setup: fix NULL pointer dereference Check return value of grub_guess_root_devices Found by: Coverity scan. CID: 73638, 73751 --- util/setup.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/util/setup.c b/util/setup.c index d74567d0a..8aa5a39a7 100644 --- a/util/setup.c +++ b/util/setup.c @@ -312,6 +312,9 @@ SETUP (const char *dir, char **cur; int found = 0; + if (!root_devices) + grub_util_error (_("cannot find a device for %s (is /dev mounted?)"), dir); + for (cur = root_devices; *cur; cur++) { char *drive; From 269a522c7db1f383ccf0998a7cf9c4b1797ea0d9 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sun, 10 Jan 2016 10:41:04 +0300 Subject: [PATCH 630/722] hostdisk: fix device detection Condition was apparently reversed so GRUB assumed all devices were files. This later made it skip BLKFLSBUF ioctl on Linux which caused various page cache coherency issues. Observed were - failure to validate blocklist install (read content did not match just written) - failure to detect Linux MD on disk after online hot addition (GRUB got stale superblock) Closes: 46691 --- grub-core/kern/emu/hostdisk.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/grub-core/kern/emu/hostdisk.c b/grub-core/kern/emu/hostdisk.c index 610518d0c..87e3e2512 100644 --- a/grub-core/kern/emu/hostdisk.c +++ b/grub-core/kern/emu/hostdisk.c @@ -161,9 +161,9 @@ grub_util_biosdisk_open (const char *name, grub_disk_t disk) { struct stat st; # if GRUB_DISK_DEVS_ARE_CHAR - if (fstat (fd, &st) < 0 || ! S_ISCHR (st.st_mode)) + if (fstat (fd, &st) >= 0 && S_ISCHR (st.st_mode)) # else - if (fstat (fd, &st) < 0 || ! S_ISBLK (st.st_mode)) + if (fstat (fd, &st) >= 0 && S_ISBLK (st.st_mode)) # endif data->is_disk = 1; } From 528256932b8586587c7b339418d3865206717b60 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sun, 10 Jan 2016 11:33:13 +0300 Subject: [PATCH 631/722] net: remove dead and redundant code server cannot be NULL at this point (we return error earlier if it is). Also structure is zalloc'ed, so no need to explicitly initialize members to 0. Found by: Coverity scan. CID: 73837 --- grub-core/net/net.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/grub-core/net/net.c b/grub-core/net/net.c index a0472d5d4..85b0cf774 100644 --- a/grub-core/net/net.c +++ b/grub-core/net/net.c @@ -1322,20 +1322,13 @@ grub_net_open_real (const char *name) if (!ret) return NULL; ret->protocol = proto; - if (server) + ret->server = grub_strdup (server); + if (!ret->server) { - ret->server = grub_strdup (server); - if (!ret->server) - { - grub_free (ret); - return NULL; - } + grub_free (ret); + return NULL; } - else - ret->server = NULL; ret->fs = &grub_net_fs; - ret->offset = 0; - ret->eof = 0; return ret; } } From 962b69d9503bdd91120d2c0fcfd17ae6d37db71c Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sun, 10 Jan 2016 11:51:34 +0300 Subject: [PATCH 632/722] grub-mkimage: remove redundant NULL check Found by: Coverity scan. CID: 73737 --- util/grub-mkimage.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/util/grub-mkimage.c b/util/grub-mkimage.c index 1e0bcf1bf..10375f4d2 100644 --- a/util/grub-mkimage.c +++ b/util/grub-mkimage.c @@ -304,8 +304,7 @@ main (int argc, char *argv[]) grub_util_file_sync (fp); fclose (fp); - if (arguments.dir) - free (arguments.dir); + free (arguments.dir); if (arguments.output) free (arguments.output); From 66768b99f15033bf55bc6c360cae6a6660be5c5f Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sun, 10 Jan 2016 16:08:06 +0300 Subject: [PATCH 633/722] grub-install: include ehci in list of native modules This matches behavior of "nativedisk" command. Reported and tested by Smith Henry --- util/grub-install.c | 1 + 1 file changed, 1 insertion(+) diff --git a/util/grub-install.c b/util/grub-install.c index eabd6de4d..6c89c2b0c 100644 --- a/util/grub-install.c +++ b/util/grub-install.c @@ -1282,6 +1282,7 @@ main (int argc, char *argv[]) grub_install_push_module ("ahci"); grub_install_push_module ("ohci"); grub_install_push_module ("uhci"); + grub_install_push_module ("ehci"); grub_install_push_module ("usbms"); } else if (disk_module && disk_module[0]) From 8fe17d91afc610d99458102a2a81abfdd542f4c0 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Tue, 12 Jan 2016 20:26:30 +0300 Subject: [PATCH 634/722] acpi: fix memory leak Found by: Coverity scan. CID: 96673 --- grub-core/commands/acpi.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/grub-core/commands/acpi.c b/grub-core/commands/acpi.c index ece49b4a9..b5c2f27c1 100644 --- a/grub-core/commands/acpi.c +++ b/grub-core/commands/acpi.c @@ -593,6 +593,9 @@ grub_cmd_acpi (struct grub_extcmd_context *ctxt, int argc, char **args) if (! table->addr) { free_tables (); + grub_free (exclude); + grub_free (load_only); + grub_free (table); return grub_errno; } table->next = acpi_tables; From 1bff60e5aac71552aafe0dc5e08ff62ef32ee711 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Tue, 12 Jan 2016 20:37:43 +0300 Subject: [PATCH 635/722] nativedisk: fix memory leak Based on Coverity scan. CID: 96660 Extended to also cover other error return places. --- grub-core/commands/nativedisk.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/grub-core/commands/nativedisk.c b/grub-core/commands/nativedisk.c index b3bc4639c..345f97c4d 100644 --- a/grub-core/commands/nativedisk.c +++ b/grub-core/commands/nativedisk.c @@ -198,7 +198,10 @@ grub_cmd_nativedisk (grub_command_t cmd __attribute__ ((unused)), return grub_errno; if (get_uuid (NULL, &uuid_root, 0)) - return grub_errno; + { + grub_free (mods); + return grub_errno; + } prefdev = grub_file_get_device_name (prefix); if (grub_errno) @@ -210,6 +213,8 @@ grub_cmd_nativedisk (grub_command_t cmd __attribute__ ((unused)), if (get_uuid (prefdev, &uuid_prefix, 0)) { grub_free (uuid_root); + grub_free (prefdev); + grub_free (mods); return grub_errno; } @@ -289,12 +294,15 @@ grub_cmd_nativedisk (grub_command_t cmd __attribute__ ((unused)), } grub_free (uuid_root); grub_free (uuid_prefix); + grub_free (prefdev); + grub_free (mods); return GRUB_ERR_NONE; fail: grub_free (uuid_root); grub_free (uuid_prefix); + grub_free (prefdev); for (i = 0; i < mods_loaded; i++) if (mods[i]) @@ -302,6 +310,8 @@ grub_cmd_nativedisk (grub_command_t cmd __attribute__ ((unused)), mods[i]->fini = 0; grub_dl_unload (mods[i]); } + grub_free (mods); + return grub_errno; } From 5db2190f2cd12706d1df00303dc9eaf7a78b08e1 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Tue, 12 Jan 2016 20:41:44 +0300 Subject: [PATCH 636/722] parttool: fix memory leak Found by: Coverity scan. CID: 96652 --- grub-core/commands/parttool.c | 1 + 1 file changed, 1 insertion(+) diff --git a/grub-core/commands/parttool.c b/grub-core/commands/parttool.c index 42c590e1a..693e2cb42 100644 --- a/grub-core/commands/parttool.c +++ b/grub-core/commands/parttool.c @@ -283,6 +283,7 @@ grub_cmd_parttool (grub_command_t cmd __attribute__ ((unused)), } if (! cur) { + grub_free (parsed); grub_device_close (dev); return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("unknown argument `%s'"), args[i]); From f3c84fa79847ee365742153a2f3cd47e678aef4a Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Tue, 12 Jan 2016 20:53:26 +0300 Subject: [PATCH 637/722] password_pbkdf2: fix memory leak Found by: Coverity scan. CID: 96656 --- grub-core/commands/password_pbkdf2.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/grub-core/commands/password_pbkdf2.c b/grub-core/commands/password_pbkdf2.c index c6a77c8c5..da636e621 100644 --- a/grub-core/commands/password_pbkdf2.c +++ b/grub-core/commands/password_pbkdf2.c @@ -45,6 +45,7 @@ check_password (const char *user, const char *entered, void *pin) grub_uint8_t *buf; struct pbkdf2_password *pass = pin; gcry_err_code_t err; + grub_err_t ret; buf = grub_malloc (pass->buflen); if (!buf) @@ -55,17 +56,17 @@ check_password (const char *user, const char *entered, void *pin) pass->salt, pass->saltlen, pass->c, buf, pass->buflen); if (err) + ret = grub_crypto_gcry_error (err); + else if (grub_crypto_memcmp (buf, pass->expected, pass->buflen) != 0) + ret = GRUB_ACCESS_DENIED; + else { - grub_free (buf); - return grub_crypto_gcry_error (err); + grub_auth_authenticate (user); + ret = GRUB_ERR_NONE; } - if (grub_crypto_memcmp (buf, pass->expected, pass->buflen) != 0) - return GRUB_ACCESS_DENIED; - - grub_auth_authenticate (user); - - return GRUB_ERR_NONE; + grub_free (buf); + return ret; } static inline int From 6c35ce72bad698051f82b087cd026f8e5331f915 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Tue, 12 Jan 2016 21:10:12 +0300 Subject: [PATCH 638/722] verify: fix memory leak Found by: Coverity scan. CID: 96643 --- grub-core/commands/verify.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/grub-core/commands/verify.c b/grub-core/commands/verify.c index 9620a3b4c..67cb1c785 100644 --- a/grub-core/commands/verify.c +++ b/grub-core/commands/verify.c @@ -324,19 +324,19 @@ grub_load_public_key (grub_file_t f) if (grub_file_read (f, &l, sizeof (l)) != sizeof (l)) { grub_error (GRUB_ERR_BAD_SIGNATURE, N_("bad signature")); - goto fail; + break; } lb = (grub_be_to_cpu16 (l) + GRUB_CHAR_BIT - 1) / GRUB_CHAR_BIT; if (lb > READBUF_SIZE - sizeof (grub_uint16_t)) { grub_error (GRUB_ERR_BAD_SIGNATURE, N_("bad signature")); - goto fail; + break; } if (grub_file_read (f, buffer + sizeof (grub_uint16_t), lb) != (grub_ssize_t) lb) { grub_error (GRUB_ERR_BAD_SIGNATURE, N_("bad signature")); - goto fail; + break; } grub_memcpy (buffer, &l, sizeof (l)); @@ -346,10 +346,16 @@ grub_load_public_key (grub_file_t f) buffer, lb + sizeof (grub_uint16_t), 0)) { grub_error (GRUB_ERR_BAD_SIGNATURE, N_("bad signature")); - goto fail; + break; } } + if (i < pkalgos[pk].nmpipub) + { + grub_free (sk); + goto fail; + } + GRUB_MD_SHA1->final (fingerprint_context); grub_memcpy (sk->fingerprint, GRUB_MD_SHA1->read (fingerprint_context), 20); From e9d71db53a1f3e14abfdcf879f734ce1211175f0 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Tue, 12 Jan 2016 21:16:34 +0300 Subject: [PATCH 639/722] efidisk: fix memory leak Found by: Coverity scan. CID: 96644 --- grub-core/disk/efi/efidisk.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/grub-core/disk/efi/efidisk.c b/grub-core/disk/efi/efidisk.c index a8783a3c1..1c00e3ec8 100644 --- a/grub-core/disk/efi/efidisk.c +++ b/grub-core/disk/efi/efidisk.c @@ -85,6 +85,12 @@ make_devices (void) { /* Uggh. */ grub_free (handles); + while (devices) + { + d = devices->next; + grub_free (devices); + devices = d; + } return 0; } From dbb0f9fa4fe7a9c3721178edf2421825dce5ad07 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Tue, 12 Jan 2016 21:25:40 +0300 Subject: [PATCH 640/722] efiemu: fix memory leak Found by: Coverity scan. CID: 156610 --- grub-core/efiemu/loadcore.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/grub-core/efiemu/loadcore.c b/grub-core/efiemu/loadcore.c index e68e7e4d1..44085ef81 100644 --- a/grub-core/efiemu/loadcore.c +++ b/grub-core/efiemu/loadcore.c @@ -154,7 +154,10 @@ grub_efiemu_init_segments (grub_efiemu_segment_t *segs, const Elf_Ehdr *e) s->sh_flags & SHF_EXECINSTR ? GRUB_EFI_RUNTIME_SERVICES_CODE : GRUB_EFI_RUNTIME_SERVICES_DATA); if (seg->handle < 0) - return grub_errno; + { + grub_free (seg); + return grub_errno; + } seg->off = 0; } From a4b1326f0d0382be62bb224ea5532ab3fae1b440 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Tue, 12 Jan 2016 21:33:34 +0300 Subject: [PATCH 641/722] gfxmenu: fix memory leak Found by: Coverity scan. CID: 96657 --- grub-core/gfxmenu/gfxmenu.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/grub-core/gfxmenu/gfxmenu.c b/grub-core/gfxmenu/gfxmenu.c index f49fce802..8a17dda2c 100644 --- a/grub-core/gfxmenu/gfxmenu.c +++ b/grub-core/gfxmenu/gfxmenu.c @@ -63,14 +63,14 @@ grub_gfxmenu_try (int entry, grub_menu_t menu, int nested) return grub_error (GRUB_ERR_FILE_NOT_FOUND, N_("variable `%s' isn't set"), "theme"); - instance = grub_zalloc (sizeof (*instance)); - if (!instance) - return grub_errno; - err = grub_video_get_info (&mode_info); if (err) return err; + instance = grub_zalloc (sizeof (*instance)); + if (!instance) + return grub_errno; + if (theme_path[0] != '/' && theme_path[0] != '(') { const char *prefix; From 9daf7aae8b917155b253951b83cbc8e5bed7f636 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Tue, 12 Jan 2016 21:41:48 +0300 Subject: [PATCH 642/722] truecrypt: fix memory leak Found by: Coverity scan. CID: 156611 --- grub-core/loader/i386/pc/truecrypt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/loader/i386/pc/truecrypt.c b/grub-core/loader/i386/pc/truecrypt.c index 159eab1a7..9ea4fde42 100644 --- a/grub-core/loader/i386/pc/truecrypt.c +++ b/grub-core/loader/i386/pc/truecrypt.c @@ -205,7 +205,7 @@ grub_cmd_truecrypt (grub_command_t cmd __attribute__ ((unused)), fail: if (!grub_errno) - return grub_error (GRUB_ERR_BAD_OS, "bad truecrypt ISO"); + grub_error (GRUB_ERR_BAD_OS, "bad truecrypt ISO"); if (file) grub_file_close (file); From 29862fdc3a921b9d3cf34ae15e779907d554b6ce Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Tue, 12 Jan 2016 21:43:43 +0300 Subject: [PATCH 643/722] xnu: fix memory leak Found by: Coverity scan. CID: 96663 --- grub-core/loader/i386/xnu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/loader/i386/xnu.c b/grub-core/loader/i386/xnu.c index 2fe1fdc1f..a4a6f932e 100644 --- a/grub-core/loader/i386/xnu.c +++ b/grub-core/loader/i386/xnu.c @@ -338,7 +338,7 @@ grub_xnu_devprop_add_property_utf16 (struct grub_xnu_devprop_device_descriptor * utf8 = grub_malloc (namelen * 4 + 1); if (!utf8) { - grub_free (utf8); + grub_free (utf16); return grub_errno; } From 26533fe6bca59e340fe33c658c0a3c8aca3f04ff Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Tue, 12 Jan 2016 22:36:53 +0300 Subject: [PATCH 644/722] normal: fix memory leak Found by: Coverity scan. CID: 96641, 96670, 96667 --- grub-core/normal/menu_entry.c | 7 ++++++- grub-core/normal/term.c | 4 ++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/grub-core/normal/menu_entry.c b/grub-core/normal/menu_entry.c index 2b732250d..b80d161dd 100644 --- a/grub-core/normal/menu_entry.c +++ b/grub-core/normal/menu_entry.c @@ -476,7 +476,10 @@ insert_string (struct screen *screen, const char *s, int update) (grub_uint8_t *) s, (p - s), 0); if (! ensure_space (current_linep, size)) - return 0; + { + grub_free (unicode_msg); + return 0; + } grub_memmove (current_linep->buf + screen->column + size, current_linep->buf + screen->column, @@ -1265,6 +1268,7 @@ grub_menu_entry_run (grub_menu_entry_t entry) if (! screen->lines[i].pos) { grub_print_error (); + destroy_screen (screen); grub_errno = GRUB_ERR_NONE; return; } @@ -1274,6 +1278,7 @@ grub_menu_entry_run (grub_menu_entry_t entry) if (!screen->terms) { grub_print_error (); + destroy_screen (screen); grub_errno = GRUB_ERR_NONE; return; } diff --git a/grub-core/normal/term.c b/grub-core/normal/term.c index 4c2238b25..ac5d69f0f 100644 --- a/grub-core/normal/term.c +++ b/grub-core/normal/term.c @@ -77,8 +77,6 @@ print_more (void) grub_term_output_t term; grub_uint32_t *unicode_str, *unicode_last_position; - pos = grub_term_save_pos (); - /* TRANSLATORS: This has to fit on one line. It's ok to include few words but don't write poems. */ grub_utf8_to_ucs4_alloc (_("--MORE--"), &unicode_str, @@ -90,6 +88,8 @@ print_more (void) return; } + pos = grub_term_save_pos (); + grub_setcolorstate (GRUB_TERM_COLOR_HIGHLIGHT); FOR_ACTIVE_TERM_OUTPUTS(term) From b95e92678882f56056c64ae29092bc9cf129905f Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Tue, 12 Jan 2016 22:50:30 +0300 Subject: [PATCH 645/722] script: fix memory leak Found by: Coverity scan. CID: 96637 --- grub-core/script/execute.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/grub-core/script/execute.c b/grub-core/script/execute.c index bb70ebf17..a8502d907 100644 --- a/grub-core/script/execute.c +++ b/grub-core/script/execute.c @@ -681,18 +681,14 @@ grub_script_arglist_to_argv (struct grub_script_arglist *arglist, } *op = '\0'; - if (grub_script_argv_append (&result, p, op - p)) - { - grub_free (p); - need_cleanup = 1; - /* Fall through to cleanup */ - } + need_cleanup = grub_script_argv_append (&result, p, op - p); + grub_free (p); + /* Fall through to cleanup */ } else { - if (append (&result, values[i], 1)) - need_cleanup = 1; - /* Fall through to cleanup */ + need_cleanup = append (&result, values[i], 1); + /* Fall through to cleanup */ } } From 4f8fe948b95d662cdf02effcda6cdfff36b1c4b1 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Wed, 13 Jan 2016 20:15:07 +0300 Subject: [PATCH 646/722] loader: Unintended sign extension CID: 96707, 96699, 96693, 96691, 96711, 96709, 96708, 96703, 96702, 96700, 96698, 96696, 96695, 96692, 96710, 96705 --- grub-core/kern/dl.c | 2 +- grub-core/loader/i386/bsdXX.c | 24 ++++++++++++------------ grub-core/loader/multiboot_elfxx.c | 4 ++-- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/grub-core/kern/dl.c b/grub-core/kern/dl.c index 3a438e92f..59a6ef4ca 100644 --- a/grub-core/kern/dl.c +++ b/grub-core/kern/dl.c @@ -605,7 +605,7 @@ grub_dl_load_core_noinit (void *addr, grub_size_t size) } /* Make sure that every section is within the core. */ - if (size < e->e_shoff + e->e_shentsize * e->e_shnum) + if (size < e->e_shoff + (grub_uint32_t) e->e_shentsize * e->e_shnum) { grub_error (GRUB_ERR_BAD_OS, "ELF sections outside core"); return 0; diff --git a/grub-core/loader/i386/bsdXX.c b/grub-core/loader/i386/bsdXX.c index 9f57cfa82..0d14deeb7 100644 --- a/grub-core/loader/i386/bsdXX.c +++ b/grub-core/loader/i386/bsdXX.c @@ -48,15 +48,15 @@ read_headers (grub_file_t file, const char *filename, Elf_Ehdr *e, char **shdr) if (e->e_ident[EI_CLASS] != SUFFIX (ELFCLASS)) return grub_error (GRUB_ERR_BAD_OS, N_("invalid arch-dependent ELF magic")); - *shdr = grub_malloc (e->e_shnum * e->e_shentsize); + *shdr = grub_malloc ((grub_uint32_t) e->e_shnum * e->e_shentsize); if (! *shdr) return grub_errno; if (grub_file_seek (file, e->e_shoff) == (grub_off_t) -1) return grub_errno; - if (grub_file_read (file, *shdr, e->e_shnum * e->e_shentsize) - != e->e_shnum * e->e_shentsize) + if (grub_file_read (file, *shdr, (grub_uint32_t) e->e_shnum * e->e_shentsize) + != (grub_uint32_t) e->e_shnum * e->e_shentsize) { if (grub_errno) return grub_errno; @@ -200,8 +200,8 @@ SUFFIX (grub_freebsd_load_elfmodule) (struct grub_relocator *relocator, if (chunk_size < sizeof (e)) chunk_size = sizeof (e); - chunk_size += e.e_phnum * e.e_phentsize; - chunk_size += e.e_shnum * e.e_shentsize; + chunk_size += (grub_uint32_t) e.e_phnum * e.e_phentsize; + chunk_size += (grub_uint32_t) e.e_shnum * e.e_shentsize; { grub_relocator_chunk_t ch; @@ -253,14 +253,14 @@ SUFFIX (grub_freebsd_load_elfmodule) (struct grub_relocator *relocator, curload = module + sizeof (e); load (file, argv[0], (grub_uint8_t *) chunk_src + curload - *kern_end, e.e_shoff, - e.e_shnum * e.e_shentsize); + (grub_uint32_t) e.e_shnum * e.e_shentsize); e.e_shoff = curload - module; - curload += e.e_shnum * e.e_shentsize; + curload += (grub_uint32_t) e.e_shnum * e.e_shentsize; load (file, argv[0], (grub_uint8_t *) chunk_src + curload - *kern_end, e.e_phoff, - e.e_phnum * e.e_phentsize); + (grub_uint32_t) e.e_phnum * e.e_phentsize); e.e_phoff = curload - module; - curload += e.e_phnum * e.e_phentsize; + curload += (grub_uint32_t) e.e_phnum * e.e_phentsize; *kern_end = curload; @@ -462,7 +462,7 @@ SUFFIX (grub_netbsd_load_elf_meta) (struct grub_relocator *relocator, chunk_size = ALIGN_UP (symsize, sizeof (grub_freebsd_addr_t)) + ALIGN_UP (strsize, sizeof (grub_freebsd_addr_t)) - + sizeof (e) + e.e_shnum * e.e_shentsize; + + sizeof (e) + (grub_uint32_t) e.e_shnum * e.e_shentsize; symtarget = ALIGN_UP (*kern_end, sizeof (grub_freebsd_addr_t)); { @@ -498,10 +498,10 @@ SUFFIX (grub_netbsd_load_elf_meta) (struct grub_relocator *relocator, s2 = (Elf_Shdr *) curload; grub_memcpy (curload, s, e.e_shentsize); if (s == symsh) - s2->sh_offset = sizeof (e) + e.e_shnum * e.e_shentsize; + s2->sh_offset = sizeof (e) + (grub_uint32_t) e.e_shnum * e.e_shentsize; else if (s == strsh) s2->sh_offset = ALIGN_UP (symsize, sizeof (grub_freebsd_addr_t)) - + sizeof (e) + e.e_shnum * e.e_shentsize; + + sizeof (e) + (grub_uint32_t) e.e_shnum * e.e_shentsize; else s2->sh_offset = 0; s2->sh_addr = s2->sh_offset; diff --git a/grub-core/loader/multiboot_elfxx.c b/grub-core/loader/multiboot_elfxx.c index a7bebcb3c..e3a39b609 100644 --- a/grub-core/loader/multiboot_elfxx.c +++ b/grub-core/loader/multiboot_elfxx.c @@ -164,7 +164,7 @@ CONCAT(grub_multiboot_load_elf, XX) (grub_file_t file, const char *filename, voi { grub_uint8_t *shdr, *shdrptr; - shdr = grub_malloc (ehdr->e_shnum * ehdr->e_shentsize); + shdr = grub_malloc ((grub_uint32_t) ehdr->e_shnum * ehdr->e_shentsize); if (!shdr) return grub_errno; @@ -174,7 +174,7 @@ CONCAT(grub_multiboot_load_elf, XX) (grub_file_t file, const char *filename, voi return grub_errno; } - if (grub_file_read (file, shdr, ehdr->e_shnum * ehdr->e_shentsize) + if (grub_file_read (file, shdr, (grub_uint32_t) ehdr->e_shnum * ehdr->e_shentsize) != (grub_ssize_t) ehdr->e_shnum * ehdr->e_shentsize) { if (!grub_errno) From eefa3239c2aa9531e45a9a3a98cb605b2b563827 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sat, 16 Jan 2016 20:34:02 +0300 Subject: [PATCH 647/722] legacycfg: fix memory leaks and add NULL check Memory leaks found by Coverity scan. CID: 96642, 96645 --- grub-core/commands/legacycfg.c | 43 +++++++++++++++++++++++++--------- 1 file changed, 32 insertions(+), 11 deletions(-) diff --git a/grub-core/commands/legacycfg.c b/grub-core/commands/legacycfg.c index d42d7779e..dd9d9f18f 100644 --- a/grub-core/commands/legacycfg.c +++ b/grub-core/commands/legacycfg.c @@ -253,6 +253,7 @@ grub_cmd_legacy_kernel (struct grub_command *mycmd __attribute__ ((unused)), struct grub_command *cmd; char **cutargs; int cutargc; + grub_err_t err = GRUB_ERR_NONE; for (i = 0; i < 2; i++) { @@ -314,6 +315,8 @@ grub_cmd_legacy_kernel (struct grub_command *mycmd __attribute__ ((unused)), return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected")); cutargs = grub_malloc (sizeof (cutargs[0]) * (argc - 1)); + if (!cutargs) + return grub_errno; cutargc = argc - 1; grub_memcpy (cutargs + 1, args + 2, sizeof (cutargs[0]) * (argc - 2)); cutargs[0] = args[0]; @@ -333,7 +336,7 @@ grub_cmd_legacy_kernel (struct grub_command *mycmd __attribute__ ((unused)), if (!(cmd->func) (cmd, cutargc, cutargs)) { kernel_type = LINUX; - return GRUB_ERR_NONE; + goto out; } } grub_errno = GRUB_ERR_NONE; @@ -348,7 +351,7 @@ grub_cmd_legacy_kernel (struct grub_command *mycmd __attribute__ ((unused)), if (!(cmd->func) (cmd, argc, args)) { kernel_type = MULTIBOOT; - return GRUB_ERR_NONE; + goto out; } } grub_errno = GRUB_ERR_NONE; @@ -413,7 +416,7 @@ grub_cmd_legacy_kernel (struct grub_command *mycmd __attribute__ ((unused)), if (!(cmd->func) (cmd, cutargc, cutargs)) { kernel_type = KFREEBSD; - return GRUB_ERR_NONE; + goto out; } } grub_errno = GRUB_ERR_NONE; @@ -422,6 +425,8 @@ grub_cmd_legacy_kernel (struct grub_command *mycmd __attribute__ ((unused)), char **bsdargs; int bsdargc; char bsddevname[sizeof ("wdXXXXXXXXXXXXY")]; + int found = 0; + if (bsd_device == -1) { bsdargs = cutargs; @@ -432,6 +437,11 @@ grub_cmd_legacy_kernel (struct grub_command *mycmd __attribute__ ((unused)), char rbuf[3] = "-r"; bsdargc = cutargc + 2; bsdargs = grub_malloc (sizeof (bsdargs[0]) * bsdargc); + if (!bsdargs) + { + err = grub_errno; + goto out; + } grub_memcpy (bsdargs, args, argc * sizeof (bsdargs[0])); bsdargs[argc] = rbuf; bsdargs[argc + 1] = bsddevname; @@ -447,7 +457,8 @@ grub_cmd_legacy_kernel (struct grub_command *mycmd __attribute__ ((unused)), if (!(cmd->func) (cmd, bsdargc, bsdargs)) { kernel_type = KNETBSD; - return GRUB_ERR_NONE; + found = 1; + goto free_bsdargs; } } grub_errno = GRUB_ERR_NONE; @@ -460,20 +471,28 @@ grub_cmd_legacy_kernel (struct grub_command *mycmd __attribute__ ((unused)), if (!(cmd->func) (cmd, bsdargc, bsdargs)) { kernel_type = KOPENBSD; - return GRUB_ERR_NONE; + found = 1; + goto free_bsdargs; } } grub_errno = GRUB_ERR_NONE; } + +free_bsdargs: if (bsdargs != cutargs) grub_free (bsdargs); + if (found) + goto out; } } } while (0); - return grub_error (GRUB_ERR_BAD_OS, "couldn't load file %s", - args[0]); + err = grub_error (GRUB_ERR_BAD_OS, "couldn't load file %s", + args[0]); +out: + grub_free (cutargs); + return err; } static grub_err_t @@ -534,15 +553,17 @@ grub_cmd_legacy_initrdnounzip (struct grub_command *mycmd __attribute__ ((unused char **newargs; grub_err_t err; char nounzipbuf[10] = "--nounzip"; + + cmd = grub_command_find ("module"); + if (!cmd) + return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("can't find command `%s'"), + "module"); + newargs = grub_malloc ((argc + 1) * sizeof (newargs[0])); if (!newargs) return grub_errno; grub_memcpy (newargs + 1, args, argc * sizeof (newargs[0])); newargs[0] = nounzipbuf; - cmd = grub_command_find ("module"); - if (!cmd) - return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("can't find command `%s'"), - "module"); err = cmd->func (cmd, argc + 1, newargs); grub_free (newargs); From 9b4256bf059f30e3f707cd3eb0d8e6db96b19a3f Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sat, 16 Jan 2016 20:48:33 +0300 Subject: [PATCH 648/722] net: fix memory leaks Found by: Coverity scan. CID: 96638, 96648 --- grub-core/net/net.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/grub-core/net/net.c b/grub-core/net/net.c index 85b0cf774..d07029b34 100644 --- a/grub-core/net/net.c +++ b/grub-core/net/net.c @@ -299,12 +299,6 @@ grub_net_ipv6_get_link_local (struct grub_net_card *card, char *ptr; grub_net_network_level_address_t addr; - name = grub_malloc (grub_strlen (card->name) - + GRUB_NET_MAX_STR_HWADDR_LEN - + sizeof (":link")); - if (!name) - return NULL; - addr.type = GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV6; addr.ipv6[0] = grub_cpu_to_be64_compile_time (0xfe80ULL << 48); addr.ipv6[1] = grub_net_ipv6_get_id (hwaddr); @@ -317,6 +311,12 @@ grub_net_ipv6_get_link_local (struct grub_net_card *card, return inf; } + name = grub_malloc (grub_strlen (card->name) + + GRUB_NET_MAX_STR_HWADDR_LEN + + sizeof (":link")); + if (!name) + return NULL; + ptr = grub_stpcpy (name, card->name); if (grub_net_hwaddr_cmp (&card->default_address, hwaddr) != 0) { @@ -1421,7 +1421,10 @@ grub_net_fs_open (struct grub_file *file_out, const char *name) file->device->net->packs.last = NULL; file->device->net->name = grub_strdup (name); if (!file->device->net->name) - return grub_errno; + { + grub_free (file); + return grub_errno; + } err = file->device->net->protocol->open (file, name); if (err) From d4561cd080b6511e62bfbf27f443262fd7a5e5be Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sat, 16 Jan 2016 20:59:50 +0300 Subject: [PATCH 649/722] tcp: fix memory leaks Found by: Coverity scan. CID: 96639, 96647 --- grub-core/net/tcp.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/grub-core/net/tcp.c b/grub-core/net/tcp.c index 576f68498..e8ad34b84 100644 --- a/grub-core/net/tcp.c +++ b/grub-core/net/tcp.c @@ -606,10 +606,15 @@ grub_net_tcp_open (char *server, nb = grub_netbuff_alloc (sizeof (*tcph) + 128); if (!nb) - return NULL; + { + grub_free (socket); + return NULL; + } + err = grub_netbuff_reserve (nb, 128); if (err) { + grub_free (socket); grub_netbuff_free (nb); return NULL; } @@ -617,12 +622,14 @@ grub_net_tcp_open (char *server, err = grub_netbuff_put (nb, sizeof (*tcph)); if (err) { + grub_free (socket); grub_netbuff_free (nb); return NULL; } socket->pq = grub_priority_queue_new (sizeof (struct grub_net_buff *), cmp); if (!socket->pq) { + grub_free (socket); grub_netbuff_free (nb); return NULL; } @@ -978,6 +985,7 @@ grub_net_recv_tcp_packet (struct grub_net_buff *nb, cmp); if (!sock->pq) { + grub_free (sock); grub_netbuff_free (nb); return grub_errno; } From 77002c65d3532384682dd1ac861f4349089c5704 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sat, 16 Jan 2016 21:27:57 +0300 Subject: [PATCH 650/722] tftp: fix memory leaks in open If protocol open fails, file is immediately freed, so data was leaked. Found by: Coverity scan. CID: 96659 --- grub-core/net/tftp.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/grub-core/net/tftp.c b/grub-core/net/tftp.c index 1319671ff..7d90bf66e 100644 --- a/grub-core/net/tftp.c +++ b/grub-core/net/tftp.c @@ -326,7 +326,10 @@ tftp_open (struct grub_file *file, const char *filename) grub_netbuff_reserve (&nb, 1500); err = grub_netbuff_push (&nb, sizeof (*tftph)); if (err) - return err; + { + grub_free (data); + return err; + } tftph = (struct tftphdr *) nb.data; @@ -361,19 +364,26 @@ tftp_open (struct grub_file *file, const char *filename) err = grub_netbuff_unput (&nb, nb.tail - (nb.data + hdrlen)); if (err) - return err; + { + grub_free (data); + return err; + } file->not_easily_seekable = 1; file->data = data; data->pq = grub_priority_queue_new (sizeof (struct grub_net_buff *), cmp); if (!data->pq) - return grub_errno; + { + grub_free (data); + return grub_errno; + } err = grub_net_resolve_address (file->device->net->server, &addr); if (err) { destroy_pq (data); + grub_free (data); return err; } @@ -383,6 +393,7 @@ tftp_open (struct grub_file *file, const char *filename) if (!data->sock) { destroy_pq (data); + grub_free (data); return grub_errno; } @@ -396,6 +407,7 @@ tftp_open (struct grub_file *file, const char *filename) { grub_net_udp_close (data->sock); destroy_pq (data); + grub_free (data); return err; } grub_net_poll_cards (GRUB_NET_INTERVAL + (i * GRUB_NET_INTERVAL_ADDITION), @@ -412,6 +424,7 @@ tftp_open (struct grub_file *file, const char *filename) { grub_net_udp_close (data->sock); destroy_pq (data); + grub_free (data); return grub_errno; } From f826d914e2fc390b6e7b6767e6aefcea8dbe95a7 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sat, 16 Jan 2016 21:47:28 +0300 Subject: [PATCH 651/722] grub-probe: fix memory leak Found by: Coverity scan. CID: 73783 --- util/grub-probe.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/util/grub-probe.c b/util/grub-probe.c index 36b7f8bcb..8ac527d2f 100644 --- a/util/grub-probe.c +++ b/util/grub-probe.c @@ -279,7 +279,7 @@ probe (const char *path, char **device_names, char delim) printf ("%s", *curdev); putchar (delim); } - return; + goto free_device_names; } if (print == PRINT_DISK) @@ -297,7 +297,7 @@ probe (const char *path, char **device_names, char delim) putchar (delim); free (disk); } - return; + goto free_device_names; } for (curdev = device_names; *curdev; curdev++) @@ -669,6 +669,7 @@ probe (const char *path, char **device_names, char delim) free (*curdrive); free (drives_names); +free_device_names: if (path != NULL) { for (curdev = device_names; *curdev; curdev++) From 95440b41d33c30ebd12d16f042d60ca700a8f4d8 Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Sat, 16 Jan 2016 20:37:15 +0000 Subject: [PATCH 652/722] ahci, ehci: Fix typos --- grub-core/bus/usb/ehci.c | 2 +- grub-core/disk/ahci.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/grub-core/bus/usb/ehci.c b/grub-core/bus/usb/ehci.c index 8ece40086..c986c24f6 100644 --- a/grub-core/bus/usb/ehci.c +++ b/grub-core/bus/usb/ehci.c @@ -1121,7 +1121,7 @@ grub_ehci_free_tds (struct grub_ehci *e, grub_ehci_td_t td, token = grub_le_to_cpu32 (td->token); to_transfer = (token & GRUB_EHCI_TOTAL_MASK) >> GRUB_EHCI_TOTAL_OFF; - /* Check state of TD - if it did not transfered + /* Check state of TD - if it did not transfer * whole data then set last_trans - it should be last executed TD * in case when something went wrong. */ if (transfer && (td->size != to_transfer)) diff --git a/grub-core/disk/ahci.c b/grub-core/disk/ahci.c index fc640d5d4..494a1b773 100644 --- a/grub-core/disk/ahci.c +++ b/grub-core/disk/ahci.c @@ -32,7 +32,7 @@ GRUB_MOD_LICENSE ("GPLv3+"); struct grub_ahci_cmd_head { grub_uint32_t config; - grub_uint32_t transfered; + grub_uint32_t transferred; grub_uint64_t command_table_base; grub_uint32_t unused[4]; }; @@ -954,7 +954,7 @@ grub_ahci_readwrite_real (struct grub_ahci_device *dev, grub_dprintf ("ahci", "AHCI tfd = %x\n", dev->hba->ports[dev->port].task_file_data); - dev->command_list[0].transfered = 0; + dev->command_list[0].transferred = 0; dev->command_list[0].command_table_base = grub_dma_get_phys (dev->command_table_chunk); @@ -1044,7 +1044,7 @@ grub_ahci_readwrite_real (struct grub_ahci_device *dev, dev->hba->ports[dev->port].command_issue, dev->hba->ports[dev->port].intstatus, dev->hba->ports[dev->port].task_file_data, - dev->command_list[0].transfered, + dev->command_list[0].transferred, dev->hba->ports[dev->port].sata_error, ((grub_uint32_t *) grub_dma_get_virt (dev->rfis))[0x00], ((grub_uint32_t *) grub_dma_get_virt (dev->rfis))[0x18]); From 92bbf2571463e230682406a9d631580f928af11f Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Sat, 16 Jan 2016 20:40:55 +0000 Subject: [PATCH 653/722] loader/bsd: Fix signed/unsigned comparison --- grub-core/loader/i386/bsdXX.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/loader/i386/bsdXX.c b/grub-core/loader/i386/bsdXX.c index 0d14deeb7..af6741d15 100644 --- a/grub-core/loader/i386/bsdXX.c +++ b/grub-core/loader/i386/bsdXX.c @@ -56,7 +56,7 @@ read_headers (grub_file_t file, const char *filename, Elf_Ehdr *e, char **shdr) return grub_errno; if (grub_file_read (file, *shdr, (grub_uint32_t) e->e_shnum * e->e_shentsize) - != (grub_uint32_t) e->e_shnum * e->e_shentsize) + != (grub_ssize_t) ((grub_uint32_t) e->e_shnum * e->e_shentsize)) { if (grub_errno) return grub_errno; From 47e67d809cca22b77ea73ab4dbe04cfd5b11bae1 Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Wed, 20 Jan 2016 15:56:55 +0000 Subject: [PATCH 654/722] Remove pragmas related to -Wunreachable-code -Wunreachable-code has been a no-op since GCC 4.5; GRUB hasn't been compiled with it since 2012; and GCC 6 produces "error: '-Wunreachable-code' is not an option that controls warnings" for these. Fixes Debian bug #812047. --- grub-core/lib/pbkdf2.c | 1 - grub-core/script/parser.y | 1 - 2 files changed, 2 deletions(-) diff --git a/grub-core/lib/pbkdf2.c b/grub-core/lib/pbkdf2.c index 01cee3951..28aa96c46 100644 --- a/grub-core/lib/pbkdf2.c +++ b/grub-core/lib/pbkdf2.c @@ -31,7 +31,6 @@ GRUB_MOD_LICENSE ("GPLv2+"); desired derived output length DKLEN. Output buffer is DK which must have room for at least DKLEN octets. The output buffer will be filled with the derived data. */ -#pragma GCC diagnostic ignored "-Wunreachable-code" gcry_err_code_t grub_crypto_pbkdf2 (const struct gcry_md_spec *md, diff --git a/grub-core/script/parser.y b/grub-core/script/parser.y index 1d60e9de2..4f0ab8319 100644 --- a/grub-core/script/parser.y +++ b/grub-core/script/parser.y @@ -30,7 +30,6 @@ #include "grub_script.tab.h" -#pragma GCC diagnostic ignored "-Wunreachable-code" #pragma GCC diagnostic ignored "-Wmissing-declarations" %} From 7c6c2ad42c3a3a2cbe73ef7808cc6b85fc895ac0 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 8 Jan 2016 16:22:19 +0100 Subject: [PATCH 655/722] i386-ieee1275: Increase maximum heap size to accomodate highres graphi tests --- grub-core/kern/ieee1275/init.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/grub-core/kern/ieee1275/init.c b/grub-core/kern/ieee1275/init.c index 4303509f2..12590225e 100644 --- a/grub-core/kern/ieee1275/init.c +++ b/grub-core/kern/ieee1275/init.c @@ -46,11 +46,19 @@ #define HEAP_MIN_SIZE (unsigned long) (2 * 1024 * 1024) /* The maximum heap size we're going to claim */ +#ifdef __i386__ +#define HEAP_MAX_SIZE (unsigned long) (64 * 1024 * 1024) +#else #define HEAP_MAX_SIZE (unsigned long) (32 * 1024 * 1024) +#endif /* If possible, we will avoid claiming heap above this address, because it seems to cause relocation problems with OSes that link at 4 MiB */ +#ifdef __i386__ +#define HEAP_MAX_ADDR (unsigned long) (64 * 1024 * 1024) +#else #define HEAP_MAX_ADDR (unsigned long) (32 * 1024 * 1024) +#endif extern char _start[]; extern char _end[]; From cc2ed410391773c2b6f094d9d699ac219adbc499 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 8 Jan 2016 16:22:47 +0100 Subject: [PATCH 656/722] arm: Ignore qemu clock bug --- grub-core/tests/sleep_test.c | 9 ++++++++- tests/grub_cmd_sleep.in | 5 +++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/grub-core/tests/sleep_test.c b/grub-core/tests/sleep_test.c index 3dda30312..3d11c717c 100644 --- a/grub-core/tests/sleep_test.c +++ b/grub-core/tests/sleep_test.c @@ -33,12 +33,19 @@ sleep_test (void) { struct grub_datetime st, en; grub_int32_t stu = 0, enu = 0; + int is_delayok; grub_test_assert (!grub_get_datetime (&st), "Couldn't retrieve start time"); grub_millisleep (10000); grub_test_assert (!grub_get_datetime (&en), "Couldn't retrieve end time"); grub_test_assert (grub_datetime2unixtime (&st, &stu), "Invalid date"); grub_test_assert (grub_datetime2unixtime (&en, &enu), "Invalid date"); - grub_test_assert (enu - stu >= 9 && enu - stu <= 11, "Interval out of range: %d", enu-stu); + is_delayok = (enu - stu >= 9 && enu - stu <= 11); +#ifdef __arm__ + /* Ignore QEMU bug */ + if (enu - stu >= 15 && enu - stu <= 17) + is_delayok = 1; +#endif + grub_test_assert (is_delayok, "Interval out of range: %d", enu-stu); } diff --git a/tests/grub_cmd_sleep.in b/tests/grub_cmd_sleep.in index 1c84fbfbb..eb362aa24 100644 --- a/tests/grub_cmd_sleep.in +++ b/tests/grub_cmd_sleep.in @@ -14,6 +14,11 @@ dt=`echo 'date; sleep 10; date' | @builddir@/grub-shell` dt1="$(date -u -d "$(echo "$dt" | head -n 1)" +%s)" dt2="$(date -u -d "$(echo "$dt" | tail -n 1)" +%s)" +# Ignore QEMU bug +if [ "${grub_modinfo_target_cpu}" = arm ] && [ $((dt2 - dt1)) -ge 15 ] && [ $((dt2 - dt1)) -le 17 ]; then + exit 0; +fi + if [ $((dt2 - dt1)) -gt 11 ] || [ $((dt2 - dt1)) -lt 9 ]; then echo "Interval not in range $dt2-$dt1 != 10" exit 1 From 0edd750e50698854068358ea53528100a9192902 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 22 Jan 2016 10:18:47 +0100 Subject: [PATCH 657/722] xen_boot: Remove obsolete module type distinctions. --- grub-core/loader/arm64/xen_boot.c | 148 ++++++------------------------ 1 file changed, 30 insertions(+), 118 deletions(-) diff --git a/grub-core/loader/arm64/xen_boot.c b/grub-core/loader/arm64/xen_boot.c index d1a218929..a914eb8e2 100644 --- a/grub-core/loader/arm64/xen_boot.c +++ b/grub-core/loader/arm64/xen_boot.c @@ -37,16 +37,6 @@ GRUB_MOD_LICENSE ("GPLv3+"); #define XEN_HYPERVISOR_NAME "xen_hypervisor" - -#define MODULE_DEFAULT_ALIGN (0x0) -#define MODULE_IMAGE_MIN_ALIGN MODULE_DEFAULT_ALIGN -#define MODULE_INITRD_MIN_ALIGN MODULE_DEFAULT_ALIGN -#define MODULE_XSM_MIN_ALIGN MODULE_DEFAULT_ALIGN -#define MODULE_CUSTOM_MIN_ALIGN MODULE_DEFAULT_ALIGN - -#define MODULE_IMAGE_COMPATIBLE "multiboot,kernel\0multiboot,module" -#define MODULE_INITRD_COMPATIBLE "multiboot,ramdisk\0multiboot,module" -#define MODULE_XSM_COMPATIBLE "xen,xsm-policy\0multiboot,module" #define MODULE_CUSTOM_COMPATIBLE "multiboot,module" /* This maximum size is defined in Power.org ePAPR V1.1 @@ -74,14 +64,6 @@ enum module_type }; typedef enum module_type module_type_t; -struct fdt_node_info -{ - module_type_t type; - - const char *compat_string; - grub_size_t compat_string_size; -}; - struct xen_hypervisor_header { struct grub_arm64_linux_kernel_header efi_head; @@ -98,7 +80,7 @@ struct xen_boot_binary { struct xen_boot_binary *next; struct xen_boot_binary **prev; - const char *name; + int is_hypervisor; grub_addr_t start; grub_size_t size; @@ -106,8 +88,6 @@ struct xen_boot_binary char *cmdline; int cmdline_size; - - struct fdt_node_info node_info; }; static grub_dl_t my_mod; @@ -116,19 +96,6 @@ static int loaded; static struct xen_boot_binary *xen_hypervisor; static struct xen_boot_binary *module_head; -static const grub_size_t module_default_align[] = { - MODULE_IMAGE_MIN_ALIGN, - MODULE_INITRD_MIN_ALIGN, - MODULE_XSM_MIN_ALIGN, - MODULE_CUSTOM_MIN_ALIGN -}; - -static const compat_string_struct_t default_compat_string[] = { - FDT_COMPATIBLE (MODULE_IMAGE_COMPATIBLE), - FDT_COMPATIBLE (MODULE_INITRD_COMPATIBLE), - FDT_COMPATIBLE (MODULE_XSM_COMPATIBLE), - FDT_COMPATIBLE (MODULE_CUSTOM_COMPATIBLE) -}; static __inline grub_addr_t xen_boot_address_align (grub_addr_t start, grub_size_t align) @@ -136,20 +103,6 @@ xen_boot_address_align (grub_addr_t start, grub_size_t align) return (align ? (ALIGN_UP (start, align)) : start); } -/* set module type according to command name. */ -static grub_err_t -set_module_type (grub_command_t cmd, struct xen_boot_binary *module) -{ - if (!grub_strcmp (cmd->name, "xen_linux")) - module->node_info.type = MODULE_IMAGE; - else if (!grub_strcmp (cmd->name, "xen_initrd")) - module->node_info.type = MODULE_INITRD; - else if (!grub_strcmp (cmd->name, "xen_xsm")) - module->node_info.type = MODULE_XSM; - - return GRUB_ERR_NONE; -} - static grub_err_t prepare_xen_hypervisor_params (void *xen_boot_fdt) { @@ -203,15 +156,11 @@ prepare_xen_module_params (struct xen_boot_binary *module, void *xen_boot_fdt) grub_fdt_add_subnode (xen_boot_fdt, chosen_node, module_name); retval = grub_fdt_set_prop (xen_boot_fdt, module_node, "compatible", - module->node_info.compat_string, - (grub_uint32_t) module-> - node_info.compat_string_size); + MODULE_CUSTOM_COMPATIBLE, sizeof(MODULE_CUSTOM_COMPATIBLE) - 1); if (retval) return grub_error (GRUB_ERR_IO, "failed to update FDT"); - grub_dprintf ("xen_loader", "Module %s compatible = %s size = 0x%lx\n", - module->name, module->node_info.compat_string, - module->node_info.compat_string_size); + grub_dprintf ("xen_loader", "Module\n"); retval = grub_fdt_set_reg64 (xen_boot_fdt, module_node, xen_boot_address_align (module->start, @@ -223,7 +172,7 @@ prepare_xen_module_params (struct xen_boot_binary *module, void *xen_boot_fdt) if (module->cmdline && module->cmdline_size > 0) { grub_dprintf ("xen_loader", - "Module %s cmdline : %s @ %p size:%d\n", module->name, + "Module cmdline : %s @ %p size:%d\n", module->cmdline, module->cmdline, module->cmdline_size); retval = grub_fdt_set_prop (xen_boot_fdt, module_node, "bootargs", @@ -233,8 +182,7 @@ prepare_xen_module_params (struct xen_boot_binary *module, void *xen_boot_fdt) } else { - grub_dprintf ("xen_loader", "Module %s has not bootargs!\n", - module->name); + grub_dprintf ("xen_loader", "Module has no bootargs!\n"); } return GRUB_ERR_NONE; @@ -251,8 +199,8 @@ finalize_params_xen_boot (void) additional_size += FDT_NODE_NAME_MAX_SIZE + xen_hypervisor->cmdline_size; FOR_LIST_ELEMENTS (module, module_head) { - additional_size += 6 * FDT_NODE_NAME_MAX_SIZE + module-> - node_info.compat_string_size + module->cmdline_size; + additional_size += 6 * FDT_NODE_NAME_MAX_SIZE + sizeof(MODULE_CUSTOM_COMPATIBLE) - 1 + + module->cmdline_size; } xen_boot_fdt = grub_fdt_load (additional_size); @@ -275,8 +223,7 @@ finalize_params_xen_boot (void) { if (module->start && module->size > 0) { - grub_dprintf ("xen_loader", "Module %s @ 0x%lx size:0x%lx\n", - module->name, + grub_dprintf ("xen_loader", "Module @ 0x%lx size:0x%lx\n", xen_boot_address_align (module->start, module->align), module->size); if (prepare_xen_module_params (module, xen_boot_fdt) != GRUB_ERR_NONE) @@ -284,7 +231,7 @@ finalize_params_xen_boot (void) } else { - grub_dprintf ("xen_loader", "Module info error: %s!\n", module->name); + grub_dprintf ("xen_loader", "Module info error!\n"); goto fail; } } @@ -327,19 +274,16 @@ single_binary_unload (struct xen_boot_binary *binary) { grub_free (binary->cmdline); grub_dprintf ("xen_loader", - "Module %s cmdline memory free @ %p size: %d\n", - binary->name, binary->cmdline, binary->cmdline_size); + "Module cmdline memory free @ %p size: %d\n", + binary->cmdline, binary->cmdline_size); } - if (binary->node_info.type == MODULE_CUSTOM) - grub_free ((void *) binary->node_info.compat_string); - - if (grub_strcmp (binary->name, XEN_HYPERVISOR_NAME)) + if (!binary->is_hypervisor) grub_list_remove (GRUB_AS_LIST (binary)); grub_dprintf ("xen_loader", - "Module %s struct memory free @ %p size: 0x%lx\n", - binary->name, binary, sizeof (binary)); + "Module struct memory free @ %p size: 0x%lx\n", + binary, sizeof (binary)); grub_free (binary); return; @@ -377,8 +321,7 @@ xen_boot_binary_load (struct xen_boot_binary *binary, grub_file_t file, int argc, char *argv[]) { binary->size = grub_file_size (file); - grub_dprintf ("xen_loader", "Xen_boot %s file size: 0x%lx\n", - binary->name, binary->size); + grub_dprintf ("xen_loader", "Xen_boot file size: 0x%lx\n", binary->size); binary->start = (grub_addr_t) grub_efi_allocate_pages (0, @@ -391,8 +334,8 @@ xen_boot_binary_load (struct xen_boot_binary *binary, grub_file_t file, return; } - grub_dprintf ("xen_loader", "Xen_boot %s numpages: 0x%lx\n", - binary->name, GRUB_EFI_BYTES_TO_PAGES (binary->size + binary->align)); + grub_dprintf ("xen_loader", "Xen_boot numpages: 0x%lx\n", + GRUB_EFI_BYTES_TO_PAGES (binary->size + binary->align)); if (grub_file_read (file, (void *) xen_boot_address_align (binary->start, binary->align), @@ -416,7 +359,7 @@ xen_boot_binary_load (struct xen_boot_binary *binary, grub_file_t file, grub_create_loader_cmdline (argc - 1, argv + 1, binary->cmdline, binary->cmdline_size); grub_dprintf ("xen_loader", - "Xen_boot %s cmdline @ %p %s, size: %d\n", binary->name, + "Xen_boot cmdline @ %p %s, size: %d\n", binary->cmdline, binary->cmdline, binary->cmdline_size); } else @@ -430,7 +373,8 @@ xen_boot_binary_load (struct xen_boot_binary *binary, grub_file_t file, } static grub_err_t -grub_cmd_xen_module (grub_command_t cmd, int argc, char *argv[]) +grub_cmd_xen_module (grub_command_t cmd __attribute__((unused)), + int argc, char *argv[]) { struct xen_boot_binary *module = NULL; @@ -454,34 +398,10 @@ grub_cmd_xen_module (grub_command_t cmd, int argc, char *argv[]) if (!module) return grub_errno; - /* process all the options and get module type */ - if (set_module_type (cmd, module) != GRUB_ERR_NONE) - goto fail; - switch (module->node_info.type) - { - case MODULE_IMAGE: - case MODULE_INITRD: - case MODULE_XSM: - module->node_info.compat_string = - default_compat_string[module->node_info.type].compat_string; - module->node_info.compat_string_size = - default_compat_string[module->node_info.type].size; - break; + module->is_hypervisor = 0; + module->align = 4096; - case MODULE_CUSTOM: - /* we have set the node_info in set_module_type */ - break; - - default: - return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("invalid argument")); - } - module->name = module->node_info.compat_string; - module->align = module_default_align[module->node_info.type]; - - grub_dprintf ("xen_loader", "Init %s module and node info:\n" - "compatible %s\ncompat_string_size 0x%lx\n", - module->name, module->node_info.compat_string, - module->node_info.compat_string_size); + grub_dprintf ("xen_loader", "Init module and node info\n"); file = grub_file_open (argv[0]); if (!file) @@ -491,7 +411,7 @@ grub_cmd_xen_module (grub_command_t cmd, int argc, char *argv[]) if (grub_errno == GRUB_ERR_NONE) grub_list_push (GRUB_AS_LIST_P (&module_head), GRUB_AS_LIST (module)); -fail: + fail: if (file) grub_file_close (file); if (grub_errno != GRUB_ERR_NONE) @@ -535,7 +455,7 @@ grub_cmd_xen_hypervisor (grub_command_t cmd __attribute__ ((unused)), if (!xen_hypervisor) return grub_errno; - xen_hypervisor->name = XEN_HYPERVISOR_NAME; + xen_hypervisor->is_hypervisor = 1; xen_hypervisor->align = (grub_size_t) sh.optional_header.section_alignment; xen_boot_binary_load (xen_hypervisor, file, argc, argv); @@ -559,29 +479,21 @@ fail: } static grub_command_t cmd_xen_hypervisor; -static grub_command_t cmd_xen_linux, cmd_xen_initrd, cmd_xen_xsm; +static grub_command_t cmd_xen_module; GRUB_MOD_INIT (xen_boot) { cmd_xen_hypervisor = grub_register_command ("xen_hypervisor", grub_cmd_xen_hypervisor, 0, N_("Load a xen hypervisor.")); - cmd_xen_linux = - grub_register_command ("xen_linux", grub_cmd_xen_module, 0, - N_("Load a xen linux kernel for dom0.")); - cmd_xen_initrd = - grub_register_command ("xen_initrd", grub_cmd_xen_module, 0, - N_("Load a xen initrd for dom0.")); - cmd_xen_xsm = - grub_register_command ("xen_xsm", grub_cmd_xen_module, 0, - N_("Load a xen security module.")); + cmd_xen_module = + grub_register_command ("xen_module", grub_cmd_xen_module, 0, + N_("Load a xen module.")); my_mod = mod; } GRUB_MOD_FINI (xen_boot) { grub_unregister_command (cmd_xen_hypervisor); - grub_unregister_command (cmd_xen_linux); - grub_unregister_command (cmd_xen_initrd); - grub_unregister_command (cmd_xen_xsm); + grub_unregister_command (cmd_xen_module); } From 64e2d139fe1c9133b0eda0a9da8e8c2c03368dea Mon Sep 17 00:00:00 2001 From: Michael Chang Date: Fri, 22 Jan 2016 11:05:32 +0100 Subject: [PATCH 658/722] Restore terminal settings on grub-emu exit. --- grub-core/kern/emu/main.c | 6 ++++++ grub-core/kern/emu/misc.c | 2 ++ 2 files changed, 8 insertions(+) diff --git a/grub-core/kern/emu/main.c b/grub-core/kern/emu/main.c index 51e8a5715..953a93c8a 100644 --- a/grub-core/kern/emu/main.c +++ b/grub-core/kern/emu/main.c @@ -65,6 +65,12 @@ grub_reboot (void) longjmp (main_env, 1); } +void +grub_exit (void) +{ + grub_reboot (); +} + void grub_machine_init (void) { diff --git a/grub-core/kern/emu/misc.c b/grub-core/kern/emu/misc.c index 06985013d..d361feb00 100644 --- a/grub-core/kern/emu/misc.c +++ b/grub-core/kern/emu/misc.c @@ -134,11 +134,13 @@ xasprintf (const char *fmt, ...) } #endif +#if !defined (GRUB_MACHINE_EMU) || defined (GRUB_UTIL) void grub_exit (void) { exit (1); } +#endif grub_uint64_t grub_get_time_ms (void) From dab148891ee64ba5420a11bdddad9983fc387954 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 22 Jan 2016 13:27:36 +0100 Subject: [PATCH 659/722] Document expr1 expr2 syntax for test command --- docs/grub.texi | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/grub.texi b/docs/grub.texi index 9a25a0bdb..f9173cc27 100644 --- a/docs/grub.texi +++ b/docs/grub.texi @@ -5042,6 +5042,8 @@ the length of @var{string} is zero @var{expression} is false @item @var{expression1} @code{-a} @var{expression2} both @var{expression1} and @var{expression2} are true +@item @var{expression1} @var{expression2} +both @var{expression1} and @var{expression2} are true. This syntax is not POSIX-compliant and is not recommended. @item @var{expression1} @code{-o} @var{expression2} either @var{expression1} or @var{expression2} is true @end table From ae3b83a4d4df75a01198a2fed7542391e7c449e0 Mon Sep 17 00:00:00 2001 From: Robert Elliott Date: Fri, 22 Jan 2016 13:32:30 +0100 Subject: [PATCH 660/722] efiemu: Handle persistent RAM and unknown possible future additions. --- grub-core/efiemu/mm.c | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/grub-core/efiemu/mm.c b/grub-core/efiemu/mm.c index d4a4f3aad..13af4ad0d 100644 --- a/grub-core/efiemu/mm.c +++ b/grub-core/efiemu/mm.c @@ -99,7 +99,8 @@ grub_efiemu_request_memalign (grub_size_t align, grub_size_t size, grub_size_t align_overhead; struct grub_efiemu_memrequest *ret, *cur, *prev; /* Check that the request is correct */ - if (type >= GRUB_EFI_MAX_MEMORY_TYPE || type <= GRUB_EFI_LOADER_CODE) + if (type <= GRUB_EFI_LOADER_CODE || type == GRUB_EFI_PERSISTENT_MEMORY || + type >= GRUB_EFI_MAX_MEMORY_TYPE) return -2; /* Add new size to requested size */ @@ -166,6 +167,13 @@ efiemu_alloc_requests (void) GRUB_EFI_MEMORY_MAPPED_IO, GRUB_EFI_MEMORY_MAPPED_IO_PORT_SPACE, GRUB_EFI_PAL_CODE + + /* + * These are not allocatable: + * GRUB_EFI_RESERVED_MEMORY_TYPE + * GRUB_EFI_PERSISTENT_MEMORY + * >= GRUB_EFI_MAX_MEMORY_TYPE + */ }; /* Compute total memory needed */ @@ -402,6 +410,10 @@ fill_hook (grub_uint64_t addr, grub_uint64_t size, grub_memory_type_t type, return grub_efiemu_add_to_mmap (addr, size, GRUB_EFI_ACPI_MEMORY_NVS); + case GRUB_MEMORY_PRAM: + case GRUB_MEMORY_PMEM: + return grub_efiemu_add_to_mmap (addr, size, + GRUB_EFI_PERSISTENT_MEMORY); default: grub_dprintf ("efiemu", "Unknown memory type %d. Assuming unusable\n", type); @@ -445,7 +457,7 @@ grub_efiemu_mmap_iterate (grub_memory_hook_t hook, void *hook_data) case GRUB_EFI_MEMORY_MAPPED_IO: case GRUB_EFI_MEMORY_MAPPED_IO_PORT_SPACE: case GRUB_EFI_PAL_CODE: - case GRUB_EFI_MAX_MEMORY_TYPE: + default: hook (efiemu_mmap[i].physical_start, efiemu_mmap[i].num_pages * 4096, GRUB_MEMORY_RESERVED, hook_data); break; @@ -468,6 +480,12 @@ grub_efiemu_mmap_iterate (grub_memory_hook_t hook, void *hook_data) hook (efiemu_mmap[i].physical_start, efiemu_mmap[i].num_pages * 4096, GRUB_MEMORY_NVS, hook_data); break; + + case GRUB_EFI_PERSISTENT_MEMORY: + hook (efiemu_mmap[i].physical_start, efiemu_mmap[i].num_pages * 4096, + GRUB_MEMORY_PMEM, hook_data); + break; + } return 0; @@ -503,7 +521,8 @@ grub_efiemu_mmap_sort_and_uniq (void) [GRUB_EFI_ACPI_MEMORY_NVS] = 3, [GRUB_EFI_MEMORY_MAPPED_IO] = 4, [GRUB_EFI_MEMORY_MAPPED_IO_PORT_SPACE] = 4, - [GRUB_EFI_PAL_CODE] = 4 + [GRUB_EFI_PAL_CODE] = 4, + [GRUB_EFI_PERSISTENT_MEMORY] = 4 }; int i, j, k, done; From 5f2b285bf8d645bf0c7a46dd5434d83824f23278 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 22 Jan 2016 13:50:53 +0100 Subject: [PATCH 661/722] Document cpuid -p --- docs/grub.texi | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/docs/grub.texi b/docs/grub.texi index f9173cc27..0afdd8ccd 100644 --- a/docs/grub.texi +++ b/docs/grub.texi @@ -4073,12 +4073,15 @@ after @command{configfile} returns. @node cpuid @subsection cpuid -@deffn Command cpuid [-l] +@deffn Command cpuid [-l] [-p] Check for CPU features. This command is only available on x86 systems. With the @option{-l} option, return true if the CPU supports long mode (64-bit). +With the @option{-p} option, return true if the CPU supports Physical +Address Extension (PAE). + If invoked without options, this command currently behaves as if it had been invoked with @option{-l}. This may change in the future. @end deffn From b6a03dfd327489d53ee07c6d7d593b99c7b7cb62 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 22 Jan 2016 14:10:30 +0100 Subject: [PATCH 662/722] efiemu: Fix compilation failure --- grub-core/efiemu/mm.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/grub-core/efiemu/mm.c b/grub-core/efiemu/mm.c index 13af4ad0d..e606dbffc 100644 --- a/grub-core/efiemu/mm.c +++ b/grub-core/efiemu/mm.c @@ -410,8 +410,8 @@ fill_hook (grub_uint64_t addr, grub_uint64_t size, grub_memory_type_t type, return grub_efiemu_add_to_mmap (addr, size, GRUB_EFI_ACPI_MEMORY_NVS); - case GRUB_MEMORY_PRAM: - case GRUB_MEMORY_PMEM: + case GRUB_MEMORY_PERSISTENT: + case GRUB_MEMORY_PERSISTENT_LEGACY: return grub_efiemu_add_to_mmap (addr, size, GRUB_EFI_PERSISTENT_MEMORY); default: @@ -483,7 +483,7 @@ grub_efiemu_mmap_iterate (grub_memory_hook_t hook, void *hook_data) case GRUB_EFI_PERSISTENT_MEMORY: hook (efiemu_mmap[i].physical_start, efiemu_mmap[i].num_pages * 4096, - GRUB_MEMORY_PMEM, hook_data); + GRUB_MEMORY_PERSISTENT, hook_data); break; } From 605eecc985b677d196b558d4d8cec6592a68e462 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 22 Jan 2016 19:09:37 +0100 Subject: [PATCH 663/722] arm64: Add support for relocations needed for linaro gcc --- grub-core/kern/arm64/dl.c | 18 ++++++++++++++ grub-core/kern/arm64/dl_helper.c | 40 ++++++++++++++++++++++++++++++++ include/grub/arm64/reloc.h | 8 +++++++ include/grub/elf.h | 3 +++ util/grub-mkimagexx.c | 31 +++++++++++++++++++++++++ util/grub-module-verifier.c | 8 ++++++- 6 files changed, 107 insertions(+), 1 deletion(-) diff --git a/grub-core/kern/arm64/dl.c b/grub-core/kern/arm64/dl.c index e19ba6a0d..cf50d7250 100644 --- a/grub-core/kern/arm64/dl.c +++ b/grub-core/kern/arm64/dl.c @@ -132,6 +132,12 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr, *abs_place = (grub_uint64_t) sym_addr; } break; + case R_AARCH64_ADD_ABS_LO12_NC: + grub_arm64_set_abs_lo12 (place, sym_addr); + break; + case R_AARCH64_LDST64_ABS_LO12_NC: + grub_arm64_set_abs_lo12_ldst64 (place, sym_addr); + break; case R_AARCH64_CALL26: case R_AARCH64_JUMP26: { @@ -154,6 +160,18 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr, grub_arm64_set_xxxx26_offset (place, offset); } break; + case R_AARCH64_ADR_PREL_PG_HI21: + { + grub_int64_t offset = (sym_addr & ~0xfffULL) - (((grub_uint64_t) place) & ~0xfffULL); + + if (!grub_arm64_check_hi21_signed (offset)) + return grub_error (GRUB_ERR_BAD_MODULE, + "HI21 out of range"); + + grub_arm64_set_hi21 (place, offset); + } + break; + default: return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, N_("relocation 0x%x is not implemented yet"), diff --git a/grub-core/kern/arm64/dl_helper.c b/grub-core/kern/arm64/dl_helper.c index d213ab93e..f031b1ae9 100644 --- a/grub-core/kern/arm64/dl_helper.c +++ b/grub-core/kern/arm64/dl_helper.c @@ -53,3 +53,43 @@ grub_arm64_set_xxxx26_offset (grub_uint32_t *place, grub_int64_t offset) *place &= insmask; *place |= grub_cpu_to_le32 (offset >> 2) & ~insmask; } + +int +grub_arm64_check_hi21_signed (grub_int64_t offset) +{ + if (offset != (grub_int64_t)(grub_int32_t)offset) + return 0; + return 1; +} + +void +grub_arm64_set_hi21 (grub_uint32_t *place, grub_int64_t offset) +{ + const grub_uint32_t insmask = grub_cpu_to_le32_compile_time (0x9f00001f); + grub_uint32_t val; + + offset >>= 12; + + val = ((offset & 3) << 29) | (((offset >> 2) & 0x7ffff) << 5); + + *place &= insmask; + *place |= grub_cpu_to_le32 (val) & ~insmask; +} + +void +grub_arm64_set_abs_lo12 (grub_uint32_t *place, grub_int64_t target) +{ + const grub_uint32_t insmask = grub_cpu_to_le32_compile_time (0xffc003ff); + + *place &= insmask; + *place |= grub_cpu_to_le32 (target << 10) & ~insmask; +} + +void +grub_arm64_set_abs_lo12_ldst64 (grub_uint32_t *place, grub_int64_t target) +{ + const grub_uint32_t insmask = grub_cpu_to_le32_compile_time (0xfff803ff); + + *place &= insmask; + *place |= grub_cpu_to_le32 (target << 7) & ~insmask; +} diff --git a/include/grub/arm64/reloc.h b/include/grub/arm64/reloc.h index 4aed3d715..452c14822 100644 --- a/include/grub/arm64/reloc.h +++ b/include/grub/arm64/reloc.h @@ -22,5 +22,13 @@ int grub_arm_64_check_xxxx26_offset (grub_int64_t offset); void grub_arm64_set_xxxx26_offset (grub_uint32_t *place, grub_int64_t offset); +int +grub_arm64_check_hi21_signed (grub_int64_t offset); +void +grub_arm64_set_hi21 (grub_uint32_t *place, grub_int64_t offset); +void +grub_arm64_set_abs_lo12 (grub_uint32_t *place, grub_int64_t target); +void +grub_arm64_set_abs_lo12_ldst64 (grub_uint32_t *place, grub_int64_t target); #endif diff --git a/include/grub/elf.h b/include/grub/elf.h index caa796390..db15acecf 100644 --- a/include/grub/elf.h +++ b/include/grub/elf.h @@ -2068,6 +2068,9 @@ typedef Elf32_Addr Elf32_Conflict; #define R_AARCH64_NONE 0 /* No relocation. */ #define R_AARCH64_ABS64 257 /* Direct 64 bit. */ #define R_AARCH64_ABS32 258 /* Direct 32 bit. */ +#define R_AARCH64_ADR_PREL_PG_HI21 275 +#define R_AARCH64_ADD_ABS_LO12_NC 277 +#define R_AARCH64_LDST64_ABS_LO12_NC 286 #define R_AARCH64_JUMP26 282 /* 26-bit relative. */ #define R_AARCH64_CALL26 283 /* 26-bit relative. */ #define R_AARCH64_COPY 1024 /* Copy symbol at runtime. */ diff --git a/util/grub-mkimagexx.c b/util/grub-mkimagexx.c index 0e0c6f7a1..06b6a724d 100644 --- a/util/grub-mkimagexx.c +++ b/util/grub-mkimagexx.c @@ -836,6 +836,14 @@ SUFFIX (relocate_addresses) (Elf_Ehdr *e, Elf_Shdr *sections, *target = grub_host_to_target64 (grub_target_to_host64 (*target) + sym_addr); } break; + case R_AARCH64_ADD_ABS_LO12_NC: + grub_arm64_set_abs_lo12 ((grub_uint32_t *) target, + sym_addr); + break; + case R_AARCH64_LDST64_ABS_LO12_NC: + grub_arm64_set_abs_lo12_ldst64 ((grub_uint32_t *) target, + sym_addr); + break; case R_AARCH64_JUMP26: case R_AARCH64_CALL26: { @@ -848,6 +856,17 @@ SUFFIX (relocate_addresses) (Elf_Ehdr *e, Elf_Shdr *sections, sym_addr); } break; + case R_AARCH64_ADR_PREL_PG_HI21: + { + sym_addr &= ~0xfffULL; + sym_addr -= (offset + SUFFIX (entry_point)) & ~0xfffULL; + if (!grub_arm64_check_hi21_signed (sym_addr)) + grub_util_error ("%s", "CALL26 Relocation out of range"); + + grub_arm64_set_hi21((grub_uint32_t *)target, + sym_addr); + } + break; default: grub_util_error (_("relocation 0x%x is not implemented yet"), (unsigned int) ELF_R_TYPE (info)); @@ -1200,6 +1219,15 @@ SUFFIX (make_reloc_section) (Elf_Ehdr *e, void **out, case R_AARCH64_CALL26: case R_AARCH64_JUMP26: break; + /* Page-relative relocations do not require fixup entries. */ + case R_AARCH64_ADR_PREL_PG_HI21: + /* We page-align the whole kernel, so no need + for fixup entries. + */ + case R_AARCH64_ADD_ABS_LO12_NC: + case R_AARCH64_LDST64_ABS_LO12_NC: + break; + default: grub_util_error (_("relocation 0x%x is not implemented yet"), (unsigned int) ELF_R_TYPE (info)); @@ -1343,6 +1371,9 @@ SUFFIX (locate_sections) (const char *kernel_path, Elf_Shdr *s; *all_align = 1; + /* Page-aligning simplifies relocation handling. */ + if (image_target->elf_target == EM_AARCH64) + *all_align = 4096; section_addresses = xmalloc (sizeof (*section_addresses) * num_sections); memset (section_addresses, 0, sizeof (*section_addresses) * num_sections); diff --git a/util/grub-module-verifier.c b/util/grub-module-verifier.c index e217dcddc..405c91170 100644 --- a/util/grub-module-verifier.c +++ b/util/grub-module-verifier.c @@ -107,7 +107,13 @@ struct grub_module_verifier_arch archs[] = { R_AARCH64_CALL26, R_AARCH64_JUMP26, -1 - } }, + }, (int[]){ + R_AARCH64_ADR_PREL_PG_HI21, + R_AARCH64_ADD_ABS_LO12_NC, + R_AARCH64_LDST64_ABS_LO12_NC, + -1 + } + }, }; From ff84a9b868ea36da23248da780b8e85bdc4c183d Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 22 Jan 2016 19:28:08 +0100 Subject: [PATCH 664/722] Error out if mtools invocation fails. --- util/grub-mkrescue.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/util/grub-mkrescue.c b/util/grub-mkrescue.c index da0dc021a..238d4840e 100644 --- a/util/grub-mkrescue.c +++ b/util/grub-mkrescue.c @@ -787,9 +787,14 @@ main (int argc, char *argv[]) free (efidir_efi_boot); efiimgfat = grub_util_path_concat (2, iso9660_dir, "efi.img"); - grub_util_exec ((const char * []) { "mformat", "-C", "-f", "2880", "-L", "16", "-i", + int rv; + rv = grub_util_exec ((const char * []) { "mformat", "-C", "-f", "2880", "-L", "16", "-i", efiimgfat, "::", NULL }); - grub_util_exec ((const char * []) { "mcopy", "-s", "-i", efiimgfat, efidir_efi, "::/", NULL }); + if (rv != 0) + grub_util_error ("`%s` invocation failed\n", "mformat"); + rv = grub_util_exec ((const char * []) { "mcopy", "-s", "-i", efiimgfat, efidir_efi, "::/", NULL }); + if (rv != 0) + grub_util_error ("`%s` invocation failed\n", "mformat"); xorriso_push ("--efi-boot"); xorriso_push ("efi.img"); xorriso_push ("-efi-boot-part"); From 7290bb5623cd8d9b50b756d0ea40eb6a269985e7 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Mon, 1 Feb 2016 20:13:48 +0300 Subject: [PATCH 665/722] 10_linux: avoid multi-device root= kernel argument If root filesystem is multidev btrfs, do not attempt to pass all devices as kernel root= argument. This results in splitting command line in GRUB due to embedded newline and even if we managed to quote it, kernel does not know how to interpret it anyway. Multidev btrfs requires user space device scanning, so passing single device would not work too. This still respects user settings GRUB_DISABLE_LINUX_UUID. Not sure what we should do in this case. Closes: 45709 --- util/grub.d/10_linux.in | 4 +++- util/grub.d/20_linux_xen.in | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in index 859b608f6..5a78513ae 100644 --- a/util/grub.d/10_linux.in +++ b/util/grub.d/10_linux.in @@ -43,9 +43,11 @@ case ${GRUB_DEVICE} in ;; esac +# btrfs may reside on multiple devices. We cannot pass them as value of root= parameter +# and mounting btrfs requires user space scanning, so force UUID in this case. if [ "x${GRUB_DEVICE_UUID}" = "x" ] || [ "x${GRUB_DISABLE_LINUX_UUID}" = "xtrue" ] \ || ! test -e "/dev/disk/by-uuid/${GRUB_DEVICE_UUID}" \ - || uses_abstraction "${GRUB_DEVICE}" lvm; then + || test -e "${GRUB_DEVICE}" && uses_abstraction "${GRUB_DEVICE}" lvm; then LINUX_ROOT_DEVICE=${GRUB_DEVICE} else LINUX_ROOT_DEVICE=UUID=${GRUB_DEVICE_UUID} diff --git a/util/grub.d/20_linux_xen.in b/util/grub.d/20_linux_xen.in index f532fb98f..46045db1a 100644 --- a/util/grub.d/20_linux_xen.in +++ b/util/grub.d/20_linux_xen.in @@ -43,9 +43,11 @@ case ${GRUB_DEVICE} in ;; esac +# btrfs may reside on multiple devices. We cannot pass them as value of root= parameter +# and mounting btrfs requires user space scanning, so force UUID in this case. if [ "x${GRUB_DEVICE_UUID}" = "x" ] || [ "x${GRUB_DISABLE_LINUX_UUID}" = "xtrue" ] \ || ! test -e "/dev/disk/by-uuid/${GRUB_DEVICE_UUID}" \ - || uses_abstraction "${GRUB_DEVICE}" lvm; then + || test -e "${GRUB_DEVICE}" && uses_abstraction "${GRUB_DEVICE}" lvm; then LINUX_ROOT_DEVICE=${GRUB_DEVICE} else LINUX_ROOT_DEVICE=UUID=${GRUB_DEVICE_UUID} From 67dba97e4598eaf2deb14da044fbfb1c119cf76f Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Wed, 3 Feb 2016 20:34:55 +0300 Subject: [PATCH 666/722] support modules without symbol table all_video module does not have any code or data and exists solely for .moddeps section to pull in dependencies. This makes all symbols unneeded. While in current binutils (last released version as of this commit is 2.26) ``strip --strip-unneeded'' unintentionally adds section symbols for each existing section, this behavior was considered a bug and changed in commit 14f2c699ddca1e2f706342dffc59a6c7e23e844c to completely strip symbol table in this case. Older binutils (verified with 2.17) and some other toolchains (at least elftoolchain r3223M), both used in FreeBSD, remove symbol table in all_video as well. Relax run-time check and do not return error for modules without symbol table. Add additional checks to module verifier to make sure such modules a) have non-empty .moddeps section. Without either externally visible symbols or .moddeps modules are completely useless and should not be built. b) do not have any relocations. Closes: 46986 v2: add run-time check for empty symbol table if relocations are present as suggested by Vladimir. --- grub-core/kern/dl.c | 8 +++++++- util/grub-module-verifierXX.c | 18 +++++++++++++++++- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/grub-core/kern/dl.c b/grub-core/kern/dl.c index 59a6ef4ca..e394cd96f 100644 --- a/grub-core/kern/dl.c +++ b/grub-core/kern/dl.c @@ -333,8 +333,11 @@ grub_dl_resolve_symbols (grub_dl_t mod, Elf_Ehdr *e) if (s->sh_type == SHT_SYMTAB) break; + /* Module without symbol table may still be used to pull in dependencies. + We verify at build time that such modules do not contain any relocations + that may reference symbol table. */ if (i == e->e_shnum) - return grub_error (GRUB_ERR_BAD_MODULE, N_("no symbol table")); + return GRUB_ERR_NONE; #ifdef GRUB_MODULES_MACHINE_READONLY mod->symtab = grub_malloc (s->sh_size); @@ -576,6 +579,9 @@ grub_dl_relocate_symbols (grub_dl_t mod, void *ehdr) if (seg) { + if (!mod->symtab) + return grub_error (GRUB_ERR_BAD_MODULE, "relocation without symbol table"); + err = grub_arch_dl_relocate_symbols (mod, ehdr, s, seg); if (err) return err; diff --git a/util/grub-module-verifierXX.c b/util/grub-module-verifierXX.c index f612d51f3..9c04caa63 100644 --- a/util/grub-module-verifierXX.c +++ b/util/grub-module-verifierXX.c @@ -176,7 +176,7 @@ get_symtab (const struct grub_module_verifier_arch *arch, Elf_Ehdr *e, Elf_Word break; if (i == grub_target_to_host16 (e->e_shnum)) - grub_util_error ("no symbol table"); + return NULL; sym = (Elf_Sym *) ((char *) e + grub_target_to_host (s->sh_offset)); *size = grub_target_to_host (s->sh_size); @@ -191,7 +191,21 @@ check_symbols (const struct grub_module_verifier_arch *arch, Elf_Ehdr *e) Elf_Word size, entsize; unsigned i; + /* Module without symbol table and without .moddeps section is useless + at boot time, so catch it early to prevent build errors */ sym = get_symtab (arch, e, &size, &entsize); + if (!sym) + { + Elf_Shdr *s = find_section (arch, e, ".moddeps"); + + if (!s) + grub_util_error ("no symbol table and no .moddeps section"); + + if (!s->sh_size) + grub_util_error ("no symbol table and empty .moddeps section"); + + return; + } for (i = 0; i < size / entsize; @@ -243,6 +257,8 @@ section_check_relocations (const struct grub_module_verifier_arch *arch, void *e Elf_Word symtabsize, symtabentsize; symtab = get_symtab (arch, ehdr, &symtabsize, &symtabentsize); + if (!symtab) + grub_util_error ("relocation without symbol table"); for (rel = (Elf_Rel *) ((char *) ehdr + grub_target_to_host (s->sh_offset)), max = (Elf_Rel *) ((char *) rel + grub_target_to_host (s->sh_size)); From 2d425ffdd57845e4c967b468f8cee164d2ddc85f Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Thu, 11 Feb 2016 11:58:28 +0100 Subject: [PATCH 667/722] xnu: supply ramsize to the kernel. Without this info recent kernels crash as they allocate no heap. --- grub-core/loader/i386/xnu.c | 23 +++++++++++++++++++++++ include/grub/i386/xnu.h | 3 ++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/grub-core/loader/i386/xnu.c b/grub-core/loader/i386/xnu.c index a4a6f932e..7962b0e1d 100644 --- a/grub-core/loader/i386/xnu.c +++ b/grub-core/loader/i386/xnu.c @@ -897,6 +897,28 @@ grub_xnu_set_video (struct grub_xnu_boot_params_common *params) return GRUB_ERR_NONE; } +static int +total_ram_hook (grub_uint64_t addr __attribute__ ((unused)), grub_uint64_t size, + grub_memory_type_t type, + void *data) +{ + grub_uint64_t *result = data; + + if (type != GRUB_MEMORY_AVAILABLE) + return 0; + *result += size; + return 0; +} + +static grub_uint64_t +get_total_ram (void) +{ + grub_uint64_t result = 0; + + grub_mmap_iterate (total_ram_hook, &result); + return result; +} + /* Boot xnu. */ grub_err_t grub_xnu_boot (void) @@ -973,6 +995,7 @@ grub_xnu_boot (void) { bootparams_common = &bootparams->v2.common; bootparams->v2.fsbfreq = fsbfreq; + bootparams->v2.ram_size = get_total_ram(); } else bootparams_common = &bootparams->v1.common; diff --git a/include/grub/i386/xnu.h b/include/grub/i386/xnu.h index a076b8a97..062a7ddbe 100644 --- a/include/grub/i386/xnu.h +++ b/include/grub/i386/xnu.h @@ -89,7 +89,8 @@ struct grub_xnu_boot_params_v2 grub_uint64_t efi_runtime_first_page_virtual; grub_uint32_t efi_system_table; - grub_uint32_t unused2[11]; + grub_uint32_t unused2[9]; + grub_uint64_t ram_size; grub_uint64_t fsbfreq; grub_uint32_t unused3[734]; } GRUB_PACKED; From df4df4d887fab794139adea5e7deee98ded046da Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Thu, 11 Feb 2016 12:30:45 +0100 Subject: [PATCH 668/722] xnu: Include relocated EFI in heap size. --- grub-core/loader/i386/xnu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/loader/i386/xnu.c b/grub-core/loader/i386/xnu.c index 7962b0e1d..7b11c65f0 100644 --- a/grub-core/loader/i386/xnu.c +++ b/grub-core/loader/i386/xnu.c @@ -1103,7 +1103,7 @@ grub_xnu_boot (void) bootparams_common->efi_mmap = memory_map_target; bootparams_common->efi_mmap_size = memory_map_size; bootparams_common->heap_start = grub_xnu_heap_target_start; - bootparams_common->heap_size = grub_xnu_heap_size; + bootparams_common->heap_size = curruntimepage * GRUB_XNU_PAGESIZE - grub_xnu_heap_target_start; /* Parameters for asm helper. */ grub_xnu_stack = bootparams_common->heap_start From 281baeecd3613eadb985f81cfe1b00ef937eb9e2 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 12 Feb 2016 09:10:08 +0100 Subject: [PATCH 669/722] Fix emu compilation error on arm. --- grub-core/kern/emu/main.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/grub-core/kern/emu/main.c b/grub-core/kern/emu/main.c index 953a93c8a..f91280f68 100644 --- a/grub-core/kern/emu/main.c +++ b/grub-core/kern/emu/main.c @@ -201,7 +201,7 @@ main (int argc, char *argv[]) volatile int hold = 0; size_t total_module_size = sizeof (struct grub_module_info), memdisk_size = 0; struct grub_module_info *modinfo; - char *mods; + void *mods; grub_util_host_init (&argc, &argv); @@ -232,10 +232,10 @@ main (int argc, char *argv[]) struct grub_module_header *header = (struct grub_module_header *) mods; header->type = OBJ_TYPE_MEMDISK; header->size = memdisk_size + sizeof (*header); - mods += sizeof (*header); + mods = header + 1; grub_util_load_image (arguments.mem_disk, mods); - mods += memdisk_size; + mods = (char *) mods + memdisk_size; } grub_modbase = (grub_addr_t) modinfo; From 8ad190cac258f2070a94f1250c0fb91eca6f7685 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 12 Feb 2016 09:11:06 +0100 Subject: [PATCH 670/722] Make unaligned types public. This simplifies code which has to handle those types. --- include/grub/types.h | 74 ++++++++++++++++++++------------------------ 1 file changed, 34 insertions(+), 40 deletions(-) diff --git a/include/grub/types.h b/include/grub/types.h index e732efb5c..b93e48201 100644 --- a/include/grub/types.h +++ b/include/grub/types.h @@ -254,55 +254,49 @@ static inline grub_uint64_t grub_swap_bytes64(grub_uint64_t _x) #endif /* ! WORDS_BIGENDIAN */ -static inline grub_uint16_t grub_get_unaligned16 (const void *ptr) +struct grub_unaligned_uint16 { - struct grub_unaligned_uint16_t - { - grub_uint16_t d; - } GRUB_PACKED; - const struct grub_unaligned_uint16_t *dd - = (const struct grub_unaligned_uint16_t *) ptr; - return dd->d; -} - -static inline void grub_set_unaligned16 (void *ptr, grub_uint16_t val) + grub_uint16_t val; +} GRUB_PACKED; +struct grub_unaligned_uint32 { - struct grub_unaligned_uint16_t - { - grub_uint16_t d; - } GRUB_PACKED; - struct grub_unaligned_uint16_t *dd = (struct grub_unaligned_uint16_t *) ptr; - dd->d = val; -} - -static inline grub_uint32_t grub_get_unaligned32 (const void *ptr) -{ - struct grub_unaligned_uint32_t - { - grub_uint32_t d; - } GRUB_PACKED; - const struct grub_unaligned_uint32_t *dd - = (const struct grub_unaligned_uint32_t *) ptr; - return dd->d; -} - -static inline void grub_set_unaligned32 (void *ptr, grub_uint32_t val) -{ - struct grub_unaligned_uint32_t - { - grub_uint32_t d; - } GRUB_PACKED; - struct grub_unaligned_uint32_t *dd = (struct grub_unaligned_uint32_t *) ptr; - dd->d = val; -} - + grub_uint32_t val; +} GRUB_PACKED; struct grub_unaligned_uint64 { grub_uint64_t val; } GRUB_PACKED; +typedef struct grub_unaligned_uint16 grub_unaligned_uint16_t; +typedef struct grub_unaligned_uint32 grub_unaligned_uint32_t; typedef struct grub_unaligned_uint64 grub_unaligned_uint64_t; +static inline grub_uint16_t grub_get_unaligned16 (const void *ptr) +{ + const struct grub_unaligned_uint16 *dd + = (const struct grub_unaligned_uint16 *) ptr; + return dd->val; +} + +static inline void grub_set_unaligned16 (void *ptr, grub_uint16_t val) +{ + struct grub_unaligned_uint16 *dd = (struct grub_unaligned_uint16 *) ptr; + dd->val = val; +} + +static inline grub_uint32_t grub_get_unaligned32 (const void *ptr) +{ + const struct grub_unaligned_uint32 *dd + = (const struct grub_unaligned_uint32 *) ptr; + return dd->val; +} + +static inline void grub_set_unaligned32 (void *ptr, grub_uint32_t val) +{ + struct grub_unaligned_uint32 *dd = (struct grub_unaligned_uint32 *) ptr; + dd->val = val; +} + static inline grub_uint64_t grub_get_unaligned64 (const void *ptr) { const struct grub_unaligned_uint64 *dd From b29638222ec75c93f19e16f7ee4b091fe6cc1650 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 12 Feb 2016 11:35:48 +0100 Subject: [PATCH 671/722] Make grub_acpi_find_fadt accessible generically --- grub-core/kern/acpi.c | 85 +++++++++++++++++++++++++++++++ grub-core/kern/i386/tsc_pmtimer.c | 85 ------------------------------- include/grub/acpi.h | 2 +- 3 files changed, 86 insertions(+), 86 deletions(-) diff --git a/grub-core/kern/acpi.c b/grub-core/kern/acpi.c index 02c1f4f6f..5746ac00c 100644 --- a/grub-core/kern/acpi.c +++ b/grub-core/kern/acpi.c @@ -32,3 +32,88 @@ grub_byte_checksum (void *base, grub_size_t size) ret += *ptr; return ret; } + +static void * +grub_acpi_rsdt_find_table (struct grub_acpi_table_header *rsdt, const char *sig) +{ + grub_size_t s; + grub_unaligned_uint32_t *ptr; + + if (!rsdt) + return 0; + + if (grub_memcmp (rsdt->signature, "RSDT", 4) != 0) + return 0; + + ptr = (grub_unaligned_uint32_t *) (rsdt + 1); + s = (rsdt->length - sizeof (*rsdt)) / sizeof (grub_uint32_t); + for (; s; s--, ptr++) + { + struct grub_acpi_table_header *tbl; + tbl = (struct grub_acpi_table_header *) (grub_addr_t) ptr->val; + if (grub_memcmp (tbl->signature, sig, 4) == 0) + return tbl; + } + return 0; +} + +static void * +grub_acpi_xsdt_find_table (struct grub_acpi_table_header *xsdt, const char *sig) +{ + grub_size_t s; + grub_unaligned_uint64_t *ptr; + + if (!xsdt) + return 0; + + if (grub_memcmp (xsdt->signature, "XSDT", 4) != 0) + return 0; + + ptr = (grub_unaligned_uint64_t *) (xsdt + 1); + s = (xsdt->length - sizeof (*xsdt)) / sizeof (grub_uint32_t); + for (; s; s--, ptr++) + { + struct grub_acpi_table_header *tbl; +#if GRUB_CPU_SIZEOF_VOID_P != 8 + if (ptr->val >> 32) + continue; +#endif + tbl = (struct grub_acpi_table_header *) (grub_addr_t) ptr->val; + if (grub_memcmp (tbl->signature, sig, 4) == 0) + return tbl; + } + return 0; +} + +struct grub_acpi_fadt * +grub_acpi_find_fadt (void) +{ + struct grub_acpi_fadt *fadt = 0; + struct grub_acpi_rsdp_v10 *rsdpv1; + struct grub_acpi_rsdp_v20 *rsdpv2; + rsdpv1 = grub_machine_acpi_get_rsdpv1 (); + if (rsdpv1) + fadt = grub_acpi_rsdt_find_table ((struct grub_acpi_table_header *) + (grub_addr_t) rsdpv1->rsdt_addr, + GRUB_ACPI_FADT_SIGNATURE); + if (fadt) + return fadt; + rsdpv2 = grub_machine_acpi_get_rsdpv2 (); + if (rsdpv2) + fadt = grub_acpi_rsdt_find_table ((struct grub_acpi_table_header *) + (grub_addr_t) rsdpv2->rsdpv1.rsdt_addr, + GRUB_ACPI_FADT_SIGNATURE); + if (fadt) + return fadt; + if (rsdpv2 +#if GRUB_CPU_SIZEOF_VOID_P != 8 + && !(rsdpv2->xsdt_addr >> 32) +#endif + ) + fadt = grub_acpi_xsdt_find_table ((struct grub_acpi_table_header *) + (grub_addr_t) rsdpv2->xsdt_addr, + GRUB_ACPI_FADT_SIGNATURE); + if (fadt) + return fadt; + return 0; +} diff --git a/grub-core/kern/i386/tsc_pmtimer.c b/grub-core/kern/i386/tsc_pmtimer.c index 6a47ab7be..2495e6fd4 100644 --- a/grub-core/kern/i386/tsc_pmtimer.c +++ b/grub-core/kern/i386/tsc_pmtimer.c @@ -27,91 +27,6 @@ #include #include -static void * -grub_acpi_rsdt_find_table (struct grub_acpi_table_header *rsdt, const char *sig) -{ - grub_size_t s; - grub_uint32_t *ptr; - - if (!rsdt) - return 0; - - if (grub_memcmp (rsdt->signature, "RSDT", 4) != 0) - return 0; - - ptr = (grub_uint32_t *) (rsdt + 1); - s = (rsdt->length - sizeof (*rsdt)) / sizeof (grub_uint32_t); - for (; s; s--, ptr++) - { - struct grub_acpi_table_header *tbl; - tbl = (struct grub_acpi_table_header *) (grub_addr_t) *ptr; - if (grub_memcmp (tbl->signature, sig, 4) == 0) - return tbl; - } - return 0; -} - -static void * -grub_acpi_xsdt_find_table (struct grub_acpi_table_header *xsdt, const char *sig) -{ - grub_size_t s; - grub_uint64_t *ptr; - - if (!xsdt) - return 0; - - if (grub_memcmp (xsdt->signature, "XSDT", 4) != 0) - return 0; - - ptr = (grub_uint64_t *) (xsdt + 1); - s = (xsdt->length - sizeof (*xsdt)) / sizeof (grub_uint32_t); - for (; s; s--, ptr++) - { - struct grub_acpi_table_header *tbl; -#if GRUB_CPU_SIZEOF_VOID_P != 8 - if (*ptr >> 32) - continue; -#endif - tbl = (struct grub_acpi_table_header *) (grub_addr_t) *ptr; - if (grub_memcmp (tbl->signature, sig, 4) == 0) - return tbl; - } - return 0; -} - -struct grub_acpi_fadt * -grub_acpi_find_fadt (void) -{ - struct grub_acpi_fadt *fadt = 0; - struct grub_acpi_rsdp_v10 *rsdpv1; - struct grub_acpi_rsdp_v20 *rsdpv2; - rsdpv1 = grub_machine_acpi_get_rsdpv1 (); - if (rsdpv1) - fadt = grub_acpi_rsdt_find_table ((struct grub_acpi_table_header *) - (grub_addr_t) rsdpv1->rsdt_addr, - GRUB_ACPI_FADT_SIGNATURE); - if (fadt) - return fadt; - rsdpv2 = grub_machine_acpi_get_rsdpv2 (); - if (rsdpv2) - fadt = grub_acpi_rsdt_find_table ((struct grub_acpi_table_header *) - (grub_addr_t) rsdpv2->rsdpv1.rsdt_addr, - GRUB_ACPI_FADT_SIGNATURE); - if (fadt) - return fadt; - if (rsdpv2 -#if GRUB_CPU_SIZEOF_VOID_P != 8 - && !(rsdpv2->xsdt_addr >> 32) -#endif - ) - fadt = grub_acpi_xsdt_find_table ((struct grub_acpi_table_header *) - (grub_addr_t) rsdpv2->xsdt_addr, - GRUB_ACPI_FADT_SIGNATURE); - if (fadt) - return fadt; - return 0; -} - int grub_tsc_calibrate_from_pmtimer (void) { diff --git a/include/grub/acpi.h b/include/grub/acpi.h index a4224e046..66148f684 100644 --- a/include/grub/acpi.h +++ b/include/grub/acpi.h @@ -242,6 +242,6 @@ enum }; struct grub_acpi_fadt * -grub_acpi_find_fadt (void); +EXPORT_FUNC(grub_acpi_find_fadt) (void); #endif /* ! GRUB_ACPI_HEADER */ From 1933d3737133314c97e42f6ad928f00ed6e71120 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 12 Feb 2016 11:38:51 +0100 Subject: [PATCH 672/722] Make grub_cpu_is_tsc_supported generally available. --- grub-core/kern/i386/tsc.c | 16 ---------------- include/grub/i386/tsc.h | 16 ++++++++++++++++ 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/grub-core/kern/i386/tsc.c b/grub-core/kern/i386/tsc.c index 82cdea491..2e85289d8 100644 --- a/grub-core/kern/i386/tsc.c +++ b/grub-core/kern/i386/tsc.c @@ -43,22 +43,6 @@ grub_tsc_get_time_ms (void) return ((al * grub_tsc_rate) >> 32) + ah * grub_tsc_rate; } -static __inline int -grub_cpu_is_tsc_supported (void) -{ -#ifndef GRUB_MACHINE_XEN - grub_uint32_t a,b,c,d; - if (! grub_cpu_is_cpuid_supported ()) - return 0; - - grub_cpuid(1,a,b,c,d); - - return (d & (1 << 4)) != 0; -#else - return 1; -#endif -} - static int calibrate_tsc_hardcode (void) { diff --git a/include/grub/i386/tsc.h b/include/grub/i386/tsc.h index 71fa7ca2f..a0aa2c573 100644 --- a/include/grub/i386/tsc.h +++ b/include/grub/i386/tsc.h @@ -51,4 +51,20 @@ grub_get_tsc (void) return (((grub_uint64_t) hi) << 32) | lo; } +static __inline int +grub_cpu_is_tsc_supported (void) +{ +#ifndef GRUB_MACHINE_XEN + grub_uint32_t a,b,c,d; + if (! grub_cpu_is_cpuid_supported ()) + return 0; + + grub_cpuid(1,a,b,c,d); + + return (d & (1 << 4)) != 0; +#else + return 1; +#endif +} + #endif /* ! KERNEL_CPU_TSC_HEADER */ From d9a3bfead8236377c2f46eb75c4fd7fef93696ea Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 12 Feb 2016 11:40:51 +0100 Subject: [PATCH 673/722] Split pmtimer wait and tsc measurement from pmtimer tsc calibration. --- grub-core/Makefile.am | 2 ++ grub-core/kern/i386/tsc_pmtimer.c | 47 ++++++++++++++++++++----------- include/grub/i386/pmtimer.h | 37 ++++++++++++++++++++++++ 3 files changed, 69 insertions(+), 17 deletions(-) create mode 100644 include/grub/i386/pmtimer.h diff --git a/grub-core/Makefile.am b/grub-core/Makefile.am index 90502cb1e..04e9395fd 100644 --- a/grub-core/Makefile.am +++ b/grub-core/Makefile.am @@ -107,6 +107,7 @@ KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/disk.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/i386/tsc.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/acpi.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/pci.h +KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/i386/pmtimer.h endif if COND_i386_coreboot @@ -162,6 +163,7 @@ KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/disk.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/i386/tsc.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/pci.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/acpi.h +KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/i386/pmtimer.h endif if COND_ia64_efi diff --git a/grub-core/kern/i386/tsc_pmtimer.c b/grub-core/kern/i386/tsc_pmtimer.c index 2495e6fd4..c9c361699 100644 --- a/grub-core/kern/i386/tsc_pmtimer.c +++ b/grub-core/kern/i386/tsc_pmtimer.c @@ -24,44 +24,35 @@ #include #include #include +#include #include #include -int -grub_tsc_calibrate_from_pmtimer (void) +grub_uint64_t +grub_pmtimer_wait_count_tsc (grub_port_t pmtimer, + grub_uint16_t num_pm_ticks) { grub_uint32_t start; grub_uint32_t last; grub_uint32_t cur, end; - struct grub_acpi_fadt *fadt; - grub_port_t p; grub_uint64_t start_tsc; grub_uint64_t end_tsc; int num_iter = 0; - fadt = grub_acpi_find_fadt (); - if (!fadt) - return 0; - p = fadt->pmtimer; - if (!p) - return 0; - - start = grub_inl (p) & 0xffffff; + start = grub_inl (pmtimer) & 0xffffff; last = start; - /* It's 3.579545 MHz clock. Wait 1 ms. */ - end = start + 3580; + end = start + num_pm_ticks; start_tsc = grub_get_tsc (); while (1) { - cur = grub_inl (p) & 0xffffff; + cur = grub_inl (pmtimer) & 0xffffff; if (cur < last) cur |= 0x1000000; num_iter++; if (cur >= end) { end_tsc = grub_get_tsc (); - grub_tsc_rate = grub_divmod64 ((1ULL << 32), end_tsc - start_tsc, 0); - return 1; + return end_tsc - start_tsc; } /* Check for broken PM timer. 50000000 TSCs is between 5 ms (10GHz) and 200 ms (250 MHz) @@ -73,3 +64,25 @@ grub_tsc_calibrate_from_pmtimer (void) } } } + +int +grub_tsc_calibrate_from_pmtimer (void) +{ + struct grub_acpi_fadt *fadt; + grub_port_t pmtimer; + grub_uint64_t tsc_diff; + + fadt = grub_acpi_find_fadt (); + if (!fadt) + return 0; + pmtimer = fadt->pmtimer; + if (!pmtimer) + return 0; + + /* It's 3.579545 MHz clock. Wait 1 ms. */ + tsc_diff = grub_pmtimer_wait_count_tsc (pmtimer, 3580); + if (tsc_diff == 0) + return 0; + grub_tsc_rate = grub_divmod64 ((1ULL << 32), tsc_diff, 0); + return 1; +} diff --git a/include/grub/i386/pmtimer.h b/include/grub/i386/pmtimer.h new file mode 100644 index 000000000..ac091806a --- /dev/null +++ b/include/grub/i386/pmtimer.h @@ -0,0 +1,37 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2008,2009 Free Software Foundation, Inc. + * + * GRUB is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GRUB is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GRUB. If not, see . + */ + +#ifndef KERNEL_CPU_PMTIMER_HEADER +#define KERNEL_CPU_PMTIMER_HEADER 1 + +#include +#include + +/* + Preconditions: + * Caller has ensured that both pmtimer and tsc are supported + * 1 <= num_pm_ticks <= 3580 + Return: + * Number of TSC ticks elapsed + * 0 on failure. +*/ +grub_uint64_t +EXPORT_FUNC(grub_pmtimer_wait_count_tsc) (grub_port_t pmtimer, + grub_uint16_t num_pm_ticks); + +#endif From e5c930019104f4ad958c8c327097a1efed144374 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 12 Feb 2016 12:33:41 +0100 Subject: [PATCH 674/722] printf: Fix and test %% behaviour in presence of subsequenbt args. --- grub-core/kern/misc.c | 7 +++++++ tests/printf_unit_test.c | 3 +++ 2 files changed, 10 insertions(+) diff --git a/grub-core/kern/misc.c b/grub-core/kern/misc.c index 906d2c2f7..e3f851633 100644 --- a/grub-core/kern/misc.c +++ b/grub-core/kern/misc.c @@ -740,6 +740,12 @@ parse_printf_args (const char *fmt0, struct printf_args *args, fmt++; c = *fmt++; + if (c == '%') + { + n--; + continue; + } + if (c == 'l') { c = *fmt++; @@ -876,6 +882,7 @@ grub_vsnprintf_real (char *str, grub_size_t max_len, const char *fmt0, if (c == '%') { write_char (str, &count, max_len,c); + n--; continue; } diff --git a/tests/printf_unit_test.c b/tests/printf_unit_test.c index eb76bd002..d7b12c6db 100644 --- a/tests/printf_unit_test.c +++ b/tests/printf_unit_test.c @@ -66,6 +66,9 @@ printf_test (void) grub_snprintf (real, sizeof (real), "%3$d %2$lld %1$d", 1, 2LL, 3); snprintf (expected, sizeof (expected), "%3$d %2$lld %1$d", 1, 2LL, 3); grub_test_assert (strcmp (real, expected) == 0, MSG); + grub_snprintf (real, sizeof (real), "%%0%dd ", 1); + snprintf (expected, sizeof (expected), "%%0%dd ", 1); + grub_test_assert (strcmp (real, expected) == 0, MSG); } GRUB_UNIT_TEST ("printf_unit_test", printf_test); From 342d6edb970dd8af21feea3acf02905a5d117e38 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 12 Feb 2016 12:34:54 +0100 Subject: [PATCH 675/722] yylex: use grub_fatal for exit. lexer calls yylex_fatal on fatal internal errors. yylex_fatal itself is declared as noreturn and calls exit. Returning from noreturn function has unpredictable consequences. --- grub-core/script/yylex.l | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/script/yylex.l b/grub-core/script/yylex.l index 9c2cfe115..95b219170 100644 --- a/grub-core/script/yylex.l +++ b/grub-core/script/yylex.l @@ -92,7 +92,7 @@ typedef size_t yy_size_t; #define stdout 0 #define fprintf(...) 0 -#define exit(...) +#define exit(...) grub_fatal("fatal error in lexer") #endif } From e72de13b9e36dd0ab32eddb1848d403e3bbe7862 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 12 Feb 2016 12:39:38 +0100 Subject: [PATCH 676/722] Add RNG module. --- grub-core/Makefile.core.def | 16 +++++ grub-core/lib/i386/random.c | 103 +++++++++++++++++++++++++++++++ grub-core/lib/random.c | 120 ++++++++++++++++++++++++++++++++++++ include/grub/random.h | 33 ++++++++++ 4 files changed, 272 insertions(+) create mode 100644 grub-core/lib/i386/random.c create mode 100644 grub-core/lib/random.c create mode 100644 include/grub/random.h diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def index 0cc40bb2b..18e3208be 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def @@ -1686,6 +1686,22 @@ module = { x86 = loader/xnu.c; enable = x86; +} + +module = { + name = random; + x86 = lib/i386/random.c; + common = lib/random.c; + + i386_multiboot = kern/i386/tsc_pmtimer.c; + i386_coreboot = kern/i386/tsc_pmtimer.c; + i386_pc = kern/i386/tsc_pmtimer.c; + + enable = i386_multiboot; + enable = i386_coreboot; + enable = i386_pc; + enable = i386_efi; + enable = x86_64_efi; }; module = { diff --git a/grub-core/lib/i386/random.c b/grub-core/lib/i386/random.c new file mode 100644 index 000000000..cd83d2f8f --- /dev/null +++ b/grub-core/lib/i386/random.c @@ -0,0 +1,103 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2016 Free Software Foundation, Inc. + * + * GRUB is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GRUB is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GRUB. If not, see . + */ + +#include +#include +#include +#include +#include + +static int have_tsc = -1, have_pmtimer = -1; +static grub_port_t pmtimer_port; + +static int +detect_pmtimer (void) +{ + struct grub_acpi_fadt *fadt; + fadt = grub_acpi_find_fadt (); + if (!fadt) + return 0; + pmtimer_port = fadt->pmtimer; + if (!pmtimer_port) + return 0; + return 1; +} + +static int +pmtimer_tsc_get_random_bit (void) +{ + /* It's hard to come up with figures about pmtimer and tsc jitter but + 50 ppm seems to be typical. So we need 10^6/50 tsc cycles to get drift + of one tsc cycle. With TSC at least of 800 MHz it means 1/(50*800) + = 1/40000 s or about 3579545 / 40000 = 90 pmtimer ticks. + This gives us rate of 40000 bit/s or 5 kB/s. + */ + grub_uint64_t tsc_diff; + tsc_diff = grub_pmtimer_wait_count_tsc (pmtimer_port, 90); + if (tsc_diff == 0) + { + have_pmtimer = 0; + return -1; + } + return tsc_diff & 1; +} + +static int +pmtimer_tsc_get_random_byte (void) +{ + grub_uint8_t ret = 0; + int i, c; + for (i = 0; i < 8; i++) + { + c = pmtimer_tsc_get_random_bit (); + if (c < 0) + return -1; + ret |= c << i; + } + return ret; +} + +static int +pmtimer_fill_buffer (void *buffer, grub_size_t sz) +{ + grub_uint8_t *p = buffer; + int c; + while (sz) + { + c = pmtimer_tsc_get_random_byte (); + if (c < 0) + return 0; + *p++ = c; + sz--; + } + return 1; +} + +int +grub_crypto_arch_get_random (void *buffer, grub_size_t sz) +{ + if (have_tsc == -1) + have_tsc = grub_cpu_is_tsc_supported (); + if (!have_tsc) + return 0; + if (have_pmtimer == -1) + have_pmtimer = detect_pmtimer (); + if (!have_pmtimer) + return 0; + return pmtimer_fill_buffer (buffer, sz); +} diff --git a/grub-core/lib/random.c b/grub-core/lib/random.c new file mode 100644 index 000000000..43b966438 --- /dev/null +++ b/grub-core/lib/random.c @@ -0,0 +1,120 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2016 Free Software Foundation, Inc. + * + * GRUB is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GRUB is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GRUB. If not, see . + */ + +#include +#include +#include +#include +#include + +GRUB_MOD_LICENSE ("GPLv3+"); + +grub_err_t +grub_crypto_get_random (void *buffer, grub_size_t sz) +{ + /* This is an arbitrer between different methods. + TODO: Add more methods in the future. */ + /* TODO: Add some PRNG smartness to reduce damage from bad entropy. */ + if (grub_crypto_arch_get_random (buffer, sz)) + return GRUB_ERR_NONE; + return grub_error (GRUB_ERR_IO, "no random sources found"); +} + +static int +get_num_digits (int val) +{ + int ret = 0; + while (val != 0) + { + ret++; + val /= 10; + } + if (ret == 0) + return 1; + return ret; +} + +#pragma GCC diagnostic ignored "-Wformat-nonliteral" + +static grub_err_t +grub_cmd_hexdump_random (grub_command_t cmd __attribute__ ((unused)), int argc, char **args) +{ + grub_size_t length = 64; + grub_err_t err; + void *buffer; + grub_uint8_t *ptr; + int stats[256]; + int i, digits = 2; + char template[10]; + + if (argc >= 1) + length = grub_strtoull (args[0], 0, 0); + + if (length == 0) + return grub_error (GRUB_ERR_BAD_ARGUMENT, "length pust be positive"); + + buffer = grub_malloc (length); + if (!buffer) + return grub_errno; + + err = grub_crypto_get_random (buffer, length); + if (err) + { + grub_free (buffer); + return err; + } + + hexdump (0, buffer, length); + grub_memset(stats, 0, sizeof(stats)); + for (ptr = buffer; ptr < (grub_uint8_t *) buffer + length; ptr++) + stats[*ptr]++; + grub_printf ("Statistics:\n"); + for (i = 0; i < 256; i++) + { + int z = get_num_digits (stats[i]); + if (z > digits) + digits = z; + } + + grub_snprintf (template, sizeof (template), "%%0%dd ", digits); + + for (i = 0; i < 256; i++) + { + grub_printf ("%s", template);//, stats[i]); + if ((i & 0xf) == 0xf) + grub_printf ("\n"); + } + + grub_free (buffer); + + return 0; +} + +static grub_command_t cmd; + +GRUB_MOD_INIT (random) +{ + cmd = grub_register_command ("hexdump_random", grub_cmd_hexdump_random, + N_("[LENGTH]"), + N_("Hexdump random data.")); +} + +GRUB_MOD_FINI (random) +{ + grub_unregister_command (cmd); +} diff --git a/include/grub/random.h b/include/grub/random.h new file mode 100644 index 000000000..4b75c0e2b --- /dev/null +++ b/include/grub/random.h @@ -0,0 +1,33 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2016 Free Software Foundation, Inc. + * + * GRUB is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GRUB is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GRUB. If not, see . + */ + +#ifndef GRUB_RANDOM_HEADER +#define GRUB_RANDOM_HEADER 1 + +#include +#include + +/* Not peer-reviewed. May not be any better than string of zeros. */ +grub_err_t +grub_crypto_get_random (void *buffer, grub_size_t sz); + +/* Do not use directly. Use grub_crypto_get_random instead. */ +int +grub_crypto_arch_get_random (void *buffer, grub_size_t sz); + +#endif From 22aa31bcc33ff480a8d94931d08235c12b4eecd8 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 12 Feb 2016 12:40:10 +0100 Subject: [PATCH 677/722] xnu: Supply random seed. Now we're able to load kernels up to El Capitan. --- grub-core/Makefile.core.def | 13 +++++++++++-- grub-core/loader/i386/xnu.c | 21 +++++++++++++++++++++ 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def index 18e3208be..58438c48d 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def @@ -1685,8 +1685,17 @@ module = { x86 = loader/i386/xnu.c; x86 = loader/xnu.c; - enable = x86; -} + /* Code is pretty generic but relies on RNG which + is available only on few platforms. It's not a + big deal as xnu needs ACPI anyway and we have + RNG on all platforms with ACPI. + */ + enable = i386_multiboot; + enable = i386_coreboot; + enable = i386_pc; + enable = i386_efi; + enable = x86_64_efi; +}; module = { name = random; diff --git a/grub-core/loader/i386/xnu.c b/grub-core/loader/i386/xnu.c index 7b11c65f0..59ef73a73 100644 --- a/grub-core/loader/i386/xnu.c +++ b/grub-core/loader/i386/xnu.c @@ -35,6 +35,7 @@ #include #include #include +#include #define min(a,b) (((a) < (b)) ? (a) : (b)) #define max(a,b) (((a) > (b)) ? (a) : (b)) @@ -577,11 +578,31 @@ static grub_err_t grub_cpu_xnu_fill_devicetree (grub_uint64_t *fsbfreq_out) { struct grub_xnu_devtree_key *efikey; + struct grub_xnu_devtree_key *chosenkey; struct grub_xnu_devtree_key *cfgtablekey; struct grub_xnu_devtree_key *curval; struct grub_xnu_devtree_key *runtimesrvkey; struct grub_xnu_devtree_key *platformkey; unsigned i, j; + grub_err_t err; + + chosenkey = grub_xnu_create_key (&grub_xnu_devtree_root, "chosen"); + if (! chosenkey) + return grub_errno; + + /* Random seed. */ + curval = grub_xnu_create_value (&(chosenkey->first_child), "random-seed"); + if (! curval) + return grub_errno; + curval->datasize = 64; + curval->data = grub_malloc (curval->datasize); + if (! curval->data) + return grub_errno; + /* Our random is not peer-reviewed but xnu uses this seed only for + ASLR in kernel. */ + err = grub_crypto_get_random (curval->data, curval->datasize); + if (err) + return err; /* The value "model". */ /* FIXME: may this value be sometimes different? */ From 127cfea8bec7a06b27c0df393728e20e276e9543 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 12 Feb 2016 12:41:28 +0100 Subject: [PATCH 678/722] default_payload: Include syslinuxcfg, all filesystems and xnu. --- Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.am b/Makefile.am index 70a8af873..71c23e50d 100644 --- a/Makefile.am +++ b/Makefile.am @@ -410,7 +410,7 @@ bootcheck: $(BOOTCHECKS) if COND_i386_coreboot default_payload.elf: grub-mkstandalone grub-mkimage - pkgdatadir=. ./grub-mkstandalone --grub-mkimage=./grub-mkimage -O i386-coreboot -o $@ --modules='ahci pata ehci uhci ohci usb_keyboard usbms part_msdos xfs ext2 fat at_keyboard part_gpt usbserial_usbdebug cbfs' --install-modules='ls linux search configfile normal cbtime cbls memrw iorw minicmd lsmmap lspci halt reboot hexdump pcidump regexp setpci lsacpi chain test serial multiboot cbmemc linux16 gzio echo help' --fonts= --themes= --locales= -d grub-core/ /boot/grub/grub.cfg=$(srcdir)/coreboot.cfg + pkgdatadir=. ./grub-mkstandalone --grub-mkimage=./grub-mkimage -O i386-coreboot -o $@ --modules='ahci pata ehci uhci ohci usb_keyboard usbms part_msdos ext2 fat at_keyboard part_gpt usbserial_usbdebug cbfs' --install-modules='ls linux search configfile normal cbtime cbls memrw iorw minicmd lsmmap lspci halt reboot hexdump pcidump regexp setpci lsacpi chain test serial multiboot cbmemc linux16 gzio echo help syslinuxcfg xnu $(shell cat grub-core/fs.lst)' --fonts= --themes= --locales= -d grub-core/ /boot/grub/grub.cfg=$(srcdir)/coreboot.cfg endif endif From 6f4189ffc19283b7a7ea8129d38a63bd4285f337 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 12 Feb 2016 12:42:04 +0100 Subject: [PATCH 679/722] powerpc: Trim header in tests. --- tests/util/grub-shell.in | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/util/grub-shell.in b/tests/util/grub-shell.in index 5ba2c299c..663cde663 100644 --- a/tests/util/grub-shell.in +++ b/tests/util/grub-shell.in @@ -82,6 +82,7 @@ case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in serial_port=escc-ch-b serial_null="-serial null" netbootext=elf + trim=1 ;; sparc64-ieee1275) From 4598cafa7d0a71ba39fbe59a8df1a9195994feec Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 12 Feb 2016 12:43:02 +0100 Subject: [PATCH 680/722] arm64: Use cpu timer for timekeeping. --- grub-core/Makefile.core.def | 2 +- grub-core/kern/arm64/efi/init.c | 60 +++++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 grub-core/kern/arm64/efi/init.c diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def index 58438c48d..887450110 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def @@ -213,7 +213,7 @@ kernel = { arm_efi = kern/arm/efi/init.c; arm_efi = kern/arm/efi/misc.c; - arm64_efi = kern/arm/efi/init.c; + arm64_efi = kern/arm64/efi/init.c; i386_pc = kern/i386/pc/init.c; i386_pc = kern/i386/pc/mmap.c; diff --git a/grub-core/kern/arm64/efi/init.c b/grub-core/kern/arm64/efi/init.c new file mode 100644 index 000000000..6224999ec --- /dev/null +++ b/grub-core/kern/arm64/efi/init.c @@ -0,0 +1,60 @@ +/* init.c - initialize an arm-based EFI system */ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2013 Free Software Foundation, Inc. + * + * GRUB is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GRUB is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GRUB. If not, see . + */ + +#include +#include +#include +#include +#include +#include +#include + +static grub_uint64_t timer_frequency_in_khz; + +static grub_uint64_t +grub_efi_get_time_ms (void) +{ + grub_uint64_t tmr; + asm volatile("mrs %0, cntvct_el0" : "=r" (tmr)); + + return tmr / timer_frequency_in_khz; +} + + +void +grub_machine_init (void) +{ + grub_uint64_t timer_frequency; + + grub_efi_init (); + + asm volatile("mrs %0, cntfrq_el0" : "=r" (timer_frequency)); + timer_frequency_in_khz = timer_frequency / 1000; + + grub_install_get_time_ms (grub_efi_get_time_ms); +} + +void +grub_machine_fini (int flags) +{ + if (!(flags & GRUB_LOADER_FLAG_NORETURN)) + return; + + grub_efi_fini (); +} From 7c35f65aaca8539d3fccea17e3ff6fc0e71143a4 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 12 Feb 2016 15:42:26 +0100 Subject: [PATCH 681/722] xnu: Add new kernel path to autoconfig. --- util/grub.d/10_xnu.in | 3 +++ util/grub.d/30_os-prober.in | 3 +++ 2 files changed, 6 insertions(+) diff --git a/util/grub.d/10_xnu.in b/util/grub.d/10_xnu.in index 51ee2f427..9c40b4536 100644 --- a/util/grub.d/10_xnu.in +++ b/util/grub.d/10_xnu.in @@ -56,6 +56,9 @@ EOF fi if [ /kernelcache -nt /System/Library/Extensions ]; then $1 /kernelcache boot-uuid=\${uuid} rd=*uuid + elif [ -f /System/Library/Kernels/kernel ]; then + $1 /System/Library/Kernels/kernel boot-uuid=\${uuid} rd=*uuid + xnu_kextdir /System/Library/Extensions else $1 /mach_kernel boot-uuid=\${uuid} rd=*uuid if [ /System/Library/Extensions.mkext -nt /System/Library/Extensions ]; then diff --git a/util/grub.d/30_os-prober.in b/util/grub.d/30_os-prober.in index 5604ce2b6..515a68c7a 100644 --- a/util/grub.d/30_os-prober.in +++ b/util/grub.d/30_os-prober.in @@ -71,6 +71,9 @@ EOF fi if [ /kernelcache -nt /System/Library/Extensions ]; then $1 /kernelcache boot-uuid=\${uuid} rd=*uuid + elif [ -f /System/Library/Kernels/kernel ]; then + $1 /System/Library/Kernels/kernel boot-uuid=\${uuid} rd=*uuid + xnu_kextdir /System/Library/Extensions else $1 /mach_kernel boot-uuid=\${uuid} rd=*uuid if [ /System/Library/Extensions.mkext -nt /System/Library/Extensions ]; then From 6e1ace590afd02abbdfdf05cff0672fc3906365a Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 12 Feb 2016 15:46:05 +0100 Subject: [PATCH 682/722] Change -v to -V for version of shell utils. --- util/grub-kbdcomp.in | 4 ++-- util/grub-mkconfig.in | 2 +- util/grub-reboot.in | 4 ++-- util/grub-set-default.in | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/util/grub-kbdcomp.in b/util/grub-kbdcomp.in index 715c483af..a15ec24e5 100644 --- a/util/grub-kbdcomp.in +++ b/util/grub-kbdcomp.in @@ -25,7 +25,7 @@ usage () { gettext "Make GRUB keyboard layout file."; echo echo print_option_help "-h, --help" "$(gettext "print this message and exit")" - print_option_help "-v, --version" "$(gettext "print the version information and exit")" + print_option_help "-V, --version" "$(gettext "print the version information and exit")" print_option_help "-o, --output=$(gettext FILE)" "$(gettext "save output in FILE [required]")" echo gettext_printf "%s generates a keyboard layout for GRUB using ckbcomp\n" "$self" @@ -54,7 +54,7 @@ do -h | --help) usage exit 0 ;; - -v | --version) + -V | --version) echo "$self (${PACKAGE_NAME}) ${PACKAGE_VERSION}" exit 0 ;; -o | --output) diff --git a/util/grub-mkconfig.in b/util/grub-mkconfig.in index 3183744bf..203b07696 100644 --- a/util/grub-mkconfig.in +++ b/util/grub-mkconfig.in @@ -85,7 +85,7 @@ do -h | --help) usage exit 0 ;; - -v | --version) + -V | --version) echo "$self (${PACKAGE_NAME}) ${PACKAGE_VERSION}" exit 0 ;; -o | --output) diff --git a/util/grub-reboot.in b/util/grub-reboot.in index 225fe5f21..4d4f75704 100644 --- a/util/grub-reboot.in +++ b/util/grub-reboot.in @@ -47,7 +47,7 @@ usage () { gettext_printf "Usage: %s [OPTION] MENU_ENTRY\n" "$self" gettext "Set the default boot menu entry for GRUB, for the next boot only."; echo print_option_help "-h, --help" "$(gettext "print this message and exit")" - print_option_help "-v, --version" "$(gettext "print the version information and exit")" + print_option_help "-V, --version" "$(gettext "print the version information and exit")" dirmsg="$(gettext_printf "expect GRUB images under the directory DIR/%s instead of the %s directory" "@grubdirname@" "$grubdir")" print_option_help "--boot-directory=$(gettext "DIR")" "$dirmsg" echo @@ -81,7 +81,7 @@ do -h | --help) usage exit 0 ;; - -v | --version) + -V | --version) echo "$self (${PACKAGE_NAME}) ${PACKAGE_VERSION}" exit 0 ;; diff --git a/util/grub-set-default.in b/util/grub-set-default.in index 83a7be12f..6036f81e5 100644 --- a/util/grub-set-default.in +++ b/util/grub-set-default.in @@ -49,7 +49,7 @@ usage () { gettext_printf "This requires setting GRUB_DEFAULT=saved in %s/default/grub.\n" "$sysconfdir" echo print_option_help "-h, --help" "$(gettext "print this message and exit")" - print_option_help "-v, --version" "$(gettext "print the version information and exit")" + print_option_help "-V, --version" "$(gettext "print the version information and exit")" dirmsg="$(gettext_printf "expect GRUB images under the directory DIR/%s instead of the %s directory" "@grubdirname@" "$grubdir")" print_option_help "--boot-directory=$(gettext "DIR")" "$dirmsg" echo @@ -79,7 +79,7 @@ do -h | --help) usage exit 0 ;; - -v | --version) + -V | --version) echo "$self (${PACKAGE_NAME}) ${PACKAGE_VERSION}" exit 0 ;; From eba6db6323caf2c25e3531902b73c4a1a40a2d1a Mon Sep 17 00:00:00 2001 From: Daniel Kiper Date: Fri, 12 Feb 2016 15:58:22 +0100 Subject: [PATCH 683/722] relocator: Fix integer underflow. --- grub-core/lib/relocator.c | 50 +++++++++++++++++++++++---------------- 1 file changed, 30 insertions(+), 20 deletions(-) diff --git a/grub-core/lib/relocator.c b/grub-core/lib/relocator.c index f759c7f41..ea3ebc719 100644 --- a/grub-core/lib/relocator.c +++ b/grub-core/lib/relocator.c @@ -736,26 +736,36 @@ malloc_in_range (struct grub_relocator *rel, } isinsideafter = (!ncollisions && (nstarted || ((nlefto || nstartedfw) && !nblockfw))); - if (!isinsidebefore && isinsideafter) - starta = from_low_priv ? ALIGN_UP (events[j].pos, align) - : ALIGN_DOWN (events[j].pos - size, align) + size; - if (isinsidebefore && !isinsideafter && from_low_priv) - { - target = starta; - if (target < start) - target = start; - if (target + size <= end && target + size <= events[j].pos) - /* Found an usable address. */ - goto found; - } - if (isinsidebefore && !isinsideafter && !from_low_priv) - { - target = starta - size; - if (target > end - size) - target = end - size; - if (target >= start && target >= events[j].pos) - goto found; - } + if (from_low_priv) { + if (!isinsidebefore && isinsideafter) + starta = ALIGN_UP (events[j].pos, align); + + if (isinsidebefore && !isinsideafter) + { + target = starta; + if (target < start) + target = start; + if (target + size <= end && target + size <= events[j].pos) + /* Found an usable address. */ + goto found; + } + } else { + if (!isinsidebefore && isinsideafter) + { + if (events[j].pos >= size) + starta = ALIGN_DOWN (events[j].pos - size, align) + size; + else + starta = 0; + } + if (isinsidebefore && !isinsideafter && starta >= size) + { + target = starta - size; + if (target > end - size) + target = end - size; + if (target >= start && target >= events[j].pos) + goto found; + } + } } } From feef882f98f335b2725edc53af76f5ff50551949 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 12 Feb 2016 16:08:04 +0100 Subject: [PATCH 684/722] grub-shell: Update 32-bit OVMF binary name. --- tests/util/grub-shell.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/util/grub-shell.in b/tests/util/grub-shell.in index 663cde663..7848b4222 100644 --- a/tests/util/grub-shell.in +++ b/tests/util/grub-shell.in @@ -165,7 +165,7 @@ case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in boot=cd console=console trim=1 - qemuopts="-bios OVMF32.fd $qemuopts" + qemuopts="-bios OVMF-ia32.fd $qemuopts" ;; x86_64-efi) qemu=qemu-system-x86_64 From ce01054ec3f8f8d03fba434de94ab00118c16593 Mon Sep 17 00:00:00 2001 From: Toomas Soome Date: Fri, 12 Feb 2016 16:31:23 +0100 Subject: [PATCH 685/722] lz4: Fix pointer overflow --- grub-core/fs/zfs/zfs_lz4.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/grub-core/fs/zfs/zfs_lz4.c b/grub-core/fs/zfs/zfs_lz4.c index 1212a8986..2f73449f0 100644 --- a/grub-core/fs/zfs/zfs_lz4.c +++ b/grub-core/fs/zfs/zfs_lz4.c @@ -184,6 +184,8 @@ LZ4_uncompress_unknownOutputSize(const char *source, } } /* copy literals */ + if ((grub_addr_t) length > ~(grub_addr_t)op) + goto _output_error; cpy = op + length; if ((cpy > oend - COPYLENGTH) || (ip + length > iend - COPYLENGTH)) { From a2ab8c2172367e25f79617cad878102bd5f8a336 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 12 Feb 2016 17:51:52 +0100 Subject: [PATCH 686/722] TODO: Remove obsolete link --- TODO | 4 ---- 1 file changed, 4 deletions(-) diff --git a/TODO b/TODO index 6ec1521cd..a9b6d3523 100644 --- a/TODO +++ b/TODO @@ -7,7 +7,3 @@ glance. So write to first. For bug tracking, refer to: http://savannah.gnu.org/bugs/?group=grub - -Our wiki also lists some areas that need work: - - http://grub.enbug.org/ From f96b34224e50dbba055f7744406038d5beccf2a6 Mon Sep 17 00:00:00 2001 From: Andreas Freimuth Date: Fri, 12 Feb 2016 19:19:11 +0100 Subject: [PATCH 687/722] Add Thinkpad T410s button cmos address. --- docs/grub.texi | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/grub.texi b/docs/grub.texi index 0afdd8ccd..82f6fa459 100644 --- a/docs/grub.texi +++ b/docs/grub.texi @@ -2538,6 +2538,8 @@ team are: 85:3 @item Asus EeePC 1005PE 84:1 (unconfirmed) +@item LENOVO ThinkPad T410s (2912W1C) +101:3 @end table To take full advantage of this function, install GRUB into the MBR From 080a20861c08397bfef5eb1471b6124a82a0777c Mon Sep 17 00:00:00 2001 From: Eric Snowberg Date: Fri, 12 Feb 2016 23:16:03 +0100 Subject: [PATCH 688/722] OBP available region contains grub. Start at grub_phys_end. This prevents a problem where grub was being overwritten since grub_phys_start does not start at a zero offset within the memory map. --- grub-core/loader/sparc64/ieee1275/linux.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/grub-core/loader/sparc64/ieee1275/linux.c b/grub-core/loader/sparc64/ieee1275/linux.c index d44d7a113..67ef04883 100644 --- a/grub-core/loader/sparc64/ieee1275/linux.c +++ b/grub-core/loader/sparc64/ieee1275/linux.c @@ -203,20 +203,20 @@ alloc_phys_choose (grub_uint64_t addr, grub_uint64_t len, if (addr + ctx->size >= end) return 0; - if (addr >= grub_phys_start && addr < grub_phys_end) - { - addr = ALIGN_UP (grub_phys_end, FOUR_MB); - if (addr + ctx->size >= end) - return 0; - } - if ((addr + ctx->size) >= grub_phys_start - && (addr + ctx->size) < grub_phys_end) + /* OBP available region contains grub. Start at grub_phys_end. */ + /* grub_phys_start does not start at the beginning of the memory region */ + if ((grub_phys_start >= addr && grub_phys_end < end) || + (addr > grub_phys_start && addr < grub_phys_end)) { addr = ALIGN_UP (grub_phys_end, FOUR_MB); if (addr + ctx->size >= end) return 0; } + grub_dprintf("loader", + "addr = 0x%lx grub_phys_start = 0x%lx grub_phys_end = 0x%lx\n", + addr, grub_phys_start, grub_phys_end); + if (loaded) { grub_addr_t linux_end = ALIGN_UP (linux_paddr + linux_size, FOUR_MB); From 25492a0f047cb7a6583ae195568599c296a604d6 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sun, 10 Jan 2016 13:48:26 +0100 Subject: [PATCH 689/722] Add wbinvd around bios call. Via C3 has problems with cache coherency when transitioning between the modes, so flush it around bios calls. --- grub-core/kern/i386/int.S | 11 +++++++++++ grub-core/kern/i386/pc/init.c | 24 ++++++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/grub-core/kern/i386/int.S b/grub-core/kern/i386/int.S index 7edace404..862a54202 100644 --- a/grub-core/kern/i386/int.S +++ b/grub-core/kern/i386/int.S @@ -44,6 +44,13 @@ FUNCTION(grub_bios_interrupt) movl 24(%edx), %esi movl 28(%edx), %edx + /* + Via C3 CPUs have cache coherence problems, so we need to call + wbinvd at these 2 points. As wbinvd slows down boot, don't do + it on non-VIA. 9090 is nop nop. */ +VARIABLE(grub_bios_via_workaround1) + .byte 0x90, 0x90 + PROT_TO_REAL .code16 pushf @@ -92,6 +99,10 @@ intno: movw %ax, LOCAL(bios_register_es) popf + +VARIABLE(grub_bios_via_workaround2) + .byte 0x90, 0x90 + REAL_TO_PROT .code32 diff --git a/grub-core/kern/i386/pc/init.c b/grub-core/kern/i386/pc/init.c index 3c8160aab..27bc68b8a 100644 --- a/grub-core/kern/i386/pc/init.c +++ b/grub-core/kern/i386/pc/init.c @@ -32,6 +32,7 @@ #include #include #include +#include #include #include @@ -184,6 +185,26 @@ mmap_iterate_hook (grub_uint64_t addr, grub_uint64_t size, return 0; } +extern grub_uint16_t grub_bios_via_workaround1, grub_bios_via_workaround2; + +/* Via needs additional wbinvd. */ +static void +grub_via_workaround_init (void) +{ + grub_uint32_t manufacturer[3], max_cpuid; + if (! grub_cpu_is_cpuid_supported ()) + return; + + grub_cpuid (0, max_cpuid, manufacturer[0], manufacturer[2], manufacturer[1]); + + if (grub_memcmp (manufacturer, "CentaurHauls", 12) != 0) + return; + + grub_bios_via_workaround1 = 0x090f; + grub_bios_via_workaround2 = 0x090f; + asm volatile ("wbinvd"); +} + void grub_machine_init (void) { @@ -193,6 +214,9 @@ grub_machine_init (void) #endif grub_addr_t modend; + /* This has to happen before any BIOS calls. */ + grub_via_workaround_init (); + grub_modbase = GRUB_MEMORY_MACHINE_DECOMPRESSION_ADDR + (_edata - _start); /* Initialize the console as early as possible. */ From 5cae910665ac0de9e409e3b606232cd66854081e Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Wed, 17 Feb 2016 17:56:41 +0100 Subject: [PATCH 690/722] Fix warnings when compiling with -O3 --- conf/Makefile.common | 2 +- grub-core/commands/i386/cmostest.c | 6 +++--- grub-core/fs/ntfscomp.c | 2 +- grub-core/fs/zfs/zfs.c | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/conf/Makefile.common b/conf/Makefile.common index 11296b550..6db04343a 100644 --- a/conf/Makefile.common +++ b/conf/Makefile.common @@ -65,7 +65,7 @@ grubconfdir = $(sysconfdir)/grub.d platformdir = $(pkglibdir)/$(target_cpu)-$(platform) starfielddir = $(pkgdatadir)/themes/starfield -CFLAGS_GNULIB = -Wno-undef -Wno-sign-compare -Wno-unused -Wno-unused-parameter -Wno-redundant-decls -Wno-unreachable-code -Wno-conversion +CFLAGS_GNULIB = -Wno-undef -Wno-sign-compare -Wno-unused -Wno-unused-parameter -Wno-redundant-decls -Wno-unreachable-code -Wno-conversion -Wno-maybe-uninitialized CPPFLAGS_GNULIB = -I$(top_builddir)/grub-core/gnulib -I$(top_srcdir)/grub-core/gnulib CFLAGS_POSIX = -fno-builtin diff --git a/grub-core/commands/i386/cmostest.c b/grub-core/commands/i386/cmostest.c index e5dea0769..c839b704d 100644 --- a/grub-core/commands/i386/cmostest.c +++ b/grub-core/commands/i386/cmostest.c @@ -45,7 +45,7 @@ static grub_err_t grub_cmd_cmostest (struct grub_command *cmd __attribute__ ((unused)), int argc, char *argv[]) { - int byte, bit; + int byte = 0, bit = 0; grub_err_t err; grub_uint8_t value; @@ -67,7 +67,7 @@ static grub_err_t grub_cmd_cmosclean (struct grub_command *cmd __attribute__ ((unused)), int argc, char *argv[]) { - int byte, bit; + int byte = 0, bit = 0; grub_err_t err; grub_uint8_t value; @@ -85,7 +85,7 @@ static grub_err_t grub_cmd_cmosset (struct grub_command *cmd __attribute__ ((unused)), int argc, char *argv[]) { - int byte, bit; + int byte = 0, bit = 0; grub_err_t err; grub_uint8_t value; diff --git a/grub-core/fs/ntfscomp.c b/grub-core/fs/ntfscomp.c index 2e1ce51a8..3cd97d337 100644 --- a/grub-core/fs/ntfscomp.c +++ b/grub-core/fs/ntfscomp.c @@ -104,7 +104,7 @@ decomp_block (struct grub_ntfs_comp *cc, grub_uint8_t *dest) if (tag & 1) { grub_uint32_t i, len, delta, code, lmask, dshift; - grub_uint16_t word; + grub_uint16_t word = 0; if (decomp_get16 (cc, &word)) return grub_errno; diff --git a/grub-core/fs/zfs/zfs.c b/grub-core/fs/zfs/zfs.c index c4ead29fb..6e1fff9e9 100644 --- a/grub-core/fs/zfs/zfs.c +++ b/grub-core/fs/zfs/zfs.c @@ -3132,7 +3132,7 @@ make_mdn (dnode_end_t * mdn, struct grub_zfs_data *data) { void *osp; blkptr_t *bp; - grub_size_t ospsize; + grub_size_t ospsize = 0; grub_err_t err; grub_dprintf ("zfs", "endian = %d\n", mdn->endian); From fabde8324d1fccb79778d180aee30894c0b10c63 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Wed, 17 Feb 2016 17:58:05 +0100 Subject: [PATCH 691/722] Remove -Wno-maybe-uninitialized as it may not be present. --- conf/Makefile.common | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/Makefile.common b/conf/Makefile.common index 6db04343a..11296b550 100644 --- a/conf/Makefile.common +++ b/conf/Makefile.common @@ -65,7 +65,7 @@ grubconfdir = $(sysconfdir)/grub.d platformdir = $(pkglibdir)/$(target_cpu)-$(platform) starfielddir = $(pkgdatadir)/themes/starfield -CFLAGS_GNULIB = -Wno-undef -Wno-sign-compare -Wno-unused -Wno-unused-parameter -Wno-redundant-decls -Wno-unreachable-code -Wno-conversion -Wno-maybe-uninitialized +CFLAGS_GNULIB = -Wno-undef -Wno-sign-compare -Wno-unused -Wno-unused-parameter -Wno-redundant-decls -Wno-unreachable-code -Wno-conversion CPPFLAGS_GNULIB = -I$(top_builddir)/grub-core/gnulib -I$(top_srcdir)/grub-core/gnulib CFLAGS_POSIX = -fno-builtin From 59ec05bcf8bb443853c109039752cefdfc1c5e13 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Wed, 17 Feb 2016 18:09:44 +0100 Subject: [PATCH 692/722] mm: Avoid integer overflow. --- grub-core/kern/mm.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/grub-core/kern/mm.c b/grub-core/kern/mm.c index 1c3d02388..ee88ff611 100644 --- a/grub-core/kern/mm.c +++ b/grub-core/kern/mm.c @@ -325,6 +325,15 @@ grub_memalign (grub_size_t align, grub_size_t size) if (!grub_mm_base) goto fail; + if (size > ~(grub_size_t) align) + goto fail; + + /* We currently assume at least a 32-bit grub_size_t, + so limiting allocations to - 1MiB + in name of sanity is beneficial. */ + if ((size + align) > ~(grub_size_t) 0x100000) + goto fail; + align = (align >> GRUB_MM_ALIGN_LOG2); if (align == 0) align = 1; From 8d69065f5282e1f9e0b09a166586ce3a6b897581 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Wed, 17 Feb 2016 18:10:31 +0100 Subject: [PATCH 693/722] default_payload.elf: Add modules from $(EXTRA_PAYLOAD_MODULES). This allows coreboot building system to add extra modules depending on user config. --- Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.am b/Makefile.am index 71c23e50d..cccd466aa 100644 --- a/Makefile.am +++ b/Makefile.am @@ -410,7 +410,7 @@ bootcheck: $(BOOTCHECKS) if COND_i386_coreboot default_payload.elf: grub-mkstandalone grub-mkimage - pkgdatadir=. ./grub-mkstandalone --grub-mkimage=./grub-mkimage -O i386-coreboot -o $@ --modules='ahci pata ehci uhci ohci usb_keyboard usbms part_msdos ext2 fat at_keyboard part_gpt usbserial_usbdebug cbfs' --install-modules='ls linux search configfile normal cbtime cbls memrw iorw minicmd lsmmap lspci halt reboot hexdump pcidump regexp setpci lsacpi chain test serial multiboot cbmemc linux16 gzio echo help syslinuxcfg xnu $(shell cat grub-core/fs.lst)' --fonts= --themes= --locales= -d grub-core/ /boot/grub/grub.cfg=$(srcdir)/coreboot.cfg + pkgdatadir=. ./grub-mkstandalone --grub-mkimage=./grub-mkimage -O i386-coreboot -o $@ --modules='ahci pata ehci uhci ohci usb_keyboard usbms part_msdos ext2 fat at_keyboard part_gpt usbserial_usbdebug cbfs' --install-modules='ls linux search configfile normal cbtime cbls memrw iorw minicmd lsmmap lspci halt reboot hexdump pcidump regexp setpci lsacpi chain test serial multiboot cbmemc linux16 gzio echo help syslinuxcfg xnu $(shell cat grub-core/fs.lst) $(EXTRA_PAYLOAD_MODULES)' --fonts= --themes= --locales= -d grub-core/ /boot/grub/grub.cfg=$(srcdir)/coreboot.cfg endif endif From 01d50c25398d124c275f05ca2926657e2198bed4 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Wed, 17 Feb 2016 18:11:51 +0100 Subject: [PATCH 694/722] default_payload.elf: Include password_pbkdf2. Withoout this module we may end up in a system where no password is accepted. --- Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.am b/Makefile.am index cccd466aa..f132a8839 100644 --- a/Makefile.am +++ b/Makefile.am @@ -410,7 +410,7 @@ bootcheck: $(BOOTCHECKS) if COND_i386_coreboot default_payload.elf: grub-mkstandalone grub-mkimage - pkgdatadir=. ./grub-mkstandalone --grub-mkimage=./grub-mkimage -O i386-coreboot -o $@ --modules='ahci pata ehci uhci ohci usb_keyboard usbms part_msdos ext2 fat at_keyboard part_gpt usbserial_usbdebug cbfs' --install-modules='ls linux search configfile normal cbtime cbls memrw iorw minicmd lsmmap lspci halt reboot hexdump pcidump regexp setpci lsacpi chain test serial multiboot cbmemc linux16 gzio echo help syslinuxcfg xnu $(shell cat grub-core/fs.lst) $(EXTRA_PAYLOAD_MODULES)' --fonts= --themes= --locales= -d grub-core/ /boot/grub/grub.cfg=$(srcdir)/coreboot.cfg + pkgdatadir=. ./grub-mkstandalone --grub-mkimage=./grub-mkimage -O i386-coreboot -o $@ --modules='ahci pata ehci uhci ohci usb_keyboard usbms part_msdos ext2 fat at_keyboard part_gpt usbserial_usbdebug cbfs' --install-modules='ls linux search configfile normal cbtime cbls memrw iorw minicmd lsmmap lspci halt reboot hexdump pcidump regexp setpci lsacpi chain test serial multiboot cbmemc linux16 gzio echo help syslinuxcfg xnu $(shell cat grub-core/fs.lst) password_pbkdf2 $(EXTRA_PAYLOAD_MODULES)' --fonts= --themes= --locales= -d grub-core/ /boot/grub/grub.cfg=$(srcdir)/coreboot.cfg endif endif From e3745f908706c07fa249616255ed993ef5704351 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Wed, 17 Feb 2016 18:19:18 +0100 Subject: [PATCH 695/722] default_payload.elf: Always rebuild and remove before build. It's difficult to know all dependencies. Since it's manual and cheap target anyway, simply always rebuild it. --- Makefile.am | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Makefile.am b/Makefile.am index f132a8839..288e621d3 100644 --- a/Makefile.am +++ b/Makefile.am @@ -409,7 +409,8 @@ BOOTCHECK_TIMEOUT=180 bootcheck: $(BOOTCHECKS) if COND_i386_coreboot -default_payload.elf: grub-mkstandalone grub-mkimage +default_payload.elf: grub-mkstandalone grub-mkimage FORCE + rm $@ pkgdatadir=. ./grub-mkstandalone --grub-mkimage=./grub-mkimage -O i386-coreboot -o $@ --modules='ahci pata ehci uhci ohci usb_keyboard usbms part_msdos ext2 fat at_keyboard part_gpt usbserial_usbdebug cbfs' --install-modules='ls linux search configfile normal cbtime cbls memrw iorw minicmd lsmmap lspci halt reboot hexdump pcidump regexp setpci lsacpi chain test serial multiboot cbmemc linux16 gzio echo help syslinuxcfg xnu $(shell cat grub-core/fs.lst) password_pbkdf2 $(EXTRA_PAYLOAD_MODULES)' --fonts= --themes= --locales= -d grub-core/ /boot/grub/grub.cfg=$(srcdir)/coreboot.cfg endif From 625934ec0f208836c6f2dbe7bd8ad658cbdd8537 Mon Sep 17 00:00:00 2001 From: Thomas Huth Date: Fri, 29 Jan 2016 15:26:58 +0100 Subject: [PATCH 696/722] menu_entry: Disable cursor during update_screen() When running grub in a VGA console of a KVM pseries guest on PowerPC, you can see the cursor sweeping over the whole line when entering a character in editor mode. This is visible because grub always refreshes the whole line when entering a character in editor mode, and drawing characters is quite a slow operation with the firmware used for the powerpc pseries guests (SLOF). To avoid this ugliness, the cursor should be disabled when refreshing the screen contents during update_screen(). Signed-off-by: Thomas Huth --- grub-core/normal/menu_entry.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/grub-core/normal/menu_entry.c b/grub-core/normal/menu_entry.c index b80d161dd..eeeee5580 100644 --- a/grub-core/normal/menu_entry.c +++ b/grub-core/normal/menu_entry.c @@ -254,6 +254,8 @@ update_screen (struct screen *screen, struct per_term_screen *term_screen, mode = ALL_LINES; } + grub_term_setcursor (term_screen->term, 0); + if (mode != NO_LINE) { /* Draw lines. This code is tricky, because this must calculate logical @@ -361,6 +363,8 @@ update_screen (struct screen *screen, struct per_term_screen *term_screen, } + grub_term_setcursor (term_screen->term, 1); + grub_term_refresh (term_screen->term); } From bc220962e366b1b46769ed6f9fa5be603ba58ab5 Mon Sep 17 00:00:00 2001 From: Eric Snowberg Date: Mon, 15 Feb 2016 10:53:45 -0800 Subject: [PATCH 697/722] ieee1275: prevent buffer over-read Prevent buffer over-read in grub_machine_mmap_iterate. This was causing phys_base from being calculated properly. This then caused the wrong value to be placed in ramdisk_image within struct linux_hdrs. Which prevented the ramdisk from loading on boot. Newer SPARC systems contain more than 8 available memory entries. For example on a T5-8 with 2TB of memory, the memory layout could look like this: T5-8 Memory reg 00000000 30000000 0000003f b0000000 00000800 00000000 00000040 00000000 00001000 00000000 00000040 00000000 00001800 00000000 00000040 00000000 00002000 00000000 00000040 00000000 00002800 00000000 00000040 00000000 00003000 00000000 00000040 00000000 00003800 00000000 00000040 00000000 available 00003800 00000000 0000003f ffcae000 00003000 00000000 00000040 00000000 00002800 00000000 00000040 00000000 00002000 00000000 00000040 00000000 00001800 00000000 00000040 00000000 00001000 00000000 00000040 00000000 00000800 00000000 00000040 00000000 00000000 70000000 0000003f 70000000 00000000 6eef8000 00000000 00002000 00000000 30400000 00000000 3eaf6000 name memory Signed-off-by: Eric Snowberg --- grub-core/kern/ieee1275/mmap.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/grub-core/kern/ieee1275/mmap.c b/grub-core/kern/ieee1275/mmap.c index 911bb0011..d7f6a1bde 100644 --- a/grub-core/kern/ieee1275/mmap.c +++ b/grub-core/kern/ieee1275/mmap.c @@ -25,7 +25,7 @@ grub_machine_mmap_iterate (grub_memory_hook_t hook, void *hook_data) { grub_ieee1275_phandle_t root; grub_ieee1275_phandle_t memory; - grub_uint32_t available[32]; + grub_uint32_t available[128]; grub_ssize_t available_size; grub_uint32_t address_cells = 1; grub_uint32_t size_cells = 1; @@ -49,6 +49,9 @@ grub_machine_mmap_iterate (grub_memory_hook_t hook, void *hook_data) sizeof available, &available_size)) return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "couldn't examine /memory/available property"); + if (available_size > sizeof (available)) + return grub_error (GRUB_ERR_UNKNOWN_DEVICE, + "/memory response buffer exceeded"); if (grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_BROKEN_ADDRESS_CELLS)) { From be4e9d20a559ea0ddab5c1abe512a3d875742389 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sat, 20 Feb 2016 09:12:15 +0100 Subject: [PATCH 698/722] Refresh before abort This ensures that abort message is actually visible to the user. --- grub-core/kern/misc.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/grub-core/kern/misc.c b/grub-core/kern/misc.c index e3f851633..d1a54df6c 100644 --- a/grub-core/kern/misc.c +++ b/grub-core/kern/misc.c @@ -1106,6 +1106,8 @@ grub_fatal (const char *fmt, ...) grub_vprintf (_(fmt), ap); va_end (ap); + grub_refresh (); + grub_abort (); } From 0678b5d629a4c9a7258d24a0af10920d0e965da7 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 22 Feb 2016 03:25:50 +0100 Subject: [PATCH 699/722] usb_keyboard: Remove useless include This prevents non-PCI machines from having USB. --- grub-core/term/usb_keyboard.c | 1 - 1 file changed, 1 deletion(-) diff --git a/grub-core/term/usb_keyboard.c b/grub-core/term/usb_keyboard.c index 3b7484635..e67b8f785 100644 --- a/grub-core/term/usb_keyboard.c +++ b/grub-core/term/usb_keyboard.c @@ -19,7 +19,6 @@ #include #include -#include #include #include #include From 054d1325e9ece974aecb478e6b43ca6c37d0bb3e Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Mon, 22 Feb 2016 03:32:50 +0100 Subject: [PATCH 700/722] Improve EHCI logging Add dprintf's on common error paths and remove some entries which are too noisy. --- grub-core/bus/usb/ehci.c | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/grub-core/bus/usb/ehci.c b/grub-core/bus/usb/ehci.c index c986c24f6..ae1efb214 100644 --- a/grub-core/bus/usb/ehci.c +++ b/grub-core/bus/usb/ehci.c @@ -1289,16 +1289,26 @@ grub_ehci_setup_transfer (grub_usb_controller_t dev, grub_ehci_td_t td_prev = NULL; int i; struct grub_ehci_transfer_controller_data *cdata; + grub_uint32_t status; /* Check if EHCI is running and AL is enabled */ - if ((grub_ehci_oper_read32 (e, GRUB_EHCI_STATUS) - & GRUB_EHCI_ST_HC_HALTED) != 0) + status = grub_ehci_oper_read32 (e, GRUB_EHCI_STATUS); + if ((status & GRUB_EHCI_ST_HC_HALTED) != 0) /* XXX: Fix it: Currently we don't do anything to restart EHCI */ - return GRUB_USB_ERR_INTERNAL; - if ((grub_ehci_oper_read32 (e, GRUB_EHCI_STATUS) + { + grub_dprintf ("ehci", "setup_transfer: halted, status = 0x%x\n", + status); + return GRUB_USB_ERR_INTERNAL; + } + status = grub_ehci_oper_read32 (e, GRUB_EHCI_STATUS); + if ((status & (GRUB_EHCI_ST_AS_STATUS | GRUB_EHCI_ST_PS_STATUS)) == 0) /* XXX: Fix it: Currently we don't do anything to restart EHCI */ - return GRUB_USB_ERR_INTERNAL; + { + grub_dprintf ("ehci", "setup_transfer: no AS/PS, status = 0x%x\n", + status); + return GRUB_USB_ERR_INTERNAL; + } /* Allocate memory for controller transfer data. */ cdata = grub_malloc (sizeof (*cdata)); @@ -1310,6 +1320,7 @@ grub_ehci_setup_transfer (grub_usb_controller_t dev, cdata->qh_virt = grub_ehci_find_qh (e, transfer); if (!cdata->qh_virt) { + grub_dprintf ("ehci", "setup_transfer: no QH\n"); grub_free (cdata); return GRUB_USB_ERR_INTERNAL; } @@ -1319,6 +1330,7 @@ grub_ehci_setup_transfer (grub_usb_controller_t dev, cdata->td_alt_virt = grub_ehci_alloc_td (e); if (!cdata->td_alt_virt) { + grub_dprintf ("ehci", "setup_transfer: no TDs\n"); grub_free (cdata); return GRUB_USB_ERR_INTERNAL; } @@ -1345,6 +1357,7 @@ grub_ehci_setup_transfer (grub_usb_controller_t dev, grub_ehci_free_tds (e, cdata->td_first_virt, NULL, &actual); grub_free (cdata); + grub_dprintf ("ehci", "setup_transfer: no TD\n"); return GRUB_USB_ERR_INTERNAL; } @@ -1777,11 +1790,6 @@ grub_ehci_detect_dev (grub_usb_controller_t dev, int port, int *changed) status = grub_ehci_port_read (e, port); - grub_dprintf ("ehci", "detect_dev: EHCI STATUS: %08x\n", - grub_ehci_oper_read32 (e, GRUB_EHCI_STATUS)); - grub_dprintf ("ehci", "detect_dev: iobase=%p, port=%d, status=0x%02x\n", - e->iobase, port, status); - /* Connect Status Change bit - it detects change of connection */ if (status & GRUB_EHCI_PORT_CONNECT_CH) { From 15dfea842c03fd373b0b39e98716051815416e95 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Tue, 23 Feb 2016 09:12:14 +0300 Subject: [PATCH 701/722] multiboot2: zero reserved field in memory map Documentation says, bootloader should set reserved field to zero. Reported by Wink Saville --- grub-core/loader/multiboot_mbi2.c | 1 + 1 file changed, 1 insertion(+) diff --git a/grub-core/loader/multiboot_mbi2.c b/grub-core/loader/multiboot_mbi2.c index d7c19bc99..f147d674d 100644 --- a/grub-core/loader/multiboot_mbi2.c +++ b/grub-core/loader/multiboot_mbi2.c @@ -420,6 +420,7 @@ grub_fill_multiboot_mmap_iter (grub_uint64_t addr, grub_uint64_t size, (*mmap_entry)->addr = addr; (*mmap_entry)->len = size; (*mmap_entry)->type = type; + (*mmap_entry)->zero = 0; (*mmap_entry)++; return 0; From 1b782e902e69516f82158203674d4951a40c82d4 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Tue, 23 Feb 2016 23:14:41 +0300 Subject: [PATCH 702/722] search: actually skip floppy with --no-floppy grub_device_iterate() ignores device when iterator returns 1, not 0. Reported by Carlos E. R. --- grub-core/commands/search.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/commands/search.c b/grub-core/commands/search.c index 440303a4e..7dd32e445 100644 --- a/grub-core/commands/search.c +++ b/grub-core/commands/search.c @@ -64,7 +64,7 @@ iterate_device (const char *name, void *data) /* Skip floppy drives when requested. */ if (ctx->no_floppy && name[0] == 'f' && name[1] == 'd' && name[2] >= '0' && name[2] <= '9') - return 0; + return 1; #ifdef DO_SEARCH_FS_UUID #define compare_fn grub_strcasecmp From 94c56a4c65c9b2c0cb99f225fadffc2ca990c9d1 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Tue, 23 Feb 2016 08:57:31 +0100 Subject: [PATCH 703/722] ieee1275: fix signed comparison --- grub-core/kern/ieee1275/mmap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/kern/ieee1275/mmap.c b/grub-core/kern/ieee1275/mmap.c index d7f6a1bde..bf325eadf 100644 --- a/grub-core/kern/ieee1275/mmap.c +++ b/grub-core/kern/ieee1275/mmap.c @@ -49,7 +49,7 @@ grub_machine_mmap_iterate (grub_memory_hook_t hook, void *hook_data) sizeof available, &available_size)) return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "couldn't examine /memory/available property"); - if (available_size > sizeof (available)) + if (available_size < 0 || (grub_size_t) available_size > sizeof (available)) return grub_error (GRUB_ERR_UNKNOWN_DEVICE, "/memory response buffer exceeded"); From eb9f401fc1e919fa29602d4d7b9b4378338e16e9 Mon Sep 17 00:00:00 2001 From: Josef Bacik Date: Wed, 10 Feb 2016 13:21:00 -0800 Subject: [PATCH 704/722] net: fix ipv6 routing ipv6 routing in grub2 is broken, we cannot talk to anything outside our local network or anything that doesn't route in our global namespace. This patch fixes this by doing a couple of things 1) Read the router information off of the router advertisement. If we have a router lifetime we need to take the source address and create a route from it. 2) Changes the routing stuff slightly to allow you to specify a gateway _and_ an interface. Since the router advertisements come in on the link local address we need to associate it with the global address on the card. So when we are processing the router advertisement, either use the SLAAC interface we create and add the route to that interface, or loop through the global addresses we currently have on our interface and associate it with one of those addresses. We need to have a special case here for the default route so that it gets used, we do this by setting the masksize to 0 to mean it encompasses all networks. The routing code will automatically select the best route so if there is a closer match we will use that. With this patch I can now talk to ipv6 addresses outside of my local network. Thanks, Signed-off-by: Josef Bacik --- grub-core/net/bootp.c | 2 +- grub-core/net/drivers/ieee1275/ofnet.c | 4 +- grub-core/net/icmp6.c | 63 +++++++++++++++++++++++++- grub-core/net/net.c | 40 ++++++---------- include/grub/net.h | 25 +++++++++- 5 files changed, 103 insertions(+), 31 deletions(-) diff --git a/grub-core/net/bootp.c b/grub-core/net/bootp.c index 4fdeac3ef..a088244b4 100644 --- a/grub-core/net/bootp.c +++ b/grub-core/net/bootp.c @@ -82,7 +82,7 @@ parse_dhcp_vendor (const char *name, const void *vend, int limit, int *mask) grub_memcpy (&gw.ipv4, ptr, sizeof (gw.ipv4)); rname = grub_xasprintf ("%s:default", name); if (rname) - grub_net_add_route_gw (rname, target, gw); + grub_net_add_route_gw (rname, target, gw, NULL); grub_free (rname); } break; diff --git a/grub-core/net/drivers/ieee1275/ofnet.c b/grub-core/net/drivers/ieee1275/ofnet.c index eff9085ed..6bd3b922e 100644 --- a/grub-core/net/drivers/ieee1275/ofnet.c +++ b/grub-core/net/drivers/ieee1275/ofnet.c @@ -151,7 +151,7 @@ grub_ieee1275_parse_bootpath (const char *devpath, char *bootpath, grub_net_network_level_address_t client_addr, gateway_addr, subnet_mask; grub_net_link_level_address_t hw_addr; grub_net_interface_flags_t flags = 0; - struct grub_net_network_level_interface *inter; + struct grub_net_network_level_interface *inter = NULL; hw_addr.type = GRUB_NET_LINK_LEVEL_PROTOCOL_ETHERNET; @@ -221,7 +221,7 @@ grub_ieee1275_parse_bootpath (const char *devpath, char *bootpath, target.ipv4.masksize = 0; rname = grub_xasprintf ("%s:default", ((*card)->name)); if (rname) - grub_net_add_route_gw (rname, target, gateway_addr); + grub_net_add_route_gw (rname, target, gateway_addr, inter); else return grub_errno; } diff --git a/grub-core/net/icmp6.c b/grub-core/net/icmp6.c index 7953e68ec..2cbd95dce 100644 --- a/grub-core/net/icmp6.c +++ b/grub-core/net/icmp6.c @@ -115,6 +115,7 @@ grub_net_recv_icmp6_packet (struct grub_net_buff *nb, grub_uint8_t ttl) { struct icmp_header *icmph; + struct grub_net_network_level_interface *orig_inf = inf; grub_err_t err; grub_uint16_t checksum; @@ -345,14 +346,31 @@ grub_net_recv_icmp6_packet (struct grub_net_buff *nb, { grub_uint8_t *ptr; struct option_header *ohdr; + struct router_adv *radv; + struct grub_net_network_level_interface *route_inf = NULL; + int default_route = 0; if (icmph->code) break; + radv = (struct router_adv *)nb->data; err = grub_netbuff_pull (nb, sizeof (struct router_adv)); if (err) { grub_netbuff_free (nb); return err; } + if (grub_be_to_cpu16 (radv->router_lifetime) > 0) + { + struct grub_net_route *route; + + FOR_NET_ROUTES (route) + { + if (!grub_memcmp (&route->gw, source, sizeof (route->gw))) + break; + } + if (route == NULL) + default_route = 1; + } + for (ptr = (grub_uint8_t *) nb->data; ptr < nb->tail; ptr += ohdr->len * 8) { @@ -413,7 +431,11 @@ grub_net_recv_icmp6_packet (struct grub_net_buff *nb, /* Update lease time if needed here once we have lease times. */ if (inf) - continue; + { + if (!route_inf) + route_inf = inf; + continue; + } grub_dprintf ("net", "creating slaac\n"); @@ -429,12 +451,51 @@ grub_net_recv_icmp6_packet (struct grub_net_buff *nb, inf = grub_net_add_addr (name, card, &addr, &slaac->address, 0); + if (!route_inf) + route_inf = inf; grub_net_add_route (name, netaddr, inf); grub_free (name); } } } } + if (default_route) + { + char *name; + grub_net_network_level_netaddress_t netaddr; + name = grub_xasprintf ("%s:ra:default6", card->name); + if (!name) + { + grub_errno = GRUB_ERR_NONE; + goto next; + } + /* Default routes take alll of the traffic, so make the mask huge */ + netaddr.type = GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV6; + netaddr.ipv6.masksize = 0; + netaddr.ipv6.base[0] = 0; + netaddr.ipv6.base[1] = 0; + + /* May not have gotten slaac info, find a global address on this + card. */ + if (route_inf == NULL) + { + FOR_NET_NETWORK_LEVEL_INTERFACES (inf) + { + if (inf->card == card && inf != orig_inf + && inf->address.type == GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV6 + && grub_net_hwaddr_cmp(&inf->hwaddress, + &orig_inf->hwaddress) == 0) + { + route_inf = inf; + break; + } + } + } + if (route_inf != NULL) + grub_net_add_route_gw (name, netaddr, *source, route_inf); + grub_free (name); + } +next: if (ptr != nb->tail) break; } diff --git a/grub-core/net/net.c b/grub-core/net/net.c index d07029b34..942459527 100644 --- a/grub-core/net/net.c +++ b/grub-core/net/net.c @@ -37,21 +37,6 @@ GRUB_MOD_LICENSE ("GPLv3+"); char *grub_net_default_server; -struct grub_net_route -{ - struct grub_net_route *next; - struct grub_net_route **prev; - grub_net_network_level_netaddress_t target; - char *name; - struct grub_net_network_level_protocol *prot; - int is_gateway; - union - { - struct grub_net_network_level_interface *interface; - grub_net_network_level_address_t gw; - }; -}; - struct grub_net_route *grub_net_routes = NULL; struct grub_net_network_level_interface *grub_net_network_level_interfaces = NULL; struct grub_net_card *grub_net_cards = NULL; @@ -410,14 +395,6 @@ grub_cmd_ipv6_autoconf (struct grub_command *cmd __attribute__ ((unused)), return err; } -static inline void -grub_net_route_register (struct grub_net_route *route) -{ - grub_list_push (GRUB_AS_LIST_P (&grub_net_routes), - GRUB_AS_LIST (route)); -} - -#define FOR_NET_ROUTES(var) for (var = grub_net_routes; var; var = var->next) static int parse_ip (const char *val, grub_uint32_t *ip, const char **rest) @@ -524,6 +501,8 @@ match_net (const grub_net_network_level_netaddress_t *net, case GRUB_NET_NETWORK_LEVEL_PROTOCOL_IPV6: { grub_uint64_t mask[2]; + if (net->ipv6.masksize == 0) + return 1; if (net->ipv6.masksize <= 64) { mask[0] = 0xffffffffffffffffULL << (64 - net->ipv6.masksize); @@ -687,7 +666,14 @@ grub_net_route_address (grub_net_network_level_address_t addr, return GRUB_ERR_NONE; } if (depth == 0) - *gateway = bestroute->gw; + { + *gateway = bestroute->gw; + if (bestroute->interface != NULL) + { + *interf = bestroute->interface; + return GRUB_ERR_NONE; + } + } curtarget = bestroute->gw; } @@ -1109,7 +1095,8 @@ grub_net_add_route (const char *name, grub_err_t grub_net_add_route_gw (const char *name, grub_net_network_level_netaddress_t target, - grub_net_network_level_address_t gw) + grub_net_network_level_address_t gw, + struct grub_net_network_level_interface *inter) { struct grub_net_route *route; @@ -1127,6 +1114,7 @@ grub_net_add_route_gw (const char *name, route->target = target; route->is_gateway = 1; route->gw = gw; + route->interface = inter; grub_net_route_register (route); @@ -1152,7 +1140,7 @@ grub_cmd_addroute (struct grub_command *cmd __attribute__ ((unused)), err = grub_net_resolve_address (args[3], &gw); if (err) return err; - return grub_net_add_route_gw (args[0], target, gw); + return grub_net_add_route_gw (args[0], target, gw, NULL); } else { diff --git a/include/grub/net.h b/include/grub/net.h index 538baa33e..2192fa186 100644 --- a/include/grub/net.h +++ b/include/grub/net.h @@ -191,6 +191,18 @@ typedef struct grub_net_network_level_netaddress }; } grub_net_network_level_netaddress_t; +struct grub_net_route +{ + struct grub_net_route *next; + struct grub_net_route **prev; + grub_net_network_level_netaddress_t target; + char *name; + struct grub_net_network_level_protocol *prot; + int is_gateway; + struct grub_net_network_level_interface *interface; + grub_net_network_level_address_t gw; +}; + #define FOR_PACKETS(cont,var) for (var = (cont).first; var; var = var->next) static inline grub_err_t @@ -367,6 +379,16 @@ grub_net_card_unregister (struct grub_net_card *card); #define FOR_NET_CARDS_SAFE(var, next) for (var = grub_net_cards, next = (var ? var->next : 0); var; var = next, next = (var ? var->next : 0)) +extern struct grub_net_route *grub_net_routes; + +static inline void +grub_net_route_register (struct grub_net_route *route) +{ + grub_list_push (GRUB_AS_LIST_P (&grub_net_routes), + GRUB_AS_LIST (route)); +} + +#define FOR_NET_ROUTES(var) for (var = grub_net_routes; var; var = var->next) struct grub_net_session * grub_net_open_tcp (char *address, grub_uint16_t port); @@ -392,7 +414,8 @@ grub_net_add_route (const char *name, grub_err_t grub_net_add_route_gw (const char *name, grub_net_network_level_netaddress_t target, - grub_net_network_level_address_t gw); + grub_net_network_level_address_t gw, + struct grub_net_network_level_interface *inter); #define GRUB_NET_BOOTP_MAC_ADDR_LEN 16 From 5486a4e12b7ad18f06156bb042a350a39d355c22 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 26 Feb 2016 11:12:35 +0100 Subject: [PATCH 705/722] Makefile: Don't delete default_payload.elf if it doesn't exist. --- Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.am b/Makefile.am index 288e621d3..00a9663b3 100644 --- a/Makefile.am +++ b/Makefile.am @@ -410,7 +410,7 @@ bootcheck: $(BOOTCHECKS) if COND_i386_coreboot default_payload.elf: grub-mkstandalone grub-mkimage FORCE - rm $@ + test -f $@ && rm $@ || true pkgdatadir=. ./grub-mkstandalone --grub-mkimage=./grub-mkimage -O i386-coreboot -o $@ --modules='ahci pata ehci uhci ohci usb_keyboard usbms part_msdos ext2 fat at_keyboard part_gpt usbserial_usbdebug cbfs' --install-modules='ls linux search configfile normal cbtime cbls memrw iorw minicmd lsmmap lspci halt reboot hexdump pcidump regexp setpci lsacpi chain test serial multiboot cbmemc linux16 gzio echo help syslinuxcfg xnu $(shell cat grub-core/fs.lst) password_pbkdf2 $(EXTRA_PAYLOAD_MODULES)' --fonts= --themes= --locales= -d grub-core/ /boot/grub/grub.cfg=$(srcdir)/coreboot.cfg endif From 06a3b0b214d077cc2a52a6295175de3c79c04113 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 26 Feb 2016 11:37:47 +0100 Subject: [PATCH 706/722] Regenerate checksums --- grub-core/tests/checksums.h | 196 ++++++++++++++++++------------------ 1 file changed, 98 insertions(+), 98 deletions(-) diff --git a/grub-core/tests/checksums.h b/grub-core/tests/checksums.h index b42d63d25..2320158d4 100644 --- a/grub-core/tests/checksums.h +++ b/grub-core/tests/checksums.h @@ -1,101 +1,101 @@ - { "cmdline_cat", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x24dc7bce, 0x24dc7bce, 0x338542b, 0x338542b, 0x2016b9d1, 0x2016b9d1, 0xc2619a36, 0xc2619a36, 0x10fce1e, 0x10fce1e, 0x8267298e, 0x8267298e, 0xf44246cf, 0xf44246cf, 0x3ee2860f, 0x3ee2860f, 0x1191f916, 0x1191f916, 0xfa8ce1b5, 0xfa8ce1b5, 0xc1f18b8e, 0xc1f18b8e, 0x43f8c0e8, 0x43f8c0e8, 0xbc0d166a, 0xbc0d166a, 0x7b742e8f, 0x7b742e8f, 0x2c3c7f89, 0x2c3c7f89, 0x80148a7e, 0x80148a7e, 0x21daaadf, 0x21daaadf, 0x15e97fa9, 0x15e97fa9, 0x2428d454, 0x2428d454, 0xb12b0f78, 0xb12b0f78, 0x29648b05, 0x8ce36e6f, 0xd26b03dd, 0xd26b03dd, }, 45 }, - { "cmdline_cat", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0xd09d4d28, 0xd09d4d28, 0xb41a2f17, 0xb41a2f17, 0x56381354, 0x56381354, 0xf2c5615f, 0xf2c5615f, 0xa41822ae, 0xa41822ae, 0xba2e3e60, 0xba2e3e60, 0x1859aaac, 0x1859aaac, 0x6c354a92, 0x6c354a92, 0x652d3eb, 0x652d3eb, 0xffcf0fd8, 0xffcf0fd8, 0xd3c9187c, 0xd3c9187c, 0xdee59346, 0xdee59346, 0x950f6354, 0x950f6354, 0xa2f7e36a, 0xa2f7e36a, 0x3967359a, 0x3967359a, 0x12738c9a, 0x12738c9a, 0xffb94ca3, 0xffb94ca3, 0xd9384791, 0xd9384791, 0xade1fd25, 0xade1fd25, 0xca109ebe, 0xca109ebe, 0x6e794e, 0x20d769cf, 0x29cc1fdc, 0x29cc1fdc, }, 45 }, - { "cmdline_cat", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x6cfe9089, 0x6cfe9089, 0xbe85dea2, 0xbe85dea2, 0x5f57923d, 0x5f57923d, 0xd28ad04b, 0xd28ad04b, 0x9ac91b28, 0x9ac91b28, 0x26977f54, 0x26977f54, 0x56cfda54, 0x56cfda54, 0xae54550f, 0xae54550f, 0x5843182b, 0x5843182b, 0xa1524272, 0xa1524272, 0x86b707db, 0x86b707db, 0x4127540e, 0x4127540e, 0xe89ea08e, 0xe89ea08e, 0x85f4dccc, 0x85f4dccc, 0xf910d16c, 0xf910d16c, 0xd43ff6b8, 0xd43ff6b8, 0xcdec4fd0, 0xcdec4fd0, 0xad650879, 0xad650879, 0x6d8e01c7, 0x6d8e01c7, 0x3ce7c69f, 0x3ce7c69f, 0xed54e2ef, 0x141319e, 0x9003a604, 0x9003a604, }, 45 }, - { "cmdline_cat", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x37f1b28e, 0x37f1b28e, 0x248de37a, 0x248de37a, 0x8b84bbe6, 0x8b84bbe6, 0x62efb943, 0x62efb943, 0x50d082fd, 0x50d082fd, 0x68a0c1, 0x68a0c1, 0xa335f8d0, 0xa335f8d0, 0xf26eaa27, 0xf26eaa27, 0x9f661fa2, 0x9f661fa2, 0x9a9c6bcb, 0x9a9c6bcb, 0xa5427057, 0xa5427057, 0x59aabcc8, 0x59aabcc8, 0xd1563970, 0xd1563970, 0x5f65ea2e, 0x5f65ea2e, 0xce189d5e, 0xce189d5e, 0xa0ac6e61, 0xa0ac6e61, 0xf85ec3, 0xf85ec3, 0xa6a5bea8, 0xa6a5bea8, 0xae55a1ba, 0xae55a1ba, 0x23f4e9e3, 0x23f4e9e3, 0x580abc5c, 0x58b54e7f, 0xafe85bbb, 0xafe85bbb, }, 45 }, - { "cmdline_cat", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x6d4812ec, 0x6d4812ec, 0x9d93973a, 0x9d93973a, 0x88cb4e17, 0x88cb4e17, 0x81f14f0a, 0x81f14f0a, 0x7f9f1875, 0x7f9f1875, 0x292f8345, 0x292f8345, 0x524cefe0, 0x524cefe0, 0x5d02251, 0x5d02251, 0x61afaf9e, 0x61afaf9e, 0xc327f8b9, 0xc327f8b9, 0xa1ece03d, 0xa1ece03d, 0xbb98b63c, 0xbb98b63c, 0x61b920db, 0x61b920db, 0xb1571b03, 0xb1571b03, 0xd315b012, 0xd315b012, 0xee77780c, 0xee77780c, 0x9b6ce52e, 0x9b6ce52e, 0x3b18a467, 0x3b18a467, 0x5ab91ffb, 0x5ab91ffb, 0x9255edea, 0x9255edea, 0x9ca85712, 0xa249a7fa, 0x213825f8, 0x213825f8, }, 45 }, - { "cmdline_cat", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x10bc4224, 0x10bc4224, 0xb8085994, 0xb8085994, 0x6ab26d0a, 0x6ab26d0a, 0xde71396c, 0xde71396c, 0x425a3956, 0x425a3956, 0xb7d2a7e3, 0xb7d2a7e3, 0x658ab388, 0x658ab388, 0x3fadf9dc, 0x3fadf9dc, 0xb29884ae, 0xb29884ae, 0x3a0830a7, 0x3a0830a7, 0xcf41267a, 0xcf41267a, 0x121c9703, 0x121c9703, 0xd126f87c, 0xd126f87c, 0x3b9d5bf6, 0x3b9d5bf6, 0x2a05cbef, 0x2a05cbef, 0x9ad41c2c, 0x9ad41c2c, 0xebf19db8, 0xebf19db8, 0x79f1b335, 0x79f1b335, 0xad2f9e8d, 0xad2f9e8d, 0x99596c48, 0x99596c48, 0x75b1cae6, 0x3cd081b2, 0x23e8ef2f, 0x23e8ef2f, }, 45 }, - { "cmdline_cat", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x8920d2ff, 0x8920d2ff, 0x369cb8d2, 0x369cb8d2, 0x880f23e4, 0x880f23e4, 0xf4a02ce2, 0xf4a02ce2, 0x7933f9a4, 0x7933f9a4, 0x488859f0, 0x488859f0, 0x75855108, 0x75855108, 0xf0463685, 0xf0463685, 0xf3e90b78, 0xf3e90b78, 0xac92b2b6, 0xac92b2b6, 0x63131cc5, 0x63131cc5, 0xfb714a00, 0xfb714a00, 0xc495c9a0, 0xc495c9a0, 0x314b6225, 0x314b6225, 0xc0d56232, 0xc0d56232, 0xa051d312, 0xa051d312, 0x9c0d295c, 0x9c0d295c, 0x3f234b5, 0x3f234b5, 0xa4201189, 0xa4201189, 0x23af1b2f, 0x23af1b2f, 0xc787ef0f, 0x2a3c46f8, 0xf03fe2d9, 0xf03fe2d9, }, 45 }, - { "gfxterm_menu", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0xdff707ef, 0xb938eb6c, 0xdff707ef, 0x9c01caa8, 0x59c36f00, 0x59c36f00, 0xd3548a15, 0xd3548a15, 0xd3548a15, 0xadd4e773, 0xadd4e773, 0xadd4e773, 0xcf22f2a1, 0xcf22f2a1, 0xcf22f2a1, 0x59c36f00, 0x9c01caa8, 0x9c01caa8, 0x59c36f00, }, 20 }, - { "gfxterm_menu", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x59f141e3, 0xfddbc65b, 0x59f141e3, 0x77f4c49c, 0xaa4593fe, 0xaa4593fe, 0x7d5e4ea7, 0x7d5e4ea7, 0x7d5e4ea7, 0xdbab43c0, 0xdbab43c0, 0xdbab43c0, 0xf693e8b8, 0xf693e8b8, 0xf693e8b8, 0xaa4593fe, 0x77f4c49c, 0x77f4c49c, 0xaa4593fe, }, 20 }, - { "gfxterm_menu", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x9ac56bc2, 0x2049341a, 0x9ac56bc2, 0xc7d20646, 0xc9cbf769, 0xc9cbf769, 0x7c3c68c, 0x7c3c68c, 0x7c3c68c, 0xf91b0740, 0xf91b0740, 0xf91b0740, 0x1051b848, 0x1051b848, 0x1051b848, 0xc9cbf769, 0xc7d20646, 0xc7d20646, 0xc9cbf769, }, 20 }, - { "gfxterm_menu", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0xd50b603, 0xbef0bf34, 0xd50b603, 0xa306ffdb, 0x9813a416, 0x9813a416, 0x60ef8d73, 0x60ef8d73, 0x60ef8d73, 0xf1340b40, 0xf1340b40, 0xf1340b40, 0xe88e3690, 0xe88e3690, 0xe88e3690, 0x9813a416, 0xa306ffdb, 0xa306ffdb, 0x9813a416, }, 20 }, - { "gfxterm_menu", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x9408bd4d, 0x84fea62c, 0x9408bd4d, 0xe2ae88fe, 0x5fcf013d, 0x5fcf013d, 0x6f5971e2, 0x6f5971e2, 0x6f5971e2, 0xbd496994, 0xbd496994, 0xbd496994, 0xab3a560b, 0xab3a560b, 0xab3a560b, 0x5fcf013d, 0xe2ae88fe, 0xe2ae88fe, 0x5fcf013d, }, 20 }, - { "gfxterm_menu", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x8460b76a, 0xd01813b4, 0x8460b76a, 0x9f656d6d, 0xdd28f52b, 0xdd28f52b, 0xda805056, 0xda805056, 0xda805056, 0xfbbca9b2, 0xfbbca9b2, 0xfbbca9b2, 0x8604623e, 0x8604623e, 0x8604623e, 0xdd28f52b, 0x9f656d6d, 0x9f656d6d, 0xdd28f52b, }, 20 }, - { "gfxterm_menu", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x115542af, 0xbac49512, 0x115542af, 0xeeea592f, 0x43d1f34, 0x43d1f34, 0x9a133a7f, 0x9a133a7f, 0x9a133a7f, 0xe51993d7, 0xe51993d7, 0xe51993d7, 0x7c489651, 0x7c489651, 0x7c489651, 0x43d1f34, 0xeeea592f, 0xeeea592f, 0x43d1f34, }, 20 }, - { "gfxmenu", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x60e56714, 0x14275a99, 0x60e56714, 0x35080c92, 0x9a2e0d26, 0x35f491f9, 0x35f491f9, 0x35f491f9, 0x692c6739, 0x692c6739, 0x692c6739, 0x40b4a9ab, 0x40b4a9ab, 0x40b4a9ab, 0x59c36f00, 0x35080c92, 0x35080c92, }, 18 }, - { "gfxmenu", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x33d94a8c, 0x7b789e53, 0x33d94a8c, 0xe8b9b6bf, 0xa9d58ccd, 0xeee84c5, 0xeee84c5, 0xeee84c5, 0x5bb12ecf, 0x5bb12ecf, 0x5bb12ecf, 0x3282e686, 0x3282e686, 0x3282e686, 0xaa4593fe, 0xe8b9b6bf, 0xe8b9b6bf, }, 18 }, - { "gfxmenu", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xe4669404, 0x9afa8e99, 0xe4669404, 0xdd25167e, 0x5411be8b, 0x2cf5262a, 0x2cf5262a, 0x2cf5262a, 0x534b80be, 0x534b80be, 0x534b80be, 0x113fe0c6, 0x113fe0c6, 0x113fe0c6, 0xc9cbf769, 0xdd25167e, 0xdd25167e, }, 18 }, - { "gfxmenu", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x1c3742c9, 0x37ed1568, 0x12f55eef, 0x37ed1568, 0x8aa8ad16, 0x740d78cf, 0x7bd2e3a3, 0x7bd2e3a3, 0x7bd2e3a3, 0x907709df, 0x907709df, 0x907709df, 0x963c092f, 0x963c092f, 0x963c092f, 0x1c3742c9, 0x8aa8ad16, 0x8aa8ad16, }, 18 }, - { "gfxmenu", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0xcc5a7bed, 0xc5315ac9, 0x7dece9d3, 0xc5315ac9, 0xc84ef08b, 0xbcda144c, 0xd45c93dc, 0xd45c93dc, 0xd45c93dc, 0xbb154fcd, 0xbb154fcd, 0xbb154fcd, 0xb6e3d1ce, 0xb6e3d1ce, 0xb6e3d1ce, 0xcc5a7bed, 0xc84ef08b, 0xc84ef08b, }, 18 }, - { "gfxmenu", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xef4a3312, 0x40a72ecd, 0x2304571f, 0x40a72ecd, 0xd2de6d81, 0x5d55a141, 0x304db662, 0x304db662, 0x304db662, 0xf6fff27c, 0xf6fff27c, 0xf6fff27c, 0xe29a22c3, 0xe29a22c3, 0xe29a22c3, 0xef4a3312, 0xd2de6d81, 0xd2de6d81, }, 18 }, - { "gfxmenu", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x54e48d80, 0xe6143ead, 0x19816f75, 0xe6143ead, 0xe2db78c2, 0xa992f629, 0xe0ddd143, 0xe0ddd143, 0xe0ddd143, 0x612e2792, 0x612e2792, 0x612e2792, 0xf78a9efd, 0xf78a9efd, 0xf78a9efd, 0x54e48d80, 0xe2db78c2, 0xe2db78c2, }, 18 }, - { "gfxterm_ar", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x3d69d4f7, 0x5b2df52e, 0x3d69d4f7, 0x7e9f19b0, 0x59c36f00, 0x59c36f00, 0xaa418d14, 0xaa418d14, 0xaa418d14, 0xd4c1e072, 0xd4c1e072, 0xd4c1e072, 0xb637f5a0, 0xb637f5a0, 0xb637f5a0, 0x59c36f00, 0x7e9f19b0, 0x7e9f19b0, 0x59c36f00, }, 20 }, - { "gfxterm_ar", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0xea153935, 0xadda68ff, 0xea153935, 0xc410bc4a, 0xaa4593fe, 0xaa4593fe, 0x63090f39, 0x63090f39, 0x63090f39, 0xc5fc025e, 0xc5fc025e, 0xc5fc025e, 0xe8c4a926, 0xe8c4a926, 0xe8c4a926, 0xaa4593fe, 0xc410bc4a, 0xc410bc4a, 0xaa4593fe, }, 20 }, - { "gfxterm_ar", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xe677248f, 0x9a146b56, 0xe677248f, 0xbb60490b, 0xc9cbf769, 0xc9cbf769, 0xebd87b6a, 0xebd87b6a, 0xebd87b6a, 0x1500baa6, 0x1500baa6, 0x1500baa6, 0xfc4a05ae, 0xfc4a05ae, 0xfc4a05ae, 0xc9cbf769, 0xbb60490b, 0xbb60490b, 0xc9cbf769, }, 20 }, - { "gfxterm_ar", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x2fe1d8b3, 0x344dc22f, 0x2fe1d8b3, 0x81b7916b, 0x9813a416, 0x9813a416, 0xb42009b, 0xb42009b, 0xb42009b, 0x9a9986a8, 0x9a9986a8, 0x9a9986a8, 0x8323bb78, 0x8323bb78, 0x8323bb78, 0x9813a416, 0x81b7916b, 0x81b7916b, 0x9813a416, }, 20 }, - { "gfxterm_ar", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x2f2ab760, 0x373afa93, 0x2f2ab760, 0x598c82d3, 0x5fcf013d, 0x5fcf013d, 0x8a9a15e2, 0x8a9a15e2, 0x8a9a15e2, 0x588a0d94, 0x588a0d94, 0x588a0d94, 0x4ef9320b, 0x4ef9320b, 0x4ef9320b, 0x5fcf013d, 0x598c82d3, 0x598c82d3, 0x5fcf013d, }, 20 }, - { "gfxterm_ar", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xb9de66a8, 0x2b705981, 0xb9de66a8, 0xa2dbbcaf, 0xdd28f52b, 0xdd28f52b, 0x971eb98b, 0x971eb98b, 0x971eb98b, 0xb622406f, 0xb622406f, 0xb622406f, 0xcb9a8be3, 0xcb9a8be3, 0xcb9a8be3, 0xdd28f52b, 0xa2dbbcaf, 0xa2dbbcaf, 0xdd28f52b, }, 20 }, - { "gfxterm_ar", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x84029f68, 0x7385ec77, 0x84029f68, 0x7bbd84e8, 0x43d1f34, 0x43d1f34, 0x73cb201f, 0x73cb201f, 0x73cb201f, 0xcc189b7, 0xcc189b7, 0xcc189b7, 0x95908c31, 0x95908c31, 0x95908c31, 0x43d1f34, 0x7bbd84e8, 0x7bbd84e8, 0x43d1f34, }, 20 }, - { "gfxterm_cyr", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0xb2446469, 0xca75968f, 0xb2446469, 0xf1b2a92e, 0x59c36f00, 0x59c36f00, 0xc0eac671, 0xc0eac671, 0xc0eac671, 0xbe6aab17, 0xbe6aab17, 0xbe6aab17, 0xdc9cbec5, 0xdc9cbec5, 0xdc9cbec5, 0x59c36f00, 0xf1b2a92e, 0xf1b2a92e, 0x59c36f00, }, 20 }, - { "gfxterm_cyr", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0xe219612c, 0x41ad1120, 0xe219612c, 0xcc1ce453, 0xaa4593fe, 0xaa4593fe, 0x1f05167, 0x1f05167, 0x1f05167, 0xa7055c00, 0xa7055c00, 0xa7055c00, 0x8a3df778, 0x8a3df778, 0x8a3df778, 0xaa4593fe, 0xcc1ce453, 0xcc1ce453, 0xaa4593fe, }, 20 }, - { "gfxterm_cyr", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x9f3ca4a3, 0x3df9621e, 0x9f3ca4a3, 0xc22bc927, 0xc9cbf769, 0xc9cbf769, 0x8f0b71ba, 0x8f0b71ba, 0x8f0b71ba, 0x71d3b076, 0x71d3b076, 0x71d3b076, 0x98990f7e, 0x98990f7e, 0x98990f7e, 0xc9cbf769, 0xc22bc927, 0xc22bc927, 0xc9cbf769, }, 20 }, - { "gfxterm_cyr", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x6b1e7755, 0x4532973e, 0x6b1e7755, 0xc5483e8d, 0x9813a416, 0x9813a416, 0xa279dbc8, 0xa279dbc8, 0xa279dbc8, 0x33a25dfb, 0x33a25dfb, 0x33a25dfb, 0x2a18602b, 0x2a18602b, 0x2a18602b, 0x9813a416, 0xc5483e8d, 0xc5483e8d, 0x9813a416, }, 20 }, - { "gfxterm_cyr", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0xa3774c63, 0x38dffb0e, 0xa3774c63, 0xd5d179d0, 0x5fcf013d, 0x5fcf013d, 0x28872666, 0x28872666, 0x28872666, 0xfa973e10, 0xfa973e10, 0xfa973e10, 0xece4018f, 0xece4018f, 0xece4018f, 0x5fcf013d, 0xd5d179d0, 0xd5d179d0, 0x5fcf013d, }, 20 }, - { "gfxterm_cyr", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xe9556aa5, 0x77425030, 0xe9556aa5, 0xf250b0a2, 0xdd28f52b, 0xdd28f52b, 0x938cfa6a, 0x938cfa6a, 0x938cfa6a, 0xb2b0038e, 0xb2b0038e, 0xb2b0038e, 0xcf08c802, 0xcf08c802, 0xcf08c802, 0xdd28f52b, 0xf250b0a2, 0xf250b0a2, 0xdd28f52b, }, 20 }, - { "gfxterm_cyr", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x9adc43d0, 0xd8ac5204, 0x9adc43d0, 0x65635850, 0x43d1f34, 0x43d1f34, 0xc182db12, 0xc182db12, 0xc182db12, 0xbe8872ba, 0xbe8872ba, 0xbe8872ba, 0x27d9773c, 0x27d9773c, 0x27d9773c, 0x43d1f34, 0x65635850, 0x65635850, 0x43d1f34, }, 20 }, - { "gfxterm_heb", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x7fd0187d, 0x7d05975c, 0x7fd0187d, 0x3c26d53a, 0x59c36f00, 0x59c36f00, 0xb4fad8de, 0xb4fad8de, 0xb4fad8de, 0xca7ab5b8, 0xca7ab5b8, 0xca7ab5b8, 0xa88ca06a, 0xa88ca06a, 0xa88ca06a, 0x59c36f00, 0x3c26d53a, 0x3c26d53a, 0x59c36f00, }, 20 }, - { "gfxterm_heb", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x54f3fad9, 0xe7a5a67a, 0x54f3fad9, 0x7af67fa6, 0xaa4593fe, 0xaa4593fe, 0xcae58c6a, 0xcae58c6a, 0xcae58c6a, 0x6c10810d, 0x6c10810d, 0x6c10810d, 0x41282a75, 0x41282a75, 0x41282a75, 0xaa4593fe, 0x7af67fa6, 0x7af67fa6, 0xaa4593fe, }, 20 }, - { "gfxterm_heb", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x869916b8, 0x373dbcc3, 0x869916b8, 0xdb8e7b3c, 0xc9cbf769, 0xc9cbf769, 0xaa0c75c1, 0xaa0c75c1, 0xaa0c75c1, 0x54d4b40d, 0x54d4b40d, 0x54d4b40d, 0xbd9e0b05, 0xbd9e0b05, 0xbd9e0b05, 0xc9cbf769, 0xdb8e7b3c, 0xdb8e7b3c, 0xc9cbf769, }, 20 }, - { "gfxterm_heb", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0xb2f32f4, 0xff8e66df, 0xb2f32f4, 0xa5797b2c, 0x9813a416, 0x9813a416, 0x9fc65347, 0x9fc65347, 0x9fc65347, 0xe1dd574, 0xe1dd574, 0xe1dd574, 0x17a7e8a4, 0x17a7e8a4, 0x17a7e8a4, 0x9813a416, 0xa5797b2c, 0xa5797b2c, 0x9813a416, }, 20 }, - { "gfxterm_heb", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x26280874, 0x6f7dd72, 0x26280874, 0x508e3dc7, 0x5fcf013d, 0x5fcf013d, 0x197943fe, 0x197943fe, 0x197943fe, 0xcb695b88, 0xcb695b88, 0xcb695b88, 0xdd1a6417, 0xdd1a6417, 0xdd1a6417, 0x5fcf013d, 0x508e3dc7, 0x508e3dc7, 0x5fcf013d, }, 20 }, - { "gfxterm_heb", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xd23ae631, 0xe5a30d5e, 0xd23ae631, 0xc93f3c36, 0xdd28f52b, 0xdd28f52b, 0x7042f8c, 0x7042f8c, 0x7042f8c, 0x2638d668, 0x2638d668, 0x2638d668, 0x5b801de4, 0x5b801de4, 0x5b801de4, 0xdd28f52b, 0xc93f3c36, 0xc93f3c36, 0xdd28f52b, }, 20 }, - { "gfxterm_heb", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x8d469c0b, 0xabeb5779, 0x8d469c0b, 0x72f9878b, 0x43d1f34, 0x43d1f34, 0xd8397828, 0xd8397828, 0xd8397828, 0xa733d180, 0xa733d180, 0xa733d180, 0x3e62d406, 0x3e62d406, 0x3e62d406, 0x43d1f34, 0x72f9878b, 0x72f9878b, 0x43d1f34, }, 20 }, - { "gfxterm_gre", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0xd668f275, 0x6a2de04f, 0xd668f275, 0x959e3f32, 0x59c36f00, 0x59c36f00, 0xc43520a0, 0xc43520a0, 0xc43520a0, 0xbab54dc6, 0xbab54dc6, 0xbab54dc6, 0xd8435814, 0xd8435814, 0xd8435814, 0x59c36f00, 0x959e3f32, 0x959e3f32, 0x59c36f00, }, 20 }, - { "gfxterm_gre", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0xe170ffb5, 0x17402498, 0xe170ffb5, 0xcf757aca, 0xaa4593fe, 0xaa4593fe, 0x4ec32c62, 0x4ec32c62, 0x4ec32c62, 0xe8362105, 0xe8362105, 0xe8362105, 0xc50e8a7d, 0xc50e8a7d, 0xc50e8a7d, 0xaa4593fe, 0xcf757aca, 0xcf757aca, 0xaa4593fe, }, 20 }, - { "gfxterm_gre", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xf4aef2d6, 0x47a46008, 0xf4aef2d6, 0xa9b99f52, 0xc9cbf769, 0xc9cbf769, 0x4f1a5666, 0x4f1a5666, 0x4f1a5666, 0xb1c297aa, 0xb1c297aa, 0xb1c297aa, 0x588828a2, 0x588828a2, 0x588828a2, 0xc9cbf769, 0xa9b99f52, 0xa9b99f52, 0xc9cbf769, }, 20 }, - { "gfxterm_gre", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0xc2ed8f74, 0xb7ab0607, 0xc2ed8f74, 0x6cbbc6ac, 0x9813a416, 0x9813a416, 0x535e7ba8, 0x535e7ba8, 0x535e7ba8, 0xc285fd9b, 0xc285fd9b, 0xc285fd9b, 0xdb3fc04b, 0xdb3fc04b, 0xdb3fc04b, 0x9813a416, 0x6cbbc6ac, 0x6cbbc6ac, 0x9813a416, }, 20 }, - { "gfxterm_gre", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0xf62383d8, 0x9489f90c, 0xf62383d8, 0x8085b66b, 0x5fcf013d, 0x5fcf013d, 0xb7f78bc2, 0xb7f78bc2, 0xb7f78bc2, 0x65e793b4, 0x65e793b4, 0x65e793b4, 0x7394ac2b, 0x7394ac2b, 0x7394ac2b, 0x5fcf013d, 0x8085b66b, 0x8085b66b, 0x5fcf013d, }, 20 }, - { "gfxterm_gre", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x753d8bc0, 0x5c9029d6, 0x753d8bc0, 0x6e3851c7, 0xdd28f52b, 0xdd28f52b, 0x1a40e22e, 0x1a40e22e, 0x1a40e22e, 0x3b7c1bca, 0x3b7c1bca, 0x3b7c1bca, 0x46c4d046, 0x46c4d046, 0x46c4d046, 0xdd28f52b, 0x6e3851c7, 0x6e3851c7, 0xdd28f52b, }, 20 }, - { "gfxterm_gre", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x62a774, 0xbb4b794c, 0x62a774, 0xffddbcf4, 0x43d1f34, 0x43d1f34, 0x83fede87, 0x83fede87, 0x83fede87, 0xfcf4772f, 0xfcf4772f, 0xfcf4772f, 0x65a572a9, 0x65a572a9, 0x65a572a9, 0x43d1f34, 0xffddbcf4, 0xffddbcf4, 0x43d1f34, }, 20 }, - { "gfxterm_ru", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x2edc6dc9, 0x166a6552, 0x2edc6dc9, 0x6d2aa08e, 0x59c36f00, 0x59c36f00, 0xd214e1a2, 0xd214e1a2, 0xd214e1a2, 0xac948cc4, 0xac948cc4, 0xac948cc4, 0xce629916, 0xce629916, 0xce629916, 0x59c36f00, 0x6d2aa08e, 0x6d2aa08e, 0x59c36f00, }, 20 }, - { "gfxterm_ru", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0xc12e1a21, 0x1e6e7468, 0xc12e1a21, 0xef2b9f5e, 0xaa4593fe, 0xaa4593fe, 0x1c792d02, 0x1c792d02, 0x1c792d02, 0xba8c2065, 0xba8c2065, 0xba8c2065, 0x97b48b1d, 0x97b48b1d, 0x97b48b1d, 0xaa4593fe, 0xef2b9f5e, 0xef2b9f5e, 0xaa4593fe, }, 20 }, - { "gfxterm_ru", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x510524f7, 0x7f9806b4, 0x510524f7, 0xc124973, 0xc9cbf769, 0xc9cbf769, 0x1a561d55, 0x1a561d55, 0x1a561d55, 0xe48edc99, 0xe48edc99, 0xe48edc99, 0xdc46391, 0xdc46391, 0xdc46391, 0xc9cbf769, 0xc124973, 0xc124973, 0xc9cbf769, }, 20 }, - { "gfxterm_ru", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0xa1ee6604, 0xd307a4d9, 0xa1ee6604, 0xfb82fdc, 0x9813a416, 0x9813a416, 0x5b7ed439, 0x5b7ed439, 0x5b7ed439, 0xcaa5520a, 0xcaa5520a, 0xcaa5520a, 0xd31f6fda, 0xd31f6fda, 0xd31f6fda, 0x9813a416, 0xfb82fdc, 0xfb82fdc, 0x9813a416, }, 20 }, - { "gfxterm_ru", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x4e2bb6a8, 0x67c92bf4, 0x4e2bb6a8, 0x388d831b, 0x5fcf013d, 0x5fcf013d, 0xe69beaed, 0xe69beaed, 0xe69beaed, 0x348bf29b, 0x348bf29b, 0x348bf29b, 0x22f8cd04, 0x22f8cd04, 0x22f8cd04, 0x5fcf013d, 0x388d831b, 0x388d831b, 0x5fcf013d, }, 20 }, - { "gfxterm_ru", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xeb6b461d, 0x679ed094, 0xeb6b461d, 0xf06e9c1a, 0xdd28f52b, 0xdd28f52b, 0xdf34624d, 0xdf34624d, 0xdf34624d, 0xfe089ba9, 0xfe089ba9, 0xfe089ba9, 0x83b05025, 0x83b05025, 0x83b05025, 0xdd28f52b, 0xf06e9c1a, 0xf06e9c1a, 0xdd28f52b, }, 20 }, - { "gfxterm_ru", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0xc486143c, 0x7b487645, 0xc486143c, 0x3b390fbc, 0x43d1f34, 0x43d1f34, 0x9576cd6b, 0x9576cd6b, 0x9576cd6b, 0xea7c64c3, 0xea7c64c3, 0xea7c64c3, 0x732d6145, 0x732d6145, 0x732d6145, 0x43d1f34, 0x3b390fbc, 0x3b390fbc, 0x43d1f34, }, 20 }, - { "gfxterm_fr", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0xa024d435, 0x8bc3f107, 0xa024d435, 0xe3d21972, 0x59c36f00, 0x59c36f00, 0x9412860d, 0x9412860d, 0x9412860d, 0xea92eb6b, 0xea92eb6b, 0xea92eb6b, 0x8864feb9, 0x8864feb9, 0x8864feb9, 0x59c36f00, 0xe3d21972, 0xe3d21972, 0x59c36f00, }, 20 }, - { "gfxterm_fr", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0xbf89b975, 0x481e2ecc, 0xbf89b975, 0x918c3c0a, 0xaa4593fe, 0xaa4593fe, 0xa8509e2c, 0xa8509e2c, 0xa8509e2c, 0xea5934b, 0xea5934b, 0xea5934b, 0x239d3833, 0x239d3833, 0x239d3833, 0xaa4593fe, 0x918c3c0a, 0x918c3c0a, 0xaa4593fe, }, 20 }, - { "gfxterm_fr", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x4d84ea04, 0xd1029f5b, 0x4d84ea04, 0x10938780, 0xc9cbf769, 0xc9cbf769, 0x3677fab0, 0x3677fab0, 0x3677fab0, 0xc8af3b7c, 0xc8af3b7c, 0xc8af3b7c, 0x21e58474, 0x21e58474, 0x21e58474, 0xc9cbf769, 0x10938780, 0x10938780, 0xc9cbf769, }, 20 }, - { "gfxterm_fr", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x9e5f6ab3, 0xda3fae82, 0x9e5f6ab3, 0x3009236b, 0x9813a416, 0x9813a416, 0x5710fb5f, 0x5710fb5f, 0x5710fb5f, 0xc6cb7d6c, 0xc6cb7d6c, 0xc6cb7d6c, 0xdf7140bc, 0xdf7140bc, 0xdf7140bc, 0x9813a416, 0x3009236b, 0x3009236b, 0x9813a416, }, 20 }, - { "gfxterm_fr", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x28f46625, 0xf4bfdc80, 0x28f46625, 0x5e525396, 0x5fcf013d, 0x5fcf013d, 0xb3f9b24b, 0xb3f9b24b, 0xb3f9b24b, 0x61e9aa3d, 0x61e9aa3d, 0x61e9aa3d, 0x779a95a2, 0x779a95a2, 0x779a95a2, 0x5fcf013d, 0x5e525396, 0x5e525396, 0x5fcf013d, }, 20 }, - { "gfxterm_fr", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x8c12e300, 0xa71b83e7, 0x8c12e300, 0x97173907, 0xdd28f52b, 0xdd28f52b, 0x2f660f28, 0x2f660f28, 0x2f660f28, 0xe5af6cc, 0xe5af6cc, 0xe5af6cc, 0x73e23d40, 0x73e23d40, 0x73e23d40, 0xdd28f52b, 0x97173907, 0x97173907, 0xdd28f52b, }, 20 }, - { "gfxterm_fr", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0xbaaaeec4, 0x7f7cd53b, 0xbaaaeec4, 0x4515f544, 0x43d1f34, 0x43d1f34, 0xd254254f, 0xd254254f, 0xd254254f, 0xad5e8ce7, 0xad5e8ce7, 0xad5e8ce7, 0x340f8961, 0x340f8961, 0x340f8961, 0x43d1f34, 0x4515f544, 0x4515f544, 0x43d1f34, }, 20 }, - { "gfxterm_quot", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x63166340, 0x5d98fc3, 0x63166340, 0x20e0ae07, 0x59c36f00, 0x59c36f00, 0xd3548a15, 0xd3548a15, 0xd3548a15, 0xadd4e773, 0xadd4e773, 0xadd4e773, 0xcf22f2a1, 0xcf22f2a1, 0xcf22f2a1, 0x59c36f00, 0x20e0ae07, 0x20e0ae07, 0x59c36f00, }, 20 }, - { "gfxterm_quot", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0xe0916467, 0x44bbe3df, 0xe0916467, 0xce94e118, 0xaa4593fe, 0xaa4593fe, 0x7d5e4ea7, 0x7d5e4ea7, 0x7d5e4ea7, 0xdbab43c0, 0xdbab43c0, 0xdbab43c0, 0xf693e8b8, 0xf693e8b8, 0xf693e8b8, 0xaa4593fe, 0xce94e118, 0xce94e118, 0xaa4593fe, }, 20 }, - { "gfxterm_quot", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x1aad9b94, 0xa021c44c, 0x1aad9b94, 0x47baf610, 0xc9cbf769, 0xc9cbf769, 0x7c3c68c, 0x7c3c68c, 0x7c3c68c, 0xf91b0740, 0xf91b0740, 0xf91b0740, 0x1051b848, 0x1051b848, 0x1051b848, 0xc9cbf769, 0x47baf610, 0x47baf610, 0xc9cbf769, }, 20 }, - { "gfxterm_quot", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0xb8710521, 0xbd10c16, 0xb8710521, 0x16274cf9, 0x9813a416, 0x9813a416, 0x60ef8d73, 0x60ef8d73, 0x60ef8d73, 0xf1340b40, 0xf1340b40, 0xf1340b40, 0xe88e3690, 0xe88e3690, 0xe88e3690, 0x9813a416, 0x16274cf9, 0x16274cf9, 0x9813a416, }, 20 }, - { "gfxterm_quot", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0xd62b53b5, 0xc6dd48d4, 0xd62b53b5, 0xa08d6606, 0x5fcf013d, 0x5fcf013d, 0x6f5971e2, 0x6f5971e2, 0x6f5971e2, 0xbd496994, 0xbd496994, 0xbd496994, 0xab3a560b, 0xab3a560b, 0xab3a560b, 0x5fcf013d, 0xa08d6606, 0xa08d6606, 0x5fcf013d, }, 20 }, - { "gfxterm_quot", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x10503615, 0x442892cb, 0x10503615, 0xb55ec12, 0xdd28f52b, 0xdd28f52b, 0xda805056, 0xda805056, 0xda805056, 0xfbbca9b2, 0xfbbca9b2, 0xfbbca9b2, 0x8604623e, 0x8604623e, 0x8604623e, 0xdd28f52b, 0xb55ec12, 0xb55ec12, 0xdd28f52b, }, 20 }, - { "gfxterm_quot", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x5c9d00a2, 0xf70cd71f, 0x5c9d00a2, 0xa3221b22, 0x43d1f34, 0x43d1f34, 0x9a133a7f, 0x9a133a7f, 0x9a133a7f, 0xe51993d7, 0xe51993d7, 0xe51993d7, 0x7c489651, 0x7c489651, 0x7c489651, 0x43d1f34, 0xa3221b22, 0xa3221b22, 0x43d1f34, }, 20 }, - { "gfxterm_piglatin", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0xbc89067b, 0xf339b29f, 0xbc89067b, 0xff7fcb3c, 0x59c36f00, 0x59c36f00, 0x5915b839, 0x5915b839, 0x5915b839, 0x2795d55f, 0x2795d55f, 0x2795d55f, 0x4563c08d, 0x4563c08d, 0x4563c08d, 0x59c36f00, 0xff7fcb3c, 0xff7fcb3c, 0x59c36f00, }, 20 }, - { "gfxterm_piglatin", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0xb19b98f6, 0xb8ffac95, 0xb19b98f6, 0x9f9e1d89, 0xaa4593fe, 0xaa4593fe, 0x6cb5454, 0x6cb5454, 0x6cb5454, 0xa03e5933, 0xa03e5933, 0xa03e5933, 0x8d06f24b, 0x8d06f24b, 0x8d06f24b, 0xaa4593fe, 0x9f9e1d89, 0x9f9e1d89, 0xaa4593fe, }, 20 }, - { "gfxterm_piglatin", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x133d7c3b, 0xd26c8a26, 0x133d7c3b, 0x4e2a11bf, 0xc9cbf769, 0xc9cbf769, 0x36504e54, 0x36504e54, 0x36504e54, 0xc8888f98, 0xc8888f98, 0xc8888f98, 0x21c23090, 0x21c23090, 0x21c23090, 0xc9cbf769, 0x4e2a11bf, 0x4e2a11bf, 0xc9cbf769, }, 20 }, - { "gfxterm_piglatin", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0xbfc94fbe, 0xe32be512, 0xbfc94fbe, 0x119f0666, 0x9813a416, 0x9813a416, 0x8350694d, 0x8350694d, 0x8350694d, 0x128bef7e, 0x128bef7e, 0x128bef7e, 0xb31d2ae, 0xb31d2ae, 0xb31d2ae, 0x9813a416, 0x119f0666, 0x119f0666, 0x9813a416, }, 20 }, - { "gfxterm_piglatin", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x9cf25061, 0xe5e2b458, 0x9cf25061, 0xea5465d2, 0x5fcf013d, 0x5fcf013d, 0xa5bfba08, 0xa5bfba08, 0xa5bfba08, 0x77afa27e, 0x77afa27e, 0x77afa27e, 0x61dc9de1, 0x61dc9de1, 0x61dc9de1, 0x5fcf013d, 0xea5465d2, 0xea5465d2, 0x5fcf013d, }, 20 }, - { "gfxterm_piglatin", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xc968ecc5, 0xa3105cfb, 0xc968ecc5, 0xd26d36c2, 0xdd28f52b, 0xdd28f52b, 0xff2fd4b8, 0xff2fd4b8, 0xff2fd4b8, 0xde132d5c, 0xde132d5c, 0xde132d5c, 0xa3abe6d0, 0xa3abe6d0, 0xa3abe6d0, 0xdd28f52b, 0xd26d36c2, 0xd26d36c2, 0xdd28f52b, }, 20 }, - { "gfxterm_piglatin", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0xf17f3c, 0xf3672115, 0xf17f3c, 0xff4e64bc, 0x43d1f34, 0x43d1f34, 0x6ec799ab, 0x6ec799ab, 0x6ec799ab, 0x11cd3003, 0x11cd3003, 0x11cd3003, 0x889c3585, 0x889c3585, 0x889c3585, 0x43d1f34, 0xff4e64bc, 0xff4e64bc, 0x43d1f34, }, 20 }, - { "gfxterm_ch", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x20f2a62b, 0x12808b5f, 0x20f2a62b, 0x63046b6c, 0x59c36f00, 0x59c36f00, 0x23e6cac6, 0x23e6cac6, 0x23e6cac6, 0x5d66a7a0, 0x5d66a7a0, 0x5d66a7a0, 0x3f90b272, 0x3f90b272, 0x3f90b272, 0x59c36f00, 0x63046b6c, 0x63046b6c, 0x59c36f00, }, 20 }, - { "gfxterm_ch", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x52fcbd8f, 0x7119870a, 0x52fcbd8f, 0x7cf938f0, 0xaa4593fe, 0xaa4593fe, 0x4bb9a19, 0x4bb9a19, 0x4bb9a19, 0xa24e977e, 0xa24e977e, 0xa24e977e, 0x8f763c06, 0x8f763c06, 0x8f763c06, 0xaa4593fe, 0x7cf938f0, 0x7cf938f0, 0xaa4593fe, }, 20 }, - { "gfxterm_ch", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xe4d74d3f, 0xd2dab4f0, 0xe4d74d3f, 0xb9c020bb, 0xc9cbf769, 0xc9cbf769, 0xa4955f92, 0xa4955f92, 0xa4955f92, 0x5a4d9e5e, 0x5a4d9e5e, 0x5a4d9e5e, 0xb3072156, 0xb3072156, 0xb3072156, 0xc9cbf769, 0xb9c020bb, 0xb9c020bb, 0xc9cbf769, }, 20 }, - { "gfxterm_ch", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0xa1c2b9ec, 0x34038c40, 0xa1c2b9ec, 0xf94f034, 0x9813a416, 0x9813a416, 0x438820a6, 0x438820a6, 0x438820a6, 0xd253a695, 0xd253a695, 0xd253a695, 0xcbe99b45, 0xcbe99b45, 0xcbe99b45, 0x9813a416, 0xf94f034, 0xf94f034, 0x9813a416, }, 20 }, - { "gfxterm_ch", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x339cc65f, 0xe46f6cec, 0x339cc65f, 0x453af3ec, 0x5fcf013d, 0x5fcf013d, 0xad75b235, 0xad75b235, 0xad75b235, 0x7f65aa43, 0x7f65aa43, 0x7f65aa43, 0x691695dc, 0x691695dc, 0x691695dc, 0x5fcf013d, 0x453af3ec, 0x453af3ec, 0x5fcf013d, }, 20 }, - { "gfxterm_ch", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x1c229a1a, 0x83752c05, 0x1c229a1a, 0x727401d, 0xdd28f52b, 0xdd28f52b, 0x4b4f5d0, 0x4b4f5d0, 0x4b4f5d0, 0x25880c34, 0x25880c34, 0x25880c34, 0x5830c7b8, 0x5830c7b8, 0x5830c7b8, 0xdd28f52b, 0x727401d, 0x727401d, 0xdd28f52b, }, 20 }, - { "gfxterm_ch", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x4d69e76c, 0x11e8d41f, 0x4d69e76c, 0xb2d6fcec, 0x43d1f34, 0x43d1f34, 0x15b4256, 0x15b4256, 0x15b4256, 0x7e51ebfe, 0x7e51ebfe, 0x7e51ebfe, 0xe700ee78, 0xe700ee78, 0xe700ee78, 0x43d1f34, 0xb2d6fcec, 0xb2d6fcec, 0x43d1f34, }, 20 }, - { "gfxterm_red", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0xecc0313, 0x6803ef90, 0xecc0313, 0x59e1bdcd, 0x59c36f00, 0x59c36f00, 0xbaf5c463, 0xbaf5c463, 0xbaf5c463, 0xc475a905, 0xc475a905, 0xc475a905, 0xa683bcd7, 0xa683bcd7, 0xa683bcd7, 0x59c36f00, 0x59e1bdcd, 0x59e1bdcd, 0x59c36f00, }, 20 }, - { "gfxterm_red", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0xfb839522, 0x5fa9129a, 0xfb839522, 0x4b244f74, 0xaa4593fe, 0xaa4593fe, 0xf644f45d, 0xf644f45d, 0xf644f45d, 0x50b1f93a, 0x50b1f93a, 0x50b1f93a, 0x7d895242, 0x7d895242, 0x7d895242, 0xaa4593fe, 0x4b244f74, 0x4b244f74, 0xaa4593fe, }, 20 }, - { "gfxterm_red", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xf84fee63, 0x42c3b1bb, 0xf84fee63, 0xe86af0cd, 0xc9cbf769, 0xc9cbf769, 0x93e5d13b, 0x93e5d13b, 0x93e5d13b, 0x6d3d10f7, 0x6d3d10f7, 0x6d3d10f7, 0x8477afff, 0x8477afff, 0x8477afff, 0xc9cbf769, 0xe86af0cd, 0xe86af0cd, 0xc9cbf769, }, 20 }, - { "gfxterm_red", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0xcbed2522, 0x784d2c15, 0xcbed2522, 0xfb9cd90d, 0x9813a416, 0x9813a416, 0x94668b23, 0x94668b23, 0x94668b23, 0x5bd0d10, 0x5bd0d10, 0x5bd0d10, 0x1c0730c0, 0x1c0730c0, 0x1c0730c0, 0x9813a416, 0xfb9cd90d, 0xfb9cd90d, 0x9813a416, }, 20 }, - { "gfxterm_red", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0xc1ca0a91, 0xd13c11f0, 0xc1ca0a91, 0x6fcde564, 0x5fcf013d, 0x5fcf013d, 0xb6cdf7a2, 0xb6cdf7a2, 0xb6cdf7a2, 0x64ddefd4, 0x64ddefd4, 0x64ddefd4, 0x72aed04b, 0x72aed04b, 0x72aed04b, 0x5fcf013d, 0x6fcde564, 0x6fcde564, 0x5fcf013d, }, 20 }, - { "gfxterm_red", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xca477228, 0x9e3fd6f6, 0xca477228, 0x4423b9f2, 0xdd28f52b, 0xdd28f52b, 0x1ff53543, 0x1ff53543, 0x1ff53543, 0x3ec9cca7, 0x3ec9cca7, 0x3ec9cca7, 0x4371072b, 0x4371072b, 0x4371072b, 0xdd28f52b, 0x4423b9f2, 0x4423b9f2, 0xdd28f52b, }, 20 }, - { "gfxterm_red", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0xfe345ca6, 0x55a58b1b, 0xfe345ca6, 0x696cda06, 0x43d1f34, 0x43d1f34, 0x72d541bf, 0x72d541bf, 0x72d541bf, 0xddfe817, 0xddfe817, 0xddfe817, 0x948eed91, 0x948eed91, 0x948eed91, 0x43d1f34, 0x696cda06, 0x696cda06, 0x43d1f34, }, 20 }, - { "gfxterm_high", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x4cfdf9ab, 0x2a321528, 0x4cfdf9ab, 0xf4b75661, 0x59c36f00, 0x59c36f00, 0xd3548a15, 0xd3548a15, 0xd3548a15, 0xadd4e773, 0xadd4e773, 0xadd4e773, 0xcf22f2a1, 0xcf22f2a1, 0xcf22f2a1, 0x59c36f00, 0xf4b75661, 0xf4b75661, 0x59c36f00, }, 20 }, - { "gfxterm_high", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x287ff948, 0x8c557ef0, 0x287ff948, 0xebf931c7, 0xaa4593fe, 0xaa4593fe, 0x7d5e4ea7, 0x7d5e4ea7, 0x7d5e4ea7, 0xdbab43c0, 0xdbab43c0, 0xdbab43c0, 0xf693e8b8, 0xf693e8b8, 0xf693e8b8, 0xaa4593fe, 0xebf931c7, 0xebf931c7, 0xaa4593fe, }, 20 }, - { "gfxterm_high", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x5ecea36b, 0xe442fcb3, 0x5ecea36b, 0x1cab5f56, 0xc9cbf769, 0xc9cbf769, 0x7c3c68c, 0x7c3c68c, 0x7c3c68c, 0xf91b0740, 0xf91b0740, 0xf91b0740, 0x1051b848, 0x1051b848, 0x1051b848, 0xc9cbf769, 0x1cab5f56, 0x1cab5f56, 0xc9cbf769, }, 20 }, - { "gfxterm_high", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0xf6c7d73a, 0x4567de0d, 0xf6c7d73a, 0xb8d47573, 0x9813a416, 0x9813a416, 0x60ef8d73, 0x60ef8d73, 0x60ef8d73, 0xf1340b40, 0xf1340b40, 0xf1340b40, 0xe88e3690, 0xe88e3690, 0xe88e3690, 0x9813a416, 0xb8d47573, 0xb8d47573, 0x9813a416, }, 20 }, - { "gfxterm_high", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x56e3bddb, 0x4615a6ba, 0x56e3bddb, 0xc585b2ec, 0x5fcf013d, 0x5fcf013d, 0x6f5971e2, 0x6f5971e2, 0x6f5971e2, 0xbd496994, 0xbd496994, 0xbd496994, 0xab3a560b, 0xab3a560b, 0xab3a560b, 0x5fcf013d, 0xc585b2ec, 0xc585b2ec, 0x5fcf013d, }, 20 }, - { "gfxterm_high", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x5ebfa46, 0x51935e98, 0x5ebfa46, 0xe26d3e18, 0xdd28f52b, 0xdd28f52b, 0xda805056, 0xda805056, 0xda805056, 0xfbbca9b2, 0xfbbca9b2, 0xfbbca9b2, 0x8604623e, 0x8604623e, 0x8604623e, 0xdd28f52b, 0xe26d3e18, 0xe26d3e18, 0xdd28f52b, }, 20 }, - { "gfxterm_high", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x4995beac, 0xe2046911, 0x4995beac, 0x311de003, 0x43d1f34, 0x43d1f34, 0x9a133a7f, 0x9a133a7f, 0x9a133a7f, 0xe51993d7, 0xe51993d7, 0xe51993d7, 0x7c489651, 0x7c489651, 0x7c489651, 0x43d1f34, 0x311de003, 0x311de003, 0x43d1f34, }, 20 }, + { "cmdline_cat", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x24285504, 0x24285504, 0x3cc7ae1, 0x3cc7ae1, 0x20e2971b, 0x20e2971b, 0xc295b4fc, 0xc295b4fc, 0x1fbe0d4, 0x1fbe0d4, 0x82930744, 0x82930744, 0xf4b66805, 0xf4b66805, 0x3e16a8c5, 0x3e16a8c5, 0x1165d7dc, 0x1165d7dc, 0xfa78cf7f, 0xfa78cf7f, 0xc105a544, 0xc105a544, 0x430cee22, 0x430cee22, 0xbcf938a0, 0xbcf938a0, 0x7b800045, 0x7b800045, 0x2cc85143, 0x2cc85143, 0x80e0a4b4, 0x80e0a4b4, 0x212e8415, 0x212e8415, 0x151d5163, 0x151d5163, 0x24dcfa9e, 0x24dcfa9e, 0xb1df21b2, 0xb1df21b2, 0x2990a5cf, 0x8c1740a5, 0xd29f2d17, 0xd29f2d17, }, 45 }, + { "cmdline_cat", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x2b224886, 0x2b224886, 0x4fa52ab9, 0x4fa52ab9, 0xad8716fa, 0xad8716fa, 0x97a64f1, 0x97a64f1, 0x5fa72700, 0x5fa72700, 0x41913bce, 0x41913bce, 0xe3e6af02, 0xe3e6af02, 0x978a4f3c, 0x978a4f3c, 0xfdedd645, 0xfdedd645, 0x4700a76, 0x4700a76, 0x28761dd2, 0x28761dd2, 0x255a96e8, 0x255a96e8, 0x6eb066fa, 0x6eb066fa, 0x5948e6c4, 0x5948e6c4, 0xc2d83034, 0xc2d83034, 0xe9cc8934, 0xe9cc8934, 0x406490d, 0x406490d, 0x2287423f, 0x2287423f, 0x565ef88b, 0x565ef88b, 0x31af9b10, 0x31af9b10, 0xfbd17ce0, 0xdb686c61, 0xd2731a72, 0xd2731a72, }, 45 }, + { "cmdline_cat", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x999febcd, 0x999febcd, 0x4be4a5e6, 0x4be4a5e6, 0xaa36e979, 0xaa36e979, 0x27ebab0f, 0x27ebab0f, 0x6fa8606c, 0x6fa8606c, 0xd3f60410, 0xd3f60410, 0xa3aea110, 0xa3aea110, 0x5b352e4b, 0x5b352e4b, 0xad22636f, 0xad22636f, 0x54333936, 0x54333936, 0x73d67c9f, 0x73d67c9f, 0xb4462f4a, 0xb4462f4a, 0x1dffdbca, 0x1dffdbca, 0x7095a788, 0x7095a788, 0xc71aa28, 0xc71aa28, 0x215e8dfc, 0x215e8dfc, 0x388d3494, 0x388d3494, 0x5804733d, 0x5804733d, 0x98ef7a83, 0x98ef7a83, 0xc986bddb, 0xc986bddb, 0x183599ab, 0xf4204ada, 0x6562dd40, 0x6562dd40, }, 45 }, + { "cmdline_cat", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0xea25e7f1, 0xea25e7f1, 0xf959b605, 0xf959b605, 0x5650ee99, 0x5650ee99, 0xbf3bec3c, 0xbf3bec3c, 0x8d04d782, 0x8d04d782, 0xddbcf5be, 0xddbcf5be, 0x7ee1adaf, 0x7ee1adaf, 0x2fbaff58, 0x2fbaff58, 0x42b24add, 0x42b24add, 0x47483eb4, 0x47483eb4, 0x78962528, 0x78962528, 0x847ee9b7, 0x847ee9b7, 0xc826c0f, 0xc826c0f, 0x82b1bf51, 0x82b1bf51, 0x13ccc821, 0x13ccc821, 0x7d783b1e, 0x7d783b1e, 0xdd2c0bbc, 0xdd2c0bbc, 0x7b71ebd7, 0x7b71ebd7, 0x7381f4c5, 0x7381f4c5, 0xfe20bc9c, 0xfe20bc9c, 0x85dee923, 0x85611b00, 0x723c0ec4, 0x723c0ec4, }, 45 }, + { "cmdline_cat", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0xbc52dc5f, 0xbc52dc5f, 0x4c895989, 0x4c895989, 0x59d180a4, 0x59d180a4, 0x50eb81b9, 0x50eb81b9, 0xae85d6c6, 0xae85d6c6, 0xf8354df6, 0xf8354df6, 0x83562153, 0x83562153, 0xd4caece2, 0xd4caece2, 0xb0b5612d, 0xb0b5612d, 0x123d360a, 0x123d360a, 0x70f62e8e, 0x70f62e8e, 0x6a82788f, 0x6a82788f, 0xb0a3ee68, 0xb0a3ee68, 0x604dd5b0, 0x604dd5b0, 0x20f7ea1, 0x20f7ea1, 0x3f6db6bf, 0x3f6db6bf, 0x4a762b9d, 0x4a762b9d, 0xea026ad4, 0xea026ad4, 0x8ba3d148, 0x8ba3d148, 0x434f2359, 0x434f2359, 0x4db299a1, 0x73536949, 0xf022eb4b, 0xf022eb4b, }, 45 }, + { "cmdline_cat", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x7cfd676, 0x7cfd676, 0xaf7bcdc6, 0xaf7bcdc6, 0x7dc1f958, 0x7dc1f958, 0xc902ad3e, 0xc902ad3e, 0x5529ad04, 0x5529ad04, 0xa0a133b1, 0xa0a133b1, 0x72f927da, 0x72f927da, 0x28de6d8e, 0x28de6d8e, 0xa5eb10fc, 0xa5eb10fc, 0x2d7ba4f5, 0x2d7ba4f5, 0xd832b228, 0xd832b228, 0x56f0351, 0x56f0351, 0xc6556c2e, 0xc6556c2e, 0x2ceecfa4, 0x2ceecfa4, 0x3d765fbd, 0x3d765fbd, 0x8da7887e, 0x8da7887e, 0xfc8209ea, 0xfc8209ea, 0x6e822767, 0x6e822767, 0xba5c0adf, 0xba5c0adf, 0x8e2af81a, 0x8e2af81a, 0x62c25eb4, 0x2ba315e0, 0x349b7b7d, 0x349b7b7d, }, 45 }, + { "cmdline_cat", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x361fdea5, 0x361fdea5, 0x89a3b488, 0x89a3b488, 0x37302fbe, 0x37302fbe, 0x4b9f20b8, 0x4b9f20b8, 0xc60cf5fe, 0xc60cf5fe, 0xf7b755aa, 0xf7b755aa, 0xcaba5d52, 0xcaba5d52, 0x4f793adf, 0x4f793adf, 0x4cd60722, 0x4cd60722, 0x13adbeec, 0x13adbeec, 0xdc2c109f, 0xdc2c109f, 0x444e465a, 0x444e465a, 0x7baac5fa, 0x7baac5fa, 0x8e746e7f, 0x8e746e7f, 0x7fea6e68, 0x7fea6e68, 0x1f6edf48, 0x1f6edf48, 0x23322506, 0x23322506, 0xbccd38ef, 0xbccd38ef, 0x1b1f1dd3, 0x1b1f1dd3, 0x9c901775, 0x9c901775, 0x78b8e355, 0x95034aa2, 0x4f00ee83, 0x4f00ee83, }, 45 }, + { "gfxterm_menu", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0xdf032925, 0xb9ccc5a6, 0xdf032925, 0x9cf5e462, 0x59c36f00, 0x59c36f00, 0xd3a0a4df, 0xd3a0a4df, 0xd3a0a4df, 0xad20c9b9, 0xad20c9b9, 0xad20c9b9, 0xcfd6dc6b, 0xcfd6dc6b, 0xcfd6dc6b, 0x59c36f00, 0x9cf5e462, 0x9cf5e462, 0x59c36f00, }, 20 }, + { "gfxterm_menu", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0xa24e444d, 0x664c3f5, 0xa24e444d, 0x8c4bc132, 0xaa4593fe, 0xaa4593fe, 0x86e14b09, 0x86e14b09, 0x86e14b09, 0x2014466e, 0x2014466e, 0x2014466e, 0xd2ced16, 0xd2ced16, 0xd2ced16, 0xaa4593fe, 0x8c4bc132, 0x8c4bc132, 0xaa4593fe, }, 20 }, + { "gfxterm_menu", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x6fa41086, 0xd5284f5e, 0x6fa41086, 0x32b37d02, 0xc9cbf769, 0xc9cbf769, 0xf2a2bdc8, 0xf2a2bdc8, 0xf2a2bdc8, 0xc7a7c04, 0xc7a7c04, 0xc7a7c04, 0xe530c30c, 0xe530c30c, 0xe530c30c, 0xc9cbf769, 0x32b37d02, 0x32b37d02, 0xc9cbf769, }, 20 }, + { "gfxterm_menu", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0xd084e37c, 0x6324ea4b, 0xd084e37c, 0x7ed2aaa4, 0x9813a416, 0x9813a416, 0xbd3bd80c, 0xbd3bd80c, 0xbd3bd80c, 0x2ce05e3f, 0x2ce05e3f, 0x2ce05e3f, 0x355a63ef, 0x355a63ef, 0x355a63ef, 0x9813a416, 0x7ed2aaa4, 0x7ed2aaa4, 0x9813a416, }, 20 }, + { "gfxterm_menu", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x451273fe, 0x55e4689f, 0x451273fe, 0x33b4464d, 0x5fcf013d, 0x5fcf013d, 0xbe43bf51, 0xbe43bf51, 0xbe43bf51, 0x6c53a727, 0x6c53a727, 0x6c53a727, 0x7a2098b8, 0x7a2098b8, 0x7a2098b8, 0x5fcf013d, 0x33b4464d, 0x33b4464d, 0x5fcf013d, }, 20 }, + { "gfxterm_menu", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x93132338, 0xc76b87e6, 0x93132338, 0x8816f93f, 0xdd28f52b, 0xdd28f52b, 0xcdf3c404, 0xcdf3c404, 0xcdf3c404, 0xeccf3de0, 0xeccf3de0, 0xeccf3de0, 0x9177f66c, 0x9177f66c, 0x9177f66c, 0xdd28f52b, 0x8816f93f, 0x8816f93f, 0xdd28f52b, }, 20 }, + { "gfxterm_menu", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0xae6a4ef5, 0x5fb9948, 0xae6a4ef5, 0x51d55575, 0x43d1f34, 0x43d1f34, 0x252c3625, 0x252c3625, 0x252c3625, 0x5a269f8d, 0x5a269f8d, 0x5a269f8d, 0xc3779a0b, 0xc3779a0b, 0xc3779a0b, 0x43d1f34, 0x51d55575, 0x51d55575, 0x43d1f34, }, 20 }, + { "gfxmenu", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x60e56714, 0x14275a99, 0x60e56714, 0x35080c92, 0x9a2e0d26, 0xc53fe194, 0xc53fe194, 0xc53fe194, 0x99e71754, 0x99e71754, 0x99e71754, 0xb07fd9c6, 0xb07fd9c6, 0xb07fd9c6, 0x59c36f00, 0x35080c92, 0x35080c92, }, 18 }, + { "gfxmenu", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x33d94a8c, 0x7b789e53, 0x33d94a8c, 0xe8b9b6bf, 0xa9d58ccd, 0x8cf0d333, 0x8cf0d333, 0x8cf0d333, 0xd9af7939, 0xd9af7939, 0xd9af7939, 0xb09cb170, 0xb09cb170, 0xb09cb170, 0xaa4593fe, 0xe8b9b6bf, 0xe8b9b6bf, }, 18 }, + { "gfxmenu", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xe4669404, 0x9afa8e99, 0xe4669404, 0xdd25167e, 0x5411be8b, 0x3589841c, 0x3589841c, 0x3589841c, 0x4a372288, 0x4a372288, 0x4a372288, 0x84342f0, 0x84342f0, 0x84342f0, 0xc9cbf769, 0xdd25167e, 0xdd25167e, }, 18 }, + { "gfxmenu", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x1c3742c9, 0x37ed1568, 0x12f55eef, 0x37ed1568, 0x8aa8ad16, 0x740d78cf, 0x1a9dc2bc, 0x1a9dc2bc, 0x1a9dc2bc, 0xf13828c0, 0xf13828c0, 0xf13828c0, 0xf7732830, 0xf7732830, 0xf7732830, 0x1c3742c9, 0x8aa8ad16, 0x8aa8ad16, }, 18 }, + { "gfxmenu", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0xcc5a7bed, 0xc5315ac9, 0x7dece9d3, 0xc5315ac9, 0xc84ef08b, 0xbcda144c, 0x321e548b, 0x321e548b, 0x321e548b, 0x5d57889a, 0x5d57889a, 0x5d57889a, 0x50a11699, 0x50a11699, 0x50a11699, 0xcc5a7bed, 0xc84ef08b, 0xc84ef08b, }, 18 }, + { "gfxmenu", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xef4a3312, 0x40a72ecd, 0x2304571f, 0x40a72ecd, 0xd2de6d81, 0x5d55a141, 0x8ccafa03, 0x8ccafa03, 0x8ccafa03, 0x4a78be1d, 0x4a78be1d, 0x4a78be1d, 0x5e1d6ea2, 0x5e1d6ea2, 0x5e1d6ea2, 0xef4a3312, 0xd2de6d81, 0xd2de6d81, }, 18 }, + { "gfxmenu", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x54e48d80, 0xe6143ead, 0x19816f75, 0xe6143ead, 0xe2db78c2, 0xa992f629, 0x5fefa0d1, 0x5fefa0d1, 0x5fefa0d1, 0xde1c5600, 0xde1c5600, 0xde1c5600, 0x48b8ef6f, 0x48b8ef6f, 0x48b8ef6f, 0x54e48d80, 0xe2db78c2, 0xe2db78c2, }, 18 }, + { "gfxterm_ar", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x25ba43d4, 0x43fe620d, 0x25ba43d4, 0x664c8e93, 0x59c36f00, 0x59c36f00, 0xb2921a37, 0xb2921a37, 0xb2921a37, 0xcc127751, 0xcc127751, 0xcc127751, 0xaee46283, 0xaee46283, 0xaee46283, 0x59c36f00, 0x664c8e93, 0x664c8e93, 0x59c36f00, }, 20 }, + { "gfxterm_ar", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x2aa2a72b, 0x6d6df6e1, 0x2aa2a72b, 0x4a72254, 0xaa4593fe, 0xaa4593fe, 0xa3be9127, 0xa3be9127, 0xa3be9127, 0x54b9c40, 0x54b9c40, 0x54b9c40, 0x28733738, 0x28733738, 0x28733738, 0xaa4593fe, 0x4a72254, 0x4a72254, 0xaa4593fe, }, 20 }, + { "gfxterm_ar", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x9e799f98, 0xe21ad041, 0x9e799f98, 0xc36ef21c, 0xc9cbf769, 0xc9cbf769, 0x93d6c07d, 0x93d6c07d, 0x93d6c07d, 0x6d0e01b1, 0x6d0e01b1, 0x6d0e01b1, 0x8444beb9, 0x8444beb9, 0x8444beb9, 0xc9cbf769, 0xc36ef21c, 0xc36ef21c, 0xc9cbf769, }, 20 }, + { "gfxterm_ar", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x7ffc43fd, 0x64505961, 0x7ffc43fd, 0xd1aa0a25, 0x9813a416, 0x9813a416, 0x5b5f9bd5, 0x5b5f9bd5, 0x5b5f9bd5, 0xca841de6, 0xca841de6, 0xca841de6, 0xd33e2036, 0xd33e2036, 0xd33e2036, 0x9813a416, 0xd1aa0a25, 0xd1aa0a25, 0x9813a416, }, 20 }, + { "gfxterm_ar", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x570ca3fc, 0x4f1cee0f, 0x570ca3fc, 0x21aa964f, 0x5fcf013d, 0x5fcf013d, 0xf2bc017e, 0xf2bc017e, 0xf2bc017e, 0x20ac1908, 0x20ac1908, 0x20ac1908, 0x36df2697, 0x36df2697, 0x36df2697, 0x5fcf013d, 0x21aa964f, 0x21aa964f, 0x5fcf013d, }, 20 }, + { "gfxterm_ar", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xcf9798d3, 0x5d39a7fa, 0xcf9798d3, 0xd49242d4, 0xdd28f52b, 0xdd28f52b, 0xe15747f0, 0xe15747f0, 0xe15747f0, 0xc06bbe14, 0xc06bbe14, 0xc06bbe14, 0xbdd37598, 0xbdd37598, 0xbdd37598, 0xdd28f52b, 0xd49242d4, 0xd49242d4, 0xdd28f52b, }, 20 }, + { "gfxterm_ar", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0xae6154e8, 0x59e627f7, 0xae6154e8, 0x51de4f68, 0x43d1f34, 0x43d1f34, 0x59a8eb9f, 0x59a8eb9f, 0x59a8eb9f, 0x26a24237, 0x26a24237, 0x26a24237, 0xbff347b1, 0xbff347b1, 0xbff347b1, 0x43d1f34, 0x51de4f68, 0x51de4f68, 0x43d1f34, }, 20 }, + { "gfxterm_cyr", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0xb2b04aa3, 0xca81b845, 0xb2b04aa3, 0xf14687e4, 0x59c36f00, 0x59c36f00, 0xc01ee8bb, 0xc01ee8bb, 0xc01ee8bb, 0xbe9e85dd, 0xbe9e85dd, 0xbe9e85dd, 0xdc68900f, 0xdc68900f, 0xdc68900f, 0x59c36f00, 0xf14687e4, 0xf14687e4, 0x59c36f00, }, 20 }, + { "gfxterm_cyr", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x19a66482, 0xba12148e, 0x19a66482, 0x37a3e1fd, 0xaa4593fe, 0xaa4593fe, 0xfa4f54c9, 0xfa4f54c9, 0xfa4f54c9, 0x5cba59ae, 0x5cba59ae, 0x5cba59ae, 0x7182f2d6, 0x7182f2d6, 0x7182f2d6, 0xaa4593fe, 0x37a3e1fd, 0x37a3e1fd, 0xaa4593fe, }, 20 }, + { "gfxterm_cyr", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x6a5ddfe7, 0xc898195a, 0x6a5ddfe7, 0x374ab263, 0xc9cbf769, 0xc9cbf769, 0x7a6a0afe, 0x7a6a0afe, 0x7a6a0afe, 0x84b2cb32, 0x84b2cb32, 0x84b2cb32, 0x6df8743a, 0x6df8743a, 0x6df8743a, 0xc9cbf769, 0x374ab263, 0x374ab263, 0xc9cbf769, }, 20 }, + { "gfxterm_cyr", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0xb6ca222a, 0x98e6c241, 0xb6ca222a, 0x189c6bf2, 0x9813a416, 0x9813a416, 0x7fad8eb7, 0x7fad8eb7, 0x7fad8eb7, 0xee760884, 0xee760884, 0xee760884, 0xf7cc3554, 0xf7cc3554, 0xf7cc3554, 0x9813a416, 0x189c6bf2, 0x189c6bf2, 0x9813a416, }, 20 }, + { "gfxterm_cyr", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x726d82d0, 0xe9c535bd, 0x726d82d0, 0x4cbb763, 0x5fcf013d, 0x5fcf013d, 0xf99de8d5, 0xf99de8d5, 0xf99de8d5, 0x2b8df0a3, 0x2b8df0a3, 0x2b8df0a3, 0x3dfecf3c, 0x3dfecf3c, 0x3dfecf3c, 0x5fcf013d, 0x4cbb763, 0x4cbb763, 0x5fcf013d, }, 20 }, + { "gfxterm_cyr", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xfe26fef7, 0x6031c462, 0xfe26fef7, 0xe52324f0, 0xdd28f52b, 0xdd28f52b, 0x84ff6e38, 0x84ff6e38, 0x84ff6e38, 0xa5c397dc, 0xa5c397dc, 0xa5c397dc, 0xd87b5c50, 0xd87b5c50, 0xd87b5c50, 0xdd28f52b, 0xe52324f0, 0xe52324f0, 0xdd28f52b, }, 20 }, + { "gfxterm_cyr", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x25e34f8a, 0x67935e5e, 0x25e34f8a, 0xda5c540a, 0x43d1f34, 0x43d1f34, 0x7ebdd748, 0x7ebdd748, 0x7ebdd748, 0x1b77ee0, 0x1b77ee0, 0x1b77ee0, 0x98e67b66, 0x98e67b66, 0x98e67b66, 0x43d1f34, 0xda5c540a, 0xda5c540a, 0x43d1f34, }, 20 }, + { "gfxterm_heb", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x67038f5e, 0x65d6007f, 0x67038f5e, 0x24f54219, 0x59c36f00, 0x59c36f00, 0xac294ffd, 0xac294ffd, 0xac294ffd, 0xd2a9229b, 0xd2a9229b, 0xd2a9229b, 0xb05f3749, 0xb05f3749, 0xb05f3749, 0x59c36f00, 0x24f54219, 0x24f54219, 0x59c36f00, }, 20 }, + { "gfxterm_heb", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x944464c7, 0x27123864, 0x944464c7, 0xba41e1b8, 0xaa4593fe, 0xaa4593fe, 0xa521274, 0xa521274, 0xa521274, 0xaca71f13, 0xaca71f13, 0xaca71f13, 0x819fb46b, 0x819fb46b, 0x819fb46b, 0xaa4593fe, 0xba41e1b8, 0xba41e1b8, 0xaa4593fe, }, 20 }, + { "gfxterm_heb", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xfe97adaf, 0x4f3307d4, 0xfe97adaf, 0xa380c02b, 0xc9cbf769, 0xc9cbf769, 0xd202ced6, 0xd202ced6, 0xd202ced6, 0x2cda0f1a, 0x2cda0f1a, 0x2cda0f1a, 0xc590b012, 0xc590b012, 0xc590b012, 0xc9cbf769, 0xa380c02b, 0xa380c02b, 0xc9cbf769, }, 20 }, + { "gfxterm_heb", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x5b32a9ba, 0xaf93fd91, 0x5b32a9ba, 0xf564e062, 0x9813a416, 0x9813a416, 0xcfdbc809, 0xcfdbc809, 0xcfdbc809, 0x5e004e3a, 0x5e004e3a, 0x5e004e3a, 0x47ba73ea, 0x47ba73ea, 0x47ba73ea, 0x9813a416, 0xf564e062, 0xf564e062, 0x9813a416, }, 20 }, + { "gfxterm_heb", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x5e0e1ce8, 0x7ed1c9ee, 0x5e0e1ce8, 0x28a8295b, 0x5fcf013d, 0x5fcf013d, 0x615f5762, 0x615f5762, 0x615f5762, 0xb34f4f14, 0xb34f4f14, 0xb34f4f14, 0xa53c708b, 0xa53c708b, 0xa53c708b, 0x5fcf013d, 0x28a8295b, 0x28a8295b, 0x5fcf013d, }, 20 }, + { "gfxterm_heb", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xa473184a, 0x93eaf325, 0xa473184a, 0xbf76c24d, 0xdd28f52b, 0xdd28f52b, 0x714dd1f7, 0x714dd1f7, 0x714dd1f7, 0x50712813, 0x50712813, 0x50712813, 0x2dc9e39f, 0x2dc9e39f, 0x2dc9e39f, 0xdd28f52b, 0xbf76c24d, 0xbf76c24d, 0xdd28f52b, }, 20 }, + { "gfxterm_heb", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0xa725578b, 0x81889cf9, 0xa725578b, 0x589a4c0b, 0x43d1f34, 0x43d1f34, 0xf25ab3a8, 0xf25ab3a8, 0xf25ab3a8, 0x8d501a00, 0x8d501a00, 0x8d501a00, 0x14011f86, 0x14011f86, 0x14011f86, 0x43d1f34, 0x589a4c0b, 0x589a4c0b, 0x43d1f34, }, 20 }, + { "gfxterm_gre", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0xd69cdcbf, 0x6ad9ce85, 0xd69cdcbf, 0x956a11f8, 0x59c36f00, 0x59c36f00, 0xc4c10e6a, 0xc4c10e6a, 0xc4c10e6a, 0xba41630c, 0xba41630c, 0xba41630c, 0xd8b776de, 0xd8b776de, 0xd8b776de, 0x59c36f00, 0x956a11f8, 0x956a11f8, 0x59c36f00, }, 20 }, + { "gfxterm_gre", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x1acffa1b, 0xecff2136, 0x1acffa1b, 0x34ca7f64, 0xaa4593fe, 0xaa4593fe, 0xb57c29cc, 0xb57c29cc, 0xb57c29cc, 0x138924ab, 0x138924ab, 0x138924ab, 0x3eb18fd3, 0x3eb18fd3, 0x3eb18fd3, 0xaa4593fe, 0x34ca7f64, 0x34ca7f64, 0xaa4593fe, }, 20 }, + { "gfxterm_gre", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x1cf8992, 0xb2c51b4c, 0x1cf8992, 0x5cd8e416, 0xc9cbf769, 0xc9cbf769, 0xba7b2d22, 0xba7b2d22, 0xba7b2d22, 0x44a3ecee, 0x44a3ecee, 0x44a3ecee, 0xade953e6, 0xade953e6, 0xade953e6, 0xc9cbf769, 0x5cd8e416, 0x5cd8e416, 0xc9cbf769, }, 20 }, + { "gfxterm_gre", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x1f39da0b, 0x6a7f5378, 0x1f39da0b, 0xb16f93d3, 0x9813a416, 0x9813a416, 0x8e8a2ed7, 0x8e8a2ed7, 0x8e8a2ed7, 0x1f51a8e4, 0x1f51a8e4, 0x1f51a8e4, 0x6eb9534, 0x6eb9534, 0x6eb9534, 0x9813a416, 0xb16f93d3, 0xb16f93d3, 0x9813a416, }, 20 }, + { "gfxterm_gre", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x27394d6b, 0x459337bf, 0x27394d6b, 0x519f78d8, 0x5fcf013d, 0x5fcf013d, 0x66ed4571, 0x66ed4571, 0x66ed4571, 0xb4fd5d07, 0xb4fd5d07, 0xb4fd5d07, 0xa28e6298, 0xa28e6298, 0xa28e6298, 0x5fcf013d, 0x519f78d8, 0x519f78d8, 0x5fcf013d, }, 20 }, + { "gfxterm_gre", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x624e1f92, 0x4be3bd84, 0x624e1f92, 0x794bc595, 0xdd28f52b, 0xdd28f52b, 0xd33767c, 0xd33767c, 0xd33767c, 0x2c0f8f98, 0x2c0f8f98, 0x2c0f8f98, 0x51b74414, 0x51b74414, 0x51b74414, 0xdd28f52b, 0x794bc595, 0x794bc595, 0xdd28f52b, }, 20 }, + { "gfxterm_gre", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0xbf5dab2e, 0x4747516, 0xbf5dab2e, 0x40e2b0ae, 0x43d1f34, 0x43d1f34, 0x3cc1d2dd, 0x3cc1d2dd, 0x3cc1d2dd, 0x43cb7b75, 0x43cb7b75, 0x43cb7b75, 0xda9a7ef3, 0xda9a7ef3, 0xda9a7ef3, 0x43d1f34, 0x40e2b0ae, 0x40e2b0ae, 0x43d1f34, }, 20 }, + { "gfxterm_ru", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x2e284303, 0x169e4b98, 0x2e284303, 0x6dde8e44, 0x59c36f00, 0x59c36f00, 0xd2e0cf68, 0xd2e0cf68, 0xd2e0cf68, 0xac60a20e, 0xac60a20e, 0xac60a20e, 0xce96b7dc, 0xce96b7dc, 0xce96b7dc, 0x59c36f00, 0x6dde8e44, 0x6dde8e44, 0x59c36f00, }, 20 }, + { "gfxterm_ru", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x3a911f8f, 0xe5d171c6, 0x3a911f8f, 0x14949af0, 0xaa4593fe, 0xaa4593fe, 0xe7c628ac, 0xe7c628ac, 0xe7c628ac, 0x413325cb, 0x413325cb, 0x413325cb, 0x6c0b8eb3, 0x6c0b8eb3, 0x6c0b8eb3, 0xaa4593fe, 0x14949af0, 0x14949af0, 0xaa4593fe, }, 20 }, + { "gfxterm_ru", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xa4645fb3, 0x8af97df0, 0xa4645fb3, 0xf9733237, 0xc9cbf769, 0xc9cbf769, 0xef376611, 0xef376611, 0xef376611, 0x11efa7dd, 0x11efa7dd, 0x11efa7dd, 0xf8a518d5, 0xf8a518d5, 0xf8a518d5, 0xc9cbf769, 0xf9733237, 0xf9733237, 0xc9cbf769, }, 20 }, + { "gfxterm_ru", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x7c3a337b, 0xed3f1a6, 0x7c3a337b, 0xd26c7aa3, 0x9813a416, 0x9813a416, 0x86aa8146, 0x86aa8146, 0x86aa8146, 0x17710775, 0x17710775, 0x17710775, 0xecb3aa5, 0xecb3aa5, 0xecb3aa5, 0x9813a416, 0xd26c7aa3, 0xd26c7aa3, 0x9813a416, }, 20 }, + { "gfxterm_ru", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x9f31781b, 0xb6d3e547, 0x9f31781b, 0xe9974da8, 0x5fcf013d, 0x5fcf013d, 0x3781245e, 0x3781245e, 0x3781245e, 0xe5913c28, 0xe5913c28, 0xe5913c28, 0xf3e203b7, 0xf3e203b7, 0xf3e203b7, 0x5fcf013d, 0xe9974da8, 0xe9974da8, 0x5fcf013d, }, 20 }, + { "gfxterm_ru", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xfc18d24f, 0x70ed44c6, 0xfc18d24f, 0xe71d0848, 0xdd28f52b, 0xdd28f52b, 0xc847f61f, 0xc847f61f, 0xc847f61f, 0xe97b0ffb, 0xe97b0ffb, 0xe97b0ffb, 0x94c3c477, 0x94c3c477, 0x94c3c477, 0xdd28f52b, 0xe71d0848, 0xe71d0848, 0xdd28f52b, }, 20 }, + { "gfxterm_ru", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x7bb91866, 0xc4777a1f, 0x7bb91866, 0x840603e6, 0x43d1f34, 0x43d1f34, 0x2a49c131, 0x2a49c131, 0x2a49c131, 0x55436899, 0x55436899, 0x55436899, 0xcc126d1f, 0xcc126d1f, 0xcc126d1f, 0x43d1f34, 0x840603e6, 0x840603e6, 0x43d1f34, }, 20 }, + { "gfxterm_fr", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0xa0d0faff, 0x8b37dfcd, 0xa0d0faff, 0xe32637b8, 0x59c36f00, 0x59c36f00, 0x94e6a8c7, 0x94e6a8c7, 0x94e6a8c7, 0xea66c5a1, 0xea66c5a1, 0xea66c5a1, 0x8890d073, 0x8890d073, 0x8890d073, 0x59c36f00, 0xe32637b8, 0xe32637b8, 0x59c36f00, }, 20 }, + { "gfxterm_fr", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x4436bcdb, 0xb3a12b62, 0x4436bcdb, 0x6a3339a4, 0xaa4593fe, 0xaa4593fe, 0x53ef9b82, 0x53ef9b82, 0x53ef9b82, 0xf51a96e5, 0xf51a96e5, 0xf51a96e5, 0xd8223d9d, 0xd8223d9d, 0xd8223d9d, 0xaa4593fe, 0x6a3339a4, 0x6a3339a4, 0xaa4593fe, }, 20 }, + { "gfxterm_fr", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xb8e59140, 0x2463e41f, 0xb8e59140, 0xe5f2fcc4, 0xc9cbf769, 0xc9cbf769, 0xc31681f4, 0xc31681f4, 0xc31681f4, 0x3dce4038, 0x3dce4038, 0x3dce4038, 0xd484ff30, 0xd484ff30, 0xd484ff30, 0xc9cbf769, 0xe5f2fcc4, 0xe5f2fcc4, 0xc9cbf769, }, 20 }, + { "gfxterm_fr", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x438b3fcc, 0x7ebfbfd, 0x438b3fcc, 0xeddd7614, 0x9813a416, 0x9813a416, 0x8ac4ae20, 0x8ac4ae20, 0x8ac4ae20, 0x1b1f2813, 0x1b1f2813, 0x1b1f2813, 0x2a515c3, 0x2a515c3, 0x2a515c3, 0x9813a416, 0xeddd7614, 0xeddd7614, 0x9813a416, }, 20 }, + { "gfxterm_fr", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0xf9eea896, 0x25a51233, 0xf9eea896, 0x8f489d25, 0x5fcf013d, 0x5fcf013d, 0x62e37cf8, 0x62e37cf8, 0x62e37cf8, 0xb0f3648e, 0xb0f3648e, 0xb0f3648e, 0xa6805b11, 0xa6805b11, 0xa6805b11, 0x5fcf013d, 0x8f489d25, 0x8f489d25, 0x5fcf013d, }, 20 }, + { "gfxterm_fr", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x9b617752, 0xb06817b5, 0x9b617752, 0x8064ad55, 0xdd28f52b, 0xdd28f52b, 0x38159b7a, 0x38159b7a, 0x38159b7a, 0x1929629e, 0x1929629e, 0x1929629e, 0x6491a912, 0x6491a912, 0x6491a912, 0xdd28f52b, 0x8064ad55, 0x8064ad55, 0xdd28f52b, }, 20 }, + { "gfxterm_fr", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x595e29e, 0xc043d961, 0x595e29e, 0xfa2af91e, 0x43d1f34, 0x43d1f34, 0x6d6b2915, 0x6d6b2915, 0x6d6b2915, 0x126180bd, 0x126180bd, 0x126180bd, 0x8b30853b, 0x8b30853b, 0x8b30853b, 0x43d1f34, 0xfa2af91e, 0xfa2af91e, 0x43d1f34, }, 20 }, + { "gfxterm_quot", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x63e24d8a, 0x52da109, 0x63e24d8a, 0x201480cd, 0x59c36f00, 0x59c36f00, 0xd3a0a4df, 0xd3a0a4df, 0xd3a0a4df, 0xad20c9b9, 0xad20c9b9, 0xad20c9b9, 0xcfd6dc6b, 0xcfd6dc6b, 0xcfd6dc6b, 0x59c36f00, 0x201480cd, 0x201480cd, 0x59c36f00, }, 20 }, + { "gfxterm_quot", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x1b2e61c9, 0xbf04e671, 0x1b2e61c9, 0x352be4b6, 0xaa4593fe, 0xaa4593fe, 0x86e14b09, 0x86e14b09, 0x86e14b09, 0x2014466e, 0x2014466e, 0x2014466e, 0xd2ced16, 0xd2ced16, 0xd2ced16, 0xaa4593fe, 0x352be4b6, 0x352be4b6, 0xaa4593fe, }, 20 }, + { "gfxterm_quot", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xefcce0d0, 0x5540bf08, 0xefcce0d0, 0xb2db8d54, 0xc9cbf769, 0xc9cbf769, 0xf2a2bdc8, 0xf2a2bdc8, 0xf2a2bdc8, 0xc7a7c04, 0xc7a7c04, 0xc7a7c04, 0xe530c30c, 0xe530c30c, 0xe530c30c, 0xc9cbf769, 0xb2db8d54, 0xb2db8d54, 0xc9cbf769, }, 20 }, + { "gfxterm_quot", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x65a5505e, 0xd6055969, 0x65a5505e, 0xcbf31986, 0x9813a416, 0x9813a416, 0xbd3bd80c, 0xbd3bd80c, 0xbd3bd80c, 0x2ce05e3f, 0x2ce05e3f, 0x2ce05e3f, 0x355a63ef, 0x355a63ef, 0x355a63ef, 0x9813a416, 0xcbf31986, 0xcbf31986, 0x9813a416, }, 20 }, + { "gfxterm_quot", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x7319d06, 0x17c78667, 0x7319d06, 0x7197a8b5, 0x5fcf013d, 0x5fcf013d, 0xbe43bf51, 0xbe43bf51, 0xbe43bf51, 0x6c53a727, 0x6c53a727, 0x6c53a727, 0x7a2098b8, 0x7a2098b8, 0x7a2098b8, 0x5fcf013d, 0x7197a8b5, 0x7197a8b5, 0x5fcf013d, }, 20 }, + { "gfxterm_quot", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x723a247, 0x535b0699, 0x723a247, 0x1c267840, 0xdd28f52b, 0xdd28f52b, 0xcdf3c404, 0xcdf3c404, 0xcdf3c404, 0xeccf3de0, 0xeccf3de0, 0xeccf3de0, 0x9177f66c, 0x9177f66c, 0x9177f66c, 0xdd28f52b, 0x1c267840, 0x1c267840, 0xdd28f52b, }, 20 }, + { "gfxterm_quot", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0xe3a20cf8, 0x4833db45, 0xe3a20cf8, 0x1c1d1778, 0x43d1f34, 0x43d1f34, 0x252c3625, 0x252c3625, 0x252c3625, 0x5a269f8d, 0x5a269f8d, 0x5a269f8d, 0xc3779a0b, 0xc3779a0b, 0xc3779a0b, 0x43d1f34, 0x1c1d1778, 0x1c1d1778, 0x43d1f34, }, 20 }, + { "gfxterm_piglatin", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x24b38cd5, 0x6b033831, 0x24b38cd5, 0x67454192, 0x59c36f00, 0x59c36f00, 0xc12f3297, 0xc12f3297, 0xc12f3297, 0xbfaf5ff1, 0xbfaf5ff1, 0xbfaf5ff1, 0xdd594a23, 0xdd594a23, 0xdd594a23, 0x59c36f00, 0x67454192, 0x67454192, 0x59c36f00, }, 20 }, + { "gfxterm_piglatin", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x54f09885, 0x5d94ace6, 0x54f09885, 0x7af51dfa, 0xaa4593fe, 0xaa4593fe, 0xe3a05427, 0xe3a05427, 0xe3a05427, 0x45555940, 0x45555940, 0x45555940, 0x686df238, 0x686df238, 0x686df238, 0xaa4593fe, 0x7af51dfa, 0x7af51dfa, 0xaa4593fe, }, 20 }, + { "gfxterm_piglatin", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x53c2ee74, 0x92931869, 0x53c2ee74, 0xed583f0, 0xc9cbf769, 0xc9cbf769, 0x76afdc1b, 0x76afdc1b, 0x76afdc1b, 0x88771dd7, 0x88771dd7, 0x88771dd7, 0x613da2df, 0x613da2df, 0x613da2df, 0xc9cbf769, 0xed583f0, 0xed583f0, 0xc9cbf769, }, 20 }, + { "gfxterm_piglatin", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x4e5ded6f, 0x12bf47c3, 0x4e5ded6f, 0xe00ba4b7, 0x9813a416, 0x9813a416, 0x72c4cb9c, 0x72c4cb9c, 0x72c4cb9c, 0xe31f4daf, 0xe31f4daf, 0xe31f4daf, 0xfaa5707f, 0xfaa5707f, 0xfaa5707f, 0x9813a416, 0xe00ba4b7, 0xe00ba4b7, 0x9813a416, }, 20 }, + { "gfxterm_piglatin", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x3566adf6, 0x4c7649cf, 0x3566adf6, 0x43c09845, 0x5fcf013d, 0x5fcf013d, 0xc2b479f, 0xc2b479f, 0xc2b479f, 0xde3b5fe9, 0xde3b5fe9, 0xde3b5fe9, 0xc8486076, 0xc8486076, 0xc8486076, 0x5fcf013d, 0x43c09845, 0x43c09845, 0x5fcf013d, }, 20 }, + { "gfxterm_piglatin", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xec1bda0d, 0x86636a33, 0xec1bda0d, 0xf71e000a, 0xdd28f52b, 0xdd28f52b, 0xda5ce270, 0xda5ce270, 0xda5ce270, 0xfb601b94, 0xfb601b94, 0xfb601b94, 0x86d8d018, 0x86d8d018, 0x86d8d018, 0xdd28f52b, 0xf71e000a, 0xf71e000a, 0xdd28f52b, }, 20 }, + { "gfxterm_piglatin", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x619415be, 0x92024b97, 0x619415be, 0x9e2b0e3e, 0x43d1f34, 0x43d1f34, 0xfa2f329, 0xfa2f329, 0xfa2f329, 0x70a85a81, 0x70a85a81, 0x70a85a81, 0xe9f95f07, 0xe9f95f07, 0xe9f95f07, 0x43d1f34, 0x9e2b0e3e, 0x9e2b0e3e, 0x43d1f34, }, 20 }, + { "gfxterm_ch", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x200688e1, 0x1274a595, 0x200688e1, 0x63f045a6, 0x59c36f00, 0x59c36f00, 0x2312e40c, 0x2312e40c, 0x2312e40c, 0x5d92896a, 0x5d92896a, 0x5d92896a, 0x3f649cb8, 0x3f649cb8, 0x3f649cb8, 0x59c36f00, 0x63f045a6, 0x63f045a6, 0x59c36f00, }, 20 }, + { "gfxterm_ch", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0xa943b821, 0x8aa682a4, 0xa943b821, 0x87463d5e, 0xaa4593fe, 0xaa4593fe, 0xff049fb7, 0xff049fb7, 0xff049fb7, 0x59f192d0, 0x59f192d0, 0x59f192d0, 0x74c939a8, 0x74c939a8, 0x74c939a8, 0xaa4593fe, 0x87463d5e, 0x87463d5e, 0xaa4593fe, }, 20 }, + { "gfxterm_ch", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0x11b6367b, 0x27bbcfb4, 0x11b6367b, 0x4ca15bff, 0xc9cbf769, 0xc9cbf769, 0x51f424d6, 0x51f424d6, 0x51f424d6, 0xaf2ce51a, 0xaf2ce51a, 0xaf2ce51a, 0x46665a12, 0x46665a12, 0x46665a12, 0xc9cbf769, 0x4ca15bff, 0x4ca15bff, 0xc9cbf769, }, 20 }, + { "gfxterm_ch", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x7c16ec93, 0xe9d7d93f, 0x7c16ec93, 0xd240a54b, 0x9813a416, 0x9813a416, 0x9e5c75d9, 0x9e5c75d9, 0x9e5c75d9, 0xf87f3ea, 0xf87f3ea, 0xf87f3ea, 0x163dce3a, 0x163dce3a, 0x163dce3a, 0x9813a416, 0xd240a54b, 0xd240a54b, 0x9813a416, }, 20 }, + { "gfxterm_ch", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0xe28608ec, 0x3575a25f, 0xe28608ec, 0x94203d5f, 0x5fcf013d, 0x5fcf013d, 0x7c6f7c86, 0x7c6f7c86, 0x7c6f7c86, 0xae7f64f0, 0xae7f64f0, 0xae7f64f0, 0xb80c5b6f, 0xb80c5b6f, 0xb80c5b6f, 0x5fcf013d, 0x94203d5f, 0x94203d5f, 0x5fcf013d, }, 20 }, + { "gfxterm_ch", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xb510e48, 0x9406b857, 0xb510e48, 0x1054d44f, 0xdd28f52b, 0xdd28f52b, 0x13c76182, 0x13c76182, 0x13c76182, 0x32fb9866, 0x32fb9866, 0x32fb9866, 0x4f4353ea, 0x4f4353ea, 0x4f4353ea, 0xdd28f52b, 0x1054d44f, 0x1054d44f, 0xdd28f52b, }, 20 }, + { "gfxterm_ch", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0xf256eb36, 0xaed7d845, 0xf256eb36, 0xde9f0b6, 0x43d1f34, 0x43d1f34, 0xbe644e0c, 0xbe644e0c, 0xbe644e0c, 0xc16ee7a4, 0xc16ee7a4, 0xc16ee7a4, 0x583fe222, 0x583fe222, 0x583fe222, 0x43d1f34, 0xde9f0b6, 0xde9f0b6, 0x43d1f34, }, 20 }, + { "gfxterm_red", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0xe382dd9, 0x68f7c15a, 0xe382dd9, 0x59159307, 0x59c36f00, 0x59c36f00, 0xba01eaa9, 0xba01eaa9, 0xba01eaa9, 0xc48187cf, 0xc48187cf, 0xc48187cf, 0xa677921d, 0xa677921d, 0xa677921d, 0x59c36f00, 0x59159307, 0x59159307, 0x59c36f00, }, 20 }, + { "gfxterm_red", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0x3c908c, 0xa4161734, 0x3c908c, 0xb09b4ada, 0xaa4593fe, 0xaa4593fe, 0xdfbf1f3, 0xdfbf1f3, 0xdfbf1f3, 0xab0efc94, 0xab0efc94, 0xab0efc94, 0x863657ec, 0x863657ec, 0x863657ec, 0xaa4593fe, 0xb09b4ada, 0xb09b4ada, 0xaa4593fe, }, 20 }, + { "gfxterm_red", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xd2e9527, 0xb7a2caff, 0xd2e9527, 0x1d0b8b89, 0xc9cbf769, 0xc9cbf769, 0x6684aa7f, 0x6684aa7f, 0x6684aa7f, 0x985c6bb3, 0x985c6bb3, 0x985c6bb3, 0x7116d4bb, 0x7116d4bb, 0x7116d4bb, 0xc9cbf769, 0x1d0b8b89, 0x1d0b8b89, 0xc9cbf769, }, 20 }, + { "gfxterm_red", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x1639705d, 0xa599796a, 0x1639705d, 0x26488c72, 0x9813a416, 0x9813a416, 0x49b2de5c, 0x49b2de5c, 0x49b2de5c, 0xd869586f, 0xd869586f, 0xd869586f, 0xc1d365bf, 0xc1d365bf, 0xc1d365bf, 0x9813a416, 0x26488c72, 0x26488c72, 0x9813a416, }, 20 }, + { "gfxterm_red", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x10d0c422, 0x26df43, 0x10d0c422, 0xbed72bd7, 0x5fcf013d, 0x5fcf013d, 0x67d73911, 0x67d73911, 0x67d73911, 0xb5c72167, 0xb5c72167, 0xb5c72167, 0xa3b41ef8, 0xa3b41ef8, 0xa3b41ef8, 0x5fcf013d, 0xbed72bd7, 0xbed72bd7, 0x5fcf013d, }, 20 }, + { "gfxterm_red", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0xdd34e67a, 0x894c42a4, 0xdd34e67a, 0x53502da0, 0xdd28f52b, 0xdd28f52b, 0x886a111, 0x886a111, 0x886a111, 0x29ba58f5, 0x29ba58f5, 0x29ba58f5, 0x54029379, 0x54029379, 0x54029379, 0xdd28f52b, 0x53502da0, 0x53502da0, 0xdd28f52b, }, 20 }, + { "gfxterm_red", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0x410b50fc, 0xea9a8741, 0x410b50fc, 0xd653d65c, 0x43d1f34, 0x43d1f34, 0xcdea4de5, 0xcdea4de5, 0xcdea4de5, 0xb2e0e44d, 0xb2e0e44d, 0xb2e0e44d, 0x2bb1e1cb, 0x2bb1e1cb, 0x2bb1e1cb, 0x43d1f34, 0xd653d65c, 0xd653d65c, 0x43d1f34, }, 20 }, + { "gfxterm_high", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x59c36f00, 0x4c09d761, 0x2ac63be2, 0x4c09d761, 0xf44378ab, 0x59c36f00, 0x59c36f00, 0xd3a0a4df, 0xd3a0a4df, 0xd3a0a4df, 0xad20c9b9, 0xad20c9b9, 0xad20c9b9, 0xcfd6dc6b, 0xcfd6dc6b, 0xcfd6dc6b, 0x59c36f00, 0xf44378ab, 0xf44378ab, 0x59c36f00, }, 20 }, + { "gfxterm_high", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0xaa4593fe, 0xd3c0fce6, 0x77ea7b5e, 0xd3c0fce6, 0x10463469, 0xaa4593fe, 0xaa4593fe, 0x86e14b09, 0x86e14b09, 0x86e14b09, 0x2014466e, 0x2014466e, 0x2014466e, 0xd2ced16, 0xd2ced16, 0xd2ced16, 0xaa4593fe, 0x10463469, 0x10463469, 0xaa4593fe, }, 20 }, + { "gfxterm_high", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xc9cbf769, 0xabafd82f, 0x112387f7, 0xabafd82f, 0xe9ca2412, 0xc9cbf769, 0xc9cbf769, 0xf2a2bdc8, 0xf2a2bdc8, 0xf2a2bdc8, 0xc7a7c04, 0xc7a7c04, 0xc7a7c04, 0xe530c30c, 0xe530c30c, 0xe530c30c, 0xc9cbf769, 0xe9ca2412, 0xe9ca2412, 0xc9cbf769, }, 20 }, + { "gfxterm_high", 640, 480, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 640x480xrgba8888 */, (grub_uint32_t []) { 0x9813a416, 0x2b138245, 0x98b38b72, 0x2b138245, 0x6500200c, 0x9813a416, 0x9813a416, 0xbd3bd80c, 0xbd3bd80c, 0xbd3bd80c, 0x2ce05e3f, 0x2ce05e3f, 0x2ce05e3f, 0x355a63ef, 0x355a63ef, 0x355a63ef, 0x9813a416, 0x6500200c, 0x6500200c, 0x9813a416, }, 20 }, + { "gfxterm_high", 800, 600, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 800x600xrgba8888 */, (grub_uint32_t []) { 0x5fcf013d, 0x87f97368, 0x970f6809, 0x87f97368, 0x149f7c5f, 0x5fcf013d, 0x5fcf013d, 0xbe43bf51, 0xbe43bf51, 0xbe43bf51, 0x6c53a727, 0x6c53a727, 0x6c53a727, 0x7a2098b8, 0x7a2098b8, 0x7a2098b8, 0x5fcf013d, 0x149f7c5f, 0x149f7c5f, 0x5fcf013d, }, 20 }, + { "gfxterm_high", 1024, 768, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 1024x768xrgba8888 */, (grub_uint32_t []) { 0xdd28f52b, 0x12986e14, 0x46e0caca, 0x12986e14, 0xf51eaa4a, 0xdd28f52b, 0xdd28f52b, 0xcdf3c404, 0xcdf3c404, 0xcdf3c404, 0xeccf3de0, 0xeccf3de0, 0xeccf3de0, 0x9177f66c, 0x9177f66c, 0x9177f66c, 0xdd28f52b, 0xf51eaa4a, 0xf51eaa4a, 0xdd28f52b, }, 20 }, + { "gfxterm_high", 2560, 1440, 0x1, 256, 32, 4, 16, 8, 8, 8, 0, 8, 24, 8 /* 2560x1440xrgba8888 */, (grub_uint32_t []) { 0x43d1f34, 0xf6aab2f6, 0x5d3b654b, 0xf6aab2f6, 0x8e22ec59, 0x43d1f34, 0x43d1f34, 0x252c3625, 0x252c3625, 0x252c3625, 0x5a269f8d, 0x5a269f8d, 0x5a269f8d, 0xc3779a0b, 0xc3779a0b, 0xc3779a0b, 0x43d1f34, 0x8e22ec59, 0x8e22ec59, 0x43d1f34, }, 20 }, { "videotest", 640, 480, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 640x480xi16 */, (grub_uint32_t []) { 0x1368a483, 0x1368a483, 0x1368a483, 0x1368a483, 0x1368a483, }, 5 }, { "videotest", 800, 600, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 800x600xi16 */, (grub_uint32_t []) { 0x7033079c, 0x7033079c, 0x7033079c, 0x7033079c, 0x7033079c, }, 5 }, { "videotest", 1024, 768, 0x2, 16, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0 /* 1024x768xi16 */, (grub_uint32_t []) { 0xff583fbf, 0xff583fbf, 0xff583fbf, 0xff583fbf, 0xff583fbf, }, 5 }, From b00e4c2bd9fd051678a8aadafa95ad14b3c866ba Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Fri, 26 Feb 2016 21:44:37 +0300 Subject: [PATCH 707/722] efidisk: prevent errors from diskfilter scan of removable drives Map EFI_NO_MEDIA to GRUB_ERR_OUT_OF_RANGE that is ignored by diskfilter. This actually matches pretty close (we obviously attempt to read outside of media) and avoids adding more error codes. This affects only internally initiated scans. If read/write from removable is explicitly requested, we still return an error and text explanation is more clear for user than generic error. Reported and tested by Andreas Loew --- grub-core/disk/efi/efidisk.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/grub-core/disk/efi/efidisk.c b/grub-core/disk/efi/efidisk.c index 1c00e3ec8..ea753446d 100644 --- a/grub-core/disk/efi/efidisk.c +++ b/grub-core/disk/efi/efidisk.c @@ -547,7 +547,9 @@ grub_efidisk_read (struct grub_disk *disk, grub_disk_addr_t sector, status = grub_efidisk_readwrite (disk, sector, size, buf, 0); - if (status != GRUB_EFI_SUCCESS) + if (status == GRUB_EFI_NO_MEDIA) + return grub_error (GRUB_ERR_OUT_OF_RANGE, N_("no media in `%s'", disk->name)); + else if (status != GRUB_EFI_SUCCESS) return grub_error (GRUB_ERR_READ_ERROR, N_("failure reading sector 0x%llx from `%s'"), (unsigned long long) sector, @@ -568,7 +570,9 @@ grub_efidisk_write (struct grub_disk *disk, grub_disk_addr_t sector, status = grub_efidisk_readwrite (disk, sector, size, (char *) buf, 1); - if (status != GRUB_EFI_SUCCESS) + if (status == GRUB_EFI_NO_MEDIA) + return grub_error (GRUB_ERR_OUT_OF_RANGE, N_("no media in `%s'", disk->name)); + else if (status != GRUB_EFI_SUCCESS) return grub_error (GRUB_ERR_WRITE_ERROR, N_("failure writing sector 0x%llx to `%s'"), (unsigned long long) sector, disk->name); From 109189ce01ea6467055ca56b725ce263597db6d4 Mon Sep 17 00:00:00 2001 From: Andrei Borzenkov Date: Sat, 27 Feb 2016 15:16:48 +0300 Subject: [PATCH 708/722] efidisk: fix misplaced parenthesis in b00e4c2 --- grub-core/disk/efi/efidisk.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/grub-core/disk/efi/efidisk.c b/grub-core/disk/efi/efidisk.c index ea753446d..75bb4a9ca 100644 --- a/grub-core/disk/efi/efidisk.c +++ b/grub-core/disk/efi/efidisk.c @@ -548,7 +548,7 @@ grub_efidisk_read (struct grub_disk *disk, grub_disk_addr_t sector, status = grub_efidisk_readwrite (disk, sector, size, buf, 0); if (status == GRUB_EFI_NO_MEDIA) - return grub_error (GRUB_ERR_OUT_OF_RANGE, N_("no media in `%s'", disk->name)); + return grub_error (GRUB_ERR_OUT_OF_RANGE, N_("no media in `%s'"), disk->name); else if (status != GRUB_EFI_SUCCESS) return grub_error (GRUB_ERR_READ_ERROR, N_("failure reading sector 0x%llx from `%s'"), @@ -571,7 +571,7 @@ grub_efidisk_write (struct grub_disk *disk, grub_disk_addr_t sector, status = grub_efidisk_readwrite (disk, sector, size, (char *) buf, 1); if (status == GRUB_EFI_NO_MEDIA) - return grub_error (GRUB_ERR_OUT_OF_RANGE, N_("no media in `%s'", disk->name)); + return grub_error (GRUB_ERR_OUT_OF_RANGE, N_("no media in `%s'"), disk->name); else if (status != GRUB_EFI_SUCCESS) return grub_error (GRUB_ERR_WRITE_ERROR, N_("failure writing sector 0x%llx to `%s'"), From 070e190305986dff1d528af08b964667f29dc914 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 26 Feb 2016 11:56:28 +0100 Subject: [PATCH 709/722] Use console rather than serial_efi0 on arm64-efi in tests --- tests/util/grub-shell.in | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/util/grub-shell.in b/tests/util/grub-shell.in index 7848b4222..ab19dbbf5 100644 --- a/tests/util/grub-shell.in +++ b/tests/util/grub-shell.in @@ -74,6 +74,7 @@ case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in disk=0 # To skip "Welcome to GRUB" and color setttings trim=1 + serial_port= ;; powerpc-ieee1275) boot=hd @@ -181,7 +182,7 @@ case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in trim=1 qemuopts="-machine virt -cpu cortex-a57 -bios /usr/share/qemu-efi/QEMU_EFI.fd $qemuopts" disk="device virtio-blk-device,drive=hd1 -drive if=none,id=hd1,file=" - serial_port=efi0 + serial_port= ;; arm-efi) qemu=qemu-system-arm @@ -322,7 +323,7 @@ fi if [ "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" = powerpc-ieee1275 ]; then echo insmod escc >>${cfgfile} fi -if [ "${grub_modinfo_platform}" != emu ]; then +if [ "${serial_port}" != "" ]; then echo "serial ${serial_port}" >>${cfgfile} term="serial_${serial_port}" else From 8c26dace6f4db4245b57f05257c07b1253eb7490 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 26 Feb 2016 12:26:56 +0100 Subject: [PATCH 710/722] cat: Don't switch terminal mode when there is nothing to highlight. This just pollutes serial console. --- grub-core/commands/cat.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/grub-core/commands/cat.c b/grub-core/commands/cat.c index 8a7f1af78..88d904436 100644 --- a/grub-core/commands/cat.c +++ b/grub-core/commands/cat.c @@ -140,10 +140,13 @@ grub_cmd_cat (grub_extcmd_context_t ctxt, int argc, char **args) grub_setcolorstate (GRUB_TERM_COLOR_STANDARD); } - grub_setcolorstate (GRUB_TERM_COLOR_HIGHLIGHT); - for (j = 0; j < utcount; j++) - grub_printf ("<%x>", (unsigned int) utbuf[j]); - grub_setcolorstate (GRUB_TERM_COLOR_STANDARD); + if (utcount) + { + grub_setcolorstate (GRUB_TERM_COLOR_HIGHLIGHT); + for (j = 0; j < utcount; j++) + grub_printf ("<%x>", (unsigned int) utbuf[j]); + grub_setcolorstate (GRUB_TERM_COLOR_STANDARD); + } grub_xputs ("\n"); grub_refresh (); From 2ebef43cf6276168c72b63f7bd66fad3b030973e Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 26 Feb 2016 14:56:22 +0100 Subject: [PATCH 711/722] bsd: Ensure that kernel is loaded before loading module. kernel_type may be set to the type of failed kernel. This patching-up is easier than to reflow kernel loading routines. --- grub-core/loader/i386/bsd.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/grub-core/loader/i386/bsd.c b/grub-core/loader/i386/bsd.c index bc377b362..7f96515da 100644 --- a/grub-core/loader/i386/bsd.c +++ b/grub-core/loader/i386/bsd.c @@ -1889,6 +1889,10 @@ grub_cmd_freebsd_module (grub_command_t cmd __attribute__ ((unused)), grub_err_t err; void *src; + if (! grub_loader_is_loaded ()) + return grub_error (GRUB_ERR_BAD_ARGUMENT, + N_("you need to load the kernel first")); + if (kernel_type != KERNEL_TYPE_FREEBSD) return grub_error (GRUB_ERR_BAD_ARGUMENT, "no FreeBSD loaded"); @@ -1992,6 +1996,10 @@ grub_cmd_netbsd_module (grub_command_t cmd, { grub_uint32_t type; + if (! grub_loader_is_loaded ()) + return grub_error (GRUB_ERR_BAD_ARGUMENT, + N_("you need to load the kernel first")); + if (kernel_type != KERNEL_TYPE_NETBSD) return grub_error (GRUB_ERR_BAD_ARGUMENT, "no NetBSD loaded"); @@ -2070,6 +2078,10 @@ grub_cmd_openbsd_ramdisk (grub_command_t cmd __attribute__ ((unused)), if (argc != 1) return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected")); + if (! grub_loader_is_loaded ()) + return grub_error (GRUB_ERR_BAD_ARGUMENT, + N_("you need to load the kernel first")); + if (kernel_type != KERNEL_TYPE_OPENBSD) return grub_error (GRUB_ERR_BAD_OS, "no kOpenBSD loaded"); From 36212460d3565b18439a3a8130b28e6c97702c6a Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Thu, 18 Feb 2016 20:26:44 +0100 Subject: [PATCH 712/722] mkimage.c: Split into separate files. util/grub-mkimagexx.c is included in a special way into mkimage.c. Interoperation between defines makes this very tricky. Instead just have a clean interface and compile util/grub-mkimage*.c separately from mkimage.c --- Makefile.util.def | 10 ++ include/grub/util/mkimage.h | 170 ++++++++++++++++++++++ util/grub-mkimage32.c | 22 +++ util/grub-mkimage64.c | 22 +++ util/grub-mkimagexx.c | 244 ++++++++++++++++++++++---------- util/mkimage.c | 275 ++---------------------------------- 6 files changed, 406 insertions(+), 337 deletions(-) create mode 100644 include/grub/util/mkimage.h create mode 100644 util/grub-mkimage32.c create mode 100644 util/grub-mkimage64.c diff --git a/Makefile.util.def b/Makefile.util.def index db7e8ec2a..ed9b4c697 100644 --- a/Makefile.util.def +++ b/Makefile.util.def @@ -172,6 +172,8 @@ program = { common = util/grub-mkimage.c; common = util/mkimage.c; + common = util/grub-mkimage32.c; + common = util/grub-mkimage64.c; common = util/resolve.c; common = grub-core/kern/emu/argp_common.c; common = grub-core/osdep/init.c; @@ -510,6 +512,8 @@ program = { common = util/render-label.c; common = util/glue-efi.c; common = util/mkimage.c; + common = util/grub-mkimage32.c; + common = util/grub-mkimage64.c; common = util/grub-install-common.c; common = util/setup_bios.c; common = util/setup_sparc.c; @@ -552,6 +556,8 @@ program = { common = util/render-label.c; common = util/glue-efi.c; common = util/mkimage.c; + common = util/grub-mkimage32.c; + common = util/grub-mkimage64.c; common = util/grub-install-common.c; common = util/setup_bios.c; common = util/setup_sparc.c; @@ -595,6 +601,8 @@ program = { common = util/grub-install.c; common = util/probe.c; common = util/mkimage.c; + common = util/grub-mkimage32.c; + common = util/grub-mkimage64.c; common = util/grub-install-common.c; common = util/setup_bios.c; common = util/setup_sparc.c; @@ -632,6 +640,8 @@ program = { common = util/grub-mknetdir.c; common = util/mkimage.c; + common = util/grub-mkimage32.c; + common = util/grub-mkimage64.c; common = util/grub-install-common.c; common = util/setup_bios.c; common = util/setup_sparc.c; diff --git a/include/grub/util/mkimage.h b/include/grub/util/mkimage.h new file mode 100644 index 000000000..564adbce7 --- /dev/null +++ b/include/grub/util/mkimage.h @@ -0,0 +1,170 @@ +/* + * GRUB -- GRand Unified Bootloader + * Copyright (C) 2013 Free Software Foundation, Inc. + * + * GRUB is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GRUB is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GRUB. If not, see . + */ + +#ifndef GRUB_UTIL_MKIMAGE_HEADER +#define GRUB_UTIL_MKIMAGE_HEADER 1 + +/* Private header. Use only in mkimage-related sources. */ +char * +grub_mkimage_load_image32 (const char *kernel_path, size_t *exec_size, + size_t *kernel_sz, size_t *bss_size, + size_t total_module_size, grub_uint64_t *start, + void **reloc_section, size_t *reloc_size, + size_t *align, + const struct grub_install_image_target_desc *image_target); +char * +grub_mkimage_load_image64 (const char *kernel_path, size_t *exec_size, + size_t *kernel_sz, size_t *bss_size, + size_t total_module_size, grub_uint64_t *start, + void **reloc_section, size_t *reloc_size, + size_t *align, + const struct grub_install_image_target_desc *image_target); +void +grub_mkimage_generate_elf32 (const struct grub_install_image_target_desc *image_target, + int note, char **core_img, size_t *core_size, + Elf32_Addr target_addr, grub_size_t align, + size_t kernel_size, size_t bss_size); +void +grub_mkimage_generate_elf64 (const struct grub_install_image_target_desc *image_target, + int note, char **core_img, size_t *core_size, + Elf64_Addr target_addr, grub_size_t align, + size_t kernel_size, size_t bss_size); + +struct grub_install_image_target_desc +{ + const char *dirname; + const char *names[6]; + grub_size_t voidp_sizeof; + int bigendian; + enum { + IMAGE_I386_PC, IMAGE_EFI, IMAGE_COREBOOT, + IMAGE_SPARC64_AOUT, IMAGE_SPARC64_RAW, IMAGE_SPARC64_CDCORE, + IMAGE_I386_IEEE1275, + IMAGE_LOONGSON_ELF, IMAGE_QEMU, IMAGE_PPC, IMAGE_YEELOONG_FLASH, + IMAGE_FULOONG2F_FLASH, IMAGE_I386_PC_PXE, IMAGE_MIPS_ARC, + IMAGE_QEMU_MIPS_FLASH, IMAGE_UBOOT, IMAGE_XEN, IMAGE_I386_PC_ELTORITO + } id; + enum + { + PLATFORM_FLAGS_NONE = 0, + PLATFORM_FLAGS_DECOMPRESSORS = 2, + PLATFORM_FLAGS_MODULES_BEFORE_KERNEL = 4, + } flags; + unsigned total_module_size; + unsigned decompressor_compressed_size; + unsigned decompressor_uncompressed_size; + unsigned decompressor_uncompressed_addr; + unsigned link_align; + grub_uint16_t elf_target; + unsigned section_align; + signed vaddr_offset; + grub_uint64_t link_addr; + unsigned mod_gap, mod_align; + grub_compression_t default_compression; + grub_uint16_t pe_target; +}; + +#define grub_target_to_host32(x) (grub_target_to_host32_real (image_target, (x))) +#define grub_host_to_target32(x) (grub_host_to_target32_real (image_target, (x))) +#define grub_target_to_host64(x) (grub_target_to_host64_real (image_target, (x))) +#define grub_host_to_target64(x) (grub_host_to_target64_real (image_target, (x))) +#define grub_host_to_target_addr(x) (grub_host_to_target_addr_real (image_target, (x))) +#define grub_target_to_host16(x) (grub_target_to_host16_real (image_target, (x))) +#define grub_host_to_target16(x) (grub_host_to_target16_real (image_target, (x))) + +static inline grub_uint32_t +grub_target_to_host32_real (const struct grub_install_image_target_desc *image_target, + grub_uint32_t in) +{ + if (image_target->bigendian) + return grub_be_to_cpu32 (in); + else + return grub_le_to_cpu32 (in); +} + +static inline grub_uint64_t +grub_target_to_host64_real (const struct grub_install_image_target_desc *image_target, + grub_uint64_t in) +{ + if (image_target->bigendian) + return grub_be_to_cpu64 (in); + else + return grub_le_to_cpu64 (in); +} + +static inline grub_uint64_t +grub_host_to_target64_real (const struct grub_install_image_target_desc *image_target, + grub_uint64_t in) +{ + if (image_target->bigendian) + return grub_cpu_to_be64 (in); + else + return grub_cpu_to_le64 (in); +} + +static inline grub_uint32_t +grub_host_to_target32_real (const struct grub_install_image_target_desc *image_target, + grub_uint32_t in) +{ + if (image_target->bigendian) + return grub_cpu_to_be32 (in); + else + return grub_cpu_to_le32 (in); +} + +static inline grub_uint16_t +grub_target_to_host16_real (const struct grub_install_image_target_desc *image_target, + grub_uint16_t in) +{ + if (image_target->bigendian) + return grub_be_to_cpu16 (in); + else + return grub_le_to_cpu16 (in); +} + +static inline grub_uint16_t +grub_host_to_target16_real (const struct grub_install_image_target_desc *image_target, + grub_uint16_t in) +{ + if (image_target->bigendian) + return grub_cpu_to_be16 (in); + else + return grub_cpu_to_le16 (in); +} + +static inline grub_uint64_t +grub_host_to_target_addr_real (const struct grub_install_image_target_desc *image_target, grub_uint64_t in) +{ + if (image_target->voidp_sizeof == 8) + return grub_host_to_target64_real (image_target, in); + else + return grub_host_to_target32_real (image_target, in); +} + +static inline grub_uint64_t +grub_target_to_host_real (const struct grub_install_image_target_desc *image_target, grub_uint64_t in) +{ + if (image_target->voidp_sizeof == 8) + return grub_target_to_host64_real (image_target, in); + else + return grub_target_to_host32_real (image_target, in); +} + +#define grub_target_to_host(val) grub_target_to_host_real(image_target, (val)) + +#endif diff --git a/util/grub-mkimage32.c b/util/grub-mkimage32.c new file mode 100644 index 000000000..9b31397bc --- /dev/null +++ b/util/grub-mkimage32.c @@ -0,0 +1,22 @@ +#define MKIMAGE_ELF32 1 + +# define SUFFIX(x) x ## 32 +# define ELFCLASSXX ELFCLASS32 +# define Elf_Ehdr Elf32_Ehdr +# define Elf_Phdr Elf32_Phdr +# define Elf_Nhdr Elf32_Nhdr +# define Elf_Addr Elf32_Addr +# define Elf_Sym Elf32_Sym +# define Elf_Off Elf32_Off +# define Elf_Shdr Elf32_Shdr +# define Elf_Rela Elf32_Rela +# define Elf_Rel Elf32_Rel +# define Elf_Word Elf32_Word +# define Elf_Half Elf32_Half +# define Elf_Section Elf32_Section +# define ELF_R_SYM(val) ELF32_R_SYM(val) +# define ELF_R_TYPE(val) ELF32_R_TYPE(val) +# define ELF_ST_TYPE(val) ELF32_ST_TYPE(val) +#define XEN_NOTE_SIZE 132 + +#include "grub-mkimagexx.c" diff --git a/util/grub-mkimage64.c b/util/grub-mkimage64.c new file mode 100644 index 000000000..d83345924 --- /dev/null +++ b/util/grub-mkimage64.c @@ -0,0 +1,22 @@ +#define MKIMAGE_ELF64 1 + +# define SUFFIX(x) x ## 64 +# define ELFCLASSXX ELFCLASS64 +# define Elf_Ehdr Elf64_Ehdr +# define Elf_Phdr Elf64_Phdr +# define Elf_Nhdr Elf64_Nhdr +# define Elf_Addr Elf64_Addr +# define Elf_Sym Elf64_Sym +# define Elf_Off Elf64_Off +# define Elf_Shdr Elf64_Shdr +# define Elf_Rela Elf64_Rela +# define Elf_Rel Elf64_Rel +# define Elf_Word Elf64_Word +# define Elf_Half Elf64_Half +# define Elf_Section Elf64_Section +# define ELF_R_SYM(val) ELF64_R_SYM(val) +# define ELF_R_TYPE(val) ELF64_R_TYPE(val) +# define ELF_ST_TYPE(val) ELF64_ST_TYPE(val) +#define XEN_NOTE_SIZE 120 + +#include "grub-mkimagexx.c" diff --git a/util/grub-mkimagexx.c b/util/grub-mkimagexx.c index 06b6a724d..03874be57 100644 --- a/util/grub-mkimagexx.c +++ b/util/grub-mkimagexx.c @@ -17,58 +17,172 @@ * along with GRUB. If not, see . */ -#undef ELF_R_SYM -#undef ELF_R_TYPE +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include -#if defined(MKIMAGE_ELF32) -# define SUFFIX(x) x ## 32 -# define ELFCLASSXX ELFCLASS32 -# define Elf_Ehdr Elf32_Ehdr -# define Elf_Phdr Elf32_Phdr -# define Elf_Nhdr Elf32_Nhdr -# define Elf_Addr Elf32_Addr -# define Elf_Sym Elf32_Sym -# define Elf_Off Elf32_Off -# define Elf_Shdr Elf32_Shdr -# define Elf_Rela Elf32_Rela -# define Elf_Rel Elf32_Rel -# define Elf_Word Elf32_Word -# define Elf_Half Elf32_Half -# define Elf_Section Elf32_Section -# define ELF_R_SYM(val) ELF32_R_SYM(val) -# define ELF_R_TYPE(val) ELF32_R_TYPE(val) -# define ELF_ST_TYPE(val) ELF32_ST_TYPE(val) -#define XEN_NOTE_SIZE 132 -#elif defined(MKIMAGE_ELF64) -# define SUFFIX(x) x ## 64 -# define ELFCLASSXX ELFCLASS64 -# define Elf_Ehdr Elf64_Ehdr -# define Elf_Phdr Elf64_Phdr -# define Elf_Nhdr Elf64_Nhdr -# define Elf_Addr Elf64_Addr -# define Elf_Sym Elf64_Sym -# define Elf_Off Elf64_Off -# define Elf_Shdr Elf64_Shdr -# define Elf_Rela Elf64_Rela -# define Elf_Rel Elf64_Rel -# define Elf_Word Elf64_Word -# define Elf_Half Elf64_Half -# define Elf_Section Elf64_Section -# define ELF_R_SYM(val) ELF64_R_SYM(val) -# define ELF_R_TYPE(val) ELF64_R_TYPE(val) -# define ELF_ST_TYPE(val) ELF64_ST_TYPE(val) -#define XEN_NOTE_SIZE 120 -#else -#error "I'm confused" -#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#pragma GCC diagnostic ignored "-Wcast-align" static Elf_Addr SUFFIX (entry_point); -static void -SUFFIX (generate_elf) (const struct grub_install_image_target_desc *image_target, - int note, char **core_img, size_t *core_size, - Elf_Addr target_addr, grub_size_t align, - size_t kernel_size, size_t bss_size) +/* These structures are defined according to the CHRP binding to IEEE1275, + "Client Program Format" section. */ + +struct grub_ieee1275_note_desc +{ + grub_uint32_t real_mode; + grub_uint32_t real_base; + grub_uint32_t real_size; + grub_uint32_t virt_base; + grub_uint32_t virt_size; + grub_uint32_t load_base; +}; + +#define GRUB_IEEE1275_NOTE_NAME "PowerPC" +#define GRUB_IEEE1275_NOTE_TYPE 0x1275 + +struct grub_ieee1275_note +{ + Elf32_Nhdr header; + char name[ALIGN_UP(sizeof (GRUB_IEEE1275_NOTE_NAME), 4)]; + struct grub_ieee1275_note_desc descriptor; +}; + +#define GRUB_XEN_NOTE_NAME "Xen" + +struct fixup_block_list +{ + struct fixup_block_list *next; + int state; + struct grub_pe32_fixup_block b; +}; + +#define ALIGN_ADDR(x) (ALIGN_UP((x), image_target->voidp_sizeof)) + +#ifdef MKIMAGE_ELF32 + +/* + * R_ARM_THM_CALL/THM_JUMP24 + * + * Relocate Thumb (T32) instruction set relative branches: + * B.W, BL and BLX + */ +static grub_err_t +grub_arm_reloc_thm_call (grub_uint16_t *target, Elf32_Addr sym_addr) +{ + grub_int32_t offset; + + offset = grub_arm_thm_call_get_offset (target); + + grub_dprintf ("dl", " sym_addr = 0x%08x", sym_addr); + + offset += sym_addr; + + grub_dprintf("dl", " BL*: target=%p, sym_addr=0x%08x, offset=%d\n", + target, sym_addr, offset); + + /* Keep traditional (pre-Thumb2) limits on blx. In any case if the kernel + is bigger than 2M (currently under 150K) then we probably have a problem + somewhere else. */ + if (offset < -0x200000 || offset >= 0x200000) + return grub_error (GRUB_ERR_BAD_MODULE, + "THM_CALL Relocation out of range."); + + grub_dprintf ("dl", " relative destination = %p", + (char *) target + offset); + + return grub_arm_thm_call_set_offset (target, offset); +} + +/* + * R_ARM_THM_JUMP19 + * + * Relocate conditional Thumb (T32) B.W + */ +static grub_err_t +grub_arm_reloc_thm_jump19 (grub_uint16_t *target, Elf32_Addr sym_addr) +{ + grub_int32_t offset; + + if (!(sym_addr & 1)) + return grub_error (GRUB_ERR_BAD_MODULE, + "Relocation targeting wrong execution state"); + + offset = grub_arm_thm_jump19_get_offset (target); + + /* Adjust and re-truncate offset */ + offset += sym_addr; + + if (!grub_arm_thm_jump19_check_offset (offset)) + return grub_error (GRUB_ERR_BAD_MODULE, + "THM_JUMP19 Relocation out of range."); + + grub_arm_thm_jump19_set_offset (target, offset); + + return GRUB_ERR_NONE; +} + +/* + * R_ARM_JUMP24 + * + * Relocate ARM (A32) B + */ +static grub_err_t +grub_arm_reloc_jump24 (grub_uint32_t *target, Elf32_Addr sym_addr) +{ + grub_int32_t offset; + + if (sym_addr & 1) + return grub_error (GRUB_ERR_BAD_MODULE, + "Relocation targeting wrong execution state"); + + offset = grub_arm_jump24_get_offset (target); + offset += sym_addr; + + if (!grub_arm_jump24_check_offset (offset)) + return grub_error (GRUB_ERR_BAD_MODULE, + "JUMP24 Relocation out of range."); + + + grub_arm_jump24_set_offset (target, offset); + + return GRUB_ERR_NONE; +} + +#endif + +void +SUFFIX (grub_mkimage_generate_elf) (const struct grub_install_image_target_desc *image_target, + int note, char **core_img, size_t *core_size, + Elf_Addr target_addr, grub_size_t align, + size_t kernel_size, size_t bss_size) { char *elf_img; size_t program_size; @@ -1457,13 +1571,13 @@ SUFFIX (locate_sections) (const char *kernel_path, return section_addresses; } -static char * -SUFFIX (load_image) (const char *kernel_path, size_t *exec_size, - size_t *kernel_sz, size_t *bss_size, - size_t total_module_size, grub_uint64_t *start, - void **reloc_section, size_t *reloc_size, - size_t *align, - const struct grub_install_image_target_desc *image_target) +char * +SUFFIX (grub_mkimage_load_image) (const char *kernel_path, size_t *exec_size, + size_t *kernel_sz, size_t *bss_size, + size_t total_module_size, grub_uint64_t *start, + void **reloc_section, size_t *reloc_size, + size_t *align, + const struct grub_install_image_target_desc *image_target) { char *kernel_img, *out_img; const char *strtab; @@ -1671,23 +1785,3 @@ SUFFIX (load_image) (const char *kernel_path, size_t *exec_size, return out_img; } - - -#undef SUFFIX -#undef ELFCLASSXX -#undef Elf_Ehdr -#undef Elf_Phdr -#undef Elf_Nhdr -#undef Elf_Shdr -#undef Elf_Addr -#undef Elf_Sym -#undef Elf_Off -#undef Elf_Rela -#undef Elf_Rel -#undef ELF_R_TYPE -#undef ELF_R_SYM -#undef Elf_Word -#undef Elf_Half -#undef Elf_Section -#undef ELF_ST_TYPE -#undef XEN_NOTE_SIZE diff --git a/util/mkimage.c b/util/mkimage.c index c3365bbbd..86bb78190 100644 --- a/util/mkimage.c +++ b/util/mkimage.c @@ -46,6 +46,7 @@ #include #include #include +#include #define ALIGN_ADDR(x) (ALIGN_UP((x), image_target->voidp_sizeof)) @@ -53,45 +54,13 @@ #include #endif +#pragma GCC diagnostic ignored "-Wcast-align" + #define TARGET_NO_FIELD 0xffffffff /* use 2015-01-01T00:00:00+0000 as a stock timestamp */ #define STABLE_EMBEDDING_TIMESTAMP 1420070400 -struct grub_install_image_target_desc -{ - const char *dirname; - const char *names[6]; - grub_size_t voidp_sizeof; - int bigendian; - enum { - IMAGE_I386_PC, IMAGE_EFI, IMAGE_COREBOOT, - IMAGE_SPARC64_AOUT, IMAGE_SPARC64_RAW, IMAGE_SPARC64_CDCORE, - IMAGE_I386_IEEE1275, - IMAGE_LOONGSON_ELF, IMAGE_QEMU, IMAGE_PPC, IMAGE_YEELOONG_FLASH, - IMAGE_FULOONG2F_FLASH, IMAGE_I386_PC_PXE, IMAGE_MIPS_ARC, - IMAGE_QEMU_MIPS_FLASH, IMAGE_UBOOT, IMAGE_XEN, IMAGE_I386_PC_ELTORITO - } id; - enum - { - PLATFORM_FLAGS_NONE = 0, - PLATFORM_FLAGS_DECOMPRESSORS = 2, - PLATFORM_FLAGS_MODULES_BEFORE_KERNEL = 4, - } flags; - unsigned total_module_size; - unsigned decompressor_compressed_size; - unsigned decompressor_uncompressed_size; - unsigned decompressor_uncompressed_addr; - unsigned link_align; - grub_uint16_t elf_target; - unsigned section_align; - signed vaddr_offset; - grub_uint64_t link_addr; - unsigned mod_gap, mod_align; - grub_compression_t default_compression; - grub_uint16_t pe_target; -}; - #define EFI32_HEADER_SIZE ALIGN_UP (GRUB_PE32_MSDOS_STUB_SIZE \ + GRUB_PE32_SIGNATURE_SIZE \ + sizeof (struct grub_pe32_coff_header) \ @@ -603,119 +572,6 @@ static const struct grub_install_image_target_desc image_targets[] = }, }; -#define grub_target_to_host32(x) (grub_target_to_host32_real (image_target, (x))) -#define grub_host_to_target32(x) (grub_host_to_target32_real (image_target, (x))) -#define grub_target_to_host64(x) (grub_target_to_host64_real (image_target, (x))) -#define grub_host_to_target64(x) (grub_host_to_target64_real (image_target, (x))) -#define grub_host_to_target_addr(x) (grub_host_to_target_addr_real (image_target, (x))) -#define grub_target_to_host16(x) (grub_target_to_host16_real (image_target, (x))) -#define grub_host_to_target16(x) (grub_host_to_target16_real (image_target, (x))) - -static inline grub_uint32_t -grub_target_to_host32_real (const struct grub_install_image_target_desc *image_target, - grub_uint32_t in) -{ - if (image_target->bigendian) - return grub_be_to_cpu32 (in); - else - return grub_le_to_cpu32 (in); -} - -static inline grub_uint64_t -grub_target_to_host64_real (const struct grub_install_image_target_desc *image_target, - grub_uint64_t in) -{ - if (image_target->bigendian) - return grub_be_to_cpu64 (in); - else - return grub_le_to_cpu64 (in); -} - -static inline grub_uint64_t -grub_host_to_target64_real (const struct grub_install_image_target_desc *image_target, - grub_uint64_t in) -{ - if (image_target->bigendian) - return grub_cpu_to_be64 (in); - else - return grub_cpu_to_le64 (in); -} - -static inline grub_uint32_t -grub_host_to_target32_real (const struct grub_install_image_target_desc *image_target, - grub_uint32_t in) -{ - if (image_target->bigendian) - return grub_cpu_to_be32 (in); - else - return grub_cpu_to_le32 (in); -} - -static inline grub_uint16_t -grub_target_to_host16_real (const struct grub_install_image_target_desc *image_target, - grub_uint16_t in) -{ - if (image_target->bigendian) - return grub_be_to_cpu16 (in); - else - return grub_le_to_cpu16 (in); -} - -static inline grub_uint16_t -grub_host_to_target16_real (const struct grub_install_image_target_desc *image_target, - grub_uint16_t in) -{ - if (image_target->bigendian) - return grub_cpu_to_be16 (in); - else - return grub_cpu_to_le16 (in); -} - -static inline grub_uint64_t -grub_host_to_target_addr_real (const struct grub_install_image_target_desc *image_target, grub_uint64_t in) -{ - if (image_target->voidp_sizeof == 8) - return grub_host_to_target64_real (image_target, in); - else - return grub_host_to_target32_real (image_target, in); -} - -static inline grub_uint64_t -grub_target_to_host_real (const struct grub_install_image_target_desc *image_target, grub_uint64_t in) -{ - if (image_target->voidp_sizeof == 8) - return grub_target_to_host64_real (image_target, in); - else - return grub_target_to_host32_real (image_target, in); -} - -#define GRUB_IEEE1275_NOTE_NAME "PowerPC" -#define GRUB_IEEE1275_NOTE_TYPE 0x1275 - -/* These structures are defined according to the CHRP binding to IEEE1275, - "Client Program Format" section. */ - -struct grub_ieee1275_note_desc -{ - grub_uint32_t real_mode; - grub_uint32_t real_base; - grub_uint32_t real_size; - grub_uint32_t virt_base; - grub_uint32_t virt_size; - grub_uint32_t load_base; -}; - -struct grub_ieee1275_note -{ - Elf32_Nhdr header; - char name[ALIGN_UP(sizeof (GRUB_IEEE1275_NOTE_NAME), 4)]; - struct grub_ieee1275_note_desc descriptor; -}; - -#define GRUB_XEN_NOTE_NAME "Xen" - -#define grub_target_to_host(val) grub_target_to_host_real(image_target, (val)) - #include static void *SzAlloc(void *p __attribute__ ((unused)), size_t size) { return xmalloc(size); } @@ -830,111 +686,6 @@ compress_kernel (const struct grub_install_image_target_desc *image_target, char *core_size = kernel_size; } -struct fixup_block_list -{ - struct fixup_block_list *next; - int state; - struct grub_pe32_fixup_block b; -}; - -/* - * R_ARM_THM_CALL/THM_JUMP24 - * - * Relocate Thumb (T32) instruction set relative branches: - * B.W, BL and BLX - */ -static grub_err_t -grub_arm_reloc_thm_call (grub_uint16_t *target, Elf32_Addr sym_addr) -{ - grub_int32_t offset; - - offset = grub_arm_thm_call_get_offset (target); - - grub_dprintf ("dl", " sym_addr = 0x%08x", sym_addr); - - offset += sym_addr; - - grub_dprintf("dl", " BL*: target=%p, sym_addr=0x%08x, offset=%d\n", - target, sym_addr, offset); - - /* Keep traditional (pre-Thumb2) limits on blx. In any case if the kernel - is bigger than 2M (currently under 150K) then we probably have a problem - somewhere else. */ - if (offset < -0x200000 || offset >= 0x200000) - return grub_error (GRUB_ERR_BAD_MODULE, - "THM_CALL Relocation out of range."); - - grub_dprintf ("dl", " relative destination = %p", - (char *) target + offset); - - return grub_arm_thm_call_set_offset (target, offset); -} - -/* - * R_ARM_THM_JUMP19 - * - * Relocate conditional Thumb (T32) B.W - */ -static grub_err_t -grub_arm_reloc_thm_jump19 (grub_uint16_t *target, Elf32_Addr sym_addr) -{ - grub_int32_t offset; - - if (!(sym_addr & 1)) - return grub_error (GRUB_ERR_BAD_MODULE, - "Relocation targeting wrong execution state"); - - offset = grub_arm_thm_jump19_get_offset (target); - - /* Adjust and re-truncate offset */ - offset += sym_addr; - - if (!grub_arm_thm_jump19_check_offset (offset)) - return grub_error (GRUB_ERR_BAD_MODULE, - "THM_JUMP19 Relocation out of range."); - - grub_arm_thm_jump19_set_offset (target, offset); - - return GRUB_ERR_NONE; -} - -/* - * R_ARM_JUMP24 - * - * Relocate ARM (A32) B - */ -static grub_err_t -grub_arm_reloc_jump24 (grub_uint32_t *target, Elf32_Addr sym_addr) -{ - grub_int32_t offset; - - if (sym_addr & 1) - return grub_error (GRUB_ERR_BAD_MODULE, - "Relocation targeting wrong execution state"); - - offset = grub_arm_jump24_get_offset (target); - offset += sym_addr; - - if (!grub_arm_jump24_check_offset (offset)) - return grub_error (GRUB_ERR_BAD_MODULE, - "JUMP24 Relocation out of range."); - - - grub_arm_jump24_set_offset (target, offset); - - return GRUB_ERR_NONE; -} - -#pragma GCC diagnostic ignored "-Wcast-align" - -#define MKIMAGE_ELF32 1 -#include "grub-mkimagexx.c" -#undef MKIMAGE_ELF32 - -#define MKIMAGE_ELF64 1 -#include "grub-mkimagexx.c" -#undef MKIMAGE_ELF64 - const struct grub_install_image_target_desc * grub_install_get_image_target (const char *arg) { @@ -1063,13 +814,13 @@ grub_install_generate_image (const char *dir, const char *prefix, (unsigned long long) total_module_size); if (image_target->voidp_sizeof == 4) - kernel_img = load_image32 (kernel_path, &exec_size, &kernel_size, &bss_size, - total_module_size, &start_address, &rel_section, - &reloc_size, &align, image_target); + kernel_img = grub_mkimage_load_image32 (kernel_path, &exec_size, &kernel_size, &bss_size, + total_module_size, &start_address, &rel_section, + &reloc_size, &align, image_target); else - kernel_img = load_image64 (kernel_path, &exec_size, &kernel_size, &bss_size, - total_module_size, &start_address, &rel_section, - &reloc_size, &align, image_target); + kernel_img = grub_mkimage_load_image64 (kernel_path, &exec_size, &kernel_size, &bss_size, + total_module_size, &start_address, &rel_section, + &reloc_size, &align, image_target); if (image_target->id == IMAGE_XEN && align < 4096) align = 4096; @@ -1890,11 +1641,11 @@ grub_install_generate_image (const char *dir, const char *prefix, else target_addr = image_target->link_addr; if (image_target->voidp_sizeof == 4) - generate_elf32 (image_target, note, &core_img, &core_size, - target_addr, align, kernel_size, bss_size); + grub_mkimage_generate_elf32 (image_target, note, &core_img, &core_size, + target_addr, align, kernel_size, bss_size); else - generate_elf64 (image_target, note, &core_img, &core_size, - target_addr, align, kernel_size, bss_size); + grub_mkimage_generate_elf64 (image_target, note, &core_img, &core_size, + target_addr, align, kernel_size, bss_size); } break; } From dd3969e7ec3a09bb4625aef5a852d4ffcf04b639 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Thu, 18 Feb 2016 20:54:37 +0100 Subject: [PATCH 713/722] mkimagexx: Split PE and generic part for relocations. As a preparation for U-Boot relocations, split emitting PE-relocations from parsing source ELF-relocations. --- util/grub-mkimagexx.c | 415 ++++++++++++++++++++++-------------------- 1 file changed, 219 insertions(+), 196 deletions(-) diff --git a/util/grub-mkimagexx.c b/util/grub-mkimagexx.c index 03874be57..a39803a06 100644 --- a/util/grub-mkimagexx.c +++ b/util/grub-mkimagexx.c @@ -1095,9 +1095,9 @@ SUFFIX (relocate_addresses) (Elf_Ehdr *e, Elf_Shdr *sections, /* Add a PE32's fixup entry for a relocation. Return the resulting address after having written to the file OUT. */ static Elf_Addr -SUFFIX (add_fixup_entry) (struct fixup_block_list **cblock, grub_uint16_t type, - Elf_Addr addr, int flush, Elf_Addr current_address, - const struct grub_install_image_target_desc *image_target) +add_fixup_entry (struct fixup_block_list **cblock, grub_uint16_t type, + Elf_Addr addr, int flush, Elf_Addr current_address, + const struct grub_install_image_target_desc *image_target) { struct grub_pe32_fixup_block *b; @@ -1187,22 +1187,222 @@ SUFFIX (add_fixup_entry) (struct fixup_block_list **cblock, grub_uint16_t type, return current_address; } +struct translate_context +{ + struct fixup_block_list *lst, *lst0; + Elf_Addr current_address; +}; + +static void +translate_reloc_start (struct translate_context *ctx) +{ + ctx->lst = ctx->lst0 = xmalloc (sizeof (*ctx->lst) + 2 * 0x1000); + memset (ctx->lst, 0, sizeof (*ctx->lst) + 2 * 0x1000); + ctx->current_address = 0; +} + +static void +translate_relocation (struct translate_context *ctx, + Elf_Addr addr, + Elf_Addr info, + const struct grub_install_image_target_desc *image_target) +{ + /* Necessary to relocate only absolute addresses. */ + switch (image_target->elf_target) + { + case EM_386: + if (ELF_R_TYPE (info) == R_386_32) + { + grub_util_info ("adding a relocation entry for 0x%" + GRUB_HOST_PRIxLONG_LONG, + (unsigned long long) addr); + ctx->current_address + = add_fixup_entry (&ctx->lst, + GRUB_PE32_REL_BASED_HIGHLOW, + addr, 0, ctx->current_address, + image_target); + } + break; + case EM_X86_64: + if ((ELF_R_TYPE (info) == R_X86_64_32) || + (ELF_R_TYPE (info) == R_X86_64_32S)) + { + grub_util_error ("can\'t add fixup entry for R_X86_64_32(S)"); + } + else if (ELF_R_TYPE (info) == R_X86_64_64) + { + grub_util_info ("adding a relocation entry for 0x%" + GRUB_HOST_PRIxLONG_LONG, + (unsigned long long) addr); + ctx->current_address + = add_fixup_entry (&ctx->lst, + GRUB_PE32_REL_BASED_DIR64, + addr, + 0, ctx->current_address, + image_target); + } + break; + case EM_IA_64: + switch (ELF_R_TYPE (info)) + { + case R_IA64_PCREL64LSB: + case R_IA64_LDXMOV: + case R_IA64_PCREL21B: + case R_IA64_LTOFF_FPTR22: + case R_IA64_LTOFF22X: + case R_IA64_LTOFF22: + case R_IA64_GPREL22: + case R_IA64_SEGREL64LSB: + break; + + case R_IA64_FPTR64LSB: + case R_IA64_DIR64LSB: +#if 1 + { + grub_util_info ("adding a relocation entry for 0x%" + GRUB_HOST_PRIxLONG_LONG, + (unsigned long long) addr); + ctx->current_address + = add_fixup_entry (&ctx->lst, + GRUB_PE32_REL_BASED_DIR64, + addr, + 0, ctx->current_address, + image_target); + } +#endif + break; + default: + grub_util_error (_("relocation 0x%x is not implemented yet"), + (unsigned int) ELF_R_TYPE (info)); + break; + } + break; + case EM_AARCH64: + switch (ELF_R_TYPE (info)) + { + case R_AARCH64_ABS64: + { + ctx->current_address + = add_fixup_entry (&ctx->lst, + GRUB_PE32_REL_BASED_DIR64, + addr, 0, ctx->current_address, + image_target); + } + break; + /* Relative relocations do not require fixup entries. */ + case R_AARCH64_CALL26: + case R_AARCH64_JUMP26: + break; + /* Page-relative relocations do not require fixup entries. */ + case R_AARCH64_ADR_PREL_PG_HI21: + /* We page-align the whole kernel, so no need + for fixup entries. + */ + case R_AARCH64_ADD_ABS_LO12_NC: + case R_AARCH64_LDST64_ABS_LO12_NC: + break; + + default: + grub_util_error (_("relocation 0x%x is not implemented yet"), + (unsigned int) ELF_R_TYPE (info)); + break; + } + break; + break; +#if defined(MKIMAGE_ELF32) + case EM_ARM: + switch (ELF_R_TYPE (info)) + { + case R_ARM_V4BX: + /* Relative relocations do not require fixup entries. */ + case R_ARM_JUMP24: + case R_ARM_THM_CALL: + case R_ARM_THM_JUMP19: + case R_ARM_THM_JUMP24: + case R_ARM_CALL: + { + grub_util_info (" %s: not adding fixup: 0x%08x : 0x%08x", __FUNCTION__, (unsigned int) addr, (unsigned int) ctx->current_address); + } + break; + /* Create fixup entry for PE/COFF loader */ + case R_ARM_ABS32: + { + ctx->current_address + = add_fixup_entry (&ctx->lst, + GRUB_PE32_REL_BASED_HIGHLOW, + addr, 0, ctx->current_address, + image_target); + } + break; + default: + grub_util_error (_("relocation 0x%x is not implemented yet"), + (unsigned int) ELF_R_TYPE (info)); + break; + } + break; +#endif /* defined(MKIMAGE_ELF32) */ + default: + grub_util_error ("unknown machine type 0x%x", image_target->elf_target); + } +} + +static Elf_Addr +finish_reloc_translation (struct translate_context *ctx, void **out, + const struct grub_install_image_target_desc *image_target) +{ + ctx->current_address = add_fixup_entry (&ctx->lst, 0, 0, 1, ctx->current_address, image_target); + + { + grub_uint8_t *ptr; + ptr = *out = xmalloc (ctx->current_address); + for (ctx->lst = ctx->lst0; ctx->lst; ctx->lst = ctx->lst->next) + if (ctx->lst->state) + { + memcpy (ptr, &ctx->lst->b, grub_target_to_host32 (ctx->lst->b.block_size)); + ptr += grub_target_to_host32 (ctx->lst->b.block_size); + } + assert ((ctx->current_address + (grub_uint8_t *) *out) == ptr); + } + + for (ctx->lst = ctx->lst0; ctx->lst; ) + { + struct fixup_block_list *next; + next = ctx->lst->next; + free (ctx->lst); + ctx->lst = next; + } + + return ctx->current_address; +} + +static void +translate_reloc_jumpers (struct translate_context *ctx, + Elf_Addr jumpers, grub_size_t njumpers, + const struct grub_install_image_target_desc *image_target) +{ + unsigned i; + for (i = 0; i < njumpers; i++) + ctx->current_address = add_fixup_entry (&ctx->lst, + GRUB_PE32_REL_BASED_DIR64, + jumpers + 8 * i, + 0, ctx->current_address, + image_target); +} + /* Make a .reloc section. */ static Elf_Addr -SUFFIX (make_reloc_section) (Elf_Ehdr *e, void **out, - Elf_Addr *section_addresses, Elf_Shdr *sections, - Elf_Half section_entsize, Elf_Half num_sections, - const char *strtab, - Elf_Addr jumpers, grub_size_t njumpers, - const struct grub_install_image_target_desc *image_target) +make_reloc_section (Elf_Ehdr *e, void **out, + Elf_Addr *section_addresses, Elf_Shdr *sections, + Elf_Half section_entsize, Elf_Half num_sections, + const char *strtab, + Elf_Addr jumpers, grub_size_t njumpers, + const struct grub_install_image_target_desc *image_target) { unsigned i; Elf_Shdr *s; - struct fixup_block_list *lst, *lst0; - Elf_Addr current_address = 0; + struct translate_context ctx; - lst = lst0 = xmalloc (sizeof (*lst) + 2 * 0x1000); - memset (lst, 0, sizeof (*lst) + 2 * 0x1000); + translate_reloc_start (&ctx); for (i = 0, s = sections; i < num_sections; i++, s = (Elf_Shdr *) ((char *) s + section_entsize)) @@ -1231,199 +1431,22 @@ SUFFIX (make_reloc_section) (Elf_Ehdr *e, void **out, { Elf_Addr info; Elf_Addr offset; + Elf_Addr addr; offset = grub_target_to_host (r->r_offset); info = grub_target_to_host (r->r_info); - /* Necessary to relocate only absolute addresses. */ - switch (image_target->elf_target) - { - case EM_386: - if (ELF_R_TYPE (info) == R_386_32) - { - Elf_Addr addr; + addr = section_address + offset; - addr = section_address + offset; - grub_util_info ("adding a relocation entry for 0x%" - GRUB_HOST_PRIxLONG_LONG, - (unsigned long long) addr); - current_address - = SUFFIX (add_fixup_entry) (&lst, - GRUB_PE32_REL_BASED_HIGHLOW, - addr, 0, current_address, - image_target); - } - break; - case EM_X86_64: - if ((ELF_R_TYPE (info) == R_X86_64_32) || - (ELF_R_TYPE (info) == R_X86_64_32S)) - { - grub_util_error ("can\'t add fixup entry for R_X86_64_32(S)"); - } - else if (ELF_R_TYPE (info) == R_X86_64_64) - { - Elf_Addr addr; - - addr = section_address + offset; - grub_util_info ("adding a relocation entry for 0x%" - GRUB_HOST_PRIxLONG_LONG, - (unsigned long long) addr); - current_address - = SUFFIX (add_fixup_entry) (&lst, - GRUB_PE32_REL_BASED_DIR64, - addr, - 0, current_address, - image_target); - } - break; - case EM_IA_64: - switch (ELF_R_TYPE (info)) - { - case R_IA64_PCREL64LSB: - case R_IA64_LDXMOV: - case R_IA64_PCREL21B: - case R_IA64_LTOFF_FPTR22: - case R_IA64_LTOFF22X: - case R_IA64_LTOFF22: - case R_IA64_GPREL22: - case R_IA64_SEGREL64LSB: - break; - - case R_IA64_FPTR64LSB: - case R_IA64_DIR64LSB: -#if 1 - { - Elf_Addr addr; - - addr = section_address + offset; - grub_util_info ("adding a relocation entry for 0x%" - GRUB_HOST_PRIxLONG_LONG, - (unsigned long long) addr); - current_address - = SUFFIX (add_fixup_entry) (&lst, - GRUB_PE32_REL_BASED_DIR64, - addr, - 0, current_address, - image_target); - } -#endif - break; - default: - grub_util_error (_("relocation 0x%x is not implemented yet"), - (unsigned int) ELF_R_TYPE (info)); - break; - } - break; - case EM_AARCH64: - switch (ELF_R_TYPE (info)) - { - case R_AARCH64_ABS64: - { - Elf_Addr addr; - - addr = section_address + offset; - current_address - = SUFFIX (add_fixup_entry) (&lst, - GRUB_PE32_REL_BASED_DIR64, - addr, 0, current_address, - image_target); - } - break; - /* Relative relocations do not require fixup entries. */ - case R_AARCH64_CALL26: - case R_AARCH64_JUMP26: - break; - /* Page-relative relocations do not require fixup entries. */ - case R_AARCH64_ADR_PREL_PG_HI21: - /* We page-align the whole kernel, so no need - for fixup entries. - */ - case R_AARCH64_ADD_ABS_LO12_NC: - case R_AARCH64_LDST64_ABS_LO12_NC: - break; - - default: - grub_util_error (_("relocation 0x%x is not implemented yet"), - (unsigned int) ELF_R_TYPE (info)); - break; - } - break; - break; -#if defined(MKIMAGE_ELF32) - case EM_ARM: - switch (ELF_R_TYPE (info)) - { - case R_ARM_V4BX: - /* Relative relocations do not require fixup entries. */ - case R_ARM_JUMP24: - case R_ARM_THM_CALL: - case R_ARM_THM_JUMP19: - case R_ARM_THM_JUMP24: - case R_ARM_CALL: - { - Elf_Addr addr; - - addr = section_address + offset; - grub_util_info (" %s: not adding fixup: 0x%08x : 0x%08x", __FUNCTION__, (unsigned int) addr, (unsigned int) current_address); - } - break; - /* Create fixup entry for PE/COFF loader */ - case R_ARM_ABS32: - { - Elf_Addr addr; - - addr = section_address + offset; - current_address - = SUFFIX (add_fixup_entry) (&lst, - GRUB_PE32_REL_BASED_HIGHLOW, - addr, 0, current_address, - image_target); - } - break; - default: - grub_util_error (_("relocation 0x%x is not implemented yet"), - (unsigned int) ELF_R_TYPE (info)); - break; - } - break; -#endif /* defined(MKIMAGE_ELF32) */ - default: - grub_util_error ("unknown machine type 0x%x", image_target->elf_target); - } + translate_relocation (&ctx, addr, info, image_target); } } if (image_target->elf_target == EM_IA_64) - for (i = 0; i < njumpers; i++) - current_address = SUFFIX (add_fixup_entry) (&lst, - GRUB_PE32_REL_BASED_DIR64, - jumpers + 8 * i, - 0, current_address, - image_target); + translate_reloc_jumpers (&ctx, jumpers, njumpers, + image_target); - current_address = SUFFIX (add_fixup_entry) (&lst, 0, 0, 1, current_address, image_target); - - { - grub_uint8_t *ptr; - ptr = *out = xmalloc (current_address); - for (lst = lst0; lst; lst = lst->next) - if (lst->state) - { - memcpy (ptr, &lst->b, grub_target_to_host32 (lst->b.block_size)); - ptr += grub_target_to_host32 (lst->b.block_size); - } - assert ((current_address + (grub_uint8_t *) *out) == ptr); - } - - for (lst = lst0; lst; ) - { - struct fixup_block_list *next; - next = lst->next; - free (lst); - lst = next; - } - - return current_address; + return finish_reloc_translation (&ctx, out, image_target); } /* Determine if this section is a text section. Return false if this From 73a9c742fe15ab62b3a828f6600556b142f71f93 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 19 Feb 2016 01:49:53 +0100 Subject: [PATCH 714/722] Encapsulate image layout into a separate structure. Currently we pass around a lot of pointer. Instead put all relevant data into one structure. --- include/grub/util/mkimage.h | 32 ++++++---- util/grub-mkimagexx.c | 116 ++++++++++++++++++------------------ util/mkimage.c | 112 +++++++++++++++++----------------- 3 files changed, 133 insertions(+), 127 deletions(-) diff --git a/include/grub/util/mkimage.h b/include/grub/util/mkimage.h index 564adbce7..8169939a7 100644 --- a/include/grub/util/mkimage.h +++ b/include/grub/util/mkimage.h @@ -19,20 +19,32 @@ #ifndef GRUB_UTIL_MKIMAGE_HEADER #define GRUB_UTIL_MKIMAGE_HEADER 1 +struct grub_mkimage_layout +{ + size_t exec_size; + size_t kernel_size; + size_t bss_size; + grub_uint64_t start_address; + void *reloc_section; + size_t reloc_size; + size_t align; + grub_size_t ia64jmp_off; + grub_size_t tramp_off; + grub_size_t ia64_got_off; + grub_size_t got_size; + unsigned ia64jmpnum; +}; + /* Private header. Use only in mkimage-related sources. */ char * -grub_mkimage_load_image32 (const char *kernel_path, size_t *exec_size, - size_t *kernel_sz, size_t *bss_size, - size_t total_module_size, grub_uint64_t *start, - void **reloc_section, size_t *reloc_size, - size_t *align, +grub_mkimage_load_image32 (const char *kernel_path, + size_t total_module_size, + struct grub_mkimage_layout *layout, const struct grub_install_image_target_desc *image_target); char * -grub_mkimage_load_image64 (const char *kernel_path, size_t *exec_size, - size_t *kernel_sz, size_t *bss_size, - size_t total_module_size, grub_uint64_t *start, - void **reloc_section, size_t *reloc_size, - size_t *align, +grub_mkimage_load_image64 (const char *kernel_path, + size_t total_module_size, + struct grub_mkimage_layout *layout, const struct grub_install_image_target_desc *image_target); void grub_mkimage_generate_elf32 (const struct grub_install_image_target_desc *image_target, diff --git a/util/grub-mkimagexx.c b/util/grub-mkimagexx.c index a39803a06..74f86f5df 100644 --- a/util/grub-mkimagexx.c +++ b/util/grub-mkimagexx.c @@ -1346,22 +1346,23 @@ translate_relocation (struct translate_context *ctx, } } -static Elf_Addr -finish_reloc_translation (struct translate_context *ctx, void **out, +static void +finish_reloc_translation (struct translate_context *ctx, + struct grub_mkimage_layout *layout, const struct grub_install_image_target_desc *image_target) { ctx->current_address = add_fixup_entry (&ctx->lst, 0, 0, 1, ctx->current_address, image_target); { grub_uint8_t *ptr; - ptr = *out = xmalloc (ctx->current_address); + layout->reloc_section = ptr = xmalloc (ctx->current_address); for (ctx->lst = ctx->lst0; ctx->lst; ctx->lst = ctx->lst->next) if (ctx->lst->state) { memcpy (ptr, &ctx->lst->b, grub_target_to_host32 (ctx->lst->b.block_size)); ptr += grub_target_to_host32 (ctx->lst->b.block_size); } - assert ((ctx->current_address + (grub_uint8_t *) *out) == ptr); + assert ((ctx->current_address + (grub_uint8_t *) layout->reloc_section) == ptr); } for (ctx->lst = ctx->lst0; ctx->lst; ) @@ -1372,7 +1373,7 @@ finish_reloc_translation (struct translate_context *ctx, void **out, ctx->lst = next; } - return ctx->current_address; + layout->reloc_size = ctx->current_address; } static void @@ -1390,8 +1391,8 @@ translate_reloc_jumpers (struct translate_context *ctx, } /* Make a .reloc section. */ -static Elf_Addr -make_reloc_section (Elf_Ehdr *e, void **out, +static void +make_reloc_section (Elf_Ehdr *e, struct grub_mkimage_layout *layout, Elf_Addr *section_addresses, Elf_Shdr *sections, Elf_Half section_entsize, Elf_Half num_sections, const char *strtab, @@ -1446,7 +1447,7 @@ make_reloc_section (Elf_Ehdr *e, void **out, translate_reloc_jumpers (&ctx, jumpers, njumpers, image_target); - return finish_reloc_translation (&ctx, out, image_target); + finish_reloc_translation (&ctx, layout, image_target); } /* Determine if this section is a text section. Return false if this @@ -1498,8 +1499,7 @@ static Elf_Addr * SUFFIX (locate_sections) (const char *kernel_path, Elf_Shdr *sections, Elf_Half section_entsize, Elf_Half num_sections, const char *strtab, - size_t *exec_size, size_t *kernel_sz, - size_t *all_align, + struct grub_mkimage_layout *layout, const struct grub_install_image_target_desc *image_target) { int i; @@ -1507,10 +1507,10 @@ SUFFIX (locate_sections) (const char *kernel_path, Elf_Addr *section_addresses; Elf_Shdr *s; - *all_align = 1; + layout->align = 1; /* Page-aligning simplifies relocation handling. */ if (image_target->elf_target == EM_AARCH64) - *all_align = 4096; + layout->align = 4096; section_addresses = xmalloc (sizeof (*section_addresses) * num_sections); memset (section_addresses, 0, sizeof (*section_addresses) * num_sections); @@ -1521,8 +1521,8 @@ SUFFIX (locate_sections) (const char *kernel_path, i < num_sections; i++, s = (Elf_Shdr *) ((char *) s + section_entsize)) if ((grub_target_to_host (s->sh_flags) & SHF_ALLOC) - && grub_host_to_target32 (s->sh_addralign) > *all_align) - *all_align = grub_host_to_target32 (s->sh_addralign); + && grub_host_to_target32 (s->sh_addralign) > layout->align) + layout->align = grub_host_to_target32 (s->sh_addralign); /* .text */ @@ -1562,7 +1562,7 @@ SUFFIX (locate_sections) (const char *kernel_path, current_address = ALIGN_UP (current_address + image_target->vaddr_offset, image_target->section_align) - image_target->vaddr_offset; - *exec_size = current_address; + layout->exec_size = current_address; /* .data */ for (i = 0, s = sections; @@ -1590,16 +1590,14 @@ SUFFIX (locate_sections) (const char *kernel_path, current_address = ALIGN_UP (current_address + image_target->vaddr_offset, image_target->section_align) - image_target->vaddr_offset; - *kernel_sz = current_address; + layout->kernel_size = current_address; return section_addresses; } char * -SUFFIX (grub_mkimage_load_image) (const char *kernel_path, size_t *exec_size, - size_t *kernel_sz, size_t *bss_size, - size_t total_module_size, grub_uint64_t *start, - void **reloc_section, size_t *reloc_size, - size_t *align, +SUFFIX (grub_mkimage_load_image) (const char *kernel_path, + size_t total_module_size, + struct grub_mkimage_layout *layout, const struct grub_install_image_target_desc *image_target) { char *kernel_img, *out_img; @@ -1614,12 +1612,11 @@ SUFFIX (grub_mkimage_load_image) (const char *kernel_path, size_t *exec_size, Elf_Off section_offset; Elf_Half section_entsize; grub_size_t kernel_size; - grub_size_t ia64jmp_off = 0, tramp_off = 0, ia64_got_off = 0; - unsigned ia64jmpnum = 0; Elf_Shdr *symtab_section = 0; - grub_size_t got = 0; - *start = 0; + grub_memset (layout, 0, sizeof (*layout)); + + layout->start_address = 0; kernel_size = grub_util_get_image_size (kernel_path); kernel_img = xmalloc (kernel_size); @@ -1646,7 +1643,7 @@ SUFFIX (grub_mkimage_load_image) (const char *kernel_path, size_t *exec_size, section_addresses = SUFFIX (locate_sections) (kernel_path, sections, section_entsize, num_sections, strtab, - exec_size, kernel_sz, align, + layout, image_target); section_vaddresses = xmalloc (sizeof (*section_addresses) * num_sections); @@ -1656,7 +1653,7 @@ SUFFIX (grub_mkimage_load_image) (const char *kernel_path, size_t *exec_size, if (image_target->id != IMAGE_EFI) { - Elf_Addr current_address = *kernel_sz; + Elf_Addr current_address = layout->kernel_size; for (i = 0, s = sections; i < num_sections; @@ -1686,15 +1683,15 @@ SUFFIX (grub_mkimage_load_image) (const char *kernel_path, size_t *exec_size, current_address = ALIGN_UP (current_address + image_target->vaddr_offset, image_target->section_align) - image_target->vaddr_offset; - *bss_size = current_address - *kernel_sz; + layout->bss_size = current_address - layout->kernel_size; } else - *bss_size = 0; + layout->bss_size = 0; if (image_target->id == IMAGE_SPARC64_AOUT || image_target->id == IMAGE_SPARC64_RAW || image_target->id == IMAGE_SPARC64_CDCORE) - *kernel_sz = ALIGN_UP (*kernel_sz, image_target->mod_align); + layout->kernel_size = ALIGN_UP (layout->kernel_size, image_target->mod_align); if (image_target->id == IMAGE_EFI) { @@ -1715,13 +1712,13 @@ SUFFIX (grub_mkimage_load_image) (const char *kernel_path, size_t *exec_size, { grub_size_t tramp; - *kernel_sz = ALIGN_UP (*kernel_sz, 16); + layout->kernel_size = ALIGN_UP (layout->kernel_size, 16); tramp = arm_get_trampoline_size (e, sections, section_entsize, num_sections, image_target); - tramp_off = *kernel_sz; - *kernel_sz += ALIGN_UP (tramp, 16); + layout->tramp_off = layout->kernel_size; + layout->kernel_size += ALIGN_UP (tramp, 16); } #endif @@ -1730,61 +1727,62 @@ SUFFIX (grub_mkimage_load_image) (const char *kernel_path, size_t *exec_size, { grub_size_t tramp; - *kernel_sz = ALIGN_UP (*kernel_sz, 16); + layout->kernel_size = ALIGN_UP (layout->kernel_size, 16); - grub_ia64_dl_get_tramp_got_size (e, &tramp, &got); + grub_ia64_dl_get_tramp_got_size (e, &tramp, &layout->got_size); - tramp_off = *kernel_sz; - *kernel_sz += ALIGN_UP (tramp, 16); + layout->tramp_off = layout->kernel_size; + layout->kernel_size += ALIGN_UP (tramp, 16); - ia64jmp_off = *kernel_sz; - ia64jmpnum = SUFFIX (count_funcs) (e, symtab_section, + layout->ia64jmp_off = layout->kernel_size; + layout->ia64jmpnum = SUFFIX (count_funcs) (e, symtab_section, image_target); - *kernel_sz += 16 * ia64jmpnum; + layout->kernel_size += 16 * layout->ia64jmpnum; - ia64_got_off = *kernel_sz; - *kernel_sz += ALIGN_UP (got, 16); + layout->ia64_got_off = layout->kernel_size; + layout->kernel_size += ALIGN_UP (layout->got_size, 16); } #endif } else { - *reloc_size = 0; - *reloc_section = NULL; + layout->reloc_size = 0; + layout->reloc_section = NULL; } - out_img = xmalloc (*kernel_sz + total_module_size); - memset (out_img, 0, *kernel_sz + total_module_size); + out_img = xmalloc (layout->kernel_size + total_module_size); + memset (out_img, 0, layout->kernel_size + total_module_size); if (image_target->id == IMAGE_EFI) { - *start = SUFFIX (relocate_symbols) (e, sections, symtab_section, + layout->start_address = SUFFIX (relocate_symbols) (e, sections, symtab_section, section_vaddresses, section_entsize, num_sections, - (char *) out_img + ia64jmp_off, - ia64jmp_off + (char *) out_img + layout->ia64jmp_off, + layout->ia64jmp_off + image_target->vaddr_offset, image_target); - if (*start == 0) + if (layout->start_address == 0) grub_util_error ("start symbol is not defined"); - SUFFIX (entry_point) = (Elf_Addr) *start; + SUFFIX (entry_point) = (Elf_Addr) layout->start_address; /* Resolve addresses in the virtual address space. */ SUFFIX (relocate_addresses) (e, sections, section_addresses, section_entsize, num_sections, strtab, - out_img, tramp_off, ia64_got_off, + out_img, layout->tramp_off, + layout->ia64_got_off, image_target); - *reloc_size = SUFFIX (make_reloc_section) (e, reloc_section, - section_vaddresses, sections, - section_entsize, num_sections, - strtab, ia64jmp_off - + image_target->vaddr_offset, - 2 * ia64jmpnum + (got / 8), - image_target); + make_reloc_section (e, layout, + section_vaddresses, sections, + section_entsize, num_sections, + strtab, layout->ia64jmp_off + + image_target->vaddr_offset, + 2 * layout->ia64jmpnum + (layout->got_size / 8), + image_target); } for (i = 0, s = sections; diff --git a/util/mkimage.c b/util/mkimage.c index 86bb78190..ab58d34c0 100644 --- a/util/mkimage.c +++ b/util/mkimage.c @@ -742,17 +742,14 @@ grub_install_generate_image (const char *dir, const char *prefix, grub_compression_t comp) { char *kernel_img, *core_img; - size_t kernel_size, total_module_size, core_size, exec_size; + size_t total_module_size, core_size; size_t memdisk_size = 0, config_size = 0; size_t prefix_size = 0; char *kernel_path; size_t offset; struct grub_util_path_list *path_list, *p; - size_t bss_size; - grub_uint64_t start_address; - void *rel_section = 0; - size_t reloc_size = 0, align; size_t decompress_size = 0; + struct grub_mkimage_layout layout; if (comp == GRUB_COMPRESSION_AUTO) comp = image_target->default_compression; @@ -814,15 +811,13 @@ grub_install_generate_image (const char *dir, const char *prefix, (unsigned long long) total_module_size); if (image_target->voidp_sizeof == 4) - kernel_img = grub_mkimage_load_image32 (kernel_path, &exec_size, &kernel_size, &bss_size, - total_module_size, &start_address, &rel_section, - &reloc_size, &align, image_target); + kernel_img = grub_mkimage_load_image32 (kernel_path, total_module_size, + &layout, image_target); else - kernel_img = grub_mkimage_load_image64 (kernel_path, &exec_size, &kernel_size, &bss_size, - total_module_size, &start_address, &rel_section, - &reloc_size, &align, image_target); - if (image_target->id == IMAGE_XEN && align < 4096) - align = 4096; + kernel_img = grub_mkimage_load_image64 (kernel_path, total_module_size, + &layout, image_target); + if (image_target->id == IMAGE_XEN && layout.align < 4096) + layout.align = 4096; if ((image_target->flags & PLATFORM_FLAGS_DECOMPRESSORS) && (image_target->total_module_size != TARGET_NO_FIELD)) @@ -831,7 +826,7 @@ grub_install_generate_image (const char *dir, const char *prefix, if (image_target->flags & PLATFORM_FLAGS_MODULES_BEFORE_KERNEL) { - memmove (kernel_img + total_module_size, kernel_img, kernel_size); + memmove (kernel_img + total_module_size, kernel_img, layout.kernel_size); memset (kernel_img, 0, total_module_size); } @@ -842,14 +837,14 @@ grub_install_generate_image (const char *dir, const char *prefix, if (image_target->flags & PLATFORM_FLAGS_MODULES_BEFORE_KERNEL) modinfo = (struct grub_module_info64 *) kernel_img; else - modinfo = (struct grub_module_info64 *) (kernel_img + kernel_size); + modinfo = (struct grub_module_info64 *) (kernel_img + layout.kernel_size); modinfo->magic = grub_host_to_target32 (GRUB_MODULE_MAGIC); modinfo->offset = grub_host_to_target_addr (sizeof (struct grub_module_info64)); modinfo->size = grub_host_to_target_addr (total_module_size); if (image_target->flags & PLATFORM_FLAGS_MODULES_BEFORE_KERNEL) offset = sizeof (struct grub_module_info64); else - offset = kernel_size + sizeof (struct grub_module_info64); + offset = layout.kernel_size + sizeof (struct grub_module_info64); } else { @@ -858,14 +853,14 @@ grub_install_generate_image (const char *dir, const char *prefix, if (image_target->flags & PLATFORM_FLAGS_MODULES_BEFORE_KERNEL) modinfo = (struct grub_module_info32 *) kernel_img; else - modinfo = (struct grub_module_info32 *) (kernel_img + kernel_size); + modinfo = (struct grub_module_info32 *) (kernel_img + layout.kernel_size); modinfo->magic = grub_host_to_target32 (GRUB_MODULE_MAGIC); modinfo->offset = grub_host_to_target_addr (sizeof (struct grub_module_info32)); modinfo->size = grub_host_to_target_addr (total_module_size); if (image_target->flags & PLATFORM_FLAGS_MODULES_BEFORE_KERNEL) offset = sizeof (struct grub_module_info32); else - offset = kernel_size + sizeof (struct grub_module_info32); + offset = layout.kernel_size + sizeof (struct grub_module_info32); } for (p = path_list; p; p = p->next) @@ -944,8 +939,8 @@ grub_install_generate_image (const char *dir, const char *prefix, grub_util_info ("kernel_img=%p, kernel_size=0x%" GRUB_HOST_PRIxLONG_LONG, kernel_img, - (unsigned long long) kernel_size); - compress_kernel (image_target, kernel_img, kernel_size + total_module_size, + (unsigned long long) layout.kernel_size); + compress_kernel (image_target, kernel_img, layout.kernel_size + total_module_size, &core_img, &core_size, comp); free (kernel_img); @@ -997,7 +992,7 @@ grub_install_generate_image (const char *dir, const char *prefix, if (image_target->decompressor_uncompressed_size != TARGET_NO_FIELD) *((grub_uint32_t *) (decompress_img + image_target->decompressor_uncompressed_size)) - = grub_host_to_target32 (kernel_size + total_module_size); + = grub_host_to_target32 (layout.kernel_size + total_module_size); if (image_target->decompressor_uncompressed_addr != TARGET_NO_FIELD) { @@ -1030,16 +1025,17 @@ grub_install_generate_image (const char *dir, const char *prefix, case IMAGE_I386_PC_ELTORITO: if (GRUB_KERNEL_I386_PC_LINK_ADDR + core_size > 0x78000 || (core_size > (0xffff << GRUB_DISK_SECTOR_BITS)) - || (kernel_size + bss_size + GRUB_KERNEL_I386_PC_LINK_ADDR > 0x68000)) + || (layout.kernel_size + layout.bss_size + + GRUB_KERNEL_I386_PC_LINK_ADDR > 0x68000)) grub_util_error (_("core image is too big (0x%x > 0x%x)"), GRUB_KERNEL_I386_PC_LINK_ADDR + (unsigned) core_size, 0x78000); /* fallthrough */ case IMAGE_COREBOOT: case IMAGE_QEMU: - if (kernel_size + bss_size + GRUB_KERNEL_I386_PC_LINK_ADDR > 0x68000) + if (layout.kernel_size + layout.bss_size + GRUB_KERNEL_I386_PC_LINK_ADDR > 0x68000) grub_util_error (_("kernel image is too big (0x%x > 0x%x)"), - (unsigned) kernel_size + (unsigned) bss_size + (unsigned) layout.kernel_size + (unsigned) layout.bss_size + GRUB_KERNEL_I386_PC_LINK_ADDR, 0x68000); break; @@ -1161,13 +1157,13 @@ grub_install_generate_image (const char *dir, const char *prefix, reloc_addr = ALIGN_UP (header_size + core_size, image_target->section_align); - pe_size = ALIGN_UP (reloc_addr + reloc_size, + pe_size = ALIGN_UP (reloc_addr + layout.reloc_size, image_target->section_align); - pe_img = xmalloc (reloc_addr + reloc_size); + pe_img = xmalloc (reloc_addr + layout.reloc_size); memset (pe_img, 0, header_size); memcpy ((char *) pe_img + header_size, core_img, core_size); memset ((char *) pe_img + header_size + core_size, 0, reloc_addr - (header_size + core_size)); - memcpy ((char *) pe_img + reloc_addr, rel_section, reloc_size); + memcpy ((char *) pe_img + reloc_addr, layout.reloc_section, layout.reloc_size); header = pe_img; /* The magic. */ @@ -1201,14 +1197,14 @@ grub_install_generate_image (const char *dir, const char *prefix, (header + GRUB_PE32_MSDOS_STUB_SIZE + GRUB_PE32_SIGNATURE_SIZE + sizeof (struct grub_pe32_coff_header)); o->magic = grub_host_to_target16 (GRUB_PE32_PE32_MAGIC); - o->code_size = grub_host_to_target32 (exec_size); - o->data_size = grub_cpu_to_le32 (reloc_addr - exec_size + o->code_size = grub_host_to_target32 (layout.exec_size); + o->data_size = grub_cpu_to_le32 (reloc_addr - layout.exec_size - header_size); - o->bss_size = grub_cpu_to_le32 (bss_size); - o->entry_addr = grub_cpu_to_le32 (start_address); + o->bss_size = grub_cpu_to_le32 (layout.bss_size); + o->entry_addr = grub_cpu_to_le32 (layout.start_address); o->code_base = grub_cpu_to_le32 (header_size); - o->data_base = grub_host_to_target32 (header_size + exec_size); + o->data_base = grub_host_to_target32 (header_size + layout.exec_size); o->image_base = 0; o->section_alignment = grub_host_to_target32 (image_target->section_align); @@ -1226,7 +1222,7 @@ grub_install_generate_image (const char *dir, const char *prefix, o->num_data_directories = grub_host_to_target32 (GRUB_PE32_NUM_DATA_DIRECTORIES); o->base_relocation_table.rva = grub_host_to_target32 (reloc_addr); - o->base_relocation_table.size = grub_host_to_target32 (reloc_size); + o->base_relocation_table.size = grub_host_to_target32 (layout.reloc_size); sections = o + 1; } else @@ -1239,11 +1235,11 @@ grub_install_generate_image (const char *dir, const char *prefix, (header + GRUB_PE32_MSDOS_STUB_SIZE + GRUB_PE32_SIGNATURE_SIZE + sizeof (struct grub_pe32_coff_header)); o->magic = grub_host_to_target16 (GRUB_PE32_PE64_MAGIC); - o->code_size = grub_host_to_target32 (exec_size); - o->data_size = grub_cpu_to_le32 (reloc_addr - exec_size + o->code_size = grub_host_to_target32 (layout.exec_size); + o->data_size = grub_cpu_to_le32 (reloc_addr - layout.exec_size - header_size); - o->bss_size = grub_cpu_to_le32 (bss_size); - o->entry_addr = grub_cpu_to_le32 (start_address); + o->bss_size = grub_cpu_to_le32 (layout.bss_size); + o->entry_addr = grub_cpu_to_le32 (layout.start_address); o->code_base = grub_cpu_to_le32 (header_size); o->image_base = 0; o->section_alignment = grub_host_to_target32 (image_target->section_align); @@ -1262,15 +1258,15 @@ grub_install_generate_image (const char *dir, const char *prefix, = grub_host_to_target32 (GRUB_PE32_NUM_DATA_DIRECTORIES); o->base_relocation_table.rva = grub_host_to_target32 (reloc_addr); - o->base_relocation_table.size = grub_host_to_target32 (reloc_size); + o->base_relocation_table.size = grub_host_to_target32 (layout.reloc_size); sections = o + 1; } /* The sections. */ text_section = sections; strcpy (text_section->name, ".text"); - text_section->virtual_size = grub_cpu_to_le32 (exec_size); + text_section->virtual_size = grub_cpu_to_le32 (layout.exec_size); text_section->virtual_address = grub_cpu_to_le32 (header_size); - text_section->raw_data_size = grub_cpu_to_le32 (exec_size); + text_section->raw_data_size = grub_cpu_to_le32 (layout.exec_size); text_section->raw_data_offset = grub_cpu_to_le32 (header_size); text_section->characteristics = grub_cpu_to_le32_compile_time ( GRUB_PE32_SCN_CNT_CODE @@ -1279,10 +1275,10 @@ grub_install_generate_image (const char *dir, const char *prefix, data_section = text_section + 1; strcpy (data_section->name, ".data"); - data_section->virtual_size = grub_cpu_to_le32 (kernel_size - exec_size); - data_section->virtual_address = grub_cpu_to_le32 (header_size + exec_size); - data_section->raw_data_size = grub_cpu_to_le32 (kernel_size - exec_size); - data_section->raw_data_offset = grub_cpu_to_le32 (header_size + exec_size); + data_section->virtual_size = grub_cpu_to_le32 (layout.kernel_size - layout.exec_size); + data_section->virtual_address = grub_cpu_to_le32 (header_size + layout.exec_size); + data_section->raw_data_size = grub_cpu_to_le32 (layout.kernel_size - layout.exec_size); + data_section->raw_data_offset = grub_cpu_to_le32 (header_size + layout.exec_size); data_section->characteristics = grub_cpu_to_le32_compile_time (GRUB_PE32_SCN_CNT_INITIALIZED_DATA | GRUB_PE32_SCN_MEM_READ @@ -1291,8 +1287,8 @@ grub_install_generate_image (const char *dir, const char *prefix, #if 0 bss_section = data_section + 1; strcpy (bss_section->name, ".bss"); - bss_section->virtual_size = grub_cpu_to_le32 (bss_size); - bss_section->virtual_address = grub_cpu_to_le32 (header_size + kernel_size); + bss_section->virtual_size = grub_cpu_to_le32 (layout.bss_size); + bss_section->virtual_address = grub_cpu_to_le32 (header_size + layout.kernel_size); bss_section->raw_data_size = 0; bss_section->raw_data_offset = 0; bss_section->characteristics @@ -1305,10 +1301,10 @@ grub_install_generate_image (const char *dir, const char *prefix, mods_section = data_section + 1; strcpy (mods_section->name, "mods"); - mods_section->virtual_size = grub_cpu_to_le32 (reloc_addr - kernel_size - header_size); - mods_section->virtual_address = grub_cpu_to_le32 (header_size + kernel_size + bss_size); - mods_section->raw_data_size = grub_cpu_to_le32 (reloc_addr - kernel_size - header_size); - mods_section->raw_data_offset = grub_cpu_to_le32 (header_size + kernel_size); + mods_section->virtual_size = grub_cpu_to_le32 (reloc_addr - layout.kernel_size - header_size); + mods_section->virtual_address = grub_cpu_to_le32 (header_size + layout.kernel_size + layout.bss_size); + mods_section->raw_data_size = grub_cpu_to_le32 (reloc_addr - layout.kernel_size - header_size); + mods_section->raw_data_offset = grub_cpu_to_le32 (header_size + layout.kernel_size); mods_section->characteristics = grub_cpu_to_le32_compile_time (GRUB_PE32_SCN_CNT_INITIALIZED_DATA | GRUB_PE32_SCN_MEM_READ @@ -1316,9 +1312,9 @@ grub_install_generate_image (const char *dir, const char *prefix, reloc_section = mods_section + 1; strcpy (reloc_section->name, ".reloc"); - reloc_section->virtual_size = grub_cpu_to_le32 (reloc_size); - reloc_section->virtual_address = grub_cpu_to_le32 (reloc_addr + bss_size); - reloc_section->raw_data_size = grub_cpu_to_le32 (reloc_size); + reloc_section->virtual_size = grub_cpu_to_le32 (layout.reloc_size); + reloc_section->virtual_address = grub_cpu_to_le32 (reloc_addr + layout.bss_size); + reloc_section->raw_data_size = grub_cpu_to_le32 (layout.reloc_size); reloc_section->raw_data_offset = grub_cpu_to_le32 (reloc_addr); reloc_section->characteristics = grub_cpu_to_le32_compile_time (GRUB_PE32_SCN_CNT_INITIALIZED_DATA @@ -1589,7 +1585,7 @@ grub_install_generate_image (const char *dir, const char *prefix, target_addr = (image_target->link_addr - decompress_size); else target_addr = ALIGN_UP (image_target->link_addr - + kernel_size + total_module_size, 32); + + layout.kernel_size + total_module_size, 32); ecoff_img = xmalloc (program_size + sizeof (*head) + sizeof (*section)); grub_memset (ecoff_img, 0, program_size + sizeof (*head) + sizeof (*section)); @@ -1636,16 +1632,16 @@ grub_install_generate_image (const char *dir, const char *prefix, target_addr = (image_target->link_addr - decompress_size); else target_addr = ALIGN_UP (image_target->link_addr - + kernel_size + total_module_size, 32); + + layout.kernel_size + total_module_size, 32); } else target_addr = image_target->link_addr; if (image_target->voidp_sizeof == 4) grub_mkimage_generate_elf32 (image_target, note, &core_img, &core_size, - target_addr, align, kernel_size, bss_size); + target_addr, layout.align, layout.kernel_size, layout.bss_size); else grub_mkimage_generate_elf64 (image_target, note, &core_img, &core_size, - target_addr, align, kernel_size, bss_size); + target_addr, layout.align, layout.kernel_size, layout.bss_size); } break; } @@ -1653,7 +1649,7 @@ grub_install_generate_image (const char *dir, const char *prefix, grub_util_write_image (core_img, core_size, out, outname); free (core_img); free (kernel_path); - free (rel_section); + free (layout.reloc_section); grub_util_free_path_list (path_list); } From df21fff50456c6db9f487af0a3383e9e365595af Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Thu, 18 Feb 2016 20:57:21 +0100 Subject: [PATCH 715/722] Provide __bss_start and _end symbols in grub-mkimage. For this ensure that all bss sections are merged. We need this to correctly prelink non-PE relocatable images. --- include/grub/util/mkimage.h | 2 + util/grub-mkimagexx.c | 137 +++++++++++++++++++++++------------- 2 files changed, 89 insertions(+), 50 deletions(-) diff --git a/include/grub/util/mkimage.h b/include/grub/util/mkimage.h index 8169939a7..25a49d5c3 100644 --- a/include/grub/util/mkimage.h +++ b/include/grub/util/mkimage.h @@ -33,6 +33,8 @@ struct grub_mkimage_layout grub_size_t ia64_got_off; grub_size_t got_size; unsigned ia64jmpnum; + Elf_Addr bss_start; + Elf_Addr end; }; /* Private header. Use only in mkimage-related sources. */ diff --git a/util/grub-mkimagexx.c b/util/grub-mkimagexx.c index 74f86f5df..433322d85 100644 --- a/util/grub-mkimagexx.c +++ b/util/grub-mkimagexx.c @@ -490,6 +490,7 @@ SUFFIX (relocate_symbols) (Elf_Ehdr *e, Elf_Shdr *sections, Elf_Shdr *symtab_section, Elf_Addr *section_addresses, Elf_Half section_entsize, Elf_Half num_sections, void *jumpers, Elf_Addr jumpers_addr, + Elf_Addr bss_start, Elf_Addr end, const struct grub_install_image_target_desc *image_target) { Elf_Word symtab_size, sym_size, num_syms; @@ -528,16 +529,22 @@ SUFFIX (relocate_symbols) (Elf_Ehdr *e, Elf_Shdr *sections, } else if (cur_index == STN_UNDEF) { - if (sym->st_name) + if (sym->st_name && grub_strcmp (name, "__bss_start")) + sym->st_value = bss_start; + else if (sym->st_name && grub_strcmp (name, "__end")) + sym->st_value = end; + else if (sym->st_name) grub_util_error ("undefined symbol %s", name); else continue; } else if (cur_index >= num_sections) grub_util_error ("section %d does not exist", cur_index); - - sym->st_value = (grub_target_to_host (sym->st_value) - + section_addresses[cur_index]); + else + { + sym->st_value = (grub_target_to_host (sym->st_value) + + section_addresses[cur_index]); + } if (image_target->elf_target == EM_IA_64 && ELF_ST_TYPE (sym->st_info) == STT_FUNC) @@ -1462,9 +1469,7 @@ SUFFIX (is_text_section) (Elf_Shdr *s, const struct grub_install_image_target_de == (SHF_EXECINSTR | SHF_ALLOC)); } -/* Determine if this section is a data section. This assumes that - BSS is also a data section, since the converter initializes BSS - when producing PE32 to avoid a bug in EFI implementations. */ +/* Determine if this section is a data section. */ static int SUFFIX (is_data_section) (Elf_Shdr *s, const struct grub_install_image_target_desc *image_target) { @@ -1472,7 +1477,16 @@ SUFFIX (is_data_section) (Elf_Shdr *s, const struct grub_install_image_target_de && grub_target_to_host32 (s->sh_type) != SHT_PROGBITS) return 0; return ((grub_target_to_host (s->sh_flags) & (SHF_EXECINSTR | SHF_ALLOC)) - == SHF_ALLOC); + == SHF_ALLOC) && !(grub_target_to_host32 (s->sh_type) == SHT_NOBITS); +} + +static int +SUFFIX (is_bss_section) (Elf_Shdr *s, const struct grub_install_image_target_desc *image_target) +{ + if (!is_relocatable (image_target)) + return 0; + return ((grub_target_to_host (s->sh_flags) & (SHF_EXECINSTR | SHF_ALLOC)) + == SHF_ALLOC) && (grub_target_to_host32 (s->sh_type) == SHT_NOBITS); } /* Return if the ELF header is valid. */ @@ -1492,6 +1506,32 @@ SUFFIX (check_elf_header) (Elf_Ehdr *e, size_t size, const struct grub_install_i return 1; } +static Elf_Addr +SUFFIX (put_section) (Elf_Shdr *s, int i, + Elf_Addr current_address, + Elf_Addr *section_addresses, + const char *strtab, + const struct grub_install_image_target_desc *image_target) +{ + Elf_Word align = grub_host_to_target_addr (s->sh_addralign); + const char *name = strtab + grub_host_to_target32 (s->sh_name); + + if (align) + current_address = ALIGN_UP (current_address + image_target->vaddr_offset, + align) + - image_target->vaddr_offset; + + grub_util_info ("locating the section %s at 0x%" + GRUB_HOST_PRIxLONG_LONG, + name, (unsigned long long) current_address); + if (!is_relocatable (image_target)) + current_address = grub_host_to_target_addr (s->sh_addr) + - image_target->link_addr; + section_addresses[i] = current_address; + current_address += grub_host_to_target_addr (s->sh_size); + return current_address; +} + /* Locate section addresses by merging code sections and data sections into .text and .data, respectively. Return the array of section addresses. */ @@ -1531,32 +1571,22 @@ SUFFIX (locate_sections) (const char *kernel_path, i++, s = (Elf_Shdr *) ((char *) s + section_entsize)) if (SUFFIX (is_text_section) (s, image_target)) { - Elf_Word align = grub_host_to_target_addr (s->sh_addralign); - const char *name = strtab + grub_host_to_target32 (s->sh_name); - if (align) - current_address = ALIGN_UP (current_address + image_target->vaddr_offset, - align) - image_target->vaddr_offset; - grub_util_info ("locating the section %s at 0x%" - GRUB_HOST_PRIxLONG_LONG, - name, (unsigned long long) current_address); - if (image_target->id != IMAGE_EFI) + current_address = SUFFIX (put_section) (s, i, + current_address, + section_addresses, + strtab, + image_target); + if (!is_relocatable (image_target) && + grub_host_to_target_addr (s->sh_addr) != image_target->link_addr) { - current_address = grub_host_to_target_addr (s->sh_addr) - - image_target->link_addr; - if (grub_host_to_target_addr (s->sh_addr) - != image_target->link_addr) - { - char *msg - = grub_xasprintf (_("`%s' is miscompiled: its start address is 0x%llx" - " instead of 0x%llx: ld.gold bug?"), - kernel_path, - (unsigned long long) grub_host_to_target_addr (s->sh_addr), - (unsigned long long) image_target->link_addr); - grub_util_error ("%s", msg); - } + char *msg + = grub_xasprintf (_("`%s' is miscompiled: its start address is 0x%llx" + " instead of 0x%llx: ld.gold bug?"), + kernel_path, + (unsigned long long) grub_host_to_target_addr (s->sh_addr), + (unsigned long long) image_target->link_addr); + grub_util_error ("%s", msg); } - section_addresses[i] = current_address; - current_address += grub_host_to_target_addr (s->sh_size); } current_address = ALIGN_UP (current_address + image_target->vaddr_offset, @@ -1569,27 +1599,31 @@ SUFFIX (locate_sections) (const char *kernel_path, i < num_sections; i++, s = (Elf_Shdr *) ((char *) s + section_entsize)) if (SUFFIX (is_data_section) (s, image_target)) - { - Elf_Word align = grub_host_to_target_addr (s->sh_addralign); - const char *name = strtab + grub_host_to_target32 (s->sh_name); - - if (align) - current_address = ALIGN_UP (current_address + image_target->vaddr_offset, - align) - - image_target->vaddr_offset; - - grub_util_info ("locating the section %s at 0x%" - GRUB_HOST_PRIxLONG_LONG, - name, (unsigned long long) current_address); - if (image_target->id != IMAGE_EFI) - current_address = grub_host_to_target_addr (s->sh_addr) - - image_target->link_addr; - section_addresses[i] = current_address; - current_address += grub_host_to_target_addr (s->sh_size); - } + current_address = SUFFIX (put_section) (s, i, + current_address, + section_addresses, + strtab, + image_target); current_address = ALIGN_UP (current_address + image_target->vaddr_offset, image_target->section_align) - image_target->vaddr_offset; + + layout->bss_start = current_address; + + /* .bss */ + for (i = 0, s = sections; + i < num_sections; + i++, s = (Elf_Shdr *) ((char *) s + section_entsize)) + if (SUFFIX (is_bss_section) (s, image_target)) + current_address = SUFFIX (put_section) (s, i, + current_address, + section_addresses, + strtab, + image_target); + + current_address = ALIGN_UP (current_address + image_target->vaddr_offset, + image_target->section_align) - image_target->vaddr_offset; + layout->end = current_address; layout->kernel_size = current_address; return section_addresses; } @@ -1789,8 +1823,11 @@ SUFFIX (grub_mkimage_load_image) (const char *kernel_path, i < num_sections; i++, s = (Elf_Shdr *) ((char *) s + section_entsize)) if (SUFFIX (is_data_section) (s, image_target) + || SUFFIX (is_bss_section) (s, image_target) || SUFFIX (is_text_section) (s, image_target)) { + /* Explicitly initialize BSS + when producing PE32 to avoid a bug in EFI implementations. */ if (grub_target_to_host32 (s->sh_type) == SHT_NOBITS) memset (out_img + section_addresses[i], 0, grub_host_to_target_addr (s->sh_size)); From 5bcb7d394c26d212cebf59c9b70a42a11f90d2bc Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Thu, 18 Feb 2016 20:58:38 +0100 Subject: [PATCH 716/722] Allow _start == 0 with relocatable images --- util/grub-mkimagexx.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/util/grub-mkimagexx.c b/util/grub-mkimagexx.c index 433322d85..fff811266 100644 --- a/util/grub-mkimagexx.c +++ b/util/grub-mkimagexx.c @@ -495,7 +495,7 @@ SUFFIX (relocate_symbols) (Elf_Ehdr *e, Elf_Shdr *sections, { Elf_Word symtab_size, sym_size, num_syms; Elf_Off symtab_offset; - Elf_Addr start_address = 0; + Elf_Addr start_address = (Elf_Addr) -1; Elf_Sym *sym; Elf_Word i; Elf_Shdr *strtab_section; @@ -560,7 +560,7 @@ SUFFIX (relocate_symbols) (Elf_Ehdr *e, Elf_Shdr *sections, (unsigned long long) sym->st_value, (unsigned long long) section_addresses[cur_index]); - if (! start_address) + if (start_address == (Elf_Addr)-1) if (strcmp (name, "_start") == 0 || strcmp (name, "start") == 0) start_address = sym->st_value; } @@ -1797,7 +1797,7 @@ SUFFIX (grub_mkimage_load_image) (const char *kernel_path, layout->ia64jmp_off + image_target->vaddr_offset, image_target); - if (layout->start_address == 0) + if (layout->start_address == (Elf_Addr) -1) grub_util_error ("start symbol is not defined"); SUFFIX (entry_point) = (Elf_Addr) layout->start_address; From 86ef66d977274051a9174437e97f923d9e97d9e8 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Fri, 19 Feb 2016 00:43:36 +0100 Subject: [PATCH 717/722] arm-uboot: Make self-relocatable to allow loading at any address --- grub-core/Makefile.core.def | 2 +- grub-core/kern/arm/uboot/startup.S | 60 +++++- include/grub/arm/uboot/kernel.h | 2 +- include/grub/offsets.h | 2 +- include/grub/util/mkimage.h | 5 +- util/grub-mkimagexx.c | 313 +++++++++++++++++++++++------ util/mkimage.c | 8 +- 7 files changed, 305 insertions(+), 87 deletions(-) diff --git a/grub-core/Makefile.core.def b/grub-core/Makefile.core.def index 887450110..58b4208b0 100644 --- a/grub-core/Makefile.core.def +++ b/grub-core/Makefile.core.def @@ -90,7 +90,7 @@ kernel = { i386_qemu_cppflags = '-DGRUB_BOOT_MACHINE_LINK_ADDR=$(GRUB_BOOT_MACHINE_LINK_ADDR)'; emu_cflags = '$(CFLAGS_GNULIB)'; emu_cppflags = '$(CPPFLAGS_GNULIB)'; - arm_uboot_ldflags = '-Wl,-Ttext=0x08000000'; + arm_uboot_ldflags = '-Wl,-r,-d'; arm_uboot_stripflags = '--strip-unneeded -K start -R .note -R .comment -R .note.gnu.gold-version'; i386_pc_startup = kern/i386/pc/startup.S; diff --git a/grub-core/kern/arm/uboot/startup.S b/grub-core/kern/arm/uboot/startup.S index 0c4a5f670..5efaae16e 100644 --- a/grub-core/kern/arm/uboot/startup.S +++ b/grub-core/kern/arm/uboot/startup.S @@ -55,10 +55,6 @@ FUNCTION(_start) VARIABLE(grub_total_module_size) .long 0 -VARIABLE(grub_uboot_machine_type) - .long 0 -VARIABLE(grub_uboot_boot_data) - .long 0 VARIABLE(grub_modbase) .long 0 bss_start_ptr: @@ -66,29 +62,66 @@ bss_start_ptr: end_ptr: .long EXT_C(_end) + @ Memory map at start: + @ * text+data + @ * list relocations + @ * modules + @ Before we enter C, we need to apply the relocations + @ and get following map: + @ * text+data + @ * BSS (cleared) + @ * stack + @ * modules + @ + @ To make things easier we ensure + @ that BSS+stack is larger than list of relocations + @ by increasing stack if necessarry. + @ This allows us to always unconditionally copy backwards + @ Currently list of relocations is ~5K and stack is set + @ to be at least 256K + FUNCTION(codestart) @ Store context: Machine ID, atags/dtb, ... @ U-Boot API signature is stored on the U-Boot heap @ Stack pointer used as start address for signature probing mov r12, sp adr sp, entry_state - push {r4-r12,lr} @ store U-Boot context (sp in r12) + push {r1-r12,lr} @ store U-Boot context (sp in r12) - str r1, EXT_C(grub_uboot_machine_type) - str r2, EXT_C(grub_uboot_boot_data) - - @ Modules have been stored as a blob in BSS, - @ they need to be manually relocated to _end + adr r1, _start ldr r0, bss_start_ptr @ src + add r0, r0, r1 + + add r0, r0, #(GRUB_KERNEL_MACHINE_MOD_ALIGN - 1) + mvn r2, #(GRUB_KERNEL_MACHINE_MOD_ALIGN - 1) + and r0, r0, r2 +1: + ldr r3, [r0], #4 @load next offset + @ both -2 and -1 are treated the same as we have only one type of relocs + @ -2 means "end of this type of relocs" and -1 means "end of all relocs" + add r2, r3, #2 + cmp r2, #1 + bls reloc_done + @ Adjust next offset + ldr r2, [r3, r1] + add r2, r2, r1 + str r2, [r3, r1] + b 1b + +reloc_done: + + @ Modules have been stored as a blob + @ they need to be manually relocated to _end add r0, r0, #(GRUB_KERNEL_MACHINE_MOD_ALIGN - 1) mvn r1, #(GRUB_KERNEL_MACHINE_MOD_ALIGN - 1) - and r0, r0, r1 + and r0, r0, r1 @ src = aligned end of relocations ldr r1, end_ptr @ dst = End of BSS ldr r2, grub_total_module_size @ blob size add r1, r1, #GRUB_KERNEL_MACHINE_STACK_SIZE and r1, r1, #~0x7 @ Ensure 8-byte alignment + sub sp, r1, #8 add r1, r1, #1024 @@ -157,6 +190,11 @@ FUNCTION(grub_uboot_return) .align 3 @ U-boot context stack space entry_state_end: +VARIABLE(grub_uboot_machine_type) + .long 0 @ r1 +VARIABLE(grub_uboot_boot_data) + .long 0 @ r2 + .long 0 @ r3 .long 0 @ r4 .long 0 @ r5 .long 0 @ r6 diff --git a/include/grub/arm/uboot/kernel.h b/include/grub/arm/uboot/kernel.h index 06e543324..ce0b149cc 100644 --- a/include/grub/arm/uboot/kernel.h +++ b/include/grub/arm/uboot/kernel.h @@ -26,7 +26,7 @@ #endif /* ! ASM_FILE */ -#define GRUB_KERNEL_MACHINE_STACK_SIZE 0x40000 +#define GRUB_KERNEL_MACHINE_STACK_SIZE GRUB_KERNEL_ARM_STACK_SIZE #define GRUB_KERNEL_MACHINE_HEAP_SIZE (grub_size_t) (16 * 1024 * 1024) #endif /* ! GRUB_KERNEL_MACHINE_HEADER */ diff --git a/include/grub/offsets.h b/include/grub/offsets.h index 85e7401ae..c88c86d4d 100644 --- a/include/grub/offsets.h +++ b/include/grub/offsets.h @@ -54,6 +54,7 @@ /* The offset of GRUB_TOTAL_MODULE_SIZE. */ #define GRUB_KERNEL_SPARC64_IEEE1275_TOTAL_MODULE_SIZE 0x8 +#define GRUB_KERNEL_ARM_STACK_SIZE 0x40000 #define GRUB_BOOT_SPARC64_IEEE1275_LIST_SIZE 12 @@ -120,7 +121,6 @@ #define GRUB_KERNEL_ARM_UBOOT_MOD_ALIGN 0x8 #define GRUB_KERNEL_ARM_UBOOT_TOTAL_MODULE_SIZE 0x4 -#define GRUB_KERNEL_ARM_UBOOT_LINK_ADDR 0x08000000 /* Minimal gap between _end and the start of the modules. It's a hack for PowerMac to prevent "CLAIM failed" error. The real fix is to diff --git a/include/grub/util/mkimage.h b/include/grub/util/mkimage.h index 25a49d5c3..2a4894213 100644 --- a/include/grub/util/mkimage.h +++ b/include/grub/util/mkimage.h @@ -33,8 +33,8 @@ struct grub_mkimage_layout grub_size_t ia64_got_off; grub_size_t got_size; unsigned ia64jmpnum; - Elf_Addr bss_start; - Elf_Addr end; + grub_uint32_t bss_start; + grub_uint32_t end; }; /* Private header. Use only in mkimage-related sources. */ @@ -83,6 +83,7 @@ struct grub_install_image_target_desc unsigned decompressor_compressed_size; unsigned decompressor_uncompressed_size; unsigned decompressor_uncompressed_addr; + unsigned reloc_table_offset; unsigned link_align; grub_uint16_t elf_target; unsigned section_align; diff --git a/util/grub-mkimagexx.c b/util/grub-mkimagexx.c index fff811266..353a9407a 100644 --- a/util/grub-mkimagexx.c +++ b/util/grub-mkimagexx.c @@ -86,6 +86,12 @@ struct fixup_block_list #define ALIGN_ADDR(x) (ALIGN_UP((x), image_target->voidp_sizeof)) +static int +is_relocatable (const struct grub_install_image_target_desc *image_target) +{ + return image_target->id == IMAGE_EFI || image_target->id == IMAGE_UBOOT; +} + #ifdef MKIMAGE_ELF32 /* @@ -529,9 +535,9 @@ SUFFIX (relocate_symbols) (Elf_Ehdr *e, Elf_Shdr *sections, } else if (cur_index == STN_UNDEF) { - if (sym->st_name && grub_strcmp (name, "__bss_start")) + if (sym->st_name && grub_strcmp (name, "__bss_start") == 0) sym->st_value = bss_start; - else if (sym->st_name && grub_strcmp (name, "__end")) + else if (sym->st_name && grub_strcmp (name, "_end") == 0) sym->st_value = end; else if (sym->st_name) grub_util_error ("undefined symbol %s", name); @@ -1008,7 +1014,8 @@ SUFFIX (relocate_addresses) (Elf_Ehdr *e, Elf_Shdr *sections, grub_util_info (" ABS32:\toffset=%d\t(0x%08x)", (int) sym_addr, (int) sym_addr); /* Data will be naturally aligned */ - sym_addr += 0x400; + if (image_target->id == IMAGE_EFI) + sym_addr += 0x400; *target = grub_host_to_target32 (grub_target_to_host32 (*target) + sym_addr); } break; @@ -1194,25 +1201,45 @@ add_fixup_entry (struct fixup_block_list **cblock, grub_uint16_t type, return current_address; } +struct raw_reloc +{ + struct raw_reloc *next; + grub_uint32_t offset; + enum raw_reloc_type { + RAW_RELOC_NONE = -1, + RAW_RELOC_32 = 0, + RAW_RELOC_MAX = 1, + } type; +}; + struct translate_context { + /* PE */ struct fixup_block_list *lst, *lst0; Elf_Addr current_address; + + /* Raw */ + struct raw_reloc *raw_relocs; }; static void -translate_reloc_start (struct translate_context *ctx) +translate_reloc_start (struct translate_context *ctx, + const struct grub_install_image_target_desc *image_target) { - ctx->lst = ctx->lst0 = xmalloc (sizeof (*ctx->lst) + 2 * 0x1000); - memset (ctx->lst, 0, sizeof (*ctx->lst) + 2 * 0x1000); - ctx->current_address = 0; + grub_memset (ctx, 0, sizeof (*ctx)); + if (image_target->id == IMAGE_EFI) + { + ctx->lst = ctx->lst0 = xmalloc (sizeof (*ctx->lst) + 2 * 0x1000); + memset (ctx->lst, 0, sizeof (*ctx->lst) + 2 * 0x1000); + ctx->current_address = 0; + } } static void -translate_relocation (struct translate_context *ctx, - Elf_Addr addr, - Elf_Addr info, - const struct grub_install_image_target_desc *image_target) +translate_relocation_pe (struct translate_context *ctx, + Elf_Addr addr, + Elf_Addr info, + const struct grub_install_image_target_desc *image_target) { /* Necessary to relocate only absolute addresses. */ switch (image_target->elf_target) @@ -1353,10 +1380,68 @@ translate_relocation (struct translate_context *ctx, } } +static enum raw_reloc_type +classify_raw_reloc (Elf_Addr info, + const struct grub_install_image_target_desc *image_target) +{ + /* Necessary to relocate only absolute addresses. */ + switch (image_target->elf_target) + { + case EM_ARM: + switch (ELF_R_TYPE (info)) + { + case R_ARM_V4BX: + case R_ARM_JUMP24: + case R_ARM_THM_CALL: + case R_ARM_THM_JUMP19: + case R_ARM_THM_JUMP24: + case R_ARM_CALL: + return RAW_RELOC_NONE; + case R_ARM_ABS32: + return RAW_RELOC_32; + default: + grub_util_error (_("relocation 0x%x is not implemented yet"), + (unsigned int) ELF_R_TYPE (info)); + break; + } + break; + default: + grub_util_error ("unknown machine type 0x%x", image_target->elf_target); + } +} + static void -finish_reloc_translation (struct translate_context *ctx, - struct grub_mkimage_layout *layout, +translate_relocation_raw (struct translate_context *ctx, + Elf_Addr addr, + Elf_Addr info, const struct grub_install_image_target_desc *image_target) +{ + enum raw_reloc_type class = classify_raw_reloc (info, image_target); + struct raw_reloc *rel; + if (class == RAW_RELOC_NONE) + return; + rel = xmalloc (sizeof (*rel)); + rel->next = ctx->raw_relocs; + rel->type = class; + rel->offset = addr; + ctx->raw_relocs = rel; +} + +static void +translate_relocation (struct translate_context *ctx, + Elf_Addr addr, + Elf_Addr info, + const struct grub_install_image_target_desc *image_target) +{ + if (image_target->id == IMAGE_EFI) + translate_relocation_pe (ctx, addr, info, image_target); + else + translate_relocation_raw (ctx, addr, info, image_target); +} + +static void +finish_reloc_translation_pe (struct translate_context *ctx, struct grub_mkimage_layout *layout, + const struct grub_install_image_target_desc *image_target) { ctx->current_address = add_fixup_entry (&ctx->lst, 0, 0, 1, ctx->current_address, image_target); @@ -1381,14 +1466,90 @@ finish_reloc_translation (struct translate_context *ctx, } layout->reloc_size = ctx->current_address; + if (image_target->elf_target == EM_ARM && layout->reloc_size > GRUB_KERNEL_ARM_STACK_SIZE) + grub_util_error ("Reloc section (%d) is bigger than stack size (%d). " + "This breaks assembly assumptions. Please increase stack size", + (int) layout->reloc_size, + (int) GRUB_KERNEL_ARM_STACK_SIZE); } +/* + Layout: + + + + + ... + + + each relocation starts with 32-bit offset. Rest depends on relocation. + mkimage stops when it sees first unknown type or end marker. + This allows images to be created with mismatched mkimage and + kernel as long as no relocations are present in kernel that mkimage + isn't aware of (in which case mkimage aborts). + This also allows simple assembly to do the relocs. +*/ + +#define RAW_SEPARATOR 0xfffffffe +#define RAW_END_MARKER 0xffffffff + +static void +finish_reloc_translation_raw (struct translate_context *ctx, struct grub_mkimage_layout *layout, + const struct grub_install_image_target_desc *image_target) +{ + size_t count = 0, sz; + enum raw_reloc_type highest = RAW_RELOC_NONE; + enum raw_reloc_type curtype; + struct raw_reloc *cur; + grub_uint32_t *p; + if (!ctx->raw_relocs) + { + layout->reloc_section = p = xmalloc (sizeof (grub_uint32_t)); + p[0] = RAW_END_MARKER; + layout->reloc_size = sizeof (grub_uint32_t); + return; + } + for (cur = ctx->raw_relocs; cur; cur = cur->next) + { + count++; + if (cur->type > highest) + highest = cur->type; + } + /* highest separators, count relocations and one end marker. */ + sz = (highest + count + 1) * sizeof (grub_uint32_t); + layout->reloc_section = p = xmalloc (sz); + for (curtype = 0; curtype <= highest; curtype++) + { + /* Support for special cases would go here. */ + for (cur = ctx->raw_relocs; cur; cur = cur->next) + if (cur->type == curtype) + { + *p++ = cur->offset; + } + *p++ = RAW_SEPARATOR; + } + *--p = RAW_END_MARKER; + layout->reloc_size = sz; +} + +static void +finish_reloc_translation (struct translate_context *ctx, struct grub_mkimage_layout *layout, + const struct grub_install_image_target_desc *image_target) +{ + if (image_target->id == IMAGE_EFI) + finish_reloc_translation_pe (ctx, layout, image_target); + else + finish_reloc_translation_raw (ctx, layout, image_target); +} + + static void translate_reloc_jumpers (struct translate_context *ctx, Elf_Addr jumpers, grub_size_t njumpers, const struct grub_install_image_target_desc *image_target) { unsigned i; + assert (image_target->id == IMAGE_EFI); for (i = 0; i < njumpers; i++) ctx->current_address = add_fixup_entry (&ctx->lst, GRUB_PE32_REL_BASED_DIR64, @@ -1403,14 +1564,13 @@ make_reloc_section (Elf_Ehdr *e, struct grub_mkimage_layout *layout, Elf_Addr *section_addresses, Elf_Shdr *sections, Elf_Half section_entsize, Elf_Half num_sections, const char *strtab, - Elf_Addr jumpers, grub_size_t njumpers, const struct grub_install_image_target_desc *image_target) { unsigned i; Elf_Shdr *s; struct translate_context ctx; - translate_reloc_start (&ctx); + translate_reloc_start (&ctx, image_target); for (i = 0, s = sections; i < num_sections; i++, s = (Elf_Shdr *) ((char *) s + section_entsize)) @@ -1451,7 +1611,10 @@ make_reloc_section (Elf_Ehdr *e, struct grub_mkimage_layout *layout, } if (image_target->elf_target == EM_IA_64) - translate_reloc_jumpers (&ctx, jumpers, njumpers, + translate_reloc_jumpers (&ctx, + layout->ia64jmp_off + + image_target->vaddr_offset, + 2 * layout->ia64jmpnum + (layout->got_size / 8), image_target); finish_reloc_translation (&ctx, layout, image_target); @@ -1462,7 +1625,7 @@ make_reloc_section (Elf_Ehdr *e, struct grub_mkimage_layout *layout, static int SUFFIX (is_text_section) (Elf_Shdr *s, const struct grub_install_image_target_desc *image_target) { - if (image_target->id != IMAGE_EFI + if (!is_relocatable (image_target) && grub_target_to_host32 (s->sh_type) != SHT_PROGBITS) return 0; return ((grub_target_to_host (s->sh_flags) & (SHF_EXECINSTR | SHF_ALLOC)) @@ -1473,7 +1636,7 @@ SUFFIX (is_text_section) (Elf_Shdr *s, const struct grub_install_image_target_de static int SUFFIX (is_data_section) (Elf_Shdr *s, const struct grub_install_image_target_desc *image_target) { - if (image_target->id != IMAGE_EFI + if (!is_relocatable (image_target) && grub_target_to_host32 (s->sh_type) != SHT_PROGBITS) return 0; return ((grub_target_to_host (s->sh_flags) & (SHF_EXECINSTR | SHF_ALLOC)) @@ -1536,14 +1699,13 @@ SUFFIX (put_section) (Elf_Shdr *s, int i, into .text and .data, respectively. Return the array of section addresses. */ static Elf_Addr * -SUFFIX (locate_sections) (const char *kernel_path, +SUFFIX (locate_sections) (Elf_Ehdr *e, const char *kernel_path, Elf_Shdr *sections, Elf_Half section_entsize, Elf_Half num_sections, const char *strtab, struct grub_mkimage_layout *layout, const struct grub_install_image_target_desc *image_target) { int i; - Elf_Addr current_address; Elf_Addr *section_addresses; Elf_Shdr *s; @@ -1555,7 +1717,7 @@ SUFFIX (locate_sections) (const char *kernel_path, section_addresses = xmalloc (sizeof (*section_addresses) * num_sections); memset (section_addresses, 0, sizeof (*section_addresses) * num_sections); - current_address = 0; + layout->kernel_size = 0; for (i = 0, s = sections; i < num_sections; @@ -1571,8 +1733,8 @@ SUFFIX (locate_sections) (const char *kernel_path, i++, s = (Elf_Shdr *) ((char *) s + section_entsize)) if (SUFFIX (is_text_section) (s, image_target)) { - current_address = SUFFIX (put_section) (s, i, - current_address, + layout->kernel_size = SUFFIX (put_section) (s, i, + layout->kernel_size, section_addresses, strtab, image_target); @@ -1589,42 +1751,63 @@ SUFFIX (locate_sections) (const char *kernel_path, } } - current_address = ALIGN_UP (current_address + image_target->vaddr_offset, + layout->kernel_size = ALIGN_UP (layout->kernel_size + image_target->vaddr_offset, image_target->section_align) - image_target->vaddr_offset; - layout->exec_size = current_address; + layout->exec_size = layout->kernel_size; /* .data */ for (i = 0, s = sections; i < num_sections; i++, s = (Elf_Shdr *) ((char *) s + section_entsize)) if (SUFFIX (is_data_section) (s, image_target)) - current_address = SUFFIX (put_section) (s, i, - current_address, + layout->kernel_size = SUFFIX (put_section) (s, i, + layout->kernel_size, section_addresses, strtab, image_target); - current_address = ALIGN_UP (current_address + image_target->vaddr_offset, - image_target->section_align) - image_target->vaddr_offset; +#ifdef MKIMAGE_ELF32 + if (image_target->elf_target == EM_ARM) + { + grub_size_t tramp; + layout->kernel_size = ALIGN_UP (layout->kernel_size + image_target->vaddr_offset, + image_target->section_align) - image_target->vaddr_offset; - layout->bss_start = current_address; + layout->kernel_size = ALIGN_UP (layout->kernel_size, 16); + + tramp = arm_get_trampoline_size (e, sections, section_entsize, + num_sections, image_target); + + layout->tramp_off = layout->kernel_size; + layout->kernel_size += ALIGN_UP (tramp, 16); + } +#endif + + layout->bss_start = layout->kernel_size; + layout->end = layout->kernel_size; /* .bss */ for (i = 0, s = sections; i < num_sections; i++, s = (Elf_Shdr *) ((char *) s + section_entsize)) if (SUFFIX (is_bss_section) (s, image_target)) - current_address = SUFFIX (put_section) (s, i, - current_address, - section_addresses, - strtab, - image_target); + layout->end = SUFFIX (put_section) (s, i, + layout->end, + section_addresses, + strtab, + image_target); - current_address = ALIGN_UP (current_address + image_target->vaddr_offset, + layout->end = ALIGN_UP (layout->end + image_target->vaddr_offset, image_target->section_align) - image_target->vaddr_offset; - layout->end = current_address; - layout->kernel_size = current_address; + /* Explicitly initialize BSS + when producing PE32 to avoid a bug in EFI implementations. + Platforms other than EFI and U-boot shouldn't have .bss in + their binaries as we build with -Wl,-Ttext. + */ + if (image_target->id != IMAGE_UBOOT) + layout->kernel_size = layout->end; + return section_addresses; } @@ -1674,7 +1857,7 @@ SUFFIX (grub_mkimage_load_image) (const char *kernel_path, + grub_host_to_target16 (e->e_shstrndx) * section_entsize); strtab = (char *) e + grub_host_to_target_addr (s->sh_offset); - section_addresses = SUFFIX (locate_sections) (kernel_path, + section_addresses = SUFFIX (locate_sections) (e, kernel_path, sections, section_entsize, num_sections, strtab, layout, @@ -1685,7 +1868,7 @@ SUFFIX (grub_mkimage_load_image) (const char *kernel_path, for (i = 0; i < num_sections; i++) section_vaddresses[i] = section_addresses[i] + image_target->vaddr_offset; - if (image_target->id != IMAGE_EFI) + if (!is_relocatable (image_target)) { Elf_Addr current_address = layout->kernel_size; @@ -1706,7 +1889,7 @@ SUFFIX (grub_mkimage_load_image) (const char *kernel_path, grub_util_info ("locating the section %s at 0x%" GRUB_HOST_PRIxLONG_LONG, name, (unsigned long long) current_address); - if (image_target->id != IMAGE_EFI) + if (!is_relocatable (image_target)) current_address = grub_host_to_target_addr (s->sh_addr) - image_target->link_addr; @@ -1724,10 +1907,11 @@ SUFFIX (grub_mkimage_load_image) (const char *kernel_path, if (image_target->id == IMAGE_SPARC64_AOUT || image_target->id == IMAGE_SPARC64_RAW + || image_target->id == IMAGE_UBOOT || image_target->id == IMAGE_SPARC64_CDCORE) layout->kernel_size = ALIGN_UP (layout->kernel_size, image_target->mod_align); - if (image_target->id == IMAGE_EFI) + if (is_relocatable (image_target)) { symtab_section = NULL; for (i = 0, s = sections; @@ -1740,22 +1924,6 @@ SUFFIX (grub_mkimage_load_image) (const char *kernel_path, } if (! symtab_section) grub_util_error ("%s", _("no symbol table")); - -#ifdef MKIMAGE_ELF32 - if (image_target->elf_target == EM_ARM) - { - grub_size_t tramp; - - layout->kernel_size = ALIGN_UP (layout->kernel_size, 16); - - tramp = arm_get_trampoline_size (e, sections, section_entsize, - num_sections, image_target); - - layout->tramp_off = layout->kernel_size; - layout->kernel_size += ALIGN_UP (tramp, 16); - } -#endif - #ifdef MKIMAGE_ELF64 if (image_target->elf_target == EM_IA_64) { @@ -1770,14 +1938,13 @@ SUFFIX (grub_mkimage_load_image) (const char *kernel_path, layout->ia64jmp_off = layout->kernel_size; layout->ia64jmpnum = SUFFIX (count_funcs) (e, symtab_section, - image_target); + image_target); layout->kernel_size += 16 * layout->ia64jmpnum; layout->ia64_got_off = layout->kernel_size; layout->kernel_size += ALIGN_UP (layout->got_size, 16); } #endif - } else { @@ -1788,7 +1955,7 @@ SUFFIX (grub_mkimage_load_image) (const char *kernel_path, out_img = xmalloc (layout->kernel_size + total_module_size); memset (out_img, 0, layout->kernel_size + total_module_size); - if (image_target->id == IMAGE_EFI) + if (is_relocatable (image_target)) { layout->start_address = SUFFIX (relocate_symbols) (e, sections, symtab_section, section_vaddresses, section_entsize, @@ -1796,6 +1963,8 @@ SUFFIX (grub_mkimage_load_image) (const char *kernel_path, (char *) out_img + layout->ia64jmp_off, layout->ia64jmp_off + image_target->vaddr_offset, + layout->bss_start, + layout->end, image_target); if (layout->start_address == (Elf_Addr) -1) grub_util_error ("start symbol is not defined"); @@ -1813,21 +1982,31 @@ SUFFIX (grub_mkimage_load_image) (const char *kernel_path, make_reloc_section (e, layout, section_vaddresses, sections, section_entsize, num_sections, - strtab, layout->ia64jmp_off - + image_target->vaddr_offset, - 2 * layout->ia64jmpnum + (layout->got_size / 8), + strtab, image_target); + if (image_target->id != IMAGE_EFI) + { + out_img = xrealloc (out_img, layout->kernel_size + total_module_size + + ALIGN_UP (layout->reloc_size, image_target->mod_align)); + memcpy (out_img + layout->kernel_size, layout->reloc_section, layout->reloc_size); + memset (out_img + layout->kernel_size + layout->reloc_size, 0, + total_module_size + ALIGN_UP (layout->reloc_size, image_target->mod_align) - layout->reloc_size); + layout->kernel_size += ALIGN_UP (layout->reloc_size, image_target->mod_align); + } } for (i = 0, s = sections; i < num_sections; i++, s = (Elf_Shdr *) ((char *) s + section_entsize)) if (SUFFIX (is_data_section) (s, image_target) - || SUFFIX (is_bss_section) (s, image_target) + /* Explicitly initialize BSS + when producing PE32 to avoid a bug in EFI implementations. + Platforms other than EFI and U-boot shouldn't have .bss in + their binaries as we build with -Wl,-Ttext. + */ + || (SUFFIX (is_bss_section) (s, image_target) && (image_target->id != IMAGE_UBOOT)) || SUFFIX (is_text_section) (s, image_target)) { - /* Explicitly initialize BSS - when producing PE32 to avoid a bug in EFI implementations. */ if (grub_target_to_host32 (s->sh_type) == SHT_NOBITS) memset (out_img + section_addresses[i], 0, grub_host_to_target_addr (s->sh_size)); diff --git a/util/mkimage.c b/util/mkimage.c index ab58d34c0..9ad4cfe42 100644 --- a/util/mkimage.c +++ b/util/mkimage.c @@ -88,6 +88,7 @@ static const struct grub_install_image_target_desc image_targets[] = .decompressor_compressed_size = TARGET_NO_FIELD, .decompressor_uncompressed_size = TARGET_NO_FIELD, .decompressor_uncompressed_addr = TARGET_NO_FIELD, + .reloc_table_offset = TARGET_NO_FIELD, .section_align = 1, .vaddr_offset = 0, .link_addr = GRUB_KERNEL_I386_COREBOOT_LINK_ADDR, @@ -527,7 +528,6 @@ static const struct grub_install_image_target_desc image_targets[] = .decompressor_uncompressed_addr = TARGET_NO_FIELD, .section_align = GRUB_KERNEL_ARM_UBOOT_MOD_ALIGN, .vaddr_offset = 0, - .link_addr = GRUB_KERNEL_ARM_UBOOT_LINK_ADDR, .elf_target = EM_ARM, .mod_gap = GRUB_KERNEL_ARM_UBOOT_MOD_GAP, .mod_align = GRUB_KERNEL_ARM_UBOOT_MOD_ALIGN, @@ -1522,9 +1522,9 @@ grub_install_generate_image (const char *dir, const char *prefix, hdr->ih_magic = grub_cpu_to_be32_compile_time (GRUB_UBOOT_IH_MAGIC); hdr->ih_time = grub_cpu_to_be32 (STABLE_EMBEDDING_TIMESTAMP); hdr->ih_size = grub_cpu_to_be32 (core_size); - hdr->ih_load = grub_cpu_to_be32 (image_target->link_addr); - hdr->ih_ep = grub_cpu_to_be32 (image_target->link_addr); - hdr->ih_type = GRUB_UBOOT_IH_TYPE_KERNEL; + hdr->ih_load = 0; + hdr->ih_ep = 0; + hdr->ih_type = GRUB_UBOOT_IH_TYPE_KERNEL_NOLOAD; hdr->ih_os = GRUB_UBOOT_IH_OS_LINUX; hdr->ih_arch = GRUB_UBOOT_IH_ARCH_ARM; hdr->ih_comp = GRUB_UBOOT_IH_COMP_NONE; From 0f076d75d04d76ab83e8472715eec71da0cb55ff Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Tue, 23 Feb 2016 12:06:48 +0100 Subject: [PATCH 718/722] ehci: Fix memory coherence This is a no-op on x86 but necessarry on ARM and may be necessarry on MIPS. --- grub-core/bus/usb/ehci.c | 41 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/grub-core/bus/usb/ehci.c b/grub-core/bus/usb/ehci.c index ae1efb214..5f4297bb2 100644 --- a/grub-core/bus/usb/ehci.c +++ b/grub-core/bus/usb/ehci.c @@ -29,6 +29,7 @@ #include #include #include +#include GRUB_MOD_LICENSE ("GPLv3+"); @@ -337,6 +338,21 @@ struct grub_ehci static struct grub_ehci *ehci; +static void +sync_all_caches (struct grub_ehci *e) +{ + if (!e) + return; + if (e->td_virt) + grub_arch_sync_dma_caches (e->td_virt, sizeof (struct grub_ehci_td) * + GRUB_EHCI_N_TD); + if (e->qh_virt) + grub_arch_sync_dma_caches (e->qh_virt, sizeof (struct grub_ehci_qh) * + GRUB_EHCI_N_QH); + if (e->framelist_virt) + grub_arch_sync_dma_caches (e->framelist_virt, 4096); +} + /* EHCC registers access functions */ static inline grub_uint32_t grub_ehci_ehcc_read32 (struct grub_ehci *e, grub_uint32_t addr) @@ -437,6 +453,8 @@ grub_ehci_reset (struct grub_ehci *e) { grub_uint64_t maxtime; + sync_all_caches (e); + grub_ehci_oper_write32 (e, GRUB_EHCI_COMMAND, GRUB_EHCI_CMD_HC_RESET | grub_ehci_oper_read32 (e, GRUB_EHCI_COMMAND)); @@ -840,6 +858,8 @@ grub_ehci_pci_iter (grub_pci_device_t dev, grub_pci_id_t pciid, e->next = ehci; ehci = e; + sync_all_caches (e); + grub_dprintf ("ehci", "EHCI grub_ehci_pci_iter: OK at all\n"); grub_dprintf ("ehci", @@ -1020,6 +1040,7 @@ grub_ehci_find_qh (struct grub_ehci *e, grub_usb_transfer_t transfer) /* Found proper existing (and linked) QH, do setup of QH */ grub_dprintf ("ehci", "find_qh: found, QH=%p\n", qh_iter); grub_ehci_setup_qh (qh_iter, transfer); + sync_all_caches (e); return qh_iter; } @@ -1291,6 +1312,8 @@ grub_ehci_setup_transfer (grub_usb_controller_t dev, struct grub_ehci_transfer_controller_data *cdata; grub_uint32_t status; + sync_all_caches (e); + /* Check if EHCI is running and AL is enabled */ status = grub_ehci_oper_read32 (e, GRUB_EHCI_STATUS); if ((status & GRUB_EHCI_ST_HC_HALTED) != 0) @@ -1399,6 +1422,8 @@ grub_ehci_setup_transfer (grub_usb_controller_t dev, * i.e. reset token */ cdata->qh_virt->td_overlay.token = grub_cpu_to_le32_compile_time (0); + sync_all_caches (e); + /* Finito */ transfer->controller_data = cdata; @@ -1447,6 +1472,8 @@ grub_ehci_parse_notrun (grub_usb_controller_t dev, grub_ehci_free_td (e, cdata->td_alt_virt); grub_free (cdata); + sync_all_caches (e); + /* Additionally, do something with EHCI to make it running (what?) */ /* Try enable EHCI and AL */ grub_ehci_oper_write32 (e, GRUB_EHCI_COMMAND, @@ -1482,6 +1509,8 @@ grub_ehci_parse_halt (grub_usb_controller_t dev, grub_ehci_free_td (e, cdata->td_alt_virt); grub_free (cdata); + sync_all_caches (e); + /* Evaluation of error code - currently we don't have GRUB USB error * codes for some EHCI states, GRUB_USB_ERR_DATA is used for them. * Order of evaluation is critical, specially bubble/stall. */ @@ -1515,6 +1544,8 @@ grub_ehci_parse_success (grub_usb_controller_t dev, grub_ehci_free_td (e, cdata->td_alt_virt); grub_free (cdata); + sync_all_caches (e); + return GRUB_USB_ERR_NONE; } @@ -1528,6 +1559,8 @@ grub_ehci_check_transfer (grub_usb_controller_t dev, transfer->controller_data; grub_uint32_t token, token_ftd; + sync_all_caches (e); + grub_dprintf ("ehci", "check_transfer: EHCI STATUS=%08x, cdata=%p, qh=%p\n", grub_ehci_oper_read32 (e, GRUB_EHCI_STATUS), @@ -1594,6 +1627,9 @@ grub_ehci_cancel_transfer (grub_usb_controller_t dev, int i; grub_uint64_t maxtime; grub_uint32_t qh_phys; + + sync_all_caches (e); + grub_uint32_t interrupt = cdata->qh_virt->ep_cap & GRUB_EHCI_SMASK_MASK; @@ -1613,6 +1649,7 @@ grub_ehci_cancel_transfer (grub_usb_controller_t dev, grub_ehci_free_tds (e, cdata->td_first_virt, transfer, &actual); grub_ehci_free_td (e, cdata->td_alt_virt); grub_free (cdata); + sync_all_caches (e); grub_dprintf ("ehci", "cancel_transfer: end - EHCI not running\n"); return GRUB_USB_ERR_NONE; } @@ -1635,6 +1672,8 @@ grub_ehci_cancel_transfer (grub_usb_controller_t dev, /* Unlink QH from AL */ e->qh_virt[i].qh_hptr = cdata->qh_virt->qh_hptr; + sync_all_caches (e); + /* If this is an interrupt transfer, we just wait for the periodic * schedule to advance a few times and then assume that the EHCI * controller has read the updated QH. */ @@ -1689,6 +1728,8 @@ grub_ehci_cancel_transfer (grub_usb_controller_t dev, grub_dprintf ("ehci", "cancel_transfer: end\n"); + sync_all_caches (e); + return GRUB_USB_ERR_NONE; } From ca028db3d47387bbbd24b40f085751ca98a09183 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Tue, 23 Feb 2016 12:07:01 +0100 Subject: [PATCH 719/722] usbtrans: Fix memory coherence and use-after-free. --- grub-core/bus/usb/usbtrans.c | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/grub-core/bus/usb/usbtrans.c b/grub-core/bus/usb/usbtrans.c index ee8680853..9266e4931 100644 --- a/grub-core/bus/usb/usbtrans.c +++ b/grub-core/bus/usb/usbtrans.c @@ -24,6 +24,7 @@ #include #include #include +#include static inline unsigned int @@ -101,6 +102,8 @@ grub_usb_control_msg (grub_usb_device_t dev, data_addr = grub_dma_get_phys (data_chunk); grub_memcpy ((char *) data, data_in, size); + grub_arch_sync_dma_caches (data, size); + grub_dprintf ("usb", "control: reqtype=0x%02x req=0x%02x val=0x%02x idx=0x%02x size=%lu\n", reqtype, request, value, index, (unsigned long)size); @@ -161,6 +164,8 @@ grub_usb_control_msg (grub_usb_device_t dev, setupdata->value = value; setupdata->index = index; setupdata->length = size; + grub_arch_sync_dma_caches (setupdata, sizeof (*setupdata)); + transfer->transactions[0].size = sizeof (*setupdata); transfer->transactions[0].pid = GRUB_USB_TRANSFER_TYPE_SETUP; transfer->transactions[0].data = setupdata_addr; @@ -202,11 +207,13 @@ grub_usb_control_msg (grub_usb_device_t dev, grub_free (transfer->transactions); grub_free (transfer); - grub_dma_free (data_chunk); grub_dma_free (setupdata_chunk); + grub_arch_sync_dma_caches (data, size0); grub_memcpy (data_in, (char *) data, size0); + grub_dma_free (data_chunk); + return err; } @@ -236,7 +243,10 @@ grub_usb_bulk_setup_readwrite (grub_usb_device_t dev, data = grub_dma_get_virt (data_chunk); data_addr = grub_dma_get_phys (data_chunk); if (type == GRUB_USB_TRANSFER_TYPE_OUT) - grub_memcpy ((char *) data, data_in, size); + { + grub_memcpy ((char *) data, data_in, size); + grub_arch_sync_dma_caches (data, size); + } /* Create a transfer. */ transfer = grub_malloc (sizeof (struct grub_usb_transfer)); @@ -306,9 +316,13 @@ grub_usb_bulk_finish_readwrite (grub_usb_transfer_t transfer) dev->toggle[transfer->endpoint] = toggle; if (transfer->dir == GRUB_USB_TRANSFER_TYPE_IN) - grub_memcpy (transfer->data, (void *) - grub_dma_get_virt (transfer->data_chunk), - transfer->size + 1); + { + grub_arch_sync_dma_caches (grub_dma_get_virt (transfer->data_chunk), + transfer->size + 1); + grub_memcpy (transfer->data, (void *) + grub_dma_get_virt (transfer->data_chunk), + transfer->size + 1); + } grub_free (transfer->transactions); grub_dma_free (transfer->data_chunk); From 51f375d688529b7c1819ba40188ee52b9333887c Mon Sep 17 00:00:00 2001 From: Leif Lindholm Date: Sat, 27 Feb 2016 13:44:59 +0100 Subject: [PATCH 720/722] efidisk: Respect block_io_protocol buffer alignment Returned from the OpenProtocol operation, the grub_efi_block_io_media structure contains the io_align field, specifying the minimum alignment required for buffers used in any data transfers with the device. Make grub_efidisk_readwrite() allocate a temporary buffer, aligned to this boundary, if the buffer passed to it does not already meet the requirements. Also sanity check the io_align field in grub_efidisk_open() for power-of-two-ness and bail if invalid. --- grub-core/disk/efi/efidisk.c | 48 ++++++++++++++++++++++++++++++------ 1 file changed, 41 insertions(+), 7 deletions(-) diff --git a/grub-core/disk/efi/efidisk.c b/grub-core/disk/efi/efidisk.c index 75bb4a9ca..3b79f7bbc 100644 --- a/grub-core/disk/efi/efidisk.c +++ b/grub-core/disk/efi/efidisk.c @@ -493,8 +493,15 @@ grub_efidisk_open (const char *name, struct grub_disk *disk) m = d->block_io->media; /* FIXME: Probably it is better to store the block size in the disk, and total sectors should be replaced with total blocks. */ - grub_dprintf ("efidisk", "m = %p, last block = %llx, block size = %x\n", - m, (unsigned long long) m->last_block, m->block_size); + grub_dprintf ("efidisk", + "m = %p, last block = %llx, block size = %x, io align = %x\n", + m, (unsigned long long) m->last_block, m->block_size, + m->io_align); + + /* Ensure required buffer alignment is a power of two (or is zero). */ + if (m->io_align & (m->io_align - 1)) + return grub_error (GRUB_ERR_IO, "invalid buffer alignment %d", m->io_align); + disk->total_sectors = m->last_block + 1; /* Don't increase this value due to bug in some EFI. */ disk->max_agglomerate = 0xa0000 >> (GRUB_DISK_CACHE_BITS + GRUB_DISK_SECTOR_BITS); @@ -524,15 +531,42 @@ grub_efidisk_readwrite (struct grub_disk *disk, grub_disk_addr_t sector, { struct grub_efidisk_data *d; grub_efi_block_io_t *bio; + grub_efi_status_t status; + grub_size_t io_align, num_bytes; + char *aligned_buf; d = disk->data; bio = d->block_io; - return efi_call_5 ((wr ? bio->write_blocks : bio->read_blocks), bio, - bio->media->media_id, - (grub_efi_uint64_t) sector, - (grub_efi_uintn_t) size << disk->log_sector_size, - buf); + /* Set alignment to 1 if 0 specified */ + io_align = bio->media->io_align ? bio->media->io_align : 1; + num_bytes = size << disk->log_sector_size; + + if ((grub_addr_t) buf & (io_align - 1)) + { + aligned_buf = grub_memalign (io_align, num_bytes); + if (! aligned_buf) + return GRUB_EFI_OUT_OF_RESOURCES; + if (wr) + grub_memcpy (aligned_buf, buf, num_bytes); + } + else + { + aligned_buf = buf; + } + + status = efi_call_5 ((wr ? bio->write_blocks : bio->read_blocks), bio, + bio->media->media_id, (grub_efi_uint64_t) sector, + (grub_efi_uintn_t) num_bytes, aligned_buf); + + if ((grub_addr_t) buf & (io_align - 1)) + { + if (!wr) + grub_memcpy (buf, aligned_buf, num_bytes); + grub_free (aligned_buf); + } + + return status; } static grub_err_t From 102e435d818e3f9e1718326c3fe55e8459e924f3 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sun, 28 Feb 2016 03:07:27 +0100 Subject: [PATCH 721/722] grub_arch_sync_dma_caches: Accept volatile address --- include/grub/cache.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/include/grub/cache.h b/include/grub/cache.h index a9b3f529c..fc669dfd1 100644 --- a/include/grub/cache.h +++ b/include/grub/cache.h @@ -35,10 +35,11 @@ void EXPORT_FUNC(grub_arch_sync_caches) (void *address, grub_size_t len); #ifndef GRUB_MACHINE_EMU #ifdef _mips -void EXPORT_FUNC(grub_arch_sync_dma_caches) (void *address, grub_size_t len); +void EXPORT_FUNC(grub_arch_sync_dma_caches) (volatile void *address, + grub_size_t len); #else static inline void -grub_arch_sync_dma_caches (void *address __attribute__ ((unused)), +grub_arch_sync_dma_caches (volatile void *address __attribute__ ((unused)), grub_size_t len __attribute__ ((unused))) { } From 8207874e5d0d05159fd8c531c87f0f6e4653b8a6 Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Sun, 28 Feb 2016 03:07:41 +0100 Subject: [PATCH 722/722] Release 2.02~beta3 --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 26d2f33c7..a85b134ec 100644 --- a/configure.ac +++ b/configure.ac @@ -31,7 +31,7 @@ dnl (such as BUILD_CC, BUILD_CFLAGS, etc.) for the build type and variables dnl with the prefix "TARGET_" (such as TARGET_CC, TARGET_CFLAGS, etc.) are dnl used for the target type. See INSTALL for full list of variables. -AC_INIT([GRUB],[2.02~beta2],[bug-grub@gnu.org]) +AC_INIT([GRUB],[2.02~beta3],[bug-grub@gnu.org]) AC_CONFIG_AUX_DIR([build-aux])