Re: [kvm-devel] Use host CPUID processor info
Dong, Eddie wrote: > Use host cpu model name, type, family, Model, stepping for guest. > > Against head. > > This is turning into a mix of the qemu cpuid and the host cpuid. We need to think of a way to make this controllable. > Signed-off-by: Yaozu (Eddie) Dong <[EMAIL PROTECTED]> > > diff --git a/qemu/qemu-kvm.c b/qemu/qemu-kvm.c > index bacdb37..1b86a13 100644 > --- a/qemu/qemu-kvm.c > +++ b/qemu/qemu-kvm.c > @@ -756,6 +755,10 @@ static void do_cpuid_ent(struct kvm_cpuid_entry *e, > uint32_t function) > if ((h_edx & 0x0010) == 0) > e->edx &= ~0x0010u; > } > +if (function == 0x8002 || function == 0x8003 > + || function == 0x8004) { > + host_cpuid(function, &e->eax, &e->ebx, &e->ecx, &e->edx); > +} > // sysenter isn't supported on compatibility mode on AMD. and > syscall > // isn't supported in compatibility mode on Intel. so advertise > the > // actuall cpu, and say goodbye to migration between different > vendors > @@ -768,6 +771,9 @@ static void do_cpuid_ent(struct kvm_cpuid_entry *e, > uint32_t function) > e->ecx = bcd[1]; > e->edx = bcd[2]; > } > +if (function == 0x1) { > + host_cpuid(function, &e->eax, NULL, NULL, NULL); > +} > } > > int kvm_qemu_init_env(CPUState *cenv) > -- error compiling committee.c: too many arguments to function - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ kvm-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel
Re: [kvm-devel] kvm-27 vs 28 I/O speed
Dave Hansen wrote: > I've noticed that some of my tests run *MUCH* slower in kvm-28 than in > 27. I'm sure that wall time is pretty wonky in the guests, but it is > much slower in real-world time as well. > > Here's a little test to create a 32MB zeroed file with dd. Here it is > from kvm-27 (this took ~5.5 seconds on my wristwatch): > 33554432 bytes transferred in 0.052050 seconds (644657845 bytes/sec) > 33554432 bytes transferred in 0.062933 seconds (533176451 bytes/sec) > > Here's the same thing from kvm-28 (~80 seconds on my wristwatch): > 33554432 bytes transferred in 38.607065 seconds (869127 bytes/sec) > 33554432 bytes transferred in 22.274318 seconds (1506418 bytes/sec) > > Same host kernel, same kvm kernel modules (from kvm-28) same guest > kernel, same command-line options, same disk image. > > Any ideas what is going on? > Is this repeatable? I don't see anything in kvm-27..kvm-28 that warrants such a regression. Things to check: - effect of pinning the vm onto one cpu (with 'taskset') - does any counter in kvm_stat behave differently If you are using qcow, maybe the effect is due to the first test hitting a hole and the second being forced to read from disk. I recommend doing performance tests from a real partition or volume. -- error compiling committee.c: too many arguments to function - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ kvm-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel
Re: [kvm-devel] In kernel PIC support: kernel patch
Dong, Eddie wrote: > Avi Kivity wrote: > >> Merged both into the 'lapic2' branch. Got the following oops running >> Windows (i386 on Intel): >> >> > > Avi: > This one should fixed the bug. > Against lapic2 dc03e1b70198e0e4aadfc9063399590fa42cf55e. > thx,eddie > > Destroy io bus earlier than all the registered bus node get freed > including vpic. > > Applied to lapic2 branch. -- error compiling committee.c: too many arguments to function - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ kvm-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel
Re: [kvm-devel] [PATCH] make kvm service script use dhclient config
>Hi list, > >in order to make the kvm service script work with DHCP on FC6 I had to >apply the following patch. Hope it's useful :-) > > >Ferry > > > >--- kvm 2007-06-07 17:13:47.0 +0200 >+++ /etc/init.d/kvm 2007-07-05 21:06:43.0 +0200 >@@ -132,7 +132,7 @@ >pgrep dhclient >/dev/null 2>&1 || i=4 >sleep 1 >done >-dhclient ${dst} >/dev/null 2>&1 >+dhclient -cf /etc/dhclient-${pif}.conf ${dst} >/dev/null 2>&1 > else > get_ip_info ${src} > ifconfig ${src} 0.0.0.0 I didn't see any /etc/dhclient-* files in my FC6. What the problem are you solving? I know there is a problem (don't rememeber the distribution) that when you run dhclient, it runs both on the bridge and on the physical interface. It that it? - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ kvm-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel
Re: [kvm-devel] [PATCH] make kvm service script use dhclient config
Dor Laor wrote: >> Hi list, >> >> in order to make the kvm service script work with DHCP on FC6 I had to >> apply the following patch. Hope it's useful :-) >> >> >> Ferry >> >> >> >> --- kvm 2007-06-07 17:13:47.0 +0200 >> +++ /etc/init.d/kvm 2007-07-05 21:06:43.0 +0200 >> @@ -132,7 +132,7 @@ >>pgrep dhclient >/dev/null 2>&1 || i=4 >>sleep 1 >>done >> -dhclient ${dst} >/dev/null 2>&1 >> +dhclient -cf /etc/dhclient-${pif}.conf ${dst} >/dev/null 2>&1 >> else >> get_ip_info ${src} >> ifconfig ${src} 0.0.0.0 >> > > I didn't see any /etc/dhclient-* files in my FC6. > What the problem are you solving? > I know there is a problem (don't rememeber the distribution) that when > you run dhclient, > it runs both on the bridge and on the physical interface. It that it? > > in my setup the dhcp client would run only on the kvm bridge and the hostname as I set up for the original network interface would not get sent to the dhcp server and would thus not land in my dns server. maybe this is a bit of a shortcut but the bridge must in some way use the same dhcp configuration as for the 'pif' it is replacing I think. as far as i now, the /etc/dhclient-* files are generated when you have the DHCP_HOSTNAME variable set in /etc/sysconfig/network-script/ifcfg-*, so maybe I should first check for presence of the file before using it but it work for me :-) about running the dhcp client twice... I think I've seen this happen but am not really sure. at the time I thought that the dhcp client didn't get properly shutdown/killed by the kvm script. the script needs to find the correct dhcp client (the one that is running of the 'pif') and shutdown that client. maybe this fails? hope this clarifies things - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ kvm-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel
[kvm-devel] bug concering Solaris ?
I have question concerning solaris as a guest system. Windows XP and Linux are up and running without problems. Now I would like to us Solaris10 for x86 too. I downloaded the ISO image and validated the MD5 checksum but when I start QEMU with "boot d" and -cdrom="location of the DVD image", QEMU dies with the following exception right after trying to access the cdrom drive: exception 6 (0) rax 0018 rbx 8d06 rcx f000ff53 rdx rsi rdi rsp 0005087e rbp r8 r9 r10 r11 r12 r13 r14 r15 rip 0003 rflags 00233002 cs (/ p 1 dpl 3 db 0 s 1 type 3 l 0 g 0 avl 0) ds (/ p 1 dpl 3 db 0 s 1 type 3 l 0 g 0 avl 0) es (/ p 1 dpl 3 db 0 s 1 type 3 l 0 g 0 avl 0) ss (/ p 1 dpl 3 db 0 s 1 type 3 l 0 g 0 avl 0) fs (/ p 1 dpl 3 db 0 s 1 type 3 l 0 g 0 avl 0) gs (/ p 1 dpl 3 db 0 s 1 type 3 l 0 g 0 avl 0) tr 0028 (2085/2088 p 1 dpl 0 db 0 s 0 type b l 0 g 0 avl 0) ldt (/ p 1 dpl 0 db 0 s 0 type 2 l 0 g 0 avl 0) gdt 8548/40 idt 1693b8/7ff cr0 6010 cr2 0 cr3 189000 cr4 90 cr8 0 efer 0 code: f0 d0 8b 00 00 53 ff 00 f0 53 ff 00 f0 53 ff 00 f0 53 ff 00 f0 53 ff 00 f0 53 ff 00 f0 a5 qemu exited: vdeq quits Are there any ideas how this issue can be resolved? I tried the same setup with the official qemu-0.9 which worked without problems. Regards, Adrian Lambeck - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ kvm-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel
[kvm-devel] [PATCH 02/20] KVM: Implement emulation of instruction "ret" (opcode 0xc3)
From: Nitin A Kamble <[EMAIL PROTECTED]> Signed-off-by: Nitin A Kamble <[EMAIL PROTECTED]> Signed-off-by: Avi Kivity <[EMAIL PROTECTED]> --- drivers/kvm/x86_emulate.c | 12 1 files changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/kvm/x86_emulate.c b/drivers/kvm/x86_emulate.c index 46c3806..92620e4 100644 --- a/drivers/kvm/x86_emulate.c +++ b/drivers/kvm/x86_emulate.c @@ -131,9 +131,9 @@ static u8 opcode_table[256] = { /* 0xB0 - 0xBF */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0xC0 - 0xC7 */ - ByteOp | DstMem | SrcImm | ModRM, DstMem | SrcImmByte | ModRM, 0, 0, - 0, 0, ByteOp | DstMem | SrcImm | ModRM | Mov, - DstMem | SrcImm | ModRM | Mov, + ByteOp | DstMem | SrcImm | ModRM, DstMem | SrcImmByte | ModRM, + 0, ImplicitOps, 0, 0, + ByteOp | DstMem | SrcImm | ModRM | Mov, DstMem | SrcImm | ModRM | Mov, /* 0xC8 - 0xCF */ 0, 0, 0, 0, 0, 0, 0, 0, /* 0xD0 - 0xD7 */ @@ -1156,14 +1156,18 @@ special_insn: case 0xf4: /* hlt */ ctxt->vcpu->halt_request = 1; goto done; + case 0xc3: /* ret */ + dst.ptr = &_eip; + goto pop_instruction; case 0x58 ... 0x5f: /* pop reg */ dst.ptr = (unsigned long *)&_regs[b & 0x7]; +pop_instruction: if ((rc = ops->read_std(register_address(ctxt->ss_base, _regs[VCPU_REGS_RSP]), dst.ptr, op_bytes, ctxt)) != 0) goto done; - register_address_increment(_regs[VCPU_REGS_RSP], dst.bytes); + register_address_increment(_regs[VCPU_REGS_RSP], op_bytes); dst.orig_val = dst.val; /* Disable writeback. */ break; } -- 1.5.2.2 - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ kvm-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel
[kvm-devel] [PATCH 01/20] KVM: Implement emulation of "pop reg" instruction (opcode 0x58-0x5f)
From: Nitin A Kamble <[EMAIL PROTECTED]> For use in real mode. Signed-off-by: Nitin A Kamble <[EMAIL PROTECTED]> Signed-off-by: Avi Kivity <[EMAIL PROTECTED]> --- drivers/kvm/x86_emulate.c | 17 +++-- 1 files changed, 15 insertions(+), 2 deletions(-) diff --git a/drivers/kvm/x86_emulate.c b/drivers/kvm/x86_emulate.c index a4a8481..46c3806 100644 --- a/drivers/kvm/x86_emulate.c +++ b/drivers/kvm/x86_emulate.c @@ -98,8 +98,11 @@ static u8 opcode_table[256] = { 0, 0, 0, 0, /* 0x40 - 0x4F */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - /* 0x50 - 0x5F */ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + /* 0x50 - 0x57 */ + 0, 0, 0, 0, 0, 0, 0, 0, + /* 0x58 - 0x5F */ + ImplicitOps, ImplicitOps, ImplicitOps, ImplicitOps, + ImplicitOps, ImplicitOps, ImplicitOps, ImplicitOps, /* 0x60 - 0x6F */ 0, 0, 0, DstReg | SrcMem32 | ModRM | Mov /* movsxd (x86/64) */ , 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -1153,6 +1156,16 @@ special_insn: case 0xf4: /* hlt */ ctxt->vcpu->halt_request = 1; goto done; + case 0x58 ... 0x5f: /* pop reg */ + dst.ptr = (unsigned long *)&_regs[b & 0x7]; + + if ((rc = ops->read_std(register_address(ctxt->ss_base, + _regs[VCPU_REGS_RSP]), dst.ptr, op_bytes, ctxt)) != 0) + goto done; + + register_address_increment(_regs[VCPU_REGS_RSP], dst.bytes); + dst.orig_val = dst.val; /* Disable writeback. */ + break; } goto writeback; -- 1.5.2.2 - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ kvm-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel
[kvm-devel] [PATCH 00/20] KVM updates for 2.6.23, part 2
This is the second set of updates for the 2.6.23 merge window. This time around, the patchset includes the cpu hotplug fixes (which also make suspend and resume robust in the presence of running virtual machines). Also included are a few fixes and core updates. Avi Kivity (11): KVM: VMX: Reinitialize the real-mode tss when entering real mode KVM: VMX: Remove unnecessary code in vmx_tlb_flush() KVM: Remove kvmfs in favor of the anonymous inodes source KVM: Clean up #includes HOTPLUG: Add CPU_DYING notifier HOTPLUG: Adapt cpuset hotplug callback to CPU_DYING HOTPLUG: Adapt thermal throttle to CPU_DYING SMP: Implement on_cpu() KVM: Keep track of which cpus have virtualization enabled KVM: Tune hotplug/suspend IPIs KVM: Use CPU_DYING for disabling virtualization Eddie Dong (1): KVM: Add support for in-kernel pio handlers Gregory Haskins (2): KVM: Adds support for in-kernel mmio handlers KVM: VMX: Fix interrupt checking on lightweight exit Joerg Roedel (1): KVM: SVM: Reliably detect if SVM was disabled by BIOS Luca Tettamanti (2): KVM: Fix x86 emulator writeback KVM: Avoid useless memory write when possible Nitin A Kamble (2): KVM: Implement emulation of "pop reg" instruction (opcode 0x58-0x5f) KVM: Implement emulation of instruction "ret" (opcode 0xc3) Shaohua Li (1): KVM: MMU: Fix Wrong tlb flush order - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ kvm-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel
[kvm-devel] [PATCH 05/20] KVM: Add support for in-kernel pio handlers
From: Eddie Dong <[EMAIL PROTECTED]> Useful for the PIC and PIT. Signed-off-by: Yaozu (Eddie) Dong <[EMAIL PROTECTED]> Signed-off-by: Avi Kivity <[EMAIL PROTECTED]> --- drivers/kvm/kvm.h |5 - drivers/kvm/kvm_main.c | 33 + 2 files changed, 37 insertions(+), 1 deletions(-) diff --git a/drivers/kvm/kvm.h b/drivers/kvm/kvm.h index 31846b1..a7c5e6b 100644 --- a/drivers/kvm/kvm.h +++ b/drivers/kvm/kvm.h @@ -241,6 +241,7 @@ struct kvm_pio_request { struct page *guest_pages[2]; unsigned guest_page_offset; int in; + int port; int size; int string; int down; @@ -303,7 +304,8 @@ static inline int kvm_iodevice_inrange(struct kvm_io_device *dev, gpa_t addr) static inline void kvm_iodevice_destructor(struct kvm_io_device *dev) { - dev->destructor(dev); + if (dev->destructor) + dev->destructor(dev); } /* @@ -453,6 +455,7 @@ struct kvm { struct list_head vm_list; struct file *filp; struct kvm_io_bus mmio_bus; + struct kvm_io_bus pio_bus; }; struct descriptor_table { diff --git a/drivers/kvm/kvm_main.c b/drivers/kvm/kvm_main.c index e157e28..7826f16 100644 --- a/drivers/kvm/kvm_main.c +++ b/drivers/kvm/kvm_main.c @@ -361,6 +361,7 @@ static struct kvm *kvm_create_vm(void) if (!kvm) return ERR_PTR(-ENOMEM); + kvm_io_bus_init(&kvm->pio_bus); spin_lock_init(&kvm->lock); INIT_LIST_HEAD(&kvm->active_mmu_pages); spin_lock(&kvm_lock); @@ -475,6 +476,7 @@ static void kvm_destroy_vm(struct kvm *kvm) spin_lock(&kvm_lock); list_del(&kvm->vm_list); spin_unlock(&kvm_lock); + kvm_io_bus_destroy(&kvm->pio_bus); kvm_io_bus_destroy(&kvm->mmio_bus); kvm_free_vcpus(kvm); kvm_free_physmem(kvm); @@ -1110,6 +1112,12 @@ static struct kvm_io_device *vcpu_find_mmio_dev(struct kvm_vcpu *vcpu, return kvm_io_bus_find_dev(&vcpu->kvm->mmio_bus, addr); } +static struct kvm_io_device *vcpu_find_pio_dev(struct kvm_vcpu *vcpu, + gpa_t addr) +{ + return kvm_io_bus_find_dev(&vcpu->kvm->pio_bus, addr); +} + static int emulator_read_emulated(unsigned long addr, void *val, unsigned int bytes, @@ -1832,6 +1840,20 @@ static int complete_pio(struct kvm_vcpu *vcpu) return 0; } +void kernel_pio(struct kvm_io_device *pio_dev, struct kvm_vcpu *vcpu) +{ + /* TODO: String I/O for in kernel device */ + + if (vcpu->pio.in) + kvm_iodevice_read(pio_dev, vcpu->pio.port, + vcpu->pio.size, + vcpu->pio_data); + else + kvm_iodevice_write(pio_dev, vcpu->pio.port, + vcpu->pio.size, + vcpu->pio_data); +} + int kvm_setup_pio(struct kvm_vcpu *vcpu, struct kvm_run *run, int in, int size, unsigned long count, int string, int down, gva_t address, int rep, unsigned port) @@ -1840,6 +1862,7 @@ int kvm_setup_pio(struct kvm_vcpu *vcpu, struct kvm_run *run, int in, int i; int nr_pages = 1; struct page *page; + struct kvm_io_device *pio_dev; vcpu->run->exit_reason = KVM_EXIT_IO; vcpu->run->io.direction = in ? KVM_EXIT_IO_IN : KVM_EXIT_IO_OUT; @@ -1851,17 +1874,27 @@ int kvm_setup_pio(struct kvm_vcpu *vcpu, struct kvm_run *run, int in, vcpu->pio.cur_count = count; vcpu->pio.size = size; vcpu->pio.in = in; + vcpu->pio.port = port; vcpu->pio.string = string; vcpu->pio.down = down; vcpu->pio.guest_page_offset = offset_in_page(address); vcpu->pio.rep = rep; + pio_dev = vcpu_find_pio_dev(vcpu, port); if (!string) { kvm_arch_ops->cache_regs(vcpu); memcpy(vcpu->pio_data, &vcpu->regs[VCPU_REGS_RAX], 4); kvm_arch_ops->decache_regs(vcpu); + if (pio_dev) { + kernel_pio(pio_dev, vcpu); + complete_pio(vcpu); + return 1; + } return 0; } + /* TODO: String I/O for in kernel device */ + if (pio_dev) + printk(KERN_ERR "kvm_setup_pio: no string io support\n"); if (!count) { kvm_arch_ops->skip_emulated_instruction(vcpu); -- 1.5.2.2 - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ kvm-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.ne
[kvm-devel] [PATCH 04/20] KVM: VMX: Fix interrupt checking on lightweight exit
From: Gregory Haskins <[EMAIL PROTECTED]> With kernel-injected interrupts, we need to check for interrupts on lightweight exits too. Signed-off-by: Gregory Haskins <[EMAIL PROTECTED]> Signed-off-by: Avi Kivity <[EMAIL PROTECTED]> --- drivers/kvm/vmx.c |6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/kvm/vmx.c b/drivers/kvm/vmx.c index d06c362..b47ddcc 100644 --- a/drivers/kvm/vmx.c +++ b/drivers/kvm/vmx.c @@ -1992,13 +1992,13 @@ static int vmx_vcpu_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run) int r; preempted: - if (!vcpu->mmio_read_completed) - do_interrupt_requests(vcpu, kvm_run); - if (vcpu->guest_debug.enabled) kvm_guest_debug_pre(vcpu); again: + if (!vcpu->mmio_read_completed) + do_interrupt_requests(vcpu, kvm_run); + vmx_save_host_state(vcpu); kvm_load_guest_fpu(vcpu); -- 1.5.2.2 - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ kvm-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel
[kvm-devel] [PATCH 11/20] KVM: SVM: Reliably detect if SVM was disabled by BIOS
From: Joerg Roedel <[EMAIL PROTECTED]> This patch adds an implementation to the svm is_disabled function to detect reliably if the BIOS disabled the SVM feature in the CPU. This fixes the issues with kernel panics when loading the kvm-amd module on machines where SVM is available but disabled. Signed-off-by: Joerg Roedel <[EMAIL PROTECTED]> Signed-off-by: Avi Kivity <[EMAIL PROTECTED]> --- drivers/kvm/svm.c |6 ++ drivers/kvm/svm.h |3 +++ 2 files changed, 9 insertions(+), 0 deletions(-) diff --git a/drivers/kvm/svm.c b/drivers/kvm/svm.c index 62ec38c..a0d4428 100644 --- a/drivers/kvm/svm.c +++ b/drivers/kvm/svm.c @@ -1735,6 +1735,12 @@ static void svm_inject_page_fault(struct kvm_vcpu *vcpu, static int is_disabled(void) { + u64 vm_cr; + + rdmsrl(MSR_VM_CR, vm_cr); + if (vm_cr & (1 << SVM_VM_CR_SVM_DISABLE)) + return 1; + return 0; } diff --git a/drivers/kvm/svm.h b/drivers/kvm/svm.h index 5e93814..3b1b0f3 100644 --- a/drivers/kvm/svm.h +++ b/drivers/kvm/svm.h @@ -175,8 +175,11 @@ struct __attribute__ ((__packed__)) vmcb { #define SVM_CPUID_FUNC 0x800a #define MSR_EFER_SVME_MASK (1ULL << 12) +#define MSR_VM_CR 0xc0010114 #define MSR_VM_HSAVE_PA 0xc0010117ULL +#define SVM_VM_CR_SVM_DISABLE 4 + #define SVM_SELECTOR_S_SHIFT 4 #define SVM_SELECTOR_DPL_SHIFT 5 #define SVM_SELECTOR_P_SHIFT 7 -- 1.5.2.2 - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ kvm-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel
[kvm-devel] [PATCH 03/20] KVM: Adds support for in-kernel mmio handlers
From: Gregory Haskins <[EMAIL PROTECTED]> Signed-off-by: Gregory Haskins <[EMAIL PROTECTED]> Signed-off-by: Avi Kivity <[EMAIL PROTECTED]> --- drivers/kvm/kvm.h | 60 ++ drivers/kvm/kvm_main.c | 94 +-- 2 files changed, 142 insertions(+), 12 deletions(-) diff --git a/drivers/kvm/kvm.h b/drivers/kvm/kvm.h index b08272b..31846b1 100644 --- a/drivers/kvm/kvm.h +++ b/drivers/kvm/kvm.h @@ -265,6 +265,65 @@ struct kvm_stat { u32 efer_reload; }; +struct kvm_io_device { + void (*read)(struct kvm_io_device *this, +gpa_t addr, +int len, +void *val); + void (*write)(struct kvm_io_device *this, + gpa_t addr, + int len, + const void *val); + int (*in_range)(struct kvm_io_device *this, gpa_t addr); + void (*destructor)(struct kvm_io_device *this); + + void *private; +}; + +static inline void kvm_iodevice_read(struct kvm_io_device *dev, +gpa_t addr, +int len, +void *val) +{ + dev->read(dev, addr, len, val); +} + +static inline void kvm_iodevice_write(struct kvm_io_device *dev, + gpa_t addr, + int len, + const void *val) +{ + dev->write(dev, addr, len, val); +} + +static inline int kvm_iodevice_inrange(struct kvm_io_device *dev, gpa_t addr) +{ + return dev->in_range(dev, addr); +} + +static inline void kvm_iodevice_destructor(struct kvm_io_device *dev) +{ + dev->destructor(dev); +} + +/* + * It would be nice to use something smarter than a linear search, TBD... + * Thankfully we dont expect many devices to register (famous last words :), + * so until then it will suffice. At least its abstracted so we can change + * in one place. + */ +struct kvm_io_bus { + int dev_count; +#define NR_IOBUS_DEVS 6 + struct kvm_io_device *devs[NR_IOBUS_DEVS]; +}; + +void kvm_io_bus_init(struct kvm_io_bus *bus); +void kvm_io_bus_destroy(struct kvm_io_bus *bus); +struct kvm_io_device *kvm_io_bus_find_dev(struct kvm_io_bus *bus, gpa_t addr); +void kvm_io_bus_register_dev(struct kvm_io_bus *bus, +struct kvm_io_device *dev); + struct kvm_vcpu { struct kvm *kvm; union { @@ -393,6 +452,7 @@ struct kvm { unsigned long rmap_overflow; struct list_head vm_list; struct file *filp; + struct kvm_io_bus mmio_bus; }; struct descriptor_table { diff --git a/drivers/kvm/kvm_main.c b/drivers/kvm/kvm_main.c index 633c2ed..e157e28 100644 --- a/drivers/kvm/kvm_main.c +++ b/drivers/kvm/kvm_main.c @@ -366,6 +366,7 @@ static struct kvm *kvm_create_vm(void) spin_lock(&kvm_lock); list_add(&kvm->vm_list, &vm_list); spin_unlock(&kvm_lock); + kvm_io_bus_init(&kvm->mmio_bus); for (i = 0; i < KVM_MAX_VCPUS; ++i) { struct kvm_vcpu *vcpu = &kvm->vcpus[i]; @@ -474,6 +475,7 @@ static void kvm_destroy_vm(struct kvm *kvm) spin_lock(&kvm_lock); list_del(&kvm->vm_list); spin_unlock(&kvm_lock); + kvm_io_bus_destroy(&kvm->mmio_bus); kvm_free_vcpus(kvm); kvm_free_physmem(kvm); kfree(kvm); @@ -1097,12 +1099,25 @@ static int emulator_write_std(unsigned long addr, return X86EMUL_UNHANDLEABLE; } +static struct kvm_io_device *vcpu_find_mmio_dev(struct kvm_vcpu *vcpu, + gpa_t addr) +{ + /* +* Note that its important to have this wrapper function because +* in the very near future we will be checking for MMIOs against +* the LAPIC as well as the general MMIO bus +*/ + return kvm_io_bus_find_dev(&vcpu->kvm->mmio_bus, addr); +} + static int emulator_read_emulated(unsigned long addr, void *val, unsigned int bytes, struct x86_emulate_ctxt *ctxt) { - struct kvm_vcpu *vcpu = ctxt->vcpu; + struct kvm_vcpu *vcpu = ctxt->vcpu; + struct kvm_io_device *mmio_dev; + gpa_t gpa; if (vcpu->mmio_read_completed) { memcpy(val, vcpu->mmio_data, bytes); @@ -,18 +1126,26 @@ static int emulator_read_emulated(unsigned long addr, } else if (emulator_read_std(addr, val, bytes, ctxt) == X86EMUL_CONTINUE) return X86EMUL_CONTINUE; - else { - gpa_t gpa = vcpu->mmu.gva_to_gpa(vcpu, addr); - if (gpa == UNMAPPED_GVA) - return X86EMUL_PROPAGATE_FAULT; - vcpu->mmio_needed = 1; - vcpu->mmio_phys_addr = gpa; -
[kvm-devel] [PATCH 14/20] HOTPLUG: Add CPU_DYING notifier
KVM wants a notification when a cpu is about to die, so it can disable hardware extensions, but at a time when user processes cannot be scheduled on the cpu, so it doesn't try to use virtualization extensions after they have been disabled. This adds a CPU_DYING notification. The notification is called in atomic context on the doomed cpu. Signed-off-by: Avi Kivity <[EMAIL PROTECTED]> --- include/linux/notifier.h |3 +++ kernel/cpu.c | 16 ++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/include/linux/notifier.h b/include/linux/notifier.h index 9431101..576f2bb 100644 --- a/include/linux/notifier.h +++ b/include/linux/notifier.h @@ -196,6 +196,8 @@ extern int __srcu_notifier_call_chain(struct srcu_notifier_head *nh, #define CPU_DEAD 0x0007 /* CPU (unsigned)v dead */ #define CPU_LOCK_ACQUIRE 0x0008 /* Acquire all hotcpu locks */ #define CPU_LOCK_RELEASE 0x0009 /* Release all hotcpu locks */ +#define CPU_DYING 0x000A /* CPU (unsigned)v not running any task, + * not handling interrupts, soon dead */ /* Used for CPU hotplug events occuring while tasks are frozen due to a suspend * operation in progress @@ -208,6 +210,7 @@ extern int __srcu_notifier_call_chain(struct srcu_notifier_head *nh, #define CPU_DOWN_PREPARE_FROZEN(CPU_DOWN_PREPARE | CPU_TASKS_FROZEN) #define CPU_DOWN_FAILED_FROZEN (CPU_DOWN_FAILED | CPU_TASKS_FROZEN) #define CPU_DEAD_FROZEN(CPU_DEAD | CPU_TASKS_FROZEN) +#define CPU_DYING_FROZEN (CPU_DYING | CPU_TASKS_FROZEN) #endif /* __KERNEL__ */ #endif /* _LINUX_NOTIFIER_H */ diff --git a/kernel/cpu.c b/kernel/cpu.c index 208cf34..181ae70 100644 --- a/kernel/cpu.c +++ b/kernel/cpu.c @@ -103,11 +103,19 @@ static inline void check_for_tasks(int cpu) write_unlock_irq(&tasklist_lock); } +struct take_cpu_down_param { + unsigned long mod; + void *hcpu; +}; + /* Take this CPU down. */ -static int take_cpu_down(void *unused) +static int take_cpu_down(void *_param) { + struct take_cpu_down_param *param = _param; int err; + raw_notifier_call_chain(&cpu_chain, CPU_DYING | param->mod, + param->hcpu); /* Ensure this CPU doesn't handle any more interrupts. */ err = __cpu_disable(); if (err < 0) @@ -127,6 +135,10 @@ static int _cpu_down(unsigned int cpu, int tasks_frozen) cpumask_t old_allowed, tmp; void *hcpu = (void *)(long)cpu; unsigned long mod = tasks_frozen ? CPU_TASKS_FROZEN : 0; + struct take_cpu_down_param tcd_param = { + .mod = mod, + .hcpu = hcpu, + }; if (num_online_cpus() == 1) return -EBUSY; @@ -153,7 +165,7 @@ static int _cpu_down(unsigned int cpu, int tasks_frozen) set_cpus_allowed(current, tmp); mutex_lock(&cpu_bitmask_lock); - p = __stop_machine_run(take_cpu_down, NULL, cpu); + p = __stop_machine_run(take_cpu_down, &tcd_param, cpu); mutex_unlock(&cpu_bitmask_lock); if (IS_ERR(p) || cpu_online(cpu)) { -- 1.5.2.2 - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ kvm-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel
[kvm-devel] [PATCH 10/20] KVM: VMX: Remove unnecessary code in vmx_tlb_flush()
A vmexit implicitly flushes the tlb; the code is bogus. Noted by Shaohua Li. Signed-off-by: Avi Kivity <[EMAIL PROTECTED]> --- drivers/kvm/vmx.c |1 - 1 files changed, 0 insertions(+), 1 deletions(-) diff --git a/drivers/kvm/vmx.c b/drivers/kvm/vmx.c index 42a9163..7d04ffa 100644 --- a/drivers/kvm/vmx.c +++ b/drivers/kvm/vmx.c @@ -1987,7 +1987,6 @@ static int dm_request_for_irq_injection(struct kvm_vcpu *vcpu, static void vmx_flush_tlb(struct kvm_vcpu *vcpu) { - vmcs_writel(GUEST_CR3, vmcs_readl(GUEST_CR3)); } static int vmx_vcpu_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run) -- 1.5.2.2 - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ kvm-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel
[kvm-devel] [PATCH 12/20] KVM: Remove kvmfs in favor of the anonymous inodes source
kvm uses a pseudo filesystem, kvmfs, to generate inodes, a job that the new anonymous inodes source does much better. Cc: Davide Libenzi <[EMAIL PROTECTED]> Signed-off-by: Avi Kivity <[EMAIL PROTECTED]> --- drivers/kvm/kvm_main.c | 143 fs/anon_inodes.c |1 + include/linux/magic.h |1 - 3 files changed, 12 insertions(+), 133 deletions(-) diff --git a/drivers/kvm/kvm_main.c b/drivers/kvm/kvm_main.c index 5603000..26ca90f 100644 --- a/drivers/kvm/kvm_main.c +++ b/drivers/kvm/kvm_main.c @@ -43,6 +43,7 @@ #include #include #include +#include #include "x86_emulate.h" #include "segment_descriptor.h" @@ -81,8 +82,6 @@ static struct kvm_stats_debugfs_item { static struct dentry *debugfs_dir; -struct vfsmount *kvmfs_mnt; - #define MAX_IO_MSRS 256 #define CR0_RESEVED_BITS 0x1ffaffc0ULL @@ -104,55 +103,6 @@ struct segment_descriptor_64 { static long kvm_vcpu_ioctl(struct file *file, unsigned int ioctl, unsigned long arg); -static struct inode *kvmfs_inode(struct file_operations *fops) -{ - int error = -ENOMEM; - struct inode *inode = new_inode(kvmfs_mnt->mnt_sb); - - if (!inode) - goto eexit_1; - - inode->i_fop = fops; - - /* -* Mark the inode dirty from the very beginning, -* that way it will never be moved to the dirty -* list because mark_inode_dirty() will think -* that it already _is_ on the dirty list. -*/ - inode->i_state = I_DIRTY; - inode->i_mode = S_IRUSR | S_IWUSR; - inode->i_uid = current->fsuid; - inode->i_gid = current->fsgid; - inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; - return inode; - -eexit_1: - return ERR_PTR(error); -} - -static struct file *kvmfs_file(struct inode *inode, void *private_data) -{ - struct file *file = get_empty_filp(); - - if (!file) - return ERR_PTR(-ENFILE); - - file->f_path.mnt = mntget(kvmfs_mnt); - file->f_path.dentry = d_alloc_anon(inode); - if (!file->f_path.dentry) - return ERR_PTR(-ENOMEM); - file->f_mapping = inode->i_mapping; - - file->f_pos = 0; - file->f_flags = O_RDWR; - file->f_op = inode->i_fop; - file->f_mode = FMODE_READ | FMODE_WRITE; - file->f_version = 0; - file->private_data = private_data; - return file; -} - unsigned long segment_base(u16 selector) { struct descriptor_table gdt; @@ -2413,34 +2363,12 @@ static int create_vcpu_fd(struct kvm_vcpu *vcpu) struct inode *inode; struct file *file; + r = anon_inode_getfd(&fd, &inode, &file, +"kvm-vcpu", &kvm_vcpu_fops, vcpu); + if (r) + return r; atomic_inc(&vcpu->kvm->filp->f_count); - inode = kvmfs_inode(&kvm_vcpu_fops); - if (IS_ERR(inode)) { - r = PTR_ERR(inode); - goto out1; - } - - file = kvmfs_file(inode, vcpu); - if (IS_ERR(file)) { - r = PTR_ERR(file); - goto out2; - } - - r = get_unused_fd(); - if (r < 0) - goto out3; - fd = r; - fd_install(fd, file); - return fd; - -out3: - fput(file); -out2: - iput(inode); -out1: - fput(vcpu->kvm->filp); - return r; } /* @@ -2905,41 +2833,18 @@ static int kvm_dev_ioctl_create_vm(void) struct file *file; struct kvm *kvm; - inode = kvmfs_inode(&kvm_vm_fops); - if (IS_ERR(inode)) { - r = PTR_ERR(inode); - goto out1; - } - kvm = kvm_create_vm(); - if (IS_ERR(kvm)) { - r = PTR_ERR(kvm); - goto out2; + if (IS_ERR(kvm)) + return PTR_ERR(kvm); + r = anon_inode_getfd(&fd, &inode, &file, "kvm-vm", &kvm_vm_fops, kvm); + if (r) { + kvm_destroy_vm(kvm); + return r; } - file = kvmfs_file(inode, kvm); - if (IS_ERR(file)) { - r = PTR_ERR(file); - goto out3; - } kvm->filp = file; - r = get_unused_fd(); - if (r < 0) - goto out4; - fd = r; - fd_install(fd, file); - return fd; - -out4: - fput(file); -out3: - kvm_destroy_vm(kvm); -out2: - iput(inode); -out1: - return r; } static long kvm_dev_ioctl(struct file *filp, @@ -3211,18 +3116,6 @@ static struct sys_device kvm_sysdev = { hpa_t bad_page_address; -static int kvmfs_get_sb(struct file_system_type *fs_type, int flags, - const char *dev_name, void *data, struct vfsmount *mnt) -{ - return get_sb_pseudo(fs_type, "kvm:", NULL, KVMFS_SUPER_MAGIC, mnt); -} - -static struct file_system_type kvm_fs_type = { - .name = "kvmfs", - .get_sb = kvmfs_get_sb, - .k
[kvm-devel] [PATCH 07/20] KVM: Avoid useless memory write when possible
From: Luca Tettamanti <[EMAIL PROTECTED]> When writing to normal memory and the memory area is unchanged the write can be safely skipped, avoiding the costly kvm_mmu_pte_write. Signed-Off-By: Luca Tettamanti <[EMAIL PROTECTED]> Signed-off-by: Avi Kivity <[EMAIL PROTECTED]> --- drivers/kvm/kvm_main.c |6 -- 1 files changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/kvm/kvm_main.c b/drivers/kvm/kvm_main.c index 7826f16..5603000 100644 --- a/drivers/kvm/kvm_main.c +++ b/drivers/kvm/kvm_main.c @@ -1170,8 +1170,10 @@ static int emulator_write_phys(struct kvm_vcpu *vcpu, gpa_t gpa, return 0; mark_page_dirty(vcpu->kvm, gpa >> PAGE_SHIFT); virt = kmap_atomic(page, KM_USER0); - kvm_mmu_pte_write(vcpu, gpa, virt + offset, val, bytes); - memcpy(virt + offset_in_page(gpa), val, bytes); + if (memcmp(virt + offset_in_page(gpa), val, bytes)) { + kvm_mmu_pte_write(vcpu, gpa, virt + offset, val, bytes); + memcpy(virt + offset_in_page(gpa), val, bytes); + } kunmap_atomic(virt, KM_USER0); return 1; } -- 1.5.2.2 - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ kvm-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel
[kvm-devel] [PATCH 09/20] KVM: MMU: Fix Wrong tlb flush order
From: Shaohua Li <[EMAIL PROTECTED]> Need to flush the tlb after updating a pte, not before. Signed-off-by: Shaohua Li <[EMAIL PROTECTED]> Signed-off-by: Avi Kivity <[EMAIL PROTECTED]> --- drivers/kvm/mmu.c |2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/drivers/kvm/mmu.c b/drivers/kvm/mmu.c index ad50cfd..49ffbd3 100644 --- a/drivers/kvm/mmu.c +++ b/drivers/kvm/mmu.c @@ -441,8 +441,8 @@ static void rmap_write_protect(struct kvm_vcpu *vcpu, u64 gfn) BUG_ON(!(*spte & PT_WRITABLE_MASK)); rmap_printk("rmap_write_protect: spte %p %llx\n", spte, *spte); rmap_remove(vcpu, spte); - kvm_flush_remote_tlbs(vcpu->kvm); set_shadow_pte(spte, *spte & ~PT_WRITABLE_MASK); + kvm_flush_remote_tlbs(vcpu->kvm); } } -- 1.5.2.2 - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ kvm-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel
[kvm-devel] [PATCH 19/20] KVM: Tune hotplug/suspend IPIs
The hotplug IPIs can be called from the cpu on which we are currently running on, so use on_cpu(). Similarly, drop on_each_cpu() for the suspend/resume callbacks, as we're in atomic context here and only one cpu is up anyway. Signed-off-by: Avi Kivity <[EMAIL PROTECTED]> --- drivers/kvm/kvm_main.c |8 1 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/kvm/kvm_main.c b/drivers/kvm/kvm_main.c index 3226ad4..54cad51 100644 --- a/drivers/kvm/kvm_main.c +++ b/drivers/kvm/kvm_main.c @@ -3010,13 +3010,13 @@ static int kvm_cpu_hotplug(struct notifier_block *notifier, unsigned long val, case CPU_UP_CANCELED_FROZEN: printk(KERN_INFO "kvm: disabling virtualization on CPU%d\n", cpu); - smp_call_function_single(cpu, hardware_disable, NULL, 0, 1); + on_cpu(cpu, hardware_disable, NULL, 0, 1); break; case CPU_ONLINE: case CPU_ONLINE_FROZEN: printk(KERN_INFO "kvm: enabling virtualization on CPU%d\n", cpu); - smp_call_function_single(cpu, hardware_enable, NULL, 0, 1); + on_cpu(cpu, hardware_enable, NULL, 0, 1); break; } return NOTIFY_OK; @@ -3110,13 +3110,13 @@ static void kvm_exit_debug(void) static int kvm_suspend(struct sys_device *dev, pm_message_t state) { - on_each_cpu(hardware_disable, NULL, 0, 0); + hardware_disable(NULL); return 0; } static int kvm_resume(struct sys_device *dev) { - on_each_cpu(hardware_disable, NULL, 0, 0); + hardware_enable(NULL); return 0; } -- 1.5.2.2 - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ kvm-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel
[kvm-devel] [PATCH 17/20] SMP: Implement on_cpu()
This defines on_cpu() which is similar to smp_call_function_single() except that it works if cpu happens to be the current cpu. Can also be seen as a complement to on_each_cpu() (which also doesn't treat the current cpu specially). Signed-off-by: Avi Kivity <[EMAIL PROTECTED]> --- include/linux/smp.h | 16 kernel/softirq.c| 24 2 files changed, 40 insertions(+), 0 deletions(-) diff --git a/include/linux/smp.h b/include/linux/smp.h index 96ac21f..613edd2 100644 --- a/include/linux/smp.h +++ b/include/linux/smp.h @@ -7,6 +7,7 @@ */ #include +#include extern void cpu_idle(void); @@ -61,6 +62,11 @@ int smp_call_function_single(int cpuid, void (*func) (void *info), void *info, * Call a function on all processors */ int on_each_cpu(void (*func) (void *info), void *info, int retry, int wait); +/* + * Call a function on one processor + */ +int on_cpu(int cpu, void (*func)(void *info), void *info, + int retry, int wait); #define MSG_ALL_BUT_SELF 0x8000 /* Assume <32768 CPU's */ #define MSG_ALL0x8001 @@ -96,6 +102,16 @@ static inline int up_smp_call_function(void) local_irq_enable(); \ 0; \ }) + +static inline int on_cpu(int cpu, void (*func)(void *info), void *info, +int retry, int wait) +{ + local_irq_disable(); + func(info); + local_irq_enable(); + return 0; +} + static inline void smp_send_reschedule(int cpu) { } #define num_booting_cpus() 1 #define smp_prepare_boot_cpu() do {} while (0) diff --git a/kernel/softirq.c b/kernel/softirq.c index 0b9886a..11666f7 100644 --- a/kernel/softirq.c +++ b/kernel/softirq.c @@ -658,4 +658,28 @@ int on_each_cpu(void (*func) (void *info), void *info, int retry, int wait) return ret; } EXPORT_SYMBOL(on_each_cpu); + +/* + * Call a function on one processor, which might be the currently executing + * processor. + */ +int on_cpu(int cpu, void (*func) (void *info), void *info, + int retry, int wait) +{ + int ret; + int this_cpu; + + this_cpu = get_cpu(); + if (this_cpu == cpu) { + local_irq_disable(); + func(info); + local_irq_enable(); + ret = 0; + } else + ret = smp_call_function_single(cpu, func, info, retry, wait); + put_cpu(); + return ret; +} +EXPORT_SYMBOL(on_cpu); + #endif -- 1.5.2.2 - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ kvm-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel
[kvm-devel] [PATCH 15/20] HOTPLUG: Adapt cpuset hotplug callback to CPU_DYING
CPU_DYING is called in atomic context, so don't try to take any locks. Signed-off-by: Avi Kivity <[EMAIL PROTECTED]> --- kernel/cpuset.c |3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diff --git a/kernel/cpuset.c b/kernel/cpuset.c index 4c49188..c4d123f 100644 --- a/kernel/cpuset.c +++ b/kernel/cpuset.c @@ -2138,6 +2138,9 @@ static void common_cpu_mem_hotplug_unplug(void) static int cpuset_handle_cpuhp(struct notifier_block *nb, unsigned long phase, void *cpu) { + if (phase == CPU_DYING || phase == CPU_DYING_FROZEN) + return NOTIFY_DONE; + common_cpu_mem_hotplug_unplug(); return 0; } -- 1.5.2.2 - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ kvm-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel
[kvm-devel] [PATCH 08/20] KVM: VMX: Reinitialize the real-mode tss when entering real mode
Protected mode code may have corrupted the real-mode tss, so re-initialize it when switching to real mode. Signed-off-by: Avi Kivity <[EMAIL PROTECTED]> --- drivers/kvm/vmx.c |4 1 files changed, 4 insertions(+), 0 deletions(-) diff --git a/drivers/kvm/vmx.c b/drivers/kvm/vmx.c index b47ddcc..42a9163 100644 --- a/drivers/kvm/vmx.c +++ b/drivers/kvm/vmx.c @@ -31,6 +31,8 @@ MODULE_AUTHOR("Qumranet"); MODULE_LICENSE("GPL"); +static int init_rmode_tss(struct kvm *kvm); + static DEFINE_PER_CPU(struct vmcs *, vmxarea); static DEFINE_PER_CPU(struct vmcs *, current_vmcs); @@ -951,6 +953,8 @@ static void enter_rmode(struct kvm_vcpu *vcpu) fix_rmode_seg(VCPU_SREG_DS, &vcpu->rmode.ds); fix_rmode_seg(VCPU_SREG_GS, &vcpu->rmode.gs); fix_rmode_seg(VCPU_SREG_FS, &vcpu->rmode.fs); + + init_rmode_tss(vcpu->kvm); } #ifdef CONFIG_X86_64 -- 1.5.2.2 - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ kvm-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel
[kvm-devel] [PATCH 06/20] KVM: Fix x86 emulator writeback
From: Luca Tettamanti <[EMAIL PROTECTED]> When the old value and new one are the same the emulator skips the write; this is undesirable when the destination is a MMIO area and the write shall be performed regardless of the previous value. This optimization breaks e.g. a Linux guest APIC compiled without X86_GOOD_APIC. Remove the check and perform the writeback stage in the emulation unless it's explicitly disabled (currently push and some 2 bytes instructions may disable the writeback). Signed-Off-By: Luca Tettamanti <[EMAIL PROTECTED]> Signed-off-by: Avi Kivity <[EMAIL PROTECTED]> --- drivers/kvm/x86_emulate.c |9 + 1 files changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/kvm/x86_emulate.c b/drivers/kvm/x86_emulate.c index 92620e4..f60012d 100644 --- a/drivers/kvm/x86_emulate.c +++ b/drivers/kvm/x86_emulate.c @@ -485,6 +485,7 @@ x86_emulate_memop(struct x86_emulate_ctxt *ctxt, struct x86_emulate_ops *ops) int mode = ctxt->mode; unsigned long modrm_ea; int use_modrm_ea, index_reg = 0, base_reg = 0, scale, rip_relative = 0; + int no_wb = 0; /* Shadow copy of register state. Committed on successful emulation. */ unsigned long _regs[NR_VCPU_REGS]; @@ -1051,7 +1052,7 @@ done_prefixes: _regs[VCPU_REGS_RSP]), &dst.val, dst.bytes, ctxt)) != 0) goto done; - dst.val = dst.orig_val; /* skanky: disable writeback */ + no_wb = 1; break; default: goto cannot_emulate; @@ -1060,7 +1061,7 @@ done_prefixes: } writeback: - if ((d & Mov) || (dst.orig_val != dst.val)) { + if (!no_wb) { switch (dst.type) { case OP_REG: /* The 4-byte case *is* correct: in 64-bit mode we zero-extend. */ @@ -1168,7 +1169,7 @@ pop_instruction: goto done; register_address_increment(_regs[VCPU_REGS_RSP], op_bytes); - dst.orig_val = dst.val; /* Disable writeback. */ + no_wb = 1; /* Disable writeback. */ break; } goto writeback; @@ -1323,7 +1324,7 @@ twobyte_insn: twobyte_special_insn: /* Disable writeback. */ - dst.orig_val = dst.val; + no_wb = 1; switch (b) { case 0x09: /* wbinvd */ break; -- 1.5.2.2 - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ kvm-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel
[kvm-devel] [PATCH 18/20] KVM: Keep track of which cpus have virtualization enabled
By keeping track of which cpus have virtualization enabled, we prevent double-enable or double-disable during hotplug, which is a very fatal oops. Signed-off-by: Avi Kivity <[EMAIL PROTECTED]> --- drivers/kvm/kvm_main.c | 45 + 1 files changed, 33 insertions(+), 12 deletions(-) diff --git a/drivers/kvm/kvm_main.c b/drivers/kvm/kvm_main.c index ea02719..3226ad4 100644 --- a/drivers/kvm/kvm_main.c +++ b/drivers/kvm/kvm_main.c @@ -50,8 +50,12 @@ MODULE_LICENSE("GPL"); static DEFINE_SPINLOCK(kvm_lock); static LIST_HEAD(vm_list); +static cpumask_t cpus_hardware_enabled; + struct kvm_arch_ops *kvm_arch_ops; +static void hardware_disable(void *ignored); + #define STAT_OFFSET(x) offsetof(struct kvm_vcpu, stat.x) static struct kvm_stats_debugfs_item { @@ -2930,7 +2934,7 @@ static int kvm_reboot(struct notifier_block *notifier, unsigned long val, * in vmx root mode. */ printk(KERN_INFO "kvm: exiting hardware virtualization\n"); - on_each_cpu(kvm_arch_ops->hardware_disable, NULL, 0, 1); + on_each_cpu(hardware_disable, NULL, 0, 1); } return NOTIFY_OK; } @@ -2973,6 +2977,27 @@ static void decache_vcpus_on_cpu(int cpu) spin_unlock(&kvm_lock); } +static void hardware_enable(void *junk) +{ + int cpu = raw_smp_processor_id(); + + if (cpu_isset(cpu, cpus_hardware_enabled)) + return; + cpu_set(cpu, cpus_hardware_enabled); + kvm_arch_ops->hardware_enable(NULL); +} + +static void hardware_disable(void *junk) +{ + int cpu = raw_smp_processor_id(); + + if (!cpu_isset(cpu, cpus_hardware_enabled)) + return; + cpu_clear(cpu, cpus_hardware_enabled); + decache_vcpus_on_cpu(cpu); + kvm_arch_ops->hardware_disable(NULL); +} + static int kvm_cpu_hotplug(struct notifier_block *notifier, unsigned long val, void *v) { @@ -2985,16 +3010,13 @@ static int kvm_cpu_hotplug(struct notifier_block *notifier, unsigned long val, case CPU_UP_CANCELED_FROZEN: printk(KERN_INFO "kvm: disabling virtualization on CPU%d\n", cpu); - decache_vcpus_on_cpu(cpu); - smp_call_function_single(cpu, kvm_arch_ops->hardware_disable, -NULL, 0, 1); + smp_call_function_single(cpu, hardware_disable, NULL, 0, 1); break; case CPU_ONLINE: case CPU_ONLINE_FROZEN: printk(KERN_INFO "kvm: enabling virtualization on CPU%d\n", cpu); - smp_call_function_single(cpu, kvm_arch_ops->hardware_enable, -NULL, 0, 1); + smp_call_function_single(cpu, hardware_enable, NULL, 0, 1); break; } return NOTIFY_OK; @@ -3088,14 +3110,13 @@ static void kvm_exit_debug(void) static int kvm_suspend(struct sys_device *dev, pm_message_t state) { - decache_vcpus_on_cpu(raw_smp_processor_id()); - on_each_cpu(kvm_arch_ops->hardware_disable, NULL, 0, 1); + on_each_cpu(hardware_disable, NULL, 0, 0); return 0; } static int kvm_resume(struct sys_device *dev) { - on_each_cpu(kvm_arch_ops->hardware_enable, NULL, 0, 1); + on_each_cpu(hardware_disable, NULL, 0, 0); return 0; } @@ -3136,7 +3157,7 @@ int kvm_init_arch(struct kvm_arch_ops *ops, struct module *module) if (r < 0) goto out; - on_each_cpu(kvm_arch_ops->hardware_enable, NULL, 0, 1); + on_each_cpu(hardware_enable, NULL, 0, 1); r = register_cpu_notifier(&kvm_cpu_notifier); if (r) goto out_free_1; @@ -3168,7 +3189,7 @@ out_free_2: unregister_reboot_notifier(&kvm_reboot_notifier); unregister_cpu_notifier(&kvm_cpu_notifier); out_free_1: - on_each_cpu(kvm_arch_ops->hardware_disable, NULL, 0, 1); + on_each_cpu(hardware_disable, NULL, 0, 1); kvm_arch_ops->hardware_unsetup(); out: kvm_arch_ops = NULL; @@ -3182,7 +3203,7 @@ void kvm_exit_arch(void) sysdev_class_unregister(&kvm_sysdev_class); unregister_reboot_notifier(&kvm_reboot_notifier); unregister_cpu_notifier(&kvm_cpu_notifier); - on_each_cpu(kvm_arch_ops->hardware_disable, NULL, 0, 1); + on_each_cpu(hardware_disable, NULL, 0, 1); kvm_arch_ops->hardware_unsetup(); kvm_arch_ops = NULL; } -- 1.5.2.2 - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ kvm-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listi
[kvm-devel] [PATCH 16/20] HOTPLUG: Adapt thermal throttle to CPU_DYING
CPU_DYING is notified in atomic context, so no taking mutexes here. Signed-off-by: Avi Kivity <[EMAIL PROTECTED]> --- arch/i386/kernel/cpu/mcheck/therm_throt.c |6 -- 1 files changed, 4 insertions(+), 2 deletions(-) diff --git a/arch/i386/kernel/cpu/mcheck/therm_throt.c b/arch/i386/kernel/cpu/mcheck/therm_throt.c index 7ba7c3a..1203dc5 100644 --- a/arch/i386/kernel/cpu/mcheck/therm_throt.c +++ b/arch/i386/kernel/cpu/mcheck/therm_throt.c @@ -134,19 +134,21 @@ static __cpuinit int thermal_throttle_cpu_callback(struct notifier_block *nfb, int err; sys_dev = get_cpu_sysdev(cpu); - mutex_lock(&therm_cpu_lock); switch (action) { case CPU_ONLINE: case CPU_ONLINE_FROZEN: + mutex_lock(&therm_cpu_lock); err = thermal_throttle_add_dev(sys_dev); + mutex_unlock(&therm_cpu_lock); WARN_ON(err); break; case CPU_DEAD: case CPU_DEAD_FROZEN: + mutex_lock(&therm_cpu_lock); thermal_throttle_remove_dev(sys_dev); + mutex_unlock(&therm_cpu_lock); break; } - mutex_unlock(&therm_cpu_lock); return NOTIFY_OK; } -- 1.5.2.2 - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ kvm-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel
[kvm-devel] [PATCH 13/20] KVM: Clean up #includes
Remove unnecessary ones, and rearange the remaining in the standard order. Signed-off-by: Avi Kivity <[EMAIL PROTECTED]> --- drivers/kvm/kvm_main.c | 18 +++--- drivers/kvm/mmu.c | 10 ++ drivers/kvm/svm.c |7 --- drivers/kvm/vmx.c |5 +++-- 4 files changed, 20 insertions(+), 20 deletions(-) diff --git a/drivers/kvm/kvm_main.c b/drivers/kvm/kvm_main.c index 26ca90f..ea02719 100644 --- a/drivers/kvm/kvm_main.c +++ b/drivers/kvm/kvm_main.c @@ -16,37 +16,33 @@ */ #include "kvm.h" +#include "x86_emulate.h" +#include "segment_descriptor.h" #include #include #include -#include -#include #include #include -#include #include #include #include -#include #include -#include #include #include #include -#include #include #include -#include -#include -#include #include #include #include #include -#include "x86_emulate.h" -#include "segment_descriptor.h" +#include +#include +#include +#include +#include MODULE_AUTHOR("Qumranet"); MODULE_LICENSE("GPL"); diff --git a/drivers/kvm/mmu.c b/drivers/kvm/mmu.c index 49ffbd3..b297a6b 100644 --- a/drivers/kvm/mmu.c +++ b/drivers/kvm/mmu.c @@ -16,16 +16,18 @@ * the COPYING file in the top-level directory. * */ + +#include "vmx.h" +#include "kvm.h" + #include #include -#include #include #include #include -#include -#include "vmx.h" -#include "kvm.h" +#include +#include #undef MMU_DEBUG diff --git a/drivers/kvm/svm.c b/drivers/kvm/svm.c index a0d4428..bc818cc 100644 --- a/drivers/kvm/svm.c +++ b/drivers/kvm/svm.c @@ -14,16 +14,17 @@ * */ +#include "kvm_svm.h" +#include "x86_emulate.h" + #include #include #include #include #include #include -#include -#include "kvm_svm.h" -#include "x86_emulate.h" +#include MODULE_AUTHOR("Qumranet"); MODULE_LICENSE("GPL"); diff --git a/drivers/kvm/vmx.c b/drivers/kvm/vmx.c index 7d04ffa..80628f6 100644 --- a/drivers/kvm/vmx.c +++ b/drivers/kvm/vmx.c @@ -17,17 +17,18 @@ #include "kvm.h" #include "vmx.h" +#include "segment_descriptor.h" + #include #include #include #include #include #include + #include #include -#include "segment_descriptor.h" - MODULE_AUTHOR("Qumranet"); MODULE_LICENSE("GPL"); -- 1.5.2.2 - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ kvm-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel
[kvm-devel] [PATCH 20/20] KVM: Use CPU_DYING for disabling virtualization
Only at the CPU_DYING stage can we be sure that no user process will be scheduled onto the cpu and oops when trying to use virtualization extensions. Signed-off-by: Avi Kivity <[EMAIL PROTECTED]> --- drivers/kvm/kvm_main.c |4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/kvm/kvm_main.c b/drivers/kvm/kvm_main.c index 54cad51..83bb284 100644 --- a/drivers/kvm/kvm_main.c +++ b/drivers/kvm/kvm_main.c @@ -3004,8 +3004,8 @@ static int kvm_cpu_hotplug(struct notifier_block *notifier, unsigned long val, int cpu = (long)v; switch (val) { - case CPU_DOWN_PREPARE: - case CPU_DOWN_PREPARE_FROZEN: + case CPU_DYING: + case CPU_DYING_FROZEN: case CPU_UP_CANCELED: case CPU_UP_CANCELED_FROZEN: printk(KERN_INFO "kvm: disabling virtualization on CPU%d\n", -- 1.5.2.2 - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ kvm-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel
Re: [kvm-devel] bug concering Solaris ?
Adrian Lambeck wrote: > I have question concerning solaris as a guest system. Windows XP and > Linux are up and running without problems. > Now I would like to us Solaris10 for x86 too. I downloaded the ISO image > and validated the MD5 checksum but when I start QEMU with "boot d" and > -cdrom="location of the DVD image", QEMU dies with the following > exception right after trying to access the cdrom drive: > > exception 6 (0) > rax 0018 rbx 8d06 rcx f000ff53 rdx > > rsi rdi rsp 0005087e rbp > > r8 r9 r10 r11 > > r12 r13 r14 r15 > > rip 0003 rflags 00233002 > cs (/ p 1 dpl 3 db 0 s 1 type 3 l 0 g 0 avl 0) > ds (/ p 1 dpl 3 db 0 s 1 type 3 l 0 g 0 avl 0) > es (/ p 1 dpl 3 db 0 s 1 type 3 l 0 g 0 avl 0) > ss (/ p 1 dpl 3 db 0 s 1 type 3 l 0 g 0 avl 0) > fs (/ p 1 dpl 3 db 0 s 1 type 3 l 0 g 0 avl 0) > gs (/ p 1 dpl 3 db 0 s 1 type 3 l 0 g 0 avl 0) > tr 0028 (2085/2088 p 1 dpl 0 db 0 s 0 type b l 0 g 0 avl 0) > ldt (/ p 1 dpl 0 db 0 s 0 type 2 l 0 g 0 avl 0) > gdt 8548/40 > idt 1693b8/7ff > cr0 6010 cr2 0 cr3 189000 cr4 90 cr8 0 efer 0 > code: f0 d0 8b 00 00 53 ff 00 f0 53 ff 00 f0 53 ff 00 f0 53 ff 00 f0 53 > ff 00 f0 53 ff 00 f0 a5 > qemu exited: vdeq quits > > > Are there any ideas how this issue can be resolved? > I tried the same setup with the official qemu-0.9 which worked without > problems. > This looks like the real mode problem (see http://kvm.qumranet.com/kvmwiki/Intel_Real_Mode_Emulation_Problems) (are you on an Intel cpu?), although the symptoms aren't exactly the usual ones. I suggest installing with -no-kvm, and then booting the newly installed guest with kvm. -- error compiling committee.c: too many arguments to function - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ kvm-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel
Re: [kvm-devel] [PATCH 09/20] KVM: MMU: Fix Wrong tlb flush order
* Avi Kivity <[EMAIL PROTECTED]> wrote: > From: Shaohua Li <[EMAIL PROTECTED]> > > Need to flush the tlb after updating a pte, not before. > rmap_remove(vcpu, spte); > - kvm_flush_remote_tlbs(vcpu->kvm); > set_shadow_pte(spte, *spte & ~PT_WRITABLE_MASK); > + kvm_flush_remote_tlbs(vcpu->kvm); hm, isnt this a must-have fix for v2.6.22 (and .21) as well? Ingo - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ kvm-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel
Re: [kvm-devel] [PATCH 09/20] KVM: MMU: Fix Wrong tlb flush order
Ingo Molnar wrote: > * Avi Kivity <[EMAIL PROTECTED]> wrote: > > >> From: Shaohua Li <[EMAIL PROTECTED]> >> >> Need to flush the tlb after updating a pte, not before. >> > > >> rmap_remove(vcpu, spte); >> -kvm_flush_remote_tlbs(vcpu->kvm); >> set_shadow_pte(spte, *spte & ~PT_WRITABLE_MASK); >> +kvm_flush_remote_tlbs(vcpu->kvm); >> > > hm, isnt this a must-have fix for v2.6.22 (and .21) as well? > Guest SMP support is only enabled by another patch in this patchset. -- error compiling committee.c: too many arguments to function - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ kvm-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel
[kvm-devel] [PATCH][RFC] kvm-scheduler integration
Intel VT essentially introduces a new set of registers into the processor; this means we cannot preempt kvm in kernel mode lest a new VM run with and old VM's registers. In addition, kvm lazy switches some host registers as well. (AMD does not introduce new registers, but we still want lazy msr switching, and we want to know when we move to a different cpu in order to be able to guarantee a monotonously increasing tsc). Current kvm code simply disables preemption when guest context is in use. This, however, has many drawbacks: - some kvm mmu code is O(n), causing possibly unbounded latencies and causing -rt great unhappiness. - the mmu code wants to sleep (especially with guest paging), but can't. - some optimizations are not possible; for example, if we switch from one VM to another, we need not restore some host registers (as they will simply be overwritten with the new guest registers immediately). This patch adds hooks to the scheduler that allow kvm to be notified about scheduling decisions involving virtual machines. When we schedule out a VM, kvm is told to swap guest registers out; when we schedule the VM in, we swap the registers back in. Note that this patch does not include optimizations; it just makes most kvm code preemptible. A follow on patch to convert the kvm spinlock to a mutex should be trivial. The only fly in the ointment is that it crashes quite soon. Haven't figured out why yet, but comments on the general direction would be welcome. Signed-off-by: Avi Kivity <[EMAIL PROTECTED]> diff --git a/drivers/kvm/Kconfig b/drivers/kvm/Kconfig index 33fa28a..b6aadc8 100644 --- a/drivers/kvm/Kconfig +++ b/drivers/kvm/Kconfig @@ -40,4 +40,9 @@ config KVM_AMD Provides support for KVM on AMD processors equipped with the AMD-V (SVM) extensions. +config SCHED_KVM + bool + default y + depends on KVM + endif # VIRTUALIZATION diff --git a/drivers/kvm/kvm.h b/drivers/kvm/kvm.h index a7c5e6b..bb97dcc 100644 --- a/drivers/kvm/kvm.h +++ b/drivers/kvm/kvm.h @@ -474,7 +474,7 @@ struct kvm_arch_ops { int (*vcpu_create)(struct kvm_vcpu *vcpu); void (*vcpu_free)(struct kvm_vcpu *vcpu); - void (*vcpu_load)(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); diff --git a/drivers/kvm/kvm_main.c b/drivers/kvm/kvm_main.c index ea02719..eb742d4 100644 --- a/drivers/kvm/kvm_main.c +++ b/drivers/kvm/kvm_main.c @@ -230,8 +230,13 @@ EXPORT_SYMBOL_GPL(kvm_put_guest_fpu); */ static void vcpu_load(struct kvm_vcpu *vcpu) { + int cpu; + mutex_lock(&vcpu->mutex); - kvm_arch_ops->vcpu_load(vcpu); + cpu = get_cpu(); + sched_load_kvm_state(vcpu); + kvm_arch_ops->vcpu_load(vcpu, cpu); + put_cpu(); } /* @@ -241,19 +246,26 @@ static void vcpu_load(struct kvm_vcpu *vcpu) static struct kvm_vcpu *vcpu_load_slot(struct kvm *kvm, int slot) { struct kvm_vcpu *vcpu = &kvm->vcpus[slot]; + int cpu; mutex_lock(&vcpu->mutex); if (!vcpu->vmcs) { mutex_unlock(&vcpu->mutex); return NULL; } - kvm_arch_ops->vcpu_load(vcpu); + cpu = get_cpu(); + sched_load_kvm_state(vcpu); + kvm_arch_ops->vcpu_load(vcpu, cpu); + put_cpu(); return vcpu; } static void vcpu_put(struct kvm_vcpu *vcpu) { + preempt_disable(); kvm_arch_ops->vcpu_put(vcpu); + sched_put_kvm_state(); + preempt_enable(); mutex_unlock(&vcpu->mutex); } @@ -1650,9 +1662,7 @@ void kvm_resched(struct kvm_vcpu *vcpu) { if (!need_resched()) return; - vcpu_put(vcpu); cond_resched(); - vcpu_load(vcpu); } EXPORT_SYMBOL_GPL(kvm_resched); @@ -1718,11 +1728,9 @@ static int pio_copy_data(struct kvm_vcpu *vcpu) unsigned bytes; int nr_pages = vcpu->pio.guest_pages[1] ? 2 : 1; - kvm_arch_ops->vcpu_put(vcpu); q = vmap(vcpu->pio.guest_pages, nr_pages, VM_READ|VM_WRITE, PAGE_KERNEL); if (!q) { - kvm_arch_ops->vcpu_load(vcpu); free_pio_guest_pages(vcpu); return -ENOMEM; } @@ -1734,7 +1742,6 @@ static int pio_copy_data(struct kvm_vcpu *vcpu) memcpy(p, q, bytes); q -= vcpu->pio.guest_page_offset; vunmap(q); - kvm_arch_ops->vcpu_load(vcpu); free_pio_guest_pages(vcpu); return 0; } @@ -2375,6 +2382,7 @@ static int kvm_vm_ioctl_create_vcpu(struct kvm *kvm, int n) int r; struct kvm_vcpu *vcpu; struct page *page; + int cpu; r = -EINVAL; if (!valid_vcpu(n)) @@ -2414,7 +2422,10 @@ static int kvm_vm_ioctl_create_vcpu(struct kvm *kvm, int n) if (r < 0) goto out_free_vcpus; - kvm_arch_ops->vcpu_load(vcpu); + cpu = g
Re: [kvm-devel] [PATCH][RFC] kvm-scheduler integration
* Avi Kivity <[EMAIL PROTECTED]> wrote: > Intel VT essentially introduces a new set of registers into the > processor; this means we cannot preempt kvm in kernel mode lest a new > VM run with and old VM's registers. In addition, kvm lazy switches > some host registers as well. (AMD does not introduce new registers, > but we still want lazy msr switching, and we want to know when we move > to a different cpu in order to be able to guarantee a monotonously > increasing tsc). > > Current kvm code simply disables preemption when guest context is in > use. This, however, has many drawbacks: > > - some kvm mmu code is O(n), causing possibly unbounded latencies and causing > -rt great unhappiness. > - the mmu code wants to sleep (especially with guest paging), but can't. > - some optimizations are not possible; for example, if we switch from one > VM to another, we need not restore some host registers (as they will simply > be overwritten with the new guest registers immediately). > > This patch adds hooks to the scheduler that allow kvm to be notified > about scheduling decisions involving virtual machines. When we > schedule out a VM, kvm is told to swap guest registers out; when we > schedule the VM in, we swap the registers back in. hm, why not do what i have in -rt? See the patch below. Seems to work fine for me, although i might be missing something. Ingo -> Subject: [patch] kvm: make vcpu_load/put preemptible From: Ingo Molnar <[EMAIL PROTECTED]> make vcpu_load/put preemptible. Signed-off-by: Ingo Molnar <[EMAIL PROTECTED]> --- drivers/kvm/svm.c | 13 ++--- drivers/kvm/vmx.c | 15 --- 2 files changed, 22 insertions(+), 6 deletions(-) Index: linux-rt-rebase.q/drivers/kvm/svm.c === --- linux-rt-rebase.q.orig/drivers/kvm/svm.c +++ linux-rt-rebase.q/drivers/kvm/svm.c @@ -610,9 +610,17 @@ static void svm_free_vcpu(struct kvm_vcp static void svm_vcpu_load(struct kvm_vcpu *vcpu) { - int cpu, i; + int cpu = raw_smp_processor_id(), i; + cpumask_t this_mask = cpumask_of_cpu(cpu); + + /* +* Keep the context preemptible, but do not migrate +* away to another CPU. TODO: make sure this persists. +* Save/restore original mask. +*/ + if (unlikely(!cpus_equal(current->cpus_allowed, this_mask))) + set_cpus_allowed(current, cpumask_of_cpu(cpu)); - cpu = get_cpu(); if (unlikely(cpu != vcpu->cpu)) { u64 tsc_this, delta; @@ -638,7 +646,6 @@ static void svm_vcpu_put(struct kvm_vcpu wrmsrl(host_save_user_msrs[i], vcpu->svm->host_user_msrs[i]); rdtscll(vcpu->host_tsc); - put_cpu(); } static void svm_vcpu_decache(struct kvm_vcpu *vcpu) Index: linux-rt-rebase.q/drivers/kvm/vmx.c === --- linux-rt-rebase.q.orig/drivers/kvm/vmx.c +++ linux-rt-rebase.q/drivers/kvm/vmx.c @@ -241,9 +241,16 @@ static void vmcs_set_bits(unsigned long static void vmx_vcpu_load(struct kvm_vcpu *vcpu) { u64 phys_addr = __pa(vcpu->vmcs); - int cpu; + int cpu = raw_smp_processor_id(); + cpumask_t this_mask = cpumask_of_cpu(cpu); - cpu = get_cpu(); + /* +* Keep the context preemptible, but do not migrate +* away to another CPU. TODO: make sure this persists. +* Save/restore original mask. +*/ + if (unlikely(!cpus_equal(current->cpus_allowed, this_mask))) + set_cpus_allowed(current, cpumask_of_cpu(cpu)); if (vcpu->cpu != cpu) vcpu_clear(vcpu); @@ -281,7 +288,6 @@ static void vmx_vcpu_load(struct kvm_vcp static void vmx_vcpu_put(struct kvm_vcpu *vcpu) { kvm_put_guest_fpu(vcpu); - put_cpu(); } static void vmx_vcpu_decache(struct kvm_vcpu *vcpu) @@ -1862,6 +1868,7 @@ again: } #endif + preempt_disable(); asm ( /* Store host registers */ "pushf \n\t" @@ -2002,6 +2009,8 @@ again: reload_tss(); } + preempt_enable(); + ++vcpu->stat.exits; #ifdef CONFIG_X86_64 - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ kvm-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel
Re: [kvm-devel] [PATCH][RFC] kvm-scheduler integration
Ingo Molnar wrote: > * Avi Kivity <[EMAIL PROTECTED]> wrote: > > >> Intel VT essentially introduces a new set of registers into the >> processor; this means we cannot preempt kvm in kernel mode lest a new >> VM run with and old VM's registers. In addition, kvm lazy switches >> some host registers as well. (AMD does not introduce new registers, >> but we still want lazy msr switching, and we want to know when we move >> to a different cpu in order to be able to guarantee a monotonously >> increasing tsc). >> >> Current kvm code simply disables preemption when guest context is in >> use. This, however, has many drawbacks: >> >> - some kvm mmu code is O(n), causing possibly unbounded latencies and causing >> -rt great unhappiness. >> - the mmu code wants to sleep (especially with guest paging), but can't. >> - some optimizations are not possible; for example, if we switch from one >> VM to another, we need not restore some host registers (as they will simply >> be overwritten with the new guest registers immediately). >> >> This patch adds hooks to the scheduler that allow kvm to be notified >> about scheduling decisions involving virtual machines. When we >> schedule out a VM, kvm is told to swap guest registers out; when we >> schedule the VM in, we swap the registers back in. >> > > hm, why not do what i have in -rt? See the patch below. Seems to work > fine for me, although i might be missing something. > How can this work with >1 VM? We need to execute vmptrld with the new VM's vmcs before touching any VT registers. Recent kvm also keeps the guest syscall msrs on the host, so if you switch context to a process that then issues a syscall, you enter the host kernel at the guest syscall entry point... makes for nice stacktraces. > Ingo > > -> > Subject: [patch] kvm: make vcpu_load/put preemptible > From: Ingo Molnar <[EMAIL PROTECTED]> > > make vcpu_load/put preemptible. > > Signed-off-by: Ingo Molnar <[EMAIL PROTECTED]> > --- > drivers/kvm/svm.c | 13 ++--- > drivers/kvm/vmx.c | 15 --- > 2 files changed, 22 insertions(+), 6 deletions(-) > > Index: linux-rt-rebase.q/drivers/kvm/svm.c > === > --- linux-rt-rebase.q.orig/drivers/kvm/svm.c > +++ linux-rt-rebase.q/drivers/kvm/svm.c > @@ -610,9 +610,17 @@ static void svm_free_vcpu(struct kvm_vcp > > static void svm_vcpu_load(struct kvm_vcpu *vcpu) > { > - int cpu, i; > + int cpu = raw_smp_processor_id(), i; > + cpumask_t this_mask = cpumask_of_cpu(cpu); > + > + /* > + * Keep the context preemptible, but do not migrate > + * away to another CPU. TODO: make sure this persists. > + * Save/restore original mask. > + */ > + if (unlikely(!cpus_equal(current->cpus_allowed, this_mask))) > + set_cpus_allowed(current, cpumask_of_cpu(cpu)); > > - cpu = get_cpu(); > if (unlikely(cpu != vcpu->cpu)) { > u64 tsc_this, delta; > > @@ -638,7 +646,6 @@ static void svm_vcpu_put(struct kvm_vcpu > wrmsrl(host_save_user_msrs[i], vcpu->svm->host_user_msrs[i]); > > rdtscll(vcpu->host_tsc); > - put_cpu(); > } > > static void svm_vcpu_decache(struct kvm_vcpu *vcpu) > Index: linux-rt-rebase.q/drivers/kvm/vmx.c > === > --- linux-rt-rebase.q.orig/drivers/kvm/vmx.c > +++ linux-rt-rebase.q/drivers/kvm/vmx.c > @@ -241,9 +241,16 @@ static void vmcs_set_bits(unsigned long > static void vmx_vcpu_load(struct kvm_vcpu *vcpu) > { > u64 phys_addr = __pa(vcpu->vmcs); > - int cpu; > + int cpu = raw_smp_processor_id(); > + cpumask_t this_mask = cpumask_of_cpu(cpu); > > - cpu = get_cpu(); > + /* > + * Keep the context preemptible, but do not migrate > + * away to another CPU. TODO: make sure this persists. > + * Save/restore original mask. > + */ > + if (unlikely(!cpus_equal(current->cpus_allowed, this_mask))) > + set_cpus_allowed(current, cpumask_of_cpu(cpu)); > > if (vcpu->cpu != cpu) > vcpu_clear(vcpu); > @@ -281,7 +288,6 @@ static void vmx_vcpu_load(struct kvm_vcp > static void vmx_vcpu_put(struct kvm_vcpu *vcpu) > { > kvm_put_guest_fpu(vcpu); > - put_cpu(); > } > > static void vmx_vcpu_decache(struct kvm_vcpu *vcpu) > @@ -1862,6 +1868,7 @@ again: > } > #endif > > + preempt_disable(); > asm ( > /* Store host registers */ > "pushf \n\t" > @@ -2002,6 +2009,8 @@ again: > > reload_tss(); > } > + preempt_enable(); > + > ++vcpu->stat.exits; > > #ifdef CONFIG_X86_64 > -- error compiling committee.c: too many arguments to function - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version
Re: [kvm-devel] [PATCH][RFC] kvm-scheduler integration
* Avi Kivity <[EMAIL PROTECTED]> wrote: > +#ifdef CONFIG_SCHED_KVM > +static __read_mostly struct sched_kvm_hooks kvm_hooks; > +#endif please just add a current->put_vcpu() function pointer instead of this hooks thing. > static inline void prepare_task_switch(struct rq *rq, struct task_struct > *next) > { > + unload_kvm_vcpu(current); > prepare_lock_switch(rq, next); > prepare_arch_switch(next); > } > @@ -1860,6 +1912,7 @@ static inline void finish_task_switch(struct rq *rq, > struct task_struct *prev) > prev_state = prev->state; > finish_arch_switch(prev); > finish_lock_switch(rq, prev); > + reload_kvm_vcpu(current); ok, this looks certainly cheap enough from a scheduler POV, and it cleans up the whole KVM/scheduling interaction quite nicely. (I'd not bother with tweaking the migration logic, there's enough incentive for the scheduler to keep tasks from migrating unnecessarily.) Ingo - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ kvm-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel
Re: [kvm-devel] [PATCH][RFC] kvm-scheduler integration
* Avi Kivity <[EMAIL PROTECTED]> wrote: > > hm, why not do what i have in -rt? See the patch below. Seems to > > work fine for me, although i might be missing something. > > How can this work with >1 VM? We need to execute vmptrld with the new > VM's vmcs before touching any VT registers. yeah, indeed... Ingo - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ kvm-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel
Re: [kvm-devel] [PATCH][RFC] kvm-scheduler integration
Ingo Molnar wrote: > * Avi Kivity <[EMAIL PROTECTED]> wrote: > > >> +#ifdef CONFIG_SCHED_KVM >> +static __read_mostly struct sched_kvm_hooks kvm_hooks; >> +#endif >> > > please just add a current->put_vcpu() function pointer instead of this > hooks thing. > > Won't that increase task_struct (16 bytes on 64-bit) unnecessarily? The function pointers are common to all virtual machines. >> static inline void prepare_task_switch(struct rq *rq, struct task_struct >> *next) >> { >> +unload_kvm_vcpu(current); >> prepare_lock_switch(rq, next); >> prepare_arch_switch(next); >> } >> @@ -1860,6 +1912,7 @@ static inline void finish_task_switch(struct rq *rq, >> struct task_struct *prev) >> prev_state = prev->state; >> finish_arch_switch(prev); >> finish_lock_switch(rq, prev); >> +reload_kvm_vcpu(current); >> > > ok, this looks certainly cheap enough from a scheduler POV, and it > cleans up the whole KVM/scheduling interaction quite nicely. (I'd not > bother with tweaking the migration logic, there's enough incentive for > the scheduler to keep tasks from migrating unnecessarily.) > Okay. -- error compiling committee.c: too many arguments to function - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ kvm-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel
Re: [kvm-devel] [PATCH 11/20] KVM: SVM: Reliably detect if SVM was disabled by BIOS
seems like we probably want this for 2.6.22... it fixes a panic that I've seen actually reported by several users. Is there any risk to merging it? i guess getting it into 2.6.22.1 would be OK too. - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ kvm-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel
Re: [kvm-devel] Use host CPUID processor info
Avi Kivity wrote: > Dong, Eddie wrote: >> Use host cpu model name, type, family, Model, stepping for guest. >> >> Against head. >> >> > > This is turning into a mix of the qemu cpuid and the host cpuid. We > need to think of a way to make this controllable. > Actually I am wondering why we need a Qemu CPUID. A basic concept of virtualization is that good user software (following ABI) will not know if it is running in VM or natively. But now with qemu cpuid, any application knows "I am running in a VM". Is that really what we want? thanks, eddie - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ kvm-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel
Re: [kvm-devel] [PATCH 11/20] KVM: SVM: Reliably detect if SVM was disabled by BIOS
Roland Dreier wrote: > seems like we probably want this for 2.6.22... it fixes a panic that > I've seen actually reported by several users. Is there any risk to > merging it? > > i guess getting it into 2.6.22.1 would be OK too. > Well, there were reports of miscompiles with the original patch. This one is hopefully fixed. I'll wait a day or two and upstream it. -- error compiling committee.c: too many arguments to function - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ kvm-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel
Re: [kvm-devel] [PATCH][RFC] kvm-scheduler integration
* Avi Kivity <[EMAIL PROTECTED]> wrote: > >>+#ifdef CONFIG_SCHED_KVM > >>+static __read_mostly struct sched_kvm_hooks kvm_hooks; > >>+#endif > > > >please just add a current->put_vcpu() function pointer instead of > >this hooks thing. > > Won't that increase task_struct (16 bytes on 64-bit) unnecessarily? > The function pointers are common to all virtual machines. well, this function pointer could then be reused by other virtual machines as well, couldnt it? If the task struct overhead is a problem (it really isnt, and it's dependent on CONFIG_KVM) then we could switch it around to a notifier-alike mechanism. Ingo - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ kvm-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel
Re: [kvm-devel] Use host CPUID processor info
Dong, Eddie wrote: > Avi Kivity wrote: > >> Dong, Eddie wrote: >> >>> Use host cpu model name, type, family, Model, stepping for guest. >>> >>> Against head. >>> >>> >>> >> This is turning into a mix of the qemu cpuid and the host cpuid. We >> need to think of a way to make this controllable. >> >> > Actually I am wondering why we need a Qemu CPUID. A basic concept of > virtualization is that good user software (following ABI) will not know > if it is running in VM or natively. But now with qemu cpuid, any > application knows "I am running in a VM". Is that really what we want? > One of the uses of virtualization is to abstract the underlying hardware, so that a VM image can run on any platform (live migration is an example of this use case). For that we must not let any detail of the hardware be visible. On the other hand, other users (desktop users, or users with homogeneous server farms) will want to use the full capabilities of the hardware, requiring the host cpuid to be exposed. We need to support both use cases. -- error compiling committee.c: too many arguments to function - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ kvm-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel
Re: [kvm-devel] [PATCH][RFC] kvm-scheduler integration
Ingo Molnar wrote: > * Avi Kivity <[EMAIL PROTECTED]> wrote: > > +#ifdef CONFIG_SCHED_KVM +static __read_mostly struct sched_kvm_hooks kvm_hooks; +#endif >>> please just add a current->put_vcpu() function pointer instead of >>> this hooks thing. >>> >> Won't that increase task_struct (16 bytes on 64-bit) unnecessarily? >> The function pointers are common to all virtual machines. >> > > well, this function pointer could then be reused by other virtual > machines as well, couldnt it? I don't get this. If we add a couple of members to task_struct, it can't be reused. The values will be the same across all tasks, but the memory will be gone (including tasks which aren't virtual machines). > If the task struct overhead is a problem > (it really isnt, and it's dependent on CONFIG_KVM) then we could switch > it around to a notifier-alike mechanism. > I'm hoping that CONFIG_KVM will be enabled on most distro kernels, so we need to optimize for that case as well. -- error compiling committee.c: too many arguments to function - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ kvm-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel
Re: [kvm-devel] [PATCH][RFC] kvm-scheduler integration
* Avi Kivity <[EMAIL PROTECTED]> wrote: > >> Won't that increase task_struct (16 bytes on 64-bit) unnecessarily? > >> The function pointers are common to all virtual machines. > > > > well, this function pointer could then be reused by other virtual > > machines as well, couldnt it? > > I don't get this. If we add a couple of members to task_struct, it > can't be reused. The values will be the same across all tasks, but > the memory will be gone (including tasks which aren't virtual > machines). i mean, the function pointer is set by KVM, but it could be set to a different value by other hypervisors. but ... no strong feelings either way, your patch is certainly fine. Acked-by: Ingo Molnar <[EMAIL PROTECTED]> Ingo - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ kvm-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel
Re: [kvm-devel] Use host CPUID processor info
Avi Kivity wrote: > > One of the uses of virtualization is to abstract the underlying > hardware, so that a VM image can run on any platform (live > migration is > an example of this use case). For that we must not let any detail of > the hardware be visible. I doutb about the live migration cross different architecture. A VM using AMD 3DNow can't be migrated to Intel Box. Even within Intel processores, A VM using SSE2 can't be migrated to a platform w/o SSE2 support. Only if the VM is using the minimal instruction set, minimal features may be able to live migrate to other platforms. If this is the purpose, probably we can use an ancient processor model for the VM to achieve best migration capability in case hybrid processor is adopted. In that way we meet both requirement: live migration and app doesn't know it is a VM. Further more, there needs a capibility check for live migration to see if it can be migrated to a new platform. If we use host processor model, Qemu can simply check both new processor model and required one to see if migration can be done, if we use virtual processor model, say qemu processor, we have trouble: A vm using qemu processor compiled with SSE2 can't be migrated to a new platform w/o SSE2 though the capability check at migration decision make time says OK (both are qemu processoe). I think we need to revisit the policy here. Eddie - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ kvm-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel
Re: [kvm-devel] Use host CPUID processor info
Dong, Eddie wrote: > Avi Kivity wrote: > >> One of the uses of virtualization is to abstract the underlying >> hardware, so that a VM image can run on any platform (live >> migration is >> an example of this use case). For that we must not let any detail of >> the hardware be visible. >> > > I doutb about the live migration cross different architecture. A VM > using AMD 3DNow can't be migrated to Intel Box. Even within Intel > processores, A VM using SSE2 can't be migrated to a platform w/o SSE2 > support. > > Only if the VM is using the minimal instruction set, minimal features > may be able to live migrate to other platforms. If this is the purpose, > probably we can use an ancient processor model for the VM to achieve > best migration capability in case hybrid processor is adopted. In that > way we meet both requirement: live migration and app doesn't know it is > a VM. > It doesn't have to be too ancient. All virtualization capable processors support at least sse2 (and maybe sse3 too). > Further more, there needs a capibility check for live migration to see > if it can be migrated to a new platform. If we use host processor model, > Qemu can simply check both new processor model and required one to see > if migration can be done, if we use virtual processor model, say qemu > processor, we have trouble: A vm using qemu processor compiled with SSE2 > can't be migrated to a new platform w/o SSE2 though the capability check > at migration decision make time says OK (both are qemu processoe). No, you only need to check that the host processor is a superset of the virtualized processor. A management solution can also compute a cpuid that is common to all machines in the farm and tell qemu to use that via the command line. -- error compiling committee.c: too many arguments to function - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ kvm-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel
Re: [kvm-devel] [PATCH][RFC] kvm-scheduler integration
Ingo Molnar wrote: > * Avi Kivity <[EMAIL PROTECTED]> wrote: > > Won't that increase task_struct (16 bytes on 64-bit) unnecessarily? The function pointers are common to all virtual machines. >>> well, this function pointer could then be reused by other virtual >>> machines as well, couldnt it? >>> >> I don't get this. If we add a couple of members to task_struct, it >> can't be reused. The values will be the same across all tasks, but >> the memory will be gone (including tasks which aren't virtual >> machines). >> > > i mean, the function pointer is set by KVM, but it could be set to a > different value by other hypervisors. > > What other hypervisors? ;-) Oh, if Rusty wants it for lguest I can put a pointer or a chain into task_struct. But I doubt it -- with paravirtualization there are no costly new registers to swap. > but ... no strong feelings either way, your patch is certainly fine. > > Acked-by: Ingo Molnar <[EMAIL PROTECTED]> > Thanks! -- error compiling committee.c: too many arguments to function - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ kvm-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel
Re: [kvm-devel] [PATCH][RFC] kvm-scheduler integration
On Sun, 2007-07-08 at 15:48 +0200, Ingo Molnar wrote: > * Avi Kivity <[EMAIL PROTECTED]> wrote: > > > >>+#ifdef CONFIG_SCHED_KVM > > >>+static __read_mostly struct sched_kvm_hooks kvm_hooks; > > >>+#endif > > > > > >please just add a current->put_vcpu() function pointer instead of > > >this hooks thing. > > > > Won't that increase task_struct (16 bytes on 64-bit) unnecessarily? > > The function pointers are common to all virtual machines. > > well, this function pointer could then be reused by other virtual > machines as well, couldnt it? If the task struct overhead is a problem > (it really isnt, and it's dependent on CONFIG_KVM) then we could switch > it around to a notifier-alike mechanism. OK, this patch is *ugly*. Not that there's anything wrong with a patch which says "I'm going to preempt you", but making it kvm-specific is ugly. ISTR times past where I wanted such a hook, although none spring immediately into my pre-coffee brain. I think a "struct preempt_ops *" and a "void *preempt_ops_data" inside every task struct is a better idea. Call the config option PREEMPT_SCHED_HOOKS and now there's nothing kvm-specific about it... Cheers, Rusty. - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ kvm-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel
[kvm-devel] User space for lapic2
Avi: To make lapic code into mainline earlier, I am thinking what should the user space code look like. If we wait till lapic branch has all same functionality as mainline have today i.e. live migration, all guests etc, we may have very long way to go given that only Greg (temply off), me have contribution to the code besides you. So what I am thinking is to reduce the bar to "no regression", which means a user space command to choice kernel pic/apic. When choosing user pic/apic, we make sure everything works including livemigration and all known good guests; if choosing kernel pic/apic, we have better performance but some feature lagging such as live migration. Does this make sense? If yes, How about command option "-irqchip k" and "-irqchip u"? the default value is user. thx, eddie - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ kvm-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel
[kvm-devel] Compile error
I meet the error below when I compile KVM module against 30dac03825e830641054a829fe99ff6d1f2ebe0d. The kernel is 2.6.22-rc4. + make -C kernel make[1]: Entering directory `/workspace/ia32e/nightly/kvm-master-2.6.22-rc4-20070708190117/kvm-users pace/BUILD/kernel' make -j20 -C /lib/modules/2.6.22-rc4/build M=`pwd` "$@" make[2]: Entering directory `/usr/src/redhat/BUILD/kernel-2.6.22rc4g85f6038f' LD /workspace/ia32e/nightly/kvm-master-2.6.22-rc4-20070708190117/kvm-usersp ace/BUILD/kernel/built-in.o CC [M] /workspace/ia32e/nightly/kvm-master-2.6.22-rc4-20070708190117/kvm-usersp ace/BUILD/kernel/svm.o CC [M] /workspace/ia32e/nightly/kvm-master-2.6.22-rc4-20070708190117/kvm-usersp ace/BUILD/kernel/vmx.o CC [M] /workspace/ia32e/nightly/kvm-master-2.6.22-rc4-20070708190117/kvm-usersp ace/BUILD/kernel/vmx-debug.o CC [M] /workspace/ia32e/nightly/kvm-master-2.6.22-rc4-20070708190117/kvm-usersp ace/BUILD/kernel/kvm_main.o CC [M] /workspace/ia32e/nightly/kvm-master-2.6.22-rc4-20070708190117/kvm-usersp ace/BUILD/kernel/mmu.o CC [M] /workspace/ia32e/nightly/kvm-master-2.6.22-rc4-20070708190117/kvm-usersp ace/BUILD/kernel/x86_emulate.o CC [M] /workspace/ia32e/nightly/kvm-master-2.6.22-rc4-20070708190117/kvm-usersp ace/BUILD/kernel/anon_inodes.o /workspace/ia32e/nightly/kvm-master-2.6.22-rc4-20070708190117/kvm-usersp ace/BUILD/kernel/kvm_main.c: In function 'kvm_cpu_hotplug': /workspace/ia32e/nightly/kvm-master-2.6.22-rc4-20070708190117/kvm-usersp ace/BUILD/kernel/kvm_main.c:3007: error: 'CPU_DYING' undeclared (first use in this function) /workspace/ia32e/nightly/kvm-master-2.6.22-rc4-20070708190117/kvm-usersp ace/BUILD/kernel/kvm_main.c:3007: error: (Each undeclared identifier is reported only once /workspace/ia32e/nightly/kvm-master-2.6.22-rc4-20070708190117/kvm-usersp ace/BUILD/kernel/kvm_main.c:3007: error: for each function it appears in.) /workspace/ia32e/nightly/kvm-master-2.6.22-rc4-20070708190117/kvm-usersp ace/BUILD/kernel/kvm_main.c:3008: error: 'CPU_DYING_FROZEN' undeclared (first use in this function) /workspace/ia32e/nightly/kvm-master-2.6.22-rc4-20070708190117/kvm-usersp ace/BUILD/kernel/kvm_main.c:3013: warning: implicit declaration of function 'on_cpu' make[3]: *** [/workspace/ia32e/nightly/kvm-master-2.6.22-rc4-20070708190117/kvm-users pace/BUILD/kernel/kvm_main.o] Error 1 make[3]: *** Waiting for unfinished jobs How can I fix this issue? Thanks Yunfeng - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ kvm-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel
Re: [kvm-devel] [PATCH][RFC] kvm-scheduler integration
Rusty Russell wrote: > On Sun, 2007-07-08 at 15:48 +0200, Ingo Molnar wrote: > >> * Avi Kivity <[EMAIL PROTECTED]> wrote: >> >> > +#ifdef CONFIG_SCHED_KVM > +static __read_mostly struct sched_kvm_hooks kvm_hooks; > +#endif > please just add a current->put_vcpu() function pointer instead of this hooks thing. >>> Won't that increase task_struct (16 bytes on 64-bit) unnecessarily? >>> The function pointers are common to all virtual machines. >>> >> well, this function pointer could then be reused by other virtual >> machines as well, couldnt it? If the task struct overhead is a problem >> (it really isnt, and it's dependent on CONFIG_KVM) then we could switch >> it around to a notifier-alike mechanism. >> > > OK, this patch is *ugly*. Not that there's anything wrong with a patch > which says "I'm going to preempt you", but making it kvm-specific is > ugly. ISTR times past where I wanted such a hook, although none spring > immediately into my pre-coffee brain. > > I think a "struct preempt_ops *" and a "void *preempt_ops_data" inside > every task struct is a better idea. Call the config option > PREEMPT_SCHED_HOOKS and now there's nothing kvm-specific about it... > I considered that, but your proposal does not allow a single task to have multiple preemption hooks installed (hookers?!). Since in general there's no reason to suppose that users would be mutually exclusive, we need to have a struct hlist of these things. All in all this seemed to indicate that the second user should have the honor of figuring out that stuff. -- Do not meddle in the internals of kernels, for they are subtle and quick to panic. - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ kvm-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel
Re: [kvm-devel] [PATCH][RFC] kvm-scheduler integration
[cc list restored] Andi Kleen wrote: > Avi Kivity writes: > >> diff --git a/include/linux/sched.h b/include/linux/sched.h >> index 693f0e6..b705876 100644 >> --- a/include/linux/sched.h >> +++ b/include/linux/sched.h >> @@ -875,6 +875,10 @@ struct task_struct { >> pid_t pid; >> pid_t tgid; >> >> +#ifdef CONFIG_SCHED_KVM >> +struct kvm_vcpu *kvm_vcpu; >> +#endif >> > > You should be careful to put this into a cache line that > is already touched during context switch. Otherwise > if it needs an additional cache miss it might become > very costly > Yeah, I'll look into task_struct again to find a good place. > Also it's a bit worrying to expose hooks into the scheduler > to any modules. How would others be stopped from abusing this? > The functions for installing a hook are out-of-line and EXPORT_SYMBOL_GPL'ed, in case that helps. -- Do not meddle in the internals of kernels, for they are subtle and quick to panic. - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ kvm-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel
Re: [kvm-devel] [PATCH 17/20] SMP: Implement on_cpu()
[cc list restored] Andi Kleen wrote: >> This defines on_cpu() which is similar to smp_call_function_single() >> except that it works if cpu happens to be the current cpu. Can also be >> seen as a complement to on_each_cpu() (which also doesn't treat the >> current cpu specially). >> > > I think it would be better to fix smp_call_function_single to just > handle this case transparently. There aren't that many callers yet because it > is > fairly new. > Well, smp_call_function_single() is arch specific whereas on_cpu() is generic code. Perhaps rename smp_call_function_single() to __smp_call_function_single() and on_cpu() to smp_call_function_single()? I dislike the loss of symmetry though. -- Do not meddle in the internals of kernels, for they are subtle and quick to panic. - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ kvm-devel mailing list kvm-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/kvm-devel