From 830ce1f69238136c0197858242f16cf44e0d6cb9 Mon Sep 17 00:00:00 2001
From: hc <hc@nodka.com>
Date: Fri, 01 Nov 2024 03:09:37 +0000
Subject: [PATCH] gpio config
---
kernel/include/linux/kvm_host.h | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 55 insertions(+), 0 deletions(-)
diff --git a/kernel/include/linux/kvm_host.h b/kernel/include/linux/kvm_host.h
index 9cb0a3d..36d741e 100644
--- a/kernel/include/linux/kvm_host.h
+++ b/kernel/include/linux/kvm_host.h
@@ -14,6 +14,7 @@
#include <linux/mm.h>
#include <linux/mmu_notifier.h>
#include <linux/preempt.h>
+#include <linux/dovetail.h>
#include <linux/msi.h>
#include <linux/slab.h>
#include <linux/vmalloc.h>
@@ -260,10 +261,23 @@
unsigned len;
};
+/*
+ * Called when the host is about to leave the inband stage. Typically
+ * used for switching the current vcpu out of guest mode before a
+ * companion core reinstates an oob task context.
+ */
+struct kvm_oob_notifier {
+ void (*handler)(struct kvm_oob_notifier *nfy);
+ bool put_vcpu;
+};
+
struct kvm_vcpu {
struct kvm *kvm;
#ifdef CONFIG_PREEMPT_NOTIFIERS
struct preempt_notifier preempt_notifier;
+#endif
+#ifdef CONFIG_DOVETAIL
+ struct kvm_oob_notifier oob_notifier;
#endif
int cpu;
int vcpu_id; /* id given by userspace at creation */
@@ -1502,6 +1516,47 @@
}
#endif /* CONFIG_HAVE_KVM_VCPU_RUN_PID_CHANGE */
+#if defined(CONFIG_DOVETAIL) && defined(CONFIG_KVM)
+static inline void inband_init_vcpu(struct kvm_vcpu *vcpu,
+ void (*preempt_handler)(struct kvm_oob_notifier *nfy))
+{
+ vcpu->oob_notifier.handler = preempt_handler;
+ vcpu->oob_notifier.put_vcpu = false;
+}
+
+static inline void inband_enter_guest(struct kvm_vcpu *vcpu)
+{
+ struct irq_pipeline_data *p = raw_cpu_ptr(&irq_pipeline);
+ WRITE_ONCE(p->vcpu_notify, &vcpu->oob_notifier);
+}
+
+static inline void inband_exit_guest(void)
+{
+ struct irq_pipeline_data *p = raw_cpu_ptr(&irq_pipeline);
+ WRITE_ONCE(p->vcpu_notify, NULL);
+}
+
+static inline void inband_set_vcpu_release_state(struct kvm_vcpu *vcpu,
+ bool pending)
+{
+ vcpu->oob_notifier.put_vcpu = pending;
+}
+#else
+static inline void inband_init_vcpu(struct kvm_vcpu *vcpu,
+ void (*preempt_handler)(struct kvm_oob_notifier *nfy))
+{ }
+
+static inline void inband_enter_guest(struct kvm_vcpu *vcpu)
+{ }
+
+static inline void inband_exit_guest(void)
+{ }
+
+static inline void inband_set_vcpu_release_state(struct kvm_vcpu *vcpu,
+ bool pending)
+{ }
+#endif
+
typedef int (*kvm_vm_thread_fn_t)(struct kvm *kvm, uintptr_t data);
int kvm_vm_create_worker_thread(struct kvm *kvm, kvm_vm_thread_fn_t thread_fn,
--
Gitblit v1.6.2