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

Pull powerpc fixes from Michael Ellerman:
"Fix our KVM reverse map real-mode handling since we enabled huge
vmalloc (in some configurations).

Revert a recent change to our IOMMU code which broke some devices.

Fix KVM handling of FSCR on P7/P8, which could have possibly let a
guest crash it's Qemu.

Fix kprobes validation of prefixed instructions across page boundary.

Thanks to Alexey Kardashevskiy, Christophe Leroy, Fabiano Rosas,
Frederic Barrat, Naveen N. Rao, and Nicholas Piggin"

* tag 'powerpc-5.13-5' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux:
Revert "powerpc/kernel/iommu: Align size for IOMMU_PAGE_SIZE() to save TCEs"
KVM: PPC: Book3S HV: Save host FSCR in the P7/8 path
powerpc: Fix reverse map real-mode address lookup with huge vmalloc
powerpc/kprobes: Fix validation of prefixed instructions across page boundary

+49 -57
+29
arch/powerpc/include/asm/pte-walk.h
··· 31 31 pgd_t *pgdir = init_mm.pgd; 32 32 return __find_linux_pte(pgdir, ea, NULL, hshift); 33 33 } 34 + 35 + /* 36 + * Convert a kernel vmap virtual address (vmalloc or ioremap space) to a 37 + * physical address, without taking locks. This can be used in real-mode. 38 + */ 39 + static inline phys_addr_t ppc_find_vmap_phys(unsigned long addr) 40 + { 41 + pte_t *ptep; 42 + phys_addr_t pa; 43 + int hugepage_shift; 44 + 45 + /* 46 + * init_mm does not free page tables, and does not do THP. It may 47 + * have huge pages from huge vmalloc / ioremap etc. 48 + */ 49 + ptep = find_init_mm_pte(addr, &hugepage_shift); 50 + if (WARN_ON(!ptep)) 51 + return 0; 52 + 53 + pa = PFN_PHYS(pte_pfn(*ptep)); 54 + 55 + if (!hugepage_shift) 56 + hugepage_shift = PAGE_SHIFT; 57 + 58 + pa |= addr & ((1ul << hugepage_shift) - 1); 59 + 60 + return pa; 61 + } 62 + 34 63 /* 35 64 * This is what we should always use. Any other lockless page table lookup needs 36 65 * careful audit against THP split.
+1 -22
arch/powerpc/kernel/eeh.c
··· 346 346 */ 347 347 static inline unsigned long eeh_token_to_phys(unsigned long token) 348 348 { 349 - pte_t *ptep; 350 - unsigned long pa; 351 - int hugepage_shift; 352 - 353 - /* 354 - * We won't find hugepages here(this is iomem). Hence we are not 355 - * worried about _PAGE_SPLITTING/collapse. Also we will not hit 356 - * page table free, because of init_mm. 357 - */ 358 - ptep = find_init_mm_pte(token, &hugepage_shift); 359 - if (!ptep) 360 - return token; 361 - 362 - pa = pte_pfn(*ptep); 363 - 364 - /* On radix we can do hugepage mappings for io, so handle that */ 365 - if (!hugepage_shift) 366 - hugepage_shift = PAGE_SHIFT; 367 - 368 - pa <<= PAGE_SHIFT; 369 - pa |= token & ((1ul << hugepage_shift) - 1); 370 - return pa; 349 + return ppc_find_vmap_phys(token); 371 350 } 372 351 373 352 /*
+3 -13
arch/powerpc/kernel/io-workarounds.c
··· 55 55 #ifdef CONFIG_PPC_INDIRECT_MMIO 56 56 struct iowa_bus *iowa_mem_find_bus(const PCI_IO_ADDR addr) 57 57 { 58 - unsigned hugepage_shift; 59 58 struct iowa_bus *bus; 60 59 int token; 61 60 ··· 64 65 bus = &iowa_busses[token - 1]; 65 66 else { 66 67 unsigned long vaddr, paddr; 67 - pte_t *ptep; 68 68 69 69 vaddr = (unsigned long)PCI_FIX_ADDR(addr); 70 70 if (vaddr < PHB_IO_BASE || vaddr >= PHB_IO_END) 71 71 return NULL; 72 - /* 73 - * We won't find huge pages here (iomem). Also can't hit 74 - * a page table free due to init_mm 75 - */ 76 - ptep = find_init_mm_pte(vaddr, &hugepage_shift); 77 - if (ptep == NULL) 78 - paddr = 0; 79 - else { 80 - WARN_ON(hugepage_shift); 81 - paddr = pte_pfn(*ptep) << PAGE_SHIFT; 82 - } 72 + 73 + paddr = ppc_find_vmap_phys(vaddr); 74 + 83 75 bus = iowa_pci_find(vaddr, paddr); 84 76 85 77 if (bus == NULL)
+5 -6
arch/powerpc/kernel/iommu.c
··· 898 898 unsigned int order; 899 899 unsigned int nio_pages, io_order; 900 900 struct page *page; 901 - size_t size_io = size; 902 901 903 902 size = PAGE_ALIGN(size); 904 903 order = get_order(size); ··· 924 925 memset(ret, 0, size); 925 926 926 927 /* Set up tces to cover the allocated range */ 927 - size_io = IOMMU_PAGE_ALIGN(size_io, tbl); 928 - nio_pages = size_io >> tbl->it_page_shift; 929 - io_order = get_iommu_order(size_io, tbl); 928 + nio_pages = size >> tbl->it_page_shift; 929 + io_order = get_iommu_order(size, tbl); 930 930 mapping = iommu_alloc(dev, tbl, ret, nio_pages, DMA_BIDIRECTIONAL, 931 931 mask >> tbl->it_page_shift, io_order, 0); 932 932 if (mapping == DMA_MAPPING_ERROR) { ··· 940 942 void *vaddr, dma_addr_t dma_handle) 941 943 { 942 944 if (tbl) { 943 - size_t size_io = IOMMU_PAGE_ALIGN(size, tbl); 944 - unsigned int nio_pages = size_io >> tbl->it_page_shift; 945 + unsigned int nio_pages; 945 946 947 + size = PAGE_ALIGN(size); 948 + nio_pages = size >> tbl->it_page_shift; 946 949 iommu_free(tbl, dma_handle, nio_pages); 947 950 size = PAGE_ALIGN(size); 948 951 free_pages((unsigned long)vaddr, get_order(size));
+2 -2
arch/powerpc/kernel/kprobes.c
··· 108 108 int ret = 0; 109 109 struct kprobe *prev; 110 110 struct ppc_inst insn = ppc_inst_read((struct ppc_inst *)p->addr); 111 - struct ppc_inst prefix = ppc_inst_read((struct ppc_inst *)(p->addr - 1)); 112 111 113 112 if ((unsigned long)p->addr & 0x03) { 114 113 printk("Attempt to register kprobe at an unaligned address\n"); ··· 115 116 } else if (IS_MTMSRD(insn) || IS_RFID(insn) || IS_RFI(insn)) { 116 117 printk("Cannot register a kprobe on rfi/rfid or mtmsr[d]\n"); 117 118 ret = -EINVAL; 118 - } else if (ppc_inst_prefixed(prefix)) { 119 + } else if ((unsigned long)p->addr & ~PAGE_MASK && 120 + ppc_inst_prefixed(ppc_inst_read((struct ppc_inst *)(p->addr - 1)))) { 119 121 printk("Cannot register a kprobe on the second word of prefixed instruction\n"); 120 122 ret = -EINVAL; 121 123 }
-1
arch/powerpc/kvm/book3s_hv.c
··· 4455 4455 mtspr(SPRN_EBBRR, ebb_regs[1]); 4456 4456 mtspr(SPRN_BESCR, ebb_regs[2]); 4457 4457 mtspr(SPRN_TAR, user_tar); 4458 - mtspr(SPRN_FSCR, current->thread.fscr); 4459 4458 } 4460 4459 mtspr(SPRN_VRSAVE, user_vrsave); 4461 4460
+2 -13
arch/powerpc/kvm/book3s_hv_rm_mmu.c
··· 23 23 #include <asm/pte-walk.h> 24 24 25 25 /* Translate address of a vmalloc'd thing to a linear map address */ 26 - static void *real_vmalloc_addr(void *x) 26 + static void *real_vmalloc_addr(void *addr) 27 27 { 28 - unsigned long addr = (unsigned long) x; 29 - pte_t *p; 30 - /* 31 - * assume we don't have huge pages in vmalloc space... 32 - * So don't worry about THP collapse/split. Called 33 - * Only in realmode with MSR_EE = 0, hence won't need irq_save/restore. 34 - */ 35 - p = find_init_mm_pte(addr, NULL); 36 - if (!p || !pte_present(*p)) 37 - return NULL; 38 - addr = (pte_pfn(*p) << PAGE_SHIFT) | (addr & ~PAGE_MASK); 39 - return __va(addr); 28 + return __va(ppc_find_vmap_phys((unsigned long)addr)); 40 29 } 41 30 42 31 /* Return 1 if we need to do a global tlbie, 0 if we can use tlbiel */
+7
arch/powerpc/kvm/book3s_hv_rmhandlers.S
··· 59 59 #define STACK_SLOT_UAMOR (SFS-88) 60 60 #define STACK_SLOT_DAWR1 (SFS-96) 61 61 #define STACK_SLOT_DAWRX1 (SFS-104) 62 + #define STACK_SLOT_FSCR (SFS-112) 62 63 /* the following is used by the P9 short path */ 63 64 #define STACK_SLOT_NVGPRS (SFS-152) /* 18 gprs */ 64 65 ··· 687 686 std r6, STACK_SLOT_DAWR0(r1) 688 687 std r7, STACK_SLOT_DAWRX0(r1) 689 688 std r8, STACK_SLOT_IAMR(r1) 689 + mfspr r5, SPRN_FSCR 690 + std r5, STACK_SLOT_FSCR(r1) 690 691 END_FTR_SECTION_IFSET(CPU_FTR_ARCH_207S) 691 692 BEGIN_FTR_SECTION 692 693 mfspr r6, SPRN_DAWR1 ··· 1666 1663 ld r7, STACK_SLOT_HFSCR(r1) 1667 1664 mtspr SPRN_HFSCR, r7 1668 1665 ALT_FTR_SECTION_END_IFCLR(CPU_FTR_ARCH_300) 1666 + BEGIN_FTR_SECTION 1667 + ld r5, STACK_SLOT_FSCR(r1) 1668 + mtspr SPRN_FSCR, r5 1669 + END_FTR_SECTION_IFSET(CPU_FTR_ARCH_207S) 1669 1670 /* 1670 1671 * Restore various registers to 0, where non-zero values 1671 1672 * set by the guest could disrupt the host.