Rusty Russell | 1 Aug 2007 02:11
Picon
Gravatar

[PATCH] Hoist push_irq/pop_irq into kvm.h

Everyone can use push_irq() and pop_irq(), so move them to common code.

Signed-off-by: Rusty Russell <rusty@...>

diff -r f48242856f1c drivers/kvm/kvm.h
--- a/drivers/kvm/kvm.h	Wed Aug 01 09:57:03 2007 +1000
+++ b/drivers/kvm/kvm.h	Wed Aug 01 10:06:10 2007 +1000
 <at>  <at>  -716,6 +716,24  <at>  <at>  static inline u32 get_rdx_init_val(void)
 	return 0x600; /* P6 family */
 }

+static inline u8 kvm_pop_irq(struct kvm_vcpu *vcpu)
+{
+	int word_index = __ffs(vcpu->irq_summary);
+	int bit_index = __ffs(vcpu->irq_pending[word_index]);
+	int irq = word_index * BITS_PER_LONG + bit_index;
+
+	clear_bit(bit_index, &vcpu->irq_pending[word_index]);
+	if (!vcpu->irq_pending[word_index])
+		clear_bit(word_index, &vcpu->irq_summary);
+	return irq;
+}
+
+static inline void kvm_push_irq(struct kvm_vcpu *vcpu, u8 irq)
+{
+	set_bit(irq, vcpu->irq_pending);
+	set_bit(irq / BITS_PER_LONG, &vcpu->irq_summary);
+}
+
 #define ASM_VMX_VMCLEAR_RAX       ".byte 0x66, 0x0f, 0xc7, 0x30"
(Continue reading)

Rusty Russell | 1 Aug 2007 02:12
Picon
Gravatar

[PATCH] Remove stat_set from debugfs

We shouldn't define stat_set on the debug attributes, since that will
cause silent failure on writing: without a set argument, userspace
will get -EACCESS.

Signed-off-by: Rusty Russell <rusty@...>

diff -r 968bc14f06fd drivers/kvm/kvm_main.c
--- a/drivers/kvm/kvm_main.c	Tue Jul 31 19:34:48 2007 +1000
+++ b/drivers/kvm/kvm_main.c	Tue Jul 31 19:36:33 2007 +1000
 <at>  <at>  -3009,11 +3009,7  <at>  <at>  static u64 stat_get(void *_offset)
 	return total;
 }

-static void stat_set(void *offset, u64 val)
-{
-}
-
-DEFINE_SIMPLE_ATTRIBUTE(stat_fops, stat_get, stat_set, "%llu\n");
+DEFINE_SIMPLE_ATTRIBUTE(stat_fops, stat_get, NULL, "%llu\n");

 static __init void kvm_init_debug(void)
 {

-------------------------------------------------------------------------
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/
Rusty Russell | 1 Aug 2007 02:17
Picon
Gravatar

[PATCH] Remove unneeded kvm_dev_open and kvm_dev_release functions.

Devices don't need open or release functions.

Signed-off-by: Rusty Russell <rusty@...>

diff -r 9fde0a9cae6b drivers/kvm/kvm_main.c
--- a/drivers/kvm/kvm_main.c	Fri Jul 27 17:14:25 2007 +1000
+++ b/drivers/kvm/kvm_main.c	Fri Jul 27 17:17:57 2007 +1000
 <at>  <at>  -363,11 +363,6  <at>  <at>  static struct kvm *kvm_create_vm(void)
 	return kvm;
 }

-static int kvm_dev_open(struct inode *inode, struct file *filp)
-{
-	return 0;
-}
-
 /*
  * Free any memory in  <at> free but not in  <at> dont.
  */
 <at>  <at>  -435,11 +430,6  <at>  <at>  static void kvm_free_vcpus(struct kvm *k
 		}
 	}

-}
-
-static int kvm_dev_release(struct inode *inode, struct file *filp)
-{
-	return 0;
 }

(Continue reading)

Rusty Russell | 1 Aug 2007 02:31
Picon
Gravatar

[PATCH] lmsw sets lower 16 bits of cr0, not just lower 4

According to my Intel manual, although lmsw only causes an exit when
trying to set the bottom 4 bits, it is supposed to set the bottom 16
bits of cr0.

Signed-off-by: Rusty Russell <rusty@...>

