support times
This commit is contained in:
@@ -82,6 +82,7 @@ void x86_init_perfctr(void);
|
||||
int gettime_local_support = 0;
|
||||
|
||||
extern int kprintf(const char *format, ...);
|
||||
extern int interrupt_from_user(void *);
|
||||
|
||||
static struct idt_entry{
|
||||
uint32_t desc[4];
|
||||
@@ -786,6 +787,8 @@ void handle_interrupt(int vector, struct x86_user_context *regs)
|
||||
lapic_ack();
|
||||
++v->in_interrupt;
|
||||
|
||||
set_cputime(interrupt_from_user(regs)? 1: 2);
|
||||
|
||||
dkprintf("CPU[%d] got interrupt, vector: %d, RIP: 0x%lX\n",
|
||||
ihk_mc_get_processor_id(), vector, regs->gpr.rip);
|
||||
|
||||
@@ -862,12 +865,14 @@ void handle_interrupt(int vector, struct x86_user_context *regs)
|
||||
|
||||
check_signal(0, regs, 0);
|
||||
check_need_resched();
|
||||
set_cputime(0);
|
||||
|
||||
--v->in_interrupt;
|
||||
}
|
||||
|
||||
void gpe_handler(struct x86_user_context *regs)
|
||||
{
|
||||
set_cputime(interrupt_from_user(regs)? 1: 2);
|
||||
kprintf("General protection fault (err: %lx, %lx:%lx)\n",
|
||||
regs->gpr.error, regs->gpr.cs, regs->gpr.rip);
|
||||
arch_show_interrupt_context(regs);
|
||||
@@ -877,6 +882,7 @@ void gpe_handler(struct x86_user_context *regs)
|
||||
set_signal(SIGSEGV, regs, NULL);
|
||||
check_signal(0, regs, 0);
|
||||
check_need_resched();
|
||||
set_cputime(0);
|
||||
// panic("GPF");
|
||||
}
|
||||
|
||||
@@ -886,6 +892,7 @@ void debug_handler(struct x86_user_context *regs)
|
||||
int si_code = 0;
|
||||
struct siginfo info;
|
||||
|
||||
set_cputime(interrupt_from_user(regs)? 1: 2);
|
||||
#ifdef DEBUG_PRINT_CPU
|
||||
kprintf("debug exception (err: %lx, %lx:%lx)\n",
|
||||
regs->gpr.error, regs->gpr.cs, regs->gpr.rip);
|
||||
@@ -905,12 +912,14 @@ void debug_handler(struct x86_user_context *regs)
|
||||
set_signal(SIGTRAP, regs, &info);
|
||||
check_signal(0, regs, 0);
|
||||
check_need_resched();
|
||||
set_cputime(0);
|
||||
}
|
||||
|
||||
void int3_handler(struct x86_user_context *regs)
|
||||
{
|
||||
struct siginfo info;
|
||||
|
||||
set_cputime(interrupt_from_user(regs)? 1: 2);
|
||||
#ifdef DEBUG_PRINT_CPU
|
||||
kprintf("int3 exception (err: %lx, %lx:%lx)\n",
|
||||
regs->gpr.error, regs->gpr.cs, regs->gpr.rip);
|
||||
@@ -922,6 +931,7 @@ void int3_handler(struct x86_user_context *regs)
|
||||
set_signal(SIGTRAP, regs, &info);
|
||||
check_signal(0, regs, 0);
|
||||
check_need_resched();
|
||||
set_cputime(0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -69,6 +69,7 @@ SYSCALL_DELEGATED(79, getcwd)
|
||||
SYSCALL_DELEGATED(89, readlink)
|
||||
SYSCALL_HANDLED(96, gettimeofday)
|
||||
SYSCALL_HANDLED(97, getrlimit)
|
||||
SYSCALL_HANDLED(100, times)
|
||||
SYSCALL_HANDLED(101, ptrace)
|
||||
SYSCALL_HANDLED(102, getuid)
|
||||
SYSCALL_HANDLED(104, getgid)
|
||||
|
||||
@@ -209,7 +209,9 @@ enter_user_mode:
|
||||
callq release_runq_lock
|
||||
movq $0, %rdi
|
||||
movq %rsp, %rsi
|
||||
call check_signal
|
||||
call check_signal
|
||||
movq $0, %rdi
|
||||
call set_cputime
|
||||
POP_ALL_REGS
|
||||
addq $8, %rsp
|
||||
iretq
|
||||
|
||||
@@ -756,6 +756,14 @@ hassigpending(struct thread *thread)
|
||||
return getsigpending(thread, 0);
|
||||
}
|
||||
|
||||
int
|
||||
interrupt_from_user(void *regs0)
|
||||
{
|
||||
struct x86_user_context *regs = regs0;
|
||||
|
||||
return !(regs->gpr.rsp & 0x8000000000000000);
|
||||
}
|
||||
|
||||
void
|
||||
check_signal(unsigned long rc, void *regs0, int num)
|
||||
{
|
||||
@@ -785,7 +793,7 @@ check_signal(unsigned long rc, void *regs0, int num)
|
||||
return;
|
||||
}
|
||||
|
||||
if(regs != NULL && (regs->gpr.rsp & 0x8000000000000000)) {
|
||||
if(regs != NULL && !interrupt_from_user(regs)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user