All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Yang, Sheng" <sheng.yang@intel.com>
To: kvm-devel@lists.sourceforge.net
Subject: [PATCH 3/6] kvm: qemu: Add option for enable/disable in kernel PIT
Date: Tue, 4 Mar 2008 18:22:52 +0800	[thread overview]
Message-ID: <200803041822.52573.sheng.yang@intel.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 4675 bytes --]

From 40cf60009d1031891a34685b690dad47290a0b04 Mon Sep 17 00:00:00 2001
From: Sheng Yang <sheng.yang@intel.com>
Date: Tue, 4 Mar 2008 09:29:55 +0800
Subject: [PATCH] kvm: qemu: Add option for enable/disable in kernel PIT


Signed-off-by: Sheng Yang <sheng.yang@intel.com>
---
 libkvm/libkvm-x86.c |    7 +++++++
 qemu/hw/i8254.c     |   12 +++++++++---
 qemu/hw/pc.c        |    6 ++++++
 qemu/qemu-kvm.c     |    4 ++++
 qemu/qemu-kvm.h     |    2 ++
 qemu/vl.c           |    8 ++++++++
 6 files changed, 36 insertions(+), 3 deletions(-)

diff --git a/libkvm/libkvm-x86.c b/libkvm/libkvm-x86.c
index b3a241e..22a6283 100644
--- a/libkvm/libkvm-x86.c
+++ b/libkvm/libkvm-x86.c
@@ -630,3 +630,10 @@ int kvm_disable_tpr_access_reporting(kvm_context_t kvm, 
int vcpu)
 }

 #endif
+
+int kvm_pit_in_kernel(kvm_context_t kvm)
+{
+#ifdef KVM_CAP_PIT
+	return kvm->pit_in_kernel;
+#endif
+}
diff --git a/qemu/hw/i8254.c b/qemu/hw/i8254.c
index c281680..0753ca9 100644
--- a/qemu/hw/i8254.c
+++ b/qemu/hw/i8254.c
@@ -26,6 +26,8 @@
 #include "isa.h"
 #include "qemu-timer.h"

+#include "qemu-kvm.h"
+
 //#define DEBUG_PIT

 #define RW_STATE_LSB 1
@@ -492,9 +494,13 @@ PITState *pit_init(int base, qemu_irq irq)
     PITChannelState *s;

     s = &pit->channels[0];
-    /* the timer 0 is connected to an IRQ */
-    s->irq_timer = qemu_new_timer(vm_clock, pit_irq_timer, s);
-    s->irq = irq;
+#ifdef KVM_CAP_PIT
+    if (!kvm_enabled() || !qemu_kvm_pit_in_kernel()) {
+	    /* the timer 0 is connected to an IRQ */
+	    s->irq_timer = qemu_new_timer(vm_clock, pit_irq_timer, s);
+	    s->irq = irq;
+    }
+#endif

     register_savevm("i8254", base, 1, pit_save, pit_load, pit);

diff --git a/qemu/hw/pc.c b/qemu/hw/pc.c
index 1122b87..4587a5c 100644
--- a/qemu/hw/pc.c
+++ b/qemu/hw/pc.c
@@ -984,7 +984,13 @@ static void pc_init1(ram_addr_t ram_size, int 
vga_ram_size,
         ioapic = ioapic_init();
     }
     pit = pit_init(0x40, i8259[0]);
+#ifdef KVM_CAP_PIT
+    if (!kvm_enabled() || !qemu_kvm_pit_in_kernel()) {
+#endif
     pcspk_init(pit);
+#ifdef KVM_CAP_PIT
+    }
+#endif
     if (pci_enabled) {
         pic_set_alt_irq_func(isa_pic, ioapic_set_irq, ioapic);
     }
diff --git a/qemu/qemu-kvm.c b/qemu/qemu-kvm.c
index 051946e..196e38e 100644
--- a/qemu/qemu-kvm.c
+++ b/qemu/qemu-kvm.c
@@ -10,6 +10,7 @@

 int kvm_allowed = 1;
 int kvm_irqchip = 1;
+int kvm_pit = 1;

 #include <string.h>
 #include "hw/hw.h"
@@ -536,6 +537,9 @@ int kvm_qemu_create_context(void)
     if (!kvm_irqchip) {
         kvm_disable_irqchip_creation(kvm_context);
     }
