grub.git
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>
7 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>
7 years agoasm-tests/i386-pc: Check that movl is 5 bytes.
Andrei Borzenkov [Wed, 28 Sep 2016 17:31:04 +0000 (20:31 +0300)]
asm-tests/i386-pc: Check that movl is 5 bytes.

LLVM 3.9 now emits short form of jump instructions, but it is still using
32 bit addresses for some movl instructions. Fortunately it was caught early:

clang ... boot/i386/pc/boot.S
clang -cc1as: fatal error: error in backend: invalid .org offset '440' (at offset '441')

Add additional check to catch it during configure run and force -no-integrated-as.

Closes: 49200

More details in
  https://lists.gnu.org/archive/html/grub-devel/2015-02/msg00099.html
  https://llvm.org/bugs/show_bug.cgi?id=22662

7 years agoAdd missing va_end() to xasprintf() in grub-emu.
Pete Batard [Sat, 13 Aug 2016 08:51:34 +0000 (10:51 +0200)]
Add missing va_end() to xasprintf() in grub-emu.

7 years agoat_keyboard: fix numpad "0" and "." mapping
Andrei Borzenkov [Wed, 27 Jul 2016 05:33:12 +0000 (08:33 +0300)]
at_keyboard: fix numpad "0" and "." mapping

Reported for set 1 by fgndevelop <fgndevelop@posteo.org>. Apparently
set 2 was reversed too.

7 years agodns: fix buffer overflow for data->addresses in recv_hook
Andrei Borzenkov [Tue, 26 Jul 2016 17:38:58 +0000 (20:38 +0300)]
dns: fix buffer overflow for data->addresses in recv_hook

We may get more than one response before exiting out of loop in
grub_net_dns_lookup, but buffer was allocated for the first response only,
so storing answers from subsequent replies wrote past allocated size.
We never really use more than the very first address during lookup so there
is little point in collecting all of them. Just quit early if we already have
some reply.

Code needs serious redesign to actually collect multiple answers
and select the best fit according to requested type (IPv4 or IPv6).

Reported and tested by Michael Chang <mchang@suse.com>

7 years agoxfs: accept filesystem with meta_uuid
Andrei Borzenkov [Tue, 26 Jul 2016 17:29:26 +0000 (20:29 +0300)]
xfs: accept filesystem with meta_uuid

XFS V5 stores UUID in metadata and compares them with superblock UUID.
To allow changing of user-visible UUID it stores original value in new
superblock field (meta_uuid) and sets incompatible flag to indicate that
new field must be used to verify metadata. Our driver currently does not
check metadata UUID so simply accept such filesystem.

Reported-By: Marcos Mello <marcosfrm@outlook.com>
Reviewd by Jan Kara <jack@suse.cz>

8 years agonet: translate pxe prefix to tftp when checking for self-load
Andrei Borzenkov [Tue, 3 May 2016 16:23:31 +0000 (19:23 +0300)]
net: translate pxe prefix to tftp when checking for self-load

Commit ba218c1 missed legacy pxe and pxe: prefixes which are
translated to tftp, so comparison failed.

8 years agonet: reset net->stall in grub_net_seek_real
Andrei Borzenkov [Sat, 30 Apr 2016 06:15:36 +0000 (09:15 +0300)]
net: reset net->stall in grub_net_seek_real

If we open new connection, we need to reset stall indication, otherwise
nothing will ever be polled (low level code rely on this field being
zero when establishing connection).

8 years agohttp: reset EOF indication in http_seek
Stefan Fritsch [Sat, 30 Apr 2016 06:10:12 +0000 (09:10 +0300)]
http: reset EOF indication in http_seek

Otherwise next read will stop polling too early due to stale EOF
indicator, returning incomplete data to caller.

8 years agobuild: Use AC_HEADER_MAJOR to find device macros
Mike Gilbert [Tue, 19 Apr 2016 18:27:22 +0000 (14:27 -0400)]
build: Use AC_HEADER_MAJOR to find device macros

Depending on the OS/libc, device macros are defined in different
headers. This change ensures we include the right one.

sys/types.h - BSD
sys/mkdev.h - Sun
sys/sysmacros.h - glibc (Linux)

glibc currently pulls sys/sysmacros.h into sys/types.h, but this may
change in a future release.