diff -r f06a5d7dc984 drivers/kvm/kvm_main.c
--- a/drivers/kvm/kvm_main.c	Wed Jul 25 13:05:14 2007 +1000
+++ b/drivers/kvm/kvm_main.c	Wed Jul 25 13:15:24 2007 +1000
 <at>  <at>  -526,7 +526,7  <at>  <at>  EXPORT_SYMBOL_GPL(set_cr0);

 void lmsw(struct kvm_vcpu *vcpu, unsigned long msw)
 {
-	set_cr0(vcpu, (vcpu->cr0 & ~0x0ful) | (msw & 0x0f));
+	set_cr0(vcpu, (vcpu->cr0 & ~0xffffUL) | (msw & 0xffff));
 }
 EXPORT_SYMBOL_GPL(lmsw);

-------------------------------------------------------------------------
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/
Scott Lerman | 1 Aug 2007 02:40
Picon

KVM hangs on start

I installed kvm from Ubuntu's 7.04 repository. When I try start kvm with

kvm -m 256 -cdrom /path/to/kubuntu-7.04-dvd-i386.iso -boot d .kvm/server.img

I get a BIOS screen that says Loading... (among other typical BIOS information), then just does nothing while using 100% of one of the cores on my CPU. The server.img disk image is newly created. I've been following https://help.ubuntu.com/community/KVM, and everything up to this point has worked fine. My CPU is an Athlon AM2. Anybody else seen this issue before and have any ideas on what the problem is?

--
Scott Lerman

-------------------------------------------------------------------------
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@...
https://lists.sourceforge.net/lists/listinfo/kvm-devel
Rusty Russell | 1 Aug 2007 02:48
Picon
Gravatar

[PATCH] Add and use pr_unimpl for standard formatting of unimplemented features.

All guest-invokable printks should be ratelimited to prevent malicious
guests from flooding logs.  This is a start.

Signed-off-by: Rusty Russell <rusty@...>

