Displaying 20 results from an estimated 22 matches for "kvmi_sock_shutdown".
2019 Aug 13
1
[RFC PATCH v6 02/92] kvm: introspection: add basic ioctls (hook/unhook)
...it pairs with the refcount_inc_not_zero 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...
2019 Aug 09
0
[RFC PATCH v6 02/92] kvm: introspection: add basic ioctls (hook/unhook)
...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
+ * from the introspector, and the only way into the introspection is
+ * thru the event handlers. Make sure the introspection ends.
+ */
+ kvmi_put(kvm);
+}
+
+static int kvmi_recv(void *arg)
+{
+ struct kvmi...
2020 Jul 21
0
[PATCH v9 54/84] KVM: introspection: add the crash action handling on the event reply
...nged, 28 insertions(+)
diff --git a/virt/kvm/introspection/kvmi.c b/virt/kvm/introspection/kvmi.c
index 02a866ca8d8c..9e0014bbf9a6 100644
--- a/virt/kvm/introspection/kvmi.c
+++ b/virt/kvm/introspection/kvmi.c
@@ -749,9 +749,37 @@ static void kvmi_handle_unsupported_event_action(struct kvm *kvm)
kvmi_sock_shutdown(KVMI(kvm));
}
+static int kvmi_vcpu_kill(int sig, struct kvm_vcpu *vcpu)
+{
+ struct kernel_siginfo siginfo[1] = {};
+ int err = -ESRCH;
+ struct pid *pid;
+
+ rcu_read_lock();
+ pid = rcu_dereference(vcpu->pid);
+ if (pid)
+ err = kill_pid_info(sig, siginfo, pid);
+ rcu_read_unlock();
+
+ r...
2019 Aug 09
0
[RFC PATCH v6 04/92] kvm: introspection: add the read/dispatch message function
...efine kvmi_err(ikvm, fmt, ...) \
kvm_info("%pU ERROR: " fmt, &ikvm->uuid, ## __VA_ARGS__)
+#define KVMI_MSG_SIZE_ALLOC (sizeof(struct kvmi_msg_hdr) + KVMI_MSG_SIZE)
+
#define KVMI_KNOWN_VCPU_EVENTS ( \
BIT(KVMI_EVENT_CR) | \
BIT(KVMI_EVENT_MSR) | \
@@ -91,4 +93,9 @@ void kvmi_sock_shutdown(struct kvmi *ikvm);
void kvmi_sock_put(struct kvmi *ikvm);
bool kvmi_msg_process(struct kvmi *ikvm);
+/* kvmi.c */
+void *kvmi_msg_alloc(void);
+void *kvmi_msg_alloc_check(size_t size);
+void kvmi_msg_free(void *addr);
+
#endif
diff --git a/virt/kvm/kvmi_msg.c b/virt/kvm/kvmi_msg.c
index 4de01...
2020 Jul 21
0
[PATCH v9 40/84] KVM: introspection: add the read/dispatch message function
...)
{
+ kvmi_cache_destroy();
}
static void free_kvmi(struct kvm *kvm)
diff --git a/virt/kvm/introspection/kvmi_int.h b/virt/kvm/introspection/kvmi_int.h
index f0a8d653d79b..5e4eabeefc5b 100644
--- a/virt/kvm/introspection/kvmi_int.h
+++ b/virt/kvm/introspection/kvmi_int.h
@@ -26,4 +26,9 @@ void kvmi_sock_shutdown(struct kvm_introspection *kvmi);
void kvmi_sock_put(struct kvm_introspection *kvmi);
bool kvmi_msg_process(struct kvm_introspection *kvmi);
+/* kvmi.c */
+void *kvmi_msg_alloc(void);
+void kvmi_msg_free(void *addr);
+bool kvmi_is_command_allowed(struct kvm_introspection *kvmi, u16 id);
+
#endi...
2020 Feb 07
0
[RFC PATCH v7 39/78] KVM: introspection: add the read/dispatch message function
...int.h
@@ -16,6 +16,8 @@
#define kvmi_err(kvmi, fmt, ...) \
kvm_info("%pU ERROR: " fmt, &kvmi->uuid, ## __VA_ARGS__)
+#define KVMI_MSG_SIZE_ALLOC (sizeof(struct kvmi_msg_hdr) + KVMI_MSG_SIZE)
+
#define KVMI_KNOWN_EVENTS 0
#define KVMI_KNOWN_COMMANDS 0
@@ -28,4 +30,9 @@ void kvmi_sock_shutdown(struct kvm_introspection *kvmi);
void kvmi_sock_put(struct kvm_introspection *kvmi);
bool kvmi_msg_process(struct kvm_introspection *kvmi);
+/* kvmi.c */
+void *kvmi_msg_alloc(void);
+void *kvmi_msg_alloc_check(size_t size);
+void kvmi_msg_free(void *addr);
+
#endif
diff --git a/virt/kvm/intro...
2020 Feb 07
0
[RFC PATCH v7 52/78] KVM: introspection: add KVMI_EVENT_PAUSE_VCPU
...;PAUSE");
+ }
}
void kvmi_handle_requests(struct kvm_vcpu *vcpu)
diff --git a/virt/kvm/introspection/kvmi_int.h b/virt/kvm/introspection/kvmi_int.h
index d1d93488af1c..50b2b98dd99b 100644
--- a/virt/kvm/introspection/kvmi_int.h
+++ b/virt/kvm/introspection/kvmi_int.h
@@ -54,6 +54,7 @@ void kvmi_sock_shutdown(struct kvm_introspection *kvmi);
void kvmi_sock_put(struct kvm_introspection *kvmi);
bool kvmi_msg_process(struct kvm_introspection *kvmi);
int kvmi_msg_send_unhook(struct kvm_introspection *kvmi);
+u32 kvmi_msg_send_vcpu_pause(struct kvm_vcpu *vcpu);
/* kvmi.c */
void *kvmi_msg_alloc(void);...
2020 Feb 07
0
[RFC PATCH v7 48/78] KVM: introspection: handle vCPU introspection requests
...nt_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 kvmi_recv_thread(void *arg)
*/
kvmi_sock_shutdown(kvmi);
+ kvmi_put(kvmi->kvm);
return 0;
}
@@ -293,9 +319,18 @@ int kvmi_hook(struct kvm *kvm, const struct kvm_introspection_hook *hook)
if (err)
goto destroy;
+ init_completion(&kvm->kvmi_complete);
+
+ refcount_set(&kvm->kvmi_ref, 1);
+ /*
+ * Paired with refcount_...
2020 Feb 07
0
[RFC PATCH v7 49/78] KVM: introspection: handle vCPU commands
...gt;hdr.id;
+ int err;
+
+ job->vcpu = vcpu;
+
+ err = msg_vcpu[id](job, &job->msg->hdr, job->msg + 1);
+
+ if (err) {
+ struct kvm_introspection *kvmi = KVMI(vcpu->kvm);
+
+ kvmi_err(kvmi,
+ "%s: cmd id: %zu (%s), err: %d\n", __func__,
+ id, id2str(id), err);
+ kvmi_sock_shutdown(kvmi);
+ }
+}
+
+static void kvmi_free_ctx(void *_ctx)
+{
+ const struct kvmi_vcpu_cmd_job *ctx = _ctx;
+
+ kvmi_msg_free(ctx->msg);
+ kfree(ctx);
+}
+
+static int kvmi_msg_queue_to_vcpu(struct kvm_vcpu *vcpu,
+ const struct kvmi_vcpu_cmd_job *cmd)
+{
+ return kvmi_add_job(vcpu, kvmi_job_vc...
2020 Jul 21
0
[PATCH v9 50/84] KVM: introspection: handle vCPU commands
...ctx;
+ size_t id = job->msg->hdr.id;
+ int err;
+
+ job->vcpu = vcpu;
+
+ err = msg_vcpu[id](job, &job->msg->hdr, job->msg + 1);
+
+ /*
+ * This is running from the vCPU thread.
+ * Any error that is not sent with the reply
+ * will shut down the socket.
+ */
+ if (err)
+ kvmi_sock_shutdown(KVMI(vcpu->kvm));
+}
+
+static void kvmi_free_ctx(void *_ctx)
+{
+ const struct kvmi_vcpu_msg_job *ctx = _ctx;
+
+ kvmi_msg_free(ctx->msg);
+ kfree(ctx);
+}
+
+static int kvmi_msg_queue_to_vcpu(struct kvm_vcpu *vcpu,
+ const struct kvmi_vcpu_msg_job *cmd)
+{
+ return kvmi_add_job(vcpu, k...
2020 Feb 07
0
[RFC PATCH v7 44/78] KVM: introspection: add KVMI_VM_CONTROL_EVENTS
...e KVMI(kvm) ((struct kvm_introspection *)((kvm)->kvmi))
+static inline bool is_vm_event_enabled(struct kvm_introspection *kvmi,
+ int event)
+{
+ return test_bit(event, kvmi->vm_event_enable_mask);
+}
+
/* kvmi_msg.c */
bool kvmi_sock_get(struct kvm_introspection *kvmi, int fd);
void kvmi_sock_shutdown(struct kvm_introspection *kvmi);
@@ -45,5 +52,7 @@ int kvmi_msg_send_unhook(struct kvm_introspection *kvmi);
void *kvmi_msg_alloc(void);
void *kvmi_msg_alloc_check(size_t size);
void kvmi_msg_free(void *addr);
+int kvmi_cmd_vm_control_events(struct kvm_introspection *kvmi,
+ unsigned int even...
2020 Feb 07
0
[RFC PATCH v7 43/78] KVM: introspection: add KVMI_EVENT_UNHOOK
...( \
+ BIT(KVMI_EVENT_UNHOOK) \
+ )
+#define KVMI_KNOWN_VCPU_EVENTS 0
+
+#define KVMI_KNOWN_EVENTS (KVMI_KNOWN_VM_EVENTS | KVMI_KNOWN_VCPU_EVENTS)
#define KVMI_KNOWN_COMMANDS ( \
BIT(KVMI_GET_VERSION) \
@@ -34,6 +39,7 @@ bool kvmi_sock_get(struct kvm_introspection *kvmi, int fd);
void kvmi_sock_shutdown(struct kvm_introspection *kvmi);
void kvmi_sock_put(struct kvm_introspection *kvmi);
bool kvmi_msg_process(struct kvm_introspection *kvmi);
+int kvmi_msg_send_unhook(struct kvm_introspection *kvmi);
/* kvmi.c */
void *kvmi_msg_alloc(void);
diff --git a/virt/kvm/introspection/kvmi_msg.c b/virt...
2020 Feb 07
0
[RFC PATCH v7 57/78] KVM: introspection: add KVMI_EVENT_HYPERCALL
...m_introspection *kvmi,
return test_bit(event, kvmi->vm_event_enable_mask);
}
+static inline bool is_event_enabled(struct kvm_vcpu *vcpu, int event)
+{
+ return test_bit(event, VCPUI(vcpu)->ev_mask);
+}
+
/* kvmi_msg.c */
bool kvmi_sock_get(struct kvm_introspection *kvmi, int fd);
void kvmi_sock_shutdown(struct kvm_introspection *kvmi);
@@ -59,6 +65,7 @@ void kvmi_sock_put(struct kvm_introspection *kvmi);
bool kvmi_msg_process(struct kvm_introspection *kvmi);
int kvmi_msg_send_unhook(struct kvm_introspection *kvmi);
u32 kvmi_msg_send_vcpu_pause(struct kvm_vcpu *vcpu);
+u32 kvmi_msg_send_hypercal...
2019 Aug 09
0
[RFC PATCH v6 27/92] kvm: introspection: use page track
...l cmd_reply_disabled;
};
+struct kvmi_mem_access {
+ gfn_t gfn;
+ u8 access;
+ struct kvmi_arch_mem_access arch;
+};
+
+static inline bool is_event_enabled(struct kvm_vcpu *vcpu, int event)
+{
+ return false; /* TODO */
+}
+
/* kvmi_msg.c */
bool kvmi_sock_get(struct kvmi *ikvm, int fd);
void kvmi_sock_shutdown(struct kvmi *ikvm);
@@ -138,7 +154,12 @@ int kvmi_add_job(struct kvm_vcpu *vcpu,
void *ctx, void (*free_fct)(void *ctx));
/* arch */
+void kvmi_arch_update_page_tracking(struct kvm *kvm,
+ struct kvm_memory_slot *slot,
+ struct kvmi_mem_access *m);
void kvmi_arch_setup_event(s...
2020 Jul 21
0
[PATCH v9 44/84] KVM: introspection: add KVMI_EVENT_UNHOOK
...turn err;
+}
diff --git a/virt/kvm/introspection/kvmi_int.h b/virt/kvm/introspection/kvmi_int.h
index 0bca4bd0a415..c385dc0eb708 100644
--- a/virt/kvm/introspection/kvmi_int.h
+++ b/virt/kvm/introspection/kvmi_int.h
@@ -25,6 +25,7 @@ bool kvmi_sock_get(struct kvm_introspection *kvmi, int fd);
void kvmi_sock_shutdown(struct kvm_introspection *kvmi);
void kvmi_sock_put(struct kvm_introspection *kvmi);
bool kvmi_msg_process(struct kvm_introspection *kvmi);
+int kvmi_msg_send_unhook(struct kvm_introspection *kvmi);
/* kvmi.c */
void *kvmi_msg_alloc(void);
diff --git a/virt/kvm/introspection/kvmi_msg.c b/virt...
2019 Aug 09
0
[RFC PATCH v6 16/92] kvm: introspection: handle events and event replies
...= -EINTR;
+
+ err = kvmi_sock_write(ikvm, vec, n, msg_size);
+ if (err)
+ goto out;
+
+ ivcpu->reply_waiting = true;
+ err = kvmi_run_jobs_and_wait(vcpu);
+ if (err)
+ goto out;
+
+ err = ivcpu->reply.error;
+ if (err)
+ goto out;
+
+ *action = ivcpu->reply.action;
+
+out:
+ if (err)
+ kvmi_sock_shutdown(ikvm);
+ return err;
+}
+
2020 Feb 07
0
[RFC PATCH v7 60/78] KVM: introspection: add KVMI_VCPU_CONTROL_CR and KVMI_EVENT_CR
..._PHYSICAL) \
| BIT(KVMI_VCPU_GET_INFO) \
| BIT(KVMI_VCPU_PAUSE) \
+ | BIT(KVMI_VCPU_CONTROL_CR) \
| BIT(KVMI_VCPU_CONTROL_EVENTS) \
| BIT(KVMI_VCPU_GET_CPUID) \
| BIT(KVMI_VCPU_GET_REGISTERS) \
@@ -64,6 +66,9 @@ bool kvmi_sock_get(struct kvm_introspection *kvmi, int fd);
void kvmi_sock_shutdown(struct kvm_introspection *kvmi);
void kvmi_sock_put(struct kvm_introspection *kvmi);
bool kvmi_msg_process(struct kvm_introspection *kvmi);
+int kvmi_send_event(struct kvm_vcpu *vcpu, u32 ev_id,
+ void *ev, size_t ev_size,
+ void *rpl, size_t rpl_size, int *action);
int kvmi_msg_send_u...
2020 Feb 07
78
[RFC PATCH v7 00/78] 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 VMs (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
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