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 's390-6.8-2' of git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux

Pull more s390 updates from Alexander Gordeev:

- do not enable by default the support of 31-bit Enterprise Systems
Architecture (ESA) ELF binaries

- drop automatic CONFIG_KEXEC selection, while set CONFIG_KEXEC=y
explicitly for defconfig and debug_defconfig only

- fix zpci_get_max_io_size() to allow PCI block stores where normal PCI
stores were used otherwise

- remove unneeded tsk variable in do_exception() fault handler

- __load_fpu_regs() is only called from the core kernel code.
Therefore, remove not needed EXPORT_SYMBOL.

- remove leftover comment from s390_fpregs_set() callback

- few cleanups to Processor Activity Instrumentation (PAI) code (which
perf framework is based on)

- replace Wenjia Zhang with Thorsten Winkler as s390 Inter-User
Communication Vehicle (IUCV) networking maintainer

- Fix all scenarios where queues previously removed from a guest's
Adjunct-Processor (AP) configuration do not re-appear in a reset
state when they are subsequently made available to a guest again

* tag 's390-6.8-2' of git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux:
s390/vfio-ap: do not reset queue removed from host config
s390/vfio-ap: reset queues associated with adapter for queue unbound from driver
s390/vfio-ap: reset queues filtered from the guest's AP config
s390/vfio-ap: let on_scan_complete() callback filter matrix and update guest's APCB
s390/vfio-ap: loop over the shadow APCB when filtering guest's AP configuration
s390/vfio-ap: always filter entire AP matrix
s390/net: add Thorsten Winkler as maintainer
s390/pai_ext: split function paiext_push_sample
s390/pai_ext: rework function paiext_copy argments
s390/pai: rework paiXXX_start and paiXXX_stop functions
s390/pai_crypto: split function paicrypt_push_sample
s390/pai: rework paixxxx_getctr interface
s390/ptrace: remove leftover comment
s390/fpu: remove __load_fpu_regs() export
s390/mm,fault: remove not needed tsk variable
s390/pci: fix max size calculation in zpci_memcpy_toio()
s390/kexec: do not automatically select KEXEC option
s390/compat: change default for CONFIG_COMPAT to "n"

