Commit graph

9832 commits

Author SHA1 Message Date
Vladimir Serbinenko
384d3e5b84 genmoddep: Check that no modules provide the same symbol.
The semantics of 2 modules providing the same symbol are undefined. So
ensure that it doesn't happen.
2020-09-21 12:02:37 -04:00
Vladimir Serbinenko
547d8201cf Fix symbols appearing in several modules in linux*.
If same symbol is provided by 2 modules its semantics are undefined.
Avoid this by depending rather than double-including files.
2020-09-21 12:02:37 -04:00
Vladimir Serbinenko
ec4630c2b5 multiboot: disentangle multiboot and multiboot2.
Previously we had multiboot and multiboot2 declaring the same symbols.
This can potentially lead to aliasing and strange behaviours when e.g.
module instead of module2 is used with multiboot2.

Bug: #51137
2020-09-21 12:02:37 -04:00
Vladimir Serbinenko
aa34f69d5d hdparm: Depend on hexdump rather than having a second copy of hexdump. 2020-09-21 12:02:37 -04:00
Vladimir Serbinenko
ebb62ba084 grub.texi: Fix typo
Reported by: 	Ori Avtalion <saltyhorse>
2020-09-21 12:02:37 -04:00
Pete Batard
0f6ca5ecf9 io: add a GRUB_GZ prefix to gzio specific defines
* This is done to avoid a conflict with a PACKED define in the EDK2
2020-09-21 12:02:37 -04:00
Pete Batard
5ba09fb415 core: use GRUB_TERM_ definitions when handling term characters
* Also use hex value for GRUB_TERM_ESC as '\e' is not in the C standard and is not understood by some compilers
2020-09-21 12:02:37 -04:00
Leif Lindholm
5f294d3b9e efi: change heap allocation type to GRUB_EFI_LOADER_CODE
With upcoming changes to EDK2, allocations of type EFI_LOADER_DATA may
not return regions with execute ability. Since modules are loaded onto
the heap, change the heap allocation type to GRUB_EFI_LOADER_CODE in
order to permit execution on systems with this feature enabled.

Closes: 50420

Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org>
2020-09-21 12:02:37 -04:00
Leif Lindholm
01f3dcc70a arm64 linux loader: improve type portability
In preparation for turning this into a common loader for 32-bit and 64-bit
platforms, ensure the code will compile cleanly for either.

Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org>
2020-09-21 12:02:37 -04:00
Leif Lindholm
793b90c851 efi: Add GRUB_PE32_MAGIC definition
Add a generic GRUB_PE32_MAGIC definition for the PE 'MZ' tag and delete
the existing one in arm64/linux.h.

Update arm64 Linux loader to use this new definition.

Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org>
2020-09-21 12:02:37 -04:00
Leif Lindholm
30f13fbfa6 efi: move fdt helper library
There is nothing ARM64 (or even ARM) specific about the efi fdt helper
library, which is used for locating or overriding a firmware-provided
devicetree in a UEFI system - so move it to loader/efi for reuse.

Move the fdtload.h include file to grub/efi and update path to
efi/fdtload.h in source code referring to it.

Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org>
2020-09-21 12:02:37 -04:00
Vladimir Serbinenko
6825a1d3f1 Remove grub_efi_allocate_pages.
grub_efi_allocate_pages Essentially does 2 unrelated things:
* Allocate at fixed address.
* Allocate at any address.

To switch between 2 different functions it uses address == 0 as magic
value which is wrong as 0 is a perfectly valid fixed adress to allocate at.
2020-09-21 12:02:37 -04:00
Leif Lindholm
22619f1593 efi: refactor grub_efi_allocate_pages
Expose a new function, grub_efi_allocate_pages_real(), making it possible
to specify allocation type and memory type as supported by the UEFI
AllocatePages boot service.

Make grub_efi_allocate_pages() a consumer of the new function,
maintaining its old functionality.

Also delete some left-around #if 1/#else blocks in the affected
functions.

Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org>
2020-09-21 11:32:45 -04:00
Vladimir Serbinenko
184d71d527 Fail if xorriso failed.
If xorriso failed most likely we didn't generate a meaningful image.
2020-09-21 11:32:45 -04:00
Vladimir Serbinenko
1fd3a7f048 mkrescue: Check xorriso presence before doing anything else.
mkrescue can't do anything useful without xorriso, so abort early if it's
not available.
2020-09-21 11:32:45 -04:00
Pali Rohár
682b3134b6 * grub-core/fs/udf.c: Add support for UUID
Use same algorithm as in libblkid from util-linux v2.30.

1. Take first 16 bytes from UTF-8 encoded string of VolumeSetIdentifier
2. If all bytes are hexadecimal digits, convert to lowercase and use as UUID
3. If first 8 bytes are not all hexadecimal digits, convert those 8 bytes
   to their hexadecimal representation, resulting in 16 bytes for UUID
