Skip to content

Commit e08d227

Browse files
committed
Merge tag 's390-6.12-2' of git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux
Pull more s390 updates from Vasily Gorbik: - Clean up and improve vdso code: use SYM_* macros for function and data annotations, add CFI annotations to fix GDB unwinding, optimize the chacha20 implementation - Add vfio-ap driver feature advertisement for use by libvirt and mdevctl * tag 's390-6.12-2' of git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux: s390/vfio-ap: Driver feature advertisement s390/vdso: Use one large alternative instead of an alternative branch s390/vdso: Use SYM_DATA_START_LOCAL()/SYM_DATA_END() for data objects tools: Add additional SYM_*() stubs to linkage.h s390/vdso: Use macros for annotation of asm functions s390/vdso: Add CFI annotations to __arch_chacha20_blocks_nostack() s390/vdso: Fix comment within __arch_chacha20_blocks_nostack() s390/vdso: Get rid of permutation constants
2 parents 6f81a44 + 2d87213 commit e08d227

File tree

5 files changed

+86
-51
lines changed

5 files changed

+86
-51
lines changed

Documentation/arch/s390/vfio-ap.rst

+30
Original file line numberDiff line numberDiff line change
@@ -999,6 +999,36 @@ the vfio_ap mediated device to which it is assigned as long as each new APQN
999999
resulting from plugging it in references a queue device bound to the vfio_ap
10001000
device driver.
10011001

1002+
Driver Features
1003+
===============
1004+
The vfio_ap driver exposes a sysfs file containing supported features.
1005+
This exists so third party tools (like Libvirt and mdevctl) can query the
1006+
availability of specific features.
1007+
1008+
The features list can be found here: /sys/bus/matrix/devices/matrix/features
1009+
1010+
Entries are space delimited. Each entry consists of a combination of
1011+
alphanumeric and underscore characters.
1012+
1013+
Example:
1014+
cat /sys/bus/matrix/devices/matrix/features
1015+
guest_matrix dyn ap_config
1016+
1017+
the following features are advertised:
1018+
1019+
---------------+---------------------------------------------------------------+
1020+
| Flag | Description |
1021+
+==============+===============================================================+
1022+
| guest_matrix | guest_matrix attribute exists. It reports the matrix of |
1023+
| | adapters and domains that are or will be passed through to a |
1024+
| | guest when the mdev is attached to it. |
1025+
+--------------+---------------------------------------------------------------+
1026+
| dyn | Indicates hot plug/unplug of AP adapters, domains and control |
1027+
| | domains for a guest to which the mdev is attached. |
1028+
+------------+-----------------------------------------------------------------+
1029+
| ap_config | ap_config interface for one-shot modifications to mdev config |
1030+
+--------------+---------------------------------------------------------------+
1031+
10021032
Limitations
10031033
===========
10041034
Live guest migration is not supported for guests using AP devices without

arch/s390/kernel/vdso64/vdso_user_wrapper.S

+4-10
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,7 @@
1313
* for details.
1414
*/
1515
.macro vdso_func func
16-
.globl __kernel_\func
17-
.type __kernel_\func,@function
18-
__ALIGN
19-
__kernel_\func:
16+
SYM_FUNC_START(__kernel_\func)
2017
CFI_STARTPROC
2118
aghi %r15,-STACK_FRAME_VDSO_OVERHEAD
2219
CFI_DEF_CFA_OFFSET (STACK_FRAME_USER_OVERHEAD + STACK_FRAME_VDSO_OVERHEAD)
@@ -32,7 +29,7 @@ __kernel_\func:
3229
CFI_RESTORE 15
3330
br %r14
3431
CFI_ENDPROC
35-
.size __kernel_\func,.-__kernel_\func
32+
SYM_FUNC_END(__kernel_\func)
3633
.endm
3734

3835
vdso_func gettimeofday
@@ -41,16 +38,13 @@ vdso_func clock_gettime
4138
vdso_func getcpu
4239

4340
.macro vdso_syscall func,syscall
44-
.globl __kernel_\func
45-
.type __kernel_\func,@function
46-
__ALIGN
47-
__kernel_\func:
41+
SYM_FUNC_START(__kernel_\func)
4842
CFI_STARTPROC
4943
svc \syscall
5044
/* Make sure we notice when a syscall returns, which shouldn't happen */
5145
.word 0
5246
CFI_ENDPROC
53-
.size __kernel_\func,.-__kernel_\func
47+
SYM_FUNC_END(__kernel_\func)
5448
.endm
5549

