Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F108197284
D22946.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
3 KB
Referenced Files
None
Subscribers
None
D22946.diff
View Options
Index: head/sys/dev/random/fortuna.c
===================================================================
--- head/sys/dev/random/fortuna.c
+++ head/sys/dev/random/fortuna.c
@@ -359,6 +359,13 @@
*/
pl = event->he_destination % RANDOM_FORTUNA_NPOOLS;
/*
+ * If a VM generation ID changes (clone and play or VM rewind), we want
+ * to incorporate that as soon as possible. Override destingation pool
+ * for immediate next use.
+ */
+ if (event->he_source == RANDOM_PURE_VMGENID)
+ pl = 0;
+ /*
* We ignore low entropy static/counter fields towards the end of the
* he_event structure in order to increase measurable entropy when
* conducting SP800-90B entropy analysis measurements of seed material
Index: head/sys/dev/random/random_harvestq.c
===================================================================
--- head/sys/dev/random/random_harvestq.c
+++ head/sys/dev/random/random_harvestq.c
@@ -354,6 +354,7 @@
[RANDOM_PURE_CCP] = "PURE_CCP",
[RANDOM_PURE_DARN] = "PURE_DARN",
[RANDOM_PURE_TPM] = "PURE_TPM",
+ [RANDOM_PURE_VMGENID] = "VMGENID",
/* "ENTROPYSOURCE" */
};
Index: head/sys/dev/vmgenc/vmgenc_acpi.c
===================================================================
--- head/sys/dev/vmgenc/vmgenc_acpi.c
+++ head/sys/dev/vmgenc/vmgenc_acpi.c
@@ -52,12 +52,14 @@
#include <sys/malloc.h>
#include <sys/module.h>
#include <sys/mutex.h>
+#include <sys/random.h>
#include <sys/sysctl.h>
#include <sys/systm.h>
#include <contrib/dev/acpica/include/acpi.h>
#include <dev/acpica/acpivar.h>
+#include <dev/random/random_harvestq.h>
#include <dev/vmgenc/vmgenc_acpi.h>
#ifndef ACPI_NOTIFY_STATUS_CHANGED
@@ -80,6 +82,20 @@
};
static void
+vmgenc_harvest_all(const void *p, size_t sz)
+{
+ size_t nbytes;
+
+ while (sz > 0) {
+ nbytes = MIN(sz,
+ sizeof(((struct harvest_event *)0)->he_entropy));
+ random_harvest_direct(p, nbytes, RANDOM_PURE_VMGENID);
+ p = (const char *)p + nbytes;
+ sz -= nbytes;
+ }
+}
+
+static void
vmgenc_status_changed(void *context)
{
uint8_t guid[GUID_BYTES];
@@ -97,6 +113,8 @@
/* Update cache. */
memcpy(sc->vmg_cache_guid, guid, GUID_BYTES);
+ vmgenc_harvest_all(sc->vmg_cache_guid, sizeof(sc->vmg_cache_guid));
+
EVENTHANDLER_INVOKE(acpi_vmgenc_event);
acpi_UserNotify("VMGenerationCounter", acpi_get_handle(dev), 0);
}
@@ -219,6 +237,9 @@
memcpy(sc->vmg_cache_guid, __DEVOLATILE(void *, sc->vmg_pguid),
sizeof(sc->vmg_cache_guid));
+ random_harvest_register_source(RANDOM_PURE_VMGENID);
+ vmgenc_harvest_all(sc->vmg_cache_guid, sizeof(sc->vmg_cache_guid));
+
AcpiInstallNotifyHandler(h, ACPI_DEVICE_NOTIFY, vmgenc_notify, dev);
return (0);
}
@@ -238,3 +259,4 @@
static devclass_t vmgenc_devclass;
DRIVER_MODULE(vmgenc, acpi, vmgenc_driver, vmgenc_devclass, NULL, NULL);
MODULE_DEPEND(vmgenc, acpi, 1, 1, 1);
+MODULE_DEPEND(vemgenc, random_harvestq, 1, 1, 1);
Index: head/sys/sys/random.h
===================================================================
--- head/sys/sys/random.h
+++ head/sys/sys/random.h
@@ -102,6 +102,7 @@
RANDOM_PURE_CCP,
RANDOM_PURE_DARN,
RANDOM_PURE_TPM,
+ RANDOM_PURE_VMGENID,
ENTROPYSOURCE
};
_Static_assert(ENTROPYSOURCE <= 32,
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Jan 23, 1:04 PM (21 h, 22 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
16054663
Default Alt Text
D22946.diff (3 KB)
Attached To
Mode
D22946: vmgenid(4): Integrate as a random(4) source
Attached
Detach File
Event Timeline
Log In to Comment