Re: [kvm-devel] add back pending timer irqs for kernel APIC timer

2007-08-24 Thread Dong, Eddie
Avi Kivity wrote:
 Dong, Eddie wrote:
 Avi:
  Any comments to this patch? Seems not in yet.
  The sequence is apic-timer-TMCCT.patch,
 apic-timer-last5.patch and apic-timer-pending4.patch.
 thx,eddie
 
 
 I'd like to get guest smp in first...
 

Avi:
We have got SMP Linux up too, which is based on top of these
patches, can u check in these to make next series simple?
thx,eddie

-
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/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


[kvm-devel] [PATCH 5/5] Architecture independence layer - v1 - split_generic_x86_change

2007-08-24 Thread Christian Ehrhardt
from Christian Ehrhardt

This contains the major changes done mostly in kvm_main.c to implement 
the generic handling of the ioctls with the mapping to arch functions as 
needed.

Signed-off-by: Christian Ehrhardt [EMAIL PROTECTED]
---
 kvm.h  |   20 ++
 kvm_arch.h |   34 
 kvm_main.c |  431 
+++--
 3 files changed, 104 insertions(+), 381 deletions(-)

diff --git a/drivers/kvm/kvm.h b/drivers/kvm/kvm.h
index ff07e64..9bdb408 100644
--- a/drivers/kvm/kvm.h
+++ b/drivers/kvm/kvm.h
@@ -681,4 +681,24 @@ 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)
 
+/* generic functions provided to arch module part by kvm_main code 
after split */
+extern __read_mostly struct preempt_ops kvm_preempt_ops;
+
+void kvm_destroy_vm(struct kvm *kvm);
+void kvm_free_physmem_slot(struct kvm_memory_slot *free,
+   struct kvm_memory_slot *dont);
+
+struct kvm_io_device *vcpu_find_mmio_dev(struct kvm_vcpu *vcpu,
+gpa_t addr);
+int complete_pio(struct kvm_vcpu *vcpu);
+
+__init void kvm_init_debug(void);
+void kvm_exit_debug(void);
+
+int kvm_init_generic(unsigned int vcpu_size, struct module *module);
+void kvm_exit_generic(void);
+
+void vcpu_load(struct kvm_vcpu *vcpu);
+void vcpu_put(struct kvm_vcpu *vcpu);
+
 #endif
diff --git a/drivers/kvm/kvm_arch.h b/drivers/kvm/kvm_arch.h
index 6658948..8e4759f 100644
--- a/drivers/kvm/kvm_arch.h
+++ b/drivers/kvm/kvm_arch.h
@@ -11,4 +11,38 @@
 
 #include linux/module.h
 
+long kvm_arch_dev_ioctl(struct file *filp, unsigned int ioctl,
+unsigned long arg);
+void kvm_arch_free_vcpus(struct kvm *kvm);
+
+long kvm_arch_vm_ioctl(struct file *filp, unsigned int ioctl,
+   unsigned long arg);
+struct kvm_vcpu* kvm_arch_vcpu_create(struct kvm *kvm, unsigned id);
+void kvm_arch_vcpu_free(struct kvm_vcpu *vcpu);
+void kvm_arch_vcpu_decache(struct kvm_vcpu *vcpu);
+
+void kvm_arch_vcpu_load(struct kvm_vcpu *vcpu, int cpu);
+void kvm_arch_vcpu_put(struct kvm_vcpu *vcpu);
+void kvm_arch_cache_regs(struct kvm_vcpu *vcpu);
+void kvm_arch_decache_regs(struct kvm_vcpu *vcpu);
+
+void kvm_arch_skip_emulated_instruction(struct kvm_vcpu *vcpu);
+void kvm_arch_inject_gp(struct kvm_vcpu *vcpu);
+
+long kvm_arch_vcpu_ioctl(struct file *filp, unsigned int ioctl,
+ unsigned long arg);
+int kvm_arch_vcpu_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run);
+int kvm_arch_vcpu_debug_guest(struct kvm_vcpu *vcpu,
+  struct kvm_debug_guest *dbg);
+int kvm_arch_vcpu_get_regs(struct kvm_vcpu *vcpu, struct kvm_regs *regs);
+int kvm_arch_vcpu_set_regs(struct kvm_vcpu *vcpu, struct kvm_regs *regs);
+int kvm_arch_vcpu_get_fpu(struct kvm_vcpu *vcpu, struct kvm_fpu *fpu);
+int kvm_arch_vcpu_set_fpu(struct kvm_vcpu *vcpu, struct kvm_fpu *fpu);
+
+void kvm_arch_hardware_enable(void *junk);
+void kvm_arch_hardware_disable(void *junk);
+
+__exit void kvm_arch_exit(void);
+__init int kvm_arch_init(void);
+
 #endif
diff --git a/drivers/kvm/kvm_main.c b/drivers/kvm/kvm_main.c
index 6046665..b1e94e2 100644
--- a/drivers/kvm/kvm_main.c
+++ b/drivers/kvm/kvm_main.c
@@ -43,13 +43,11 @@ static LIST_HEAD(vm_list);
 
 static cpumask_t cpus_hardware_enabled;
 
-struct kvm_x86_ops *kvm_x86_ops;
-struct kmem_cache *kvm_vcpu_cache;
-EXPORT_SYMBOL_GPL(kvm_vcpu_cache);
+#define STAT_OFFSET(x) offsetof(struct kvm_vcpu, stat.x)
 
-static __read_mostly struct preempt_ops kvm_preempt_ops;
+__read_mostly struct preempt_ops kvm_preempt_ops;
 
-#define STAT_OFFSET(x) offsetof(struct kvm_vcpu, stat.x)
+static struct dentry *debugfs_dir;
 
 static struct kvm_stats_debugfs_item {
 const char *name;
@@ -73,209 +71,37 @@ static struct kvm_stats_debugfs_item {
 { NULL }
 };
 
-static struct dentry *debugfs_dir;
-
-#define MAX_IO_MSRS 256
-
-#define CR0_RESERVED_BITS\
-(~(unsigned long)(X86_CR0_PE | X86_CR0_MP | X86_CR0_EM | X86_CR0_TS \
-  | X86_CR0_ET | X86_CR0_NE | X86_CR0_WP | X86_CR0_AM \
-  | X86_CR0_NW | X86_CR0_CD | X86_CR0_PG))
-#define CR4_RESERVED_BITS\
-(~(unsigned long)(X86_CR4_VME | X86_CR4_PVI | X86_CR4_TSD | X86_CR4_DE\
-  | X86_CR4_PSE | X86_CR4_PAE | X86_CR4_MCE\
-  | X86_CR4_PGE | X86_CR4_PCE | X86_CR4_OSFXSR\
-  | X86_CR4_OSXMMEXCPT | X86_CR4_VMXE))
-
-#define CR8_RESERVED_BITS (~(unsigned long)X86_CR8_TPR)
-#define EFER_RESERVED_BITS 0xf2fe
-
-#ifdef CONFIG_X86_64
-// LDT or TSS descriptor in the GDT. 16 bytes.
-struct segment_descriptor_64 {
-struct segment_descriptor s;
-u32 base_higher;
-u32 pad_zero;
-};
-
-#endif
-
 static long kvm_vcpu_ioctl(struct file *file, unsigned int ioctl,
-   unsigned long arg);
-
-unsigned long 

[kvm-devel] [PATCH 3/5] Architecture independence layer - v1 - split_generic_x86_move

2007-08-24 Thread Christian Ehrhardt
from Christian Ehrhardt

This contains the deletions of x86 arch specific code done in kvm_main.

Signed-off-by: Christian Ehrhardt [EMAIL PROTECTED]
---
 kvm.h |   63 --
 kvm_main.c| 1431 
--
 mmu.c |2
 svm.c |1
 vmx.c |2
 x86_emulate.c |2
 6 files changed, 12 insertions(+), 1489 deletions(-)

diff --git a/drivers/kvm/kvm.h b/drivers/kvm/kvm.h
index a3dcc96..ff07e64 100644
--- a/drivers/kvm/kvm.h
+++ b/drivers/kvm/kvm.h
@@ -415,65 +415,6 @@ struct descriptor_table {
 unsigned long base;
 } __attribute__((packed));
 
-struct kvm_x86_ops {
-int (*cpu_has_kvm_support)(void);  /* __init */
-int (*disabled_by_bios)(void); /* __init */
-void (*hardware_enable)(void *dummy);  /* __init */
-void (*hardware_disable)(void *dummy);
-void (*check_processor_compatibility)(void *rtn);
-int (*hardware_setup)(void);   /* __init */
-void (*hardware_unsetup)(void);/* __exit */
-
-/* Create, but do not attach this VCPU */
-struct kvm_vcpu *(*vcpu_create)(struct kvm *kvm, unsigned id);
-void (*vcpu_free)(struct kvm_vcpu *vcpu);
-
-void (*vcpu_load)(struct kvm_vcpu *vcpu, int cpu);
-void (*vcpu_put)(struct kvm_vcpu *vcpu);
-void (*vcpu_decache)(struct kvm_vcpu *vcpu);
-
-int (*set_guest_debug)(struct kvm_vcpu *vcpu,
-   struct kvm_debug_guest *dbg);
-int (*get_msr)(struct kvm_vcpu *vcpu, u32 msr_index, u64 *pdata);
-int (*set_msr)(struct kvm_vcpu *vcpu, u32 msr_index, u64 data);
-u64 (*get_segment_base)(struct kvm_vcpu *vcpu, int seg);
-void (*get_segment)(struct kvm_vcpu *vcpu,
-struct kvm_segment *var, int seg);
-void (*set_segment)(struct kvm_vcpu *vcpu,
-struct kvm_segment *var, int seg);
-void (*get_cs_db_l_bits)(struct kvm_vcpu *vcpu, int *db, int *l);
-void (*decache_cr4_guest_bits)(struct kvm_vcpu *vcpu);
-void (*set_cr0)(struct kvm_vcpu *vcpu, unsigned long cr0);
-void (*set_cr3)(struct kvm_vcpu *vcpu, unsigned long cr3);
-void (*set_cr4)(struct kvm_vcpu *vcpu, unsigned long cr4);
-void (*set_efer)(struct kvm_vcpu *vcpu, u64 efer);
-void (*get_idt)(struct kvm_vcpu *vcpu, struct descriptor_table *dt);
-void (*set_idt)(struct kvm_vcpu *vcpu, struct descriptor_table *dt);
-void (*get_gdt)(struct kvm_vcpu *vcpu, struct descriptor_table *dt);
-void (*set_gdt)(struct kvm_vcpu *vcpu, struct descriptor_table *dt);
-unsigned long (*get_dr)(struct kvm_vcpu *vcpu, int dr);
-void (*set_dr)(struct kvm_vcpu *vcpu, int dr, unsigned long value,
-   int *exception);
-void (*cache_regs)(struct kvm_vcpu *vcpu);
-void (*decache_regs)(struct kvm_vcpu *vcpu);
-unsigned long (*get_rflags)(struct kvm_vcpu *vcpu);
-void (*set_rflags)(struct kvm_vcpu *vcpu, unsigned long rflags);
-
-void (*invlpg)(struct kvm_vcpu *vcpu, gva_t addr);
-void (*tlb_flush)(struct kvm_vcpu *vcpu);
-void (*inject_page_fault)(struct kvm_vcpu *vcpu,
-  unsigned long addr, u32 err_code);
-
-void (*inject_gp)(struct kvm_vcpu *vcpu, unsigned err_code);
-
-int (*run)(struct kvm_vcpu *vcpu, struct kvm_run *run);
-void (*skip_emulated_instruction)(struct kvm_vcpu *vcpu);
-void (*patch_hypercall)(struct kvm_vcpu *vcpu,
-unsigned char *hypercall_addr);
-};
-
-extern struct kvm_x86_ops *kvm_x86_ops;
-
 /* The guest did something we don't support. */
 #define pr_unimpl(vcpu, fmt, ...)\
  do {\
@@ -488,10 +429,6 @@ extern struct kvm_x86_ops *kvm_x86_ops;
 int kvm_vcpu_init(struct kvm_vcpu *vcpu, struct kvm *kvm, unsigned id);
 void kvm_vcpu_uninit(struct kvm_vcpu *vcpu);
 
-int kvm_init_x86(struct kvm_x86_ops *ops, unsigned int vcpu_size,
-  struct module *module);
-void kvm_exit_x86(void);
-
 int kvm_mmu_module_init(void);
 void kvm_mmu_module_exit(void);
 
diff --git a/drivers/kvm/kvm_main.c b/drivers/kvm/kvm_main.c
index 64c2cc4..6046665 100644
--- a/drivers/kvm/kvm_main.c
+++ b/drivers/kvm/kvm_main.c
@@ -16,33 +16,24 @@
  */
 
 #include kvm.h
-#include x86_emulate.h
-#include segment_descriptor.h
-
 #include linux/kvm.h
+#include kvm_arch.h
+
 #include linux/module.h
-#include linux/errno.h
 #include linux/percpu.h
-#include linux/gfp.h
-#include linux/mm.h
 #include linux/miscdevice.h
 #include linux/vmalloc.h
 #include linux/reboot.h
 #include linux/debugfs.h
-#include linux/highmem.h
 #include linux/file.h
 #include linux/sysdev.h
 #include linux/cpu.h
-#include linux/sched.h
-#include linux/cpumask.h
 #include linux/smp.h
 #include linux/anon_inodes.h
+#include linux/err.h
+#include linux/fs.h
 
-#include asm/processor.h
-#include asm/msr.h
-#include asm/io.h
 #include asm/uaccess.h
-#include asm/desc.h
 
 MODULE_AUTHOR(Qumranet);
 MODULE_LICENSE(GPL);
@@ -391,234 +382,6 @@ static int 

[kvm-devel] [PATCH 4/5] Architecture independence layer - v1 - split_generic_x86_x86.c

2007-08-24 Thread Christian Ehrhardt
from Christian Ehrhardt

Contains the insertion of the x86 arch code to x86.[ch] and some minor 
changes adopting this x86.c arch implementations to the new interface.

Signed-off-by: Christian Ehrhardt [EMAIL PROTECTED]
---
 x86.c | 1851 
++
 x86.h |   63 ++
 2 files changed, 1914 insertions(+)

diff --git a/drivers/kvm/x86.c b/drivers/kvm/x86.c
index 5c72fee..8660414 100644
--- a/drivers/kvm/x86.c
+++ b/drivers/kvm/x86.c
@@ -49,3 +49,1854 @@
 MODULE_AUTHOR(Qumranet);
 MODULE_LICENSE(GPL);
 
+struct kvm_x86_ops *kvm_x86_ops;
+struct kmem_cache *kvm_vcpu_cache;
+EXPORT_SYMBOL_GPL(kvm_vcpu_cache);
+
+#define MAX_IO_MSRS 256
+
+#define CR0_RESERVED_BITS\
+(~(unsigned long)(X86_CR0_PE | X86_CR0_MP | X86_CR0_EM | X86_CR0_TS \
+  | X86_CR0_ET | X86_CR0_NE | X86_CR0_WP | X86_CR0_AM \
+  | X86_CR0_NW | X86_CR0_CD | X86_CR0_PG))
+#define CR4_RESERVED_BITS\
+(~(unsigned long)(X86_CR4_VME | X86_CR4_PVI | X86_CR4_TSD | X86_CR4_DE\
+  | X86_CR4_PSE | X86_CR4_PAE | X86_CR4_MCE\
+  | X86_CR4_PGE | X86_CR4_PCE | X86_CR4_OSFXSR\
+  | X86_CR4_OSXMMEXCPT | X86_CR4_VMXE))
+
+#define CR8_RESERVED_BITS (~(unsigned long)X86_CR8_TPR)
+#define EFER_RESERVED_BITS 0xf2fe
+
+#ifdef CONFIG_X86_64
+// LDT or TSS descriptor in the GDT. 16 bytes.
+struct segment_descriptor_64 {
+struct segment_descriptor s;
+u32 base_higher;
+u32 pad_zero;
+};
+
+#endif
+
+unsigned long segment_base(u16 selector)
+{
+struct descriptor_table gdt;
+struct segment_descriptor *d;
+unsigned long table_base;
+typedef unsigned long ul;
+unsigned long v;
+
+if (selector == 0)
+return 0;
+
+asm (sgdt %0 : =m(gdt));
+table_base = gdt.base;
+
+if (selector  4) {   /* from ldt */
+u16 ldt_selector;
+
+asm (sldt %0 : =g(ldt_selector));
+table_base = segment_base(ldt_selector);
+}
+d = (struct segment_descriptor *)(table_base + (selector  ~7));
+v = d-base_low | ((ul)d-base_mid  16) | ((ul)d-base_high  24);
+#ifdef CONFIG_X86_64
+if (d-system == 0
+ (d-type == 2 || d-type == 9 || d-type == 11))
+v |= ((ul)((struct segment_descriptor_64 *)d)-base_higher)  32;
+#endif
+return v;
+}
+EXPORT_SYMBOL_GPL(segment_base);
+
+void kvm_load_guest_fpu(struct kvm_vcpu *vcpu)
+{
+if (!vcpu-fpu_active || vcpu-guest_fpu_loaded)
+return;
+
+vcpu-guest_fpu_loaded = 1;
+fx_save(vcpu-host_fx_image);
+fx_restore(vcpu-guest_fx_image);
+}
+EXPORT_SYMBOL_GPL(kvm_load_guest_fpu);
+
+void kvm_put_guest_fpu(struct kvm_vcpu *vcpu)
+{
+if (!vcpu-guest_fpu_loaded)
+return;
+
+vcpu-guest_fpu_loaded = 0;
+fx_save(vcpu-guest_fx_image);
+fx_restore(vcpu-host_fx_image);
+}
+EXPORT_SYMBOL_GPL(kvm_put_guest_fpu);
+
+static void ack_flush(void *_completed)
+{
+atomic_t *completed = _completed;
+
+atomic_inc(completed);
+}
+
+void kvm_flush_remote_tlbs(struct kvm *kvm)
+{
+int i, cpu, needed;
+cpumask_t cpus;
+struct kvm_vcpu *vcpu;
+atomic_t completed;
+
+atomic_set(completed, 0);
+cpus_clear(cpus);
+needed = 0;
+for (i = 0; i  KVM_MAX_VCPUS; ++i) {
+vcpu = kvm-vcpus[i];
+if (!vcpu)
+continue;
+if (test_and_set_bit(KVM_TLB_FLUSH, vcpu-requests))
+continue;
+cpu = vcpu-cpu;
+if (cpu != -1  cpu != raw_smp_processor_id())
+if (!cpu_isset(cpu, cpus)) {
+cpu_set(cpu, cpus);
+++needed;
+}
+}
+
+/*
+ * We really want smp_call_function_mask() here.  But that's not
+ * available, so ipi all cpus in parallel and wait for them
+ * to complete.
+ */
+for (cpu = first_cpu(cpus); cpu != NR_CPUS; cpu = next_cpu(cpu, cpus))
+smp_call_function_single(cpu, ack_flush, completed, 1, 0);
+while (atomic_read(completed) != needed) {
+cpu_relax();
+barrier();
+}
+}
+
+int kvm_vcpu_init(struct kvm_vcpu *vcpu, struct kvm *kvm, unsigned id)
+{
+struct page *page;
+int r;
+
+mutex_init(vcpu-mutex);
+vcpu-cpu = -1;
+vcpu-mmu.root_hpa = INVALID_PAGE;
+vcpu-kvm = kvm;
+vcpu-vcpu_id = id;
+
+page = alloc_page(GFP_KERNEL | __GFP_ZERO);
+if (!page) {
+r = -ENOMEM;
+goto fail;
+}
+vcpu-run = page_address(page);
+
+page = alloc_page(GFP_KERNEL | __GFP_ZERO);
+if (!page) {
+r = -ENOMEM;
+goto fail_free_run;
+}
+vcpu-pio_data = page_address(page);
+
+r = kvm_mmu_create(vcpu);
+if (r  0)
+goto fail_free_pio_data;
+
+return 0;
+
+fail_free_pio_data:
+free_page((unsigned long)vcpu-pio_data);
+fail_free_run:
+free_page((unsigned long)vcpu-run);
+fail:
+return -ENOMEM;
+}
+EXPORT_SYMBOL_GPL(kvm_vcpu_init);
+
+void kvm_vcpu_uninit(struct 

Re: [kvm-devel] [kvm-commits] KVM: VMX: Use shadow TPR/cr8 for64-bits guests

2007-08-24 Thread Dong, Eddie
[EMAIL PROTECTED] wrote:
 I remember when I added something similar to the lapic series that
 both of my C2D systems (Merom + Woodcrest) reported that they didn't
 support the feature in the HW.  Since those were fairly new, which
 ones *do* support this (out of curiosity), or is there a microcode
 update floating around out there ;).

Using latest microcode is always better :-)
You may see something amazing.

thx,eddie

-
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/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


[kvm-devel] Remove APIC lock

2007-08-24 Thread Dong, Eddie
Avi:

apic-lock is used in many place to avoid race condition with apic
timer call back
function which may run on different pCPU. This patch migrate the
apic timer to
same CPU with the one VP runs on, thus the lock is no longer
necessary.

thx,eddie

Signed-off-by: Yaozu (Eddie) Dong [EMAIL PROTECTED]


diff --git a/drivers/kvm/irq.h b/drivers/kvm/irq.h
index b6283d2..f324cfb 100644
--- a/drivers/kvm/irq.h
+++ b/drivers/kvm/irq.h
@@ -106,7 +106,6 @@ struct kvm_ioapic {
 };
 
 struct kvm_lapic {
-   spinlock_t lock;/* TODO for revise */
unsigned long base_address;
struct kvm_io_device dev;
struct {
@@ -159,5 +158,6 @@ void kvm_apic_timer_intr_post(struct kvm_vcpu *vcpu,
int vec);
 void kvm_timer_intr_post(struct kvm_vcpu *vcpu, int vec);
 void kvm_inject_pending_timer_irqs(struct kvm_vcpu *vcpu);
 void kvm_inject_apic_timer_irqs(struct kvm_vcpu *vcpu);
+void kvm_migrate_apic_timer(struct kvm_vcpu *vcpu);
 
 #endif
diff --git a/drivers/kvm/lapic.c b/drivers/kvm/lapic.c
index 751ec03..d9385a5 100644
--- a/drivers/kvm/lapic.c
+++ b/drivers/kvm/lapic.c
@@ -176,9 +176,7 @@ int kvm_lapic_find_highest_irr(struct kvm_vcpu
*vcpu)
 
if (!apic)
return 0;
-   spin_lock_bh(apic-lock);
highest_irr = apic_find_highest_irr(apic);
-   spin_unlock_bh(apic-lock);
 
return highest_irr;
 }
@@ -525,9 +523,7 @@ static void apic_mmio_read(struct kvm_io_device
*this,
   (unsigned long)address, len);
return;
}
-   spin_lock_bh(apic-lock);
result = __apic_read(apic, offset  ~0xf);
-   spin_unlock_bh(apic-lock);
 
switch (len) {
case 1:
@@ -571,7 +567,6 @@ static void apic_mmio_write(struct kvm_io_device
*this,
 
offset = 0xff0;
 
-   spin_lock_bh(apic-lock);
switch (offset) {
case APIC_ID:   /* Local APIC ID */
apic_set_reg(apic, APIC_ID, val);
@@ -645,7 +640,6 @@ static void apic_mmio_write(struct kvm_io_device
*this,
APIC_BUS_CYCLE_NS * apic-timer.divide_count
* val;
 
/* Make sure the lock ordering is coherent */
-   spin_unlock_bh(apic-lock);
hrtimer_cancel(apic-timer.dev);
atomic_set(apic-timer.pending, 0);
hrtimer_start(apic-timer.dev,
@@ -687,7 +681,6 @@ static void apic_mmio_write(struct kvm_io_device
*this,
break;
}
 
-   spin_unlock_bh(apic-lock);
 }
 
 static int apic_mmio_range(struct kvm_io_device *this, gpa_t addr)
@@ -695,15 +688,12 @@ static int apic_mmio_range(struct kvm_io_device
*this, gpa_t addr)
struct kvm_lapic *apic = (struct kvm_lapic *)this-private;
int ret = 0;
 
-   spin_lock_bh(apic-lock);
 
if (apic_hw_enabled(apic) 
(addr = apic-base_address) 
(addr  (apic-base_address + LAPIC_MMIO_LENGTH)))
ret = 1;
 
-   spin_unlock_bh(apic-lock);
-
return ret;
 }
 
@@ -711,7 +701,6 @@ void kvm_free_apic(struct kvm_lapic *apic)
 {
if (!apic)
return;
-   spin_lock_bh(apic-lock);
 
hrtimer_cancel(apic-timer.dev);
 
@@ -720,8 +709,6 @@ void kvm_free_apic(struct kvm_lapic *apic)
apic-regs_page = 0;
}
 
-   spin_unlock_bh(apic-lock);
-
kfree(apic);
 }
 
@@ -737,9 +724,7 @@ void kvm_lapic_set_tpr(struct kvm_vcpu *vcpu,
unsigned long cr8)
 
if (!apic)
return;
-   spin_lock_bh(apic-lock);
apic_set_tpr(apic, ((cr8  0x0f)  4));
-   spin_unlock_bh(apic-lock);
 }
 
 u64 kvm_lapic_get_cr8(struct kvm_vcpu *vcpu)
@@ -749,9 +734,7 @@ u64 kvm_lapic_get_cr8(struct kvm_vcpu *vcpu)
 
if (!apic)
return 0;
-   spin_lock_bh(apic-lock);
tpr = (u64) apic_get_reg(apic, APIC_TASKPRI);
-   spin_unlock_bh(apic-lock);
 
return (tpr  0xf0)  4;
 }
@@ -766,7 +749,6 @@ void kvm_lapic_set_base(struct kvm_vcpu *vcpu, u64
value)
vcpu-apic_base = value;
return;
}
-   spin_lock_bh(apic-lock);
if (apic-vcpu-vcpu_id)
value = ~MSR_IA32_APICBASE_BSP;
 
