From: Anthony Liguori <aliguori-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
To: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
Subject: Re: [PATCH] Refactor hypercall infrastructure
Date: Fri, 14 Sep 2007 14:47:39 -0500 [thread overview]
Message-ID: <46EAE55B.10906@us.ibm.com> (raw)
In-Reply-To: <11897991353793-git-send-email-aliguori-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
[-- Attachment #1: Type: text/plain, Size: 245 bytes --]
Attached is the patch I'm using to test it. I'm going to take a look at
Rusty's pv_ops implementation for kvm-lite so that we can submit a
single common one instead of introducing mine and having unnecessary churn.
Regards,
Anthony Liguori
[-- Attachment #2: kvm-paravirt-ops.diff --]
[-- Type: text/x-patch, Size: 5092 bytes --]
Subject: [PATCH 2/3] KVM paravirt-ops implementation (v2)
From: Anthony Liguori <aliguori-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
Cc: Avi Kivity <avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
Cc: virtualization-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org
Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
A very simple paravirt_ops implementation for KVM. Future patches will add
more sophisticated optimizations. The goal of having this presenting this now
is to validate the new hypercall infrastructure and to make my patch queue
smaller.
Signed-off-by: Anthony Liguori <aliguori-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
diff --git a/arch/i386/Kconfig b/arch/i386/Kconfig
index 97b64d7..95a67d4 100644
--- a/arch/i386/Kconfig
+++ b/arch/i386/Kconfig
@@ -237,6 +237,13 @@ config VMI
at the moment), by linking the kernel to a GPL-ed ROM module
provided by the hypervisor.
+config KVM_GUEST
+ bool "KVM paravirt-ops support"
+ depends on PARAVIRT
+ help
+ This option enables various optimizations for running under the KVM
+ hypervisor.
+
config ACPI_SRAT
bool
default y
diff --git a/arch/i386/kernel/Makefile b/arch/i386/kernel/Makefile
index 9d33b00..6308fcf 100644
--- a/arch/i386/kernel/Makefile
+++ b/arch/i386/kernel/Makefile
@@ -42,6 +42,7 @@ obj-$(CONFIG_K8_NB) += k8.o
obj-$(CONFIG_MGEODE_LX) += geode.o
obj-$(CONFIG_VMI) += vmi.o vmiclock.o
+obj-$(CONFIG_KVM_GUEST) += kvm.o
obj-$(CONFIG_PARAVIRT) += paravirt.o
obj-y += pcspeaker.o
diff --git a/arch/i386/kernel/kvm.c b/arch/i386/kernel/kvm.c
new file mode 100644
index 0000000..42ffe25
--- /dev/null
+++ b/arch/i386/kernel/kvm.c
@@ -0,0 +1,55 @@
+/*
+ * KVM paravirt_ops implementation
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Copyright IBM Corporation, 2007
+ * Authors: Anthony Liguori <aliguori-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
+ */
+
+#include <linux/kernel.h>
+#include <linux/kvm_para.h>
+
+/*
+ * No need for any "IO delay" on KVM
+ */
+static void kvm_io_delay(void)
+{
+}
+
+static __init void paravirt_setup(void)
+{
+ int i;
+
+ paravirt_ops.name = "KVM";
+
+ if (kvm_para_has_feature(KVM_PARA_FEATURE_NOP_IO_DELAY))
+ paravirt_ops.io_delay = kvm_io_delay;
+
+ paravirt_ops.paravirt_enabled = 1;
+
+ printk(KERN_INFO "KVM: Issuing hypercall\n");
+ for (i = 0; i < 2; i++)
+ i += kvm_hypercall0(0);
+ printk(KERN_INFO "KVM: done hypercall\n");
+}
+
+void __init kvm_guest_init(void)
+{
+ printk(KERN_INFO "KVM: kvm guest init\n");
+
+ if (kvm_para_available())
+ paravirt_setup();
+}
diff --git a/drivers/kvm/kvm_main.c b/drivers/kvm/kvm_main.c
index 5211d19..d04cead 100644
--- a/drivers/kvm/kvm_main.c
+++ b/drivers/kvm/kvm_main.c
@@ -1405,6 +1405,11 @@ int kvm_emulate_hypercall(struct kvm_vcpu *vcpu)
}
switch (nr) {
+ case 0:
+ printk("KVM: guest hypercall: %lx %lx %lx %lx\n",
+ a0, a1, a2, a3);
+ ret = 0;
+ break;
default:
ret = -KVM_ENOSYS;
break;
@@ -1430,6 +1435,7 @@ int kvm_fix_hypercall(struct kvm_vcpu *vcpu)
kvm_mmu_zap_all(vcpu->kvm);
kvm_x86_ops->cache_regs(vcpu);
+ printk(KERN_INFO "kvm: patching hypercall at %lx\n", vcpu->rip);
kvm_x86_ops->patch_hypercall(vcpu, instruction);
if (emulator_write_emulated(vcpu->rip, instruction, 3, vcpu)
!= X86EMUL_CONTINUE)
diff --git a/include/linux/kvm_para.h b/include/linux/kvm_para.h
index 448112a..89d807a 100644
--- a/include/linux/kvm_para.h
+++ b/include/linux/kvm_para.h
@@ -4,7 +4,15 @@
#ifdef __KERNEL__
#include <asm/processor.h>
-#define KVM_HYPERCALL ".byte 0x0f,0x01,0xc1"
+#ifdef CONFIG_KVM_GUEST
+void __init kvm_guest_init(void);
+#else
+static inline void kvm_guest_init(void)
+{
+}
+#endif
+
+#define KVM_HYPERCALL ".byte 0x0f,0x01,0xd9"
static inline long kvm_hypercall0(unsigned int nr)
{
@@ -83,4 +91,6 @@ static inline int kvm_para_has_feature(unsigned int feature)
#define KVM_ENOSYS 1000
+#define KVM_PARA_FEATURE_NOP_IO_DELAY 0
+
#endif
diff --git a/init/main.c b/init/main.c
index 9def935..61d8328 100644
--- a/init/main.c
+++ b/init/main.c
@@ -55,6 +55,7 @@
#include <linux/pid_namespace.h>
#include <linux/device.h>
#include <linux/kthread.h>
+#include <linux/kvm_para.h>
#include <asm/io.h>
#include <asm/bugs.h>
@@ -569,6 +570,7 @@ asmlinkage void __init start_kernel(void)
}
sort_main_extable();
trap_init();
+ kvm_guest_init();
rcu_init();
init_IRQ();
pidhash_init();
[-- Attachment #3: Type: text/plain, Size: 228 bytes --]
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
[-- Attachment #4: Type: text/plain, Size: 186 bytes --]
_______________________________________________
kvm-devel mailing list
kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
https://lists.sourceforge.net/lists/listinfo/kvm-devel
next prev parent reply other threads:[~2007-09-14 19:47 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-09-14 19:45 [PATCH] Refactor hypercall infrastructure Anthony Liguori
[not found] ` <11897991353793-git-send-email-aliguori-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2007-09-14 19:47 ` Anthony Liguori [this message]
2007-09-14 20:53 ` Jeremy Fitzhardinge
[not found] ` <46EAF4C6.8090903-TSDbQ3PG+2Y@public.gmane.org>
2007-09-14 21:02 ` Anthony Liguori
[not found] ` <46EAF6FC.80207-rdkfGonbjUSkNkDKm+mE6A@public.gmane.org>
2007-09-14 21:20 ` Zachary Amsden
[not found] ` <1189804847.5982.137.camel-cxY/u30q8FloTgUnLF1by8fTvwmfpRNyZeezCHUQhQ4@public.gmane.org>
2007-09-14 21:44 ` Anthony Liguori
[not found] ` <46EB00D8.3090903-rdkfGonbjUSkNkDKm+mE6A@public.gmane.org>
2007-09-15 3:37 ` Zachary Amsden
[not found] ` <1189827476.5982.143.camel-cxY/u30q8FloTgUnLF1by8fTvwmfpRNyZeezCHUQhQ4@public.gmane.org>
2007-09-15 8:08 ` Avi Kivity
2007-09-15 17:33 ` Anthony Liguori
2007-09-14 21:22 ` Jeremy Fitzhardinge
[not found] ` <46EAFBA0.4020503-TSDbQ3PG+2Y@public.gmane.org>
2007-09-14 21:46 ` Anthony Liguori
[not found] ` <46EB0136.6080105-rdkfGonbjUSkNkDKm+mE6A@public.gmane.org>
2007-09-14 21:52 ` Jeremy Fitzhardinge
[not found] ` <46EB02BA.6030909-TSDbQ3PG+2Y@public.gmane.org>
2007-09-14 22:08 ` Anthony Liguori
[not found] ` <46EB0657.40603-rdkfGonbjUSkNkDKm+mE6A@public.gmane.org>
2007-09-14 22:40 ` Nakajima, Jun
[not found] ` <97D612E30E1F88419025B06CB4CF1BE10379EBF9-1a9uaKK1+wJcIJlls4ac1rfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2007-09-14 23:00 ` Jeremy Fitzhardinge
[not found] ` <46EB1285.5050807-TSDbQ3PG+2Y@public.gmane.org>
2007-09-15 0:10 ` Nakajima, Jun
[not found] ` <97D612E30E1F88419025B06CB4CF1BE10379ED0A-1a9uaKK1+wJcIJlls4ac1rfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2007-09-15 0:28 ` Jeremy Fitzhardinge
[not found] ` <46EB2716.1070908-TSDbQ3PG+2Y@public.gmane.org>
2007-09-15 1:04 ` Nakajima, Jun
[not found] ` <97D612E30E1F88419025B06CB4CF1BE10379ED4C-1a9uaKK1+wJcIJlls4ac1rfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2007-09-15 4:53 ` Jeremy Fitzhardinge
[not found] ` <46EB6556.5020506-TSDbQ3PG+2Y@public.gmane.org>
2007-09-15 6:11 ` Nakajima, Jun
2007-09-15 18:23 ` [kvm-devel] " Anthony Liguori
[not found] ` <46EC233B.5010209-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2007-09-17 18:14 ` Nakajima, Jun
2007-09-17 18:27 ` [kvm-devel] " Anthony Liguori
[not found] ` <46EEC6FE.5060306-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2007-09-17 19:15 ` Jeremy Fitzhardinge
[not found] ` <46EED256.40801-TSDbQ3PG+2Y@public.gmane.org>
2007-09-17 19:33 ` Anthony Liguori
2007-09-17 19:15 ` [kvm-devel] " Jeremy Fitzhardinge
[not found] ` <46EED250.5080207-TSDbQ3PG+2Y@public.gmane.org>
2007-09-17 20:52 ` Nakajima, Jun
2007-09-15 8:00 ` Avi Kivity
2007-09-15 7:53 ` Avi Kivity
2007-09-15 2:35 ` Rusty Russell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=46EAE55B.10906@us.ibm.com \
--to=aliguori-r/jw6+rmf7hqt0dzr+alfa@public.gmane.org \
--cc=kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox