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

Merge tag 'powerpc-5.18-3' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux

Pull powerpc fixes from Michael Ellerman:

- Partly revert a change to our timer_interrupt() that caused lockups
with high res timers disabled.

- Fix a bug in KVM TCE handling that could corrupt kernel memory.

- Two commits fixing Power9/Power10 perf alternative event selection.

Thanks to Alexey Kardashevskiy, Athira Rajeev, David Gibson, Frederic
Barrat, Madhavan Srinivasan, Miguel Ojeda, and Nicholas Piggin.

* tag 'powerpc-5.18-3' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux:
powerpc/perf: Fix 32bit compile
powerpc/perf: Fix power10 event alternatives
powerpc/perf: Fix power9 event alternatives
KVM: PPC: Fix TCE handling for VFIO
powerpc/time: Always set decrementer in timer_interrupt()

+66 -66
+14 -15
arch/powerpc/kernel/time.c
··· 615 615 return; 616 616 } 617 617 618 - /* Conditionally hard-enable interrupts. */ 619 - if (should_hard_irq_enable()) { 620 - /* 621 - * Ensure a positive value is written to the decrementer, or 622 - * else some CPUs will continue to take decrementer exceptions. 623 - * When the PPC_WATCHDOG (decrementer based) is configured, 624 - * keep this at most 31 bits, which is about 4 seconds on most 625 - * systems, which gives the watchdog a chance of catching timer 626 - * interrupt hard lockups. 627 - */ 628 - if (IS_ENABLED(CONFIG_PPC_WATCHDOG)) 629 - set_dec(0x7fffffff); 630 - else 631 - set_dec(decrementer_max); 618 + /* 619 + * Ensure a positive value is written to the decrementer, or 620 + * else some CPUs will continue to take decrementer exceptions. 621 + * When the PPC_WATCHDOG (decrementer based) is configured, 622 + * keep this at most 31 bits, which is about 4 seconds on most 623 + * systems, which gives the watchdog a chance of catching timer 624 + * interrupt hard lockups. 625 + */ 626 + if (IS_ENABLED(CONFIG_PPC_WATCHDOG)) 627 + set_dec(0x7fffffff); 628 + else 629 + set_dec(decrementer_max); 632 630 631 + /* Conditionally hard-enable interrupts. */ 632 + if (should_hard_irq_enable()) 633 633 do_hard_irq_enable(); 634 - } 635 634 636 635 #if defined(CONFIG_PPC32) && defined(CONFIG_PPC_PMAC) 637 636 if (atomic_read(&ppc_n_lost_interrupts) != 0)
+23 -22
arch/powerpc/kvm/book3s_64_vio.c
··· 420 420 tbl[idx % TCES_PER_PAGE] = tce; 421 421 } 422 422 423 - static void kvmppc_clear_tce(struct mm_struct *mm, struct iommu_table *tbl, 424 - unsigned long entry) 423 + static void kvmppc_clear_tce(struct mm_struct *mm, struct kvmppc_spapr_tce_table *stt, 424 + struct iommu_table *tbl, unsigned long entry) 425 425 { 426 - unsigned long hpa = 0; 427 - enum dma_data_direction dir = DMA_NONE; 426 + unsigned long i; 427 + unsigned long subpages = 1ULL << (stt->page_shift - tbl->it_page_shift); 428 + unsigned long io_entry = entry << (stt->page_shift - tbl->it_page_shift); 428 429 429 - iommu_tce_xchg_no_kill(mm, tbl, entry, &hpa, &dir); 430 + for (i = 0; i < subpages; ++i) { 431 + unsigned long hpa = 0; 432 + enum dma_data_direction dir = DMA_NONE; 433 + 434 + iommu_tce_xchg_no_kill(mm, tbl, io_entry + i, &hpa, &dir); 435 + } 430 436 } 431 437 432 438 static long kvmppc_tce_iommu_mapped_dec(struct kvm *kvm, ··· 490 484 if (ret != H_SUCCESS) 491 485 break; 492 486 } 487 + 488 + iommu_tce_kill(tbl, io_entry, subpages); 493 489 494 490 return ret; 495 491 } ··· 552 544 break; 553 545 } 554 546 547 + iommu_tce_kill(tbl, io_entry, subpages); 548 + 555 549 return ret; 556 550 } 557 551 ··· 600 590 ret = kvmppc_tce_iommu_map(vcpu->kvm, stt, stit->tbl, 601 591 entry, ua, dir); 602 592 603 - iommu_tce_kill(stit->tbl, entry, 1); 604 593 605 594 if (ret != H_SUCCESS) { 606 - kvmppc_clear_tce(vcpu->kvm->mm, stit->tbl, entry); 595 + kvmppc_clear_tce(vcpu->kvm->mm, stt, stit->tbl, entry); 607 596 goto unlock_exit; 608 597 } 609 598 } ··· 678 669 */ 679 670 if (get_user(tce, tces + i)) { 680 671 ret = H_TOO_HARD; 681 - goto invalidate_exit; 672 + goto unlock_exit; 682 673 } 683 674 tce = be64_to_cpu(tce); 684 675 685 676 if (kvmppc_tce_to_ua(vcpu->kvm, tce, &ua)) { 686 677 ret = H_PARAMETER; 687 - goto invalidate_exit; 678 + goto unlock_exit; 688 679 } 689 680 690 681 list_for_each_entry_lockless(stit, &stt->iommu_tables, next) { ··· 693 684 iommu_tce_direction(tce)); 694 685 695 686 if (ret != H_SUCCESS) { 696 - kvmppc_clear_tce(vcpu->kvm->mm, stit->tbl, 697 - entry); 698 - goto invalidate_exit; 687 + kvmppc_clear_tce(vcpu->kvm->mm, stt, stit->tbl, 688 + entry + i); 689 + goto unlock_exit; 699 690 } 700 691 } 701 692 702 693 kvmppc_tce_put(stt, entry + i, tce); 703 694 } 704 - 705 - invalidate_exit: 706 - list_for_each_entry_lockless(stit, &stt->iommu_tables, next) 707 - iommu_tce_kill(stit->tbl, entry, npages); 708 695 709 696 unlock_exit: 710 697 srcu_read_unlock(&vcpu->kvm->srcu, idx); ··· 740 735 continue; 741 736 742 737 if (ret == H_TOO_HARD) 743 - goto invalidate_exit; 738 + return ret; 744 739 745 740 WARN_ON_ONCE(1); 746 - kvmppc_clear_tce(vcpu->kvm->mm, stit->tbl, entry); 741 + kvmppc_clear_tce(vcpu->kvm->mm, stt, stit->tbl, entry + i); 747 742 } 748 743 } 749 744 750 745 for (i = 0; i < npages; ++i, ioba += (1ULL << stt->page_shift)) 751 746 kvmppc_tce_put(stt, ioba >> stt->page_shift, tce_value); 752 - 753 - invalidate_exit: 754 - list_for_each_entry_lockless(stit, &stt->iommu_tables, next) 755 - iommu_tce_kill(stit->tbl, ioba >> stt->page_shift, npages); 756 747 757 748 return ret; 758 749 }
+22 -22
arch/powerpc/kvm/book3s_64_vio_hv.c
··· 247 247 tbl->it_ops->tce_kill(tbl, entry, pages, true); 248 248 } 249 249 250 - static void kvmppc_rm_clear_tce(struct kvm *kvm, struct iommu_table *tbl, 251 - unsigned long entry) 250 + static void kvmppc_rm_clear_tce(struct kvm *kvm, struct kvmppc_spapr_tce_table *stt, 251 + struct iommu_table *tbl, unsigned long entry) 252 252 { 253 - unsigned long hpa = 0; 254 - enum dma_data_direction dir = DMA_NONE; 253 + unsigned long i; 254 + unsigned long subpages = 1ULL << (stt->page_shift - tbl->it_page_shift); 255 + unsigned long io_entry = entry << (stt->page_shift - tbl->it_page_shift); 255 256 256 - iommu_tce_xchg_no_kill_rm(kvm->mm, tbl, entry, &hpa, &dir); 257 + for (i = 0; i < subpages; ++i) { 258 + unsigned long hpa = 0; 259 + enum dma_data_direction dir = DMA_NONE; 260 + 261 + iommu_tce_xchg_no_kill_rm(kvm->mm, tbl, io_entry + i, &hpa, &dir); 262 + } 257 263 } 258 264 259 265 static long kvmppc_rm_tce_iommu_mapped_dec(struct kvm *kvm, ··· 321 315 if (ret != H_SUCCESS) 322 316 break; 323 317 } 318 + 319 + iommu_tce_kill_rm(tbl, io_entry, subpages); 324 320 325 321 return ret; 326 322 } ··· 387 379 break; 388 380 } 389 381 382 + iommu_tce_kill_rm(tbl, io_entry, subpages); 383 + 390 384 return ret; 391 385 } 392 386 ··· 430 420 ret = kvmppc_rm_tce_iommu_map(vcpu->kvm, stt, 431 421 stit->tbl, entry, ua, dir); 432 422 433 - iommu_tce_kill_rm(stit->tbl, entry, 1); 434 - 435 423 if (ret != H_SUCCESS) { 436 - kvmppc_rm_clear_tce(vcpu->kvm, stit->tbl, entry); 424 + kvmppc_rm_clear_tce(vcpu->kvm, stt, stit->tbl, entry); 437 425 return ret; 438 426 } 439 427 } ··· 569 561 ua = 0; 570 562 if (kvmppc_rm_tce_to_ua(vcpu->kvm, tce, &ua)) { 571 563 ret = H_PARAMETER; 572 - goto invalidate_exit; 564 + goto unlock_exit; 573 565 } 574 566 575 567 list_for_each_entry_lockless(stit, &stt->iommu_tables, next) { ··· 578 570 iommu_tce_direction(tce)); 579 571 580 572 if (ret != H_SUCCESS) { 581 - kvmppc_rm_clear_tce(vcpu->kvm, stit->tbl, 582 - entry); 583 - goto invalidate_exit; 573 + kvmppc_rm_clear_tce(vcpu->kvm, stt, stit->tbl, 574 + entry + i); 575 + goto unlock_exit; 584 576 } 585 577 } 586 578 587 579 kvmppc_rm_tce_put(stt, entry + i, tce); 588 580 } 589 - 590 - invalidate_exit: 591 - list_for_each_entry_lockless(stit, &stt->iommu_tables, next) 592 - iommu_tce_kill_rm(stit->tbl, entry, npages); 593 581 594 582 unlock_exit: 595 583 if (!prereg) ··· 624 620 continue; 625 621 626 622 if (ret == H_TOO_HARD) 627 - goto invalidate_exit; 623 + return ret; 628 624 629 625 WARN_ON_ONCE_RM(1); 630 - kvmppc_rm_clear_tce(vcpu->kvm, stit->tbl, entry); 626 + kvmppc_rm_clear_tce(vcpu->kvm, stt, stit->tbl, entry + i); 631 627 } 632 628 } 633 629 634 630 for (i = 0; i < npages; ++i, ioba += (1ULL << stt->page_shift)) 635 631 kvmppc_rm_tce_put(stt, ioba >> stt->page_shift, tce_value); 636 - 637 - invalidate_exit: 638 - list_for_each_entry_lockless(stit, &stt->iommu_tables, next) 639 - iommu_tce_kill_rm(stit->tbl, ioba >> stt->page_shift, npages); 640 632 641 633 return ret; 642 634 }
+2 -2
arch/powerpc/perf/Makefile
··· 3 3 obj-y += callchain.o callchain_$(BITS).o perf_regs.o 4 4 obj-$(CONFIG_COMPAT) += callchain_32.o 5 5 6 - obj-$(CONFIG_PPC_PERF_CTRS) += core-book3s.o bhrb.o 6 + obj-$(CONFIG_PPC_PERF_CTRS) += core-book3s.o 7 7 obj64-$(CONFIG_PPC_PERF_CTRS) += ppc970-pmu.o power5-pmu.o \ 8 8 power5+-pmu.o power6-pmu.o power7-pmu.o \ 9 9 isa207-common.o power8-pmu.o power9-pmu.o \ 10 - generic-compat-pmu.o power10-pmu.o 10 + generic-compat-pmu.o power10-pmu.o bhrb.o 11 11 obj32-$(CONFIG_PPC_PERF_CTRS) += mpc7450-pmu.o 12 12 13 13 obj-$(CONFIG_PPC_POWERNV) += imc-pmu.o
+1 -1
arch/powerpc/perf/power10-pmu.c
··· 91 91 92 92 /* Table of alternatives, sorted by column 0 */ 93 93 static const unsigned int power10_event_alternatives[][MAX_ALT] = { 94 - { PM_CYC_ALT, PM_CYC }, 95 94 { PM_INST_CMPL_ALT, PM_INST_CMPL }, 95 + { PM_CYC_ALT, PM_CYC }, 96 96 }; 97 97 98 98 static int power10_get_alternatives(u64 event, unsigned int flags, u64 alt[])
+4 -4
arch/powerpc/perf/power9-pmu.c
··· 133 133 134 134 /* Table of alternatives, sorted by column 0 */ 135 135 static const unsigned int power9_event_alternatives[][MAX_ALT] = { 136 - { PM_INST_DISP, PM_INST_DISP_ALT }, 137 - { PM_RUN_CYC_ALT, PM_RUN_CYC }, 138 - { PM_RUN_INST_CMPL_ALT, PM_RUN_INST_CMPL }, 139 - { PM_LD_MISS_L1, PM_LD_MISS_L1_ALT }, 140 136 { PM_BR_2PATH, PM_BR_2PATH_ALT }, 137 + { PM_INST_DISP, PM_INST_DISP_ALT }, 138 + { PM_RUN_CYC_ALT, PM_RUN_CYC }, 139 + { PM_LD_MISS_L1, PM_LD_MISS_L1_ALT }, 140 + { PM_RUN_INST_CMPL_ALT, PM_RUN_INST_CMPL }, 141 141 }; 142 142 143 143 static int power9_get_alternatives(u64 event, unsigned int flags, u64 alt[])