Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch 'kvm-updates-2.6.26' of git://git.kernel.org/pub/scm/linux/kernel/git/avi/kvm

* 'kvm-updates-2.6.26' of git://git.kernel.org/pub/scm/linux/kernel/git/avi/kvm:
KVM: MMU: Fix is_empty_shadow_page() check
KVM: MMU: Fix printk() format string
KVM: IOAPIC: only set remote_irr if interrupt was injected
KVM: MMU: reschedule during shadow teardown
KVM: VMX: Clear CR4.VMXE in hardware_disable
KVM: migrate PIT timer
KVM: ppc: Report bad GFNs
KVM: ppc: Use a read lock around MMU operations, and release it on error
KVM: ppc: Remove unmatched kunmap() call
KVM: ppc: add lwzx/stwz emulation
KVM: ppc: Remove duplicate function
KVM: s390: Fix race condition in kvm_s390_handle_wait
KVM: s390: Send program check on access error
KVM: s390: fix interrupt delivery
KVM: s390: handle machine checks when guest is running
KVM: s390: fix locking order problem in enable_sie
KVM: s390: use yield instead of schedule to implement diag 0x44
KVM: x86 emulator: fix hypercall return value on AMD
KVM: ia64: fix zero extending for mmio ld1/2/4 emulation in KVM

