Changeset View
Changeset View
Standalone View
Standalone View
sys/kern/kern_sharedpage.c
Show First 20 Lines • Show All 302 Lines • ▼ Show 20 Lines | |||||
void | void | ||||
exec_sysvec_init(void *param) | exec_sysvec_init(void *param) | ||||
{ | { | ||||
struct sysentvec *sv; | struct sysentvec *sv; | ||||
#ifdef RANDOM_FENESTRASX | #ifdef RANDOM_FENESTRASX | ||||
ptrdiff_t base; | ptrdiff_t base; | ||||
#endif | #endif | ||||
u_int flags; | |||||
sv = (struct sysentvec *)param; | sv = (struct sysentvec *)param; | ||||
if ((sv->sv_flags & SV_SHP) == 0) | flags = sv->sv_flags; | ||||
kib: I think that this assert (sv_shared_page_base != 0) should be only done if SV_SHP flag is set. | |||||
if ((flags & SV_SHP) == 0) | |||||
return; | return; | ||||
sv->sv_shared_page_obj = shared_page_obj; | sv->sv_shared_page_obj = shared_page_obj; | ||||
if ((flags & SV_ABI_MASK) == SV_ABI_FREEBSD) | |||||
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); | ||||
if ((sv->sv_flags & SV_ABI_MASK) != SV_ABI_FREEBSD) | if ((flags & SV_TIMEKEEP) != 0) { | ||||
Not Done Inline ActionsAdd {} around then statement, it is multi-line. kib: Add {} around then statement, it is multi-line. | |||||
return; | |||||
if ((sv->sv_flags & SV_TIMEKEEP) != 0) { | |||||
#ifdef COMPAT_FREEBSD32 | #ifdef COMPAT_FREEBSD32 | ||||
if ((sv->sv_flags & SV_ILP32) != 0) { | if ((flags & SV_ILP32) != 0) { | ||||
KASSERT(compat32_svtk == NULL, | KASSERT(compat32_svtk == NULL && | ||||
(flags & SV_ABI_MASK) == SV_ABI_FREEBSD, | |||||
("Compat32 already registered")); | ("Compat32 already registered")); | ||||
if ((flags & SV_ABI_MASK) == SV_ABI_FREEBSD) | |||||
kibUnsubmitted Not Done Inline ActionsWhy do you need to check this condition? The assert on the previous line verified that the condition is true. kib: Why do you need to check this condition? The assert on the previous line verified that the… | |||||
compat32_svtk = alloc_sv_tk_compat32(); | compat32_svtk = alloc_sv_tk_compat32(); | ||||
sv->sv_timekeep_base = sv->sv_shared_page_base + | sv->sv_timekeep_base = sv->sv_shared_page_base + | ||||
compat32_svtk->sv_timekeep_off; | compat32_svtk->sv_timekeep_off; | ||||
} else { | } else { | ||||
#endif | #endif | ||||
KASSERT(host_svtk == NULL, ("Host already registered")); | KASSERT(host_svtk == NULL && | ||||
(flags & SV_ABI_MASK) == SV_ABI_FREEBSD, | |||||
("Host already registered")); | |||||
if ((flags & SV_ABI_MASK) == SV_ABI_FREEBSD) | |||||
host_svtk = alloc_sv_tk(); | host_svtk = alloc_sv_tk(); | ||||
sv->sv_timekeep_base = sv->sv_shared_page_base + | sv->sv_timekeep_base = sv->sv_shared_page_base + | ||||
host_svtk->sv_timekeep_off; | host_svtk->sv_timekeep_off; | ||||
#ifdef COMPAT_FREEBSD32 | #ifdef COMPAT_FREEBSD32 | ||||
} | } | ||||
#endif | #endif | ||||
} | } | ||||
#ifdef RANDOM_FENESTRASX | #ifdef RANDOM_FENESTRASX | ||||
if ((sv->sv_flags & SV_RNG_SEED_VER) != 0) { | if ((flags & SV_RNG_SEED_VER) != 0) { | ||||
Not Done Inline ActionsThis one should be conditional on ABI_FREEBSD as well, perhaps? kib: This one should be conditional on ABI_FREEBSD as well, perhaps? | |||||
/* | /* | ||||
Not Done Inline ActionsThis can be written as a single check ((flags & (SV_ABI_MASK | SV_RNG_SEED_VER) ) == (SV_ABI_FREEBSD | SV_RNG_SEED_VER)) but it is up to you. kib: This can be written as a single check
```
((flags & (SV_ABI_MASK | SV_RNG_SEED_VER) ) ==… | |||||
* Only allocate a single VDSO entry for multiple sysentvecs, | * Only allocate a single VDSO entry for multiple sysentvecs, | ||||
* i.e., native and COMPAT32. | * i.e., native and COMPAT32. | ||||
*/ | */ | ||||
if (fxrng_shpage_mapping == NULL) | if (fxrng_shpage_mapping == NULL) | ||||
alloc_sv_fxrng_generation(); | alloc_sv_fxrng_generation(); | ||||
base = (char *)fxrng_shpage_mapping - shared_page_mapping; | base = (char *)fxrng_shpage_mapping - shared_page_mapping; | ||||
sv->sv_fxrng_gen_base = sv->sv_shared_page_base + base; | sv->sv_fxrng_gen_base = sv->sv_shared_page_base + base; | ||||
} | } | ||||
Show All 17 Lines | exec_sysvec_init_secondary(struct sysentvec *sv, struct sysentvec *sv2) | ||||
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); | ||||
} | } | ||||
} | |||||
void | |||||
exec_sysvec_init_abi(void *param) | |||||
{ | |||||
struct sysentvec *sv; | |||||
sv = param; | |||||
MPASS((sv->sv_flags & SV_ABI_MASK) != SV_ABI_FREEBSD); | |||||
MPASS(sv->sv_shared_page_obj == 0); | |||||
MPASS(sv->sv_shared_page_base != 0); | |||||
Not Done Inline ActionsShould sv->sv_shared_page_obj == 0 (NULL BTW?) and sv->sv_shared_page_base != 0 asserts moved to exec_sysvec_init() ? kib: Should `sv->sv_shared_page_obj == 0` (NULL BTW?) and `sv->sv_shared_page_base != 0` asserts… | |||||
MPASS((sv->sv_flags & SV_SHP) != 0); | |||||
if ((sv->sv_flags & SV_TIMEKEEP) != 0) { | |||||
#ifdef COMPAT_FREEBSD32 | |||||
Not Done Inline ActionsNow, with the changes to exec_sysvec_init(), what is the reason to have exec_sysvec_init_abi()? It only asserts some state. kib: Now, with the changes to exec_sysvec_init(), what is the reason to have exec_sysvec_init_abi()? | |||||
if ((sv->sv_flags & SV_ILP32) != 0) { | |||||
KASSERT(compat32_svtk != NULL, | |||||
("Compat32 not registered")); | |||||
} else { | |||||
#endif | |||||
KASSERT(host_svtk != NULL, ("Host not registered")); | |||||
#ifdef COMPAT_FREEBSD32 | |||||
} | |||||
#endif | |||||
} | |||||
exec_sysvec_init(sv); | |||||
} | } |
I think that this assert (sv_shared_page_base != 0) should be only done if SV_SHP flag is set.