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