Skip to content

Commit f9c0354

Browse files
committed
Merge tag 's390-6.9-2' of git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux
Pull more s390 updates from Heiko Carstens: - Various virtual vs physical address usage fixes - Add new bitwise types and helper functions and use them in s390 specific drivers and code to make it easier to find virtual vs physical address usage bugs. Right now virtual and physical addresses are identical for s390, except for module, vmalloc, and similar areas. This will be changed, hopefully with the next merge window, so that e.g. the kernel image and modules will be located close to each other, allowing for direct branches and also for some other simplifications. As a prerequisite this requires to fix all misuses of virtual and physical addresses. As it turned out people are so used to the concept that virtual and physical addresses are the same, that new bugs got added to code which was already fixed. In order to avoid that even more code gets merged which adds such bugs add and use new bitwise types, so that sparse can be used to find such usage bugs. Most likely the new types can go away again after some time - Provide a simple ARCH_HAS_DEBUG_VIRTUAL implementation - Fix kprobe branch handling: if an out-of-line single stepped relative branch instruction has a target address within a certain address area in the entry code, the program check handler may incorrectly execute cleanup code as if KVM code was executed, leading to crashes - Fix reference counting of zcrypt card objects - Various other small fixes and cleanups * tag 's390-6.9-2' of git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux: (41 commits) s390/entry: compare gmap asce to determine guest/host fault s390/entry: remove OUTSIDE macro s390/entry: add CIF_SIE flag and remove sie64a() address check s390/cio: use while (i--) pattern to clean up s390/raw3270: make class3270 constant s390/raw3270: improve raw3270_init() readability s390/tape: make tape_class constant s390/vmlogrdr: make vmlogrdr_class constant s390/vmur: make vmur_class constant s390/zcrypt: make zcrypt_class constant s390/mm: provide simple ARCH_HAS_DEBUG_VIRTUAL support s390/vfio_ccw_cp: use new address translation helpers s390/iucv: use new address translation helpers s390/ctcm: use new address translation helpers s390/lcs: use new address translation helpers s390/qeth: use new address translation helpers s390/zfcp: use new address translation helpers s390/tape: fix virtual vs physical address confusion s390/3270: use new address translation helpers s390/3215: use new address translation helpers ...
2 parents 24f5bb9 + 64c3431 commit f9c0354

Some content is hidden

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

67 files changed

+771
-553
lines changed

arch/s390/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ config S390
6363
select ARCH_ENABLE_MEMORY_HOTREMOVE
6464
select ARCH_ENABLE_SPLIT_PMD_PTLOCK if PGTABLE_LEVELS > 2
6565
select ARCH_HAS_CURRENT_STACK_POINTER
66+
select ARCH_HAS_DEBUG_VIRTUAL
6667
select ARCH_HAS_DEBUG_VM_PGTABLE
6768
select ARCH_HAS_DEBUG_WX
6869
select ARCH_HAS_DEVMEM_IS_ALLOWED

arch/s390/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ KBUILD_AFLAGS_DECOMPRESSOR += $(if $(CONFIG_DEBUG_INFO),$(aflags_dwarf))
2929
endif
3030
KBUILD_CFLAGS_DECOMPRESSOR := $(CLANG_FLAGS) -m64 -O2 -mpacked-stack
3131
KBUILD_CFLAGS_DECOMPRESSOR += -DDISABLE_BRANCH_PROFILING -D__NO_FORTIFY
32+
KBUILD_CFLAGS_DECOMPRESSOR += -D__DECOMPRESSOR
3233
KBUILD_CFLAGS_DECOMPRESSOR += -fno-delete-null-pointer-checks -msoft-float -mbackchain
3334
KBUILD_CFLAGS_DECOMPRESSOR += -fno-asynchronous-unwind-tables
3435
KBUILD_CFLAGS_DECOMPRESSOR += -ffreestanding

arch/s390/configs/debug_defconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -810,6 +810,7 @@ CONFIG_DEBUG_OBJECTS_PERCPU_COUNTER=y
810810
CONFIG_DEBUG_STACK_USAGE=y
811811
CONFIG_DEBUG_VM=y
812812
CONFIG_DEBUG_VM_PGFLAGS=y
813+
CONFIG_DEBUG_VIRTUAL=y
813814
CONFIG_DEBUG_MEMORY_INIT=y
814815
CONFIG_MEMORY_NOTIFIER_ERROR_INJECT=m
815816
CONFIG_DEBUG_PER_CPU_MAPS=y

