Skip to content

Commit 6a46676

Browse files
committed
Merge tag 's390-6.5-1' of git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux
Pull s390 updates from Alexander Gordeev: - Fix the style of protected key API driver source: use x-mas tree for all local variable declarations - Rework protected key API driver to not use the struct pkey_protkey and pkey_clrkey anymore. Both structures have a fixed size buffer, but with the support of ECC protected key these buffers are not big enough. Use dynamic buffers internally and transparently for userspace - Add support for a new 'non CCA clear key token' with ECC clear keys supported: ECC P256, ECC P384, ECC P521, ECC ED25519 and ECC ED448. This makes it possible to derive a protected key from the ECC clear key input via PKEY_KBLOB2PROTK3 ioctl, while currently the only way to derive is via PCKMO instruction - The s390 PMU of PAI crypto and extension 1 NNPA counters use atomic_t for reference counting. Replace this with the proper data type refcount_t - Select ARCH_SUPPORTS_INT128, but limit this to clang for now, since gcc generates inefficient code, which may lead to stack overflows - Replace one-element array with flexible-array member in struct vfio_ccw_parent and refactor the rest of the code accordingly. Also, prefer struct_size() over sizeof() open- coded versions - Introduce OS_INFO_FLAGS_ENTRY pointing to a flags field and OS_INFO_FLAG_REIPL_CLEAR flag that informs a dumper whether the system memory should be cleared or not once dumped - Fix a hang when a user attempts to remove a VFIO-AP mediated device attached to a guest: add VFIO_DEVICE_GET_IRQ_INFO and VFIO_DEVICE_SET_IRQS IOCTLs and wire up the VFIO bus driver callback to request a release of the device - Fix calculation for R_390_GOTENT relocations for modules - Allow any user space process with CAP_PERFMON capability read and display the CPU Measurement facility counter sets - Rework large statically-defined per-CPU cpu_cf_events data structure and replace it with dynamically allocated structures created when a perf_event_open() system call is invoked or /dev/hwctr device is accessed * tag 's390-6.5-1' of git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux: s390/cpum_cf: rework PER_CPU_DEFINE of struct cpu_cf_events s390/cpum_cf: open access to hwctr device for CAP_PERFMON privileged process s390/module: fix rela calculation for R_390_GOTENT s390/vfio-ap: wire in the vfio_device_ops request callback s390/vfio-ap: realize the VFIO_DEVICE_SET_IRQS ioctl s390/vfio-ap: realize the VFIO_DEVICE_GET_IRQ_INFO ioctl s390/pkey: add support for ecc clear key s390/pkey: do not use struct pkey_protkey s390/pkey: introduce reverse x-mas trees s390/zcore: conditionally clear memory on reipl s390/ipl: add REIPL_CLEAR flag to os_info vfio/ccw: use struct_size() helper vfio/ccw: replace one-element array with flexible-array member s390: select ARCH_SUPPORTS_INT128 s390/pai_ext: replace atomic_t with refcount_t s390/pai_crypto: replace atomic_t with refcount_t
2 parents 8d8026f + 9b9cf3c commit 6a46676

File tree

21 files changed

+997
-328
lines changed

21 files changed

+997
-328
lines changed

arch/s390/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ config S390
117117
select ARCH_SUPPORTS_ATOMIC_RMW
118118
select ARCH_SUPPORTS_DEBUG_PAGEALLOC
119119
select ARCH_SUPPORTS_HUGETLBFS
120+
select ARCH_SUPPORTS_INT128 if CC_HAS_INT128 && CC_IS_CLANG
120121
select ARCH_SUPPORTS_NUMA_BALANCING
121122
select ARCH_SUPPORTS_PER_VMA_LOCK
122123
select ARCH_USE_BUILTIN_BSWAP

