@@ -29,6 +29,7 @@ static inline int irq_canonicalize(int irq)
extern __visible void smp_kvm_posted_intr_ipi(struct pt_regs *regs);
extern __visible void smp_kvm_posted_intr_wakeup_ipi(struct pt_regs *regs);
extern __visible void smp_kvm_posted_intr_nested_ipi(struct pt_regs *regs);
+extern void kvm_set_isolation_exit_handler(void (*handler)(void));
#endif
extern void (*x86_platform_ipi_callback)(void);
@@ -295,6 +295,17 @@ void kvm_set_posted_intr_wakeup_handler(void (*handler)(void))
}
EXPORT_SYMBOL_GPL(kvm_set_posted_intr_wakeup_handler);
+void (*kvm_isolation_exit_handler)(void) = dummy_handler;
+
+void kvm_set_isolation_exit_handler(void (*handler)(void))
+{
+ if (handler)
+ kvm_isolation_exit_handler = handler;
+ else
+ kvm_isolation_exit_handler = dummy_handler;
+}
+EXPORT_SYMBOL_GPL(kvm_set_isolation_exit_handler);
+
/*
* Handler for POSTED_INTERRUPT_VECTOR.
*/
@@ -5,6 +5,7 @@
* KVM Address Space Isolation
*/
+#include <linux/kvm_host.h>
#include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/printk.h>
@@ -95,6 +96,16 @@ static void kvm_isolation_uninit_mm(void)
free_pages((unsigned long)kvm_pgd, PGD_ALLOCATION_ORDER);
}
+static void kvm_isolation_set_handlers(void)
+{
+ kvm_set_isolation_exit_handler(kvm_isolation_exit);
+}
+
+static void kvm_isolation_clear_handlers(void)
+{
+ kvm_set_isolation_exit_handler(NULL);
+}
+
int kvm_isolation_init(void)
{
int r;
@@ -106,6 +117,7 @@ int kvm_isolation_init(void)
if (r)
return r;
+ kvm_isolation_set_handlers();
pr_info("KVM: x86: Running with isolated address space\n");
return 0;
@@ -116,6 +128,7 @@ void kvm_isolation_uninit(void)
if (!address_space_isolation)
return;
+ kvm_isolation_clear_handlers();
kvm_isolation_uninit_mm();
pr_info("KVM: x86: End of isolated address space\n");
}