Skip to content

Commit becdce1

Browse files
committed
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux
Pull s390 updates from Martin Schwidefsky: - Improvements for the spectre defense: * The spectre related code is consolidated to a single file nospec-branch.c * Automatic enable/disable for the spectre v2 defenses (expoline vs. nobp) * Syslog messages for specve v2 are added * Enable CONFIG_GENERIC_CPU_VULNERABILITIES and define the attribute functions for spectre v1 and v2 - Add helper macros for assembler alternatives and use them to shorten the code in entry.S. - Add support for persistent configuration data via the SCLP Store Data interface. The H/W interface requires a page table that uses 4K pages only, the code to setup such an address space is added as well. - Enable virtio GPU emulation in QEMU. To do this the depends statements for a few common Kconfig options are modified. - Add support for format-3 channel path descriptors and add a binary sysfs interface to export the associated utility strings. - Add a sysfs attribute to control the IFCC handling in case of constant channel errors. - The vfio-ccw changes from Cornelia. - Bug fixes and cleanups. * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux: (40 commits) s390/kvm: improve stack frame constants in entry.S s390/lpp: use assembler alternatives for the LPP instruction s390/entry.S: use assembler alternatives s390: add assembler macros for CPU alternatives s390: add sysfs attributes for spectre s390: report spectre mitigation via syslog s390: add automatic detection of the spectre defense s390: move nobp parameter functions to nospec-branch.c s390/cio: add util_string sysfs attribute s390/chsc: query utility strings via fmt3 channel path descriptor s390/cio: rename struct channel_path_desc s390/cio: fix unbind of io_subchannel_driver s390/qdio: split up CCQ handling for EQBS / SQBS s390/qdio: don't retry EQBS after CCQ 96 s390/qdio: restrict buffer merging to eligible devices s390/qdio: don't merge ERROR output buffers s390/qdio: simplify math in get_*_buffer_frontier() s390/decompressor: trim uncompressed image head during the build s390/crypto: Fix kernel crash on aes_s390 module remove. s390/defkeymap: fix global init to zero ...
2 parents f8cf2f1 + 92fa7a1 commit becdce1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+1633
-475
lines changed

Documentation/s390/vfio-ccw.txt

Lines changed: 38 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ every detail. More information/reference could be found here:
2828
https://en.wikipedia.org/wiki/Channel_I/O
2929
- s390 architecture:
3030
s390 Principles of Operation manual (IBM Form. No. SA22-7832)
31-
- The existing Qemu code which implements a simple emulated channel
31+
- The existing QEMU code which implements a simple emulated channel
3232
subsystem could also be a good reference. It makes it easier to follow
3333
the flow.
3434
qemu/hw/s390x/css.c
@@ -39,22 +39,22 @@ For vfio mediated device framework:
3939
Motivation of vfio-ccw
4040
----------------------
4141

42-
Currently, a guest virtualized via qemu/kvm on s390 only sees
42+
Typically, a guest virtualized via QEMU/KVM on s390 only sees
4343
paravirtualized virtio devices via the "Virtio Over Channel I/O
4444
(virtio-ccw)" transport. This makes virtio devices discoverable via
4545
standard operating system algorithms for handling channel devices.
4646

4747
However this is not enough. On s390 for the majority of devices, which
4848
use the standard Channel I/O based mechanism, we also need to provide
49-
the functionality of passing through them to a Qemu virtual machine.
49+
the functionality of passing through them to a QEMU virtual machine.
5050
This includes devices that don't have a virtio counterpart (e.g. tape
5151
drives) or that have specific characteristics which guests want to
5252
exploit.
5353

5454
For passing a device to a guest, we want to use the same interface as
55-
everybody else, namely vfio. Thus, we would like to introduce vfio
56-
support for channel devices. And we would like to name this new vfio
57-
device "vfio-ccw".
55+
everybody else, namely vfio. We implement this vfio support for channel
56+
devices via the vfio mediated device framework and the subchannel device
57+
driver "vfio_ccw".
5858

5959
Access patterns of CCW devices
6060
------------------------------
@@ -99,7 +99,7 @@ As mentioned above, we realize vfio-ccw with a mdev implementation.
9999
Channel I/O does not have IOMMU hardware support, so the physical
100100
vfio-ccw device does not have an IOMMU level translation or isolation.
101101

