aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOlivier Certner <olce@FreeBSD.org>2026-02-13 17:03:31 +0000
committerOlivier Certner <olce@FreeBSD.org>2026-02-16 10:28:48 +0000
commit7c2fc4419db43a8a7d1886b0b8e08aa97bfa31e4 (patch)
treea639de7f42fd906a95ca45ce3d585336c09f9572
parent38c18332642500fdfe075a82f88e033f6673a53f (diff)
sys/compat/freebsd32: FF clock struct: Don't pack, use 'ffcounter32'
Packing 'struct ffclock_estimate32', in absence of substitution of 'ffcounter' (some 'uint64_t') by a 32-bit compatible type, was necessary on amd64 since 'uint64_t' is 8-byte aligned, which leaves a padding gap of 4-byte between fields 'update_time' and 'update_ffcount'. This gap does not exist on i386 (or amd64 32-bit mode), as 'uint64_t' there is only 4-byte aligned. Change the type of the 'update_ffcount' and 'leapsec_next' fields to the recently introduced 'freebsd32_uint64_t', and adapt copy-in and copy-out accordingly. Using `CP()` previously worked due to the '__packed__' attribute. Reviewed by: kib MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D55282
-rw-r--r--sys/compat/freebsd32/freebsd32.h12
-rw-r--r--sys/compat/freebsd32/freebsd32_misc.c8
2 files changed, 9 insertions, 11 deletions
diff --git a/sys/compat/freebsd32/freebsd32.h b/sys/compat/freebsd32/freebsd32.h
index 5210ce55b228..1436b630689f 100644
--- a/sys/compat/freebsd32/freebsd32.h
+++ b/sys/compat/freebsd32/freebsd32.h
@@ -60,8 +60,8 @@ struct bintime32 {
struct ffclock_estimate32 {
struct bintime32 update_time;
- ffcounter update_ffcount;
- ffcounter leapsec_next;
+ freebsd32_uint64_t update_ffcount;
+ freebsd32_uint64_t leapsec_next;
freebsd32_uint64_t period;
uint32_t errb_abs;
uint32_t errb_rate;
@@ -69,11 +69,9 @@ struct ffclock_estimate32 {
int16_t leapsec_total;
int8_t leapsec;
int8_t _pad;
-}
-#if defined(__amd64__)
-__attribute__((packed))
-#endif
-;
+};
+_Static_assert(sizeof(ffcounter) == sizeof(freebsd32_uint64_t),
+ "'ffcounter' size discrepancy'");
#if defined(__amd64__) || defined(__i386__)
_Static_assert(sizeof(struct ffclock_estimate32) == 52, "ffclock_estimate32 size");
#else
diff --git a/sys/compat/freebsd32/freebsd32_misc.c b/sys/compat/freebsd32/freebsd32_misc.c
index 457e599c22d2..1064987c3abf 100644
--- a/sys/compat/freebsd32/freebsd32_misc.c
+++ b/sys/compat/freebsd32/freebsd32_misc.c
@@ -4147,8 +4147,8 @@ freebsd32_ffclock_setestimate(struct thread *td,
CP(cest.update_time, cest32.update_time, sec);
memcpy(&cest.update_time.frac, &cest32.update_time.frac, sizeof(uint64_t));
- CP(cest, cest32, update_ffcount);
- CP(cest, cest32, leapsec_next);
+ FU64_CP(cest, cest32, update_ffcount);
+ FU64_CP(cest, cest32, leapsec_next);
FU64_CP(cest, cest32, period);
CP(cest, cest32, errb_abs);
CP(cest, cest32, errb_rate);
@@ -4177,8 +4177,8 @@ freebsd32_ffclock_getestimate(struct thread *td,
CP(cest32.update_time, cest.update_time, sec);
memcpy(&cest32.update_time.frac, &cest.update_time.frac, sizeof(uint64_t));
- CP(cest32, cest, update_ffcount);
- CP(cest32, cest, leapsec_next);
+ FU64_CP(cest32, cest, update_ffcount);
+ FU64_CP(cest32, cest, leapsec_next);
FU64_CP(cest32, cest, period);
CP(cest32, cest, errb_abs);
CP(cest32, cest, errb_rate);