diff -r 8b44d107639d drivers/kvm/kvm.h
--- a/drivers/kvm/kvm.h	Wed Aug 01 10:29:10 2007 +1000
+++ b/drivers/kvm/kvm.h	Wed Aug 01 10:36:35 2007 +1000
 <at>  <at>  -474,6 +474,14  <at>  <at>  struct kvm_arch_ops {

 extern struct kvm_arch_ops *kvm_arch_ops;

+/* The guest did something we don't support. */
+#define pr_unimpl(vcpu, fmt, ...)					\
+ do {									\
+	if (printk_ratelimit())						\
+		printk(KERN_ERR "kvm: %i: cpu%i " fmt,			\
+		       current->tgid, (vcpu)->vcpu_id , ## __VA_ARGS__); \
+ } while(0)
+
 #define kvm_printf(kvm, fmt ...) printk(KERN_DEBUG fmt)
 #define vcpu_printf(vcpu, fmt...) kvm_printf(vcpu->kvm, fmt)

diff -r 8b44d107639d drivers/kvm/kvm_main.c
--- a/drivers/kvm/kvm_main.c	Wed Aug 01 10:29:10 2007 +1000
+++ b/drivers/kvm/kvm_main.c	Wed Aug 01 10:39:47 2007 +1000
 <at>  <at>  -962,8 +962,7  <at>  <at>  static int emulator_write_std(unsigned l
 			      unsigned int bytes,
 			      struct kvm_vcpu *vcpu)
 {
-	printk(KERN_ERR "emulator_write_std: addr %lx n %d\n",
-	       addr, bytes);
+	pr_unimpl(vcpu, "emulator_write_std: addr %lx n %d\n", addr, bytes);
 	return X86EMUL_UNHANDLEABLE;
 }

 <at>  <at>  -1138,8 +1137,7  <at>  <at>  int emulator_get_dr(struct x86_emulate_c
 		*dest = kvm_arch_ops->get_dr(vcpu, dr);
 		return X86EMUL_CONTINUE;
 	default:
-		printk(KERN_DEBUG "%s: unexpected dr %u\n",
-		       __FUNCTION__, dr);
+		pr_unimpl(vcpu, "%s: unexpected dr %u\n", __FUNCTION__, dr);
 		return X86EMUL_UNHANDLEABLE;
 	}
 }
 <at>  <at>  -1488,7 +1486,7  <at>  <at>  int kvm_get_msr_common(struct kvm_vcpu *
 		break;
 #endif
 	default:
-		printk(KERN_ERR "kvm: unhandled rdmsr: 0x%x\n", msr);
+		pr_unimpl(vcpu, "unhandled rdmsr: 0x%x\n", msr);
 		return 1;
 	}
 	*pdata = data;
 <at>  <at>  -1543,11 +1541,11  <at>  <at>  int kvm_set_msr_common(struct kvm_vcpu *
 		break;
 #endif
 	case MSR_IA32_MC0_STATUS:
-		printk(KERN_WARNING "%s: MSR_IA32_MC0_STATUS 0x%llx, nop\n",
+		pr_unimpl(vcpu, "%s: MSR_IA32_MC0_STATUS 0x%llx, nop\n",
 		       __FUNCTION__, data);
 		break;
 	case MSR_IA32_MCG_STATUS:
-		printk(KERN_WARNING "%s: MSR_IA32_MCG_STATUS 0x%llx, nop\n",
+		pr_unimpl(vcpu, "%s: MSR_IA32_MCG_STATUS 0x%llx, nop\n",
 			__FUNCTION__, data);
 		break;
 	case MSR_IA32_UCODE_REV:
 <at>  <at>  -1567,7 +1565,7  <at>  <at>  int kvm_set_msr_common(struct kvm_vcpu *
 		return vcpu_register_para(vcpu, data);

 	default:
-		printk(KERN_ERR "kvm: unhandled wrmsr: 0x%x\n", msr);
+		pr_unimpl(vcpu, "unhandled wrmsr: 0x%x\n", msr);
 		return 1;
 	}
 	return 0;
 <at>  <at>  -1798,7 +1796,7  <at>  <at>  int kvm_setup_pio(struct kvm_vcpu *vcpu,
 		/*
 		 * String I/O in reverse.  Yuck.  Kill the guest, fix later.
 		 */
-		printk(KERN_ERR "kvm: guest string pio down\n");
+		pr_unimpl(vcpu, "guest string pio down\n");
 		inject_gp(vcpu);
 		return 1;
 	}
 <at>  <at>  -1829,7 +1827,7  <at>  <at>  int kvm_setup_pio(struct kvm_vcpu *vcpu,
 				ret = 1;
 		}
 	} else if (pio_dev)
-		printk(KERN_ERR "no string pio read support yet, "
+		pr_unimpl(vcpu, "no string pio read support yet, "
 		       "port %x size %d count %ld\n",
 			port, size, count);

diff -r 8b44d107639d drivers/kvm/svm.c
--- a/drivers/kvm/svm.c	Wed Aug 01 10:29:10 2007 +1000
+++ b/drivers/kvm/svm.c	Wed Aug 01 10:39:34 2007 +1000
 <at>  <at>  -1149,7 +1149,7  <at>  <at>  static int task_switch_interception(stru
 static int task_switch_interception(struct vcpu_svm *svm,
 				    struct kvm_run *kvm_run)
 {
-	printk(KERN_DEBUG "%s: task swiche is unsupported\n", __FUNCTION__);
+	pr_unimpl(&svm->vcpu, "%s: task switch is unsupported\n", __FUNCTION__);
 	kvm_run->exit_reason = KVM_EXIT_UNKNOWN;
 	return 0;
 }
 <at>  <at>  -1165,7 +1165,7  <at>  <at>  static int emulate_on_interception(struc
 				   struct kvm_run *kvm_run)
 {
 	if (emulate_instruction(&svm->vcpu, NULL, 0, 0) != EMULATE_DONE)
-		printk(KERN_ERR "%s: failed\n", __FUNCTION__);
+		pr_unimpl(&svm->vcpu, "%s: failed\n", __FUNCTION__);
 	return 1;
 }

diff -r 8b44d107639d drivers/kvm/vmx.c
--- a/drivers/kvm/vmx.c	Wed Aug 01 10:29:10 2007 +1000
+++ b/drivers/kvm/vmx.c	Wed Aug 01 10:36:35 2007 +1000
 <at>  <at>  -1907,7 +1907,7  <at>  <at>  static int handle_cr(struct kvm_vcpu *vc
 		break;
 	}
 	kvm_run->exit_reason = 0;
-	printk(KERN_ERR "kvm: unhandled control register: op %d cr %d\n",
+	pr_unimpl(vcpu, "unhandled control register: op %d cr %d\n",
 	       (int)(exit_qualification >> 4) & 3, cr);
 	return 0;
 }

-------------------------------------------------------------------------
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/
Gerb Stralko | 1 Aug 2007 04:26
Picon

Re: problem running kvm with 2.6.22

On 7/31/07, Avi Kivity <avi@...> wrote:
> Gerb Stralko wrote:
> > however when i run the following commands:
> >
> > stralko <at> magnum_pi ~ $ sudo /usr/local/kvm/bin/qemu-system-x86_64 -hda
> > /mnt/kvm/win32xp.img -cdrom /mnt/kvm/win32xp.iso -boot d -m 512
> > Could not initialize SDL - exiting
> >

This is weird, when i do
$>su -
$>/usr/local/kvm/bin/qemu-system-x86_64 -hda \
  /mnt/kvm/win32xp.img \
  -cdrom /mnt/kvm/win32xp.iso -boot d -m 512

it works like a champ!  Some permission problem with SDL (i guess),
kvm is working fine...sorry for the noise.

-gerb

-------------------------------------------------------------------------
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/
Rusty Russell | 1 Aug 2007 06:46
Picon
Gravatar

[PATCH] Use kmem_cache_free for kmem_cache_zalloc'ed objects

We use kfree in svm.c and vmx.c, and this works, but it could break at
any time.  kfree() is supposed to match up with kmalloc().

Signed-off-by: Rusty Russell <rusty@...>

diff -r 7e054bfac61d drivers/kvm/svm.c
--- a/drivers/kvm/svm.c	Wed Aug 01 10:42:06 2007 +1000
+++ b/drivers/kvm/svm.c	Wed Aug 01 14:41:22 2007 +1000
 <at>  <at>  -592,7 +592,7  <at>  <at>  uninit:
 uninit:
 	kvm_vcpu_uninit(&svm->vcpu);
 free_svm:
-	kfree(svm);
+	kmem_cache_free(kvm_vcpu_cache, svm);
 out:
 	return ERR_PTR(err);
 }
 <at>  <at>  -603,7 +603,7  <at>  <at>  static void svm_free_vcpu(struct kvm_vcp

 	__free_page(pfn_to_page(svm->vmcb_pa >> PAGE_SHIFT));
 	kvm_vcpu_uninit(vcpu);
-	kfree(svm);
+	kmem_cache_free(kvm_vcpu_cache, svm);
 }

 static void svm_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
diff -r 7e054bfac61d drivers/kvm/vmx.c
--- a/drivers/kvm/vmx.c	Wed Aug 01 10:42:06 2007 +1000
+++ b/drivers/kvm/vmx.c	Wed Aug 01 14:41:41 2007 +1000
 <at>  <at>  -2344,7 +2344,7  <at>  <at>  static void vmx_free_vcpu(struct kvm_vcp
 	kfree(vmx->host_msrs);
 	kfree(vmx->guest_msrs);
 	kvm_vcpu_uninit(vcpu);
-	kfree(vmx);
+	kmem_cache_free(kvm_vcpu_cache, vmx);
 }

 static struct kvm_vcpu *vmx_create_vcpu(struct kvm *kvm, unsigned int id)
 <at>  <at>  -2395,7 +2395,7  <at>  <at>  uninit_vcpu:
 uninit_vcpu:
 	kvm_vcpu_uninit(&vmx->vcpu);
 free_vcpu:
-	kfree(vmx);
+	kmem_cache_free(kvm_vcpu_cache, vmx);
 	return ERR_PTR(err);
 }

-------------------------------------------------------------------------
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/
Ulrich Schreiner | 1 Aug 2007 07:22
Picon
Favicon

kvm very slow

hi,

im using a 64 bit fedora7 system with a quad-core processor to host
multiple virtual machines.

my current kernel is:

Linux testserver 2.6.22.1-27.fc7 #1 SMP Tue Jul 17 17:19:58 EDT 2007
x86_64 x86_64 x86_64 GNU/Linux

(now there is a 2.6.22.1-33.fc7 to download, but i think it is not the
point here).

i installed

  kvm.x86_64: 31-1.fc8

because of a crash i reported as a bug with the older kvm module.

this system starts a F7 image with the following command:

/usr/bin/qemu-kvm 
  -net nic,macadr=52.54.00.12.34.57 
  -net tap,script=./ifup.py,ifname=tap0
  -hda /var/qemu/vm_images/F7image.img 
  -boot c: -m 512 -vnc :2 -k de

inside the image there is fedora 7, but a 32bit system.

almost everything works (reboot hangs), but the system is extremely
slow! the clock inside the system is extremely slow: every *virtual*
second in the image is about two or more seconds in the *real* world.

the "clocksource=pit" argument does not help.

but it is not only the clock ... the whole system is really slow!

on the other side i have an notebook with an old core2 processor which
cannot run KVM, so i run qemu/kqemu. if i start the image on this host,
i have much better performance. inside the image there is an apache,
subversion and a trac; all three systems are really fast on the notebook
compared to the quadcore 64bit host!

when starting qemu without kqemu i get a warning on console an poor
performance. when starting "qemu-kvm" i get no warning, but the same
poor performance. how can i check if the kvm-modules are really loaded?

any other ideas what i can do? 

thanks
</usc>

-------------------------------------------------------------------------
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/
Dong, Eddie | 1 Aug 2007 08:20
Picon
Favicon

Re: lapic2 branch rebased

Avi Kivity wrote:
> I rebased the lapic2 branch onto current master.  Because there were
> many nontrivial changes, the result is in a new branch,
> lapic3.  This is
> for both kernel and userspace.
> 

lapic3 clearly crashes after the rebase due to APIC register
    access earlier than APIC instance is created, because
vcpu is dynamic created now.

    Fix crash by moving APIC creation code into
    VMX/SVM creation code.

    Signed-off-by: Yaozu (Eddie) Dong <eddie.dong@...>

diff --git a/drivers/kvm/kvm_main.c b/drivers/kvm/kvm_main.c
index b09595e..cb244f6 100644
--- a/drivers/kvm/kvm_main.c
+++ b/drivers/kvm/kvm_main.c
 <at>  <at>  -2470,11 +2470,6  <at>  <at>  static int kvm_vm_ioctl_create_vcpu(struct kvm
*kvm, int n)
 	/* We do fxsave: this must be aligned. */
 	BUG_ON((unsigned long)&vcpu->host_fx_image & 0xF);

-	if (irqchip_in_kernel(vcpu->kvm)) {
-		r = kvm_create_lapic(vcpu);
-		if (r < 0)
-			goto free_vcpu;
-	}
 	vcpu_load(vcpu);
 	r = kvm_mmu_setup(vcpu);
 	vcpu_put(vcpu);
diff --git a/drivers/kvm/lapic.c b/drivers/kvm/lapic.c
index e3db1cd..7f60bf3 100644
--- a/drivers/kvm/lapic.c
+++ b/drivers/kvm/lapic.c
 <at>  <at>  -944,6 +944,7  <at>  <at>  nomem:
 	kvm_free_apic(apic);
 	return -ENOMEM;
 }
+EXPORT_SYMBOL_GPL(kvm_create_lapic);

 int kvm_apic_has_interrupt(struct kvm_vcpu *vcpu)
 {
diff --git a/drivers/kvm/svm.c b/drivers/kvm/svm.c
index 015ab4b..6bf0c21 100644
--- a/drivers/kvm/svm.c
+++ b/drivers/kvm/svm.c
 <at>  <at>  -587,6 +587,12  <at>  <at>  static struct kvm_vcpu *svm_create_vcpu(struct kvm
*kvm, unsigned int id)
 	if (err)
 		goto free_svm;

+	if (irqchip_in_kernel(kvm)) {
+		err = kvm_create_lapic(&svm->vcpu);
+		if (err < 0)
+			goto free_svm;
+	}
+
 	page = alloc_page(GFP_KERNEL);
 	if (!page) {
 		err = -ENOMEM;
diff --git a/drivers/kvm/vmx.c b/drivers/kvm/vmx.c
index 9bb8867..667c9cd 100644
--- a/drivers/kvm/vmx.c
+++ b/drivers/kvm/vmx.c
 <at>  <at>  -2439,6 +2439,12  <at>  <at>  static struct kvm_vcpu *vmx_create_vcpu(struct
kvm *kvm, unsigned int id)
 	if (err)
 		goto free_vcpu;

+	if (irqchip_in_kernel(kvm)) {
+		err = kvm_create_lapic(&vmx->vcpu);
+		if (err < 0)
+			goto free_vcpu;
+	}
+
 	vmx->guest_msrs = kmalloc(PAGE_SIZE, GFP_KERNEL);
 	if (!vmx->guest_msrs) {
 		err = -ENOMEM;
Attachment (lapic3_rebase_fix.patch): application/octet-stream, 2124 bytes
-------------------------------------------------------------------------
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@...
https://lists.sourceforge.net/lists/listinfo/kvm-devel

Gmane