Skip to content

Commit 16cdf08

Browse files
committed
Merge tag 's390-5.4-2' of git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux
Pull more s390 updates from Vasily Gorbik: - Fix three kasan findings - Add PERF_EVENT_IOC_PERIOD ioctl support - Add Crypto Express7S support and extend sysfs attributes for pkey - Minor common I/O layer documentation corrections * tag 's390-5.4-2' of git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux: s390/cio: exclude subchannels with no parent from pseudo check s390/cio: avoid calling strlen on null pointer s390/topology: avoid firing events before kobjs are created s390/cpumf: Remove mixed white space s390/cpum_sf: Support ioctl PERF_EVENT_IOC_PERIOD s390/zcrypt: CEX7S exploitation support s390/cio: fix intparm documentation s390/pkey: Add sysfs attributes to emit AES CIPHER key blobs
2 parents ec56103 + ab57588 commit 16cdf08

File tree

14 files changed

+334
-82
lines changed

14 files changed

+334
-82
lines changed

arch/s390/include/asm/cpu_mf.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ struct hws_qsi_info_block { /* Bit(s) */
7070
unsigned long tear; /* 24-31: TEAR contents */
7171
unsigned long dear; /* 32-39: DEAR contents */
7272
unsigned int rsvrd0; /* 40-43: reserved */
73-
unsigned int cpu_speed; /* 44-47: CPU speed */
73+
unsigned int cpu_speed; /* 44-47: CPU speed */
7474
unsigned long long rsvrd1; /* 48-55: reserved */
7575
unsigned long long rsvrd2; /* 56-63: reserved */
7676
} __packed;
@@ -89,10 +89,10 @@ struct hws_lsctl_request_block {
8989
unsigned long tear; /* 16-23: TEAR contents */
9090
unsigned long dear; /* 24-31: DEAR contents */
9191
/* 32-63: */
92-
unsigned long rsvrd1; /* reserved */
93-
unsigned long rsvrd2; /* reserved */
94-
unsigned long rsvrd3; /* reserved */
95-
unsigned long rsvrd4; /* reserved */
92+
unsigned long rsvrd1; /* reserved */
93+
unsigned long rsvrd2; /* reserved */
94+
unsigned long rsvrd3; /* reserved */
95+
unsigned long rsvrd4; /* reserved */
9696
} __packed;
9797

