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

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

Pull more s390 updates from Heiko Carstens:

- add support for system call stack randomization

- handle stale PCI deconfiguration events

- couple of defconfig updates

- some fixes and cleanups

* tag 's390-5.13-2' of git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux:
s390: fix detection of vector enhancements facility 1 vs. vector packed decimal facility
s390/entry: add support for syscall stack randomization
s390/configs: change CONFIG_VIRTIO_CONSOLE to "m"
s390/cio: remove invalid condition on IO_SCH_UNREG
s390/cpumf: remove call to perf_event_update_userpage
s390/cpumf: move counter set size calculation to common place
s390/cpumf: beautify if-then-else indentation
s390/configs: enable CONFIG_PCI_IOV
s390/pci: handle stale deconfiguration events
s390/pci: rename zpci_configure_device()

+103 -80
+1
arch/s390/Kconfig
··· 140 140 select HAVE_ARCH_JUMP_LABEL_RELATIVE 141 141 select HAVE_ARCH_KASAN 142 142 select HAVE_ARCH_KASAN_VMALLOC 143 + select HAVE_ARCH_RANDOMIZE_KSTACK_OFFSET 143 144 select HAVE_ARCH_SECCOMP_FILTER 144 145 select HAVE_ARCH_SOFT_DIRTY 145 146 select HAVE_ARCH_TRACEHOOK
+2 -1
arch/s390/configs/debug_defconfig
··· 387 387 CONFIG_BPF_JIT=y 388 388 CONFIG_NET_PKTGEN=m 389 389 CONFIG_PCI=y 390 + CONFIG_PCI_IOV=y 390 391 # CONFIG_PCIEASPM is not set 391 392 CONFIG_PCI_DEBUG=y 392 393 CONFIG_HOTPLUG_PCI=y ··· 549 548 # CONFIG_INPUT_MOUSE is not set 550 549 # CONFIG_SERIO is not set 551 550 CONFIG_LEGACY_PTY_COUNT=0 552 - CONFIG_VIRTIO_CONSOLE=y 551 + CONFIG_VIRTIO_CONSOLE=m 553 552 CONFIG_HW_RANDOM_VIRTIO=m 554 553 CONFIG_RAW_DRIVER=m 555 554 CONFIG_HANGCHECK_TIMER=m
+2 -1
arch/s390/configs/defconfig
··· 377 377 CONFIG_BPF_JIT=y 378 378 CONFIG_NET_PKTGEN=m 379 379 CONFIG_PCI=y 380 + CONFIG_PCI_IOV=y 380 381 # CONFIG_PCIEASPM is not set 381 382 CONFIG_HOTPLUG_PCI=y 382 383 CONFIG_HOTPLUG_PCI_S390=y ··· 541 540 # CONFIG_INPUT_MOUSE is not set 542 541 # CONFIG_SERIO is not set 543 542 CONFIG_LEGACY_PTY_COUNT=0 544 - CONFIG_VIRTIO_CONSOLE=y 543 + CONFIG_VIRTIO_CONSOLE=m 545 544 CONFIG_HW_RANDOM_VIRTIO=m 546 545 CONFIG_RAW_DRIVER=m 547 546 CONFIG_HANGCHECK_TIMER=m
+2
arch/s390/include/asm/cpu_mcf.h
··· 123 123 return test_facility(142); 124 124 } 125 125 126 + size_t cpum_cf_ctrset_size(enum cpumf_ctr_set ctrset, 127 + struct cpumf_ctr_info *info); 126 128 #endif /* _ASM_S390_CPU_MCF_H */
+10
arch/s390/include/asm/entry-common.h
··· 4 4 5 5 #include <linux/sched.h> 6 6 #include <linux/audit.h> 7 + #include <linux/randomize_kstack.h> 7 8 #include <linux/tracehook.h> 8 9 #include <linux/processor.h> 9 10 #include <linux/uaccess.h> 11 + #include <asm/timex.h> 10 12 #include <asm/fpu/api.h> 11 13 12 14 #define ARCH_EXIT_TO_USER_MODE_WORK (_TIF_GUARDED_STORAGE | _TIF_PER_TRAP) ··· 49 47 } 50 48 51 49 #define arch_exit_to_user_mode arch_exit_to_user_mode 50 + 51 + static inline void arch_exit_to_user_mode_prepare(struct pt_regs *regs, 52 + unsigned long ti_work) 53 + { 54 + choose_random_kstack_offset(get_tod_clock_fast() & 0xff); 55 + } 56 + 57 + #define arch_exit_to_user_mode_prepare arch_exit_to_user_mode_prepare 52 58 53 59 static inline bool on_thread_stack(void) 54 60 {
+1 -1
arch/s390/include/asm/pci.h
··· 204 204 struct zpci_dev *zpci_create_device(u32 fid, u32 fh, enum zpci_state state); 205 205 int zpci_enable_device(struct zpci_dev *); 206 206 int zpci_disable_device(struct zpci_dev *); 207 - int zpci_configure_device(struct zpci_dev *zdev, u32 fh); 207 + int zpci_scan_configured_device(struct zpci_dev *zdev, u32 fh); 208 208 int zpci_deconfigure_device(struct zpci_dev *zdev); 209 209 210 210 int zpci_register_ioat(struct zpci_dev *, u8, u64, u64, u64);
+3 -9
arch/s390/kernel/perf_cpum_cf.c
··· 230 230 /* No support for kernel space counters only */ 231 231 } else if (!attr->exclude_kernel && attr->exclude_user) { 232 232 return -EOPNOTSUPP; 233 - 234 - /* Count user and kernel space */ 235 - } else { 233 + } else { /* Count user and kernel space */ 236 234 if (ev >= ARRAY_SIZE(cpumf_generic_events_basic)) 237 235 return -EOPNOTSUPP; 238 236 ev = cpumf_generic_events_basic[ev]; ··· 400 402 */ 401 403 if (!atomic_dec_return(&cpuhw->ctr_set[hwc->config_base])) 402 404 ctr_set_stop(&cpuhw->state, hwc->config_base); 403 - event->hw.state |= PERF_HES_STOPPED; 405 + hwc->state |= PERF_HES_STOPPED; 404 406 } 405 407 406 408 if ((flags & PERF_EF_UPDATE) && !(hwc->state & PERF_HES_UPTODATE)) { 407 409 hw_perf_event_update(event); 408 - event->hw.state |= PERF_HES_UPTODATE; 410 + hwc->state |= PERF_HES_UPTODATE; 409 411 } 410 412 } 411 413 ··· 428 430 if (flags & PERF_EF_START) 429 431 cpumf_pmu_start(event, PERF_EF_RELOAD); 430 432 431 - perf_event_update_userpage(event); 432 - 433 433 return 0; 434 434 } 435 435 ··· 447 451 */ 448 452 if (!atomic_read(&cpuhw->ctr_set[event->hw.config_base])) 449 453 ctr_set_disable(&cpuhw->state, event->hw.config_base); 450 - 451 - perf_event_update_userpage(event); 452 454 } 453 455 454 456 /*
+46
arch/s390/kernel/perf_cpum_cf_common.c
··· 170 170 return cpum_cf_setup(cpu, PMC_RELEASE); 171 171 } 172 172 173 + /* Return the maximum possible counter set size (in number of 8 byte counters) 174 + * depending on type and model number. 175 + */ 176 + size_t cpum_cf_ctrset_size(enum cpumf_ctr_set ctrset, 177 + struct cpumf_ctr_info *info) 178 + { 179 + size_t ctrset_size = 0; 180 + 181 + switch (ctrset) { 182 + case CPUMF_CTR_SET_BASIC: 183 + if (info->cfvn >= 1) 184 + ctrset_size = 6; 185 + break; 186 + case CPUMF_CTR_SET_USER: 187 + if (info->cfvn == 1) 188 + ctrset_size = 6; 189 + else if (info->cfvn >= 3) 190 + ctrset_size = 2; 191 + break; 192 + case CPUMF_CTR_SET_CRYPTO: 193 + if (info->csvn >= 1 && info->csvn <= 5) 194 + ctrset_size = 16; 195 + else if (info->csvn == 6) 196 + ctrset_size = 20; 197 + break; 198 + case CPUMF_CTR_SET_EXT: 199 + if (info->csvn == 1) 200 + ctrset_size = 32; 201 + else if (info->csvn == 2) 202 + ctrset_size = 48; 203 + else if (info->csvn >= 3 && info->csvn <= 5) 204 + ctrset_size = 128; 205 + else if (info->csvn == 6) 206 + ctrset_size = 160; 207 + break; 208 + case CPUMF_CTR_SET_MT_DIAG: 209 + if (info->csvn > 3) 210 + ctrset_size = 48; 211 + break; 212 + case CPUMF_CTR_SET_MAX: 213 + break; 214 + } 215 + 216 + return ctrset_size; 217 + } 218 + 173 219 static int __init cpum_cf_init(void) 174 220 { 175 221 int rc;
+4 -50
arch/s390/kernel/perf_cpum_cf_diag.c
··· 316 316 debug_sprintf_event(cf_diag_dbg, 5, "%s event %p\n", __func__, event); 317 317 } 318 318 319 - /* Return the maximum possible counter set size (in number of 8 byte counters) 320 - * depending on type and model number. 321 - */ 322 - static size_t cf_diag_ctrset_size(enum cpumf_ctr_set ctrset, 323 - struct cpumf_ctr_info *info) 324 - { 325 - size_t ctrset_size = 0; 326 - 327 - switch (ctrset) { 328 - case CPUMF_CTR_SET_BASIC: 329 - if (info->cfvn >= 1) 330 - ctrset_size = 6; 331 - break; 332 - case CPUMF_CTR_SET_USER: 333 - if (info->cfvn == 1) 334 - ctrset_size = 6; 335 - else if (info->cfvn >= 3) 336 - ctrset_size = 2; 337 - break; 338 - case CPUMF_CTR_SET_CRYPTO: 339 - if (info->csvn >= 1 && info->csvn <= 5) 340 - ctrset_size = 16; 341 - else if (info->csvn == 6) 342 - ctrset_size = 20; 343 - break; 344 - case CPUMF_CTR_SET_EXT: 345 - if (info->csvn == 1) 346 - ctrset_size = 32; 347 - else if (info->csvn == 2) 348 - ctrset_size = 48; 349 - else if (info->csvn >= 3 && info->csvn <= 5) 350 - ctrset_size = 128; 351 - else if (info->csvn == 6) 352 - ctrset_size = 160; 353 - break; 354 - case CPUMF_CTR_SET_MT_DIAG: 355 - if (info->csvn > 3) 356 - ctrset_size = 48; 357 - break; 358 - case CPUMF_CTR_SET_MAX: 359 - break; 360 - } 361 - 362 - return ctrset_size; 363 - } 364 - 365 319 /* Calculate memory needed to store all counter sets together with header and 366 320 * trailer data. This is independend of the counter set authorization which 367 321 * can vary depending on the configuration. ··· 326 372 enum cpumf_ctr_set i; 327 373 328 374 for (i = CPUMF_CTR_SET_BASIC; i < CPUMF_CTR_SET_MAX; ++i) { 329 - size_t size = cf_diag_ctrset_size(i, info); 375 + size_t size = cpum_cf_ctrset_size(i, info); 330 376 331 377 if (size) 332 378 max_size += size * sizeof(u64) + ··· 359 405 ctrdata->def = CF_DIAG_CTRSET_DEF; 360 406 ctrdata->set = ctrset; 361 407 ctrdata->res1 = 0; 362 - ctrset_size = cf_diag_ctrset_size(ctrset, &cpuhw->info); 408 + ctrset_size = cpum_cf_ctrset_size(ctrset, &cpuhw->info); 363 409 364 410 if (ctrset_size) { /* Save data */ 365 411 need = ctrset_size * sizeof(u64) + sizeof(*ctrdata); ··· 799 845 800 846 if (!(p->sets & cpumf_ctr_ctl[set])) 801 847 continue; /* Counter set not in list */ 802 - set_size = cf_diag_ctrset_size(set, &cpuhw->info); 848 + set_size = cpum_cf_ctrset_size(set, &cpuhw->info); 803 849 space = sizeof(csd->data) - csd->used; 804 850 space = cf_diag_cpuset_read(sp, set, set_size, space); 805 851 if (space) { ··· 929 975 for (i = CPUMF_CTR_SET_BASIC; i < CPUMF_CTR_SET_MAX; ++i) { 930 976 if (!(sets & cpumf_ctr_ctl[i])) 931 977 continue; 932 - bytes += cf_diag_ctrset_size(i, &cpuhw->info) * sizeof(u64) + 978 + bytes += cpum_cf_ctrset_size(i, &cpuhw->info) * sizeof(u64) + 933 979 sizeof(((struct s390_ctrset_setdata *)0)->set) + 934 980 sizeof(((struct s390_ctrset_setdata *)0)->no_cnts); 935 981 }
+2 -2
arch/s390/kernel/setup.c
··· 937 937 if (MACHINE_HAS_VX) { 938 938 elf_hwcap |= HWCAP_S390_VXRS; 939 939 if (test_facility(134)) 940 - elf_hwcap |= HWCAP_S390_VXRS_EXT; 941 - if (test_facility(135)) 942 940 elf_hwcap |= HWCAP_S390_VXRS_BCD; 941 + if (test_facility(135)) 942 + elf_hwcap |= HWCAP_S390_VXRS_EXT; 943 943 if (test_facility(148)) 944 944 elf_hwcap |= HWCAP_S390_VXRS_EXT2; 945 945 if (test_facility(152))
+1
arch/s390/kernel/syscall.c
··· 142 142 143 143 void noinstr __do_syscall(struct pt_regs *regs, int per_trap) 144 144 { 145 + add_random_kstack_offset(); 145 146 enter_from_user_mode(regs); 146 147 147 148 memcpy(&regs->gprs[8], S390_lowcore.save_area_sync, 8 * sizeof(unsigned long));
+2
arch/s390/kernel/traps.c
··· 17 17 #include "asm/ptrace.h" 18 18 #include <linux/kprobes.h> 19 19 #include <linux/kdebug.h> 20 + #include <linux/randomize_kstack.h> 20 21 #include <linux/extable.h> 21 22 #include <linux/ptrace.h> 22 23 #include <linux/sched.h> ··· 302 301 unsigned int trapnr, syscall_redirect = 0; 303 302 irqentry_state_t state; 304 303 304 + add_random_kstack_offset(); 305 305 regs->int_code = *(u32 *)&S390_lowcore.pgm_ilc; 306 306 regs->int_parm_long = S390_lowcore.trans_exc_code; 307 307
+6 -4
arch/s390/pci/pci.c
··· 738 738 } 739 739 740 740 /** 741 - * zpci_configure_device() - Configure a zpci_dev 741 + * zpci_scan_configured_device() - Scan a freshly configured zpci_dev 742 742 * @zdev: The zpci_dev to be configured 743 743 * @fh: The general function handle supplied by the platform 744 744 * 745 745 * Given a device in the configuration state Configured, enables, scans and 746 - * adds it to the common code PCI subsystem. If any failure occurs, the 747 - * zpci_dev is left disabled. 746 + * adds it to the common code PCI subsystem if possible. If the PCI device is 747 + * parked because we can not yet create a PCI bus because we have not seen 748 + * function 0, it is ignored but will be scanned once function 0 appears. 749 + * If any failure occurs, the zpci_dev is left disabled. 748 750 * 749 751 * Return: 0 on success, or an error code otherwise 750 752 */ 751 - int zpci_configure_device(struct zpci_dev *zdev, u32 fh) 753 + int zpci_scan_configured_device(struct zpci_dev *zdev, u32 fh) 752 754 { 753 755 int rc; 754 756
+19 -9
arch/s390/pci/pci_event.c
··· 76 76 77 77 static void zpci_event_hard_deconfigured(struct zpci_dev *zdev, u32 fh) 78 78 { 79 - enum zpci_state state; 80 - 81 79 zdev->fh = fh; 82 80 /* Give the driver a hint that the function is 83 81 * already unusable. ··· 86 88 */ 87 89 zpci_disable_device(zdev); 88 90 zdev->state = ZPCI_FN_STATE_STANDBY; 89 - if (!clp_get_state(zdev->fid, &state) && 90 - state == ZPCI_FN_STATE_RESERVED) { 91 - zpci_zdev_put(zdev); 92 - } 93 91 } 94 92 95 93 static void __zpci_event_availability(struct zpci_ccdf_avail *ccdf) 96 94 { 97 95 struct zpci_dev *zdev = get_zdev_by_fid(ccdf->fid); 96 + enum zpci_state state; 98 97 99 98 zpci_err("avail CCDF:\n"); 100 99 zpci_err_hex(ccdf, sizeof(*ccdf)); ··· 108 113 break; 109 114 zdev->state = ZPCI_FN_STATE_CONFIGURED; 110 115 } 111 - zpci_configure_device(zdev, ccdf->fh); 116 + zpci_scan_configured_device(zdev, ccdf->fh); 112 117 break; 113 118 case 0x0302: /* Reserved -> Standby */ 114 119 if (!zdev) ··· 118 123 break; 119 124 case 0x0303: /* Deconfiguration requested */ 120 125 if (zdev) { 126 + /* The event may have been queued before we confirgured 127 + * the device. 128 + */ 129 + if (zdev->state != ZPCI_FN_STATE_CONFIGURED) 130 + break; 121 131 zdev->fh = ccdf->fh; 122 132 zpci_deconfigure_device(zdev); 123 133 } 124 134 break; 125 135 case 0x0304: /* Configured -> Standby|Reserved */ 126 - if (zdev) 127 - zpci_event_hard_deconfigured(zdev, ccdf->fh); 136 + if (zdev) { 137 + /* The event may have been queued before we confirgured 138 + * the device.: 139 + */ 140 + if (zdev->state == ZPCI_FN_STATE_CONFIGURED) 141 + zpci_event_hard_deconfigured(zdev, ccdf->fh); 142 + /* The 0x0304 event may immediately reserve the device */ 143 + if (!clp_get_state(zdev->fid, &state) && 144 + state == ZPCI_FN_STATE_RESERVED) { 145 + zpci_zdev_put(zdev); 146 + } 147 + } 128 148 break; 129 149 case 0x0306: /* 0x308 or 0x302 for multiple devices */ 130 150 zpci_remove_reserved_devices();
+1 -1
drivers/pci/hotplug/s390_pci_hpc.c
··· 35 35 return rc; 36 36 zdev->state = ZPCI_FN_STATE_CONFIGURED; 37 37 38 - return zpci_configure_device(zdev, zdev->fh); 38 + return zpci_scan_configured_device(zdev, zdev->fh); 39 39 } 40 40 41 41 static int disable_slot(struct hotplug_slot *hotplug_slot)
+1 -2
drivers/s390/cio/device.c
··· 1532 1532 switch (action) { 1533 1533 case IO_SCH_ORPH_UNREG: 1534 1534 case IO_SCH_UNREG: 1535 - if (!cdev) 1536 - css_sch_device_unregister(sch); 1535 + css_sch_device_unregister(sch); 1537 1536 break; 1538 1537 case IO_SCH_ORPH_ATTACH: 1539 1538 case IO_SCH_UNREG_ATTACH: