Skip to content

Commit 2a4c0c1

Browse files
committed
Merge tag 's390-7.1-1' of git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux
Pull s390 updates from Vasily Gorbik: - Add support for CONFIG_PAGE_TABLE_CHECK and enable it in debug_defconfig. s390 can only tell user from kernel PTEs via the mm, so mm_struct is now passed into pxx_user_accessible_page() callbacks - Expose the PCI function UID as an arch-specific slot attribute in sysfs so a function can be identified by its user-defined id while still in standby. Introduces a generic ARCH_PCI_SLOT_GROUPS hook in drivers/pci/slot.c - Refresh s390 PCI documentation to reflect current behavior and cover previously undocumented sysfs attributes - zcrypt device driver cleanup series: consistent field types, clearer variable naming, a kernel-doc warning fix, and a comment explaining the intentional synchronize_rcu() in pkey_handler_register() - Provide an s390 arch_raw_cpu_ptr() that avoids the detour via get_lowcore() using alternatives, shrinking defconfig by ~27 kB - Guard identity-base randomization with kaslr_enabled() so nokaslr keeps the identity mapping at 0 even with RANDOMIZE_IDENTITY_BASE=y - Build S390_MODULES_SANITY_TEST as a module only by requiring KUNIT && m, since built-in would not exercise module loading - Remove the permanently commented-out HMCDRV_DEV_CLASS create_class() code in the hmcdrv driver - Drop stale ident_map_size extern conflicting with asm/page.h * tag 's390-7.1-1' of git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux: s390/zcrypt: Fix warning about wrong kernel doc comment PCI: s390: Expose the UID as an arch specific PCI slot attribute docs: s390/pci: Improve and update PCI documentation s390/pkey: Add comment about synchronize_rcu() to pkey base s390/hmcdrv: Remove commented out code s390/zcrypt: Slight rework on the agent_id field s390/zcrypt: Explicitly use a card variable in _zcrypt_send_cprb s390/zcrypt: Rework MKVP fields and handling s390/zcrypt: Make apfs a real unsigned int field s390/zcrypt: Rework domain processing within zcrypt device driver s390/zcrypt: Move inline function rng_type6cprb_msgx from header to code s390/percpu: Provide arch_raw_cpu_ptr() s390: Enable page table check for debug_defconfig s390/pgtable: Add s390 support for page table check s390/pgtable: Use set_pmd_bit() to invalidate PMD entry mm/page_table_check: Pass mm_struct to pxx_user_accessible_page() s390/boot: Respect kaslr_enabled() for identity randomization s390/Kconfig: Make modules sanity test a module-only option s390/setup: Drop stale ident_map_size declaration
2 parents 8fd12b0 + 8d7ea40 commit 2a4c0c1

28 files changed

Lines changed: 471 additions & 393 deletions

File tree

Documentation/arch/s390/pci.rst

Lines changed: 108 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ S/390 PCI
66

77
Authors:
88
- Pierre Morel
9+
- Niklas Schnelle
910

1011
Copyright, IBM Corp. 2020
1112

@@ -27,14 +28,16 @@ Command line parameters
2728
debugfs entries
2829
---------------
2930

30-
The S/390 debug feature (s390dbf) generates views to hold various debug results in sysfs directories of the form:
31+
The S/390 debug feature (s390dbf) generates views to hold various debug results
32+
in sysfs directories of the form:
3133

3234
* /sys/kernel/debug/s390dbf/pci_*/
3335

3436
For example:
3537

3638
- /sys/kernel/debug/s390dbf/pci_msg/sprintf
37-
Holds messages from the processing of PCI events, like machine check handling
39+
40+
holds messages from the processing of PCI events, like machine check handling
3841
and setting of global functionality, like UID checking.
3942

4043
Change the level of logging to be more or less verbose by piping
@@ -47,87 +50,141 @@ Sysfs entries
4750

4851
Entries specific to zPCI functions and entries that hold zPCI information.
4952

50-
* /sys/bus/pci/slots/XXXXXXXX
53+
* /sys/bus/pci/slots/XXXXXXXX:
5154

52-
The slot entries are set up using the function identifier (FID) of the
53-
PCI function. The format depicted as XXXXXXXX above is 8 hexadecimal digits
54-
with 0 padding and lower case hexadecimal digits.
55+
The slot entries are set up using the function identifier (FID) of the PCI
56+
function as slot name. The format depicted as XXXXXXXX above is 8 hexadecimal
57+
digits with 0 padding and lower case hexadecimal digits.
5558

5659
- /sys/bus/pci/slots/XXXXXXXX/power
5760

61+
In addition to using the FID as the name of the slot, the slot directory
62+
also contains the following s390-specific slot attributes.
63+
64+
- uid:
65+
The User-defined identifier (UID) of the function which may be configured
66+
by this slot. See also the corresponding attribute of the device.
67+
5868
A physical function that currently supports a virtual function cannot be
5969
powered off until all virtual functions are removed with:
60-
echo 0 > /sys/bus/pci/devices/XXXX:XX:XX.X/sriov_numvf
70+
echo 0 > /sys/bus/pci/devices/DDDD:BB:dd.f/sriov_numvf
6171

62-
* /sys/bus/pci/devices/XXXX:XX:XX.X/
72+
* /sys/bus/pci/devices/DDDD:BB:dd.f/:
6373

64-
- function_id
65-
A zPCI function identifier that uniquely identifies the function in the Z server.
74+
- function_id:
75+
The zPCI function identifier (FID) is a 32-bit hexadecimal value that
76+
uniquely identifies the PCI function. Unless the hypervisor provides
77+
a virtual FID e.g. on KVM this identifier is unique across the machine even
78+
between different partitions.
6679

67-
- function_handle
68-
Low-level identifier used for a configured PCI function.
69-
It might be useful for debugging.
80+
- function_handle:
81+
This 32-bit hexadecimal value is a low-level identifier used for a PCI
82+
function. Note that the function handle may be changed and become invalid
83+
on PCI events and when enabling/disabling the PCI function.
7084

71-
- pchid
72-
Model-dependent location of the I/O adapter.
85+
- pchid:
86+
This 16-bit hexadecimal value encodes a model-dependent location for
87+
the PCI function.
7388

74-
- pfgid
75-
PCI function group ID, functions that share identical functionality
89+
- pfgid:
90+
PCI function group ID; functions that share identical functionality
7691
use a common identifier.
7792
A PCI group defines interrupts, IOMMU, IOTLB, and DMA specifics.
7893

79-
- vfn
94+
- vfn:
8095
The virtual function number, from 1 to N for virtual functions,
8196
0 for physical functions.
8297

83-
- pft
84-
The PCI function type
85-
86-
- port
87-
The port corresponds to the physical port the function is attached to.
88-
It also gives an indication of the physical function a virtual function
89-
is attached to.
90-
91-
- uid
92-
The user identifier (UID) may be defined as part of the machine
93-
configuration or the z/VM or KVM guest configuration. If the accompanying
94-
uid_is_unique attribute is 1 the platform guarantees that the UID is unique
95-
within that instance and no devices with the same UID can be attached
96-
during the lifetime of the system.
97-
98-
- uid_is_unique
99-
Indicates whether the user identifier (UID) is guaranteed to be and remain
100-
unique within this Linux instance.
101-
102-
- pfip/segmentX
98+
- pft:
99+
The PCI function type is an s390-specific type attribute. It indicates
100+
a more general, usage oriented, type than PCI Specification
101+
class/vendor/device identifiers. That is PCI functions with the same pft
102+
value may be backed by different hardware implementations. At the same time
103+
apart from unclassified functions (pft is 0x00) the same pft value
104+
generally implies a similar usage model. At the same time the same
105+
PCI hardware device may appear with different pft values when in a
106+
different usage model. For example NETD and NETH VFs may be implemented
107+
by the same PCI hardware device but in NETD the parent Physical Function
108+
is user managed while with NETH it is platform managed.
109+
110+
Currently the following PFT values are defined:
111+
112+
- 0x00 (UNC): Unclassified
113+
- 0x02 (ROCE): RoCE Express
114+
- 0x05 (ISM): Internal Shared Memory
115+
- 0x0a (ROC2): RoCE Express 2
116+
- 0x0b (NVMe): NVMe
117+
- 0x0c (NETH): Network Express hybrid
118+
- 0x0d (CNW): Cloud Network Adapter
119+
- 0x0f (NETD): Network Express direct
120+
121+
- port:
122+
The port is a decimal value corresponding to the physical port the function
123+
is attached to. Virtual Functions (VFs) share the port with their parent
124+
Physical Function (PF). A value of 0 indicates that the port attribute is
125+
not applicable for that PCI function type.
126+
127+
- uid:
128+
The user-defined identifier (UID) for a PCI function is a 32-bit
129+
hexadecimal value. It is defined on a per instance basis as part of the
130+
partition, KVM guest, or z/VM guest configuration. If UID Checking is
131+
enabled the platform ensures that the UID is unique within that instance
132+
and no two PCI functions with the same UID will be visible to the instance.
133+
134+
Independent of this guarantee and unlike the function ID (FID) the UID may
135+
be the same in different partitions within the same machine. This allows to
136+
create PCI configurations in multiple partitions to be identical in the
137+
UID-namespace.
138+
139+
- uid_is_unique:
140+
A 0 or 1 flag indicating whether the user-defined identifier (UID) is
141+
guaranteed to be and remain unique within this Linux instance. This
142+
platform feature is called UID Checking.
143+
144+
- pfip/segmentX:
103145
The segments determine the isolation of a function.
104146
They correspond to the physical path to the function.
105147
The more the segments are different, the more the functions are isolated.
106148

149+
- fidparm:
150+
Contains an 8-bit-per-PCI function parameter field in hexadecimal provided
151+
by the platform. The meaning of this field is PCI function type specific.
152+
For NETH VFs a value of 0x01 indicates that the function supports
153+
promiscuous mode.
154+
155+
* /sys/firmware/clp/uid_checking:
156+
157+
In addition to the per-device uid_is_unique attribute this presents a
158+
global indication of whether UID Checking is enabled. This allows users
159+
to check for UID Checking even when no PCI functions are configured.
160+
107161
Enumeration and hotplug
108162
=======================
109163

110164
The PCI address consists of four parts: domain, bus, device and function,
111-
and is of this form: DDDD:BB:dd.f
165+
and is of this form: DDDD:BB:dd.f.
112166

113-
* When not using multi-functions (norid is set, or the firmware does not
114-
support multi-functions):
167+
* For a PCI function for which the platform does not expose the RID, the
168+
pci=norid kernel parameter is used, or a so-called isolated Virtual Function
169+
which does have RID information but is used without its parent Physical
170+
Function being part of the same PCI configuration:
115171

116172
- There is only one function per domain.
117173

118-
- The domain is set from the zPCI function's UID as defined during the
119-
LPAR creation.
174+
- The domain is set from the zPCI function's UID if UID Checking is on;
175+
otherwise the domain ID is generated dynamically and is not stable
176+
across reboots or hot plug.
120177

121-
* When using multi-functions (norid parameter is not set),
122-
zPCI functions are addressed differently:
178+
* For a PCI function for which the platform exposes the RID and which
179+
is not an Isolated Virtual Function:
123180

124181
- There is still only one bus per domain.
125182

126-
- There can be up to 256 functions per bus.
183+
- There can be up to 256 PCI functions per bus.
127184

128-
- The domain part of the address of all functions for
129-
a multi-Function device is set from the zPCI function's UID as defined
130-
in the LPAR creation for the function zero.
185+
- The domain part of the address of all functions within the same topology is
186+
that of the configured PCI function with the lowest devfn within that
187+
topology.
131188

132-
- New functions will only be ready for use after the function zero
133-
(the function with devfn 0) has been enumerated.
189+
- Virtual Functions generated by an SR-IOV capable Physical Function only
190+
become visible once SR-IOV is enabled.

arch/arm64/include/asm/pgtable.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1276,17 +1276,17 @@ static inline int pmdp_set_access_flags(struct vm_area_struct *vma,
12761276
#endif
12771277

12781278
#ifdef CONFIG_PAGE_TABLE_CHECK
1279-
static inline bool pte_user_accessible_page(pte_t pte, unsigned long addr)
1279+
static inline bool pte_user_accessible_page(struct mm_struct *mm, unsigned long addr, pte_t pte)
12801280
{
12811281
return pte_valid(pte) && (pte_user(pte) || pte_user_exec(pte));
12821282
}
12831283

1284-
static inline bool pmd_user_accessible_page(pmd_t pmd, unsigned long addr)
1284+
static inline bool pmd_user_accessible_page(struct mm_struct *mm, unsigned long addr, pmd_t pmd)
12851285
{
12861286
return pmd_valid(pmd) && !pmd_table(pmd) && (pmd_user(pmd) || pmd_user_exec(pmd));
12871287
}
12881288

1289-
static inline bool pud_user_accessible_page(pud_t pud, unsigned long addr)
1289+
static inline bool pud_user_accessible_page(struct mm_struct *mm, unsigned long addr, pud_t pud)
12901290
{
12911291
return pud_valid(pud) && !pud_table(pud) && (pud_user(pud) || pud_user_exec(pud));
12921292
}

arch/powerpc/include/asm/book3s/32/pgtable.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ static inline bool pte_access_permitted(pte_t pte, bool write)
438438
return true;
439439
}
440440

441-
static inline bool pte_user_accessible_page(pte_t pte, unsigned long addr)
441+
static inline bool pte_user_accessible_page(struct mm_struct *mm, unsigned long addr, pte_t pte)
442442
{
443443
return pte_present(pte) && !is_kernel_addr(addr);
444444
}

arch/powerpc/include/asm/book3s/64/pgtable.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -549,7 +549,7 @@ static inline bool pte_access_permitted(pte_t pte, bool write)
549549
return arch_pte_access_permitted(pte_val(pte), write, 0);
550550
}
551551

552-
static inline bool pte_user_accessible_page(pte_t pte, unsigned long addr)
552+
static inline bool pte_user_accessible_page(struct mm_struct *mm, unsigned long addr, pte_t pte)
553553
{
554554
return pte_present(pte) && pte_user(pte);
555555
}
@@ -925,9 +925,9 @@ static inline bool pud_access_permitted(pud_t pud, bool write)
925925
}
926926

927927
#define pud_user_accessible_page pud_user_accessible_page
928-
static inline bool pud_user_accessible_page(pud_t pud, unsigned long addr)
928+
static inline bool pud_user_accessible_page(struct mm_struct *mm, unsigned long addr, pud_t pud)
929929
{
930-
return pud_leaf(pud) && pte_user_accessible_page(pud_pte(pud), addr);
930+
return pud_leaf(pud) && pte_user_accessible_page(mm, addr, pud_pte(pud));
931931
}
932932

933933
#define __p4d_raw(x) ((p4d_t) { __pgd_raw(x) })
@@ -1096,9 +1096,9 @@ static inline bool pmd_access_permitted(pmd_t pmd, bool write)
10961096
}
10971097

10981098
#define pmd_user_accessible_page pmd_user_accessible_page
1099-
static inline bool pmd_user_accessible_page(pmd_t pmd, unsigned long addr)
1099+
static inline bool pmd_user_accessible_page(struct mm_struct *mm, unsigned long addr, pmd_t pmd)
11001100
{
1101-
return pmd_leaf(pmd) && pte_user_accessible_page(pmd_pte(pmd), addr);
1101+
return pmd_leaf(pmd) && pte_user_accessible_page(mm, addr, pmd_pte(pmd));
11021102
}
11031103

11041104
#ifdef CONFIG_TRANSPARENT_HUGEPAGE

arch/powerpc/include/asm/nohash/pgtable.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ static inline bool pte_access_permitted(pte_t pte, bool write)
249249
return true;
250250
}
251251

252-
static inline bool pte_user_accessible_page(pte_t pte, unsigned long addr)
252+
static inline bool pte_user_accessible_page(struct mm_struct *mm, unsigned long addr, pte_t pte)
253253
{
254254
return pte_present(pte) && !is_kernel_addr(addr);
255255
}

arch/powerpc/include/asm/pgtable.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,11 +213,11 @@ static inline bool arch_supports_memmap_on_memory(unsigned long vmemmap_size)
213213
#endif /* CONFIG_PPC64 */
214214

215215
#ifndef pmd_user_accessible_page
216-
#define pmd_user_accessible_page(pmd, addr) false
216+
#define pmd_user_accessible_page(mm, addr, pmd) false
217217
#endif
218218

219219
#ifndef pud_user_accessible_page
220-
#define pud_user_accessible_page(pud, addr) false
220+
#define pud_user_accessible_page(mm, addr, pud) false
221221
#endif
222222

223223
#endif /* __ASSEMBLER__ */

arch/riscv/include/asm/pgtable.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -984,17 +984,17 @@ static inline void set_pud_at(struct mm_struct *mm, unsigned long addr,
984984
}
985985

986986
#ifdef CONFIG_PAGE_TABLE_CHECK
987-
static inline bool pte_user_accessible_page(pte_t pte, unsigned long addr)
987+
static inline bool pte_user_accessible_page(struct mm_struct *mm, unsigned long addr, pte_t pte)
988988
{
989989
return pte_present(pte) && pte_user(pte);
990990
}
991991

992-
static inline bool pmd_user_accessible_page(pmd_t pmd, unsigned long addr)
992+
static inline bool pmd_user_accessible_page(struct mm_struct *mm, unsigned long addr, pmd_t pmd)
993993
{
994994
return pmd_leaf(pmd) && pmd_user(pmd);
995995
}
996996

997-
static inline bool pud_user_accessible_page(pud_t pud, unsigned long addr)
997+
static inline bool pud_user_accessible_page(struct mm_struct *mm, unsigned long addr, pud_t pud)
998998
{
999999
return pud_leaf(pud) && pud_user(pud);
10001000
}

arch/s390/Kconfig

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ config S390
152152
select ARCH_SUPPORTS_INT128 if CC_HAS_INT128 && CC_IS_CLANG
153153
select ARCH_SUPPORTS_MSEAL_SYSTEM_MAPPINGS
154154
select ARCH_SUPPORTS_NUMA_BALANCING
155+
select ARCH_SUPPORTS_PAGE_TABLE_CHECK
155156
select ARCH_SUPPORTS_PER_VMA_LOCK
156157
select ARCH_USE_BUILTIN_BSWAP
157158
select ARCH_USE_CMPXCHG_LOCKREF
@@ -1023,7 +1024,7 @@ config S390_KPROBES_SANITY_TEST
10231024

10241025
config S390_MODULES_SANITY_TEST
10251026
def_tristate n
1026-
depends on KUNIT
1027+
depends on KUNIT && m
10271028
default KUNIT_ALL_TESTS
10281029
prompt "Enable s390 specific modules tests"
10291030
select S390_MODULES_SANITY_TEST_HELPERS

arch/s390/boot/startup.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,8 @@ static unsigned long setup_kernel_memory_layout(unsigned long kernel_size)
440440
max_mappable = max(ident_map_size, MAX_DCSS_ADDR);
441441
max_mappable = min(max_mappable, vmemmap_start);
442442
#ifdef CONFIG_RANDOMIZE_IDENTITY_BASE
443-
__identity_base = round_down(vmemmap_start - max_mappable, rte_size);
443+
if (kaslr_enabled())
444+
__identity_base = round_down(vmemmap_start - max_mappable, rte_size);
444445
#endif
445446
boot_debug("identity map: 0x%016lx-0x%016lx\n", __identity_base,
446447
__identity_base + ident_map_size);

arch/s390/configs/debug_defconfig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -925,3 +925,5 @@ CONFIG_PERCPU_TEST=m
925925
CONFIG_ATOMIC64_SELFTEST=y
926926
CONFIG_TEST_BITOPS=m
927927
CONFIG_TEST_BPF=m
928+
CONFIG_PAGE_TABLE_CHECK=y
929+
CONFIG_PAGE_TABLE_CHECK_ENFORCED=y

0 commit comments

Comments
 (0)