git: 8fe73008036b - stable/13 - tc_fill_vdso_timehands32(): fix

From: Konstantin Belousov <kib_at_FreeBSD.org>
Date: Sat, 19 Aug 2023 00:35:57 UTC
The branch stable/13 has been updated by kib:

URL: https://cgit.FreeBSD.org/src/commit/?id=8fe73008036b0770e3d0a5b41e9b845feb46bdf1

commit 8fe73008036b0770e3d0a5b41e9b845feb46bdf1
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2023-08-12 19:51:37 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2023-08-19 00:35:29 +0000

    tc_fill_vdso_timehands32(): fix
    
    PR:     273085
    
    (cherry picked from commit 93626d54370292b09cd0ca604b144737109e9071)
---
 sys/dev/acpica/acpi_hpet.c | 3 ++-
 sys/x86/include/vdso.h     | 7 ++++++-
 sys/x86/x86/pvclock.c      | 2 +-
 sys/x86/x86/tsc.c          | 3 ++-
 4 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/sys/dev/acpica/acpi_hpet.c b/sys/dev/acpica/acpi_hpet.c
index e35e3808a980..e6f83512feed 100644
--- a/sys/dev/acpica/acpi_hpet.c
+++ b/sys/dev/acpica/acpi_hpet.c
@@ -173,7 +173,8 @@ hpet_vdso_timehands32(struct vdso_timehands32 *vdso_th32,
 	vdso_th32->th_algo = VDSO_TH_ALGO_X86_HPET;
 	vdso_th32->th_x86_shift = 0;
 	vdso_th32->th_x86_hpet_idx = device_get_unit(sc->dev);
-	vdso_th32->th_x86_pvc_last_systime = 0;
+	vdso_th32->th_x86_pvc_last_systime[0] = 0;
+	vdso_th32->th_x86_pvc_last_systime[1] = 0;
 	vdso_th32->th_x86_pvc_stable_mask = 0;
 	bzero(vdso_th32->th_res, sizeof(vdso_th32->th_res));
 	return (sc->mmap_allow != 0);
diff --git a/sys/x86/include/vdso.h b/sys/x86/include/vdso.h
index 546a92a47301..be90e26702f7 100644
--- a/sys/x86/include/vdso.h
+++ b/sys/x86/include/vdso.h
@@ -49,7 +49,12 @@
 #ifdef _KERNEL
 #ifdef COMPAT_FREEBSD32
 
-#define	VDSO_TIMEHANDS_MD32	VDSO_TIMEHANDS_MD
+#define	VDSO_TIMEHANDS_MD32			\
+	uint32_t	th_x86_shift;		\
+	uint32_t	th_x86_hpet_idx;	\
+	uint32_t	th_x86_pvc_last_systime[2];\
+	uint8_t		th_x86_pvc_stable_mask;	\
+	uint8_t		th_res[15];
 
 #endif
 #endif
diff --git a/sys/x86/x86/pvclock.c b/sys/x86/x86/pvclock.c
index 3da3373bb2ee..9d8ac99f5a8a 100644
--- a/sys/x86/x86/pvclock.c
+++ b/sys/x86/x86/pvclock.c
@@ -253,7 +253,7 @@ pvclock_tc_vdso_timehands32(struct vdso_timehands32 *vdso_th,
 	vdso_th->th_algo = VDSO_TH_ALGO_X86_PVCLK;
 	vdso_th->th_x86_shift = 0;
 	vdso_th->th_x86_hpet_idx = 0;
-	vdso_th->th_x86_pvc_last_systime =
+	*(uint64_t *)&vdso_th->th_x86_pvc_last_systime[0] =
 	    atomic_load_acq_64(&pvclock_last_systime);
 	vdso_th->th_x86_pvc_stable_mask = !pvc->vdso_force_unstable &&
 	    pvc->stable_flag_supported ? PVCLOCK_FLAG_TSC_STABLE : 0;
diff --git a/sys/x86/x86/tsc.c b/sys/x86/x86/tsc.c
index 94305dfdc82f..4eab4dc1692b 100644
--- a/sys/x86/x86/tsc.c
+++ b/sys/x86/x86/tsc.c
@@ -967,7 +967,8 @@ x86_tsc_vdso_timehands32(struct vdso_timehands32 *vdso_th32,
 	vdso_th32->th_algo = VDSO_TH_ALGO_X86_TSC;
 	vdso_th32->th_x86_shift = (int)(intptr_t)tc->tc_priv;
 	vdso_th32->th_x86_hpet_idx = 0xffffffff;
-	vdso_th32->th_x86_pvc_last_systime = 0;
+	vdso_th32->th_x86_pvc_last_systime[0] = 0;
+	vdso_th32->th_x86_pvc_last_systime[1] = 0;
 	vdso_th32->th_x86_pvc_stable_mask = 0;
 	bzero(vdso_th32->th_res, sizeof(vdso_th32->th_res));
 	return (1);