]> git.proxmox.com Git - grub2.git/log
grub2.git
6 years agoDisable use of floppy devices
Colin Watson [Mon, 13 Jan 2014 12:12:54 +0000 (12:12 +0000)]
Disable use of floppy devices

An ugly kludge.  Should this be merged upstream?

Author: Robert Millan

Patch-Name: disable_floppies.patch

6 years agoSupport running grub-probe in grub-legacy's update-grub
Robert Millan [Mon, 13 Jan 2014 12:12:53 +0000 (12:12 +0000)]
Support running grub-probe in grub-legacy's update-grub

Author: Colin Watson <cjwatson@debian.org>
Forwarded: not-needed
Last-Update: 2013-12-25

Patch-Name: grub_legacy_0_based_partitions.patch

6 years agoImprove handling of Debian kernel version numbers
Robert Millan [Mon, 13 Jan 2014 12:12:52 +0000 (12:12 +0000)]
Improve handling of Debian kernel version numbers

Forwarded: not-needed
Last-Update: 2013-12-20

Patch-Name: dpkg_version_comparison.patch

6 years agoWrite marker if core.img was written to filesystem
Colin Watson [Mon, 13 Jan 2014 12:12:51 +0000 (12:12 +0000)]
Write marker if core.img was written to filesystem

The Debian bug reporting script includes a warning in this case.

Patch-Name: core_in_fs.patch

6 years agoHack prefix for OLPC
Colin Watson [Mon, 13 Jan 2014 12:12:50 +0000 (12:12 +0000)]
Hack prefix for OLPC

This sucks, but it's better than what OFW was giving us.

Patch-Name: olpc_prefix_hack.patch

6 years agoImport replacement CRC operations from libgcrypt
Colin Watson [Fri, 16 Feb 2018 11:02:19 +0000 (11:02 +0000)]
Import replacement CRC operations from libgcrypt

Mostly backported from
https://git.gnupg.org/cgi-bin/gitweb.cgi?p=libgcrypt.git;a=commitdiff;h=06e122baa3321483a47bbf82fd2a4540becfa0c9,
but importing bufhelp.h from libgcrypt 1.7.0 as well.  We can drop this
once GRUB updates to a newer import of libgcrypt.

The new implementation is not encumbered by the restrictive Internet
Society licence on RFCs.

Bug-Debian: https://bugs.debian.org/745409
Last-Update: 2018-02-16

Patch-Name: replace-libgcrypt-crc.patch

6 years agoRemove RFC-licence-encumbered CRC implementation
Colin Watson [Fri, 16 Feb 2018 10:55:45 +0000 (10:55 +0000)]
Remove RFC-licence-encumbered CRC implementation

We'll replace this with a free version imported from newer versions of
libgcrypt.

https://bugs.debian.org/745409

7 years agoImport grub2_2.02.orig.tar.xz
Colin Watson [Fri, 23 Jun 2017 09:07:51 +0000 (10:07 +0100)]
Import grub2_2.02.orig.tar.xz

7 years agoIncrease version to 2.02.
Vladimir Serbinenko [Tue, 25 Apr 2017 14:23:16 +0000 (16:23 +0200)]
Increase version to 2.02.

7 years agoFix remaining cases of gcc 7 fallthrough warning.
Vladimir Serbinenko [Wed, 12 Apr 2017 01:42:38 +0000 (01:42 +0000)]
Fix remaining cases of gcc 7 fallthrough warning.

They are all intended, so just add the relevant comment.

7 years agoAdd gnulib-fix-gcc7-fallthrough.diff
Andrei Borzenkov [Tue, 4 Apr 2017 16:37:47 +0000 (19:37 +0300)]
Add gnulib-fix-gcc7-fallthrough.diff

As long as the code is not upstream, add it as explicit patch for the
case of gnulib refresh.

7 years agoi386, x86_64, ppc: fix switch fallthrough cases with GCC7
Andrei Borzenkov [Tue, 4 Apr 2017 16:23:55 +0000 (19:23 +0300)]
i386, x86_64, ppc: fix switch fallthrough cases with GCC7

In util/getroot and efidisk slightly modify exitsing comment to mostly
retain it but still make GCC7 compliant with respect to fall through
annotation.

In grub-core/lib/xzembed/xz_dec_lzma2.c it adds same comments as
upstream.

In grub-core/tests/setjmp_tets.c declare functions as "noreturn" to
suppress GCC7 warning.

In grub-core/gnulib/regexec.c use new __attribute__, because existing
annotation is not recognized by GCC7 parser (which requires that comment
immediately precedes case statement).

Otherwise add FALLTHROUGH comment.

Closes: 50598
7 years agobtrfs: avoid "used uninitialized" error with GCC7
Andrei Borzenkov [Tue, 4 Apr 2017 16:22:32 +0000 (19:22 +0300)]
btrfs: avoid "used uninitialized" error with GCC7

sblock was local and so considered new variable on every loop
iteration.

Closes: 50597
7 years agoacpi: add missing efi_call wrapper to acpi command
Andrei Borzenkov [Sun, 2 Apr 2017 11:47:20 +0000 (14:47 +0300)]
acpi: add missing efi_call wrapper to acpi command

Fixed loading of ACPI tables on EFI (side effect was apparent memory
corruption ranging from unpredictable behavior to system reset).

Reported by Nando Eva <nando4eva@ymail.com>

