Skip to content

Commit 6b4879a

Browse files
committed
Also allow CLOCK_REALTIME in clock_gettime
This fixes an issue with certificate validation
1 parent b94ea76 commit 6b4879a

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

lib/tinykvm/linux/system_calls.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1651,21 +1651,23 @@ void Machine::setup_linux_system_calls()
16511651
SYS_clock_gettime, [](vCPU& cpu) { // clock_gettime
16521652
auto& regs = cpu.registers();
16531653
struct timespec ts;
1654-
regs.rax = clock_gettime(CLOCK_MONOTONIC, &ts);
1654+
clockid_t clk_id = regs.rdi;
1655+
if (clk_id == CLOCK_REALTIME)
1656+
clk_id = CLOCK_REALTIME;
1657+
else
1658+
clk_id = CLOCK_MONOTONIC;
1659+
regs.rax = clock_gettime(clk_id, &ts);
16551660
if (int(regs.rax) < 0)
16561661
regs.rax = -errno;
16571662
else
16581663
cpu.machine().copy_to_guest(regs.rsi, &ts, sizeof(ts));
16591664
SYSPRINT("clock_gettime(clk=%lld, buf=0x%llX) = %lld\n",
16601665
regs.rdi, regs.rsi, regs.rax);
16611666
cpu.set_registers(regs);
1662-
//cpu.machine().threads().suspend_and_yield();
16631667
});
16641668
Machine::install_syscall_handler(
16651669
SYS_clock_nanosleep, [](vCPU& cpu) { // clock_nanosleep
16661670
auto& regs = cpu.registers();
1667-
// We don't allow sleeping in the guest
1668-
// but we can set the remaining time to the requested value
16691671
const uint64_t g_buf = regs.rdx;
16701672
const uint64_t g_rem = regs.r10;
16711673
struct timespec ts;

0 commit comments

Comments
 (0)