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

Merge tag 's390-6.19-2' of git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux

Pull more s390 updates from Heiko Carstens:

- Use the MSI parent domain API instead of the legacy API for setup and
teardown of PCI MSI IRQs

- Select POSIX_CPU_TIMERS_TASK_WORK now that VIRT_XFER_TO_GUEST_WORK
has been implemented for s390

- Fix a KVM bug which can lead to guest memory corruption

- Fix KASAN shadow memory mapping for hotplugged memory

- Minor bug fixes and improvements

* tag 's390-6.19-2' of git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux:
s390/bug: Add missing alignment
s390/bug: Add missing CONFIG_BUG ifdef again
KVM: s390: Fix gmap_helper_zap_one_page() again
s390/pci: Migrate s390 IRQ logic to IRQ domain API
genirq: Change hwirq parameter to irq_hw_number_t
s390: Select POSIX_CPU_TIMERS_TASK_WORK
s390: Unmap early KASAN shadow on memory offlining
s390/vmem: Support 2G page splitting for KASAN shadow freeing
s390/boot: Use entire page for PTEs
s390/vmur: Use scnprintf() instead of sprintf()

+333 -174
+2
arch/s390/Kconfig
··· 238 238 select HAVE_PERF_EVENTS 239 239 select HAVE_PERF_REGS 240 240 select HAVE_PERF_USER_STACK_DUMP 241 + select HAVE_POSIX_CPU_TIMERS_TASK_WORK 241 242 select HAVE_PREEMPT_DYNAMIC_KEY 242 243 select HAVE_REGS_AND_STACK_ACCESS_API 243 244 select HAVE_RELIABLE_STACKTRACE ··· 255 254 select HOTPLUG_SMT 256 255 select IOMMU_HELPER if PCI 257 256 select IOMMU_SUPPORT if PCI 257 + select IRQ_MSI_LIB if PCI 258 258 select KASAN_VMALLOC if KASAN 259 259 select LOCK_MM_AND_FIND_VMA 260 260 select MMU_GATHER_MERGE_VMAS
+2 -14
arch/s390/boot/vmem.c
··· 244 244 245 245 static pte_t *boot_pte_alloc(void) 246 246 { 247 - static void *pte_leftover; 248 247 pte_t *pte; 249 248 250 - /* 251 - * handling pte_leftovers this way helps to avoid memory fragmentation 252 - * during POPULATE_KASAN_MAP_SHADOW when EDAT is off 253 - */ 254 - if (!pte_leftover) { 255 - pte_leftover = (void *)physmem_alloc_or_die(RR_VMEM, PAGE_SIZE, PAGE_SIZE); 256 - pte = pte_leftover + _PAGE_TABLE_SIZE; 257 - __arch_set_page_dat(pte, 1); 258 - } else { 259 - pte = pte_leftover; 260 - pte_leftover = NULL; 261 - } 262 - 249 + pte = (void *)physmem_alloc_or_die(RR_VMEM, PAGE_SIZE, PAGE_SIZE); 250 + __arch_set_page_dat(pte, 1); 263 251 memset64((u64 *)pte, _PAGE_INVALID, PTRS_PER_PTE); 264 252 return pte; 265 253 }
+5
arch/s390/include/asm/bug.h
··· 4 4 5 5 #include <linux/stringify.h> 6 6 7 + #ifdef CONFIG_BUG 8 + 7 9 #ifndef CONFIG_DEBUG_BUGVERBOSE 8 10 #define _BUGVERBOSE_LOCATION(file, line) 9 11 #else 10 12 #define __BUGVERBOSE_LOCATION(file, line) \ 11 13 .pushsection .rodata.str, "aMS", @progbits, 1; \ 14 + .align 2; \ 12 15 10002: .ascii file "\0"; \ 13 16 .popsection; \ 14 17 \ ··· 54 51 } while (0) 55 52 56 53 #define HAVE_ARCH_BUG 54 + 55 + #endif /* CONFIG_BUG */ 57 56 58 57 #include <asm-generic/bug.h> 59 58
+2
arch/s390/include/asm/page.h
··· 166 166 return CC_TRANSFORM(cc); 167 167 } 168 168 169 + int split_pud_page(pud_t *pudp, unsigned long addr); 170 + 169 171 /* Bits int the storage key */ 170 172 #define _PAGE_CHANGED 0x02 /* HW changed bit */ 171 173 #define _PAGE_REFERENCED 0x04 /* HW referenced bit */
+5
arch/s390/include/asm/pci.h
··· 5 5 #include <linux/pci.h> 6 6 #include <linux/mutex.h> 7 7 #include <linux/iommu.h> 8 + #include <linux/irqdomain.h> 8 9 #include <linux/pci_hotplug.h> 9 10 #include <asm/pci_clp.h> 10 11 #include <asm/pci_debug.h> ··· 110 109 struct list_head resources; 111 110 struct list_head bus_next; 112 111 struct resource bus_resource; 112 + struct irq_domain *msi_parent_domain; 113 113 int topo; /* TID if topo_is_tid, PCHID otherwise */ 114 114 int domain_nr; 115 115 u8 multifunction : 1; ··· 312 310 /* IRQ */ 313 311 int __init zpci_irq_init(void); 314 312 void __init zpci_irq_exit(void); 313 + int zpci_set_irq(struct zpci_dev *zdev); 314 + int zpci_create_parent_msi_domain(struct zpci_bus *zbus); 315 + void zpci_remove_parent_msi_domain(struct zpci_bus *zbus); 315 316 316 317 /* FMB */ 317 318 int zpci_fmb_enable_device(struct zpci_dev *);
+7 -2
arch/s390/mm/gmap_helpers.c
··· 47 47 void gmap_helper_zap_one_page(struct mm_struct *mm, unsigned long vmaddr) 48 48 { 49 49 struct vm_area_struct *vma; 50 + unsigned long pgstev; 50 51 spinlock_t *ptl; 51 52 pgste_t pgste; 52 53 pte_t *ptep; ··· 66 65 if (pte_swap(*ptep)) { 67 66 preempt_disable(); 68 67 pgste = pgste_get_lock(ptep); 68 + pgstev = pgste_val(pgste); 69 69 70 - ptep_zap_softleaf_entry(mm, softleaf_from_pte(*ptep)); 71 - pte_clear(mm, vmaddr, ptep); 70 + if ((pgstev & _PGSTE_GPS_USAGE_MASK) == _PGSTE_GPS_USAGE_UNUSED || 71 + (pgstev & _PGSTE_GPS_ZERO)) { 72 + ptep_zap_softleaf_entry(mm, softleaf_from_pte(*ptep)); 73 + pte_clear(mm, vmaddr, ptep); 74 + } 72 75 73 76 pgste_set_unlock(ptep, pgste); 74 77 preempt_enable();
+1 -1
arch/s390/mm/pageattr.c
··· 204 204 return rc; 205 205 } 206 206 207 - static int split_pud_page(pud_t *pudp, unsigned long addr) 207 + int split_pud_page(pud_t *pudp, unsigned long addr) 208 208 { 209 209 unsigned long pmd_addr, prot; 210 210 pmd_t *pm_dir, *pmdp;
+12 -2
arch/s390/mm/vmem.c
··· 330 330 if (pud_leaf(*pud)) { 331 331 if (IS_ALIGNED(addr, PUD_SIZE) && 332 332 IS_ALIGNED(next, PUD_SIZE)) { 333 + if (!direct) 334 + vmem_free_pages(pud_deref(*pud), get_order(PUD_SIZE), altmap); 333 335 pud_clear(pud); 334 336 pages++; 337 + continue; 338 + } else { 339 + split_pud_page(pud, addr & PUD_MASK); 335 340 } 336 - continue; 337 341 } 338 342 } else if (pud_none(*pud)) { 339 343 if (IS_ALIGNED(addr, PUD_SIZE) && ··· 437 433 438 434 if (WARN_ON_ONCE(!PAGE_ALIGNED(start | end))) 439 435 return -EINVAL; 440 - /* Don't mess with any tables not fully in 1:1 mapping & vmemmap area */ 436 + /* Don't mess with any tables not fully in 1:1 mapping, vmemmap & kasan area */ 437 + #ifdef CONFIG_KASAN 438 + if (WARN_ON_ONCE(!(start >= KASAN_SHADOW_START && end <= KASAN_SHADOW_END) && 439 + end > __abs_lowcore)) 440 + return -EINVAL; 441 + #else 441 442 if (WARN_ON_ONCE(end > __abs_lowcore)) 442 443 return -EINVAL; 444 + #endif 443 445 for (addr = start; addr < end; addr = next) { 444 446 next = pgd_addr_end(addr, end); 445 447 pgd = pgd_offset_k(addr);
+6
arch/s390/pci/pci.c
··· 708 708 if (rc) 709 709 return rc; 710 710 711 + if (zdev->msi_nr_irqs > 0) { 712 + rc = zpci_set_irq(zdev); 713 + if (rc) 714 + return rc; 715 + } 716 + 711 717 rc = zpci_iommu_register_ioat(zdev, &status); 712 718 if (rc) 713 719 zpci_disable_device(zdev);
+14 -4
arch/s390/pci/pci_bus.c
··· 14 14 #include <linux/err.h> 15 15 #include <linux/delay.h> 16 16 #include <linux/seq_file.h> 17 + #include <linux/irqdomain.h> 17 18 #include <linux/jump_label.h> 18 19 #include <linux/pci.h> 19 20 #include <linux/printk.h> ··· 199 198 zbus->multifunction = zpci_bus_is_multifunction_root(fr); 200 199 zbus->max_bus_speed = fr->max_bus_speed; 201 200 201 + if (zpci_create_parent_msi_domain(zbus)) 202 + goto out_free_domain; 203 + 202 204 /* 203 205 * Note that the zbus->resources are taken over and zbus->resources 204 206 * is empty after a successful call 205 207 */ 206 208 bus = pci_create_root_bus(NULL, ZPCI_BUS_NR, ops, zbus, &zbus->resources); 207 - if (!bus) { 208 - zpci_free_domain(zbus->domain_nr); 209 - return -EFAULT; 210 - } 209 + if (!bus) 210 + goto out_remove_msi_domain; 211 211 212 212 zbus->bus = bus; 213 + dev_set_msi_domain(&zbus->bus->dev, zbus->msi_parent_domain); 213 214 214 215 return 0; 216 + 217 + out_remove_msi_domain: 218 + zpci_remove_parent_msi_domain(zbus); 219 + out_free_domain: 220 + zpci_free_domain(zbus->domain_nr); 221 + return -ENOMEM; 215 222 } 216 223 217 224 static void zpci_bus_release(struct kref *kref) ··· 240 231 mutex_lock(&zbus_list_lock); 241 232 list_del(&zbus->bus_next); 242 233 mutex_unlock(&zbus_list_lock); 234 + zpci_remove_parent_msi_domain(zbus); 243 235 kfree(zbus); 244 236 } 245 237
+251 -141
arch/s390/pci/pci_irq.c
··· 6 6 #include <linux/kernel_stat.h> 7 7 #include <linux/pci.h> 8 8 #include <linux/msi.h> 9 + #include <linux/irqchip/irq-msi-lib.h> 9 10 #include <linux/smp.h> 10 11 11 12 #include <asm/isc.h> ··· 98 97 } 99 98 100 99 /* Register adapter interruptions */ 101 - static int zpci_set_irq(struct zpci_dev *zdev) 100 + int zpci_set_irq(struct zpci_dev *zdev) 102 101 { 103 102 int rc; 104 103 ··· 126 125 static int zpci_set_irq_affinity(struct irq_data *data, const struct cpumask *dest, 127 126 bool force) 128 127 { 129 - struct msi_desc *entry = irq_data_get_msi_desc(data); 130 - struct msi_msg msg = entry->msg; 131 - int cpu_addr = smp_cpu_get_cpu_address(cpumask_first(dest)); 132 - 133 - msg.address_lo &= 0xff0000ff; 134 - msg.address_lo |= (cpu_addr << 8); 135 - pci_write_msi_msg(data->irq, &msg); 136 - 128 + irq_data_update_affinity(data, dest); 137 129 return IRQ_SET_MASK_OK; 130 + } 131 + 132 + /* 133 + * Encode the hwirq number for the parent domain. The encoding must be unique 134 + * for each IRQ of each device in the parent domain, so it uses the devfn to 135 + * identify the device and the msi_index to identify the IRQ within that device. 136 + */ 137 + static inline u32 zpci_encode_hwirq(u8 devfn, u16 msi_index) 138 + { 139 + return (devfn << 16) | msi_index; 140 + } 141 + 142 + static inline u16 zpci_decode_hwirq_msi_index(irq_hw_number_t hwirq) 143 + { 144 + return hwirq & 0xffff; 145 + } 146 + 147 + static void zpci_compose_msi_msg(struct irq_data *data, struct msi_msg *msg) 148 + { 149 + struct msi_desc *desc = irq_data_get_msi_desc(data); 150 + struct zpci_dev *zdev = to_zpci_dev(desc->dev); 151 + 152 + if (irq_delivery == DIRECTED) { 153 + int cpu = cpumask_first(irq_data_get_affinity_mask(data)); 154 + 155 + msg->address_lo = zdev->msi_addr & 0xff0000ff; 156 + msg->address_lo |= (smp_cpu_get_cpu_address(cpu) << 8); 157 + } else { 158 + msg->address_lo = zdev->msi_addr & 0xffffffff; 159 + } 160 + msg->address_hi = zdev->msi_addr >> 32; 161 + msg->data = zpci_decode_hwirq_msi_index(data->hwirq); 138 162 } 139 163 140 164 static struct irq_chip zpci_irq_chip = { 141 165 .name = "PCI-MSI", 142 - .irq_unmask = pci_msi_unmask_irq, 143 - .irq_mask = pci_msi_mask_irq, 166 + .irq_compose_msi_msg = zpci_compose_msi_msg, 144 167 }; 145 168 146 169 static void zpci_handle_cpu_local_irq(bool rescan) 147 170 { 148 171 struct airq_iv *dibv = zpci_ibv[smp_processor_id()]; 149 172 union zpci_sic_iib iib = {{0}}; 173 + struct irq_domain *msi_domain; 174 + irq_hw_number_t hwirq; 150 175 unsigned long bit; 151 176 int irqs_on = 0; 152 177 ··· 190 163 continue; 191 164 } 192 165 inc_irq_stat(IRQIO_MSI); 193 - generic_handle_irq(airq_iv_get_data(dibv, bit)); 166 + hwirq = airq_iv_get_data(dibv, bit); 167 + msi_domain = (struct irq_domain *)airq_iv_get_ptr(dibv, bit); 168 + generic_handle_domain_irq(msi_domain, hwirq); 194 169 } 195 170 } 196 171 ··· 257 228 struct tpi_info *tpi_info) 258 229 { 259 230 union zpci_sic_iib iib = {{0}}; 231 + struct irq_domain *msi_domain; 232 + irq_hw_number_t hwirq; 260 233 unsigned long si, ai; 261 234 struct airq_iv *aibv; 262 235 int irqs_on = 0; ··· 286 255 break; 287 256 inc_irq_stat(IRQIO_MSI); 288 257 airq_iv_lock(aibv, ai); 289 - generic_handle_irq(airq_iv_get_data(aibv, ai)); 258 + hwirq = airq_iv_get_data(aibv, ai); 259 + msi_domain = (struct irq_domain *)airq_iv_get_ptr(aibv, ai); 260 + generic_handle_domain_irq(msi_domain, hwirq); 290 261 airq_iv_unlock(aibv, ai); 291 262 } 292 263 } ··· 310 277 zdev->aisb = *bit; 311 278 312 279 /* Create adapter interrupt vector */ 313 - zdev->aibv = airq_iv_create(msi_vecs, AIRQ_IV_DATA | AIRQ_IV_BITLOCK, NULL); 280 + zdev->aibv = airq_iv_create(msi_vecs, 281 + AIRQ_IV_PTR | AIRQ_IV_DATA | AIRQ_IV_BITLOCK, 282 + NULL); 314 283 if (!zdev->aibv) 315 284 return -ENOMEM; 316 285 ··· 322 287 *bit = 0; 323 288 } 324 289 return 0; 325 - } 326 - 327 - int arch_setup_msi_irqs(struct pci_dev *pdev, int nvec, int type) 328 - { 329 - unsigned int hwirq, msi_vecs, irqs_per_msi, i, cpu; 330 - struct zpci_dev *zdev = to_zpci(pdev); 331 - struct msi_desc *msi; 332 - struct msi_msg msg; 333 - unsigned long bit; 334 - int cpu_addr; 335 - int rc, irq; 336 - 337 - zdev->aisb = -1UL; 338 - zdev->msi_first_bit = -1U; 339 - 340 - msi_vecs = min_t(unsigned int, nvec, zdev->max_msi); 341 - if (msi_vecs < nvec) { 342 - pr_info("%s requested %d irqs, allocate system limit of %d", 343 - pci_name(pdev), nvec, zdev->max_msi); 344 - } 345 - 346 - rc = __alloc_airq(zdev, msi_vecs, &bit); 347 - if (rc < 0) 348 - return rc; 349 - 350 - /* 351 - * Request MSI interrupts: 352 - * When using MSI, nvec_used interrupt sources and their irq 353 - * descriptors are controlled through one msi descriptor. 354 - * Thus the outer loop over msi descriptors shall run only once, 355 - * while two inner loops iterate over the interrupt vectors. 356 - * When using MSI-X, each interrupt vector/irq descriptor 357 - * is bound to exactly one msi descriptor (nvec_used is one). 358 - * So the inner loops are executed once, while the outer iterates 359 - * over the MSI-X descriptors. 360 - */ 361 - hwirq = bit; 362 - msi_for_each_desc(msi, &pdev->dev, MSI_DESC_NOTASSOCIATED) { 363 - if (hwirq - bit >= msi_vecs) 364 - break; 365 - irqs_per_msi = min_t(unsigned int, msi_vecs, msi->nvec_used); 366 - irq = __irq_alloc_descs(-1, 0, irqs_per_msi, 0, THIS_MODULE, 367 - (irq_delivery == DIRECTED) ? 368 - msi->affinity : NULL); 369 - if (irq < 0) 370 - return -ENOMEM; 371 - 372 - for (i = 0; i < irqs_per_msi; i++) { 373 - rc = irq_set_msi_desc_off(irq, i, msi); 374 - if (rc) 375 - return rc; 376 - irq_set_chip_and_handler(irq + i, &zpci_irq_chip, 377 - handle_percpu_irq); 378 - } 379 - 380 - msg.data = hwirq - bit; 381 - if (irq_delivery == DIRECTED) { 382 - if (msi->affinity) 383 - cpu = cpumask_first(&msi->affinity->mask); 384 - else 385 - cpu = 0; 386 - cpu_addr = smp_cpu_get_cpu_address(cpu); 387 - 388 - msg.address_lo = zdev->msi_addr & 0xff0000ff; 389 - msg.address_lo |= (cpu_addr << 8); 390 - 391 - for_each_possible_cpu(cpu) { 392 - for (i = 0; i < irqs_per_msi; i++) 393 - airq_iv_set_data(zpci_ibv[cpu], 394 - hwirq + i, irq + i); 395 - } 396 - } else { 397 - msg.address_lo = zdev->msi_addr & 0xffffffff; 398 - for (i = 0; i < irqs_per_msi; i++) 399 - airq_iv_set_data(zdev->aibv, hwirq + i, irq + i); 400 - } 401 - msg.address_hi = zdev->msi_addr >> 32; 402 - pci_write_msi_msg(irq, &msg); 403 - hwirq += irqs_per_msi; 404 - } 405 - 406 - zdev->msi_first_bit = bit; 407 - zdev->msi_nr_irqs = hwirq - bit; 408 - 409 - rc = zpci_set_irq(zdev); 410 - if (rc) 411 - return rc; 412 - 413 - return (zdev->msi_nr_irqs == nvec) ? 0 : zdev->msi_nr_irqs; 414 - } 415 - 416 - void arch_teardown_msi_irqs(struct pci_dev *pdev) 417 - { 418 - struct zpci_dev *zdev = to_zpci(pdev); 419 - struct msi_desc *msi; 420 - unsigned int i; 421 - int rc; 422 - 423 - /* Disable interrupts */ 424 - rc = zpci_clear_irq(zdev); 425 - if (rc) 426 - return; 427 - 428 - /* Release MSI interrupts */ 429 - msi_for_each_desc(msi, &pdev->dev, MSI_DESC_ASSOCIATED) { 430 - for (i = 0; i < msi->nvec_used; i++) { 431 - irq_set_msi_desc(msi->irq + i, NULL); 432 - irq_free_desc(msi->irq + i); 433 - } 434 - msi->msg.address_lo = 0; 435 - msi->msg.address_hi = 0; 436 - msi->msg.data = 0; 437 - msi->irq = 0; 438 - } 439 - 440 - if (zdev->aisb != -1UL) { 441 - zpci_ibv[zdev->aisb] = NULL; 442 - airq_iv_free_bit(zpci_sbv, zdev->aisb); 443 - zdev->aisb = -1UL; 444 - } 445 - if (zdev->aibv) { 446 - airq_iv_release(zdev->aibv); 447 - zdev->aibv = NULL; 448 - } 449 - 450 - if ((irq_delivery == DIRECTED) && zdev->msi_first_bit != -1U) 451 - airq_iv_free(zpci_ibv[0], zdev->msi_first_bit, zdev->msi_nr_irqs); 452 290 } 453 291 454 292 bool arch_restore_msi_irqs(struct pci_dev *pdev) ··· 336 428 .handler = zpci_floating_irq_handler, 337 429 .isc = PCI_ISC, 338 430 }; 431 + 432 + static void zpci_msi_teardown_directed(struct zpci_dev *zdev) 433 + { 434 + airq_iv_free(zpci_ibv[0], zdev->msi_first_bit, zdev->max_msi); 435 + zdev->msi_first_bit = -1U; 436 + zdev->msi_nr_irqs = 0; 437 + } 438 + 439 + static void zpci_msi_teardown_floating(struct zpci_dev *zdev) 440 + { 441 + airq_iv_release(zdev->aibv); 442 + zdev->aibv = NULL; 443 + airq_iv_free_bit(zpci_sbv, zdev->aisb); 444 + zdev->aisb = -1UL; 445 + zdev->msi_first_bit = -1U; 446 + zdev->msi_nr_irqs = 0; 447 + } 448 + 449 + static void zpci_msi_teardown(struct irq_domain *domain, msi_alloc_info_t *arg) 450 + { 451 + struct zpci_dev *zdev = to_zpci_dev(domain->dev); 452 + 453 + zpci_clear_irq(zdev); 454 + if (irq_delivery == DIRECTED) 455 + zpci_msi_teardown_directed(zdev); 456 + else 457 + zpci_msi_teardown_floating(zdev); 458 + } 459 + 460 + static int zpci_msi_prepare(struct irq_domain *domain, 461 + struct device *dev, int nvec, 462 + msi_alloc_info_t *info) 463 + { 464 + struct zpci_dev *zdev = to_zpci_dev(dev); 465 + struct pci_dev *pdev = to_pci_dev(dev); 466 + unsigned long bit; 467 + int msi_vecs, rc; 468 + 469 + msi_vecs = min_t(unsigned int, nvec, zdev->max_msi); 470 + if (msi_vecs < nvec) { 471 + pr_info("%s requested %d IRQs, allocate system limit of %d\n", 472 + pci_name(pdev), nvec, zdev->max_msi); 473 + } 474 + 475 + rc = __alloc_airq(zdev, msi_vecs, &bit); 476 + if (rc) { 477 + pr_err("Allocating adapter IRQs for %s failed\n", pci_name(pdev)); 478 + return rc; 479 + } 480 + 481 + zdev->msi_first_bit = bit; 482 + zdev->msi_nr_irqs = msi_vecs; 483 + rc = zpci_set_irq(zdev); 484 + if (rc) { 485 + pr_err("Registering adapter IRQs for %s failed\n", 486 + pci_name(pdev)); 487 + 488 + if (irq_delivery == DIRECTED) 489 + zpci_msi_teardown_directed(zdev); 490 + else 491 + zpci_msi_teardown_floating(zdev); 492 + return rc; 493 + } 494 + return 0; 495 + } 496 + 497 + static int zpci_msi_domain_alloc(struct irq_domain *domain, unsigned int virq, 498 + unsigned int nr_irqs, void *args) 499 + { 500 + struct msi_desc *desc = ((msi_alloc_info_t *)args)->desc; 501 + struct zpci_dev *zdev = to_zpci_dev(desc->dev); 502 + struct zpci_bus *zbus = zdev->zbus; 503 + unsigned int cpu, hwirq; 504 + unsigned long bit; 505 + int i; 506 + 507 + bit = zdev->msi_first_bit + desc->msi_index; 508 + hwirq = zpci_encode_hwirq(zdev->devfn, desc->msi_index); 509 + 510 + if (desc->msi_index + nr_irqs > zdev->max_msi) 511 + return -EINVAL; 512 + 513 + for (i = 0; i < nr_irqs; i++) { 514 + irq_domain_set_info(domain, virq + i, hwirq + i, 515 + &zpci_irq_chip, zdev, 516 + handle_percpu_irq, NULL, NULL); 517 + 518 + if (irq_delivery == DIRECTED) { 519 + for_each_possible_cpu(cpu) { 520 + airq_iv_set_ptr(zpci_ibv[cpu], bit + i, 521 + (unsigned long)zbus->msi_parent_domain); 522 + airq_iv_set_data(zpci_ibv[cpu], bit + i, hwirq + i); 523 + } 524 + } else { 525 + airq_iv_set_ptr(zdev->aibv, bit + i, 526 + (unsigned long)zbus->msi_parent_domain); 527 + airq_iv_set_data(zdev->aibv, bit + i, hwirq + i); 528 + } 529 + } 530 + 531 + return 0; 532 + } 533 + 534 + static void zpci_msi_clear_airq(struct irq_data *d, int i) 535 + { 536 + struct msi_desc *desc = irq_data_get_msi_desc(d); 537 + struct zpci_dev *zdev = to_zpci_dev(desc->dev); 538 + unsigned long bit; 539 + unsigned int cpu; 540 + u16 msi_index; 541 + 542 + msi_index = zpci_decode_hwirq_msi_index(d->hwirq); 543 + bit = zdev->msi_first_bit + msi_index; 544 + 545 + if (irq_delivery == DIRECTED) { 546 + for_each_possible_cpu(cpu) { 547 + airq_iv_set_ptr(zpci_ibv[cpu], bit + i, 0); 548 + airq_iv_set_data(zpci_ibv[cpu], bit + i, 0); 549 + } 550 + } else { 551 + airq_iv_set_ptr(zdev->aibv, bit + i, 0); 552 + airq_iv_set_data(zdev->aibv, bit + i, 0); 553 + } 554 + } 555 + 556 + static void zpci_msi_domain_free(struct irq_domain *domain, unsigned int virq, 557 + unsigned int nr_irqs) 558 + { 559 + struct irq_data *d; 560 + int i; 561 + 562 + for (i = 0; i < nr_irqs; i++) { 563 + d = irq_domain_get_irq_data(domain, virq + i); 564 + zpci_msi_clear_airq(d, i); 565 + irq_domain_reset_irq_data(d); 566 + } 567 + } 568 + 569 + static const struct irq_domain_ops zpci_msi_domain_ops = { 570 + .alloc = zpci_msi_domain_alloc, 571 + .free = zpci_msi_domain_free, 572 + }; 573 + 574 + static bool zpci_init_dev_msi_info(struct device *dev, struct irq_domain *domain, 575 + struct irq_domain *real_parent, 576 + struct msi_domain_info *info) 577 + { 578 + if (!msi_lib_init_dev_msi_info(dev, domain, real_parent, info)) 579 + return false; 580 + 581 + info->ops->msi_prepare = zpci_msi_prepare; 582 + info->ops->msi_teardown = zpci_msi_teardown; 583 + 584 + return true; 585 + } 586 + 587 + static struct msi_parent_ops zpci_msi_parent_ops = { 588 + .supported_flags = MSI_GENERIC_FLAGS_MASK | 589 + MSI_FLAG_PCI_MSIX | 590 + MSI_FLAG_MULTI_PCI_MSI, 591 + .required_flags = MSI_FLAG_USE_DEF_DOM_OPS | 592 + MSI_FLAG_USE_DEF_CHIP_OPS, 593 + .init_dev_msi_info = zpci_init_dev_msi_info, 594 + }; 595 + 596 + int zpci_create_parent_msi_domain(struct zpci_bus *zbus) 597 + { 598 + char fwnode_name[18]; 599 + 600 + snprintf(fwnode_name, sizeof(fwnode_name), "ZPCI_MSI_DOM_%04x", zbus->domain_nr); 601 + struct irq_domain_info info = { 602 + .fwnode = irq_domain_alloc_named_fwnode(fwnode_name), 603 + .ops = &zpci_msi_domain_ops, 604 + }; 605 + 606 + if (!info.fwnode) { 607 + pr_err("Failed to allocate fwnode for MSI IRQ domain\n"); 608 + return -ENOMEM; 609 + } 610 + 611 + if (irq_delivery == FLOATING) 612 + zpci_msi_parent_ops.required_flags |= MSI_FLAG_NO_AFFINITY; 613 + 614 + zbus->msi_parent_domain = msi_create_parent_irq_domain(&info, &zpci_msi_parent_ops); 615 + if (!zbus->msi_parent_domain) { 616 + irq_domain_free_fwnode(info.fwnode); 617 + pr_err("Failed to create MSI IRQ domain\n"); 618 + return -ENOMEM; 619 + } 620 + 621 + return 0; 622 + } 623 + 624 + void zpci_remove_parent_msi_domain(struct zpci_bus *zbus) 625 + { 626 + struct fwnode_handle *fn; 627 + 628 + fn = zbus->msi_parent_domain->fwnode; 629 + irq_domain_remove(zbus->msi_parent_domain); 630 + irq_domain_free_fwnode(fn); 631 + } 339 632 340 633 static void __init cpu_enable_directed_irq(void *unused) 341 634 { ··· 574 465 * is only done on the first vector. 575 466 */ 576 467 zpci_ibv[cpu] = airq_iv_create(cache_line_size() * BITS_PER_BYTE, 468 + AIRQ_IV_PTR | 577 469 AIRQ_IV_DATA | 578 470 AIRQ_IV_CACHELINE | 579 471 (!cpu ? AIRQ_IV_ALLOC : 0), NULL);
+16
drivers/s390/char/sclp_mem.c
··· 44 44 unsigned int id; 45 45 unsigned int memmap_on_memory; 46 46 unsigned int config; 47 + #ifdef CONFIG_KASAN 48 + unsigned int early_shadow_mapped; 49 + #endif 47 50 }; 48 51 49 52 struct sclp_mem_arg { ··· 247 244 put_device(&mem->dev); 248 245 sclp_mem_change_state(addr, block_size, 0); 249 246 __remove_memory(addr, block_size); 247 + #ifdef CONFIG_KASAN 248 + if (sclp_mem->early_shadow_mapped) { 249 + unsigned long start, end; 250 + 251 + start = (unsigned long)kasan_mem_to_shadow(__va(addr)); 252 + end = start + (block_size >> KASAN_SHADOW_SCALE_SHIFT); 253 + vmemmap_free(start, end, NULL); 254 + sclp_mem->early_shadow_mapped = 0; 255 + } 256 + #endif 250 257 WRITE_ONCE(sclp_mem->config, 0); 251 258 } 252 259 out_unlock: ··· 329 316 330 317 sclp_mem->memmap_on_memory = memmap_on_memory; 331 318 sclp_mem->config = config; 319 + #ifdef CONFIG_KASAN 320 + sclp_mem->early_shadow_mapped = config; 321 + #endif 332 322 sclp_mem->id = id; 333 323 kobject_init(&sclp_mem->kobj, &ktype); 334 324 rc = kobject_add(&sclp_mem->kobj, &kset->kobj, "memory%d", id);
+4 -4
drivers/s390/char/vmur.c
··· 154 154 struct ccw_device *cdev; 155 155 struct urdev *urd; 156 156 157 - sprintf(bus_id, "0.0.%04x", devno); 157 + scnprintf(bus_id, sizeof(bus_id), "0.0.%04x", devno); 158 158 cdev = get_ccwdev_by_busid(&ur_driver, bus_id); 159 159 if (!cdev) 160 160 return NULL; ··· 904 904 goto fail_free_cdev; 905 905 if (urd->cdev->id.cu_type == READER_PUNCH_DEVTYPE) { 906 906 if (urd->class == DEV_CLASS_UR_I) 907 - sprintf(node_id, "vmrdr-%s", dev_name(&cdev->dev)); 907 + scnprintf(node_id, sizeof(node_id), "vmrdr-%s", dev_name(&cdev->dev)); 908 908 if (urd->class == DEV_CLASS_UR_O) 909 - sprintf(node_id, "vmpun-%s", dev_name(&cdev->dev)); 909 + scnprintf(node_id, sizeof(node_id), "vmpun-%s", dev_name(&cdev->dev)); 910 910 } else if (urd->cdev->id.cu_type == PRINTER_DEVTYPE) { 911 - sprintf(node_id, "vmprt-%s", dev_name(&cdev->dev)); 911 + scnprintf(node_id, sizeof(node_id), "vmprt-%s", dev_name(&cdev->dev)); 912 912 } else { 913 913 rc = -EOPNOTSUPP; 914 914 goto fail_free_cdev;
+3 -3
include/linux/irqdesc.h
··· 182 182 * and handle the result interrupt number. Return -EINVAL if 183 183 * conversion failed. 184 184 */ 185 - int generic_handle_domain_irq(struct irq_domain *domain, unsigned int hwirq); 186 - int generic_handle_domain_irq_safe(struct irq_domain *domain, unsigned int hwirq); 187 - int generic_handle_domain_nmi(struct irq_domain *domain, unsigned int hwirq); 185 + int generic_handle_domain_irq(struct irq_domain *domain, irq_hw_number_t hwirq); 186 + int generic_handle_domain_irq_safe(struct irq_domain *domain, irq_hw_number_t hwirq); 187 + int generic_handle_domain_nmi(struct irq_domain *domain, irq_hw_number_t hwirq); 188 188 #endif 189 189 190 190 /* Test to see if a driver has successfully requested an irq */
+3 -3
kernel/irq/irqdesc.c
··· 720 720 * This function must be called from an IRQ context with irq regs 721 721 * initialized. 722 722 */ 723 - int generic_handle_domain_irq(struct irq_domain *domain, unsigned int hwirq) 723 + int generic_handle_domain_irq(struct irq_domain *domain, irq_hw_number_t hwirq) 724 724 { 725 725 return handle_irq_desc(irq_resolve_mapping(domain, hwirq)); 726 726 } ··· 738 738 * context). If the interrupt is marked as 'enforce IRQ-context only' then 739 739 * the function must be invoked from hard interrupt context. 740 740 */ 741 - int generic_handle_domain_irq_safe(struct irq_domain *domain, unsigned int hwirq) 741 + int generic_handle_domain_irq_safe(struct irq_domain *domain, irq_hw_number_t hwirq) 742 742 { 743 743 unsigned long flags; 744 744 int ret; ··· 761 761 * This function must be called from an NMI context with irq regs 762 762 * initialized. 763 763 **/ 764 - int generic_handle_domain_nmi(struct irq_domain *domain, unsigned int hwirq) 764 + int generic_handle_domain_nmi(struct irq_domain *domain, irq_hw_number_t hwirq) 765 765 { 766 766 WARN_ON_ONCE(!in_nmi()); 767 767 return handle_irq_desc(irq_resolve_mapping(domain, hwirq));