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 tag 'powerpc-4.18-4' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux

Pull powerpc fixes from Michael Ellerman:
"Two regression fixes, one for xmon disassembly formatting and the
other to fix the E500 build.

Two commits to fix a potential security issue in the VFIO code under
obscure circumstances.

And finally a fix to the Power9 idle code to restore SPRG3, which is
user visible and used for sched_getcpu().

Thanks to: Alexey Kardashevskiy, David Gibson. Gautham R. Shenoy,
James Clarke"

* tag 'powerpc-4.18-4' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux:
powerpc/powernv: Fix save/restore of SPRG3 on entry/exit from stop (idle)
powerpc/Makefile: Assemble with -me500 when building for E500
KVM: PPC: Check if IOMMU page is contained in the pinned physical page
vfio/spapr: Use IOMMU pageshift rather than pagesize
powerpc/xmon: Fix disassembly since printf changes

+52 -14
+1
arch/powerpc/Makefile
··· 243 243 cpu-as-$(CONFIG_4xx) += -Wa,-m405 244 244 cpu-as-$(CONFIG_ALTIVEC) += $(call as-option,-Wa$(comma)-maltivec) 245 245 cpu-as-$(CONFIG_E200) += -Wa,-me200 246 + cpu-as-$(CONFIG_E500) += -Wa,-me500 246 247 cpu-as-$(CONFIG_PPC_BOOK3S_64) += -Wa,-mpower4 247 248 cpu-as-$(CONFIG_PPC_E500MC) += $(call as-option,-Wa$(comma)-me500mc) 248 249
+2 -2
arch/powerpc/include/asm/mmu_context.h
··· 35 35 extern struct mm_iommu_table_group_mem_t *mm_iommu_find(struct mm_struct *mm, 36 36 unsigned long ua, unsigned long entries); 37 37 extern long mm_iommu_ua_to_hpa(struct mm_iommu_table_group_mem_t *mem, 38 - unsigned long ua, unsigned long *hpa); 38 + unsigned long ua, unsigned int pageshift, unsigned long *hpa); 39 39 extern long mm_iommu_ua_to_hpa_rm(struct mm_iommu_table_group_mem_t *mem, 40 - unsigned long ua, unsigned long *hpa); 40 + unsigned long ua, unsigned int pageshift, unsigned long *hpa); 41 41 extern long mm_iommu_mapped_inc(struct mm_iommu_table_group_mem_t *mem); 42 42 extern void mm_iommu_mapped_dec(struct mm_iommu_table_group_mem_t *mem); 43 43 #endif
+2
arch/powerpc/kernel/idle_book3s.S
··· 144 144 mtspr SPRN_MMCR1, r4 145 145 146 146 ld r3, STOP_MMCR2(r13) 147 + ld r4, PACA_SPRG_VDSO(r13) 147 148 mtspr SPRN_MMCR2, r3 149 + mtspr SPRN_SPRG3, r4 148 150 blr 149 151 150 152 /*
+1 -1
arch/powerpc/kvm/book3s_64_vio.c
··· 449 449 /* This only handles v2 IOMMU type, v1 is handled via ioctl() */ 450 450 return H_TOO_HARD; 451 451 452 - if (WARN_ON_ONCE(mm_iommu_ua_to_hpa(mem, ua, &hpa))) 452 + if (WARN_ON_ONCE(mm_iommu_ua_to_hpa(mem, ua, tbl->it_page_shift, &hpa))) 453 453 return H_HARDWARE; 454 454 455 455 if (mm_iommu_mapped_inc(mem))
+4 -2
arch/powerpc/kvm/book3s_64_vio_hv.c
··· 279 279 if (!mem) 280 280 return H_TOO_HARD; 281 281 282 - if (WARN_ON_ONCE_RM(mm_iommu_ua_to_hpa_rm(mem, ua, &hpa))) 282 + if (WARN_ON_ONCE_RM(mm_iommu_ua_to_hpa_rm(mem, ua, tbl->it_page_shift, 283 + &hpa))) 283 284 return H_HARDWARE; 284 285 285 286 pua = (void *) vmalloc_to_phys(pua); ··· 470 469 471 470 mem = mm_iommu_lookup_rm(vcpu->kvm->mm, ua, IOMMU_PAGE_SIZE_4K); 472 471 if (mem) 473 - prereg = mm_iommu_ua_to_hpa_rm(mem, ua, &tces) == 0; 472 + prereg = mm_iommu_ua_to_hpa_rm(mem, ua, 473 + IOMMU_PAGE_SHIFT_4K, &tces) == 0; 474 474 } 475 475 476 476 if (!prereg) {
+35 -2
arch/powerpc/mm/mmu_context_iommu.c
··· 19 19 #include <linux/hugetlb.h> 20 20 #include <linux/swap.h> 21 21 #include <asm/mmu_context.h> 22 + #include <asm/pte-walk.h> 22 23 23 24 static DEFINE_MUTEX(mem_list_mutex); 24 25 ··· 28 27 struct rcu_head rcu; 29 28 unsigned long used; 30 29 atomic64_t mapped; 30 + unsigned int pageshift; 31 31 u64 ua; /* userspace address */ 32 32 u64 entries; /* number of entries in hpas[] */ 33 33 u64 *hpas; /* vmalloc'ed */ ··· 127 125 { 128 126 struct mm_iommu_table_group_mem_t *mem; 129 127 long i, j, ret = 0, locked_entries = 0; 128 + unsigned int pageshift; 129 + unsigned long flags; 130 130 struct page *page = NULL; 131 131 132 132 mutex_lock(&mem_list_mutex); ··· 163 159 goto unlock_exit; 164 160 } 165 161 162 + /* 163 + * For a starting point for a maximum page size calculation 164 + * we use @ua and @entries natural alignment to allow IOMMU pages 165 + * smaller than huge pages but still bigger than PAGE_SIZE. 166 + */ 167 + mem->pageshift = __ffs(ua | (entries << PAGE_SHIFT)); 166 168 mem->hpas = vzalloc(array_size(entries, sizeof(mem->hpas[0]))); 167 169 if (!mem->hpas) { 168 170 kfree(mem); ··· 209 199 } 210 200 } 211 201 populate: 202 + pageshift = PAGE_SHIFT; 203 + if (PageCompound(page)) { 204 + pte_t *pte; 205 + struct page *head = compound_head(page); 206 + unsigned int compshift = compound_order(head); 207 + 208 + local_irq_save(flags); /* disables as well */ 209 + pte = find_linux_pte(mm->pgd, ua, NULL, &pageshift); 210 + local_irq_restore(flags); 211 + 212 + /* Double check it is still the same pinned page */ 213 + if (pte && pte_page(*pte) == head && 214 + pageshift == compshift) 215 + pageshift = max_t(unsigned int, pageshift, 216 + PAGE_SHIFT); 217 + } 218 + mem->pageshift = min(mem->pageshift, pageshift); 212 219 mem->hpas[i] = page_to_pfn(page) << PAGE_SHIFT; 213 220 } 214 221 ··· 376 349 EXPORT_SYMBOL_GPL(mm_iommu_find); 377 350 378 351 long mm_iommu_ua_to_hpa(struct mm_iommu_table_group_mem_t *mem, 379 - unsigned long ua, unsigned long *hpa) 352 + unsigned long ua, unsigned int pageshift, unsigned long *hpa) 380 353 { 381 354 const long entry = (ua - mem->ua) >> PAGE_SHIFT; 382 355 u64 *va = &mem->hpas[entry]; 383 356 384 357 if (entry >= mem->entries) 358 + return -EFAULT; 359 + 360 + if (pageshift > mem->pageshift) 385 361 return -EFAULT; 386 362 387 363 *hpa = *va | (ua & ~PAGE_MASK); ··· 394 364 EXPORT_SYMBOL_GPL(mm_iommu_ua_to_hpa); 395 365 396 366 long mm_iommu_ua_to_hpa_rm(struct mm_iommu_table_group_mem_t *mem, 397 - unsigned long ua, unsigned long *hpa) 367 + unsigned long ua, unsigned int pageshift, unsigned long *hpa) 398 368 { 399 369 const long entry = (ua - mem->ua) >> PAGE_SHIFT; 400 370 void *va = &mem->hpas[entry]; 401 371 unsigned long *pa; 402 372 403 373 if (entry >= mem->entries) 374 + return -EFAULT; 375 + 376 + if (pageshift > mem->pageshift) 404 377 return -EFAULT; 405 378 406 379 pa = (void *) vmalloc_to_phys(va);
+2 -2
arch/powerpc/xmon/xmon.c
··· 2734 2734 { 2735 2735 int nr, dotted; 2736 2736 unsigned long first_adr; 2737 - unsigned long inst, last_inst = 0; 2737 + unsigned int inst, last_inst = 0; 2738 2738 unsigned char val[4]; 2739 2739 2740 2740 dotted = 0; ··· 2758 2758 dotted = 0; 2759 2759 last_inst = inst; 2760 2760 if (praddr) 2761 - printf(REG" %.8lx", adr, inst); 2761 + printf(REG" %.8x", adr, inst); 2762 2762 printf("\t"); 2763 2763 dump_func(inst, adr); 2764 2764 printf("\n");
+5 -5
drivers/vfio/vfio_iommu_spapr_tce.c
··· 457 457 } 458 458 459 459 static int tce_iommu_prereg_ua_to_hpa(struct tce_container *container, 460 - unsigned long tce, unsigned long size, 460 + unsigned long tce, unsigned long shift, 461 461 unsigned long *phpa, struct mm_iommu_table_group_mem_t **pmem) 462 462 { 463 463 long ret = 0; 464 464 struct mm_iommu_table_group_mem_t *mem; 465 465 466 - mem = mm_iommu_lookup(container->mm, tce, size); 466 + mem = mm_iommu_lookup(container->mm, tce, 1ULL << shift); 467 467 if (!mem) 468 468 return -EINVAL; 469 469 470 - ret = mm_iommu_ua_to_hpa(mem, tce, phpa); 470 + ret = mm_iommu_ua_to_hpa(mem, tce, shift, phpa); 471 471 if (ret) 472 472 return -EINVAL; 473 473 ··· 487 487 if (!pua) 488 488 return; 489 489 490 - ret = tce_iommu_prereg_ua_to_hpa(container, *pua, IOMMU_PAGE_SIZE(tbl), 490 + ret = tce_iommu_prereg_ua_to_hpa(container, *pua, tbl->it_page_shift, 491 491 &hpa, &mem); 492 492 if (ret) 493 493 pr_debug("%s: tce %lx at #%lx was not cached, ret=%d\n", ··· 611 611 entry + i); 612 612 613 613 ret = tce_iommu_prereg_ua_to_hpa(container, 614 - tce, IOMMU_PAGE_SIZE(tbl), &hpa, &mem); 614 + tce, tbl->it_page_shift, &hpa, &mem); 615 615 if (ret) 616 616 break; 617 617