9898
struct hws_basic_entry {

arch/s390/include/asm/perf_event.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ struct perf_sf_sde_regs {
6060
#define PERF_CPUM_SF_MODE_MASK (PERF_CPUM_SF_BASIC_MODE| \
6161
PERF_CPUM_SF_DIAG_MODE)
6262
#define PERF_CPUM_SF_FULL_BLOCKS 0x0004 /* Process full SDBs only */
63+
#define PERF_CPUM_SF_FREQ_MODE 0x0008 /* Sampling with frequency */
6364

6465
#define REG_NONE 0
6566
#define REG_OVERFLOW 1
@@ -70,5 +71,6 @@ struct perf_sf_sde_regs {
7071
#define SAMPL_FLAGS(hwc) ((hwc)->config_base)
7172
#define SAMPL_DIAG_MODE(hwc) (SAMPL_FLAGS(hwc) & PERF_CPUM_SF_DIAG_MODE)
7273
#define SDB_FULL_BLOCKS(hwc) (SAMPL_FLAGS(hwc) & PERF_CPUM_SF_FULL_BLOCKS)
74+
#define SAMPLE_FREQ_MODE(hwc) (SAMPL_FLAGS(hwc) & PERF_CPUM_SF_FREQ_MODE)
7375

7476
#endif /* _ASM_S390_PERF_EVENT_H */

arch/s390/include/uapi/asm/zcrypt.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*
55
* zcrypt 2.2.1 (user-visible header)
66
*
7-
* Copyright IBM Corp. 2001, 2018
7+
* Copyright IBM Corp. 2001, 2019
88
* Author(s): Robert Burroughs
99
* Eric Rossman ([email protected])
1010
*
@@ -286,7 +286,7 @@ struct zcrypt_device_matrix_ext {
286286
* 0x08: CEX3A
287287
* 0x0a: CEX4
288288
* 0x0b: CEX5
289-
* 0x0c: CEX6
289+
* 0x0c: CEX6 and CEX7
290290
* 0x0d: device is disabled
291291
*
292292
* ZCRYPT_QDEPTH_MASK

arch/s390/kernel/perf_cpum_sf.c

Lines changed: 125 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -673,13 +673,89 @@ static void cpumsf_output_event_pid(struct perf_event *event,
673673
rcu_read_unlock();
674674
}
675675

676+
static unsigned long getrate(bool freq, unsigned long sample,
677+
struct hws_qsi_info_block *si)
678+
{
679+
unsigned long rate;
680+
681+
if (freq) {
682+
rate = freq_to_sample_rate(si, sample);
683+
rate = hw_limit_rate(si, rate);
684+
} else {
685+
/* The min/max sampling rates specifies the valid range
686+
* of sample periods. If the specified sample period is
687+
* out of range, limit the period to the range boundary.
688+
*/
689+
rate = hw_limit_rate(si, sample);
690+
691+
/* The perf core maintains a maximum sample rate that is
692+
* configurable through the sysctl interface. Ensure the
693+
* sampling rate does not exceed this value. This also helps
694+
* to avoid throttling when pushing samples with
695+
* perf_event_overflow().
696+
*/
697+
if (sample_rate_to_freq(si, rate) >
698+
sysctl_perf_event_sample_rate) {
699+
debug_sprintf_event(sfdbg, 1,
700+
"Sampling rate exceeds maximum "
701+
"perf sample rate\n");
702+
rate = 0;
703+
}
704+
}
705+
return rate;
706+
}
707+
708+
/* The sampling information (si) contains information about the
709+
* min/max sampling intervals and the CPU speed. So calculate the
710+
* correct sampling interval and avoid the whole period adjust
711+
* feedback loop.
712+
*
713+
* Since the CPU Measurement sampling facility can not handle frequency
714+
* calculate the sampling interval when frequency is specified using
715+
* this formula:
716+
* interval := cpu_speed * 1000000 / sample_freq
717+
*
718+
* Returns errno on bad input and zero on success with parameter interval
719+
* set to the correct sampling rate.
720+
*
721+
* Note: This function turns off freq bit to avoid calling function
722+
* perf_adjust_period(). This causes frequency adjustment in the common
723+
* code part which causes tremendous variations in the counter values.
724+
*/
725+
static int __hw_perf_event_init_rate(struct perf_event *event,
726+
struct hws_qsi_info_block *si)
727+
{
728+
struct perf_event_attr *attr = &event->attr;
729+
struct hw_perf_event *hwc = &event->hw;
730+
unsigned long rate;
731+
732+
if (attr->freq) {
733+
if (!attr->sample_freq)
734+
return -EINVAL;
735+
rate = getrate(attr->freq, attr->sample_freq, si);
736+
attr->freq = 0; /* Don't call perf_adjust_period() */
737+
SAMPL_FLAGS(hwc) |= PERF_CPUM_SF_FREQ_MODE;
738+
} else {
739+
rate = getrate(attr->freq, attr->sample_period, si);
740+
if (!rate)
741+
return -EINVAL;
742+
}
743+
attr->sample_period = rate;
744+
SAMPL_RATE(hwc) = rate;
745+
hw_init_period(hwc, SAMPL_RATE(hwc));
746+
debug_sprintf_event(sfdbg, 4, "__hw_perf_event_init_rate:"
747+
"cpu:%d period:%llx freq:%d,%#lx\n", event->cpu,
748+
event->attr.sample_period, event->attr.freq,
749+
SAMPLE_FREQ_MODE(hwc));
750+
return 0;
751+
}
752+
676753
static int __hw_perf_event_init(struct perf_event *event)
677754
{
678755
struct cpu_hw_sf *cpuhw;
679756
struct hws_qsi_info_block si;
680757
struct perf_event_attr *attr = &event->attr;
681758
struct hw_perf_event *hwc = &event->hw;
682-
unsigned long rate;
683759
int cpu, err;
684760

685761
/* Reserve CPU-measurement sampling facility */
@@ -745,43 +821,9 @@ static int __hw_perf_event_init(struct perf_event *event)
745821
if (attr->config1 & PERF_CPUM_SF_FULL_BLOCKS)
746822
SAMPL_FLAGS(hwc) |= PERF_CPUM_SF_FULL_BLOCKS;
747823

748-
/* The sampling information (si) contains information about the
749-
* min/max sampling intervals and the CPU speed. So calculate the
750-
* correct sampling interval and avoid the whole period adjust
751-
* feedback loop.
752-
*/
753-
rate = 0;
754-
if (attr->freq) {
755-
if (!attr->sample_freq) {
756-
err = -EINVAL;
757-
goto out;
758-
}
759-
rate = freq_to_sample_rate(&si, attr->sample_freq);
760-
rate = hw_limit_rate(&si, rate);
761-
attr->freq = 0;
762-
attr->sample_period = rate;
763-
} else {
764-
/* The min/max sampling rates specifies the valid range
765-
* of sample periods. If the specified sample period is
766-
* out of range, limit the period to the range boundary.
767-
*/
768-
rate = hw_limit_rate(&si, hwc->sample_period);
769-
770-
/* The perf core maintains a maximum sample rate that is
771-
* configurable through the sysctl interface. Ensure the
772-
* sampling rate does not exceed this value. This also helps
773-
* to avoid throttling when pushing samples with
774-
* perf_event_overflow().
775-
*/
776-
if (sample_rate_to_freq(&si, rate) >
777-
sysctl_perf_event_sample_rate) {
778-
err = -EINVAL;
779-
debug_sprintf_event(sfdbg, 1, "Sampling rate exceeds maximum perf sample rate\n");
780-
goto out;
781-
}
782-
}
783-
SAMPL_RATE(hwc) = rate;
784-
hw_init_period(hwc, SAMPL_RATE(hwc));
824+
err = __hw_perf_event_init_rate(event, &si);
825+
if (err)
826+
goto out;
785827

786828
/* Initialize sample data overflow accounting */
787829
hwc->extra_reg.reg = REG_OVERFLOW;
@@ -904,6 +946,8 @@ static void cpumsf_pmu_enable(struct pmu *pmu)
904946
if (sfb_has_pending_allocs(&cpuhw->sfb, hwc))
905947
extend_sampling_buffer(&cpuhw->sfb, hwc);
906948
}
949+
/* Rate may be adjusted with ioctl() */
950+
cpuhw->lsctl.interval = SAMPL_RATE(&cpuhw->event->hw);
907951
}
908952

909953
/* (Re)enable the PMU and sampling facility */
@@ -922,8 +966,9 @@ static void cpumsf_pmu_enable(struct pmu *pmu)
922966
lpp(&S390_lowcore.lpp);
923967

924968
debug_sprintf_event(sfdbg, 6, "pmu_enable: es=%i cs=%i ed=%i cd=%i "
925-
"tear=%p dear=%p\n", cpuhw->lsctl.es,
926-
cpuhw->lsctl.cs, cpuhw->lsctl.ed, cpuhw->lsctl.cd,
969+
"interval:%lx tear=%p dear=%p\n",
970+
cpuhw->lsctl.es, cpuhw->lsctl.cs, cpuhw->lsctl.ed,
971+
cpuhw->lsctl.cd, cpuhw->lsctl.interval,
927972
(void *) cpuhw->lsctl.tear,
928973
(void *) cpuhw->lsctl.dear);
929974
}
@@ -1717,6 +1762,44 @@ static void cpumsf_pmu_read(struct perf_event *event)
17171762
/* Nothing to do ... updates are interrupt-driven */
17181763
}
17191764