7 years agoIncrement version to GRUB 2.02~rc2.
Vladimir Serbinenko [Wed, 15 Mar 2017 08:20:29 +0000 (09:20 +0100)]
Increment version to GRUB 2.02~rc2.

7 years agoUse core2duo for bootcheck test on 64-bit EFI.
Vladimir Serbinenko [Wed, 15 Mar 2017 08:20:14 +0000 (09:20 +0100)]
Use core2duo for bootcheck test on 64-bit EFI.

Obviously pentium2 can't run efi64.

7 years agoefi: skip iPXE block device.
Andrei Borzenkov [Tue, 14 Mar 2017 04:12:32 +0000 (04:12 +0000)]
efi: skip iPXE block device.

iPXE adds Simple File System Protocol to loaded image handle, as side
effect it also adds Block IO protocol (according to comments, to work
around some bugs in EDK2). GRUB assumes that every device with Block IO
is disk and skips network initialization entirely. But iPXE Block IO
implementation is just a stub which always fails for every operation
so cannot be used. Attempt to detect and skip such devices.

We are using media ID which iPXE sets to "iPXE" and block IO size in
hope that no real device would announce 1B block ...

Closes: 50518
7 years agoxen: Fix wrong register in relocator.
phcoder [Sun, 5 Mar 2017 09:04:07 +0000 (10:04 +0100)]
xen: Fix wrong register in relocator.

This fixes chainloading of some GRUB variants.

7 years agovideo_fb: Fix blue collor if using unoptimized blitter.
Vladimir Serbinenko [Thu, 9 Feb 2017 01:22:24 +0000 (02:22 +0100)]
video_fb: Fix blue collor if using unoptimized blitter.

when unmapping the color what matters is the mode of source, not target.

7 years agolegacy_initrd: Strip any additional arguments to initrd.
Vladimir Serbinenko [Fri, 24 Feb 2017 21:23:09 +0000 (21:23 +0000)]
legacy_initrd: Strip any additional arguments to initrd.

7 years agogrub-fs-tester: improve squash4 tests
Andrei Borzenkov [Sun, 26 Feb 2017 11:38:04 +0000 (14:38 +0300)]
grub-fs-tester: improve squash4 tests

1. Make sure files are not multiple of block size. This will ensure tail packing
for squash4 and may also trigger more codes paths in other filesystems.

2. Call mksquashfs with -always-use-fragments to force tail packing.

7 years agoefi: strip off final NULL from File Path in grub_efi_get_filename
Andrei Borzenkov [Sat, 25 Feb 2017 05:39:38 +0000 (08:39 +0300)]
efi: strip off final NULL from File Path in grub_efi_get_filename

UEFI 2.6 9.3.6.4 File Path Media Device Path says that Path Name is
"A NULL-terminated Path string including directory and file names".

Strip final NULL from Path Name in each File Path node when constructing
full path. To be on safe side, strip all of them.

Fixes failure chainloading grub from grub, when loaded grub truncates
image path and does not find its grub.cfg.

https://bugzilla.opensuse.org/show_bug.cgi?id=1026344

This was triggered by commit ce95549cc54b5d6f494608a7c390dba3aab4fba7;
before it we built Path Name without trailing NULL, and apparently all
other bootloaders use single File Path node, thus not exposing this bug.

7 years agosquash4: fix handling of fragments and sparse files
Andrei Borzenkov [Fri, 24 Feb 2017 16:10:43 +0000 (19:10 +0300)]
squash4: fix handling of fragments and sparse files

1. Do not assume block list and fragment are mutually exclusive. Squash
can pack file tail as fragment (unless -no-fragments is specified); so
check read offset and read either from block list or from fragments as
appropriate.

2. Support sparse files with zero blocks.

3. Fix fragment read - frag.offset is absolute fragment position,
not offset relative to ino.chunk.

Reported and tested by Carlo Caione <carlo@endlessm.com>

7 years agoWhitelist sparc64-ieee1275 as having no video modules.
Vladimir Serbinenko [Wed, 22 Feb 2017 08:55:51 +0000 (09:55 +0100)]
Whitelist sparc64-ieee1275 as having no video modules.

ieee1275_fb is not built on sparc64 due to virtual address issues.

7 years agoscript: fix double free in lexer
Andrei Borzenkov [Sun, 12 Feb 2017 06:23:34 +0000 (09:23 +0300)]
script: fix double free in lexer

yylex_destroy() already frees scanner.

Found by: Coverity scan.
CID: 176636

7 years agoxen: Fix parsing of XZ kernel.
Vladimir Serbinenko [Mon, 6 Feb 2017 23:47:23 +0000 (00:47 +0100)]
xen: Fix parsing of XZ kernel.

In case of xz, the uncompressed size is appended to xz data which confuses
our xz decompressor. Trim it.

7 years agoxen: Fix handling of GRUB chainloading.
Vladimir Serbinenko [Mon, 6 Feb 2017 23:42:43 +0000 (00:42 +0100)]
xen: Fix handling of GRUB chainloading.

In case of GRUB we put remapper after domain pages and not at 0x0.
In this case we use max_addr to put remapper. Unfortunately we increment
max_addr as well in this case resulting in virt mapping mapping page
at old max_addr and trying to boot using new max_addr.

Closes 46014.

