diff --git a/Kernel/Process.cpp b/Kernel/Process.cpp index b5cbae8776f..6ed4f5105f7 100644 --- a/Kernel/Process.cpp +++ b/Kernel/Process.cpp @@ -95,7 +95,6 @@ namespace Kernel { static void create_signal_trampolines(); -static void create_kernel_info_page(); Process* Process::current; @@ -103,8 +102,6 @@ static pid_t next_pid; InlineLinkedList* g_processes; static String* s_hostname; static Lock* s_hostname_lock; -static VirtualAddress s_info_page_address_for_userspace; -static VirtualAddress s_info_page_address_for_kernel; VirtualAddress g_return_to_ring3_from_signal_trampoline; HashMap>* g_modules; @@ -124,14 +121,6 @@ void Process::initialize() s_hostname_lock = new Lock; create_signal_trampolines(); - create_kernel_info_page(); -} - -void Process::update_info_page_timestamp(const timeval& tv) -{ - auto* info_page = (KernelInfoPage*)s_info_page_address_for_kernel.as_ptr(); - info_page->serial++; - const_cast(info_page->now) = tv; } Vector Process::all_pids() @@ -1500,15 +1489,6 @@ void create_signal_trampolines() trampoline_region->remap(); } -void create_kernel_info_page() -{ - auto* info_page_region_for_userspace = MM.allocate_user_accessible_kernel_region(PAGE_SIZE, "Kernel info page", Region::Access::Read).leak_ptr(); - auto* info_page_region_for_kernel = MM.allocate_kernel_region_with_vmobject(info_page_region_for_userspace->vmobject(), PAGE_SIZE, "Kernel info page", Region::Access::Read | Region::Access::Write).leak_ptr(); - s_info_page_address_for_userspace = info_page_region_for_userspace->vaddr(); - s_info_page_address_for_kernel = info_page_region_for_kernel->vaddr(); - memset(s_info_page_address_for_kernel.as_ptr(), 0, PAGE_SIZE); -} - int Process::sys$sigreturn(RegisterState& registers) { REQUIRE_PROMISE(stdio); @@ -2330,7 +2310,7 @@ int Process::sys$sleep(unsigned seconds) timeval kgettimeofday() { - return const_cast(((KernelInfoPage*)s_info_page_address_for_kernel.as_ptr())->now); + return g_timeofday; } void compute_relative_timeout_from_absolute(const timeval& absolute_time, timeval& relative_time) @@ -4639,12 +4619,6 @@ int Process::sys$profiling_disable(pid_t pid) return 0; } -void* Process::sys$get_kernel_info_page() -{ - REQUIRE_PROMISE(stdio); - return s_info_page_address_for_userspace.as_ptr(); -} - Thread& Process::any_thread() { Thread* found_thread = nullptr; diff --git a/Kernel/Process.h b/Kernel/Process.h index 7911b97d238..d746dc015c8 100644 --- a/Kernel/Process.h +++ b/Kernel/Process.h @@ -135,8 +135,6 @@ public: static Process* from_pid(pid_t); - static void update_info_page_timestamp(const timeval&); - const String& name() const { return m_name; } pid_t pid() const { return m_pid; } pid_t sid() const { return m_sid; } @@ -299,7 +297,6 @@ public: int sys$module_unload(const char* name, size_t name_length); int sys$profiling_enable(pid_t); int sys$profiling_disable(pid_t); - void* sys$get_kernel_info_page(); int sys$futex(const Syscall::SC_futex_params*); int sys$set_thread_boost(int tid, int amount); int sys$set_process_boost(pid_t, int amount); diff --git a/Kernel/Scheduler.cpp b/Kernel/Scheduler.cpp index 6563effc3f6..1523caf0dc7 100644 --- a/Kernel/Scheduler.cpp +++ b/Kernel/Scheduler.cpp @@ -42,6 +42,7 @@ namespace Kernel { SchedulerData* g_scheduler_data; +timeval g_timeofday; void Scheduler::init_thread(Thread& thread) { @@ -596,10 +597,8 @@ void Scheduler::timer_tick(const RegisterState& regs) ++g_uptime; - timeval tv; - tv.tv_sec = TimeManagement::the().epoch_time(); - tv.tv_usec = TimeManagement::the().ticks_this_second() * 1000; - Process::update_info_page_timestamp(tv); + g_timeofday.tv_sec = TimeManagement::the().epoch_time(); + g_timeofday.tv_usec = TimeManagement::the().ticks_this_second() * 1000; if (Process::current->is_profiling()) { SmapDisabler disabler; diff --git a/Kernel/Scheduler.h b/Kernel/Scheduler.h index 4f28132ba30..ea374fa946c 100644 --- a/Kernel/Scheduler.h +++ b/Kernel/Scheduler.h @@ -46,6 +46,7 @@ extern WaitQueue* g_finalizer_wait_queue; extern bool g_finalizer_has_work; extern u64 g_uptime; extern SchedulerData* g_scheduler_data; +extern timeval g_timeofday; class Scheduler { public: diff --git a/Kernel/Syscall.h b/Kernel/Syscall.h index b1b8fa130d9..44f6f0a7d5e 100644 --- a/Kernel/Syscall.h +++ b/Kernel/Syscall.h @@ -173,7 +173,6 @@ namespace Kernel { __ENUMERATE_SYSCALL(shbuf_set_volatile) \ __ENUMERATE_SYSCALL(profiling_enable) \ __ENUMERATE_SYSCALL(profiling_disable) \ - __ENUMERATE_SYSCALL(get_kernel_info_page) \ __ENUMERATE_SYSCALL(futex) \ __ENUMERATE_SYSCALL(set_thread_boost) \ __ENUMERATE_SYSCALL(set_process_boost) \ diff --git a/Libraries/LibC/time.cpp b/Libraries/LibC/time.cpp index 3b056506827..602ac54e3a6 100644 --- a/Libraries/LibC/time.cpp +++ b/Libraries/LibC/time.cpp @@ -51,17 +51,8 @@ time_t time(time_t* tloc) int gettimeofday(struct timeval* __restrict__ tv, void* __restrict__) { - static volatile KernelInfoPage* kernel_info; - if (!kernel_info) - kernel_info = (volatile KernelInfoPage*)syscall(SC_get_kernel_info_page); - - for (;;) { - auto serial = kernel_info->serial; - *tv = const_cast(kernel_info->now); - if (serial == kernel_info->serial) - break; - } - return 0; + int rc = syscall(SC_gettimeofday, tv); + __RETURN_WITH_ERRNO(rc, rc, -1); } char* ctime(const time_t* t)