https://sourceware.org/ml/libc-alpha/2015-11/msg00253.html

8 years agohttp: fix superfluous null line in range request header
Michael Chang [Wed, 6 Apr 2016 10:19:14 +0000 (18:19 +0800)]
http: fix superfluous null line in range request header

At least the apache sever is very unhappy with that extra null line and will
take more than ten seconds in responding to each range request, which slows
down a lot the entire http file transfer process or even time out.

8 years agoconfigure: set -fno-pie together with -fno-PIE
Andrei Borzenkov [Tue, 22 Mar 2016 17:12:22 +0000 (20:12 +0300)]
configure: set -fno-pie together with -fno-PIE

OpenBSD 5.9 apparently defaults to -fpie. We use -fno-PIE when appropriate
already, but that is not enough - it does not turn off -fpie.

Actually check for -fPIE is not precise enough. __PIE__ is set for both
-fpie and -fPIE but with different values. As far as I can tell, both
options were introduced at the same time, so both should always be supported.

This fixes compilation on OpenBSD 5.9 which otherwise created insanely big
lzma_decompress.img.

Reported, suggested and tested by: Jiri B <jirib@devio.us>

8 years agobootp: check that interface is not NULL in configure_by_dhcp_ack
Andrei Borzenkov [Sun, 20 Mar 2016 07:32:33 +0000 (10:32 +0300)]
bootp: check that interface is not NULL in configure_by_dhcp_ack

grub_net_add_addr may fail with OOM and we use returned interface
later without any checks.

8 years agobootp: fix memory leak in grub_cmd_dhcpopt
Andrei Borzenkov [Sat, 19 Mar 2016 06:39:30 +0000 (09:39 +0300)]
bootp: fix memory leak in grub_cmd_dhcpopt

8 years agoRemove the variable oldname which is attempting to free stack space.
Aaron Luft [Mon, 14 Mar 2016 20:48:33 +0000 (16:48 -0400)]
Remove the variable oldname which is attempting to free stack space.

Historically this variable hold previous value of filename that
had to be freed if allocated previously. Currently this branch
is entered only if filename was not allocated previously so it
became redundant. It did not cause real problems because grub_free
was not called, but code is confusing and causes compilation error
in some cases.

8 years agoMakefile.util.def: add $LIBINTL to grub-macbless flags
Andrei Borzenkov [Sun, 13 Mar 2016 05:11:58 +0000 (08:11 +0300)]
Makefile.util.def: add $LIBINTL to grub-macbless flags

Fixes compilation on OpenBSD 5.9.

Reported by Jiri B <jirib@devio.us>

