-
Notifications
You must be signed in to change notification settings - Fork 5
feat(vm): surface the “No bootable device” error in the VM #2183
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
eofff
wants to merge
27
commits into
main
Choose a base branch
from
chore/vm/bootable-experiments
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
3fb72b5
t
cb432a9
t2
cea35eb
patch
69019f4
t
6a07e70
patch new
820b2cd
t
d0d8884
prerefactor
a281afe
build files refactoring
79b9398
403
1dcbad0
seabios patch
5758e5a
bios2
2641372
try patch
c3bd6c5
try patch 2
5752f2d
try patch 3
b6627b3
pppatch
a5d5ee7
patch))))
db8a024
pppatch
0325af5
patch
dace647
move
195a750
correct applying
06c8291
p
a475cd3
fix patch
1b0b2f4
qmp
5228d6e
d
46999e0
fix rebase
b06add2
up
0e8cfc5
param
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
images/edk2/patches/001-debug-device-no-bootable-device-message.patch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| diff --git a/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c b/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c | ||
| index d9f61757cf..d2a0e5f6a1 100644 | ||
| --- a/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c | ||
| +++ b/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c | ||
| @@ -2020,6 +2020,14 @@ PlatformBootManagerUnableToBoot ( | ||
| EFI_BOOT_MANAGER_LOAD_OPTION BootManagerMenu; | ||
| UINTN Index; | ||
|
|
||
| + { | ||
| + STATIC CONST CHAR8 Msg[] = "No bootable device.\r\n"; | ||
| + UINTN i; | ||
| + for (i = 0; i < sizeof (Msg) - 1; i++) { | ||
| + IoWrite8 (0x403, (UINT8)Msg[i]); | ||
| + } | ||
| + } | ||
| + | ||
| if (FeaturePcdGet (PcdBootRestrictToFirmware)) { | ||
| AsciiPrint ( | ||
| "%a: No bootable option was found.\n", | ||
| diff --git a/ShellPkg/Application/Shell/Shell.c b/ShellPkg/Application/Shell/Shell.c | ||
| index 9bacf9d8c7..ea78559516 100644 | ||
| --- a/ShellPkg/Application/Shell/Shell.c | ||
| +++ b/ShellPkg/Application/Shell/Shell.c | ||
| @@ -359,6 +359,14 @@ UefiMain ( | ||
| EFI_SIMPLE_TEXT_INPUT_PROTOCOL *OldConIn; | ||
| SPLIT_LIST *Split; | ||
|
|
||
| + { | ||
| + STATIC CONST CHAR8 Msg[] = "No bootable device.\r\n"; | ||
| + UINTN i; | ||
| + for (i = 0; i < sizeof (Msg) - 1; i++) { | ||
| + IoWrite8 (0x403, (UINT8)Msg[i]); | ||
| + } | ||
| + } | ||
| + | ||
| if (PcdGet8 (PcdShellSupportLevel) > 3) { | ||
| return (EFI_UNSUPPORTED); | ||
| } | ||
| diff --git a/ShellPkg/Application/Shell/Shell.h b/ShellPkg/Application/Shell/Shell.h | ||
| index 89b4ac6b02..cd82e6f608 100644 | ||
| --- a/ShellPkg/Application/Shell/Shell.h | ||
| +++ b/ShellPkg/Application/Shell/Shell.h | ||
| @@ -42,6 +42,7 @@ | ||
| #include <Library/HandleParsingLib.h> | ||
| #include <Library/FileHandleLib.h> | ||
| #include <Library/UefiHiiServicesLib.h> | ||
| +#include <Library/IoLib.h> | ||
|
|
||
| #include "ShellParametersProtocol.h" | ||
| #include "ShellProtocol.h" | ||
| diff --git a/ShellPkg/Application/Shell/Shell.inf b/ShellPkg/Application/Shell/Shell.inf | ||
| index f1e41de133..88b033bc35 100644 | ||
| --- a/ShellPkg/Application/Shell/Shell.inf | ||
| +++ b/ShellPkg/Application/Shell/Shell.inf | ||
| @@ -66,6 +66,7 @@ | ||
| SortLib | ||
| HandleParsingLib | ||
| UefiHiiServicesLib | ||
| + IoLib | ||
|
|
||
| [Guids] | ||
| gShellVariableGuid ## SOMETIMES_CONSUMES ## GUID |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| # 001-isa-debug-port-no-bootable-device-message.patch | ||
| If an EFI “No bootable device” error occurs, or the system drops into the EFI shell, output “No bootable device.” to the debug device at address 0x403. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,132 @@ | ||
| diff --git a/hw/char/debugcon.c b/hw/char/debugcon.c | ||
| index fdb04fe..0cf2325 100644 | ||
| --- a/hw/char/debugcon.c | ||
| +++ b/hw/char/debugcon.c | ||
| @@ -26,6 +26,7 @@ | ||
|
|
||
| #include "qemu/osdep.h" | ||
| #include "qapi/error.h" | ||
| +#include "qapi/qapi-events-control.h" | ||
| #include "qemu/module.h" | ||
| #include "chardev/char-fe.h" | ||
| #include "hw/isa/isa.h" | ||
| @@ -34,6 +35,7 @@ | ||
| #include "qom/object.h" | ||
|
|
||
| #define TYPE_ISA_DEBUGCON_DEVICE "isa-debugcon" | ||
| +#define DEBUGCON_NO_BOOTABLE_DEVICE "No bootable device." | ||
| OBJECT_DECLARE_SIMPLE_TYPE(ISADebugconState, ISA_DEBUGCON_DEVICE) | ||
|
|
||
| //#define DEBUG_DEBUGCON | ||
| @@ -42,6 +44,9 @@ typedef struct DebugconState { | ||
| MemoryRegion io; | ||
| CharBackend chr; | ||
| uint32_t readback; | ||
| + bool watch_no_bootable_device; | ||
| + char match_buf[sizeof(DEBUGCON_NO_BOOTABLE_DEVICE) - 1]; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It seems there is no need to decrease size for buf length, |
||
| + size_t match_len; | ||
| } DebugconState; | ||
|
|
||
| struct ISADebugconState { | ||
| @@ -51,6 +56,27 @@ struct ISADebugconState { | ||
| DebugconState state; | ||
| }; | ||
|
|
||
| +static void debugcon_maybe_emit_no_bootable_device(DebugconState *s, | ||
| + unsigned char ch) | ||
| +{ | ||
| + if (!s->watch_no_bootable_device) { | ||
| + return; | ||
| + } | ||
| + | ||
| + if (s->match_len < sizeof(s->match_buf)) { | ||
| + s->match_buf[s->match_len++] = ch; | ||
| + } else { | ||
| + memmove(s->match_buf, s->match_buf + 1, sizeof(s->match_buf) - 1); | ||
| + s->match_buf[sizeof(s->match_buf) - 1] = ch; | ||
| + } | ||
| + | ||
| + if (s->match_len == sizeof(s->match_buf) && | ||
| + memcmp(s->match_buf, DEBUGCON_NO_BOOTABLE_DEVICE, | ||
| + sizeof(s->match_buf)) == 0) { | ||
| + qapi_event_send_no_bootable_device(); | ||
| + } | ||
| +} | ||
| + | ||
| static void debugcon_ioport_write(void *opaque, hwaddr addr, uint64_t val, | ||
| unsigned width) | ||
| { | ||
| @@ -64,6 +90,7 @@ static void debugcon_ioport_write(void *opaque, hwaddr addr, uint64_t val, | ||
| /* XXX this blocks entire thread. Rewrite to use | ||
| * qemu_chr_fe_write and background I/O callbacks */ | ||
| qemu_chr_fe_write_all(&s->chr, &ch, 1); | ||
| + debugcon_maybe_emit_no_bootable_device(s, ch); | ||
| } | ||
|
|
||
|
|
||
| @@ -118,6 +145,8 @@ static Property debugcon_isa_properties[] = { | ||
| DEFINE_PROP_UINT32("iobase", ISADebugconState, iobase, 0xe9), | ||
| DEFINE_PROP_CHR("chardev", ISADebugconState, state.chr), | ||
| DEFINE_PROP_UINT32("readback", ISADebugconState, state.readback, 0xe9), | ||
| + DEFINE_PROP_BOOL("watch-no-bootable", ISADebugconState, | ||
| + state.watch_no_bootable_device, false), | ||
| DEFINE_PROP_END_OF_LIST(), | ||
| }; | ||
|
|
||
| diff --git a/qapi/control.json b/qapi/control.json | ||
| index 336386f..e1e727e 100644 | ||
| --- a/qapi/control.json | ||
| +++ b/qapi/control.json | ||
| @@ -209,3 +209,13 @@ | ||
| '*pretty': 'bool', | ||
| 'chardev': 'str' | ||
| } } | ||
| + | ||
| +## | ||
| +# @NO_BOOTABLE_DEVICE: | ||
| +# | ||
| +# Emitted when `isa-debugcon` with enabled no-bootable watching | ||
| +# receives the string "No bootable device.". | ||
| +# | ||
| +# Since: 0.14 | ||
| +## | ||
| +{ 'event': 'NO_BOOTABLE_DEVICE' } | ||
| diff --git a/tests/qtest/qmp-test.c b/tests/qtest/qmp-test.c | ||
| index 22957fa..9b4840e 100644 | ||
| --- a/tests/qtest/qmp-test.c | ||
| +++ b/tests/qtest/qmp-test.c | ||
| @@ -337,6 +337,25 @@ static void test_qmp_missing_any_arg(void) | ||
| qtest_quit(qts); | ||
| } | ||
|
|
||
| +static void test_qmp_no_bootable_device_event(void) | ||
| +{ | ||
| + static const char trigger[] = "No bootable device."; | ||
| + QTestState *qts; | ||
| + size_t i; | ||
| + | ||
| + qts = qtest_initf("-nodefaults -machine q35 " | ||
| + "-chardev null,id=debugcon " | ||
| + "-device isa-debugcon,iobase=0x402,chardev=debugcon," | ||
| + "watch-no-bootable=on"); | ||
| + | ||
| + for (i = 0; i < sizeof(trigger) - 1; i++) { | ||
| + qtest_outb(qts, 0x402, trigger[i]); | ||
| + } | ||
| + | ||
| + qtest_qmp_eventwait(qts, "NO_BOOTABLE_DEVICE"); | ||
| + qtest_quit(qts); | ||
| +} | ||
| + | ||
| int main(int argc, char *argv[]) | ||
| { | ||
| g_test_init(&argc, &argv, NULL); | ||
| @@ -348,6 +367,8 @@ int main(int argc, char *argv[]) | ||
| #endif | ||
| qtest_add_func("qmp/preconfig", test_qmp_preconfig); | ||
| qtest_add_func("qmp/missing-any-arg", test_qmp_missing_any_arg); | ||
| + qtest_add_func("qmp/no-bootable-device-event", | ||
| + test_qmp_no_bootable_device_event); | ||
|
|
||
| return g_test_run(); | ||
| } | ||
13 changes: 13 additions & 0 deletions
13
images/qemu/patches/seabios/001-alt-skip-flags-when-parse-objdump-section.patch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| diff --git a/scripts/layoutrom.py b/scripts/layoutrom.py | ||
| index 6616721..4f655dc 100755 | ||
| --- a/scripts/layoutrom.py | ||
| +++ b/scripts/layoutrom.py | ||
| @@ -564,7 +564,7 @@ def parseObjDump(file, fileid): | ||
|
|
||
| if state == 'section': | ||
| try: | ||
| - idx, name, size, vma, lma, fileoff, align = line.split() | ||
| + idx, name, size, vma, lma, fileoff, align, *_flags = line.split() | ||
| if align[:3] != '2**': | ||
| continue | ||
| section = Section() |
38 changes: 38 additions & 0 deletions
38
images/qemu/patches/seabios/002-0x403-debug-port-no-bootable-device-message.patch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| diff --git a/src/boot.c b/src/boot.c | ||
| index 1effd80..ec5992f 100644 | ||
| --- a/src/boot.c | ||
| +++ b/src/boot.c | ||
| @@ -21,6 +21,7 @@ | ||
| #include "string.h" // memset | ||
| #include "util.h" // irqtimer_calc | ||
| #include "tcgbios.h" // tpm_* | ||
| +#include "x86.h" // outb | ||
|
|
||
| /**************************************************************** | ||
| * Helper search functions | ||
| @@ -960,12 +961,23 @@ boot_rom(u32 vector) | ||
| } | ||
|
|
||
| // Unable to find bootable device - warn user and eventually retry. | ||
| +static void | ||
| +write_port_403(const char *s) | ||
| +{ | ||
| + if (!CONFIG_DEBUG_IO || !runningOnQEMU()) | ||
| + return; | ||
| + | ||
| + for (; *s; s++) | ||
| + outb(*s, 0x403); | ||
| +} | ||
| + | ||
| static void | ||
| boot_fail(void) | ||
| { | ||
| - if (BootRetryTime == (u32)-1) | ||
| + if (BootRetryTime == (u32)-1) { | ||
| printf("No bootable device.\n"); | ||
| - else | ||
| + write_port_403("No bootable device.\n"); | ||
| + } else | ||
| printf("No bootable device. Retrying in %d seconds.\n" | ||
| , BootRetryTime/1000); | ||
| // Wait for 'BootRetryTime' milliseconds and then reboot. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| # Patches | ||
|
|
||
| ## 001-alt-skip-flags-when-parse-objdump-section.patch | ||
|
|
||
| This patch makes `scripts/layoutrom.py` tolerate extra flags in `objdump` | ||
| section output. | ||
|
|
||
| ## 002-0x403-debug-port-no-bootable-device-message.patch | ||
|
|
||
| If SeaBIOS cannot find a bootable device on QEMU, this patch also outputs | ||
| `No bootable device.` to the debug device at address `0x403`. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For consistency with other images.