+298 -194
+2 -2
MAINTAINERS
··· 19124 19124 19125 19125 S390 IUCV NETWORK LAYER 19126 19126 M: Alexandra Winter <wintera@linux.ibm.com> 19127 - M: Wenjia Zhang <wenjia@linux.ibm.com> 19127 + M: Thorsten Winkler <twinkler@linux.ibm.com> 19128 19128 L: linux-s390@vger.kernel.org 19129 19129 L: netdev@vger.kernel.org 19130 19130 S: Supported ··· 19143 19143 19144 19144 S390 NETWORK DRIVERS 19145 19145 M: Alexandra Winter <wintera@linux.ibm.com> 19146 - M: Wenjia Zhang <wenjia@linux.ibm.com> 19146 + M: Thorsten Winkler <twinkler@linux.ibm.com> 19147 19147 L: linux-s390@vger.kernel.org 19148 19148 L: netdev@vger.kernel.org 19149 19149 S: Supported
+4 -3
arch/s390/Kconfig
··· 216 216 select HAVE_VIRT_CPU_ACCOUNTING_IDLE 217 217 select IOMMU_HELPER if PCI 218 218 select IOMMU_SUPPORT if PCI 219 - select KEXEC 220 219 select MMU_GATHER_MERGE_VMAS 221 220 select MMU_GATHER_NO_GATHER 222 221 select MMU_GATHER_RCU_TABLE_FREE ··· 442 443 line. 443 444 444 445 config COMPAT 445 - def_bool y 446 + def_bool n 446 447 prompt "Kernel support for 31 bit emulation" 447 448 select ARCH_WANT_OLD_COMPAT_IPC 448 449 select COMPAT_OLD_SIGACTION ··· 453 454 Select this option if you want to enable your system kernel to 454 455 handle system-calls from ELF binaries for 31 bit ESA. This option 455 456 (and some other stuff like libraries and such) is needed for 456 - executing 31 bit applications. It is safe to say "Y". 457 + executing 31 bit applications. 458 + 459 + If unsure say N. 457 460 458 461 config SMP 459 462 def_bool y
+1
arch/s390/configs/debug_defconfig
··· 40 40 CONFIG_EXPERT=y 41 41 # CONFIG_SYSFS_SYSCALL is not set 42 42 CONFIG_PROFILING=y 43 + CONFIG_KEXEC=y 43 44 CONFIG_KEXEC_FILE=y 44 45 CONFIG_KEXEC_SIG=y 45 46 CONFIG_CRASH_DUMP=y
+1
arch/s390/configs/defconfig
··· 38 38 CONFIG_EXPERT=y 39 39 # CONFIG_SYSFS_SYSCALL is not set 40 40 CONFIG_PROFILING=y 41 + CONFIG_KEXEC=y 41 42 CONFIG_KEXEC_FILE=y 42 43 CONFIG_KEXEC_SIG=y 43 44 CONFIG_CRASH_DUMP=y
-1
arch/s390/configs/zfcpdump_defconfig
··· 10 10 CONFIG_CC_OPTIMIZE_FOR_SIZE=y 11 11 CONFIG_CRASH_DUMP=y 12 12 CONFIG_MARCH_Z13=y 13 - # CONFIG_COMPAT is not set 14 13 CONFIG_NR_CPUS=2 15 14 CONFIG_HZ_100=y 16 15 # CONFIG_CHSC_SCH is not set
+18 -14
arch/s390/include/asm/pci_io.h
··· 11 11 /* I/O size constraints */ 12 12 #define ZPCI_MAX_READ_SIZE 8 13 13 #define ZPCI_MAX_WRITE_SIZE 128 14 + #define ZPCI_BOUNDARY_SIZE (1 << 12) 15 + #define ZPCI_BOUNDARY_MASK (ZPCI_BOUNDARY_SIZE - 1) 14 16 15 17 /* I/O Map */ 16 18 #define ZPCI_IOMAP_SHIFT 48 ··· 127 125 int zpci_write_block(volatile void __iomem *dst, const void *src, 128 126 unsigned long len); 129 127 130 - static inline u8 zpci_get_max_write_size(u64 src, u64 dst, int len, int max) 128 + static inline int zpci_get_max_io_size(u64 src, u64 dst, int len, int max) 131 129 { 132 - int count = len > max ? max : len, size = 1; 130 + int offset = dst & ZPCI_BOUNDARY_MASK; 131 + int size; 133 132 134 - while (!(src & 0x1) && !(dst & 0x1) && ((size << 1) <= count)) { 135 - dst = dst >> 1; 136 - src = src >> 1; 137 - size = size << 1; 138 - } 139 - return size; 133 + size = min3(len, ZPCI_BOUNDARY_SIZE - offset, max); 134 + if (IS_ALIGNED(src, 8) && IS_ALIGNED(dst, 8) && IS_ALIGNED(size, 8)) 135 + return size; 136 + 137 + if (size >= 8) 138 + return 8; 139 + return rounddown_pow_of_two(size); 140 140 } 141 141 142 142 static inline int zpci_memcpy_fromio(void *dst, ··· 148 144 int size, rc = 0; 149 145 150 146 while (n > 0) { 151 - size = zpci_get_max_write_size((u64 __force) src, 152 - (u64) dst, n, 153 - ZPCI_MAX_READ_SIZE); 147 + size = zpci_get_max_io_size((u64 __force) src, 148 + (u64) dst, n, 149 + ZPCI_MAX_READ_SIZE); 154 150 rc = zpci_read_single(dst, src, size); 155 151 if (rc) 156 152 break; ··· 170 166 return -EINVAL; 171 167 172 168 while (n > 0) { 173 - size = zpci_get_max_write_size((u64 __force) dst, 174 - (u64) src, n, 175 - ZPCI_MAX_WRITE_SIZE); 169 + size = zpci_get_max_io_size((u64 __force) dst, 170 + (u64) src, n, 171 + ZPCI_MAX_WRITE_SIZE); 176 172 if (size > 8) /* main path */ 177 173 rc = zpci_write_block(dst, src, size); 178 174 else
-1
arch/s390/kernel/fpu.c
··· 208 208 } 209 209 clear_cpu_flag(CIF_FPU); 210 210 } 211 - EXPORT_SYMBOL(__load_fpu_regs); 212 211 213 212 void load_fpu_regs(void) 214 213 {
+43 -37
arch/s390/kernel/perf_pai_crypto.c
··· 111 111 mutex_unlock(&pai_reserve_mutex); 112 112 } 113 113 114 - static u64 paicrypt_getctr(struct paicrypt_map *cpump, int nr, bool kernel) 114 + static u64 paicrypt_getctr(unsigned long *page, int nr, bool kernel) 115 115 { 116 116 if (kernel) 117 117 nr += PAI_CRYPTO_MAXCTR; 118 - return cpump->page[nr]; 118 + return page[nr]; 119 119 } 120 120 121 121 /* Read the counter values. Return value from location in CMP. For event ··· 129 129 int i; 130 130 131 131 if (event->attr.config != PAI_CRYPTO_BASE) { 132 - return paicrypt_getctr(cpump, 132 + return paicrypt_getctr(cpump->page, 133 133 event->attr.config - PAI_CRYPTO_BASE, 134 134 kernel); 135 135 } 136 136 137 137 for (i = 1; i <= paicrypt_cnt; i++) { 138 - u64 val = paicrypt_getctr(cpump, i, kernel); 138 + u64 val = paicrypt_getctr(cpump->page, i, kernel); 139 139 140 140 if (!val) 141 141 continue; ··· 317 317 * Events are added, deleted and re-added when 2 or more events 318 318 * are active at the same time. 319 319 */ 320 - if (!event->hw.last_tag) { 321 - event->hw.last_tag = 1; 322 - sum = paicrypt_getall(event); /* Get current value */ 323 - local64_set(&event->hw.prev_count, sum); 320 + if (!event->attr.sample_period) { /* Counting */ 321 + if (!event->hw.last_tag) { 322 + event->hw.last_tag = 1; 323 + sum = paicrypt_getall(event); /* Get current value */ 324 + local64_set(&event->hw.prev_count, sum); 325 + } 326 + } else { /* Sampling */ 327 + perf_sched_cb_inc(event->pmu); 324 328 } 325 329 } 326 330 ··· 340 336 local_ctl_set_bit(0, CR0_CRYPTOGRAPHY_COUNTER_BIT); 341 337 } 342 338 cpump->event = event; 343 - if (flags & PERF_EF_START && !event->attr.sample_period) { 344 - /* Only counting needs initial counter value */ 339 + if (flags & PERF_EF_START) 345 340 paicrypt_start(event, PERF_EF_RELOAD); 346 - } 347 341 event->hw.state = 0; 348 - if (event->attr.sample_period) 349 - perf_sched_cb_inc(event->pmu); 350 342 return 0; 351 343 } 352 344 353 345 static void paicrypt_stop(struct perf_event *event, int flags) 354 346 { 355 - paicrypt_read(event); 347 + if (!event->attr.sample_period) /* Counting */ 348 + paicrypt_read(event); 349 + else /* Sampling */ 350 + perf_sched_cb_dec(event->pmu); 356 351 event->hw.state = PERF_HES_STOPPED; 357 352 } 358 353 ··· 360 357 struct paicrypt_mapptr *mp = this_cpu_ptr(paicrypt_root.mapptr); 361 358 struct paicrypt_map *cpump = mp->mapptr; 362 359 363 - if (event->attr.sample_period) 364 - perf_sched_cb_dec(event->pmu); 365 - if (!event->attr.sample_period) 366 - /* Only counting needs to read counter */ 367 - paicrypt_stop(event, PERF_EF_UPDATE); 360 + paicrypt_stop(event, PERF_EF_UPDATE); 368 361 if (--cpump->active_events == 0) { 369 362 local_ctl_clear_bit(0, CR0_CRYPTOGRAPHY_COUNTER_BIT); 370 363 WRITE_ONCE(S390_lowcore.ccd, 0); ··· 372 373 * 2 bytes: Number of counter 373 374 * 8 bytes: Value of counter 374 375 */ 375 - static size_t paicrypt_copy(struct pai_userdata *userdata, 376 - struct paicrypt_map *cpump, 376 + static size_t paicrypt_copy(struct pai_userdata *userdata, unsigned long *page, 377 377 bool exclude_user, bool exclude_kernel) 378 378 { 379 379 int i, outidx = 0; ··· 381 383 u64 val = 0; 382 384 383 385 if (!exclude_kernel) 384 - val += paicrypt_getctr(cpump, i, true); 386 + val += paicrypt_getctr(page, i, true); 385 387 if (!exclude_user) 386 - val += paicrypt_getctr(cpump, i, false); 388 + val += paicrypt_getctr(page, i, false); 387 389 if (val) { 388 390 userdata[outidx].num = i; 389 391 userdata[outidx].value = val; ··· 393 395 return outidx * sizeof(struct pai_userdata); 394 396 } 395 397 396 - static int paicrypt_push_sample(void) 398 + static int paicrypt_push_sample(size_t rawsize, struct paicrypt_map *cpump, 399 + struct perf_event *event) 397 400 { 398 - struct paicrypt_mapptr *mp = this_cpu_ptr(paicrypt_root.mapptr); 399 - struct paicrypt_map *cpump = mp->mapptr; 400 - struct perf_event *event = cpump->event; 401 401 struct perf_sample_data data; 402 402 struct perf_raw_record raw; 403 403 struct pt_regs regs; 404 - size_t rawsize; 405 404 int overflow; 406 - 407 - if (!cpump->event) /* No event active */ 408 - return 0; 409 - rawsize = paicrypt_copy(cpump->save, cpump, 410 - cpump->event->attr.exclude_user, 411 - cpump->event->attr.exclude_kernel); 412 - if (!rawsize) /* No incremented counters */ 413 - return 0; 414 405 415 406 /* Setup perf sample */ 416 407 memset(&regs, 0, sizeof(regs)); ··· 431 444 return overflow; 432 445 } 433 446 447 + /* Check if there is data to be saved on schedule out of a task. */ 448 + static int paicrypt_have_sample(void) 449 + { 450 + struct paicrypt_mapptr *mp = this_cpu_ptr(paicrypt_root.mapptr); 451 + struct paicrypt_map *cpump = mp->mapptr; 452 + struct perf_event *event = cpump->event; 453 + size_t rawsize; 454 + int rc = 0; 455 + 456 + if (!event) /* No event active */ 457 + return 0; 458 + rawsize = paicrypt_copy(cpump->save, cpump->page, 459 + cpump->event->attr.exclude_user, 460 + cpump->event->attr.exclude_kernel); 461 + if (rawsize) /* No incremented counters */ 462 + rc = paicrypt_push_sample(rawsize, cpump, event); 463 + return rc; 464 + } 465 + 434 466 /* Called on schedule-in and schedule-out. No access to event structure, 435 467 * but for sampling only event CRYPTO_ALL is allowed. 436 468 */ ··· 459 453 * results on schedule_out and if page was dirty, clear values. 460 454 */ 461 455 if (!sched_in) 462 - paicrypt_push_sample(); 456 + paicrypt_have_sample(); 463 457 } 464 458 465 459 /* Attribute definitions for paicrypt interface. As with other CPU
+43 -36
arch/s390/kernel/perf_pai_ext.c
··· 276 276 return 0; 277 277 } 278 278 279 - static u64 paiext_getctr(struct paiext_map *cpump, int nr) 279 + static u64 paiext_getctr(unsigned long *area, int nr) 280 280 { 281 - return cpump->area[nr]; 281 + return area[nr]; 282 282 } 283 283 284 284 /* Read the counter values. Return value from location in buffer. For event ··· 292 292 int i; 293 293 294 294 if (event->attr.config != PAI_NNPA_BASE) 295 - return paiext_getctr(cpump, event->attr.config - PAI_NNPA_BASE); 295 + return paiext_getctr(cpump->area, 296 + event->attr.config - PAI_NNPA_BASE); 296 297 297 298 for (i = 1; i <= paiext_cnt; i++) 298 - sum += paiext_getctr(cpump, i); 299 + sum += paiext_getctr(cpump->area, i); 299 300 300 301 return sum; 301 302 } ··· 321 320 { 322 321 u64 sum; 323 322 324 - if (event->hw.last_tag) 325 - return; 326 - event->hw.last_tag = 1; 327 - sum = paiext_getall(event); /* Get current value */ 328 - local64_set(&event->hw.prev_count, sum); 323 + if (!event->attr.sample_period) { /* Counting */ 324 + if (!event->hw.last_tag) { 325 + event->hw.last_tag = 1; 326 + sum = paiext_getall(event); /* Get current value */ 327 + local64_set(&event->hw.prev_count, sum); 328 + } 329 + } else { /* Sampling */ 330 + perf_sched_cb_inc(event->pmu); 331 + } 329 332 } 330 333 331 334 static int paiext_add(struct perf_event *event, int flags) ··· 346 341 debug_sprintf_event(paiext_dbg, 4, "%s 1508 %llx acc %llx\n", 347 342 __func__, S390_lowcore.aicd, pcb->acc); 348 343 } 349 - if (flags & PERF_EF_START && !event->attr.sample_period) { 350 - /* Only counting needs initial counter value */ 344 + cpump->event = event; 345 + if (flags & PERF_EF_START) 351 346 paiext_start(event, PERF_EF_RELOAD); 352 - } 353 347 event->hw.state = 0; 354 - if (event->attr.sample_period) { 355 - cpump->event = event; 356 - perf_sched_cb_inc(event->pmu); 357 - } 358 348 return 0; 359 349 } 360 350 361 351 static void paiext_stop(struct perf_event *event, int flags) 362 352 { 363 - paiext_read(event); 353 + if (!event->attr.sample_period) /* Counting */ 354 + paiext_read(event); 355 + else /* Sampling */ 356 + perf_sched_cb_dec(event->pmu); 364 357 event->hw.state = PERF_HES_STOPPED; 365 358 } 366 359 ··· 368 365 struct paiext_map *cpump = mp->mapptr; 369 366 struct paiext_cb *pcb = cpump->paiext_cb; 370 367 371 - if (event->attr.sample_period) 372 - perf_sched_cb_dec(event->pmu); 373 - if (!event->attr.sample_period) { 374 - /* Only counting needs to read counter */ 375 - paiext_stop(event, PERF_EF_UPDATE); 376 - } 368 + paiext_stop(event, PERF_EF_UPDATE); 377 369 if (--cpump->active_events == 0) { 378 370 /* Disable CPU instruction lookup for PAIE1 control block */ 379 371 local_ctl_clear_bit(0, CR0_PAI_EXTENSION_BIT); ··· 384 386 * 2 bytes: Number of counter 385 387 * 8 bytes: Value of counter 386 388 */ 387 - static size_t paiext_copy(struct paiext_map *cpump) 389 + static size_t paiext_copy(struct pai_userdata *userdata, unsigned long *area) 388 390 { 389 - struct pai_userdata *userdata = cpump->save; 390 391 int i, outidx = 0; 391 392 392 393 for (i = 1; i <= paiext_cnt; i++) { 393 - u64 val = paiext_getctr(cpump, i); 394 + u64 val = paiext_getctr(area, i); 394 395 395 396 if (val) { 396 397 userdata[outidx].num = i; ··· 415 418 * sched_task() callback. That callback is not active after paiext_del() 416 419 * returns and has deleted the event on that CPU. 417 420 */ 418 - static int paiext_push_sample(void) 421 + static int paiext_push_sample(size_t rawsize, struct paiext_map *cpump, 422 + struct perf_event *event) 419 423 { 420 - struct paiext_mapptr *mp = this_cpu_ptr(paiext_root.mapptr); 421 - struct paiext_map *cpump = mp->mapptr; 422 - struct perf_event *event = cpump->event; 423 424 struct perf_sample_data data; 424 425 struct perf_raw_record raw; 425 426 struct pt_regs regs; 426 - size_t rawsize; 427 427 int overflow; 428 - 429 - rawsize = paiext_copy(cpump); 430 - if (!rawsize) /* No incremented counters */ 431 - return 0; 432 428 433 429 /* Setup perf sample */ 434 430 memset(&regs, 0, sizeof(regs)); ··· 451 461 return overflow; 452 462 } 453 463 464 + /* Check if there is data to be saved on schedule out of a task. */ 465 + static int paiext_have_sample(void) 466 + { 467 + struct paiext_mapptr *mp = this_cpu_ptr(paiext_root.mapptr); 468 + struct paiext_map *cpump = mp->mapptr; 469 + struct perf_event *event = cpump->event; 470 + size_t rawsize; 471 + int rc = 0; 472 + 473 + if (!event) 474 + return 0; 475 + rawsize = paiext_copy(cpump->save, cpump->area); 476 + if (rawsize) /* Incremented counters */ 477 + rc = paiext_push_sample(rawsize, cpump, event); 478 + return rc; 479 + } 480 + 454 481 /* Called on schedule-in and schedule-out. No access to event structure, 455 482 * but for sampling only event NNPA_ALL is allowed. 456 483 */ ··· 477 470 * results on schedule_out and if page was dirty, clear values. 478 471 */ 479 472 if (!sched_in) 480 - paiext_push_sample(); 473 + paiext_have_sample(); 481 474 } 482 475 483 476 /* Attribute definitions for pai extension1 interface. As with other CPU
-1
arch/s390/kernel/ptrace.c
··· 917 917 else 918 918 memcpy(&fprs, target->thread.fpu.fprs, sizeof(fprs)); 919 919 920 - /* If setting FPC, must validate it first. */ 921 920 if (count > 0 && pos < offsetof(s390_fp_regs, fprs)) { 922 921 u32 ufpc[2] = { target->thread.fpu.fpc, 0 }; 923 922 rc = user_regset_copyin(&pos, &count, &kbuf, &ubuf, &ufpc,
+1 -3
arch/s390/mm/fault.c
··· 280 280 static void do_exception(struct pt_regs *regs, int access) 281 281 { 282 282 struct vm_area_struct *vma; 283 - struct task_struct *tsk; 284 283 unsigned long address; 285 284 struct mm_struct *mm; 286 285 enum fault_type type; ··· 288 289 vm_fault_t fault; 289 290 bool is_write; 290 291 291 - tsk = current; 292 292 /* 293 293 * The instruction that caused the program check has 294 294 * been nullified. Don't signal single step via SIGTRAP. ··· 295 297 clear_thread_flag(TIF_PER_TRAP); 296 298 if (kprobe_page_fault(regs, 14)) 297 299 return; 298 - mm = tsk->mm; 300 + mm = current->mm; 299 301 address = get_fault_address(regs); 300 302 is_write = fault_is_write(regs); 301 303 type = get_fault_type(regs);
+6 -6
arch/s390/pci/pci_mmio.c
··· 97 97 return -EINVAL; 98 98 99 99 while (n > 0) { 100 - size = zpci_get_max_write_size((u64 __force) dst, 101 - (u64 __force) src, n, 102 - ZPCI_MAX_WRITE_SIZE); 100 + size = zpci_get_max_io_size((u64 __force) dst, 101 + (u64 __force) src, n, 102 + ZPCI_MAX_WRITE_SIZE); 103 103 if (size > 8) /* main path */ 104 104 rc = __pcistb_mio_inuser(dst, src, size, &status); 105 105 else ··· 242 242 u8 status; 243 243 244 244 while (n > 0) { 245 - size = zpci_get_max_write_size((u64 __force) src, 246 - (u64 __force) dst, n, 247 - ZPCI_MAX_READ_SIZE); 245 + size = zpci_get_max_io_size((u64 __force) src, 246 + (u64 __force) dst, n, 247 + ZPCI_MAX_READ_SIZE); 248 248 rc = __pcilg_mio_inuser(dst, src, size, &status); 249 249 if (rc) 250 250 break;
+176 -90
drivers/s390/crypto/vfio_ap_ops.c
··· 32 32 33 33 #define AP_RESET_INTERVAL 20 /* Reset sleep interval (20ms) */ 34 34 35 - static int vfio_ap_mdev_reset_queues(struct ap_queue_table *qtable); 35 + static int vfio_ap_mdev_reset_queues(struct ap_matrix_mdev *matrix_mdev); 36 + static int vfio_ap_mdev_reset_qlist(struct list_head *qlist); 36 37 static struct vfio_ap_queue *vfio_ap_find_queue(int apqn); 37 38 static const struct vfio_device_ops vfio_ap_matrix_dev_ops; 38 39 static void vfio_ap_mdev_reset_queue(struct vfio_ap_queue *q); ··· 666 665 * device driver. 667 666 * 668 667 * @matrix_mdev: the matrix mdev whose matrix is to be filtered. 668 + * @apm_filtered: a 256-bit bitmap for storing the APIDs filtered from the 669 + * guest's AP configuration that are still in the host's AP 670 + * configuration. 669 671 * 670 672 * Note: If an APQN referencing a queue device that is not bound to the vfio_ap 671 673 * driver, its APID will be filtered from the guest's APCB. The matrix 672 674 * structure precludes filtering an individual APQN, so its APID will be 673 - * filtered. 675 + * filtered. Consequently, all queues associated with the adapter that 676 + * are in the host's AP configuration must be reset. If queues are 677 + * subsequently made available again to the guest, they should re-appear 678 + * in a reset state 674 679 * 675 680 * Return: a boolean value indicating whether the KVM guest's APCB was changed 676 681 * by the filtering or not. 677 682 */ 678 - static bool vfio_ap_mdev_filter_matrix(unsigned long *apm, unsigned long *aqm, 679 - struct ap_matrix_mdev *matrix_mdev) 683 + static bool vfio_ap_mdev_filter_matrix(struct ap_matrix_mdev *matrix_mdev, 684 + unsigned long *apm_filtered) 680 685 { 681 686 unsigned long apid, apqi, apqn; 682 687 DECLARE_BITMAP(prev_shadow_apm, AP_DEVICES); ··· 692 685 bitmap_copy(prev_shadow_apm, matrix_mdev->shadow_apcb.apm, AP_DEVICES); 693 686 bitmap_copy(prev_shadow_aqm, matrix_mdev->shadow_apcb.aqm, AP_DOMAINS); 694 687 vfio_ap_matrix_init(&matrix_dev->info, &matrix_mdev->shadow_apcb); 688 + bitmap_clear(apm_filtered, 0, AP_DEVICES); 695 689 696 690 /* 697 691 * Copy the adapters, domains and control domains to the shadow_apcb ··· 704 696 bitmap_and(matrix_mdev->shadow_apcb.aqm, matrix_mdev->matrix.aqm, 705 697 (unsigned long *)matrix_dev->info.aqm, AP_DOMAINS); 706 698 707 - for_each_set_bit_inv(apid, apm, AP_DEVICES) { 708 - for_each_set_bit_inv(apqi, aqm, AP_DOMAINS) { 699 + for_each_set_bit_inv(apid, matrix_mdev->shadow_apcb.apm, AP_DEVICES) { 700 + for_each_set_bit_inv(apqi, matrix_mdev->shadow_apcb.aqm, 701 + AP_DOMAINS) { 709 702 /* 710 703 * If the APQN is not bound to the vfio_ap device 711 704 * driver, then we can't assign it to the guest's ··· 718 709 apqn = AP_MKQID(apid, apqi); 719 710 q = vfio_ap_mdev_get_queue(matrix_mdev, apqn); 720 711 if (!q || q->reset_status.response_code) { 721 - clear_bit_inv(apid, 722 - matrix_mdev->shadow_apcb.apm); 712 + clear_bit_inv(apid, matrix_mdev->shadow_apcb.apm); 713 + 714 + /* 715 + * If the adapter was previously plugged into 716 + * the guest, let's let the caller know that 717 + * the APID was filtered. 718 + */ 719 + if (test_bit_inv(apid, prev_shadow_apm)) 720 + set_bit_inv(apid, apm_filtered); 721 + 723 722 break; 724 723 } 725 724 } ··· 829 812 830 813 mutex_lock(&matrix_dev->guests_lock); 831 814 mutex_lock(&matrix_dev->mdevs_lock); 832 - vfio_ap_mdev_reset_queues(&matrix_mdev->qtable); 815 + vfio_ap_mdev_reset_queues(matrix_mdev); 833 816 vfio_ap_mdev_unlink_fr_queues(matrix_mdev); 834 817 list_del(&matrix_mdev->node); 835 818 mutex_unlock(&matrix_dev->mdevs_lock); ··· 939 922 AP_MKQID(apid, apqi)); 940 923 } 941 924 925 + static void collect_queues_to_reset(struct ap_matrix_mdev *matrix_mdev, 926 + unsigned long apid, 927 + struct list_head *qlist) 928 + { 929 + struct vfio_ap_queue *q; 930 + unsigned long apqi; 931 + 932 + for_each_set_bit_inv(apqi, matrix_mdev->shadow_apcb.aqm, AP_DOMAINS) { 933 + q = vfio_ap_mdev_get_queue(matrix_mdev, AP_MKQID(apid, apqi)); 934 + if (q) 935 + list_add_tail(&q->reset_qnode, qlist); 936 + } 937 + } 938 + 939 + static void reset_queues_for_apid(struct ap_matrix_mdev *matrix_mdev, 940 + unsigned long apid) 941 + { 942 + struct list_head qlist; 943 + 944 + INIT_LIST_HEAD(&qlist); 945 + collect_queues_to_reset(matrix_mdev, apid, &qlist); 946 + vfio_ap_mdev_reset_qlist(&qlist); 947 + } 948 + 949 + static int reset_queues_for_apids(struct ap_matrix_mdev *matrix_mdev, 950 + unsigned long *apm_reset) 951 + { 952 + struct list_head qlist; 953 + unsigned long apid; 954 + 955 + if (bitmap_empty(apm_reset, AP_DEVICES)) 956 + return 0; 957 + 958 + INIT_LIST_HEAD(&qlist); 959 + 960 + for_each_set_bit_inv(apid, apm_reset, AP_DEVICES) 961 + collect_queues_to_reset(matrix_mdev, apid, &qlist); 962 + 963 + return vfio_ap_mdev_reset_qlist(&qlist); 964 + } 965 + 942 966 /** 943 967 * assign_adapter_store - parses the APID from @buf and sets the 944 968 * corresponding bit in the mediated matrix device's APM ··· 1020 962 { 1021 963 int ret; 1022 964 unsigned long apid; 1023 - DECLARE_BITMAP(apm_delta, AP_DEVICES); 965 + DECLARE_BITMAP(apm_filtered, AP_DEVICES); 1024 966 struct ap_matrix_mdev *matrix_mdev = dev_get_drvdata(dev); 1025 967 1026 968 mutex_lock(&ap_perms_mutex); ··· 1049 991 } 1050 992 1051 993 vfio_ap_mdev_link_adapter(matrix_mdev, apid); 1052 - memset(apm_delta, 0, sizeof(apm_delta)); 1053 - set_bit_inv(apid, apm_delta); 1054 994 1055 - if (vfio_ap_mdev_filter_matrix(apm_delta, 1056 - matrix_mdev->matrix.aqm, matrix_mdev)) 995 + if (vfio_ap_mdev_filter_matrix(matrix_mdev, apm_filtered)) { 1057 996 vfio_ap_mdev_update_guest_apcb(matrix_mdev); 997 + reset_queues_for_apids(matrix_mdev, apm_filtered); 998 + } 1058 999 1059 1000 ret = count; 1060 1001 done: ··· 1084 1027 * adapter was assigned. 1085 1028 * @matrix_mdev: the matrix mediated device to which the adapter was assigned. 1086 1029 * @apid: the APID of the unassigned adapter. 1087 - * @qtable: table for storing queues associated with unassigned adapter. 1030 + * @qlist: list for storing queues associated with unassigned adapter that 1031 + * need to be reset. 1088 1032 */ 1089 1033 static void vfio_ap_mdev_unlink_adapter(struct ap_matrix_mdev *matrix_mdev, 1090 1034 unsigned long apid, 1091 - struct ap_queue_table *qtable) 1035 + struct list_head *qlist) 1092 1036 { 1093 1037 unsigned long apqi; 1094 1038 struct vfio_ap_queue *q; ··· 1097 1039 for_each_set_bit_inv(apqi, matrix_mdev->matrix.aqm, AP_DOMAINS) { 1098 1040 q = vfio_ap_unlink_apqn_fr_mdev(matrix_mdev, apid, apqi); 1099 1041 1100 - if (q && qtable) { 1042 + if (q && qlist) { 1101 1043 if (test_bit_inv(apid, matrix_mdev->shadow_apcb.apm) && 1102 1044 test_bit_inv(apqi, matrix_mdev->shadow_apcb.aqm)) 1103 - hash_add(qtable->queues, &q->mdev_qnode, 1104 - q->apqn); 1045 + list_add_tail(&q->reset_qnode, qlist); 1105 1046 } 1106 1047 } 1107 1048 } ··· 1108 1051 static void vfio_ap_mdev_hot_unplug_adapter(struct ap_matrix_mdev *matrix_mdev, 1109 1052 unsigned long apid) 1110 1053 { 1111 - int loop_cursor; 1112 - struct vfio_ap_queue *q; 1113 - struct ap_queue_table *qtable = kzalloc(sizeof(*qtable), GFP_KERNEL); 1054 + struct vfio_ap_queue *q, *tmpq; 1055 + struct list_head qlist; 1114 1056 1115 - hash_init(qtable->queues); 1116 - vfio_ap_mdev_unlink_adapter(matrix_mdev, apid, qtable); 1057 + INIT_LIST_HEAD(&qlist); 1058 + vfio_ap_mdev_unlink_adapter(matrix_mdev, apid, &qlist); 1117 1059 1118 1060 if (test_bit_inv(apid, matrix_mdev->shadow_apcb.apm)) { 1119 1061 clear_bit_inv(apid, matrix_mdev->shadow_apcb.apm); 1120 1062 vfio_ap_mdev_update_guest_apcb(matrix_mdev); 1121 1063 } 1122 1064 1123 - vfio_ap_mdev_reset_queues(qtable); 1065 + vfio_ap_mdev_reset_qlist(&qlist); 1124 1066 1125 - hash_for_each(qtable->queues, loop_cursor, q, mdev_qnode) { 1067 + list_for_each_entry_safe(q, tmpq, &qlist, reset_qnode) { 1126 1068 vfio_ap_unlink_mdev_fr_queue(q); 1127 - hash_del(&q->mdev_qnode); 1069 + list_del(&q->reset_qnode); 1128 1070 } 1129 - 1130 - kfree(qtable); 1131 1071 } 1132 1072 1133 1073 /** ··· 1225 1171 { 1226 1172 int ret; 1227 1173 unsigned long apqi; 1228 - DECLARE_BITMAP(aqm_delta, AP_DOMAINS); 1174 + DECLARE_BITMAP(apm_filtered, AP_DEVICES); 1229 1175 struct ap_matrix_mdev *matrix_mdev = dev_get_drvdata(dev); 1230 1176 1231 1177 mutex_lock(&ap_perms_mutex); ··· 1254 1200 } 1255 1201 1256 1202 vfio_ap_mdev_link_domain(matrix_mdev, apqi); 1257 - memset(aqm_delta, 0, sizeof(aqm_delta)); 1258 - set_bit_inv(apqi, aqm_delta); 1259 1203 1260 - if (vfio_ap_mdev_filter_matrix(matrix_mdev->matrix.apm, aqm_delta, 1261 - matrix_mdev)) 1204 + if (vfio_ap_mdev_filter_matrix(matrix_mdev, apm_filtered)) { 1262 1205 vfio_ap_mdev_update_guest_apcb(matrix_mdev); 1206 + reset_queues_for_apids(matrix_mdev, apm_filtered); 1207 + } 1263 1208 1264 1209 ret = count; 1265 1210 done: ··· 1271 1218 1272 1219 static void vfio_ap_mdev_unlink_domain(struct ap_matrix_mdev *matrix_mdev, 1273 1220 unsigned long apqi, 1274 - struct ap_queue_table *qtable) 1221 + struct list_head *qlist) 1275 1222 { 1276 1223 unsigned long apid; 1277 1224 struct vfio_ap_queue *q; ··· 1279 1226 for_each_set_bit_inv(apid, matrix_mdev->matrix.apm, AP_DEVICES) { 1280 1227 q = vfio_ap_unlink_apqn_fr_mdev(matrix_mdev, apid, apqi); 1281 1228 1282 - if (q && qtable) { 1229 + if (q && qlist) { 1283 1230 if (test_bit_inv(apid, matrix_mdev->shadow_apcb.apm) && 1284 1231 test_bit_inv(apqi, matrix_mdev->shadow_apcb.aqm)) 1285 - hash_add(qtable->queues, &q->mdev_qnode, 1286 - q->apqn); 1232 + list_add_tail(&q->reset_qnode, qlist); 1287 1233 } 1288 1234 } 1289 1235 } ··· 1290 1238 static void vfio_ap_mdev_hot_unplug_domain(struct ap_matrix_mdev *matrix_mdev, 1291 1239 unsigned long apqi) 1292 1240 { 1293 - int loop_cursor; 1294 - struct vfio_ap_queue *q; 1295 - struct ap_queue_table *qtable = kzalloc(sizeof(*qtable), GFP_KERNEL); 1241 + struct vfio_ap_queue *q, *tmpq; 1242 + struct list_head qlist; 1296 1243 1297 - hash_init(qtable->queues); 1298 - vfio_ap_mdev_unlink_domain(matrix_mdev, apqi, qtable); 1244 + INIT_LIST_HEAD(&qlist); 1245 + vfio_ap_mdev_unlink_domain(matrix_mdev, apqi, &qlist); 1299 1246 1300 1247 if (test_bit_inv(apqi, matrix_mdev->shadow_apcb.aqm)) { 1301 1248 clear_bit_inv(apqi, matrix_mdev->shadow_apcb.aqm); 1302 1249 vfio_ap_mdev_update_guest_apcb(matrix_mdev); 1303 1250 } 1304 1251 1305 - vfio_ap_mdev_reset_queues(qtable); 1252 + vfio_ap_mdev_reset_qlist(&qlist); 1306 1253 1307 - hash_for_each(qtable->queues, loop_cursor, q, mdev_qnode) { 1254 + list_for_each_entry_safe(q, tmpq, &qlist, reset_qnode) { 1308 1255 vfio_ap_unlink_mdev_fr_queue(q); 1309 - hash_del(&q->mdev_qnode); 1256 + list_del(&q->reset_qnode); 1310 1257 } 1311 - 1312 - kfree(qtable); 1313 1258 } 1314 1259 1315 1260 /** ··· 1661 1612 get_update_locks_for_kvm(kvm); 1662 1613 1663 1614 kvm_arch_crypto_clear_masks(kvm); 1664 - vfio_ap_mdev_reset_queues(&matrix_mdev->qtable); 1615 + vfio_ap_mdev_reset_queues(matrix_mdev); 1665 1616 kvm_put_kvm(kvm); 1666 1617 matrix_mdev->kvm = NULL; 1667 1618 ··· 1797 1748 } 1798 1749 } 1799 1750 1800 - static int vfio_ap_mdev_reset_queues(struct ap_queue_table *qtable) 1751 + static int vfio_ap_mdev_reset_queues(struct ap_matrix_mdev *matrix_mdev) 1801 1752 { 1802 1753 int ret = 0, loop_cursor; 1803 1754 struct vfio_ap_queue *q; 1804 1755 1805 - hash_for_each(qtable->queues, loop_cursor, q, mdev_qnode) 1756 + hash_for_each(matrix_mdev->qtable.queues, loop_cursor, q, mdev_qnode) 1806 1757 vfio_ap_mdev_reset_queue(q); 1807 1758 1808 - hash_for_each(qtable->queues, loop_cursor, q, mdev_qnode) { 1759 + hash_for_each(matrix_mdev->qtable.queues, loop_cursor, q, mdev_qnode) { 1760 + flush_work(&q->reset_work); 1761 + 1762 + if (q->reset_status.response_code) 1763 + ret = -EIO; 1764 + } 1765 + 1766 + return ret; 1767 + } 1768 + 1769 + static int vfio_ap_mdev_reset_qlist(struct list_head *qlist) 1770 + { 1771 + int ret = 0; 1772 + struct vfio_ap_queue *q; 1773 + 1774 + list_for_each_entry(q, qlist, reset_qnode) 1775 + vfio_ap_mdev_reset_queue(q); 1776 + 1777 + list_for_each_entry(q, qlist, reset_qnode) { 1809 1778 flush_work(&q->reset_work); 1810 1779 1811 1780 if (q->reset_status.response_code) ··· 2009 1942 ret = vfio_ap_mdev_get_device_info(arg); 2010 1943 break; 2011 1944 case VFIO_DEVICE_RESET: 2012 - ret = vfio_ap_mdev_reset_queues(&matrix_mdev->qtable); 1945 + ret = vfio_ap_mdev_reset_queues(matrix_mdev); 2013 1946 break; 2014 1947 case VFIO_DEVICE_GET_IRQ_INFO: 2015 1948 ret = vfio_ap_get_irq_info(arg); ··· 2155 2088 { 2156 2089 int ret; 2157 2090 struct vfio_ap_queue *q; 2091 + DECLARE_BITMAP(apm_filtered, AP_DEVICES); 2158 2092 struct ap_matrix_mdev *matrix_mdev; 2159 2093 2160 2094 ret = sysfs_create_group(&apdev->device.kobj, &vfio_queue_attr_group); ··· 2177 2109 if (matrix_mdev) { 2178 2110 vfio_ap_mdev_link_queue(matrix_mdev, q); 2179 2111 2180 - if (vfio_ap_mdev_filter_matrix(matrix_mdev->matrix.apm, 2181 - matrix_mdev->matrix.aqm, 2182 - matrix_mdev)) 2112 + /* 2113 + * If we're in the process of handling the adding of adapters or 2114 + * domains to the host's AP configuration, then let the 2115 + * vfio_ap device driver's on_scan_complete callback filter the 2116 + * matrix and update the guest's AP configuration after all of 2117 + * the new queue devices are probed. 2118 + */ 2119 + if (!bitmap_empty(matrix_mdev->apm_add, AP_DEVICES) || 2120 + !bitmap_empty(matrix_mdev->aqm_add, AP_DOMAINS)) 2121 + goto done; 2122 + 2123 + if (vfio_ap_mdev_filter_matrix(matrix_mdev, apm_filtered)) { 2183 2124 vfio_ap_mdev_update_guest_apcb(matrix_mdev); 2125 + reset_queues_for_apids(matrix_mdev, apm_filtered); 2126 + } 2184 2127 } 2128 + 2129 + done: 2185 2130 dev_set_drvdata(&apdev->device, q); 2186 2131 release_update_locks_for_mdev(matrix_mdev); 2187 2132 2188 - return 0; 2133 + return ret; 2189 2134 2190 2135 err_remove_group: 2191 2136 sysfs_remove_group(&apdev->device.kobj, &vfio_queue_attr_group); ··· 2215 2134 q = dev_get_drvdata(&apdev->device); 2216 2135 get_update_locks_for_queue(q); 2217 2136 matrix_mdev = q->matrix_mdev; 2137 + apid = AP_QID_CARD(q->apqn); 2138 + apqi = AP_QID_QUEUE(q->apqn); 2218 2139 2219 2140 if (matrix_mdev) { 2220 - vfio_ap_unlink_queue_fr_mdev(q); 2221 - 2222 - apid = AP_QID_CARD(q->apqn); 2223 - apqi = AP_QID_QUEUE(q->apqn); 2224 - 2225 - /* 2226 - * If the queue is assigned to the guest's APCB, then remove 2227 - * the adapter's APID from the APCB and hot it into the guest. 2228 - */ 2141 + /* If the queue is assigned to the guest's AP configuration */ 2229 2142 if (test_bit_inv(apid, matrix_mdev->shadow_apcb.apm) && 2230 2143 test_bit_inv(apqi, matrix_mdev->shadow_apcb.aqm)) { 2144 + /* 2145 + * Since the queues are defined via a matrix of adapters 2146 + * and domains, it is not possible to hot unplug a 2147 + * single queue; so, let's unplug the adapter. 2148 + */ 2231 2149 clear_bit_inv(apid, matrix_mdev->shadow_apcb.apm); 2232 2150 vfio_ap_mdev_update_guest_apcb(matrix_mdev); 2151 + reset_queues_for_apid(matrix_mdev, apid); 2152 + goto done; 2233 2153 } 2234 2154 } 2235 2155 2236 - vfio_ap_mdev_reset_queue(q); 2237 - flush_work(&q->reset_work); 2156 + /* 2157 + * If the queue is not in the host's AP configuration, then resetting 2158 + * it will fail with response code 01, (APQN not valid); so, let's make 2159 + * sure it is in the host's config. 2160 + */ 2161 + if (test_bit_inv(apid, (unsigned long *)matrix_dev->info.apm) && 2162 + test_bit_inv(apqi, (unsigned long *)matrix_dev->info.aqm)) { 2163 + vfio_ap_mdev_reset_queue(q); 2164 + flush_work(&q->reset_work); 2165 + } 2166 + 2167 + done: 2168 + if (matrix_mdev) 2169 + vfio_ap_unlink_queue_fr_mdev(q); 2170 + 2238 2171 dev_set_drvdata(&apdev->device, NULL); 2239 2172 kfree(q); 2240 2173 release_update_locks_for_mdev(matrix_mdev); ··· 2556 2461 2557 2462 static void vfio_ap_mdev_hot_plug_cfg(struct ap_matrix_mdev *matrix_mdev) 2558 2463 { 2559 - bool do_hotplug = false; 2560 - int filter_domains = 0; 2561 - int filter_adapters = 0; 2562 - DECLARE_BITMAP(apm, AP_DEVICES); 2563 - DECLARE_BITMAP(aqm, AP_DOMAINS); 2464 + DECLARE_BITMAP(apm_filtered, AP_DEVICES); 2465 + bool filter_domains, filter_adapters, filter_cdoms, do_hotplug = false; 2564 2466 2565 2467 mutex_lock(&matrix_mdev->kvm->lock); 2566 2468 mutex_lock(&matrix_dev->mdevs_lock); 2567 2469 2568 - filter_adapters = bitmap_and(apm, matrix_mdev->matrix.apm, 2569 - matrix_mdev->apm_add, AP_DEVICES); 2570 - filter_domains = bitmap_and(aqm, matrix_mdev->matrix.aqm, 2571 - matrix_mdev->aqm_add, AP_DOMAINS); 2470 + filter_adapters = bitmap_intersects(matrix_mdev->matrix.apm, 2471 + matrix_mdev->apm_add, AP_DEVICES); 2472 + filter_domains = bitmap_intersects(matrix_mdev->matrix.aqm, 2473 + matrix_mdev->aqm_add, AP_DOMAINS); 2474 + filter_cdoms = bitmap_intersects(matrix_mdev->matrix.adm, 2475 + matrix_mdev->adm_add, AP_DOMAINS); 2572 2476 2573 - if (filter_adapters && filter_domains) 2574 - do_hotplug |= vfio_ap_mdev_filter_matrix(apm, aqm, matrix_mdev); 2575 - else if (filter_adapters) 2576 - do_hotplug |= 2577 - vfio_ap_mdev_filter_matrix(apm, 2578 - matrix_mdev->shadow_apcb.aqm, 2579 - matrix_mdev); 2580 - else 2581 - do_hotplug |= 2582 - vfio_ap_mdev_filter_matrix(matrix_mdev->shadow_apcb.apm, 2583 - aqm, matrix_mdev); 2477 + if (filter_adapters || filter_domains) 2478 + do_hotplug = vfio_ap_mdev_filter_matrix(matrix_mdev, apm_filtered); 2584 2479 2585 - if (bitmap_intersects(matrix_mdev->matrix.adm, matrix_mdev->adm_add, 2586 - AP_DOMAINS)) 2480 + if (filter_cdoms) 2587 2481 do_hotplug |= vfio_ap_mdev_filter_cdoms(matrix_mdev); 2588 2482 2589 2483 if (do_hotplug) 2590 2484 vfio_ap_mdev_update_guest_apcb(matrix_mdev); 2485 + 2486 + reset_queues_for_apids(matrix_mdev, apm_filtered); 2591 2487 2592 2488 mutex_unlock(&matrix_dev->mdevs_lock); 2593 2489 mutex_unlock(&matrix_mdev->kvm->lock);
+3
drivers/s390/crypto/vfio_ap_private.h
··· 133 133 * @apqn: the APQN of the AP queue device 134 134 * @saved_isc: the guest ISC registered with the GIB interface 135 135 * @mdev_qnode: allows the vfio_ap_queue struct to be added to a hashtable 136 + * @reset_qnode: allows the vfio_ap_queue struct to be added to a list of queues 137 + * that need to be reset 136 138 * @reset_status: the status from the last reset of the queue 137 139 * @reset_work: work to wait for queue reset to complete 138 140 */ ··· 145 143 #define VFIO_AP_ISC_INVALID 0xff 146 144 unsigned char saved_isc; 147 145 struct hlist_node mdev_qnode; 146 + struct list_head reset_qnode; 148 147 struct ap_queue_status reset_status; 149 148 struct work_struct reset_work; 150 149 };