-/* $OpenBSD: cpu.c,v 1.124 2024/07/10 11:01:24 kettenis Exp $ */
+/* $OpenBSD: cpu.c,v 1.125 2024/07/11 12:07:39 kettenis Exp $ */
/*
* Copyright (c) 2016 Dale Rahn <drahn@dalerahn.com>
uint64_t cpu_id_aa64pfr1;
int arm64_has_lse;
+int arm64_has_rng;
#ifdef CRYPTO
int arm64_has_aes;
#endif
NULL, "cpu", DV_DULL
};
+struct timeout cpu_rng_to;
+void cpu_rng(void *);
+
void cpu_opp_init(struct cpu_info *, uint32_t);
void cpu_psci_init(struct cpu_info *);
void cpu_psci_idle_cycle(void);
void cpu_opp_kstat_attach(struct cpu_info *ci);
#endif
+void
+cpu_rng(void *arg)
+{
+ struct timeout *to = arg;
+ uint64_t rndr;
+ int ret;
+
+ ret = __builtin_arm_rndrrs(&rndr);
+ if (ret)
+ ret = __builtin_arm_rndr(&rndr);
+ if (ret == 0) {
+ enqueue_randomness(rndr & 0xffffffff);
+ enqueue_randomness(rndr >> 32);
+ }
+
+ if (to)
+ timeout_add_msec(to, 1000);
+}
+
/*
* Enable mitigation for Spectre-V2 branch target injection
* vulnerabilities (CVE-2017-5715).
if (ID_AA64ISAR0_RNDR(id) >= ID_AA64ISAR0_RNDR_IMPL) {
printf("%sRNDR", sep);
sep = ",";
+ arm64_has_rng = 1;
}
if (ID_AA64ISAR0_TLB(id) >= ID_AA64ISAR0_TLB_IOS) {
}
cpu_init();
+
+ if (arm64_has_rng) {
+ timeout_set(&cpu_rng_to, cpu_rng, &cpu_rng_to);
+ cpu_rng(&cpu_rng_to);
+ }
#ifdef MULTIPROCESSOR
}
#endif
-# $OpenBSD: Makefile.arm64,v 1.48 2024/07/02 10:25:16 kettenis Exp $
+# $OpenBSD: Makefile.arm64,v 1.49 2024/07/11 12:07:40 kettenis Exp $
# For instructions on building kernels consult the config(8) and options(4)
# manual pages.
-Wno-unused-but-set-variable -Wno-gnu-folding-constant \
-Wframe-larger-than=2047
-CMACHFLAGS= -march=armv8-a+nofp+nosimd \
+CMACHFLAGS= -march=armv8-a+nofp+nosimd+rng \
-fno-omit-frame-pointer -mno-omit-leaf-frame-pointer \
-ffixed-x18
CMACHFLAGS+= -ffreestanding ${NOPIE_FLAGS}