arch/s390/crypto/paes_s390.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* s390 implementation of the AES Cipher Algorithm with protected keys.
66
*
77
* s390 Version:
8-
* Copyright IBM Corp. 2017,2020
8+
* Copyright IBM Corp. 2017, 2023
99
* Author(s): Martin Schwidefsky <[email protected]>
1010
* Harald Freudenberger <[email protected]>
1111
*/
@@ -132,7 +132,8 @@ static inline int __paes_keyblob2pkey(struct key_blob *kb,
132132
if (i > 0 && ret == -EAGAIN && in_task())
133133
if (msleep_interruptible(1000))
134134
return -EINTR;
135-
ret = pkey_keyblob2pkey(kb->key, kb->keylen, pk);
135+
ret = pkey_keyblob2pkey(kb->key, kb->keylen,
136+
pk->protkey, &pk->len, &pk->type);
136137
if (ret == 0)
137138
break;
138139
}
@@ -145,6 +146,7 @@ static inline int __paes_convert_key(struct s390_paes_ctx *ctx)
145146
int ret;
146147
struct pkey_protkey pkey;
147148

149+
pkey.len = sizeof(pkey.protkey);
148150
ret = __paes_keyblob2pkey(&ctx->kb, &pkey);
149151
if (ret)
150152
return ret;
@@ -414,6 +416,9 @@ static inline int __xts_paes_convert_key(struct s390_pxts_ctx *ctx)
414416
{
415417
struct pkey_protkey pkey0, pkey1;
416418

419+
pkey0.len = sizeof(pkey0.protkey);
420+
pkey1.len = sizeof(pkey1.protkey);
421+
417422
if (__paes_keyblob2pkey(&ctx->kb[0], &pkey0) ||
418423
__paes_keyblob2pkey(&ctx->kb[1], &pkey1))
419424
return -EINVAL;

arch/s390/include/asm/asm-prototypes.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,8 @@
66
#include <asm/fpu/api.h>
77
#include <asm-generic/asm-prototypes.h>
88

9+
__int128_t __ashlti3(__int128_t a, int b);
10+
__int128_t __ashrti3(__int128_t a, int b);
11+
__int128_t __lshrti3(__int128_t a, int b);
12+
913
#endif /* _ASM_S390_PROTOTYPES_H */

arch/s390/include/asm/cpacf.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/*
33
* CP Assist for Cryptographic Functions (CPACF)
44
*
5-
* Copyright IBM Corp. 2003, 2017
5+
* Copyright IBM Corp. 2003, 2023
66
* Author(s): Thomas Spatzier
77
* Jan Glauber
88
* Harald Freudenberger ([email protected])
@@ -132,6 +132,11 @@
132132
#define CPACF_PCKMO_ENC_AES_128_KEY 0x12
133133
#define CPACF_PCKMO_ENC_AES_192_KEY 0x13
134134
#define CPACF_PCKMO_ENC_AES_256_KEY 0x14
135+
#define CPACF_PCKMO_ENC_ECC_P256_KEY 0x20
136+
#define CPACF_PCKMO_ENC_ECC_P384_KEY 0x21
137+
#define CPACF_PCKMO_ENC_ECC_P521_KEY 0x22
138+
#define CPACF_PCKMO_ENC_ECC_ED25519_KEY 0x28
139+
#define CPACF_PCKMO_ENC_ECC_ED448_KEY 0x29
135140

136141
/*
137142
* Function codes for the PRNO (PERFORM RANDOM NUMBER OPERATION)

arch/s390/include/asm/os_info.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616

1717
#define OS_INFO_VMCOREINFO 0
1818
#define OS_INFO_REIPL_BLOCK 1
19+
#define OS_INFO_FLAGS_ENTRY 2
20+
21+
#define OS_INFO_FLAG_REIPL_CLEAR (1UL << 0)
1922

2023
struct os_info_entry {
2124
u64 addr;
@@ -30,8 +33,8 @@ struct os_info {
3033
u16 version_minor;
3134
u64 crashkernel_addr;
3235
u64 crashkernel_size;
33-
struct os_info_entry entry[2];
34-
u8 reserved[4024];
36+
struct os_info_entry entry[3];
37+
u8 reserved[4004];
3538
} __packed;
3639

3740
void os_info_init(void);

arch/s390/include/asm/pkey.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/*
33
* Kernelspace interface to the pkey device driver
44
*
5-
* Copyright IBM Corp. 2016,2019
5+
* Copyright IBM Corp. 2016, 2023
66
*
77
* Author: Harald Freudenberger <[email protected]>
88
*
@@ -23,6 +23,6 @@
2323
* @return 0 on success, negative errno value on failure
2424
*/
2525
int pkey_keyblob2pkey(const u8 *key, u32 keylen,
26-
struct pkey_protkey *protkey);
26+
u8 *protkey, u32 *protkeylen, u32 *protkeytype);
2727

