Skip to contentSkip to conversation

More x86 code movement

PATCH In review Hollis Blanchard 2 participants 8 messages Oct 31, 2007 – Nov 4, 2007 1 message not in the archive KVM

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 More x86 code movement

More straightforward code movement from kvm_main.c to x86.c. These patches have been build-tested on x86-32, but not run.

 kvm.h      |   23 +
 kvm_main.c |  757 -------------------------------------------------------------
 x86.c      |  734 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 764 insertions(+), 750 deletions(-)

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/

#1 lore raw

PATCH 1/1 Make exported debugfs data architecture-specific

---
Each architecture can export its own data via the same "kvm" debugfs directory.

drivers/kvm/kvm.h +7 -0
@@ -759,4 +759,11 @@ static inline u32 get_rdx_init_val(void)
 #define TSS_REDIRECTION_SIZE (256 / 8)
 #define RMODE_TSS_SIZE (TSS_BASE_SIZE + TSS_REDIRECTION_SIZE + TSS_IOPB_SIZE + 1)
 
+struct kvm_stats_debugfs_item {
+	const char *name;
+	int offset;
+	struct dentry *dentry;
+};
+extern struct kvm_stats_debugfs_item debugfs_entries[];
+
 #endif
drivers/kvm/kvm_main.c +0 -25
@@ -62,31 +62,6 @@ EXPORT_SYMBOL_GPL(kvm_vcpu_cache);
 EXPORT_SYMBOL_GPL(kvm_vcpu_cache);
 
 static __read_mostly struct preempt_ops kvm_preempt_ops;
-
-#define STAT_OFFSET(x) offsetof(struct kvm_vcpu, stat.x)
-
-static struct kvm_stats_debugfs_item {
-	const char *name;
-	int offset;
-	struct dentry *dentry;
-} debugfs_entries[] = {
-	{ "pf_fixed", STAT_OFFSET(pf_fixed) },
-	{ "pf_guest", STAT_OFFSET(pf_guest) },
-	{ "tlb_flush", STAT_OFFSET(tlb_flush) },
-	{ "invlpg", STAT_OFFSET(invlpg) },
-	{ "exits", STAT_OFFSET(exits) },
-	{ "io_exits", STAT_OFFSET(io_exits) },
-	{ "mmio_exits", STAT_OFFSET(mmio_exits) },
-	{ "signal_exits", STAT_OFFSET(signal_exits) },
-	{ "irq_window", STAT_OFFSET(irq_window_exits) },
-	{ "halt_exits", STAT_OFFSET(halt_exits) },
-	{ "halt_wakeup", STAT_OFFSET(halt_wakeup) },
-	{ "request_irq", STAT_OFFSET(request_irq_exits) },
-	{ "irq_exits", STAT_OFFSET(irq_exits) },
-	{ "light_exits", STAT_OFFSET(light_exits) },
-	{ "efer_reload", STAT_OFFSET(efer_reload) },
-	{ NULL }
-};
 
 static struct dentry *debugfs_dir;
 
drivers/kvm/x86.c +22 -0
@@ -39,6 +39,28 @@
 
 #define CR8_RESERVED_BITS (~(unsigned long)X86_CR8_TPR)
 #define EFER_RESERVED_BITS 0xfffffffffffff2fe