7 years agolinguas: Don't skip ko.po.
Vladimir Serbinenko [Fri, 3 Feb 2017 23:06:57 +0000 (00:06 +0100)]
linguas: Don't skip ko.po.

Translation project doesn't require copyright disclaimers. They're independant
from us. They're responsible for their copyright story.

7 years agoFix truncated checksum.h.
Vladimir Serbinenko [Fri, 3 Feb 2017 19:17:48 +0000 (20:17 +0100)]
Fix truncated checksum.h.

7 years agoRegenerate checksums.h
Vladimir Serbinenko [Fri, 3 Feb 2017 12:41:13 +0000 (13:41 +0100)]
Regenerate checksums.h

Screenshots contain version, so we need new checksums.

7 years agoRelease 2.02-rc1.
Vladimir Serbinenko [Fri, 3 Feb 2017 11:34:21 +0000 (12:34 +0100)]
Release 2.02-rc1.

7 years agoFix mingw compilation.
Vladimir Serbinenko [Fri, 3 Feb 2017 11:59:50 +0000 (12:59 +0100)]
Fix mingw compilation.

7 years agodocumentation: Clarify documentation for special environment variable "default".
Daniel Kahn Gillmor [Fri, 3 Feb 2017 11:32:25 +0000 (12:32 +0100)]
documentation: Clarify documentation for special environment variable "default".

The current documentation for the special environment variable
"default" is confusing and unclear.  This patch attempts to clean it
up.

In particular, the current documentation refers to the "number or
title", but then in the example it gives, the menu entries and
submenus all have numbers *in* their title; furthermore, there is no
example given about how to choose the number, or any indication about
whether counting is zero-indexed or 1-indexed.

Having a cleaner example and presenting all variants (numeric, title,
and id) should make it clearer to the user.

Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
7 years agoAvoid causing kernel oops in nilfs2 test.
Vladimir Serbinenko [Thu, 2 Feb 2017 23:34:07 +0000 (00:34 +0100)]
Avoid causing kernel oops in nilfs2 test.

1024-byte and 2048-byte blocks don't really work with some kernels, skip
them as we don't want any oops'es.

7 years agobtrfs: Shorten label by one character.
Vladimir Serbinenko [Thu, 2 Feb 2017 23:30:29 +0000 (00:30 +0100)]
btrfs: Shorten label by one character.

mkfs.btrfs imposes a slightly lower limit than would be possible in btrfs.

7 years agogrub-fs-tester: Fix mkudffs invocation.
Vladimir Serbinenko [Thu, 2 Feb 2017 22:32:38 +0000 (23:32 +0100)]
grub-fs-tester: Fix mkudffs invocation.

With current invocation order of arguments is wrong and path is hardcoded.

7 years agogrub-fs-tester: Fix fat test.
Vladimir Serbinenko [Thu, 2 Feb 2017 22:19:00 +0000 (23:19 +0100)]
grub-fs-tester: Fix fat test.

mkfs.vfat ignores -S when invoked on a disk, including loopback device,
so do an mkfs on underlying image.

7 years agoi386/relocator: Align stack in grub_relocator64_efi relocator
Daniel Kiper [Thu, 2 Feb 2017 14:19:18 +0000 (15:19 +0100)]
i386/relocator: Align stack in grub_relocator64_efi relocator

Unified Extensible Firmware Interface Specification, Version 2.6,
section 2.3.4, x64 Platforms, boot services, says among others:
The stack must be 16-byte aligned. So, do it. Otherwise OS may
boot only by chance as it happens right now.

Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>
7 years agoi386-ieee1275: Add missing bootcheck target.
Vladimir Serbinenko [Thu, 2 Feb 2017 20:41:33 +0000 (21:41 +0100)]
i386-ieee1275: Add missing bootcheck target.

7 years agobootcheck-linux-i386: Use -cpu pentium2.
Vladimir Serbinenko [Thu, 2 Feb 2017 20:41:18 +0000 (21:41 +0100)]
bootcheck-linux-i386: Use -cpu pentium2.

Most modern kernels are compiled for i686, so use -cpu pentium2
to avoid spurious failures.

7 years agoUse -fPIC with arm64 with clang.
Vladimir Serbinenko [Thu, 2 Feb 2017 00:24:11 +0000 (01:24 +0100)]
Use -fPIC with arm64 with clang.

Currently it doesn't work either way but with -fPIC it should work once
clang bug is fixed.

7 years agoINSTALL: Fix mention of thumb-clang.
Vladimir Serbinenko [Thu, 2 Feb 2017 00:11:52 +0000 (01:11 +0100)]
INSTALL: Fix mention of thumb-clang.

7 years agoFix thumb compilation with clang.
Vladimir Serbinenko [Wed, 1 Feb 2017 23:59:49 +0000 (00:59 +0100)]
Fix thumb compilation with clang.

According to EABI only STT_FUNC has convention of lowest bit indicating
execution mode. R_THM_{JUMP,CALL}* relocations are assumed to be pointing
to thumb mode unless they use STT_FUNC.

7 years agoAdd missing strtoull_test.c
Vladimir Serbinenko [Wed, 1 Feb 2017 20:50:17 +0000 (21:50 +0100)]
Add missing strtoull_test.c

It was forgotten in my local directory.

7 years agoarm64: Add support for GOT and PCREL32 relocations.
Vladimir Serbinenko [Wed, 1 Feb 2017 20:46:19 +0000 (21:46 +0100)]
arm64: Add support for GOT and PCREL32 relocations.