102-
Sub-channel I/O instructions are all privileged instructions, When
102+
Subchannel I/O instructions are all privileged instructions. When
103103
handling the I/O instruction interception, vfio-ccw has the software
104104
policing and translation how the channel program is programmed before
105105
it gets sent to hardware.
@@ -121,7 +121,7 @@ devices:
121121
- The vfio_mdev driver for the mediated vfio ccw device.
122122
This is provided by the mdev framework. It is a vfio device driver for
123123
the mdev that created by vfio_ccw.
124-
It realize a group of vfio device driver callbacks, adds itself to a
124+
It realizes a group of vfio device driver callbacks, adds itself to a
125125
vfio group, and registers itself to the mdev framework as a mdev
126126
driver.
127127
It uses a vfio iommu backend that uses the existing map and unmap
@@ -178,7 +178,7 @@ vfio-ccw I/O region
178178

179179
An I/O region is used to accept channel program request from user
180180
space and store I/O interrupt result for user space to retrieve. The
181-
defination of the region is:
181+
definition of the region is:
182182

183183
struct ccw_io_region {
184184
#define ORB_AREA_SIZE 12
@@ -198,30 +198,23 @@ irb_area stores the I/O result.
198198

199199
ret_code stores a return code for each access of the region.
200200

201-
vfio-ccw patches overview
202-
-------------------------
201+
vfio-ccw operation details
202+
--------------------------
203203

204-
For now, our patches are rebased on the latest mdev implementation.
205-
vfio-ccw follows what vfio-pci did on the s390 paltform and uses
206-
vfio-iommu-type1 as the vfio iommu backend. It's a good start to launch
207-
the code review for vfio-ccw. Note that the implementation is far from
208-
complete yet; but we'd like to get feedback for the general
209-
architecture.
204+
vfio-ccw follows what vfio-pci did on the s390 platform and uses
205+
vfio-iommu-type1 as the vfio iommu backend.
210206

211207
* CCW translation APIs
212-
- Description:
213-
These introduce a group of APIs (start with 'cp_') to do CCW
214-
translation. The CCWs passed in by a user space program are
215-
organized with their guest physical memory addresses. These APIs
216-
will copy the CCWs into the kernel space, and assemble a runnable
217-
kernel channel program by updating the guest physical addresses with
218-
their corresponding host physical addresses.
219-
- Patches:
220-
vfio: ccw: introduce channel program interfaces
208+
A group of APIs (start with 'cp_') to do CCW translation. The CCWs
209+
passed in by a user space program are organized with their guest
210+
physical memory addresses. These APIs will copy the CCWs into kernel
211+
space, and assemble a runnable kernel channel program by updating the
212+
guest physical addresses with their corresponding host physical addresses.
213+
Note that we have to use IDALs even for direct-access CCWs, as the
214+
referenced memory can be located anywhere, including above 2G.
221215

222216
* vfio_ccw device driver
223-
- Description:
224-
The following patches utilizes the CCW translation APIs and introduce
217+
This driver utilizes the CCW translation APIs and introduces
225218
vfio_ccw, which is the driver for the I/O subchannel devices you want
226219
to pass through.
227220
vfio_ccw implements the following vfio ioctls:
@@ -236,20 +229,14 @@ architecture.
236229
This also provides the SET_IRQ ioctl to setup an event notifier to
237230
notify the user space program the I/O completion in an asynchronous
238231
way.
239-
- Patches:
240-
vfio: ccw: basic implementation for vfio_ccw driver
241-
vfio: ccw: introduce ccw_io_region
242-
vfio: ccw: realize VFIO_DEVICE_GET_REGION_INFO ioctl
243-
vfio: ccw: realize VFIO_DEVICE_RESET ioctl
244-
vfio: ccw: realize VFIO_DEVICE_G(S)ET_IRQ_INFO ioctls
245-
246-
The user of vfio-ccw is not limited to Qemu, while Qemu is definitely a
232+
233+
The use of vfio-ccw is not limited to QEMU, while QEMU is definitely a
247234
good example to get understand how these patches work. Here is a little
248-
bit more detail how an I/O request triggered by the Qemu guest will be
235+
bit more detail how an I/O request triggered by the QEMU guest will be
249236
handled (without error handling).
250237

251238
Explanation:
252-
Q1-Q7: Qemu side process.
239+
Q1-Q7: QEMU side process.
253240
K1-K5: Kernel side process.
254241

255242
Q1. Get I/O region info during initialization.
@@ -263,15 +250,15 @@ Q4. Write the guest channel program and ORB to the I/O region.
263250
K2. Translate the guest channel program to a host kernel space
264251
channel program, which becomes runnable for a real device.
265252
K3. With the necessary information contained in the orb passed in
266-
by Qemu, issue the ccwchain to the device.
253+
by QEMU, issue the ccwchain to the device.
267254
K4. Return the ssch CC code.
268255
Q5. Return the CC code to the guest.
269256

270257
... ...
271258

272259
K5. Interrupt handler gets the I/O result and write the result to
273260
the I/O region.
274-
K6. Signal Qemu to retrieve the result.
261+
K6. Signal QEMU to retrieve the result.
275262
Q6. Get the signal and event handler reads out the result from the I/O
276263
region.
277264
Q7. Update the irb for the guest.
@@ -289,10 +276,20 @@ More information for DASD and ECKD could be found here:
289276
https://en.wikipedia.org/wiki/Direct-access_storage_device
290277
https://en.wikipedia.org/wiki/Count_key_data
291278

292-
Together with the corresponding work in Qemu, we can bring the passed
279+
Together with the corresponding work in QEMU, we can bring the passed
293280
through DASD/ECKD device online in a guest now and use it as a block
294281
device.
295282

283+
While the current code allows the guest to start channel programs via
284+
START SUBCHANNEL, support for HALT SUBCHANNEL or CLEAR SUBCHANNEL is
285+
not yet implemented.
286+
287+
vfio-ccw supports classic (command mode) channel I/O only. Transport
288+
mode (HPF) is not supported.
289+
290+
QDIO subchannels are currently not supported. Classic devices other than
291+
DASD/ECKD might work, but have not been tested.
292+
296293
Reference
297294
---------
298295
1. ESA/s390 Principles of Operation manual (IBM Form. No. SA22-7832)

arch/s390/Kconfig

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ config S390
120120
select GENERIC_CLOCKEVENTS
121121
select GENERIC_CPU_AUTOPROBE
122122
select GENERIC_CPU_DEVICES if !SMP
123+
select GENERIC_CPU_VULNERABILITIES
123124
select GENERIC_FIND_FIRST_BIT
124125
select GENERIC_SMP_IDLE_THREAD
125126
select GENERIC_TIME_VSYSCALL
@@ -576,7 +577,7 @@ choice
576577
config EXPOLINE_OFF
577578
bool "spectre_v2=off"
578579

579-
config EXPOLINE_MEDIUM
580+
config EXPOLINE_AUTO
580581
bool "spectre_v2=auto"
581582

582583
config EXPOLINE_FULL

arch/s390/Makefile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,6 @@ cflags-$(CONFIG_MARCH_Z14_TUNE) += -mtune=z14
4747

4848
cflags-y += -Wa,-I$(srctree)/arch/$(ARCH)/include
4949

50-
#KBUILD_IMAGE is necessary for make rpm
51-
KBUILD_IMAGE :=arch/s390/boot/image
52-
5350
#
5451
# Prevent tail-call optimizations, to get clearer backtraces:
5552
#
@@ -84,7 +81,7 @@ ifdef CONFIG_EXPOLINE
8481
CC_FLAGS_EXPOLINE += -mfunction-return=thunk
8582
CC_FLAGS_EXPOLINE += -mindirect-branch-table
8683
export CC_FLAGS_EXPOLINE
87-
cflags-y += $(CC_FLAGS_EXPOLINE)
84+
cflags-y += $(CC_FLAGS_EXPOLINE) -DCC_USING_EXPOLINE
8885
endif
8986
endif
9087

@@ -126,6 +123,9 @@ tools := arch/s390/tools
126123

127124
all: image bzImage
128125

126+
#KBUILD_IMAGE is necessary for packaging targets like rpm-pkg, deb-pkg...
127+
KBUILD_IMAGE := $(boot)/bzImage
128+
129129
install: vmlinux
130130
$(Q)$(MAKE) $(build)=$(boot) $@
131131

arch/s390/boot/compressed/Makefile

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,16 @@ LDFLAGS_vmlinux := --oformat $(LD_BFD) -e startup -T
2929
$(obj)/vmlinux: $(obj)/vmlinux.lds $(OBJECTS)
3030
$(call if_changed,ld)
3131

32-
sed-sizes := -e 's/^\([0-9a-fA-F]*\) . \(__bss_start\|_end\)$$/\#define SZ\2 0x\1/p'
32+
TRIM_HEAD_SIZE := 0x11000
3333

34-
quiet_cmd_sizes = GEN $@
34+
sed-sizes := -e 's/^\([0-9a-fA-F]*\) . \(__bss_start\|_end\)$$/\#define SZ\2 (0x\1 - $(TRIM_HEAD_SIZE))/p'
35+
36+
quiet_cmd_sizes = GEN $@
3537
cmd_sizes = $(NM) $< | sed -n $(sed-sizes) > $@
3638

39+
quiet_cmd_trim_head = TRIM $@
40+
cmd_trim_head = tail -c +$$(($(TRIM_HEAD_SIZE) + 1)) $< > $@
41+
3742
$(obj)/sizes.h: vmlinux
3843
$(call if_changed,sizes)
3944

@@ -43,10 +48,13 @@ $(obj)/head.o: $(obj)/sizes.h
4348
CFLAGS_misc.o += -I$(objtree)/$(obj)
4449
$(obj)/misc.o: $(obj)/sizes.h
4550

46-
OBJCOPYFLAGS_vmlinux.bin := -R .comment -S
47-
$(obj)/vmlinux.bin: vmlinux
51+
OBJCOPYFLAGS_vmlinux.bin.full := -R .comment -S
52+
$(obj)/vmlinux.bin.full: vmlinux
4853
$(call if_changed,objcopy)
4954

55+
$(obj)/vmlinux.bin: $(obj)/vmlinux.bin.full
56+
$(call if_changed,trim_head)
57+
5058
vmlinux.bin.all-y := $(obj)/vmlinux.bin
5159

5260
suffix-$(CONFIG_KERNEL_GZIP) := gz

arch/s390/boot/compressed/head.S

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,10 @@ ENTRY(startup_continue)
2323
aghi %r15,-160
2424
brasl %r14,decompress_kernel
2525
# Set up registers for memory mover. We move the decompressed image to
26-
# 0x11000, starting at offset 0x11000 in the decompressed image so
27-
# that code living at 0x11000 in the image will end up at 0x11000 in
28-
# memory.
26+
# 0x11000, where startup_continue of the decompressed image is supposed
27+
# to be.
2928
lgr %r4,%r2
3029
lg %r2,.Loffset-.LPG1(%r13)
31-
la %r4,0(%r2,%r4)
3230
lg %r3,.Lmvsize-.LPG1(%r13)
3331
lgr %r5,%r3
3432
# Move the memory mover someplace safe so it doesn't overwrite itself.

arch/s390/boot/compressed/misc.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727
/* Symbols defined by linker scripts */
2828
extern char input_data[];
2929
extern int input_len;
30-
extern char _text, _end;
31-
extern char _bss, _ebss;
30+
extern char _end[];
31+
extern char _bss[], _ebss[];
3232

3333
static void error(char *m);
3434

@@ -144,7 +144,7 @@ unsigned long decompress_kernel(void)
144144
{
145145
void *output, *kernel_end;
146146

147-
output = (void *) ALIGN((unsigned long) &_end + HEAP_SIZE, PAGE_SIZE);
147+
output = (void *) ALIGN((unsigned long) _end + HEAP_SIZE, PAGE_SIZE);
148148
kernel_end = output + SZ__bss_start;
149149
check_ipl_parmblock((void *) 0, (unsigned long) kernel_end);
150150

@@ -166,8 +166,8 @@ unsigned long decompress_kernel(void)
166166
* Clear bss section. free_mem_ptr and free_mem_end_ptr need to be
167167
* initialized afterwards since they reside in bss.
168168
*/
169-
memset(&_bss, 0, &_ebss - &_bss);
170-
free_mem_ptr = (unsigned long) &_end;
169+
memset(_bss, 0, _ebss - _bss);
170+
free_mem_ptr = (unsigned long) _end;
171171
free_mem_end_ptr = free_mem_ptr + HEAP_SIZE;
172172

173173
__decompress(input_data, input_len, NULL, NULL, output, 0, NULL, error);

arch/s390/boot/compressed/vmlinux.lds.S

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ SECTIONS
5252
/* Sections to be discarded */
5353
/DISCARD/ : {
5454
*(.eh_frame)
55+
*(__ex_table)
5556
*(*__ksymtab*)
5657
}
5758
}

arch/s390/crypto/aes_s390.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1047,6 +1047,7 @@ static struct aead_alg gcm_aes_aead = {
10471047

10481048
static struct crypto_alg *aes_s390_algs_ptr[5];
10491049
static int aes_s390_algs_num;
1050+
static struct aead_alg *aes_s390_aead_alg;
10501051

10511052
static int aes_s390_register_alg(struct crypto_alg *alg)
10521053
{
@@ -1065,7 +1066,8 @@ static void aes_s390_fini(void)
10651066
if (ctrblk)
10661067
free_page((unsigned long) ctrblk);
10671068

1068-
crypto_unregister_aead(&gcm_aes_aead);
1069+
if (aes_s390_aead_alg)
1070+
crypto_unregister_aead(aes_s390_aead_alg);
10691071
}
10701072

10711073
static int __init aes_s390_init(void)
@@ -1123,6 +1125,7 @@ static int __init aes_s390_init(void)
11231125
ret = crypto_register_aead(&gcm_aes_aead);
11241126
if (ret)
11251127
goto out_err;
1128+
aes_s390_aead_alg = &gcm_aes_aead;
11261129
}
11271130

11281131
return 0;

0 commit comments

Comments
 (0)