Skip to content

Commit ec0e6bd

Browse files
committed
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux
Pull s390 fixes from Martin Schwidefsky: "One performance optimization for page_clear and a couple of bug fixes" * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux: s390/mm: fix incorrect ASCE after crst_table_downgrade s390/ftrace: fix crashes when switching tracers / add notrace to cpu_relax() s390/pci: unify pci_iomap symbol exports s390/pci: fix [un]map_resources sequence s390: let the compiler do page clearing s390/pci: fix possible information leak in mmio syscall s390/dcss: array index 'i' is used before limits check. s390/scm_block: fix off by one during cluster reservation s390/jump label: improve and fix sanity check s390/jump label: add missing jump_label_apply_nops() call
2 parents e7901af + 691d526 commit ec0e6bd

File tree

9 files changed

+38
-39
lines changed

9 files changed

+38
-39
lines changed

arch/s390/include/asm/mmu_context.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
6262
{
6363
int cpu = smp_processor_id();
6464

65+
S390_lowcore.user_asce = next->context.asce_bits | __pa(next->pgd);
6566
if (prev == next)
6667
return;
6768
if (MACHINE_HAS_TLB_LC)
@@ -73,7 +74,6 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
7374
atomic_dec(&prev->context.attach_count);
7475
if (MACHINE_HAS_TLB_LC)
7576
cpumask_clear_cpu(cpu, &prev->context.cpu_attach_mask);
76-
S390_lowcore.user_asce = next->context.asce_bits | __pa(next->pgd);
7777
}
7878

7979
#define finish_arch_post_lock_switch finish_arch_post_lock_switch

arch/s390/include/asm/page.h

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,7 @@ static inline void storage_key_init_range(unsigned long start, unsigned long end
3737
#endif
3838
}
3939

40-
static inline void clear_page(void *page)
41-
{
42-
register unsigned long reg1 asm ("1") = 0;
43-
register void *reg2 asm ("2") = page;
44-
register unsigned long reg3 asm ("3") = 4096;
45-
asm volatile(
46-
" mvcl 2,0"
47-
: "+d" (reg2), "+d" (reg3) : "d" (reg1)
48-
: "memory", "cc");
49-
}
40+
#define clear_page(page) memset((page), 0, PAGE_SIZE)
5041