7 years agomkimage: Fix memory leak.
Vladimir Serbinenko [Wed, 1 Feb 2017 20:21:17 +0000 (21:21 +0100)]
mkimage: Fix memory leak.

7 years agoarm/arm64: Fix improper use of start address.
Vladimir Serbinenko [Wed, 1 Feb 2017 19:12:07 +0000 (20:12 +0100)]
arm/arm64: Fix improper use of start address.

It was used instead of loading address of current section or of entire buffer.

7 years agoia64: Fix iterator for relocation entries.
Vladimir Serbinenko [Wed, 1 Feb 2017 19:10:26 +0000 (20:10 +0100)]
ia64: Fix iterator for relocation entries.

Don't assume relocation entry size and use sh_entsize properly.

7 years agoarm: Fix trampoline generation.
Vladimir Serbinenko [Wed, 1 Feb 2017 14:58:36 +0000 (15:58 +0100)]
arm: Fix trampoline generation.

We used the wrong pointer in this case. It worked only by accident.

7 years agoFix bootcheck-related files compilation.
Vladimir Serbinenko [Wed, 1 Feb 2017 14:57:08 +0000 (15:57 +0100)]
Fix bootcheck-related files compilation.

We need -static as otherwise linker will set interpreter field and ld.so
is not available on our initrd's.
Strip all sections we don't need on binary tests.

7 years agoRegenerate checksum.h.
Vladimir Serbinenko [Tue, 31 Jan 2017 21:36:11 +0000 (22:36 +0100)]
Regenerate checksum.h.

Screenshots checked.
Using unifont from http://ftp.us.debian.org/debian/pool/main/u/unifont/xfonts-unifont_7.0.06-1_all.deb.

7 years agogrub-mkfont: Remove leftover debug statement.
Vladimir Serbinenko [Tue, 31 Jan 2017 21:32:21 +0000 (22:32 +0100)]
grub-mkfont: Remove leftover debug statement.

7 years agocharset: Trim away RLM and LRM.
Vladimir Serbinenko [Tue, 31 Jan 2017 18:29:31 +0000 (19:29 +0100)]
charset: Trim away RLM and LRM.

They are not visible but would otherwise end up as [LRM] or [RLM] squares
with some fonts.

7 years agogfxterm: Fix clearing of cursor.
Vladimir Serbinenko [Tue, 31 Jan 2017 17:49:37 +0000 (18:49 +0100)]
gfxterm: Fix clearing of cursor.

If ascent is bigger than height - 2, then we draw over character box but then
to clear cursor we only draw over character box. So trim ascent if necessarry.

7 years agoia64: Add support for R_IA64_GPREL64I.
Vladimir Serbinenko [Tue, 31 Jan 2017 11:39:01 +0000 (12:39 +0100)]
ia64: Add support for R_IA64_GPREL64I.

Recent GCC generates those relocations, so we need to support them.

7 years agogrub-module-verifier: Add mips to all_video whitelist.
Vladimir Serbinenko [Mon, 30 Jan 2017 18:52:58 +0000 (19:52 +0100)]
grub-module-verifier: Add mips to all_video whitelist.

On MIPS video is compiled-in. So all_video is empty. Whitelist it.

7 years agoFix -nopie/-nopie check.
Vladimir Serbinenko [Mon, 30 Jan 2017 13:38:50 +0000 (14:38 +0100)]
Fix -nopie/-nopie check.

We don't use lgcc_s but missing lgcc_s or another library cause test to fail.
So use -nostdlib.
We need to use -Werror to avoid warning-generated case to be accepted.
Clang uses -nopie rather than -no-pie. Check both and use whichever one works.
Additionally android clang passes -pie to the linker even though it doesn't
define __PIE__. So if compilation without no-pie logic fails add -nopie/-no-pie
even if __PIE__ is not defined.

7 years agogrub-module-verifier: Ignore all_video emptiness on xen.
Vladimir Serbinenko [Mon, 30 Jan 2017 00:13:41 +0000 (00:13 +0000)]
grub-module-verifier: Ignore all_video emptiness on xen.

It's intentional that it's empty when no video modules
are available.

7 years agoSupport arm clang 3.8 amd later.
Vladimir Serbinenko [Sat, 28 Jan 2017 14:41:23 +0000 (14:41 +0000)]
Support arm clang 3.8 amd later.

clang 3.8 and later doesn't support -mllvm -use-arm-movt=0
whereas older clang doesn't know -mno-movt. So use
-mno-movt whenever possible and fallback to mllvm variant.

7 years agoexfat: Support files over 4GiB
Carlo Caione [Fri, 27 Jan 2017 22:10:21 +0000 (22:10 +0000)]
exfat: Support files over 4GiB

file size in grub_fat_data was 32-bit on exfat.

7 years agoEnsure that grub_reboot doesn't return on emu.
Vladimir Serbinenko [Mon, 23 Jan 2017 20:32:25 +0000 (23:32 +0300)]
Ensure that grub_reboot doesn't return on emu.

Use grub_fatal if longjmp fails.

grub_reboot is marked as noreturn so return would cause
a crash.

7 years agogrub-shell: skip font copying when no font is available.
Vladimir Serbinenko [Mon, 23 Jan 2017 18:25:25 +0000 (21:25 +0300)]
grub-shell: skip font copying when no font is available.