8 years agoFailed config now returns exit code (#1252311)
Robert Marshall [Fri, 29 Jan 2016 19:49:24 +0000 (14:49 -0500)]
Failed config now returns exit code (#1252311)

Grub would notify the user if the new config was invalid, however, it
did not exit properly with exit code 1. Added the proper exit code.

Resolves: rhbz#1252311

8 years agoxen_file: Fix invalid payload size
Michael Chang [Fri, 11 Mar 2016 09:26:51 +0000 (10:26 +0100)]
xen_file: Fix invalid payload size

8 years agomultiboot2: Remove useless GRUB_PACKED
Vladimir Serbinenko [Thu, 10 Mar 2016 20:16:10 +0000 (21:16 +0100)]
multiboot2: Remove useless GRUB_PACKED

Reported by: Daniel Kiper

8 years ago20_linux_xen: fix test for GRUB_DEVICE
Andrei Borzenkov [Sun, 6 Mar 2016 05:54:19 +0000 (08:54 +0300)]
20_linux_xen: fix test for GRUB_DEVICE

Same fix as in 082bc9f.

8 years ago10_linux: Fix grouping of tests for GRUB_DEVICE
Mike Gilbert [Sat, 5 Mar 2016 22:30:48 +0000 (17:30 -0500)]
10_linux: Fix grouping of tests for GRUB_DEVICE

Commit 7290bb562 causes GRUB_DISABLE_LINUX_UUID to be ignored due to
mixing of || and && operators. Add some parens to help with that.

8 years agoNEWS update
Andrei Borzenkov [Sun, 28 Feb 2016 18:52:08 +0000 (21:52 +0300)]
NEWS update

8 years agoRelease 2.02~beta3
Vladimir Serbinenko [Sun, 28 Feb 2016 02:07:41 +0000 (03:07 +0100)]
Release 2.02~beta3

8 years agogrub_arch_sync_dma_caches: Accept volatile address
Vladimir Serbinenko [Sun, 28 Feb 2016 02:07:27 +0000 (03:07 +0100)]
grub_arch_sync_dma_caches: Accept volatile address

8 years agoefidisk: Respect block_io_protocol buffer alignment
Leif Lindholm [Sat, 27 Feb 2016 12:44:59 +0000 (13:44 +0100)]
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.

8 years agousbtrans: Fix memory coherence and use-after-free.
Vladimir Serbinenko [Tue, 23 Feb 2016 11:07:01 +0000 (12:07 +0100)]
usbtrans: Fix memory coherence and use-after-free.

8 years agoehci: Fix memory coherence
Vladimir Serbinenko [Tue, 23 Feb 2016 11:06:48 +0000 (12:06 +0100)]
ehci: Fix memory coherence

This is a no-op on x86 but necessarry on ARM and may be necessarry on MIPS.

8 years agoarm-uboot: Make self-relocatable to allow loading at any address
Vladimir Serbinenko [Thu, 18 Feb 2016 23:43:36 +0000 (00:43 +0100)]
arm-uboot: Make self-relocatable to allow loading at any address

8 years agoAllow _start == 0 with relocatable images
Vladimir Serbinenko [Thu, 18 Feb 2016 19:58:38 +0000 (20:58 +0100)]
Allow _start == 0 with relocatable images

8 years agoProvide __bss_start and _end symbols in grub-mkimage.
Vladimir Serbinenko [Thu, 18 Feb 2016 19:57:21 +0000 (20:57 +0100)]
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.

8 years agoEncapsulate image layout into a separate structure.
Vladimir Serbinenko [Fri, 19 Feb 2016 00:49:53 +0000 (01:49 +0100)]
Encapsulate image layout into a separate structure.

Currently we pass around a lot of pointer. Instead put all relevant data
into one structure.

8 years agomkimagexx: Split PE and generic part for relocations.
Vladimir Serbinenko [Thu, 18 Feb 2016 19:54:37 +0000 (20:54 +0100)]
mkimagexx: Split PE and generic part for relocations.

As a preparation for U-Boot relocations, split emitting PE-relocations
from parsing source ELF-relocations.

8 years agomkimage.c: Split into separate files.
Vladimir Serbinenko [Thu, 18 Feb 2016 19:26:44 +0000 (20:26 +0100)]
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

8 years agobsd: Ensure that kernel is loaded before loading module.
Vladimir Serbinenko [Fri, 26 Feb 2016 13:56:22 +0000 (14:56 +0100)]
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.

8 years agocat: Don't switch terminal mode when there is nothing to highlight.
Vladimir Serbinenko [Fri, 26 Feb 2016 11:26:56 +0000 (12:26 +0100)]
cat: Don't switch terminal mode when there is nothing to highlight.

This just pollutes serial console.

8 years agoUse console rather than serial_efi0 on arm64-efi in tests
Vladimir Serbinenko [Fri, 26 Feb 2016 10:56:28 +0000 (11:56 +0100)]
Use console rather than serial_efi0 on arm64-efi in tests

8 years agoefidisk: fix misplaced parenthesis in b00e4c2
Andrei Borzenkov [Sat, 27 Feb 2016 12:16:48 +0000 (15:16 +0300)]
efidisk: fix misplaced parenthesis in b00e4c2

8 years agoefidisk: prevent errors from diskfilter scan of removable drives
Andrei Borzenkov [Fri, 26 Feb 2016 18:44:37 +0000 (21:44 +0300)]
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 <Andreas.Loew@gmx.net>

8 years agoRegenerate checksums
Vladimir Serbinenko [Fri, 26 Feb 2016 10:37:47 +0000 (11:37 +0100)]
Regenerate checksums

8 years agoMakefile: Don't delete default_payload.elf if it doesn't exist.
Vladimir Serbinenko [Fri, 26 Feb 2016 10:12:35 +0000 (11:12 +0100)]
Makefile: Don't delete default_payload.elf if it doesn't exist.

8 years agonet: fix ipv6 routing
Josef Bacik [Wed, 10 Feb 2016 21:21:00 +0000 (13:21 -0800)]
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 <jbacik@fb.com>
8 years agoieee1275: fix signed comparison
Vladimir Serbinenko [Tue, 23 Feb 2016 07:57:31 +0000 (08:57 +0100)]
ieee1275: fix signed comparison

8 years agosearch: actually skip floppy with --no-floppy
Andrei Borzenkov [Tue, 23 Feb 2016 20:14:41 +0000 (23:14 +0300)]
search: actually skip floppy with --no-floppy

grub_device_iterate() ignores device when iterator returns 1, not 0.

Reported by Carlos E. R. <robin.listas@telefonica.net>

8 years agomultiboot2: zero reserved field in memory map
Andrei Borzenkov [Tue, 23 Feb 2016 06:12:14 +0000 (09:12 +0300)]
multiboot2: zero reserved field in memory map

Documentation says, bootloader should set reserved field to zero.

Reported by Wink Saville <wink@saville.com>

8 years agoImprove EHCI logging
Vladimir Serbinenko [Mon, 22 Feb 2016 02:32:50 +0000 (03:32 +0100)]
Improve EHCI logging

Add dprintf's on common error paths and remove some entries which are too
noisy.

8 years agousb_keyboard: Remove useless include
Vladimir Serbinenko [Mon, 22 Feb 2016 02:25:50 +0000 (03:25 +0100)]
usb_keyboard: Remove useless include

This prevents non-PCI machines from having USB.

8 years agoRefresh before abort
Vladimir Serbinenko [Sat, 20 Feb 2016 08:12:15 +0000 (09:12 +0100)]
Refresh before abort

This ensures that abort message is actually visible to the user.

8 years agoieee1275: prevent buffer over-read
Eric Snowberg [Mon, 15 Feb 2016 18:53:45 +0000 (10:53 -0800)]
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 <eric.snowberg@oracle.com>
8 years agomenu_entry: Disable cursor during update_screen()
Thomas Huth [Fri, 29 Jan 2016 14:26:58 +0000 (15:26 +0100)]
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 <thuth@redhat.com>
8 years agodefault_payload.elf: Always rebuild and remove before build.
Vladimir Serbinenko [Wed, 17 Feb 2016 17:19:18 +0000 (18:19 +0100)]
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.

8 years agodefault_payload.elf: Include password_pbkdf2.
Vladimir Serbinenko [Wed, 17 Feb 2016 17:11:51 +0000 (18:11 +0100)]
default_payload.elf: Include password_pbkdf2.

Withoout this module we may end up in a system where no password is
accepted.

8 years agodefault_payload.elf: Add modules from $(EXTRA_PAYLOAD_MODULES).
Vladimir Serbinenko [Wed, 17 Feb 2016 17:10:31 +0000 (18:10 +0100)]
default_payload.elf: Add modules from $(EXTRA_PAYLOAD_MODULES).

This allows coreboot building system to add extra modules depending
on user config.

8 years agomm: Avoid integer overflow.
Vladimir Serbinenko [Wed, 17 Feb 2016 17:09:44 +0000 (18:09 +0100)]
mm: Avoid integer overflow.

8 years agoRemove -Wno-maybe-uninitialized as it may not be present.
Vladimir Serbinenko [Wed, 17 Feb 2016 16:58:05 +0000 (17:58 +0100)]
Remove -Wno-maybe-uninitialized as it may not be present.

8 years agoFix warnings when compiling with -O3
Vladimir Serbinenko [Wed, 17 Feb 2016 16:56:41 +0000 (17:56 +0100)]
Fix warnings when compiling with -O3

8 years agoAdd wbinvd around bios call.
Vladimir Serbinenko [Sun, 10 Jan 2016 12:48:26 +0000 (13:48 +0100)]
Add wbinvd around bios call.

Via C3 has problems with cache coherency when transitioning between the modes,
so flush it around bios calls.

8 years agoOBP available region contains grub. Start at grub_phys_end.
Eric Snowberg [Fri, 12 Feb 2016 22:16:03 +0000 (23:16 +0100)]
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.

8 years agoAdd Thinkpad T410s button cmos address.
Andreas Freimuth [Fri, 12 Feb 2016 18:19:11 +0000 (19:19 +0100)]
Add Thinkpad T410s button cmos address.

8 years agoTODO: Remove obsolete link
Vladimir Serbinenko [Fri, 12 Feb 2016 16:51:52 +0000 (17:51 +0100)]
TODO: Remove obsolete link

8 years agolz4: Fix pointer overflow
Toomas Soome [Fri, 12 Feb 2016 15:31:23 +0000 (16:31 +0100)]
lz4: Fix pointer overflow

8 years agogrub-shell: Update 32-bit OVMF binary name.
Vladimir Serbinenko [Fri, 12 Feb 2016 15:08:04 +0000 (16:08 +0100)]
grub-shell: Update 32-bit OVMF binary name.

8 years agorelocator: Fix integer underflow.
Daniel Kiper [Fri, 12 Feb 2016 14:58:22 +0000 (15:58 +0100)]
relocator: Fix integer underflow.

8 years agoChange -v to -V for version of shell utils.
Vladimir Serbinenko [Fri, 12 Feb 2016 14:46:05 +0000 (15:46 +0100)]
Change -v to -V for version of shell utils.

8 years agoxnu: Add new kernel path to autoconfig.
Vladimir Serbinenko [Fri, 12 Feb 2016 14:42:26 +0000 (15:42 +0100)]
xnu: Add new kernel path to autoconfig.

8 years agoarm64: Use cpu timer for timekeeping.
Vladimir Serbinenko [Fri, 12 Feb 2016 11:43:02 +0000 (12:43 +0100)]
arm64: Use cpu timer for timekeeping.

8 years agopowerpc: Trim header in tests.
Vladimir Serbinenko [Fri, 12 Feb 2016 11:42:04 +0000 (12:42 +0100)]
powerpc: Trim header in tests.

8 years agodefault_payload: Include syslinuxcfg, all filesystems and xnu.
Vladimir Serbinenko [Fri, 12 Feb 2016 11:41:28 +0000 (12:41 +0100)]
default_payload: Include syslinuxcfg, all filesystems and xnu.

8 years agoxnu: Supply random seed.
Vladimir Serbinenko [Fri, 12 Feb 2016 11:40:10 +0000 (12:40 +0100)]
xnu: Supply random seed.

Now we're able to load kernels up to El Capitan.

8 years agoAdd RNG module.
Vladimir Serbinenko [Fri, 12 Feb 2016 11:39:38 +0000 (12:39 +0100)]
Add RNG module.

8 years agoyylex: use grub_fatal for exit.
Vladimir Serbinenko [Fri, 12 Feb 2016 11:34:54 +0000 (12:34 +0100)]
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.

8 years agoprintf: Fix and test %% behaviour in presence of subsequenbt args.
Vladimir Serbinenko [Fri, 12 Feb 2016 11:33:41 +0000 (12:33 +0100)]
printf: Fix and test %% behaviour in presence of subsequenbt args.

8 years agoSplit pmtimer wait and tsc measurement from pmtimer tsc calibration.
Vladimir Serbinenko [Fri, 12 Feb 2016 10:40:51 +0000 (11:40 +0100)]
Split pmtimer wait and tsc measurement from pmtimer tsc calibration.

8 years agoMake grub_cpu_is_tsc_supported generally available.
Vladimir Serbinenko [Fri, 12 Feb 2016 10:38:51 +0000 (11:38 +0100)]
Make grub_cpu_is_tsc_supported generally available.

8 years agoMake grub_acpi_find_fadt accessible generically
Vladimir Serbinenko [Fri, 12 Feb 2016 10:35:48 +0000 (11:35 +0100)]
Make grub_acpi_find_fadt accessible generically

8 years agoMake unaligned types public.
Vladimir Serbinenko [Fri, 12 Feb 2016 08:11:06 +0000 (09:11 +0100)]
Make unaligned types public.

This simplifies code which has to handle those types.

8 years agoFix emu compilation error on arm.
Vladimir Serbinenko [Fri, 12 Feb 2016 08:10:08 +0000 (09:10 +0100)]
Fix emu compilation error on arm.