qubes-linux-kernel/patches.drivers/e1000e-entropy-source.patch
2011-04-19 22:09:59 +02:00

87 lines
2.9 KiB
Diff

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(-)
--- a/drivers/net/e1000e/e1000.h
+++ b/drivers/net/e1000e/e1000.h
@@ -467,6 +467,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);
--- a/drivers/net/e1000e/netdev.c
+++ b/drivers/net/e1000e/netdev.c
@@ -1847,8 +1847,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);
@@ -1889,6 +1889,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);
@@ -1900,7 +1901,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;
@@ -1910,8 +1912,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);
--- a/drivers/net/e1000e/param.c
+++ b/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.