Commit graph

398 commits

Author SHA1 Message Date
Vladimir Serbinenko
ca0a4f689a verifiers: File type for fine-grained signature-verification controlling
Let's provide file type info to the I/O layer. This way verifiers
framework and its users will be able to differentiate files and verify
only required ones.

This is preparatory patch.

Signed-off-by: Vladimir Serbinenko <phcoder@gmail.com>
Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com>
Reviewed-by: Ross Philipson <ross.philipson@oracle.com>
2018-11-09 13:25:31 +01:00
Goffredo Baroncelli
fa926cb4b4 btrfs: Make more generic the code for RAID 6 rebuilding
The original code which handles the recovery of a RAID 6 disks array
assumes that all reads are multiple of 1 << GRUB_DISK_SECTOR_BITS and it
assumes that all the I/O is done via the struct grub_diskfilter_segment.
This is not true for the btrfs code. In order to reuse the native
grub_raid6_recover() code, it is modified to not call
grub_diskfilter_read_node() directly, but to call an handler passed
as an argument.

Signed-off-by: Goffredo Baroncelli <kreijack@inwind.it>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2018-10-31 12:07:29 +01:00
Paul Menzel
d62cafcf35 ahci: Increase time-out from 10 s to 32 s
This is a cryptographically signed message in MIME format.

Date: Thu, 9 Aug 2018 07:27:35 +0200

Currently, the GRUB payload for coreboot does not detect the Western
Digital hard disk WDC WD20EARS-60M AB51 connected to the ASRock E350M1,
as that takes over ten seconds to spin up.

```
disk/ahci.c:533: port 0, err: 0
disk/ahci.c:539: port 0, err: 0
disk/ahci.c:543: port 0, err: 0
disk/ahci.c:549: port 0, offset: 120, tfd:80, CMD: 6016
disk/ahci.c:552: port 0, err: 0
disk/ahci.c:563: port 0, offset: 120, tfd:80, CMD: 6016
disk/ahci.c:566: port: 0, err: 0
disk/ahci.c:593: port 0 is busy
disk/ahci.c:621: cleaning up failed devs
```

GRUB detects the drive, when either unloading the module *ahci*, and
then loading it again, or when doing a warm reset.

As the ten second time-out is too short, increase it to 32 seconds,
used by SeaBIOS. which detects the drive successfully.

The AHCI driver in libpayload uses 30 seconds, and that time-out was
added in commit 354066e1 (libpayload: ahci: Increase timeout for
signature reading) with the description below.

> We can't read the drives signature before it's ready, i.e. spun up.
> So set the timeout to the standard 30s. Also put a notice on the
> console, so the user knows why the signature reading failed.

Signed-off-by: Paul Menzel <pmenzel@molgen.mpg.de>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2018-09-13 10:54:54 +02:00
Nicholas Vinson
a16f4a822f disk: Update grub_gpt_partentry
Rename grub_gpt_part_type to grub_gpt_part_guid and update grub_gpt_partentry
to use this type for both the partition type GUID string and the partition GUID
string entries.  This change ensures that the two GUID fields are handled more
consistently and helps to simplify the changes needed to add Linux partition
GUID support.

Signed-off-by: Nicholas Vinson <nvinson234@gmail.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2018-04-23 13:21:45 +02:00
Stefan Fritsch
566a03a623 ahci: Improve error handling
Check the error bits in the interrupt status register. According to the
AHCI 1.2 spec, "Interrupt sources that are disabled (‘0’) are still
reflected in the status registers.", so this should work even though
grub uses polling

This fixes the following problem on a Fujitsu E744 laptop:

Sometimes there is a very long delay (up to several minutes) when
booting from hard disk. It seems accessing the DVD drive (which has no
disk inserted) sometimes fails with some errors, which leads to each
access being stalled until the 20s timeout triggers. This seems to
happen when grub is trying to read filesystem/partition data.

The problem is that the command_issue bit that is checked in the loop is
only reset if the "HBA receives a FIS which clears the BSY, DRQ, and ERR
bits for the command", but the ERR bit is never cleared. Therefore
command_issue is never reset and grub waits for the timeout.

The relevant bit in our case is the Task File Error Status (TFES), which
is equivalent to the ERR bit 0 in tfd. But this patch also checks
the other error bits except for the "Interface non-fatal error status"
bit.

