Changeset View
Changeset View
Standalone View
Standalone View
lib/libc/x86/sys/__vdso_gettc.c
Show First 20 Lines • Show All 224 Lines • ▼ Show 20 Lines | __vdso_init_hpet(uint32_t u) | ||||
if (old_map != NULL) | if (old_map != NULL) | ||||
return; | return; | ||||
/* | /* | ||||
* Explicitely check for the capability mode to avoid | * Explicitely check for the capability mode to avoid | ||||
* triggering trap_enocap on the device open by absolute path. | * triggering trap_enocap on the device open by absolute path. | ||||
*/ | */ | ||||
if ((cap_getmode(&mode) == 0 && mode != 0) || | if ((cap_getmode(&mode) == 0 && mode != 0) || | ||||
(fd = _open(devname, O_RDONLY)) == -1) { | (fd = _open(devname, O_RDONLY | O_CLOEXEC)) == -1) { | ||||
/* Prevent the caller from re-entering. */ | /* Prevent the caller from re-entering. */ | ||||
atomic_cmpset_rel_ptr((volatile uintptr_t *)&hpet_dev_map[u], | atomic_cmpset_rel_ptr((volatile uintptr_t *)&hpet_dev_map[u], | ||||
(uintptr_t)old_map, (uintptr_t)MAP_FAILED); | (uintptr_t)old_map, (uintptr_t)MAP_FAILED); | ||||
return; | return; | ||||
} | } | ||||
new_map = mmap(NULL, PAGE_SIZE, PROT_READ, MAP_SHARED, fd, 0); | new_map = mmap(NULL, PAGE_SIZE, PROT_READ, MAP_SHARED, fd, 0); | ||||
_close(fd); | _close(fd); | ||||
Show All 19 Lines | |||||
__vdso_init_hyperv_tsc(void) | __vdso_init_hyperv_tsc(void) | ||||
{ | { | ||||
int fd; | int fd; | ||||
unsigned int mode; | unsigned int mode; | ||||
if (cap_getmode(&mode) == 0 && mode != 0) | if (cap_getmode(&mode) == 0 && mode != 0) | ||||
goto fail; | goto fail; | ||||
fd = _open(HYPERV_REFTSC_DEVPATH, O_RDONLY); | fd = _open(HYPERV_REFTSC_DEVPATH, O_RDONLY | O_CLOEXEC); | ||||
if (fd < 0) | if (fd < 0) | ||||
goto fail; | goto fail; | ||||
hyperv_ref_tsc = mmap(NULL, sizeof(*hyperv_ref_tsc), PROT_READ, | hyperv_ref_tsc = mmap(NULL, sizeof(*hyperv_ref_tsc), PROT_READ, | ||||
MAP_SHARED, fd, 0); | MAP_SHARED, fd, 0); | ||||
_close(fd); | _close(fd); | ||||
return; | return; | ||||
fail: | fail: | ||||
▲ Show 20 Lines • Show All 84 Lines • Show Last 20 Lines |