@@ -778,19 +760,11 @@ void kvm_lapic_set_base(struct kvm_vcpu *vcpu, u64
value)
apic_debug(apic base msr is 0x%016 PRIx64 , and base address
is 
   0x%lx.\n, vcpu-apic_base, apic-base_address);
 
-   spin_unlock_bh(apic-lock);
 }
 
 u64 kvm_lapic_get_base(struct kvm_vcpu *vcpu)
 {
-   struct kvm_lapic *apic = (struct kvm_lapic *)vcpu-apic;
-   u64 base;
-
-   spin_lock_bh(apic-lock);
-   base = vcpu-apic_base;
-   spin_unlock_bh(apic-lock);
-
-   return base;
+   return vcpu-apic_base;
 }
 EXPORT_SYMBOL_GPL(kvm_lapic_get_base);
 
@@ -808,8 +782,6 @@ static void lapic_reset(struct kvm_vcpu *vcpu)
/* Stop the timer in case it's a reset to an active apic */
 

Re: [kvm-devel] Remove APIC lock

2007-08-24 Thread Gregory Haskins
On Fri, 2007-08-24 at 21:08 +0800, Dong, Eddie wrote:
 Avi:
 
 apic-lock is used in many place to avoid race condition with apic
 timer call back
 function which may run on different pCPU. This patch migrate the
 apic timer to
 same CPU with the one VP runs on, thus the lock is no longer
 necessary.
 

What about sources that can inject interrupts besides the timer?  (E.g.
in-kernel PV drivers)


-
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/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] Remove APIC lock

2007-08-24 Thread Dong, Eddie
Gregory Haskins wrote:
 On Fri, 2007-08-24 at 21:08 +0800, Dong, Eddie wrote:
 Avi:
 
 apic-lock is used in many place to avoid race condition with
 apic timer call back function which may run on different pCPU.
 This patch migrate the apic timer to same CPU with the one VP
 runs on, thus the lock is no longer necessary. 
 
 
 What about sources that can inject interrupts besides the timer? 
 (E.g. in-kernel PV drivers)

Injecting IRQ is OK, since it is just operation to IRR register which we
can 
use atomic operations. Xen also do in that way.

Eddie

-
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/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] [PATCH 2/5] Architecture independence layer - v1 - basic mechanism

2007-08-24 Thread Laurent Vivier
Christian Ehrhardt wrote:
 +config KVM_POWERPC_440
 +tristate KVM for embedded PowerPC 440 cores
 +depends on KVM  POWERPC
 +---help---
 +  Provides support for KVM on embedded PowerPC 440 cores
 +
 +config KVM_POWERPC_E500
 +tristate KVM for embedded PowerPC e500 cores
 +depends on KVM  POWERPC
 +---help---
 +  Provides support for KVM on embedded PowerPC e500 cores

An off-the-topic question: is your implementation will be compatible with the
PowerPC 7447A I have in my iBook G4 ?

Laurent
-- 
- [EMAIL PROTECTED]  --
  Software is hard - Donald Knuth



signature.asc
Description: OpenPGP digital signature
-
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/___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


[kvm-devel] Using the VNC option

2007-08-24 Thread Cam Macdonell

Hello,

I'm a little stumped in running the -vnc option for KVM.  I am unable to 
connect my vncviewer.  Even just running through localhost won't work. 
I specify -vnc localhost:5001, but vncviewer won't connect.  Can someone 
point me to a simple example of using the vnc option.  The man page 
refers to a display as the argument to -vnc, I'm unclear what this means.

Thanks,
Cam

-
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/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] Remove APIC lock

2007-08-24 Thread Dong, Eddie
[EMAIL PROTECTED] wrote:
 Gregory Haskins wrote:
 On Fri, 2007-08-24 at 21:08 +0800, Dong, Eddie wrote:
 Avi:
 
 apic-lock is used in many place to avoid race condition with
 apic timer call back function which may run on different pCPU.
 This patch migrate the apic timer to same CPU with the one VP
 runs on, thus the lock is no longer necessary.
 
 
 What about sources that can inject interrupts besides the timer?
 (E.g. in-kernel PV drivers)
 
 Injecting IRQ is OK, since it is just operation to IRR
 register which we
 can
 use atomic operations. Xen also do in that way.
 
O, said too quick. Xen current has evolved to  be protected by a
bigger irqlock for both APIC  IOAPIC, and PIC uses per chip lock.

For our case, PIC/IOAPIC now is using kvm-lock. So APIC is working
with kvm-lock too. But this lock may be too big for pv driver. We may
need to think of a solution to cover both APIC  IOAPIC in future.
Eddie

-
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/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] Remove APIC lock

2007-08-24 Thread Gregory Haskins
On Fri, 2007-08-24 at 22:24 +0800, Dong, Eddie wrote:
 [EMAIL PROTECTED] wrote:
  Gregory Haskins wrote:
  On Fri, 2007-08-24 at 21:08 +0800, Dong, Eddie wrote:
  Avi:
  
  apic-lock is used in many place to avoid race condition with
  apic timer call back function which may run on different pCPU.
  This patch migrate the apic timer to same CPU with the one VP
  runs on, thus the lock is no longer necessary.
  
  
  What about sources that can inject interrupts besides the timer?
  (E.g. in-kernel PV drivers)
  
  Injecting IRQ is OK, since it is just operation to IRR
  register which we
  can
  use atomic operations. Xen also do in that way.
  
 O, said too quick. Xen current has evolved to  be protected by a
 bigger irqlock for both APIC  IOAPIC, and PIC uses per chip lock.
 
 For our case, PIC/IOAPIC now is using kvm-lock. So APIC is working
 with kvm-lock too. But this lock may be too big for pv driver. We may
 need to think of a solution to cover both APIC  IOAPIC in future.

Yeah, I would highly recommend you make this more fine grained.  For
example, I had a vcpu-irq.lock, and a per-chip lock (e.g. one per apic,
per pic, (and one per ioapic but I never got there)).  Event injection
is a hot-spot, so coarse locking is probably going to cause performance
deficiencies.


-
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/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] [Qemu-devel] [PATCH 3/4] Add support for HPET periodic timer.

2007-08-24 Thread Luca
On 8/23/07, Dan Kenigsberg [EMAIL PROTECTED] wrote:
 On Thu, Aug 23, 2007 at 12:09:47AM +0200, Andi Kleen wrote:
   $ dmesg |grep -i hpet
   ACPI: HPET 7D5B6AE0, 0038 (r1 A M I  OEMHPET   5000708 MSFT   97)
   ACPI: HPET id: 0x8086a301 base: 0xfed0
   hpet0: at MMIO 0xfed0, IRQs 2, 8, 0, 0
   hpet0: 4 64-bit timers, 14318180 Hz
   hpet_resources: 0xfed0 is busy
 
  What kernel version was that? There was a bug that caused this pre .22
 

 I have vanilla 2.6.22.3 on that machine.

Try:
cat /sys/devices/system/clocksource/clocksource0/available_clocksource

do you see HPET listed twice?

Luca

-
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/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


[kvm-devel] [PATCH 00/13] PV-IO v4

2007-08-24 Thread Gregory Haskins
The following series implements v4 of the PV-IO series.

Changes since v3:

1)Rebased on top of kvm.git HEAD
2)Forward ported Ingo's/Dor's baseline work for paravirtualization (Dropped
  ballon and net driver) 
3)Fixed numerous bugs:  You can now pass packets via the IOQNET loopback.

I am on vacation next week (figures...just in time for the KVM forum) and
will be also traveling for business for a good portion of Sept.Based on
that, I figured I would make one more drop with my latest stuff.

Have a good time at the forum!  I will talk to you guys when everyone is back
in the swing of things.

-Greg



-
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/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


[kvm-devel] [PATCH 01/13] PV: Add basic infrastructure for paravirtual/hypercall infrastructure

2007-08-24 Thread Gregory Haskins
Author: Ingo Molnar [EMAIL PROTECTED]
Author: Dor Laor [EMAIL PROTECTED]

Signed-off-by: Gregory Haskins [EMAIL PROTECTED]
---

 include/asm-i386/hypercall.h   |  138 
 include/asm-x86_64/hypercall.h |  100 +
 2 files changed, 238 insertions(+), 0 deletions(-)