arch/s390/include/asm/ccwdev.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,8 @@ extern void ccw_device_destroy_console(struct ccw_device *);
217217
extern int ccw_device_enable_console(struct ccw_device *);
218218
extern void ccw_device_wait_idle(struct ccw_device *);
219219

220-
extern void *ccw_device_dma_zalloc(struct ccw_device *cdev, size_t size);
220+
extern void *ccw_device_dma_zalloc(struct ccw_device *cdev, size_t size,
221+
dma32_t *dma_handle);
221222
extern void ccw_device_dma_free(struct ccw_device *cdev,
222223
void *cpu_addr, size_t size);
223224

arch/s390/include/asm/cio.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
#include <linux/bitops.h>
99
#include <linux/genalloc.h>
10+
#include <asm/dma-types.h>
1011
#include <asm/types.h>
1112
#include <asm/tpi.h>
1213

@@ -32,7 +33,7 @@ struct ccw1 {
3233
__u8 cmd_code;
3334
__u8 flags;
3435
__u16 count;
35-
__u32 cda;
36+
dma32_t cda;
3637
} __attribute__ ((packed,aligned(8)));
3738

3839
/**
@@ -152,8 +153,8 @@ struct sublog {
152153
struct esw0 {
153154
struct sublog sublog;
154155
struct erw erw;
155-
__u32 faddr[2];
156-
__u32 saddr;
156+
dma32_t faddr[2];
157+
dma32_t saddr;
157158
} __attribute__ ((packed));
158159

159160
/**
@@ -364,6 +365,8 @@ extern struct device *cio_get_dma_css_dev(void);
364365

365366
void *cio_gp_dma_zalloc(struct gen_pool *gp_dma, struct device *dma_dev,
366367
size_t size);
368+
void *__cio_gp_dma_zalloc(struct gen_pool *gp_dma, struct device *dma_dev,
369+
size_t size, dma32_t *dma_handle);
367370
void cio_gp_dma_free(struct gen_pool *gp_dma, void *cpu_addr, size_t size);
368371
void cio_gp_dma_destroy(struct gen_pool *gp_dma, struct device *dma_dev);
369372
struct gen_pool *cio_gp_dma_create(struct device *dma_dev, int nr_pages);

arch/s390/include/asm/dma-types.h

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
/* SPDX-License-Identifier: GPL-2.0 */
2+
3+
#ifndef _ASM_S390_DMA_TYPES_H_
4+
#define _ASM_S390_DMA_TYPES_H_
5+
6+
#include <linux/types.h>
7+
#include <linux/io.h>
8+
9+
/*
10+
* typedef dma32_t
11+
* Contains a 31 bit absolute address to a DMA capable piece of storage.
12+
*
13+
* For CIO, DMA addresses are always absolute addresses. These addresses tend
14+
* to be used in architectured memory blocks (like ORB, IDAW, MIDAW). Under
15+
* certain circumstances 31 bit wide addresses must be used because the
16+
* address must fit in 31 bits.
17+
*
18+
* This type is to be used when such fields can be modelled as 32 bit wide.
19+
*/
20+
typedef u32 __bitwise dma32_t;
21+
22+
/*
23+
* typedef dma64_t
24+
* Contains a 64 bit absolute address to a DMA capable piece of storage.
25+
*
26+
* For CIO, DMA addresses are always absolute addresses. These addresses tend
27+
* to be used in architectured memory blocks (like ORB, IDAW, MIDAW).
28+
*
29+
* This type is to be used to model such 64 bit wide fields.
30+
*/
31+
typedef u64 __bitwise dma64_t;
32+
33+
/*
34+
* Although DMA addresses should be obtained using the DMA API, in cases when
35+
* it is known that the first argument holds a virtual address that points to
36+
* DMA-able 31 bit addressable storage, then this function can be safely used.
37+
*/
38+
static inline dma32_t virt_to_dma32(void *ptr)
39+
{
40+
return (__force dma32_t)__pa32(ptr);
41+
}
42+
43+
static inline void *dma32_to_virt(dma32_t addr)
44+
{
45+
return __va((__force unsigned long)addr);
46+
}
47+
48+
static inline dma32_t u32_to_dma32(u32 addr)
49+
{
50+
return (__force dma32_t)addr;
51+
}
52+
53+
static inline u32 dma32_to_u32(dma32_t addr)
54+
{
55+
return (__force u32)addr;
56+
}
57+
58+
static inline dma32_t dma32_add(dma32_t a, u32 b)
59+
{
60+
return (__force dma32_t)((__force u32)a + b);
61+
}
62+
63+
static inline dma32_t dma32_and(dma32_t a, u32 b)
64+
{
65+
return (__force dma32_t)((__force u32)a & b);
66+
}
67+
68+
/*
69+
* Although DMA addresses should be obtained using the DMA API, in cases when
70+
* it is known that the first argument holds a virtual address that points to
71+
* DMA-able storage, then this function can be safely used.
72+
*/
73+
static inline dma64_t virt_to_dma64(void *ptr)
74+
{
75+
return (__force dma64_t)__pa(ptr);
76+
}
77+
78+
static inline void *dma64_to_virt(dma64_t addr)
79+
{
80+
return __va((__force unsigned long)addr);
81+
}
82+
83+
static inline dma64_t u64_to_dma64(u64 addr)
84+
{
85+
return (__force dma64_t)addr;
86+
}
87+
88+
static inline u64 dma64_to_u64(dma64_t addr)
89+
{
90+
return (__force u64)addr;
91+
}
92+
93+
static inline dma64_t dma64_add(dma64_t a, u64 b)
94+
{
95+
return (__force dma64_t)((__force u64)a + b);
96+
}
97+
98+
static inline dma64_t dma64_and(dma64_t a, u64 b)
99+
{
100+
return (__force dma64_t)((__force u64)a & b);
101+
}
102+
103+
#endif /* _ASM_S390_DMA_TYPES_H_ */

