search for: kvmi_put

Displaying 20 results from an estimated 28 matches for "kvmi_put".

Did you mean: kvmi_int
2019 Aug 13
1
[RFC PATCH v6 02/92] kvm: introspection: add basic ioctls (hook/unhook)
...in kvmi_get. > + refcount_set(&kvm->kvmi_ref, 1); > + > @@ -57,8 +183,27 @@ void kvmi_destroy_vm(struct kvm *kvm) > if (!ikvm) > return; > > + /* trigger socket shutdown - kvmi_recv() will start shutdown process */ > + kvmi_sock_shutdown(ikvm); > + > kvmi_put(kvm); > > /* wait for introspection resources to be released */ > wait_for_completion_killable(&kvm->kvmi_completed); > } > + This addition means that kvmi_destroy_vm should have called kvmi_end_introspection instead. In patch 1, kvmi_end_introspection should have bee...
2019 Aug 09
0
[RFC PATCH v6 27/92] kvm: introspection: use page track
...kvm_page_track_notifier_node *node, + bool *data_ready) +{ + struct kvmi *ikvm; + bool ret = true; + + ikvm = kvmi_get(vcpu->kvm); + if (!ikvm) + return true; + + if (is_event_enabled(vcpu, KVMI_EVENT_PF)) + ret = __kvmi_track_preread(vcpu, gpa, gva, new, bytes, node, + data_ready); + + kvmi_put(vcpu->kvm); + + return ret; +} + +static bool __kvmi_track_prewrite(struct kvm_vcpu *vcpu, gpa_t gpa, gva_t gva, + const u8 *new, int bytes, + struct kvm_page_track_notifier_node *node) +{ + if (!is_pf_of_interest(vcpu, gpa, KVMI_PAGE_ACCESS_W)) + return true; + + return kvmi_arch_pf_event(vcpu...
2020 Feb 07
0
[RFC PATCH v7 48/78] KVM: introspection: handle vCPU introspection requests
...->kvmi_complete); kvmi_sock_put(kvmi); } @@ -242,8 +252,23 @@ int kvmi_ioctl_unhook(struct kvm *kvm) return 0; } +struct kvm_introspection * __must_check kvmi_get(struct kvm *kvm) +{ + if (refcount_inc_not_zero(&kvm->kvmi_ref)) + return kvm->kvmi; + + return NULL; +} + +void kvmi_put(struct kvm *kvm) +{ + if (refcount_dec_and_test(&kvm->kvmi_ref)) + complete(&kvm->kvmi_complete); +} + static int __kvmi_hook(struct kvm *kvm, const struct kvm_introspection_hook *hook) + { struct kvm_introspection *kvmi = KVMI(kvm); @@ -266,6 +291,7 @@ static int kvm...
2019 Aug 13
1
[RFC PATCH v6 13/92] kvm: introspection: make the vCPU wait even when its jobs list is empty
...+void kvmi_handle_requests(struct kvm_vcpu *vcpu) > +{ > + struct kvmi *ikvm; > + > + ikvm = kvmi_get(vcpu->kvm); > + if (!ikvm) > + return; > + > + for (;;) { > + int err = kvmi_run_jobs_and_wait(vcpu); > + > + if (err) > + break; > + } > + > + kvmi_put(vcpu->kvm); > +} > + Using kvmi_run_jobs_and_wait from two places (here and kvmi_send_event) is very confusing. Does kvmi_handle_requests need to do this, or can it just use kvmi_run_jobs? Paolo
2019 Aug 09
0
[RFC PATCH v6 02/92] kvm: introspection: add basic ioctls (hook/unhook)
..._must_check kvmi_get(struct kvm *kvm) static void kvmi_destroy(struct kvm *kvm) { + kfree(kvm->kvmi); + kvm->kvmi = NULL; } static void kvmi_release(struct kvm *kvm) { + kvmi_sock_put(IKVM(kvm)); kvmi_destroy(kvm); complete(&kvm->kvmi_completed); @@ -43,6 +64,111 @@ void kvmi_put(struct kvm *kvm) kvmi_release(kvm); } +static void kvmi_end_introspection(struct kvmi *ikvm) +{ + struct kvm *kvm = ikvm->kvm; + + /* Signal QEMU which is waiting for POLLHUP. */ + kvmi_sock_shutdown(ikvm); + + /* + * At this moment the socket is shut down, no more commands will come + *...
2020 Feb 07
0
[RFC PATCH v7 60/78] KVM: introspection: add KVMI_VCPU_CONTROL_CR and KVMI_EVENT_CR
...gned long *new_value) +{ + struct kvm_introspection *kvmi; + bool ret = true; + + if (old_value == *new_value) + return true; + + kvmi = kvmi_get(vcpu->kvm); + if (!kvmi) + return true; + + if (is_event_enabled(vcpu, KVMI_EVENT_CR)) + ret = __kvmi_cr_event(vcpu, cr, old_value, new_value); + + kvmi_put(vcpu->kvm); + + return ret; +} + +bool kvmi_cr3_intercepted(struct kvm_vcpu *vcpu) +{ + struct kvm_introspection *kvmi; + bool ret; + + kvmi = kvmi_get(vcpu->kvm); + if (!kvmi) + return false; + + ret = test_bit(3, VCPUI(vcpu)->arch.cr_mask); + + kvmi_put(vcpu->kvm); + + return ret; +}...
2020 Feb 07
0
[RFC PATCH v7 74/78] KVM: introspection: add KVMI_VCPU_CONTROL_SINGLESTEP
...(struct kvm_vcpu *vcpu) if (!kvmi) return true; + if (VCPUI(vcpu)->singlestep.loop) + kvmi_arch_start_singlestep(vcpu); + if (kvmi_inject_pending_exception(vcpu)) r = false; @@ -1296,3 +1302,20 @@ static void kvmi_track_flush_slot(struct kvm *kvm, struct kvm_memory_slot *slot, kvmi_put(kvm); } + +bool kvmi_vcpu_running_singlestep(struct kvm_vcpu *vcpu) +{ + struct kvm_introspection *kvmi; + bool ret; + + kvmi = kvmi_get(vcpu->kvm); + if (!kvmi) + return false; + + ret = VCPUI(vcpu)->singlestep.loop; + + kvmi_put(vcpu->kvm); + + return ret; +} +EXPORT_SYMBOL(kvmi_vcpu_r...
2019 Aug 12
2
[RFC PATCH v6 01/92] kvm: introduce KVMI (VM introspection subsystem)
...c void kvmi_destroy(struct kvm *kvm) > +{ > +} > + > +static void kvmi_release(struct kvm *kvm) > +{ > + kvmi_destroy(kvm); > + > + complete(&kvm->kvmi_completed); > +} > + > +/* This function may be called from atomic context and must not sleep */ > +void kvmi_put(struct kvm *kvm) > +{ > + if (refcount_dec_and_test(&kvm->kvmi_ref)) > + kvmi_release(kvm); > +} > + > +void kvmi_create_vm(struct kvm *kvm) > +{ > + init_completion(&kvm->kvmi_completed); > + complete(&kvm->kvmi_completed); Pretty sure you don'...
2019 Aug 09
0
[RFC PATCH v6 01/92] kvm: introduce KVMI (VM introspection subsystem)
...i_ref)) + return kvm->kvmi; + + return NULL; +} + +static void kvmi_destroy(struct kvm *kvm) +{ +} + +static void kvmi_release(struct kvm *kvm) +{ + kvmi_destroy(kvm); + + complete(&kvm->kvmi_completed); +} + +/* This function may be called from atomic context and must not sleep */ +void kvmi_put(struct kvm *kvm) +{ + if (refcount_dec_and_test(&kvm->kvmi_ref)) + kvmi_release(kvm); +} + +void kvmi_create_vm(struct kvm *kvm) +{ + init_completion(&kvm->kvmi_completed); + complete(&kvm->kvmi_completed); +} + +void kvmi_destroy_vm(struct kvm *kvm) +{ + struct kvmi *ikvm; +...
2019 Aug 09
0
[RFC PATCH v6 64/92] kvm: introspection: add single-stepping
...vm->ss_level = 0; + + kvmi_arch_stop_single_step(vcpu); + + atomic_set(&ikvm->ss_active, false); + /* + * Make ss_active update visible + * before resuming all the other vCPUs. + */ + smp_mb__after_atomic(); + kvm_make_all_cpus_request(kvm, 0); + + ivcpu->ss_owner = false; + +out: + kvmi_put(kvm); +} +EXPORT_SYMBOL(kvmi_stop_ss); + +static bool kvmi_acquire_ss(struct kvm_vcpu *vcpu) +{ + struct kvmi_vcpu *ivcpu = IVCPU(vcpu); + struct kvmi *ikvm = IKVM(vcpu->kvm); + + if (ivcpu->ss_owner) + return true; + + if (atomic_cmpxchg(&ikvm->ss_active, false, true) != false) + re...
2019 Aug 09
0
[RFC PATCH v6 13/92] kvm: introspection: make the vCPU wait even when its jobs list is empty
...+ kvmi_add_job(vcpu, kvmi_job_wait, NULL, NULL); + } + + return err; +} + +void kvmi_handle_requests(struct kvm_vcpu *vcpu) +{ + struct kvmi *ikvm; + + ikvm = kvmi_get(vcpu->kvm); + if (!ikvm) + return; + + for (;;) { + int err = kvmi_run_jobs_and_wait(vcpu); + + if (err) + break; + } + + kvmi_put(vcpu->kvm); +} + int kvmi_cmd_control_vm_events(struct kvmi *ikvm, unsigned int event_id, bool enable) { diff --git a/virt/kvm/kvmi_int.h b/virt/kvm/kvmi_int.h index 97f91a568096..47418e9a86f6 100644 --- a/virt/kvm/kvmi_int.h +++ b/virt/kvm/kvmi_int.h @@ -85,6 +85,8 @@ struct kvmi_j...
2019 Aug 09
117
[RFC PATCH v6 00/92] VM introspection
The KVM introspection subsystem provides a facility for applications running on the host or in a separate VM, to control the execution of other VM-s (pause, resume, shutdown), query the state of the vCPUs (GPRs, MSRs etc.), alter the page access bits in the shadow page tables (only for the hardware backed ones, eg. Intel's EPT) and receive notifications when events of interest have taken place
2019 Aug 09
117
[RFC PATCH v6 00/92] VM introspection
The KVM introspection subsystem provides a facility for applications running on the host or in a separate VM, to control the execution of other VM-s (pause, resume, shutdown), query the state of the vCPUs (GPRs, MSRs etc.), alter the page access bits in the shadow page tables (only for the hardware backed ones, eg. Intel's EPT) and receive notifications when events of interest have taken place
2020 Jul 21
0
[PATCH v9 69/84] KVM: introspection: add KVMI_VCPU_GET_XCR
...cpu_get_xcr_reply { + u64 value; +}; + #endif /* _UAPI_ASM_X86_KVMI_H */ diff --git a/arch/x86/kvm/kvmi.c b/arch/x86/kvm/kvmi.c index 55c5e290730c..ff70c9a33ccf 100644 --- a/arch/x86/kvm/kvmi.c +++ b/arch/x86/kvm/kvmi.c @@ -720,3 +720,20 @@ void kvmi_xsetbv_event(struct kvm_vcpu *vcpu, u8 xcr, kvmi_put(vcpu->kvm); } + +int kvmi_arch_cmd_vcpu_get_xcr(struct kvm_vcpu *vcpu, + const struct kvmi_vcpu_get_xcr *req, + struct kvmi_vcpu_get_xcr_reply *rpl) +{ + int i; + + for (i = 0; i < ARRAY_SIZE(req->padding); i++) + if (req->padding[i]) + return -KVM_EINVAL; + + if (...
2019 Aug 12
1
[RFC PATCH v6 64/92] kvm: introspection: add single-stepping
...> + atomic_set(&ikvm->ss_active, false); > + /* > + * Make ss_active update visible > + * before resuming all the other vCPUs. > + */ > + smp_mb__after_atomic(); > + kvm_make_all_cpus_request(kvm, 0); > + > + ivcpu->ss_owner = false; > + > +out: > + kvmi_put(kvm); > +} > +EXPORT_SYMBOL(kvmi_stop_ss); > + > +static bool kvmi_acquire_ss(struct kvm_vcpu *vcpu) > +{ > + struct kvmi_vcpu *ivcpu = IVCPU(vcpu); > + struct kvmi *ikvm = IKVM(vcpu->kvm); > + > + if (ivcpu->ss_owner) > + return true; > + > + if (atomic_c...
2020 Feb 07
0
[RFC PATCH v7 64/78] KVM: introspection: add KVMI_EVENT_XSETBV
...ommon_event_actions(vcpu->kvm, action, "XSETBV"); + } +} + +void kvmi_xsetbv_event(struct kvm_vcpu *vcpu) +{ + struct kvm_introspection *kvmi; + + kvmi = kvmi_get(vcpu->kvm); + if (!kvmi) + return; + + if (is_event_enabled(vcpu, KVMI_EVENT_XSETBV)) + __kvmi_xsetbv_event(vcpu); + + kvmi_put(vcpu->kvm); +}
2020 Feb 07
0
[RFC PATCH v7 59/78] KVM: introspection: restore the state of #BP interception on unhook
...kvmi; @@ -331,7 +348,7 @@ int kvmi_hook(struct kvm *kvm, const struct kvm_introspection_hook *hook) mutex_lock(&kvm->kvmi_lock); - if (kvm->kvmi) { + if (!ready_to_hook(kvm)) { err = -EEXIST; goto out; } @@ -793,7 +810,11 @@ void kvmi_handle_requests(struct kvm_vcpu *vcpu) kvmi_put(vcpu->kvm); out: - kvmi_arch_restore_interception(vcpu); + if (kvmi_arch_restore_interception(vcpu)) { + mutex_lock(&vcpu->kvm->kvmi_lock); + kvmi_arch_vcpu_free(vcpu); + mutex_unlock(&vcpu->kvm->kvmi_lock); + } } int kvmi_cmd_vcpu_pause(struct kvm_vcpu *vcpu, bool...
2020 Feb 07
0
[RFC PATCH v7 75/78] KVM: introspection: add KVMI_EVENT_SINGLESTEP
...+} + +static void kvmi_singlestep_event(struct kvm_vcpu *vcpu, bool success) +{ + struct kvm_introspection *kvmi; + struct kvm *kvm = vcpu->kvm; + + kvmi = kvmi_get(kvm); + if (!kvmi) + return; + + if (is_event_enabled(vcpu, KVMI_EVENT_SINGLESTEP)) + __kvmi_singlestep_event(vcpu, success); + + kvmi_put(kvm); +} + +void kvmi_singlestep_done(struct kvm_vcpu *vcpu) +{ + kvmi_singlestep_event(vcpu, true); +} +EXPORT_SYMBOL(kvmi_singlestep_done); + +void kvmi_singlestep_failed(struct kvm_vcpu *vcpu) +{ + kvmi_singlestep_event(vcpu, false); +} +EXPORT_SYMBOL(kvmi_singlestep_failed); diff --git a/virt/k...
2020 Jul 21
0
[PATCH v9 81/84] KVM: introspection: add KVMI_EVENT_SINGLESTEP
...uct kvm_vcpu *vcpu, bool success) +{ + struct kvm_vcpu_introspection *vcpui; + struct kvm_introspection *kvmi; + struct kvm *kvm = vcpu->kvm; + + kvmi = kvmi_get(kvm); + if (!kvmi) + return; + + vcpui = VCPUI(vcpu); + + if (vcpui->singlestep.loop) + kvmi_singlestep_event(vcpu, success); + + kvmi_put(kvm); +} + +void kvmi_singlestep_done(struct kvm_vcpu *vcpu) +{ + kvmi_handle_singlestep_exit(vcpu, true); +} +EXPORT_SYMBOL(kvmi_singlestep_done); + +void kvmi_singlestep_failed(struct kvm_vcpu *vcpu) +{ + kvmi_handle_singlestep_exit(vcpu, false); +} +EXPORT_SYMBOL(kvmi_singlestep_failed); diff --...
2020 Jul 21
0
[PATCH v9 68/84] KVM: introspection: add KVMI_EVENT_XSETBV
...id kvmi_xsetbv_event(struct kvm_vcpu *vcpu, u8 xcr, + u64 old_value, u64 new_value) +{ + struct kvm_introspection *kvmi; + + kvmi = kvmi_get(vcpu->kvm); + if (!kvmi) + return; + + if (is_event_enabled(vcpu, KVMI_EVENT_XSETBV)) + __kvmi_xsetbv_event(vcpu, xcr, old_value, new_value); + + kvmi_put(vcpu->kvm); +} diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index af987ad1a174..c3557a11817f 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -919,6 +919,12 @@ static int __kvm_set_xcr(struct kvm_vcpu *vcpu, u32 index, u64 xcr) } vcpu->arch.xcr0 = xcr0; +#ifdef CONFIG...