+106 -79
+2 -1
arch/ia64/kvm/mmio.c
··· 159 159 160 160 if (p->u.ioreq.state == STATE_IORESP_READY) { 161 161 if (dir == IOREQ_READ) 162 - *dest = p->u.ioreq.data; 162 + /* it's necessary to ensure zero extending */ 163 + *dest = p->u.ioreq.data & (~0UL >> (64-(s*8))); 163 164 } else 164 165 panic_vm(vcpu); 165 166 out:
+4 -5
arch/powerpc/kvm/44x_tlb.c
··· 116 116 struct tlbe *stlbe = &vcpu->arch.shadow_tlb[index]; 117 117 struct page *page = vcpu->arch.shadow_pages[index]; 118 118 119 - kunmap(vcpu->arch.shadow_pages[index]); 120 - 121 119 if (get_tlb_v(stlbe)) { 122 120 if (kvmppc_44x_tlbe_is_writable(stlbe)) 123 121 kvm_release_page_dirty(page); ··· 142 144 stlbe = &vcpu->arch.shadow_tlb[victim]; 143 145 144 146 /* Get reference to new page. */ 145 - down_write(&current->mm->mmap_sem); 147 + down_read(&current->mm->mmap_sem); 146 148 new_page = gfn_to_page(vcpu->kvm, gfn); 147 149 if (is_error_page(new_page)) { 148 - printk(KERN_ERR "Couldn't get guest page!\n"); 150 + printk(KERN_ERR "Couldn't get guest page for gfn %lx!\n", gfn); 149 151 kvm_release_page_clean(new_page); 152 + up_read(&current->mm->mmap_sem); 150 153 return; 151 154 } 152 155 hpaddr = page_to_phys(new_page); 153 156 154 157 /* Drop reference to old page. */ 155 158 kvmppc_44x_shadow_release(vcpu, victim); 156 - up_write(&current->mm->mmap_sem); 159 + up_read(&current->mm->mmap_sem); 157 160 158 161 vcpu->arch.shadow_pages[victim] = new_page; 159 162
-33
arch/powerpc/kvm/booke_guest.c
··· 227 227 } 228 228 } 229 229 230 - static int kvmppc_emulate_mmio(struct kvm_run *run, struct kvm_vcpu *vcpu) 231 - { 232 - enum emulation_result er; 233 - int r; 234 - 235 - er = kvmppc_emulate_instruction(run, vcpu); 236 - switch (er) { 237 - case EMULATE_DONE: 238 - /* Future optimization: only reload non-volatiles if they were 239 - * actually modified. */ 240 - r = RESUME_GUEST_NV; 241 - break; 242 - case EMULATE_DO_MMIO: 243 - run->exit_reason = KVM_EXIT_MMIO; 244 - /* We must reload nonvolatiles because "update" load/store 245 - * instructions modify register state. */ 246 - /* Future optimization: only reload non-volatiles if they were 247 - * actually modified. */ 248 - r = RESUME_HOST_NV; 249 - break; 250 - case EMULATE_FAIL: 251 - /* XXX Deliver Program interrupt to guest. */ 252 - printk(KERN_EMERG "%s: emulation failed (%08x)\n", __func__, 253 - vcpu->arch.last_inst); 254 - r = RESUME_HOST; 255 - break; 256 - default: 257 - BUG(); 258 - } 259 - 260 - return r; 261 - } 262 - 263 230 /** 264 231 * kvmppc_handle_exit 265 232 *
+12
arch/powerpc/kvm/emulate.c
··· 246 246 case 31: 247 247 switch (get_xop(inst)) { 248 248 249 + case 23: /* lwzx */ 250 + rt = get_rt(inst); 251 + emulated = kvmppc_handle_load(run, vcpu, rt, 4, 1); 252 + break; 253 + 249 254 case 83: /* mfmsr */ 250 255 rt = get_rt(inst); 251 256 vcpu->arch.gpr[rt] = vcpu->arch.msr; ··· 270 265 case 146: /* mtmsr */ 271 266 rs = get_rs(inst); 272 267 kvmppc_set_msr(vcpu, vcpu->arch.gpr[rs]); 268 + break; 269 + 270 + case 151: /* stwx */ 271 + rs = get_rs(inst); 272 + emulated = kvmppc_handle_store(run, vcpu, 273 + vcpu->arch.gpr[rs], 274 + 4, 1); 273 275 break; 274 276 275 277 case 163: /* wrteei */
+1 -1
arch/s390/kvm/diag.c
··· 20 20 VCPU_EVENT(vcpu, 5, "%s", "diag time slice end"); 21 21 vcpu->stat.diagnose_44++; 22 22 vcpu_put(vcpu); 23 - schedule(); 23 + yield(); 24 24 vcpu_load(vcpu); 25 25 return 0; 26 26 }
+5 -2
arch/s390/kvm/interrupt.c
··· 339 339 if (kvm_cpu_has_interrupt(vcpu)) 340 340 return 0; 341 341 342 + __set_cpu_idle(vcpu); 343 + spin_lock_bh(&vcpu->arch.local_int.lock); 344 + vcpu->arch.local_int.timer_due = 0; 345 + spin_unlock_bh(&vcpu->arch.local_int.lock); 346 + 342 347 if (psw_interrupts_disabled(vcpu)) { 343 348 VCPU_EVENT(vcpu, 3, "%s", "disabled wait"); 344 349 __unset_cpu_idle(vcpu); ··· 371 366 no_timer: 372 367 spin_lock_bh(&vcpu->arch.local_int.float_int->lock); 373 368 spin_lock_bh(&vcpu->arch.local_int.lock); 374 - __set_cpu_idle(vcpu); 375 - vcpu->arch.local_int.timer_due = 0; 376 369 add_wait_queue(&vcpu->arch.local_int.wq, &wait); 377 370 while (list_empty(&vcpu->arch.local_int.list) && 378 371 list_empty(&vcpu->arch.local_int.float_int->list) &&
+11 -2
arch/s390/kvm/kvm-s390.c
··· 423 423 return -EINVAL; /* not implemented yet */ 424 424 } 425 425 426 + extern void s390_handle_mcck(void); 427 + 426 428 static void __vcpu_run(struct kvm_vcpu *vcpu) 427 429 { 428 430 memcpy(&vcpu->arch.sie_block->gg14, &vcpu->arch.guest_gprs[14], 16); ··· 432 430 if (need_resched()) 433 431 schedule(); 434 432 433 + if (test_thread_flag(TIF_MCCK_PENDING)) 434 + s390_handle_mcck(); 435 + 436 + kvm_s390_deliver_pending_interrupts(vcpu); 437 + 435 438 vcpu->arch.sie_block->icptcode = 0; 436 439 local_irq_disable(); 437 440 kvm_guest_enter(); 438 441 local_irq_enable(); 439 442 VCPU_EVENT(vcpu, 6, "entering sie flags %x", 440 443 atomic_read(&vcpu->arch.sie_block->cpuflags)); 441 - sie64a(vcpu->arch.sie_block, vcpu->arch.guest_gprs); 444 + if (sie64a(vcpu->arch.sie_block, vcpu->arch.guest_gprs)) { 445 + VCPU_EVENT(vcpu, 3, "%s", "fault in sie instruction"); 446 + kvm_s390_inject_program_int(vcpu, PGM_ADDRESSING); 447 + } 442 448 VCPU_EVENT(vcpu, 6, "exit sie icptcode %d", 443 449 vcpu->arch.sie_block->icptcode); 444 450 local_irq_disable(); ··· 485 475 might_sleep(); 486 476 487 477 do { 488 - kvm_s390_deliver_pending_interrupts(vcpu); 489 478 __vcpu_run(vcpu); 490 479 rc = kvm_handle_sie_intercept(vcpu); 491 480 } while (!signal_pending(current) && !rc);
+27 -17
arch/s390/mm/pgtable.c
··· 254 254 int s390_enable_sie(void) 255 255 { 256 256 struct task_struct *tsk = current; 257 - struct mm_struct *mm; 258 - int rc; 257 + struct mm_struct *mm, *old_mm; 259 258 260 - task_lock(tsk); 261 - 262 - rc = 0; 259 + /* Do we have pgstes? if yes, we are done */ 263 260 if (tsk->mm->context.pgstes) 264 - goto unlock; 261 + return 0; 265 262 266 - rc = -EINVAL; 263 + /* lets check if we are allowed to replace the mm */ 264 + task_lock(tsk); 267 265 if (!tsk->mm || atomic_read(&tsk->mm->mm_users) > 1 || 268 - tsk->mm != tsk->active_mm || tsk->mm->ioctx_list) 269 - goto unlock; 266 + tsk->mm != tsk->active_mm || tsk->mm->ioctx_list) { 267 + task_unlock(tsk); 268 + return -EINVAL; 269 + } 270 + task_unlock(tsk); 270 271 271 - tsk->mm->context.pgstes = 1; /* dirty little tricks .. */ 272 + /* we copy the mm with pgstes enabled */ 273 + tsk->mm->context.pgstes = 1; 272 274 mm = dup_mm(tsk); 273 275 tsk->mm->context.pgstes = 0; 274 - 275 - rc = -ENOMEM; 276 276 if (!mm) 277 - goto unlock; 278 - mmput(tsk->mm); 277 + return -ENOMEM; 278 + 279 + /* Now lets check again if somebody attached ptrace etc */ 280 + task_lock(tsk); 281 + if (!tsk->mm || atomic_read(&tsk->mm->mm_users) > 1 || 282 + tsk->mm != tsk->active_mm || tsk->mm->ioctx_list) { 283 + mmput(mm); 284 + task_unlock(tsk); 285 + return -EINVAL; 286 + } 287 + 288 + /* ok, we are alone. No ptrace, no threads, etc. */ 289 + old_mm = tsk->mm; 279 290 tsk->mm = tsk->active_mm = mm; 280 291 preempt_disable(); 281 292 update_mm(mm, tsk); 282 293 cpu_set(smp_processor_id(), mm->cpu_vm_mask); 283 294 preempt_enable(); 284 - rc = 0; 285 - unlock: 286 295 task_unlock(tsk); 287 - return rc; 296 + mmput(old_mm); 297 + return 0; 288 298 } 289 299 EXPORT_SYMBOL_GPL(s390_enable_sie);
+13 -1
arch/x86/kvm/i8254.c
··· 200 200 201 201 atomic_inc(&pt->pending); 202 202 smp_mb__after_atomic_inc(); 203 - /* FIXME: handle case where the guest is in guest mode */ 204 203 if (vcpu0 && waitqueue_active(&vcpu0->wq)) { 205 204 vcpu0->arch.mp_state = KVM_MP_STATE_RUNNABLE; 206 205 wake_up_interruptible(&vcpu0->wq); ··· 234 235 return HRTIMER_RESTART; 235 236 else 236 237 return HRTIMER_NORESTART; 238 + } 239 + 240 + void __kvm_migrate_pit_timer(struct kvm_vcpu *vcpu) 241 + { 242 + struct kvm_pit *pit = vcpu->kvm->arch.vpit; 243 + struct hrtimer *timer; 244 + 245 + if (vcpu->vcpu_id != 0 || !pit) 246 + return; 247 + 248 + timer = &pit->pit_state.pit_timer.timer; 249 + if (hrtimer_cancel(timer)) 250 + hrtimer_start(timer, timer->expires, HRTIMER_MODE_ABS); 237 251 } 238 252 239 253 static void destroy_pit_timer(struct kvm_kpit_timer *pt)
+6
arch/x86/kvm/irq.c
··· 94 94 /* TODO: PIT, RTC etc. */ 95 95 } 96 96 EXPORT_SYMBOL_GPL(kvm_timer_intr_post); 97 + 98 + void __kvm_migrate_timers(struct kvm_vcpu *vcpu) 99 + { 100 + __kvm_migrate_apic_timer(vcpu); 101 + __kvm_migrate_pit_timer(vcpu); 102 + }
+2
arch/x86/kvm/irq.h
··· 84 84 void kvm_inject_pending_timer_irqs(struct kvm_vcpu *vcpu); 85 85 void kvm_inject_apic_timer_irqs(struct kvm_vcpu *vcpu); 86 86 void __kvm_migrate_apic_timer(struct kvm_vcpu *vcpu); 87 + void __kvm_migrate_pit_timer(struct kvm_vcpu *vcpu); 88 + void __kvm_migrate_timers(struct kvm_vcpu *vcpu); 87 89 88 90 int pit_has_pending_timer(struct kvm_vcpu *vcpu); 89 91 int apic_has_pending_timer(struct kvm_vcpu *vcpu);
+2 -1
arch/x86/kvm/mmu.c
··· 658 658 u64 *end; 659 659 660 660 for (pos = spt, end = pos + PAGE_SIZE / sizeof(u64); pos != end; pos++) 661 - if (*pos != shadow_trap_nonpresent_pte) { 661 + if (is_shadow_present_pte(*pos)) { 662 662 printk(KERN_ERR "%s: %p %llx\n", __func__, 663 663 pos, *pos); 664 664 return 0; ··· 1858 1858 sp = container_of(vcpu->kvm->arch.active_mmu_pages.next, 1859 1859 struct kvm_mmu_page, link); 1860 1860 kvm_mmu_zap_page(vcpu->kvm, sp); 1861 + cond_resched(); 1861 1862 } 1862 1863 free_page((unsigned long)vcpu->arch.mmu.pae_root); 1863 1864 }
+1 -1
arch/x86/kvm/paging_tmpl.h
··· 418 418 419 419 /* mmio */ 420 420 if (is_error_pfn(pfn)) { 421 - pgprintk("gfn %x is mmio\n", walker.gfn); 421 + pgprintk("gfn %lx is mmio\n", walker.gfn); 422 422 kvm_release_pfn_clean(pfn); 423 423 return 1; 424 424 }
+1 -1
arch/x86/kvm/svm.c
··· 688 688 delta = vcpu->arch.host_tsc - tsc_this; 689 689 svm->vmcb->control.tsc_offset += delta; 690 690 vcpu->cpu = cpu; 691 - kvm_migrate_apic_timer(vcpu); 691 + kvm_migrate_timers(vcpu); 692 692 } 693 693 694 694 for (i = 0; i < NR_HOST_SAVE_USER_MSRS; i++)
+2 -1
arch/x86/kvm/vmx.c
··· 608 608 609 609 if (vcpu->cpu != cpu) { 610 610 vcpu_clear(vmx); 611 - kvm_migrate_apic_timer(vcpu); 611 + kvm_migrate_timers(vcpu); 612 612 vpid_sync_vcpu_all(vmx); 613 613 } 614 614 ··· 1036 1036 static void hardware_disable(void *garbage) 1037 1037 { 1038 1038 asm volatile (ASM_VMX_VMXOFF : : : "cc"); 1039 + write_cr4(read_cr4() & ~X86_CR4_VMXE); 1039 1040 } 1040 1041 1041 1042 static __init int adjust_vmx_controls(u32 ctl_min, u32 ctl_opt,
+1 -1
arch/x86/kvm/x86.c
··· 2758 2758 2759 2759 if (vcpu->requests) { 2760 2760 if (test_and_clear_bit(KVM_REQ_MIGRATE_TIMER, &vcpu->requests)) 2761 - __kvm_migrate_apic_timer(vcpu); 2761 + __kvm_migrate_timers(vcpu); 2762 2762 if (test_and_clear_bit(KVM_REQ_REPORT_TPR_ACCESS, 2763 2763 &vcpu->requests)) { 2764 2764 kvm_run->exit_reason = KVM_EXIT_TPR_ACCESS;
+2 -1
arch/x86/kvm/x86_emulate.c
··· 1727 1727 if (rc) 1728 1728 goto done; 1729 1729 1730 - kvm_emulate_hypercall(ctxt->vcpu); 1730 + /* Let the processor re-execute the fixed hypercall */ 1731 + c->eip = ctxt->vcpu->arch.rip; 1731 1732 /* Disable writeback. */ 1732 1733 c->dst.type = OP_NONE; 1733 1734 break;
+1
drivers/s390/s390mach.c
··· 207 207 do_exit(SIGSEGV); 208 208 } 209 209 } 210 + EXPORT_SYMBOL_GPL(s390_handle_mcck); 210 211 211 212 /* 212 213 * returns 0 if all registers could be validated
+1
include/asm-powerpc/kvm_ppc.h
··· 57 57 58 58 extern int kvmppc_emulate_instruction(struct kvm_run *run, 59 59 struct kvm_vcpu *vcpu); 60 + extern int kvmppc_emulate_mmio(struct kvm_run *run, struct kvm_vcpu *vcpu); 60 61 61 62 extern void kvmppc_mmu_map(struct kvm_vcpu *vcpu, u64 gvaddr, gfn_t gfn, 62 63 u64 asid, u32 flags);
+1 -1
include/linux/kvm_host.h
··· 297 297 return (gpa_t)gfn << PAGE_SHIFT; 298 298 } 299 299 300 - static inline void kvm_migrate_apic_timer(struct kvm_vcpu *vcpu) 300 + static inline void kvm_migrate_timers(struct kvm_vcpu *vcpu) 301 301 { 302 302 set_bit(KVM_REQ_MIGRATE_TIMER, &vcpu->requests); 303 303 }
+11 -10
virt/kvm/ioapic.c
··· 45 45 #else 46 46 #define ioapic_debug(fmt, arg...) 47 47 #endif 48 - static void ioapic_deliver(struct kvm_ioapic *vioapic, int irq); 48 + static int ioapic_deliver(struct kvm_ioapic *vioapic, int irq); 49 49 50 50 static unsigned long ioapic_read_indirect(struct kvm_ioapic *ioapic, 51 51 unsigned long addr, ··· 89 89 pent = &ioapic->redirtbl[idx]; 90 90 91 91 if (!pent->fields.mask) { 92 - ioapic_deliver(ioapic, idx); 93 - if (pent->fields.trig_mode == IOAPIC_LEVEL_TRIG) 92 + int injected = ioapic_deliver(ioapic, idx); 93 + if (injected && pent->fields.trig_mode == IOAPIC_LEVEL_TRIG) 94 94 pent->fields.remote_irr = 1; 95 95 } 96 96 if (!pent->fields.trig_mode) ··· 133 133 } 134 134 } 135 135 136 - static void ioapic_inj_irq(struct kvm_ioapic *ioapic, 136 + static int ioapic_inj_irq(struct kvm_ioapic *ioapic, 137 137 struct kvm_vcpu *vcpu, 138 138 u8 vector, u8 trig_mode, u8 delivery_mode) 139 139 { ··· 143 143 ASSERT((delivery_mode == IOAPIC_FIXED) || 144 144 (delivery_mode == IOAPIC_LOWEST_PRIORITY)); 145 145 146 - kvm_apic_set_irq(vcpu, vector, trig_mode); 146 + return kvm_apic_set_irq(vcpu, vector, trig_mode); 147 147 } 148 148 149 149 static u32 ioapic_get_delivery_bitmask(struct kvm_ioapic *ioapic, u8 dest, ··· 186 186 return mask; 187 187 } 188 188 189 - static void ioapic_deliver(struct kvm_ioapic *ioapic, int irq) 189 + static int ioapic_deliver(struct kvm_ioapic *ioapic, int irq) 190 190 { 191 191 u8 dest = ioapic->redirtbl[irq].fields.dest_id; 192 192 u8 dest_mode = ioapic->redirtbl[irq].fields.dest_mode; ··· 195 195 u8 trig_mode = ioapic->redirtbl[irq].fields.trig_mode; 196 196 u32 deliver_bitmask; 197 197 struct kvm_vcpu *vcpu; 198 - int vcpu_id; 198 + int vcpu_id, r = 0; 199 199 200 200 ioapic_debug("dest=%x dest_mode=%x delivery_mode=%x " 201 201 "vector=%x trig_mode=%x\n", ··· 204 204 deliver_bitmask = ioapic_get_delivery_bitmask(ioapic, dest, dest_mode); 205 205 if (!deliver_bitmask) { 206 206 ioapic_debug("no target on destination\n"); 207 - return; 207 + return 0; 208 208 } 209 209 210 210 switch (delivery_mode) { ··· 216 216 vcpu = ioapic->kvm->vcpus[0]; 217 217 #endif 218 218 if (vcpu != NULL) 219 - ioapic_inj_irq(ioapic, vcpu, vector, 219 + r = ioapic_inj_irq(ioapic, vcpu, vector, 220 220 trig_mode, delivery_mode); 221 221 else 222 222 ioapic_debug("null lowest prio vcpu: " ··· 234 234 deliver_bitmask &= ~(1 << vcpu_id); 235 235 vcpu = ioapic->kvm->vcpus[vcpu_id]; 236 236 if (vcpu) { 237 - ioapic_inj_irq(ioapic, vcpu, vector, 237 + r = ioapic_inj_irq(ioapic, vcpu, vector, 238 238 trig_mode, delivery_mode); 239 239 } 240 240 } ··· 246 246 delivery_mode); 247 247 break; 248 248 } 249 + return r; 249 250 } 250 251 251 252 void kvm_ioapic_set_irq(struct kvm_ioapic *ioapic, int irq, int level)