mirror of
https://src.fedoraproject.org/rpms/grub2.git
synced 2024-12-01 00:48:18 +00:00
f74b50e380
Signed-off-by: Peter Jones <pjones@redhat.com>
248 lines
6.8 KiB
Diff
248 lines
6.8 KiB
Diff
From 14cbdee1aa0b21b73611823a7d9a9eb8466a7dc2 Mon Sep 17 00:00:00 2001
|
|
From: Vladimir 'phcoder' Serbinenko <phcoder@gmail.com>
|
|
Date: Mon, 29 Apr 2013 12:16:46 +0200
|
|
Subject: [PATCH 389/482] Enforce disabling of firmware disk drivers
|
|
when native drivers kick in.
|
|
|
|
---
|
|
ChangeLog | 4 ++++
|
|
grub-core/bus/usb/ehci.c | 4 ++++
|
|
grub-core/bus/usb/ohci.c | 4 ++++
|
|
grub-core/bus/usb/uhci.c | 2 ++
|
|
grub-core/disk/ahci.c | 13 +------------
|
|
grub-core/disk/efi/efidisk.c | 19 ++++++++++++-------
|
|
grub-core/disk/ieee1275/ofdisk.c | 18 ++++++++++--------
|
|
grub-core/disk/pata.c | 8 +-------
|
|
include/grub/disk.h | 14 ++++++++++++++
|
|
9 files changed, 52 insertions(+), 34 deletions(-)
|
|
|
|
diff --git a/ChangeLog b/ChangeLog
|
|
index 1ba588d..1dea1aa 100644
|
|
--- a/ChangeLog
|
|
+++ b/ChangeLog
|
|
@@ -1,5 +1,9 @@
|
|
2013-04-29 Vladimir Serbinenko <phcoder@gmail.com>
|
|
|
|
+ Enforce disabling of firmware disk drivers when native drivers kick in.
|
|
+
|
|
+2013-04-29 Vladimir Serbinenko <phcoder@gmail.com>
|
|
+
|
|
* grub-core/commands/nativedisk.c: Customize the list of modules on
|
|
platform. Don't try to search for disks already using native drivers.
|
|
|
|
diff --git a/grub-core/bus/usb/ehci.c b/grub-core/bus/usb/ehci.c
|
|
index d18a87f..9294445 100644
|
|
--- a/grub-core/bus/usb/ehci.c
|
|
+++ b/grub-core/bus/usb/ehci.c
|
|
@@ -28,6 +28,7 @@
|
|
#include <grub/time.h>
|
|
#include <grub/loader.h>
|
|
#include <grub/cs5536.h>
|
|
+#include <grub/disk.h>
|
|
|
|
GRUB_MOD_LICENSE ("GPLv3+");
|
|
|
|
@@ -1909,6 +1910,9 @@ GRUB_MOD_INIT (ehci)
|
|
{
|
|
COMPILE_TIME_ASSERT (sizeof (struct grub_ehci_td) == 64);
|
|
COMPILE_TIME_ASSERT (sizeof (struct grub_ehci_qh) == 96);
|
|
+
|
|
+ grub_stop_disk_firmware ();
|
|
+
|
|
grub_boot_time ("Initing EHCI hardware");
|
|
grub_ehci_inithw ();
|
|
grub_boot_time ("Registering EHCI driver");
|
|
diff --git a/grub-core/bus/usb/ohci.c b/grub-core/bus/usb/ohci.c
|
|
index 2f3fd91..3be5c8d 100644
|
|
--- a/grub-core/bus/usb/ohci.c
|
|
+++ b/grub-core/bus/usb/ohci.c
|
|
@@ -28,6 +28,7 @@
|
|
#include <grub/time.h>
|
|
#include <grub/cs5536.h>
|
|
#include <grub/loader.h>
|
|
+#include <grub/disk.h>
|
|
|
|
GRUB_MOD_LICENSE ("GPLv3+");
|
|
|
|
@@ -1442,6 +1443,9 @@ GRUB_MOD_INIT(ohci)
|
|
{
|
|
COMPILE_TIME_ASSERT (sizeof (struct grub_ohci_td) == 32);
|
|
COMPILE_TIME_ASSERT (sizeof (struct grub_ohci_ed) == 16);
|
|
+
|
|
+ grub_stop_disk_firmware ();
|
|
+
|
|
grub_ohci_inithw ();
|
|
grub_usb_controller_dev_register (&usb_controller);
|
|
fini_hnd = grub_loader_register_preboot_hook (grub_ohci_fini_hw,
|
|
diff --git a/grub-core/bus/usb/uhci.c b/grub-core/bus/usb/uhci.c
|
|
index a314637..c2e2e7e 100644
|
|
--- a/grub-core/bus/usb/uhci.c
|
|
+++ b/grub-core/bus/usb/uhci.c
|
|
@@ -866,6 +866,8 @@ static struct grub_usb_controller_dev usb_controller =
|
|
|
|
GRUB_MOD_INIT(uhci)
|
|
{
|
|
+ grub_stop_disk_firmware ();
|
|
+
|
|
grub_uhci_inithw ();
|
|
grub_usb_controller_dev_register (&usb_controller);
|
|
grub_dprintf ("uhci", "registered\n");
|
|
diff --git a/grub-core/disk/ahci.c b/grub-core/disk/ahci.c
|
|
index e617042..554fcc5 100644
|
|
--- a/grub-core/disk/ahci.c
|
|
+++ b/grub-core/disk/ahci.c
|
|
@@ -183,11 +183,6 @@ grub_ahci_pciinit (grub_pci_device_t dev,
|
|
if (class >> 8 != 0x010601)
|
|
return 0;
|
|
|
|
-#ifdef GRUB_MACHINE_QEMU
|
|
- addr = grub_pci_make_address (dev, GRUB_PCI_REG_COMMAND);
|
|
- grub_pci_write_word (addr, 0x107);
|
|
-#endif
|
|
-
|
|
addr = grub_pci_make_address (dev, GRUB_PCI_REG_ADDRESS_REG5);
|
|
|
|
#ifdef GRUB_MACHINE_QEMU
|
|
@@ -1102,13 +1097,7 @@ static struct grub_preboot *fini_hnd;
|
|
|
|
GRUB_MOD_INIT(ahci)
|
|
{
|
|
- /* To prevent two drivers operating on the same disks. */
|
|
- grub_disk_firmware_is_tainted = 1;
|
|
- if (grub_disk_firmware_fini)
|
|
- {
|
|
- grub_disk_firmware_fini ();
|
|
- grub_disk_firmware_fini = NULL;
|
|
- }
|
|
+ grub_stop_disk_firmware ();
|
|
|
|
/* AHCI initialization. */
|
|
grub_ahci_initialize ();
|
|
diff --git a/grub-core/disk/efi/efidisk.c b/grub-core/disk/efi/efidisk.c
|
|
index e168d07..ebd906e 100644
|
|
--- a/grub-core/disk/efi/efidisk.c
|
|
+++ b/grub-core/disk/efi/efidisk.c
|
|
@@ -624,21 +624,26 @@ static struct grub_disk_dev grub_efidisk_dev =
|
|
};
|
|
|
|
void
|
|
-grub_efidisk_init (void)
|
|
-{
|
|
- enumerate_disks ();
|
|
- grub_disk_dev_register (&grub_efidisk_dev);
|
|
-}
|
|
-
|
|
-void
|
|
grub_efidisk_fini (void)
|
|
{
|
|
free_devices (fd_devices);
|
|
free_devices (hd_devices);
|
|
free_devices (cd_devices);
|
|
+ fd_devices = 0;
|
|
+ hd_devices = 0;
|
|
+ cd_devices = 0;
|
|
grub_disk_dev_unregister (&grub_efidisk_dev);
|
|
}
|
|
|
|
+void
|
|
+grub_efidisk_init (void)
|
|
+{
|
|
+ grub_disk_firmware_fini = grub_efidisk_fini;
|
|
+
|
|
+ enumerate_disks ();
|
|
+ grub_disk_dev_register (&grub_efidisk_dev);
|
|
+}
|
|
+
|
|
/* Some utility functions to map GRUB devices with EFI devices. */
|
|
grub_efi_handle_t
|
|
grub_efidisk_get_device_handle (grub_disk_t disk)
|
|
diff --git a/grub-core/disk/ieee1275/ofdisk.c b/grub-core/disk/ieee1275/ofdisk.c
|
|
index ec92c4d..2a31ecd 100644
|
|
--- a/grub-core/disk/ieee1275/ofdisk.c
|
|
+++ b/grub-core/disk/ieee1275/ofdisk.c
|
|
@@ -550,14 +550,6 @@ insert_bootpath (void)
|
|
}
|
|
|
|
void
|
|
-grub_ofdisk_init (void)
|
|
-{
|
|
- insert_bootpath ();
|
|
-
|
|
- grub_disk_dev_register (&grub_ofdisk_dev);
|
|
-}
|
|
-
|
|
-void
|
|
grub_ofdisk_fini (void)
|
|
{
|
|
if (last_ihandle)
|
|
@@ -568,6 +560,16 @@ grub_ofdisk_fini (void)
|
|
grub_disk_dev_unregister (&grub_ofdisk_dev);
|
|
}
|
|
|
|
+void
|
|
+grub_ofdisk_init (void)
|
|
+{
|
|
+ grub_disk_firmware_fini = grub_ofdisk_fini;
|
|
+
|
|
+ insert_bootpath ();
|
|
+
|
|
+ grub_disk_dev_register (&grub_ofdisk_dev);
|
|
+}
|
|
+
|
|
grub_err_t
|
|
grub_ofdisk_get_block_size (const char *device, grub_uint32_t *block_size)
|
|
{
|
|
diff --git a/grub-core/disk/pata.c b/grub-core/disk/pata.c
|
|
index 75e5deb..8c4b27b 100644
|
|
--- a/grub-core/disk/pata.c
|
|
+++ b/grub-core/disk/pata.c
|
|
@@ -530,13 +530,7 @@ static struct grub_ata_dev grub_pata_dev =
|
|
|
|
GRUB_MOD_INIT(ata_pthru)
|
|
{
|
|
- /* To prevent two drivers operating on the same disks. */
|
|
- grub_disk_firmware_is_tainted = 1;
|
|
- if (grub_disk_firmware_fini)
|
|
- {
|
|
- grub_disk_firmware_fini ();
|
|
- grub_disk_firmware_fini = NULL;
|
|
- }
|
|
+ grub_stop_disk_firmware ();
|
|
|
|
/* ATA initialization. */
|
|
grub_pata_initialize ();
|
|
diff --git a/include/grub/disk.h b/include/grub/disk.h
|
|
index d19b1ac..8fa09a6 100644
|
|
--- a/include/grub/disk.h
|
|
+++ b/include/grub/disk.h
|
|
@@ -25,6 +25,8 @@
|
|
#include <grub/err.h>
|
|
#include <grub/types.h>
|
|
#include <grub/device.h>
|
|
+/* For NULL. */
|
|
+#include <grub/mm.h>
|
|
|
|
/* These are used to set a device id. When you add a new disk device,
|
|
you must define a new id for it here. */
|
|
@@ -205,6 +207,18 @@ EXPORT_FUNC(grub_disk_cache_get_performance) (unsigned long *hits, unsigned long
|
|
extern void (* EXPORT_VAR(grub_disk_firmware_fini)) (void);
|
|
extern int EXPORT_VAR(grub_disk_firmware_is_tainted);
|
|
|
|
+static inline void
|
|
+grub_stop_disk_firmware (void)
|
|
+{
|
|
+ /* To prevent two drivers operating on the same disks. */
|
|
+ grub_disk_firmware_is_tainted = 1;
|
|
+ if (grub_disk_firmware_fini)
|
|
+ {
|
|
+ grub_disk_firmware_fini ();
|
|
+ grub_disk_firmware_fini = NULL;
|
|
+ }
|
|
+}
|
|
+
|
|
#if defined (GRUB_UTIL)
|
|
void grub_lvm_init (void);
|
|
void grub_ldm_init (void);
|
|
--
|
|
1.8.2.1
|
|
|