Signed-off-by: Stefan Fritsch <fritsch@genua.de>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2018-01-29 12:53:24 +01:00
Andrei Borzenkov
4bd4a88725 i386, x86_64, ppc: fix switch fallthrough cases with GCC7
In util/getroot and efidisk slightly modify exitsing comment to mostly
retain it but still make GCC7 compliant with respect to fall through
annotation.

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

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

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

Otherwise add FALLTHROUGH comment.

Closes: 50598
2017-04-04 19:23:55 +03:00
Andrei Borzenkov
c42cb97f08 efi: skip iPXE block device.
iPXE adds Simple File System Protocol to loaded image handle, as side
effect it also adds Block IO protocol (according to comments, to work
around some bugs in EDK2). GRUB assumes that every device with Block IO
is disk and skips network initialization entirely. But iPXE Block IO
implementation is just a stub which always fails for every operation
so cannot be used. Attempt to detect and skip such devices.

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

Closes: 50518
2017-03-14 04:14:36 +00: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
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
Colin Watson
95440b41d3 ahci, ehci: Fix typos 2016-01-16 20:37:15 +00:00
Andrei Borzenkov
e9d71db53a efidisk: fix memory leak
Found by: Coverity scan.
CID: 96644
2016-01-12 21:52:50 +03:00
Paulo Flabiano Smorigo
c899d9f42c ofdisk: add sas disks to the device list 2015-11-12 09:23:02 -02:00
Paulo Flabiano Smorigo
a50dbb743e ofdisk: add a comment about vscsi method 2015-11-10 21:20:20 -02: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
Eric Snowberg
0b72543afd ofdisk: Fix devpath freeing logic. 2015-10-26 23:03:06 +01:00
Andrei Borzenkov
c93d3e6947 cryptodisk: strip parenthesis from backing device name
Otherwise subsequent disk open fails.

Reported-By: Klemens Nanni <contact@autoboot.org>
2015-09-13 20:12:31 +03:00
Felix Zielcke
8e3d2c80ed disk/ldm, partmap/msdos.c: fix spelling error 2015-08-22 21:22:41 +02:00
Vladimir Serbinenko
72fc110d95 ahci: Ensure that bus mastering is set.
Fixes ahci_test failing on several platforms.
2015-07-28 01:51:14 +02:00
Vladimir Serbinenko
389d509df0 diskfilter: Make name a const char to fix compilation error. 2015-07-22 20:39:14 +02:00
Vladimir Serbinenko
9f27f9f691 dmraid_nvidia: Set a name to usable value to avoid null dereference.
Reported by: Andrei Borzenkov
2015-07-22 01:57:40 +02:00
Andrei Borzenkov
cd816bd236 disk/scsi: fix use after free
Found by: Coverity scan.
CID: 96713
2015-06-20 23:38:18 +03:00
Paul Menzel
f4b1b48a83 disk/ahci.c: Use defines GRUB_AHCI_HBA_PORT_CMD_SPIN_UP and GRUB_AHCI_HBA_PORT_CMD_POWER_ON
Instead of hard coding `2` and `4` use the macros defined already at the
top of the file. As a consequence, wrap the now too long line.
2015-06-12 09:43:00 +03:00
Paul Menzel
ca59c24bd0 disk/ahci.c: Add port number to port debug messages
Currently, some messages cannot be mapped to the port they belong to as
the port number is missing from the output. So add `port: n` to the
debug messages.
2015-05-31 09:26:46 +03:00
Paul Menzel
fd73b3d008 Correct spelling of *scheduled*
Run the command below

	$ git grep -l schedulded | xargs sed -i 's/schedulded/scheduled/g'

and revert the change in `ChangeLog-2015`.