2828
#endif /* _KAPI_PKEY_H */

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

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/*
33
* Userspace interface to the pkey device driver
44
*
5-
* Copyright IBM Corp. 2017, 2019
5+
* Copyright IBM Corp. 2017, 2023
66
*
77
* Author: Harald Freudenberger <[email protected]>
88
*
@@ -32,10 +32,15 @@
3232
#define MINKEYBLOBSIZE SECKEYBLOBSIZE
3333

3434
/* defines for the type field within the pkey_protkey struct */
35-
#define PKEY_KEYTYPE_AES_128 1
36-
#define PKEY_KEYTYPE_AES_192 2
37-
#define PKEY_KEYTYPE_AES_256 3
38-
#define PKEY_KEYTYPE_ECC 4
35+
#define PKEY_KEYTYPE_AES_128 1
36+
#define PKEY_KEYTYPE_AES_192 2
37+
#define PKEY_KEYTYPE_AES_256 3
38+
#define PKEY_KEYTYPE_ECC 4
39+
#define PKEY_KEYTYPE_ECC_P256 5
40+
#define PKEY_KEYTYPE_ECC_P384 6
41+
#define PKEY_KEYTYPE_ECC_P521 7
42+
#define PKEY_KEYTYPE_ECC_ED25519 8
43+
#define PKEY_KEYTYPE_ECC_ED448 9
3944

4045
/* the newer ioctls use a pkey_key_type enum for type information */
4146
enum pkey_key_type {

arch/s390/kernel/ipl.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,8 @@ static bool reipl_fcp_clear;
176176
static bool reipl_ccw_clear;
177177
static bool reipl_eckd_clear;
178178

179+
static unsigned long os_info_flags;
180+
179181
static inline int __diag308(unsigned long subcode, unsigned long addr)
180182
{
181183
union register_pair r1;
@@ -1938,6 +1940,20 @@ static void dump_reipl_run(struct shutdown_trigger *trigger)
19381940
struct lowcore *abs_lc;
19391941
unsigned int csum;
19401942

1943+
/*
1944+
* Set REIPL_CLEAR flag in os_info flags entry indicating
1945+
* 'clear' sysfs attribute has been set on the panicked system
1946+
* for specified reipl type.
1947+
* Always set for IPL_TYPE_NSS and IPL_TYPE_UNKNOWN.
1948+
*/
1949+
if ((reipl_type == IPL_TYPE_CCW && reipl_ccw_clear) ||
1950+
(reipl_type == IPL_TYPE_ECKD && reipl_eckd_clear) ||
1951+
(reipl_type == IPL_TYPE_FCP && reipl_fcp_clear) ||
1952+
(reipl_type == IPL_TYPE_NVME && reipl_nvme_clear) ||
1953+
reipl_type == IPL_TYPE_NSS ||
1954+
reipl_type == IPL_TYPE_UNKNOWN)
1955+
os_info_flags |= OS_INFO_FLAG_REIPL_CLEAR;
1956+
os_info_entry_add(OS_INFO_FLAGS_ENTRY, &os_info_flags, sizeof(os_info_flags));
19411957
csum = (__force unsigned int)
19421958
csum_partial(reipl_block_actual, reipl_block_actual->hdr.len, 0);
19431959
abs_lc = get_abs_lowcore();

arch/s390/kernel/module.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,8 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
352352
rc = apply_rela_bits(loc, val, 0, 64, 0, write);
353353
else if (r_type == R_390_GOTENT ||
354354
r_type == R_390_GOTPLTENT) {
355-
val += (Elf_Addr) me->mem[MOD_TEXT].base - loc;
355+
val += (Elf_Addr)me->mem[MOD_TEXT].base +
356+
me->arch.got_offset - loc;
356357
rc = apply_rela_bits(loc, val, 1, 32, 1, write);
357358
}
358359
break;

0 commit comments

Comments
 (0)