5142
/*
5243
* copy_page uses the mvcl instruction with 0xb0 padding byte in order to

arch/s390/kernel/jump_label.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,20 @@ static void jump_label_make_branch(struct jump_entry *entry, struct insn *insn)
3636
insn->offset = (entry->target - entry->code) >> 1;
3737
}
3838

39-
static void jump_label_bug(struct jump_entry *entry, struct insn *insn)
39+
static void jump_label_bug(struct jump_entry *entry, struct insn *expected,
40+
struct insn *new)
4041
{
4142
unsigned char *ipc = (unsigned char *)entry->code;
42-
unsigned char *ipe = (unsigned char *)insn;
43+
unsigned char *ipe = (unsigned char *)expected;
44+
unsigned char *ipn = (unsigned char *)new;
4345

4446
pr_emerg("Jump label code mismatch at %pS [%p]\n", ipc, ipc);
4547
pr_emerg("Found: %02x %02x %02x %02x %02x %02x\n",
4648
ipc[0], ipc[1], ipc[2], ipc[3], ipc[4], ipc[5]);
4749
pr_emerg("Expected: %02x %02x %02x %02x %02x %02x\n",
4850
ipe[0], ipe[1], ipe[2], ipe[3], ipe[4], ipe[5]);
51+
pr_emerg("New: %02x %02x %02x %02x %02x %02x\n",
52+
ipn[0], ipn[1], ipn[2], ipn[3], ipn[4], ipn[5]);
4953
panic("Corrupted kernel text");
5054
}
5155

@@ -69,10 +73,10 @@ static void __jump_label_transform(struct jump_entry *entry,
6973
}
7074
if (init) {
7175
if (memcmp((void *)entry->code, &orignop, sizeof(orignop)))
72-
jump_label_bug(entry, &old);
76+
jump_label_bug(entry, &orignop, &new);
7377
} else {
7478
if (memcmp((void *)entry->code, &old, sizeof(old)))
75-
jump_label_bug(entry, &old);
79+
jump_label_bug(entry, &old, &new);
7680
}
7781
probe_kernel_write((void *)entry->code, &new, sizeof(new));
7882
}

arch/s390/kernel/module.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,7 @@ int module_finalize(const Elf_Ehdr *hdr,
436436
const Elf_Shdr *sechdrs,
437437
struct module *me)
438438
{
439+
jump_label_apply_nops(me);
439440
vfree(me->arch.syminfo);
440441
me->arch.syminfo = NULL;
441442
return 0;

arch/s390/kernel/processor.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
static DEFINE_PER_CPU(struct cpuid, cpu_id);
2020

21-
void cpu_relax(void)
21+
void notrace cpu_relax(void)
2222
{
2323
if (!smp_cpu_mtid && MACHINE_HAS_DIAG44)
2424
asm volatile("diag 0,0,0x44");

arch/s390/pci/pci.c

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ void __iomem *pci_iomap_range(struct pci_dev *pdev,
287287
addr = ZPCI_IOMAP_ADDR_BASE | ((u64) idx << 48);
288288
return (void __iomem *) addr + offset;
289289
}
290-
EXPORT_SYMBOL_GPL(pci_iomap_range);
290+
EXPORT_SYMBOL(pci_iomap_range);
291291

292292
void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long maxlen)
293293
{
@@ -309,7 +309,7 @@ void pci_iounmap(struct pci_dev *pdev, void __iomem *addr)
309309
}
310310
spin_unlock(&zpci_iomap_lock);
311311
}
312-
EXPORT_SYMBOL_GPL(pci_iounmap);
312+
EXPORT_SYMBOL(pci_iounmap);
313313

314314
static int pci_read(struct pci_bus *bus, unsigned int devfn, int where,
315315
int size, u32 *val)
@@ -483,9 +483,8 @@ void arch_teardown_msi_irqs(struct pci_dev *pdev)
483483
airq_iv_free_bit(zpci_aisb_iv, zdev->aisb);
484484
}
485485

486-
static void zpci_map_resources(struct zpci_dev *zdev)
486+
static void zpci_map_resources(struct pci_dev *pdev)
487487
{
488-
struct pci_dev *pdev = zdev->pdev;
489488
resource_size_t len;
490489
int i;
491490

@@ -499,9 +498,8 @@ static void zpci_map_resources(struct zpci_dev *zdev)
499498
}
500499
}
501500

502-
static void zpci_unmap_resources(struct zpci_dev *zdev)
501+
static void zpci_unmap_resources(struct pci_dev *pdev)
503502
{
504-
struct pci_dev *pdev = zdev->pdev;
505503
resource_size_t len;
506504
int i;
507505

@@ -651,7 +649,7 @@ int pcibios_add_device(struct pci_dev *pdev)
651649

652650
zdev->pdev = pdev;
653651
pdev->dev.groups = zpci_attr_groups;
654-
zpci_map_resources(zdev);
652+
zpci_map_resources(pdev);
655653

656654
for (i = 0; i < PCI_BAR_COUNT; i++) {
657655
res = &pdev->resource[i];
@@ -663,14 +661,18 @@ int pcibios_add_device(struct pci_dev *pdev)
663661
return 0;
664662
}
665663

664+
void pcibios_release_device(struct pci_dev *pdev)
665+
{
666+
zpci_unmap_resources(pdev);
667+
}
668+
666669
int pcibios_enable_device(struct pci_dev *pdev, int mask)
667670
{
668671
struct zpci_dev *zdev = get_zdev(pdev);
669672

670673
zdev->pdev = pdev;
671674
zpci_debug_init_device(zdev);
672675
zpci_fmb_enable_device(zdev);
673-
zpci_map_resources(zdev);
674676

675677
return pci_enable_resources(pdev, mask);
676678
}
@@ -679,7 +681,6 @@ void pcibios_disable_device(struct pci_dev *pdev)
679681
{
680682
struct zpci_dev *zdev = get_zdev(pdev);
681683

682-
zpci_unmap_resources(zdev);
683684
zpci_fmb_disable_device(zdev);
684685
zpci_debug_exit_device(zdev);
685686
zdev->pdev = NULL;
@@ -688,7 +689,8 @@ void pcibios_disable_device(struct pci_dev *pdev)
688689
#ifdef CONFIG_HIBERNATE_CALLBACKS
689690
static int zpci_restore(struct device *dev)
690691
{
691-
struct zpci_dev *zdev = get_zdev(to_pci_dev(dev));
692+
struct pci_dev *pdev = to_pci_dev(dev);
693+
struct zpci_dev *zdev = get_zdev(pdev);
692694
int ret = 0;
693695

694696
if (zdev->state != ZPCI_FN_STATE_ONLINE)
@@ -698,7 +700,7 @@ static int zpci_restore(struct device *dev)
698700
if (ret)
699701
goto out;
700702

701-
zpci_map_resources(zdev);
703+
zpci_map_resources(pdev);
702704
zpci_register_ioat(zdev, 0, zdev->start_dma + PAGE_OFFSET,
703705
zdev->start_dma + zdev->iommu_size - 1,
704706
(u64) zdev->dma_table);
@@ -709,12 +711,14 @@ static int zpci_restore(struct device *dev)
709711

710712
static int zpci_freeze(struct device *dev)
711713
{
712-
struct zpci_dev *zdev = get_zdev(to_pci_dev(dev));
714+
struct pci_dev *pdev = to_pci_dev(dev);
715+
struct zpci_dev *zdev = get_zdev(pdev);
713716

714717
if (zdev->state != ZPCI_FN_STATE_ONLINE)
715718
return 0;
716719

717720
zpci_unregister_ioat(zdev, 0);
721+
zpci_unmap_resources(pdev);
718722
return clp_disable_fh(zdev);
719723
}
720724

arch/s390/pci/pci_mmio.c

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,7 @@ SYSCALL_DEFINE3(s390_pci_mmio_write, unsigned long, mmio_addr,
6464
if (copy_from_user(buf, user_buffer, length))
6565
goto out;
6666

67-
memcpy_toio(io_addr, buf, length);
68-
ret = 0;
67+
ret = zpci_memcpy_toio(io_addr, buf, length);
6968
out:
7069
if (buf != local_buf)
7170
kfree(buf);
@@ -98,16 +97,16 @@ SYSCALL_DEFINE3(s390_pci_mmio_read, unsigned long, mmio_addr,
9897
goto out;
9998
io_addr = (void __iomem *)((pfn << PAGE_SHIFT) | (mmio_addr & ~PAGE_MASK));
10099

101-
ret = -EFAULT;
102-
if ((unsigned long) io_addr < ZPCI_IOMAP_ADDR_BASE)
100+
if ((unsigned long) io_addr < ZPCI_IOMAP_ADDR_BASE) {
101+
ret = -EFAULT;
103102
goto out;
104-
105-
memcpy_fromio(buf, io_addr, length);
106-
107-
if (copy_to_user(user_buffer, buf, length))
103+
}
104+
ret = zpci_memcpy_fromio(buf, io_addr, length);
105+
if (ret)
108106
goto out;
107+
if (copy_to_user(user_buffer, buf, length))
108+
ret = -EFAULT;
109109

110-
ret = 0;
111110
out:
112111
if (buf != local_buf)
113112
kfree(buf);

drivers/s390/block/dcssblk.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,7 @@ dcssblk_add_store(struct device *dev, struct device_attribute *attr, const char
547547
* parse input
548548
*/
549549
num_of_segments = 0;
550-
for (i = 0; ((buf[i] != '\0') && (buf[i] != '\n') && i < count); i++) {
550+
for (i = 0; (i < count && (buf[i] != '\0') && (buf[i] != '\n')); i++) {
551551
for (j = i; (buf[j] != ':') &&
552552
(buf[j] != '\0') &&
553553
(buf[j] != '\n') &&

drivers/s390/block/scm_blk_cluster.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ bool scm_reserve_cluster(struct scm_request *scmrq)
9292
add = 0;
9393
continue;
9494
}
95-
for (pos = 0; pos <= iter->aob->request.msb_count; pos++) {
95+
for (pos = 0; pos < iter->aob->request.msb_count; pos++) {
9696
if (clusters_intersect(req, iter->request[pos]) &&
9797
(rq_data_dir(req) == WRITE ||
9898
rq_data_dir(iter->request[pos]) == WRITE)) {

0 commit comments

Comments
 (0)