5650
vdso_syscall restart_syscall,__NR_restart_syscall

arch/s390/kernel/vdso64/vgetrandom-chacha.S

+36-40
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
/* SPDX-License-Identifier: GPL-2.0 */
22

3+
#include <linux/stringify.h>
34
#include <linux/linkage.h>
45
#include <asm/alternative.h>
6+
#include <asm/dwarf.h>
57
#include <asm/fpu-insn.h>
68

79
#define STATE0 %v0
@@ -12,9 +14,6 @@
1214
#define COPY1 %v5
1315
#define COPY2 %v6
1416
#define COPY3 %v7
15-
#define PERM4 %v16
16-
#define PERM8 %v17
17-
#define PERM12 %v18
1817
#define BEPERM %v19
1918
#define TMP0 %v20
2019
#define TMP1 %v21
@@ -23,13 +22,11 @@
2322

2423
.section .rodata
2524

26-
.balign 128
27-
.Lconstants:
25+
.balign 32
26+
SYM_DATA_START_LOCAL(chacha20_constants)
2827
.long 0x61707865,0x3320646e,0x79622d32,0x6b206574 # endian-neutral
29-
.long 0x04050607,0x08090a0b,0x0c0d0e0f,0x00010203 # rotl 4 bytes
30-
.long 0x08090a0b,0x0c0d0e0f,0x00010203,0x04050607 # rotl 8 bytes
31-
.long 0x0c0d0e0f,0x00010203,0x04050607,0x08090a0b # rotl 12 bytes
3228
.long 0x03020100,0x07060504,0x0b0a0908,0x0f0e0d0c # byte swap
29+
SYM_DATA_END(chacha20_constants)
3330

3431
.text
3532
/*
@@ -43,13 +40,14 @@
4340
* size_t nblocks)
4441
*/
4542
SYM_FUNC_START(__arch_chacha20_blocks_nostack)
46-
larl %r1,.Lconstants
43+
CFI_STARTPROC
44+
larl %r1,chacha20_constants
4745

4846
/* COPY0 = "expand 32-byte k" */
4947
VL COPY0,0,,%r1
5048

51-
/* PERM4-PERM12,BEPERM = byte selectors for VPERM */
52-
VLM PERM4,BEPERM,16,%r1
49+
/* BEPERM = byte selectors for VPERM */
50+
ALTERNATIVE __stringify(VL BEPERM,16,,%r1), "brcl 0,0", ALT_FACILITY(148)
5351

5452
/* COPY1,COPY2 = key */
5553
VLM COPY1,COPY2,0,%r3
@@ -89,11 +87,11 @@ SYM_FUNC_START(__arch_chacha20_blocks_nostack)
8987
VERLLF STATE1,STATE1,7
9088

9189
/* STATE1[0,1,2,3] = STATE1[1,2,3,0] */
92-
VPERM STATE1,STATE1,STATE1,PERM4
90+
VSLDB STATE1,STATE1,STATE1,4
9391
/* STATE2[0,1,2,3] = STATE2[2,3,0,1] */
94-
VPERM STATE2,STATE2,STATE2,PERM8
92+
VSLDB STATE2,STATE2,STATE2,8
9593
/* STATE3[0,1,2,3] = STATE3[3,0,1,2] */
96-
VPERM STATE3,STATE3,STATE3,PERM12
94+
VSLDB STATE3,STATE3,STATE3,12
9795

9896
/* STATE0 += STATE1, STATE3 = rotl32(STATE3 ^ STATE0, 16) */
9997
VAF STATE0,STATE0,STATE1
@@ -116,32 +114,38 @@ SYM_FUNC_START(__arch_chacha20_blocks_nostack)
116114
VERLLF STATE1,STATE1,7
117115

118116
/* STATE1[0,1,2,3] = STATE1[3,0,1,2] */
119-
VPERM STATE1,STATE1,STATE1,PERM12
117+
VSLDB STATE1,STATE1,STATE1,12
120118
/* STATE2[0,1,2,3] = STATE2[2,3,0,1] */
121-
VPERM STATE2,STATE2,STATE2,PERM8
119+
VSLDB STATE2,STATE2,STATE2,8
122120
/* STATE3[0,1,2,3] = STATE3[1,2,3,0] */
123-
VPERM STATE3,STATE3,STATE3,PERM4
121+
VSLDB STATE3,STATE3,STATE3,4
124122
brctg %r0,.Ldoubleround
125123

