From: Lei Xia Date: Tue, 4 May 2010 21:31:09 +0000 (-0500) Subject: Add hypercall for guest to get CPU frequency X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=commitdiff_plain;h=affa74f0a3ac623aaa3042e251771c04e63cf846;p=palacios.git Add hypercall for guest to get CPU frequency --- diff --git a/palacios/include/palacios/vmm_hypercall.h b/palacios/include/palacios/vmm_hypercall.h index 8a7fc5d..a7c79f2 100644 --- a/palacios/include/palacios/vmm_hypercall.h +++ b/palacios/include/palacios/vmm_hypercall.h @@ -50,7 +50,8 @@ typedef enum { TELEMETRY_HCALL = 0x3001, // no args BALLOON_START_HCALL = 0xba00, // RAX: size BALLOON_QUERY_HCALL = 0xba01, // RCX: req_pgs(out), RDX: alloc_pgs(out) - OS_DEBUG_HCALL = 0xc0c0 // RBX: msg_gpa, RCX: msg_len, RDX: buf_is_va (flag) + OS_DEBUG_HCALL = 0xc0c0, // RBX: msg_gpa, RCX: msg_len, RDX: buf_is_va (flag) + TIME_CPUFREQ_HCALL = 0xd000 //RCX: cpu freq (out) } hcall_id_t; diff --git a/palacios/src/palacios/vmm_time.c b/palacios/src/palacios/vmm_time.c index 44d5d02..b169669 100644 --- a/palacios/src/palacios/vmm_time.c +++ b/palacios/src/palacios/vmm_time.c @@ -21,6 +21,18 @@ #include #include +static int handle_cpufreq_hcall(struct guest_info * info, uint_t hcall_id, void * priv_data) { + struct vm_time * time_state = &(info->time_state); + + info->vm_regs.rbx = time_state->cpu_freq; + + PrintDebug("Guest request cpu frequency: return %ld\n", (long)info->vm_regs.rbx); + + return 0; +} + + + void v3_init_time(struct guest_info * info) { struct vm_time * time_state = &(info->time_state); @@ -32,6 +44,8 @@ void v3_init_time(struct guest_info * info) { INIT_LIST_HEAD(&(time_state->timers)); time_state->num_timers = 0; + + v3_register_hypercall(info->vm_info, TIME_CPUFREQ_HCALL, handle_cpufreq_hcall, NULL); }