Blame SOURCES/0019-OvmfPkg-PlatformBootManagerLib-connect-consoles-unco.patch

cc9195
From fca819227b23a4d0597e3da42d7edce1da8fb0f4 Mon Sep 17 00:00:00 2001
cc9195
From: Laszlo Ersek <lersek@redhat.com>
cc9195
Date: Tue, 15 May 2018 12:40:05 +0200
cc9195
Subject: OvmfPkg/PlatformBootManagerLib: connect consoles unconditionally
cc9195
cc9195
Notes about the RHEL-7.6/ovmf-20180508-2.gitee3198e672e2.el7 ->
cc9195
RHEL-8.0/20180508-ee3198e672e2 rebase:
cc9195
cc9195
- reorder the rebase changelog in the commit message so that it reads like
cc9195
  a blog: place more recent entries near the top
cc9195
- no changes to the patch body
cc9195
cc9195
Message-id: <20180515104005.12265-2-lersek@redhat.com>
cc9195
Patchwork-id: 80268
cc9195
O-Subject:  [RHEL-7.6 ovmf PATCH 1/1] OvmfPkg/PlatformBootManagerLib: connect
cc9195
	consoles unconditionally
cc9195
Bugzilla: 1577546
cc9195
Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
cc9195
Acked-by: Vitaly Kuznetsov <vkuznets@redhat.com>
cc9195
cc9195
If both ConIn and ConOut exist, but ConIn references none of the PS/2
cc9195
keyboard, the USB wild-card keyboard, and any serial ports, then
cc9195
PlatformInitializeConsole() currently allows the boot to proceed without
cc9195
any input devices at all. This makes for a bad user experience -- the
cc9195
firmware menu could only be entered through OsIndications, set by a guest
cc9195
OS.
cc9195
cc9195
Do what ArmVirtQemu does already, namely connect the consoles, and add
cc9195
them to ConIn / ConOut / ErrOut, unconditionally. (The underlying
cc9195
EfiBootManagerUpdateConsoleVariable() function checks for duplicates.)
cc9195
cc9195
The issue used to be masked by the EfiBootManagerConnectAll() call that
cc9195
got conditionalized in commit 245c643cc8b7.
cc9195
cc9195
This patch is best viewed with "git show -b -W".
cc9195
cc9195
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
cc9195
Cc: Jordan Justen <jordan.l.justen@intel.com>
cc9195
Fixes: 245c643cc8b73240c3b88cb55b2911b285a8c10d
cc9195
Ref: https://bugzilla.redhat.com/show_bug.cgi?id=1577546
cc9195
Contributed-under: TianoCore Contribution Agreement 1.1
cc9195
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
cc9195
Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
cc9195
(cherry picked from commit f803c03cc2e0b6b0b0bed447a97ea2c61b04ed82)
cc9195
(cherry picked from commit 3e05bfc48cd7b2cf4c1cbfc1d0cd2572338fad1e)
cc9195
---
cc9195
 .../Library/PlatformBootManagerLib/BdsPlatform.c   | 127 +++++++--------------
cc9195
 1 file changed, 44 insertions(+), 83 deletions(-)
cc9195
cc9195
diff --git a/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c b/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c
cc9195
index 862fa6eb..004b753 100644
cc9195
--- a/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c
cc9195
+++ b/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c
cc9195
@@ -26,7 +26,6 @@ VOID          *mEfiDevPathNotifyReg;
cc9195
 EFI_EVENT     mEfiDevPathEvent;
cc9195
 VOID          *mEmuVariableEventReg;
cc9195
 EFI_EVENT     mEmuVariableEvent;
cc9195
-BOOLEAN       mDetectVgaOnly;
cc9195
 UINT16        mHostBridgeDevId;
cc9195
 
cc9195
 //
cc9195
@@ -830,35 +829,33 @@ DetectAndPreparePlatformPciDevicePath (
cc9195
     );
cc9195
   ASSERT_EFI_ERROR (Status);
cc9195
 