7 years agoDon't use -mlong-calls on arm.
Vladimir Serbinenko [Mon, 23 Jan 2017 20:57:23 +0000 (23:57 +0300)]
Don't use -mlong-calls on arm.

We don't really need it and it's flaky and creates
bogus symbols with clang.

7 years agoconfigure: Disable movw/movt with clang.
Vladimir Serbinenko [Sun, 22 Jan 2017 21:52:32 +0000 (00:52 +0300)]
configure: Disable movw/movt with clang.

Those relocations are not compatible with PE and also
not compatible with custom uboot relocator.
Disable them.

7 years agogrub-fs-tester: Delete directory once we're done.
Vladimir Serbinenko [Fri, 27 Jan 2017 18:00:40 +0000 (18:00 +0000)]
grub-fs-tester: Delete directory once we're done.

7 years agogrub-fs-tester: Accomodate for slower systems.
Vladimir Serbinenko [Fri, 27 Jan 2017 17:58:15 +0000 (17:58 +0000)]
grub-fs-tester: Accomodate for slower systems.

fstime can be more different with xz squashfs.
Allow difference up to 3 seconds.
This code is ugly now but rewriting it now is not on the
table.

7 years agogrub-fs-tester: Accomodate for testing in proot containers.
Vladimir Serbinenko [Fri, 27 Jan 2017 17:46:47 +0000 (17:46 +0000)]
grub-fs-tester: Accomodate for testing in proot containers.

proot creates hidden files with .proot prefix and name
derived from real file name. So decrease file name length
and path depth. For some reason depth 85 also results in
undeleteable directory, so use 84 instead of 85.

7 years agoosdep/linux: handle autofs entries in /proc/self/mountinfo
Andrei Borzenkov [Tue, 24 Jan 2017 17:05:19 +0000 (20:05 +0300)]
osdep/linux: handle autofs entries in /proc/self/mountinfo

These entries have placeholder for device name and so are useless for our
purpose. grub failed with something like

grub-install: error: failed to get canonical path of `systemd-1'.

When we see autofs entry, record it (to keep parent-child relationship) but
continue to look for real mount. If it is found, we process it as usual. If
only autofs entry exists, attempt to trigger mount by opening mount point
and retry. Mount point itself is then kept open to avoid timeout.

Recent systemd is by default using automount for /boot/efi so this should
become more popular problem on EFI systems.

Closes: 49942
7 years agolinux: fix "vga=XX deprecated" warning for text mode
Andrei Borzenkov [Sun, 8 Jan 2017 12:52:49 +0000 (15:52 +0300)]
linux: fix "vga=XX deprecated" warning for text mode

Arguments were in reverse order which resulted in

text is deprecated. Use set gfxpayload=vga=0 before linux command instead.

7 years agoconfigure: fix check for sys/sysmacros.h under glibc 2.25+
Andrei Borzenkov [Thu, 22 Dec 2016 19:48:25 +0000 (22:48 +0300)]
configure: fix check for sys/sysmacros.h under glibc 2.25+

glibc 2.25 still includes sys/sysmacros.h in sys/types.h but also emits
deprecation warning. So test for sys/types.h succeeds in configure but later
compilation fails because we use -Werror by default.

While this is fixed in current autoconf GIT, we really cannot force everyone
to use bleeding edge (that is not even released right now). So run test under
-Werror as well to force proper detection.

This should have no impact on autoconf 2.70+ as AC_HEADER_MAJOR in this version
simply checks for header existence.

Reported and tested by Khem Raj <raj.khem@gmail.com>

7 years agoFix fwpath in efi netboot
Michael Chang [Mon, 19 Dec 2016 09:09:04 +0000 (17:09 +0800)]
Fix fwpath in efi netboot

The path returned by grub_efi_net_config has already been stripped for the
directory part extracted from cached bootp packet. We should just return the
result to avoild it be stripped again.

It fixed the problem that grub.efi as NBP image always looking for grub.cfg and
platform directory in upper folder rather than current one it gets loaded while
$prefix is empty. The behavior is inconsistent with other architecture and how
we would expect empty $prefix going to be in general.

The only exception to the general rule of empty $prefix is that when loaded
from platform directory itself, the platform part is stripped thus upper folder
is used for looking up files. It meets the case for how grub-mknetdir lay out
the files under tftp root directory, but also hide away this issue to be
identified as it appears to be just works.

Also fix possible memory leak by moving grub_efi_get_filename() call after
grub_efi_net_config().

7 years agoefi: properly terminate filepath with NULL in chainloader
Andrei Borzenkov [Thu, 15 Dec 2016 13:07:00 +0000 (16:07 +0300)]
efi: properly terminate filepath with NULL in chainloader

EFI File Path Media Device Path is defined as NULL terminated string;
but chainloader built file paths without final NULL. This caused error
with Secure Boot and Linux Foundation PreLoader on Acer with InsydeH20 BIOS.
Apparently firmware failed verification with EFI_INVALID_PARAMETER which is
considered fatal error by PreLoader.

Reported and tested by Giovanni Santini <itachi.sama.amaterasu@gmail.com>

7 years agoconfigure: add check for -no-pie if the compiler default to -fPIE
Magnus Granberg [Wed, 14 Dec 2016 17:44:41 +0000 (20:44 +0300)]
configure: add check for -no-pie if the compiler default to -fPIE

When Grub is compile with gcc 6.1 that have --enable-defult-pie set.
It fail with.
-ffreestanding   -m32 -Wl,-melf_i386 -Wl,--build-id=none  -nostdlib -Wl,-N -Wl,-r,-d   -
o trig.module  trig_module-trigtables.o
grep 'MARKER' gcry_whirlpool.marker.new > gcry_whirlpool.marker; rm -f
gcry_whirlpool.marker.new
/usr/lib/gcc/x86_64-pc-linux-gnu/6.1.0/../../../../x86_64-pc-linux-gnu/bin/ld: -r and -
shared may not be used together
collect2: error: ld returned 1 exit status
Makefile:26993: recipe for target 'trig.module' failed

Check that compiler supports -no-pie and add it to linker flags.

7 years agoofnet: implement the receive buffer
Stanislav Kholmanskikh [Mon, 12 Dec 2016 15:03:39 +0000 (18:03 +0300)]
ofnet: implement the receive buffer

get_card_packet() from ofnet.c allocates a netbuff based on the device's MTU:

 nb = grub_netbuff_alloc (dev->mtu + 64 + 2);

In the case when the MTU is large, and the received packet is
relatively small, this leads to allocation of significantly more memory,
than it's required. An example could be transmission of TFTP packets
with 0x400 blksize via a network card with 0x10000 MTU.

This patch implements a per-card receive buffer in a way similar to efinet.c,
and makes get_card_packet() allocate a netbuff of the received data size.

Signed-off-by: Stanislav Kholmanskikh <stanislav.kholmanskikh@oracle.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
7 years agoofnet: move the allocation of the transmit buffer into a function
Stanislav Kholmanskikh [Mon, 12 Dec 2016 15:03:38 +0000 (18:03 +0300)]
ofnet: move the allocation of the transmit buffer into a function

In the current code search_net_devices() uses the "alloc-mem" command
from the IEEE1275 User Interface for allocation of the transmit buffer
for the case when GRUB_IEEE1275_FLAG_VIRT_TO_REAL_BROKEN is set.

I don't have hardware where this flag is set to verify if this
workaround is still needed. However, further changes to ofnet will
require to execute this workaround one more time. Therefore, to
avoid possible duplication of code I'm moving this piece of
code into a function.

Signed-off-by: Stanislav Kholmanskikh <stanislav.kholmanskikh@oracle.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
7 years agoefi: Move fdt helper into own file
Alexander Graf [Mon, 21 Nov 2016 15:23:02 +0000 (16:23 +0100)]
efi: Move fdt helper into own file

We only support FDT files with EFI on arm and arm64 systems, not
on x86. So move the helper that finds a prepopulated FDT UUID
into its own file and only build it for architectures where it
also gets called.

Signed-off-by: Alexander Graf <agraf@suse.de>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
7 years agoNEWS updates
Andrei Borzenkov [Tue, 22 Nov 2016 17:51:54 +0000 (20:51 +0300)]
NEWS updates

7 years agobootp: export next server IP as environment variable
Andrei Borzenkov [Tue, 22 Nov 2016 17:42:23 +0000 (20:42 +0300)]
bootp: export next server IP as environment variable

Network boot autoconfiguration sets default server to next server IP
(siaddr) from BOOTP/DHCP reply, but manual configuration using net_bootp
exports only server name. Unfortunately semantic of server name is not
clearly defined. BOOTP RFC 951 defines it only for client request, and
DHCP RFC 1541 only mentions it, without any implied usage. It looks like
this field is mostly empty in server replies.

Export next server IP as net_<interface>_next_server variable. This allows
grub configuration script to set $root/$prefix based on information obtained
by net_bootp.

Reported and tested by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com>
Cc: nikunj@linux.vnet.ibm.com
v2: change variable name to net_<interface>_next_server as discussed on the list

7 years agoconfigure.ac: don't require build time grub-mkfont on powerpc-ieee1275
Aaro Koskinen [Wed, 9 Nov 2016 21:26:43 +0000 (23:26 +0200)]
configure.ac: don't require build time grub-mkfont on powerpc-ieee1275

Don't require build time grub-mkfont on powerpc-ieee1275.

Signed-off-by: Aaro Koskinen <aaro.koskinen@iki.fi>
7 years agogrub-mknetdir: Add support for ARM64 EFI
Dirk Mueller [Tue, 11 Oct 2016 20:19:02 +0000 (22:19 +0200)]
grub-mknetdir: Add support for ARM64 EFI

7 years ago.gitignore: Add grub-core/build-grub-module-verifier
Joonas Lahtinen [Thu, 10 Nov 2016 13:45:38 +0000 (15:45 +0200)]
.gitignore: Add grub-core/build-grub-module-verifier

Signed-off-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
7 years agoarm efi: Use fdt from firmware when available
Alexander Graf [Sun, 28 Feb 2016 23:22:24 +0000 (00:22 +0100)]
arm efi: Use fdt from firmware when available

If EFI is nice enough to pass us an FDT using configuration tables on 32bit
ARM, we should really try and make use of it.

Signed-off-by: Alexander Graf <agraf@suse.de>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
7 years agoarm64: Move firmware fdt search into global function
Alexander Graf [Sun, 28 Feb 2016 23:22:23 +0000 (00:22 +0100)]
arm64: Move firmware fdt search into global function

Searching for a device tree that EFI passes to us via configuration tables
is nothing architecture specific. Move it into generic code.

Signed-off-by: Alexander Graf <agraf@suse.de>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
7 years agofix detection of non-LUKS CRYPT
Corey Hickey [Sat, 5 Nov 2016 04:58:14 +0000 (21:58 -0700)]
fix detection of non-LUKS CRYPT

grub_util_get_dm_abstraction() does a string comparison of insufficient
length. When using a UUID such as "CRYPT-PLAIN-sda6_crypt", the function
returns GRUB_DEV_ABSTRACTION_LUKS.

This results in the error:
    ./grub-probe: error: disk `cryptouuid/sda6_crypt' not found.

