summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sys/arch/amd64/amd64/machdep.c34
-rw-r--r--sys/arch/amd64/conf/GENERIC1
-rw-r--r--sys/arch/amd64/isa/i8042.c18
-rw-r--r--sys/crypto/chacha20.c (renamed from sys/dev/random/chacha20.c)2
-rw-r--r--sys/crypto/siphash.c (renamed from sys/dev/random/siphash.c)2
-rw-r--r--sys/dev/random/entropy.c2
-rw-r--r--sys/dev/random/random.c4
-rw-r--r--sys/include/arch/amd64/cpu.h2
-rw-r--r--sys/include/crypto/chacha20.h (renamed from sys/include/dev/random/chacha20.h)0
-rw-r--r--sys/include/crypto/siphash.h (renamed from sys/include/dev/random/siphash.h)0
10 files changed, 55 insertions, 10 deletions
diff --git a/sys/arch/amd64/amd64/machdep.c b/sys/arch/amd64/amd64/machdep.c
index d310460..40950f9 100644
--- a/sys/arch/amd64/amd64/machdep.c
+++ b/sys/arch/amd64/amd64/machdep.c
@@ -187,9 +187,10 @@ enable_simd(void)
}
static void
-cpu_check_feat(struct cpu_info *ci)
+cpu_get_info(struct cpu_info *ci)
{
- uint32_t unused, ebx;
+ uint32_t eax, ebx, unused;
+ uint8_t ext_model, ext_family;
/* Extended features */
CPUID(0x07, unused, ebx, unused, unused);
@@ -197,6 +198,33 @@ cpu_check_feat(struct cpu_info *ci)
ci->feat |= CPU_FEAT_SMEP;
if (ISSET(ebx, BIT(20)))
ci->feat |= CPU_FEAT_SMAP;
+
+ /*
+ * Processor info and feature bits
+ */
+ CPUID(0x01, eax, unused, unused, unused);
+ ci->model = (eax >> 4) & 0xF;
+ ci->family = (eax >> 8) & 0xF;
+
+ /*
+ * If the family ID is 15 then the actual family
+ * ID is the sum of the extended family and the
+ * family ID fields.
+ */
+ if (ci->family == 0xF) {
+ ext_family = (eax >> 20) & 0xFF;
+ ci->family += ext_family;
+ }
+
+ /*
+ * If the family has the value of either 6 or 15,
+ * then the extended model number would be used.
+ * Slap them together if this is the case.
+ */
+ if (ci->family == 6 || ci->family == 15) {
+ ext_model = (eax >> 16) & 0xF;
+ ci->model |= (ext_model << 4);
+ }
}
void
@@ -383,7 +411,7 @@ cpu_startup(struct cpu_info *ci)
init_tss(ci);
try_mitigate_spectre();
- cpu_check_feat(ci);
+ cpu_get_info(ci);
cpu_enable_smep();
enable_simd();
diff --git a/sys/arch/amd64/conf/GENERIC b/sys/arch/amd64/conf/GENERIC
index 95fe2e0..e407fa9 100644
--- a/sys/arch/amd64/conf/GENERIC
+++ b/sys/arch/amd64/conf/GENERIC
@@ -10,6 +10,7 @@ option SERIAL_DEBUG yes // Enable kmsg serial logging
option USER_KMSG no // Show kmsg in user consoles
option CPU_SMEP yes // Supervisor Memory Exec Protection
option PANIC_SCR no // Clear screen on panic
+option I8042_POLL yes // Use polling for the i8042
// Kernel constants
setval SCHED_NQUEUE 4 // Number of scheduler queues (for MLFQ)
diff --git a/sys/arch/amd64/isa/i8042.c b/sys/arch/amd64/isa/i8042.c
index cde70ff..3ae645d 100644
--- a/sys/arch/amd64/isa/i8042.c
+++ b/sys/arch/amd64/isa/i8042.c
@@ -53,6 +53,13 @@
#include <string.h>
#include <assert.h>
+/* From kconf(9) */
+#if !defined(__I8042_POLL)
+#define I8042_POLL 0
+#else
+#define I8042_POLL __I8042_POLL
+#endif
+
#define KEY_REP_MAX 2
#define pr_trace(fmt, ...) kprintf("i8042: " fmt, ##__VA_ARGS__)
@@ -424,13 +431,20 @@ i8042_init(void)
quirks |= I8042_HOSTILE;
pr_trace("ThinkPad T420s detected, assuming hostile\n");
pr_trace("disabling irq 1, polling as fallback\n");
- spawn(&polltd, i8042_sync_loop, NULL, 0, NULL);
}
- if (!ISSET(quirks, I8042_HOSTILE)) {
+ /*
+ * If the i8042 has the hostile quirk or we are
+ * configured to poll for events, spawn the polling
+ * thread.
+ */
+ if (!ISSET(quirks, I8042_HOSTILE) && !I8042_POLL) {
/* Enable interrupts */
i8042_drain();
i8042_en_intr();
+ } else if (ISSET(quirks, I8042_HOSTILE) || I8042_POLL) {
+ spawn(&polltd, i8042_sync_loop, NULL, 0, NULL);
+ pr_trace("polling events\n");
}
i8042_write(I8042_CMD, I8042_ENABLE_PORT0);
diff --git a/sys/dev/random/chacha20.c b/sys/crypto/chacha20.c
index 41f823c..5c979a2 100644
--- a/sys/dev/random/chacha20.c
+++ b/sys/crypto/chacha20.c
@@ -27,7 +27,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include <dev/random/chacha20.h>
+#include <crypto/chacha20.h>
static const char sigma[16] = "expand 32-byte k";
diff --git a/sys/dev/random/siphash.c b/sys/crypto/siphash.c
index 2b2243f..e0cad44 100644
--- a/sys/dev/random/siphash.c
+++ b/sys/crypto/siphash.c
@@ -29,7 +29,7 @@
Jean-Philippe Aumasson (https://131002.net/siphash/siphash24.c)
*/
-#include <dev/random/siphash.h>
+#include <crypto/siphash.h>
#include <stdint.h>
#if defined(__BYTE_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__) && \
diff --git a/sys/dev/random/entropy.c b/sys/dev/random/entropy.c
index d392b9c..4e723a4 100644
--- a/sys/dev/random/entropy.c
+++ b/sys/dev/random/entropy.c
@@ -30,7 +30,7 @@
#include <stdint.h>
#include <string.h>
#include <dev/random/entropy.h>
-#include <dev/random/siphash.h>
+#include <crypto/siphash.h>
void
mix_entropy(struct entropy_pool *ep, const uint8_t *input,
diff --git a/sys/dev/random/random.c b/sys/dev/random/random.c
index d79df69..9bca719 100644
--- a/sys/dev/random/random.c
+++ b/sys/dev/random/random.c
@@ -30,9 +30,9 @@
#include <sys/sio.h>
#include <sys/device.h>
#include <sys/driver.h>
-#include <dev/random/chacha20.h>
-#include <dev/random/siphash.h>
#include <dev/random/entropy.h>
+#include <crypto/chacha20.h>
+#include <crypto/siphash.h>
#include <fs/devfs.h>
#include <string.h>
diff --git a/sys/include/arch/amd64/cpu.h b/sys/include/arch/amd64/cpu.h
index 46e5df7..a5f09fb 100644
--- a/sys/include/arch/amd64/cpu.h
+++ b/sys/include/arch/amd64/cpu.h
@@ -45,6 +45,8 @@
struct cpu_info {
uint32_t apicid;
uint32_t feat;
+ uint8_t model : 4; /* CPU model number */
+ uint8_t family : 4; /* CPU family ID */
uint8_t has_x2apic : 1;
uint8_t tlb_shootdown : 1;
uint8_t ipl;
diff --git a/sys/include/dev/random/chacha20.h b/sys/include/crypto/chacha20.h
index d35702a..d35702a 100644
--- a/sys/include/dev/random/chacha20.h
+++ b/sys/include/crypto/chacha20.h
diff --git a/sys/include/dev/random/siphash.h b/sys/include/crypto/siphash.h
index ecabb4a..ecabb4a 100644
--- a/sys/include/dev/random/siphash.h
+++ b/sys/include/crypto/siphash.h