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 git://git.kernel.org/pub/scm/virt/kvm/kvm

Pull kvm fixes from Marcelo Tosatti.

* git://git.kernel.org/pub/scm/virt/kvm/kvm:
KVM: x86 emulator: use stack size attribute to mask rsp in stack ops
KVM: MMU: Fix mmu_shrink() so that it can free mmu pages as intended
ppc: e500_tlb memset clears nothing
KVM: PPC: Add cache flush on page map
KVM: PPC: Book3S HV: Fix incorrect branch in H_CEDE code
KVM: x86: update KVM_SAVE_MSRS_BEGIN to correct value

+64 -23
+1
arch/powerpc/include/asm/kvm_host.h
··· 33 33 #include <asm/kvm_asm.h> 34 34 #include <asm/processor.h> 35 35 #include <asm/page.h> 36 + #include <asm/cacheflush.h> 36 37 37 38 #define KVM_MAX_VCPUS NR_CPUS 38 39 #define KVM_MAX_VCORES NR_CPUS
+12
arch/powerpc/include/asm/kvm_ppc.h
··· 219 219 void kvmppc_free_lpid(long lpid); 220 220 void kvmppc_init_lpid(unsigned long nr_lpids); 221 221 222 + static inline void kvmppc_mmu_flush_icache(pfn_t pfn) 223 + { 224 + /* Clear i-cache for new pages */ 225 + struct page *page; 226 + page = pfn_to_page(pfn); 227 + if (!test_bit(PG_arch_1, &page->flags)) { 228 + flush_dcache_icache_page(page); 229 + set_bit(PG_arch_1, &page->flags); 230 + } 231 + } 232 + 233 + 222 234 #endif /* __POWERPC_KVM_PPC_H__ */
+3
arch/powerpc/kvm/book3s_32_mmu_host.c
··· 211 211 pteg1 |= PP_RWRX; 212 212 } 213 213 214 + if (orig_pte->may_execute) 215 + kvmppc_mmu_flush_icache(hpaddr >> PAGE_SHIFT); 216 + 214 217 local_irq_disable(); 215 218 216 219 if (pteg[rr]) {
+2
arch/powerpc/kvm/book3s_64_mmu_host.c
··· 126 126 127 127 if (!orig_pte->may_execute) 128 128 rflags |= HPTE_R_N; 129 + else 130 + kvmppc_mmu_flush_icache(hpaddr >> PAGE_SHIFT); 129 131 130 132 hash = hpt_hash(va, PTE_SIZE, MMU_SEGSIZE_256M); 131 133
+7 -5
arch/powerpc/kvm/book3s_hv_rmhandlers.S
··· 1421 1421 sync /* order setting ceded vs. testing prodded */ 1422 1422 lbz r5,VCPU_PRODDED(r3) 1423 1423 cmpwi r5,0 1424 - bne 1f 1424 + bne kvm_cede_prodded 1425 1425 li r0,0 /* set trap to 0 to say hcall is handled */ 1426 1426 stw r0,VCPU_TRAP(r3) 1427 1427 li r0,H_SUCCESS 1428 1428 std r0,VCPU_GPR(R3)(r3) 1429 1429 BEGIN_FTR_SECTION 1430 - b 2f /* just send it up to host on 970 */ 1430 + b kvm_cede_exit /* just send it up to host on 970 */ 1431 1431 END_FTR_SECTION_IFCLR(CPU_FTR_ARCH_206) 1432 1432 1433 1433 /* ··· 1446 1446 or r4,r4,r0 1447 1447 PPC_POPCNTW(R7,R4) 1448 1448 cmpw r7,r8 1449 - bge 2f 1449 + bge kvm_cede_exit 1450 1450 stwcx. r4,0,r6 1451 1451 bne 31b 1452 1452 li r0,1 ··· 1555 1555 b hcall_real_fallback 1556 1556 1557 1557 /* cede when already previously prodded case */ 1558 - 1: li r0,0 1558 + kvm_cede_prodded: 1559 + li r0,0 1559 1560 stb r0,VCPU_PRODDED(r3) 1560 1561 sync /* order testing prodded vs. clearing ceded */ 1561 1562 stb r0,VCPU_CEDED(r3) ··· 1564 1563 blr 1565 1564 1566 1565 /* we've ceded but we want to give control to the host */ 1567 - 2: li r3,H_TOO_HARD 1566 + kvm_cede_exit: 1567 + li r3,H_TOO_HARD 1568 1568 blr 1569 1569 1570 1570 secondary_too_late:
+7 -4
arch/powerpc/kvm/e500_tlb.c
··· 322 322 static void clear_tlb1_bitmap(struct kvmppc_vcpu_e500 *vcpu_e500) 323 323 { 324 324 if (vcpu_e500->g2h_tlb1_map) 325 - memset(vcpu_e500->g2h_tlb1_map, 326 - sizeof(u64) * vcpu_e500->gtlb_params[1].entries, 0); 325 + memset(vcpu_e500->g2h_tlb1_map, 0, 326 + sizeof(u64) * vcpu_e500->gtlb_params[1].entries); 327 327 if (vcpu_e500->h2g_tlb1_rmap) 328 - memset(vcpu_e500->h2g_tlb1_rmap, 329 - sizeof(unsigned int) * host_tlb_params[1].entries, 0); 328 + memset(vcpu_e500->h2g_tlb1_rmap, 0, 329 + sizeof(unsigned int) * host_tlb_params[1].entries); 330 330 } 331 331 332 332 static void clear_tlb_privs(struct kvmppc_vcpu_e500 *vcpu_e500) ··· 539 539 540 540 kvmppc_e500_setup_stlbe(&vcpu_e500->vcpu, gtlbe, tsize, 541 541 ref, gvaddr, stlbe); 542 + 543 + /* Clear i-cache for new pages */ 544 + kvmppc_mmu_flush_icache(pfn); 542 545 } 543 546 544 547 /* XXX only map the one-one case, for now use TLB0 */
+1
arch/powerpc/mm/mem.c
··· 469 469 __flush_dcache_icache_phys(page_to_pfn(page) << PAGE_SHIFT); 470 470 #endif 471 471 } 472 + EXPORT_SYMBOL(flush_dcache_icache_page); 472 473 473 474 void clear_user_page(void *page, unsigned long vaddr, struct page *pg) 474 475 {
+21 -9
arch/x86/kvm/emulate.c
··· 475 475 return address_mask(ctxt, reg); 476 476 } 477 477 478 + static void masked_increment(ulong *reg, ulong mask, int inc) 479 + { 480 + assign_masked(reg, *reg + inc, mask); 481 + } 482 + 478 483 static inline void 479 484 register_address_increment(struct x86_emulate_ctxt *ctxt, unsigned long *reg, int inc) 480 485 { 486 + ulong mask; 487 + 481 488 if (ctxt->ad_bytes == sizeof(unsigned long)) 482 - *reg += inc; 489 + mask = ~0UL; 483 490 else 484 - *reg = (*reg & ~ad_mask(ctxt)) | ((*reg + inc) & ad_mask(ctxt)); 491 + mask = ad_mask(ctxt); 492 + masked_increment(reg, mask, inc); 493 + } 494 + 495 + static void rsp_increment(struct x86_emulate_ctxt *ctxt, int inc) 496 + { 497 + masked_increment(&ctxt->regs[VCPU_REGS_RSP], stack_mask(ctxt), inc); 485 498 } 486 499 487 500 static inline void jmp_rel(struct x86_emulate_ctxt *ctxt, int rel) ··· 1535 1522 { 1536 1523 struct segmented_address addr; 1537 1524 1538 - register_address_increment(ctxt, &ctxt->regs[VCPU_REGS_RSP], -bytes); 1539 - addr.ea = register_address(ctxt, ctxt->regs[VCPU_REGS_RSP]); 1525 + rsp_increment(ctxt, -bytes); 1526 + addr.ea = ctxt->regs[VCPU_REGS_RSP] & stack_mask(ctxt); 1540 1527 addr.seg = VCPU_SREG_SS; 1541 1528 1542 1529 return segmented_write(ctxt, addr, data, bytes); ··· 1555 1542 int rc; 1556 1543 struct segmented_address addr; 1557 1544 1558 - addr.ea = register_address(ctxt, ctxt->regs[VCPU_REGS_RSP]); 1545 + addr.ea = ctxt->regs[VCPU_REGS_RSP] & stack_mask(ctxt); 1559 1546 addr.seg = VCPU_SREG_SS; 1560 1547 rc = segmented_read(ctxt, addr, dest, len); 1561 1548 if (rc != X86EMUL_CONTINUE) 1562 1549 return rc; 1563 1550 1564 - register_address_increment(ctxt, &ctxt->regs[VCPU_REGS_RSP], len); 1551 + rsp_increment(ctxt, len); 1565 1552 return rc; 1566 1553 } 1567 1554 ··· 1701 1688 1702 1689 while (reg >= VCPU_REGS_RAX) { 1703 1690 if (reg == VCPU_REGS_RSP) { 1704 - register_address_increment(ctxt, &ctxt->regs[VCPU_REGS_RSP], 1705 - ctxt->op_bytes); 1691 + rsp_increment(ctxt, ctxt->op_bytes); 1706 1692 --reg; 1707 1693 } 1708 1694 ··· 2837 2825 rc = emulate_pop(ctxt, &ctxt->dst.val, ctxt->op_bytes); 2838 2826 if (rc != X86EMUL_CONTINUE) 2839 2827 return rc; 2840 - register_address_increment(ctxt, &ctxt->regs[VCPU_REGS_RSP], ctxt->src.val); 2828 + rsp_increment(ctxt, ctxt->src.val); 2841 2829 return X86EMUL_CONTINUE; 2842 2830 } 2843 2831
+9 -4
arch/x86/kvm/mmu.c
··· 4113 4113 LIST_HEAD(invalid_list); 4114 4114 4115 4115 /* 4116 + * Never scan more than sc->nr_to_scan VM instances. 4117 + * Will not hit this condition practically since we do not try 4118 + * to shrink more than one VM and it is very unlikely to see 4119 + * !n_used_mmu_pages so many times. 4120 + */ 4121 + if (!nr_to_scan--) 4122 + break; 4123 + /* 4116 4124 * n_used_mmu_pages is accessed without holding kvm->mmu_lock 4117 4125 * here. We may skip a VM instance errorneosly, but we do not 4118 4126 * want to shrink a VM that only started to populate its MMU 4119 4127 * anyway. 4120 4128 */ 4121 - if (kvm->arch.n_used_mmu_pages > 0) { 4122 - if (!nr_to_scan--) 4123 - break; 4129 + if (!kvm->arch.n_used_mmu_pages) 4124 4130 continue; 4125 - } 4126 4131 4127 4132 idx = srcu_read_lock(&kvm->srcu); 4128 4133 spin_lock(&kvm->mmu_lock);
+1 -1
arch/x86/kvm/x86.c
··· 806 806 * kvm-specific. Those are put in the beginning of the list. 807 807 */ 808 808 809 - #define KVM_SAVE_MSRS_BEGIN 9 809 + #define KVM_SAVE_MSRS_BEGIN 10 810 810 static u32 msrs_to_save[] = { 811 811 MSR_KVM_SYSTEM_TIME, MSR_KVM_WALL_CLOCK, 812 812 MSR_KVM_SYSTEM_TIME_NEW, MSR_KVM_WALL_CLOCK_NEW,