This appears to be a copy/paste error introduced in:
a10e7a5a8918bea6e2632055129fa9b516fe965a

The bug was (apparently) latent until revealed by:
3bca85b4184f74995a7cc2791e432173fde26d34

Signed-off-by: Corey Hickey <bugfood-c@fatooh.org>
7 years agoxen: add capability to load p2m list outside of kernel mapping
Juergen Gross [Thu, 3 Mar 2016 09:38:16 +0000 (10:38 +0100)]
xen: add capability to load p2m list outside of kernel mapping

Modern pvops linux kernels support a p2m list not covered by the
kernel mapping. This capability is flagged by an elf-note specifying
the virtual address the kernel is expecting the p2m list to be mapped
to.

In case the elf-note is set by the kernel don't place the p2m list
into the kernel mapping, but map it to the given address. This will
allow to support domains with larger memory, as the kernel mapping is
limited to 2GB and a domain with huge memory in the TB range will have
a p2m list larger than this.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
7 years agoxen: modify page table construction
Juergen Gross [Thu, 3 Mar 2016 09:38:15 +0000 (10:38 +0100)]
xen: modify page table construction

Modify the page table construction to allow multiple virtual regions
to be mapped. This is done as preparation for removing the p2m list
from the initial kernel mapping in order to support huge pv domains.

This allows a cleaner approach for mapping the relocator page by
using this capability.

The interface to the assembler level of the relocator has to be changed
in order to be able to process multiple page table areas.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
7 years agoxen: add capability to load initrd outside of initial mapping
Juergen Gross [Thu, 3 Mar 2016 09:38:14 +0000 (10:38 +0100)]
xen: add capability to load initrd outside of initial mapping

Modern pvops linux kernels support an initrd not covered by the initial
mapping. This capability is flagged by an elf-note.

In case the elf-note is set by the kernel don't place the initrd into
the initial mapping. This will allow to load larger initrds and/or
support domains with larger memory, as the initial mapping is limited
to 2GB and it is containing the p2m list.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
7 years agoxen: factor out allocation of page tables into separate function
Juergen Gross [Thu, 3 Mar 2016 09:38:13 +0000 (10:38 +0100)]
xen: factor out allocation of page tables into separate function

Do the allocation of page tables in a separate function. This will
allow to do the allocation at different times of the boot preparations
depending on the features the kernel is supporting.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
7 years agoxen: factor out allocation of special pages into separate function
Juergen Gross [Thu, 3 Mar 2016 09:38:12 +0000 (10:38 +0100)]
xen: factor out allocation of special pages into separate function

Do the allocation of special pages (start info, console and xenbus
ring buffers) in a separate function. This will allow to do the
allocation at different times of the boot preparations depending on
the features the kernel is supporting.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
7 years agoxen: factor out p2m list allocation into separate function
Juergen Gross [Thu, 3 Mar 2016 09:38:11 +0000 (10:38 +0100)]
xen: factor out p2m list allocation into separate function

Do the p2m list allocation of the to be loaded kernel in a separate
function. This will allow doing the p2m list allocation at different
times of the boot preparations depending on the features the kernel
is supporting.

While at this remove superfluous setting of first_p2m_pfn and
nr_p2m_frames as those are needed only in case of the p2m list not
being mapped by the initial kernel mapping.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
7 years agoxen: synchronize xen header
Juergen Gross [Thu, 3 Mar 2016 09:38:10 +0000 (10:38 +0100)]
xen: synchronize xen header

Get actual version of include/xen/xen.h from the Xen repository in
order to be able to use constants defined there.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
7 years agoxen: add elfnote.h to avoid using numbers instead of constants
Juergen Gross [Thu, 3 Mar 2016 09:38:09 +0000 (10:38 +0100)]
xen: add elfnote.h to avoid using numbers instead of constants

Various features and parameters of a pv-kernel are specified via
elf notes in the kernel image. Those notes are part of the interface
between the Xen hypervisor and the kernel.

Instead of using num,bers in the code when interpreting the elf notes
make use of the header supplied by Xen for that purpose.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
7 years agoxen: reduce number of global variables in xen loader
Juergen Gross [Thu, 3 Mar 2016 09:38:08 +0000 (10:38 +0100)]
xen: reduce number of global variables in xen loader

The loader for xen paravirtualized environment is using lots of global
variables. Reduce the number by making them either local or by putting
them into a single state structure.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
7 years agoxen: avoid memleaks on error
Juergen Gross [Thu, 3 Mar 2016 09:38:07 +0000 (10:38 +0100)]
xen: avoid memleaks on error

