VirtualBox

Changeset 98131 in vbox for trunk


Ignore:
Timestamp:
Jan 19, 2023 9:20:54 AM (21 months ago)
Author:
vboxsync
Message:

Devices/EFI: Make EFI produce a VMBootFail event if no guest could be booted, disables the EFI Shell as a default boot option (can still be selected from the boot manager), bugref:7249

Location:
trunk/src/VBox/Devices/EFI
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/EFI/DevEFI.cpp

    r98103 r98131  
    461461}
    462462#endif /* IN_RING3 */
     463
     464
     465/**
     466 * Handles writes to the event port.
     467 *
     468 * @returns VBox status suitable for I/O port write handler.
     469 *
     470 * @param   pThisCC             The EFI state for the current context.
     471 * @param   u32                 The value being written.
     472 * @param   cb                  The size of the value.
     473 */
     474static int efiR3PortEventWrite(PDEVEFIR3 pThisCC, uint32_t u32, unsigned cb)
     475{
     476    if (cb == sizeof(uint16_t))
     477    {
     478        switch (u32)
     479        {
     480            case EFI_EVENT_TYPE_BOOT_FAILED:
     481            {
     482                /* No additional data for this event. */
     483                LogRel(("EFI: Boot failure\n"));
     484                int rc = PDMDevHlpVMSetRuntimeError(pThisCC->pDevIns, 0 /*fFlags*/, "VMBootFail",
     485                                                    N_("The VM failed to boot. This is possibly caused by not having an operating system installed or a misconfigured boot order. Maybe picking a guest OS install DVD will resolve the situation"));
     486                AssertRC(rc);
     487                break;
     488            }
     489            default:
     490                Log(("EFI: Unknown event: %#x (cb=%d)\n", u32, cb));
     491                break;
     492        }
     493    }
     494    else
     495        Log(("EFI: Invalid write size for the event port cb=%u\n", cb));
     496
     497    return VINF_SUCCESS;
     498}
    463499
    464500
     
    782818                    break;
    783819            }
     820            break;
     821        }
     822
     823        case EFI_PORT_EVENT:
     824        {
     825            rc = efiR3PortEventWrite(pThisCC, u32, cb);
    784826            break;
    785827        }
  • trunk/src/VBox/Devices/EFI/DevEFI.h

    r98103 r98131  
    123123/** @} */
    124124
    125 /** Undefined port. */
    126 #define EFI_PORT_UNDEFINED      (EFI_PORT_BASE+0x2)
     125/** EFI event signalling.
     126 * A 16-bit event identifier is written first.
     127 * It might follow a number of writes to convey additional data,
     128 * the size depends on the event identifier.
     129 */
     130#define EFI_PORT_EVENT          (EFI_PORT_BASE+0x2)
     131
     132/**
     133 * Events.
     134 */
     135typedef enum EFI_EVENT_TYPE
     136{
     137    /** Invalid event id. */
     138    EFI_EVENT_TYPE_INVALID = 0,
     139    /** Booting any guest OS failed. */
     140    EFI_EVENT_TYPE_BOOT_FAILED,
     141    /** 32bit blow up hack. */
     142    EFI_EVENT_TYPE_16_BIT_HACK = 0x7fff
     143} EFI_EVENT_TYPE;
     144
    127145
    128146/** Debug logging.
  • trunk/src/VBox/Devices/EFI/Firmware/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c

    r89983 r98131  
    1313#include <Library/Tcg2PhysicalPresenceLib.h>
    1414#include <Library/XenPlatformLib.h>
     15#ifdef VBOX
     16# include <Library/IoLib.h>
     17# include "../../../../DevEFI.h"
     18#endif
    1519
    1620
     
    15411545  // Register UEFI Shell
    15421546  //
     1547#ifndef VBOX
    15431548  PlatformRegisterFvBootOption (
    15441549    &gUefiShellFileGuid, L"EFI Internal Shell", LOAD_OPTION_ACTIVE
    15451550    );
     1551#else
     1552  /*
     1553   * Don't start the shell automatically (can still be selected from the boot manager)
     1554   * so we get into the error path when none of the boot options worked.
     1555   */
     1556  PlatformRegisterFvBootOption (
     1557    &gUefiShellFileGuid, L"EFI Internal Shell", 0
     1558    );
     1559#endif
    15461560
    15471561  RemoveStaleFvFileOptions ();
     
    17101724  UINTN                        Index;
    17111725
     1726#ifdef VBOX
     1727  IoWrite16(EFI_PORT_EVENT, EFI_EVENT_TYPE_BOOT_FAILED);
     1728#endif
     1729
    17121730  //
    17131731  // BootManagerMenu doesn't contain the correct information when return status
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette