]> git.proxmox.com Git - mirror_edk2.git/commitdiff
OvmfPkg/QemuVideoDxe/VbeShim: handle PAM1 register on Q35 correctly
authorLaszlo Ersek <lersek@redhat.com>
Tue, 19 Sep 2017 15:05:08 +0000 (17:05 +0200)
committerLaszlo Ersek <lersek@redhat.com>
Wed, 20 Sep 2017 18:25:19 +0000 (20:25 +0200)
In commit db27e9f3d8f0 ("OvmfPkg/LegacyRegion: Support legacy region
manipulation of Q35", 2016-03-15), Ray extended the
OvmfPkg/Csm/CsmSupportLib PAM register manipulation to Q35. However, we
missed that the same should be done to the QemuVideoDxe VBE Shim as well.

The omission has caused no problems in practice on Q35, because QEMU has
let us write to the ROM area, regardless of the PAM1 setting, all this
time. This has now changed with recent QEMU commit 208fa0e43645 ("pc: make
'pc.rom' readonly when machine has PCI enabled", 2017-07-28). The QEMU
commit exposes the OVMF bug when Windows 7 is started on Q35, using QEMU
2.10 -- the VBE Shim is no longer put in place and Windows 7 cannot find
it.

To remedy this, assign the "Pam1Address" local variable a PciLib address
that matches the board type (i440fx vs. q35).

Regarding the PcdLib dependency: QemuVideoDxe already uses PcdLib, both
directly (see "PcdDriverSupportedEfiVersion") and indirectly (e.g. via the
DxePciLibI440FxQ35 PciLib instance). Add PcdLib to [LibraryClasses] for
completeness.

Cc: Aleksei Kovura <alex3kov@zoho.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Igor Mammedov <imammedo@redhat.com>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Ref: https://bugs.launchpad.net/qemu/+bug/1715700
Reported-by: Aleksei Kovura <alex3kov@zoho.com>
Special-thanks-to: Gerd Hoffmann <kraxel@redhat.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Tested-by: Aleksei Kovura <alex3kov@zoho.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
OvmfPkg/QemuVideoDxe/QemuVideoDxe.inf
OvmfPkg/QemuVideoDxe/VbeShim.c

index 7c7d429bca274a8a08d3fc43a05701e185759e05..577e07b0a8bf577d851eacda8b5d326d7fc31901 100644 (file)
@@ -60,6 +60,7 @@
   DebugLib\r
   DevicePathLib\r
   MemoryAllocationLib\r
+  PcdLib\r
   PciLib\r
   PrintLib\r
   TimerLib\r
@@ -75,4 +76,4 @@
 \r
 [Pcd]\r
   gOptionRomPkgTokenSpaceGuid.PcdDriverSupportedEfiVersion\r
-\r
+  gUefiOvmfPkgTokenSpaceGuid.PcdOvmfHostBridgePciDevId\r
index bc90e067266de5e867764a93ed4f6ab9175b6827..e45a08e8873f15cdf366b0b4a537e6b579460392 100644 (file)
@@ -25,6 +25,7 @@
 #include <Library/DebugLib.h>\r
 #include <Library/PciLib.h>\r
 #include <Library/PrintLib.h>\r
+#include <OvmfPlatforms.h>\r
 \r
 #include "Qemu.h"\r
 #include "VbeShim.h"\r
@@ -64,6 +65,7 @@ InstallVbeShim (
   UINTN                Segment0Pages;\r
   IVT_ENTRY            *Int0x10;\r
   EFI_STATUS           Segment0AllocationStatus;\r
+  UINT16               HostBridgeDevId;\r
   UINTN                Pam1Address;\r
   UINT8                Pam1;\r
   UINTN                SegmentCPages;\r
@@ -131,7 +133,30 @@ InstallVbeShim (
   //\r
   // Put the shim in place first.\r
   //\r
-  Pam1Address = PCI_LIB_ADDRESS (0, 0, 0, 0x5A);\r
+  // Start by determining the address of the PAM1 register.\r
+  //\r
+  HostBridgeDevId = PcdGet16 (PcdOvmfHostBridgePciDevId);\r
+  switch (HostBridgeDevId) {\r
+  case INTEL_82441_DEVICE_ID:\r
+    Pam1Address = PMC_REGISTER_PIIX4 (PIIX4_PAM1);\r
+    break;\r
+  case INTEL_Q35_MCH_DEVICE_ID:\r
+    Pam1Address = DRAMC_REGISTER_Q35 (MCH_PAM1);\r
+    break;\r
+  default:\r
+    DEBUG ((\r
+      DEBUG_ERROR,\r
+      "%a: unknown host bridge device ID: 0x%04x\n",\r
+      __FUNCTION__,\r
+      HostBridgeDevId\r
+      ));\r
+    ASSERT (FALSE);\r
+\r
+    if (!EFI_ERROR (Segment0AllocationStatus)) {\r
+      gBS->FreePages (Segment0, Segment0Pages);\r
+    }\r
+    return;\r
+  }\r
   //\r
   // low nibble covers 0xC0000 to 0xC3FFF\r
   // high nibble covers 0xC4000 to 0xC7FFF\r