4. Otherwise, compose UUID from two parts:
   1. part: converted first 8 bytes (which are hexadecimal digits) to lowercase
   2. part: encoded following 4 bytes to their hexadecimal representation (16 bytes)

So UUID would always have 16 hexadecimal digits in lowercase variant.

According to UDF specification, first 16 Unicode characters of
VolumeSetIdentifier should be unique value and first 8 should be
hexadecimal characters.

In most cases all 16 characters are hexadecimal, but e.g. MS Windows
format.exe set only first 8 as hexadecimal and remaining as fixed
(non-unique) which violates specification.
2020-09-21 11:32:45 -04:00
Pali Rohár
ab444c54a7 udf: Fix reading label, lvd.ident is dstring
UDF dstring has stored length in the last byte of buffer. Therefore last
byte is not part of recorded characters. And empty string in dstring is
encoded as empty buffer, including first byte (compression id).
2020-09-21 11:32:45 -04:00
Pete Batard
e2296e205e zfs: remove size_t typedef and use grub_size_t instead
* Prevents some toolchains from issuing a warning on size_t redef.
2020-09-21 11:32:45 -04:00
Rob Clark
a74336596f Fix a segfault in lsefi
when protocols_per_handle returns error, we can't use the pointers we
passed to it, and that includes trusting num_protocols.

Signed-off-by: Peter Jones <pjones@redhat.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2020-09-21 11:32:45 -04:00
Vladimir Serbinenko
21b3d3efee fdt: silence clang warning. 2020-09-21 11:32:45 -04:00
Vladimir Serbinenko
0c4852ea0e arm-efi: Fix compilation 2020-09-21 11:32:45 -04:00
Vladimir Serbinenko
8efa8a0e94 ehci: Fix compilation on i386 2020-09-21 11:32:45 -04:00
phcoder
a4d4008588 cache: Fix compilation for ppc, sparc and arm64 2020-09-21 11:32:45 -04:00
phcoder
8d54a08733 ehci: Fix compilation for amd64 2020-09-21 11:32:45 -04:00
Eric Biggers
4aaa6b639d Allow GRUB to mount ext2/3/4 filesystems that have the encryption feature.
On such a filesystem, inodes may have EXT4_ENCRYPT_FLAG set.
For a regular file, this means its contents are encrypted; for a
directory, this means the filenames in its directory entries are
encrypted; and for a symlink, this means its target is encrypted.  Since
GRUB cannot decrypt encrypted contents or filenames, just issue an error
if it would need to do so.  This is sufficient to allow unencrypted boot
files to co-exist with encrypted files elsewhere on the filesystem.

(Note that encrypted regular files and symlinks will not normally be
encountered outside an encrypted directory; however, it's possible via
hard links, so they still need to be handled.)

Tested by booting from an ext4 /boot partition on which I had run
'tune2fs -O encrypt'.  I also verified that the expected error messages
are printed when trying to access encrypted directories, files, and
symlinks from the GRUB command line.  Also ran 'sudo ./grub-fs-tester
ext4_encrypt'; note that this requires e2fsprogs v1.43+ and Linux v4.1+.

Signed-off-by: Eric Biggers <ebiggers@google.com>
2020-09-21 11:32:45 -04:00
Eric Snowberg
da4e8334b2 sparc64: Don't use devspec to determine the OBP path
Don't use devspec to determine the OBP path on SPARC hardware.  Within all
versions of Linux on SPARC, the devspec returns one of three values:
"none", "vnet-port", or "vdisk".  Unlike on PPC, none of these values
are useful in determining the OBP path.

Before this patch grub-ofpathname always returned the wrong value
for a virtual disk. For example:

% grub-ofpathname /dev/vdiskc2
vdisk/disk@2:b

After this patch it now returns the correct value:

% grub-ofpathname /dev/vdiskc2
/virtual-devices@100/channel-devices@200/disk@2:b

Orabug: 24459765

Signed-off-by: Eric Snowberg <eric.snowberg@oracle.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2020-09-21 11:32:45 -04:00
Fu Wei
6e329bec23 arm64: Update the introduction of Xen boot commands in docs/grub.texi
delete: xen_linux, xen_initrd, xen_xsm
add: xen_module

This update bases on
    commit 0edd750e50
    Author: Vladimir Serbinenko <phcoder@gmail.com>
    Date:   Fri Jan 22 10:18:47 2016 +0100

        xen_boot: Remove obsolete module type distinctions.

Also bases on the module loading mechanism of Xen code:
488c2a8 docs/arm64: clarify the documention for loading XSM support
67831c4 docs/arm64: update the documentation for loading XSM support
ca32012 xen/arm64: check XSM Magic from the second unknown module.

