Lines Matching full:vcpu
132 * When a vCPU stops to due to an event that should be reported to the
134 * The vCPU thread then sets 'stopped_vcpu' if it is not already set
137 * vCPU. When the debugger resumes execution via continue or step,
141 * An idle vCPU will have all of the boolean fields set to false.
143 * When a vCPU is stepped, 'stepping' is set to true when the vCPU is
144 * released to execute the stepped instruction. When the vCPU reports
147 * When a vCPU hits a breakpoint set by the debug server,
162 static struct vcpu **vcpus;
287 guest_paging_info(struct vcpu *vcpu, struct vm_guest_paging *paging) in guest_paging_info() argument
298 if (vm_get_register_set(vcpu, nitems(regset), regset, regs) == -1) in guest_paging_info()
335 if (vm_get_register_set(vcpu, nitems(regset), regset, regs) == -1) in guest_paging_info()
352 * Map a guest virtual address to a physical address (for a given vcpu).
358 guest_vaddr2paddr(struct vcpu *vcpu, uint64_t vaddr, uint64_t *paddr) in guest_vaddr2paddr() argument
363 if (guest_paging_info(vcpu, &paging) == -1) in guest_vaddr2paddr()
368 * accessible, not if the current vCPU can write. in guest_vaddr2paddr()
370 if (vm_gla2gpa_nofault(vcpu, &paging, vaddr, PROT_READ, paddr, in guest_vaddr2paddr()
778 * to an event triggered on a specific vCPU such as a breakpoint or
779 * stepping trap, stopped_vcpu will be set to the vCPU triggering the
781 * the reporting vCPU for vCPU events.
802 debug("$vCPU %d reporting swbreak\n", stopped_vcpu); in report_stop()
806 debug("$vCPU %d reporting step\n", stopped_vcpu); in report_stop()
808 debug("$vCPU %d reporting ???\n", stopped_vcpu); in report_stop()
815 * If this stop is due to a vCPU event, clear that event to mark it as
847 * vCPU threads invoke this function whenever the vCPU enters the
848 * debug server to pause or report an event. vCPU threads wait here
852 _gdb_cpu_suspend(struct vcpu *vcpu, bool report_stop) in _gdb_cpu_suspend() argument
854 int vcpuid = vcpu_id(vcpu); in _gdb_cpu_suspend()
856 debug("$vCPU %d suspending\n", vcpuid); in _gdb_cpu_suspend()
863 debug("$vCPU %d resuming\n", vcpuid); in _gdb_cpu_suspend()
867 * Requests vCPU single-stepping using a
871 _gdb_set_step(struct vcpu *vcpu, int val) in _gdb_set_step() argument
880 error = vm_set_capability(vcpu, VM_CAP_MTRAP_EXIT, val); in _gdb_set_step()
882 error = vm_set_capability(vcpu, VM_CAP_RFLAGS_TF, val); in _gdb_set_step()
884 (void)vm_set_capability(vcpu, VM_CAP_MASK_HWINTR, val); in _gdb_set_step()
886 error = vm_set_capability(vcpu, VM_CAP_SS_EXIT, val); in _gdb_set_step()
888 error = vm_set_capability(vcpu, VM_CAP_MASK_HWINTR, val); in _gdb_set_step()
894 * Checks whether single-stepping is supported for a given vCPU.
897 _gdb_check_step(struct vcpu *vcpu) in _gdb_check_step() argument
902 if (vm_get_capability(vcpu, VM_CAP_MTRAP_EXIT, &val) != 0) { in _gdb_check_step()
903 if (vm_get_capability(vcpu, VM_CAP_RFLAGS_TF, &val) != 0) in _gdb_check_step()
907 (void)vcpu; in _gdb_check_step()
913 * Invoked at the start of a vCPU thread's execution to inform the
917 gdb_cpu_add(struct vcpu *vcpu) in gdb_cpu_add() argument
923 vcpuid = vcpu_id(vcpu); in gdb_cpu_add()
924 debug("$vCPU %d starting\n", vcpuid); in gdb_cpu_add()
928 vcpus[vcpuid] = vcpu; in gdb_cpu_add()
931 vm_set_capability(vcpu, GDB_BREAKPOINT_CAP, 1); in gdb_cpu_add()
932 debug("$vCPU %d enabled breakpoint exits\n", vcpuid); in gdb_cpu_add()
936 * If a vcpu is added while vcpus are stopped, suspend the new in gdb_cpu_add()
937 * vcpu so that it will pop back out with a debug exit before in gdb_cpu_add()
948 _gdb_cpu_suspend(vcpu, false); in gdb_cpu_add()
953 * In particular, this refers to the kernel's view of the vCPU in gdb_cpu_add()
960 error = vm_suspend_cpu(vcpu); in gdb_cpu_add()
968 * Invoked by vCPU before resuming execution. This enables stepping
969 * if the vCPU is marked as stepping.
972 gdb_cpu_resume(struct vcpu *vcpu) in gdb_cpu_resume() argument
977 vs = &vcpu_state[vcpu_id(vcpu)]; in gdb_cpu_resume()
986 error = _gdb_set_step(vcpu, 1); in gdb_cpu_resume()
992 * Handler for VM_EXITCODE_DEBUG used to suspend a vCPU when the guest
993 * has been suspended due to an event on different vCPU or in response
997 gdb_cpu_suspend(struct vcpu *vcpu) in gdb_cpu_suspend() argument
1003 _gdb_cpu_suspend(vcpu, true); in gdb_cpu_suspend()
1004 gdb_cpu_resume(vcpu); in gdb_cpu_suspend()
1021 * Invoked each time a vmexit handler needs to step a vCPU.
1025 gdb_cpu_step(struct vcpu *vcpu) in gdb_cpu_step() argument
1028 int vcpuid = vcpu_id(vcpu); in gdb_cpu_step()
1031 debug("$vCPU %d stepped\n", vcpuid); in gdb_cpu_step()
1037 error = _gdb_set_step(vcpu, 0); in gdb_cpu_step()
1042 debug("$vCPU %d reporting step\n", vcpuid); in gdb_cpu_step()
1046 _gdb_cpu_suspend(vcpu, true); in gdb_cpu_step()
1048 gdb_cpu_resume(vcpu); in gdb_cpu_step()
1058 gdb_cpu_debug(struct vcpu *vcpu, struct vm_exit *vmexit) in gdb_cpu_debug() argument
1066 gdb_cpu_step(vcpu); in gdb_cpu_debug()
1070 gdb_cpu_step(vcpu); in gdb_cpu_debug()
1075 * Handler for VM_EXITCODE_MTRAP reported when a vCPU single-steps via
1079 gdb_cpu_mtrap(struct vcpu *vcpu) in gdb_cpu_mtrap() argument
1083 gdb_cpu_step(vcpu); in gdb_cpu_mtrap()
1099 gdb_cpu_breakpoint(struct vcpu *vcpu, struct vm_exit *vmexit) in gdb_cpu_breakpoint() argument
1110 vcpuid = vcpu_id(vcpu); in gdb_cpu_breakpoint()
1112 error = guest_vaddr2paddr(vcpu, guest_pc(vmexit), &gpa); in gdb_cpu_breakpoint()
1121 vm_set_register(vcpu, GDB_PC_REGNAME, guest_pc(vmexit)); in gdb_cpu_breakpoint()
1124 debug("$vCPU %d reporting breakpoint at rip %#lx\n", in gdb_cpu_breakpoint()
1129 _gdb_cpu_suspend(vcpu, true); in gdb_cpu_breakpoint()
1141 gdb_cpu_resume(vcpu); in gdb_cpu_breakpoint()
1143 debug("$vCPU %d injecting breakpoint at rip %#lx\n", vcpuid, in gdb_cpu_breakpoint()
1146 error = vm_set_register(vcpu, VM_REG_GUEST_ENTRY_INST_LENGTH, in gdb_cpu_breakpoint()
1149 error = vm_inject_exception(vcpu, IDT_BP, 0, 0, 0); in gdb_cpu_breakpoint()
1155 error = vm_inject_exception(vcpu, esr, 0); in gdb_cpu_breakpoint()
1163 gdb_step_vcpu(struct vcpu *vcpu) in gdb_step_vcpu() argument
1167 vcpuid = vcpu_id(vcpu); in gdb_step_vcpu()
1168 debug("$vCPU %d step\n", vcpuid); in gdb_step_vcpu()
1169 error = _gdb_check_step(vcpu); in gdb_step_vcpu()
1175 vm_resume_cpu(vcpu); in gdb_step_vcpu()
1469 int vcpu; in set_breakpoint_caps() local
1473 vcpu = CPU_FFS(&mask) - 1; in set_breakpoint_caps()
1474 CPU_CLR(vcpu, &mask); in set_breakpoint_caps()
1475 if (vm_set_capability(vcpus[vcpu], GDB_BREAKPOINT_CAP, in set_breakpoint_caps()
1478 debug("$vCPU %d %sabled breakpoint exits\n", vcpu, in set_breakpoint_caps()
1740 int vcpu; in gdb_query() local
1751 vcpu = CPU_FFS(&mask) - 1; in gdb_query()
1752 CPU_CLR(vcpu, &mask); in gdb_query()
1757 append_integer(vcpu + 1); in gdb_query()
1784 snprintf(buf, sizeof(buf), "vCPU %d", tid - 1); in gdb_query()
2243 * Set vcpu 0 in vcpus_suspended. This will trigger the in init_gdb()
2244 * logic in gdb_cpu_add() to suspend the first vcpu before in init_gdb()
2245 * it starts execution. The vcpu will remain suspended in init_gdb()