grub/grub-core
Paul Menzel d3a3543a56 normal/menu: Do not treat error values as key presses
Some terminals, like `grub-core/term/at_keyboard.c`, return `-1` in case
they are not ready yet.

      if (! KEYBOARD_ISREADY (grub_inb (KEYBOARD_REG_STATUS)))
        return -1;

Currently, that is treated as a key press, and the menu time-out is
cancelled/cleared. This is unwanted, as the boot is stopped and the user
manually has to select a menu entry. Therefore, adapt the condition to
require the key value also to be greater than 0.

`GRUB_TERM_NO_KEY` is defined as 0, so the condition could be collapsed
to greater or equal than (≥) 0, but the compiler will probably do that
for us anyway, so keep the cases separate for clarity.

This is tested with coreboot, the GRUB default payload, and the
configuration file `grub.cfg` below.

For GRUB:

    $ ./autogen.sh
    $ ./configure --with-platform=coreboot
    $ make -j`nproc`
    $ make default_payload.elf

For coreboot:

    $ more grub.cfg
    serial --unit 0 --speed 115200
    set timeout=5

    menuentry 'halt' {
        halt
    }
    $ build/cbfstool build/coreboot.rom add-payload \
        -f /dev/shm/grub/default_payload.elf -n fallback/payload -c lzma
    $ build/cbfstool build/coreboot.rom add -f grub.cfg -n etc/grub.cfg -t raw
    $ qemu-system-x86_64 --version
    QEMU emulator version 3.1.0 (Debian 1:3.1+dfsg-2+b1)
    Copyright (c) 2003-2018 Fabrice Bellard and the QEMU Project developers
    $ qemu-system-x86_64 -M pc -bios build/coreboot.rom -serial stdio -nic none

Currently, the time-out is cancelled/cleared. With the commit, it is not.
With a small GRUB payload, this the problem is also reproducible on the
ASRock E350M1.

Link: http://lists.gnu.org/archive/html/grub-devel/2019-01/msg00037.html

Signed-off-by: Paul Menzel <pmenzel@molgen.mpg.de>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
2019-02-25 14:02:06 +01:00
..
boot diskboot: Trivial correction on stale comments 2018-04-23 13:04:58 +02:00
bus ehci: Fix compilation on i386 2017-07-09 21:31:19 +02:00
commands fdt: Treat device tree file type like ACPI 2019-02-25 14:02:06 +01:00
disk uboot: Add the missing disk write operation support 2019-01-22 15:23:51 +01:00
efiemu verifiers: File type for fine-grained signature-verification controlling 2018-11-09 13:25:31 +01:00
font verifiers: File type for fine-grained signature-verification controlling 2018-11-09 13:25:31 +01:00
fs btrfs: Add zstd support to grub btrfs 2018-11-26 23:10:11 +01:00
gdb i386, x86_64, ppc: fix switch fallthrough cases with GCC7 2017-04-04 19:23:55 +03:00
gettext verifiers: File type for fine-grained signature-verification controlling 2018-11-09 13:25:31 +01:00
gfxmenu verifiers: File type for fine-grained signature-verification controlling 2018-11-09 13:25:31 +01:00
gnulib i386, x86_64, ppc: fix switch fallthrough cases with GCC7 2017-04-04 19:23:55 +03:00
hello * grub-core/commands/gptsync.c: Fix typographic quoting. 2012-03-03 13:05:08 +01:00
hook * grub-core/hook/datehook.c (grub_read_hook_datetime): Small stylistic 2011-11-11 21:03:49 +01:00
io verifiers: File type for fine-grained signature-verification controlling 2018-11-09 13:25:31 +01:00
kern RISC-V: Add to build system 2019-02-25 14:02:05 +01:00
lib RISC-V: Add to build system 2019-02-25 14:02:05 +01:00
loader RISC-V: Add Linux load logic 2019-02-25 11:33:06 +01:00
mmap xen: Prepare common code for Xen PVH support 2018-12-12 12:03:27 +01:00
net ofnet: Fix build regression in grub_ieee1275_parse_bootpath() 2018-11-28 13:48:45 +01:00
normal normal/menu: Do not treat error values as key presses 2019-02-25 14:02:06 +01:00
osdep generic/blocklist: Fix implicit declaration of function grub_file_filter_disable_compression() 2018-11-21 14:45:33 +01:00
partmap msdos: Fix overflow in converting partition start and length into 512B blocks 2018-09-27 14:56:45 +02:00
parttool * grub-core/net/http.c: Add TRANSLATORS comments. 2012-03-05 16:42:26 +01:00
script verifiers: Verify commands executed by grub 2018-12-12 13:17:52 +01:00
term efi/console: Fix the "enter" key not working on x86 tablets 2018-07-11 11:53:28 +02:00
tests Regenerate checksum.h with newer unifont. 2017-08-30 17:12:04 +02:00
video verifiers: File type for fine-grained signature-verification controlling 2018-11-09 13:25:31 +01:00
gdb_grub.in * grub-core/gdb_grub.in: Fix overflow and wrong field. 2013-10-14 03:40:20 +02:00
genemuinit.sh use MODULE_FILES for genemuinit* instead of MOD_FILES 2014-01-18 23:15:40 +04:00
genemuinitheader.sh use MODULE_FILES for genemuinit* instead of MOD_FILES 2014-01-18 23:15:40 +04:00
genmod.sh.in .mod files: Strip annobin annotations and .eh_frame, and their relocations 2018-03-05 14:08:22 +01:00
genmoddep.awk enforcing fixup 2017-08-14 16:27:10 +02:00
gensyminfo.sh.in Fix shebang for termux. 2017-05-03 12:49:31 +02:00
gensymlist.sh Make 'make check' work on emu. 2013-04-27 02:00:16 +02:00
gentrigtables.c * grub-core/gentrigtables.c: Make tables const. 2013-03-01 11:15:09 +01:00
gmodule.pl.in * grub-core/gmodule.pl.in: Accept newer binutils which output 2014-09-21 18:23:23 +02:00
gnulib-fix-gcc7-fallthrough.diff Add gnulib-fix-gcc7-fallthrough.diff 2017-04-04 19:37:47 +03:00
gnulib-fix-null-deref.diff Import new gnulib. 2013-04-11 21:12:46 +02:00
gnulib-fix-width.diff Import new gnulib. 2013-04-11 21:12:46 +02:00
gnulib-no-abort.diff Import new gnulib. 2013-04-11 21:12:46 +02:00
gnulib-no-gets.diff Import new gnulib. 2013-04-11 21:12:46 +02:00
Makefile.am RISC-V: Add to build system 2019-02-25 14:02:05 +01:00
Makefile.core.def RISC-V: Add to build system 2019-02-25 14:02:05 +01:00
modinfo.sh.in Fix shebang for termux. 2017-05-03 12:49:31 +02:00