qubes-linux-kernel/patches.drivers/e1000e-entropy-source.patch

93 lines
3.4 KiB
Diff
Raw Normal View History

From: Jiri Benc <jbenc@suse.cz>
Subject: Enable e1000e as entropy source (disabled by default)
References: FATE#307517
Patch-mainline: never
Current disk-less systems have no entropy source whatsoever. Therefore, the
network drivers tg3, bnx2, e1000, e1000e, igb and ixgbe should be enabled to
feed entropy to the kernel via the IRQF_SAMPLE_RANDOM flag when loaded. This
option shall not be enabled by default but implemented via a module option to
be activated by the administrator.
Signed-off-by: Brandon Philips <bphilips@suse.de>
---
drivers/net/e1000e/e1000.h | 1 +
drivers/net/e1000e/netdev.c | 14 +++++++++-----
drivers/net/e1000e/param.c | 4 ++++
3 files changed, 14 insertions(+), 5 deletions(-)
Index: linux-2.6.34-master/drivers/net/e1000e/e1000.h
===================================================================
--- linux-2.6.34-master.orig/drivers/net/e1000e/e1000.h
+++ linux-2.6.34-master/drivers/net/e1000e/e1000.h
@@ -466,6 +466,7 @@ extern void e1000e_reset_interrupt_capab
extern void e1000e_disable_aspm(struct pci_dev *pdev, u16 state);
extern unsigned int copybreak;
+extern int entropy;
extern char *e1000e_get_hw_dev_name(struct e1000_hw *hw);
Index: linux-2.6.34-master/drivers/net/e1000e/netdev.c
===================================================================
--- linux-2.6.34-master.orig/drivers/net/e1000e/netdev.c
+++ linux-2.6.34-master/drivers/net/e1000e/netdev.c
@@ -1496,8 +1496,8 @@ static int e1000_request_msix(struct e10
else
memcpy(adapter->rx_ring->name, netdev->name, IFNAMSIZ);
err = request_irq(adapter->msix_entries[vector].vector,
- e1000_intr_msix_rx, 0, adapter->rx_ring->name,
- netdev);
+ e1000_intr_msix_rx, entropy ? IRQF_SAMPLE_RANDOM : 0,
+ adapter->rx_ring->name, netdev);
if (err)
goto out;
adapter->rx_ring->itr_register = E1000_EITR_82574(vector);
@@ -1538,6 +1538,7 @@ static int e1000_request_irq(struct e100
{
struct net_device *netdev = adapter->netdev;
int err;
+ int irq_flags = 0;
if (adapter->msix_entries) {
err = e1000_request_msix(adapter);
@@ -1549,7 +1550,8 @@ static int e1000_request_irq(struct e100
e1000e_set_interrupt_capability(adapter);
}
if (adapter->flags & FLAG_MSI_ENABLED) {
- err = request_irq(adapter->pdev->irq, e1000_intr_msi, 0,
+ err = request_irq(adapter->pdev->irq, e1000_intr_msi,
+ entropy ? IRQF_SAMPLE_RANDOM : 0,
netdev->name, netdev);
if (!err)
return err;
@@ -1559,8 +1561,10 @@ static int e1000_request_irq(struct e100
adapter->int_mode = E1000E_INT_MODE_LEGACY;
}
- err = request_irq(adapter->pdev->irq, e1000_intr, IRQF_SHARED,
- netdev->name, netdev);
+ if (entropy)
+ irq_flags |= IRQF_SAMPLE_RANDOM;
+ err = request_irq(adapter->pdev->irq, e1000_intr,
+ irq_flags | IRQF_SHARED, netdev->name, netdev);
if (err)
e_err("Unable to allocate interrupt, Error: %d\n", err);
Index: linux-2.6.34-master/drivers/net/e1000e/param.c
===================================================================
--- linux-2.6.34-master.orig/drivers/net/e1000e/param.c
+++ linux-2.6.34-master/drivers/net/e1000e/param.c
@@ -31,6 +31,10 @@
#include "e1000.h"
+int entropy = 0;
+module_param(entropy, int, 0);
+MODULE_PARM_DESC(entropy, "Allow e1000e to populate the /dev/random entropy pool");
+
/*
* This is the only thing that needs to be changed to adjust the
* maximum number of ports that the driver can manage.