tc_fill_vdso_timehands32(): fix

On 64bit, there is a 4-byte hole in struct vdso_timekeep32 after
tk_current, if the structure is not packed.  This is due to the MD
th_x86_pvc_last_systime being 64bit.

Change amd64 VDSO_TIMEHANDS_MD32 to not use uint64_t, replace it with
pair of uint32_t, as it is done for all other members.

PR:	273085
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
This commit is contained in:
Konstantin Belousov 2023-08-12 22:51:37 +03:00
parent 41acfee690
commit 93626d5437
4 changed files with 11 additions and 4 deletions

View file

@ -171,7 +171,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);

View file

@ -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

View file

@ -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;

View file

@ -990,7 +990,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);