1765+
/* Check if the new sampling period/freqeuncy is appropriate.
1766+
*
1767+
* Return non-zero on error and zero on passed checks.
1768+
*/
1769+
static int cpumsf_pmu_check_period(struct perf_event *event, u64 value)
1770+
{
1771+
struct hws_qsi_info_block si;
1772+
unsigned long rate;
1773+
bool do_freq;
1774+
1775+
memset(&si, 0, sizeof(si));
1776+
if (event->cpu == -1) {
1777+
if (qsi(&si))
1778+
return -ENODEV;
1779+
} else {
1780+
/* Event is pinned to a particular CPU, retrieve the per-CPU
1781+
* sampling structure for accessing the CPU-specific QSI.
1782+
*/
1783+
struct cpu_hw_sf *cpuhw = &per_cpu(cpu_hw_sf, event->cpu);
1784+
1785+
si = cpuhw->qsi;
1786+
}
1787+
1788+
do_freq = !!SAMPLE_FREQ_MODE(&event->hw);
1789+
rate = getrate(do_freq, value, &si);
1790+
if (!rate)
1791+
return -EINVAL;
1792+
1793+
event->attr.sample_period = rate;
1794+
SAMPL_RATE(&event->hw) = rate;
1795+
hw_init_period(&event->hw, SAMPL_RATE(&event->hw));
1796+
debug_sprintf_event(sfdbg, 4, "cpumsf_pmu_check_period:"
1797+
"cpu:%d value:%llx period:%llx freq:%d\n",
1798+
event->cpu, value,
1799+
event->attr.sample_period, do_freq);
1800+
return 0;
1801+
}
1802+
17201803
/* Activate sampling control.
17211804
* Next call of pmu_enable() starts sampling.
17221805
*/
@@ -1908,6 +1991,8 @@ static struct pmu cpumf_sampling = {
19081991

19091992
.setup_aux = aux_buffer_setup,
19101993
.free_aux = aux_buffer_free,
1994+
1995+
.check_period = cpumsf_pmu_check_period,
19111996
};
19121997