Including "miscellaneous" spelling fix noted by richardvoigt@gmail.com
2015-05-30 10:05:43 +03:00
Paul Menzel
5e74a3e6df disk/ahci: Use defines GRUB_ATA_STATUS_BUSY and GRUB_ATA_STATUS_DRQ
Instead of hard coding `0x88` use the macros defined in `disk/ata.h`.
2015-05-24 21:19:01 +03:00
Andrei Borzenkov
5082ea6184 remove extra newlines in grub_util_* strings
grub_util_{info,warn,error} already add trailing newlines, so remove
them from format strings. Also trailing full stops are already added.
2015-05-13 09:47:17 +03:00
Andrei Borzenkov
7b386b7031 efidisk: move device path helpers in core for efinet 2015-05-07 20:37:16 +03:00
Andrei Borzenkov
527eeeeee6 core: add LVM RAID1 support
Closes 44534.
2015-03-19 21:30:27 +03:00
Vladimir Serbinenko
87ec3b7fa9 Don't continue to query block-size if disk doesn't have it.
Stops poluting screen with a lot of "block-size: exception -21".
2015-03-03 20:50:37 +01:00
Vladimir Serbinenko
67a6a9512a raid6: Optimize by removing division. 2015-02-26 22:07:22 +01:00
Vladimir Serbinenko
f76c98b79e dmraid_nvidia: Fix division by 0 and missing byte-swap. 2015-02-26 22:06:19 +01:00
Vladimir Serbinenko
94f701a826 crypto: restrict cipher block size to power of 2.
All current ciphers have blocks which are power of 2 and it's
unlikely to change. Other block length would be tricky to handle anyway.
This restriction allows avoiding extra divisions.
2015-02-26 22:04:40 +01:00
Vladimir Serbinenko
967e5aa591 ofdisk: Exclude floppies from scanning.
It causes similar hang as CD on at least the qemu.
2015-02-21 16:16:48 +01:00
Andrei Borzenkov
8f5ebb1245 diskfilter_make_raid: more memory leaks in failure path 2015-02-15 10:14:07 +03:00
Vladimir Serbinenko
2ae9457e6e disk/lvm: Use zalloc to ensure that segments are initialised to sane value.
Reported by: EmanueL Czirai.
2015-02-14 20:31:00 +01:00
Andrei Borzenkov
fc535b32b9 diskfilter: fix double free of lv names for mdraid
Avoid micro-optimization in grub_diskfilter_make_raid and make sure
name and fullname are independent strings. This avoids need to special
case it everywhere else.

Also fix memory leak in failure case in grub_diskfilter_make_raid.

Closes: 41582
2015-02-14 19:08:58 +03:00
Andrei Borzenkov
e27fdbd686 diskfilter: fix crash in validate_lv for mdraid arrays
Commit 750f4bacd3 put LV validation before
actual vg assignment. Make grub_diskfilter_make_raid to assign ->vg as
happens in other cases for consistency. Also clean up redundant code and add
explicit NULL lv->vg check in validate_lv.

Also fix segment validation in validate_lv; it became obvious when crash
was fixed.

Closes: 44199
2015-02-14 17:56:01 +03:00
Vladimir Serbinenko
9ee5ae1fae Document intentional fallthroughs.
Found by: Coverity scan.
2015-01-27 17:17:58 +01:00
Vladimir Serbinenko
d1130afa5f biosdisk: Add missing cast.
Found by: Coverity scan.
2015-01-24 21:50:30 +01:00
Vladimir Serbinenko
7656b72b17 disk/geli: Add missing free.
Found by: Coverity scan.
2015-01-24 21:47:51 +01:00
Vladimir Serbinenko
6f43e350ed disk/geli: Add missing seek success check.
Found by: Coverity scan.
2015-01-24 21:46:23 +01:00
Vladimir Serbinenko
f2baeb194b disk/diskfilter: Add missing lv presence check.
Found by: Coverity scan.
2015-01-24 21:44:27 +01:00
Vladimir Serbinenko
4c7337bfe9 disk/cryptodisk: Add missing error check.
Found by: Coverity scan.
2015-01-24 21:38:22 +01:00
Vladimir Serbinenko
2a8200bba8 disk/ahci: Fix device_map_range argument.
Argument is not used on x86, hence it's gone unnoticed.

Found by: Coverity scan.
2015-01-24 21:37:28 +01:00
Vladimir Serbinenko
7d97335942 disk/AFsplitter: check argument validity before doing any allocs.
This avoids possible memory leaks.

Found by: Coverity scan.
2015-01-24 21:33:30 +01:00
Vladimir Serbinenko
7d027b4d3e efidisk: Return the determined root disk even if partition is unknown. 2015-01-24 19:53:13 +01:00
Andrey Borzenkov
2f73d2733c accept also hdX as alias to native Xen disk name
To be compatible with legacy pv-grub, sort disks by increasing order of handle
value. This allows reusing legacy pv-grub menu.lst which is using hdX names.

Suggested-By: Michael Chang <mchang@suse.com>
Closes: 44026
2015-01-23 19:52:45 +03:00
Vladimir Serbinenko
750f4bacd3 * grub-core/disk/diskfilter.c: Validate volumes to avoid division by zero. 2015-01-21 17:42:13 +01:00
Vladimir Serbinenko
4200ad44fe * grub-core/disk/i386/pc/biosdisk.c: Check disk size sanity. 2015-01-21 17:42:12 +01:00