cc9195
-  if (!mDetectVgaOnly) {
cc9195
+  //
cc9195
+  // Here we decide whether it is LPC Bridge
cc9195
+  //
cc9195
+  if ((IS_PCI_LPC (Pci)) ||
cc9195
+      ((IS_PCI_ISA_PDECODE (Pci)) &&
cc9195
+       (Pci->Hdr.VendorId == 0x8086) &&
cc9195
+       (Pci->Hdr.DeviceId == 0x7000)
cc9195
+      )
cc9195
+     ) {
cc9195
     //
cc9195
-    // Here we decide whether it is LPC Bridge
cc9195
+    // Add IsaKeyboard to ConIn,
cc9195
+    // add IsaSerial to ConOut, ConIn, ErrOut
cc9195
     //
cc9195
-    if ((IS_PCI_LPC (Pci)) ||
cc9195
-        ((IS_PCI_ISA_PDECODE (Pci)) &&
cc9195
-         (Pci->Hdr.VendorId == 0x8086) &&
cc9195
-         (Pci->Hdr.DeviceId == 0x7000)
cc9195
-        )
cc9195
-       ) {
cc9195
-      //
cc9195
-      // Add IsaKeyboard to ConIn,
cc9195
-      // add IsaSerial to ConOut, ConIn, ErrOut
cc9195
-      //
cc9195
-      DEBUG ((EFI_D_INFO, "Found LPC Bridge device\n"));
cc9195
-      PrepareLpcBridgeDevicePath (Handle);
cc9195
-      return EFI_SUCCESS;
cc9195
-    }
cc9195
+    DEBUG ((EFI_D_INFO, "Found LPC Bridge device\n"));
cc9195
+    PrepareLpcBridgeDevicePath (Handle);
cc9195
+    return EFI_SUCCESS;
cc9195
+  }
cc9195
+  //
cc9195
+  // Here we decide which Serial device to enable in PCI bus
cc9195
+  //
cc9195
+  if (IS_PCI_16550SERIAL (Pci)) {
cc9195
     //
cc9195
-    // Here we decide which Serial device to enable in PCI bus
cc9195
+    // Add them to ConOut, ConIn, ErrOut.
cc9195
     //
cc9195
-    if (IS_PCI_16550SERIAL (Pci)) {
cc9195
-      //
cc9195
-      // Add them to ConOut, ConIn, ErrOut.
cc9195
-      //
cc9195
-      DEBUG ((EFI_D_INFO, "Found PCI 16550 SERIAL device\n"));
cc9195
-      PreparePciSerialDevicePath (Handle);
cc9195
-      return EFI_SUCCESS;
cc9195
-    }
cc9195
+    DEBUG ((EFI_D_INFO, "Found PCI 16550 SERIAL device\n"));
cc9195
+    PreparePciSerialDevicePath (Handle);
cc9195
+    return EFI_SUCCESS;
cc9195
   }
cc9195
 
cc9195
   //
cc9195
@@ -878,26 +875,6 @@ DetectAndPreparePlatformPciDevicePath (
cc9195
 
cc9195
 
cc9195
 /**
cc9195
-  Do platform specific PCI Device check and add them to ConOut, ConIn, ErrOut
cc9195
-
cc9195
-  @param[in]  DetectVgaOnly - Only detect VGA device if it's TRUE.
cc9195
-
cc9195
-  @retval EFI_SUCCESS - PCI Device check and Console variable update
cc9195
-                        successfully.
cc9195
-  @retval EFI_STATUS - PCI Device check or Console variable update fail.
cc9195
-
cc9195
-**/
cc9195
-EFI_STATUS
cc9195
-DetectAndPreparePlatformPciDevicePaths (
cc9195
-  BOOLEAN DetectVgaOnly
cc9195
-  )
cc9195
-{
cc9195
-  mDetectVgaOnly = DetectVgaOnly;
cc9195
-  return VisitAllPciInstances (DetectAndPreparePlatformPciDevicePath);
cc9195
-}
cc9195
-
cc9195
-
cc9195
-/**
cc9195
   Connect the predefined platform default console device.
cc9195
 
cc9195
   Always try to find and enable PCI display devices.
cc9195
@@ -910,50 +887,34 @@ PlatformInitializeConsole (
cc9195
   )
cc9195
 {
cc9195
   UINTN                              Index;
cc9195
-  EFI_DEVICE_PATH_PROTOCOL           *VarConout;
cc9195
-  EFI_DEVICE_PATH_PROTOCOL           *VarConin;
cc9195
 
cc9195
   //
cc9195
-  // Connect RootBridge
cc9195
+  // Do platform specific PCI Device check and add them to ConOut, ConIn,
cc9195
+  // ErrOut
cc9195
   //
cc9195
-  GetEfiGlobalVariable2 (EFI_CON_OUT_VARIABLE_NAME, (VOID **) &VarConout,
cc9195
-    NULL);
cc9195
-  GetEfiGlobalVariable2 (EFI_CON_IN_VARIABLE_NAME, (VOID **) &VarConin, NULL);
cc9195
-
cc9195
-  if (VarConout == NULL || VarConin == NULL) {
cc9195
-    //
cc9195
-    // Do platform specific PCI Device check and add them to ConOut, ConIn,
cc9195
-    // ErrOut
cc9195
-    //
cc9195
-    DetectAndPreparePlatformPciDevicePaths (FALSE);
cc9195
+  VisitAllPciInstances (DetectAndPreparePlatformPciDevicePath);
cc9195
 
cc9195
+  //
cc9195
+  // Have chance to connect the platform default console,
cc9195
+  // the platform default console is the minimum device group
cc9195
+  // the platform should support
cc9195
+  //
cc9195
+  for (Index = 0; PlatformConsole[Index].DevicePath != NULL; ++Index) {
cc9195
     //
cc9195
-    // Have chance to connect the platform default console,
cc9195
-    // the platform default console is the minimum device group
cc9195
-    // the platform should support
cc9195
+    // Update the console variable with the connect type
cc9195
     //
cc9195
-    for (Index = 0; PlatformConsole[Index].DevicePath != NULL; ++Index) {
cc9195
-      //
cc9195
-      // Update the console variable with the connect type
cc9195
-      //
cc9195
-      if ((PlatformConsole[Index].ConnectType & CONSOLE_IN) == CONSOLE_IN) {
cc9195
-        EfiBootManagerUpdateConsoleVariable (ConIn,
cc9195
-          PlatformConsole[Index].DevicePath, NULL);
cc9195
-      }
cc9195
-      if ((PlatformConsole[Index].ConnectType & CONSOLE_OUT) == CONSOLE_OUT) {
cc9195
-        EfiBootManagerUpdateConsoleVariable (ConOut,
cc9195
-          PlatformConsole[Index].DevicePath, NULL);
cc9195
-      }
cc9195
-      if ((PlatformConsole[Index].ConnectType & STD_ERROR) == STD_ERROR) {
cc9195
-        EfiBootManagerUpdateConsoleVariable (ErrOut,
cc9195
-          PlatformConsole[Index].DevicePath, NULL);
cc9195
-      }
cc9195
+    if ((PlatformConsole[Index].ConnectType & CONSOLE_IN) == CONSOLE_IN) {
cc9195
+      EfiBootManagerUpdateConsoleVariable (ConIn,
cc9195
+        PlatformConsole[Index].DevicePath, NULL);
cc9195
+    }
cc9195
+    if ((PlatformConsole[Index].ConnectType & CONSOLE_OUT) == CONSOLE_OUT) {
cc9195
+      EfiBootManagerUpdateConsoleVariable (ConOut,
cc9195
+        PlatformConsole[Index].DevicePath, NULL);
cc9195
+    }
cc9195
+    if ((PlatformConsole[Index].ConnectType & STD_ERROR) == STD_ERROR) {
cc9195
+      EfiBootManagerUpdateConsoleVariable (ErrOut,
cc9195
+        PlatformConsole[Index].DevicePath, NULL);
cc9195
     }
cc9195
-  } else {
cc9195
-    //
cc9195
-    // Only detect VGA device and add them to ConOut
cc9195
-    //
cc9195
-    DetectAndPreparePlatformPciDevicePaths (TRUE);
cc9195
   }
cc9195
 }
cc9195
 
cc9195
-- 
cc9195
1.8.3.1
cc9195