Skip to content

Commit 0723a16

Browse files
committed
Merge tag 's390-6.19-2' of git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux
Pull more s390 updates from Heiko Carstens: - Use the MSI parent domain API instead of the legacy API for setup and teardown of PCI MSI IRQs - Select POSIX_CPU_TIMERS_TASK_WORK now that VIRT_XFER_TO_GUEST_WORK has been implemented for s390 - Fix a KVM bug which can lead to guest memory corruption - Fix KASAN shadow memory mapping for hotplugged memory - Minor bug fixes and improvements * tag 's390-6.19-2' of git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux: s390/bug: Add missing alignment s390/bug: Add missing CONFIG_BUG ifdef again KVM: s390: Fix gmap_helper_zap_one_page() again s390/pci: Migrate s390 IRQ logic to IRQ domain API genirq: Change hwirq parameter to irq_hw_number_t s390: Select POSIX_CPU_TIMERS_TASK_WORK s390: Unmap early KASAN shadow on memory offlining s390/vmem: Support 2G page splitting for KASAN shadow freeing s390/boot: Use entire page for PTEs s390/vmur: Use scnprintf() instead of sprintf()
2 parents 840b22e + 70075e3 commit 0723a16

15 files changed

Lines changed: 303 additions & 144 deletions

File tree

arch/s390/Kconfig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,7 @@ config S390
238238
select HAVE_PERF_EVENTS
239239
select HAVE_PERF_REGS
240240
select HAVE_PERF_USER_STACK_DUMP
241+
select HAVE_POSIX_CPU_TIMERS_TASK_WORK
241242
select HAVE_PREEMPT_DYNAMIC_KEY
242243
select HAVE_REGS_AND_STACK_ACCESS_API
243244
select HAVE_RELIABLE_STACKTRACE
@@ -254,6 +255,7 @@ config S390
254255
select HOTPLUG_SMT
255256
select IOMMU_HELPER if PCI
256257
select IOMMU_SUPPORT if PCI
258+
select IRQ_MSI_LIB if PCI
257259
select KASAN_VMALLOC if KASAN
258260
select LOCK_MM_AND_FIND_VMA
259261
select MMU_GATHER_MERGE_VMAS

arch/s390/boot/vmem.c

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -244,22 +244,10 @@ static void *boot_crst_alloc(unsigned long val)
244244

245245
static pte_t *boot_pte_alloc(void)
246246
{
247-
static void *pte_leftover;
248247
pte_t *pte;
249248

250-
/*
251-
* handling pte_leftovers this way helps to avoid memory fragmentation
252-
* during POPULATE_KASAN_MAP_SHADOW when EDAT is off
253-
*/
254-
if (!pte_leftover) {
255-
pte_leftover = (void *)physmem_alloc_or_die(RR_VMEM, PAGE_SIZE, PAGE_SIZE);
256-
pte = pte_leftover + _PAGE_TABLE_SIZE;
257-
__arch_set_page_dat(pte, 1);
258-
} else {
259-
pte = pte_leftover;
260-
pte_leftover = NULL;
261-
}
262-
249+
pte = (void *)physmem_alloc_or_die(RR_VMEM, PAGE_SIZE, PAGE_SIZE);
250+
__arch_set_page_dat(pte, 1);
263251
memset64((u64 *)pte, _PAGE_INVALID, PTRS_PER_PTE);
264252
return pte;
265253
}

arch/s390/include/asm/bug.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,14 @@
44

55
#include <linux/stringify.h>
66

7+
#ifdef CONFIG_BUG
8+
79
#ifndef CONFIG_DEBUG_BUGVERBOSE
810
#define _BUGVERBOSE_LOCATION(file, line)
911
#else
1012
#define __BUGVERBOSE_LOCATION(file, line) \
1113
.pushsection .rodata.str, "aMS", @progbits, 1; \
14+
.align 2; \
1215
10002: .ascii file "\0"; \
1316
.popsection; \
1417
\
@@ -52,6 +55,8 @@ do { \
5255

5356
#define HAVE_ARCH_BUG
5457

58+
#endif /* CONFIG_BUG */
59+
5560
#include <asm-generic/bug.h>
5661

5762
#endif /* _ASM_S390_BUG_H */

arch/s390/include/asm/page.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,8 @@ static inline int page_reset_referenced(unsigned long addr)
166166
return CC_TRANSFORM(cc);
167167
}
168168

169+
int split_pud_page(pud_t *pudp, unsigned long addr);
170+
169171
/* Bits int the storage key */
170172
#define _PAGE_CHANGED 0x02 /* HW changed bit */
171173
#define _PAGE_REFERENCED 0x04 /* HW referenced bit */

arch/s390/include/asm/pci.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include <linux/pci.h>
66
#include <linux/mutex.h>
77
#include <linux/iommu.h>
8+
#include <linux/irqdomain.h>
89
#include <linux/pci_hotplug.h>
910
#include <asm/pci_clp.h>
1011
#include <asm/pci_debug.h>
@@ -109,6 +110,7 @@ struct zpci_bus {
109110
struct list_head resources;
110111
struct list_head bus_next;
111112
struct resource bus_resource;
113+
struct irq_domain *msi_parent_domain;
112114
int topo; /* TID if topo_is_tid, PCHID otherwise */
113115
int domain_nr;
114116
u8 multifunction : 1;
@@ -310,6 +312,9 @@ int zpci_dma_exit_device(struct zpci_dev *zdev);
310312
/* IRQ */
311313
int __init zpci_irq_init(void);
312314
void __init zpci_irq_exit(void);
315+
int zpci_set_irq(struct zpci_dev *zdev);
316+
int zpci_create_parent_msi_domain(struct zpci_bus *zbus);
317+
void zpci_remove_parent_msi_domain(struct zpci_bus *zbus);
313318

314319
/* FMB */
315320
int zpci_fmb_enable_device(struct zpci_dev *);

arch/s390/mm/gmap_helpers.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ static void ptep_zap_softleaf_entry(struct mm_struct *mm, softleaf_t entry)
4747
void gmap_helper_zap_one_page(struct mm_struct *mm, unsigned long vmaddr)
4848
{
4949
struct vm_area_struct *vma;
50+
unsigned long pgstev;
5051
spinlock_t *ptl;
5152
pgste_t pgste;
5253
pte_t *ptep;
@@ -65,9 +66,13 @@ void gmap_helper_zap_one_page(struct mm_struct *mm, unsigned long vmaddr)
6566
if (pte_swap(*ptep)) {
6667
preempt_disable();
6768
pgste = pgste_get_lock(ptep);
69+
pgstev = pgste_val(pgste);
6870

69-
ptep_zap_softleaf_entry(mm, softleaf_from_pte(*ptep));
70-
pte_clear(mm, vmaddr, ptep);
71+
if ((pgstev & _PGSTE_GPS_USAGE_MASK) == _PGSTE_GPS_USAGE_UNUSED ||
72+
(pgstev & _PGSTE_GPS_ZERO)) {
73+
ptep_zap_softleaf_entry(mm, softleaf_from_pte(*ptep));
74+
pte_clear(mm, vmaddr, ptep);
75+
}
7176

7277
pgste_set_unlock(ptep, pgste);
7378
preempt_enable();

arch/s390/mm/pageattr.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ static int walk_pmd_level(pud_t *pudp, unsigned long addr, unsigned long end,
204204
return rc;
205205
}
206206

207-
static int split_pud_page(pud_t *pudp, unsigned long addr)
207+
int split_pud_page(pud_t *pudp, unsigned long addr)
208208
{
209209
unsigned long pmd_addr, prot;
210210
pmd_t *pm_dir, *pmdp;

arch/s390/mm/vmem.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -330,10 +330,14 @@ static int modify_pud_table(p4d_t *p4d, unsigned long addr, unsigned long end,
330330
if (pud_leaf(*pud)) {
331331
if (IS_ALIGNED(addr, PUD_SIZE) &&
332332
IS_ALIGNED(next, PUD_SIZE)) {
333+
if (!direct)
334+
vmem_free_pages(pud_deref(*pud), get_order(PUD_SIZE), altmap);
333335
pud_clear(pud);
334336
pages++;
337+
continue;
338+
} else {
339+
split_pud_page(pud, addr & PUD_MASK);
335340
}
336-
continue;
337341
}
338342
} else if (pud_none(*pud)) {
339343
if (IS_ALIGNED(addr, PUD_SIZE) &&
@@ -433,9 +437,15 @@ static int modify_pagetable(unsigned long start, unsigned long end, bool add,
433437

434438
if (WARN_ON_ONCE(!PAGE_ALIGNED(start | end)))
435439
return -EINVAL;
436-
/* Don't mess with any tables not fully in 1:1 mapping & vmemmap area */
440+
/* Don't mess with any tables not fully in 1:1 mapping, vmemmap & kasan area */
441+
#ifdef CONFIG_KASAN
442+
if (WARN_ON_ONCE(!(start >= KASAN_SHADOW_START && end <= KASAN_SHADOW_END) &&
443+
end > __abs_lowcore))
444+
return -EINVAL;
445+
#else
437446
if (WARN_ON_ONCE(end > __abs_lowcore))
438447
return -EINVAL;
448+
#endif
439449
for (addr = start; addr < end; addr = next) {
440450
next = pgd_addr_end(addr, end);
441451
pgd = pgd_offset_k(addr);

arch/s390/pci/pci.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -708,6 +708,12 @@ int zpci_reenable_device(struct zpci_dev *zdev)
708708
if (rc)
709709
return rc;
710710

711+
if (zdev->msi_nr_irqs > 0) {
712+
rc = zpci_set_irq(zdev);
713+
if (rc)
714+
return rc;
715+
}
716+
711717
rc = zpci_iommu_register_ioat(zdev, &status);
712718
if (rc)
713719
zpci_disable_device(zdev);

arch/s390/pci/pci_bus.c

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <linux/err.h>
1515
#include <linux/delay.h>
1616
#include <linux/seq_file.h>
17+
#include <linux/irqdomain.h>
1718
#include <linux/jump_label.h>
1819
#include <linux/pci.h>
1920
#include <linux/printk.h>
@@ -198,19 +199,27 @@ static int zpci_bus_create_pci_bus(struct zpci_bus *zbus, struct zpci_dev *fr, s
198199
zbus->multifunction = zpci_bus_is_multifunction_root(fr);
199200
zbus->max_bus_speed = fr->max_bus_speed;
200201

202+
if (zpci_create_parent_msi_domain(zbus))
203+
goto out_free_domain;
204+
201205
/*
202206
* Note that the zbus->resources are taken over and zbus->resources
203207
* is empty after a successful call
204208
*/
205209
bus = pci_create_root_bus(NULL, ZPCI_BUS_NR, ops, zbus, &zbus->resources);
206-
if (!bus) {
207-
zpci_free_domain(zbus->domain_nr);
208-
return -EFAULT;
209-
}
210+
if (!bus)
211+
goto out_remove_msi_domain;
210212

211213
zbus->bus = bus;
214+
dev_set_msi_domain(&zbus->bus->dev, zbus->msi_parent_domain);
212215

213216
return 0;
217+
218+
out_remove_msi_domain:
219+
zpci_remove_parent_msi_domain(zbus);
220+
out_free_domain:
221+
zpci_free_domain(zbus->domain_nr);
222+
return -ENOMEM;
214223
}
215224

216225
static void zpci_bus_release(struct kref *kref)
@@ -231,6 +240,7 @@ static void zpci_bus_release(struct kref *kref)
231240
mutex_lock(&zbus_list_lock);
232241
list_del(&zbus->bus_next);
233242
mutex_unlock(&zbus_list_lock);
243+
zpci_remove_parent_msi_domain(zbus);
234244
kfree(zbus);
235245
}
236246

0 commit comments

Comments
 (0)