Lines Matching refs:xen
11 #include "xen.h"
20 #include <xen/interface/xen.h>
21 #include <xen/interface/vcpu.h>
22 #include <xen/interface/version.h>
23 #include <xen/interface/event_channel.h>
24 #include <xen/interface/sched.h>
26 #include <asm/xen/cpuid.h>
39 struct gfn_to_pfn_cache *gpc = &kvm->arch.xen.shinfo_cache;
83 if (IS_ENABLED(CONFIG_64BIT) && kvm->arch.xen.long_mode) {
118 if (atomic_read(&vcpu->arch.xen.timer_pending) > 0) {
123 e.port = vcpu->arch.xen.timer_virq;
128 vcpu->arch.xen.timer_expires = 0;
129 atomic_set(&vcpu->arch.xen.timer_pending, 0);
136 arch.xen.timer);
137 if (atomic_read(&vcpu->arch.xen.timer_pending))
140 atomic_inc(&vcpu->arch.xen.timer_pending);
149 atomic_set(&vcpu->arch.xen.timer_pending, 0);
150 vcpu->arch.xen.timer_expires = guest_abs;
153 xen_timer_callback(&vcpu->arch.xen.timer);
156 hrtimer_start(&vcpu->arch.xen.timer,
164 hrtimer_cancel(&vcpu->arch.xen.timer);
165 vcpu->arch.xen.timer_expires = 0;
166 atomic_set(&vcpu->arch.xen.timer_pending, 0);
171 hrtimer_init(&vcpu->arch.xen.timer, CLOCK_MONOTONIC,
173 vcpu->arch.xen.timer.function = xen_timer_callback;
178 struct kvm_vcpu_xen *vx = &v->arch.xen;
248 if (IS_ENABLED(CONFIG_64BIT) && v->kvm->arch.xen.long_mode) {
312 if (v->kvm->arch.xen.runstate_update_flag)
376 if (v->kvm->arch.xen.runstate_update_flag) {
445 struct kvm_vcpu_xen *vx = &v->arch.xen;
480 irq.vector = v->arch.xen.upcall_vector;
492 * In that case, there are bits in vcpu->arch.xen.evtchn_pending_sel which
499 unsigned long evtchn_pending_sel = READ_ONCE(v->arch.xen.evtchn_pending_sel);
500 struct gfn_to_pfn_cache *gpc = &v->arch.xen.vcpu_info_cache;
522 if (IS_ENABLED(CONFIG_64BIT) && v->kvm->arch.xen.long_mode) {
530 "+m" (v->arch.xen.evtchn_pending_sel)
542 "+m" (v->arch.xen.evtchn_pending_sel)
549 if (v->arch.xen.upcall_vector)
557 struct gfn_to_pfn_cache *gpc = &v->arch.xen.vcpu_info_cache;
614 mutex_lock(&kvm->arch.xen.xen_lock);
615 kvm->arch.xen.long_mode = !!data->u.long_mode;
616 mutex_unlock(&kvm->arch.xen.xen_lock);
622 mutex_lock(&kvm->arch.xen.xen_lock);
624 mutex_unlock(&kvm->arch.xen.xen_lock);
631 mutex_lock(&kvm->arch.xen.xen_lock);
632 kvm->arch.xen.upcall_vector = data->u.vector;
633 mutex_unlock(&kvm->arch.xen.xen_lock);
643 mutex_lock(&kvm->arch.xen.xen_lock);
644 kvm->arch.xen.xen_version = data->u.xen_version;
645 mutex_unlock(&kvm->arch.xen.xen_lock);
654 mutex_lock(&kvm->arch.xen.xen_lock);
655 kvm->arch.xen.runstate_update_flag = !!data->u.runstate_update_flag;
656 mutex_unlock(&kvm->arch.xen.xen_lock);
671 mutex_lock(&kvm->arch.xen.xen_lock);
675 data->u.long_mode = kvm->arch.xen.long_mode;
680 if (kvm->arch.xen.shinfo_cache.active)
681 data->u.shared_info.gfn = gpa_to_gfn(kvm->arch.xen.shinfo_cache.gpa);
688 data->u.vector = kvm->arch.xen.upcall_vector;
693 data->u.xen_version = kvm->arch.xen.xen_version;
702 data->u.runstate_update_flag = kvm->arch.xen.runstate_update_flag;
710 mutex_unlock(&kvm->arch.xen.xen_lock);
718 mutex_lock(&vcpu->kvm->arch.xen.xen_lock);
730 kvm_gpc_deactivate(&vcpu->arch.xen.vcpu_info_cache);
735 r = kvm_gpc_activate(&vcpu->arch.xen.vcpu_info_cache,
744 kvm_gpc_deactivate(&vcpu->arch.xen.vcpu_time_info_cache);
749 r = kvm_gpc_activate(&vcpu->arch.xen.vcpu_time_info_cache,
766 kvm_gpc_deactivate(&vcpu->arch.xen.runstate_cache);
767 kvm_gpc_deactivate(&vcpu->arch.xen.runstate2_cache);
776 if (IS_ENABLED(CONFIG_64BIT) && vcpu->kvm->arch.xen.long_mode)
783 r = kvm_gpc_activate(&vcpu->arch.xen.runstate_cache,
790 kvm_gpc_deactivate(&vcpu->arch.xen.runstate2_cache);
794 r = kvm_gpc_activate(&vcpu->arch.xen.runstate2_cache,
840 vcpu->arch.xen.current_runstate = data->u.runstate.state;
841 vcpu->arch.xen.runstate_entry_time =
843 vcpu->arch.xen.runstate_times[RUNSTATE_running] =
845 vcpu->arch.xen.runstate_times[RUNSTATE_runnable] =
847 vcpu->arch.xen.runstate_times[RUNSTATE_blocked] =
849 vcpu->arch.xen.runstate_times[RUNSTATE_offline] =
851 vcpu->arch.xen.last_steal = current->sched_info.run_delay;
876 (vcpu->arch.xen.runstate_entry_time +
882 vcpu->arch.xen.runstate_entry_time +=
884 vcpu->arch.xen.runstate_times[RUNSTATE_running] +=
886 vcpu->arch.xen.runstate_times[RUNSTATE_runnable] +=
888 vcpu->arch.xen.runstate_times[RUNSTATE_blocked] +=
890 vcpu->arch.xen.runstate_times[RUNSTATE_offline] +=
895 else if (vcpu->arch.xen.runstate_cache.active)
904 vcpu->arch.xen.vcpu_id = data->u.vcpu_id;
916 if (!vcpu->arch.xen.timer.function)
921 vcpu->arch.xen.timer_virq = data->u.timer.port;
936 vcpu->arch.xen.upcall_vector = data->u.vector;
946 mutex_unlock(&vcpu->kvm->arch.xen.xen_lock);
954 mutex_lock(&vcpu->kvm->arch.xen.xen_lock);
958 if (vcpu->arch.xen.vcpu_info_cache.active)
959 data->u.gpa = vcpu->arch.xen.vcpu_info_cache.gpa;
966 if (vcpu->arch.xen.vcpu_time_info_cache.active)
967 data->u.gpa = vcpu->arch.xen.vcpu_time_info_cache.gpa;
978 if (vcpu->arch.xen.runstate_cache.active) {
979 data->u.gpa = vcpu->arch.xen.runstate_cache.gpa;
989 data->u.runstate.state = vcpu->arch.xen.current_runstate;
998 data->u.runstate.state = vcpu->arch.xen.current_runstate;
1000 vcpu->arch.xen.runstate_entry_time;
1002 vcpu->arch.xen.runstate_times[RUNSTATE_running];
1004 vcpu->arch.xen.runstate_times[RUNSTATE_runnable];
1006 vcpu->arch.xen.runstate_times[RUNSTATE_blocked];
1008 vcpu->arch.xen.runstate_times[RUNSTATE_offline];
1017 data->u.vcpu_id = vcpu->arch.xen.vcpu_id;
1022 data->u.timer.port = vcpu->arch.xen.timer_virq;
1024 data->u.timer.expires_ns = vcpu->arch.xen.timer_expires;
1029 data->u.vector = vcpu->arch.xen.upcall_vector;
1037 mutex_unlock(&vcpu->kvm->arch.xen.xen_lock);
1049 vcpu->kvm->arch.xen.long_mode = lm;
1130 mutex_lock(&kvm->arch.xen.xen_lock);
1139 mutex_unlock(&kvm->arch.xen.xen_lock);
1153 if (unlikely(!kvm_is_linear_rip(vcpu, vcpu->arch.xen.hypercall_rip)))
1156 return kvm_xen_hypercall_set_result(vcpu, run->xen.u.hcall.result);
1161 if (IS_ENABLED(CONFIG_64BIT) && kvm->arch.xen.long_mode)
1171 struct gfn_to_pfn_cache *gpc = &kvm->arch.xen.shinfo_cache;
1183 if (IS_ENABLED(CONFIG_64BIT) && kvm->arch.xen.long_mode) {
1274 vcpu->arch.xen.poll_evtchn = port;
1276 vcpu->arch.xen.poll_evtchn = -1;
1278 set_bit(vcpu->vcpu_idx, vcpu->kvm->arch.xen.poll_mask);
1284 mod_timer(&vcpu->arch.xen.poll_timer,
1290 del_timer(&vcpu->arch.xen.poll_timer);
1295 vcpu->arch.xen.poll_evtchn = 0;
1299 clear_bit(vcpu->vcpu_idx, vcpu->kvm->arch.xen.poll_mask);
1308 struct kvm_vcpu *vcpu = from_timer(vcpu, t, arch.xen.poll_timer);
1350 if (vcpu->arch.xen.vcpu_id != vcpu_id) {
1388 if (vcpu->arch.xen.vcpu_id != vcpu_id) {
1480 if (params[0] == XENVER_version && vcpu->kvm->arch.xen.xen_version) {
1481 r = vcpu->kvm->arch.xen.xen_version;
1514 vcpu->run->xen.type = KVM_EXIT_XEN_HCALL;
1515 vcpu->run->xen.u.hcall.longmode = longmode;
1516 vcpu->run->xen.u.hcall.cpl = cpl;
1517 vcpu->run->xen.u.hcall.input = input;
1518 vcpu->run->xen.u.hcall.params[0] = params[0];
1519 vcpu->run->xen.u.hcall.params[1] = params[1];
1520 vcpu->run->xen.u.hcall.params[2] = params[2];
1521 vcpu->run->xen.u.hcall.params[3] = params[3];
1522 vcpu->run->xen.u.hcall.params[4] = params[4];
1523 vcpu->run->xen.u.hcall.params[5] = params[5];
1524 vcpu->arch.xen.hypercall_rip = kvm_get_linear_rip(vcpu);
1533 int poll_evtchn = vcpu->arch.xen.poll_evtchn;
1536 test_and_clear_bit(vcpu->vcpu_idx, vcpu->kvm->arch.xen.poll_mask)) {
1554 struct gfn_to_pfn_cache *gpc = &kvm->arch.xen.shinfo_cache;
1572 if (!vcpu->arch.xen.vcpu_info_cache.active)
1586 if (IS_ENABLED(CONFIG_64BIT) && kvm->arch.xen.long_mode) {
1614 gpc = &vcpu->arch.xen.vcpu_info_cache;
1622 if (!test_and_set_bit(port_word_bit, &vcpu->arch.xen.evtchn_pending_sel))
1627 if (IS_ENABLED(CONFIG_64BIT) && kvm->arch.xen.long_mode) {
1643 if (kick_vcpu && vcpu->arch.xen.upcall_vector) {
1682 mutex_lock(&kvm->arch.xen.xen_lock);
1699 struct gfn_to_pfn_cache *gpc = &kvm->arch.xen.shinfo_cache;
1711 mutex_unlock(&kvm->arch.xen.xen_lock);
1827 mutex_lock(&kvm->arch.xen.xen_lock);
1828 evtchnfd = idr_find(&kvm->arch.xen.evtchn_ports, port);
1858 mutex_unlock(&kvm->arch.xen.xen_lock);
1921 mutex_lock(&kvm->arch.xen.xen_lock);
1922 ret = idr_alloc(&kvm->arch.xen.evtchn_ports, evtchnfd, port, port + 1,
1924 mutex_unlock(&kvm->arch.xen.xen_lock);
1942 mutex_lock(&kvm->arch.xen.xen_lock);
1943 evtchnfd = idr_remove(&kvm->arch.xen.evtchn_ports, port);
1944 mutex_unlock(&kvm->arch.xen.xen_lock);
1962 mutex_lock(&kvm->arch.xen.xen_lock);
1969 idr_for_each_entry(&kvm->arch.xen.evtchn_ports, evtchnfd, i)
1974 mutex_unlock(&kvm->arch.xen.xen_lock);
1979 idr_for_each_entry(&kvm->arch.xen.evtchn_ports, evtchnfd, i) {
1981 idr_remove(&kvm->arch.xen.evtchn_ports, evtchnfd->send_port);
1983 mutex_unlock(&kvm->arch.xen.xen_lock);
2036 evtchnfd = idr_find(&vcpu->kvm->arch.xen.evtchn_ports, send.port);
2055 vcpu->arch.xen.vcpu_id = vcpu->vcpu_idx;
2056 vcpu->arch.xen.poll_evtchn = 0;
2058 timer_setup(&vcpu->arch.xen.poll_timer, cancel_evtchn_poll, 0);
2060 kvm_gpc_init(&vcpu->arch.xen.runstate_cache, vcpu->kvm, NULL,
2062 kvm_gpc_init(&vcpu->arch.xen.runstate2_cache, vcpu->kvm, NULL,
2064 kvm_gpc_init(&vcpu->arch.xen.vcpu_info_cache, vcpu->kvm, NULL,
2066 kvm_gpc_init(&vcpu->arch.xen.vcpu_time_info_cache, vcpu->kvm, NULL,
2075 kvm_gpc_deactivate(&vcpu->arch.xen.runstate_cache);
2076 kvm_gpc_deactivate(&vcpu->arch.xen.runstate2_cache);
2077 kvm_gpc_deactivate(&vcpu->arch.xen.vcpu_info_cache);
2078 kvm_gpc_deactivate(&vcpu->arch.xen.vcpu_time_info_cache);
2080 del_timer_sync(&vcpu->arch.xen.poll_timer);
2088 if (!vcpu->arch.xen.cpuid.base)
2091 function = vcpu->arch.xen.cpuid.base | XEN_CPUID_LEAF(3);
2092 if (function > vcpu->arch.xen.cpuid.limit)
2108 mutex_init(&kvm->arch.xen.xen_lock);
2109 idr_init(&kvm->arch.xen.evtchn_ports);
2110 kvm_gpc_init(&kvm->arch.xen.shinfo_cache, kvm, NULL, KVM_HOST_USES_PFN);
2118 kvm_gpc_deactivate(&kvm->arch.xen.shinfo_cache);
2120 idr_for_each_entry(&kvm->arch.xen.evtchn_ports, evtchnfd, i) {
2125 idr_destroy(&kvm->arch.xen.evtchn_ports);