From: "Yang, Sheng" <sheng.yang@intel.com>
To: kvm-devel@lists.sourceforge.net
Subject: [PATCH 2/6] kvm: libkvm: Add Supporting for in-kernel PIT model
Date: Tue, 4 Mar 2008 18:22:48 +0800 [thread overview]
Message-ID: <200803041822.48614.sheng.yang@intel.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 2767 bytes --]
From da231cf5bb50310b4b98cc4b58370723b8e3f65d Mon Sep 17 00:00:00 2001
From: Sheng Yang <sheng.yang@intel.com>
Date: Sun, 27 Jan 2008 11:25:29 +0800
Subject: [PATCH] kvm: libkvm: Add Supporting for in-kernel PIT model
Signed-off-by: Sheng Yang <sheng.yang@intel.com>
---
kernel/Kbuild | 2 +-
libkvm/kvm-common.h | 4 ++++
libkvm/libkvm-x86.c | 25 +++++++++++++++++++++++++
libkvm/libkvm.c | 5 +++++
4 files changed, 35 insertions(+), 1 deletions(-)
diff --git a/kernel/Kbuild b/kernel/Kbuild
index ed02f5a..014cc17 100644
--- a/kernel/Kbuild
+++ b/kernel/Kbuild
@@ -1,7 +1,7 @@
EXTRA_CFLAGS := -I$(src)/include -include $(src)/external-module-compat.h
obj-m := kvm.o kvm-intel.o kvm-amd.o
kvm-objs := kvm_main.o x86.o mmu.o x86_emulate.o anon_inodes.o irq.o i8259.o
\
- lapic.o ioapic.o preempt.o
+ lapic.o ioapic.o preempt.o i8254.o
kvm-intel-objs := vmx.o vmx-debug.o
kvm-amd-objs := svm.o
diff --git a/libkvm/kvm-common.h b/libkvm/kvm-common.h
index d4df1a4..b8a88ee 100644
--- a/libkvm/kvm-common.h
+++ b/libkvm/kvm-common.h
@@ -47,6 +47,10 @@ struct kvm_context {
int no_irqchip_creation;
/// in-kernel irqchip status
int irqchip_in_kernel;
+ /// do not create in-kernel pit if set
+ int no_pit_creation;
+ /// in-kernel pit status
+ int pit_in_kernel;
};
void init_slots(void);
diff --git a/libkvm/libkvm-x86.c b/libkvm/libkvm-x86.c
index 4bd0e2f..b3a241e 100644
--- a/libkvm/libkvm-x86.c
+++ b/libkvm/libkvm-x86.c
@@ -144,6 +144,27 @@ int kvm_arch_create_default_phys_mem(kvm_context_t kvm,
return 0;
}
+int kvm_create_pit(kvm_context_t kvm)
+{
+#ifdef KVM_CAP_PIT
+ int r;
+
+ kvm->pit_in_kernel = 0;
+ if (!kvm->no_pit_creation) {
+ r = ioctl(kvm->fd, KVM_CHECK_EXTENSION, KVM_CAP_PIT);
+ if (r > 0) {
+ r = ioctl(kvm->vm_fd, KVM_CREATE_PIT);
+ if (r >= 0)
+ kvm->pit_in_kernel = 1;
+ else {
+ printf("Create kernel PIC irqchip failed\n");
+ return r;
+ }
+ }
+ }
+#endif
+ return 0;
+}
int kvm_arch_create(kvm_context_t kvm, unsigned long phys_mem_bytes,
void **vm_mem)
@@ -154,6 +175,10 @@ int kvm_arch_create(kvm_context_t kvm, unsigned long
phys_mem_bytes,
if (r < 0)
return r;
+ r = kvm_create_pit(kvm);
+ if (r < 0)
+ return r;
+
return 0;
}
diff --git a/libkvm/libkvm.c b/libkvm/libkvm.c
index 966501c..a7cc0e6 100644
--- a/libkvm/libkvm.c
+++ b/libkvm/libkvm.c
@@ -271,6 +271,11 @@ void kvm_disable_irqchip_creation(kvm_context_t kvm)
kvm->no_irqchip_creation = 1;
}
+void kvm_disable_pit_creation(kvm_context_t kvm)
+{
+ kvm->no_pit_creation = 1;
+}
+
int kvm_create_vcpu(kvm_context_t kvm, int slot)
{
long mmap_size;
--
debian.1.5.3.7.1-dirty
[-- Attachment #2: 0001-kvm-libkvm-Add-Supporting-for-in-kernel-PIT-model.patch --]
[-- Type: text/x-diff, Size: 2771 bytes --]
From da231cf5bb50310b4b98cc4b58370723b8e3f65d Mon Sep 17 00:00:00 2001
From: Sheng Yang <sheng.yang@intel.com>
Date: Sun, 27 Jan 2008 11:25:29 +0800
Subject: [PATCH] kvm: libkvm: Add Supporting for in-kernel PIT model
Signed-off-by: Sheng Yang <sheng.yang@intel.com>
---
kernel/Kbuild | 2 +-
libkvm/kvm-common.h | 4 ++++
libkvm/libkvm-x86.c | 25 +++++++++++++++++++++++++
libkvm/libkvm.c | 5 +++++
4 files changed, 35 insertions(+), 1 deletions(-)
diff --git a/kernel/Kbuild b/kernel/Kbuild
index ed02f5a..014cc17 100644
--- a/kernel/Kbuild
+++ b/kernel/Kbuild
@@ -1,7 +1,7 @@
EXTRA_CFLAGS := -I$(src)/include -include $(src)/external-module-compat.h
obj-m := kvm.o kvm-intel.o kvm-amd.o
kvm-objs := kvm_main.o x86.o mmu.o x86_emulate.o anon_inodes.o irq.o i8259.o \
- lapic.o ioapic.o preempt.o
+ lapic.o ioapic.o preempt.o i8254.o
kvm-intel-objs := vmx.o vmx-debug.o
kvm-amd-objs := svm.o
diff --git a/libkvm/kvm-common.h b/libkvm/kvm-common.h
index d4df1a4..b8a88ee 100644
--- a/libkvm/kvm-common.h
+++ b/libkvm/kvm-common.h
@@ -47,6 +47,10 @@ struct kvm_context {
int no_irqchip_creation;
/// in-kernel irqchip status
int irqchip_in_kernel;
+ /// do not create in-kernel pit if set
+ int no_pit_creation;
+ /// in-kernel pit status
+ int pit_in_kernel;
};
void init_slots(void);
diff --git a/libkvm/libkvm-x86.c b/libkvm/libkvm-x86.c
index 4bd0e2f..b3a241e 100644
--- a/libkvm/libkvm-x86.c
+++ b/libkvm/libkvm-x86.c
@@ -144,6 +144,27 @@ int kvm_arch_create_default_phys_mem(kvm_context_t kvm,
return 0;
}
+int kvm_create_pit(kvm_context_t kvm)
+{
+#ifdef KVM_CAP_PIT
+ int r;
+
+ kvm->pit_in_kernel = 0;
+ if (!kvm->no_pit_creation) {
+ r = ioctl(kvm->fd, KVM_CHECK_EXTENSION, KVM_CAP_PIT);
+ if (r > 0) {
+ r = ioctl(kvm->vm_fd, KVM_CREATE_PIT);
+ if (r >= 0)
+ kvm->pit_in_kernel = 1;
+ else {
+ printf("Create kernel PIC irqchip failed\n");
+ return r;
+ }
+ }
+ }
+#endif
+ return 0;
+}
int kvm_arch_create(kvm_context_t kvm, unsigned long phys_mem_bytes,
void **vm_mem)
@@ -154,6 +175,10 @@ int kvm_arch_create(kvm_context_t kvm, unsigned long phys_mem_bytes,
if (r < 0)
return r;
+ r = kvm_create_pit(kvm);
+ if (r < 0)
+ return r;
+
return 0;
}
diff --git a/libkvm/libkvm.c b/libkvm/libkvm.c
index 966501c..a7cc0e6 100644
--- a/libkvm/libkvm.c
+++ b/libkvm/libkvm.c
@@ -271,6 +271,11 @@ void kvm_disable_irqchip_creation(kvm_context_t kvm)
kvm->no_irqchip_creation = 1;
}
+void kvm_disable_pit_creation(kvm_context_t kvm)
+{
+ kvm->no_pit_creation = 1;
+}
+
int kvm_create_vcpu(kvm_context_t kvm, int slot)
{
long mmap_size;
--
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
next reply other threads:[~2008-03-04 10:22 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-03-04 10:22 Yang, Sheng [this message]
-- strict thread matches above, loose matches on Subject: below --
2008-03-07 12:52 [PATCH 2/6] kvm: libkvm: Add Supporting for in-kernel PIT model Yang, Sheng
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.48614.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.