Compare commits

...
Author SHA1 Message Date
Vladimir Serbinenko 3ffd8219c5 wip fs-tester 2017-01-27 18:48:27 +00:00
Vladimir Serbinenko 79fc008935 Don't use -mlong-calls on arm.
We don't really need it and it's flaky and creates
bogus symbols with clang.
2017-01-27 18:48:25 +00:00
Vladimir Serbinenko bf9c561670 configure: Disable movw/movt with clang.
Those relocations are not compatible with PE and also
not compatible with custom uboot relocator.
Disable them.
2017-01-27 18:48:23 +00:00
Vladimir Serbinenko afa9dda37e grub-fs-tester: Delete directory once we're done. 2017-01-27 18:00:40 +00:00
Vladimir Serbinenko cde63a3bb0 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.
2017-01-27 17:58:15 +00:00
Vladimir Serbinenko bf0e59cebf 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.
2017-01-27 17:46:47 +00:00
Andrei Borzenkov a2932fbe8a 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
2017-01-24 20:05:19 +03:00
Andrei Borzenkov 972765fe82 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.
2017-01-08 15:52:49 +03:00
Andrei Borzenkov 07662af7ae 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>
2016-12-22 22:48:25 +03:00
Michael Chang 562c406763 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().
2016-12-22 22:37:32 +03:00
Andrei Borzenkov ce95549cc5 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>
2016-12-15 16:07:00 +03:00
Magnus Granberg a3e9da054d 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.
2016-12-14 20:44:41 +03:00
Stanislav Kholmanskikh 130234bc78 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>
2016-12-14 14:13:34 +01:00
Stanislav Kholmanskikh 7b4c54c4ad 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>
2016-12-14 14:13:34 +01:00
Alexander Graf 0d2345774d 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>
2016-11-24 10:09:24 +01:00
Andrei Borzenkov c9a8d037a8 NEWS updates 2016-11-22 20:51:54 +03:00
Andrei Borzenkov f8c3af3b61 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
2016-11-22 20:43:04 +03:00
Aaro Koskinen 0af7539bd2 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>
2016-11-22 20:41:34 +03:00
Dirk Mueller 0d663b50b9 grub-mknetdir: Add support for ARM64 EFI 2016-11-14 19:27:13 +03:00
Joonas Lahtinen 28511b0da9 .gitignore: Add grub-core/build-grub-module-verifier
Signed-off-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
2016-11-12 12:07:31 +03:00
Alexander Graf e1b099fb69 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>
2016-11-10 13:21:00 +01:00
Alexander Graf fbca374105 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>
2016-11-10 13:20:56 +01:00
Corey Hickey 5f311e86d2 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:
a10e7a5a89

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

Signed-off-by: Corey Hickey <bugfood-c@fatooh.org>
2016-11-05 15:28:50 +03:00
Juergen Gross 0de3eeb623 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>
2016-10-27 16:22:06 +02:00
Juergen Gross b67a95ecad 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>
2016-10-27 16:22:06 +02:00
Juergen Gross 5500cefccd 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>
2016-10-27 16:22:06 +02:00
Juergen Gross d73976fdff 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>
2016-10-27 16:22:06 +02:00
Juergen Gross 1fbb2b4b39 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>
2016-10-27 16:22:06 +02:00
Juergen Gross c221ea06b5 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>
2016-10-27 16:22:06 +02:00
Juergen Gross 72c28509fa 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>
2016-10-27 16:22:06 +02:00
Juergen Gross 7e5fcb0b34 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>
2016-10-27 16:21:25 +02:00
Juergen Gross 6ae55ce103 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>
2016-10-27 16:17:15 +02:00
Juergen Gross c69d1858f1 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>
2016-10-27 16:17:15 +02:00
Juergen Gross 4231927e44 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>
2016-10-27 16:16:54 +02:00
Daniel Kiper a620876e3b 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>
2016-10-27 15:55:16 +02:00
Daniel Kiper f2b6c20a25 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>
2016-10-27 15:55:00 +02:00
Daniel Kiper ba89c19f49 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>
2016-10-27 15:54:46 +02:00
Daniel Kiper 9862b24121 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>
2016-10-27 15:53:43 +02:00
Sakar Arora e563928ba4 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>
2016-10-18 20:26:42 +03:00
Andrei Borzenkov a0bf403f66 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
2016-09-28 20:31:04 +03:00
Pete Batard 4e0f8f66e3 Add missing va_end() to xasprintf() in grub-emu. 2016-08-13 16:36:01 +03:00
Andrei Borzenkov c831d2073b at_keyboard: fix numpad "0" and "." mapping
Reported for set 1 by fgndevelop <fgndevelop@posteo.org>. Apparently
set 2 was reversed too.
2016-07-27 08:33:12 +03:00
Andrei Borzenkov 52408aa946 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>
2016-07-26 20:38:58 +03:00
Andrei Borzenkov 58590cb2ef 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>
2016-07-26 20:29:26 +03:00
Andrei Borzenkov b524fa27f5 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.
2016-05-03 19:23:31 +03:00
Andrei Borzenkov e045af148a 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).
2016-04-30 09:15:36 +03:00
Stefan Fritsch 13f7ead3a1 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.
2016-04-30 09:13:34 +03:00
Mike Gilbert 7a5b301e3a 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
2016-04-24 08:12:42 +03:00
Michael Chang abf9beb7d6 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.
2016-04-09 07:08:13 +03:00
Andrei Borzenkov f4d35d49e3 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>
2016-03-22 20:12:22 +03:00
Andrei Borzenkov 6714d7ecff 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.
2016-03-20 10:32:33 +03:00
Andrei Borzenkov 5b8ddf6e03 bootp: fix memory leak in grub_cmd_dhcpopt 2016-03-19 09:39:30 +03:00
Aaron Luft 76eac44af3 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.
2016-03-15 22:04:38 +03:00
Andrei Borzenkov ee83919e93 Makefile.util.def: add $LIBINTL to grub-macbless flags
Fixes compilation on OpenBSD 5.9.

Reported by Jiri B <jirib@devio.us>
2016-03-13 08:11:58 +03:00
Robert Marshall 3c3e96d044 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
2016-03-11 17:24:56 +01:00
Michael Chang 15aee573d2 xen_file: Fix invalid payload size 2016-03-11 10:26:51 +01:00
Vladimir Serbinenko 7f2a856fae multiboot2: Remove useless GRUB_PACKED
Reported by: Daniel Kiper
2016-03-10 21:16:10 +01:00
Andrei Borzenkov 9545a8fd04 20_linux_xen: fix test for GRUB_DEVICE
Same fix as in 082bc9f.
2016-03-06 08:54:19 +03:00
Mike Gilbert 082bc9f77b 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.
2016-03-06 08:51:07 +03:00
Andrei Borzenkov d017ea8ede NEWS update 2016-02-28 21:52:08 +03:00
Vladimir Serbinenko 8207874e5d Release 2.02~beta3 2016-02-28 03:07:41 +01:00
Vladimir Serbinenko 102e435d81 grub_arch_sync_dma_caches: Accept volatile address 2016-02-28 03:07:27 +01:00
Leif Lindholm 51f375d688 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.
2016-02-27 13:44:59 +01:00
Vladimir Serbinenko ca028db3d4 usbtrans: Fix memory coherence and use-after-free. 2016-02-27 13:40:52 +01:00
Vladimir Serbinenko 0f076d75d0 ehci: Fix memory coherence
This is a no-op on x86 but necessarry on ARM and may be necessarry on MIPS.
2016-02-27 13:40:52 +01:00
Vladimir Serbinenko 86ef66d977 arm-uboot: Make self-relocatable to allow loading at any address 2016-02-27 13:40:52 +01:00
Vladimir Serbinenko 5bcb7d394c Allow _start == 0 with relocatable images 2016-02-27 13:35:36 +01:00
Vladimir Serbinenko df21fff504 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.
2016-02-27 13:35:36 +01:00
Vladimir Serbinenko 73a9c742fe Encapsulate image layout into a separate structure.
Currently we pass around a lot of pointer. Instead put all relevant data
into one structure.
2016-02-27 13:35:36 +01:00
Vladimir Serbinenko dd3969e7ec mkimagexx: Split PE and generic part for relocations.
As a preparation for U-Boot relocations, split emitting PE-relocations
from parsing source ELF-relocations.
2016-02-27 13:35:36 +01:00
Vladimir Serbinenko 36212460d3 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
2016-02-27 13:35:36 +01:00
Vladimir Serbinenko 2ebef43cf6 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.
2016-02-27 13:35:36 +01:00
Vladimir Serbinenko 8c26dace6f cat: Don't switch terminal mode when there is nothing to highlight.
This just pollutes serial console.
2016-02-27 13:35:36 +01:00
Vladimir Serbinenko 070e190305 Use console rather than serial_efi0 on arm64-efi in tests 2016-02-27 13:35:36 +01:00
Andrei Borzenkov 109189ce01 efidisk: fix misplaced parenthesis in b00e4c2 2016-02-27 15:16:48 +03:00
Andrei Borzenkov b00e4c2bd9 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>
2016-02-26 21:44:37 +03:00
Vladimir Serbinenko 06a3b0b214 Regenerate checksums 2016-02-26 11:37:47 +01:00
Vladimir Serbinenko 5486a4e12b Makefile: Don't delete default_payload.elf if it doesn't exist. 2016-02-26 11:14:46 +01:00
Josef Bacik eb9f401fc1 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>
2016-02-25 22:38:52 +03:00
Vladimir Serbinenko 94c56a4c65 ieee1275: fix signed comparison 2016-02-24 18:37:22 +01:00
Andrei Borzenkov 1b782e902e 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>
2016-02-23 23:17:24 +03:00
Andrei Borzenkov 15dfea842c multiboot2: zero reserved field in memory map
Documentation says, bootloader should set reserved field to zero.

Reported by Wink Saville <wink@saville.com>
2016-02-23 09:12:14 +03:00
Vladimir Serbinenko 054d1325e9 Improve EHCI logging
Add dprintf's on common error paths and remove some entries which are too
noisy.
2016-02-22 20:07:10 +01:00
Vladimir Serbinenko 0678b5d629 usb_keyboard: Remove useless include
This prevents non-PCI machines from having USB.
2016-02-22 20:05:54 +01:00
Vladimir Serbinenko be4e9d20a5 Refresh before abort
This ensures that abort message is actually visible to the user.
2016-02-22 19:46:55 +01:00
Eric Snowberg bc220962e3 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>
2016-02-22 10:01:31 +03:00
Thomas Huth 625934ec0f 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>
2016-02-22 09:59:27 +03:00
Vladimir Serbinenko e3745f9087 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.
2016-02-17 18:19:18 +01:00
Vladimir Serbinenko 01d50c2539 default_payload.elf: Include password_pbkdf2.
Withoout this module we may end up in a system where no password is
accepted.
2016-02-17 18:11:51 +01:00
Vladimir Serbinenko 8d69065f52 default_payload.elf: Add modules from $(EXTRA_PAYLOAD_MODULES).
This allows coreboot building system to add extra modules depending
on user config.
2016-02-17 18:10:31 +01:00
Vladimir Serbinenko 59ec05bcf8 mm: Avoid integer overflow. 2016-02-17 18:09:44 +01:00
Vladimir Serbinenko fabde8324d Remove -Wno-maybe-uninitialized as it may not be present. 2016-02-17 17:58:05 +01:00
Vladimir Serbinenko 5cae910665 Fix warnings when compiling with -O3 2016-02-17 17:56:41 +01:00
Vladimir Serbinenko 25492a0f04 Add wbinvd around bios call.
Via C3 has problems with cache coherency when transitioning between the modes,
so flush it around bios calls.
2016-02-14 08:34:10 +01:00
Eric Snowberg 080a20861c 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.
2016-02-12 23:16:03 +01:00
Andreas Freimuth f96b34224e Add Thinkpad T410s button cmos address. 2016-02-12 19:19:11 +01:00
Vladimir Serbinenko a2ab8c2172 TODO: Remove obsolete link 2016-02-12 17:51:52 +01:00
Toomas Soome ce01054ec3 lz4: Fix pointer overflow 2016-02-12 17:26:32 +01:00
Vladimir Serbinenko feef882f98 grub-shell: Update 32-bit OVMF binary name. 2016-02-12 16:08:04 +01:00
Daniel Kiper eba6db6323 relocator: Fix integer underflow. 2016-02-12 16:07:57 +01:00
Vladimir Serbinenko 6e1ace590a Change -v to -V for version of shell utils. 2016-02-12 15:46:05 +01:00
Vladimir Serbinenko 7c35f65aac xnu: Add new kernel path to autoconfig. 2016-02-12 15:42:26 +01:00
Vladimir Serbinenko 4598cafa7d arm64: Use cpu timer for timekeeping. 2016-02-12 12:43:02 +01:00
Vladimir Serbinenko 6f4189ffc1 powerpc: Trim header in tests. 2016-02-12 12:42:04 +01:00
Vladimir Serbinenko 127cfea8be default_payload: Include syslinuxcfg, all filesystems and xnu. 2016-02-12 12:41:28 +01:00
Vladimir Serbinenko 22aa31bcc3 xnu: Supply random seed.
Now we're able to load kernels up to El Capitan.
2016-02-12 12:40:10 +01:00
Vladimir Serbinenko e72de13b9e Add RNG module. 2016-02-12 12:39:38 +01:00
Vladimir Serbinenko 342d6edb97 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.
2016-02-12 12:34:54 +01:00
Vladimir Serbinenko e5c9300191 printf: Fix and test %% behaviour in presence of subsequenbt args. 2016-02-12 12:33:41 +01:00
Vladimir Serbinenko d9a3bfead8 Split pmtimer wait and tsc measurement from pmtimer tsc calibration. 2016-02-12 11:40:51 +01:00
Vladimir Serbinenko 1933d37371 Make grub_cpu_is_tsc_supported generally available. 2016-02-12 11:38:51 +01:00
Vladimir Serbinenko b29638222e Make grub_acpi_find_fadt accessible generically 2016-02-12 11:35:48 +01:00
Vladimir Serbinenko 8ad190cac2 Make unaligned types public.
This simplifies code which has to handle those types.
2016-02-12 09:11:06 +01:00
Vladimir Serbinenko 281baeecd3 Fix emu compilation error on arm. 2016-02-12 09:10:08 +01:00
Vladimir Serbinenko df4df4d887 xnu: Include relocated EFI in heap size. 2016-02-11 12:30:45 +01:00
Vladimir Serbinenko 2d425ffdd5 xnu: supply ramsize to the kernel.
Without this info recent kernels crash as they allocate no heap.
2016-02-11 11:58:28 +01:00
Andrei Borzenkov 67dba97e45 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.
2016-02-03 20:34:55 +03:00
Andrei Borzenkov 7290bb5623 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
2016-02-01 20:13:48 +03:00
Vladimir Serbinenko ff84a9b868 Error out if mtools invocation fails. 2016-01-22 19:28:08 +01:00
Vladimir Serbinenko 605eecc985 arm64: Add support for relocations needed for linaro gcc 2016-01-22 19:09:37 +01:00
Vladimir Serbinenko b6a03dfd32 efiemu: Fix compilation failure 2016-01-22 14:10:30 +01:00
Vladimir Serbinenko 5f2b285bf8 Document cpuid -p 2016-01-22 13:50:53 +01:00
Robert Elliott ae3b83a4d4 efiemu: Handle persistent RAM and unknown possible future additions. 2016-01-22 13:32:30 +01:00
Vladimir Serbinenko dab148891e Document expr1 expr2 syntax for test command 2016-01-22 13:27:36 +01:00
Michael Chang 64e2d139fe Restore terminal settings on grub-emu exit. 2016-01-22 11:05:32 +01:00
Vladimir Serbinenko 0edd750e50 xen_boot: Remove obsolete module type distinctions. 2016-01-22 10:18:47 +01:00
Vladimir Serbinenko cc2ed41039 arm: Ignore qemu clock bug 2016-01-22 10:12:43 +01:00
Vladimir Serbinenko 7c6c2ad42c i386-ieee1275: Increase maximum heap size to accomodate highres graphi tests 2016-01-22 10:12:43 +01:00
Colin Watson 47e67d809c 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.
2016-01-20 15:56:55 +00:00
Colin Watson 92bbf25714 loader/bsd: Fix signed/unsigned comparison 2016-01-16 20:40:55 +00:00
Colin Watson 95440b41d3 ahci, ehci: Fix typos 2016-01-16 20:37:15 +00:00
Andrei Borzenkov f826d914e2 grub-probe: fix memory leak
Found by: Coverity scan.
CID: 73783
2016-01-16 21:47:28 +03:00
Andrei Borzenkov 77002c65d3 tftp: fix memory leaks in open
If protocol open fails, file is immediately freed, so data was leaked.

Found by: Coverity scan.
CID: 96659
2016-01-16 21:27:57 +03:00
Andrei Borzenkov d4561cd080 tcp: fix memory leaks
Found by: Coverity scan.
CID: 96639, 96647
2016-01-16 20:59:50 +03:00
Andrei Borzenkov 9b4256bf05 net: fix memory leaks
Found by: Coverity scan.
CID: 96638, 96648
2016-01-16 20:48:33 +03:00
Andrei Borzenkov eefa3239c2 legacycfg: fix memory leaks and add NULL check
Memory leaks found by Coverity scan.
CID: 96642, 96645
2016-01-16 20:34:02 +03:00
Andrei Borzenkov 4f8fe948b9 loader: Unintended sign extension
CID: 96707, 96699, 96693, 96691, 96711, 96709, 96708, 96703, 96702,
96700, 96698, 96696, 96695, 96692, 96710, 96705
2016-01-15 19:18:05 +03:00
Andrei Borzenkov b95e926788 script: fix memory leak
Found by: Coverity scan.
CID: 96637
2016-01-12 22:50:30 +03:00
Andrei Borzenkov 26533fe6bc normal: fix memory leak
Found by: Coverity scan.
CID: 96641, 96670, 96667
2016-01-12 22:40:03 +03:00
Andrei Borzenkov 29862fdc3a xnu: fix memory leak
Found by: Coverity scan.
CID: 96663
2016-01-12 21:52:51 +03:00
Andrei Borzenkov 9daf7aae8b truecrypt: fix memory leak
Found by: Coverity scan.
CID: 156611
2016-01-12 21:52:51 +03:00
Andrei Borzenkov a4b1326f0d gfxmenu: fix memory leak
Found by: Coverity scan.
CID: 96657
2016-01-12 21:52:50 +03:00
Andrei Borzenkov dbb0f9fa4f efiemu: fix memory leak
Found by: Coverity scan.
CID: 156610
2016-01-12 21:52:50 +03:00
Andrei Borzenkov e9d71db53a efidisk: fix memory leak
Found by: Coverity scan.
CID: 96644
2016-01-12 21:52:50 +03:00
Andrei Borzenkov 6c35ce72ba verify: fix memory leak
Found by: Coverity scan.
CID: 96643
2016-01-12 21:52:42 +03:00
Andrei Borzenkov f3c84fa798 password_pbkdf2: fix memory leak
Found by: Coverity scan.
CID: 96656
2016-01-12 20:53:26 +03:00
Andrei Borzenkov 5db2190f2c parttool: fix memory leak
Found by: Coverity scan.
CID: 96652
2016-01-12 20:41:44 +03:00
Andrei Borzenkov 1bff60e5aa nativedisk: fix memory leak
Based on Coverity scan.
CID: 96660

Extended to also cover other error return places.
2016-01-12 20:37:43 +03:00
Andrei Borzenkov 8fe17d91af acpi: fix memory leak
Found by: Coverity scan.
CID: 96673
2016-01-12 20:26:30 +03:00
Andrei Borzenkov 66768b99f1 grub-install: include ehci in list of native modules
This matches behavior of "nativedisk" command.

Reported and tested by Smith Henry <sh37092@gmail.com>
2016-01-10 16:08:06 +03:00
Andrei Borzenkov 962b69d950 grub-mkimage: remove redundant NULL check
Found by: Coverity scan.
CID: 73737
2016-01-10 11:51:34 +03:00
Andrei Borzenkov 528256932b 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
2016-01-10 11:33:13 +03:00
Andrei Borzenkov 269a522c7d 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
2016-01-10 10:41:04 +03:00
Andrei Borzenkov 5a5a3c6963 setup: fix NULL pointer dereference
Check return value of grub_guess_root_devices

Found by: Coverity scan.
CID: 73638, 73751
2016-01-09 21:25:22 +03:00
Andrei Borzenkov 670c43af27 mkimage: fix unintended sign extension
Found by: Coverity scan.
CID: 73691, 73717
2016-01-09 21:05:44 +03:00
Andrei Borzenkov dc27d254f2 util/getroot: delete dead code
is_part cannot be non-zero at this point.

Found by: Coveruty scan.
CID: 73838
2016-01-09 20:54:54 +03:00
Andrei Borzenkov 31f6506c57 loader/multiboot: fix unintended sign extension
Found by: Coveruty scan.
CID: 73700, 73763
2016-01-09 19:58:51 +03:00
Andrei Borzenkov 9fecb0588e kern/elf: fix unintended sign extension
Found by: Coverity scan.
CID: 73729, 73735, 73758, 73760
2016-01-09 19:41:26 +03:00
Andrei Borzenkov aafd205c92 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
2016-01-09 18:55:55 +03:00
Andrei Borzenkov bd60f5a207 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
2016-01-09 18:15:27 +03:00
Andrei Borzenkov 725548a285 grub-mklayout: check subscript bounds
Found by: Coverity scan.
CID: 73686
2016-01-09 14:13:36 +03:00
Andrei Borzenkov d5cc487d39 grub-probe: fix memory leak
Found by: Coverity scan.
CID: 73783
2016-01-09 13:55:28 +03:00
Andrei Borzenkov fa2af21ec8 gfxmenu: fix memory leak
Found by: Coverity scan.
CID: 73766
2016-01-09 13:55:28 +03:00
Andrei Borzenkov 0e075ac385 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
2016-01-09 13:55:18 +03:00
Andrei Borzenkov 57e7f1b775 setup: fix memory leak
Found by: Coverity scan.
CID: 73680, 73715
2016-01-09 13:10:10 +03:00
Andrei Borzenkov 67d9ce82ac efiemu: check return value of grub_efiemu_write_value
Found by: Coverity scan.
CID: 73590
2016-01-09 11:36:42 +03:00
Andrei Borzenkov 12bf87466f efiemu: change code to avoid Coverity false positive
CID: 73623
2016-01-09 11:36:42 +03:00
Andrei Borzenkov 97c41e1216 efiemu: fix unintended sign extension
Found by: Coverity scan.
CID: 73883, 73637
2016-01-09 11:36:42 +03:00
Andrei Borzenkov 8ab2675ede hfs: fix memory leak
Found by: Coverity scan.
CID: 156531
2016-01-09 11:36:42 +03:00
Andrei Borzenkov efc04d65c7 grub-module-verifier: fix unintended sign extension
Found by: Coverity scan.
CID: 156533, 156532
2016-01-09 11:36:42 +03:00
Vladimir Serbinenko b4787552b0 Tests: Support arm-efi 2016-01-08 09:49:08 +01:00
Vladimir Serbinenko e4c49cab9b arm64/setjmp: Add missing move for arg1 == 0 case. 2016-01-07 21:10:05 +01:00
Vladimir Serbinenko 9efd79f376 grub-shell: Support arm64-efi 2016-01-07 21:02:53 +01:00
Mark Salter 7eb27a49e9 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.
2016-01-07 20:54:20 +01:00
Vladimir Serbinenko a2dcab70f8 x86_64-efi: Automatically add -bios OVMF.fd to qemu in tests. 2016-01-07 19:29:53 +01:00
Vladimir Serbinenko 62328a95c9 Allow GRUB_QEMU_OPTS to override machine. 2016-01-07 19:28:47 +01:00
Vladimir Serbinenko 6e4174f6f9 arm64: Disable tests that need native drivers. 2016-01-07 19:27:56 +01:00
Vladimir Serbinenko 06c94739a5 Disable NetBSD bootcheck on EFI until it supports ACPI on EFI. 2016-01-07 19:27:10 +01:00
Vladimir Serbinenko db5eb6225d grub-shell: Use new cbfstool syntax. 2016-01-07 15:55:45 +01:00
Vladimir Serbinenko 44876dd64e 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.
2016-01-07 15:54:42 +01:00
Vladimir Serbinenko 86e3b4ba1a hddboot_test: reenable on OVMF
OVMF now supports booting from disks.
2016-01-07 15:54:06 +01:00
Vladimir Serbinenko 607d66116a iee1275/datetime: Fix off-by-1 error. 2016-01-07 15:53:42 +01:00
Vladimir Serbinenko 716c9f2675 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.
2016-01-07 15:51:03 +01:00
Vladimir Serbinenko 9f8f9e62af minixfs_test: Check if mkfs.minixfs supports -B option. 2016-01-05 21:10:27 +01:00
Vladimir Serbinenko f86fd54cf0 Add memdisk support to grub-emu.
Use it to add custom files, so that tests which need them work.
2016-01-05 21:10:27 +01:00
Vladimir Serbinenko 3f430a0126 Move file loading functions to grub-emu.
So that we can use it in grub-emu as well as utils.
2016-01-05 21:10:27 +01:00
Vladimir Serbinenko f2b54835f2 Disable progress indicator in grub-shell.
This disables progress indicator for tests. This in turn fixes test
flakiness as they ended up timing-dependent.
2016-01-05 21:10:10 +01:00
Vladimir Serbinenko 300be005a8 Update checksums 2016-01-05 11:55:30 +01:00
Andrei Borzenkov aa7bb4607b 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 <g.lip@gmx.com>
2016-01-02 21:33:18 +03:00
Andrei Borzenkov 19554a6034 acpihalt: fix GRUB_DSDT_TEST compilation 2016-01-02 19:02:19 +03:00
Andrei Borzenkov ba83ed1538 Add missing BUILD_EXEEXT 2016-01-01 12:06:40 +03:00
Vladimir Serbinenko 80fdaf1d01 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
2015-12-31 22:36:23 +01:00
Andrey Borzenkov 4d6e9c8a92 remove temporary .bin files (kernel and modules) 2015-12-31 23:00:25 +03:00
Andrey Borzenkov af23303cbd add dejavu built fonts to cleanfiles 2015-12-31 22:23:12 +03:00
Andrei Borzenkov c67025fad5 Add grub-module-verifier files to EXTRA_DIST 2015-12-31 21:35:11 +03:00
Vladimir Serbinenko 40051fedc3 configure: Add -fno-unwind-tables if supported.
Unwind tables are useless for us bt consume space if present. Ensure that they
are not.
2015-12-31 19:20:03 +01:00
Vladimir Serbinenko dcc499aaf0 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.
2015-12-31 18:30:39 +01:00
Vladimir Serbinenko 3b21499506 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.
2015-12-31 18:20:11 +01:00
Vladimir Serbinenko 5ae590b32d 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.
2015-12-31 18:19:15 +01:00
Vladimir Serbinenko f1b3525385 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.
2015-12-31 18:15:49 +01:00
Vladimir Serbinenko 68e158dffd 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.
2015-12-31 18:13:59 +01:00
Vladimir Serbinenko e1b2b9bf1d 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.
2015-12-31 15:29:28 +01:00
Vladimir Serbinenko 76588d1319 xen/relocator: Use local symbol to ensure that code is relocation-free. 2015-12-31 14:54:56 +01:00
Vladimir Serbinenko 60ae582142 backtrace: Fix register call syntax 2015-12-31 14:54:48 +01:00
Vladimir Serbinenko a7cf8b1e23 Verify modules on build-time rather than failing in runtime. 2015-12-31 13:09:15 +01:00
Vladimir Serbinenko 5919626c90 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.
2015-12-31 13:07:16 +01:00
Andrey Borzenkov 2333a83baa 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).
2015-12-30 22:30:16 +03:00
Vladimir Serbinenko 79cfad6fbe backtrace: Remove assembly assumption that grub_backtrace_pointer is under 4G 2015-12-30 18:19:44 +01:00
Andrei Borzenkov 93ecc3f1f8 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 <mchang@suse.com>
2015-12-30 06:20:51 +03:00
Vladimir Serbinenko dbab354157 grub-mkrescue: Delete temporary file
Reported by: Thomas Schmitt
2015-12-29 17:48:34 +01:00
Vladimir Serbinenko 4111882828 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.
2015-12-29 17:43:05 +01:00
Vladimir Serbinenko ca7bb46d5c exfat: Fix stream extension flag parsing. 2015-12-29 17:42:25 +01:00
Andrei Borzenkov 3bca85b418 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
2015-12-26 21:45:22 +03:00
Andrei Borzenkov a9399f2e1e 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.
2015-12-19 11:32:49 +03:00
Robert Elliott c79c59f129 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
2015-12-17 21:00:44 +03:00
Andrei Borzenkov 609c049dcc 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
2015-12-16 21:20:30 +03:00
Andrei Borzenkov 7136b545c1 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).
2015-12-16 19:20:10 +03:00
Hector Marco-Gisbert 451d80e52d 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 <hecmargi@upv.es>
Signed-off-by: Ismael Ripoll-Ripoll <iripoll@disca.upv.es>
Also-By: Andrey Borzenkov <arvidjaar@gmail.com>
2015-12-16 07:57:18 +03:00
Andrei Borzenkov ff5726b878 NEWS: more additions
Also-By: Robert Elliott <elliott@hpe.com>
2015-12-15 10:43:12 +03:00
Robert Elliott 76ce1de740 Translate UEFI persistent memory type
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 <phcoder@gmail.com>
Suggested-by: Andrei Borzenkov <arvidjaar@gmail.com>
2015-12-15 10:25:34 +03:00
Vladimir Serbinenko 4803db51ff Document bootlocation discovery limitations and xen platform limitations 2015-12-14 16:21:24 +01:00
Josef Bacik fb47807918 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 <jbacik@fb.com>
2015-12-07 20:52:27 +03:00
Michael Chang a03c1034f6 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 <vkuznets@redhat.com>
2015-12-01 18:49:38 +03:00
Andrei Borzenkov 346a494d7c 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).
2015-11-28 21:11:34 +03:00
Andrei Borzenkov f4c143789a Replace numbers with grub_memory_type_t enums 2015-11-27 19:52:16 +03:00
Andrei Borzenkov a261842785 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 <mcheung63@hotmail.com>
2015-11-27 19:42:23 +03:00
Vladimir Serbinenko d43a5ee651 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.
2015-11-27 11:39:55 +01:00
Andrei Borzenkov 3d2c8048da efi: really mark memory of unknown type as reserved
9be4c45dbe 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) <elliott@hpe.com>
2015-11-26 19:50:42 +03:00
Josef Bacik f9d1b4422e 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 <jbacik@fb.com>
2015-11-24 20:48:16 +03:00
Andrei Borzenkov 6a46cbcc5c 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
2015-11-18 22:23:58 +03:00
Andrei Borzenkov 50d6f38feb lsefisystab: add missing comma after 7994077 2015-11-17 06:27:17 +03:00
Pavel Bludov 7994077ab9 Add some UUIDs found in the hardware 2015-11-14 17:57:35 +03:00
Konstantin Vlasov 5646e03dba gfxterm: fix calculation of terminal-top and terminal-height
They used screen width, not height.
2015-11-13 21:54:19 +03:00
Paulo Flabiano Smorigo c899d9f42c ofdisk: add sas disks to the device list 2015-11-12 09:23:02 -02:00
Vladimir Serbinenko e0bd66c314 multiboot: Don't rely on particular ordering of options. 2015-11-12 11:54:38 +01:00
Vladimir Serbinenko 95ba04606f multiboot_mbi: Fix handling of --quirk-bad-kludge. 2015-11-12 11:54:13 +01:00
Fu Wei a771a7b9f6 xen_boot: Remove useless file_name_index variable. 2015-11-12 11:33:55 +01:00
Fu Wei fb94736fe8 Document ARM64 xen commands 2015-11-12 11:32:01 +01:00
Vladimir Serbinenko 323ef2bdc3 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
2015-11-11 18:14:25 +00:00
Paulo Flabiano Smorigo a50dbb743e ofdisk: add a comment about vscsi method 2015-11-10 21:20:20 -02:00
Vladimir Serbinenko 25a9b8f208 fdt.mod: Move license tag to the right file. 2015-11-09 16:15:30 +01:00
Fu Wei 372400b419 fdt.mod: Add missing license tag. 2015-11-09 15:27:59 +01:00
Vladimir Serbinenko 254f92815b kern/elf: Ignore cast-align warnings 2015-11-09 11:39:30 +01:00
Vladimir Serbinenko cb28250cfc 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.
2015-11-09 03:24:04 +01:00
Vladimir Serbinenko 4656ced41c fstester: Enforce LC_ALL=C 2015-11-08 22:39:36 +01:00
Vladimir Serbinenko b2fc9acdc9 Adapt build-system to use imported xen headers. 2015-11-08 21:24:18 +01:00
Vladimir Serbinenko e07badcc31 Import xen headers directly into GRUB 2015-11-08 21:23:52 +01:00
Vladimir Serbinenko 855fe6869c cbfs: Check for ptr range sanity.
Triaged by Andrei and enhanced with suggestions by Aaron Durbin
Also-By: Andrei Borzenkov <arvidjaar@gmail.com>
2015-11-08 20:34:30 +01:00
Vladimir Serbinenko a39137aefe Remove reliance C.UTF-8 2015-11-08 20:23:15 +01:00
Vladimir Serbinenko db97faec91 genmoddep.awk: Add a test that we have no circular dependencies 2015-11-08 20:00:27 +01:00
Vladimir Serbinenko 7cc27aeda9 Makefile.core.def: Break circular dependency on arm64. 2015-11-08 18:47:53 +01:00
Vladimir Serbinenko ae66efc63b 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).
2015-11-08 18:45:57 +01:00
Andrei Borzenkov c054020581 partmap_test: check that parted is available
Skip test if parted is unavailable instead of returning false failure.
2015-11-07 23:42:35 +03:00
grub-devel@iam.tj c7f93a20c4 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.
2015-11-07 18:52:59 +03:00
Andrey Borzenkov bcf8c5814d doc: document config_directory and config_file variables 2015-11-07 17:03:38 +03:00
Andrei Borzenkov dff8d0e3f5 unix/getroot: remove unused MAJOR definition
We use major() everywhere, these definitions just add to confusion.
2015-11-07 17:02:21 +03:00
Andrei Borzenkov c1fbc26203 Add comments to code for commit d313218 2015-11-07 13:01:23 +03:00
Andrei Borzenkov 349a381df0 devmapper/getroot: use makedev instead of direct shift
Fixes device detection with large number of devices.

Reported by Tim Wallberg <twalberg@comcast.net>
2015-11-07 09:46:46 +03:00
Andrei Borzenkov 1018e91dce 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.
2015-11-06 21:33:28 +03:00
Vladimir Serbinenko cd6d79cda2 configure.ac: Explicitly add -mno-sse3 on x86. 2015-11-06 04:32:34 +01:00
Vladimir Serbinenko 5b7b4d9781 README: Remove dead link to the wiki 2015-11-06 04:31:23 +01:00
225 changed files with 10459 additions and 2770 deletions

No files matched your search