126-
/* OUTPUT0 = STATE0 + STATE0 */
124+
/* OUTPUT0 = STATE0 + COPY0 */
127125
VAF STATE0,STATE0,COPY0
128-
/* OUTPUT1 = STATE1 + STATE1 */
126+
/* OUTPUT1 = STATE1 + COPY1 */
129127
VAF STATE1,STATE1,COPY1
130-
/* OUTPUT2 = STATE2 + STATE2 */
128+
/* OUTPUT2 = STATE2 + COPY2 */
131129
VAF STATE2,STATE2,COPY2
132-
/* OUTPUT2 = STATE3 + STATE3 */
130+
/* OUTPUT3 = STATE3 + COPY3 */
133131
VAF STATE3,STATE3,COPY3
134132

135-
/*
136-
* 32 bit wise little endian store to OUTPUT. If the vector
137-
* enhancement facility 2 is not installed use the slow path.
138-
*/
139-
ALTERNATIVE "brc 0xf,.Lstoreslow", "nop", ALT_FACILITY(148)
140-
VSTBRF STATE0,0,,%r2
141-
VSTBRF STATE1,16,,%r2
142-
VSTBRF STATE2,32,,%r2
143-
VSTBRF STATE3,48,,%r2
144-
.Lstoredone:
133+
ALTERNATIVE \
134+
__stringify( \
135+
/* Convert STATE to little endian and store to OUTPUT */\
136+
VPERM TMP0,STATE0,STATE0,BEPERM; \
137+
VPERM TMP1,STATE1,STATE1,BEPERM; \
138+
VPERM TMP2,STATE2,STATE2,BEPERM; \
139+
VPERM TMP3,STATE3,STATE3,BEPERM; \
140+
VSTM TMP0,TMP3,0,%r2), \
141+
__stringify( \
142+
/* 32 bit wise little endian store to OUTPUT */ \
143+
VSTBRF STATE0,0,,%r2; \
144+
VSTBRF STATE1,16,,%r2; \
145+
VSTBRF STATE2,32,,%r2; \
146+
VSTBRF STATE3,48,,%r2; \
147+
brcl 0,0), \
148+
ALT_FACILITY(148)
145149

146150
/* ++COPY3.COUNTER */
147151
/* alsih %r3,1 */
@@ -173,13 +177,5 @@ SYM_FUNC_START(__arch_chacha20_blocks_nostack)
173177
VZERO TMP3
174178

175179
br %r14
176-
177-
.Lstoreslow:
178-
/* Convert STATE to little endian format and store to OUTPUT */
179-
VPERM TMP0,STATE0,STATE0,BEPERM
180-
VPERM TMP1,STATE1,STATE1,BEPERM
181-
VPERM TMP2,STATE2,STATE2,BEPERM
182-
VPERM TMP3,STATE3,STATE3,BEPERM
183-
VSTM TMP0,TMP3,0,%r2
184-
j .Lstoredone
180+
CFI_ENDPROC
185181
SYM_FUNC_END(__arch_chacha20_blocks_nostack)

drivers/s390/crypto/vfio_ap_drv.c

+13
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,18 @@ MODULE_LICENSE("GPL v2");
2626
struct ap_matrix_dev *matrix_dev;
2727
debug_info_t *vfio_ap_dbf_info;
2828

29+
static ssize_t features_show(struct device *dev, struct device_attribute *attr, char *buf)
30+
{
31+
return sysfs_emit(buf, "guest_matrix hotplug ap_config\n");
32+
}
33+
static DEVICE_ATTR_RO(features);
34+
35+
static struct attribute *matrix_dev_attrs[] = {
36+
&dev_attr_features.attr,
37+
NULL,
38+
};
39+
ATTRIBUTE_GROUPS(matrix_dev);
40+
2941
/* Only type 10 adapters (CEX4 and later) are supported
3042
* by the AP matrix device driver
3143
*/
@@ -68,6 +80,7 @@ static struct device_driver matrix_driver = {
6880
.name = "vfio_ap",
6981
.bus = &matrix_bus,
7082
.suppress_bind_attrs = true,
83+
.dev_groups = matrix_dev_groups,
7184
};
7285

7386
static int vfio_ap_matrix_dev_create(void)

tools/include/linux/linkage.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
#include <linux/export.h>
55

66
#define SYM_FUNC_START(x) .globl x; x:
7-
87
#define SYM_FUNC_END(x)
8+
#define SYM_DATA_START(x) .globl x; x:
9+
#define SYM_DATA_START_LOCAL(x) x:
10+
#define SYM_DATA_END(x)
911

1012
#endif /* _TOOLS_INCLUDE_LINUX_LINKAGE_H */

0 commit comments

Comments
 (0)