Signed-off-by: Fu Wei <fu.wei@linaro.org>
Reviewed-by: Julien Grall <julien.grall@arm.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2020-09-21 11:32:45 -04:00
Fu Wei
911910089b util/grub.d/20_linux_xen.in: Add xen_boot command support for aarch64
This patch adds the support of xen_boot command for aarch64:
    xen_hypervisor
    xen_module
These two commands are only for aarch64, since it has its own protocol and
commands to boot xen hypervisor and Dom0, but not multiboot.

For other architectures, they are still using multiboot and module
commands.

Signed-off-by: Fu Wei <fu.wei@linaro.org>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2020-09-21 11:32:45 -04:00
Fu Wei
3418e2bd52 arm64: Add "--nounzip" option support in xen_module command
This patch adds "--nounzip" option support in order to
be compatible with the module command of multiboot on other architecture,
by this way we can simplify grub-mkconfig support code.

This patch also allow us to use zip compressed module(like Linux kernel
for Dom0).

Signed-off-by: Fu Wei <fu.wei@linaro.org>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2020-09-21 11:32:45 -04:00
Julien Grall
bf4d71848f arm64/xen_boot: Fix Xen boot using GRUB2 on AARCH64
Xen is currently crashing because of malformed compatible property for
the boot module. This is because the property string is not
null-terminated as requested by the ePAR spec.

Signed-off-by: Julien Grall <julien.grall@linaro.org>
Tested-by: Fu Wei <fu.wei@linaro.org>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2020-09-21 11:32:45 -04:00
Eric Snowberg
53d00ac6ef sparc64: Close cdboot ihandle
The ihandle is left open with a cd-core image.  This will cause a delay
booting grub from a virtual cdrom in a LDOM.  It will also cause problems
as Linux boots, since it expects the ihandle to be closed during init.

Orabug: 25911275

Signed-off-by: Eric Snowberg <eric.snowberg@oracle.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2020-09-21 11:32:45 -04:00
Vladimir Serbinenko
6ff34a6a81 at_keyboard: Fix falco chromebook case.
EC is slow, so we need few delays for it to toggle the bits correctly.

Command to enable clock and keyboard were not sent.
2020-09-21 11:32:45 -04:00
Julius Werner
4ffbbeca95 coreboot: Changed cbmemc to support updated console format from coreboot. 2020-09-21 11:32:45 -04:00
Vladimir Serbinenko
4ff15188e3 Missing parts of previous commit 2020-09-21 11:32:45 -04:00
Vladimir Serbinenko
366dee1f7f arm_coreboot: Add Chromebook keyboard driver. 2020-09-21 11:32:45 -04:00
Vladimir Serbinenko
aad5863e98 rk3288_spi: Add SPI driver 2020-09-21 11:32:45 -04:00
Vladimir Serbinenko
eaa55f4a23 fdtbus: Add ability to send/receive messages on parent busses. 2020-09-21 11:32:45 -04:00
Vladimir Serbinenko
212c93aa36 Fix bug on FDT nodes with compatible property 2020-09-21 11:32:45 -04:00
Vladimir Serbinenko
25a88d14dd arm_coreboot: Support EHCI. 2020-09-21 11:32:45 -04:00
Vladimir Serbinenko
56c0a46068 ehci: Split core code from PCI part.
On ARM often EHCI is present without PCI and just declared in device
tree. So splitcore from PCI part.
2020-09-21 11:32:45 -04:00
Vladimir Serbinenko
d4529d5d02 arm_coreboot: Support DMA.
This is needed to support USB and some other busses.
2020-09-21 11:32:45 -04:00
Vladimir Serbinenko
5e1a343a37 arm_coreboot: Support loading linux images. 2020-09-21 11:32:45 -04:00
Vladimir Serbinenko
f09c41cfa9 arm_coreboot: Support grub-mkstandalone. 2020-09-21 11:32:45 -04:00
Vladimir Serbinenko
f66206989f arm_coreboot: Support keyboard for vexpress. 2020-09-21 11:32:45 -04:00
Vladimir Serbinenko
7948b1a398 at_keyboard: Split protocol from controller code.
On vexpress controller is different but protocol is the same, so reuse the
code.
2020-09-21 11:32:45 -04:00
Vladimir Serbinenko
ed5c6e9385 arm-coreboot: Export FDT routines.
We need to use them from modules as well.
2020-09-21 11:32:45 -04:00
Vladimir Serbinenko
7b6c1ca1ac arm-coreboot: Support for vexpress timer. 2020-09-21 11:32:45 -04:00
Vladimir Serbinenko
1895c3806b Add support for device-tree-based drivers. 2020-09-21 11:32:45 -04:00
Vladimir Serbinenko
aa7585d04b arm-coreboot: Start new port. 2020-09-21 11:32:45 -04:00
Vladimir Serbinenko
2f061fac71 Rename uboot/datetime to dummy/datetime.
It's just a stub and is not UBoot-specific.
2020-09-21 11:32:45 -04:00