19131998
static void cpumf_measurement_alert(struct ext_code ext_code,

arch/s390/kernel/topology.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,8 @@ int arch_update_cpu_topology(void)
311311
on_each_cpu(__arch_update_dedicated_flag, NULL, 0);
312312
for_each_online_cpu(cpu) {
313313
dev = get_cpu_device(cpu);
314-
kobject_uevent(&dev->kobj, KOBJ_CHANGE);
314+
if (dev)
315+
kobject_uevent(&dev->kobj, KOBJ_CHANGE);
315316
}
316317
return rc;
317318
}

drivers/s390/cio/ccwgroup.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ int ccwgroup_create_dev(struct device *parent, struct ccwgroup_driver *gdrv,
372372
goto error;
373373
}
374374
/* Check for trailing stuff. */
375-
if (i == num_devices && strlen(buf) > 0) {
375+
if (i == num_devices && buf && strlen(buf) > 0) {
376376
rc = -EINVAL;
377377
goto error;
378378
}

drivers/s390/cio/css.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1388,6 +1388,8 @@ device_initcall(cio_settle_init);
13881388

13891389
int sch_is_pseudo_sch(struct subchannel *sch)
13901390
{
1391+
if (!sch->dev.parent)
1392+
return 0;
13911393
return sch == to_css(sch->dev.parent)->pseudo_subchannel;
13921394
}
13931395

drivers/s390/cio/device_ops.c

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,7 @@ EXPORT_SYMBOL(ccw_device_is_multipath);
124124
/**
125125
* ccw_device_clear() - terminate I/O request processing
126126
* @cdev: target ccw device
127-
* @intparm: interruption parameter; value is only used if no I/O is
128-
* outstanding, otherwise the intparm associated with the I/O request
129-
* is returned
127+
* @intparm: interruption parameter to be returned upon conclusion of csch
130128
*
131129
* ccw_device_clear() calls csch on @cdev's subchannel.
132130
* Returns:
@@ -179,6 +177,9 @@ int ccw_device_clear(struct ccw_device *cdev, unsigned long intparm)
179177
* completed during the time specified by @expires. If a timeout occurs, the
180178
* channel program is terminated via xsch, hsch or csch, and the device's
181179
* interrupt handler will be called with an irb containing ERR_PTR(-%ETIMEDOUT).
180+
* The interruption handler will echo back the @intparm specified here, unless
181+
* another interruption parameter is specified by a subsequent invocation of
182+
* ccw_device_halt() or ccw_device_clear().
182183
* Returns:
183184
* %0, if the operation was successful;
184185
* -%EBUSY, if the device is busy, or status pending;
@@ -256,6 +257,9 @@ int ccw_device_start_timeout_key(struct ccw_device *cdev, struct ccw1 *cpa,
256257
* Start a S/390 channel program. When the interrupt arrives, the
257258
* IRQ handler is called, either immediately, delayed (dev-end missing,
258259
* or sense required) or never (no IRQ handler registered).
260+
* The interruption handler will echo back the @intparm specified here, unless
261+
* another interruption parameter is specified by a subsequent invocation of
262+
* ccw_device_halt() or ccw_device_clear().
259263
* Returns:
260264
* %0, if the operation was successful;
261265
* -%EBUSY, if the device is busy, or status pending;
@@ -287,6 +291,9 @@ int ccw_device_start_key(struct ccw_device *cdev, struct ccw1 *cpa,
287291
* Start a S/390 channel program. When the interrupt arrives, the
288292
* IRQ handler is called, either immediately, delayed (dev-end missing,
289293
* or sense required) or never (no IRQ handler registered).
294+
* The interruption handler will echo back the @intparm specified here, unless
295+
* another interruption parameter is specified by a subsequent invocation of
296+
* ccw_device_halt() or ccw_device_clear().
290297
* Returns:
291298
* %0, if the operation was successful;
292299
* -%EBUSY, if the device is busy, or status pending;
@@ -322,6 +329,9 @@ int ccw_device_start(struct ccw_device *cdev, struct ccw1 *cpa,
322329
* completed during the time specified by @expires. If a timeout occurs, the
323330
* channel program is terminated via xsch, hsch or csch, and the device's
324331
* interrupt handler will be called with an irb containing ERR_PTR(-%ETIMEDOUT).
332+
* The interruption handler will echo back the @intparm specified here, unless
333+
* another interruption parameter is specified by a subsequent invocation of
334+
* ccw_device_halt() or ccw_device_clear().
325335
* Returns:
326336
* %0, if the operation was successful;
327337
* -%EBUSY, if the device is busy, or status pending;
@@ -343,11 +353,12 @@ int ccw_device_start_timeout(struct ccw_device *cdev, struct ccw1 *cpa,
343353
/**
344354
* ccw_device_halt() - halt I/O request processing
345355
* @cdev: target ccw device
346-
* @intparm: interruption parameter; value is only used if no I/O is
347-
* outstanding, otherwise the intparm associated with the I/O request
348-
* is returned
356+
* @intparm: interruption parameter to be returned upon conclusion of hsch
349357
*
350358
* ccw_device_halt() calls hsch on @cdev's subchannel.
359+
* The interruption handler will echo back the @intparm specified here, unless
360+
* another interruption parameter is specified by a subsequent invocation of
361+
* ccw_device_clear().
351362
* Returns:
352363
* %0 on success,
353364
* -%ENODEV on device not operational,

drivers/s390/crypto/ap_bus.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1322,24 +1322,24 @@ static int ap_get_compatible_type(ap_qid_t qid, int rawtype, unsigned int func)
13221322
/* < CEX2A is not supported */
13231323
if (rawtype < AP_DEVICE_TYPE_CEX2A)
13241324
return 0;
1325-
/* up to CEX6 known and fully supported */
1326-
if (rawtype <= AP_DEVICE_TYPE_CEX6)
1325+
/* up to CEX7 known and fully supported */
1326+
if (rawtype <= AP_DEVICE_TYPE_CEX7)
13271327
return rawtype;
13281328
/*
1329-
* unknown new type > CEX6, check for compatibility
1329+
* unknown new type > CEX7, check for compatibility
13301330
* to the highest known and supported type which is
1331-
* currently CEX6 with the help of the QACT function.
1331+
* currently CEX7 with the help of the QACT function.
13321332
*/
13331333
if (ap_qact_available()) {
13341334
struct ap_queue_status status;
13351335
union ap_qact_ap_info apinfo = {0};
13361336

13371337
apinfo.mode = (func >> 26) & 0x07;
1338-
apinfo.cat = AP_DEVICE_TYPE_CEX6;
1338+
apinfo.cat = AP_DEVICE_TYPE_CEX7;
13391339
status = ap_qact(qid, 0, &apinfo);
13401340
if (status.response_code == AP_RESPONSE_NORMAL
13411341
&& apinfo.cat >= AP_DEVICE_TYPE_CEX2A
1342-
&& apinfo.cat <= AP_DEVICE_TYPE_CEX6)
1342+
&& apinfo.cat <= AP_DEVICE_TYPE_CEX7)
13431343
comp_type = apinfo.cat;
13441344
}
13451345
if (!comp_type)

0 commit comments

Comments
 (0)