Lines Matching full:vcpu

20 static int diag_release_pages(struct kvm_vcpu *vcpu)  in diag_release_pages()  argument
23 unsigned long prefix = kvm_s390_get_prefix(vcpu); in diag_release_pages()
25 start = vcpu->run->s.regs.gprs[(vcpu->arch.sie_block->ipa & 0xf0) >> 4]; in diag_release_pages()
26 end = vcpu->run->s.regs.gprs[vcpu->arch.sie_block->ipa & 0xf] + PAGE_SIZE; in diag_release_pages()
27 vcpu->stat.instruction_diagnose_10++; in diag_release_pages()
31 return kvm_s390_inject_program_int(vcpu, PGM_SPECIFICATION); in diag_release_pages()
33 VCPU_EVENT(vcpu, 5, "diag release pages %lX %lX", start, end); in diag_release_pages()
40 gmap_discard(vcpu->arch.gmap, start, end); in diag_release_pages()
48 gmap_discard(vcpu->arch.gmap, start, prefix); in diag_release_pages()
50 gmap_discard(vcpu->arch.gmap, 0, PAGE_SIZE); in diag_release_pages()
52 gmap_discard(vcpu->arch.gmap, PAGE_SIZE, 2 * PAGE_SIZE); in diag_release_pages()
53 gmap_discard(vcpu->arch.gmap, prefix + 2 * PAGE_SIZE, end); in diag_release_pages()
58 static int __diag_page_ref_service(struct kvm_vcpu *vcpu) in __diag_page_ref_service() argument
72 u16 rx = (vcpu->arch.sie_block->ipa & 0xf0) >> 4; in __diag_page_ref_service()
73 u16 ry = (vcpu->arch.sie_block->ipa & 0x0f); in __diag_page_ref_service()
75 VCPU_EVENT(vcpu, 3, "diag page reference parameter block at 0x%llx", in __diag_page_ref_service()
76 vcpu->run->s.regs.gprs[rx]); in __diag_page_ref_service()
77 vcpu->stat.instruction_diagnose_258++; in __diag_page_ref_service()
78 if (vcpu->run->s.regs.gprs[rx] & 7) in __diag_page_ref_service()
79 return kvm_s390_inject_program_int(vcpu, PGM_SPECIFICATION); in __diag_page_ref_service()
80 rc = read_guest_real(vcpu, vcpu->run->s.regs.gprs[rx], &parm, sizeof(parm)); in __diag_page_ref_service()
82 return kvm_s390_inject_prog_cond(vcpu, rc); in __diag_page_ref_service()
84 return kvm_s390_inject_program_int(vcpu, PGM_SPECIFICATION); in __diag_page_ref_service()
88 VCPU_EVENT(vcpu, 3, "pageref token addr 0x%llx " in __diag_page_ref_service()
91 if (vcpu->arch.pfault_token != KVM_S390_PFAULT_TOKEN_INVALID) { in __diag_page_ref_service()
97 vcpu->run->s.regs.gprs[ry] = 8; in __diag_page_ref_service()
103 return kvm_s390_inject_program_int(vcpu, PGM_SPECIFICATION); in __diag_page_ref_service()
105 if (!kvm_is_gpa_in_memslot(vcpu->kvm, parm.token_addr)) in __diag_page_ref_service()
106 return kvm_s390_inject_program_int(vcpu, PGM_ADDRESSING); in __diag_page_ref_service()
108 vcpu->arch.pfault_token = parm.token_addr; in __diag_page_ref_service()
109 vcpu->arch.pfault_select = parm.select_mask; in __diag_page_ref_service()
110 vcpu->arch.pfault_compare = parm.compare_mask; in __diag_page_ref_service()
111 vcpu->run->s.regs.gprs[ry] = 0; in __diag_page_ref_service()
120 VCPU_EVENT(vcpu, 3, "pageref cancel addr 0x%llx", parm.token_addr); in __diag_page_ref_service()
123 return kvm_s390_inject_program_int(vcpu, PGM_SPECIFICATION); in __diag_page_ref_service()
125 vcpu->run->s.regs.gprs[ry] = 0; in __diag_page_ref_service()
130 if (vcpu->arch.pfault_token == KVM_S390_PFAULT_TOKEN_INVALID) in __diag_page_ref_service()
131 vcpu->run->s.regs.gprs[ry] = 4; in __diag_page_ref_service()
133 vcpu->arch.pfault_token = KVM_S390_PFAULT_TOKEN_INVALID; in __diag_page_ref_service()
145 static int __diag_time_slice_end(struct kvm_vcpu *vcpu) in __diag_time_slice_end() argument
147 VCPU_EVENT(vcpu, 5, "%s", "diag time slice end"); in __diag_time_slice_end()
148 vcpu->stat.instruction_diagnose_44++; in __diag_time_slice_end()
149 kvm_vcpu_on_spin(vcpu, true); in __diag_time_slice_end()
166 static int __diag_time_slice_end_directed(struct kvm_vcpu *vcpu) in __diag_time_slice_end_directed() argument
172 tid = vcpu->run->s.regs.gprs[(vcpu->arch.sie_block->ipa & 0xf0) >> 4]; in __diag_time_slice_end_directed()
173 vcpu->stat.instruction_diagnose_9c++; in __diag_time_slice_end_directed()
176 if (tid == vcpu->vcpu_id) in __diag_time_slice_end_directed()
180 tcpu = kvm_get_vcpu_by_id(vcpu->kvm, tid); in __diag_time_slice_end_directed()
184 /* target guest VCPU already running */ in __diag_time_slice_end_directed()
194 VCPU_EVENT(vcpu, 5, in __diag_time_slice_end_directed()
197 vcpu->stat.diag_9c_forward++; in __diag_time_slice_end_directed()
204 VCPU_EVENT(vcpu, 5, "diag time slice end directed to %d: done", tid); in __diag_time_slice_end_directed()
207 VCPU_EVENT(vcpu, 5, "diag time slice end directed to %d: ignored", tid); in __diag_time_slice_end_directed()
208 vcpu->stat.diag_9c_ignored++; in __diag_time_slice_end_directed()
212 static int __diag_ipl_functions(struct kvm_vcpu *vcpu) in __diag_ipl_functions() argument
214 unsigned int reg = vcpu->arch.sie_block->ipa & 0xf; in __diag_ipl_functions()
215 unsigned long subcode = vcpu->run->s.regs.gprs[reg] & 0xffff; in __diag_ipl_functions()
217 VCPU_EVENT(vcpu, 3, "diag ipl functions, subcode %lx", subcode); in __diag_ipl_functions()
218 vcpu->stat.instruction_diagnose_308++; in __diag_ipl_functions()
221 vcpu->run->s390_reset_flags = KVM_S390_RESET_CLEAR; in __diag_ipl_functions()
224 vcpu->run->s390_reset_flags = 0; in __diag_ipl_functions()
234 if (!kvm_s390_user_cpu_state_ctrl(vcpu->kvm)) in __diag_ipl_functions()
235 kvm_s390_vcpu_stop(vcpu); in __diag_ipl_functions()
236 vcpu->run->s390_reset_flags |= KVM_S390_RESET_SUBSYSTEM; in __diag_ipl_functions()
237 vcpu->run->s390_reset_flags |= KVM_S390_RESET_IPL; in __diag_ipl_functions()
238 vcpu->run->s390_reset_flags |= KVM_S390_RESET_CPU_INIT; in __diag_ipl_functions()
239 vcpu->run->exit_reason = KVM_EXIT_S390_RESET; in __diag_ipl_functions()
240 VCPU_EVENT(vcpu, 3, "requesting userspace resets %llx", in __diag_ipl_functions()
241 vcpu->run->s390_reset_flags); in __diag_ipl_functions()
242 trace_kvm_s390_request_resets(vcpu->run->s390_reset_flags); in __diag_ipl_functions()
246 static int __diag_virtio_hypercall(struct kvm_vcpu *vcpu) in __diag_virtio_hypercall() argument
250 vcpu->stat.instruction_diagnose_500++; in __diag_virtio_hypercall()
252 if (!vcpu->kvm->arch.css_support || in __diag_virtio_hypercall()
253 (vcpu->run->s.regs.gprs[1] != KVM_S390_VIRTIO_CCW_NOTIFY)) in __diag_virtio_hypercall()
256 VCPU_EVENT(vcpu, 4, "diag 0x500 schid 0x%8.8x queue 0x%x cookie 0x%llx", in __diag_virtio_hypercall()
257 (u32) vcpu->run->s.regs.gprs[2], in __diag_virtio_hypercall()
258 (u32) vcpu->run->s.regs.gprs[3], in __diag_virtio_hypercall()
259 vcpu->run->s.regs.gprs[4]); in __diag_virtio_hypercall()
267 ret = kvm_io_bus_write_cookie(vcpu, KVM_VIRTIO_CCW_NOTIFY_BUS, in __diag_virtio_hypercall()
268 vcpu->run->s.regs.gprs[2] & 0xffffffff, in __diag_virtio_hypercall()
269 8, &vcpu->run->s.regs.gprs[3], in __diag_virtio_hypercall()
270 vcpu->run->s.regs.gprs[4]); in __diag_virtio_hypercall()
277 vcpu->run->s.regs.gprs[2] = ret; in __diag_virtio_hypercall()
282 int kvm_s390_handle_diag(struct kvm_vcpu *vcpu) in kvm_s390_handle_diag() argument
284 int code = kvm_s390_get_base_disp_rs(vcpu, NULL) & 0xffff; in kvm_s390_handle_diag()
286 if (vcpu->arch.sie_block->gpsw.mask & PSW_MASK_PSTATE) in kvm_s390_handle_diag()
287 return kvm_s390_inject_program_int(vcpu, PGM_PRIVILEGED_OP); in kvm_s390_handle_diag()
289 trace_kvm_s390_handle_diag(vcpu, code); in kvm_s390_handle_diag()
292 return diag_release_pages(vcpu); in kvm_s390_handle_diag()
294 return __diag_time_slice_end(vcpu); in kvm_s390_handle_diag()
296 return __diag_time_slice_end_directed(vcpu); in kvm_s390_handle_diag()
298 return __diag_page_ref_service(vcpu); in kvm_s390_handle_diag()
300 return __diag_ipl_functions(vcpu); in kvm_s390_handle_diag()
302 return __diag_virtio_hypercall(vcpu); in kvm_s390_handle_diag()
304 vcpu->stat.instruction_diagnose_other++; in kvm_s390_handle_diag()