Palacios Public Git Repository

To checkout Palacios execute

  git clone http://v3vee.org/palacios/palacios.web/palacios.git
This will give you the master branch. You probably want the devel branch or one of the release branches. To switch to the devel branch, simply execute
  cd palacios
  git checkout --track -b devel origin/devel
The other branches are similar.


Removal of debugging code from halt code
[palacios.git] / palacios / src / palacios / vmm_halt.c
1 /* 
2  * This file is part of the Palacios Virtual Machine Monitor developed
3  * by the V3VEE Project with funding from the United States National 
4  * Science Foundation and the Department of Energy.  
5  *
6  * The V3VEE Project is a joint project between Northwestern University
7  * and the University of New Mexico.  You can find out more at 
8  * http://www.v3vee.org
9  *
10  * Copyright (c) 2008, Peter Dinda <pdinda@northwestern.edu>
11  * Copyright (c) 2008, Jack Lange <jarusl@cs.northwestern.edu> 
12  * Copyright (c) 2008, The V3VEE Project <http://www.v3vee.org> 
13  * All rights reserved.
14  *
15  * Author: Peter Dinda <pdinda@northwestern.edu>
16  *
17  * This is free software.  You are permitted to use,
18  * redistribute, and modify it as specified in the file "V3VEE_LICENSE".
19  */
20
21 #include <palacios/vmm_halt.h>
22 #include <palacios/vmm_intr.h>
23 #include <palacios/vmm_lowlevel.h> 
24 #include <palacios/vmm_perftune.h>
25
26 #ifndef V3_CONFIG_DEBUG_HALT
27 #undef PrintDebug
28 #define PrintDebug(fmt, args...)
29 #endif
30
31
32 //
33 // This should trigger a #GP if cpl != 0, otherwise, yield to host
34 //
35
36 int v3_handle_halt(struct guest_info * info) 
37 {
38     
39     if (info->cpl != 0) { 
40         v3_raise_exception(info, GPF_EXCEPTION);
41     } else {
42         uint64_t start_cycles;
43         
44         PrintDebug(info->vm_info, info, "CPU Yield\n");
45
46         start_cycles  = v3_get_host_time(&info->time_state);
47
48         while (!v3_intr_pending(info) &&
49                !v3_excp_pending(info) &&
50                (info->vm_info->run_state == VM_RUNNING)) {
51             uint64_t t, cycles;
52
53             t = v3_get_host_time(&info->time_state);
54
55             /* Yield, allowing time to pass while yielded */
56             v3_strategy_driven_yield(info, v3_cycle_diff_in_usec(info, start_cycles, t));
57
58             cycles = v3_get_host_time(&info->time_state) - t;
59
60             v3_advance_time(info, &cycles);
61
62             v3_update_timers(info);
63             
64
65             
66             /* At this point, we either have some combination of 
67                interrupts, including perhaps a timer interrupt, or 
68                no interrupt.
69             */
70             if (!v3_intr_pending(info)) {
71                 /* if no interrupt, then we do halt */
72                 /* asm("hlt"); */
73             }
74
75             // participate in any barrier that might be raised
76             v3_wait_at_barrier(info);
77
78             // stop if the VM is being halted or core is being reset
79             if (info->core_run_state == CORE_STOPPED || info->core_run_state == CORE_RESETTING) { 
80                 break;
81             }
82
83         }
84
85         /* V3_Print(info->vm_info, info, "palacios: done with halt\n"); */
86         
87         info->rip += 1;
88         
89     }
90
91     return 0;
92 }