When loading a Xen pv-kernel avoid memory leaks in case of errors.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
7 years agoxen: make xen loader callable multiple times
Juergen Gross [Thu, 3 Mar 2016 09:38:06 +0000 (10:38 +0100)]
xen: make xen loader callable multiple times

The loader for xen paravirtualized environment isn't callable multiple
times as it won't free any memory in case of failure.

Call grub_relocator_unload() as other modules do it before allocating
a new relocator or when unloading the module.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
7 years agomultiboot2: Add support for relocatable images
Daniel Kiper [Fri, 17 Jul 2015 19:02:09 +0000 (21:02 +0200)]
multiboot2: Add support for relocatable images

Currently multiboot2 protocol loads image exactly at address specified in
ELF or multiboot2 header. This solution works quite well on legacy BIOS
platforms. It is possible because memory regions are placed at predictable
addresses (though I was not able to find any spec which says that it is
strong requirement, so, it looks that it is just a goodwill of hardware
designers). However, EFI platforms are more volatile. Even if required
memory regions live at specific addresses then they are sometimes simply
not free (e.g. used by boot/runtime services on Dell PowerEdge R820 and
OVMF). This means that you are not able to just set up final image
destination on build time. You have to provide method to relocate image
contents to real load address which is usually different than load address
specified in ELF and multiboot2 headers.

This patch provides all needed machinery to do self relocation in image code.
First of all GRUB2 reads min_addr (min. load addr), max_addr (max. load addr),
align (required image alignment), preference (it says which memory regions are
preferred by image, e.g. none, low, high) from multiboot_header_tag_relocatable
header tag contained in binary (at this stage load addresses from multiboot2
and/or ELF headers are ignored). Later loader tries to fulfill request (not only
that one) and if it succeeds then it informs image about real load address via
multiboot_tag_load_base_addr tag. At this stage GRUB2 role is finished. Starting
from now executable must cope with relocations itself using whole static and
dynamic knowledge provided by boot loader.

This patch does not provide functionality which could do relocations using
ELF relocation data. However, I was asked by Konrad Rzeszutek Wilk and Vladimir
'phcoder' Serbinenko to investigate that thing. It looks that relevant machinery
could be added to existing code (including this patch) without huge effort.
Additionally, ELF relocation could live in parallel with self relocation provided
by this patch. However, during research I realized that first of all we should
establish the details how ELF relocatable image should look like and how it should
be build. At least to build proper test/example files.

So, this patch just provides support for self relocatable images. If ELF file
with relocs is loaded then GRUB2 complains loudly and ignores it. Support for
such files will be added later.

This patch was tested with Xen image which uses that functionality. However, this Xen
feature is still under development and new patchset will be released in about 2-3 weeks.

Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>
Reviewed-by: Vladimir Serbinenko <phcoder@gmail.com>
7 years agomultiboot2: Do not pass memory maps to image if EFI boot services are enabled
Daniel Kiper [Fri, 17 Jul 2015 22:09:31 +0000 (00:09 +0200)]
multiboot2: Do not pass memory maps to image if EFI boot services are enabled

If image requested EFI boot services then skip multiboot2 memory maps.
Main reason for not providing maps is because they will likely be
invalid. We do a few allocations after filling them, e.g. for relocator
needs. Usually we do not care as we would have finished boot services.
If we keep boot services then it is easier/safer to not provide maps.
However, if image needs memory maps and they are not provided by bootloader
then it should get itself just before ExitBootServices() call.

Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>
Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Reviewed-by: Vladimir Serbinenko <phcoder@gmail.com>
7 years agomultiboot2: Add tags used to pass ImageHandle to loaded image
Daniel Kiper [Wed, 19 Nov 2014 23:09:54 +0000 (00:09 +0100)]
multiboot2: Add tags used to pass ImageHandle to loaded image

Add tags used to pass ImageHandle to loaded image if requested.
It is used by at least ExitBootServices() function.

Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>
Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Reviewed-by: Vladimir Serbinenko <phcoder@gmail.com>
7 years agoi386/relocator: Add grub_relocator64_efi relocator
Daniel Kiper [Fri, 17 Jul 2015 17:43:42 +0000 (19:43 +0200)]
i386/relocator: Add grub_relocator64_efi relocator

Add grub_relocator64_efi relocator. It will be used on EFI 64-bit platforms
when multiboot2 compatible image requests MULTIBOOT_TAG_TYPE_EFI_BS. Relocator
will set lower parts of %rax and %rbx accordingly to multiboot2 specification.
On the other hand processor mode, just before jumping into loaded image, will
be set accordingly to Unified Extensible Firmware Interface Specification,
Version 2.4 Errata B, section 2.3.4, x64 Platforms, boot services. This way
loaded image will be able to use EFI boot services without any issues.

Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>
Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Reviewed-by: Vladimir Serbinenko <phcoder@gmail.com>
8 years agonet/ip: Fix limit_time calculation in freeing old fragments
Sakar Arora [Mon, 19 Sep 2016 19:31:17 +0000 (01:01 +0530)]
net/ip: Fix limit_time calculation in freeing old fragments

limit_time underflows when current time is less than 90000ms.
This causes packet fragments received during this time, i.e.,
till 90000ms pass since timer init, to be rejected.

Hence, set it to 0 if its less than 90000.

Signed-off-by: Sakar Arora <Sakar.Arora@nxp.com>