+    if (!kvm_pit) {
+        kvm_disable_pit_creation(kvm_context);
+    }
     if (kvm_create(kvm_context, phys_ram_size, (void**)&phys_ram_base) < 0) {
 	kvm_qemu_destroy();
 	return -1;
diff --git a/qemu/qemu-kvm.h b/qemu/qemu-kvm.h
index 8e45f30..ff9c86e 100644
--- a/qemu/qemu-kvm.h
+++ b/qemu/qemu-kvm.h
@@ -84,9 +84,11 @@ extern kvm_context_t kvm_context;

 #define kvm_enabled() (kvm_allowed)
 #define qemu_kvm_irqchip_in_kernel() kvm_irqchip_in_kernel(kvm_context)
+#define qemu_kvm_pit_in_kernel() kvm_pit_in_kernel(kvm_context)
 #else
 #define kvm_enabled() (0)
 #define qemu_kvm_irqchip_in_kernel() (0)
+#define qemu_kvm_pit_in_kernel() (0)
 #endif

 #endif
diff --git a/qemu/vl.c b/qemu/vl.c
index f10fbd8..4c69ff4 100644
--- a/qemu/vl.c
+++ b/qemu/vl.c
@@ -8059,6 +8059,7 @@ static void help(int exitcode)
 	   "-no-kvm         disable KVM hardware virtualization\n"
 #endif
 	   "-no-kvm-irqchip disable KVM kernel mode PIC/IOAPIC/LAPIC\n"
+	   "-no-kvm-pit	    disable KVM kernel mode PIT\n"
 #endif
 #ifdef TARGET_I386
            "-std-vga        simulate a standard VGA card with VESA Bochs 
Extensions\n"
@@ -8177,6 +8178,7 @@ enum {
     QEMU_OPTION_no_acpi,
     QEMU_OPTION_no_kvm,
     QEMU_OPTION_no_kvm_irqchip,
+    QEMU_OPTION_no_kvm_pit,
     QEMU_OPTION_no_reboot,
     QEMU_OPTION_show_cursor,
     QEMU_OPTION_daemonize,
@@ -8263,6 +8265,7 @@ const QEMUOption qemu_options[] = {
     { "no-kvm", 0, QEMU_OPTION_no_kvm },
 #endif
     { "no-kvm-irqchip", 0, QEMU_OPTION_no_kvm_irqchip },
+    { "no-kvm-pit", 0, QEMU_OPTION_no_kvm_pit },
 #endif
 #if defined(TARGET_PPC) || defined(TARGET_SPARC)
     { "g", 1, QEMU_OPTION_g },
@@ -9191,6 +9194,11 @@ int main(int argc, char **argv)
 		kvm_irqchip = 0;
 		break;
 	    }
+	    case QEMU_OPTION_no_kvm_pit: {
+		extern int kvm_pit;
+		kvm_pit = 0;
+		break;
+	    }
 #endif
             case QEMU_OPTION_usb:
                 usb_enabled = 1;
--
debian.1.5.3.7.1-dirty


[-- Attachment #2: 0002-kvm-qemu-Add-option-for-enable-disable-in-kernel-P.patch --]
[-- Type: text/x-diff, Size: 4680 bytes --]

From 40cf60009d1031891a34685b690dad47290a0b04 Mon Sep 17 00:00:00 2001
From: Sheng Yang <sheng.yang@intel.com>
Date: Tue, 4 Mar 2008 09:29:55 +0800
Subject: [PATCH] kvm: qemu: Add option for enable/disable in kernel PIT


Signed-off-by: Sheng Yang <sheng.yang@intel.com>
---
 libkvm/libkvm-x86.c |    7 +++++++
 qemu/hw/i8254.c     |   12 +++++++++---
 qemu/hw/pc.c        |    6 ++++++
 qemu/qemu-kvm.c     |    4 ++++
 qemu/qemu-kvm.h     |    2 ++
 qemu/vl.c           |    8 ++++++++
 6 files changed, 36 insertions(+), 3 deletions(-)

diff --git a/libkvm/libkvm-x86.c b/libkvm/libkvm-x86.c
index b3a241e..22a6283 100644
--- a/libkvm/libkvm-x86.c
+++ b/libkvm/libkvm-x86.c
@@ -630,3 +630,10 @@ int kvm_disable_tpr_access_reporting(kvm_context_t kvm, int vcpu)
 }
 
 #endif
+
+int kvm_pit_in_kernel(kvm_context_t kvm)
+{
+#ifdef KVM_CAP_PIT
+	return kvm->pit_in_kernel;
+#endif
+}
diff --git a/qemu/hw/i8254.c b/qemu/hw/i8254.c
index c281680..0753ca9 100644
--- a/qemu/hw/i8254.c
+++ b/qemu/hw/i8254.c
@@ -26,6 +26,8 @@
 #include "isa.h"
 #include "qemu-timer.h"
 
+#include "qemu-kvm.h"
+
 //#define DEBUG_PIT
 
 #define RW_STATE_LSB 1
@@ -492,9 +494,13 @@ PITState *pit_init(int base, qemu_irq irq)
     PITChannelState *s;
 
     s = &pit->channels[0];
-    /* the timer 0 is connected to an IRQ */
-    s->irq_timer = qemu_new_timer(vm_clock, pit_irq_timer, s);
-    s->irq = irq;
+#ifdef KVM_CAP_PIT
+    if (!kvm_enabled() || !qemu_kvm_pit_in_kernel()) {
+	    /* the timer 0 is connected to an IRQ */
+	    s->irq_timer = qemu_new_timer(vm_clock, pit_irq_timer, s);
+	    s->irq = irq;
+    }
+#endif
 
     register_savevm("i8254", base, 1, pit_save, pit_load, pit);
 
diff --git a/qemu/hw/pc.c b/qemu/hw/pc.c
index 1122b87..4587a5c 100644
--- a/qemu/hw/pc.c
+++ b/qemu/hw/pc.c
@@ -984,7 +984,13 @@ static void pc_init1(ram_addr_t ram_size, int vga_ram_size,
         ioapic = ioapic_init();
     }
     pit = pit_init(0x40, i8259[0]);
+#ifdef KVM_CAP_PIT
+    if (!kvm_enabled() || !qemu_kvm_pit_in_kernel()) {
+#endif
     pcspk_init(pit);
+#ifdef KVM_CAP_PIT
+    }
+#endif
     if (pci_enabled) {
         pic_set_alt_irq_func(isa_pic, ioapic_set_irq, ioapic);
     }
diff --git a/qemu/qemu-kvm.c b/qemu/qemu-kvm.c
index 051946e..196e38e 100644
--- a/qemu/qemu-kvm.c
+++ b/qemu/qemu-kvm.c
@@ -10,6 +10,7 @@
 
 int kvm_allowed = 1;
 int kvm_irqchip = 1;
+int kvm_pit = 1;
 
 #include <string.h>
 #include "hw/hw.h"
@@ -536,6 +537,9 @@ int kvm_qemu_create_context(void)
     if (!kvm_irqchip) {
         kvm_disable_irqchip_creation(kvm_context);
     }
+    if (!kvm_pit) {
+        kvm_disable_pit_creation(kvm_context);
+    }
     if (kvm_create(kvm_context, phys_ram_size, (void**)&phys_ram_base) < 0) {
 	kvm_qemu_destroy();
 	return -1;
diff --git a/qemu/qemu-kvm.h b/qemu/qemu-kvm.h
index 8e45f30..ff9c86e 100644
--- a/qemu/qemu-kvm.h
+++ b/qemu/qemu-kvm.h
@@ -84,9 +84,11 @@ extern kvm_context_t kvm_context;
 
 #define kvm_enabled() (kvm_allowed)
 #define qemu_kvm_irqchip_in_kernel() kvm_irqchip_in_kernel(kvm_context)
+#define qemu_kvm_pit_in_kernel() kvm_pit_in_kernel(kvm_context)
 #else
 #define kvm_enabled() (0)
 #define qemu_kvm_irqchip_in_kernel() (0)
+#define qemu_kvm_pit_in_kernel() (0)
 #endif
 
 #endif
diff --git a/qemu/vl.c b/qemu/vl.c
index f10fbd8..4c69ff4 100644
--- a/qemu/vl.c
+++ b/qemu/vl.c
@@ -8059,6 +8059,7 @@ static void help(int exitcode)
 	   "-no-kvm         disable KVM hardware virtualization\n"
 #endif
 	   "-no-kvm-irqchip disable KVM kernel mode PIC/IOAPIC/LAPIC\n"
+	   "-no-kvm-pit	    disable KVM kernel mode PIT\n"
 #endif
 #ifdef TARGET_I386
            "-std-vga        simulate a standard VGA card with VESA Bochs Extensions\n"
@@ -8177,6 +8178,7 @@ enum {
     QEMU_OPTION_no_acpi,
     QEMU_OPTION_no_kvm,
     QEMU_OPTION_no_kvm_irqchip,
+    QEMU_OPTION_no_kvm_pit,
     QEMU_OPTION_no_reboot,
     QEMU_OPTION_show_cursor,
     QEMU_OPTION_daemonize,
@@ -8263,6 +8265,7 @@ const QEMUOption qemu_options[] = {
     { "no-kvm", 0, QEMU_OPTION_no_kvm },
 #endif
     { "no-kvm-irqchip", 0, QEMU_OPTION_no_kvm_irqchip },
+    { "no-kvm-pit", 0, QEMU_OPTION_no_kvm_pit },
 #endif
 #if defined(TARGET_PPC) || defined(TARGET_SPARC)
     { "g", 1, QEMU_OPTION_g },
@@ -9191,6 +9194,11 @@ int main(int argc, char **argv)
 		kvm_irqchip = 0;
 		break;
 	    }
+	    case QEMU_OPTION_no_kvm_pit: {
+		extern int kvm_pit;
+		kvm_pit = 0;
+		break;
+	    }
 #endif
             case QEMU_OPTION_usb:
                 usb_enabled = 1;
-- 
debian.1.5.3.7.1-dirty


[-- Attachment #3: Type: text/plain, Size: 228 bytes --]

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/

[-- Attachment #4: Type: text/plain, Size: 158 bytes --]

_______________________________________________
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel

             reply	other threads:[~2008-03-04 10:22 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-03-04 10:22 Yang, Sheng [this message]
2008-03-04 13:23 ` [PATCH 3/6] kvm: qemu: Add option for enable/disable in kernel PIT Uri Lublin
2008-03-05  2:20   ` Yang, Sheng
2008-03-06  8:46     ` Yang, Sheng
  -- strict thread matches above, loose matches on Subject: below --
2008-03-07 12:52 Yang, Sheng
2008-03-11 18:25 ` Hollis Blanchard

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=200803041822.52573.sheng.yang@intel.com \
    --to=sheng.yang@intel.com \
    --cc=kvm-devel@lists.sourceforge.net \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.