arch/s390/include/asm/eadm.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include <linux/types.h>
66
#include <linux/device.h>
77
#include <linux/blk_types.h>
8+
#include <asm/dma-types.h>
89

910
struct arqb {
1011
u64 data;
@@ -45,7 +46,7 @@ struct msb {
4546
u16:12;
4647
u16 bs:4;
4748
u32 blk_count;
48-
u64 data_addr;
49+
dma64_t data_addr;
4950
u64 scm_addr;
5051
u64:64;
5152
} __packed;
@@ -54,7 +55,7 @@ struct aidaw {
5455
u8 flags;
5556
u32 :24;
5657
u32 :32;
57-
u64 data_addr;
58+
dma64_t data_addr;
5859
} __packed;
5960

6061
#define MSB_OC_CLEAR 0

arch/s390/include/asm/fcx.h

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#define _ASM_S390_FCX_H
1111

1212
#include <linux/types.h>
13+
#include <asm/dma-types.h>
1314

1415
#define TCW_FORMAT_DEFAULT 0
1516
#define TCW_TIDAW_FORMAT_DEFAULT 0
@@ -43,16 +44,16 @@ struct tcw {
4344
u32 r:1;
4445
u32 w:1;
4546
u32 :16;
46-
u64 output;
47-
u64 input;
48-
u64 tsb;
49-
u64 tccb;
47+
dma64_t output;
48+
dma64_t input;
49+
dma64_t tsb;
50+
dma64_t tccb;
5051
u32 output_count;
5152
u32 input_count;
5253
u32 :32;
5354
u32 :32;
5455
u32 :32;
55-
u32 intrg;
56+
dma32_t intrg;
5657
} __attribute__ ((packed, aligned(64)));
5758

5859
#define TIDAW_FLAGS_LAST (1 << (7 - 0))
@@ -73,7 +74,7 @@ struct tidaw {
7374
u32 flags:8;
7475
u32 :24;
7576
u32 count;
76-
u64 addr;
77+
dma64_t addr;
7778
} __attribute__ ((packed, aligned(16)));
7879

7980
/**

0 commit comments

Comments
 (0)