From: Greg Kroah-Hartman Date: Thu, 9 Aug 2012 21:48:52 +0000 (-0700) Subject: 3.4-stable patches X-Git-Tag: v3.5.2~14 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=9d7530264eff844537b0229ef1d065aa36512ca1;p=thirdparty%2Fkernel%2Fstable-queue.git 3.4-stable patches added patches: dmi-feed-dmi-table-to-dev-random-driver.patch hid-add-asus-aio-keyboard-model-ak1d.patch hid-add-support-for-cypress-barcode-scanner-04b4-ed81.patch hid-multitouch-add-support-for-novatek-touchscreen.patch maintainers-theodore-ts-o-is-taking-over-the-random-driver.patch mfd-wm831x-feed-the-device-uuid-into-device_add_randomness.patch random-add-comment-to-random_initialize.patch random-add-new-get_random_bytes_arch-function.patch random-add-tracepoints-for-easier-debugging-and-verification.patch random-mix-in-architectural-randomness-in-extract_buf.patch random-remove-rand_initialize_irq.patch random-use-the-arch-specific-rng-in-xfer_secondary_pool.patch rtc-wm831x-feed-the-write-counter-into-device_add_randomness.patch --- diff --git a/queue-3.4/dmi-feed-dmi-table-to-dev-random-driver.patch b/queue-3.4/dmi-feed-dmi-table-to-dev-random-driver.patch new file mode 100644 index 00000000000..10b0f5e22e4 --- /dev/null +++ b/queue-3.4/dmi-feed-dmi-table-to-dev-random-driver.patch @@ -0,0 +1,39 @@ +From d114a33387472555188f142ed8e98acdb8181c6d Mon Sep 17 00:00:00 2001 +From: Tony Luck +Date: Fri, 20 Jul 2012 13:15:20 -0700 +Subject: dmi: Feed DMI table to /dev/random driver + +From: Tony Luck + +commit d114a33387472555188f142ed8e98acdb8181c6d upstream. + +Send the entire DMI (SMBIOS) table to the /dev/random driver to +help seed its pools. + +Signed-off-by: Tony Luck +Signed-off-by: Theodore Ts'o +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/firmware/dmi_scan.c | 3 +++ + 1 file changed, 3 insertions(+) + +--- a/drivers/firmware/dmi_scan.c ++++ b/drivers/firmware/dmi_scan.c +@@ -6,6 +6,7 @@ + #include + #include + #include ++#include + #include + + /* +@@ -111,6 +112,8 @@ static int __init dmi_walk_early(void (* + + dmi_table(buf, dmi_len, dmi_num, decode, NULL); + ++ add_device_randomness(buf, dmi_len); ++ + dmi_iounmap(buf, dmi_len); + return 0; + } diff --git a/queue-3.4/hid-add-asus-aio-keyboard-model-ak1d.patch b/queue-3.4/hid-add-asus-aio-keyboard-model-ak1d.patch new file mode 100644 index 00000000000..d5d9e12b583 --- /dev/null +++ b/queue-3.4/hid-add-asus-aio-keyboard-model-ak1d.patch @@ -0,0 +1,53 @@ +From 2d8767bb421574dfcf48e4be0751ce7d8f73d5d7 Mon Sep 17 00:00:00 2001 +From: Cyrus Lien +Date: Mon, 23 Jul 2012 17:11:51 +0800 +Subject: HID: add ASUS AIO keyboard model AK1D + +From: Cyrus Lien + +commit 2d8767bb421574dfcf48e4be0751ce7d8f73d5d7 upstream. + +Add Asus All-In-One PC keyboard model AK1D. + +BugLink: https://bugs.launchpad.net/bugs/1027789 + +Signed-off-by: Cyrus Lien +Signed-off-by: Jiri Kosina +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/hid/hid-chicony.c | 1 + + drivers/hid/hid-core.c | 1 + + drivers/hid/hid-ids.h | 1 + + 3 files changed, 3 insertions(+) + +--- a/drivers/hid/hid-chicony.c ++++ b/drivers/hid/hid-chicony.c +@@ -60,6 +60,7 @@ static int ch_input_mapping(struct hid_d + static const struct hid_device_id ch_devices[] = { + { HID_USB_DEVICE(USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_TACTICAL_PAD) }, + { HID_USB_DEVICE(USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_WIRELESS2) }, ++ { HID_USB_DEVICE(USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_AK1D) }, + { } + }; + MODULE_DEVICE_TABLE(hid, ch_devices); +--- a/drivers/hid/hid-core.c ++++ b/drivers/hid/hid-core.c +@@ -1404,6 +1404,7 @@ static const struct hid_device_id hid_ha + { HID_USB_DEVICE(USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_TACTICAL_PAD) }, + { HID_USB_DEVICE(USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_WIRELESS) }, + { HID_USB_DEVICE(USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_WIRELESS2) }, ++ { HID_USB_DEVICE(USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_AK1D) }, + { HID_USB_DEVICE(USB_VENDOR_ID_CHUNGHWAT, USB_DEVICE_ID_CHUNGHWAT_MULTITOUCH) }, + { HID_USB_DEVICE(USB_VENDOR_ID_CREATIVELABS, USB_DEVICE_ID_PRODIKEYS_PCMIDI) }, + { HID_USB_DEVICE(USB_VENDOR_ID_CVTOUCH, USB_DEVICE_ID_CVTOUCH_SCREEN) }, +--- a/drivers/hid/hid-ids.h ++++ b/drivers/hid/hid-ids.h +@@ -202,6 +202,7 @@ + #define USB_DEVICE_ID_CHICONY_MULTI_TOUCH 0xb19d + #define USB_DEVICE_ID_CHICONY_WIRELESS 0x0618 + #define USB_DEVICE_ID_CHICONY_WIRELESS2 0x1123 ++#define USB_DEVICE_ID_CHICONY_AK1D 0x1125 + + #define USB_VENDOR_ID_CHUNGHWAT 0x2247 + #define USB_DEVICE_ID_CHUNGHWAT_MULTITOUCH 0x0001 diff --git a/queue-3.4/hid-add-support-for-cypress-barcode-scanner-04b4-ed81.patch b/queue-3.4/hid-add-support-for-cypress-barcode-scanner-04b4-ed81.patch new file mode 100644 index 00000000000..dd45854b6e5 --- /dev/null +++ b/queue-3.4/hid-add-support-for-cypress-barcode-scanner-04b4-ed81.patch @@ -0,0 +1,53 @@ +From 76c9d8fe2c7fc34ffc387d8022c5828d6ff9df48 Mon Sep 17 00:00:00 2001 +From: Lionel Vaux +Date: Sun, 22 Jul 2012 11:32:20 +0200 +Subject: HID: add support for Cypress barcode scanner 04B4:ED81 + +From: Lionel Vaux + +commit 76c9d8fe2c7fc34ffc387d8022c5828d6ff9df48 upstream. + +Add yet another device to the list of Cypress barcode scanners +needing the CP_RDESC_SWAPPED_MIN_MAX quirk. + +Signed-off-by: Lionel Vaux (iouri) +Signed-off-by: Jiri Kosina +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/hid/hid-core.c | 1 + + drivers/hid/hid-cypress.c | 2 ++ + drivers/hid/hid-ids.h | 1 + + 3 files changed, 4 insertions(+) + +--- a/drivers/hid/hid-core.c ++++ b/drivers/hid/hid-core.c +@@ -1410,6 +1410,7 @@ static const struct hid_device_id hid_ha + { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_BARCODE_1) }, + { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_BARCODE_2) }, + { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_BARCODE_3) }, ++ { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_BARCODE_4) }, + { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_MOUSE) }, + { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_TRUETOUCH) }, + { HID_USB_DEVICE(USB_VENDOR_ID_DRAGONRISE, 0x0006) }, +--- a/drivers/hid/hid-cypress.c ++++ b/drivers/hid/hid-cypress.c +@@ -129,6 +129,8 @@ static const struct hid_device_id cp_dev + .driver_data = CP_RDESC_SWAPPED_MIN_MAX }, + { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_BARCODE_3), + .driver_data = CP_RDESC_SWAPPED_MIN_MAX }, ++ { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_BARCODE_4), ++ .driver_data = CP_RDESC_SWAPPED_MIN_MAX }, + { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_MOUSE), + .driver_data = CP_2WHEEL_MOUSE_HACK }, + { } +--- a/drivers/hid/hid-ids.h ++++ b/drivers/hid/hid-ids.h +@@ -231,6 +231,7 @@ + #define USB_DEVICE_ID_CYPRESS_BARCODE_1 0xde61 + #define USB_DEVICE_ID_CYPRESS_BARCODE_2 0xde64 + #define USB_DEVICE_ID_CYPRESS_BARCODE_3 0xbca1 ++#define USB_DEVICE_ID_CYPRESS_BARCODE_4 0xed81 + #define USB_DEVICE_ID_CYPRESS_TRUETOUCH 0xc001 + + #define USB_VENDOR_ID_DEALEXTREAME 0x10c5 diff --git a/queue-3.4/hid-multitouch-add-support-for-novatek-touchscreen.patch b/queue-3.4/hid-multitouch-add-support-for-novatek-touchscreen.patch new file mode 100644 index 00000000000..f9db39e19d1 --- /dev/null +++ b/queue-3.4/hid-multitouch-add-support-for-novatek-touchscreen.patch @@ -0,0 +1,47 @@ +From 4db703ead4535792ea54dba7275fdd1527848e74 Mon Sep 17 00:00:00 2001 +From: Austin Hendrix +Date: Mon, 4 Jun 2012 15:27:51 -0700 +Subject: HID: multitouch: add support for Novatek touchscreen + +From: Austin Hendrix + +commit 4db703ead4535792ea54dba7275fdd1527848e74 upstream. + +Add support for a Novatek touchscreen panel as a generic HID multitouch +panel. + +Signed-off-by: Austin Hendrix +Signed-off-by: Jiri Kosina +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/hid/hid-ids.h | 3 +++ + drivers/hid/hid-multitouch.c | 5 +++++ + 2 files changed, 8 insertions(+) + +--- a/drivers/hid/hid-ids.h ++++ b/drivers/hid/hid-ids.h +@@ -567,6 +567,9 @@ + #define USB_VENDOR_ID_NINTENDO 0x057e + #define USB_DEVICE_ID_NINTENDO_WIIMOTE 0x0306 + ++#define USB_VENDOR_ID_NOVATEK 0x0603 ++#define USB_DEVICE_ID_NOVATEK_PCT 0x0600 ++ + #define USB_VENDOR_ID_NTRIG 0x1b96 + #define USB_DEVICE_ID_NTRIG_TOUCH_SCREEN 0x0001 + #define USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_1 0x0003 +--- a/drivers/hid/hid-multitouch.c ++++ b/drivers/hid/hid-multitouch.c +@@ -940,6 +940,11 @@ static const struct hid_device_id mt_dev + HID_USB_DEVICE(USB_VENDOR_ID_PANASONIC, + USB_DEVICE_ID_PANABOARD_UBT880) }, + ++ /* Novatek Panel */ ++ { .driver_data = MT_CLS_DEFAULT, ++ HID_USB_DEVICE(USB_VENDOR_ID_NOVATEK, ++ USB_DEVICE_ID_NOVATEK_PCT) }, ++ + /* PenMount panels */ + { .driver_data = MT_CLS_CONFIDENCE, + HID_USB_DEVICE(USB_VENDOR_ID_PENMOUNT, diff --git a/queue-3.4/maintainers-theodore-ts-o-is-taking-over-the-random-driver.patch b/queue-3.4/maintainers-theodore-ts-o-is-taking-over-the-random-driver.patch new file mode 100644 index 00000000000..735842c2e94 --- /dev/null +++ b/queue-3.4/maintainers-theodore-ts-o-is-taking-over-the-random-driver.patch @@ -0,0 +1,31 @@ +From 330e0a01d54c2b8606c56816f99af6ebc58ec92c Mon Sep 17 00:00:00 2001 +From: Theodore Ts'o +Date: Wed, 4 Jul 2012 11:32:48 -0400 +Subject: MAINTAINERS: Theodore Ts'o is taking over the random driver + +From: Theodore Ts'o + +commit 330e0a01d54c2b8606c56816f99af6ebc58ec92c upstream. + +Matt Mackall stepped down as the /dev/random driver maintainer last +year, so Theodore Ts'o is taking back the /dev/random driver. + +Cc: Matt Mackall +Signed-off-by: "Theodore Ts'o" +Signed-off-by: Greg Kroah-Hartman + +--- + MAINTAINERS | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/MAINTAINERS ++++ b/MAINTAINERS +@@ -5566,7 +5566,7 @@ F: Documentation/blockdev/ramdisk.txt + F: drivers/block/brd.c + + RANDOM NUMBER DRIVER +-M: Matt Mackall ++M: Theodore Ts'o" + S: Maintained + F: drivers/char/random.c + diff --git a/queue-3.4/mfd-wm831x-feed-the-device-uuid-into-device_add_randomness.patch b/queue-3.4/mfd-wm831x-feed-the-device-uuid-into-device_add_randomness.patch new file mode 100644 index 00000000000..e0084605c8e --- /dev/null +++ b/queue-3.4/mfd-wm831x-feed-the-device-uuid-into-device_add_randomness.patch @@ -0,0 +1,51 @@ +From 27130f0cc3ab97560384da437e4621fc4e94f21c Mon Sep 17 00:00:00 2001 +From: Mark Brown +Date: Thu, 5 Jul 2012 20:23:21 +0000 +Subject: mfd: wm831x: Feed the device UUID into device_add_randomness() + +From: Mark Brown + +commit 27130f0cc3ab97560384da437e4621fc4e94f21c upstream. + +wm831x devices contain a unique ID value. Feed this into the newly added +device_add_randomness() to add some per device seed data to the pool. + +Signed-off-by: Mark Brown +Signed-off-by: Theodore Ts'o +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/mfd/wm831x-otp.c | 8 ++++++++ + 1 file changed, 8 insertions(+) + +--- a/drivers/mfd/wm831x-otp.c ++++ b/drivers/mfd/wm831x-otp.c +@@ -18,6 +18,7 @@ + #include + #include + #include ++#include + + #include + #include +@@ -66,6 +67,7 @@ static DEVICE_ATTR(unique_id, 0444, wm83 + + int wm831x_otp_init(struct wm831x *wm831x) + { ++ char uuid[WM831X_UNIQUE_ID_LEN]; + int ret; + + ret = device_create_file(wm831x->dev, &dev_attr_unique_id); +@@ -73,6 +75,12 @@ int wm831x_otp_init(struct wm831x *wm831 + dev_err(wm831x->dev, "Unique ID attribute not created: %d\n", + ret); + ++ ret = wm831x_unique_id_read(wm831x, uuid); ++ if (ret == 0) ++ add_device_randomness(uuid, sizeof(uuid)); ++ else ++ dev_err(wm831x->dev, "Failed to read UUID: %d\n", ret); ++ + return ret; + } + diff --git a/queue-3.4/random-add-comment-to-random_initialize.patch b/queue-3.4/random-add-comment-to-random_initialize.patch new file mode 100644 index 00000000000..060dc314efa --- /dev/null +++ b/queue-3.4/random-add-comment-to-random_initialize.patch @@ -0,0 +1,51 @@ +From cbc96b7594b5691d61eba2db8b2ea723645be9ca Mon Sep 17 00:00:00 2001 +From: Tony Luck +Date: Mon, 23 Jul 2012 09:47:57 -0700 +Subject: random: Add comment to random_initialize() + +From: Tony Luck + +commit cbc96b7594b5691d61eba2db8b2ea723645be9ca upstream. + +Many platforms have per-machine instance data (serial numbers, +asset tags, etc.) squirreled away in areas that are accessed +during early system bringup. Mixing this data into the random +pools has a very high value in providing better random data, +so we should allow (and even encourage) architecture code to +call add_device_randomness() from the setup_arch() paths. + +However, this limits our options for internal structure of +the random driver since random_initialize() is not called +until long after setup_arch(). + +Add a big fat comment to rand_initialize() spelling out +this requirement. + +Suggested-by: Theodore Ts'o +Signed-off-by: Tony Luck +Signed-off-by: Theodore Ts'o +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/char/random.c | 10 ++++++++++ + 1 file changed, 10 insertions(+) + +--- a/drivers/char/random.c ++++ b/drivers/char/random.c +@@ -1087,6 +1087,16 @@ static void init_std_data(struct entropy + mix_pool_bytes(r, utsname(), sizeof(*(utsname())), NULL); + } + ++/* ++ * Note that setup_arch() may call add_device_randomness() ++ * long before we get here. This allows seeding of the pools ++ * with some platform dependent data very early in the boot ++ * process. But it limits our options here. We must use ++ * statically allocated structures that already have all ++ * initializations complete at compile time. We should also ++ * take care not to overwrite the precious per platform data ++ * we were given. ++ */ + static int rand_initialize(void) + { + init_std_data(&input_pool); diff --git a/queue-3.4/random-add-new-get_random_bytes_arch-function.patch b/queue-3.4/random-add-new-get_random_bytes_arch-function.patch new file mode 100644 index 00000000000..361430395f1 --- /dev/null +++ b/queue-3.4/random-add-new-get_random_bytes_arch-function.patch @@ -0,0 +1,120 @@ +From c2557a303ab6712bb6e09447df828c557c710ac9 Mon Sep 17 00:00:00 2001 +From: Theodore Ts'o +Date: Thu, 5 Jul 2012 10:35:23 -0400 +Subject: random: add new get_random_bytes_arch() function + +From: Theodore Ts'o + +commit c2557a303ab6712bb6e09447df828c557c710ac9 upstream. + +Create a new function, get_random_bytes_arch() which will use the +architecture-specific hardware random number generator if it is +present. Change get_random_bytes() to not use the HW RNG, even if it +is avaiable. + +The reason for this is that the hw random number generator is fast (if +it is present), but it requires that we trust the hardware +manufacturer to have not put in a back door. (For example, an +increasing counter encrypted by an AES key known to the NSA.) + +It's unlikely that Intel (for example) was paid off by the US +Government to do this, but it's impossible for them to prove otherwise + --- especially since Bull Mountain is documented to use AES as a +whitener. Hence, the output of an evil, trojan-horse version of +RDRAND is statistically indistinguishable from an RDRAND implemented +to the specifications claimed by Intel. Short of using a tunnelling +electronic microscope to reverse engineer an Ivy Bridge chip and +disassembling and analyzing the CPU microcode, there's no way for us +to tell for sure. + +Since users of get_random_bytes() in the Linux kernel need to be able +to support hardware systems where the HW RNG is not present, most +time-sensitive users of this interface have already created their own +cryptographic RNG interface which uses get_random_bytes() as a seed. +So it's much better to use the HW RNG to improve the existing random +number generator, by mixing in any entropy returned by the HW RNG into +/dev/random's entropy pool, but to always _use_ /dev/random's entropy +pool. + +This way we get almost of the benefits of the HW RNG without any +potential liabilities. The only benefits we forgo is the +speed/performance enhancements --- and generic kernel code can't +depend on depend on get_random_bytes() having the speed of a HW RNG +anyway. + +For those places that really want access to the arch-specific HW RNG, +if it is available, we provide get_random_bytes_arch(). + +Signed-off-by: "Theodore Ts'o" +Signed-off-by: Greg Kroah-Hartman + + +--- + drivers/char/random.c | 29 ++++++++++++++++++++++++----- + include/linux/random.h | 1 + + 2 files changed, 25 insertions(+), 5 deletions(-) + +--- a/drivers/char/random.c ++++ b/drivers/char/random.c +@@ -1038,17 +1038,34 @@ static ssize_t extract_entropy_user(stru + + /* + * This function is the exported kernel interface. It returns some +- * number of good random numbers, suitable for seeding TCP sequence +- * numbers, etc. ++ * number of good random numbers, suitable for key generation, seeding ++ * TCP sequence numbers, etc. It does not use the hw random number ++ * generator, if available; use get_random_bytes_arch() for that. + */ + void get_random_bytes(void *buf, int nbytes) + { ++ extract_entropy(&nonblocking_pool, buf, nbytes, 0, 0); ++} ++EXPORT_SYMBOL(get_random_bytes); ++ ++/* ++ * This function will use the architecture-specific hardware random ++ * number generator if it is available. The arch-specific hw RNG will ++ * almost certainly be faster than what we can do in software, but it ++ * is impossible to verify that it is implemented securely (as ++ * opposed, to, say, the AES encryption of a sequence number using a ++ * key known by the NSA). So it's useful if we need the speed, but ++ * only if we're willing to trust the hardware manufacturer not to ++ * have put in a back door. ++ */ ++void get_random_bytes_arch(void *buf, int nbytes) ++{ + char *p = buf; + + while (nbytes) { + unsigned long v; + int chunk = min(nbytes, (int)sizeof(unsigned long)); +- ++ + if (!arch_get_random_long(&v)) + break; + +@@ -1057,9 +1074,11 @@ void get_random_bytes(void *buf, int nby + nbytes -= chunk; + } + +- extract_entropy(&nonblocking_pool, p, nbytes, 0, 0); ++ if (nbytes) ++ extract_entropy(&nonblocking_pool, p, nbytes, 0, 0); + } +-EXPORT_SYMBOL(get_random_bytes); ++EXPORT_SYMBOL(get_random_bytes_arch); ++ + + /* + * init_std_data - initialize pool with system data +--- a/include/linux/random.h ++++ b/include/linux/random.h +@@ -56,6 +56,7 @@ extern void add_input_randomness(unsigne + extern void add_interrupt_randomness(int irq, int irq_flags); + + extern void get_random_bytes(void *buf, int nbytes); ++extern void get_random_bytes_arch(void *buf, int nbytes); + void generate_random_uuid(unsigned char uuid_out[16]); + + #ifndef MODULE diff --git a/queue-3.4/random-add-tracepoints-for-easier-debugging-and-verification.patch b/queue-3.4/random-add-tracepoints-for-easier-debugging-and-verification.patch new file mode 100644 index 00000000000..000a70aefca --- /dev/null +++ b/queue-3.4/random-add-tracepoints-for-easier-debugging-and-verification.patch @@ -0,0 +1,243 @@ +From 00ce1db1a634746040ace24c09a4e3a7949a3145 Mon Sep 17 00:00:00 2001 +From: Theodore Ts'o +Date: Wed, 4 Jul 2012 16:19:30 -0400 +Subject: random: add tracepoints for easier debugging and verification + +From: Theodore Ts'o + +commit 00ce1db1a634746040ace24c09a4e3a7949a3145 upstream. + +Signed-off-by: "Theodore Ts'o" +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/char/random.c | 26 ++++++-- + include/trace/events/random.h | 134 ++++++++++++++++++++++++++++++++++++++++++ + 2 files changed, 156 insertions(+), 4 deletions(-) + +--- a/drivers/char/random.c ++++ b/drivers/char/random.c +@@ -266,6 +266,9 @@ + #include + #include + ++#define CREATE_TRACE_POINTS ++#include ++ + /* + * Configuration information + */ +@@ -478,8 +481,8 @@ static __u32 const twist_table[8] = { + * it's cheap to do so and helps slightly in the expected case where + * the entropy is concentrated in the low-order bits. + */ +-static void __mix_pool_bytes(struct entropy_store *r, const void *in, +- int nbytes, __u8 out[64]) ++static void _mix_pool_bytes(struct entropy_store *r, const void *in, ++ int nbytes, __u8 out[64]) + { + unsigned long i, j, tap1, tap2, tap3, tap4, tap5; + int input_rotate; +@@ -531,13 +534,21 @@ static void __mix_pool_bytes(struct entr + ((__u32 *)out)[j] = r->pool[(i - j) & wordmask]; + } + +-static void mix_pool_bytes(struct entropy_store *r, const void *in, ++static void __mix_pool_bytes(struct entropy_store *r, const void *in, + int nbytes, __u8 out[64]) + { ++ trace_mix_pool_bytes_nolock(r->name, nbytes, _RET_IP_); ++ _mix_pool_bytes(r, in, nbytes, out); ++} ++ ++static void mix_pool_bytes(struct entropy_store *r, const void *in, ++ int nbytes, __u8 out[64]) ++{ + unsigned long flags; + ++ trace_mix_pool_bytes(r->name, nbytes, _RET_IP_); + spin_lock_irqsave(&r->lock, flags); +- __mix_pool_bytes(r, in, nbytes, out); ++ _mix_pool_bytes(r, in, nbytes, out); + spin_unlock_irqrestore(&r->lock, flags); + } + +@@ -585,6 +596,7 @@ static void credit_entropy_bits(struct e + retry: + entropy_count = orig = ACCESS_ONCE(r->entropy_count); + entropy_count += nbits; ++ + if (entropy_count < 0) { + DEBUG_ENT("negative entropy/overflow\n"); + entropy_count = 0; +@@ -599,6 +611,9 @@ retry: + r->initialized = 1; + } + ++ trace_credit_entropy_bits(r->name, nbits, entropy_count, ++ r->entropy_total, _RET_IP_); ++ + /* should we wake readers? */ + if (r == &input_pool && entropy_count >= random_read_wakeup_thresh) { + wake_up_interruptible(&random_read_wait); +@@ -971,6 +986,7 @@ static ssize_t extract_entropy(struct en + ssize_t ret = 0, i; + __u8 tmp[EXTRACT_SIZE]; + ++ trace_extract_entropy(r->name, nbytes, r->entropy_count, _RET_IP_); + xfer_secondary_pool(r, nbytes); + nbytes = account(r, nbytes, min, reserved); + +@@ -1005,6 +1021,7 @@ static ssize_t extract_entropy_user(stru + ssize_t ret = 0, i; + __u8 tmp[EXTRACT_SIZE]; + ++ trace_extract_entropy_user(r->name, nbytes, r->entropy_count, _RET_IP_); + xfer_secondary_pool(r, nbytes); + nbytes = account(r, nbytes, 0, 0); + +@@ -1062,6 +1079,7 @@ void get_random_bytes_arch(void *buf, in + { + char *p = buf; + ++ trace_get_random_bytes(nbytes, _RET_IP_); + while (nbytes) { + unsigned long v; + int chunk = min(nbytes, (int)sizeof(unsigned long)); +--- /dev/null ++++ b/include/trace/events/random.h +@@ -0,0 +1,134 @@ ++#undef TRACE_SYSTEM ++#define TRACE_SYSTEM random ++ ++#if !defined(_TRACE_RANDOM_H) || defined(TRACE_HEADER_MULTI_READ) ++#define _TRACE_RANDOM_H ++ ++#include ++#include ++ ++DECLARE_EVENT_CLASS(random__mix_pool_bytes, ++ TP_PROTO(const char *pool_name, int bytes, unsigned long IP), ++ ++ TP_ARGS(pool_name, bytes, IP), ++ ++ TP_STRUCT__entry( ++ __field( const char *, pool_name ) ++ __field( int, bytes ) ++ __field(unsigned long, IP ) ++ ), ++ ++ TP_fast_assign( ++ __entry->pool_name = pool_name; ++ __entry->bytes = bytes; ++ __entry->IP = IP; ++ ), ++ ++ TP_printk("%s pool: bytes %d caller %pF", ++ __entry->pool_name, __entry->bytes, (void *)__entry->IP) ++); ++ ++DEFINE_EVENT(random__mix_pool_bytes, mix_pool_bytes, ++ TP_PROTO(const char *pool_name, int bytes, unsigned long IP), ++ ++ TP_ARGS(pool_name, bytes, IP) ++); ++ ++DEFINE_EVENT(random__mix_pool_bytes, mix_pool_bytes_nolock, ++ TP_PROTO(const char *pool_name, int bytes, unsigned long IP), ++ ++ TP_ARGS(pool_name, bytes, IP) ++); ++ ++TRACE_EVENT(credit_entropy_bits, ++ TP_PROTO(const char *pool_name, int bits, int entropy_count, ++ int entropy_total, unsigned long IP), ++ ++ TP_ARGS(pool_name, bits, entropy_count, entropy_total, IP), ++ ++ TP_STRUCT__entry( ++ __field( const char *, pool_name ) ++ __field( int, bits ) ++ __field( int, entropy_count ) ++ __field( int, entropy_total ) ++ __field(unsigned long, IP ) ++ ), ++ ++ TP_fast_assign( ++ __entry->pool_name = pool_name; ++ __entry->bits = bits; ++ __entry->entropy_count = entropy_count; ++ __entry->entropy_total = entropy_total; ++ __entry->IP = IP; ++ ), ++ ++ TP_printk("%s pool: bits %d entropy_count %d entropy_total %d " ++ "caller %pF", __entry->pool_name, __entry->bits, ++ __entry->entropy_count, __entry->entropy_total, ++ (void *)__entry->IP) ++); ++ ++TRACE_EVENT(get_random_bytes, ++ TP_PROTO(int nbytes, unsigned long IP), ++ ++ TP_ARGS(nbytes, IP), ++ ++ TP_STRUCT__entry( ++ __field( int, nbytes ) ++ __field(unsigned long, IP ) ++ ), ++ ++ TP_fast_assign( ++ __entry->nbytes = nbytes; ++ __entry->IP = IP; ++ ), ++ ++ TP_printk("nbytes %d caller %pF", __entry->nbytes, (void *)__entry->IP) ++); ++ ++DECLARE_EVENT_CLASS(random__extract_entropy, ++ TP_PROTO(const char *pool_name, int nbytes, int entropy_count, ++ unsigned long IP), ++ ++ TP_ARGS(pool_name, nbytes, entropy_count, IP), ++ ++ TP_STRUCT__entry( ++ __field( const char *, pool_name ) ++ __field( int, nbytes ) ++ __field( int, entropy_count ) ++ __field(unsigned long, IP ) ++ ), ++ ++ TP_fast_assign( ++ __entry->pool_name = pool_name; ++ __entry->nbytes = nbytes; ++ __entry->entropy_count = entropy_count; ++ __entry->IP = IP; ++ ), ++ ++ TP_printk("%s pool: nbytes %d entropy_count %d caller %pF", ++ __entry->pool_name, __entry->nbytes, __entry->entropy_count, ++ (void *)__entry->IP) ++); ++ ++ ++DEFINE_EVENT(random__extract_entropy, extract_entropy, ++ TP_PROTO(const char *pool_name, int nbytes, int entropy_count, ++ unsigned long IP), ++ ++ TP_ARGS(pool_name, nbytes, entropy_count, IP) ++); ++ ++DEFINE_EVENT(random__extract_entropy, extract_entropy_user, ++ TP_PROTO(const char *pool_name, int nbytes, int entropy_count, ++ unsigned long IP), ++ ++ TP_ARGS(pool_name, nbytes, entropy_count, IP) ++); ++ ++ ++ ++#endif /* _TRACE_RANDOM_H */ ++ ++/* This part must be outside protection */ ++#include diff --git a/queue-3.4/random-mix-in-architectural-randomness-in-extract_buf.patch b/queue-3.4/random-mix-in-architectural-randomness-in-extract_buf.patch new file mode 100644 index 00000000000..ced71c569fe --- /dev/null +++ b/queue-3.4/random-mix-in-architectural-randomness-in-extract_buf.patch @@ -0,0 +1,148 @@ +From d2e7c96af1e54b507ae2a6a7dd2baf588417a7e5 Mon Sep 17 00:00:00 2001 +From: "H. Peter Anvin" +Date: Fri, 27 Jul 2012 22:26:08 -0400 +Subject: random: mix in architectural randomness in extract_buf() + +From: "H. Peter Anvin" + +commit d2e7c96af1e54b507ae2a6a7dd2baf588417a7e5 upstream. + +Mix in any architectural randomness in extract_buf() instead of +xfer_secondary_buf(). This allows us to mix in more architectural +randomness, and it also makes xfer_secondary_buf() faster, moving a +tiny bit of additional CPU overhead to process which is extracting the +randomness. + +[ Commit description modified by tytso to remove an extended + advertisement for the RDRAND instruction. ] + +Signed-off-by: H. Peter Anvin +Acked-by: Ingo Molnar +Cc: DJ Johnston +Signed-off-by: Theodore Ts'o +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/char/random.c | 56 ++++++++++++++++++++++++++++---------------------- + 1 file changed, 32 insertions(+), 24 deletions(-) + +--- a/drivers/char/random.c ++++ b/drivers/char/random.c +@@ -277,6 +277,8 @@ + #define SEC_XFER_SIZE 512 + #define EXTRACT_SIZE 10 + ++#define LONGS(x) (((x) + sizeof(unsigned long) - 1)/sizeof(unsigned long)) ++ + /* + * The minimum number of bits of entropy before we wake up a read on + * /dev/random. Should be enough to do a significant reseed. +@@ -813,11 +815,7 @@ static ssize_t extract_entropy(struct en + */ + static void xfer_secondary_pool(struct entropy_store *r, size_t nbytes) + { +- union { +- __u32 tmp[OUTPUT_POOL_WORDS]; +- long hwrand[4]; +- } u; +- int i; ++ __u32 tmp[OUTPUT_POOL_WORDS]; + + if (r->pull && r->entropy_count < nbytes * 8 && + r->entropy_count < r->poolinfo->POOLBITS) { +@@ -828,23 +826,17 @@ static void xfer_secondary_pool(struct e + /* pull at least as many as BYTES as wakeup BITS */ + bytes = max_t(int, bytes, random_read_wakeup_thresh / 8); + /* but never more than the buffer size */ +- bytes = min_t(int, bytes, sizeof(u.tmp)); ++ bytes = min_t(int, bytes, sizeof(tmp)); + + DEBUG_ENT("going to reseed %s with %d bits " + "(%d of %d requested)\n", + r->name, bytes * 8, nbytes * 8, r->entropy_count); + +- bytes = extract_entropy(r->pull, u.tmp, bytes, ++ bytes = extract_entropy(r->pull, tmp, bytes, + random_read_wakeup_thresh / 8, rsvd); +- mix_pool_bytes(r, u.tmp, bytes, NULL); ++ mix_pool_bytes(r, tmp, bytes, NULL); + credit_entropy_bits(r, bytes*8); + } +- kmemcheck_mark_initialized(&u.hwrand, sizeof(u.hwrand)); +- for (i = 0; i < 4; i++) +- if (arch_get_random_long(&u.hwrand[i])) +- break; +- if (i) +- mix_pool_bytes(r, &u.hwrand, sizeof(u.hwrand), 0); + } + + /* +@@ -901,15 +893,19 @@ static size_t account(struct entropy_sto + static void extract_buf(struct entropy_store *r, __u8 *out) + { + int i; +- __u32 hash[5], workspace[SHA_WORKSPACE_WORDS]; ++ union { ++ __u32 w[5]; ++ unsigned long l[LONGS(EXTRACT_SIZE)]; ++ } hash; ++ __u32 workspace[SHA_WORKSPACE_WORDS]; + __u8 extract[64]; + unsigned long flags; + + /* Generate a hash across the pool, 16 words (512 bits) at a time */ +- sha_init(hash); ++ sha_init(hash.w); + spin_lock_irqsave(&r->lock, flags); + for (i = 0; i < r->poolinfo->poolwords; i += 16) +- sha_transform(hash, (__u8 *)(r->pool + i), workspace); ++ sha_transform(hash.w, (__u8 *)(r->pool + i), workspace); + + /* + * We mix the hash back into the pool to prevent backtracking +@@ -920,14 +916,14 @@ static void extract_buf(struct entropy_s + * brute-forcing the feedback as hard as brute-forcing the + * hash. + */ +- __mix_pool_bytes(r, hash, sizeof(hash), extract); ++ __mix_pool_bytes(r, hash.w, sizeof(hash.w), extract); + spin_unlock_irqrestore(&r->lock, flags); + + /* + * To avoid duplicates, we atomically extract a portion of the + * pool while mixing, and hash one final time. + */ +- sha_transform(hash, extract, workspace); ++ sha_transform(hash.w, extract, workspace); + memset(extract, 0, sizeof(extract)); + memset(workspace, 0, sizeof(workspace)); + +@@ -936,11 +932,23 @@ static void extract_buf(struct entropy_s + * pattern, we fold it in half. Thus, we always feed back + * twice as much data as we output. + */ +- hash[0] ^= hash[3]; +- hash[1] ^= hash[4]; +- hash[2] ^= rol32(hash[2], 16); +- memcpy(out, hash, EXTRACT_SIZE); +- memset(hash, 0, sizeof(hash)); ++ hash.w[0] ^= hash.w[3]; ++ hash.w[1] ^= hash.w[4]; ++ hash.w[2] ^= rol32(hash.w[2], 16); ++ ++ /* ++ * If we have a architectural hardware random number ++ * generator, mix that in, too. ++ */ ++ for (i = 0; i < LONGS(EXTRACT_SIZE); i++) { ++ unsigned long v; ++ if (!arch_get_random_long(&v)) ++ break; ++ hash.l[i] ^= v; ++ } ++ ++ memcpy(out, &hash, EXTRACT_SIZE); ++ memset(&hash, 0, sizeof(hash)); + } + + static ssize_t extract_entropy(struct entropy_store *r, void *buf, diff --git a/queue-3.4/random-remove-rand_initialize_irq.patch b/queue-3.4/random-remove-rand_initialize_irq.patch new file mode 100644 index 00000000000..fe660bddbb5 --- /dev/null +++ b/queue-3.4/random-remove-rand_initialize_irq.patch @@ -0,0 +1,176 @@ +From c5857ccf293968348e5eb4ebedc68074de3dcda6 Mon Sep 17 00:00:00 2001 +From: Theodore Ts'o +Date: Sat, 14 Jul 2012 20:27:52 -0400 +Subject: random: remove rand_initialize_irq() + +From: Theodore Ts'o + +commit c5857ccf293968348e5eb4ebedc68074de3dcda6 upstream. + +With the new interrupt sampling system, we are no longer using the +timer_rand_state structure in the irq descriptor, so we can stop +initializing it now. + +[ Merged in fixes from Sedat to find some last missing references to + rand_initialize_irq() ] + +Signed-off-by: "Theodore Ts'o" +Signed-off-by: Sedat Dilek +Signed-off-by: Greg Kroah-Hartman + +--- + arch/ia64/kernel/irq_ia64.c | 1 + drivers/char/random.c | 55 -------------------------------------------- + drivers/mfd/ab3100-core.c | 3 -- + include/linux/irqdesc.h | 1 + include/linux/random.h | 2 - + kernel/irq/manage.c | 17 ------------- + 6 files changed, 79 deletions(-) + +--- a/arch/ia64/kernel/irq_ia64.c ++++ b/arch/ia64/kernel/irq_ia64.c +@@ -23,7 +23,6 @@ + #include + #include + #include +-#include /* for rand_initialize_irq() */ + #include + #include + #include +--- a/drivers/char/random.c ++++ b/drivers/char/random.c +@@ -634,43 +634,6 @@ struct timer_rand_state { + unsigned dont_count_entropy:1; + }; + +-#ifndef CONFIG_GENERIC_HARDIRQS +- +-static struct timer_rand_state *irq_timer_state[NR_IRQS]; +- +-static struct timer_rand_state *get_timer_rand_state(unsigned int irq) +-{ +- return irq_timer_state[irq]; +-} +- +-static void set_timer_rand_state(unsigned int irq, +- struct timer_rand_state *state) +-{ +- irq_timer_state[irq] = state; +-} +- +-#else +- +-static struct timer_rand_state *get_timer_rand_state(unsigned int irq) +-{ +- struct irq_desc *desc; +- +- desc = irq_to_desc(irq); +- +- return desc->timer_rand_state; +-} +- +-static void set_timer_rand_state(unsigned int irq, +- struct timer_rand_state *state) +-{ +- struct irq_desc *desc; +- +- desc = irq_to_desc(irq); +- +- desc->timer_rand_state = state; +-} +-#endif +- + /* + * Add device- or boot-specific data to the input and nonblocking + * pools to help initialize them to unique values. +@@ -1133,24 +1096,6 @@ static int rand_initialize(void) + } + module_init(rand_initialize); + +-void rand_initialize_irq(int irq) +-{ +- struct timer_rand_state *state; +- +- state = get_timer_rand_state(irq); +- +- if (state) +- return; +- +- /* +- * If kzalloc returns null, we just won't use that entropy +- * source. +- */ +- state = kzalloc(sizeof(struct timer_rand_state), GFP_KERNEL); +- if (state) +- set_timer_rand_state(irq, state); +-} +- + #ifdef CONFIG_BLOCK + void rand_initialize_disk(struct gendisk *disk) + { +--- a/drivers/mfd/ab3100-core.c ++++ b/drivers/mfd/ab3100-core.c +@@ -931,9 +931,6 @@ static int __devinit ab3100_probe(struct + + err = request_threaded_irq(client->irq, NULL, ab3100_irq_handler, + IRQF_ONESHOT, "ab3100-core", ab3100); +- /* This real unpredictable IRQ is of course sampled for entropy */ +- rand_initialize_irq(client->irq); +- + if (err) + goto exit_no_irq; + +--- a/include/linux/irqdesc.h ++++ b/include/linux/irqdesc.h +@@ -39,7 +39,6 @@ struct module; + */ + struct irq_desc { + struct irq_data irq_data; +- struct timer_rand_state *timer_rand_state; + unsigned int __percpu *kstat_irqs; + irq_flow_handler_t handle_irq; + #ifdef CONFIG_IRQ_PREFLOW_FASTEOI +--- a/include/linux/random.h ++++ b/include/linux/random.h +@@ -48,8 +48,6 @@ struct rnd_state { + + #ifdef __KERNEL__ + +-extern void rand_initialize_irq(int irq); +- + extern void add_device_randomness(const void *, unsigned int); + extern void add_input_randomness(unsigned int type, unsigned int code, + unsigned int value); +--- a/kernel/irq/manage.c ++++ b/kernel/irq/manage.c +@@ -890,22 +890,6 @@ __setup_irq(unsigned int irq, struct irq + return -ENOSYS; + if (!try_module_get(desc->owner)) + return -ENODEV; +- /* +- * Some drivers like serial.c use request_irq() heavily, +- * so we have to be careful not to interfere with a +- * running system. +- */ +- if (new->flags & IRQF_SAMPLE_RANDOM) { +- /* +- * This function might sleep, we want to call it first, +- * outside of the atomic block. +- * Yes, this might clear the entropy pool if the wrong +- * driver is attempted to be loaded, without actually +- * installing a new handler, but is this really a problem, +- * only the sysadmin is able to do this. +- */ +- rand_initialize_irq(irq); +- } + + /* + * Check whether the interrupt nests into another interrupt +@@ -1339,7 +1323,6 @@ EXPORT_SYMBOL(free_irq); + * Flags: + * + * IRQF_SHARED Interrupt is shared +- * IRQF_SAMPLE_RANDOM The interrupt can be used for entropy + * IRQF_TRIGGER_* Specify active edge(s) or level + * + */ diff --git a/queue-3.4/random-use-the-arch-specific-rng-in-xfer_secondary_pool.patch b/queue-3.4/random-use-the-arch-specific-rng-in-xfer_secondary_pool.patch new file mode 100644 index 00000000000..d9885d11348 --- /dev/null +++ b/queue-3.4/random-use-the-arch-specific-rng-in-xfer_secondary_pool.patch @@ -0,0 +1,88 @@ +From e6d4947b12e8ad947add1032dd754803c6004824 Mon Sep 17 00:00:00 2001 +From: Theodore Ts'o +Date: Thu, 5 Jul 2012 10:21:01 -0400 +Subject: random: use the arch-specific rng in xfer_secondary_pool + +From: Theodore Ts'o + +commit e6d4947b12e8ad947add1032dd754803c6004824 upstream. + +If the CPU supports a hardware random number generator, use it in +xfer_secondary_pool(), where it will significantly improve things and +where we can afford it. + +Also, remove the use of the arch-specific rng in +add_timer_randomness(), since the call is significantly slower than +get_cycles(), and we're much better off using it in +xfer_secondary_pool() anyway. + +Signed-off-by: "Theodore Ts'o" +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/char/random.c | 25 ++++++++++++++++--------- + 1 file changed, 16 insertions(+), 9 deletions(-) + +--- a/drivers/char/random.c ++++ b/drivers/char/random.c +@@ -254,6 +254,7 @@ + #include + #include + #include ++#include + + #ifdef CONFIG_GENERIC_HARDIRQS + # include +@@ -702,11 +703,7 @@ static void add_timer_randomness(struct + goto out; + + sample.jiffies = jiffies; +- +- /* Use arch random value, fall back to cycles */ +- if (!arch_get_random_int(&sample.cycles)) +- sample.cycles = get_cycles(); +- ++ sample.cycles = get_cycles(); + sample.num = num; + mix_pool_bytes(&input_pool, &sample, sizeof(sample), NULL); + +@@ -838,7 +835,11 @@ static ssize_t extract_entropy(struct en + */ + static void xfer_secondary_pool(struct entropy_store *r, size_t nbytes) + { +- __u32 tmp[OUTPUT_POOL_WORDS]; ++ union { ++ __u32 tmp[OUTPUT_POOL_WORDS]; ++ long hwrand[4]; ++ } u; ++ int i; + + if (r->pull && r->entropy_count < nbytes * 8 && + r->entropy_count < r->poolinfo->POOLBITS) { +@@ -849,17 +850,23 @@ static void xfer_secondary_pool(struct e + /* pull at least as many as BYTES as wakeup BITS */ + bytes = max_t(int, bytes, random_read_wakeup_thresh / 8); + /* but never more than the buffer size */ +- bytes = min_t(int, bytes, sizeof(tmp)); ++ bytes = min_t(int, bytes, sizeof(u.tmp)); + + DEBUG_ENT("going to reseed %s with %d bits " + "(%d of %d requested)\n", + r->name, bytes * 8, nbytes * 8, r->entropy_count); + +- bytes = extract_entropy(r->pull, tmp, bytes, ++ bytes = extract_entropy(r->pull, u.tmp, bytes, + random_read_wakeup_thresh / 8, rsvd); +- mix_pool_bytes(r, tmp, bytes, NULL); ++ mix_pool_bytes(r, u.tmp, bytes, NULL); + credit_entropy_bits(r, bytes*8); + } ++ kmemcheck_mark_initialized(&u.hwrand, sizeof(u.hwrand)); ++ for (i = 0; i < 4; i++) ++ if (arch_get_random_long(&u.hwrand[i])) ++ break; ++ if (i) ++ mix_pool_bytes(r, &u.hwrand, sizeof(u.hwrand), 0); + } + + /* diff --git a/queue-3.4/rtc-wm831x-feed-the-write-counter-into-device_add_randomness.patch b/queue-3.4/rtc-wm831x-feed-the-write-counter-into-device_add_randomness.patch new file mode 100644 index 00000000000..ffc4af4807a --- /dev/null +++ b/queue-3.4/rtc-wm831x-feed-the-write-counter-into-device_add_randomness.patch @@ -0,0 +1,72 @@ +From 9dccf55f4cb011a7552a8a2749a580662f5ed8ed Mon Sep 17 00:00:00 2001 +From: Mark Brown +Date: Thu, 5 Jul 2012 20:19:17 +0000 +Subject: rtc: wm831x: Feed the write counter into device_add_randomness() + +From: Mark Brown + +commit 9dccf55f4cb011a7552a8a2749a580662f5ed8ed upstream. + +The tamper evident features of the RTC include the "write counter" which +is a pseudo-random number regenerated whenever we set the RTC. Since this +value is unpredictable it should provide some useful seeding to the random +number generator. + +Only do this on boot since the goal is to seed the pool rather than add +useful entropy. + +Signed-off-by: Mark Brown +Signed-off-by: Theodore Ts'o +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/rtc/rtc-wm831x.c | 24 +++++++++++++++++++++++- + 1 file changed, 23 insertions(+), 1 deletion(-) + +--- a/drivers/rtc/rtc-wm831x.c ++++ b/drivers/rtc/rtc-wm831x.c +@@ -24,7 +24,7 @@ + #include + #include + #include +- ++#include + + /* + * R16416 (0x4020) - RTC Write Counter +@@ -96,6 +96,26 @@ struct wm831x_rtc { + unsigned int alarm_enabled:1; + }; + ++static void wm831x_rtc_add_randomness(struct wm831x *wm831x) ++{ ++ int ret; ++ u16 reg; ++ ++ /* ++ * The write counter contains a pseudo-random number which is ++ * regenerated every time we set the RTC so it should be a ++ * useful per-system source of entropy. ++ */ ++ ret = wm831x_reg_read(wm831x, WM831X_RTC_WRITE_COUNTER); ++ if (ret >= 0) { ++ reg = ret; ++ add_device_randomness(®, sizeof(reg)); ++ } else { ++ dev_warn(wm831x->dev, "Failed to read RTC write counter: %d\n", ++ ret); ++ } ++} ++ + /* + * Read current time and date in RTC + */ +@@ -431,6 +451,8 @@ static int wm831x_rtc_probe(struct platf + alm_irq, ret); + } + ++ wm831x_rtc_add_randomness(wm831x); ++ + return 0; + + err: diff --git a/queue-3.4/series b/queue-3.4/series index 6cb077341a6..34a1c399bbd 100644 --- a/queue-3.4/series +++ b/queue-3.4/series @@ -32,3 +32,16 @@ random-use-lockless-techniques-in-the-interrupt-path.patch random-create-add_device_randomness-interface.patch usb-feed-usb-device-information-to-the-dev-random-driver.patch net-feed-dev-random-with-the-mac-address-when-registering-a-device.patch +random-use-the-arch-specific-rng-in-xfer_secondary_pool.patch +random-add-new-get_random_bytes_arch-function.patch +random-add-tracepoints-for-easier-debugging-and-verification.patch +maintainers-theodore-ts-o-is-taking-over-the-random-driver.patch +rtc-wm831x-feed-the-write-counter-into-device_add_randomness.patch +mfd-wm831x-feed-the-device-uuid-into-device_add_randomness.patch +random-remove-rand_initialize_irq.patch +random-add-comment-to-random_initialize.patch +dmi-feed-dmi-table-to-dev-random-driver.patch +random-mix-in-architectural-randomness-in-extract_buf.patch +hid-multitouch-add-support-for-novatek-touchscreen.patch +hid-add-support-for-cypress-barcode-scanner-04b4-ed81.patch +hid-add-asus-aio-keyboard-model-ak1d.patch