diff --git a/include/asm-i386/hypercall.h b/include/asm-i386/hypercall.h
new file mode 100644
index 000..8eeb23a
--- /dev/null
+++ b/include/asm-i386/hypercall.h
@@ -0,0 +1,138 @@
+#ifndef __ASM_HYPERCALL_H
+#define __ASM_HYPERCALL_H
+
+#define CONFIG_PARAVIRT 1
+#ifdef CONFIG_PARAVIRT
+
+/*
+ * Hypercalls, according to the calling convention
+ * documented in include/linux/kvm_para.h
+ *
+ * Copyright (C) 2007, Red Hat, Inc., Ingo Molnar [EMAIL PROTECTED]
+ * Copyright (C) 2007, Qumranet, Inc., Dor Laor [EMAIL PROTECTED]
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2.  See
+ * the COPYING file in the top-level directory.
+ */
+
+static inline int __hypercall0(unsigned int nr)
+{
+   int ret;
+   asm ( call hypercall_addr\n
+   : =a (ret)
+   : a (nr)
+   : memory, cc
+   );
+   return ret;
+}
+
+static inline int __hypercall1(unsigned int nr, unsigned long p1)
+{
+   int ret;
+   asm ( call hypercall_addr\n
+   : =a (ret)
+   : a (nr),
+ b (p1)
+   : memory, cc
+   );
+   return ret;
+}
+
+static inline int
+__hypercall2(unsigned int nr, unsigned long p1, unsigned long p2)
+{
+   int ret;
+   asm ( call hypercall_addr\n
+   : =a (ret)
+   : a (nr),
+ b (p1),
+ c (p2)
+   : memory, cc
+   );
+   return ret;
+}
+
+static inline int
+__hypercall3(unsigned int nr, unsigned long p1, unsigned long p2,
+unsigned long p3)
+{
+   int ret;
+   asm ( call hypercall_addr\n
+   : =a (ret)
+   : a (nr),
+ b (p1),
+ c (p2),
+ d (p3)
+   : memory, cc
+   );
+   return ret;
+}
+
+static inline int
+__hypercall4(unsigned int nr, unsigned long p1, unsigned long p2,
+unsigned long p3, unsigned long p4)
+{
+   int ret;
+   asm ( call hypercall_addr\n
+   : =a (ret)
+   : a (nr),
+ b (p1),
+ c (p2),
+ d (p3),
+ S (p4)
+   : memory, cc
+   );
+   return ret;
+}
+
+static inline int
+__hypercall5(unsigned int nr, unsigned long p1, unsigned long p2,
+unsigned long p3, unsigned long p4, unsigned long p5)
+{
+   int ret;
+   asm ( call hypercall_addr\n
+   : =a (ret)
+   : a (nr),
+ b (p1),
+ c (p2),
+ d (p3),
+ S (p4),
+ D (p5)
+   : memory, cc
+   );
+   return ret;
+}
+
+static inline int
+__hypercall6(unsigned int nr, unsigned long p1, unsigned long p2,
+unsigned long p3, unsigned long p4, unsigned long p5,
+unsigned long p6)
+{
+   int ret;
+   asm ( call hypercall_addr\n
+   : =a (ret)
+   : a (nr),
+ b (p1),
+ c (p2),
+ d (p3),
+ S (p4),
+ D (p5),
+ bp (p6)
+   : memory, cc
+   );
+   return ret;
+}
+
+
+#define hypercall(nr_params, args...)  \
+({ \
+   int __ret;  \
+   \
+   __ret = __hypercall##nr_params(args);   \
+   \
+   __ret;  \
+})
+
+#endif /* CONFIG_PARAVIRT */
+
+#endif /* __ASM_HYPERCALL_H */
diff --git a/include/asm-x86_64/hypercall.h b/include/asm-x86_64/hypercall.h
new file mode 100644
index 000..5cf15b3
--- /dev/null
+++ b/include/asm-x86_64/hypercall.h
@@ -0,0 +1,100 @@
+#ifndef __ASM_HYPERCALL_H
+#define __ASM_HYPERCALL_H
+
+#define CONFIG_PARAVIRT 1
+#ifdef CONFIG_PARAVIRT
+
+/*
+ * Hypercalls, according to the calling convention
+ * documented in include/linux/kvm_para.h
+ *
+ * Copyright (C) 2007, Red Hat, Inc., Ingo Molnar [EMAIL PROTECTED]
+ * Copyright (C) 2007, Qumranet, Inc., Dor Laor [EMAIL PROTECTED]
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2.  See
+ * the COPYING file in the top-level directory.
+ */
+
+static inline int __hypercall0(unsigned int nr)
+{
+   int ret;
+   asm ( call hypercall_addr\n
+   : =a (ret)
+   : a (nr)
+   : memory, cc
+   );
+   return ret;
+}
+
+static inline int __hypercall1(unsigned int nr, unsigned long p1)
+{
+   int 

[kvm-devel] [PATCH 02/13] KVM: Add hypercall definitions

2007-08-24 Thread Gregory Haskins
Author: Ingo Molnar [EMAIL PROTECTED]
Author: Dor Laor [EMAIL PROTECTED]

Signed-off-by: Gregory Haskins [EMAIL PROTECTED]
---

 include/linux/kvm.h |   20 
 1 files changed, 20 insertions(+), 0 deletions(-)

diff --git a/include/linux/kvm.h b/include/linux/kvm.h
index 1d5a49c..7e9b862 100644
--- a/include/linux/kvm.h
+++ b/include/linux/kvm.h
@@ -298,4 +298,24 @@ struct kvm_signal_mask {
 #define KVM_GET_FPU   _IOR(KVMIO,  0x8c, struct kvm_fpu)
 #define KVM_SET_FPU   _IOW(KVMIO,  0x8d, struct kvm_fpu)
 
+/*
+ * Hypercall calling convention:
+ *
+ * Each hypercall may have 0-6 parameters.
+ *
+ * 64-bit hypercall index is in RAX, goes from 0 to __NR_hypercalls-1
+ *
+ * 64-bit parameters 1-6 are in the standard gcc x86_64 calling convention
+ * order: RDI, RSI, RDX, RCX, R8, R9.
+ *
+ * 32-bit index is EBX, parameters are: EAX, ECX, EDX, ESI, EDI, EBP.
+ * (the first 3 are according to the gcc regparm calling convention)
+ *
+ * No registers are clobbered by the hypercall, except that the
+ * return value is in RAX.
+ */
+#define KVM_NR_HYPERCALLS  1
+
+#define __NR_hypercall_test0
+
 #endif


-
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/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


[kvm-devel] [PATCH 03/13] IOQ: Adding basic definitions for IO-Queue logic

2007-08-24 Thread Gregory Haskins
IOQ is a generic shared-memory-queue mechanism that happens to be friendly
to virtualization boundaries.  Note that it is not virtualization specific
due to its flexible transport layer.

Signed-off-by: Gregory Haskins [EMAIL PROTECTED]
---

 include/linux/ioq.h |  176 +++
 lib/Kconfig |   11 ++
 lib/Makefile|1 
 lib/ioq.c   |  228 +++
 4 files changed, 416 insertions(+), 0 deletions(-)

diff --git a/include/linux/ioq.h b/include/linux/ioq.h
new file mode 100644
index 000..d3a18a1
--- /dev/null
+++ b/include/linux/ioq.h
@@ -0,0 +1,176 @@
+/*
+ * Copyright 2007 Novell.  All Rights Reserved.
+ *
+ * IOQ is a generic shared-memory-queue mechanism that happens to be friendly
+ * to virtualization boundaries. It can be used in a variety of ways, though
+ * its intended purpose is to become the low-level communication path for
+ * paravirtualized drivers.  Note that it is not virtualization specific
+ * due to its flexible signaling layer.
+ *
+ * The following are a list of key design points:
+ *
+ * #) All shared-memory is always allocated on explicitly one side of the
+ *link.  This typically would be the guest side in a VM/VMM scenario.
+ * #) The code has the concept of north and south where north denotes the
+ *memory-owner side (e.g. guest).
+ * #) A IOQ is created on the north side (which generates a unique ID), and
+ *is connected on the remote side via its ID.  The facilitates call-path
+ *setup in a manner that is friendly across VM/VMM boundaries.
+ * #) An IOQ is manipulated using an iterator idiom.
+ * #) A IOQ Manager abstraction handles the translation between two
+ *endpoints. E.g. allocating north memory, signaling, translating
+ *addresses (e.g. GPA to PA)
+ *
+ * Author:
+ *  Gregory Haskins [EMAIL PROTECTED]
+ *
+ * This file is free software; you can redistribute it and/or modify
+ * it under the terms of version 2 of the GNU General Public License
+ * as published by the Free Software Foundation.
+ *
+ * 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,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#ifndef _LINUX_IOQ_H
+#define _LINUX_IOQ_H
+
+#include linux/sched.h
+#include linux/wait.h
+#include asm/types.h
+
+struct ioq_mgr;
+
+/*
+ *-
+ * The following structures represent data that is shared across boundaries
+ * which may be quite disparate from one another (e.g. Windows vs Linux,
+ * 32 vs 64 bit, etc).  Therefore, care has been taken to make sure they
+ * present data in a manner that is independent of the environment.
+ *---
+ */
+typedef u64 ioq_id_t;
+
+struct ioq_ring_desc {
+   u64 cookie; /* for arbitrary use by north-side */
+   u64 ptr;
+   u64 len;
+   u64 alen;
+   u8  valid;
+   u8  sown; /* South owned = 1, North owned = 0 */
+};
+
+#define IOQ_RING_MAGIC 0x47fa2fe4
+#define IOQ_RING_VER   1
+
+struct ioq_ring_idx {
+   u32 head;/* 0 based index to head of ptr array */
+   u32 tail;/* 0 based index to tail of ptr array */
+   u8  full;
+};
+
+struct ioq_irq {
+   u8  enabled;
+   u8  pending;
+};
+
+enum ioq_locality {
+   ioq_locality_north,
+   ioq_locality_south,
+};
+
+struct ioq_ring_head {
+   u32 magic;
+   u32 ver;
+   ioq_id_tid;
+   u32 count;
+   u64 ptr; /* ptr to array of ioq_ring_desc[count] */
+   struct ioq_ring_idx idx[2];
+   struct ioq_irq  irq[2];
+   u8  padding[16];
+};
+
+/* --- END SHARED STRUCTURES --- */
+
+enum ioq_idx_type {
+   ioq_idxtype_valid,
+   ioq_idxtype_inuse,
+   ioq_idxtype_invalid,
+};
+
+enum ioq_seek_type {
+   ioq_seek_tail,
+   ioq_seek_next,
+   ioq_seek_head,
+   ioq_seek_set
+};
+
+struct ioq_iterator {
+   struct ioq*ioq;
+   struct ioq_ring_idx   *idx;
+   u32pos;
+   struct ioq_ring_desc  *desc;
+   intupdate;
+};
+
+int  ioq_iter_seek(struct ioq_iterator *iter, enum ioq_seek_type type,
+  long offset, int flags);
+int  ioq_iter_push(struct ioq_iterator *iter, int flags);
+int  ioq_iter_pop(struct ioq_iterator *iter,  int flags);
+
+struct ioq_notifier {
+   void (*signal)(struct ioq_notifier*);
+};
+
+struct ioq {

[kvm-devel] [PATCH 04/13] PARAVIRTUALIZATION: Add support for a bus abstraction

2007-08-24 Thread Gregory Haskins
PV usually comes in two flavors:  device PV, and core PV.  The existing PV
ops deal in terms of the latter.  However, it would be useful to add an
interface for a virtual bus with provisions for discovery/configuration of
backend PV devices.  Often times it is desirable to run PV devices even if the
entire core is not operating with PVOPS.  Therefore, we introduce a separate
interface to deal with the devices.

Signed-off-by: Gregory Haskins [EMAIL PROTECTED]
---

 arch/i386/Kconfig|2 +
 arch/x86_64/Kconfig  |2 +
 drivers/Makefile |1 
 drivers/pvbus/Kconfig|7 ++
 drivers/pvbus/Makefile   |6 ++
 drivers/pvbus/pvbus-driver.c |  120 ++
 include/linux/pvbus.h|   59 +
 7 files changed, 197 insertions(+), 0 deletions(-)

diff --git a/arch/i386/Kconfig b/arch/i386/Kconfig
index f952493..a89b8a5 100644
--- a/arch/i386/Kconfig
+++ b/arch/i386/Kconfig
@@ -1137,6 +1137,8 @@ source drivers/pci/pcie/Kconfig
 
 source drivers/pci/Kconfig
 
+source drivers/pvbus/Kconfig
+
 config ISA_DMA_API
bool
default y
diff --git a/arch/x86_64/Kconfig b/arch/x86_64/Kconfig
index ffa0364..abf1f63 100644
--- a/arch/x86_64/Kconfig
+++ b/arch/x86_64/Kconfig
@@ -740,6 +740,8 @@ source drivers/pcmcia/Kconfig
 
 source drivers/pci/hotplug/Kconfig
 
+source drivers/pvbus/Kconfig
+
 endmenu
 
 
diff --git a/drivers/Makefile b/drivers/Makefile
index f0878b2..54dd639 100644
--- a/drivers/Makefile
+++ b/drivers/Makefile
@@ -88,3 +88,4 @@ obj-$(CONFIG_DMA_ENGINE)  += dma/
 obj-$(CONFIG_HID)  += hid/
 obj-$(CONFIG_PPC_PS3)  += ps3/
 obj-$(CONFIG_OF)   += of/
+obj-$(CONFIG_PVBUS)+= pvbus/
diff --git a/drivers/pvbus/Kconfig b/drivers/pvbus/Kconfig
new file mode 100644
index 000..1ca094d
--- /dev/null
+++ b/drivers/pvbus/Kconfig
@@ -0,0 +1,7 @@
+#
+# PVBUS configuration
+#
+
+config PVBUS
+   bool Paravirtual Bus
+
diff --git a/drivers/pvbus/Makefile b/drivers/pvbus/Makefile
new file mode 100644
index 000..0df2c2e
--- /dev/null
+++ b/drivers/pvbus/Makefile
@@ -0,0 +1,6 @@
+#
+# Makefile for the PVBUS bus specific drivers.
+#
+
+obj-y += pvbus-driver.o
+
diff --git a/drivers/pvbus/pvbus-driver.c b/drivers/pvbus/pvbus-driver.c
new file mode 100644
index 000..3f6687d
--- /dev/null
+++ b/drivers/pvbus/pvbus-driver.c
@@ -0,0 +1,120 @@
+/*
+ * Copyright 2007 Novell.  All Rights Reserved.
+ *
+ * Paravirtualized-Bus - This is a generic infrastructure for virtual devices
+ * and their drivers.  It is inspired by Rusty Russell's lguest_bus, but with
+ * the key difference that the bus is decoupled from the underlying hypervisor
+ * in both name and function.
+ *
+ * Instead, it is intended that external hypervisor support will register
+ * arbitrary devices.  Generic drivers can then monitor this bus for
+ * compatible devices regardless of the hypervisor implementation. 
+ *
+ * Author:
+ *  Gregory Haskins [EMAIL PROTECTED]
+ *
+ * This file is free software; you can redistribute it and/or modify
+ * it under the terms of version 2 of the GNU General Public License
+ * as published by the Free Software Foundation.
+ *
+ * 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,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#include linux/pvbus.h
+
+#define PVBUS_NAME pvbus
+
+/*
+ * This function is invoked whenever a new driver and/or device is added
+ * to check if there is a match
+ */
+static int pvbus_dev_match(struct device *_dev, struct device_driver *_drv)
+{
+   struct pvbus_device *dev = container_of(_dev,struct pvbus_device,dev);
+   struct pvbus_driver *drv = container_of(_drv,struct pvbus_driver,drv);
+
+   return !strcmp(dev-name, drv-name);
+}
+
+/*
+ * This function is invoked after the bus infrastructure has already made a
+ * match.  The device will contain a reference to the paired driver which
+ * we will extract.
+ */
+static int pvbus_dev_probe(struct device *_dev)
+{
+   int ret = 0;
+   struct pvbus_device*dev = container_of(_dev,struct pvbus_device, dev);
+   struct pvbus_driver*drv = container_of(_dev-driver,
+  struct pvbus_driver, drv);
+
+   if (drv-probe)
+   ret = drv-probe(dev);
+
+   return ret;
+}
+
+static struct bus_type pv_bus = {
+   .name   = PVBUS_NAME,
+   .match  = pvbus_dev_match,
+};
+
+static struct device pvbus_rootdev = {
+   .parent = NULL,
+   .bus_id = PVBUS_NAME,
+};
+
+static int __init pvbus_init(void)
+{
+   int ret;
+
+ 

[kvm-devel] [PATCH 05/13] IOQ: Add an IOQ network driver

2007-08-24 Thread Gregory Haskins
Signed-off-by: Gregory Haskins [EMAIL PROTECTED]
---

 drivers/net/Kconfig |   10 +
 drivers/net/Makefile|2 
 drivers/net/ioqnet/Makefile |   11 +
 drivers/net/ioqnet/driver.c |  678 +++
 include/linux/ioqnet.h  |   44 +++
 5 files changed, 745 insertions(+), 0 deletions(-)

diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index 81ef81c..ef05437 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -2983,4 +2983,14 @@ config NETPOLL_TRAP
 config NET_POLL_CONTROLLER
def_bool NETPOLL
 
+config IOQNET
+   tristate IOQNET (IOQ based paravirtualized network driver)
+   select IOQ
+   select PVBUS
+
+config IOQNET_DEBUG
+bool IOQNET debugging
+   depends on IOQNET
+   default n
+
 endif # NETDEVICES
diff --git a/drivers/net/Makefile b/drivers/net/Makefile
index e684212..09a744d 100644
--- a/drivers/net/Makefile
+++ b/drivers/net/Makefile
@@ -232,6 +232,8 @@ obj-$(CONFIG_ENP2611_MSF_NET) += ixp2000/
 
 obj-$(CONFIG_NETCONSOLE) += netconsole.o
 
+obj-$(CONFIG_IOQNET) += ioqnet/
+
 obj-$(CONFIG_FS_ENET) += fs_enet/
 
 obj-$(CONFIG_NETXEN_NIC) += netxen/
diff --git a/drivers/net/ioqnet/Makefile b/drivers/net/ioqnet/Makefile
new file mode 100644
index 000..d7020ee
--- /dev/null
+++ b/drivers/net/ioqnet/Makefile
@@ -0,0 +1,11 @@
+#
+# Makefile for the IOQNET ethernet driver
+#
+
+ioqnet-objs = driver.o
+obj-$(CONFIG_IOQNET) += ioqnet.o
+
+
+ifeq ($(CONFIG_IOQNET_DEBUG),y)
+EXTRA_CFLAGS += -DIOQNET_DEBUG
+endif
diff --git a/drivers/net/ioqnet/driver.c b/drivers/net/ioqnet/driver.c
new file mode 100644
index 000..244f633
--- /dev/null
+++ b/drivers/net/ioqnet/driver.c
@@ -0,0 +1,678 @@
+/*
+ * ioqnet - A paravirtualized network device based on the IOQ interface
+ *
+ * Copyright (C) 2007 Novell, Gregory Haskins [EMAIL PROTECTED]
+ *
+ * Derived from the SNULL example from the book Linux Device
+ * Drivers by Alessandro Rubini and Jonathan Corbet, published
+ * by O'Reilly  Associates.
+ */
+
+#include linux/module.h
+#include linux/init.h
+#include linux/moduleparam.h
+
+#include linux/sched.h
+#include linux/kernel.h /* printk() */
+#include linux/slab.h /* kmalloc() */
+#include linux/errno.h  /* error codes */
+#include linux/types.h  /* size_t */
+#include linux/interrupt.h /* mark_bh */
+
+#include linux/in.h
+#include linux/netdevice.h   /* struct device, and other headers */
+#include linux/etherdevice.h /* eth_type_trans */
+#include linux/ip.h  /* struct iphdr */
+#include linux/tcp.h /* struct tcphdr */
+#include linux/skbuff.h
+#include linux/ioq.h
+#include linux/pvbus.h
+
+#include linux/in6.h
+#include asm/checksum.h
+
+#include linux/ioqnet.h
+
+MODULE_AUTHOR(Gregory Haskins);
+MODULE_LICENSE(GPL);
+
+#undef PDEBUG /* undef it, just in case */
+#ifdef IOQNET_DEBUG
+#  define PDEBUG(fmt, args...) printk( KERN_DEBUG ioqnet:  fmt, ## args)
+#else
+#  define PDEBUG(fmt, args...) /* not debugging: nothing */
+#endif
+
+#define RX_RINGLEN 64
+#define TX_RINGLEN 64
+#define TX_PTRS_PER_DESC 64
+
+struct ioqnet_queue {
+   struct ioq  *queue;
+   struct ioq_notifier  notifier;
+};
+
+struct ioqnet_tx_desc {
+   struct sk_buff  *skb;
+   struct ioqnet_tx_ptr data[TX_PTRS_PER_DESC];
+};
+
+struct ioqnet_priv {
+   spinlock_t   lock;
+   struct net_device   *dev;
+   struct pvbus_device *pdev;
+   struct net_device_stats  stats;
+   struct ioqnet_queue  rxq;
+   struct ioqnet_queue  txq;
+   struct tasklet_structtxtask;
+};
+
+static int ioqnet_queue_init(struct ioqnet_priv *priv,
+struct ioqnet_queue *q,
+size_t ringsize,
+void (*func)(struct ioq_notifier*))
+{
+   int ret = priv-pdev-createqueue(priv-pdev, q-queue, ringsize, 0);
+   if (ret  0)
+   return ret;
+
+   q-notifier.signal = func;
+   q-queue-notifier = q-notifier;
+
+   return 0;
+}
+
+/* Perform a hypercall to register/connect our queues */
+static int ioqnet_connect(struct ioqnet_priv *priv)
+{
+   struct ioqnet_connect data = {
+   .rxq = priv-rxq.queue-id,
+   .txq = priv-txq.queue-id,
+   };
+
+   return priv-pdev-call(priv-pdev, IOQNET_CONNECT,
+   data, sizeof(data), 0);
+}
+
+static int ioqnet_disconnect(struct ioqnet_priv *priv)
+{
+   return priv-pdev-call(priv-pdev, IOQNET_DISCONNECT, NULL, 0, 0);
+}
+
+/* Perform a hypercall to get the assigned MAC addr */
+static int ioqnet_query_mac(struct ioqnet_priv *priv)
+{
+   return priv-pdev-call(priv-pdev,
+   IOQNET_QUERY_MAC,
+   priv-dev-dev_addr,
+   ETH_ALEN, 0);
+}
+
+
+/*
+ * Enable and disable receive interrupts.
+ */
+static void ioqnet_rx_ints(struct net_device *dev, int enable)

[kvm-devel] [PATCH 06/13] IOQNET: Add a test harness infrastructure to IOQNET

2007-08-24 Thread Gregory Haskins
We can add a IOQNET loop-back device and register it with the PVBUS to test
many aspects of the system (IOQ, PVBUS, and IOQNET itself).

Signed-off-by: Gregory Haskins [EMAIL PROTECTED]
---

 drivers/net/Kconfig   |   10 +
 drivers/net/ioqnet/Makefile   |3 
 drivers/net/ioqnet/loopback.c |  517 +
 3 files changed, 530 insertions(+), 0 deletions(-)

diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index ef05437..a6a467e 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -2993,4 +2993,14 @@ config IOQNET_DEBUG
depends on IOQNET
default n
 
+config IOQNET_LOOPBACK
+tristate IOQNET loopback device test harness
+depends on IOQNET
+default n
+---help---
+This will install a special PVBUS device that implements two IOQNET
+devices.  The devices are, of course, linked to one another forming a
+loopback mechanism.  This allows many subsystems to be tested: IOQ,
+PVBUS, and IOQNET itself.  If unsure, say N.
+ 
 endif # NETDEVICES
diff --git a/drivers/net/ioqnet/Makefile b/drivers/net/ioqnet/Makefile
index d7020ee..7d2d156 100644
--- a/drivers/net/ioqnet/Makefile
+++ b/drivers/net/ioqnet/Makefile
@@ -4,8 +4,11 @@
 
 ioqnet-objs = driver.o
 obj-$(CONFIG_IOQNET) += ioqnet.o
+ioqnet-loopback-objs = loopback.o
+obj-$(CONFIG_IOQNET_LOOPBACK) += ioqnet-loopback.o
 
 
 ifeq ($(CONFIG_IOQNET_DEBUG),y)
 EXTRA_CFLAGS += -DIOQNET_DEBUG
 endif
+
diff --git a/drivers/net/ioqnet/loopback.c b/drivers/net/ioqnet/loopback.c
new file mode 100644
index 000..9cc8d47
--- /dev/null
+++ b/drivers/net/ioqnet/loopback.c
@@ -0,0 +1,517 @@
+/*
+ * ioqnet test harness
+ *
+ * Copyright (C) 2007 Novell, Gregory Haskins [EMAIL PROTECTED]
+ *
+ * This file is free software; you can redistribute it and/or modify
+ * it under the terms of version 2 of the GNU General Public License
+ * as published by the Free Software Foundation.
+ *
+ * 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,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#include linux/module.h
+#include linux/pvbus.h
+#include linux/ioq.h
+#include linux/kthread.h
+#include linux/ioqnet.h
+#include linux/interrupt.h
+
+MODULE_AUTHOR(Gregory Haskins);
+MODULE_LICENSE(GPL);
+
+#ifndef ETH_ALEN
+#define ETH_ALEN 6
+#endif
+
+#undef PDEBUG /* undef it, just in case */
+#ifdef IOQNET_DEBUG
+#  define PDEBUG(fmt, args...) printk( KERN_DEBUG ioqnet:  fmt, ## args)
+#else
+#  define PDEBUG(fmt, args...) /* not debugging: nothing */
+#endif
+
+/*
+ * -
+ * First we must create an IOQ implementation to use while under test
+ * since these operations will all be local to the same host
+ * -
+ */
+
+struct ioqnet_lb_ioq {
+   struct ioq   ioq;
+   struct ioqnet_lb_ioq*peer;
+   struct tasklet_structtask;
+};
+
+struct ioqnet_lb_ioqmgr {
+   struct ioq_mgr  mgr;
+
+   /*
+* Since this is just a test harness, we know ahead of time that
+* we aren't going to need more than a handful of IOQs.  So to keep
+* lookups simple we will simply create a static array of them
+*/
+   struct ioqnet_lb_ioq ioqs[8];
+   int pos;
+};
+
+static struct ioqnet_lb_ioqmgr lb_ioqmgr;
+
+struct ioqnet_lb_ioq* to_ioq(struct ioq *ioq)
+{
+   return container_of(ioq, struct ioqnet_lb_ioq, ioq);
+}
+
+struct ioqnet_lb_ioqmgr* to_mgr(struct ioq_mgr *mgr)
+{
+   return container_of(mgr, struct ioqnet_lb_ioqmgr, mgr);
+}
+
+/*
+ * --
+ * ioq implementation
+ * --
+ */
+static void ioqnet_lb_ioq_wake(unsigned long data)
+{
+   struct ioqnet_lb_ioq *_ioq = (struct ioqnet_lb_ioq*)data;
+
+   if (_ioq-peer)
+   ioq_wakeup(_ioq-peer-ioq);
+}
+
+static int ioqnet_lb_ioq_signal(struct ioq *ioq)
+{
+   struct ioqnet_lb_ioq *_ioq = to_ioq(ioq);
+
+   if (_ioq-peer)
+   tasklet_schedule(_ioq-task);
+
+   return 0;
+}
+
+static void ioqnet_lb_ioq_destroy(struct ioq *ioq)
+{
+   struct ioqnet_lb_ioq *_ioq = to_ioq(ioq);
+
+   if (_ioq-peer) {
+   _ioq-peer-peer = NULL;
+   _ioq-peer   = NULL;
+   }
+
+   if (_ioq-ioq.locale == ioq_locality_north) {
+   kfree(_ioq-ioq.ring);
+   kfree(_ioq-ioq.head_desc);
+   } else
+   kfree(_ioq);
+}
+
+/*
+ * --
+ * ioqmgr implementation
+ * --
+ */
+static int 

[kvm-devel] [PATCH 07/13] IRQ: Export create_irq/destroy_irq

2007-08-24 Thread Gregory Haskins
Signed-off-by: Gregory Haskins [EMAIL PROTECTED]
---

 arch/x86_64/kernel/io_apic.c |2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/arch/x86_64/kernel/io_apic.c b/arch/x86_64/kernel/io_apic.c
index f57f8b9..f8d2508 100644
--- a/arch/x86_64/kernel/io_apic.c
+++ b/arch/x86_64/kernel/io_apic.c
@@ -1907,6 +1907,7 @@ int create_irq(void)
}
return irq;
 }
+EXPORT_SYMBOL(create_irq);
 
 void destroy_irq(unsigned int irq)
 {
@@ -1918,6 +1919,7 @@ void destroy_irq(unsigned int irq)
__clear_irq_vector(irq);
spin_unlock_irqrestore(vector_lock, flags);
 }
+EXPORT_SYMBOL(destroy_irq);
 
 /*
  * MSI mesage composition


-
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/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


[kvm-devel] [PATCH 08/13] KVM: Add a guest side driver for IOQ

2007-08-24 Thread Gregory Haskins
Signed-off-by: Gregory Haskins [EMAIL PROTECTED]
---

 drivers/kvm/Kconfig   |   16 ++
 drivers/kvm/Makefile  |2 
 drivers/kvm/ioq.h |   39 +
 drivers/kvm/ioq_guest.c   |  196 +++
 drivers/kvm/pvbus.h   |   63 +++
 drivers/kvm/pvbus_guest.c |  382 +
 include/linux/kvm.h   |4 
 7 files changed, 701 insertions(+), 1 deletions(-)

diff --git a/drivers/kvm/Kconfig b/drivers/kvm/Kconfig
index 445c6e4..d17ce96 100644
--- a/drivers/kvm/Kconfig
+++ b/drivers/kvm/Kconfig
@@ -41,4 +41,20 @@ config KVM_AMD
  Provides support for KVM on AMD processors equipped with the AMD-V
  (SVM) extensions.
 
+config KVM_GUEST
+   bool KVM Guest support
+   depends on X86
+   default n
+ 
+config KVM_PVBUS_GUEST
+tristate Paravirtualized Bus (PVBUS) support
+depends on KVM_GUEST
+select IOQ
+select PVBUS
+---help---
+   PVBUS is an infrastructure for generic PV drivers to take advantage
+   of an underlying hypervisor without having to understand the details
+   of the hypervisor itself.  You only need this option if you plan to
+   run this kernel as a KVM guest.
+
 endif # VIRTUALIZATION
diff --git a/drivers/kvm/Makefile b/drivers/kvm/Makefile
index c0a789f..cd621fc 100644
--- a/drivers/kvm/Makefile
+++ b/drivers/kvm/Makefile
@@ -8,3 +8,5 @@ kvm-intel-objs = vmx.o
 obj-$(CONFIG_KVM_INTEL) += kvm-intel.o
 kvm-amd-objs = svm.o
 obj-$(CONFIG_KVM_AMD) += kvm-amd.o
+kvm-pvbus-objs := ioq_guest.o pvbus_guest.o
+obj-$(CONFIG_KVM_PVBUS_GUEST) += kvm-pvbus.o
\ No newline at end of file
diff --git a/drivers/kvm/ioq.h b/drivers/kvm/ioq.h
new file mode 100644
index 000..7e955f1
--- /dev/null
+++ b/drivers/kvm/ioq.h
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2007 Novell.  All Rights Reserved.
+ *
+ * See include/linux/ioq.h for documentation
+ *
+ * Author:
+ * Gregory Haskins [EMAIL PROTECTED]
+ *
+ * This file is free software; you can redistribute it and/or modify
+ * it under the terms of version 2 of the GNU General Public License
+ * as published by the Free Software Foundation.
+ *
+ * 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,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#ifndef _KVM_IOQ_H_
+#define _KVM_IOQ_H_
+
+#include linux/ioq.h
+
+#define IOQHC_REGISTER   1
+#define IOQHC_UNREGISTER  2
+#define IOQHC_SIGNAL 3
+
+struct ioq_register {
+   ioq_id_t id;
+   u32  irq;
+   u64  ring;
+};
+
+
+#endif /* _KVM_IOQ_H_ */
diff --git a/drivers/kvm/ioq_guest.c b/drivers/kvm/ioq_guest.c
new file mode 100644
index 000..5f16390
--- /dev/null
+++ b/drivers/kvm/ioq_guest.c
@@ -0,0 +1,196 @@
+/*
+ * Copyright 2007 Novell.  All Rights Reserved.
+ *
+ * See include/linux/ioq.h for documentation
+ *
+ * Author:
+ * Gregory Haskins [EMAIL PROTECTED]
+ *
+ * This file is free software; you can redistribute it and/or modify
+ * it under the terms of version 2 of the GNU General Public License
+ * as published by the Free Software Foundation.
+ *
+ * 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,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#include linux/interrupt.h
+#include linux/ioq.h
+#include asm/hypercall.h
+
+#include ioq.h
+#include kvm.h
+
+struct kvmguest_ioq {
+   struct ioqioq;
+   int   irq;
+};
+
+struct kvmguest_ioq* to_ioq(struct ioq *ioq)
+{
+   return container_of(ioq, struct kvmguest_ioq, ioq);
+}
+
+static int ioq_hypercall(unsigned long nr, void *data)
+{
+   return hypercall(2, __NR_hypercall_ioq, nr, __pa(data));
+}
+
+/*
+ * --
+ * interrupt handler
+ * --
+ */
+irqreturn_t kvmguest_ioq_intr(int irq, void *dev)
+{
+   struct kvmguest_ioq *_ioq = to_ioq(dev);
+
+   ioq_wakeup(_ioq-ioq);
+
+   return IRQ_HANDLED;
+}
+
+/*
+ * --
+ * ioq implementation
+ * --
+ */
+
+static int kvmguest_ioq_signal(struct ioq *ioq)
+{
+   return ioq_hypercall(IOQHC_SIGNAL, ioq-id);
+}
+
+static void kvmguest_ioq_destroy(struct ioq *ioq)
+{
+   struct kvmguest_ioq *_ioq = to_ioq(ioq);
+   int ret;
+
+   ret = 

[kvm-devel] [PATCH 09/13] KVM: Importing Dor's base PV infrastructure work to kvm.git HEAD

2007-08-24 Thread Gregory Haskins
From: Dor Laor [EMAIL PROTECTED]

Signed-off-by: Gregory Haskins [EMAIL PROTECTED]
---

 drivers/kvm/kvm.h  |   11 +++
 drivers/kvm/kvm_main.c |  153 +++-
 drivers/kvm/svm.c  |   11 +++
 drivers/kvm/svm.h  |2 -
 drivers/kvm/vmx.c  |6 ++
 5 files changed, 148 insertions(+), 35 deletions(-)

diff --git a/drivers/kvm/kvm.h b/drivers/kvm/kvm.h
index a42a6f3..839e11c 100644
--- a/drivers/kvm/kvm.h
+++ b/drivers/kvm/kvm.h
@@ -316,9 +316,6 @@ struct kvm_vcpu {
unsigned long cr0;
unsigned long cr2;
unsigned long cr3;
-   gpa_t para_state_gpa;
-   struct page *para_state_page;
-   gpa_t hypercall_gpa;
unsigned long cr4;
unsigned long cr8;
u64 pdptrs[4]; /* pae */
@@ -388,6 +385,12 @@ struct kvm_memory_slot {
unsigned long *dirty_bitmap;
 };
 
+struct kvm_hypercall {
+   unsigned long (*hypercall)(struct kvm_vcpu*, unsigned long args[]);
+   struct module *module;
+   int idx;
+};
+
 struct kvm {
struct mutex lock; /* protects everything except vcpus */
int naliases;
@@ -588,6 +591,8 @@ int kvm_mmu_load(struct kvm_vcpu *vcpu);
 void kvm_mmu_unload(struct kvm_vcpu *vcpu);
 
 int kvm_hypercall(struct kvm_vcpu *vcpu, struct kvm_run *run);
+int kvm_register_hypercall(struct module *module, struct kvm_hypercall 
*hypercall);
+int kvm_unregister_hypercall(struct kvm_hypercall *hypercall);
 
 static inline int kvm_mmu_page_fault(struct kvm_vcpu *vcpu, gva_t gva,
 u32 error_code)
diff --git a/drivers/kvm/kvm_main.c b/drivers/kvm/kvm_main.c
index d154487..6428746 100644
--- a/drivers/kvm/kvm_main.c
+++ b/drivers/kvm/kvm_main.c
@@ -84,6 +84,8 @@ static struct kvm_stats_debugfs_item {
 
 static struct dentry *debugfs_dir;
 
+static struct kvm_hypercall hypercalls[KVM_NR_HYPERCALLS];
+
 #define MAX_IO_MSRS 256
 
 #define CR0_RESERVED_BITS  \
@@ -1263,53 +1265,150 @@ int kvm_emulate_halt(struct kvm_vcpu *vcpu)
 
vcpu-run-exit_reason = KVM_EXIT_HLT;
++vcpu-stat.halt_exits;
+
return 0;
 }
 EXPORT_SYMBOL_GPL(kvm_emulate_halt);
 
+int kvm_register_hypercall(struct module* module,
+  struct kvm_hypercall *hypercall)
+{
+   int r = 0;
+
+   if (hypercall-idx = KVM_NR_HYPERCALLS ||
+   hypercall-idx  0) {
+   printk(KERN_DEBUG %s:hypercall registration idx(%d)\n,
+__FUNCTION__, hypercall-idx);
+   return -EINVAL;
+   }
+
+   spin_lock(kvm_lock);
+
+   if (hypercalls[hypercall-idx].hypercall) {
+   printk(KERN_DEBUG %s:hypercall idx(%d) already taken\n,
+   __FUNCTION__, hypercall-idx);
+   r = -EEXIST;
+   goto out;
+   }
+
+   if (try_module_get(module)  0) {
+   printk(KERN_DEBUG %s: module reference count++ failed\n,
+   __FUNCTION__);
+   r = -EINVAL;
+   goto out;
+   }
+
+   hypercalls[hypercall-idx].hypercall = hypercall-hypercall;
+   hypercalls[hypercall-idx].module = module;
+
+out:
+   spin_unlock(kvm_lock);
+
+   return r;
+}
+EXPORT_SYMBOL_GPL(kvm_register_hypercall);
+
+int kvm_unregister_hypercall(struct kvm_hypercall *hypercall)
+{
+   if (hypercall-idx = KVM_NR_HYPERCALLS ||
+   hypercall-idx  0) {
+   printk(KERN_DEBUG %s:hypercall unregistration idx(%d)\n,
+__FUNCTION__, hypercall-idx);
+   return -EINVAL;
+   }
+
+   spin_lock(kvm_lock);
+   if (!hypercalls[hypercall-idx].hypercall) {
+   printk(KERN_DEBUG %s:hypercall idx(%d) was not registered\n,
+   __FUNCTION__, hypercall-idx);
+   spin_unlock(kvm_lock);
+   return -EEXIST;
+   }
+
+   hypercalls[hypercall-idx].hypercall = 0;
+   module_put(hypercalls[hypercall-idx].module);
+   spin_unlock(kvm_lock);
+
+   return 0;
+}
+EXPORT_SYMBOL_GPL(kvm_unregister_hypercall);
+
+/*
+ * Generic hypercall dispatcher routine.
+ * Returns 0 for user space handling, 1 on success handling
+ */
 int kvm_hypercall(struct kvm_vcpu *vcpu, struct kvm_run *run)
 {
-   unsigned long nr, a0, a1, a2, a3, a4, a5, ret;
+   unsigned long nr, ret;
+   unsigned long args[6];
+   int res = 1;
 
kvm_arch_ops-cache_regs(vcpu);
ret = -KVM_EINVAL;
 #ifdef CONFIG_X86_64
if (is_long_mode(vcpu)) {
nr = vcpu-regs[VCPU_REGS_RAX];
-   a0 = vcpu-regs[VCPU_REGS_RDI];
-   a1 = vcpu-regs[VCPU_REGS_RSI];
-   a2 = vcpu-regs[VCPU_REGS_RDX];
-   a3 = vcpu-regs[VCPU_REGS_RCX];
-   a4 = vcpu-regs[VCPU_REGS_R8];
-   a5 = vcpu-regs[VCPU_REGS_R9];
+   args[0] = vcpu-regs[VCPU_REGS_RDI];
+   args[1] = 

[kvm-devel] [PATCH 11/13] KVM: Add support for IOQ

2007-08-24 Thread Gregory Haskins
IOQ is a shared-memory-queue interface for implmenting PV driver
communication.

Signed-off-by: Gregory Haskins [EMAIL PROTECTED]
---

 drivers/kvm/Kconfig|5 +
 drivers/kvm/Makefile   |3 
 drivers/kvm/ioq.h  |   12 +-
 drivers/kvm/ioq_host.c |  365 
 drivers/kvm/kvm.h  |4 +
 drivers/kvm/kvm_main.c |3 
 6 files changed, 391 insertions(+), 1 deletions(-)

diff --git a/drivers/kvm/Kconfig b/drivers/kvm/Kconfig
index d17ce96..b81a188 100644
--- a/drivers/kvm/Kconfig
+++ b/drivers/kvm/Kconfig
@@ -41,6 +41,11 @@ config KVM_AMD
  Provides support for KVM on AMD processors equipped with the AMD-V
  (SVM) extensions.
 
+config KVM_PV_HOST
+boolean Add paravirtualization backend support to KVM
+   depends on KVM
+   select IOQ
+
 config KVM_GUEST
bool KVM Guest support
depends on X86
diff --git a/drivers/kvm/Makefile b/drivers/kvm/Makefile
index cd621fc..eb32ce5 100644
--- a/drivers/kvm/Makefile
+++ b/drivers/kvm/Makefile
@@ -3,6 +3,9 @@
 #
 
 kvm-objs := kvm_main.o mmu.o x86_emulate.o
+ifeq ($(CONFIG_KVM_PV_HOST),y)
+kvm-objs += ioq_host.o
+endif
 obj-$(CONFIG_KVM) += kvm.o
 kvm-intel-objs = vmx.o
 obj-$(CONFIG_KVM_INTEL) += kvm-intel.o
diff --git a/drivers/kvm/ioq.h b/drivers/kvm/ioq.h
index 7e955f1..347fa0b 100644
--- a/drivers/kvm/ioq.h
+++ b/drivers/kvm/ioq.h
@@ -25,7 +25,17 @@
 
 #include linux/ioq.h
 
-#define IOQHC_REGISTER   1
+struct kvm;
+
+#ifdef CONFIG_KVM_PV_HOST
+int kvmhost_ioqmgr_init(struct kvm *kvm);
+int kvmhost_ioqmgr_module_init(void);
+#else
+#define kvmhost_ioqmgr_init(kvm) {}
+#define kvmhost_ioqmgr_module_init() {}
+#endif
+
+#define IOQHC_REGISTER1
 #define IOQHC_UNREGISTER  2
 #define IOQHC_SIGNAL 3
 
diff --git a/drivers/kvm/ioq_host.c b/drivers/kvm/ioq_host.c
new file mode 100644
index 000..413f103
--- /dev/null
+++ b/drivers/kvm/ioq_host.c
@@ -0,0 +1,365 @@
+/*
+ * Copyright 2007 Novell.  All Rights Reserved.
+ *
+ * See include/linux/ioq.h for documentation
+ *
+ * Author:
+ * Gregory Haskins [EMAIL PROTECTED]
+ *
+ * This file is free software; you can redistribute it and/or modify
+ * it under the terms of version 2 of the GNU General Public License
+ * as published by the Free Software Foundation.
+ *
+ * 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,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#include linux/ioq.h
+#include linux/rbtree.h
+#include linux/spinlock.h
+#include linux/highmem.h
+
+#include asm/atomic.h
+
+#include ioq.h
+#include kvm.h
+
+struct kvmhost_ioq {
+   struct ioqioq;
+   struct rb_nodenode;
+   atomic_t  refcnt;
+   struct kvm_vcpu  *vcpu;
+   int   irq;
+};
+
+struct kvmhost_map {
+   spinlock_t lock;
+   struct rb_root root;
+};
+
+struct kvmhost_ioq_mgr {
+   struct ioq_mgr  mgr;
+   struct kvm *kvm;
+   struct kvmhost_map  map;
+};
+
+struct kvmhost_ioq* to_ioq(struct ioq *ioq)
+{
+   return container_of(ioq, struct kvmhost_ioq, ioq);
+}
+
+struct kvmhost_ioq_mgr* to_mgr(struct ioq_mgr *mgr)
+{
+   return container_of(mgr, struct kvmhost_ioq_mgr, mgr);
+}
+
+/*
+ * --
+ * rb map management
+ * --
+ */
+
+static void kvmhost_map_init(struct kvmhost_map *map)
+{
+   spin_lock_init(map-lock);
+   map-root = RB_ROOT;
+}
+
+static int kvmhost_map_register(struct kvmhost_map *map,
+   struct kvmhost_ioq *ioq)
+{
+   int ret = 0;
+   struct rb_root *root;
+   struct rb_node **new, *parent = NULL;
+
+   spin_lock(map-lock);
+
+   root = map-root;
+   new  = (root-rb_node);
+
+   /* Figure out where to put new node */
+   while (*new) {
+   struct kvmhost_ioq *this;
+
+   this   = container_of(*new, struct kvmhost_ioq, node);
+   parent = *new;
+
+   if (ioq-ioq.id  this-ioq.id)
+   new = ((*new)-rb_left);
+   else if (ioq-ioq.id  this-ioq.id)
+   new = ((*new)-rb_right);
+   else {
+   ret = -EEXIST;
+   break;
+   }
+   }
+
+   if (!ret) {
+   /* Add new node and rebalance tree. */
+   rb_link_node(ioq-node, parent, new);
+   rb_insert_color(ioq-node, root);
+   }
+
+   spin_unlock(map-lock);
+
+   return ret;
+}
+
+static struct kvmhost_ioq* kvmhost_map_find(struct kvmhost_map *map,
+   

[kvm-devel] [PATCH 12/13] KVM: Add PVBUS support to the KVM host

2007-08-24 Thread Gregory Haskins
PVBUS allows VMM agnostic PV drivers to discover/configure virtual resources

Signed-off-by: Gregory Haskins [EMAIL PROTECTED]
---

 drivers/kvm/Kconfig  |2 
 drivers/kvm/Makefile |1 
 drivers/kvm/kvm.h|3 
 drivers/kvm/kvm_main.c   |4 
 drivers/kvm/pvbus_host.c |  636 ++
 drivers/kvm/pvbus_host.h |   66 +
 6 files changed, 711 insertions(+), 1 deletions(-)

diff --git a/drivers/kvm/Kconfig b/drivers/kvm/Kconfig
index b81a188..b45c9c3 100644
--- a/drivers/kvm/Kconfig
+++ b/drivers/kvm/Kconfig
@@ -45,7 +45,7 @@ config KVM_PV_HOST
 boolean Add paravirtualization backend support to KVM
depends on KVM
select IOQ
-
+
 config KVM_GUEST
bool KVM Guest support
depends on X86
diff --git a/drivers/kvm/Makefile b/drivers/kvm/Makefile
index eb32ce5..e7b52e8 100644
--- a/drivers/kvm/Makefile
+++ b/drivers/kvm/Makefile
@@ -5,6 +5,7 @@
 kvm-objs := kvm_main.o mmu.o x86_emulate.o
 ifeq ($(CONFIG_KVM_PV_HOST),y)
 kvm-objs += ioq_host.o
+kvm-objs += pvbus_host.o
 endif
 obj-$(CONFIG_KVM) += kvm.o
 kvm-intel-objs = vmx.o
diff --git a/drivers/kvm/kvm.h b/drivers/kvm/kvm.h
index aaa6d12..9f1cdfa 100644
--- a/drivers/kvm/kvm.h
+++ b/drivers/kvm/kvm.h
@@ -14,6 +14,8 @@
 #include linux/sched.h
 #include linux/mm.h
 #include linux/preempt.h
+#include linux/pvbus.h
+  
 #include asm/signal.h
 
 #include ioq.h
@@ -414,6 +416,7 @@ struct kvm {
struct kvm_io_bus pio_bus;
 #ifdef CONFIG_KVM_PV_HOST
struct ioq_mgr *ioqmgr;
+   struct kvm_pvbus *pvbus;
 #endif
 };
 
diff --git a/drivers/kvm/kvm_main.c b/drivers/kvm/kvm_main.c
index 03d0d67..8d1e4ce 100644
--- a/drivers/kvm/kvm_main.c
+++ b/drivers/kvm/kvm_main.c
@@ -18,6 +18,7 @@
 #include kvm.h
 #include x86_emulate.h
 #include segment_descriptor.h
+#include pvbus_host.h
 
 #include linux/kvm.h
 #include linux/module.h
@@ -302,6 +303,7 @@ static struct kvm *kvm_create_vm(void)
list_add(kvm-vm_list, vm_list);
spin_unlock(kvm_lock);
kvmhost_ioqmgr_init(kvm);
+   kvm_pvbus_init(kvm);
return kvm;
 }
 
@@ -3305,6 +3307,7 @@ static __init int kvm_init(void)
memset(__va(bad_page_address), 0, PAGE_SIZE);
 
kvmhost_ioqmgr_module_init();
+   kvm_pvbus_module_init();
 
return 0;
 
@@ -3320,6 +3323,7 @@ static __exit void kvm_exit(void)
kvm_exit_debug();
__free_page(pfn_to_page(bad_page_address  PAGE_SHIFT));
kvm_mmu_module_exit();
+   kvm_pvbus_module_exit();
 }
 
 module_init(kvm_init)
diff --git a/drivers/kvm/pvbus_host.c b/drivers/kvm/pvbus_host.c
new file mode 100644
index 000..cc506f4
--- /dev/null
+++ b/drivers/kvm/pvbus_host.c
@@ -0,0 +1,636 @@
+/*
+ * Copyright 2007 Novell.  All Rights Reserved.
+ *
+ * Author:
+ * Gregory Haskins [EMAIL PROTECTED]
+ *
+ * This file is free software; you can redistribute it and/or modify
+ * it under the terms of version 2 of the GNU General Public License
+ * as published by the Free Software Foundation.
+ *
+ * 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,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#include linux/module.h
+#include linux/rbtree.h
+#include linux/spinlock.h
+#include linux/highmem.h
+#include linux/workqueue.h
+
+#include pvbus.h
+#include pvbus_host.h
+#include kvm.h
+
+struct pvbus_map {
+   int (*compare)(const void *left, const void *right);
+   const void* (*getkey)(struct rb_node *node);
+
+   struct mutex   lock;
+   struct rb_root root;
+   size_t count;
+};
+
+struct _pv_devtype {
+   struct kvm_pv_devtype *item;
+   struct rb_node node;
+};
+
+struct _pv_device {
+   struct kvm_pv_device  *item;
+   struct rb_node node;
+   struct _pv_devtype*parent;
+   intsynced;
+};
+
+static struct pvbus_map pvbus_typemap;
+
+struct kvm_pvbus_eventq {
+   struct mutex lock;
+   struct ioq  *ioq;
+
+};
+
+struct kvm_pvbus {
+   struct mutexlock;
+   struct kvm *kvm;
+   struct pvbus_mapdevmap;
+   struct kvm_pvbus_eventq eventq;
+};
+
+/*
+ * --
+ * generic rb map management
+ * --
+ */
+
+static void pvbus_map_init(struct pvbus_map *map)
+{
+   mutex_init(map-lock);
+   map-root = RB_ROOT;
+}
+
+static int pvbus_map_register(struct pvbus_map *map, struct rb_node *node)
+{
+   int ret = 0;
+   struct rb_root *root;
+   struct rb_node **new, *parent = NULL;
+
+   mutex_lock(map-lock);
+
+

[kvm-devel] [PATCH 13/13] KVM: Add an IOQNET backend driver

2007-08-24 Thread Gregory Haskins
Signed-off-by: Gregory Haskins [EMAIL PROTECTED]
---

 drivers/kvm/Kconfig   |   10 +
 drivers/kvm/Makefile  |4 
 drivers/kvm/ioqnet_host.c |  578 +
 3 files changed, 591 insertions(+), 1 deletions(-)

diff --git a/drivers/kvm/Kconfig b/drivers/kvm/Kconfig
index b45c9c3..942acc5 100644
--- a/drivers/kvm/Kconfig
+++ b/drivers/kvm/Kconfig
@@ -46,6 +46,16 @@ config KVM_PV_HOST
depends on KVM
select IOQ
 
+config KVM_IOQNET
+tristate IOQNET backend host support
+   depends on KVM_PV_HOST
+   ---help---
+   Adds a backend driver for connecting guest IOQNET drivers to a host
+based netif interface.  This ethernet like interface can then be used
+   to wire the guest into more elaborate network configurations such as
+   via a standard linux bridge.  You only need this if you plan to run
+   guests which have an IOQNET driver.  If unsure, say N.
+
 config KVM_GUEST
bool KVM Guest support
depends on X86
diff --git a/drivers/kvm/Makefile b/drivers/kvm/Makefile
index e7b52e8..e4df631 100644
--- a/drivers/kvm/Makefile
+++ b/drivers/kvm/Makefile
@@ -13,4 +13,6 @@ obj-$(CONFIG_KVM_INTEL) += kvm-intel.o
 kvm-amd-objs = svm.o
 obj-$(CONFIG_KVM_AMD) += kvm-amd.o
 kvm-pvbus-objs := ioq_guest.o pvbus_guest.o
-obj-$(CONFIG_KVM_PVBUS_GUEST) += kvm-pvbus.o
\ No newline at end of file
+obj-$(CONFIG_KVM_PVBUS_GUEST) += kvm-pvbus.o
+kvm-ioqnet-objs := ioqnet_host.o
+obj-$(CONFIG_KVM_IOQNET) += kvm-ioqnet.o
\ No newline at end of file
diff --git a/drivers/kvm/ioqnet_host.c b/drivers/kvm/ioqnet_host.c
new file mode 100644
index 000..ffec49e
--- /dev/null
+++ b/drivers/kvm/ioqnet_host.c
@@ -0,0 +1,578 @@
+/*
+ * Copyright 2007 Novell.  All Rights Reserved.
+ *
+ * ioqnet - A paravirtualized network device based on the IOQ interface.
+ *
+ * This module represents the backend driver for an IOQNET driver on the KVM
+ * platform.
+ *
+ * Author:
+ *  Gregory Haskins [EMAIL PROTECTED]
+ *
+ * Derived in part from the SNULL example from the book Linux Device
+ * Drivers by Alessandro Rubini and Jonathan Corbet, published
+ * by O'Reilly  Associates.
+ *
+ * This file is free software; you can redistribute it and/or modify
+ * it under the terms of version 2 of the GNU General Public License
+ * as published by the Free Software Foundation.
+ *
+ * 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,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#include linux/module.h
+#include linux/init.h
+#include linux/moduleparam.h
+
+#include linux/sched.h
+#include linux/kernel.h /* printk() */
+#include linux/slab.h /* kmalloc() */
+#include linux/errno.h  /* error codes */
+#include linux/types.h  /* size_t */
+#include linux/interrupt.h /* mark_bh */
+
+#include linux/in.h
+#include linux/netdevice.h   /* struct device, and other headers */
+#include linux/etherdevice.h /* eth_type_trans */
+#include linux/ip.h  /* struct iphdr */
+#include linux/tcp.h /* struct tcphdr */
+#include linux/skbuff.h
+#include linux/ioq.h
+#include linux/pvbus.h
+
+#include linux/in6.h
+#include asm/checksum.h
+#include linux/ioq.h
+#include linux/ioqnet.h
+#include linux/highmem.h
+
+#include pvbus_host.h
+#include kvm.h
+
+MODULE_AUTHOR(Gregory Haskins);
+MODULE_LICENSE(GPL);
+
+#define IOQNET_NAME ioqnet
+
+/*
+ * FIXME: Any BUG_ON code that can be triggered by a malicious guest must
+ * be turned into an inject_gp()
+ */
+
+struct ioqnet_queue {
+   struct ioq  *queue;
+   struct ioq_notifier  notifier;
+};
+
+struct ioqnet_priv {
+   spinlock_t   lock;
+   struct kvm  *kvm;
+   struct kvm_pv_device pvdev;
+   struct net_device   *netdev;
+   struct net_device_stats  stats;
+   struct ioqnet_queue  rxq;
+   struct ioqnet_queue  txq;
+   struct tasklet_structtxtask;
+   int  connected;
+   int  opened;
+};
+
+#undef PDEBUG /* undef it, just in case */
+#ifdef IOQNET_DEBUG
+#  define PDEBUG(fmt, args...) printk( KERN_DEBUG ioqnet:  fmt, ## args)
+#else
+#  define PDEBUG(fmt, args...) /* not debugging: nothing */
+#endif
+
+/*
+ * Enable and disable receive interrupts.
+ */
+static void ioqnet_rx_ints(struct net_device *dev, int enable)
+{
+   struct ioqnet_priv *priv = netdev_priv(dev);
+   struct ioq *ioq = priv-rxq.queue;
+
+   if (priv-connected) {
+   if (enable)
+   ioq_start(ioq, 0);
+   else
+   

[kvm-devel] [PATCH] KVM: Set the ET flag in CR0 after initializing FX

2007-08-24 Thread Amit Shah
This was missed when moving stuff around in fbc4f2e

Fixes Solaris guests and bug #1773613

Signed-off-by: Amit Shah [EMAIL PROTECTED]
---
 drivers/kvm/kvm_main.c |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/drivers/kvm/kvm_main.c b/drivers/kvm/kvm_main.c
index f7ff231..055d802 100644
--- a/drivers/kvm/kvm_main.c
+++ b/drivers/kvm/kvm_main.c
@@ -612,6 +612,7 @@ void fx_init(struct kvm_vcpu *vcpu)
fx_restore(vcpu-host_fx_image);
preempt_enable();

+   vcpu-cr0 |= X86_CR0_ET;
after_mxcsr_mask = offsetof(struct i387_fxsave_struct, st_space);
vcpu-guest_fx_image.mxcsr = 0x1f80;
memset((void *)vcpu-guest_fx_image + after_mxcsr_mask,

-
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/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


[kvm-devel] [PATCH 0/4] Hypercall additions

2007-08-24 Thread Dor Laor
The following patch set add some hypercall functionality:
- Improve/ease userspace hypercall handling
- Add hypercall functions for x86_64 and i386.
- Add registration mechanism so KVM kernel modules (additional to 
  what we have today) can register hypercall handlers.

The motivation is to allow PV drivers in KVM. The host side of these
drivers
will be optionaly in userspace or the kernel. I intend to implement
both.

-
In simplicity there is elegance.
Dor Laor ;)


-
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/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


[kvm-devel] [PATCH 1/4] [HYPERCALL] Add hypercalls functions

2007-08-24 Thread Dor Laor
The hypercalls can be called with various parameters number.
Both x86_64 and i386 are supported.

Signed-off-by: Dor Laor [EMAIL PROTECTED]
---
 include/asm-i386/hypercall.h   |  142

 include/asm-x86_64/hypercall.h |  105 +
 2 files changed, 247 insertions(+), 0 deletions(-)
 create mode 100644 include/asm-i386/hypercall.h
 create mode 100644 include/asm-x86_64/hypercall.h

diff --git a/include/asm-i386/hypercall.h b/include/asm-i386/hypercall.h
new file mode 100644
index 000..40fd31e
--- /dev/null
+++ b/include/asm-i386/hypercall.h
@@ -0,0 +1,142 @@
+#ifndef __ASM_HYPERCALL_H
+#define __ASM_HYPERCALL_H
+
+#define CONFIG_PARAVIRT 1
+#ifdef CONFIG_PARAVIRT
+
+/*
+ * Hypercalls, according to the calling convention
+ * documented in include/linux/kvm_para.h
+ *
+ * Copyright (C) 2007, Red Hat, Inc., Ingo Molnar [EMAIL PROTECTED]
+ * Copyright (C) 2007, Qumranet, Inc., Dor Laor [EMAIL PROTECTED]
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2.
See
+ * the COPYING file in the top-level directory.
+ */
+
+static inline int __hypercall0(unsigned int nr)
+{
+   int ret;
+   asm ( call hypercall_addr\n
+   : =a (ret)
+   : b (nr)
+   : memory, cc
+   );
+   return ret;
+}
+
+static inline int __hypercall1(unsigned int nr, unsigned long p1)
+{
+   int ret;
+   asm ( call hypercall_addr\n
+   : =a (ret)
+   : b (nr),
+ a (p1)
+   : memory, cc
+   );
+   return ret;
+}
+
+static inline int
+__hypercall2(unsigned int nr, unsigned long p1, unsigned long p2)
+{
+   int ret;
+   asm ( call hypercall_addr\n
+   : =a (ret)
+   : b (nr),
+ a (p1),
+ c (p2)
+   : memory, cc
+   );
+   return ret;
+}
+
+static inline int
+__hypercall3(unsigned int nr, unsigned long p1, unsigned long p2,
+unsigned long p3)
+{
+   int ret;
+   asm ( call hypercall_addr\n
+   : =a (ret)
+   : b (nr),
+ a (p1),
+ c (p2),
+ d (p3)
+   : memory, cc
+   );
+   return ret;
+}
+
+static inline int
+__hypercall4(unsigned int nr, unsigned long p1, unsigned long p2,
+unsigned long p3, unsigned long p4)
+{
+   int ret;
+   asm ( call hypercall_addr\n
+   : =a (ret)
+   : b (nr),
+ a (p1),
+ c (p2),
+ d (p3),
+ S (p4)
+   : memory, cc
+   );
+   return ret;
+}
+
+static inline int
+__hypercall5(unsigned int nr, unsigned long p1, unsigned long p2,
+unsigned long p3, unsigned long p4, unsigned long p5)
+{
+   int ret;
+   asm ( call hypercall_addr\n
+   : =a (ret)
+   : b (nr),
+ a (p1),
+ c (p2),
+ d (p3),
+ S (p4),
+ D (p5)
+   : memory, cc
+   );
+   return ret;
+}
+
+static inline int
+__hypercall6(unsigned int nr, unsigned long p1, unsigned long p2,
+unsigned long p3, unsigned long p4, unsigned long p5,
+unsigned long p6)
+{
+   int ret;
+   asm ( call hypercall_addr\n
+   : =a (ret)
+   : b (nr),
+ a (p1),
+ c (p2),
+ d (p3),
+ S (p4),
+ D (p5),
+ bp (p6)
+   : memory, cc
+   );
+   return ret;
+}
+
+#define hypercall(nr_params, args...)  \
+({ \
+   /* __ret is volatile to make sure call to this  \
+* function isn't optimized away by gcc. Just   \
+* having the __hypercallN() functions mention  \
+* memory is clobbered isn't enough \
+*/ \
+   volatile int __ret; \
+   \
+   __ret = __hypercall##nr_params(args);   \
+   \
+   __ret;  \
+})
+
+#endif /* CONFIG_PARAVIRT */
+
+#endif /* __ASM_HYPERCALL_H */
diff --git a/include/asm-x86_64/hypercall.h
b/include/asm-x86_64/hypercall.h
new file mode 100644
index 000..a331a9f
--- /dev/null
+++ b/include/asm-x86_64/hypercall.h
@@ -0,0 +1,105 @@
+#ifndef __ASM_HYPERCALL_H
+#define __ASM_HYPERCALL_H
+
+#define CONFIG_PARAVIRT 1
+#ifdef CONFIG_PARAVIRT
+
+/*
+ * Hypercalls, according to the calling convention
+ * documented in include/linux/kvm_para.h
+ *
+ * Copyright (C) 2007, Red Hat, Inc., Ingo Molnar [EMAIL PROTECTED]
+ * Copyright (C) 2007, Qumranet, Inc., Dor Laor [EMAIL PROTECTED]
+ *
+ * This work is licensed 

[kvm-devel] [PATCH 2/4] [HYPERCALL] Enable userspace too include kvm_para.

2007-08-24 Thread Dor Laor
Since some hypercalls can be handled in userspace, it needs
to include kvm_para too. Chande kernel types into user and
add includes for them and for page_size.

Signed-off-by: Dor Laor [EMAIL PROTECTED]
---
 include/linux/kvm_para.h |   13 -
 1 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/include/linux/kvm_para.h b/include/linux/kvm_para.h
index 3b29256..754e29d 100644
--- a/include/linux/kvm_para.h
+++ b/include/linux/kvm_para.h
@@ -8,6 +8,9 @@
  *   as we make progress.
  */
 
+#include asm/types.h
+#include asm/page.h
+
 /*
  * Per-VCPU descriptor area shared between guest and host. Writable to
  * both guest and host. Registered with the host by the guest when
@@ -25,17 +28,17 @@ struct kvm_vcpu_para_state {
 * is supposed to work - new host versions will support all old
 * guest API versions.
 */
-   u32 guest_version;
-   u32 host_version;
-   u32 size;
-   u32 ret;
+   __u32 guest_version;
+   __u32 host_version;
+   __u32 size;
+   __u32 ret;
 
/*
 * The address of the vm exit instruction (VMCALL or VMMCALL),
 * which the host will patch according to the CPU model the
 * VM runs on:
 */
-   u64 hypercall_gpa;
+   __u64 hypercall_gpa;
 
 } __attribute__ ((aligned(PAGE_SIZE)));


-
In simplicity there is elegance.
Dor Laor ;)


-
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/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


[kvm-devel] [PATCH 3/4] HYPERCALL] Update exit reason for vmcall

2007-08-24 Thread Dor Laor
It provides user space hypercall handling.
Also add cpl == 0 check for svm, htat unlike VT let software decide.

Signed-off-by: Dor Laor [EMAIL PROTECTED]
---
 drivers/kvm/kvm_main.c |2 ++
 drivers/kvm/svm.c  |5 +
 2 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/drivers/kvm/kvm_main.c b/drivers/kvm/kvm_main.c
index d154487..abd7498 100644
--- a/drivers/kvm/kvm_main.c
+++ b/drivers/kvm/kvm_main.c
@@ -1305,6 +1305,8 @@ int kvm_hypercall(struct kvm_vcpu *vcpu, struct
kvm_run *run)
run-hypercall.ret = ret;
run-hypercall.longmode = is_long_mode(vcpu);
kvm_arch_ops-decache_regs(vcpu);
+   run-exit_reason = KVM_EXIT_HYPERCALL;
+
return 0;
}
vcpu-regs[VCPU_REGS_RAX] = ret;
diff --git a/drivers/kvm/svm.c b/drivers/kvm/svm.c
index cc674bf..9bfd11e 100644
--- a/drivers/kvm/svm.c
+++ b/drivers/kvm/svm.c
@@ -1022,6 +1022,11 @@ static int halt_interception(struct vcpu_svm
*svm, struct kvm_run *kvm_run)
 
 static int vmmcall_interception(struct vcpu_svm *svm, struct kvm_run
*kvm_run)
 {
+   if (svm-vmcb-save.cpl != 0) {
+   inject_ud(svm-vcpu);
+   return 1;
+   }
+
svm-next_rip = svm-vmcb-save.rip + 3;
skip_emulated_instruction(svm-vcpu);
return kvm_hypercall(svm-vcpu, kvm_run);

-
In simplicity there is elegance.
Dor Laor ;)


-
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/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


[kvm-devel] [PATCH 4/4] [Hypercall] Allow modules registeration for hypercalls.

2007-08-24 Thread Dor Laor
New kernel modules for KVM are upcoming soon, these module
will need to use hypercalls. Before calling the hypercall function,
the kvm_main core module has to make sure it won't get unloaded.
So hypercall register/unregister are added.

Except that the kernel hypercalls handlers are numberes
0-KVM_NR_HYPERCALLS.
All the userspace handlers are above KVM_NR_HYPERCALLS.

Signed-off-by: Dor Laor [EMAIL PROTECTED]
---
 drivers/kvm/kvm.h|9 ++
 drivers/kvm/kvm_main.c   |  223
++
 include/linux/kvm_para.h |4 +-
 3 files changed, 197 insertions(+), 39 deletions(-)
 mode change 100644 = 100755 drivers/kvm/kvm_main.c

diff --git a/drivers/kvm/kvm.h b/drivers/kvm/kvm.h
index a42a6f3..37240cf 100644
--- a/drivers/kvm/kvm.h
+++ b/drivers/kvm/kvm.h
@@ -472,6 +472,12 @@ struct kvm_arch_ops {
unsigned char *hypercall_addr);
 };
 
+struct kvm_hypercall {
+   unsigned long (*hypercall)(struct kvm_vcpu*, unsigned long
args[]);
+   struct module *module;
+   int idx;
+};
+
 extern struct kvm_arch_ops *kvm_arch_ops;
 
 /* The guest did something we don't support. */
@@ -588,6 +594,9 @@ int kvm_mmu_load(struct kvm_vcpu *vcpu);
 void kvm_mmu_unload(struct kvm_vcpu *vcpu);
 
 int kvm_hypercall(struct kvm_vcpu *vcpu, struct kvm_run *run);
+int kvm_register_hypercall(struct module *module, struct kvm_hypercall
*hypercall);
+int kvm_unregister_hypercall(struct kvm_hypercall *hypercall);
+
 
 static inline int kvm_mmu_page_fault(struct kvm_vcpu *vcpu, gva_t gva,
 u32 error_code)
diff --git a/drivers/kvm/kvm_main.c b/drivers/kvm/kvm_main.c
old mode 100644
new mode 100755
index abd7498..051b47a
--- a/drivers/kvm/kvm_main.c
+++ b/drivers/kvm/kvm_main.c
@@ -20,6 +20,7 @@
 #include segment_descriptor.h
 
 #include linux/kvm.h
+#include linux/kvm_para.h
 #include linux/module.h
 #include linux/errno.h
 #include linux/percpu.h
@@ -84,6 +85,23 @@ static struct kvm_stats_debugfs_item {
 
 static struct dentry *debugfs_dir;
 
+static struct kvm_hypercall hypercalls[KVM_KERNEL_NR_HYPERCALLS];
+
+static int test_hypercall(struct kvm_vcpu *vcpu, unsigned long args[])
+{
+   printk(KERN_DEBUG %s: hypercall invoked\n, __FUNCTION__);
+
+   return 0;
+}
+
+static struct kvm_hypercall __hypercall_test = {
+   (unsigned long (*)(struct kvm_vcpu*, unsigned long
args[]))test_hypercall,
+   THIS_MODULE,
+   __NR_hypercall_test,
+};
+
+static atomic_t dev_kvm_open_count = ATOMIC_INIT(0);
+
 #define MAX_IO_MSRS 256
 
 #define CR0_RESERVED_BITS
\
@@ -302,6 +320,24 @@ static struct kvm *kvm_create_vm(void)
return kvm;
 }
 
+static int kvm_dev_open(struct inode *inode, struct file *filp)
+{
+   int ret = 0;
+
+   if (atomic_inc_return(dev_kvm_open_count) == 1) {
+   ret = kvm_register_hypercall(THIS_MODULE,
__hypercall_test);
+   if (ret  0) {
+   printk(KERN_DEBUG %s: kvm_register_hypercall
error, 
+  hypercall: %s\n,
+  __FUNCTION__, test);
+   goto out_test;
+   }
+   }
+
+out_test:
+   return ret;
+}
+
 /*
  * Free any memory in @free but not in @dont.
  */
@@ -371,6 +407,20 @@ static void kvm_free_vcpus(struct kvm *kvm)
 
 }
 
+static int kvm_dev_release(struct inode *inode, struct file *filp)
+{
+   int ret = 0;
+
+   atomic_dec(dev_kvm_open_count);
+   ret = kvm_unregister_hypercall(__hypercall_test);
+   if (ret  0) {
+   printk(KERN_DEBUG %s:kvm_unregister_hypercall error 
+  hypercall: %s\n, __FUNCTION__,
hypercall_test);
+   }
+
+   return ret;
+}
+
 static void kvm_destroy_vm(struct kvm *kvm)
 {
spin_lock(kvm_lock);
@@ -1267,50 +1317,145 @@ int kvm_emulate_halt(struct kvm_vcpu *vcpu)
 }
 EXPORT_SYMBOL_GPL(kvm_emulate_halt);
 
-int kvm_hypercall(struct kvm_vcpu *vcpu, struct kvm_run *run)
+int kvm_register_hypercall(struct module* module, struct kvm_hypercall
*hypercall)
 {
-   unsigned long nr, a0, a1, a2, a3, a4, a5, ret;
+   int r = 0;
 
-   kvm_arch_ops-cache_regs(vcpu);
-   ret = -KVM_EINVAL;
-#ifdef CONFIG_X86_64
-   if (is_long_mode(vcpu)) {
-   nr = vcpu-regs[VCPU_REGS_RAX];
-   a0 = vcpu-regs[VCPU_REGS_RDI];
-   a1 = vcpu-regs[VCPU_REGS_RSI];
-   a2 = vcpu-regs[VCPU_REGS_RDX];
-   a3 = vcpu-regs[VCPU_REGS_RCX];
-   a4 = vcpu-regs[VCPU_REGS_R8];
-   a5 = vcpu-regs[VCPU_REGS_R9];
-   } else
-#endif
-   {
+   if (hypercall-idx = KVM_KERNEL_NR_HYPERCALLS ||
+   hypercall-idx  0) {
+   printk(KERN_DEBUG %s:hypercall registration idx(%d)\n,
+__FUNCTION__, hypercall-idx);
+   return -EINVAL;
+   }
+
+   spin_lock(kvm_lock);
+
+   if (hypercalls[hypercall-idx].hypercall) {
+   

[kvm-devel] [RFC][PATCH 0/5] Enahnced virtio support for KVM - V1

2007-08-24 Thread Dor Laor
The following patch set implements KVM backend for VIRTIO.
the purpose is to have a set of net/block PV drivers for KVM, that
shares the main net/block logic with other hypervisors.

Addiotinal support for VIRTIO was added(partial state): Currently VIRTIO

implements the new/block logic, it can be extended to include the shared
memory part and the virtual bus too. Most of the code is based on
lguest.
This is a a first draft and others will come. Some work can also be
merged 
from Gregory's IOQ code. The important part is to try share as much as
code
as possible so we'll achieve best performance.

Currently a HVM guest with the network driver and userspace host support
performs 600Mbps. A block driver was written without a backend, will be
augmented
soon. Unloading the guest driver is not working yet.

Once the apic branch will be merge kernel host drivers will be added.
The intention is to have both userspace/kernel host backends (helps for
-no-kvm
and qemu too).

Comments are welcomed.

-
In simplicity there is elegance.
Dor Laor ;)


-
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/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


[kvm-devel] [RFC][PATCH 1/5] [VIRTIO] Add Rusty's virtio code

2007-08-24 Thread Dor Laor
Taken from his patch set.
Hope it will hit the kernel soon.

Signed-off-by: Dor Laor [EMAIL PROTECTED]
---
 drivers/block/Makefile |1 +
 drivers/block/virtio_blk.c |  254

 drivers/net/Makefile   |2 +-
 drivers/net/virtio_net.c   |  276

 include/linux/Kbuild   |1 +
 include/linux/virtio.h |   64 ++
 include/linux/virtio_blk.h |   45 +++
 include/linux/virtio_net.h |   15 +++
 8 files changed, 657 insertions(+), 1 deletions(-)
 create mode 100644 drivers/block/virtio_blk.c
 create mode 100644 drivers/net/virtio_net.c
 create mode 100644 include/linux/virtio.h
 create mode 100644 include/linux/virtio_blk.h
 create mode 100644 include/linux/virtio_net.h

diff --git a/drivers/block/Makefile b/drivers/block/Makefile
index 014e721..db8e677 100644
--- a/drivers/block/Makefile
+++ b/drivers/block/Makefile
@@ -25,6 +25,7 @@ obj-$(CONFIG_SUNVDC)  += sunvdc.o
 obj-$(CONFIG_BLK_DEV_UMEM) += umem.o
 obj-$(CONFIG_BLK_DEV_NBD)  += nbd.o
 obj-$(CONFIG_BLK_DEV_CRYPTOLOOP) += cryptoloop.o
+obj-y  += virtio_blk.o
 
 obj-$(CONFIG_VIODASD)  += viodasd.o
 obj-$(CONFIG_BLK_DEV_SX8)  += sx8.o
diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c
new file mode 100644
index 000..3993b24
--- /dev/null
+++ b/drivers/block/virtio_blk.c
@@ -0,0 +1,254 @@
+#define DEBUG
+#include linux/spinlock.h
+#include linux/blkdev.h
+#include linux/hdreg.h
+#include linux/virtio.h
+#include linux/virtio_blk.h
+
+static unsigned char virtblk_index = 'a';
+struct virtio_blk
+{
+   spinlock_t lock;
+
+   struct virtqueue *vq;
+
+   /* The disk structure for the kernel. */
+   struct gendisk *disk;
+
+   /* Request tracking. */
+   struct list_head reqs;
+
+   mempool_t *pool;
+
+   /* Scatterlist: can be too big for stack. */
+   struct scatterlist sg[3+MAX_PHYS_SEGMENTS];
+};
+
+struct virtblk_req
+{
+   struct list_head list;
+   struct request *req;
+   struct virtio_blk_outhdr out_hdr;
+   struct virtio_blk_inhdr in_hdr;
+};
+
+static void end_dequeued_request(struct request *req,
+request_queue_t *q, int uptodate)
+{
+   /* And so the insanity of the block layer infects us here. */
+   int nsectors = req-hard_nr_sectors;
+
+   if (blk_pc_request(req)) {
+   nsectors = (req-data_len + 511)  9;
+   if (!nsectors)
+   nsectors = 1;
+   }
+   if (end_that_request_first(req, uptodate, nsectors))
+   BUG();
+   add_disk_randomness(req-rq_disk);
+   end_that_request_last(req, uptodate);
+}
+
+static bool blk_done(struct virtqueue *vq)
+{
+   struct virtio_blk *vblk = vq-priv;
+   struct virtblk_req *vbr;
+   unsigned int len;
+   unsigned long flags;
+
+   spin_lock_irqsave(vblk-lock, flags);
+   while ((vbr = vq-ops-get_buf(vq, len)) != NULL) {
+   int uptodate;
+   switch (vbr-in_hdr.status) {
+   case VIRTIO_BLK_S_OK:
+   uptodate = 1;
+   break;
+   case VIRTIO_BLK_S_UNSUPP:
+   uptodate = -ENOTTY;
+   break;
+   default:
+   uptodate = 0;
+   break;
+   }
+
+   end_dequeued_request(vbr-req, vblk-disk-queue,
uptodate);
+   list_del(vbr-list);
+   mempool_free(vbr, vblk-pool);
+   }
+   /* In case queue is stopped waiting for more buffers. */
+   blk_start_queue(vblk-disk-queue);
+   spin_unlock_irqrestore(vblk-lock, flags);
+   return true;
+}
+
+static bool do_req(request_queue_t *q, struct virtio_blk *vblk,
+  struct request *req)
+{
+   unsigned long num, out_num, in_num;
+   struct virtblk_req *vbr;
+
+   vbr = mempool_alloc(vblk-pool, GFP_ATOMIC);
+   if (!vbr)
+   /* When another request finishes we'll try again. */
+   return false;
+
+   vbr-req = req;
+   if (blk_fs_request(vbr-req)) {
+   vbr-out_hdr.type = 0;
+   vbr-out_hdr.sector = vbr-req-sector;
+   vbr-out_hdr.ioprio = vbr-req-ioprio;
+   } else if (blk_pc_request(vbr-req)) {
+   vbr-out_hdr.type = VIRTIO_BLK_T_SCSI_CMD;
+   vbr-out_hdr.sector = 0;
+   vbr-out_hdr.ioprio = vbr-req-ioprio;
+   } else {
+   /* We don't put anything else in the queue. */
+   BUG();
+   }
+
+   if (blk_barrier_rq(vbr-req))
+   vbr-out_hdr.type |= VIRTIO_BLK_T_BARRIER;
+
+   vblk-sg[0].page = virt_to_page(vbr-out_hdr);
+   vblk-sg[0].offset = offset_in_page(vbr-out_hdr);
+   vblk-sg[0].length = sizeof(vbr-out_hdr);
+   num = blk_rq_map_sg(q, vbr-req, vblk-sg+1);
+   

[kvm-devel] [RFC][PATCH 2/5] [KVM paravirt registratio module] Add kvm para registration function

2007-08-24 Thread Dor Laor
The functions tries to register a hypercall page. It does so by msr
write.
The code should be shared by multiple paravirt device driver in the
guest.
The guest can be HVM - pv guest kernel is not a must.

Signed-off-by: Dor Laor [EMAIL PROTECTED]
---
 drivers/kvm/Kconfig  |6 +++
 drivers/kvm/Makefile |2 +
 drivers/kvm/kvm_pv.c |  101
++
 drivers/kvm/kvm_pv.h |   16 
 4 files changed, 125 insertions(+), 0 deletions(-)
 create mode 100644 drivers/kvm/kvm_pv.c
 create mode 100644 drivers/kvm/kvm_pv.h

diff --git a/drivers/kvm/Kconfig b/drivers/kvm/Kconfig
index 445c6e4..3cefd63 100644
--- a/drivers/kvm/Kconfig
+++ b/drivers/kvm/Kconfig
@@ -41,4 +41,10 @@ config KVM_AMD
  Provides support for KVM on AMD processors equipped with the
AMD-V
  (SVM) extensions.
 
+config KVM_PV
+   tristate KVM PV shared code from paravirtualized devices
+   depends on KVM
+   ---help---
+   Provides common code from paravirtualized device drivers in the
guest kernel.
+
 endif # VIRTUALIZATION
diff --git a/drivers/kvm/Makefile b/drivers/kvm/Makefile
index c0a789f..06c051e 100644
--- a/drivers/kvm/Makefile
+++ b/drivers/kvm/Makefile
@@ -8,3 +8,5 @@ kvm-intel-objs = vmx.o
 obj-$(CONFIG_KVM_INTEL) += kvm-intel.o
 kvm-amd-objs = svm.o
 obj-$(CONFIG_KVM_AMD) += kvm-amd.o
+kvm-pv-objs = kvm_pv.o
+obj-$(CONFIG_KVM_PV) += kvm-pv.o
diff --git a/drivers/kvm/kvm_pv.c b/drivers/kvm/kvm_pv.c
new file mode 100644
index 000..2417bfe
--- /dev/null
+++ b/drivers/kvm/kvm_pv.c
@@ -0,0 +1,101 @@
+/*
+ * KVM routines for paravitualization
+ *
+ * Copyright (C) 2007, Qumranet, Inc., Amit Shah
[EMAIL PROTECTED]
+ * Copyright (C) 2007, Red Hat, Inc., Ingo Molnar [EMAIL PROTECTED]
+ * Copyright (C) 2007, Qumranet, Inc., Dor Laor [EMAIL PROTECTED]
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2.
See
+ * the COPYING file in the top-level directory.
+ */
+
+#include kvm.h
+#include kvm_pv.h
+#include linux/kvm_para.h
+#include linux/kvm.h
+
+#include asm/hypercall.h
+#include linux/interrupt.h
+#include linux/kernel.h
+#include linux/module.h
+#include linux/percpu.h
+#include linux/init.h
+#include linux/version.h
+
+MODULE_DESCRIPTION(KVM paravirtual driver common routines);
+MODULE_LICENSE(GPL);
+
+/*
+ * This is the vm-syscall address - to be patched by the host to
+ * VMCALL (Intel) or VMMCALL (AMD), depending on the CPU model:
+ */
+asm (
+  .globl hypercall_addr   \n
+  .align 4\n
+  hypercall_addr: \n
+  movl $-38, %eax \n
+  ret \n
+);
+
+EXPORT_SYMBOL_GPL(hypercall_addr);
+
+#ifndef CONFIG_X86_64
+static DEFINE_PER_CPU(struct kvm_vcpu_para_state, para_state);
+#endif
+
+int kvm_guest_register_para(int cpu)
+{
+   struct page *hypercall_addr_page;
+   struct kvm_vcpu_para_state *para_state;
+   int ret;
+
+#ifdef CONFIG_X86_64
+   struct page *pstate_page;
+   if ((pstate_page = alloc_page(GFP_KERNEL)) == NULL)
+   return -ENOMEM;
+   para_state = (struct
kvm_vcpu_para_state*)page_address(pstate_page);
+#else
+   para_state =  per_cpu(para_state, cpu);
+#endif
+   /*
+   * Try to write to a magic MSR (which is invalid on any real
CPU),
+   * and thus signal to KVM that we wish to entering
para-virtualized
+   * mode:
+   */
+   para_state-guest_version = KVM_PARA_API_VERSION;
+   para_state-host_version = -1;
+   para_state-size = sizeof(*para_state);
+   para_state-ret = -1;
+
+   hypercall_addr_page = vmalloc_to_page(hypercall_addr);
+   para_state-hypercall_gpa = page_to_pfn(hypercall_addr_page) 
PAGE_SHIFT | 
+   offset_in_page(hypercall_addr);
+   printk(KERN_DEBUG kvm guest: hypercall gpa is 0x%lx\n,
(long)para_state-hypercall_gpa);
+
+   if (wrmsr_safe(MSR_KVM_API_MAGIC, __pa(para_state), 0)) {
+   printk(KERN_INFO KVM guest: WRMSR probe failed.\n);
+   ret = -1;
+   goto out_free;
+   }
+
+   printk(KERN_DEBUG kvm guest: host returned %d\n,
para_state-ret);
+   printk(KERN_DEBUG kvm guest: host version: %d\n,
para_state-host_version);
+   printk(KERN_DEBUG kvm guest: syscall entry: %02x %02x %02x
%02x\n,
+  hypercall_addr[0], hypercall_addr[1],
+  hypercall_addr[2], hypercall_addr[3]);
+
+   if (para_state-ret) {
+   printk(KERN_ERR kvm guest: host refused
registration.\n);
+   ret = -1;
+   goto out_free;
+   }
+
+   ret = 0;
+
+out_free:
+#ifdef CONFIG_X86_64
+   __free_page(pstate_page);
+#endif
+   return ret;
+}
+EXPORT_SYMBOL_GPL(kvm_guest_register_para);
diff --git a/drivers/kvm/kvm_pv.h b/drivers/kvm/kvm_pv.h
new file mode 100644
index 000..54718e4
--- /dev/null
+++ 

[kvm-devel] [RFC][PATCH 4/5] [KVM VIRTIO] A pci shared code for pv devices

2007-08-24 Thread Dor Laor
PV devices are currently discovered by pci bus.
It is standard bus for x86 and good for HVM guests.
Further flexibility will be achieved by a virtual bus, although
some HVM guest will still require pci.

Signed-off-by: Dor Laor [EMAIL PROTECTED]
---
 drivers/kvm/Makefile  |2 +-
 drivers/kvm/kvm_pci_bus.c |  158
+
 2 files changed, 159 insertions(+), 1 deletions(-)
 create mode 100644 drivers/kvm/kvm_pci_bus.c

diff --git a/drivers/kvm/Makefile b/drivers/kvm/Makefile
index 7f5607d..e51dba4 100644
--- a/drivers/kvm/Makefile
+++ b/drivers/kvm/Makefile
@@ -8,7 +8,7 @@ kvm-intel-objs = vmx.o
 obj-$(CONFIG_KVM_INTEL) += kvm-intel.o
 kvm-amd-objs = svm.o
 obj-$(CONFIG_KVM_AMD) += kvm-amd.o
-kvm-pv-objs = kvm_pv.o
+kvm-pv-objs = kvm_pv.o kvm_pci_bus.o
 obj-$(CONFIG_KVM_PV) += kvm-pv.o
 virtio-be-objs = virtio_backend.o
 obj-$(CONFIG_VIRTIO_BE) += virtio-be.o
diff --git a/drivers/kvm/kvm_pci_bus.c b/drivers/kvm/kvm_pci_bus.c
new file mode 100644
index 000..c06771e
--- /dev/null
+++ b/drivers/kvm/kvm_pci_bus.c
@@ -0,0 +1,158 @@
+/*
+ * KVM virtio pci bus backend implementation
+ *
+ * Copyright (C) 2007, Qumranet, Inc., Dor Laor [EMAIL PROTECTED]
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2.
See
+ * the COPYING file in the top-level directory.
+ */
+
+//#define DEBUG
+#include linux/virtio.h
+#include linux/spinlock.h
+#include linux/kvm.h
+#include linux/kvm_para.h
+#include linux/pci.h
+#include linux/init.h
+#include linux/ioport.h
+#include linux/interrupt.h
+#include asm/hypercall.h
+#include asm/io.h
+#include kvm_pv.h
+#include virtio_backend.h
+
+static int debug = 3;
+module_param(debug, int, 0);
+MODULE_PARM_DESC(debug, Debug level (0=none,...,16=all));
+
+#define DPRINTK(klevel, fmt, args...) \
+   if (('0' + debug) = (int)(klevel[1])) \
+   printk(klevel %s:%d:  fmt, \
+   __FUNCTION__, __LINE__, ## args)
+
+/*
+ * Map between a pci device to it's dma key.
+ * It uses io port read to read the key value from the 
+ * pci device.
+ */
+static int get_device_key(struct pci_dev *pdev, unsigned int *key)
+{
+unsigned long ioaddr;
+int rc;
+unsigned long pio_start, pio_end, pio_flags, pio_len;
+
+rc = pci_enable_device(pdev);
+if (rc)
+goto err_out;
+
+pio_start = pci_resource_start (pdev, 0);
+pio_end = pci_resource_end (pdev, 0);
+pio_flags = pci_resource_flags (pdev, 0);
+pio_len = pci_resource_len (pdev, 0);
+
+DPRINTK(KERN_DEBUG, PIO region size == 0x%lx\n, pio_len);
+
+rc = pci_request_regions (pdev, kvm_virtio);
+if (rc) {
+   DPRINTK(KERN_DEBUG, Failed register pci region\n);
+goto err_out;
+   }
+
+ioaddr = (unsigned long)pci_iomap(pdev, 0, 0);
+if (!ioaddr) {
+printk(KERN_ERR %s: cannot map PIO, aborting\n,
pci_name(pdev));
+rc = -EIO;
+goto err_out;
+}
+
+   DPRINTK(KERN_DEBUG, ioaddr is %lx\n, ioaddr);
+   *key = ioread32((void __iomem*)ioaddr);
+   DPRINTK(KERN_DEBUG, Got key = %d\n, *key);
+   *key = 0;
+
+err_out:
+return rc;
+}
+
+/*
+ * General pci init function
+ */
+int kvmbus_init_one(struct pci_dev *pdev,
+   const struct pci_device_id *ent,
+   struct virtio_bus *vbus,
+   u16 dev_type)
+{
+   struct virtio_device *vdev;
+   u8 pci_rev;
+   int rs;
+
+   vdev = kzalloc(sizeof(*vdev), GFP_KERNEL);
+   if (vdev  0) {
+   DPRINTK(KERN_ERR, failed allocating virtio_device);
+   return ENOMEM;
+   }
+
+   pci_set_drvdata(pdev, vdev);
+
+   if ((rs = kvm_guest_register_para(raw_smp_processor_id())) != 0)
{
+   DPRINTK(KERN_ERR, failed registering para\n);
+   goto out_unreg_para;
+   }
+
+   DPRINTK(KERN_DEBUG, irq is %d\n, pdev-irq);
+
+   pci_read_config_byte(pdev, PCI_REVISION_ID, pci_rev);
+
+   DPRINTK(KERN_INFO, pci dev %s (id %04x:%04x rev %02x) is a 
+   guest paravirt %s device\n,
+   pci_name(pdev), pdev-vendor, pdev-device, pci_rev,
vbus-name);
+
+   vdev-dev.bus = pdev-dev.bus;
+   vdev-dev.parent = pdev-dev;
+   sprintf(vdev-dev.bus_id, %u, 0);
+   device_initialize(vdev-dev);
+   if (device_register(vdev-dev) != 0) {
+   DPRINTK(KERN_EMERG, Cannot register device\n);
+   goto out_unreg_para;
+   }
+
+   if (get_device_key(pdev, vdev-id)  0) {
+   DPRINTK(KERN_ERR, pci dev %s cannot use ioports\n,
pci_name(pdev));
+   goto out_unreg_para;
+   }
+DPRINTK(KERN_DEBUG, Got key = %x\n, vdev-id);
+
+   vdev-desc.irq = pdev-irq;
+   vdev-desc.type = dev_type;
+   vdev-desc.status = VIRTIO_DEVICE_S_DRIVER;
+
+
+   rs = vbus-vbus_probe(vdev);
+   if (vdev  0) {
+ 

[kvm-devel] [RFC][PATCH 5/5] [KVM VIRTIO] Add network block backends for kvm.

2007-08-24 Thread Dor Laor
Add network code (tested, 600Mbps for HVM guest) and block code
(untested).
It uses the kvm_pci_bus and virtio backend mechanisems, making the
driver
minimal.

Signed-off-by: Dor Laor [EMAIL PROTECTED]
---
 drivers/kvm/Kconfig   |   12 +++
 drivers/kvm/Makefile  |5 +
 drivers/kvm/kvm_blk_backend.c |  162 +
 drivers/kvm/kvm_net_backend.c |  197
+
 include/linux/kvm_para.h  |1 +
 5 files changed, 377 insertions(+), 0 deletions(-)
 create mode 100644 drivers/kvm/kvm_blk_backend.c
 create mode 100644 drivers/kvm/kvm_net_backend.c

diff --git a/drivers/kvm/Kconfig b/drivers/kvm/Kconfig
index a4de4de..67e7868 100644
--- a/drivers/kvm/Kconfig
+++ b/drivers/kvm/Kconfig
@@ -53,4 +53,16 @@ config VIRTIO_BE
---help---
Paravirtual virtio backend greatly improves performance.
 
+config KVM_NET
+   tristate KVM paravirtual network driver
+   depends on KVM_PV  VIRTIO_BE
+   ---help---
+   Paravirtual network greatly improves performance.
+
+config KVM_BLK
+   tristate KVM paravirtual block driver
+   depends on KVM_PV  VIRTIO_BE
+   ---help---
+   Paravirtual block device greatly improves performance.
+
 endif # VIRTUALIZATION
diff --git a/drivers/kvm/Makefile b/drivers/kvm/Makefile
index e51dba4..cfb2fcd 100644
--- a/drivers/kvm/Makefile
+++ b/drivers/kvm/Makefile
@@ -12,3 +12,8 @@ kvm-pv-objs = kvm_pv.o kvm_pci_bus.o
 obj-$(CONFIG_KVM_PV) += kvm-pv.o
 virtio-be-objs = virtio_backend.o
 obj-$(CONFIG_VIRTIO_BE) += virtio-be.o
+kvm-net-objs = kvm_net_backend.o
+obj-$(CONFIG_KVM_NET) += kvm-net.o
+kvm-blk-objs = kvm_blk_backend.o
+obj-$(CONFIG_KVM_BLK) += kvm-blk.o
+
diff --git a/drivers/kvm/kvm_blk_backend.c
b/drivers/kvm/kvm_blk_backend.c
new file mode 100644
index 000..0165037
--- /dev/null
+++ b/drivers/kvm/kvm_blk_backend.c
@@ -0,0 +1,162 @@
+/*
+ * KVM virtio block device backend implementation
+ *
+ * Copyright (C) 2007, Qumranet, Inc., Dor Laor [EMAIL PROTECTED]
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2.
See
+ * the COPYING file in the top-level directory.
+ */
+
+//#define DEBUG
+#include linux/etherdevice.h
+#include linux/skbuff.h
+#include linux/virtio.h
+#include linux/virtio_blk.h
+#include linux/genhd.h
+#include linux/blkdev.h
+#include linux/spinlock.h
+#include linux/kvm.h
+#include linux/kvm_para.h
+#include linux/pci.h
+#include linux/init.h
+#include linux/ioport.h
+#include linux/interrupt.h
+#include asm/hypercall.h
+#include asm/io.h
+#include kvm_pv.h
+#include virtio_backend.h
+
+static int debug = 3;
+module_param(debug, int, 0);
+MODULE_PARM_DESC(debug, Debug level (0=none,...,16=all));
+
+#define DPRINTK(klevel, fmt, args...) \
+   if (('0' + debug) = (int)(klevel[1])) \
+   printk(klevel %s:%d:  fmt, \
+   __FUNCTION__, __LINE__, ## args)
+
+static int kvm_virtblk_probe(struct virtio_device *vdev)
+{
+   struct be_virtqueue* bvq;
+   struct gendisk *disk;
+   unsigned long sectors;
+   int err, irqf;
+
+   bvq = be_new_virtqueue(vdev);
+   if (!bvq)
+   return -ENOMEM;
+
+   bvq-io_type = VIRTIO_DEVICE_INPUT | VIRTIO_DEVICE_OUTPUT;
+
+   /* Page is initially used to pass capacity. */
+   sectors = *(unsigned long *)bvq-d;
+   *(unsigned long *)bvq-d = 0;
+
+   vdev-private = disk = virtblk_probe(bvq-vq);
+   if (IS_ERR(disk)) {
+   err = PTR_ERR(disk);
+   goto destroy;
+   }
+   set_capacity(disk, sectors);
+   blk_queue_max_hw_segments(disk-queue, NUM_DESCS-1);
+
+   //if
(virtio_devices[vdev-index].featuresVIRTIO_DEVICE_F_RANDOMNESS)
+   irqf = IRQF_SAMPLE_RANDOM;
+   //else
+   //  irqf = 0;
+
+   err = request_irq(vdev-desc.irq, be_virtqueue_interrupt, irqf,
+ disk-disk_name, bvq);
+   if (err)
+   goto unprobe;
+
+   err = hypercall(3, __NR_hypercall_register,
+   vdev-id,
+   virt_to_phys(bvq-d)  PAGE_SHIFT,
+   0);
+   if (err  0) {
+   DPRINTK(KERN_ERR, hypercall returned %d\n, err);
+   goto unprobe;
+   }
+
+   add_disk(disk);
+   vdev-private = disk;
+   vdev-be_queues = bvq;
+
+   return 0;
+
+unprobe:
+   virtblk_remove(disk);
+destroy:
+   be_destroy_virtqueue(bvq);
+
+   return err;
+}
+
+static int kvm_virtblk_unprobe(struct virtio_device *kdev)
+{
+   struct gendisk *disk = kdev-private;
+   struct be_virtqueue* bvq = kdev-be_queues;
+
+   if (disk)
+   virtblk_remove(disk);
+
+   if (bvq)
+   be_destroy_virtqueue(bvq);
+
+   synchronize_irq(kdev-desc.irq);
+   free_irq(kdev-desc.irq, disk);
+
+   return 0;
+}
+
+static struct virtio_bus kvmblk_probes = {
+   .vbus_probe = kvm_virtblk_probe,
+   .vbus_unprobe = 

[kvm-devel] [RFC][PATCH 0/6] userspace/qemu support for KVM VIRTIO

2007-08-24 Thread Dor Laor
This is the userspace backend for the PV drivers.
Only dma (based on lguest) and network are implemented.
Actually the qemu is ugly since some of the mechanisms were missing
and I wanted it to work quick. It will improve later on in the next
releases.

Again, comments are welcome.

-
In simplicity there is elegance.
Dor Laor ;)


-
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/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


[kvm-devel] [RFC][PATCH 1/6] [KVM PV DEV] Add edge pci irq hack

2007-08-24 Thread Dor Laor
Regular pci irq is level triggered, thus must be acked by port io/
mmio. For PV devices it's a bad idea since it will trigger a costly
VM exit.

This hack add ability to trigger pic/apic irqs.

Signed-off-by: Dor Laor [EMAIL PROTECTED]
---
 qemu/hw/apic.c  |   10 ++
 qemu/hw/i8259.c |   19 +++
 2 files changed, 29 insertions(+), 0 deletions(-)

diff --git a/qemu/hw/apic.c b/qemu/hw/apic.c
index dc92f8a..76fc3b9 100644
--- a/qemu/hw/apic.c
+++ b/qemu/hw/apic.c
@@ -948,6 +948,16 @@ void ioapic_set_irq(void *opaque, int vector, int
level)
 }
 }
 
+void ioapic_mark_as_edge_triggered(void *opaque, int vector)
+{
+   IOAPICState *s = opaque;
+
+   if (vector = 0  vector  IOAPIC_NUM_PINS)
+   {
+   s-ioredtbl[vector] = ~(1  15);
+   }
+}
+
 static uint32_t ioapic_mem_readl(void *opaque, target_phys_addr_t addr)
 {
 IOAPICState *s = opaque;
diff --git a/qemu/hw/i8259.c b/qemu/hw/i8259.c
index a2a8187..ace67c6 100644
--- a/qemu/hw/i8259.c
+++ b/qemu/hw/i8259.c
@@ -93,6 +93,25 @@ static inline void pic_set_irq1(PicState *s, int irq,
int level)
 }
 }
 
+void paravirt_set_irq(int irq)
+{
+PicState *s = isa_pic-pics[irq  3];
+int mask = 1  (7  irq);
+
+/* Force it to be edge triggered */
+s-elcr = ~mask;
+   s-irr |= mask;
+
+if (isa_pic-alt_irq_func  isa_pic-alt_irq_opaque)
+   {
+   /* Force it to be edge triggered */
+   ioapic_mark_as_edge_triggered(isa_pic-alt_irq_opaque,
irq);
+   isa_pic-alt_irq_func(isa_pic-alt_irq_opaque, irq, 1);
+   }
+
+pic_update_irq(isa_pic);
+}
+
 /* return the highest priority found in mask (highest = smallest
number). Return 8 if no irq */
 static inline int get_priority(PicState *s, int mask)

-
In simplicity there is elegance.
Dor Laor ;)


-
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/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


[kvm-devel] [RFC][PATCH 3/6] [KVM VIRTIO] Add the userspace hypercall handlers for virtio.

2007-08-24 Thread Dor Laor
Add the register and notify hypercalls handlers.
The register hypercall turns the guests pfn into the mapped memory
address.

Signed-off-by: Dor Laor [EMAIL PROTECTED]
---
 user/kvmctl.c |   41 +
 user/kvmctl.h |4 
 2 files changed, 45 insertions(+), 0 deletions(-)

diff --git a/user/kvmctl.c b/user/kvmctl.c
index 846aac9..831774f 100644
--- a/user/kvmctl.c
+++ b/user/kvmctl.c
@@ -19,6 +19,7 @@
 #endif
 
 #include linux/kvm.h
+#include linux/kvm_para.h
 
 #define EXPECTED_KVM_API_VERSION 12
 
@@ -846,6 +847,44 @@ static int handle_shutdown(kvm_context_t kvm, int
vcpu)
return kvm-callbacks-shutdown(kvm-opaque, vcpu);
 }
 
+static int handle_pv_notify(kvm_context_t kvm, unsigned long key,
unsigned long iotype)
+{
+   return kvm-callbacks-pv_notify(key, iotype);
+}
+
+static int handle_pv_register(kvm_context_t kvm, unsigned long key,
unsigned long out_pfn, unsigned long in_pfn)
+{
+   return kvm-callbacks-pv_register(kvm-physical_memory, key,
+   (unsigned long)kvm-physical_memory +
(out_pfn*getpagesize()),
+   (unsigned long)kvm-physical_memory +
(in_pfn*getpagesize()));
+}
+
+static int handle_hypercall(kvm_context_t kvm, struct kvm_run *kvm_run,
+  int vcpu)
+{
+   int r = 0;
+
+   switch(kvm-run[vcpu]-hypercall.nr) {
+   case __NR_hypercall_register:
+   kvm-run[vcpu]-hypercall.ret = handle_pv_register(kvm,
+
kvm-run[vcpu]-hypercall.args[0],
+
kvm-run[vcpu]-hypercall.args[1],
+
kvm-run[vcpu]-hypercall.args[2]);
+   break;
+   case __NR_hypercall_notify:
+   kvm-run[vcpu]-hypercall.ret = handle_pv_notify(kvm,
+   kvm-run[vcpu]-hypercall.args[0],
+   kvm-run[vcpu]-hypercall.args[1]);
+   break;
+   default:
+   fprintf(stderr, %s:no such nr=%llx hypercall
handling\n,
+   __FUNCTION__, kvm-run[vcpu]-hypercall.nr);
+   kvm-run[vcpu]-hypercall.ret = -EINVAL;
+   }
+
+   return r;
+}
+
 int try_push_interrupts(kvm_context_t kvm)
 {
return kvm-callbacks-try_push_interrupts(kvm-opaque);
@@ -1043,6 +1082,8 @@ again:
case KVM_EXIT_SHUTDOWN:
r = handle_shutdown(kvm, vcpu);
break;
+   case KVM_EXIT_HYPERCALL:
+   r = handle_hypercall(kvm, run, vcpu);
case KVM_EXIT_SET_TPR:
break;
default:
diff --git a/user/kvmctl.h b/user/kvmctl.h
index ff0bca6..09f40f4 100644
--- a/user/kvmctl.h
+++ b/user/kvmctl.h
@@ -66,6 +66,10 @@ struct kvm_callbacks {
 int (*try_push_interrupts)(void *opaque);
 void (*post_kvm_run)(void *opaque, int vcpu);
 int (*pre_kvm_run)(void *opaque, int vcpu);
+
+   // pv device callbacks
+int (*pv_register)(unsigned long memstart, unsigned long key,
unsigned long out, unsigned long in);
+int (*pv_notify)(unsigned long key, unsigned long iotype);
 };
 
 /*!

-
In simplicity there is elegance.
Dor Laor ;)


-
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/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


[kvm-devel] [RFC][PATCH 4/6] [KVM VIRTIO] Add module compilation for kvm virtio code.

2007-08-24 Thread Dor Laor
Signed-off-by: Dor Laor [EMAIL PROTECTED]
---
 kernel/Kbuild   |6 +-
 kernel/Makefile |1 +
 2 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/kernel/Kbuild b/kernel/Kbuild
index e97209f..0dbda35 100644
--- a/kernel/Kbuild
+++ b/kernel/Kbuild
@@ -1,5 +1,9 @@
 EXTRA_CFLAGS := -I$(src)/include -include
$(src)/external-module-compat.h
-obj-m := kvm.o kvm-intel.o kvm-amd.o
+obj-m := kvm.o kvm-intel.o kvm-amd.o kvm-pv.o virtio-be.o kvm-net.o
kvm-blk.o
 kvm-objs := kvm_main.o mmu.o x86_emulate.o anon_inodes.o preempt.o
 kvm-intel-objs := vmx.o vmx-debug.o
 kvm-amd-objs := svm.o
+kvm-pv-objs = kvm_pv.o kvm_pci_bus.o
+virtio-be-objs = virtio_backend.o
+kvm-net-objs = kvm_net_backend.o
+kvm-blk-objs = kvm_blk_backend.o
diff --git a/kernel/Makefile b/kernel/Makefile
index 28078eb..f442efd 100644
--- a/kernel/Makefile
+++ b/kernel/Makefile
@@ -25,6 +25,7 @@ sync:
rsync --exclude='*.mod.c' $(LINUX)/drivers/kvm/*.[ch] .
rsync $(LINUX)/include/linux/kvm.h \
   $(LINUX)/include/linux/kvm_para.h \
+  $(LINUX)/include/linux/virtio_be.h \
include/linux
$(call hack, kvm_main.c)
$(call hack, mmu.c)

-
In simplicity there is elegance.
Dor Laor ;)


-
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/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


[kvm-devel] [RFC][PATCH 5/6][KVM VIRTIO] Add the network device code

2007-08-24 Thread Dor Laor
This is the pci device side in qemu. It just used as
a glue between the pci, tap and virtio code.

Signed-off-by: Dor Laor [EMAIL PROTECTED]
---
 qemu/hw/paravirt_net.c |  213

 1 files changed, 213 insertions(+), 0 deletions(-)
 create mode 100644 qemu/hw/paravirt_net.c

diff --git a/qemu/hw/paravirt_net.c b/qemu/hw/paravirt_net.c
new file mode 100644
index 000..fdf2f1c
--- /dev/null
+++ b/qemu/hw/paravirt_net.c
@@ -0,0 +1,213 @@
+/*
+ * QEMU para virtual network emulation
+ * 
+ * Copyright (c) 2007 Qumranet
+ *
+ * Permission is hereby granted, free of charge, to any person
obtaining a copy
+ * of this software and associated documentation files (the
Software), to deal
+ * in the Software without restriction, including without limitation
the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or
sell
+ * copies of the Software, and to permit persons to whom the Software
is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN
+ * THE SOFTWARE.
+ */
+#include vl.h
+#include virtio.h
+#include qemu-kvm.h
+
+#define DEBUG_PARANET
+
+typedef struct PARANETState {
+uint8_t macaddr[6];
+uint8_t mult[8]; /* multicast mask array */
+PCIDevice *pci_dev;
+VLANClientState *vc;
+struct virtio_device * vdev;
+int tap_fd;
+} PARANETState;
+
+#define MAX_PARANET_DEVICES 1
+static int used_devices = 0;
+static PARANETState *paranet_devs[MAX_PARANET_DEVICES];
+
+static void paranet_reset(void *opaque)
+{
+}
+
+volatile int kvm_pvnet_pending_irq = 0;
+
+void paranet_update_irq(void *opaque)
+{
+PARANETState *s = opaque;
+
+paravirt_set_irq(s-pci_dev-config[0x3c]);
+
+return;
+}
+
+void paravirt_net_poll(void)
+{
+int i;
+
+for (i=0; iused_devices;i++) {
+paranet_devs[i]-vdev-handle_input(paranet_devs[i]-vdev);
+}
+}
+
+static int paranet_receive(void *opaque, const uint8_t *buf, int len)
+{
+   printf(PARANET:paravirt_receive\n);
+   return 0;
+}
+static int paranet_can_receive(void *opaque)
+{
+return 0;
+}
+
+static void paranet_ioport_write(void *opaque, uint32_t addr, uint32_t
val)
+{
+addr = 0xf;
+#ifdef DEBUG_PARANET
+printf(PARANET: write addr=0x%x val=0x%02x\n, addr, val);
+#endif
+
+switch (addr) {
+default:
+printf(%s: BUG\n, __FUNCTION__);
+break;
+}
+}
+
+static uint32_t paranet_ioport_read(void *opaque, uint32_t addr)
+{
+PARANETState* s=(PARANETState*)opaque;
+uint32_t val = 0;
+addr = 0xf;
+
+switch (addr) {
+   case 0:
+   val = 0;
+default:
+printf(%s: BUG\n, __FUNCTION__);
+break;
+}
+
+#ifdef DEBUG_PARANET
+printf(PARANET: read addr=0x%x, val=%x\n, addr, val);
+#endif
+return val;
+}
+
+static void paranet_save(QEMUFile* f,void* opaque)
+{
+PARANETState* s=(PARANETState*)opaque;
+
+if (s-pci_dev)
+pci_device_save(s-pci_dev, f);
+
+qemu_put_buffer(f, s-macaddr, 6);
+qemu_put_buffer(f, s-mult, 8);
+}
+
+static int paranet_load(QEMUFile* f,void* opaque,int version_id)
+{
+PARANETState* s=(PARANETState*)opaque;
+int ret = 0;
+
+if (s-pci_dev) {
+ret = pci_device_load(s-pci_dev, f);
+if (ret  0)
+   return ret;
+}
+
+qemu_get_buffer(f, s-macaddr, 6);
+qemu_get_buffer(f, s-mult, 8);
+
+return ret;
+}
+
+/***/
+/* PCI PARANET definitions */
+
+typedef struct PCIPARANETState {
+PCIDevice dev;
+PARANETState PARANET;
+} PCIPARANETState;
+
+static void paranet_map(PCIDevice *pci_dev, int region_num, 
+   uint32_t addr, uint32_t size, int type)
+{
+PCIPARANETState *d = (PCIPARANETState *)pci_dev;
+PARANETState *s = d-PARANET;
+
+register_ioport_write(addr, 16, 1, paranet_ioport_write, s);
+register_ioport_read(addr, 16, 1, paranet_ioport_read, s);
+}
+
+void pci_paranet_init(PCIBus *bus, NICInfo *nd, int devfn)
+{
+PCIPARANETState *d;
+PARANETState *s;
+uint8_t *pci_conf;
+
+printf(PARANET: pci_paranet_init start\n);
+
+virtio_init();
+
+d = (PCIPARANETState *)pci_register_device(bus,
+  PARANET,
sizeof(PCIPARANETState),
+  devfn, 
+  NULL, NULL);

[kvm-devel] [RFC][PATCH 6/6] [KVM VIRTIO] Tie the knots together.

2007-08-24 Thread Dor Laor
Except for compile stuff there are to interesting things:
1. Call paravirt_net_poll on the main_loop_wait so the tap
   can be polled for incoming packets for virtio.
2. Ugly hack (that won't stay forever) to ignore virtio tap fd
   for regular qemu handlers.

Signed-off-by: Dor Laor [EMAIL PROTECTED]
---
 qemu/Makefile.target |5 -
 qemu/hw/pci.c|2 ++
 qemu/qemu-kvm.c  |   19 ++-
 qemu/vl.c|   26 +-
 qemu/vl.h|7 +++
 5 files changed, 56 insertions(+), 3 deletions(-)

diff --git a/qemu/Makefile.target b/qemu/Makefile.target
index aeee2af..7fee36e 100644
--- a/qemu/Makefile.target
+++ b/qemu/Makefile.target
@@ -371,8 +371,11 @@ VL_OBJS+= scsi-disk.o cdrom.o lsi53c895a.o
 # USB layer
 VL_OBJS+= usb.o usb-hub.o usb-linux.o usb-hid.o usb-ohci.o usb-msd.o
 
+# VIRTIO layer
+VL_OBJS += virtio.o
+
 # PCI network cards
-VL_OBJS+= ne2000.o rtl8139.o pcnet.o
+VL_OBJS+= ne2000.o rtl8139.o pcnet.o paravirt_net.o
 
 # PCI Hypercall
 VL_OBJS+= hypercall.o
diff --git a/qemu/hw/pci.c b/qemu/hw/pci.c
index b895f98..94d1208 100644
--- a/qemu/hw/pci.c
+++ b/qemu/hw/pci.c
@@ -552,6 +552,8 @@ void pci_nic_init(PCIBus *bus, NICInfo *nd, int
devfn)
 pci_rtl8139_init(bus, nd, devfn);
 } else if (strcmp(nd-model, pcnet) == 0) {
 pci_pcnet_init(bus, nd, devfn);
+} else if (strcmp(nd-model, pv) == 0) {
+pci_paranet_init(bus, nd, devfn);
 } else {
 fprintf(stderr, qemu: Unsupported NIC: %s\n, nd-model);
 exit (1);
diff --git a/qemu/qemu-kvm.c b/qemu/qemu-kvm.c
index 491c32c..d330f41 100644
--- a/qemu/qemu-kvm.c
+++ b/qemu/qemu-kvm.c
@@ -15,7 +15,7 @@ static int lm_capable_kernel;
 
 #include string.h
 #include vl.h
-
+#include virtio.h
 #include qemu-kvm.h
 #include kvmctl.h
 #include pthread.h
@@ -953,6 +953,21 @@ static int kvm_shutdown(void *opaque, int vcpu)
 qemu_system_reset_request();
 return 1;
 }
+
+static int kvm_pv_register(unsigned long memstart, unsigned long key,
+  unsigned long out, unsigned long in)
+{
+   virtio_register_mem(memstart, key, out, in);
+   printf(%s:registered, memstart=%lx, in addr %lx, out addr
%lx\n,
+   __FUNCTION__, memstart, in, out);
+   return 0;
+}
+
+static int kvm_pv_notify(unsigned long key, unsigned long iotype)
+{
+   handle_notify(key, iotype);
+   return 0;
+}
  
 static struct kvm_callbacks qemu_kvm_ops = {
 .debug = kvm_debug,
@@ -976,6 +991,8 @@ static struct kvm_callbacks qemu_kvm_ops = {
 .try_push_interrupts = try_push_interrupts,
 .post_kvm_run = post_kvm_run,
 .pre_kvm_run = pre_kvm_run,
+.pv_register = kvm_pv_register,
+.pv_notify = kvm_pv_notify,
 };
 
 int kvm_qemu_init()
diff --git a/qemu/vl.c b/qemu/vl.c
index fcc899b..42d3e8e 100644
--- a/qemu/vl.c
+++ b/qemu/vl.c
@@ -3191,6 +3191,21 @@ typedef struct TAPState {
 int fd;
 } TAPState;
 
+
+static int fd_unset_tap = -1;
+
+int get_tap_fd(void *opaque)
+{
+TAPState *s = opaque;
+
+if (s) {
+   printf(fd_unset_tap = %d\n, s-fd);
+   fd_unset_tap = s-fd;
+   return s-fd;
+}
+return -1;
+}
+
 static void tap_receive(void *opaque, const uint8_t *buf, int size)
 {
 TAPState *s = opaque;
@@ -3204,6 +3219,12 @@ static void tap_receive(void *opaque, const
uint8_t *buf, int size)
 }
 }
 
+static int tap_read_poll(void *opaque)
+{
+   TAPState *s = opaque;
+return (s-fd != fd_unset_tap);
+}
+
 static void tap_send(void *opaque)
 {
 TAPState *s = opaque;
@@ -3227,7 +3248,7 @@ static TAPState *net_tap_fd_init(VLANState *vlan,
int fd)
 return NULL;
 s-fd = fd;
 s-vc = qemu_new_vlan_client(vlan, tap_receive, NULL, s);
-qemu_set_fd_handler(s-fd, tap_send, NULL, s);
+qemu_set_fd_handler2(s-fd, tap_read_poll, tap_send, NULL, s);
 snprintf(s-vc-info_str, sizeof(s-vc-info_str), tap: fd=%d,
fd);
 return s;
 }
@@ -6262,6 +6283,9 @@ void main_loop_wait(int timeout)
 slirp_select_poll(rfds, wfds, xfds);
 }
 #endif
+
+paravirt_net_poll();
+
 qemu_aio_poll();
 qemu_bh_poll();
 
diff --git a/qemu/vl.h b/qemu/vl.h
index dcc1003..319f59b 100644
--- a/qemu/vl.h
+++ b/qemu/vl.h
@@ -37,6 +37,7 @@
 #include unistd.h
 #include fcntl.h
 #include sys/stat.h
+#include sys/uio.h
 
 #ifndef O_LARGEFILE
 #define O_LARGEFILE 0
@@ -401,6 +402,8 @@ void qemu_handler_true(void *opaque);
 
 void do_info_network(void);
 
+int get_tap_fd(void *opaque);
+
 /* TAP win32 */
 int tap_win32_init(VLANState *vlan, const char *ifname);
 
@@ -1017,6 +1020,8 @@ void pci_pcnet_init(PCIBus *bus, NICInfo *nd, int
devfn);
 void pcnet_h_reset(void *opaque);
 void *lance_init(NICInfo *nd, uint32_t leaddr, void *dma_opaque);
 
+void pci_paranet_init(PCIBus *bus, NICInfo *nd, int devfn);
+void paravirt_net_poll(void);
 
 /* pckbd.c */
 
@@ -1050,6 +1055,7 @@ typedef struct PicState2 PicState2;
 extern PicState2 *isa_pic;
 void pic_set_irq(int irq, int 

Re: [kvm-devel] [PATCH 00/13] PV-IO v4

2007-08-24 Thread Dor Laor
The following series implements v4 of the PV-IO series.

Changes since v3:

1)Rebased on top of kvm.git HEAD
2)Forward ported Ingo's/Dor's baseline work for paravirtualization
(Dropped
  ballon and net driver)
3)Fixed numerous bugs:  You can now pass packets via the IOQNET
loopback.

I am on vacation next week (figures...just in time for the KVM forum)
and
will be also traveling for business for a good portion of Sept.Based
on
that, I figured I would make one more drop with my latest stuff.

Have a good time at the forum!  I will talk to you guys when everyone is
back
in the swing of things.

-Greg


Well, finally I just got my patches out of the door.
Now I'll have time to look into yours too, hope that we'll enjoy
the double efforts ;)
Cheers and enjoy the vacation (your not going to Tuscon Arizona are you...)
-Dor
-
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/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


[kvm-devel] KVM-36 compile error on Fedora 7

2007-08-24 Thread Mark Bidewell
When building kvm-36 with the latest Fedora kernel I get the error:

kvmctl.c: In function 'kvm_run':
kvmctl.c:1046: error: 'KVM_EXIT_SET_TPR' undeclared (first use in this
function)
kvmctl.c:1046: error: (Each undeclared identifier is reported only once
kvmctl.c:1046: error: for each function it appears in.)
make[1]: *** [kvmctl.o] Error 1
make[1]: Leaving directory `/opt/kvm-36/user'
make: *** [user] Error 2

on lines:

1046 case KVM_EXIT_SET_TPR:
1047 break;

Commenting this lines out allows KVM to compile.  kvm-35 compiles on the
latest with no error.

Am I losing anything important by commenting them out?

Mark Bidewell
-
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/___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] [PATCH 00/13] PV-IO v4

2007-08-24 Thread Gregory Haskins
On Fri, 2007-08-24 at 17:22 -0700, Dor Laor wrote:

 Cheers and enjoy the vacation

Thanks!

  (your not going to Tuscon Arizona are you...)

While I can't quite say I'd rather be in AZ than on vacation with the
family ;), I am disappointed that the timing will prevent me from
joining you guys.  Have a good time out there, and I will talk to you
guys when I get back.

-Greg

(Thanks for the patches, BTW.  I will try to take a look ASAP)




-
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/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] KVM-36 compile error on Fedora 7

2007-08-24 Thread Mark Bidewell
Thanks for your help, The output is as follows:

make -C kernel
make[1]: Entering directory `/opt/kvm-36/kernel'
make -C /lib/modules/2.6.22.4-65.fc7/build M=`pwd` $@
make[2]: Entering directory `/usr/src/kernels/2.6.22.4-65.fc7-x86_64'
test -e include/linux/autoconf.h -a -e include/config/auto.conf ||
(\
echo;   \
echo   ERROR: Kernel configuration is invalid.;   \
echo  include/linux/autoconf.h or include/config/auto.conf
are missing.;  \
echo  Run 'make oldconfig  make prepare' on kernel src to
fix it.;  \
echo;   \
/bin/false)
mkdir -p /opt/kvm-36/kernel/.tmp_versions
rm -f /opt/kvm-36/kernel/.tmp_versions/*
make -f scripts/Makefile.build obj=/opt/kvm-36/kernel
   rm -f /opt/kvm-36/kernel/built-in.o; ar rcs /opt/kvm-36/kernel/built-in.o
  gcc -Wp,-MD,/opt/kvm-36/kernel/.svm.o.d  -nostdinc -isystem
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/include -D__KERNEL__ -Iinclude
-include include/linux/autoconf.h -Wall -Wundef -Wstrict-prototypes
-Wno-trigraphs -fno-strict-aliasing -fno-common -Os  -mtune=generic -m64
-mno-red-zone -mcmodel=kernel -pipe -Wno-sign-compare
-fno-asynchronous-unwind-tables -funit-at-a-time -mno-sse -mno-mmx -mno-sse2
-mno-3dnow -maccumulate-outgoing-args -DCONFIG_AS_CFI=1
-DCONFIG_AS_CFI_SIGNAL_FRAME=1 -fstack-protector -fomit-frame-pointer -g
-fno-stack-protector -Wdeclaration-after-statement -Wno-pointer-sign
-I/opt/kvm-36/kernel/include -include /opt/kvm-36/kernel/external-
module-compat.h  -DMODULE -DKBUILD_STR(s)=#s
-DKBUILD_BASENAME=KBUILD_STR(svm)  -DKBUILD_MODNAME=KBUILD_STR(kvm_amd)
-c -o /opt/kvm-36/kernel/.tmp_svm.o /opt/kvm-36/kernel/svm.c
  gcc -Wp,-MD,/opt/kvm-36/kernel/.vmx.o.d  -nostdinc -isystem
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/include -D__KERNEL__ -Iinclude
-include include/linux/autoconf.h -Wall -Wundef -Wstrict-prototypes
-Wno-trigraphs -fno-strict-aliasing -fno-common -Os  -mtune=generic -m64
-mno-red-zone -mcmodel=kernel -pipe -Wno-sign-compare
-fno-asynchronous-unwind-tables -funit-at-a-time -mno-sse -mno-mmx -mno-sse2
-mno-3dnow -maccumulate-outgoing-args -DCONFIG_AS_CFI=1
-DCONFIG_AS_CFI_SIGNAL_FRAME=1 -fstack-protector -fomit-frame-pointer -g
-fno-stack-protector -Wdeclaration-after-statement -Wno-pointer-sign
-I/opt/kvm-36/kernel/include -include /opt/kvm-36/kernel/external-
module-compat.h  -DMODULE -DKBUILD_STR(s)=#s
-DKBUILD_BASENAME=KBUILD_STR(vmx)
-DKBUILD_MODNAME=KBUILD_STR(kvm_intel) -c -o /opt/kvm-36/kernel/.tmp_vmx.o
/opt/kvm-36/kernel/vmx.c
  gcc -Wp,-MD,/opt/kvm-36/kernel/.vmx-debug.o.d  -nostdinc -isystem
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/include -D__KERNEL__ -Iinclude
-include include/linux/autoconf.h -Wall -Wundef -Wstrict-prototypes
-Wno-trigraphs -fno-strict-aliasing -fno-common -Os  -mtune=generic -m64
-mno-red-zone -mcmodel=kernel -pipe -Wno-sign-compare
-fno-asynchronous-unwind-tables -funit-at-a-time -mno-sse -mno-mmx -mno-sse2
-mno-3dnow -maccumulate-outgoing-args -DCONFIG_AS_CFI=1
-DCONFIG_AS_CFI_SIGNAL_FRAME=1 -fstack-protector -fomit-frame-pointer -g
-fno-stack-protector -Wdeclaration-after-statement -Wno-pointer-sign
-I/opt/kvm-36/kernel/include -include /opt/kvm-36/kernel/external-
module-compat.h  -DMODULE -DKBUILD_STR(s)=#s
-DKBUILD_BASENAME=KBUILD_STR(vmx_debug)
-DKBUILD_MODNAME=KBUILD_STR(kvm_intel) -c -o /opt/kvm-36/kernel/.tmp_vmx-
debug.o /opt/kvm-36/kernel/vmx-debug.c
  gcc -Wp,-MD,/opt/kvm-36/kernel/.kvm_main.o.d  -nostdinc -isystem
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/include -D__KERNEL__ -Iinclude
-include include/linux/autoconf.h -Wall -Wundef -Wstrict-prototypes
-Wno-trigraphs -fno-strict-aliasing -fno-common -Os  -mtune=generic -m64
-mno-red-zone -mcmodel=kernel -pipe -Wno-sign-compare
-fno-asynchronous-unwind-tables -funit-at-a-time -mno-sse -mno-mmx -mno-sse2
-mno-3dnow -maccumulate-outgoing-args -DCONFIG_AS_CFI=1
-DCONFIG_AS_CFI_SIGNAL_FRAME=1 -fstack-protector -fomit-frame-pointer -g
-fno-stack-protector -Wdeclaration-after-statement -Wno-pointer-sign
-I/opt/kvm-36/kernel/include -include /opt/kvm-36/kernel/external-
module-compat.h  -DMODULE -DKBUILD_STR(s)=#s
-DKBUILD_BASENAME=KBUILD_STR(kvm_main)  -DKBUILD_MODNAME=KBUILD_STR(kvm)
-c -o /opt/kvm-36/kernel/.tmp_kvm_main.o /opt/kvm-36/kernel/kvm_main.c
  gcc -Wp,-MD,/opt/kvm-36/kernel/.mmu.o.d  -nostdinc -isystem
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/include -D__KERNEL__ -Iinclude
-include include/linux/autoconf.h -Wall -Wundef -Wstrict-prototypes
-Wno-trigraphs -fno-strict-aliasing -fno-common -Os  -mtune=generic -m64
-mno-red-zone -mcmodel=kernel -pipe -Wno-sign-compare
-fno-asynchronous-unwind-tables -funit-at-a-time -mno-sse -mno-mmx -mno-sse2
-mno-3dnow -maccumulate-outgoing-args -DCONFIG_AS_CFI=1
-DCONFIG_AS_CFI_SIGNAL_FRAME=1 -fstack-protector -fomit-frame-pointer -g
-fno-stack-protector -Wdeclaration-after-statement -Wno-pointer-sign