Changeset View
Changeset View
Standalone View
Standalone View
sys/kern/kern_sharedpage.c
Show First 20 Lines • Show All 299 Lines • ▼ Show 20 Lines | alloc_sv_fxrng_generation(void) | ||||
}; | }; | ||||
} | } | ||||
#endif /* RANDOM_FENESTRASX */ | #endif /* RANDOM_FENESTRASX */ | ||||
void | void | ||||
exec_sysvec_init(void *param) | exec_sysvec_init(void *param) | ||||
{ | { | ||||
struct sysentvec *sv; | struct sysentvec *sv; | ||||
vm_offset_t sb; | |||||
#ifdef RANDOM_FENESTRASX | #ifdef RANDOM_FENESTRASX | ||||
ptrdiff_t base; | ptrdiff_t base; | ||||
#endif | #endif | ||||
u_int flags; | u_int flags; | ||||
int res; | |||||
sv = param; | sv = param; | ||||
flags = sv->sv_flags; | flags = sv->sv_flags; | ||||
if ((flags & SV_SHP) == 0) | if ((flags & SV_SHP) == 0) | ||||
return; | return; | ||||
MPASS(sv->sv_shared_page_obj == NULL); | MPASS(sv->sv_shared_page_obj == NULL); | ||||
MPASS(sv->sv_shared_page_base != 0); | MPASS(sv->sv_shared_page_base != 0); | ||||
sv->sv_shared_page_obj = shared_page_obj; | sv->sv_shared_page_obj = shared_page_obj; | ||||
if ((flags & SV_ABI_MASK) == SV_ABI_FREEBSD) { | if ((flags & SV_ABI_MASK) == SV_ABI_FREEBSD) { | ||||
if ((flags & SV_DSO_SIG) != 0) { | |||||
sb = sv->sv_shared_page_base; | |||||
res = shared_page_fill((uintptr_t)sv->sv_szsigcode, | |||||
16, sv->sv_sigcode); | |||||
if (res == -1) | |||||
panic("copying sigtramp to shared page"); | |||||
sb += res; | |||||
sv->sv_vdso_base = sb; | |||||
sb += sv->sv_sigcodeoff; | |||||
sv->sv_sigcode_base = sb; | |||||
} else { | |||||
sv->sv_sigcode_base = sv->sv_shared_page_base + | sv->sv_sigcode_base = sv->sv_shared_page_base + | ||||
shared_page_fill(*(sv->sv_szsigcode), 16, sv->sv_sigcode); | shared_page_fill(*(sv->sv_szsigcode), 16, | ||||
sv->sv_sigcode); | |||||
} | } | ||||
jrtc27: I wouldn't be surprised if some of the Linuxulator VDSO code can then reuse this, but that's… | |||||
} | |||||
if ((flags & SV_TIMEKEEP) != 0) { | if ((flags & SV_TIMEKEEP) != 0) { | ||||
#ifdef COMPAT_FREEBSD32 | #ifdef COMPAT_FREEBSD32 | ||||
if ((flags & SV_ILP32) != 0) { | if ((flags & SV_ILP32) != 0) { | ||||
if ((flags & SV_ABI_MASK) == SV_ABI_FREEBSD) { | if ((flags & SV_ABI_MASK) == SV_ABI_FREEBSD) { | ||||
KASSERT(compat32_svtk == NULL, | KASSERT(compat32_svtk == NULL, | ||||
("Compat32 already registered")); | ("Compat32 already registered")); | ||||
compat32_svtk = alloc_sv_tk_compat32(); | compat32_svtk = alloc_sv_tk_compat32(); | ||||
} else { | } else { | ||||
Show All 34 Lines | |||||
} | } | ||||
void | void | ||||
exec_sysvec_init_secondary(struct sysentvec *sv, struct sysentvec *sv2) | exec_sysvec_init_secondary(struct sysentvec *sv, struct sysentvec *sv2) | ||||
{ | { | ||||
MPASS((sv2->sv_flags & SV_ABI_MASK) == (sv->sv_flags & SV_ABI_MASK)); | MPASS((sv2->sv_flags & SV_ABI_MASK) == (sv->sv_flags & SV_ABI_MASK)); | ||||
MPASS((sv2->sv_flags & SV_TIMEKEEP) == (sv->sv_flags & SV_TIMEKEEP)); | MPASS((sv2->sv_flags & SV_TIMEKEEP) == (sv->sv_flags & SV_TIMEKEEP)); | ||||
MPASS((sv2->sv_flags & SV_SHP) != 0 && (sv->sv_flags & SV_SHP) != 0); | MPASS((sv2->sv_flags & SV_SHP) != 0 && (sv->sv_flags & SV_SHP) != 0); | ||||
MPASS((sv2->sv_flags & SV_DSO_SIG) != 0 && | |||||
(sv->sv_flags & SV_DSO_SIG) != 0); | |||||
MPASS((sv2->sv_flags & SV_RNG_SEED_VER) == | MPASS((sv2->sv_flags & SV_RNG_SEED_VER) == | ||||
(sv->sv_flags & SV_RNG_SEED_VER)); | (sv->sv_flags & SV_RNG_SEED_VER)); | ||||
sv2->sv_shared_page_obj = sv->sv_shared_page_obj; | sv2->sv_shared_page_obj = sv->sv_shared_page_obj; | ||||
sv2->sv_sigcode_base = sv2->sv_shared_page_base + | sv2->sv_sigcode_base = sv2->sv_shared_page_base + | ||||
(sv->sv_sigcode_base - sv->sv_shared_page_base); | (sv->sv_sigcode_base - sv->sv_shared_page_base); | ||||
if ((sv2->sv_flags & SV_DSO_SIG) != 0) { | |||||
sv2->sv_vdso_base = sv2->sv_shared_page_base + | |||||
(sv->sv_vdso_base - sv->sv_shared_page_base); | |||||
} | |||||
if ((sv2->sv_flags & SV_ABI_MASK) != SV_ABI_FREEBSD) | if ((sv2->sv_flags & SV_ABI_MASK) != SV_ABI_FREEBSD) | ||||
return; | return; | ||||
if ((sv2->sv_flags & SV_TIMEKEEP) != 0) { | if ((sv2->sv_flags & SV_TIMEKEEP) != 0) { | ||||
sv2->sv_timekeep_base = sv2->sv_shared_page_base + | sv2->sv_timekeep_base = sv2->sv_shared_page_base + | ||||
(sv->sv_timekeep_base - sv->sv_shared_page_base); | (sv->sv_timekeep_base - sv->sv_shared_page_base); | ||||
} | } | ||||
if ((sv2->sv_flags & SV_RNG_SEED_VER) != 0) { | if ((sv2->sv_flags & SV_RNG_SEED_VER) != 0) { | ||||
sv2->sv_fxrng_gen_base = sv2->sv_shared_page_base + | sv2->sv_fxrng_gen_base = sv2->sv_shared_page_base + | ||||
(sv->sv_fxrng_gen_base - sv->sv_shared_page_base); | (sv->sv_fxrng_gen_base - sv->sv_shared_page_base); | ||||
} | } | ||||
} | } |
I wouldn't be surprised if some of the Linuxulator VDSO code can then reuse this, but that's someone else's problem to figure out :)