On Mon, 22 Jun 2020 19:12:22 +0300
Paul Irofti <[email protected]> wrote:
> New iteration:
>
> - ps_timekeep should not coredump, pointed by deraadt@
> - set ps_timekeep to 0 before user uvm_map for randomization
> - map timekeep before fixup. confirmed by naddy@ that it fixes NULL init
> - initialize va. clarified by kettenis@
Here's macppc again. My macppc isn't using your newest diff but does
now need to define TC_TB in <machine/timetc.h>.
The /sys/arch/powerpc/include/timetc.h in your diff never gets used,
because there is no #include <powerpc/timetc.h>. On macppc,
uname -m => macppc and
uname -p => powerpc are different,
and #include <machine/timetc.h> is /sys/arch/macppc/include/timetc.h.
I suspect that <machine/timetc.h> is /sys/arch/$i/include/timetc.h
if and only if /sys/arch/$i/compile exists.
10 days ago, naddy said, "You only need the lower register." That is
correct, so this diff also stops using mftbu (the higher register).
--- lib/libc/arch/powerpc/gen/usertc.c.before Wed Jun 24 16:42:36 2020
+++ lib/libc/arch/powerpc/gen/usertc.c Wed Jun 24 16:46:00 2020
@@ -18,4 +18,17 @@
#include <sys/types.h>
#include <sys/timetc.h>
-int (*const _tc_get_timecount)(struct timekeep *, u_int *) = NULL;
+int
+tc_get_timecount(struct timekeep *tk, u_int *tc)
+{
+ u_int tb;
+
+ if (tk->tk_user != TC_TB)
+ return -1;
+
+ asm volatile("mftb %0" : "=r"(tb));
+ *tc = tb;
+ return 0;
+}
+int (*const _tc_get_timecount)(struct timekeep *tk, u_int *tc)
+ = tc_get_timecount;
--- sys/arch/macppc/include/timetc.h.before Wed Jun 24 16:36:03 2020
+++ sys/arch/macppc/include/timetc.h Wed Jun 24 16:37:47 2020
@@ -18,6 +18,7 @@
#ifndef _MACHINE_TIMETC_H_
#define _MACHINE_TIMETC_H_
-#define TC_LAST 0
+#define TC_TB 1
+#define TC_LAST 2
#endif /* _MACHINE_TIMETC_H_ */
--- sys/arch/macppc/macppc/clock.c.before Wed Jun 24 16:39:58 2020
+++ sys/arch/macppc/macppc/clock.c Wed Jun 24 16:40:08 2020
@@ -57,7 +57,7 @@
static int32_t ticks_per_intr;
static struct timecounter tb_timecounter = {
- tb_get_timecount, NULL, 0x7fffffff, 0, "tb", 0, NULL, 0
+ tb_get_timecount, NULL, 0x7fffffff, 0, "tb", 0, NULL, TC_TB
};
/* calibrate the timecounter frequency for the listed models */