+1
View File
@@ -246,3 +246,4 @@ build-aux/test-driver
/garbage-gen /garbage-gen
/garbage-gen.exe /garbage-gen.exe
/grub-fs-tester /grub-fs-tester
grub-core/build-grub-module-verifier
+43 -35
View File
@@ -89,16 +89,21 @@ CLEANFILES += build-grub-gen-widthspec$(BUILD_EXEEXT)
if COND_STARFIELD if COND_STARFIELD
starfield_DATA = dejavu_10.pf2 dejavu_12.pf2 dejavu_bold_14.pf2 dejavu_14.pf2 dejavu_16.pf2 $(starfield_theme_files) 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 dejavu_10.pf2: $(DJVU_FONT_SOURCE) build-grub-mkfont$(BUILD_EXEEXT)
./build-grub-mkfont -s 10 -o $@ $(DJVU_FONT_SOURCE) ./build-grub-mkfont$(BUILD_EXEEXT) -s 10 -o $@ $(DJVU_FONT_SOURCE)
dejavu_12.pf2: $(DJVU_FONT_SOURCE) build-grub-mkfont CLEANFILES += dejavu_10.pf2
./build-grub-mkfont -s 12 -o $@ $(DJVU_FONT_SOURCE) dejavu_12.pf2: $(DJVU_FONT_SOURCE) build-grub-mkfont$(BUILD_EXEEXT)
dejavu_14.pf2: $(DJVU_FONT_SOURCE) build-grub-mkfont ./build-grub-mkfont$(BUILD_EXEEXT) -s 12 -o $@ $(DJVU_FONT_SOURCE)
./build-grub-mkfont -s 14 -o $@ $(DJVU_FONT_SOURCE) CLEANFILES += dejavu_12.pf2
dejavu_bold_14.pf2: $(DJVU_FONT_SOURCE) build-grub-mkfont dejavu_14.pf2: $(DJVU_FONT_SOURCE) build-grub-mkfont$(BUILD_EXEEXT)
./build-grub-mkfont -b -s 14 -o $@ $(DJVU_FONT_SOURCE) ./build-grub-mkfont$(BUILD_EXEEXT) -s 14 -o $@ $(DJVU_FONT_SOURCE)
dejavu_16.pf2: $(DJVU_FONT_SOURCE) build-grub-mkfont CLEANFILES += dejavu_14.pf2
./build-grub-mkfont -s 16 -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_EXEEXT)
./build-grub-mkfont$(BUILD_EXEEXT) -s 16 -o $@ $(DJVU_FONT_SOURCE)
CLEANFILES += dejavu_16.pf2
else else
starfield_DATA = starfield_DATA =
endif endif
@@ -106,28 +111,28 @@ endif
EXTRA_DIST += $(starfield_theme_files) 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 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 unicode.pf2: $(FONT_SOURCE) build-grub-mkfont$(BUILD_EXEEXT)
./build-grub-mkfont -o $@ $(FONT_SOURCE) || (rm -f $@; exit 1) ./build-grub-mkfont$(BUILD_EXEEXT) -o $@ $(FONT_SOURCE) || (rm -f $@; exit 1)
CLEANFILES += unicode.pf2 CLEANFILES += unicode.pf2
# Arrows and lines are needed to draw the menu, so always include them # Arrows and lines are needed to draw the menu, so always include them
UNICODE_ARROWS=0x2190-0x2193 UNICODE_ARROWS=0x2190-0x2193
UNICODE_LINES=0x2501-0x251B UNICODE_LINES=0x2501-0x251B
ascii.pf2: $(FONT_SOURCE) build-grub-mkfont ascii.pf2: $(FONT_SOURCE) build-grub-mkfont$(BUILD_EXEEXT)
./build-grub-mkfont -o $@ $(FONT_SOURCE) -r 0x0-0x7f,$(UNICODE_ARROWS),$(UNICODE_LINES) || (rm -f $@; exit 1) ./build-grub-mkfont$(BUILD_EXEEXT) -o $@ $(FONT_SOURCE) -r 0x0-0x7f,$(UNICODE_ARROWS),$(UNICODE_LINES) || (rm -f $@; exit 1)
CLEANFILES += ascii.pf2 CLEANFILES += ascii.pf2
euro.pf2: $(FONT_SOURCE) build-grub-mkfont euro.pf2: $(FONT_SOURCE) build-grub-mkfont$(BUILD_EXEEXT)
./build-grub-mkfont -o $@ $(FONT_SOURCE) -r 0x0-0x4ff,0x1e00-0x1fff,$(UNICODE_ARROWS),$(UNICODE_LINES) || (rm -f $@; exit 1) ./build-grub-mkfont$(BUILD_EXEEXT) -o $@ $(FONT_SOURCE) -r 0x0-0x4ff,0x1e00-0x1fff,$(UNICODE_ARROWS),$(UNICODE_LINES) || (rm -f $@; exit 1)
CLEANFILES += euro.pf2 CLEANFILES += euro.pf2
ascii.h: $(FONT_SOURCE) build-grub-gen-asciih ascii.h: $(FONT_SOURCE) build-grub-gen-asciih$(BUILD_EXEEXT)
./build-grub-gen-asciih $(FONT_SOURCE) $@ || (rm -f $@; exit 1) ./build-grub-gen-asciih$(BUILD_EXEEXT) $(FONT_SOURCE) $@ || (rm -f $@; exit 1)
CLEANFILES += ascii.h CLEANFILES += ascii.h
widthspec.h: $(FONT_SOURCE) build-grub-gen-widthspec widthspec.h: $(FONT_SOURCE) build-grub-gen-widthspec$(BUILD_EXEEXT)
./build-grub-gen-widthspec $(FONT_SOURCE) $@ || (rm -f $@; exit 1) ./build-grub-gen-widthspec$(BUILD_EXEEXT) $(FONT_SOURCE) $@ || (rm -f $@; exit 1)
CLEANFILES += widthspec.h CLEANFILES += widthspec.h
# Install config.h into platformdir # Install config.h into platformdir
@@ -340,33 +345,35 @@ 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 ./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 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 endif
if COND_x86_64_efi 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 endif
if COND_i386_multiboot if COND_i386_multiboot
# FreeBSD requires ACPI # *BSD 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-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 endif
if COND_i386_coreboot 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 bootcheck-kfreebsd-x86_64 bootcheck-kfreebsd-i386
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
endif endif
if COND_i386_pc if COND_i386_pc
#pc chainloader by definition is only for i386-pc #pc chainloader by definition is only for i386-pc
#ntldr and bootmgr require BIOS. #ntldr and bootmgr require BIOS.
#legacy protocol makes early BIOS calls. #legacy protocol (linux16) makes early BIOS calls.
# NetBSD crashes early on non-BIOS # 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 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 endif
@@ -402,8 +409,9 @@ BOOTCHECK_TIMEOUT=180
bootcheck: $(BOOTCHECKS) bootcheck: $(BOOTCHECKS)
if COND_i386_coreboot if COND_i386_coreboot
default_payload.elf: grub-mkstandalone grub-mkimage default_payload.elf: grub-mkstandalone grub-mkimage FORCE
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 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 endif
endif endif
+11 -1
View File
@@ -172,6 +172,8 @@ program = {
common = util/grub-mkimage.c; common = util/grub-mkimage.c;
common = util/mkimage.c; common = util/mkimage.c;
common = util/grub-mkimage32.c;
common = util/grub-mkimage64.c;
common = util/resolve.c; common = util/resolve.c;
common = grub-core/kern/emu/argp_common.c; common = grub-core/kern/emu/argp_common.c;
common = grub-core/osdep/init.c; common = grub-core/osdep/init.c;
@@ -414,7 +416,7 @@ program = {
ldadd = libgrubgcry.a; ldadd = libgrubgcry.a;
ldadd = libgrubkern.a; ldadd = libgrubkern.a;
ldadd = grub-core/gnulib/libgnu.a; ldadd = grub-core/gnulib/libgnu.a;
ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)'; ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBUTIL) $(LIBZFS) $(LIBNVPAIR) $(LIBGEOM)';
}; };
data = { data = {
@@ -510,6 +512,8 @@ program = {
common = util/render-label.c; common = util/render-label.c;
common = util/glue-efi.c; common = util/glue-efi.c;
common = util/mkimage.c; common = util/mkimage.c;
common = util/grub-mkimage32.c;
common = util/grub-mkimage64.c;
common = util/grub-install-common.c; common = util/grub-install-common.c;
common = util/setup_bios.c; common = util/setup_bios.c;
common = util/setup_sparc.c; common = util/setup_sparc.c;
@@ -552,6 +556,8 @@ program = {
common = util/render-label.c; common = util/render-label.c;
common = util/glue-efi.c; common = util/glue-efi.c;
common = util/mkimage.c; common = util/mkimage.c;
common = util/grub-mkimage32.c;
common = util/grub-mkimage64.c;
common = util/grub-install-common.c; common = util/grub-install-common.c;
common = util/setup_bios.c; common = util/setup_bios.c;
common = util/setup_sparc.c; common = util/setup_sparc.c;
@@ -595,6 +601,8 @@ program = {
common = util/grub-install.c; common = util/grub-install.c;
common = util/probe.c; common = util/probe.c;
common = util/mkimage.c; common = util/mkimage.c;
common = util/grub-mkimage32.c;
common = util/grub-mkimage64.c;
common = util/grub-install-common.c; common = util/grub-install-common.c;
common = util/setup_bios.c; common = util/setup_bios.c;
common = util/setup_sparc.c; common = util/setup_sparc.c;
@@ -632,6 +640,8 @@ program = {
common = util/grub-mknetdir.c; common = util/grub-mknetdir.c;
common = util/mkimage.c; common = util/mkimage.c;
common = util/grub-mkimage32.c;
common = util/grub-mkimage64.c;
common = util/grub-install-common.c; common = util/grub-install-common.c;
common = util/setup_bios.c; common = util/setup_bios.c;
common = util/setup_sparc.c; common = util/setup_sparc.c;
+22
View File
@@ -18,6 +18,7 @@ New in 2.02:
* ZFS features support. * ZFS features support.
* ZFS LZ4 support. * ZFS LZ4 support.
* XFS V5 format support. * XFS V5 format support.
* LVM RAID1 support.
* New/improved terminal and video support: * New/improved terminal and video support:
* Monochrome text (matching `hercules' in GRUB Legacy). * Monochrome text (matching `hercules' in GRUB Legacy).
@@ -49,6 +50,9 @@ New in 2.02:
* Improve TFTP robustness. * Improve TFTP robustness.
* Parse `nd' disk names in GRUB Legacy configuration files. * Parse `nd' disk names in GRUB Legacy configuration files.
* Issue separate DNS queries for IPv4 and IPv6. * Issue separate DNS queries for IPv4 and IPv6.
* Support IPv6 Router Advertisement to configure default router.
* New variable net_<interface>_next_server containing next server
from BOOTP reply.
* Coreboot improvements: * Coreboot improvements:
* CBFS support both in on-disk images (loopback) and flash. * CBFS support both in on-disk images (loopback) and flash.
@@ -59,6 +63,7 @@ New in 2.02:
* Command for inspecting coreboot tables (`lscoreboot'). * Command for inspecting coreboot tables (`lscoreboot').
* New target default_payload.elf. * New target default_payload.elf.
* Increased maximal core size. * Increased maximal core size.
* Prefer pmtimer for TSC calibration.
* New/improved platform support: * New/improved platform support:
* New `efifwsetup' and `lsefi' commands on EFI platforms. * New `efifwsetup' and `lsefi' commands on EFI platforms.
@@ -89,6 +94,14 @@ New in 2.02:
* 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. default if target CPU is not supported.
* Support for booting little-endian Linux kernel on powerpc. * 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.
* New Xen loader on ARM64.
* Respect alignment requirement for block device IO buffers on EFI.
* Security: * Security:
* Add optional facility to enforce that all files read by the core image * Add optional facility to enforce that all files read by the core image
@@ -127,6 +140,11 @@ New in 2.02:
menu entry immediately. menu entry immediately.
* New `file' command and grub-file utility to check file types. * New `file' command and grub-file utility to check file types.
* New syslinux configuration file parser. * New syslinux configuration file parser.
* Set menu entry class to primary OS name returned by os-prober to display
OS specific icon.
* On Linux x86 detect EFI word size in grub-install and automatically select
correct platform (x86_64-efi or i386-efi) to install. Requires Linux kernel
4.0 or higher.
* Build system: * Build system:
* Remove all uses of nested functions; GRUB no longer requires an * Remove all uses of nested functions; GRUB no longer requires an
@@ -152,6 +170,10 @@ New in 2.02:
system. system.
* emu libusb support removed (was broken and unmaintained). * emu libusb support removed (was broken and unmaintained).
* powerpc64le compile support. * powerpc64le compile support.
* Use fixed timestamp when generating GRUB image for reproducible builds.
* Verify at build time that modules contain only supported relocations and their
structure matches what boot-time module loader expects.
* Do not require fonts on powerpc-ieee1275.
* Revision control moved to git. * Revision control moved to git.
-2
View File
@@ -12,8 +12,6 @@ The URL is <http://www.gnu.org/software/grub/grub.html>.
More extensive documentation is available in the Info manual, More extensive documentation is available in the Info manual,
accessible using 'info grub' after building and installing GRUB 2. accessible using 'info grub' after building and installing GRUB 2.
Please look at the GRUB Wiki <http://grub.enbug.org> for testing
procedures.
There are a number of important user-visible differences from the There are a number of important user-visible differences from the
first version of GRUB, now known as GRUB Legacy. For a summary, please first version of GRUB, now known as GRUB Legacy. For a summary, please
-4
View File
@@ -7,7 +7,3 @@ glance. So write to <grub-devel@gnu.org> first.
For bug tracking, refer to: For bug tracking, refer to:
http://savannah.gnu.org/bugs/?group=grub http://savannah.gnu.org/bugs/?group=grub
Our wiki also lists some areas that need work:
http://grub.enbug.org/
+18
View File
@@ -390,6 +390,24 @@ else
[fi] [fi]
]) ])
dnl Check if the Linker supports `-no-pie'.
AC_DEFUN([grub_CHECK_NO_PIE],
[AC_MSG_CHECKING([whether linker accepts -no-pie])
AC_CACHE_VAL(grub_cv_cc_ld_no_pie,
[save_LDFLAGS="$LDFLAGS"
LDFLAGS="$LDFLAGS -no-pie"
AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
[grub_cv_cc_ld_no_pie=yes],
[grub_cv_cc_ld_no_pie=no])
LDFLAGS="$save_LDFLAGS"
])
AC_MSG_RESULT([$grub_cv_cc_ld_no_pie])
nopie_possible=no
if test "x$grub_cv_cc_ld_no_pie" = xyes ; then
nopie_possible=yes
fi
])
dnl Check if the C compiler supports `-fPIC'. dnl Check if the C compiler supports `-fPIC'.
AC_DEFUN([grub_CHECK_PIC],[ AC_DEFUN([grub_CHECK_PIC],[
[# Position independent executable. [# Position independent executable.
+10 -2
View File
@@ -1,10 +1,18 @@
/* on x86 old clang doesn't support .code16 /* on x86 old clang doesn't support .code16
newer clang supports it but creates 6-byte jumps instead of 3-byte ones newer clang supports it but creates 6-byte jumps instead of 3-byte ones
which makes us go over boot sector size. */ which makes us go over boot sector size.
Starting with 3.9 clang emits 3-byte jumps but still creates 8-bytes movl
instead of 5-bytes, so code overflows into data. */
.code16 .code16
jmp far jmp far
.org 4 .org 4
.space 300 jmp nearer
.org 6
movl nearer, %ebx
.org 11
.space 100
nearer:
.space 200
far: far:
.byte 0 .byte 0
+2 -2
View File
@@ -23,14 +23,14 @@ fi
if [ -d grub-core/lib/libgcrypt-grub/mpi/generic ]; then if [ -d grub-core/lib/libgcrypt-grub/mpi/generic ]; then
rm -rf grub-core/lib/libgcrypt-grub/mpi/generic rm -rf grub-core/lib/libgcrypt-grub/mpi/generic
fi 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 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 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 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" rm grub-core/lib/libgcrypt-grub/mpi/"$x"
fi 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 done
echo "Generating Automake input..." echo "Generating Automake input..."
+1 -4
View File
@@ -21,9 +21,6 @@ if COND_powerpc_ieee1275
CFLAGS_PLATFORM += -mcpu=powerpc CFLAGS_PLATFORM += -mcpu=powerpc
endif endif
#FIXME: discover and check XEN headers
CPPFLAGS_XEN = -I/usr/include
# Other options # Other options
CPPFLAGS_DEFAULT = -DGRUB_FILE=\"$(subst $(srcdir)/,,$<)\" CPPFLAGS_DEFAULT = -DGRUB_FILE=\"$(subst $(srcdir)/,,$<)\"
@@ -41,7 +38,7 @@ CFLAGS_KERNEL = $(CFLAGS_PLATFORM) -ffreestanding
LDFLAGS_KERNEL = $(LDFLAGS_PLATFORM) -nostdlib $(TARGET_LDFLAGS_OLDMAGIC) LDFLAGS_KERNEL = $(LDFLAGS_PLATFORM) -nostdlib $(TARGET_LDFLAGS_OLDMAGIC)
CPPFLAGS_KERNEL = $(CPPFLAGS_CPU) $(CPPFLAGS_PLATFORM) -DGRUB_KERNEL=1 CPPFLAGS_KERNEL = $(CPPFLAGS_CPU) $(CPPFLAGS_PLATFORM) -DGRUB_KERNEL=1
CCASFLAGS_KERNEL = $(CCASFLAGS_CPU) $(CCASFLAGS_PLATFORM) 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 CFLAGS_MODULE = $(CFLAGS_PLATFORM) -ffreestanding
LDFLAGS_MODULE = $(LDFLAGS_PLATFORM) -nostdlib $(TARGET_LDFLAGS_OLDMAGIC) -Wl,-r,-d LDFLAGS_MODULE = $(LDFLAGS_PLATFORM) -nostdlib $(TARGET_LDFLAGS_OLDMAGIC) -Wl,-r,-d
+5 -1
View File
@@ -37,7 +37,6 @@ EXTRA_DIST += grub-core/lib/libgcrypt
EXTRA_DIST += grub-core/lib/libgcrypt-grub/mpi/generic EXTRA_DIST += grub-core/lib/libgcrypt-grub/mpi/generic
EXTRA_DIST += $(shell find $(top_srcdir)/include -name '*.h') 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/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/efiemu/runtime/config.h
EXTRA_DIST += grub-core/lib/LzmaDec.c EXTRA_DIST += grub-core/lib/LzmaDec.c
@@ -51,8 +50,13 @@ EXTRA_DIST += util/import_gcrypth.sed
EXTRA_DIST += util/bin2h.c EXTRA_DIST += util/bin2h.c
EXTRA_DIST += util/grub-gen-asciih.c EXTRA_DIST += util/grub-gen-asciih.c
EXTRA_DIST += util/grub-gen-widthspec.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 += util/grub-pe2elf.c
EXTRA_DIST += m4/gnulib-cache.m4 EXTRA_DIST += m4/gnulib-cache.m4
EXTRA_DIST += m4/glibc2.m4 EXTRA_DIST += m4/glibc2.m4
EXTRA_DIST += m4/gnulib-tool.m4 EXTRA_DIST += m4/gnulib-tool.m4
+122 -78
View File
@@ -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 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. 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]) AC_CONFIG_AUX_DIR([build-aux])
@@ -315,7 +315,7 @@ AC_PROG_LN_S
if test "x$LEX" = "x:"; then if test "x$LEX" = "x:"; then
AC_MSG_ERROR([flex is not found]) AC_MSG_ERROR([flex is not found])
else 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 if test -n "$version" -a "$version" -ge 20535; then
: :
else else
@@ -388,7 +388,15 @@ fi
# Check for functions and headers. # Check for functions and headers.
AC_CHECK_FUNCS(posix_memalign memalign getextmntent) AC_CHECK_FUNCS(posix_memalign memalign getextmntent)
AC_CHECK_HEADERS(sys/param.h sys/mount.h sys/mnttab.h sys/mkdev.h limits.h) AC_CHECK_HEADERS(sys/param.h sys/mount.h sys/mnttab.h limits.h)
# glibc 2.25 still includes sys/sysmacros.h in sys/types.h but emits deprecation
# warning which causes compilation failure later with -Werror. So use -Werror here
# as well to force proper sys/sysmacros.h detection.
SAVED_CFLAGS="$CFLAGS"
CFLAGS="$HOST_CFLAGS -Werror"
AC_HEADER_MAJOR
CFLAGS="$SAVED_CFLAGS"
AC_CHECK_MEMBERS([struct statfs.f_fstypename],,,[$ac_includes_default AC_CHECK_MEMBERS([struct statfs.f_fstypename],,,[$ac_includes_default
#include <sys/param.h> #include <sys/param.h>
@@ -783,7 +791,7 @@ fi
if ( test "x$target_cpu" = xi386 || test "x$target_cpu" = xx86_64 ) && test "x$platform" != xemu; then 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 # Some toolchains enable these features by default, but they need
# registers that aren't set up properly in GRUB. # 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 fi
# GRUB doesn't use float or doubles at all. Yet some toolchains may decide # GRUB doesn't use float or doubles at all. Yet some toolchains may decide
@@ -910,12 +918,24 @@ if test x"$target_os" = xcygwin && test "x$grub_cv_cc_no_reorder_functions" = xy
TARGET_CFLAGS="$TARGET_CFLAGS -fno-reorder-functions" TARGET_CFLAGS="$TARGET_CFLAGS -fno-reorder-functions"
fi 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 # By default, GCC 4.6 generates .eh_frame sections containing unwind
# information in some cases where it previously did not. GRUB doesn't need # 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 # these and they just use up vital space. Restore the old compiler
# behaviour. # behaviour.
AC_CACHE_CHECK([whether -fno-asynchronous-unwind-tables works], [grub_cv_cc_fno_asynchronous_unwind_tables], [ 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([[]], [[]])], AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
[grub_cv_cc_fno_asynchronous_unwind_tables=yes], [grub_cv_cc_fno_asynchronous_unwind_tables=yes],
[grub_cv_cc_fno_asynchronous_unwind_tables=no]) [grub_cv_cc_fno_asynchronous_unwind_tables=no])
@@ -925,66 +945,17 @@ if test "x$grub_cv_cc_fno_asynchronous_unwind_tables" = xyes; then
TARGET_CFLAGS="$TARGET_CFLAGS -fno-asynchronous-unwind-tables" TARGET_CFLAGS="$TARGET_CFLAGS -fno-asynchronous-unwind-tables"
fi fi
AC_ARG_ENABLE([efiemu], AC_CACHE_CHECK([whether -fno-unwind-tables works], [grub_cv_cc_fno_unwind_tables], [
[AS_HELP_STRING([--enable-efiemu], CFLAGS="$TARGET_CFLAGS -fno-unwind-tables"
[build and install the efiemu runtimes (default=guessed)])]) AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
if test x"$enable_efiemu" = xno ; then [grub_cv_cc_fno_unwind_tables=yes],
efiemu_excuse="explicitly disabled" [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 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" CFLAGS="$TARGET_CFLAGS"
@@ -1078,6 +1049,73 @@ else
TARGET_IMG_CFLAGS= TARGET_IMG_CFLAGS=
fi 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) AC_SUBST(TARGET_LDFLAGS_OLDMAGIC)
@@ -1114,14 +1152,15 @@ if test "$target_cpu"-"$platform" = x86_64-efi; then
fi fi
if test "x$target_cpu" = xarm; then if test "x$target_cpu" = xarm; then
AC_CACHE_CHECK([whether option -mlong-calls works], grub_cv_cc_mlong_calls, [ AC_CACHE_CHECK([whether option -mllvm -arm-use-movt=0 works], grub_cv_cc_mllvm_arm_use_movt, [
CFLAGS="$TARGET_CFLAGS -mlong-calls -Werror" CPPFLAGS="$TARGET_CPPFLAGS -mllvm -arm-use-movt=0 -Werror"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])], AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
[grub_cv_cc_mlong_calls=yes], [grub_cv_cc_mllvm_arm_use_movt=yes],
[grub_cv_cc_mlong_calls=no]) [grub_cv_cc_mllvm_arm_use_movt=no])
]) ])
if test "x$grub_cv_cc_mlong_calls" = xyes; then if test "x$grub_cv_cc_mllvm_arm_use_movt" = xyes; then
TARGET_CFLAGS="$TARGET_CFLAGS -mlong-calls" # A trick so that clang doesn't see it on link stage
TARGET_CPPFLAGS="$TARGET_CPPFLAGS -mllvm -arm-use-movt=0"
fi fi
AC_CACHE_CHECK([whether option -mthumb-interwork works], grub_cv_cc_mthumb_interwork, [ AC_CACHE_CHECK([whether option -mthumb-interwork works], grub_cv_cc_mthumb_interwork, [
CFLAGS="$TARGET_CFLAGS -mthumb-interwork -Werror" CFLAGS="$TARGET_CFLAGS -mthumb-interwork -Werror"
@@ -1154,13 +1193,18 @@ CFLAGS="$TARGET_CFLAGS"
# Position independent executable. # Position independent executable.
grub_CHECK_PIE grub_CHECK_PIE
grub_CHECK_NO_PIE
[# Need that, because some distributions ship compilers that include [# Need that, because some distributions ship compilers that include
# `-fPIE' in the default specs. # `-fPIE' or '-fpie' and '-pie' in the default specs.
if [ x"$pie_possible" = xyes ]; then if [ x"$pie_possible" = xyes ]; then
TARGET_CFLAGS="$TARGET_CFLAGS -fno-PIE" TARGET_CFLAGS="$TARGET_CFLAGS -fno-PIE -fno-pie"
fi
if [ x"$nopie_possible" = xyes ] && [ x"$pie_possible" = xyes ]; then
TARGET_LDFLAGS="$TARGET_LDFLAGS -no-pie"
fi] fi]
CFLAGS="$TARGET_CFLAGS" CFLAGS="$TARGET_CFLAGS"
LDFLAGS="$TARGET_LDFLAGS"
# Position independent executable. # Position independent executable.
grub_CHECK_PIC grub_CHECK_PIC
@@ -1524,11 +1568,11 @@ if test x"$grub_build_mkfont_excuse" = x ; then
else else
enable_build_grub_mkfont=no enable_build_grub_mkfont=no
fi fi
if test x"$enable_build_grub_mkfont" = xno && ( test "x$platform" = xqemu || test "x$platform" = xloongson || test "x$platform" = xqemu_mips || test "x$target_cpu"-"$platform" = xpowerpc-ieee1275 || test "x$platform" = xcoreboot ); then if test x"$enable_build_grub_mkfont" = xno && ( test "x$platform" = xqemu || test "x$platform" = xloongson || test "x$platform" = xqemu_mips || test "x$platform" = xcoreboot ); then
if test x"$grub_build_mkfont_excuse" = x ; then if test x"$grub_build_mkfont_excuse" = x ; then
AC_MSG_ERROR([qemu, powerpc-ieee1275, coreboot and loongson ports needs build-time grub-mkfont]) AC_MSG_ERROR([qemu, coreboot and loongson ports need build-time grub-mkfont])
else else
AC_MSG_ERROR([qemu, powerpc-ieee1275, coreboot and loongson ports needs build-time grub-mkfont ($grub_build_mkfont_excuse)]) AC_MSG_ERROR([qemu, coreboot and loongson ports need build-time grub-mkfont ($grub_build_mkfont_excuse)])
fi fi
fi fi
@@ -1598,11 +1642,11 @@ if test x"$enable_build_grub_mkfont" = xno ; then
FONT_SOURCE= FONT_SOURCE=
fi fi
if test "x$FONT_SOURCE" = x && ( test "x$platform" = xqemu || test "x$platform" = xloongson || test "x$platform" = xqemu_mips || test "x$target_cpu"-"$platform" = xpowerpc-ieee1275 || test "x$platform" = xcoreboot ); then if test "x$FONT_SOURCE" = x && ( test "x$platform" = xqemu || test "x$platform" = xloongson || test "x$platform" = xqemu_mips || test "x$platform" = xcoreboot ); then
if test x"$grub_build_mkfont_excuse" = x ; then if test x"$grub_build_mkfont_excuse" = x ; then
AC_MSG_ERROR([qemu, powerpc-ieee1275, coreboot and loongson ports need unifont]) AC_MSG_ERROR([qemu, coreboot and loongson ports need unifont])
else else
AC_MSG_ERROR([qemu, powerpc-ieee1275, coreboot and loongson ports need unifont ($grub_build_mkfont_excuse)]) AC_MSG_ERROR([qemu, coreboot and loongson ports need unifont ($grub_build_mkfont_excuse)])
fi fi
fi fi
+104 -16
View File
@@ -2446,6 +2446,10 @@ The boot file name provided by DHCP. Read-only.
The name of the DHCP server responsible for these boot parameters. The name of the DHCP server responsible for these boot parameters.
Read-only. Read-only.
@item net_@var{<interface>}_next_server
The IP address of the next (usually, TFTP) server provided by DHCP.
Read-only.
@item net_default_interface @item net_default_interface
Initially set to name of network interface that was used to load grub. Initially set to name of network interface that was used to load grub.
Read-write, although setting it affects only interpretation of Read-write, although setting it affects only interpretation of
@@ -2538,6 +2542,8 @@ team are:
85:3 85:3
@item Asus EeePC 1005PE @item Asus EeePC 1005PE
84:1 (unconfirmed) 84:1 (unconfirmed)
@item LENOVO ThinkPad T410s (2912W1C)
101:3
@end table @end table
To take full advantage of this function, install GRUB into the MBR To take full advantage of this function, install GRUB into the MBR
@@ -3038,6 +3044,8 @@ These variables have special meaning to GRUB.
* cmdpath:: * cmdpath::
* color_highlight:: * color_highlight::
* color_normal:: * color_normal::
* config_directory::
* config_file::
* debug:: * debug::
* default:: * default::
* fallback:: * fallback::
@@ -3058,6 +3066,7 @@ These variables have special meaning to GRUB.
* net_@var{<interface>}_hostname:: * net_@var{<interface>}_hostname::
* net_@var{<interface>}_ip:: * net_@var{<interface>}_ip::
* net_@var{<interface>}_mac:: * net_@var{<interface>}_mac::
* net_@var{<interface>}_next_server::
* net_@var{<interface>}_rootpath:: * net_@var{<interface>}_rootpath::
* net_default_interface:: * net_default_interface::
* net_default_ip:: * net_default_ip::
@@ -3180,6 +3189,22 @@ matching colors of first half.
to support whole rgb24 palette but currently there is no compelling reason to support whole rgb24 palette but currently there is no compelling reason
to go beyond the current 16 colors. 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 @node debug
@subsection debug @subsection debug
@@ -3402,6 +3427,12 @@ The default is the value of @samp{color_normal} (@pxref{color_normal}).
@xref{Network}. @xref{Network}.
@node net_@var{<interface>}_next_server
@subsection net_@var{<interface>}_next_server
@xref{Network}.
@node net_@var{<interface>}_rootpath @node net_@var{<interface>}_rootpath
@subsection net_@var{<interface>}_rootpath @subsection net_@var{<interface>}_rootpath
@@ -3839,6 +3870,11 @@ you forget a command, you can run the command @command{help}
@comment * vbeinfo:: List available video modes @comment * vbeinfo:: List available video modes
* verify_detached:: Verify detached digital signature * verify_detached:: Verify detached digital signature
* videoinfo:: List available video modes * 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 @end menu
@@ -4050,12 +4086,15 @@ after @command{configfile} returns.
@node cpuid @node cpuid
@subsection cpuid @subsection cpuid
@deffn Command cpuid [-l] @deffn Command cpuid [-l] [-p]
Check for CPU features. This command is only available on x86 systems. 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 With the @option{-l} option, return true if the CPU supports long mode
(64-bit). (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 If invoked without options, this command currently behaves as if it had been
invoked with @option{-l}. This may change in the future. invoked with @option{-l}. This may change in the future.
@end deffn @end deffn
@@ -5019,6 +5058,8 @@ the length of @var{string} is zero
@var{expression} is false @var{expression} is false
@item @var{expression1} @code{-a} @var{expression2} @item @var{expression1} @code{-a} @var{expression2}
both @var{expression1} and @var{expression2} are true 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} @item @var{expression1} @code{-o} @var{expression2}
either @var{expression1} or @var{expression2} is true either @var{expression1} or @var{expression2} is true
@end table @end table
@@ -5102,6 +5143,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. List available video modes. If resolution is given, show only matching modes.
@end deffn @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 @node Networking commands
@section The list of networking commands @section The list of networking commands
@@ -5613,6 +5687,16 @@ BadRAM is the ability to mark some of the RAM as ``bad''. Note: due to protocol
limitations mips-loongson (with Linux protocol) limitations mips-loongson (with Linux protocol)
and mips-qemu_mips can use only memory up to first hole. 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 @multitable @columnfractions .20 .20 .20 .20 .20
@item @tab BIOS @tab Coreboot @tab Multiboot @tab Qemu @item @tab BIOS @tab Coreboot @tab Multiboot @tab Qemu
@item video @tab yes @tab yes @tab yes @tab yes @item video @tab yes @tab yes @tab yes @tab yes
@@ -5629,6 +5713,7 @@ and mips-qemu_mips can use only memory up to first hole.
@item badram @tab yes @tab yes @tab yes @tab yes @item badram @tab yes @tab yes @tab yes @tab yes
@item compression @tab always @tab pointless @tab no @tab no @item compression @tab always @tab pointless @tab no @tab no
@item exit @tab yes @tab no @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 @end multitable
@multitable @columnfractions .20 .20 .20 .20 .20 @multitable @columnfractions .20 .20 .20 .20 .20
@@ -5647,6 +5732,7 @@ and mips-qemu_mips can use only memory up to first hole.
@item badram @tab yes @tab yes @tab no @tab yes @item badram @tab yes @tab yes @tab no @tab yes
@item compression @tab no @tab no @tab no @tab no @item compression @tab no @tab no @tab no @tab no
@item exit @tab yes @tab yes @tab yes @tab yes @item exit @tab yes @tab yes @tab yes @tab yes
@item bootlocation @tab file @tab file @tab file, ignored @tab file
@end multitable @end multitable
@multitable @columnfractions .20 .20 .20 .20 .20 @multitable @columnfractions .20 .20 .20 .20 .20
@@ -5665,24 +5751,26 @@ and mips-qemu_mips can use only memory up to first hole.
@item badram @tab yes (*) @tab no @tab no @tab no @item badram @tab yes (*) @tab no @tab no @tab no
@item compression @tab configurable @tab no @tab no @tab configurable @item compression @tab configurable @tab no @tab no @tab configurable
@item exit @tab no @tab yes @tab yes @tab yes @item exit @tab no @tab yes @tab yes @tab yes
@item bootlocation @tab no @tab partition @tab file @tab file (*)
@end multitable @end multitable
@multitable @columnfractions .20 .20 .20 .20 .20 @multitable @columnfractions .20 .20 .20 .20 .20
@item @tab MIPS qemu @tab emu @item @tab MIPS qemu @tab emu @tab xen
@item video @tab no @tab yes @item video @tab no @tab yes @tab no
@item console charset @tab CP437 @tab Unicode (*) @item console charset @tab CP437 @tab Unicode (*) @tab ASCII
@item network @tab no @tab yes @item network @tab no @tab yes @tab no
@item ATA/AHCI @tab yes @tab no @item ATA/AHCI @tab yes @tab no @tab no
@item AT keyboard @tab yes @tab no @item AT keyboard @tab yes @tab no @tab no
@item Speaker @tab no @tab no @item Speaker @tab no @tab no @tab no
@item USB @tab N/A @tab yes @item USB @tab N/A @tab yes @tab no
@item chainloader @tab yes @tab no @item chainloader @tab yes @tab no @tab yes
@item cpuid @tab no @tab no @item cpuid @tab no @tab no @tab yes
@item hints @tab guess @tab no @item hints @tab guess @tab no @tab no
@item PCI @tab no @tab no @item PCI @tab no @tab no @tab no
@item badram @tab yes (*) @tab no @item badram @tab yes (*) @tab no @tab no
@item compression @tab configurable @tab no @item compression @tab configurable @tab no @tab no
@item exit @tab no @tab yes @item exit @tab no @tab yes @tab no
@item bootlocation @tab no @tab file @tab no
@end multitable @end multitable
@node Platform-specific operations @node Platform-specific operations
+3 -1
View File
@@ -729,9 +729,11 @@ def kernel(defn, platform):
"""if test x$(TARGET_APPLE_LINKER) = x1; then \ """if test x$(TARGET_APPLE_LINKER) = x1; then \
$(TARGET_STRIP) -S -x $(""" + cname(defn) + """) -o $@.bin $<; \ $(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 $@; \ $(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 \ elif test ! -z '$(TARGET_OBJ2ELF)'; then \
""" + "$(TARGET_STRIP) $(" + cname(defn) + "_STRIPFLAGS) -o $@.bin $< && \ """ + "$(TARGET_STRIP) $(" + cname(defn) + "_STRIPFLAGS) -o $@.bin $< && \
$(TARGET_OBJ2ELF) $@.bin $@ || (rm -f $@; rm -f $@.bin; exit 1); \ $(TARGET_OBJ2ELF) $@.bin $@ || (rm -f $@; rm -f $@.bin; exit 1); \
rm -f $@.bin; \
else """ + "$(TARGET_STRIP) $(" + cname(defn) + "_STRIPFLAGS) -o $@ $<; \ else """ + "$(TARGET_STRIP) $(" + cname(defn) + "_STRIPFLAGS) -o $@ $<; \
fi""")) fi"""))
@@ -759,7 +761,7 @@ def image(defn, platform):
if test x$(TARGET_APPLE_LINKER) = x1; then \ if test x$(TARGET_APPLE_LINKER) = x1; then \
$(MACHO2IMG) $< $@; \ $(MACHO2IMG) $< $@; \
else \ 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 fi
""") """)
+14 -1
View File
@@ -39,6 +39,10 @@ gentrigtables$(BUILD_EXEEXT): gentrigtables.c
$(BUILD_CC) -o $@ -I$(top_srcdir)/include $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) $(BUILD_LDFLAGS) $< $(BUILD_LIBM) $(BUILD_CC) -o $@ -I$(top_srcdir)/include $(BUILD_CFLAGS) $(BUILD_CPPFLAGS) $(BUILD_LDFLAGS) $< $(BUILD_LIBM)
CLEANFILES += gentrigtables$(BUILD_EXEEXT) 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
trigtables.c: gentrigtables$(BUILD_EXEEXT) gentrigtables.c $(top_srcdir)/configure.ac trigtables.c: gentrigtables$(BUILD_EXEEXT) gentrigtables.c $(top_srcdir)/configure.ac
./gentrigtables$(BUILD_EXEEXT) > $@ ./gentrigtables$(BUILD_EXEEXT) > $@
@@ -101,7 +105,9 @@ if COND_i386_efi
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/efi.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/efi/disk.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/i386/tsc.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/pci.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/i386/pmtimer.h
endif endif
if COND_i386_coreboot if COND_i386_coreboot
@@ -112,10 +118,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/gfxterm.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/font.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/bufio.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/acpi.h
endif endif
if COND_i386_multiboot if COND_i386_multiboot
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/i386/tsc.h KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/i386/tsc.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/acpi.h
endif endif
if COND_i386_qemu if COND_i386_qemu
@@ -154,11 +162,14 @@ 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/efi/disk.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/i386/tsc.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/pci.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/acpi.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/i386/pmtimer.h
endif endif
if COND_ia64_efi if COND_ia64_efi
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/efi.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/efi/disk.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/acpi.h
endif endif
if COND_mips if COND_mips
@@ -233,11 +244,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/efi.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/disk.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/arm/system.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/acpi.h
endif endif
if COND_arm64_efi if COND_arm64_efi
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/efi/efi.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/efi/disk.h
KERNEL_HEADER_FILES += $(top_srcdir)/include/grub/acpi.h
endif endif
if COND_emu if COND_emu
@@ -383,7 +396,7 @@ moddep.lst: syminfo.lst genmoddep.awk video.lst
platform_DATA += moddep.lst platform_DATA += moddep.lst
CLEANFILES += config.log syminfo.lst 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$(BUILD_EXEEXT)
TARGET_OBJ2ELF=@TARGET_OBJ2ELF@ sh $^ $@ TARGET_OBJ2ELF=@TARGET_OBJ2ELF@ sh $^ $@
platform_DATA += $(MOD_FILES) platform_DATA += $(MOD_FILES)
platform_DATA += modinfo.sh platform_DATA += modinfo.sh
+48 -18
View File
@@ -59,9 +59,6 @@ kernel = {
ia64_efi_ldflags = '-Wl,-r,-d'; ia64_efi_ldflags = '-Wl,-r,-d';
ia64_efi_stripflags = '--strip-unneeded -K start -R .note -R .comment -R .note.gnu.gold-version'; 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_ldflags = '-Wl,-r,-d';
arm_efi_stripflags = '--strip-unneeded -K start -R .note -R .comment -R .note.gnu.gold-version'; arm_efi_stripflags = '--strip-unneeded -K start -R .note -R .comment -R .note.gnu.gold-version';
@@ -93,7 +90,7 @@ kernel = {
i386_qemu_cppflags = '-DGRUB_BOOT_MACHINE_LINK_ADDR=$(GRUB_BOOT_MACHINE_LINK_ADDR)'; i386_qemu_cppflags = '-DGRUB_BOOT_MACHINE_LINK_ADDR=$(GRUB_BOOT_MACHINE_LINK_ADDR)';
emu_cflags = '$(CFLAGS_GNULIB)'; emu_cflags = '$(CFLAGS_GNULIB)';
emu_cppflags = '$(CPPFLAGS_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'; arm_uboot_stripflags = '--strip-unneeded -K start -R .note -R .comment -R .note.gnu.gold-version';
i386_pc_startup = kern/i386/pc/startup.S; i386_pc_startup = kern/i386/pc/startup.S;
@@ -174,8 +171,20 @@ kernel = {
efi = kern/efi/init.c; efi = kern/efi/init.c;
efi = kern/efi/mm.c; efi = kern/efi/mm.c;
efi = term/efi/console.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.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 = kern/i386/efi/init.c;
i386_efi = bus/pci.c; i386_efi = bus/pci.c;
@@ -187,6 +196,7 @@ kernel = {
x86_64_efi = bus/pci.c; x86_64_efi = bus/pci.c;
xen = kern/i386/tsc.c; xen = kern/i386/tsc.c;
xen = kern/i386/xen/tsc.c;
x86_64_xen = kern/x86_64/xen/hypercall.S; x86_64_xen = kern/x86_64/xen/hypercall.S;
i386_xen = kern/i386/xen/hypercall.S; i386_xen = kern/i386/xen/hypercall.S;
xen = kern/xen/init.c; xen = kern/xen/init.c;
@@ -202,8 +212,10 @@ kernel = {
arm_efi = kern/arm/efi/init.c; arm_efi = kern/arm/efi/init.c;
arm_efi = kern/arm/efi/misc.c; arm_efi = kern/arm/efi/misc.c;
arm_efi = kern/efi/fdt.c;
arm64_efi = kern/arm/efi/init.c; arm64_efi = kern/arm64/efi/init.c;
arm64_efi = kern/efi/fdt.c;
i386_pc = kern/i386/pc/init.c; i386_pc = kern/i386/pc/init.c;
i386_pc = kern/i386/pc/mmap.c; i386_pc = kern/i386/pc/mmap.c;
@@ -604,7 +616,6 @@ module = {
module = { module = {
name = lsxen; name = lsxen;
common = commands/xen/lsxen.c; common = commands/xen/lsxen.c;
cppflags = '$(CPPFLAGS_XEN)';
enable = xen; enable = xen;
}; };
@@ -669,10 +680,8 @@ module = {
name = acpi; name = acpi;
common = commands/acpi.c; common = commands/acpi.c;
efi = commands/efi/acpi.c; i386_pc = kern/acpi.c;
i386_pc = commands/i386/pc/acpi.c; i386_pc = kern/i386/pc/acpi.c;
i386_coreboot = commands/i386/pc/acpi.c;
i386_multiboot = commands/i386/pc/acpi.c;
enable = efi; enable = efi;
enable = i386_pc; enable = i386_pc;
@@ -825,7 +834,6 @@ module = {
i386_coreboot = lib/i386/halt.c; i386_coreboot = lib/i386/halt.c;
i386_qemu = lib/i386/halt.c; i386_qemu = lib/i386/halt.c;
xen = lib/xen/halt.c; xen = lib/xen/halt.c;
xen_cppflags = '$(CPPFLAGS_XEN)';
efi = lib/efi/halt.c; efi = lib/efi/halt.c;
ieee1275 = lib/ieee1275/halt.c; ieee1275 = lib/ieee1275/halt.c;
emu = lib/emu/halt.c; emu = lib/emu/halt.c;
@@ -846,7 +854,6 @@ module = {
mips_loongson = lib/mips/loongson/reboot.c; mips_loongson = lib/mips/loongson/reboot.c;
mips_qemu_mips = lib/mips/qemu_mips/reboot.c; mips_qemu_mips = lib/mips/qemu_mips/reboot.c;
xen = lib/xen/reboot.c; xen = lib/xen/reboot.c;
xen_cppflags = '$(CPPFLAGS_XEN)';
uboot = lib/uboot/reboot.c; uboot = lib/uboot/reboot.c;
common = commands/reboot.c; common = commands/reboot.c;
}; };
@@ -1526,7 +1533,7 @@ module = {
i386_xen = lib/i386/xen/relocator.S; i386_xen = lib/i386/xen/relocator.S;
x86_64_xen = lib/x86_64/xen/relocator.S; x86_64_xen = lib/x86_64/xen/relocator.S;
xen = lib/i386/relocator_common_c.c; xen = lib/i386/relocator_common_c.c;
xen_cppflags = '$(CPPFLAGS_XEN)'; x86_64_efi = lib/x86_64/efi/relocator.c;
extra_dist = lib/i386/relocator_common.S; extra_dist = lib/i386/relocator_common.S;
extra_dist = kern/powerpc/cache_flush.S; extra_dist = kern/powerpc/cache_flush.S;
@@ -1547,7 +1554,6 @@ module = {
sparc64_ieee1275 = lib/ieee1275/cmos.c; sparc64_ieee1275 = lib/ieee1275/cmos.c;
powerpc_ieee1275 = lib/ieee1275/cmos.c; powerpc_ieee1275 = lib/ieee1275/cmos.c;
xen = lib/xen/datetime.c; xen = lib/xen/datetime.c;
xen_cppflags = '$(CPPFLAGS_XEN)';
mips_arc = lib/arc/datetime.c; mips_arc = lib/arc/datetime.c;
enable = noemu; enable = noemu;
@@ -1657,7 +1663,6 @@ module = {
name = linux; name = linux;
x86 = loader/i386/linux.c; x86 = loader/i386/linux.c;
xen = loader/i386/xen.c; xen = loader/i386/xen.c;
xen_cppflags = '$(CPPFLAGS_XEN)';
i386_pc = lib/i386/pc/vesa_modes_table.c; i386_pc = lib/i386/pc/vesa_modes_table.c;
mips = loader/mips/linux.c; mips = loader/mips/linux.c;
powerpc_ieee1275 = loader/powerpc/ieee1275/linux.c; powerpc_ieee1275 = loader/powerpc/ieee1275/linux.c;
@@ -1665,7 +1670,6 @@ module = {
ia64_efi = loader/ia64/efi/linux.c; ia64_efi = loader/ia64/efi/linux.c;
arm = loader/arm/linux.c; arm = loader/arm/linux.c;
arm64 = loader/arm64/linux.c; arm64 = loader/arm64/linux.c;
fdt = lib/fdt.c;
common = loader/linux.c; common = loader/linux.c;
common = lib/cmdline.c; common = lib/cmdline.c;
enable = noemu; enable = noemu;
@@ -1674,7 +1678,8 @@ module = {
module = { module = {
name = fdt; name = fdt;
arm64 = loader/arm64/fdt.c; arm64 = loader/arm64/fdt.c;
enable = arm64; common = lib/fdt.c;
enable = fdt;
}; };
module = { module = {
@@ -1683,7 +1688,32 @@ module = {
x86 = loader/i386/xnu.c; x86 = loader/i386/xnu.c;
x86 = loader/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;
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 = { module = {
+60 -11
View File
@@ -29,6 +29,7 @@
#include <grub/loader.h> #include <grub/loader.h>
#include <grub/cs5536.h> #include <grub/cs5536.h>
#include <grub/disk.h> #include <grub/disk.h>
#include <grub/cache.h>
GRUB_MOD_LICENSE ("GPLv3+"); GRUB_MOD_LICENSE ("GPLv3+");
@@ -337,6 +338,21 @@ struct grub_ehci
static struct grub_ehci *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 */ /* EHCC registers access functions */
static inline grub_uint32_t static inline grub_uint32_t
grub_ehci_ehcc_read32 (struct grub_ehci *e, grub_uint32_t addr) 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; grub_uint64_t maxtime;
sync_all_caches (e);
grub_ehci_oper_write32 (e, GRUB_EHCI_COMMAND, grub_ehci_oper_write32 (e, GRUB_EHCI_COMMAND,
GRUB_EHCI_CMD_HC_RESET GRUB_EHCI_CMD_HC_RESET
| grub_ehci_oper_read32 (e, GRUB_EHCI_COMMAND)); | 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; e->next = ehci;
ehci = e; ehci = e;
sync_all_caches (e);
grub_dprintf ("ehci", "EHCI grub_ehci_pci_iter: OK at all\n"); grub_dprintf ("ehci", "EHCI grub_ehci_pci_iter: OK at all\n");
grub_dprintf ("ehci", 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 */ /* Found proper existing (and linked) QH, do setup of QH */
grub_dprintf ("ehci", "find_qh: found, QH=%p\n", qh_iter); grub_dprintf ("ehci", "find_qh: found, QH=%p\n", qh_iter);
grub_ehci_setup_qh (qh_iter, transfer); grub_ehci_setup_qh (qh_iter, transfer);
sync_all_caches (e);
return qh_iter; return qh_iter;
} }
@@ -1121,7 +1142,7 @@ grub_ehci_free_tds (struct grub_ehci *e, grub_ehci_td_t td,
token = grub_le_to_cpu32 (td->token); token = grub_le_to_cpu32 (td->token);
to_transfer = (token & GRUB_EHCI_TOTAL_MASK) >> GRUB_EHCI_TOTAL_OFF; 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 * whole data then set last_trans - it should be last executed TD
* in case when something went wrong. */ * in case when something went wrong. */
if (transfer && (td->size != to_transfer)) if (transfer && (td->size != to_transfer))
@@ -1289,16 +1310,28 @@ grub_ehci_setup_transfer (grub_usb_controller_t dev,
grub_ehci_td_t td_prev = NULL; grub_ehci_td_t td_prev = NULL;
int i; int i;
struct grub_ehci_transfer_controller_data *cdata; struct grub_ehci_transfer_controller_data *cdata;
grub_uint32_t status;
sync_all_caches (e);
/* Check if EHCI is running and AL is enabled */ /* Check if EHCI is running and AL is enabled */
if ((grub_ehci_oper_read32 (e, GRUB_EHCI_STATUS) status = grub_ehci_oper_read32 (e, GRUB_EHCI_STATUS);
& GRUB_EHCI_ST_HC_HALTED) != 0) if ((status & GRUB_EHCI_ST_HC_HALTED) != 0)
/* XXX: Fix it: Currently we don't do anything to restart EHCI */ /* 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) & (GRUB_EHCI_ST_AS_STATUS | GRUB_EHCI_ST_PS_STATUS)) == 0)
/* XXX: Fix it: Currently we don't do anything to restart EHCI */ /* 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. */ /* Allocate memory for controller transfer data. */
cdata = grub_malloc (sizeof (*cdata)); cdata = grub_malloc (sizeof (*cdata));
@@ -1310,6 +1343,7 @@ grub_ehci_setup_transfer (grub_usb_controller_t dev,
cdata->qh_virt = grub_ehci_find_qh (e, transfer); cdata->qh_virt = grub_ehci_find_qh (e, transfer);
if (!cdata->qh_virt) if (!cdata->qh_virt)
{ {
grub_dprintf ("ehci", "setup_transfer: no QH\n");
grub_free (cdata); grub_free (cdata);
return GRUB_USB_ERR_INTERNAL; return GRUB_USB_ERR_INTERNAL;
} }
@@ -1319,6 +1353,7 @@ grub_ehci_setup_transfer (grub_usb_controller_t dev,
cdata->td_alt_virt = grub_ehci_alloc_td (e); cdata->td_alt_virt = grub_ehci_alloc_td (e);
if (!cdata->td_alt_virt) if (!cdata->td_alt_virt)
{ {
grub_dprintf ("ehci", "setup_transfer: no TDs\n");
grub_free (cdata); grub_free (cdata);
return GRUB_USB_ERR_INTERNAL; return GRUB_USB_ERR_INTERNAL;
} }
@@ -1345,6 +1380,7 @@ grub_ehci_setup_transfer (grub_usb_controller_t dev,
grub_ehci_free_tds (e, cdata->td_first_virt, NULL, &actual); grub_ehci_free_tds (e, cdata->td_first_virt, NULL, &actual);
grub_free (cdata); grub_free (cdata);
grub_dprintf ("ehci", "setup_transfer: no TD\n");
return GRUB_USB_ERR_INTERNAL; return GRUB_USB_ERR_INTERNAL;
} }
@@ -1386,6 +1422,8 @@ grub_ehci_setup_transfer (grub_usb_controller_t dev,
* i.e. reset token */ * i.e. reset token */
cdata->qh_virt->td_overlay.token = grub_cpu_to_le32_compile_time (0); cdata->qh_virt->td_overlay.token = grub_cpu_to_le32_compile_time (0);
sync_all_caches (e);
/* Finito */ /* Finito */
transfer->controller_data = cdata; transfer->controller_data = cdata;
@@ -1434,6 +1472,8 @@ grub_ehci_parse_notrun (grub_usb_controller_t dev,
grub_ehci_free_td (e, cdata->td_alt_virt); grub_ehci_free_td (e, cdata->td_alt_virt);
grub_free (cdata); grub_free (cdata);
sync_all_caches (e);
/* Additionally, do something with EHCI to make it running (what?) */ /* Additionally, do something with EHCI to make it running (what?) */
/* Try enable EHCI and AL */ /* Try enable EHCI and AL */
grub_ehci_oper_write32 (e, GRUB_EHCI_COMMAND, grub_ehci_oper_write32 (e, GRUB_EHCI_COMMAND,
@@ -1469,6 +1509,8 @@ grub_ehci_parse_halt (grub_usb_controller_t dev,
grub_ehci_free_td (e, cdata->td_alt_virt); grub_ehci_free_td (e, cdata->td_alt_virt);
grub_free (cdata); grub_free (cdata);
sync_all_caches (e);
/* Evaluation of error code - currently we don't have GRUB USB error /* 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. * codes for some EHCI states, GRUB_USB_ERR_DATA is used for them.
* Order of evaluation is critical, specially bubble/stall. */ * Order of evaluation is critical, specially bubble/stall. */
@@ -1502,6 +1544,8 @@ grub_ehci_parse_success (grub_usb_controller_t dev,
grub_ehci_free_td (e, cdata->td_alt_virt); grub_ehci_free_td (e, cdata->td_alt_virt);
grub_free (cdata); grub_free (cdata);
sync_all_caches (e);
return GRUB_USB_ERR_NONE; return GRUB_USB_ERR_NONE;
} }
@@ -1515,6 +1559,8 @@ grub_ehci_check_transfer (grub_usb_controller_t dev,
transfer->controller_data; transfer->controller_data;
grub_uint32_t token, token_ftd; grub_uint32_t token, token_ftd;
sync_all_caches (e);
grub_dprintf ("ehci", grub_dprintf ("ehci",
"check_transfer: EHCI STATUS=%08x, cdata=%p, qh=%p\n", "check_transfer: EHCI STATUS=%08x, cdata=%p, qh=%p\n",
grub_ehci_oper_read32 (e, GRUB_EHCI_STATUS), grub_ehci_oper_read32 (e, GRUB_EHCI_STATUS),
@@ -1581,6 +1627,9 @@ grub_ehci_cancel_transfer (grub_usb_controller_t dev,
int i; int i;
grub_uint64_t maxtime; grub_uint64_t maxtime;
grub_uint32_t qh_phys; grub_uint32_t qh_phys;
sync_all_caches (e);
grub_uint32_t interrupt = grub_uint32_t interrupt =
cdata->qh_virt->ep_cap & GRUB_EHCI_SMASK_MASK; cdata->qh_virt->ep_cap & GRUB_EHCI_SMASK_MASK;
@@ -1600,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_tds (e, cdata->td_first_virt, transfer, &actual);
grub_ehci_free_td (e, cdata->td_alt_virt); grub_ehci_free_td (e, cdata->td_alt_virt);
grub_free (cdata); grub_free (cdata);
sync_all_caches (e);
grub_dprintf ("ehci", "cancel_transfer: end - EHCI not running\n"); grub_dprintf ("ehci", "cancel_transfer: end - EHCI not running\n");
return GRUB_USB_ERR_NONE; return GRUB_USB_ERR_NONE;
} }
@@ -1622,6 +1672,8 @@ grub_ehci_cancel_transfer (grub_usb_controller_t dev,
/* Unlink QH from AL */ /* Unlink QH from AL */
e->qh_virt[i].qh_hptr = cdata->qh_virt->qh_hptr; 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 /* If this is an interrupt transfer, we just wait for the periodic
* schedule to advance a few times and then assume that the EHCI * schedule to advance a few times and then assume that the EHCI
* controller has read the updated QH. */ * controller has read the updated QH. */
@@ -1676,6 +1728,8 @@ grub_ehci_cancel_transfer (grub_usb_controller_t dev,
grub_dprintf ("ehci", "cancel_transfer: end\n"); grub_dprintf ("ehci", "cancel_transfer: end\n");
sync_all_caches (e);
return GRUB_USB_ERR_NONE; return GRUB_USB_ERR_NONE;
} }
@@ -1777,11 +1831,6 @@ grub_ehci_detect_dev (grub_usb_controller_t dev, int port, int *changed)
status = grub_ehci_port_read (e, port); 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 */ /* Connect Status Change bit - it detects change of connection */
if (status & GRUB_EHCI_PORT_CONNECT_CH) if (status & GRUB_EHCI_PORT_CONNECT_CH)
{ {
+19 -5
View File
@@ -24,6 +24,7 @@
#include <grub/usb.h> #include <grub/usb.h>
#include <grub/usbtrans.h> #include <grub/usbtrans.h>
#include <grub/time.h> #include <grub/time.h>
#include <grub/cache.h>
static inline unsigned int 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); data_addr = grub_dma_get_phys (data_chunk);
grub_memcpy ((char *) data, data_in, size); grub_memcpy ((char *) data, data_in, size);
grub_arch_sync_dma_caches (data, size);
grub_dprintf ("usb", grub_dprintf ("usb",
"control: reqtype=0x%02x req=0x%02x val=0x%02x idx=0x%02x size=%lu\n", "control: reqtype=0x%02x req=0x%02x val=0x%02x idx=0x%02x size=%lu\n",
reqtype, request, value, index, (unsigned long)size); reqtype, request, value, index, (unsigned long)size);
@@ -161,6 +164,8 @@ grub_usb_control_msg (grub_usb_device_t dev,
setupdata->value = value; setupdata->value = value;
setupdata->index = index; setupdata->index = index;
setupdata->length = size; setupdata->length = size;
grub_arch_sync_dma_caches (setupdata, sizeof (*setupdata));
transfer->transactions[0].size = sizeof (*setupdata); transfer->transactions[0].size = sizeof (*setupdata);
transfer->transactions[0].pid = GRUB_USB_TRANSFER_TYPE_SETUP; transfer->transactions[0].pid = GRUB_USB_TRANSFER_TYPE_SETUP;
transfer->transactions[0].data = setupdata_addr; 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->transactions);
grub_free (transfer); grub_free (transfer);
grub_dma_free (data_chunk);
grub_dma_free (setupdata_chunk); grub_dma_free (setupdata_chunk);
grub_arch_sync_dma_caches (data, size0);
grub_memcpy (data_in, (char *) data, size0); grub_memcpy (data_in, (char *) data, size0);
grub_dma_free (data_chunk);
return err; return err;
} }
@@ -236,7 +243,10 @@ grub_usb_bulk_setup_readwrite (grub_usb_device_t dev,
data = grub_dma_get_virt (data_chunk); data = grub_dma_get_virt (data_chunk);
data_addr = grub_dma_get_phys (data_chunk); data_addr = grub_dma_get_phys (data_chunk);
if (type == GRUB_USB_TRANSFER_TYPE_OUT) 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. */ /* Create a transfer. */
transfer = grub_malloc (sizeof (struct grub_usb_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; dev->toggle[transfer->endpoint] = toggle;
if (transfer->dir == GRUB_USB_TRANSFER_TYPE_IN) if (transfer->dir == GRUB_USB_TRANSFER_TYPE_IN)
grub_memcpy (transfer->data, (void *) {
grub_dma_get_virt (transfer->data_chunk), grub_arch_sync_dma_caches (grub_dma_get_virt (transfer->data_chunk),
transfer->size + 1); transfer->size + 1);
grub_memcpy (transfer->data, (void *)
grub_dma_get_virt (transfer->data_chunk),
transfer->size + 1);
}
grub_free (transfer->transactions); grub_free (transfer->transactions);
grub_dma_free (transfer->data_chunk); grub_dma_free (transfer->data_chunk);
+3 -12
View File
@@ -61,18 +61,6 @@ static const struct grub_arg_option options[] = {
{0, 0, 0, 0, 0, 0} {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. /* rev1 is 1 if ACPIv1 is to be generated, 0 otherwise.
rev2 contains the revision of ACPIv2+ to generate or 0 if none. */ rev2 contains the revision of ACPIv2+ to generate or 0 if none. */
static int rev1, rev2; static int rev1, rev2;
@@ -605,6 +593,9 @@ grub_cmd_acpi (struct grub_extcmd_context *ctxt, int argc, char **args)
if (! table->addr) if (! table->addr)
{ {
free_tables (); free_tables ();
grub_free (exclude);
grub_free (load_only);
grub_free (table);
return grub_errno; return grub_errno;
} }
table->next = acpi_tables; table->next = acpi_tables;
+3
View File
@@ -26,6 +26,8 @@
#define grub_dprintf(cond, args...) printf ( args ) #define grub_dprintf(cond, args...) printf ( args )
#define grub_printf printf #define grub_printf printf
#define grub_util_fopen fopen
#define grub_memcmp memcmp
typedef uint64_t grub_uint64_t; typedef uint64_t grub_uint64_t;
typedef uint32_t grub_uint32_t; typedef uint32_t grub_uint32_t;
typedef uint16_t grub_uint16_t; typedef uint16_t grub_uint16_t;
@@ -246,6 +248,7 @@ get_sleep_type (grub_uint8_t *table, grub_uint8_t *ptr, grub_uint8_t *end,
if (!add) if (!add)
return -1; return -1;
break; break;
case GRUB_ACPI_OPCODE_CREATE_DWORD_FIELD:
case GRUB_ACPI_OPCODE_CREATE_WORD_FIELD: case GRUB_ACPI_OPCODE_CREATE_WORD_FIELD:
case GRUB_ACPI_OPCODE_CREATE_BYTE_FIELD: case GRUB_ACPI_OPCODE_CREATE_BYTE_FIELD:
{ {
+7 -4
View File
@@ -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_STANDARD);
} }
grub_setcolorstate (GRUB_TERM_COLOR_HIGHLIGHT); if (utcount)
for (j = 0; j < utcount; j++) {
grub_printf ("<%x>", (unsigned int) utbuf[j]); grub_setcolorstate (GRUB_TERM_COLOR_HIGHLIGHT);
grub_setcolorstate (GRUB_TERM_COLOR_STANDARD); for (j = 0; j < utcount; j++)
grub_printf ("<%x>", (unsigned int) utbuf[j]);
grub_setcolorstate (GRUB_TERM_COLOR_STANDARD);
}
grub_xputs ("\n"); grub_xputs ("\n");
grub_refresh (); grub_refresh ();
+31 -16
View File
@@ -51,7 +51,7 @@ grub_cmd_lsefimmap (grub_command_t cmd __attribute__ ((unused)),
grub_printf grub_printf
("Type Physical start - end #Pages " ("Type Physical start - end #Pages "
" Size Attributes\n"); " Size Attributes\n");
memory_map_end = ADD_MEMORY_DESCRIPTOR (memory_map, map_size); memory_map_end = ADD_MEMORY_DESCRIPTOR (memory_map, map_size);
for (desc = memory_map; for (desc = memory_map;
desc < memory_map_end; desc < memory_map_end;
@@ -74,7 +74,8 @@ grub_cmd_lsefimmap (grub_command_t cmd __attribute__ ((unused)),
"ACPI-nvs", "ACPI-nvs",
"MMIO ", "MMIO ",
"IO-ports", "IO-ports",
"PAL-code" "PAL-code",
"persist ",
}; };
if (desc->type < ARRAY_SIZE (types_str)) if (desc->type < ARRAY_SIZE (types_str))
grub_printf ("%s ", types_str[desc->type]); 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->physical_start + (desc->num_pages << 12) - 1,
desc->num_pages); desc->num_pages);
size = desc->num_pages; size = desc->num_pages << 12; /* 4 KiB page size */
size <<= (12 - 10); /*
if (size < 1024) * Since size is a multiple of 4 KiB, no need to handle units
grub_printf (" %4" PRIuGRUB_UINT64_T "KB", size); * 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 else
{ grub_printf (" %6" PRIuGRUB_UINT64_T "EiB", size >> 60);
size /= 1024;
if (size < 1024)
grub_printf (" %4" PRIuGRUB_UINT64_T "MB", size);
else
{
size /= 1024;
grub_printf (" %4" PRIuGRUB_UINT64_T "GB", size);
}
}
attr = desc->attribute; attr = desc->attribute;
if (attr & GRUB_EFI_MEMORY_RUNTIME) if (attr & GRUB_EFI_MEMORY_RUNTIME)
@@ -122,6 +131,12 @@ grub_cmd_lsefimmap (grub_command_t cmd __attribute__ ((unused)),
grub_printf (" RP"); grub_printf (" RP");
if (attr & GRUB_EFI_MEMORY_XP) if (attr & GRUB_EFI_MEMORY_XP)
grub_printf (" 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"); grub_printf ("\n");
} }
+12 -2
View File
@@ -37,10 +37,20 @@ static const struct guid_mapping guid_mappings[] =
{ {
{ GRUB_EFI_ACPI_20_TABLE_GUID, "ACPI-2.0"}, { GRUB_EFI_ACPI_20_TABLE_GUID, "ACPI-2.0"},
{ GRUB_EFI_ACPI_TABLE_GUID, "ACPI-1.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_SAL_TABLE_GUID, "SAL"},
{ GRUB_EFI_SMBIOS_TABLE_GUID, "SMBIOS"}, { GRUB_EFI_SMBIOS_TABLE_GUID, "SMBIOS"},
{ GRUB_EFI_MPS_TABLE_GUID, "MPS"}, { GRUB_EFI_SYSTEM_RESOURCE_TABLE_GUID, "SYSTEM RESOURCE TABLE"},
{ GRUB_EFI_HCDP_TABLE_GUID, "HCDP"} { GRUB_EFI_TIANO_CUSTOM_DECOMPRESS_GUID, "TIANO CUSTOM DECOMPRESS"},
{ GRUB_EFI_TSC_FREQUENCY_GUID, "TSC FREQUENCY"},
}; };
static grub_err_t static grub_err_t
+3 -3
View File
@@ -45,7 +45,7 @@ static grub_err_t
grub_cmd_cmostest (struct grub_command *cmd __attribute__ ((unused)), grub_cmd_cmostest (struct grub_command *cmd __attribute__ ((unused)),
int argc, char *argv[]) int argc, char *argv[])
{ {
int byte, bit; int byte = 0, bit = 0;
grub_err_t err; grub_err_t err;
grub_uint8_t value; grub_uint8_t value;
@@ -67,7 +67,7 @@ static grub_err_t
grub_cmd_cmosclean (struct grub_command *cmd __attribute__ ((unused)), grub_cmd_cmosclean (struct grub_command *cmd __attribute__ ((unused)),
int argc, char *argv[]) int argc, char *argv[])
{ {
int byte, bit; int byte = 0, bit = 0;
grub_err_t err; grub_err_t err;
grub_uint8_t value; grub_uint8_t value;
@@ -85,7 +85,7 @@ static grub_err_t
grub_cmd_cmosset (struct grub_command *cmd __attribute__ ((unused)), grub_cmd_cmosset (struct grub_command *cmd __attribute__ ((unused)),
int argc, char *argv[]) int argc, char *argv[])
{ {
int byte, bit; int byte = 0, bit = 0;
grub_err_t err; grub_err_t err;
grub_uint8_t value; grub_uint8_t value;
+32 -11
View File
@@ -253,6 +253,7 @@ grub_cmd_legacy_kernel (struct grub_command *mycmd __attribute__ ((unused)),
struct grub_command *cmd; struct grub_command *cmd;
char **cutargs; char **cutargs;
int cutargc; int cutargc;
grub_err_t err = GRUB_ERR_NONE;
for (i = 0; i < 2; i++) 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")); return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("filename expected"));
cutargs = grub_malloc (sizeof (cutargs[0]) * (argc - 1)); cutargs = grub_malloc (sizeof (cutargs[0]) * (argc - 1));
if (!cutargs)
return grub_errno;
cutargc = argc - 1; cutargc = argc - 1;
grub_memcpy (cutargs + 1, args + 2, sizeof (cutargs[0]) * (argc - 2)); grub_memcpy (cutargs + 1, args + 2, sizeof (cutargs[0]) * (argc - 2));
cutargs[0] = args[0]; cutargs[0] = args[0];
@@ -333,7 +336,7 @@ grub_cmd_legacy_kernel (struct grub_command *mycmd __attribute__ ((unused)),
if (!(cmd->func) (cmd, cutargc, cutargs)) if (!(cmd->func) (cmd, cutargc, cutargs))
{ {
kernel_type = LINUX; kernel_type = LINUX;
return GRUB_ERR_NONE; goto out;
} }
} }
grub_errno = GRUB_ERR_NONE; 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)) if (!(cmd->func) (cmd, argc, args))
{ {
kernel_type = MULTIBOOT; kernel_type = MULTIBOOT;
return GRUB_ERR_NONE; goto out;
} }
} }
grub_errno = GRUB_ERR_NONE; 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)) if (!(cmd->func) (cmd, cutargc, cutargs))
{ {
kernel_type = KFREEBSD; kernel_type = KFREEBSD;
return GRUB_ERR_NONE; goto out;
} }
} }
grub_errno = GRUB_ERR_NONE; grub_errno = GRUB_ERR_NONE;
@@ -422,6 +425,8 @@ grub_cmd_legacy_kernel (struct grub_command *mycmd __attribute__ ((unused)),
char **bsdargs; char **bsdargs;
int bsdargc; int bsdargc;
char bsddevname[sizeof ("wdXXXXXXXXXXXXY")]; char bsddevname[sizeof ("wdXXXXXXXXXXXXY")];
int found = 0;
if (bsd_device == -1) if (bsd_device == -1)
{ {
bsdargs = cutargs; bsdargs = cutargs;
@@ -432,6 +437,11 @@ grub_cmd_legacy_kernel (struct grub_command *mycmd __attribute__ ((unused)),
char rbuf[3] = "-r"; char rbuf[3] = "-r";
bsdargc = cutargc + 2; bsdargc = cutargc + 2;
bsdargs = grub_malloc (sizeof (bsdargs[0]) * bsdargc); bsdargs = grub_malloc (sizeof (bsdargs[0]) * bsdargc);
if (!bsdargs)
{
err = grub_errno;
goto out;
}
grub_memcpy (bsdargs, args, argc * sizeof (bsdargs[0])); grub_memcpy (bsdargs, args, argc * sizeof (bsdargs[0]));
bsdargs[argc] = rbuf; bsdargs[argc] = rbuf;
bsdargs[argc + 1] = bsddevname; bsdargs[argc + 1] = bsddevname;
@@ -447,7 +457,8 @@ grub_cmd_legacy_kernel (struct grub_command *mycmd __attribute__ ((unused)),
if (!(cmd->func) (cmd, bsdargc, bsdargs)) if (!(cmd->func) (cmd, bsdargc, bsdargs))
{ {
kernel_type = KNETBSD; kernel_type = KNETBSD;
return GRUB_ERR_NONE; found = 1;
goto free_bsdargs;
} }
} }
grub_errno = GRUB_ERR_NONE; 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)) if (!(cmd->func) (cmd, bsdargc, bsdargs))
{ {
kernel_type = KOPENBSD; kernel_type = KOPENBSD;
return GRUB_ERR_NONE; found = 1;
goto free_bsdargs;
} }
} }
grub_errno = GRUB_ERR_NONE; grub_errno = GRUB_ERR_NONE;
} }
free_bsdargs:
if (bsdargs != cutargs) if (bsdargs != cutargs)
grub_free (bsdargs); grub_free (bsdargs);
if (found)
goto out;
} }
} }
} }
while (0); while (0);
return grub_error (GRUB_ERR_BAD_OS, "couldn't load file %s", err = grub_error (GRUB_ERR_BAD_OS, "couldn't load file %s",
args[0]); args[0]);
out:
grub_free (cutargs);
return err;
} }
static grub_err_t static grub_err_t
@@ -534,15 +553,17 @@ grub_cmd_legacy_initrdnounzip (struct grub_command *mycmd __attribute__ ((unused
char **newargs; char **newargs;
grub_err_t err; grub_err_t err;
char nounzipbuf[10] = "--nounzip"; 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])); newargs = grub_malloc ((argc + 1) * sizeof (newargs[0]));
if (!newargs) if (!newargs)
return grub_errno; return grub_errno;
grub_memcpy (newargs + 1, args, argc * sizeof (newargs[0])); grub_memcpy (newargs + 1, args, argc * sizeof (newargs[0]));
newargs[0] = nounzipbuf; 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); err = cmd->func (cmd, argc + 1, newargs);
grub_free (newargs); grub_free (newargs);
+2
View File
@@ -37,6 +37,8 @@ static const char *names[] =
is required to save accross hibernations. */ is required to save accross hibernations. */
[GRUB_MEMORY_NVS] = N_("ACPI non-volatile storage RAM"), [GRUB_MEMORY_NVS] = N_("ACPI non-volatile storage RAM"),
[GRUB_MEMORY_BADRAM] = N_("faulty RAM (BadRAM)"), [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_COREBOOT_TABLES] = N_("RAM holding coreboot tables"),
[GRUB_MEMORY_CODE] = N_("RAM holding firmware code") [GRUB_MEMORY_CODE] = N_("RAM holding firmware code")
}; };
+11 -1
View File
@@ -198,7 +198,10 @@ grub_cmd_nativedisk (grub_command_t cmd __attribute__ ((unused)),
return grub_errno; return grub_errno;
if (get_uuid (NULL, &uuid_root, 0)) if (get_uuid (NULL, &uuid_root, 0))
return grub_errno; {
grub_free (mods);
return grub_errno;
}
prefdev = grub_file_get_device_name (prefix); prefdev = grub_file_get_device_name (prefix);
if (grub_errno) if (grub_errno)
@@ -210,6 +213,8 @@ grub_cmd_nativedisk (grub_command_t cmd __attribute__ ((unused)),
if (get_uuid (prefdev, &uuid_prefix, 0)) if (get_uuid (prefdev, &uuid_prefix, 0))
{ {
grub_free (uuid_root); grub_free (uuid_root);
grub_free (prefdev);
grub_free (mods);
return grub_errno; return grub_errno;
} }
@@ -289,12 +294,15 @@ grub_cmd_nativedisk (grub_command_t cmd __attribute__ ((unused)),
} }
grub_free (uuid_root); grub_free (uuid_root);
grub_free (uuid_prefix); grub_free (uuid_prefix);
grub_free (prefdev);
grub_free (mods);
return GRUB_ERR_NONE; return GRUB_ERR_NONE;
fail: fail:
grub_free (uuid_root); grub_free (uuid_root);
grub_free (uuid_prefix); grub_free (uuid_prefix);
grub_free (prefdev);
for (i = 0; i < mods_loaded; i++) for (i = 0; i < mods_loaded; i++)
if (mods[i]) if (mods[i])
@@ -302,6 +310,8 @@ grub_cmd_nativedisk (grub_command_t cmd __attribute__ ((unused)),
mods[i]->fini = 0; mods[i]->fini = 0;
grub_dl_unload (mods[i]); grub_dl_unload (mods[i]);
} }
grub_free (mods);
return grub_errno; return grub_errno;
} }
+1
View File
@@ -283,6 +283,7 @@ grub_cmd_parttool (grub_command_t cmd __attribute__ ((unused)),
} }
if (! cur) if (! cur)
{ {
grub_free (parsed);
grub_device_close (dev); grub_device_close (dev);
return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("unknown argument `%s'"), return grub_error (GRUB_ERR_BAD_ARGUMENT, N_("unknown argument `%s'"),
args[i]); args[i]);
+9 -8
View File
@@ -45,6 +45,7 @@ check_password (const char *user, const char *entered, void *pin)
grub_uint8_t *buf; grub_uint8_t *buf;
struct pbkdf2_password *pass = pin; struct pbkdf2_password *pass = pin;
gcry_err_code_t err; gcry_err_code_t err;
grub_err_t ret;
buf = grub_malloc (pass->buflen); buf = grub_malloc (pass->buflen);
if (!buf) if (!buf)
@@ -55,17 +56,17 @@ check_password (const char *user, const char *entered, void *pin)
pass->salt, pass->saltlen, pass->c, pass->salt, pass->saltlen, pass->c,
buf, pass->buflen); buf, pass->buflen);
if (err) 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); grub_auth_authenticate (user);
return grub_crypto_gcry_error (err); ret = GRUB_ERR_NONE;
} }
if (grub_crypto_memcmp (buf, pass->expected, pass->buflen) != 0) grub_free (buf);
return GRUB_ACCESS_DENIED; return ret;
grub_auth_authenticate (user);
return GRUB_ERR_NONE;
} }
static inline int static inline int
+1 -1
View File
@@ -64,7 +64,7 @@ iterate_device (const char *name, void *data)
/* Skip floppy drives when requested. */ /* Skip floppy drives when requested. */
if (ctx->no_floppy && if (ctx->no_floppy &&
name[0] == 'f' && name[1] == 'd' && name[2] >= '0' && name[2] <= '9') name[0] == 'f' && name[1] == 'd' && name[2] >= '0' && name[2] <= '9')
return 0; return 1;
#ifdef DO_SEARCH_FS_UUID #ifdef DO_SEARCH_FS_UUID
#define compare_fn grub_strcasecmp #define compare_fn grub_strcasecmp
+10 -4
View File
@@ -324,19 +324,19 @@ grub_load_public_key (grub_file_t f)
if (grub_file_read (f, &l, sizeof (l)) != sizeof (l)) if (grub_file_read (f, &l, sizeof (l)) != sizeof (l))
{ {
grub_error (GRUB_ERR_BAD_SIGNATURE, N_("bad signature")); 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; lb = (grub_be_to_cpu16 (l) + GRUB_CHAR_BIT - 1) / GRUB_CHAR_BIT;
if (lb > READBUF_SIZE - sizeof (grub_uint16_t)) if (lb > READBUF_SIZE - sizeof (grub_uint16_t))
{ {
grub_error (GRUB_ERR_BAD_SIGNATURE, N_("bad signature")); 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) if (grub_file_read (f, buffer + sizeof (grub_uint16_t), lb) != (grub_ssize_t) lb)
{ {
grub_error (GRUB_ERR_BAD_SIGNATURE, N_("bad signature")); grub_error (GRUB_ERR_BAD_SIGNATURE, N_("bad signature"));
goto fail; break;
} }
grub_memcpy (buffer, &l, sizeof (l)); 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)) buffer, lb + sizeof (grub_uint16_t), 0))
{ {
grub_error (GRUB_ERR_BAD_SIGNATURE, N_("bad signature")); 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_MD_SHA1->final (fingerprint_context);
grub_memcpy (sk->fingerprint, GRUB_MD_SHA1->read (fingerprint_context), 20); grub_memcpy (sk->fingerprint, GRUB_MD_SHA1->read (fingerprint_context), 20);
+3 -3
View File
@@ -32,7 +32,7 @@ GRUB_MOD_LICENSE ("GPLv3+");
struct grub_ahci_cmd_head struct grub_ahci_cmd_head
{ {
grub_uint32_t config; grub_uint32_t config;
grub_uint32_t transfered; grub_uint32_t transferred;
grub_uint64_t command_table_base; grub_uint64_t command_table_base;
grub_uint32_t unused[4]; 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", grub_dprintf ("ahci", "AHCI tfd = %x\n",
dev->hba->ports[dev->port].task_file_data); 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 dev->command_list[0].command_table_base
= grub_dma_get_phys (dev->command_table_chunk); = 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].command_issue,
dev->hba->ports[dev->port].intstatus, dev->hba->ports[dev->port].intstatus,
dev->hba->ports[dev->port].task_file_data, 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, 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))[0x00],
((grub_uint32_t *) grub_dma_get_virt (dev->rfis))[0x18]); ((grub_uint32_t *) grub_dma_get_virt (dev->rfis))[0x18]);
+6 -1
View File
@@ -25,6 +25,7 @@
#include <grub/fs.h> #include <grub/fs.h>
#include <grub/file.h> #include <grub/file.h>
#include <grub/procfs.h> #include <grub/procfs.h>
#include <grub/partition.h>
#ifdef GRUB_UTIL #ifdef GRUB_UTIL
#include <grub/emu/hostdisk.h> #include <grub/emu/hostdisk.h>
@@ -718,6 +719,7 @@ grub_cryptodisk_insert (grub_cryptodisk_t newdev, const char *name,
newdev->id = last_cryptodisk_id++; newdev->id = last_cryptodisk_id++;
newdev->source_id = source->id; newdev->source_id = source->id;
newdev->source_dev_id = source->dev->id; newdev->source_dev_id = source->dev->id;
newdev->partition_start = grub_partition_get_start (source->partition);
newdev->next = cryptodisk_list; newdev->next = cryptodisk_list;
cryptodisk_list = newdev; cryptodisk_list = newdev;
@@ -740,7 +742,9 @@ grub_cryptodisk_get_by_source_disk (grub_disk_t disk)
grub_cryptodisk_t dev; grub_cryptodisk_t dev;
for (dev = cryptodisk_list; dev != NULL; dev = dev->next) for (dev = cryptodisk_list; dev != NULL; dev = dev->next)
if (dev->source_id == disk->id && dev->source_dev_id == disk->dev->id) 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; 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->cheat_fd = GRUB_UTIL_FD_INVALID;
newdev->source_id = source->id; newdev->source_id = source->id;
newdev->source_dev_id = source->dev->id; newdev->source_dev_id = source->dev->id;
newdev->partition_start = grub_partition_get_start (source->partition);
newdev->id = last_cryptodisk_id++; newdev->id = last_cryptodisk_id++;
newdev->next = cryptodisk_list; newdev->next = cryptodisk_list;
cryptodisk_list = newdev; cryptodisk_list = newdev;
+53 -9
View File
@@ -85,6 +85,12 @@ make_devices (void)
{ {
/* Uggh. */ /* Uggh. */
grub_free (handles); grub_free (handles);
while (devices)
{
d = devices->next;
grub_free (devices);
devices = d;
}
return 0; return 0;
} }
@@ -487,8 +493,15 @@ grub_efidisk_open (const char *name, struct grub_disk *disk)
m = d->block_io->media; m = d->block_io->media;
/* FIXME: Probably it is better to store the block size in the disk, /* FIXME: Probably it is better to store the block size in the disk,
and total sectors should be replaced with total blocks. */ and total sectors should be replaced with total blocks. */
grub_dprintf ("efidisk", "m = %p, last block = %llx, block size = %x\n", grub_dprintf ("efidisk",
m, (unsigned long long) m->last_block, m->block_size); "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; disk->total_sectors = m->last_block + 1;
/* Don't increase this value due to bug in some EFI. */ /* Don't increase this value due to bug in some EFI. */
disk->max_agglomerate = 0xa0000 >> (GRUB_DISK_CACHE_BITS + GRUB_DISK_SECTOR_BITS); disk->max_agglomerate = 0xa0000 >> (GRUB_DISK_CACHE_BITS + GRUB_DISK_SECTOR_BITS);
@@ -518,15 +531,42 @@ grub_efidisk_readwrite (struct grub_disk *disk, grub_disk_addr_t sector,
{ {
struct grub_efidisk_data *d; struct grub_efidisk_data *d;
grub_efi_block_io_t *bio; grub_efi_block_io_t *bio;
grub_efi_status_t status;
grub_size_t io_align, num_bytes;
char *aligned_buf;
d = disk->data; d = disk->data;
bio = d->block_io; bio = d->block_io;
return efi_call_5 ((wr ? bio->write_blocks : bio->read_blocks), bio, /* Set alignment to 1 if 0 specified */
bio->media->media_id, io_align = bio->media->io_align ? bio->media->io_align : 1;
(grub_efi_uint64_t) sector, num_bytes = size << disk->log_sector_size;
(grub_efi_uintn_t) size << disk->log_sector_size,
buf); 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 static grub_err_t
@@ -541,7 +581,9 @@ grub_efidisk_read (struct grub_disk *disk, grub_disk_addr_t sector,
status = grub_efidisk_readwrite (disk, sector, size, buf, 0); 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, return grub_error (GRUB_ERR_READ_ERROR,
N_("failure reading sector 0x%llx from `%s'"), N_("failure reading sector 0x%llx from `%s'"),
(unsigned long long) sector, (unsigned long long) sector,
@@ -562,7 +604,9 @@ grub_efidisk_write (struct grub_disk *disk, grub_disk_addr_t sector,
status = grub_efidisk_readwrite (disk, sector, size, (char *) buf, 1); 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, return grub_error (GRUB_ERR_WRITE_ERROR,
N_("failure writing sector 0x%llx to `%s'"), N_("failure writing sector 0x%llx to `%s'"),
(unsigned long long) sector, disk->name); (unsigned long long) sector, disk->name);
+79
View File
@@ -228,6 +228,9 @@ dev_iterate (const struct grub_ieee1275_devalias *alias)
if (grub_ieee1275_open (alias->path, &ihandle)) if (grub_ieee1275_open (alias->path, &ihandle))
return; 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); INIT_IEEE1275_COMMON (&args.common, "call-method", 2, 3);
args.method = (grub_ieee1275_cell_t) "vscsi-report-luns"; args.method = (grub_ieee1275_cell_t) "vscsi-report-luns";
args.ihandle = ihandle; args.ihandle = ihandle;
@@ -260,6 +263,82 @@ dev_iterate (const struct grub_ieee1275_devalias *alias)
grub_free (buf); grub_free (buf);
return; 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) if (!grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_NO_TREE_SCANNING_FOR_DISKS)
&& grub_strcmp (alias->type, "block") == 0) && grub_strcmp (alias->type, "block") == 0)
+5 -2
View File
@@ -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 s->sh_flags & SHF_EXECINSTR ? GRUB_EFI_RUNTIME_SERVICES_CODE
: GRUB_EFI_RUNTIME_SERVICES_DATA); : GRUB_EFI_RUNTIME_SERVICES_DATA);
if (seg->handle < 0) if (seg->handle < 0)
return grub_errno; {
grub_free (seg);
return grub_errno;
}
seg->off = 0; seg->off = 0;
} }
@@ -343,7 +346,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")); 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. */ /* 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"), return grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"),
filename); filename);
+1 -1
View File
@@ -196,7 +196,7 @@ grub_efiemu_load_file (const char *filename)
{ {
grub_file_close (file); grub_file_close (file);
grub_efiemu_unload (); grub_efiemu_unload ();
return grub_errno; return err;
} }
grub_dprintf ("efiemu", "mm initialized\n"); grub_dprintf ("efiemu", "mm initialized\n");
+22 -3
View File
@@ -99,7 +99,8 @@ grub_efiemu_request_memalign (grub_size_t align, grub_size_t size,
grub_size_t align_overhead; grub_size_t align_overhead;
struct grub_efiemu_memrequest *ret, *cur, *prev; struct grub_efiemu_memrequest *ret, *cur, *prev;
/* Check that the request is correct */ /* 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; return -2;
/* Add new size to requested size */ /* Add new size to requested size */
@@ -166,6 +167,13 @@ efiemu_alloc_requests (void)
GRUB_EFI_MEMORY_MAPPED_IO, GRUB_EFI_MEMORY_MAPPED_IO,
GRUB_EFI_MEMORY_MAPPED_IO_PORT_SPACE, GRUB_EFI_MEMORY_MAPPED_IO_PORT_SPACE,
GRUB_EFI_PAL_CODE 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 */ /* 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, return grub_efiemu_add_to_mmap (addr, size,
GRUB_EFI_ACPI_MEMORY_NVS); GRUB_EFI_ACPI_MEMORY_NVS);
case GRUB_MEMORY_PERSISTENT:
case GRUB_MEMORY_PERSISTENT_LEGACY:
return grub_efiemu_add_to_mmap (addr, size,
GRUB_EFI_PERSISTENT_MEMORY);
default: default:
grub_dprintf ("efiemu", grub_dprintf ("efiemu",
"Unknown memory type %d. Assuming unusable\n", type); "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:
case GRUB_EFI_MEMORY_MAPPED_IO_PORT_SPACE: case GRUB_EFI_MEMORY_MAPPED_IO_PORT_SPACE:
case GRUB_EFI_PAL_CODE: case GRUB_EFI_PAL_CODE:
case GRUB_EFI_MAX_MEMORY_TYPE: default:
hook (efiemu_mmap[i].physical_start, efiemu_mmap[i].num_pages * 4096, hook (efiemu_mmap[i].physical_start, efiemu_mmap[i].num_pages * 4096,
GRUB_MEMORY_RESERVED, hook_data); GRUB_MEMORY_RESERVED, hook_data);
break; 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, hook (efiemu_mmap[i].physical_start, efiemu_mmap[i].num_pages * 4096,
GRUB_MEMORY_NVS, hook_data); GRUB_MEMORY_NVS, hook_data);
break; break;
case GRUB_EFI_PERSISTENT_MEMORY:
hook (efiemu_mmap[i].physical_start, efiemu_mmap[i].num_pages * 4096,
GRUB_MEMORY_PERSISTENT, hook_data);
break;
} }
return 0; return 0;
@@ -503,7 +521,8 @@ grub_efiemu_mmap_sort_and_uniq (void)
[GRUB_EFI_ACPI_MEMORY_NVS] = 3, [GRUB_EFI_ACPI_MEMORY_NVS] = 3,
[GRUB_EFI_MEMORY_MAPPED_IO] = 4, [GRUB_EFI_MEMORY_MAPPED_IO] = 4,
[GRUB_EFI_MEMORY_MAPPED_IO_PORT_SPACE] = 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; int i, j, k, done;
+10 -4
View File
@@ -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); ((grub_uint8_t *) grub_efiemu_mm_obtain_request (handle) + off);
/* Put pointer to the list of configuration tables in system table */ /* Put pointer to the list of configuration tables in system table */
grub_efiemu_write_value err = grub_efiemu_write_value
(&(SUFFIX (grub_efiemu_system_table)->configuration_table), 0, (&(SUFFIX (grub_efiemu_system_table)->configuration_table), 0,
conftable_handle, 0, 1, conftable_handle, 0, 1,
sizeof (SUFFIX (grub_efiemu_system_table)->configuration_table)); sizeof (SUFFIX (grub_efiemu_system_table)->configuration_table));
if (err)
{
grub_efiemu_unload ();
return err;
}
SUFFIX(grub_efiemu_system_table)->num_table_entries = cntconftables; SUFFIX(grub_efiemu_system_table)->num_table_entries = cntconftables;
/* Fill the list of configuration tables */ /* Fill the list of configuration tables */
+9 -1
View File
@@ -344,8 +344,16 @@ init_cbfsdisk (void)
ptr = *(grub_uint32_t *) 0xfffffffc; ptr = *(grub_uint32_t *) 0xfffffffc;
head = (struct cbfs_header *) (grub_addr_t) ptr; 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 < (grub_uint32_t) sizeof (*head) + 0xf
|| !validate_head (head))
return; return;
cbfsdisk_size = ALIGN_UP (grub_be_to_cpu32 (head->romsize), cbfsdisk_size = ALIGN_UP (grub_be_to_cpu32 (head->romsize),
+1 -1
View File
@@ -681,7 +681,7 @@ grub_fat_iterate_dir_next (grub_fshelp_node_t node,
ctxt->dir.file_size ctxt->dir.file_size
= grub_cpu_to_le64 (sec.type_specific.stream_extension.file_size); = grub_cpu_to_le64 (sec.type_specific.stream_extension.file_size);
ctxt->dir.have_stream = 1; 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)); & grub_cpu_to_le16_compile_time (FLAG_CONTIGUOUS));
break; break;
case 0xc1: case 0xc1:
+1
View File
@@ -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)) if (grub_hfs_find_dir (data, name, &found, GRUB_FSHELP_REG))
{ {
grub_free (data); grub_free (data);
grub_free (found);
grub_dl_unref (my_mod); grub_dl_unref (my_mod);
return grub_errno; return grub_errno;
} }
+2 -6
View File
@@ -750,19 +750,15 @@ grub_iso9660_iterate_dir (grub_fshelp_node_t dir,
if (dir->data->joliet && !ctx.filename) if (dir->data->joliet && !ctx.filename)
{ {
char *oldname, *semicolon; char *semicolon;
oldname = name;
ctx.filename = grub_iso9660_convert_string ctx.filename = grub_iso9660_convert_string
((grub_uint8_t *) oldname, dirent.namelen >> 1); ((grub_uint8_t *) name, dirent.namelen >> 1);
semicolon = grub_strrchr (ctx.filename, ';'); semicolon = grub_strrchr (ctx.filename, ';');
if (semicolon) if (semicolon)
*semicolon = '\0'; *semicolon = '\0';
if (ctx.filename_alloc)
grub_free (oldname);
ctx.filename_alloc = 1; ctx.filename_alloc = 1;
} }
+1 -1
View File
@@ -104,7 +104,7 @@ decomp_block (struct grub_ntfs_comp *cc, grub_uint8_t *dest)
if (tag & 1) if (tag & 1)
{ {
grub_uint32_t i, len, delta, code, lmask, dshift; grub_uint32_t i, len, delta, code, lmask, dshift;
grub_uint16_t word; grub_uint16_t word = 0;
if (decomp_get16 (cc, &word)) if (decomp_get16 (cc, &word))
return grub_errno; return grub_errno;
+10 -2
View File
@@ -76,8 +76,13 @@ GRUB_MOD_LICENSE ("GPLv3+");
/* incompat feature flags */ /* incompat feature flags */
#define XFS_SB_FEAT_INCOMPAT_FTYPE (1 << 0) /* filetype in dirent */ #define XFS_SB_FEAT_INCOMPAT_FTYPE (1 << 0) /* filetype in dirent */
#define XFS_SB_FEAT_INCOMPAT_SPINODES (1 << 1) /* sparse inode chunks */
#define XFS_SB_FEAT_INCOMPAT_META_UUID (1 << 2) /* metadata UUID */
/* We do not currently verify metadata UUID so it is safe to read such filesystem */
#define XFS_SB_FEAT_INCOMPAT_SUPPORTED \ #define XFS_SB_FEAT_INCOMPAT_SUPPORTED \
(XFS_SB_FEAT_INCOMPAT_FTYPE) (XFS_SB_FEAT_INCOMPAT_FTYPE | \
XFS_SB_FEAT_INCOMPAT_META_UUID)
struct grub_xfs_sblock struct grub_xfs_sblock
{ {
@@ -775,7 +780,10 @@ grub_xfs_iterate_dir (grub_fshelp_node_t dir,
c = de->name[de->len]; c = de->name[de->len];
de->name[de->len] = '\0'; de->name[de->len] = '\0';
if (iterate_dir_call_hook (ino, de->name, &ctx)) if (iterate_dir_call_hook (ino, de->name, &ctx))
return 1; {
de->name[de->len] = c;
return 1;
}
de->name[de->len] = c; de->name[de->len] = c;
de = grub_xfs_inline_next_de(dir->data, head, de); de = grub_xfs_inline_next_de(dir->data, head, de);
+1 -1
View File
@@ -3132,7 +3132,7 @@ make_mdn (dnode_end_t * mdn, struct grub_zfs_data *data)
{ {
void *osp; void *osp;
blkptr_t *bp; blkptr_t *bp;
grub_size_t ospsize; grub_size_t ospsize = 0;
grub_err_t err; grub_err_t err;
grub_dprintf ("zfs", "endian = %d\n", mdn->endian); grub_dprintf ("zfs", "endian = %d\n", mdn->endian);
+2
View File
@@ -184,6 +184,8 @@ LZ4_uncompress_unknownOutputSize(const char *source,
} }
} }
/* copy literals */ /* copy literals */
if ((grub_addr_t) length > ~(grub_addr_t)op)
goto _output_error;
cpy = op + length; cpy = op + length;
if ((cpy > oend - COPYLENGTH) || if ((cpy > oend - COPYLENGTH) ||
(ip + length > iend - COPYLENGTH)) { (ip + length > iend - COPYLENGTH)) {
+7 -4
View File
@@ -15,12 +15,12 @@ set -e
# #
# Example: # Example:
# #
# genmod.sh moddep.lst normal.module normal.mod # genmod.sh moddep.lst normal.module build-grub-module-verifier normal.mod
# #
moddep=$1 moddep=$1
infile=$2 infile=$2
outfile=$3 outfile=$4
tmpfile=${outfile}.tmp tmpfile=${outfile}.tmp
modname=`echo $infile | sed -e 's@\.module.*$@@'` modname=`echo $infile | sed -e 's@\.module.*$@@'`
@@ -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 \
-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.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 fi
if ! test -z "${TARGET_OBJ2ELF}"; then if ! test -z "${TARGET_OBJ2ELF}"; then
"${TARGET_OBJ2ELF}" $tmpfile || exit 1 "${TARGET_OBJ2ELF}" $tmpfile || exit 1
@@ -91,6 +91,9 @@ else
-nr:_grub_mod_init:grub_mod_init \ -nr:_grub_mod_init:grub_mod_init \
-nr:_grub_mod_fini:grub_mod_fini \ -nr:_grub_mod_fini:grub_mod_fini \
-wd1106 -nu -nd $tmpfile.bin $tmpfile || exit 1 -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@BUILD_EXEEXT@ $tmpfile @target_cpu@
fi fi
mv $tmpfile $outfile mv $tmpfile $outfile
+31 -1
View File
@@ -29,7 +29,7 @@ BEGIN {
} }
} }
else { else {
printf "error: %u: unrecognized input format\n", NR; printf "error: %u: unrecognized input format\n", NR >"/dev/stderr";
error++; error++;
} }
} }
@@ -39,6 +39,8 @@ END {
if (error >= 1) if (error >= 1)
exit 1; exit 1;
total_depcount = 0
for (mod in modtab) { for (mod in modtab) {
# Remove duplications. # Remove duplications.
split(modtab[mod], depmods, " "); split(modtab[mod], depmods, " ");
@@ -52,14 +54,42 @@ END {
uniqmods[depmod] = 1; uniqmods[depmod] = 1;
} }
modlist = "" modlist = ""
depcount[mod] = 0
for (depmod in uniqmods) { for (depmod in uniqmods) {
modlist = modlist " " depmod; modlist = modlist " " depmod;
inverse_dependencies[depmod] = inverse_dependencies[depmod] " " mod
depcount[mod]++
total_depcount++
} }
if (mod == "all_video") { if (mod == "all_video") {
continue; continue;
} }
printf "%s:%s\n", mod, modlist; 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 = "" modlist = ""
while (getline <"video.lst") { while (getline <"video.lst") {
modlist = modlist " " $1; modlist = modlist " " $1;
+10 -5
View File
@@ -45,6 +45,7 @@ grub_font_draw_string (const char *str, grub_font_t font,
grub_uint32_t *logical; grub_uint32_t *logical;
grub_ssize_t logical_len, visual_len; grub_ssize_t logical_len, visual_len;
struct grub_unicode_glyph *visual, *ptr; struct grub_unicode_glyph *visual, *ptr;
grub_err_t err;
logical_len = grub_utf8_to_ucs4_alloc (str, &logical, 0); logical_len = grub_utf8_to_ucs4_alloc (str, &logical, 0);
if (logical_len < 0) if (logical_len < 0)
@@ -56,24 +57,28 @@ grub_font_draw_string (const char *str, grub_font_t font,
if (visual_len < 0) if (visual_len < 0)
return grub_errno; return grub_errno;
err = GRUB_ERR_NONE;
for (ptr = visual, x = left_x; ptr < visual + visual_len; ptr++) for (ptr = visual, x = left_x; ptr < visual + visual_len; ptr++)
{ {
grub_err_t err;
struct grub_font_glyph *glyph; struct grub_font_glyph *glyph;
glyph = grub_font_construct_glyph (font, ptr); glyph = grub_font_construct_glyph (font, ptr);
if (!glyph) if (!glyph)
return grub_errno; {
err = grub_errno;
goto out;
}
err = grub_font_draw_glyph (glyph, color, x, baseline_y); err = grub_font_draw_glyph (glyph, color, x, baseline_y);
x += glyph->device_width;
if (err) if (err)
return err; goto out;
x += glyph->device_width;
} }
out:
for (ptr = visual; ptr < visual + visual_len; ptr++) for (ptr = visual; ptr < visual + visual_len; ptr++)
grub_unicode_destroy_glyph (ptr); grub_unicode_destroy_glyph (ptr);
grub_free (visual); grub_free (visual);
return GRUB_ERR_NONE; return err;
} }
/* Get the width in pixels of the specified UTF-8 string, when rendered in /* Get the width in pixels of the specified UTF-8 string, when rendered in
+4 -4
View File
@@ -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"), return grub_error (GRUB_ERR_FILE_NOT_FOUND, N_("variable `%s' isn't set"),
"theme"); "theme");
instance = grub_zalloc (sizeof (*instance));
if (!instance)
return grub_errno;
err = grub_video_get_info (&mode_info); err = grub_video_get_info (&mode_info);
if (err) if (err)
return err; return err;
instance = grub_zalloc (sizeof (*instance));
if (!instance)
return grub_errno;
if (theme_path[0] != '/' && theme_path[0] != '(') if (theme_path[0] != '/' && theme_path[0] != '(')
{ {
const char *prefix; const char *prefix;
+2 -2
View File
@@ -255,7 +255,7 @@ theme_set_string (grub_gfxmenu_view_t view,
{ {
unsigned int tmp; unsigned int tmp;
int err = theme_get_unsigned_int_from_proportional (value, int err = theme_get_unsigned_int_from_proportional (value,
view->screen.width, view->screen.height,
&tmp); &tmp);
if (err != GRUB_ERR_NONE) if (err != GRUB_ERR_NONE)
return err; return err;
@@ -275,7 +275,7 @@ theme_set_string (grub_gfxmenu_view_t view,
{ {
unsigned int tmp; unsigned int tmp;
int err = theme_get_unsigned_int_from_proportional (value, int err = theme_get_unsigned_int_from_proportional (value,
view->screen.width, view->screen.height,
&tmp); &tmp);
if (err != GRUB_ERR_NONE) if (err != GRUB_ERR_NONE)
return err; return err;
+119
View File
@@ -0,0 +1,119 @@
/*
* 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 <http://www.gnu.org/licenses/>.
*/
#include <grub/types.h>
#include <grub/time.h>
#include <grub/misc.h>
#include <grub/acpi.h>
/* 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;
}
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;
}
+2 -2
View File
@@ -38,7 +38,7 @@ static void
increment_timer (grub_efi_event_t event __attribute__ ((unused)), increment_timer (grub_efi_event_t event __attribute__ ((unused)),
void *context __attribute__ ((unused))) void *context __attribute__ ((unused)))
{ {
tmr++; tmr += 10;
} }
void void
@@ -52,7 +52,7 @@ grub_machine_init (void)
efi_call_5 (b->create_event, GRUB_EFI_EVT_TIMER | GRUB_EFI_EVT_NOTIFY_SIGNAL, efi_call_5 (b->create_event, GRUB_EFI_EVT_TIMER | GRUB_EFI_EVT_NOTIFY_SIGNAL,
GRUB_EFI_TPL_CALLBACK, increment_timer, NULL, &tmr_evt); 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); grub_install_get_time_ms (grub_efi_get_time_ms);
} }
+49 -11
View File
@@ -55,10 +55,6 @@ FUNCTION(_start)
VARIABLE(grub_total_module_size) VARIABLE(grub_total_module_size)
.long 0 .long 0
VARIABLE(grub_uboot_machine_type)
.long 0
VARIABLE(grub_uboot_boot_data)
.long 0
VARIABLE(grub_modbase) VARIABLE(grub_modbase)
.long 0 .long 0
bss_start_ptr: bss_start_ptr:
@@ -66,29 +62,66 @@ bss_start_ptr:
end_ptr: end_ptr:
.long EXT_C(_end) .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) FUNCTION(codestart)
@ Store context: Machine ID, atags/dtb, ... @ Store context: Machine ID, atags/dtb, ...
@ U-Boot API signature is stored on the U-Boot heap @ U-Boot API signature is stored on the U-Boot heap
@ Stack pointer used as start address for signature probing @ Stack pointer used as start address for signature probing
mov r12, sp mov r12, sp
adr sp, entry_state 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) adr r1, _start
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
ldr r0, bss_start_ptr @ src 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) add r0, r0, #(GRUB_KERNEL_MACHINE_MOD_ALIGN - 1)
mvn r1, #(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 r1, end_ptr @ dst = End of BSS
ldr r2, grub_total_module_size @ blob size ldr r2, grub_total_module_size @ blob size
add r1, r1, #GRUB_KERNEL_MACHINE_STACK_SIZE add r1, r1, #GRUB_KERNEL_MACHINE_STACK_SIZE
and r1, r1, #~0x7 @ Ensure 8-byte alignment and r1, r1, #~0x7 @ Ensure 8-byte alignment
sub sp, r1, #8 sub sp, r1, #8
add r1, r1, #1024 add r1, r1, #1024
@@ -157,6 +190,11 @@ FUNCTION(grub_uboot_return)
.align 3 .align 3
@ U-boot context stack space @ U-boot context stack space
entry_state_end: 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 @ r4
.long 0 @ r5 .long 0 @ r5
.long 0 @ r6 .long 0 @ r6
+18
View File
@@ -132,6 +132,12 @@ grub_arch_dl_relocate_symbols (grub_dl_t mod, void *ehdr,
*abs_place = (grub_uint64_t) sym_addr; *abs_place = (grub_uint64_t) sym_addr;
} }
break; 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_CALL26:
case R_AARCH64_JUMP26: 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); grub_arm64_set_xxxx26_offset (place, offset);
} }
break; 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: default:
return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET, return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
N_("relocation 0x%x is not implemented yet"), N_("relocation 0x%x is not implemented yet"),
+40
View File
@@ -53,3 +53,43 @@ grub_arm64_set_xxxx26_offset (grub_uint32_t *place, grub_int64_t offset)
*place &= insmask; *place &= insmask;
*place |= grub_cpu_to_le32 (offset >> 2) & ~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;
}
+60
View File
@@ -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 <http://www.gnu.org/licenses/>.
*/
#include <grub/env.h>
#include <grub/kernel.h>
#include <grub/misc.h>
#include <grub/mm.h>
#include <grub/time.h>
#include <grub/efi/efi.h>
#include <grub/loader.h>
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 ();
}
+8 -2
View File
@@ -333,8 +333,11 @@ grub_dl_resolve_symbols (grub_dl_t mod, Elf_Ehdr *e)
if (s->sh_type == SHT_SYMTAB) if (s->sh_type == SHT_SYMTAB)
break; 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) 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 #ifdef GRUB_MODULES_MACHINE_READONLY
mod->symtab = grub_malloc (s->sh_size); mod->symtab = grub_malloc (s->sh_size);
@@ -576,6 +579,9 @@ grub_dl_relocate_symbols (grub_dl_t mod, void *ehdr)
if (seg) 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); err = grub_arch_dl_relocate_symbols (mod, ehdr, s, seg);
if (err) if (err)
return err; return err;
@@ -605,7 +611,7 @@ grub_dl_load_core_noinit (void *addr, grub_size_t size)
} }
/* Make sure that every section is within the core. */ /* 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"); grub_error (GRUB_ERR_BAD_OS, "ELF sections outside core");
return 0; return 0;
File renamed without changes.
+43
View File
@@ -0,0 +1,43 @@
/* fdt.c - EFI Flattened Device Tree interaction */
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2006,2007 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 <http://www.gnu.org/licenses/>.
*/
#include <grub/efi/efi.h>
#include <grub/mm.h>
void *
grub_efi_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;
}
+5 -2
View File
@@ -59,10 +59,13 @@ grub_machine_get_bootlocation (char **device, char **path)
if (!image) if (!image)
return; return;
*device = grub_efidisk_get_device_name (image->device_handle); *device = grub_efidisk_get_device_name (image->device_handle);
*path = grub_efi_get_filename (image->file_path);
if (!*device && grub_efi_net_config) if (!*device && grub_efi_net_config)
grub_efi_net_config (image->device_handle, device, path); {
grub_efi_net_config (image->device_handle, device, path);
return;
}
*path = grub_efi_get_filename (image->file_path);
if (*path) if (*path)
{ {
/* Get the directory. */ /* Get the directory. */
+2
View File
@@ -28,6 +28,8 @@
GRUB_MOD_LICENSE ("GPLv3+"); GRUB_MOD_LICENSE ("GPLv3+");
#pragma GCC diagnostic ignored "-Wcast-align"
#if defined(__powerpc__) && defined(GRUB_MACHINE_IEEE1275) #if defined(__powerpc__) && defined(GRUB_MACHINE_IEEE1275)
#define GRUB_ELF_ENABLE_BI_ENDIAN 1 #define GRUB_ELF_ENABLE_BI_ENDIAN 1
#else #else
+1 -1
View File
@@ -12,7 +12,7 @@ grub_elfXX_load_phdrs (grub_elf_t elf)
if (elf->phdrs) if (elf->phdrs)
return GRUB_ERR_NONE; 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", grub_dprintf ("elf", "Loading program headers at 0x%llx, size 0x%lx.\n",
(unsigned long long) elf->ehdr.ehdrXX.e_phoff, (unsigned long long) elf->ehdr.ehdrXX.e_phoff,
+2 -2
View File
@@ -161,9 +161,9 @@ grub_util_biosdisk_open (const char *name, grub_disk_t disk)
{ {
struct stat st; struct stat st;
# if GRUB_DISK_DEVS_ARE_CHAR # 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 # else
if (fstat (fd, &st) < 0 || ! S_ISBLK (st.st_mode)) if (fstat (fd, &st) >= 0 && S_ISBLK (st.st_mode))
# endif # endif
data->is_disk = 1; data->is_disk = 1;
} }
+47 -1
View File
@@ -65,6 +65,12 @@ grub_reboot (void)
longjmp (main_env, 1); longjmp (main_env, 1);
} }
void
grub_exit (void)
{
grub_reboot ();
}
void void
grub_machine_init (void) grub_machine_init (void)
{ {
@@ -86,11 +92,16 @@ grub_machine_fini (int flags)
#define OPT_MEMDISK 257
static struct argp_option options[] = { static struct argp_option options[] = {
{"root", 'r', N_("DEVICE_NAME"), 0, N_("Set root device."), 2}, {"root", 'r', N_("DEVICE_NAME"), 0, N_("Set root device."), 2},
{"device-map", 'm', N_("FILE"), 0, {"device-map", 'm', N_("FILE"), 0,
/* TRANSLATORS: There are many devices in device map. */ /* TRANSLATORS: There are many devices in device map. */
N_("use FILE as the device map [default=%s]"), 0}, 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, {"directory", 'd', N_("DIR"), 0,
N_("use GRUB files in the directory DIR [default=%s]"), 0}, N_("use GRUB files in the directory DIR [default=%s]"), 0},
{"verbose", 'v', 0, 0, N_("print verbose messages."), 0}, {"verbose", 'v', 0, 0, N_("print verbose messages."), 0},
@@ -119,6 +130,7 @@ help_filter (int key, const char *text, void *input __attribute__ ((unused)))
struct arguments struct arguments
{ {
const char *dev_map; const char *dev_map;
const char *mem_disk;
int hold; int hold;
}; };
@@ -131,6 +143,9 @@ argp_parser (int key, char *arg, struct argp_state *state)
switch (key) switch (key)
{ {
case OPT_MEMDISK:
arguments->mem_disk = arg;
break;
case 'r': case 'r':
free (root_dev); free (root_dev);
root_dev = xstrdup (arg); root_dev = xstrdup (arg);
@@ -180,9 +195,13 @@ main (int argc, char *argv[])
struct arguments arguments = struct arguments arguments =
{ {
.dev_map = DEFAULT_DEVICE_MAP, .dev_map = DEFAULT_DEVICE_MAP,
.hold = 0 .hold = 0,
.mem_disk = 0,
}; };
volatile int hold = 0; volatile int hold = 0;
size_t total_module_size = sizeof (struct grub_module_info), memdisk_size = 0;
struct grub_module_info *modinfo;
void *mods;
grub_util_host_init (&argc, &argv); grub_util_host_init (&argc, &argv);
@@ -194,6 +213,33 @@ main (int argc, char *argv[])
exit(1); 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 = header + 1;
grub_util_load_image (arguments.mem_disk, mods);
mods = (char *) mods + memdisk_size;
}
grub_modbase = (grub_addr_t) modinfo;
hold = arguments.hold; hold = arguments.hold;
/* Wait until the ARGS.HOLD variable is cleared by an attached debugger. */ /* Wait until the ARGS.HOLD variable is cleared by an attached debugger. */
if (hold && verbosity > 0) if (hold && verbosity > 0)
+51
View File
@@ -127,6 +127,7 @@ xasprintf (const char *fmt, ...)
va_start (ap, fmt); va_start (ap, fmt);
result = grub_xvasprintf (fmt, ap); result = grub_xvasprintf (fmt, ap);
va_end (ap);
if (!result) if (!result)
grub_util_error ("%s", _("out of memory")); grub_util_error ("%s", _("out of memory"));
@@ -134,11 +135,13 @@ xasprintf (const char *fmt, ...)
} }
#endif #endif
#if !defined (GRUB_MACHINE_EMU) || defined (GRUB_UTIL)
void void
grub_exit (void) grub_exit (void)
{ {
exit (1); exit (1);
} }
#endif
grub_uint64_t grub_uint64_t
grub_get_time_ms (void) grub_get_time_ms (void)
@@ -149,3 +152,51 @@ grub_get_time_ms (void)
return (tv.tv_sec * 1000 + tv.tv_usec / 1000); 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);
}
+5
View File
@@ -89,6 +89,11 @@ grub_file_open (const char *name)
file->device = device; 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 (device->disk && file_name[0] != '/'
#if defined(GRUB_UTIL) || defined(GRUB_MACHINE_EMU) #if defined(GRUB_UTIL) || defined(GRUB_MACHINE_EMU)
&& grub_strcmp (device->disk->name, "host") && grub_strcmp (device->disk->name, "host")
+40
View File
@@ -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 <http://www.gnu.org/licenses/>.
*/
#include <grub/types.h>
#include <grub/time.h>
#include <grub/misc.h>
#include <grub/i386/tsc.h>
#include <grub/efi/efi.h>
#include <grub/efi/api.h>
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;
}
+11
View File
@@ -44,6 +44,13 @@ FUNCTION(grub_bios_interrupt)
movl 24(%edx), %esi movl 24(%edx), %esi
movl 28(%edx), %edx 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 PROT_TO_REAL
.code16 .code16
pushf pushf
@@ -92,6 +99,10 @@ intno:
movw %ax, LOCAL(bios_register_es) movw %ax, LOCAL(bios_register_es)
popf popf
VARIABLE(grub_bios_via_workaround2)
.byte 0x90, 0x90
REAL_TO_PROT REAL_TO_PROT
.code32 .code32
File renamed without changes.
+24
View File
@@ -32,6 +32,7 @@
#include <grub/env.h> #include <grub/env.h>
#include <grub/cache.h> #include <grub/cache.h>
#include <grub/time.h> #include <grub/time.h>
#include <grub/cpu/cpuid.h>
#include <grub/cpu/tsc.h> #include <grub/cpu/tsc.h>
#include <grub/machine/time.h> #include <grub/machine/time.h>
@@ -184,6 +185,26 @@ mmap_iterate_hook (grub_uint64_t addr, grub_uint64_t size,
return 0; 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 void
grub_machine_init (void) grub_machine_init (void)
{ {
@@ -193,6 +214,9 @@ grub_machine_init (void)
#endif #endif
grub_addr_t modend; 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); grub_modbase = GRUB_MEMORY_MACHINE_DECOMPRESSION_ADDR + (_edata - _start);
/* Initialize the console as early as possible. */ /* Initialize the console as early as possible. */
+19 -102
View File
@@ -1,7 +1,6 @@
/* kern/i386/tsc.c - x86 TSC time source implementation /* kern/i386/tsc.c - x86 TSC time source implementation
* Requires Pentium or better x86 CPU that supports the RDTSC instruction. * 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 * This module calibrates the TSC to real time.
* real time.
* *
* GRUB -- GRand Unified Bootloader * GRUB -- GRand Unified Bootloader
* Copyright (C) 2008 Free Software Foundation, Inc. * Copyright (C) 2008 Free Software Foundation, Inc.
@@ -25,12 +24,6 @@
#include <grub/misc.h> #include <grub/misc.h>
#include <grub/i386/tsc.h> #include <grub/i386/tsc.h>
#include <grub/i386/cpuid.h> #include <grub/i386/cpuid.h>
#ifdef GRUB_MACHINE_XEN
#include <grub/xen.h>
#else
#include <grub/i386/pit.h>
#endif
#include <grub/cpu/io.h>
/* This defines the value TSC had at the epoch (that is, when we calibrated it). */ /* This defines the value TSC had at the epoch (that is, when we calibrated it). */
static grub_uint64_t tsc_boot_time; static grub_uint64_t tsc_boot_time;
@@ -40,66 +33,6 @@ static grub_uint64_t tsc_boot_time;
in 32-bit. */ in 32-bit. */
grub_uint32_t grub_tsc_rate; 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 static grub_uint64_t
grub_tsc_get_time_ms (void) grub_tsc_get_time_ms (void)
{ {
@@ -110,52 +43,36 @@ grub_tsc_get_time_ms (void)
return ((al * grub_tsc_rate) >> 32) + ah * grub_tsc_rate; return ((al * grub_tsc_rate) >> 32) + ah * grub_tsc_rate;
} }
#ifndef GRUB_MACHINE_XEN static int
/* Calibrate the TSC based on the RTC. */ calibrate_tsc_hardcode (void)
static void
calibrate_tsc (void)
{ {
/* First calibrate the TSC rate (relative, not absolute time). */ grub_tsc_rate = 5368;/* 800 MHz */
grub_uint64_t end_tsc; return 1;
tsc_boot_time = grub_get_tsc ();
grub_pit_wait (0xffff);
end_tsc = grub_get_tsc ();
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
void void
grub_tsc_init (void) grub_tsc_init (void)
{ {
#ifdef GRUB_MACHINE_XEN if (!grub_cpu_is_tsc_supported ())
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 defined (GRUB_MACHINE_PCBIOS) || defined (GRUB_MACHINE_IEEE1275) #if defined (GRUB_MACHINE_PCBIOS) || defined (GRUB_MACHINE_IEEE1275)
grub_install_get_time_ms (grub_rtc_get_time_ms); grub_install_get_time_ms (grub_rtc_get_time_ms);
#else #else
grub_fatal ("no TSC found"); grub_fatal ("no TSC found");
#endif #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 #endif
grub_install_get_time_ms (grub_tsc_get_time_ms);
} }
+84
View File
@@ -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 <http://www.gnu.org/licenses/>.
*/
#include <grub/types.h>
#include <grub/time.h>
#include <grub/misc.h>
#include <grub/i386/tsc.h>
#include <grub/i386/pit.h>
#include <grub/cpu/io.h>
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) == 0x00) {
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;
}
+88
View File
@@ -0,0 +1,88 @@
/* 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 <http://www.gnu.org/licenses/>.
*/
#include <grub/types.h>
#include <grub/time.h>
#include <grub/misc.h>
#include <grub/i386/tsc.h>
#include <grub/i386/pmtimer.h>
#include <grub/acpi.h>
#include <grub/cpu/io.h>
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;
grub_uint64_t start_tsc;
grub_uint64_t end_tsc;
int num_iter = 0;
start = grub_inl (pmtimer) & 0xffffff;
last = start;
end = start + num_pm_ticks;
start_tsc = grub_get_tsc ();
while (1)
{
cur = grub_inl (pmtimer) & 0xffffff;
if (cur < last)
cur |= 0x1000000;
num_iter++;
if (cur >= end)
{
end_tsc = grub_get_tsc ();
return end_tsc - start_tsc;
}
/* 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;
}
}
}
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;
}
+40
View File
@@ -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 <http://www.gnu.org/licenses/>.
*/
#include <grub/types.h>
#include <grub/time.h>
#include <grub/misc.h>
#include <grub/i386/tsc.h>
#include <grub/xen.h>
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;
}
+9 -1
View File
@@ -46,11 +46,19 @@
#define HEAP_MIN_SIZE (unsigned long) (2 * 1024 * 1024) #define HEAP_MIN_SIZE (unsigned long) (2 * 1024 * 1024)
/* The maximum heap size we're going to claim */ /* 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) #define HEAP_MAX_SIZE (unsigned long) (32 * 1024 * 1024)
#endif
/* If possible, we will avoid claiming heap above this address, because it /* If possible, we will avoid claiming heap above this address, because it
seems to cause relocation problems with OSes that link at 4 MiB */ 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) #define HEAP_MAX_ADDR (unsigned long) (32 * 1024 * 1024)
#endif
extern char _start[]; extern char _start[];
extern char _end[]; extern char _end[];
@@ -166,7 +174,7 @@ heap_init (grub_uint64_t addr, grub_uint64_t len, grub_memory_type_t type,
{ {
unsigned long *total = data; unsigned long *total = data;
if (type != 1) if (type != GRUB_MEMORY_AVAILABLE)
return 0; return 0;
if (grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_NO_PRE1_5M_CLAIM)) if (grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_NO_PRE1_5M_CLAIM))
+4 -1
View File
@@ -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 root;
grub_ieee1275_phandle_t memory; grub_ieee1275_phandle_t memory;
grub_uint32_t available[32]; grub_uint32_t available[128];
grub_ssize_t available_size; grub_ssize_t available_size;
grub_uint32_t address_cells = 1; grub_uint32_t address_cells = 1;
grub_uint32_t size_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)) sizeof available, &available_size))
return grub_error (GRUB_ERR_UNKNOWN_DEVICE, return grub_error (GRUB_ERR_UNKNOWN_DEVICE,
"couldn't examine /memory/available property"); "couldn't examine /memory/available property");
if (available_size < 0 || (grub_size_t) 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)) if (grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_BROKEN_ADDRESS_CELLS))
{ {
+9
View File
@@ -740,6 +740,12 @@ parse_printf_args (const char *fmt0, struct printf_args *args,
fmt++; fmt++;
c = *fmt++; c = *fmt++;
if (c == '%')
{
n--;
continue;
}
if (c == 'l') if (c == 'l')
{ {
c = *fmt++; c = *fmt++;
@@ -876,6 +882,7 @@ grub_vsnprintf_real (char *str, grub_size_t max_len, const char *fmt0,
if (c == '%') if (c == '%')
{ {
write_char (str, &count, max_len,c); write_char (str, &count, max_len,c);
n--;
continue; continue;
} }
@@ -1099,6 +1106,8 @@ grub_fatal (const char *fmt, ...)
grub_vprintf (_(fmt), ap); grub_vprintf (_(fmt), ap);
va_end (ap); va_end (ap);
grub_refresh ();
grub_abort (); grub_abort ();
} }
+9
View File
@@ -325,6 +325,15 @@ grub_memalign (grub_size_t align, grub_size_t size)
if (!grub_mm_base) if (!grub_mm_base)
goto fail; 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 <adress space size> - 1MiB
in name of sanity is beneficial. */
if ((size + align) > ~(grub_size_t) 0x100000)
goto fail;
align = (align >> GRUB_MM_ALIGN_LOG2); align = (align >> GRUB_MM_ALIGN_LOG2);
if (align == 0) if (align == 0)
align = 1; align = 1;
+1
View File
@@ -268,6 +268,7 @@ grub_parser_execute (char *source)
grub_parser_execute_getline (&line, 0, &source); grub_parser_execute_getline (&line, 0, &source);
grub_rescue_parse_line (line, grub_parser_execute_getline, &source); grub_rescue_parse_line (line, grub_parser_execute_getline, &source);
grub_free (line); grub_free (line);
grub_print_error ();
} }
return grub_errno; return grub_errno;
+10 -5
View File
@@ -43,13 +43,17 @@ grub_rescue_parse_line (char *line,
/* In case of an assignment set the environment accordingly /* In case of an assignment set the environment accordingly
instead of calling a function. */ instead of calling a function. */
if (n == 1 && grub_strchr (line, '=')) if (n == 1)
{ {
char *val = grub_strchr (args[0], '='); char *val = grub_strchr (args[0], '=');
val[0] = 0;
grub_env_set (args[0], val + 1); if (val)
val[0] = '='; {
goto quit; val[0] = 0;
grub_env_set (args[0], val + 1);
val[0] = '=';
goto quit;
}
} }
/* Get the command name. */ /* Get the command name. */
@@ -72,6 +76,7 @@ grub_rescue_parse_line (char *line,
} }
quit: quit:
/* Arguments are returned in single memory chunk separated by zeroes */
grub_free (args[0]); grub_free (args[0]);
grub_free (args); grub_free (args);
+1
View File
@@ -50,6 +50,7 @@ FUNCTION(grub_longjmp)
ldp x29, x30, [x0], #16 ldp x29, x30, [x0], #16
ldr x2, [x0] ldr x2, [x0]
mov sp, x2 mov sp, x2
mov x0, #1
cmp x1, #0 cmp x1, #0
csel x0, x1, x0, ne csel x0, x1, x0, ne
ret ret
+2 -1
View File
@@ -470,7 +470,8 @@ grub_password_get (char buf[], unsigned buf_size)
if (key == '\b') if (key == '\b')
{ {
cur_len--; if (cur_len)
cur_len--;
continue; continue;
} }
+3
View File
@@ -19,6 +19,9 @@
#include <grub/fdt.h> #include <grub/fdt.h>
#include <grub/misc.h> #include <grub/misc.h>
#include <grub/mm.h> #include <grub/mm.h>
#include <grub/dl.h>
GRUB_MOD_LICENSE ("GPLv3+");
#define FDT_SUPPORTED_VERSION 17 #define FDT_SUPPORTED_VERSION 17
+4 -4
View File
@@ -56,11 +56,11 @@ void
grub_backtrace (void) grub_backtrace (void)
{ {
#ifdef __x86_64__ #ifdef __x86_64__
asm volatile ("movq %rbp, %rdi\n" asm volatile ("movq %%rbp, %%rdi\n"
"call " EXT_C("grub_backtrace_pointer")); "callq *%%rax": :"a"(grub_backtrace_pointer));
#else #else
asm volatile ("movl %ebp, %eax\n" asm volatile ("movl %%ebp, %%eax\n"
"call " EXT_C("grub_backtrace_pointer")); "calll *%%ecx": :"c"(grub_backtrace_pointer));
#endif #endif
} }
+103
View File
@@ -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 <http://www.gnu.org/licenses/>.
*/
#include <grub/random.h>
#include <grub/i386/io.h>
#include <grub/i386/tsc.h>
#include <grub/i386/pmtimer.h>
#include <grub/acpi.h>
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);
}
+11
View File
@@ -73,6 +73,14 @@ VARIABLE(grub_relocator64_rsp)
movq %rax, %rsp movq %rax, %rsp
/*
* Here is grub_relocator64_efi_start() entry point.
* Following code is shared between grub_relocator64_efi_start()
* and grub_relocator64_start().
*
* Think twice before changing anything below!!!
*/
VARIABLE(grub_relocator64_efi_start)
/* mov imm64, %rax */ /* mov imm64, %rax */
.byte 0x48 .byte 0x48
.byte 0xb8 .byte 0xb8
@@ -120,6 +128,9 @@ LOCAL(jump_addr):
VARIABLE(grub_relocator64_rip) VARIABLE(grub_relocator64_rip)
.quad 0 .quad 0
/* Here grub_relocator64_efi_start() ends. Ufff... */
VARIABLE(grub_relocator64_efi_end)
#ifndef __x86_64__ #ifndef __x86_64__
.p2align 4 .p2align 4
LOCAL(gdt): LOCAL(gdt):
+51 -36
View File
@@ -16,6 +16,8 @@
* along with GRUB. If not, see <http://www.gnu.org/licenses/>. * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include <grub/i386/memory.h>
#include <grub/i386/types.h>
#include <grub/symbol.h> #include <grub/symbol.h>
#include <grub/xen.h> #include <grub/xen.h>
@@ -23,78 +25,86 @@
VARIABLE(grub_relocator_xen_remap_start) VARIABLE(grub_relocator_xen_remap_start)
LOCAL(base): LOCAL(base):
/* mov imm32, %ebx */ /* Remap the remapper to it's new address. */
/* mov imm32, %ebx - %ebx: new virtual address of remapper */
.byte 0xbb .byte 0xbb
VARIABLE(grub_relocator_xen_remapper_virt) VARIABLE(grub_relocator_xen_remapper_virt)
.long 0 .long 0
/* mov imm32, %ecx */ /* mov imm32, %ecx - %ecx: low part of page table entry */
.byte 0xb9 .byte 0xb9
VARIABLE(grub_relocator_xen_remapper_map) VARIABLE(grub_relocator_xen_remapper_map)
.long 0 .long 0
/* mov imm32, %edx */ /* mov imm32, %edx - %edx: high part of page table entry */
.byte 0xba .byte 0xba
VARIABLE(grub_relocator_xen_remapper_map_high) VARIABLE(grub_relocator_xen_remapper_map_high)
.long 0 .long 0
movl %ebx, %ebp movl %ebx, %ebp /* %ebx is clobbered by hypercall */
movl $2, %esi movl $UVMF_INVLPG, %esi /* esi: flags (inv. single entry) */
movl $__HYPERVISOR_update_va_mapping, %eax movl $__HYPERVISOR_update_va_mapping, %eax
int $0x82 int $0x82
movl %ebp, %ebx movl %ebp, %ebx
addl $(LOCAL(cont) - LOCAL(base)), %ebx addl $(LOCAL(cont) - LOCAL(base)), %ebx
jmp *%ebx jmp *%ebx /* Continue with new virtual address */
LOCAL(cont): LOCAL(cont):
xorl %eax, %eax /* Modify mappings of new page tables to be read-only. */
movl %eax, %ebp /* mov imm32, %eax */
.byte 0xb8
VARIABLE(grub_relocator_xen_paging_areas_addr)
.long 0
movl %eax, %ebx
1: 1:
movl 0(%ebx), %ebp /* Get start pfn of the current area */
movl GRUB_TARGET_SIZEOF_LONG(%ebx), %ecx /* Get # of pg tables */
testl %ecx, %ecx /* 0 -> last area reached */
jz 3f
addl $(2 * GRUB_TARGET_SIZEOF_LONG), %ebx
movl %ebx, %esp /* Save current area pointer */
2:
movl %ecx, %edi
/* mov imm32, %eax */ /* mov imm32, %eax */
.byte 0xb8 .byte 0xb8
VARIABLE(grub_relocator_xen_mfn_list) VARIABLE(grub_relocator_xen_mfn_list)
.long 0 .long 0
movl %eax, %edi movl 0(%eax, %ebp, 4), %ecx /* mfn */
movl %ebp, %eax movl %ebp, %ebx
movl 0(%edi, %eax, 4), %ecx shll $PAGE_SHIFT, %ebx /* virtual address (1:1 mapping) */
/* mov imm32, %ebx */
.byte 0xbb
VARIABLE(grub_relocator_xen_paging_start)
.long 0
shll $12, %eax
addl %eax, %ebx
movl %ecx, %edx movl %ecx, %edx
shll $12, %ecx shll $PAGE_SHIFT, %ecx /* prepare pte low part */
shrl $20, %edx shrl $(32 - PAGE_SHIFT), %edx /* pte high part */
orl $5, %ecx orl $(GRUB_PAGE_PRESENT | GRUB_PAGE_USER), %ecx /* pte low */
movl $2, %esi movl $UVMF_INVLPG, %esi
movl $__HYPERVISOR_update_va_mapping, %eax movl $__HYPERVISOR_update_va_mapping, %eax
int $0x82 int $0x82 /* parameters: eax, ebx, ecx, edx, esi */
incl %ebp incl %ebp /* next pfn */
/* mov imm32, %ecx */ movl %edi, %ecx
.byte 0xb9
VARIABLE(grub_relocator_xen_paging_size)
.long 0
cmpl %ebp, %ecx
ja 1b loop 2b
mov %esp, %ebx /* restore area poniter */
jmp 1b
3:
/* Switch page tables: pin new L3 pt, load cr3, unpin old L3. */
/* mov imm32, %ebx */ /* mov imm32, %ebx */
.byte 0xbb .byte 0xbb
VARIABLE(grub_relocator_xen_mmu_op_addr) VARIABLE(grub_relocator_xen_mmu_op_addr)
.long 0 .long 0
movl $3, %ecx movl $3, %ecx /* 3 mmu ops */
movl $0, %edx movl $0, %edx /* pdone (not used) */
movl $0x7FF0, %esi movl $DOMID_SELF, %esi
movl $__HYPERVISOR_mmuext_op, %eax movl $__HYPERVISOR_mmuext_op, %eax
int $0x82 int $0x82
/* Continue in virtual kernel mapping. */
/* mov imm32, %eax */ /* mov imm32, %eax */
.byte 0xb8 .byte 0xb8
VARIABLE(grub_relocator_xen_remap_continue) VARIABLE(grub_relocator_xen_remap_continue)
@@ -102,6 +112,9 @@ VARIABLE(grub_relocator_xen_remap_continue)
jmp *%eax jmp *%eax
VARIABLE(grub_relocator_xen_paging_areas)
.long 0, 0, 0, 0, 0, 0, 0, 0
VARIABLE(grub_relocator_xen_mmu_op) VARIABLE(grub_relocator_xen_mmu_op)
.space 256 .space 256
@@ -109,6 +122,7 @@ VARIABLE(grub_relocator_xen_remap_end)
VARIABLE(grub_relocator_xen_start) VARIABLE(grub_relocator_xen_start)
/* Unmap old remapper area. */
/* mov imm32, %eax */ /* mov imm32, %eax */
.byte 0xb8 .byte 0xb8
VARIABLE(grub_relocator_xen_remapper_virt2) VARIABLE(grub_relocator_xen_remapper_virt2)
@@ -116,14 +130,14 @@ VARIABLE(grub_relocator_xen_remapper_virt2)
movl %eax, %edi movl %eax, %edi
xorl %ecx, %ecx xorl %ecx, %ecx /* Invalid pte */
xorl %edx, %edx xorl %edx, %edx
movl $2, %esi movl $UVMF_INVLPG, %esi
movl $__HYPERVISOR_update_va_mapping, %eax movl $__HYPERVISOR_update_va_mapping, %eax
int $0x82 int $0x82
/* Prepare registers for starting kernel. */
/* mov imm32, %eax */ /* mov imm32, %eax */
.byte 0xb8 .byte 0xb8
VARIABLE(grub_relocator_xen_stack) VARIABLE(grub_relocator_xen_stack)
@@ -145,6 +159,7 @@ VARIABLE(grub_relocator_xen_start_info)
VARIABLE(grub_relocator_xen_entry_point) VARIABLE(grub_relocator_xen_entry_point)
.long 0 .long 0
/* Now start the new kernel. */
jmp *%eax jmp *%eax
VARIABLE(grub_relocator_xen_end) VARIABLE(grub_relocator_xen_end)
+2 -2
View File
@@ -95,7 +95,7 @@ grub_get_datetime (struct grub_datetime *datetime)
datetime->year = args.year; datetime->year = args.year;
datetime->month = args.month; datetime->month = args.month;
datetime->day = args.day; datetime->day = args.day + 1;
datetime->hour = args.hour; datetime->hour = args.hour;
datetime->minute = args.minute; datetime->minute = args.minute;
datetime->second = args.second; datetime->second = args.second;
@@ -140,7 +140,7 @@ grub_set_datetime (struct grub_datetime *datetime)
args.year = datetime->year; args.year = datetime->year;
args.month = datetime->month; args.month = datetime->month;
args.day = datetime->day; args.day = datetime->day - 1;
args.hour = datetime->hour; args.hour = datetime->hour;
args.minute = datetime->minute; args.minute = datetime->minute;
args.second = datetime->second; args.second = datetime->second;
-1
View File
@@ -31,7 +31,6 @@ GRUB_MOD_LICENSE ("GPLv2+");
desired derived output length DKLEN. Output buffer is DK which desired derived output length DKLEN. Output buffer is DK which
must have room for at least DKLEN octets. The output buffer will must have room for at least DKLEN octets. The output buffer will
be filled with the derived data. */ be filled with the derived data. */
#pragma GCC diagnostic ignored "-Wunreachable-code"
gcry_err_code_t gcry_err_code_t
grub_crypto_pbkdf2 (const struct gcry_md_spec *md, grub_crypto_pbkdf2 (const struct gcry_md_spec *md,
+6
View File
@@ -38,11 +38,17 @@ grub_file_progress_hook_real (grub_disk_addr_t sector __attribute__ ((unused)),
grub_uint64_t now; grub_uint64_t now;
static grub_uint64_t last_progress_update_time; static grub_uint64_t last_progress_update_time;
grub_file_t file = data; grub_file_t file = data;
const char *e;
file->progress_offset += length; file->progress_offset += length;
if (call_depth) if (call_depth)
return; return;
e = grub_env_get ("enable_progress_indicator");
if (e && e[0] == '0') {
return;
}
call_depth = 1; call_depth = 1;
now = grub_get_time_ms (); now = grub_get_time_ms ();
+120
View File
@@ -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 <http://www.gnu.org/licenses/>.
*/
#include <grub/random.h>
#include <grub/dl.h>
#include <grub/lib/hexdump.h>
#include <grub/command.h>
#include <grub/mm.h>
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);
}
+30 -20
View File
@@ -736,26 +736,36 @@ malloc_in_range (struct grub_relocator *rel,
} }
isinsideafter = (!ncollisions && (nstarted || ((nlefto || nstartedfw) isinsideafter = (!ncollisions && (nstarted || ((nlefto || nstartedfw)
&& !nblockfw))); && !nblockfw)));
if (!isinsidebefore && isinsideafter) if (from_low_priv) {
starta = from_low_priv ? ALIGN_UP (events[j].pos, align) if (!isinsidebefore && isinsideafter)
: ALIGN_DOWN (events[j].pos - size, align) + size; starta = ALIGN_UP (events[j].pos, align);
if (isinsidebefore && !isinsideafter && from_low_priv)
{ if (isinsidebefore && !isinsideafter)
target = starta; {
if (target < start) target = starta;
target = start; if (target < start)
if (target + size <= end && target + size <= events[j].pos) target = start;
/* Found an usable address. */ if (target + size <= end && target + size <= events[j].pos)
goto found; /* Found an usable address. */
} goto found;
if (isinsidebefore && !isinsideafter && !from_low_priv) }
{ } else {
target = starta - size; if (!isinsidebefore && isinsideafter)
if (target > end - size) {
target = end - size; if (events[j].pos >= size)
if (target >= start && target >= events[j].pos) starta = ALIGN_DOWN (events[j].pos - size, align) + size;
goto found; 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;
}
}
} }
} }
+80
View File
@@ -0,0 +1,80 @@
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2009 Free Software Foundation, Inc.
* Copyright (C) 2016 Oracle and/or its affiliates. All rights reserved.
*
* 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 <http://www.gnu.org/licenses/>.
*/
#include <grub/mm.h>
#include <grub/misc.h>
#include <grub/types.h>
#include <grub/err.h>
#include <grub/i386/relocator.h>
#include <grub/relocator_private.h>
extern grub_uint64_t grub_relocator64_rax;
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_rsi;
extern grub_uint8_t grub_relocator64_efi_start;
extern grub_uint8_t grub_relocator64_efi_end;
#define RELOCATOR_SIZEOF(x) (&grub_relocator##x##_end - &grub_relocator##x##_start)
grub_err_t
grub_relocator64_efi_boot (struct grub_relocator *rel,
struct grub_relocator64_efi_state state)
{
grub_err_t err;
void *relst;
grub_relocator_chunk_t ch;
/*
* 64-bit relocator code may live above 4 GiB quite well.
* However, I do not want ask for problems. Just in case.
*/
err = grub_relocator_alloc_chunk_align (rel, &ch, 0,
0x100000000 - RELOCATOR_SIZEOF (64_efi),
RELOCATOR_SIZEOF (64_efi), 16,
GRUB_RELOCATOR_PREFERENCE_NONE, 1);
if (err)
return err;
/* Do not touch %rsp! It points to EFI created stack. */
grub_relocator64_rax = state.rax;
grub_relocator64_rbx = state.rbx;
grub_relocator64_rcx = state.rcx;
grub_relocator64_rdx = state.rdx;
grub_relocator64_rip = state.rip;
grub_relocator64_rsi = state.rsi;
grub_memmove (get_virtual_current_address (ch), &grub_relocator64_efi_start,
RELOCATOR_SIZEOF (64_efi));
err = grub_relocator_prepare_relocs (rel, get_physical_target_address (ch),
&relst, NULL);
if (err)
return err;
((void (*) (void)) relst) ();
/* Not reached. */
return GRUB_ERR_NONE;
}
+54 -77
View File
@@ -16,94 +16,85 @@
* along with GRUB. If not, see <http://www.gnu.org/licenses/>. * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include <grub/x86_64/memory.h>
#include <grub/x86_64/types.h>
#include <grub/symbol.h> #include <grub/symbol.h>
#include <grub/xen.h> #include <grub/xen.h>
/* Macro to load an imm64 value stored by the C-part into %rax: */
#define MOV_IMM64_RAX(var) .byte 0x48, 0xb8; VARIABLE(var); .quad 0
.p2align 4 /* force 16-byte alignment */ .p2align 4 /* force 16-byte alignment */
VARIABLE(grub_relocator_xen_remap_start) VARIABLE(grub_relocator_xen_remap_start)
LOCAL(base): LOCAL(base):
/* mov imm64, %rax */ /* Remap the remapper to it's new address. */
.byte 0x48 MOV_IMM64_RAX(grub_relocator_xen_remapper_virt)
.byte 0xb8
VARIABLE(grub_relocator_xen_remapper_virt)
.quad 0
movq %rax, %rdi movq %rax, %rdi /* %rdi: new virtual address of remapper */
movq %rax, %rbx movq %rax, %rbx /* Remember new virtual address */
/* mov imm64, %rax */ MOV_IMM64_RAX(grub_relocator_xen_remapper_map)
.byte 0x48
.byte 0xb8
VARIABLE(grub_relocator_xen_remapper_map)
.quad 0
movq %rax, %rsi movq %rax, %rsi /* %rsi: page table entry */
movq $2, %rdx movq $UVMF_INVLPG, %rdx /* %rdx: flags (inv. single entry) */
movq $__HYPERVISOR_update_va_mapping, %rax movq $__HYPERVISOR_update_va_mapping, %rax
syscall syscall /* Do the remap operation */
addq $(LOCAL(cont) - LOCAL(base)), %rbx addq $(LOCAL(cont) - LOCAL(base)), %rbx
jmp *%rbx jmp *%rbx /* Continue with new virtual address */
LOCAL(cont): LOCAL(cont):
/* Modify mappings of new page tables to be read-only. */
MOV_IMM64_RAX(grub_relocator_xen_mfn_list)
/* mov imm64, %rcx */ movq %rax, %rbx /* %rbx is the base of the p2m list */
.byte 0x48 leaq EXT_C(grub_relocator_xen_paging_areas) (%rip), %r8
.byte 0xb9
VARIABLE(grub_relocator_xen_paging_size)
.quad 0
/* mov imm64, %rax */
.byte 0x48
.byte 0xb8
VARIABLE(grub_relocator_xen_paging_start)
.quad 0
movq %rax, %r12
/* mov imm64, %rax */
.byte 0x48
.byte 0xb8
VARIABLE(grub_relocator_xen_mfn_list)
.quad 0
movq %rax, %rsi
1: 1:
movq 0(%r8), %r12 /* Get start pfn of the current area */
movq GRUB_TARGET_SIZEOF_LONG(%r8), %rcx /* Get # of pg tables */
testq %rcx, %rcx /* 0 -> last area reached */
jz 3f
2:
movq %r12, %rdi movq %r12, %rdi
movq %rsi, %rbx shlq $PAGE_SHIFT, %rdi /* virtual address (1:1 mapping) */
movq 0(%rsi), %rsi movq (%rbx, %r12, 8), %rsi /* mfn */
shlq $12, %rsi shlq $PAGE_SHIFT, %rsi
orq $5, %rsi orq $(GRUB_PAGE_PRESENT | GRUB_PAGE_USER), %rsi /* Build pte */
movq $2, %rdx movq $UVMF_INVLPG, %rdx
movq %rcx, %r9 movq %rcx, %r9 /* %rcx clobbered by hypercall */
movq $__HYPERVISOR_update_va_mapping, %rax movq $__HYPERVISOR_update_va_mapping, %rax
syscall syscall
movq %r9, %rcx movq %r9, %rcx
addq $8, %rbx incq %r12 /* next pfn */
addq $4096, %r12
movq %rbx, %rsi
loop 1b loop 2b
addq $(2 * GRUB_TARGET_SIZEOF_LONG), %r8 /* next pg table area */
jmp 1b
3:
/* Switch page tables: pin new L4 pt, load cr3, unpin old L4. */
leaq EXT_C(grub_relocator_xen_mmu_op) (%rip), %rdi leaq EXT_C(grub_relocator_xen_mmu_op) (%rip), %rdi
movq $3, %rsi movq $3, %rsi /* 3 mmu ops */
movq $0, %rdx movq $0, %rdx /* pdone (not used) */
movq $0x7FF0, %r10 movq $DOMID_SELF, %r10
movq $__HYPERVISOR_mmuext_op, %rax movq $__HYPERVISOR_mmuext_op, %rax
syscall syscall
/* mov imm64, %rax */ /* Continue in virtual kernel mapping. */
.byte 0x48 MOV_IMM64_RAX(grub_relocator_xen_remap_continue)
.byte 0xb8
VARIABLE(grub_relocator_xen_remap_continue)
.quad 0
jmp *%rax jmp *%rax
VARIABLE(grub_relocator_xen_paging_areas)
/* array of start, size pairs, size 0 is end marker */
.quad 0, 0, 0, 0, 0, 0, 0, 0
VARIABLE(grub_relocator_xen_mmu_op) VARIABLE(grub_relocator_xen_mmu_op)
.space 256 .space 256
@@ -111,46 +102,32 @@ VARIABLE(grub_relocator_xen_remap_end)
VARIABLE(grub_relocator_xen_start) VARIABLE(grub_relocator_xen_start)
/* mov imm64, %rax */ /* Unmap old remapper area. */
.byte 0x48 MOV_IMM64_RAX(grub_relocator_xen_remapper_virt2)
.byte 0xb8
VARIABLE(grub_relocator_xen_remapper_virt2)
.quad 0
movq %rax, %rdi movq %rax, %rdi
xorq %rax, %rax xorq %rax, %rax /* Invalid pte */
movq %rax, %rsi movq %rax, %rsi
movq $2, %rdx movq $UVMF_INVLPG, %rdx
movq $__HYPERVISOR_update_va_mapping, %rax movq $__HYPERVISOR_update_va_mapping, %rax
syscall syscall
/* Prepare registers for starting kernel. */
/* mov imm64, %rax */ MOV_IMM64_RAX(grub_relocator_xen_stack)
.byte 0x48
.byte 0xb8
VARIABLE(grub_relocator_xen_stack)
.quad 0
movq %rax, %rsp movq %rax, %rsp
/* mov imm64, %rax */ MOV_IMM64_RAX(grub_relocator_xen_start_info)
.byte 0x48
.byte 0xb8
VARIABLE(grub_relocator_xen_start_info)
.quad 0
movq %rax, %rsi movq %rax, %rsi
cld cld
/* mov imm64, %rax */ MOV_IMM64_RAX(grub_relocator_xen_entry_point)
.byte 0x48
.byte 0xb8
VARIABLE(grub_relocator_xen_entry_point)
.quad 0
/* Now start the new kernel. */
jmp *%rax jmp *%rax
VARIABLE(grub_relocator_xen_end) VARIABLE(grub_relocator_xen_end)
+20 -8
View File
@@ -29,6 +29,11 @@
typedef grub_addr_t grub_xen_reg_t; typedef grub_addr_t grub_xen_reg_t;
struct grub_relocator_xen_paging_area {
grub_xen_reg_t start;
grub_xen_reg_t size;
} GRUB_PACKED;
extern grub_uint8_t grub_relocator_xen_start; extern grub_uint8_t grub_relocator_xen_start;
extern grub_uint8_t grub_relocator_xen_end; extern grub_uint8_t grub_relocator_xen_end;
extern grub_uint8_t grub_relocator_xen_remap_start; extern grub_uint8_t grub_relocator_xen_remap_start;
@@ -36,15 +41,16 @@ extern grub_uint8_t grub_relocator_xen_remap_end;
extern grub_xen_reg_t grub_relocator_xen_stack; extern grub_xen_reg_t grub_relocator_xen_stack;
extern grub_xen_reg_t grub_relocator_xen_start_info; extern grub_xen_reg_t grub_relocator_xen_start_info;
extern grub_xen_reg_t grub_relocator_xen_entry_point; extern grub_xen_reg_t grub_relocator_xen_entry_point;
extern grub_xen_reg_t grub_relocator_xen_paging_start;
extern grub_xen_reg_t grub_relocator_xen_paging_size;
extern grub_xen_reg_t grub_relocator_xen_remapper_virt; extern grub_xen_reg_t grub_relocator_xen_remapper_virt;
extern grub_xen_reg_t grub_relocator_xen_remapper_virt2; extern grub_xen_reg_t grub_relocator_xen_remapper_virt2;
extern grub_xen_reg_t grub_relocator_xen_remapper_map; extern grub_xen_reg_t grub_relocator_xen_remapper_map;
extern grub_xen_reg_t grub_relocator_xen_mfn_list; extern grub_xen_reg_t grub_relocator_xen_mfn_list;
extern struct grub_relocator_xen_paging_area
grub_relocator_xen_paging_areas[XEN_MAX_MAPPINGS];
extern grub_xen_reg_t grub_relocator_xen_remap_continue; extern grub_xen_reg_t grub_relocator_xen_remap_continue;
#ifdef __i386__ #ifdef __i386__
extern grub_xen_reg_t grub_relocator_xen_mmu_op_addr; extern grub_xen_reg_t grub_relocator_xen_mmu_op_addr;
extern grub_xen_reg_t grub_relocator_xen_paging_areas_addr;
extern grub_xen_reg_t grub_relocator_xen_remapper_map_high; extern grub_xen_reg_t grub_relocator_xen_remapper_map_high;
#endif #endif
extern mmuext_op_t grub_relocator_xen_mmu_op[3]; extern mmuext_op_t grub_relocator_xen_mmu_op[3];
@@ -61,6 +67,7 @@ grub_relocator_xen_boot (struct grub_relocator *rel,
{ {
grub_err_t err; grub_err_t err;
void *relst; void *relst;
int i;
grub_relocator_chunk_t ch, ch_tramp; grub_relocator_chunk_t ch, ch_tramp;
grub_xen_mfn_t *mfn_list = grub_xen_mfn_t *mfn_list =
(grub_xen_mfn_t *) grub_xen_start_page_addr->mfn_list; (grub_xen_mfn_t *) grub_xen_start_page_addr->mfn_list;
@@ -77,8 +84,11 @@ grub_relocator_xen_boot (struct grub_relocator *rel,
grub_relocator_xen_stack = state.stack; grub_relocator_xen_stack = state.stack;
grub_relocator_xen_start_info = state.start_info; grub_relocator_xen_start_info = state.start_info;
grub_relocator_xen_entry_point = state.entry_point; grub_relocator_xen_entry_point = state.entry_point;
grub_relocator_xen_paging_start = state.paging_start << 12; for (i = 0; i < XEN_MAX_MAPPINGS; i++)
grub_relocator_xen_paging_size = state.paging_size; {
grub_relocator_xen_paging_areas[i].start = state.paging_start[i];
grub_relocator_xen_paging_areas[i].size = state.paging_size[i];
}
grub_relocator_xen_remapper_virt = remapper_virt; grub_relocator_xen_remapper_virt = remapper_virt;
grub_relocator_xen_remapper_virt2 = remapper_virt; grub_relocator_xen_remapper_virt2 = remapper_virt;
grub_relocator_xen_remap_continue = trampoline_virt; grub_relocator_xen_remap_continue = trampoline_virt;
@@ -88,10 +98,12 @@ grub_relocator_xen_boot (struct grub_relocator *rel,
grub_relocator_xen_remapper_map_high = (mfn_list[remapper_pfn] >> 20); grub_relocator_xen_remapper_map_high = (mfn_list[remapper_pfn] >> 20);
grub_relocator_xen_mmu_op_addr = (char *) &grub_relocator_xen_mmu_op grub_relocator_xen_mmu_op_addr = (char *) &grub_relocator_xen_mmu_op
- (char *) &grub_relocator_xen_remap_start + remapper_virt; - (char *) &grub_relocator_xen_remap_start + remapper_virt;
grub_relocator_xen_paging_areas_addr =
(char *) &grub_relocator_xen_paging_areas
- (char *) &grub_relocator_xen_remap_start + remapper_virt;
#endif #endif
grub_relocator_xen_mfn_list = state.mfn_list grub_relocator_xen_mfn_list = state.mfn_list;
+ state.paging_start * sizeof (grub_addr_t);
grub_memset (grub_relocator_xen_mmu_op, 0, grub_memset (grub_relocator_xen_mmu_op, 0,
sizeof (grub_relocator_xen_mmu_op)); sizeof (grub_relocator_xen_mmu_op));
@@ -100,9 +112,9 @@ grub_relocator_xen_boot (struct grub_relocator *rel,
#else #else
grub_relocator_xen_mmu_op[0].cmd = MMUEXT_PIN_L4_TABLE; grub_relocator_xen_mmu_op[0].cmd = MMUEXT_PIN_L4_TABLE;
#endif #endif
grub_relocator_xen_mmu_op[0].arg1.mfn = mfn_list[state.paging_start]; grub_relocator_xen_mmu_op[0].arg1.mfn = mfn_list[state.paging_start[0]];
grub_relocator_xen_mmu_op[1].cmd = MMUEXT_NEW_BASEPTR; grub_relocator_xen_mmu_op[1].cmd = MMUEXT_NEW_BASEPTR;
grub_relocator_xen_mmu_op[1].arg1.mfn = mfn_list[state.paging_start]; grub_relocator_xen_mmu_op[1].arg1.mfn = mfn_list[state.paging_start[0]];
grub_relocator_xen_mmu_op[2].cmd = MMUEXT_UNPIN_TABLE; grub_relocator_xen_mmu_op[2].cmd = MMUEXT_UNPIN_TABLE;
grub_relocator_xen_mmu_op[2].arg1.mfn = grub_relocator_xen_mmu_op[2].arg1.mfn =
mfn_list[grub_xen_start_page_addr->pt_base >> 12]; mfn_list[grub_xen_start_page_addr->pt_base >> 12];
+1 -23
View File
@@ -28,28 +28,6 @@
static void *loaded_fdt; static void *loaded_fdt;
static void *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 * void *
grub_fdt_load (grub_size_t additional_size) grub_fdt_load (grub_size_t additional_size)
{ {
@@ -65,7 +43,7 @@ grub_fdt_load (grub_size_t additional_size)
if (loaded_fdt) if (loaded_fdt)
raw_fdt = loaded_fdt; raw_fdt = loaded_fdt;
else else
raw_fdt = get_firmware_fdt(); raw_fdt = grub_efi_get_firmware_fdt();
size = size =
raw_fdt ? grub_fdt_get_totalsize (raw_fdt) : GRUB_FDT_EMPTY_TREE_SZ; raw_fdt ? grub_fdt_get_totalsize (raw_fdt) : GRUB_FDT_EMPTY_TREE_SZ;
+32 -129
View File
@@ -37,16 +37,6 @@
GRUB_MOD_LICENSE ("GPLv3+"); GRUB_MOD_LICENSE ("GPLv3+");
#define XEN_HYPERVISOR_NAME "xen_hypervisor" #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" #define MODULE_CUSTOM_COMPATIBLE "multiboot,module"
/* This maximum size is defined in Power.org ePAPR V1.1 /* 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; 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 xen_hypervisor_header
{ {
struct grub_arm64_linux_kernel_header efi_head; 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 *next;
struct xen_boot_binary **prev; struct xen_boot_binary **prev;
const char *name; int is_hypervisor;
grub_addr_t start; grub_addr_t start;
grub_size_t size; grub_size_t size;
@@ -106,8 +88,6 @@ struct xen_boot_binary
char *cmdline; char *cmdline;
int cmdline_size; int cmdline_size;
struct fdt_node_info node_info;
}; };
static grub_dl_t my_mod; 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 *xen_hypervisor;
static struct xen_boot_binary *module_head; 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 static __inline grub_addr_t
xen_boot_address_align (grub_addr_t start, grub_size_t align) xen_boot_address_align (grub_addr_t start, grub_size_t align)
@@ -136,26 +103,6 @@ xen_boot_address_align (grub_addr_t start, grub_size_t align)
return (align ? (ALIGN_UP (start, align)) : start); return (align ? (ALIGN_UP (start, align)) : start);
} }
/* Parse the option of xen_module command. For now, we support
(1) --type <the compatible stream>
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 static grub_err_t
prepare_xen_hypervisor_params (void *xen_boot_fdt) prepare_xen_hypervisor_params (void *xen_boot_fdt)
{ {
@@ -209,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); grub_fdt_add_subnode (xen_boot_fdt, chosen_node, module_name);
retval = grub_fdt_set_prop (xen_boot_fdt, module_node, "compatible", retval = grub_fdt_set_prop (xen_boot_fdt, module_node, "compatible",
module->node_info.compat_string, MODULE_CUSTOM_COMPATIBLE, sizeof(MODULE_CUSTOM_COMPATIBLE) - 1);
(grub_uint32_t) module->
node_info.compat_string_size);
if (retval) if (retval)
return grub_error (GRUB_ERR_IO, "failed to update FDT"); return grub_error (GRUB_ERR_IO, "failed to update FDT");
grub_dprintf ("xen_loader", "Module %s compatible = %s size = 0x%lx\n", grub_dprintf ("xen_loader", "Module\n");
module->name, module->node_info.compat_string,
module->node_info.compat_string_size);
retval = grub_fdt_set_reg64 (xen_boot_fdt, module_node, retval = grub_fdt_set_reg64 (xen_boot_fdt, module_node,
xen_boot_address_align (module->start, xen_boot_address_align (module->start,
@@ -229,7 +172,7 @@ prepare_xen_module_params (struct xen_boot_binary *module, void *xen_boot_fdt)
if (module->cmdline && module->cmdline_size > 0) if (module->cmdline && module->cmdline_size > 0)
{ {
grub_dprintf ("xen_loader", 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); module->cmdline, module->cmdline, module->cmdline_size);
retval = grub_fdt_set_prop (xen_boot_fdt, module_node, "bootargs", retval = grub_fdt_set_prop (xen_boot_fdt, module_node, "bootargs",
@@ -239,8 +182,7 @@ prepare_xen_module_params (struct xen_boot_binary *module, void *xen_boot_fdt)
} }
else else
{ {
grub_dprintf ("xen_loader", "Module %s has not bootargs!\n", grub_dprintf ("xen_loader", "Module has no bootargs!\n");
module->name);
} }
return GRUB_ERR_NONE; return GRUB_ERR_NONE;
@@ -257,8 +199,8 @@ finalize_params_xen_boot (void)
additional_size += FDT_NODE_NAME_MAX_SIZE + xen_hypervisor->cmdline_size; additional_size += FDT_NODE_NAME_MAX_SIZE + xen_hypervisor->cmdline_size;
FOR_LIST_ELEMENTS (module, module_head) FOR_LIST_ELEMENTS (module, module_head)
{ {
additional_size += 6 * FDT_NODE_NAME_MAX_SIZE + module-> additional_size += 6 * FDT_NODE_NAME_MAX_SIZE + sizeof(MODULE_CUSTOM_COMPATIBLE) - 1
node_info.compat_string_size + module->cmdline_size; + module->cmdline_size;
} }
xen_boot_fdt = grub_fdt_load (additional_size); xen_boot_fdt = grub_fdt_load (additional_size);
@@ -281,8 +223,7 @@ finalize_params_xen_boot (void)
{ {
if (module->start && module->size > 0) if (module->start && module->size > 0)
{ {
grub_dprintf ("xen_loader", "Module %s @ 0x%lx size:0x%lx\n", grub_dprintf ("xen_loader", "Module @ 0x%lx size:0x%lx\n",
module->name,
xen_boot_address_align (module->start, module->align), xen_boot_address_align (module->start, module->align),
module->size); module->size);
if (prepare_xen_module_params (module, xen_boot_fdt) != GRUB_ERR_NONE) if (prepare_xen_module_params (module, xen_boot_fdt) != GRUB_ERR_NONE)
@@ -290,7 +231,7 @@ finalize_params_xen_boot (void)
} }
else else
{ {
grub_dprintf ("xen_loader", "Module info error: %s!\n", module->name); grub_dprintf ("xen_loader", "Module info error!\n");
goto fail; goto fail;
} }
} }
@@ -333,19 +274,16 @@ single_binary_unload (struct xen_boot_binary *binary)
{ {
grub_free (binary->cmdline); grub_free (binary->cmdline);
grub_dprintf ("xen_loader", grub_dprintf ("xen_loader",
"Module %s cmdline memory free @ %p size: %d\n", "Module cmdline memory free @ %p size: %d\n",
binary->name, binary->cmdline, binary->cmdline_size); binary->cmdline, binary->cmdline_size);
} }
if (binary->node_info.type == MODULE_CUSTOM) if (!binary->is_hypervisor)
grub_free ((void *) binary->node_info.compat_string);
if (grub_strcmp (binary->name, XEN_HYPERVISOR_NAME))
grub_list_remove (GRUB_AS_LIST (binary)); grub_list_remove (GRUB_AS_LIST (binary));
grub_dprintf ("xen_loader", grub_dprintf ("xen_loader",
"Module %s struct memory free @ %p size: 0x%lx\n", "Module struct memory free @ %p size: 0x%lx\n",
binary->name, binary, sizeof (binary)); binary, sizeof (binary));
grub_free (binary); grub_free (binary);
return; return;
@@ -383,8 +321,7 @@ xen_boot_binary_load (struct xen_boot_binary *binary, grub_file_t file,
int argc, char *argv[]) int argc, char *argv[])
{ {
binary->size = grub_file_size (file); binary->size = grub_file_size (file);
grub_dprintf ("xen_loader", "Xen_boot %s file size: 0x%lx\n", grub_dprintf ("xen_loader", "Xen_boot file size: 0x%lx\n", binary->size);
binary->name, binary->size);
binary->start binary->start
= (grub_addr_t) grub_efi_allocate_pages (0, = (grub_addr_t) grub_efi_allocate_pages (0,
@@ -397,8 +334,8 @@ xen_boot_binary_load (struct xen_boot_binary *binary, grub_file_t file,
return; return;
} }
grub_dprintf ("xen_loader", "Xen_boot %s numpages: 0x%lx\n", grub_dprintf ("xen_loader", "Xen_boot numpages: 0x%lx\n",
binary->name, GRUB_EFI_BYTES_TO_PAGES (binary->size + binary->align)); GRUB_EFI_BYTES_TO_PAGES (binary->size + binary->align));
if (grub_file_read (file, (void *) xen_boot_address_align (binary->start, if (grub_file_read (file, (void *) xen_boot_address_align (binary->start,
binary->align), binary->align),
@@ -422,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, grub_create_loader_cmdline (argc - 1, argv + 1, binary->cmdline,
binary->cmdline_size); binary->cmdline_size);
grub_dprintf ("xen_loader", 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); binary->cmdline, binary->cmdline, binary->cmdline_size);
} }
else else
@@ -436,11 +373,11 @@ xen_boot_binary_load (struct xen_boot_binary *binary, grub_file_t file,
} }
static grub_err_t 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; struct xen_boot_binary *module = NULL;
int file_name_index = 0;
grub_file_t file = 0; grub_file_t file = 0;
if (!argc) if (!argc)
@@ -461,46 +398,20 @@ grub_cmd_xen_module (grub_command_t cmd, int argc, char *argv[])
if (!module) if (!module)
return grub_errno; return grub_errno;
/* process all the options and get module type */ module->is_hypervisor = 0;
if (set_module_type (cmd, module, &file_name_index) != module->align = 4096;
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: grub_dprintf ("xen_loader", "Init module and node info\n");
/* we have set the node_info in set_module_type */
break;
default: file = grub_file_open (argv[0]);
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) if (!file)
goto fail; goto fail;
xen_boot_binary_load (module, file, argc - file_name_index, xen_boot_binary_load (module, file, argc, argv);
argv + file_name_index);
if (grub_errno == GRUB_ERR_NONE) if (grub_errno == GRUB_ERR_NONE)
grub_list_push (GRUB_AS_LIST_P (&module_head), GRUB_AS_LIST (module)); grub_list_push (GRUB_AS_LIST_P (&module_head), GRUB_AS_LIST (module));
fail: fail:
if (file) if (file)
grub_file_close (file); grub_file_close (file);
if (grub_errno != GRUB_ERR_NONE) if (grub_errno != GRUB_ERR_NONE)
@@ -544,7 +455,7 @@ grub_cmd_xen_hypervisor (grub_command_t cmd __attribute__ ((unused)),
if (!xen_hypervisor) if (!xen_hypervisor)
return grub_errno; 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_hypervisor->align = (grub_size_t) sh.optional_header.section_alignment;
xen_boot_binary_load (xen_hypervisor, file, argc, argv); xen_boot_binary_load (xen_hypervisor, file, argc, argv);
@@ -568,29 +479,21 @@ fail:
} }
static grub_command_t cmd_xen_hypervisor; 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) GRUB_MOD_INIT (xen_boot)
{ {
cmd_xen_hypervisor = cmd_xen_hypervisor =
grub_register_command ("xen_hypervisor", grub_cmd_xen_hypervisor, 0, grub_register_command ("xen_hypervisor", grub_cmd_xen_hypervisor, 0,
N_("Load a xen hypervisor.")); N_("Load a xen hypervisor."));
cmd_xen_linux = cmd_xen_module =
grub_register_command ("xen_linux", grub_cmd_xen_module, 0, grub_register_command ("xen_module", grub_cmd_xen_module, 0,
N_("Load a xen linux kernel for dom0.")); N_("Load a xen module."));
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; my_mod = mod;
} }
GRUB_MOD_FINI (xen_boot) GRUB_MOD_FINI (xen_boot)
{ {
grub_unregister_command (cmd_xen_hypervisor); grub_unregister_command (cmd_xen_hypervisor);
grub_unregister_command (cmd_xen_linux); grub_unregister_command (cmd_xen_module);
grub_unregister_command (cmd_xen_initrd);
grub_unregister_command (cmd_xen_xsm);
} }
+5 -1
View File
@@ -122,6 +122,8 @@ copy_file_path (grub_efi_file_path_device_path_t *fp,
if (*p == '/') if (*p == '/')
*p = '\\'; *p = '\\';
/* File Path is NULL terminated */
fp->path_name[size++] = '\0';
fp->header.length = size * sizeof (grub_efi_char16_t) + sizeof (*fp); fp->header.length = size * sizeof (grub_efi_char16_t) + sizeof (*fp);
} }
@@ -156,8 +158,10 @@ make_file_path (grub_efi_device_path_t *dp, const char *filename)
d = GRUB_EFI_NEXT_DEVICE_PATH (d); d = GRUB_EFI_NEXT_DEVICE_PATH (d);
} }
/* File Path is NULL terminated. Allocate space for 2 extra characters */
/* FIXME why we split path in two components? */
file_path = grub_malloc (size file_path = grub_malloc (size
+ ((grub_strlen (dir_start) + 1) + ((grub_strlen (dir_start) + 2)
* GRUB_MAX_UTF16_PER_UTF8 * GRUB_MAX_UTF16_PER_UTF8
* sizeof (grub_efi_char16_t)) * sizeof (grub_efi_char16_t))
+ sizeof (grub_efi_file_path_device_path_t) * 2); + sizeof (grub_efi_file_path_device_path_t) * 2);
Loaded 100 of 225 files, more files were not shown because too many files have changed in this diff. Show more