+
+#define STAT_OFFSET(x) offsetof(struct kvm_vcpu, stat.x)
+
+struct kvm_stats_debugfs_item debugfs_entries[] = {
+	{ "pf_fixed", STAT_OFFSET(pf_fixed) },
+	{ "pf_guest", STAT_OFFSET(pf_guest) },
+	{ "tlb_flush", STAT_OFFSET(tlb_flush) },
+	{ "invlpg", STAT_OFFSET(invlpg) },
+	{ "exits", STAT_OFFSET(exits) },
+	{ "io_exits", STAT_OFFSET(io_exits) },
+	{ "mmio_exits", STAT_OFFSET(mmio_exits) },
+	{ "signal_exits", STAT_OFFSET(signal_exits) },
+	{ "irq_window", STAT_OFFSET(irq_window_exits) },
+	{ "halt_exits", STAT_OFFSET(halt_exits) },
+	{ "halt_wakeup", STAT_OFFSET(halt_wakeup) },
+	{ "request_irq", STAT_OFFSET(request_irq_exits) },
+	{ "irq_exits", STAT_OFFSET(irq_exits) },
+	{ "light_exits", STAT_OFFSET(light_exits) },
+	{ "efer_reload", STAT_OFFSET(efer_reload) },
+	{ NULL }
+};
+
 
 unsigned long segment_base(u16 selector)
 {

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/

#2 lore raw

PATCH 1/1 Move x86 instruction emulation code to x86.c

In reply to Hollis Blanchard
drivers/kvm/kvm.h +1 -0
@@ -589,6 +589,7 @@ int kvm_set_msr_common(struct kvm_vcpu *
 
 void fx_init(struct kvm_vcpu *vcpu);
 
+void kvm_vcpu_block(struct kvm_vcpu *vcpu);
 void kvm_resched(struct kvm_vcpu *vcpu);
 void kvm_load_guest_fpu(struct kvm_vcpu *vcpu);
 void kvm_put_guest_fpu(struct kvm_vcpu *vcpu);
drivers/kvm/kvm_main.c +1 -176

195 lines not on this page · raw message

drivers/kvm/x86.c +175 -0

178 lines not on this page · raw message

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/

#3 lore raw

PATCH 1/1 Move x86 FPU handling to x86.c

In reply to Hollis Blanchard
drivers/kvm/kvm.h +3 -0
@@ -631,6 +631,9 @@ long kvm_arch_vm_ioctl(struct file *filp
 		       unsigned int ioctl, unsigned long arg);
 void kvm_arch_destroy_vm(struct kvm *kvm);
 
+int kvm_arch_vcpu_ioctl_get_fpu(struct kvm_vcpu *vcpu, struct kvm_fpu *fpu);
+int kvm_arch_vcpu_ioctl_set_fpu(struct kvm_vcpu *vcpu, struct kvm_fpu *fpu);
+
 __init void kvm_arch_init(void);
 
 static inline void kvm_guest_enter(void)
drivers/kvm/kvm_main.c +2 -105

137 lines not on this page · raw message

drivers/kvm/x86.c +103 -0

106 lines not on this page · raw message

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/

#4 lore raw

PATCH 1/1 Move x86 vcpu ioctl handlers to x86.c

In reply to Hollis Blanchard

---
It might be preferable to handle these by defining a kvm_arch_vcpu_ioctl() rather creating lots of new functions. I could go either way.

drivers/kvm/kvm.h +10 -2
@@ -591,8 +591,6 @@ void fx_init(struct kvm_vcpu *vcpu);
 
 void kvm_vcpu_block(struct kvm_vcpu *vcpu);
 void kvm_resched(struct kvm_vcpu *vcpu);
-void kvm_load_guest_fpu(struct kvm_vcpu *vcpu);
-void kvm_put_guest_fpu(struct kvm_vcpu *vcpu);
 void kvm_flush_remote_tlbs(struct kvm *kvm);
 
 int emulator_read_std(unsigned long addr,
@@ -634,6 +632,16 @@ int kvm_arch_vcpu_ioctl_get_fpu(struct k
 int kvm_arch_vcpu_ioctl_get_fpu(struct kvm_vcpu *vcpu, struct kvm_fpu *fpu);
 int kvm_arch_vcpu_ioctl_set_fpu(struct kvm_vcpu *vcpu, struct kvm_fpu *fpu);
 
+int kvm_arch_vcpu_ioctl_get_regs(struct kvm_vcpu *vcpu, struct kvm_regs *regs);
+int kvm_arch_vcpu_ioctl_set_regs(struct kvm_vcpu *vcpu, struct kvm_regs *regs);
+int kvm_arch_vcpu_ioctl_get_sregs(struct kvm_vcpu *vcpu,
+				  struct kvm_sregs *sregs);
+int kvm_arch_vcpu_ioctl_set_sregs(struct kvm_vcpu *vcpu,
+				  struct kvm_sregs *sregs);
+int kvm_arch_vcpu_ioctl_debug_guest(struct kvm_vcpu *vcpu,
+				    struct kvm_debug_guest *dbg);
+int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run);
+
 __init void kvm_arch_init(void);
 
 static inline void kvm_guest_enter(void)
drivers/kvm/kvm_main.c +6 -442

495 lines not on this page · raw message

drivers/kvm/x86.c +434 -0

440 lines not on this page · raw message

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/

#5 lore raw
In reply to Hollis Blanchard
Quoted 4 lines · Hollis Blanchard

More straightforward code movement from kvm_main.c to x86.c. These patches have been build-tested on x86-32, but not run.

Patches are good, but I get

Quoted 11 lines

drivers/kvm/vmx.c: In function ‘vmx_vcpu_put’:
drivers/kvm/vmx.c:534: error: implicit declaration of function ‘kvm_put_guest_fpu’
drivers/kvm/x86.c: In function ‘__vcpu_run’:
drivers/kvm/x86.c:1852: error: implicit declaration of function ‘kvm_load_guest_fpu’
drivers/kvm/x86.c: At top level:
drivers/kvm/x86.c:2306: warning: conflicting types for ‘kvm_load_guest_fpu’
drivers/kvm/x86.c:1852: warning: previous implicit declaration of ‘kvm_load_guest_fpu’ was here

on x86_64.

The problem's only in the last patch, so I dropped it and applied the other three.

Signature · 8 lines
Any sufficiently difficult bug is indistinguishable from a feature.


-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/

A message that is not in the archive (sent off-list or not yet received): 4729CFB3.5070206-atKUWr5tajBWk0Htik3J/[email protected]

#7 lore raw

PATCH v2 1/1 Move x86 vcpu ioctl handlers to x86.c

3 files changed, 450 insertions(+), 442 deletions(-)
drivers/kvm/kvm.h      |   10 +
drivers/kvm/kvm_main.c |  448 ------------------------------------------------
drivers/kvm/x86.c      |  434 ++++++++++++++++++++++++++++++++++++++++++++++

---
It might be preferable to handle these by defining a kvm_arch_vcpu_ioctl() rather creating lots of new functions. I could go either way.

Changes from v1: don't remove kvm_load_guest_fpu() and kvm_put_guest_fpu() prototypes.

drivers/kvm/kvm.h +10 -0
@@ -634,6 +634,16 @@ int kvm_arch_vcpu_ioctl_get_fpu(struct k
 int kvm_arch_vcpu_ioctl_get_fpu(struct kvm_vcpu *vcpu, struct kvm_fpu *fpu);
 int kvm_arch_vcpu_ioctl_set_fpu(struct kvm_vcpu *vcpu, struct kvm_fpu *fpu);
 
+int kvm_arch_vcpu_ioctl_get_regs(struct kvm_vcpu *vcpu, struct kvm_regs *regs);
+int kvm_arch_vcpu_ioctl_set_regs(struct kvm_vcpu *vcpu, struct kvm_regs *regs);
+int kvm_arch_vcpu_ioctl_get_sregs(struct kvm_vcpu *vcpu,
+				  struct kvm_sregs *sregs);
+int kvm_arch_vcpu_ioctl_set_sregs(struct kvm_vcpu *vcpu,
+				  struct kvm_sregs *sregs);
+int kvm_arch_vcpu_ioctl_debug_guest(struct kvm_vcpu *vcpu,
+				    struct kvm_debug_guest *dbg);
+int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run);
+
 __init void kvm_arch_init(void);
 
 static inline void kvm_guest_enter(void)
drivers/kvm/kvm_main.c +6 -442

495 lines not on this page · raw message

drivers/kvm/x86.c +434 -0

440 lines not on this page · raw message

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/

Applied
#8 lore raw

Re: [PATCH] [v2] Move x86 vcpu ioctl handlers to x86.c

Quoted 6 lines · Hollis Blanchard
3 files changed, 450 insertions(+), 442 deletions(-)
drivers/kvm/kvm.h      |   10 +
drivers/kvm/kvm_main.c |  448 ------------------------------------------------
drivers/kvm/x86.c      |  434 ++++++++++++++++++++++++++++++++++++++++++++++
Quoted 9 lines

---
It might be preferable to handle these by defining a kvm_arch_vcpu_ioctl() rather creating lots of new functions. I could go either way.

Changes from v1: don't remove kvm_load_guest_fpu() and kvm_put_guest_fpu() prototypes.

Applied, thanks.

Signature · 8 lines
Any sufficiently difficult bug is indistinguishable from a feature.


-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/