Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux

Pull s390 updates from Martin Schwidefsky:

- Add the CPU id for the new z13s machine

- Add a s390 specific XOR template for RAID-5 checksumming based on the
XC instruction. Remove all other alternatives, XC is always faster

- The merge of our four different stack tracers into a single one

- Tidy up the code related to page tables, several large inline
functions are now out-of-line. Bloat-o-meter reports ~11K text size
reduction

- A binary interface for the priviledged CLP instruction to retrieve
the hardware view of the installed PCI functions

- Improvements for the dasd format code

- Bug fixes and cleanups

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux: (31 commits)
s390/pci: enforce fmb page boundary rule
s390: fix floating pointer register corruption (again)
s390/cpumf: add missing lpp magic initialization
s390: Fix misspellings in comments
s390/mm: split arch/s390/mm/pgtable.c
s390/mm: uninline pmdp_xxx functions from pgtable.h
s390/mm: uninline ptep_xxx functions from pgtable.h
s390/pci: add ioctl interface for CLP
s390: Use pr_warn instead of pr_warning
s390/dasd: remove casts to dasd_*_private
s390/dasd: Refactor dasd format functions
s390/dasd: Simplify code in format logic
s390/dasd: Improve dasd format code
s390/percpu: remove this_cpu_cmpxchg_double_4
s390/cpumf: Improve guest detection heuristics
s390/fault: merge report_user_fault implementations
s390/dis: use correct escape sequence for '%' character
s390/kvm: simplify set_guest_storage_key
s390/oprofile: add z13/z13s model numbers
s390: add z13s model number to z13 elf platform
...

+2882 -2714
+4 -4
arch/s390/Kconfig
··· 254 254 older machines. 255 255 256 256 config MARCH_Z13 257 - bool "IBM z13" 257 + bool "IBM z13s and z13" 258 258 select HAVE_MARCH_Z13_FEATURES 259 259 help 260 - Select this to enable optimizations for IBM z13 (2964 series). 261 - The kernel will be slightly faster but will not work on older 262 - machines. 260 + Select this to enable optimizations for IBM z13s and z13 (2965 and 261 + 2964 series). The kernel will be slightly faster but will not work on 262 + older machines. 263 263 264 264 endchoice 265 265
+27
arch/s390/include/asm/clp.h
··· 4 4 /* CLP common request & response block size */ 5 5 #define CLP_BLK_SIZE PAGE_SIZE 6 6 7 + #define CLP_LPS_BASE 0 8 + #define CLP_LPS_PCI 2 9 + 7 10 struct clp_req_hdr { 8 11 u16 len; 9 12 u16 cmd; 13 + u32 fmt : 4; 14 + u32 reserved1 : 28; 15 + u64 reserved2; 10 16 } __packed; 11 17 12 18 struct clp_rsp_hdr { 13 19 u16 len; 14 20 u16 rsp; 21 + u32 fmt : 4; 22 + u32 reserved1 : 28; 23 + u64 reserved2; 15 24 } __packed; 16 25 17 26 /* CLP Response Codes */ ··· 33 24 #define CLP_RC_RESNOT0 0x0070 /* Reserved field not zero */ 34 25 #define CLP_RC_NODATA 0x0080 /* No data available */ 35 26 #define CLP_RC_FC_UNKNOWN 0x0100 /* Function code not recognized */ 27 + 28 + /* Store logical-processor characteristics request */ 29 + struct clp_req_slpc { 30 + struct clp_req_hdr hdr; 31 + } __packed; 32 + 33 + struct clp_rsp_slpc { 34 + struct clp_rsp_hdr hdr; 35 + u32 reserved2[4]; 36 + u32 lpif[8]; 37 + u32 reserved3[8]; 38 + u32 lpic[8]; 39 + } __packed; 40 + 41 + struct clp_req_rsp_slpc { 42 + struct clp_req_slpc request; 43 + struct clp_rsp_slpc response; 44 + } __packed; 36 45 37 46 #endif
+64
arch/s390/include/asm/gmap.h
··· 1 + /* 2 + * KVM guest address space mapping code 3 + * 4 + * Copyright IBM Corp. 2007, 2016 5 + * Author(s): Martin Schwidefsky <schwidefsky@de.ibm.com> 6 + */ 7 + 8 + #ifndef _ASM_S390_GMAP_H 9 + #define _ASM_S390_GMAP_H 10 + 11 + /** 12 + * struct gmap_struct - guest address space 13 + * @crst_list: list of all crst tables used in the guest address space 14 + * @mm: pointer to the parent mm_struct 15 + * @guest_to_host: radix tree with guest to host address translation 16 + * @host_to_guest: radix tree with pointer to segment table entries 17 + * @guest_table_lock: spinlock to protect all entries in the guest page table 18 + * @table: pointer to the page directory 19 + * @asce: address space control element for gmap page table 20 + * @pfault_enabled: defines if pfaults are applicable for the guest 21 + */ 22 + struct gmap { 23 + struct list_head list; 24 + struct list_head crst_list; 25 + struct mm_struct *mm; 26 + struct radix_tree_root guest_to_host; 27 + struct radix_tree_root host_to_guest; 28 + spinlock_t guest_table_lock; 29 + unsigned long *table; 30 + unsigned long asce; 31 + unsigned long asce_end; 32 + void *private; 33 + bool pfault_enabled; 34 + }; 35 + 36 + /** 37 + * struct gmap_notifier - notify function block for page invalidation 38 + * @notifier_call: address of callback function 39 + */ 40 + struct gmap_notifier { 41 + struct list_head list; 42 + void (*notifier_call)(struct gmap *gmap, unsigned long gaddr); 43 + }; 44 + 45 + struct gmap *gmap_alloc(struct mm_struct *mm, unsigned long limit); 46 + void gmap_free(struct gmap *gmap); 47 + void gmap_enable(struct gmap *gmap); 48 + void gmap_disable(struct gmap *gmap); 49 + int gmap_map_segment(struct gmap *gmap, unsigned long from, 50 + unsigned long to, unsigned long len); 51 + int gmap_unmap_segment(struct gmap *gmap, unsigned long to, unsigned long len); 52 + unsigned long __gmap_translate(struct gmap *, unsigned long gaddr); 53 + unsigned long gmap_translate(struct gmap *, unsigned long gaddr); 54 + int __gmap_link(struct gmap *gmap, unsigned long gaddr, unsigned long vmaddr); 55 + int gmap_fault(struct gmap *, unsigned long gaddr, unsigned int fault_flags); 56 + void gmap_discard(struct gmap *, unsigned long from, unsigned long to); 57 + void __gmap_zap(struct gmap *, unsigned long gaddr); 58 + void gmap_unlink(struct mm_struct *, unsigned long *table, unsigned long vmaddr); 59 + 60 + void gmap_register_ipte_notifier(struct gmap_notifier *); 61 + void gmap_unregister_ipte_notifier(struct gmap_notifier *); 62 + int gmap_ipte_notify(struct gmap *, unsigned long start, unsigned long len); 63 + 64 + #endif /* _ASM_S390_GMAP_H */
+2 -3
arch/s390/include/asm/pci.h
··· 45 45 u64 rpcit_ops; 46 46 u64 dma_rbytes; 47 47 u64 dma_wbytes; 48 - } __packed __aligned(16); 48 + } __packed __aligned(64); 49 49 50 50 enum zpci_state { 51 51 ZPCI_FN_STATE_RESERVED, ··· 66 66 67 67 /* Private data per function */ 68 68 struct zpci_dev { 69 - struct pci_dev *pdev; 70 69 struct pci_bus *bus; 71 70 struct list_head entry; /* list of all zpci_devices, needed for hotplug, etc. */ 72 71 ··· 191 192 /* Debug */ 192 193 int zpci_debug_init(void); 193 194 void zpci_debug_exit(void); 194 - void zpci_debug_init_device(struct zpci_dev *); 195 + void zpci_debug_init_device(struct zpci_dev *, const char *); 195 196 void zpci_debug_exit_device(struct zpci_dev *); 196 197 void zpci_debug_info(struct zpci_dev *, struct seq_file *); 197 198
+3 -27
arch/s390/include/asm/pci_clp.h
··· 49 49 /* List PCI functions request */ 50 50 struct clp_req_list_pci { 51 51 struct clp_req_hdr hdr; 52 - u32 fmt : 4; /* cmd request block format */ 53 - u32 : 28; 54 - u64 reserved1; 55 52 u64 resume_token; 56 53 u64 reserved2; 57 54 } __packed; ··· 56 59 /* List PCI functions response */ 57 60 struct clp_rsp_list_pci { 58 61 struct clp_rsp_hdr hdr; 59 - u32 fmt : 4; /* cmd request block format */ 60 - u32 : 28; 61 - u64 reserved1; 62 62 u64 resume_token; 63 63 u32 reserved2; 64 64 u16 max_fn; ··· 67 73 /* Query PCI function request */ 68 74 struct clp_req_query_pci { 69 75 struct clp_req_hdr hdr; 70 - u32 fmt : 4; /* cmd request block format */ 71 - u32 : 28; 72 - u64 reserved1; 73 76 u32 fh; /* function handle */ 74 77 u32 reserved2; 75 78 u64 reserved3; ··· 75 84 /* Query PCI function response */ 76 85 struct clp_rsp_query_pci { 77 86 struct clp_rsp_hdr hdr; 78 - u32 fmt : 4; /* cmd request block format */ 79 - u32 : 28; 80 - u64 : 64; 81 87 u16 vfn; /* virtual fn number */ 82 88 u16 : 7; 83 89 u16 util_str_avail : 1; /* utility string available? */ ··· 96 108 /* Query PCI function group request */ 97 109 struct clp_req_query_pci_grp { 98 110 struct clp_req_hdr hdr; 99 - u32 fmt : 4; /* cmd request block format */ 100 - u32 : 28; 101 - u64 reserved1; 102 - u32 : 24; 111 + u32 reserved2 : 24; 103 112 u32 pfgid : 8; /* function group id */ 104 - u32 reserved2; 105 - u64 reserved3; 113 + u32 reserved3; 114 + u64 reserved4; 106 115 } __packed; 107 116 108 117 /* Query PCI function group response */ 109 118 struct clp_rsp_query_pci_grp { 110 119 struct clp_rsp_hdr hdr; 111 - u32 fmt : 4; /* cmd request block format */ 112 - u32 : 28; 113 - u64 reserved1; 114 120 u16 : 4; 115 121 u16 noi : 12; /* number of interrupts */ 116 122 u8 version; ··· 123 141 /* Set PCI function request */ 124 142 struct clp_req_set_pci { 125 143 struct clp_req_hdr hdr; 126 - u32 fmt : 4; /* cmd request block format */ 127 - u32 : 28; 128 - u64 reserved1; 129 144 u32 fh; /* function handle */ 130 145 u16 reserved2; 131 146 u8 oc; /* operation controls */ ··· 133 154 /* Set PCI function response */ 134 155 struct clp_rsp_set_pci { 135 156 struct clp_rsp_hdr hdr; 136 - u32 fmt : 4; /* cmd request block format */ 137 - u32 : 28; 138 - u64 reserved1; 139 157 u32 fh; /* function handle */ 140 158 u32 reserved3; 141 159 u64 reserved4;
-1
arch/s390/include/asm/percpu.h
··· 178 178 ret__; \ 179 179 }) 180 180 181 - #define this_cpu_cmpxchg_double_4 arch_this_cpu_cmpxchg_double 182 181 #define this_cpu_cmpxchg_double_8 arch_this_cpu_cmpxchg_double 183 182 184 183 #include <asm-generic/percpu.h>
+1 -1
arch/s390/include/asm/perf_event.h
··· 21 21 #define PMU_F_ERR_LSDA 0x0200 22 22 #define PMU_F_ERR_MASK (PMU_F_ERR_IBE|PMU_F_ERR_LSDA) 23 23 24 - /* Perf defintions for PMU event attributes in sysfs */ 24 + /* Perf definitions for PMU event attributes in sysfs */ 25 25 extern __init const struct attribute_group **cpumf_cf_event_group(void); 26 26 extern ssize_t cpumf_events_sysfs_show(struct device *dev, 27 27 struct device_attribute *attr,
-4
arch/s390/include/asm/pgalloc.h
··· 23 23 void page_table_free_rcu(struct mmu_gather *, unsigned long *, unsigned long); 24 24 extern int page_table_allocate_pgste; 25 25 26 - int set_guest_storage_key(struct mm_struct *mm, unsigned long addr, 27 - unsigned long key, bool nq); 28 - unsigned long get_guest_storage_key(struct mm_struct *mm, unsigned long addr); 29 - 30 26 static inline void clear_table(unsigned long *s, unsigned long val, size_t n) 31 27 { 32 28 typedef struct { char _[n]; } addrtype;
+129 -523
arch/s390/include/asm/pgtable.h
··· 298 298 299 299 /* 300 300 * Segment table entry encoding (R = read-only, I = invalid, y = young bit): 301 - * dy..R...I...wr 301 + * dy..R...I...rw 302 302 * prot-none, clean, old 00..1...1...00 303 303 * prot-none, clean, young 01..1...1...00 304 304 * prot-none, dirty, old 10..1...1...00 305 305 * prot-none, dirty, young 11..1...1...00 306 - * read-only, clean, old 00..1...1...01 307 - * read-only, clean, young 01..1...0...01 308 - * read-only, dirty, old 10..1...1...01 309 - * read-only, dirty, young 11..1...0...01 306 + * read-only, clean, old 00..1...1...10 307 + * read-only, clean, young 01..1...0...10 308 + * read-only, dirty, old 10..1...1...10 309 + * read-only, dirty, young 11..1...0...10 310 310 * read-write, clean, old 00..1...1...11 311 311 * read-write, clean, young 01..1...0...11 312 312 * read-write, dirty, old 10..0...1...11 ··· 520 520 return (pmd_val(pmd) & ~_SEGMENT_ENTRY_BITS) != 0; 521 521 } 522 522 523 - #define __HAVE_ARCH_PMDP_SET_ACCESS_FLAGS 524 - extern int pmdp_set_access_flags(struct vm_area_struct *vma, 525 - unsigned long address, pmd_t *pmdp, 526 - pmd_t entry, int dirty); 527 - 528 - #define __HAVE_ARCH_PMDP_CLEAR_YOUNG_FLUSH 529 - extern int pmdp_clear_flush_young(struct vm_area_struct *vma, 530 - unsigned long address, pmd_t *pmdp); 531 - 532 523 #define __HAVE_ARCH_PMD_WRITE 533 524 static inline int pmd_write(pmd_t pmd) 534 525 { ··· 620 629 { 621 630 pmd_val(pmd) &= ~_SEGMENT_ENTRY_SOFT_DIRTY; 622 631 return pmd; 623 - } 624 - 625 - static inline pgste_t pgste_get_lock(pte_t *ptep) 626 - { 627 - unsigned long new = 0; 628 - #ifdef CONFIG_PGSTE 629 - unsigned long old; 630 - 631 - preempt_disable(); 632 - asm( 633 - " lg %0,%2\n" 634 - "0: lgr %1,%0\n" 635 - " nihh %0,0xff7f\n" /* clear PCL bit in old */ 636 - " oihh %1,0x0080\n" /* set PCL bit in new */ 637 - " csg %0,%1,%2\n" 638 - " jl 0b\n" 639 - : "=&d" (old), "=&d" (new), "=Q" (ptep[PTRS_PER_PTE]) 640 - : "Q" (ptep[PTRS_PER_PTE]) : "cc", "memory"); 641 - #endif 642 - return __pgste(new); 643 - } 644 - 645 - static inline void pgste_set_unlock(pte_t *ptep, pgste_t pgste) 646 - { 647 - #ifdef CONFIG_PGSTE 648 - asm( 649 - " nihh %1,0xff7f\n" /* clear PCL bit */ 650 - " stg %1,%0\n" 651 - : "=Q" (ptep[PTRS_PER_PTE]) 652 - : "d" (pgste_val(pgste)), "Q" (ptep[PTRS_PER_PTE]) 653 - : "cc", "memory"); 654 - preempt_enable(); 655 - #endif 656 - } 657 - 658 - static inline pgste_t pgste_get(pte_t *ptep) 659 - { 660 - unsigned long pgste = 0; 661 - #ifdef CONFIG_PGSTE 662 - pgste = *(unsigned long *)(ptep + PTRS_PER_PTE); 663 - #endif 664 - return __pgste(pgste); 665 - } 666 - 667 - static inline void pgste_set(pte_t *ptep, pgste_t pgste) 668 - { 669 - #ifdef CONFIG_PGSTE 670 - *(pgste_t *)(ptep + PTRS_PER_PTE) = pgste; 671 - #endif 672 - } 673 - 674 - static inline pgste_t pgste_update_all(pte_t *ptep, pgste_t pgste, 675 - struct mm_struct *mm) 676 - { 677 - #ifdef CONFIG_PGSTE 678 - unsigned long address, bits, skey; 679 - 680 - if (!mm_use_skey(mm) || pte_val(*ptep) & _PAGE_INVALID) 681 - return pgste; 682 - address = pte_val(*ptep) & PAGE_MASK; 683 - skey = (unsigned long) page_get_storage_key(address); 684 - bits = skey & (_PAGE_CHANGED | _PAGE_REFERENCED); 685 - /* Transfer page changed & referenced bit to guest bits in pgste */ 686 - pgste_val(pgste) |= bits << 48; /* GR bit & GC bit */ 687 - /* Copy page access key and fetch protection bit to pgste */ 688 - pgste_val(pgste) &= ~(PGSTE_ACC_BITS | PGSTE_FP_BIT); 689 - pgste_val(pgste) |= (skey & (_PAGE_ACC_BITS | _PAGE_FP_BIT)) << 56; 690 - #endif 691 - return pgste; 692 - 693 - } 694 - 695 - static inline void pgste_set_key(pte_t *ptep, pgste_t pgste, pte_t entry, 696 - struct mm_struct *mm) 697 - { 698 - #ifdef CONFIG_PGSTE 699 - unsigned long address; 700 - unsigned long nkey; 701 - 702 - if (!mm_use_skey(mm) || pte_val(entry) & _PAGE_INVALID) 703 - return; 704 - VM_BUG_ON(!(pte_val(*ptep) & _PAGE_INVALID)); 705 - address = pte_val(entry) & PAGE_MASK; 706 - /* 707 - * Set page access key and fetch protection bit from pgste. 708 - * The guest C/R information is still in the PGSTE, set real 709 - * key C/R to 0. 710 - */ 711 - nkey = (pgste_val(pgste) & (PGSTE_ACC_BITS | PGSTE_FP_BIT)) >> 56; 712 - nkey |= (pgste_val(pgste) & (PGSTE_GR_BIT | PGSTE_GC_BIT)) >> 48; 713 - page_set_storage_key(address, nkey, 0); 714 - #endif 715 - } 716 - 717 - static inline pgste_t pgste_set_pte(pte_t *ptep, pgste_t pgste, pte_t entry) 718 - { 719 - if ((pte_val(entry) & _PAGE_PRESENT) && 720 - (pte_val(entry) & _PAGE_WRITE) && 721 - !(pte_val(entry) & _PAGE_INVALID)) { 722 - if (!MACHINE_HAS_ESOP) { 723 - /* 724 - * Without enhanced suppression-on-protection force 725 - * the dirty bit on for all writable ptes. 726 - */ 727 - pte_val(entry) |= _PAGE_DIRTY; 728 - pte_val(entry) &= ~_PAGE_PROTECT; 729 - } 730 - if (!(pte_val(entry) & _PAGE_PROTECT)) 731 - /* This pte allows write access, set user-dirty */ 732 - pgste_val(pgste) |= PGSTE_UC_BIT; 733 - } 734 - *ptep = entry; 735 - return pgste; 736 - } 737 - 738 - /** 739 - * struct gmap_struct - guest address space 740 - * @crst_list: list of all crst tables used in the guest address space 741 - * @mm: pointer to the parent mm_struct 742 - * @guest_to_host: radix tree with guest to host address translation 743 - * @host_to_guest: radix tree with pointer to segment table entries 744 - * @guest_table_lock: spinlock to protect all entries in the guest page table 745 - * @table: pointer to the page directory 746 - * @asce: address space control element for gmap page table 747 - * @pfault_enabled: defines if pfaults are applicable for the guest 748 - */ 749 - struct gmap { 750 - struct list_head list; 751 - struct list_head crst_list; 752 - struct mm_struct *mm; 753 - struct radix_tree_root guest_to_host; 754 - struct radix_tree_root host_to_guest; 755 - spinlock_t guest_table_lock; 756 - unsigned long *table; 757 - unsigned long asce; 758 - unsigned long asce_end; 759 - void *private; 760 - bool pfault_enabled; 761 - }; 762 - 763 - /** 764 - * struct gmap_notifier - notify function block for page invalidation 765 - * @notifier_call: address of callback function 766 - */ 767 - struct gmap_notifier { 768 - struct list_head list; 769 - void (*notifier_call)(struct gmap *gmap, unsigned long gaddr); 770 - }; 771 - 772 - struct gmap *gmap_alloc(struct mm_struct *mm, unsigned long limit); 773 - void gmap_free(struct gmap *gmap); 774 - void gmap_enable(struct gmap *gmap); 775 - void gmap_disable(struct gmap *gmap); 776 - int gmap_map_segment(struct gmap *gmap, unsigned long from, 777 - unsigned long to, unsigned long len); 778 - int gmap_unmap_segment(struct gmap *gmap, unsigned long to, unsigned long len); 779 - unsigned long __gmap_translate(struct gmap *, unsigned long gaddr); 780 - unsigned long gmap_translate(struct gmap *, unsigned long gaddr); 781 - int __gmap_link(struct gmap *gmap, unsigned long gaddr, unsigned long vmaddr); 782 - int gmap_fault(struct gmap *, unsigned long gaddr, unsigned int fault_flags); 783 - void gmap_discard(struct gmap *, unsigned long from, unsigned long to); 784 - void __gmap_zap(struct gmap *, unsigned long gaddr); 785 - bool gmap_test_and_clear_dirty(unsigned long address, struct gmap *); 786 - 787 - 788 - void gmap_register_ipte_notifier(struct gmap_notifier *); 789 - void gmap_unregister_ipte_notifier(struct gmap_notifier *); 790 - int gmap_ipte_notify(struct gmap *, unsigned long start, unsigned long len); 791 - void gmap_do_ipte_notify(struct mm_struct *, unsigned long addr, pte_t *); 792 - 793 - static inline pgste_t pgste_ipte_notify(struct mm_struct *mm, 794 - unsigned long addr, 795 - pte_t *ptep, pgste_t pgste) 796 - { 797 - #ifdef CONFIG_PGSTE 798 - if (pgste_val(pgste) & PGSTE_IN_BIT) { 799 - pgste_val(pgste) &= ~PGSTE_IN_BIT; 800 - gmap_do_ipte_notify(mm, addr, ptep); 801 - } 802 - #endif 803 - return pgste; 804 - } 805 - 806 - /* 807 - * Certain architectures need to do special things when PTEs 808 - * within a page table are directly modified. Thus, the following 809 - * hook is made available. 810 - */ 811 - static inline void set_pte_at(struct mm_struct *mm, unsigned long addr, 812 - pte_t *ptep, pte_t entry) 813 - { 814 - pgste_t pgste; 815 - 816 - if (mm_has_pgste(mm)) { 817 - pgste = pgste_get_lock(ptep); 818 - pgste_val(pgste) &= ~_PGSTE_GPS_ZERO; 819 - pgste_set_key(ptep, pgste, entry, mm); 820 - pgste = pgste_set_pte(ptep, pgste, entry); 821 - pgste_set_unlock(ptep, pgste); 822 - } else { 823 - *ptep = entry; 824 - } 825 632 } 826 633 827 634 /* ··· 787 998 } while (nr != 255); 788 999 } 789 1000 790 - static inline void ptep_flush_direct(struct mm_struct *mm, 791 - unsigned long address, pte_t *ptep) 792 - { 793 - int active, count; 794 - 795 - if (pte_val(*ptep) & _PAGE_INVALID) 796 - return; 797 - active = (mm == current->active_mm) ? 1 : 0; 798 - count = atomic_add_return(0x10000, &mm->context.attach_count); 799 - if (MACHINE_HAS_TLB_LC && (count & 0xffff) <= active && 800 - cpumask_equal(mm_cpumask(mm), cpumask_of(smp_processor_id()))) 801 - __ptep_ipte_local(address, ptep); 802 - else 803 - __ptep_ipte(address, ptep); 804 - atomic_sub(0x10000, &mm->context.attach_count); 805 - } 806 - 807 - static inline void ptep_flush_lazy(struct mm_struct *mm, 808 - unsigned long address, pte_t *ptep) 809 - { 810 - int active, count; 811 - 812 - if (pte_val(*ptep) & _PAGE_INVALID) 813 - return; 814 - active = (mm == current->active_mm) ? 1 : 0; 815 - count = atomic_add_return(0x10000, &mm->context.attach_count); 816 - if ((count & 0xffff) <= active) { 817 - pte_val(*ptep) |= _PAGE_INVALID; 818 - mm->context.flush_mm = 1; 819 - } else 820 - __ptep_ipte(address, ptep); 821 - atomic_sub(0x10000, &mm->context.attach_count); 822 - } 823 - 824 - /* 825 - * Get (and clear) the user dirty bit for a pte. 826 - */ 827 - static inline int ptep_test_and_clear_user_dirty(struct mm_struct *mm, 828 - unsigned long addr, 829 - pte_t *ptep) 830 - { 831 - pgste_t pgste; 832 - pte_t pte; 833 - int dirty; 834 - 835 - if (!mm_has_pgste(mm)) 836 - return 0; 837 - pgste = pgste_get_lock(ptep); 838 - dirty = !!(pgste_val(pgste) & PGSTE_UC_BIT); 839 - pgste_val(pgste) &= ~PGSTE_UC_BIT; 840 - pte = *ptep; 841 - if (dirty && (pte_val(pte) & _PAGE_PRESENT)) { 842 - pgste = pgste_ipte_notify(mm, addr, ptep, pgste); 843 - __ptep_ipte(addr, ptep); 844 - if (MACHINE_HAS_ESOP || !(pte_val(pte) & _PAGE_WRITE)) 845 - pte_val(pte) |= _PAGE_PROTECT; 846 - else 847 - pte_val(pte) |= _PAGE_INVALID; 848 - *ptep = pte; 849 - } 850 - pgste_set_unlock(ptep, pgste); 851 - return dirty; 852 - } 853 - 854 - #define __HAVE_ARCH_PTEP_TEST_AND_CLEAR_YOUNG 855 - static inline int ptep_test_and_clear_young(struct vm_area_struct *vma, 856 - unsigned long addr, pte_t *ptep) 857 - { 858 - pgste_t pgste; 859 - pte_t pte, oldpte; 860 - int young; 861 - 862 - if (mm_has_pgste(vma->vm_mm)) { 863 - pgste = pgste_get_lock(ptep); 864 - pgste = pgste_ipte_notify(vma->vm_mm, addr, ptep, pgste); 865 - } 866 - 867 - oldpte = pte = *ptep; 868 - ptep_flush_direct(vma->vm_mm, addr, ptep); 869 - young = pte_young(pte); 870 - pte = pte_mkold(pte); 871 - 872 - if (mm_has_pgste(vma->vm_mm)) { 873 - pgste = pgste_update_all(&oldpte, pgste, vma->vm_mm); 874 - pgste = pgste_set_pte(ptep, pgste, pte); 875 - pgste_set_unlock(ptep, pgste); 876 - } else 877 - *ptep = pte; 878 - 879 - return young; 880 - } 881 - 882 - #define __HAVE_ARCH_PTEP_CLEAR_YOUNG_FLUSH 883 - static inline int ptep_clear_flush_young(struct vm_area_struct *vma, 884 - unsigned long address, pte_t *ptep) 885 - { 886 - return ptep_test_and_clear_young(vma, address, ptep); 887 - } 888 - 889 1001 /* 890 1002 * This is hard to understand. ptep_get_and_clear and ptep_clear_flush 891 1003 * both clear the TLB for the unmapped pte. The reason is that ··· 800 1110 * have ptep_get_and_clear do the tlb flush. In exchange flush_tlb_range 801 1111 * is a nop. 802 1112 */ 1113 + pte_t ptep_xchg_direct(struct mm_struct *, unsigned long, pte_t *, pte_t); 1114 + pte_t ptep_xchg_lazy(struct mm_struct *, unsigned long, pte_t *, pte_t); 1115 + 1116 + #define __HAVE_ARCH_PTEP_TEST_AND_CLEAR_YOUNG 1117 + static inline int ptep_test_and_clear_young(struct vm_area_struct *vma, 1118 + unsigned long addr, pte_t *ptep) 1119 + { 1120 + pte_t pte = *ptep; 1121 + 1122 + pte = ptep_xchg_direct(vma->vm_mm, addr, ptep, pte_mkold(pte)); 1123 + return pte_young(pte); 1124 + } 1125 + 1126 + #define __HAVE_ARCH_PTEP_CLEAR_YOUNG_FLUSH 1127 + static inline int ptep_clear_flush_young(struct vm_area_struct *vma, 1128 + unsigned long address, pte_t *ptep) 1129 + { 1130 + return ptep_test_and_clear_young(vma, address, ptep); 1131 + } 1132 + 803 1133 #define __HAVE_ARCH_PTEP_GET_AND_CLEAR 804 1134 static inline pte_t ptep_get_and_clear(struct mm_struct *mm, 805 - unsigned long address, pte_t *ptep) 1135 + unsigned long addr, pte_t *ptep) 806 1136 { 807 - pgste_t pgste; 808 - pte_t pte; 809 - 810 - if (mm_has_pgste(mm)) { 811 - pgste = pgste_get_lock(ptep); 812 - pgste = pgste_ipte_notify(mm, address, ptep, pgste); 813 - } 814 - 815 - pte = *ptep; 816 - ptep_flush_lazy(mm, address, ptep); 817 - pte_val(*ptep) = _PAGE_INVALID; 818 - 819 - if (mm_has_pgste(mm)) { 820 - pgste = pgste_update_all(&pte, pgste, mm); 821 - pgste_set_unlock(ptep, pgste); 822 - } 823 - return pte; 1137 + return ptep_xchg_lazy(mm, addr, ptep, __pte(_PAGE_INVALID)); 824 1138 } 825 1139 826 1140 #define __HAVE_ARCH_PTEP_MODIFY_PROT_TRANSACTION 827 - static inline pte_t ptep_modify_prot_start(struct mm_struct *mm, 828 - unsigned long address, 829 - pte_t *ptep) 830 - { 831 - pgste_t pgste; 832 - pte_t pte; 833 - 834 - if (mm_has_pgste(mm)) { 835 - pgste = pgste_get_lock(ptep); 836 - pgste_ipte_notify(mm, address, ptep, pgste); 837 - } 838 - 839 - pte = *ptep; 840 - ptep_flush_lazy(mm, address, ptep); 841 - 842 - if (mm_has_pgste(mm)) { 843 - pgste = pgste_update_all(&pte, pgste, mm); 844 - pgste_set(ptep, pgste); 845 - } 846 - return pte; 847 - } 848 - 849 - static inline void ptep_modify_prot_commit(struct mm_struct *mm, 850 - unsigned long address, 851 - pte_t *ptep, pte_t pte) 852 - { 853 - pgste_t pgste; 854 - 855 - if (mm_has_pgste(mm)) { 856 - pgste = pgste_get(ptep); 857 - pgste_set_key(ptep, pgste, pte, mm); 858 - pgste = pgste_set_pte(ptep, pgste, pte); 859 - pgste_set_unlock(ptep, pgste); 860 - } else 861 - *ptep = pte; 862 - } 1141 + pte_t ptep_modify_prot_start(struct mm_struct *, unsigned long, pte_t *); 1142 + void ptep_modify_prot_commit(struct mm_struct *, unsigned long, pte_t *, pte_t); 863 1143 864 1144 #define __HAVE_ARCH_PTEP_CLEAR_FLUSH 865 1145 static inline pte_t ptep_clear_flush(struct vm_area_struct *vma, 866 - unsigned long address, pte_t *ptep) 1146 + unsigned long addr, pte_t *ptep) 867 1147 { 868 - pgste_t pgste; 869 - pte_t pte; 870 - 871 - if (mm_has_pgste(vma->vm_mm)) { 872 - pgste = pgste_get_lock(ptep); 873 - pgste = pgste_ipte_notify(vma->vm_mm, address, ptep, pgste); 874 - } 875 - 876 - pte = *ptep; 877 - ptep_flush_direct(vma->vm_mm, address, ptep); 878 - pte_val(*ptep) = _PAGE_INVALID; 879 - 880 - if (mm_has_pgste(vma->vm_mm)) { 881 - if ((pgste_val(pgste) & _PGSTE_GPS_USAGE_MASK) == 882 - _PGSTE_GPS_USAGE_UNUSED) 883 - pte_val(pte) |= _PAGE_UNUSED; 884 - pgste = pgste_update_all(&pte, pgste, vma->vm_mm); 885 - pgste_set_unlock(ptep, pgste); 886 - } 887 - return pte; 1148 + return ptep_xchg_direct(vma->vm_mm, addr, ptep, __pte(_PAGE_INVALID)); 888 1149 } 889 1150 890 1151 /* ··· 847 1206 */ 848 1207 #define __HAVE_ARCH_PTEP_GET_AND_CLEAR_FULL 849 1208 static inline pte_t ptep_get_and_clear_full(struct mm_struct *mm, 850 - unsigned long address, 1209 + unsigned long addr, 851 1210 pte_t *ptep, int full) 852 1211 { 853 - pgste_t pgste; 854 - pte_t pte; 855 - 856 - if (!full && mm_has_pgste(mm)) { 857 - pgste = pgste_get_lock(ptep); 858 - pgste = pgste_ipte_notify(mm, address, ptep, pgste); 1212 + if (full) { 1213 + pte_t pte = *ptep; 1214 + *ptep = __pte(_PAGE_INVALID); 1215 + return pte; 859 1216 } 860 - 861 - pte = *ptep; 862 - if (!full) 863 - ptep_flush_lazy(mm, address, ptep); 864 - pte_val(*ptep) = _PAGE_INVALID; 865 - 866 - if (!full && mm_has_pgste(mm)) { 867 - pgste = pgste_update_all(&pte, pgste, mm); 868 - pgste_set_unlock(ptep, pgste); 869 - } 870 - return pte; 1217 + return ptep_xchg_lazy(mm, addr, ptep, __pte(_PAGE_INVALID)); 871 1218 } 872 1219 873 1220 #define __HAVE_ARCH_PTEP_SET_WRPROTECT 874 - static inline pte_t ptep_set_wrprotect(struct mm_struct *mm, 875 - unsigned long address, pte_t *ptep) 1221 + static inline void ptep_set_wrprotect(struct mm_struct *mm, 1222 + unsigned long addr, pte_t *ptep) 876 1223 { 877 - pgste_t pgste; 878 1224 pte_t pte = *ptep; 879 1225 880 - if (pte_write(pte)) { 881 - if (mm_has_pgste(mm)) { 882 - pgste = pgste_get_lock(ptep); 883 - pgste = pgste_ipte_notify(mm, address, ptep, pgste); 884 - } 885 - 886 - ptep_flush_lazy(mm, address, ptep); 887 - pte = pte_wrprotect(pte); 888 - 889 - if (mm_has_pgste(mm)) { 890 - pgste = pgste_set_pte(ptep, pgste, pte); 891 - pgste_set_unlock(ptep, pgste); 892 - } else 893 - *ptep = pte; 894 - } 895 - return pte; 1226 + if (pte_write(pte)) 1227 + ptep_xchg_lazy(mm, addr, ptep, pte_wrprotect(pte)); 896 1228 } 897 1229 898 1230 #define __HAVE_ARCH_PTEP_SET_ACCESS_FLAGS 899 1231 static inline int ptep_set_access_flags(struct vm_area_struct *vma, 900 - unsigned long address, pte_t *ptep, 1232 + unsigned long addr, pte_t *ptep, 901 1233 pte_t entry, int dirty) 902 1234 { 903 - pgste_t pgste; 904 - pte_t oldpte; 905 - 906 - oldpte = *ptep; 907 - if (pte_same(oldpte, entry)) 1235 + if (pte_same(*ptep, entry)) 908 1236 return 0; 909 - if (mm_has_pgste(vma->vm_mm)) { 910 - pgste = pgste_get_lock(ptep); 911 - pgste = pgste_ipte_notify(vma->vm_mm, address, ptep, pgste); 912 - } 913 - 914 - ptep_flush_direct(vma->vm_mm, address, ptep); 915 - 916 - if (mm_has_pgste(vma->vm_mm)) { 917 - if (pte_val(oldpte) & _PAGE_INVALID) 918 - pgste_set_key(ptep, pgste, entry, vma->vm_mm); 919 - pgste = pgste_set_pte(ptep, pgste, entry); 920 - pgste_set_unlock(ptep, pgste); 921 - } else 922 - *ptep = entry; 1237 + ptep_xchg_direct(vma->vm_mm, addr, ptep, entry); 923 1238 return 1; 1239 + } 1240 + 1241 + /* 1242 + * Additional functions to handle KVM guest page tables 1243 + */ 1244 + void ptep_set_pte_at(struct mm_struct *mm, unsigned long addr, 1245 + pte_t *ptep, pte_t entry); 1246 + void ptep_set_notify(struct mm_struct *mm, unsigned long addr, pte_t *ptep); 1247 + void ptep_notify(struct mm_struct *mm, unsigned long addr, pte_t *ptep); 1248 + void ptep_zap_unused(struct mm_struct *mm, unsigned long addr, 1249 + pte_t *ptep , int reset); 1250 + void ptep_zap_key(struct mm_struct *mm, unsigned long addr, pte_t *ptep); 1251 + 1252 + bool test_and_clear_guest_dirty(struct mm_struct *mm, unsigned long address); 1253 + int set_guest_storage_key(struct mm_struct *mm, unsigned long addr, 1254 + unsigned char key, bool nq); 1255 + unsigned char get_guest_storage_key(struct mm_struct *mm, unsigned long addr); 1256 + 1257 + /* 1258 + * Certain architectures need to do special things when PTEs 1259 + * within a page table are directly modified. Thus, the following 1260 + * hook is made available. 1261 + */ 1262 + static inline void set_pte_at(struct mm_struct *mm, unsigned long addr, 1263 + pte_t *ptep, pte_t entry) 1264 + { 1265 + if (mm_has_pgste(mm)) 1266 + ptep_set_pte_at(mm, addr, ptep, entry); 1267 + else 1268 + *ptep = entry; 924 1269 } 925 1270 926 1271 /* ··· 1103 1476 : "cc" ); 1104 1477 } 1105 1478 1106 - static inline void pmdp_flush_direct(struct mm_struct *mm, 1107 - unsigned long address, pmd_t *pmdp) 1108 - { 1109 - int active, count; 1110 - 1111 - if (pmd_val(*pmdp) & _SEGMENT_ENTRY_INVALID) 1112 - return; 1113 - if (!MACHINE_HAS_IDTE) { 1114 - __pmdp_csp(pmdp); 1115 - return; 1116 - } 1117 - active = (mm == current->active_mm) ? 1 : 0; 1118 - count = atomic_add_return(0x10000, &mm->context.attach_count); 1119 - if (MACHINE_HAS_TLB_LC && (count & 0xffff) <= active && 1120 - cpumask_equal(mm_cpumask(mm), cpumask_of(smp_processor_id()))) 1121 - __pmdp_idte_local(address, pmdp); 1122 - else 1123 - __pmdp_idte(address, pmdp); 1124 - atomic_sub(0x10000, &mm->context.attach_count); 1125 - } 1126 - 1127 - static inline void pmdp_flush_lazy(struct mm_struct *mm, 1128 - unsigned long address, pmd_t *pmdp) 1129 - { 1130 - int active, count; 1131 - 1132 - if (pmd_val(*pmdp) & _SEGMENT_ENTRY_INVALID) 1133 - return; 1134 - active = (mm == current->active_mm) ? 1 : 0; 1135 - count = atomic_add_return(0x10000, &mm->context.attach_count); 1136 - if ((count & 0xffff) <= active) { 1137 - pmd_val(*pmdp) |= _SEGMENT_ENTRY_INVALID; 1138 - mm->context.flush_mm = 1; 1139 - } else if (MACHINE_HAS_IDTE) 1140 - __pmdp_idte(address, pmdp); 1141 - else 1142 - __pmdp_csp(pmdp); 1143 - atomic_sub(0x10000, &mm->context.attach_count); 1144 - } 1479 + pmd_t pmdp_xchg_direct(struct mm_struct *, unsigned long, pmd_t *, pmd_t); 1480 + pmd_t pmdp_xchg_lazy(struct mm_struct *, unsigned long, pmd_t *, pmd_t); 1145 1481 1146 1482 #ifdef CONFIG_TRANSPARENT_HUGEPAGE 1147 1483 1148 1484 #define __HAVE_ARCH_PGTABLE_DEPOSIT 1149 - extern void pgtable_trans_huge_deposit(struct mm_struct *mm, pmd_t *pmdp, 1150 - pgtable_t pgtable); 1485 + void pgtable_trans_huge_deposit(struct mm_struct *mm, pmd_t *pmdp, 1486 + pgtable_t pgtable); 1151 1487 1152 1488 #define __HAVE_ARCH_PGTABLE_WITHDRAW 1153 - extern pgtable_t pgtable_trans_huge_withdraw(struct mm_struct *mm, pmd_t *pmdp); 1489 + pgtable_t pgtable_trans_huge_withdraw(struct mm_struct *mm, pmd_t *pmdp); 1490 + 1491 + #define __HAVE_ARCH_PMDP_SET_ACCESS_FLAGS 1492 + static inline int pmdp_set_access_flags(struct vm_area_struct *vma, 1493 + unsigned long addr, pmd_t *pmdp, 1494 + pmd_t entry, int dirty) 1495 + { 1496 + VM_BUG_ON(addr & ~HPAGE_MASK); 1497 + 1498 + entry = pmd_mkyoung(entry); 1499 + if (dirty) 1500 + entry = pmd_mkdirty(entry); 1501 + if (pmd_val(*pmdp) == pmd_val(entry)) 1502 + return 0; 1503 + pmdp_xchg_direct(vma->vm_mm, addr, pmdp, entry); 1504 + return 1; 1505 + } 1506 + 1507 + #define __HAVE_ARCH_PMDP_TEST_AND_CLEAR_YOUNG 1508 + static inline int pmdp_test_and_clear_young(struct vm_area_struct *vma, 1509 + unsigned long addr, pmd_t *pmdp) 1510 + { 1511 + pmd_t pmd = *pmdp; 1512 + 1513 + pmd = pmdp_xchg_direct(vma->vm_mm, addr, pmdp, pmd_mkold(pmd)); 1514 + return pmd_young(pmd); 1515 + } 1516 + 1517 + #define __HAVE_ARCH_PMDP_CLEAR_YOUNG_FLUSH 1518 + static inline int pmdp_clear_flush_young(struct vm_area_struct *vma, 1519 + unsigned long addr, pmd_t *pmdp) 1520 + { 1521 + VM_BUG_ON(addr & ~HPAGE_MASK); 1522 + return pmdp_test_and_clear_young(vma, addr, pmdp); 1523 + } 1154 1524 1155 1525 static inline void set_pmd_at(struct mm_struct *mm, unsigned long addr, 1156 1526 pmd_t *pmdp, pmd_t entry) ··· 1163 1539 return pmd; 1164 1540 } 1165 1541 1166 - #define __HAVE_ARCH_PMDP_TEST_AND_CLEAR_YOUNG 1167 - static inline int pmdp_test_and_clear_young(struct vm_area_struct *vma, 1168 - unsigned long address, pmd_t *pmdp) 1169 - { 1170 - pmd_t pmd; 1171 - 1172 - pmd = *pmdp; 1173 - pmdp_flush_direct(vma->vm_mm, address, pmdp); 1174 - *pmdp = pmd_mkold(pmd); 1175 - return pmd_young(pmd); 1176 - } 1177 - 1178 1542 #define __HAVE_ARCH_PMDP_HUGE_GET_AND_CLEAR 1179 1543 static inline pmd_t pmdp_huge_get_and_clear(struct mm_struct *mm, 1180 - unsigned long address, pmd_t *pmdp) 1544 + unsigned long addr, pmd_t *pmdp) 1181 1545 { 1182 - pmd_t pmd = *pmdp; 1183 - 1184 - pmdp_flush_direct(mm, address, pmdp); 1185 - pmd_clear(pmdp); 1186 - return pmd; 1546 + return pmdp_xchg_direct(mm, addr, pmdp, __pmd(_SEGMENT_ENTRY_INVALID)); 1187 1547 } 1188 1548 1189 1549 #define __HAVE_ARCH_PMDP_HUGE_GET_AND_CLEAR_FULL 1190 1550 static inline pmd_t pmdp_huge_get_and_clear_full(struct mm_struct *mm, 1191 - unsigned long address, 1551 + unsigned long addr, 1192 1552 pmd_t *pmdp, int full) 1193 1553 { 1194 - pmd_t pmd = *pmdp; 1195 - 1196 - if (!full) 1197 - pmdp_flush_lazy(mm, address, pmdp); 1198 - pmd_clear(pmdp); 1199 - return pmd; 1554 + if (full) { 1555 + pmd_t pmd = *pmdp; 1556 + *pmdp = __pmd(_SEGMENT_ENTRY_INVALID); 1557 + return pmd; 1558 + } 1559 + return pmdp_xchg_lazy(mm, addr, pmdp, __pmd(_SEGMENT_ENTRY_INVALID)); 1200 1560 } 1201 1561 1202 1562 #define __HAVE_ARCH_PMDP_HUGE_CLEAR_FLUSH 1203 1563 static inline pmd_t pmdp_huge_clear_flush(struct vm_area_struct *vma, 1204 - unsigned long address, pmd_t *pmdp) 1564 + unsigned long addr, pmd_t *pmdp) 1205 1565 { 1206 - return pmdp_huge_get_and_clear(vma->vm_mm, address, pmdp); 1566 + return pmdp_huge_get_and_clear(vma->vm_mm, addr, pmdp); 1207 1567 } 1208 1568 1209 1569 #define __HAVE_ARCH_PMDP_INVALIDATE 1210 1570 static inline void pmdp_invalidate(struct vm_area_struct *vma, 1211 - unsigned long address, pmd_t *pmdp) 1571 + unsigned long addr, pmd_t *pmdp) 1212 1572 { 1213 - pmdp_flush_direct(vma->vm_mm, address, pmdp); 1573 + pmdp_xchg_direct(vma->vm_mm, addr, pmdp, __pmd(_SEGMENT_ENTRY_INVALID)); 1214 1574 } 1215 1575 1216 1576 #define __HAVE_ARCH_PMDP_SET_WRPROTECT 1217 1577 static inline void pmdp_set_wrprotect(struct mm_struct *mm, 1218 - unsigned long address, pmd_t *pmdp) 1578 + unsigned long addr, pmd_t *pmdp) 1219 1579 { 1220 1580 pmd_t pmd = *pmdp; 1221 1581 1222 - if (pmd_write(pmd)) { 1223 - pmdp_flush_direct(mm, address, pmdp); 1224 - set_pmd_at(mm, address, pmdp, pmd_wrprotect(pmd)); 1225 - } 1582 + if (pmd_write(pmd)) 1583 + pmd = pmdp_xchg_lazy(mm, addr, pmdp, pmd_wrprotect(pmd)); 1226 1584 } 1227 1585 1228 1586 static inline pmd_t pmdp_collapse_flush(struct vm_area_struct *vma,
+12
arch/s390/include/asm/processor.h
··· 184 184 struct mm_struct; 185 185 struct seq_file; 186 186 187 + typedef int (*dump_trace_func_t)(void *data, unsigned long address); 188 + void dump_trace(dump_trace_func_t func, void *data, 189 + struct task_struct *task, unsigned long sp); 190 + 187 191 void show_cacheinfo(struct seq_file *m); 188 192 189 193 /* Free all resources held by a thread. */ ··· 206 202 207 203 /* Has task runtime instrumentation enabled ? */ 208 204 #define is_ri_task(tsk) (!!(tsk)->thread.ri_cb) 205 + 206 + static inline unsigned long current_stack_pointer(void) 207 + { 208 + unsigned long sp; 209 + 210 + asm volatile("la %0,0(15)" : "=a" (sp)); 211 + return sp; 212 + } 209 213 210 214 static inline unsigned short stap(void) 211 215 {
+1 -1
arch/s390/include/asm/rwsem.h
··· 31 31 * This should be totally fair - if anything is waiting, a process that wants a 32 32 * lock will go to the back of the queue. When the currently active lock is 33 33 * released, if there's a writer at the front of the queue, then that and only 34 - * that will be woken up; if there's a bunch of consequtive readers at the 34 + * that will be woken up; if there's a bunch of consecutive readers at the 35 35 * front, then they'll all be woken up, but no other readers will be. 36 36 */ 37 37
+2
arch/s390/include/asm/setup.h
··· 101 101 #define pfault_fini() do { } while (0) 102 102 #endif /* CONFIG_PFAULT */ 103 103 104 + void report_user_fault(struct pt_regs *regs, long signr, int is_mm_fault); 105 + 104 106 extern void cmma_init(void); 105 107 106 108 extern void (*_machine_restart)(char *command);
+20 -1
arch/s390/include/asm/xor.h
··· 1 - #include <asm-generic/xor.h> 1 + /* 2 + * Optimited xor routines 3 + * 4 + * Copyright IBM Corp. 2016 5 + * Author(s): Martin Schwidefsky <schwidefsky@de.ibm.com> 6 + */ 7 + #ifndef _ASM_S390_XOR_H 8 + #define _ASM_S390_XOR_H 9 + 10 + extern struct xor_block_template xor_block_xc; 11 + 12 + #undef XOR_TRY_TEMPLATES 13 + #define XOR_TRY_TEMPLATES \ 14 + do { \ 15 + xor_speed(&xor_block_xc); \ 16 + } while (0) 17 + 18 + #define XOR_SELECT_TEMPLATE(FASTEST) (&xor_block_xc) 19 + 20 + #endif /* _ASM_S390_XOR_H */
+28
arch/s390/include/uapi/asm/clp.h
··· 1 + /* 2 + * ioctl interface for /dev/clp 3 + * 4 + * Copyright IBM Corp. 2016 5 + * Author(s): Martin Schwidefsky <schwidefsky@de.ibm.com> 6 + */ 7 + 8 + #ifndef _ASM_CLP_H 9 + #define _ASM_CLP_H 10 + 11 + #include <linux/types.h> 12 + #include <linux/ioctl.h> 13 + 14 + struct clp_req { 15 + unsigned int c : 1; 16 + unsigned int r : 1; 17 + unsigned int lps : 6; 18 + unsigned int cmd : 8; 19 + unsigned int : 16; 20 + unsigned int reserved; 21 + __u64 data_p; 22 + }; 23 + 24 + #define CLP_IOCTL_MAGIC 'c' 25 + 26 + #define CLP_SYNC _IOWR(CLP_IOCTL_MAGIC, 0xC1, struct clp_req) 27 + 28 + #endif
+1
arch/s390/kernel/asm-offsets.c
··· 12 12 #include <asm/idle.h> 13 13 #include <asm/vdso.h> 14 14 #include <asm/pgtable.h> 15 + #include <asm/gmap.h> 15 16 16 17 /* 17 18 * Make sure that the compiler is new enough. We want a compiler that
+1 -2
arch/s390/kernel/cpcmd.c
··· 96 96 (((unsigned long)response + rlen) >> 31)) { 97 97 lowbuf = kmalloc(rlen, GFP_KERNEL | GFP_DMA); 98 98 if (!lowbuf) { 99 - pr_warning("The cpcmd kernel function failed to " 100 - "allocate a response buffer\n"); 99 + pr_warn("The cpcmd kernel function failed to allocate a response buffer\n"); 101 100 return -ENOMEM; 102 101 } 103 102 spin_lock_irqsave(&cpcmd_lock, flags);
+2 -4
arch/s390/kernel/debug.c
··· 699 699 /* Since debugfs currently does not support uid/gid other than root, */ 700 700 /* we do not allow gid/uid != 0 until we get support for that. */ 701 701 if ((uid != 0) || (gid != 0)) 702 - pr_warning("Root becomes the owner of all s390dbf files " 703 - "in sysfs\n"); 702 + pr_warn("Root becomes the owner of all s390dbf files in sysfs\n"); 704 703 BUG_ON(!initialized); 705 704 mutex_lock(&debug_mutex); 706 705 ··· 1306 1307 new_level = debug_get_uint(str); 1307 1308 } 1308 1309 if(new_level < 0) { 1309 - pr_warning("%s is not a valid level for a debug " 1310 - "feature\n", str); 1310 + pr_warn("%s is not a valid level for a debug feature\n", str); 1311 1311 rc = -EINVAL; 1312 1312 } else { 1313 1313 debug_set_level(id, new_level);
+5 -12
arch/s390/kernel/dis.c
··· 1920 1920 } 1921 1921 if (separator) 1922 1922 ptr += sprintf(ptr, "%c", separator); 1923 - /* 1924 - * Use four '%' characters below because of the 1925 - * following two conversions: 1926 - * 1927 - * 1) sprintf: %%%%r -> %%r 1928 - * 2) printk : %%r -> %r 1929 - */ 1930 1923 if (operand->flags & OPERAND_GPR) 1931 - ptr += sprintf(ptr, "%%%%r%i", value); 1924 + ptr += sprintf(ptr, "%%r%i", value); 1932 1925 else if (operand->flags & OPERAND_FPR) 1933 - ptr += sprintf(ptr, "%%%%f%i", value); 1926 + ptr += sprintf(ptr, "%%f%i", value); 1934 1927 else if (operand->flags & OPERAND_AR) 1935 - ptr += sprintf(ptr, "%%%%a%i", value); 1928 + ptr += sprintf(ptr, "%%a%i", value); 1936 1929 else if (operand->flags & OPERAND_CR) 1937 - ptr += sprintf(ptr, "%%%%c%i", value); 1930 + ptr += sprintf(ptr, "%%c%i", value); 1938 1931 else if (operand->flags & OPERAND_VR) 1939 - ptr += sprintf(ptr, "%%%%v%i", value); 1932 + ptr += sprintf(ptr, "%%v%i", value); 1940 1933 else if (operand->flags & OPERAND_PCREL) 1941 1934 ptr += sprintf(ptr, "%lx", (signed int) value 1942 1935 + addr);
+49 -44
arch/s390/kernel/dumpstack.c
··· 19 19 #include <asm/ipl.h> 20 20 21 21 /* 22 - * For show_trace we have tree different stack to consider: 22 + * For dump_trace we have tree different stack to consider: 23 23 * - the panic stack which is used if the kernel stack has overflown 24 24 * - the asynchronous interrupt stack (cpu related) 25 25 * - the synchronous kernel stack (process related) 26 - * The stack trace can start at any of the three stack and can potentially 26 + * The stack trace can start at any of the three stacks and can potentially 27 27 * touch all of them. The order is: panic stack, async stack, sync stack. 28 28 */ 29 29 static unsigned long 30 - __show_trace(unsigned long sp, unsigned long low, unsigned long high) 30 + __dump_trace(dump_trace_func_t func, void *data, unsigned long sp, 31 + unsigned long low, unsigned long high) 31 32 { 32 33 struct stack_frame *sf; 33 34 struct pt_regs *regs; 34 - unsigned long addr; 35 35 36 36 while (1) { 37 37 if (sp < low || sp > high - sizeof(*sf)) 38 38 return sp; 39 39 sf = (struct stack_frame *) sp; 40 - addr = sf->gprs[8]; 41 - printk("([<%016lx>] %pSR)\n", addr, (void *)addr); 42 40 /* Follow the backchain. */ 43 41 while (1) { 42 + if (func(data, sf->gprs[8])) 43 + return sp; 44 44 low = sp; 45 45 sp = sf->back_chain; 46 46 if (!sp) ··· 48 48 if (sp <= low || sp > high - sizeof(*sf)) 49 49 return sp; 50 50 sf = (struct stack_frame *) sp; 51 - addr = sf->gprs[8]; 52 - printk(" [<%016lx>] %pSR\n", addr, (void *)addr); 53 51 } 54 52 /* Zero backchain detected, check for interrupt frame. */ 55 53 sp = (unsigned long) (sf + 1); 56 54 if (sp <= low || sp > high - sizeof(*regs)) 57 55 return sp; 58 56 regs = (struct pt_regs *) sp; 59 - addr = regs->psw.addr; 60 - printk(" [<%016lx>] %pSR\n", addr, (void *)addr); 57 + if (!user_mode(regs)) { 58 + if (func(data, regs->psw.addr)) 59 + return sp; 60 + } 61 61 low = sp; 62 62 sp = regs->gprs[15]; 63 63 } 64 64 } 65 65 66 - static void show_trace(struct task_struct *task, unsigned long *stack) 66 + void dump_trace(dump_trace_func_t func, void *data, struct task_struct *task, 67 + unsigned long sp) 67 68 { 68 - const unsigned long frame_size = 69 - STACK_FRAME_OVERHEAD + sizeof(struct pt_regs); 70 - register unsigned long __r15 asm ("15"); 71 - unsigned long sp; 69 + unsigned long frame_size; 72 70 73 - sp = (unsigned long) stack; 74 - if (!sp) 75 - sp = task ? task->thread.ksp : __r15; 76 - printk("Call Trace:\n"); 71 + frame_size = STACK_FRAME_OVERHEAD + sizeof(struct pt_regs); 77 72 #ifdef CONFIG_CHECK_STACK 78 - sp = __show_trace(sp, 73 + sp = __dump_trace(func, data, sp, 79 74 S390_lowcore.panic_stack + frame_size - 4096, 80 75 S390_lowcore.panic_stack + frame_size); 81 76 #endif 82 - sp = __show_trace(sp, 77 + sp = __dump_trace(func, data, sp, 83 78 S390_lowcore.async_stack + frame_size - ASYNC_SIZE, 84 79 S390_lowcore.async_stack + frame_size); 85 80 if (task) 86 - __show_trace(sp, (unsigned long) task_stack_page(task), 87 - (unsigned long) task_stack_page(task) + THREAD_SIZE); 81 + __dump_trace(func, data, sp, 82 + (unsigned long)task_stack_page(task), 83 + (unsigned long)task_stack_page(task) + THREAD_SIZE); 88 84 else 89 - __show_trace(sp, S390_lowcore.thread_info, 85 + __dump_trace(func, data, sp, 86 + S390_lowcore.thread_info, 90 87 S390_lowcore.thread_info + THREAD_SIZE); 88 + } 89 + EXPORT_SYMBOL_GPL(dump_trace); 90 + 91 + static int show_address(void *data, unsigned long address) 92 + { 93 + printk("([<%016lx>] %pSR)\n", address, (void *)address); 94 + return 0; 95 + } 96 + 97 + static void show_trace(struct task_struct *task, unsigned long sp) 98 + { 99 + if (!sp) 100 + sp = task ? task->thread.ksp : current_stack_pointer(); 101 + printk("Call Trace:\n"); 102 + dump_trace(show_address, NULL, task, sp); 91 103 if (!task) 92 104 task = current; 93 105 debug_show_held_locks(task); ··· 107 95 108 96 void show_stack(struct task_struct *task, unsigned long *sp) 109 97 { 110 - register unsigned long *__r15 asm ("15"); 111 98 unsigned long *stack; 112 99 int i; 113 100 114 - if (!sp) 115 - stack = task ? (unsigned long *) task->thread.ksp : __r15; 116 - else 117 - stack = sp; 118 - 101 + stack = sp; 102 + if (!stack) { 103 + if (!task) 104 + stack = (unsigned long *)current_stack_pointer(); 105 + else 106 + stack = (unsigned long *)task->thread.ksp; 107 + } 119 108 for (i = 0; i < 20; i++) { 120 109 if (((addr_t) stack & (THREAD_SIZE-1)) == 0) 121 110 break; ··· 125 112 printk("%016lx ", *stack++); 126 113 } 127 114 printk("\n"); 128 - show_trace(task, sp); 115 + show_trace(task, (unsigned long)sp); 129 116 } 130 117 131 118 static void show_last_breaking_event(struct pt_regs *regs) ··· 134 121 printk(" [<%016lx>] %pSR\n", regs->args[0], (void *)regs->args[0]); 135 122 } 136 123 137 - static inline int mask_bits(struct pt_regs *regs, unsigned long bits) 138 - { 139 - return (regs->psw.mask & bits) / ((~bits + 1) & bits); 140 - } 141 - 142 124 void show_registers(struct pt_regs *regs) 143 125 { 126 + struct psw_bits *psw = &psw_bits(regs->psw); 144 127 char *mode; 145 128 146 129 mode = user_mode(regs) ? "User" : "Krnl"; ··· 145 136 printk(" (%pSR)", (void *)regs->psw.addr); 146 137 printk("\n"); 147 138 printk(" R:%x T:%x IO:%x EX:%x Key:%x M:%x W:%x " 148 - "P:%x AS:%x CC:%x PM:%x", mask_bits(regs, PSW_MASK_PER), 149 - mask_bits(regs, PSW_MASK_DAT), mask_bits(regs, PSW_MASK_IO), 150 - mask_bits(regs, PSW_MASK_EXT), mask_bits(regs, PSW_MASK_KEY), 151 - mask_bits(regs, PSW_MASK_MCHECK), mask_bits(regs, PSW_MASK_WAIT), 152 - mask_bits(regs, PSW_MASK_PSTATE), mask_bits(regs, PSW_MASK_ASC), 153 - mask_bits(regs, PSW_MASK_CC), mask_bits(regs, PSW_MASK_PM)); 154 - printk(" EA:%x", mask_bits(regs, PSW_MASK_EA | PSW_MASK_BA)); 139 + "P:%x AS:%x CC:%x PM:%x", psw->r, psw->t, psw->i, psw->e, 140 + psw->key, psw->m, psw->w, psw->p, psw->as, psw->cc, psw->pm); 141 + printk(" RI:%x EA:%x", psw->ri, psw->eaba); 155 142 printk("\n%s GPRS: %016lx %016lx %016lx %016lx\n", mode, 156 143 regs->gprs[0], regs->gprs[1], regs->gprs[2], regs->gprs[3]); 157 144 printk(" %016lx %016lx %016lx %016lx\n", ··· 165 160 show_registers(regs); 166 161 /* Show stack backtrace if pt_regs is from kernel mode */ 167 162 if (!user_mode(regs)) 168 - show_trace(NULL, (unsigned long *) regs->gprs[15]); 163 + show_trace(NULL, regs->gprs[15]); 169 164 show_last_breaking_event(regs); 170 165 } 171 166
+3 -104
arch/s390/kernel/entry.S
··· 186 186 stg %r5,__LC_THREAD_INFO # store thread info of next 187 187 stg %r15,__LC_KERNEL_STACK # store end of kernel stack 188 188 lg %r15,__THREAD_ksp(%r1) # load kernel stack of next 189 + /* c4 is used in guest detection: arch/s390/kernel/perf_cpum_sf.c */ 189 190 lctl %c4,%c4,__TASK_pid(%r3) # load pid to control reg. 4 190 191 mvc __LC_CURRENT_PID(4,%r0),__TASK_pid(%r3) # store pid of next 191 192 lmg %r6,%r15,__SF_GPRS(%r15) # load gprs of next task ··· 1200 1199 .quad .Lpsw_idle_lpsw 1201 1200 1202 1201 .Lcleanup_save_fpu_regs: 1203 - TSTMSK __LC_CPU_FLAGS,_CIF_FPU 1204 - bor %r14 1205 - clg %r9,BASED(.Lcleanup_save_fpu_regs_done) 1206 - jhe 5f 1207 - clg %r9,BASED(.Lcleanup_save_fpu_regs_fp) 1208 - jhe 4f 1209 - clg %r9,BASED(.Lcleanup_save_fpu_regs_vx_high) 1210 - jhe 3f 1211 - clg %r9,BASED(.Lcleanup_save_fpu_regs_vx_low) 1212 - jhe 2f 1213 - clg %r9,BASED(.Lcleanup_save_fpu_fpc_end) 1214 - jhe 1f 1215 - lg %r2,__LC_CURRENT 1216 - aghi %r2,__TASK_thread 1217 - 0: # Store floating-point controls 1218 - stfpc __THREAD_FPU_fpc(%r2) 1219 - 1: # Load register save area and check if VX is active 1220 - lg %r3,__THREAD_FPU_regs(%r2) 1221 - TSTMSK __LC_MACHINE_FLAGS,MACHINE_FLAG_VX 1222 - jz 4f # no VX -> store FP regs 1223 - 2: # Store vector registers (V0-V15) 1224 - VSTM %v0,%v15,0,%r3 # vstm 0,15,0(3) 1225 - 3: # Store vector registers (V16-V31) 1226 - VSTM %v16,%v31,256,%r3 # vstm 16,31,256(3) 1227 - j 5f # -> done, set CIF_FPU flag 1228 - 4: # Store floating-point registers 1229 - std 0,0(%r3) 1230 - std 1,8(%r3) 1231 - std 2,16(%r3) 1232 - std 3,24(%r3) 1233 - std 4,32(%r3) 1234 - std 5,40(%r3) 1235 - std 6,48(%r3) 1236 - std 7,56(%r3) 1237 - std 8,64(%r3) 1238 - std 9,72(%r3) 1239 - std 10,80(%r3) 1240 - std 11,88(%r3) 1241 - std 12,96(%r3) 1242 - std 13,104(%r3) 1243 - std 14,112(%r3) 1244 - std 15,120(%r3) 1245 - 5: # Set CIF_FPU flag 1246 - oi __LC_CPU_FLAGS+7,_CIF_FPU 1247 - lg %r9,48(%r11) # return from save_fpu_regs 1202 + larl %r9,save_fpu_regs 1248 1203 br %r14 1249 - .Lcleanup_save_fpu_fpc_end: 1250 - .quad .Lsave_fpu_regs_fpc_end 1251 - .Lcleanup_save_fpu_regs_vx_low: 1252 - .quad .Lsave_fpu_regs_vx_low 1253 - .Lcleanup_save_fpu_regs_vx_high: 1254 - .quad .Lsave_fpu_regs_vx_high 1255 - .Lcleanup_save_fpu_regs_fp: 1256 - .quad .Lsave_fpu_regs_fp 1257 - .Lcleanup_save_fpu_regs_done: 1258 - .quad .Lsave_fpu_regs_done 1259 1204 1260 1205 .Lcleanup_load_fpu_regs: 1261 - TSTMSK __LC_CPU_FLAGS,_CIF_FPU 1262 - bnor %r14 1263 - clg %r9,BASED(.Lcleanup_load_fpu_regs_done) 1264 - jhe 1f 1265 - clg %r9,BASED(.Lcleanup_load_fpu_regs_fp) 1266 - jhe 2f 1267 - clg %r9,BASED(.Lcleanup_load_fpu_regs_vx_high) 1268 - jhe 3f 1269 - clg %r9,BASED(.Lcleanup_load_fpu_regs_vx) 1270 - jhe 4f 1271 - lg %r4,__LC_CURRENT 1272 - aghi %r4,__TASK_thread 1273 - lfpc __THREAD_FPU_fpc(%r4) 1274 - TSTMSK __LC_MACHINE_FLAGS,MACHINE_FLAG_VX 1275 - lg %r4,__THREAD_FPU_regs(%r4) # %r4 <- reg save area 1276 - jz 2f # -> no VX, load FP regs 1277 - 4: # Load V0 ..V15 registers 1278 - VLM %v0,%v15,0,%r4 1279 - 3: # Load V16..V31 registers 1280 - VLM %v16,%v31,256,%r4 1281 - j 1f 1282 - 2: # Load floating-point registers 1283 - ld 0,0(%r4) 1284 - ld 1,8(%r4) 1285 - ld 2,16(%r4) 1286 - ld 3,24(%r4) 1287 - ld 4,32(%r4) 1288 - ld 5,40(%r4) 1289 - ld 6,48(%r4) 1290 - ld 7,56(%r4) 1291 - ld 8,64(%r4) 1292 - ld 9,72(%r4) 1293 - ld 10,80(%r4) 1294 - ld 11,88(%r4) 1295 - ld 12,96(%r4) 1296 - ld 13,104(%r4) 1297 - ld 14,112(%r4) 1298 - ld 15,120(%r4) 1299 - 1: # Clear CIF_FPU bit 1300 - ni __LC_CPU_FLAGS+7,255-_CIF_FPU 1301 - lg %r9,48(%r11) # return from load_fpu_regs 1206 + larl %r9,load_fpu_regs 1302 1207 br %r14 1303 - .Lcleanup_load_fpu_regs_vx: 1304 - .quad .Lload_fpu_regs_vx 1305 - .Lcleanup_load_fpu_regs_vx_high: 1306 - .quad .Lload_fpu_regs_vx_high 1307 - .Lcleanup_load_fpu_regs_fp: 1308 - .quad .Lload_fpu_regs_fp 1309 - .Lcleanup_load_fpu_regs_done: 1310 - .quad .Lload_fpu_regs_done 1311 1208 1312 1209 /* 1313 1210 * Integer constants
+1 -2
arch/s390/kernel/irq.c
··· 164 164 { 165 165 unsigned long old, new; 166 166 167 - /* Get current stack pointer. */ 168 - asm volatile("la %0,0(15)" : "=a" (old)); 167 + old = current_stack_pointer(); 169 168 /* Check against async. stack address range. */ 170 169 new = S390_lowcore.async_stack; 171 170 if (((new - old) >> (PAGE_SHIFT + THREAD_ORDER)) != 0) {
+1 -1
arch/s390/kernel/perf_cpum_cf.c
··· 383 383 384 384 /* Validate the counter that is assigned to this event. 385 385 * Because the counter facility can use numerous counters at the 386 - * same time without constraints, it is not necessary to explicity 386 + * same time without constraints, it is not necessary to explicitly 387 387 * validate event groups (event->group_leader != event). 388 388 */ 389 389 err = validate_event(hwc);
+6 -3
arch/s390/kernel/perf_cpum_sf.c
··· 1022 1022 /* 1023 1023 * A non-zero guest program parameter indicates a guest 1024 1024 * sample. 1025 - * Note that some early samples might be misaccounted to 1026 - * the host. 1025 + * Note that some early samples or samples from guests without 1026 + * lpp usage would be misaccounted to the host. We use the asn 1027 + * value as a heuristic to detect most of these guest samples. 1028 + * If the value differs from the host hpp value, we assume 1029 + * it to be a KVM guest. 1027 1030 */ 1028 - if (sfr->basic.gpp) 1031 + if (sfr->basic.gpp || sfr->basic.prim_asn != (u16) sfr->basic.hpp) 1029 1032 sde_regs->in_guest = 1; 1030 1033 1031 1034 overflow = 0;
+6 -50
arch/s390/kernel/perf_event.c
··· 222 222 } 223 223 arch_initcall(service_level_perf_register); 224 224 225 - /* See also arch/s390/kernel/traps.c */ 226 - static unsigned long __store_trace(struct perf_callchain_entry *entry, 227 - unsigned long sp, 228 - unsigned long low, unsigned long high) 225 + static int __perf_callchain_kernel(void *data, unsigned long address) 229 226 { 230 - struct stack_frame *sf; 231 - struct pt_regs *regs; 227 + struct perf_callchain_entry *entry = data; 232 228 233 - while (1) { 234 - if (sp < low || sp > high - sizeof(*sf)) 235 - return sp; 236 - sf = (struct stack_frame *) sp; 237 - perf_callchain_store(entry, sf->gprs[8]); 238 - /* Follow the backchain. */ 239 - while (1) { 240 - low = sp; 241 - sp = sf->back_chain; 242 - if (!sp) 243 - break; 244 - if (sp <= low || sp > high - sizeof(*sf)) 245 - return sp; 246 - sf = (struct stack_frame *) sp; 247 - perf_callchain_store(entry, sf->gprs[8]); 248 - } 249 - /* Zero backchain detected, check for interrupt frame. */ 250 - sp = (unsigned long) (sf + 1); 251 - if (sp <= low || sp > high - sizeof(*regs)) 252 - return sp; 253 - regs = (struct pt_regs *) sp; 254 - perf_callchain_store(entry, sf->gprs[8]); 255 - low = sp; 256 - sp = regs->gprs[15]; 257 - } 229 + perf_callchain_store(entry, address); 230 + return 0; 258 231 } 259 232 260 233 void perf_callchain_kernel(struct perf_callchain_entry *entry, 261 234 struct pt_regs *regs) 262 235 { 263 - unsigned long head, frame_size; 264 - struct stack_frame *head_sf; 265 - 266 236 if (user_mode(regs)) 267 237 return; 268 - 269 - frame_size = STACK_FRAME_OVERHEAD + sizeof(struct pt_regs); 270 - head = regs->gprs[15]; 271 - head_sf = (struct stack_frame *) head; 272 - 273 - if (!head_sf || !head_sf->back_chain) 274 - return; 275 - 276 - head = head_sf->back_chain; 277 - head = __store_trace(entry, head, 278 - S390_lowcore.async_stack + frame_size - ASYNC_SIZE, 279 - S390_lowcore.async_stack + frame_size); 280 - 281 - __store_trace(entry, head, S390_lowcore.thread_info, 282 - S390_lowcore.thread_info + THREAD_SIZE); 238 + dump_trace(__perf_callchain_kernel, entry, NULL, regs->gprs[15]); 283 239 } 284 240 285 - /* Perf defintions for PMU event attributes in sysfs */ 241 + /* Perf definitions for PMU event attributes in sysfs */ 286 242 ssize_t cpumf_events_sysfs_show(struct device *dev, 287 243 struct device_attribute *attr, char *page) 288 244 {
+2
arch/s390/kernel/setup.c
··· 327 327 + PAGE_SIZE - STACK_FRAME_OVERHEAD - sizeof(struct pt_regs); 328 328 lc->current_task = (unsigned long) init_thread_union.thread_info.task; 329 329 lc->thread_info = (unsigned long) &init_thread_union; 330 + lc->lpp = LPP_MAGIC; 330 331 lc->machine_flags = S390_lowcore.machine_flags; 331 332 lc->stfl_fac_list = S390_lowcore.stfl_fac_list; 332 333 memcpy(lc->stfle_fac_list, S390_lowcore.stfle_fac_list, ··· 780 779 strcpy(elf_platform, "zEC12"); 781 780 break; 782 781 case 0x2964: 782 + case 0x2965: 783 783 strcpy(elf_platform, "z13"); 784 784 break; 785 785 }
+25 -68
arch/s390/kernel/stacktrace.c
··· 10 10 #include <linux/kallsyms.h> 11 11 #include <linux/module.h> 12 12 13 - static unsigned long save_context_stack(struct stack_trace *trace, 14 - unsigned long sp, 15 - unsigned long low, 16 - unsigned long high, 17 - int savesched) 13 + static int __save_address(void *data, unsigned long address, int nosched) 18 14 { 19 - struct stack_frame *sf; 20 - struct pt_regs *regs; 21 - unsigned long addr; 15 + struct stack_trace *trace = data; 22 16 23 - while(1) { 24 - if (sp < low || sp > high) 25 - return sp; 26 - sf = (struct stack_frame *)sp; 27 - while(1) { 28 - addr = sf->gprs[8]; 29 - if (!trace->skip) 30 - trace->entries[trace->nr_entries++] = addr; 31 - else 32 - trace->skip--; 33 - if (trace->nr_entries >= trace->max_entries) 34 - return sp; 35 - low = sp; 36 - sp = sf->back_chain; 37 - if (!sp) 38 - break; 39 - if (sp <= low || sp > high - sizeof(*sf)) 40 - return sp; 41 - sf = (struct stack_frame *)sp; 42 - } 43 - /* Zero backchain detected, check for interrupt frame. */ 44 - sp = (unsigned long)(sf + 1); 45 - if (sp <= low || sp > high - sizeof(*regs)) 46 - return sp; 47 - regs = (struct pt_regs *)sp; 48 - addr = regs->psw.addr; 49 - if (savesched || !in_sched_functions(addr)) { 50 - if (!trace->skip) 51 - trace->entries[trace->nr_entries++] = addr; 52 - else 53 - trace->skip--; 54 - } 55 - if (trace->nr_entries >= trace->max_entries) 56 - return sp; 57 - low = sp; 58 - sp = regs->gprs[15]; 17 + if (nosched && in_sched_functions(address)) 18 + return 0; 19 + if (trace->skip > 0) { 20 + trace->skip--; 21 + return 0; 59 22 } 23 + if (trace->nr_entries < trace->max_entries) { 24 + trace->entries[trace->nr_entries++] = address; 25 + return 0; 26 + } 27 + return 1; 60 28 } 61 29 62 - static void __save_stack_trace(struct stack_trace *trace, unsigned long sp) 30 + static int save_address(void *data, unsigned long address) 63 31 { 64 - unsigned long new_sp, frame_size; 32 + return __save_address(data, address, 0); 33 + } 65 34 66 - frame_size = STACK_FRAME_OVERHEAD + sizeof(struct pt_regs); 67 - new_sp = save_context_stack(trace, sp, 68 - S390_lowcore.panic_stack + frame_size - PAGE_SIZE, 69 - S390_lowcore.panic_stack + frame_size, 1); 70 - new_sp = save_context_stack(trace, new_sp, 71 - S390_lowcore.async_stack + frame_size - ASYNC_SIZE, 72 - S390_lowcore.async_stack + frame_size, 1); 73 - save_context_stack(trace, new_sp, 74 - S390_lowcore.thread_info, 75 - S390_lowcore.thread_info + THREAD_SIZE, 1); 35 + static int save_address_nosched(void *data, unsigned long address) 36 + { 37 + return __save_address(data, address, 1); 76 38 } 77 39 78 40 void save_stack_trace(struct stack_trace *trace) 79 41 { 80 - register unsigned long r15 asm ("15"); 81 42 unsigned long sp; 82 43 83 - sp = r15; 84 - __save_stack_trace(trace, sp); 44 + sp = current_stack_pointer(); 45 + dump_trace(save_address, trace, NULL, sp); 85 46 if (trace->nr_entries < trace->max_entries) 86 47 trace->entries[trace->nr_entries++] = ULONG_MAX; 87 48 } ··· 50 89 51 90 void save_stack_trace_tsk(struct task_struct *tsk, struct stack_trace *trace) 52 91 { 53 - unsigned long sp, low, high; 92 + unsigned long sp; 54 93 55 94 sp = tsk->thread.ksp; 56 - if (tsk == current) { 57 - /* Get current stack pointer. */ 58 - asm volatile("la %0,0(15)" : "=a" (sp)); 59 - } 60 - low = (unsigned long) task_stack_page(tsk); 61 - high = (unsigned long) task_pt_regs(tsk); 62 - save_context_stack(trace, sp, low, high, 0); 95 + if (tsk == current) 96 + sp = current_stack_pointer(); 97 + dump_trace(save_address_nosched, trace, tsk, sp); 63 98 if (trace->nr_entries < trace->max_entries) 64 99 trace->entries[trace->nr_entries++] = ULONG_MAX; 65 100 } ··· 66 109 unsigned long sp; 67 110 68 111 sp = kernel_stack_pointer(regs); 69 - __save_stack_trace(trace, sp); 112 + dump_trace(save_address, trace, NULL, sp); 70 113 if (trace->nr_entries < trace->max_entries) 71 114 trace->entries[trace->nr_entries++] = ULONG_MAX; 72 115 }
+2 -4
arch/s390/kernel/time.c
··· 499 499 if (etr_port0_online && etr_port1_online) 500 500 set_bit(CLOCK_SYNC_ETR, &clock_sync_flags); 501 501 } else if (etr_port0_online || etr_port1_online) { 502 - pr_warning("The real or virtual hardware system does " 503 - "not provide an ETR interface\n"); 502 + pr_warn("The real or virtual hardware system does not provide an ETR interface\n"); 504 503 etr_port0_online = etr_port1_online = 0; 505 504 } 506 505 } ··· 1463 1464 if (rc == 0) 1464 1465 set_bit(CLOCK_SYNC_HAS_STP, &clock_sync_flags); 1465 1466 else if (stp_online) { 1466 - pr_warning("The real or virtual hardware system does " 1467 - "not provide an STP interface\n"); 1467 + pr_warn("The real or virtual hardware system does not provide an STP interface\n"); 1468 1468 free_page((unsigned long) stp_page); 1469 1469 stp_page = NULL; 1470 1470 stp_online = 0;
+2 -19
arch/s390/kernel/traps.c
··· 22 22 #include <asm/fpu/api.h> 23 23 #include "entry.h" 24 24 25 - int show_unhandled_signals = 1; 26 - 27 25 static inline void __user *get_trap_ip(struct pt_regs *regs) 28 26 { 29 27 unsigned long address; ··· 31 33 else 32 34 address = regs->psw.addr; 33 35 return (void __user *) (address - (regs->int_code >> 16)); 34 - } 35 - 36 - static inline void report_user_fault(struct pt_regs *regs, int signr) 37 - { 38 - if ((task_pid_nr(current) > 1) && !show_unhandled_signals) 39 - return; 40 - if (!unhandled_signal(current, signr)) 41 - return; 42 - if (!printk_ratelimit()) 43 - return; 44 - printk("User process fault: interruption code %04x ilc:%d ", 45 - regs->int_code & 0xffff, regs->int_code >> 17); 46 - print_vma_addr("in ", regs->psw.addr); 47 - printk("\n"); 48 - show_regs(regs); 49 36 } 50 37 51 38 int is_valid_bugaddr(unsigned long addr) ··· 48 65 info.si_code = si_code; 49 66 info.si_addr = get_trap_ip(regs); 50 67 force_sig_info(si_signo, &info, current); 51 - report_user_fault(regs, si_signo); 68 + report_user_fault(regs, si_signo, 0); 52 69 } else { 53 70 const struct exception_table_entry *fixup; 54 71 fixup = search_exception_tables(regs->psw.addr); ··· 94 111 void default_trap_handler(struct pt_regs *regs) 95 112 { 96 113 if (user_mode(regs)) { 97 - report_user_fault(regs, SIGSEGV); 114 + report_user_fault(regs, SIGSEGV, 0); 98 115 do_exit(SIGSEGV); 99 116 } else 100 117 die(regs, "Unknown program exception");
+1
arch/s390/kvm/diag.c
··· 14 14 #include <linux/kvm.h> 15 15 #include <linux/kvm_host.h> 16 16 #include <asm/pgalloc.h> 17 + #include <asm/gmap.h> 17 18 #include <asm/virtio-ccw.h> 18 19 #include "kvm-s390.h" 19 20 #include "trace.h"
+2 -2
arch/s390/kvm/guestdbg.c
··· 17 17 /* 18 18 * Extends the address range given by *start and *stop to include the address 19 19 * range starting with estart and the length len. Takes care of overflowing 20 - * intervals and tries to minimize the overall intervall size. 20 + * intervals and tries to minimize the overall interval size. 21 21 */ 22 22 static void extend_address_range(u64 *start, u64 *stop, u64 estart, int len) 23 23 { ··· 72 72 return; 73 73 74 74 /* 75 - * If the guest is not interrested in branching events, we can savely 75 + * If the guest is not interested in branching events, we can safely 76 76 * limit them to the PER address range. 77 77 */ 78 78 if (!(*cr9 & PER_EVENT_BRANCH))
+1
arch/s390/kvm/interrupt.c
··· 23 23 #include <asm/uaccess.h> 24 24 #include <asm/sclp.h> 25 25 #include <asm/isc.h> 26 + #include <asm/gmap.h> 26 27 #include "kvm-s390.h" 27 28 #include "gaccess.h" 28 29 #include "trace-s390.h"
+2 -1
arch/s390/kvm/kvm-s390.c
··· 30 30 #include <asm/lowcore.h> 31 31 #include <asm/etr.h> 32 32 #include <asm/pgtable.h> 33 + #include <asm/gmap.h> 33 34 #include <asm/nmi.h> 34 35 #include <asm/switch_to.h> 35 36 #include <asm/isc.h> ··· 282 281 for (cur_gfn = memslot->base_gfn; cur_gfn <= last_gfn; cur_gfn++) { 283 282 address = gfn_to_hva_memslot(memslot, cur_gfn); 284 283 285 - if (gmap_test_and_clear_dirty(address, gmap)) 284 + if (test_and_clear_guest_dirty(gmap->mm, address)) 286 285 mark_page_dirty(kvm, cur_gfn); 287 286 if (fatal_signal_pending(current)) 288 287 return;
+1
arch/s390/kvm/priv.c
··· 23 23 #include <asm/sysinfo.h> 24 24 #include <asm/pgtable.h> 25 25 #include <asm/pgalloc.h> 26 + #include <asm/gmap.h> 26 27 #include <asm/io.h> 27 28 #include <asm/ptrace.h> 28 29 #include <asm/compat.h>
+1 -1
arch/s390/lib/Makefile
··· 3 3 # 4 4 5 5 lib-y += delay.o string.o uaccess.o find.o 6 - obj-y += mem.o 6 + obj-y += mem.o xor.o 7 7 lib-$(CONFIG_SMP) += spinlock.o 8 8 lib-$(CONFIG_KPROBES) += probes.o 9 9 lib-$(CONFIG_UPROBES) += probes.o
+134
arch/s390/lib/xor.c
··· 1 + /* 2 + * Optimized xor_block operation for RAID4/5 3 + * 4 + * Copyright IBM Corp. 2016 5 + * Author(s): Martin Schwidefsky <schwidefsky@de.ibm.com> 6 + */ 7 + 8 + #include <linux/types.h> 9 + #include <linux/module.h> 10 + #include <linux/raid/xor.h> 11 + 12 + static void xor_xc_2(unsigned long bytes, unsigned long *p1, unsigned long *p2) 13 + { 14 + asm volatile( 15 + " larl 1,2f\n" 16 + " aghi %0,-1\n" 17 + " jm 3f\n" 18 + " srlg 0,%0,8\n" 19 + " ltgr 0,0\n" 20 + " jz 1f\n" 21 + "0: xc 0(256,%1),0(%2)\n" 22 + " la %1,256(%1)\n" 23 + " la %2,256(%2)\n" 24 + " brctg 0,0b\n" 25 + "1: ex %0,0(1)\n" 26 + " j 3f\n" 27 + "2: xc 0(1,%1),0(%2)\n" 28 + "3:\n" 29 + : : "d" (bytes), "a" (p1), "a" (p2) 30 + : "0", "1", "cc", "memory"); 31 + } 32 + 33 + static void xor_xc_3(unsigned long bytes, unsigned long *p1, unsigned long *p2, 34 + unsigned long *p3) 35 + { 36 + asm volatile( 37 + " larl 1,2f\n" 38 + " aghi %0,-1\n" 39 + " jm 3f\n" 40 + " srlg 0,%0,8\n" 41 + " ltgr 0,0\n" 42 + " jz 1f\n" 43 + "0: xc 0(256,%1),0(%2)\n" 44 + " xc 0(256,%1),0(%3)\n" 45 + " la %1,256(%1)\n" 46 + " la %2,256(%2)\n" 47 + " la %3,256(%3)\n" 48 + " brctg 0,0b\n" 49 + "1: ex %0,0(1)\n" 50 + " ex %0,6(1)\n" 51 + " j 3f\n" 52 + "2: xc 0(1,%1),0(%2)\n" 53 + " xc 0(1,%1),0(%3)\n" 54 + "3:\n" 55 + : "+d" (bytes), "+a" (p1), "+a" (p2), "+a" (p3) 56 + : : "0", "1", "cc", "memory"); 57 + } 58 + 59 + static void xor_xc_4(unsigned long bytes, unsigned long *p1, unsigned long *p2, 60 + unsigned long *p3, unsigned long *p4) 61 + { 62 + asm volatile( 63 + " larl 1,2f\n" 64 + " aghi %0,-1\n" 65 + " jm 3f\n" 66 + " srlg 0,%0,8\n" 67 + " ltgr 0,0\n" 68 + " jz 1f\n" 69 + "0: xc 0(256,%1),0(%2)\n" 70 + " xc 0(256,%1),0(%3)\n" 71 + " xc 0(256,%1),0(%4)\n" 72 + " la %1,256(%1)\n" 73 + " la %2,256(%2)\n" 74 + " la %3,256(%3)\n" 75 + " la %4,256(%4)\n" 76 + " brctg 0,0b\n" 77 + "1: ex %0,0(1)\n" 78 + " ex %0,6(1)\n" 79 + " ex %0,12(1)\n" 80 + " j 3f\n" 81 + "2: xc 0(1,%1),0(%2)\n" 82 + " xc 0(1,%1),0(%3)\n" 83 + " xc 0(1,%1),0(%4)\n" 84 + "3:\n" 85 + : "+d" (bytes), "+a" (p1), "+a" (p2), "+a" (p3), "+a" (p4) 86 + : : "0", "1", "cc", "memory"); 87 + } 88 + 89 + static void xor_xc_5(unsigned long bytes, unsigned long *p1, unsigned long *p2, 90 + unsigned long *p3, unsigned long *p4, unsigned long *p5) 91 + { 92 + /* Get around a gcc oddity */ 93 + register unsigned long *reg7 asm ("7") = p5; 94 + 95 + asm volatile( 96 + " larl 1,2f\n" 97 + " aghi %0,-1\n" 98 + " jm 3f\n" 99 + " srlg 0,%0,8\n" 100 + " ltgr 0,0\n" 101 + " jz 1f\n" 102 + "0: xc 0(256,%1),0(%2)\n" 103 + " xc 0(256,%1),0(%3)\n" 104 + " xc 0(256,%1),0(%4)\n" 105 + " xc 0(256,%1),0(%5)\n" 106 + " la %1,256(%1)\n" 107 + " la %2,256(%2)\n" 108 + " la %3,256(%3)\n" 109 + " la %4,256(%4)\n" 110 + " la %5,256(%5)\n" 111 + " brctg 0,0b\n" 112 + "1: ex %0,0(1)\n" 113 + " ex %0,6(1)\n" 114 + " ex %0,12(1)\n" 115 + " ex %0,18(1)\n" 116 + " j 3f\n" 117 + "2: xc 0(1,%1),0(%2)\n" 118 + " xc 0(1,%1),0(%3)\n" 119 + " xc 0(1,%1),0(%4)\n" 120 + " xc 0(1,%1),0(%5)\n" 121 + "3:\n" 122 + : "+d" (bytes), "+a" (p1), "+a" (p2), "+a" (p3), "+a" (p4), 123 + "+a" (reg7) 124 + : : "0", "1", "cc", "memory"); 125 + } 126 + 127 + struct xor_block_template xor_block_xc = { 128 + .name = "xc", 129 + .do_2 = xor_xc_2, 130 + .do_3 = xor_xc_3, 131 + .do_4 = xor_xc_4, 132 + .do_5 = xor_xc_5, 133 + }; 134 + EXPORT_SYMBOL(xor_block_xc);
+3 -1
arch/s390/mm/Makefile
··· 2 2 # Makefile for the linux s390-specific parts of the memory manager. 3 3 # 4 4 5 - obj-y := init.o fault.o extmem.o mmap.o vmem.o pgtable.o maccess.o 5 + obj-y := init.o fault.o extmem.o mmap.o vmem.o maccess.o 6 6 obj-y += page-states.o gup.o extable.o pageattr.o mem_detect.o 7 + obj-y += pgtable.o pgalloc.o 7 8 8 9 obj-$(CONFIG_CMM) += cmm.o 9 10 obj-$(CONFIG_HUGETLB_PAGE) += hugetlbpage.o 10 11 obj-$(CONFIG_S390_PTDUMP) += dump_pagetables.o 12 + obj-$(CONFIG_PGSTE) += gmap.o
+7 -9
arch/s390/mm/extmem.c
··· 265 265 goto out_free; 266 266 } 267 267 if (diag_cc > 1) { 268 - pr_warning("Querying a DCSS type failed with rc=%ld\n", vmrc); 268 + pr_warn("Querying a DCSS type failed with rc=%ld\n", vmrc); 269 269 rc = dcss_diag_translate_rc (vmrc); 270 270 goto out_free; 271 271 } ··· 457 457 goto out_resource; 458 458 } 459 459 if (diag_cc > 1) { 460 - pr_warning("Loading DCSS %s failed with rc=%ld\n", name, 461 - end_addr); 460 + pr_warn("Loading DCSS %s failed with rc=%ld\n", name, end_addr); 462 461 rc = dcss_diag_translate_rc(end_addr); 463 462 dcss_diag(&purgeseg_scode, seg->dcss_name, 464 463 &dummy, &dummy); ··· 573 574 goto out_unlock; 574 575 } 575 576 if (atomic_read (&seg->ref_count) != 1) { 576 - pr_warning("DCSS %s is in use and cannot be reloaded\n", 577 - name); 577 + pr_warn("DCSS %s is in use and cannot be reloaded\n", name); 578 578 rc = -EAGAIN; 579 579 goto out_unlock; 580 580 } ··· 586 588 seg->res->flags |= IORESOURCE_READONLY; 587 589 588 590 if (request_resource(&iomem_resource, seg->res)) { 589 - pr_warning("DCSS %s overlaps with used memory resources " 590 - "and cannot be reloaded\n", name); 591 + pr_warn("DCSS %s overlaps with used memory resources and cannot be reloaded\n", 592 + name); 591 593 rc = -EBUSY; 592 594 kfree(seg->res); 593 595 goto out_del_mem; ··· 605 607 goto out_del_res; 606 608 } 607 609 if (diag_cc > 1) { 608 - pr_warning("Reloading DCSS %s failed with rc=%ld\n", name, 609 - end_addr); 610 + pr_warn("Reloading DCSS %s failed with rc=%ld\n", 611 + name, end_addr); 610 612 rc = dcss_diag_translate_rc(end_addr); 611 613 goto out_del_res; 612 614 }
+9 -7
arch/s390/mm/fault.c
··· 32 32 #include <asm/asm-offsets.h> 33 33 #include <asm/diag.h> 34 34 #include <asm/pgtable.h> 35 + #include <asm/gmap.h> 35 36 #include <asm/irq.h> 36 37 #include <asm/mmu_context.h> 37 38 #include <asm/facility.h> ··· 184 183 { 185 184 unsigned long asce; 186 185 186 + pr_alert("Failing address: %016lx TEID: %016lx\n", 187 + regs->int_parm_long & __FAIL_ADDR_MASK, regs->int_parm_long); 187 188 pr_alert("Fault in "); 188 189 switch (regs->int_parm_long & 3) { 189 190 case 3: ··· 221 218 dump_pagetable(asce, regs->int_parm_long & __FAIL_ADDR_MASK); 222 219 } 223 220 224 - static inline void report_user_fault(struct pt_regs *regs, long signr) 221 + int show_unhandled_signals = 1; 222 + 223 + void report_user_fault(struct pt_regs *regs, long signr, int is_mm_fault) 225 224 { 226 225 if ((task_pid_nr(current) > 1) && !show_unhandled_signals) 227 226 return; ··· 235 230 regs->int_code & 0xffff, regs->int_code >> 17); 236 231 print_vma_addr(KERN_CONT "in ", regs->psw.addr); 237 232 printk(KERN_CONT "\n"); 238 - printk(KERN_ALERT "failing address: %016lx TEID: %016lx\n", 239 - regs->int_parm_long & __FAIL_ADDR_MASK, regs->int_parm_long); 240 - dump_fault_info(regs); 233 + if (is_mm_fault) 234 + dump_fault_info(regs); 241 235 show_regs(regs); 242 236 } 243 237 ··· 248 244 { 249 245 struct siginfo si; 250 246 251 - report_user_fault(regs, SIGSEGV); 247 + report_user_fault(regs, SIGSEGV, 1); 252 248 si.si_signo = SIGSEGV; 253 249 si.si_code = si_code; 254 250 si.si_addr = (void __user *)(regs->int_parm_long & __FAIL_ADDR_MASK); ··· 276 272 else 277 273 printk(KERN_ALERT "Unable to handle kernel paging request" 278 274 " in virtual user address space\n"); 279 - printk(KERN_ALERT "failing address: %016lx TEID: %016lx\n", 280 - regs->int_parm_long & __FAIL_ADDR_MASK, regs->int_parm_long); 281 275 dump_fault_info(regs); 282 276 die(regs, "Oops"); 283 277 do_exit(SIGKILL);
+774
arch/s390/mm/gmap.c
··· 1 + /* 2 + * KVM guest address space mapping code 3 + * 4 + * Copyright IBM Corp. 2007, 2016 5 + * Author(s): Martin Schwidefsky <schwidefsky@de.ibm.com> 6 + */ 7 + 8 + #include <linux/kernel.h> 9 + #include <linux/mm.h> 10 + #include <linux/swap.h> 11 + #include <linux/smp.h> 12 + #include <linux/spinlock.h> 13 + #include <linux/slab.h> 14 + #include <linux/swapops.h> 15 + #include <linux/ksm.h> 16 + #include <linux/mman.h> 17 + 18 + #include <asm/pgtable.h> 19 + #include <asm/pgalloc.h> 20 + #include <asm/gmap.h> 21 + #include <asm/tlb.h> 22 + 23 + /** 24 + * gmap_alloc - allocate a guest address space 25 + * @mm: pointer to the parent mm_struct 26 + * @limit: maximum size of the gmap address space 27 + * 28 + * Returns a guest address space structure. 29 + */ 30 + struct gmap *gmap_alloc(struct mm_struct *mm, unsigned long limit) 31 + { 32 + struct gmap *gmap; 33 + struct page *page; 34 + unsigned long *table; 35 + unsigned long etype, atype; 36 + 37 + if (limit < (1UL << 31)) { 38 + limit = (1UL << 31) - 1; 39 + atype = _ASCE_TYPE_SEGMENT; 40 + etype = _SEGMENT_ENTRY_EMPTY; 41 + } else if (limit < (1UL << 42)) { 42 + limit = (1UL << 42) - 1; 43 + atype = _ASCE_TYPE_REGION3; 44 + etype = _REGION3_ENTRY_EMPTY; 45 + } else if (limit < (1UL << 53)) { 46 + limit = (1UL << 53) - 1; 47 + atype = _ASCE_TYPE_REGION2; 48 + etype = _REGION2_ENTRY_EMPTY; 49 + } else { 50 + limit = -1UL; 51 + atype = _ASCE_TYPE_REGION1; 52 + etype = _REGION1_ENTRY_EMPTY; 53 + } 54 + gmap = kzalloc(sizeof(struct gmap), GFP_KERNEL); 55 + if (!gmap) 56 + goto out; 57 + INIT_LIST_HEAD(&gmap->crst_list); 58 + INIT_RADIX_TREE(&gmap->guest_to_host, GFP_KERNEL); 59 + INIT_RADIX_TREE(&gmap->host_to_guest, GFP_ATOMIC); 60 + spin_lock_init(&gmap->guest_table_lock); 61 + gmap->mm = mm; 62 + page = alloc_pages(GFP_KERNEL, 2); 63 + if (!page) 64 + goto out_free; 65 + page->index = 0; 66 + list_add(&page->lru, &gmap->crst_list); 67 + table = (unsigned long *) page_to_phys(page); 68 + crst_table_init(table, etype); 69 + gmap->table = table; 70 + gmap->asce = atype | _ASCE_TABLE_LENGTH | 71 + _ASCE_USER_BITS | __pa(table); 72 + gmap->asce_end = limit; 73 + down_write(&mm->mmap_sem); 74 + list_add(&gmap->list, &mm->context.gmap_list); 75 + up_write(&mm->mmap_sem); 76 + return gmap; 77 + 78 + out_free: 79 + kfree(gmap); 80 + out: 81 + return NULL; 82 + } 83 + EXPORT_SYMBOL_GPL(gmap_alloc); 84 + 85 + static void gmap_flush_tlb(struct gmap *gmap) 86 + { 87 + if (MACHINE_HAS_IDTE) 88 + __tlb_flush_asce(gmap->mm, gmap->asce); 89 + else 90 + __tlb_flush_global(); 91 + } 92 + 93 + static void gmap_radix_tree_free(struct radix_tree_root *root) 94 + { 95 + struct radix_tree_iter iter; 96 + unsigned long indices[16]; 97 + unsigned long index; 98 + void **slot; 99 + int i, nr; 100 + 101 + /* A radix tree is freed by deleting all of its entries */ 102 + index = 0; 103 + do { 104 + nr = 0; 105 + radix_tree_for_each_slot(slot, root, &iter, index) { 106 + indices[nr] = iter.index; 107 + if (++nr == 16) 108 + break; 109 + } 110 + for (i = 0; i < nr; i++) { 111 + index = indices[i]; 112 + radix_tree_delete(root, index); 113 + } 114 + } while (nr > 0); 115 + } 116 + 117 + /** 118 + * gmap_free - free a guest address space 119 + * @gmap: pointer to the guest address space structure 120 + */ 121 + void gmap_free(struct gmap *gmap) 122 + { 123 + struct page *page, *next; 124 + 125 + /* Flush tlb. */ 126 + if (MACHINE_HAS_IDTE) 127 + __tlb_flush_asce(gmap->mm, gmap->asce); 128 + else 129 + __tlb_flush_global(); 130 + 131 + /* Free all segment & region tables. */ 132 + list_for_each_entry_safe(page, next, &gmap->crst_list, lru) 133 + __free_pages(page, 2); 134 + gmap_radix_tree_free(&gmap->guest_to_host); 135 + gmap_radix_tree_free(&gmap->host_to_guest); 136 + down_write(&gmap->mm->mmap_sem); 137 + list_del(&gmap->list); 138 + up_write(&gmap->mm->mmap_sem); 139 + kfree(gmap); 140 + } 141 + EXPORT_SYMBOL_GPL(gmap_free); 142 + 143 + /** 144 + * gmap_enable - switch primary space to the guest address space 145 + * @gmap: pointer to the guest address space structure 146 + */ 147 + void gmap_enable(struct gmap *gmap) 148 + { 149 + S390_lowcore.gmap = (unsigned long) gmap; 150 + } 151 + EXPORT_SYMBOL_GPL(gmap_enable); 152 + 153 + /** 154 + * gmap_disable - switch back to the standard primary address space 155 + * @gmap: pointer to the guest address space structure 156 + */ 157 + void gmap_disable(struct gmap *gmap) 158 + { 159 + S390_lowcore.gmap = 0UL; 160 + } 161 + EXPORT_SYMBOL_GPL(gmap_disable); 162 + 163 + /* 164 + * gmap_alloc_table is assumed to be called with mmap_sem held 165 + */ 166 + static int gmap_alloc_table(struct gmap *gmap, unsigned long *table, 167 + unsigned long init, unsigned long gaddr) 168 + { 169 + struct page *page; 170 + unsigned long *new; 171 + 172 + /* since we dont free the gmap table until gmap_free we can unlock */ 173 + page = alloc_pages(GFP_KERNEL, 2); 174 + if (!page) 175 + return -ENOMEM; 176 + new = (unsigned long *) page_to_phys(page); 177 + crst_table_init(new, init); 178 + spin_lock(&gmap->mm->page_table_lock); 179 + if (*table & _REGION_ENTRY_INVALID) { 180 + list_add(&page->lru, &gmap->crst_list); 181 + *table = (unsigned long) new | _REGION_ENTRY_LENGTH | 182 + (*table & _REGION_ENTRY_TYPE_MASK); 183 + page->index = gaddr; 184 + page = NULL; 185 + } 186 + spin_unlock(&gmap->mm->page_table_lock); 187 + if (page) 188 + __free_pages(page, 2); 189 + return 0; 190 + } 191 + 192 + /** 193 + * __gmap_segment_gaddr - find virtual address from segment pointer 194 + * @entry: pointer to a segment table entry in the guest address space 195 + * 196 + * Returns the virtual address in the guest address space for the segment 197 + */ 198 + static unsigned long __gmap_segment_gaddr(unsigned long *entry) 199 + { 200 + struct page *page; 201 + unsigned long offset, mask; 202 + 203 + offset = (unsigned long) entry / sizeof(unsigned long); 204 + offset = (offset & (PTRS_PER_PMD - 1)) * PMD_SIZE; 205 + mask = ~(PTRS_PER_PMD * sizeof(pmd_t) - 1); 206 + page = virt_to_page((void *)((unsigned long) entry & mask)); 207 + return page->index + offset; 208 + } 209 + 210 + /** 211 + * __gmap_unlink_by_vmaddr - unlink a single segment via a host address 212 + * @gmap: pointer to the guest address space structure 213 + * @vmaddr: address in the host process address space 214 + * 215 + * Returns 1 if a TLB flush is required 216 + */ 217 + static int __gmap_unlink_by_vmaddr(struct gmap *gmap, unsigned long vmaddr) 218 + { 219 + unsigned long *entry; 220 + int flush = 0; 221 + 222 + spin_lock(&gmap->guest_table_lock); 223 + entry = radix_tree_delete(&gmap->host_to_guest, vmaddr >> PMD_SHIFT); 224 + if (entry) { 225 + flush = (*entry != _SEGMENT_ENTRY_INVALID); 226 + *entry = _SEGMENT_ENTRY_INVALID; 227 + } 228 + spin_unlock(&gmap->guest_table_lock); 229 + return flush; 230 + } 231 + 232 + /** 233 + * __gmap_unmap_by_gaddr - unmap a single segment via a guest address 234 + * @gmap: pointer to the guest address space structure 235 + * @gaddr: address in the guest address space 236 + * 237 + * Returns 1 if a TLB flush is required 238 + */ 239 + static int __gmap_unmap_by_gaddr(struct gmap *gmap, unsigned long gaddr) 240 + { 241 + unsigned long vmaddr; 242 + 243 + vmaddr = (unsigned long) radix_tree_delete(&gmap->guest_to_host, 244 + gaddr >> PMD_SHIFT); 245 + return vmaddr ? __gmap_unlink_by_vmaddr(gmap, vmaddr) : 0; 246 + } 247 + 248 + /** 249 + * gmap_unmap_segment - unmap segment from the guest address space 250 + * @gmap: pointer to the guest address space structure 251 + * @to: address in the guest address space 252 + * @len: length of the memory area to unmap 253 + * 254 + * Returns 0 if the unmap succeeded, -EINVAL if not. 255 + */ 256 + int gmap_unmap_segment(struct gmap *gmap, unsigned long to, unsigned long len) 257 + { 258 + unsigned long off; 259 + int flush; 260 + 261 + if ((to | len) & (PMD_SIZE - 1)) 262 + return -EINVAL; 263 + if (len == 0 || to + len < to) 264 + return -EINVAL; 265 + 266 + flush = 0; 267 + down_write(&gmap->mm->mmap_sem); 268 + for (off = 0; off < len; off += PMD_SIZE) 269 + flush |= __gmap_unmap_by_gaddr(gmap, to + off); 270 + up_write(&gmap->mm->mmap_sem); 271 + if (flush) 272 + gmap_flush_tlb(gmap); 273 + return 0; 274 + } 275 + EXPORT_SYMBOL_GPL(gmap_unmap_segment); 276 + 277 + /** 278 + * gmap_map_segment - map a segment to the guest address space 279 + * @gmap: pointer to the guest address space structure 280 + * @from: source address in the parent address space 281 + * @to: target address in the guest address space 282 + * @len: length of the memory area to map 283 + * 284 + * Returns 0 if the mmap succeeded, -EINVAL or -ENOMEM if not. 285 + */ 286 + int gmap_map_segment(struct gmap *gmap, unsigned long from, 287 + unsigned long to, unsigned long len) 288 + { 289 + unsigned long off; 290 + int flush; 291 + 292 + if ((from | to | len) & (PMD_SIZE - 1)) 293 + return -EINVAL; 294 + if (len == 0 || from + len < from || to + len < to || 295 + from + len > TASK_MAX_SIZE || to + len > gmap->asce_end) 296 + return -EINVAL; 297 + 298 + flush = 0; 299 + down_write(&gmap->mm->mmap_sem); 300 + for (off = 0; off < len; off += PMD_SIZE) { 301 + /* Remove old translation */ 302 + flush |= __gmap_unmap_by_gaddr(gmap, to + off); 303 + /* Store new translation */ 304 + if (radix_tree_insert(&gmap->guest_to_host, 305 + (to + off) >> PMD_SHIFT, 306 + (void *) from + off)) 307 + break; 308 + } 309 + up_write(&gmap->mm->mmap_sem); 310 + if (flush) 311 + gmap_flush_tlb(gmap); 312 + if (off >= len) 313 + return 0; 314 + gmap_unmap_segment(gmap, to, len); 315 + return -ENOMEM; 316 + } 317 + EXPORT_SYMBOL_GPL(gmap_map_segment); 318 + 319 + /** 320 + * __gmap_translate - translate a guest address to a user space address 321 + * @gmap: pointer to guest mapping meta data structure 322 + * @gaddr: guest address 323 + * 324 + * Returns user space address which corresponds to the guest address or 325 + * -EFAULT if no such mapping exists. 326 + * This function does not establish potentially missing page table entries. 327 + * The mmap_sem of the mm that belongs to the address space must be held 328 + * when this function gets called. 329 + */ 330 + unsigned long __gmap_translate(struct gmap *gmap, unsigned long gaddr) 331 + { 332 + unsigned long vmaddr; 333 + 334 + vmaddr = (unsigned long) 335 + radix_tree_lookup(&gmap->guest_to_host, gaddr >> PMD_SHIFT); 336 + return vmaddr ? (vmaddr | (gaddr & ~PMD_MASK)) : -EFAULT; 337 + } 338 + EXPORT_SYMBOL_GPL(__gmap_translate); 339 + 340 + /** 341 + * gmap_translate - translate a guest address to a user space address 342 + * @gmap: pointer to guest mapping meta data structure 343 + * @gaddr: guest address 344 + * 345 + * Returns user space address which corresponds to the guest address or 346 + * -EFAULT if no such mapping exists. 347 + * This function does not establish potentially missing page table entries. 348 + */ 349 + unsigned long gmap_translate(struct gmap *gmap, unsigned long gaddr) 350 + { 351 + unsigned long rc; 352 + 353 + down_read(&gmap->mm->mmap_sem); 354 + rc = __gmap_translate(gmap, gaddr); 355 + up_read(&gmap->mm->mmap_sem); 356 + return rc; 357 + } 358 + EXPORT_SYMBOL_GPL(gmap_translate); 359 + 360 + /** 361 + * gmap_unlink - disconnect a page table from the gmap shadow tables 362 + * @gmap: pointer to guest mapping meta data structure 363 + * @table: pointer to the host page table 364 + * @vmaddr: vm address associated with the host page table 365 + */ 366 + void gmap_unlink(struct mm_struct *mm, unsigned long *table, 367 + unsigned long vmaddr) 368 + { 369 + struct gmap *gmap; 370 + int flush; 371 + 372 + list_for_each_entry(gmap, &mm->context.gmap_list, list) { 373 + flush = __gmap_unlink_by_vmaddr(gmap, vmaddr); 374 + if (flush) 375 + gmap_flush_tlb(gmap); 376 + } 377 + } 378 + 379 + /** 380 + * gmap_link - set up shadow page tables to connect a host to a guest address 381 + * @gmap: pointer to guest mapping meta data structure 382 + * @gaddr: guest address 383 + * @vmaddr: vm address 384 + * 385 + * Returns 0 on success, -ENOMEM for out of memory conditions, and -EFAULT 386 + * if the vm address is already mapped to a different guest segment. 387 + * The mmap_sem of the mm that belongs to the address space must be held 388 + * when this function gets called. 389 + */ 390 + int __gmap_link(struct gmap *gmap, unsigned long gaddr, unsigned long vmaddr) 391 + { 392 + struct mm_struct *mm; 393 + unsigned long *table; 394 + spinlock_t *ptl; 395 + pgd_t *pgd; 396 + pud_t *pud; 397 + pmd_t *pmd; 398 + int rc; 399 + 400 + /* Create higher level tables in the gmap page table */ 401 + table = gmap->table; 402 + if ((gmap->asce & _ASCE_TYPE_MASK) >= _ASCE_TYPE_REGION1) { 403 + table += (gaddr >> 53) & 0x7ff; 404 + if ((*table & _REGION_ENTRY_INVALID) && 405 + gmap_alloc_table(gmap, table, _REGION2_ENTRY_EMPTY, 406 + gaddr & 0xffe0000000000000UL)) 407 + return -ENOMEM; 408 + table = (unsigned long *)(*table & _REGION_ENTRY_ORIGIN); 409 + } 410 + if ((gmap->asce & _ASCE_TYPE_MASK) >= _ASCE_TYPE_REGION2) { 411 + table += (gaddr >> 42) & 0x7ff; 412 + if ((*table & _REGION_ENTRY_INVALID) && 413 + gmap_alloc_table(gmap, table, _REGION3_ENTRY_EMPTY, 414 + gaddr & 0xfffffc0000000000UL)) 415 + return -ENOMEM; 416 + table = (unsigned long *)(*table & _REGION_ENTRY_ORIGIN); 417 + } 418 + if ((gmap->asce & _ASCE_TYPE_MASK) >= _ASCE_TYPE_REGION3) { 419 + table += (gaddr >> 31) & 0x7ff; 420 + if ((*table & _REGION_ENTRY_INVALID) && 421 + gmap_alloc_table(gmap, table, _SEGMENT_ENTRY_EMPTY, 422 + gaddr & 0xffffffff80000000UL)) 423 + return -ENOMEM; 424 + table = (unsigned long *)(*table & _REGION_ENTRY_ORIGIN); 425 + } 426 + table += (gaddr >> 20) & 0x7ff; 427 + /* Walk the parent mm page table */ 428 + mm = gmap->mm; 429 + pgd = pgd_offset(mm, vmaddr); 430 + VM_BUG_ON(pgd_none(*pgd)); 431 + pud = pud_offset(pgd, vmaddr); 432 + VM_BUG_ON(pud_none(*pud)); 433 + pmd = pmd_offset(pud, vmaddr); 434 + VM_BUG_ON(pmd_none(*pmd)); 435 + /* large pmds cannot yet be handled */ 436 + if (pmd_large(*pmd)) 437 + return -EFAULT; 438 + /* Link gmap segment table entry location to page table. */ 439 + rc = radix_tree_preload(GFP_KERNEL); 440 + if (rc) 441 + return rc; 442 + ptl = pmd_lock(mm, pmd); 443 + spin_lock(&gmap->guest_table_lock); 444 + if (*table == _SEGMENT_ENTRY_INVALID) { 445 + rc = radix_tree_insert(&gmap->host_to_guest, 446 + vmaddr >> PMD_SHIFT, table); 447 + if (!rc) 448 + *table = pmd_val(*pmd); 449 + } else 450 + rc = 0; 451 + spin_unlock(&gmap->guest_table_lock); 452 + spin_unlock(ptl); 453 + radix_tree_preload_end(); 454 + return rc; 455 + } 456 + 457 + /** 458 + * gmap_fault - resolve a fault on a guest address 459 + * @gmap: pointer to guest mapping meta data structure 460 + * @gaddr: guest address 461 + * @fault_flags: flags to pass down to handle_mm_fault() 462 + * 463 + * Returns 0 on success, -ENOMEM for out of memory conditions, and -EFAULT 464 + * if the vm address is already mapped to a different guest segment. 465 + */ 466 + int gmap_fault(struct gmap *gmap, unsigned long gaddr, 467 + unsigned int fault_flags) 468 + { 469 + unsigned long vmaddr; 470 + int rc; 471 + bool unlocked; 472 + 473 + down_read(&gmap->mm->mmap_sem); 474 + 475 + retry: 476 + unlocked = false; 477 + vmaddr = __gmap_translate(gmap, gaddr); 478 + if (IS_ERR_VALUE(vmaddr)) { 479 + rc = vmaddr; 480 + goto out_up; 481 + } 482 + if (fixup_user_fault(current, gmap->mm, vmaddr, fault_flags, 483 + &unlocked)) { 484 + rc = -EFAULT; 485 + goto out_up; 486 + } 487 + /* 488 + * In the case that fixup_user_fault unlocked the mmap_sem during 489 + * faultin redo __gmap_translate to not race with a map/unmap_segment. 490 + */ 491 + if (unlocked) 492 + goto retry; 493 + 494 + rc = __gmap_link(gmap, gaddr, vmaddr); 495 + out_up: 496 + up_read(&gmap->mm->mmap_sem); 497 + return rc; 498 + } 499 + EXPORT_SYMBOL_GPL(gmap_fault); 500 + 501 + /* 502 + * this function is assumed to be called with mmap_sem held 503 + */ 504 + void __gmap_zap(struct gmap *gmap, unsigned long gaddr) 505 + { 506 + unsigned long vmaddr; 507 + spinlock_t *ptl; 508 + pte_t *ptep; 509 + 510 + /* Find the vm address for the guest address */ 511 + vmaddr = (unsigned long) radix_tree_lookup(&gmap->guest_to_host, 512 + gaddr >> PMD_SHIFT); 513 + if (vmaddr) { 514 + vmaddr |= gaddr & ~PMD_MASK; 515 + /* Get pointer to the page table entry */ 516 + ptep = get_locked_pte(gmap->mm, vmaddr, &ptl); 517 + if (likely(ptep)) 518 + ptep_zap_unused(gmap->mm, vmaddr, ptep, 0); 519 + pte_unmap_unlock(ptep, ptl); 520 + } 521 + } 522 + EXPORT_SYMBOL_GPL(__gmap_zap); 523 + 524 + void gmap_discard(struct gmap *gmap, unsigned long from, unsigned long to) 525 + { 526 + unsigned long gaddr, vmaddr, size; 527 + struct vm_area_struct *vma; 528 + 529 + down_read(&gmap->mm->mmap_sem); 530 + for (gaddr = from; gaddr < to; 531 + gaddr = (gaddr + PMD_SIZE) & PMD_MASK) { 532 + /* Find the vm address for the guest address */ 533 + vmaddr = (unsigned long) 534 + radix_tree_lookup(&gmap->guest_to_host, 535 + gaddr >> PMD_SHIFT); 536 + if (!vmaddr) 537 + continue; 538 + vmaddr |= gaddr & ~PMD_MASK; 539 + /* Find vma in the parent mm */ 540 + vma = find_vma(gmap->mm, vmaddr); 541 + size = min(to - gaddr, PMD_SIZE - (gaddr & ~PMD_MASK)); 542 + zap_page_range(vma, vmaddr, size, NULL); 543 + } 544 + up_read(&gmap->mm->mmap_sem); 545 + } 546 + EXPORT_SYMBOL_GPL(gmap_discard); 547 + 548 + static LIST_HEAD(gmap_notifier_list); 549 + static DEFINE_SPINLOCK(gmap_notifier_lock); 550 + 551 + /** 552 + * gmap_register_ipte_notifier - register a pte invalidation callback 553 + * @nb: pointer to the gmap notifier block 554 + */ 555 + void gmap_register_ipte_notifier(struct gmap_notifier *nb) 556 + { 557 + spin_lock(&gmap_notifier_lock); 558 + list_add(&nb->list, &gmap_notifier_list); 559 + spin_unlock(&gmap_notifier_lock); 560 + } 561 + EXPORT_SYMBOL_GPL(gmap_register_ipte_notifier); 562 + 563 + /** 564 + * gmap_unregister_ipte_notifier - remove a pte invalidation callback 565 + * @nb: pointer to the gmap notifier block 566 + */ 567 + void gmap_unregister_ipte_notifier(struct gmap_notifier *nb) 568 + { 569 + spin_lock(&gmap_notifier_lock); 570 + list_del_init(&nb->list); 571 + spin_unlock(&gmap_notifier_lock); 572 + } 573 + EXPORT_SYMBOL_GPL(gmap_unregister_ipte_notifier); 574 + 575 + /** 576 + * gmap_ipte_notify - mark a range of ptes for invalidation notification 577 + * @gmap: pointer to guest mapping meta data structure 578 + * @gaddr: virtual address in the guest address space 579 + * @len: size of area 580 + * 581 + * Returns 0 if for each page in the given range a gmap mapping exists and 582 + * the invalidation notification could be set. If the gmap mapping is missing 583 + * for one or more pages -EFAULT is returned. If no memory could be allocated 584 + * -ENOMEM is returned. This function establishes missing page table entries. 585 + */ 586 + int gmap_ipte_notify(struct gmap *gmap, unsigned long gaddr, unsigned long len) 587 + { 588 + unsigned long addr; 589 + spinlock_t *ptl; 590 + pte_t *ptep; 591 + bool unlocked; 592 + int rc = 0; 593 + 594 + if ((gaddr & ~PAGE_MASK) || (len & ~PAGE_MASK)) 595 + return -EINVAL; 596 + down_read(&gmap->mm->mmap_sem); 597 + while (len) { 598 + unlocked = false; 599 + /* Convert gmap address and connect the page tables */ 600 + addr = __gmap_translate(gmap, gaddr); 601 + if (IS_ERR_VALUE(addr)) { 602 + rc = addr; 603 + break; 604 + } 605 + /* Get the page mapped */ 606 + if (fixup_user_fault(current, gmap->mm, addr, FAULT_FLAG_WRITE, 607 + &unlocked)) { 608 + rc = -EFAULT; 609 + break; 610 + } 611 + /* While trying to map mmap_sem got unlocked. Let us retry */ 612 + if (unlocked) 613 + continue; 614 + rc = __gmap_link(gmap, gaddr, addr); 615 + if (rc) 616 + break; 617 + /* Walk the process page table, lock and get pte pointer */ 618 + ptep = get_locked_pte(gmap->mm, addr, &ptl); 619 + VM_BUG_ON(!ptep); 620 + /* Set notification bit in the pgste of the pte */ 621 + if ((pte_val(*ptep) & (_PAGE_INVALID | _PAGE_PROTECT)) == 0) { 622 + ptep_set_notify(gmap->mm, addr, ptep); 623 + gaddr += PAGE_SIZE; 624 + len -= PAGE_SIZE; 625 + } 626 + pte_unmap_unlock(ptep, ptl); 627 + } 628 + up_read(&gmap->mm->mmap_sem); 629 + return rc; 630 + } 631 + EXPORT_SYMBOL_GPL(gmap_ipte_notify); 632 + 633 + /** 634 + * ptep_notify - call all invalidation callbacks for a specific pte. 635 + * @mm: pointer to the process mm_struct 636 + * @addr: virtual address in the process address space 637 + * @pte: pointer to the page table entry 638 + * 639 + * This function is assumed to be called with the page table lock held 640 + * for the pte to notify. 641 + */ 642 + void ptep_notify(struct mm_struct *mm, unsigned long vmaddr, pte_t *pte) 643 + { 644 + unsigned long offset, gaddr; 645 + unsigned long *table; 646 + struct gmap_notifier *nb; 647 + struct gmap *gmap; 648 + 649 + offset = ((unsigned long) pte) & (255 * sizeof(pte_t)); 650 + offset = offset * (4096 / sizeof(pte_t)); 651 + spin_lock(&gmap_notifier_lock); 652 + list_for_each_entry(gmap, &mm->context.gmap_list, list) { 653 + table = radix_tree_lookup(&gmap->host_to_guest, 654 + vmaddr >> PMD_SHIFT); 655 + if (!table) 656 + continue; 657 + gaddr = __gmap_segment_gaddr(table) + offset; 658 + list_for_each_entry(nb, &gmap_notifier_list, list) 659 + nb->notifier_call(gmap, gaddr); 660 + } 661 + spin_unlock(&gmap_notifier_lock); 662 + } 663 + EXPORT_SYMBOL_GPL(ptep_notify); 664 + 665 + static inline void thp_split_mm(struct mm_struct *mm) 666 + { 667 + #ifdef CONFIG_TRANSPARENT_HUGEPAGE 668 + struct vm_area_struct *vma; 669 + unsigned long addr; 670 + 671 + for (vma = mm->mmap; vma != NULL; vma = vma->vm_next) { 672 + for (addr = vma->vm_start; 673 + addr < vma->vm_end; 674 + addr += PAGE_SIZE) 675 + follow_page(vma, addr, FOLL_SPLIT); 676 + vma->vm_flags &= ~VM_HUGEPAGE; 677 + vma->vm_flags |= VM_NOHUGEPAGE; 678 + } 679 + mm->def_flags |= VM_NOHUGEPAGE; 680 + #endif 681 + } 682 + 683 + /* 684 + * switch on pgstes for its userspace process (for kvm) 685 + */ 686 + int s390_enable_sie(void) 687 + { 688 + struct mm_struct *mm = current->mm; 689 + 690 + /* Do we have pgstes? if yes, we are done */ 691 + if (mm_has_pgste(mm)) 692 + return 0; 693 + /* Fail if the page tables are 2K */ 694 + if (!mm_alloc_pgste(mm)) 695 + return -EINVAL; 696 + down_write(&mm->mmap_sem); 697 + mm->context.has_pgste = 1; 698 + /* split thp mappings and disable thp for future mappings */ 699 + thp_split_mm(mm); 700 + up_write(&mm->mmap_sem); 701 + return 0; 702 + } 703 + EXPORT_SYMBOL_GPL(s390_enable_sie); 704 + 705 + /* 706 + * Enable storage key handling from now on and initialize the storage 707 + * keys with the default key. 708 + */ 709 + static int __s390_enable_skey(pte_t *pte, unsigned long addr, 710 + unsigned long next, struct mm_walk *walk) 711 + { 712 + /* 713 + * Remove all zero page mappings, 714 + * after establishing a policy to forbid zero page mappings 715 + * following faults for that page will get fresh anonymous pages 716 + */ 717 + if (is_zero_pfn(pte_pfn(*pte))) 718 + ptep_xchg_direct(walk->mm, addr, pte, __pte(_PAGE_INVALID)); 719 + /* Clear storage key */ 720 + ptep_zap_key(walk->mm, addr, pte); 721 + return 0; 722 + } 723 + 724 + int s390_enable_skey(void) 725 + { 726 + struct mm_walk walk = { .pte_entry = __s390_enable_skey }; 727 + struct mm_struct *mm = current->mm; 728 + struct vm_area_struct *vma; 729 + int rc = 0; 730 + 731 + down_write(&mm->mmap_sem); 732 + if (mm_use_skey(mm)) 733 + goto out_up; 734 + 735 + mm->context.use_skey = 1; 736 + for (vma = mm->mmap; vma; vma = vma->vm_next) { 737 + if (ksm_madvise(vma, vma->vm_start, vma->vm_end, 738 + MADV_UNMERGEABLE, &vma->vm_flags)) { 739 + mm->context.use_skey = 0; 740 + rc = -ENOMEM; 741 + goto out_up; 742 + } 743 + } 744 + mm->def_flags &= ~VM_MERGEABLE; 745 + 746 + walk.mm = mm; 747 + walk_page_range(0, TASK_SIZE, &walk); 748 + 749 + out_up: 750 + up_write(&mm->mmap_sem); 751 + return rc; 752 + } 753 + EXPORT_SYMBOL_GPL(s390_enable_skey); 754 + 755 + /* 756 + * Reset CMMA state, make all pages stable again. 757 + */ 758 + static int __s390_reset_cmma(pte_t *pte, unsigned long addr, 759 + unsigned long next, struct mm_walk *walk) 760 + { 761 + ptep_zap_unused(walk->mm, addr, pte, 1); 762 + return 0; 763 + } 764 + 765 + void s390_reset_cmma(struct mm_struct *mm) 766 + { 767 + struct mm_walk walk = { .pte_entry = __s390_reset_cmma }; 768 + 769 + down_write(&mm->mmap_sem); 770 + walk.mm = mm; 771 + walk_page_range(0, TASK_SIZE, &walk); 772 + up_write(&mm->mmap_sem); 773 + } 774 + EXPORT_SYMBOL_GPL(s390_reset_cmma);
+3 -4
arch/s390/mm/hugetlbpage.c
··· 105 105 unsigned long addr, pte_t *ptep) 106 106 { 107 107 pmd_t *pmdp = (pmd_t *) ptep; 108 - pte_t pte = huge_ptep_get(ptep); 108 + pmd_t old; 109 109 110 - pmdp_flush_direct(mm, addr, pmdp); 111 - pmd_val(*pmdp) = _SEGMENT_ENTRY_EMPTY; 112 - return pte; 110 + old = pmdp_xchg_direct(mm, addr, pmdp, __pmd(_SEGMENT_ENTRY_EMPTY)); 111 + return __pmd_to_pte(old); 113 112 } 114 113 115 114 pte_t *huge_pte_alloc(struct mm_struct *mm,
+3 -5
arch/s390/mm/pageattr.c
··· 65 65 static void change_page_attr(unsigned long addr, int numpages, 66 66 pte_t (*set) (pte_t)) 67 67 { 68 - pte_t *ptep, pte; 68 + pte_t *ptep; 69 69 int i; 70 70 71 71 for (i = 0; i < numpages; i++) { 72 72 ptep = walk_page_table(addr); 73 73 if (WARN_ON_ONCE(!ptep)) 74 74 break; 75 - pte = *ptep; 76 - pte = set(pte); 77 - __ptep_ipte(addr, ptep); 78 - *ptep = pte; 75 + *ptep = set(*ptep); 79 76 addr += PAGE_SIZE; 80 77 } 78 + __tlb_flush_kernel(); 81 79 } 82 80 83 81 int set_memory_ro(unsigned long addr, int numpages)
+360
arch/s390/mm/pgalloc.c
··· 1 + /* 2 + * Page table allocation functions 3 + * 4 + * Copyright IBM Corp. 2016 5 + * Author(s): Martin Schwidefsky <schwidefsky@de.ibm.com> 6 + */ 7 + 8 + #include <linux/mm.h> 9 + #include <linux/sysctl.h> 10 + #include <asm/mmu_context.h> 11 + #include <asm/pgalloc.h> 12 + #include <asm/gmap.h> 13 + #include <asm/tlb.h> 14 + #include <asm/tlbflush.h> 15 + 16 + #ifdef CONFIG_PGSTE 17 + 18 + static int page_table_allocate_pgste_min = 0; 19 + static int page_table_allocate_pgste_max = 1; 20 + int page_table_allocate_pgste = 0; 21 + EXPORT_SYMBOL(page_table_allocate_pgste); 22 + 23 + static struct ctl_table page_table_sysctl[] = { 24 + { 25 + .procname = "allocate_pgste", 26 + .data = &page_table_allocate_pgste, 27 + .maxlen = sizeof(int), 28 + .mode = S_IRUGO | S_IWUSR, 29 + .proc_handler = proc_dointvec, 30 + .extra1 = &page_table_allocate_pgste_min, 31 + .extra2 = &page_table_allocate_pgste_max, 32 + }, 33 + { } 34 + }; 35 + 36 + static struct ctl_table page_table_sysctl_dir[] = { 37 + { 38 + .procname = "vm", 39 + .maxlen = 0, 40 + .mode = 0555, 41 + .child = page_table_sysctl, 42 + }, 43 + { } 44 + }; 45 + 46 + static int __init page_table_register_sysctl(void) 47 + { 48 + return register_sysctl_table(page_table_sysctl_dir) ? 0 : -ENOMEM; 49 + } 50 + __initcall(page_table_register_sysctl); 51 + 52 + #endif /* CONFIG_PGSTE */ 53 + 54 + unsigned long *crst_table_alloc(struct mm_struct *mm) 55 + { 56 + struct page *page = alloc_pages(GFP_KERNEL, 2); 57 + 58 + if (!page) 59 + return NULL; 60 + return (unsigned long *) page_to_phys(page); 61 + } 62 + 63 + void crst_table_free(struct mm_struct *mm, unsigned long *table) 64 + { 65 + free_pages((unsigned long) table, 2); 66 + } 67 + 68 + static void __crst_table_upgrade(void *arg) 69 + { 70 + struct mm_struct *mm = arg; 71 + 72 + if (current->active_mm == mm) { 73 + clear_user_asce(); 74 + set_user_asce(mm); 75 + } 76 + __tlb_flush_local(); 77 + } 78 + 79 + int crst_table_upgrade(struct mm_struct *mm, unsigned long limit) 80 + { 81 + unsigned long *table, *pgd; 82 + unsigned long entry; 83 + int flush; 84 + 85 + BUG_ON(limit > TASK_MAX_SIZE); 86 + flush = 0; 87 + repeat: 88 + table = crst_table_alloc(mm); 89 + if (!table) 90 + return -ENOMEM; 91 + spin_lock_bh(&mm->page_table_lock); 92 + if (mm->context.asce_limit < limit) { 93 + pgd = (unsigned long *) mm->pgd; 94 + if (mm->context.asce_limit <= (1UL << 31)) { 95 + entry = _REGION3_ENTRY_EMPTY; 96 + mm->context.asce_limit = 1UL << 42; 97 + mm->context.asce_bits = _ASCE_TABLE_LENGTH | 98 + _ASCE_USER_BITS | 99 + _ASCE_TYPE_REGION3; 100 + } else { 101 + entry = _REGION2_ENTRY_EMPTY; 102 + mm->context.asce_limit = 1UL << 53; 103 + mm->context.asce_bits = _ASCE_TABLE_LENGTH | 104 + _ASCE_USER_BITS | 105 + _ASCE_TYPE_REGION2; 106 + } 107 + crst_table_init(table, entry); 108 + pgd_populate(mm, (pgd_t *) table, (pud_t *) pgd); 109 + mm->pgd = (pgd_t *) table; 110 + mm->task_size = mm->context.asce_limit; 111 + table = NULL; 112 + flush = 1; 113 + } 114 + spin_unlock_bh(&mm->page_table_lock); 115 + if (table) 116 + crst_table_free(mm, table); 117 + if (mm->context.asce_limit < limit) 118 + goto repeat; 119 + if (flush) 120 + on_each_cpu(__crst_table_upgrade, mm, 0); 121 + return 0; 122 + } 123 + 124 + void crst_table_downgrade(struct mm_struct *mm, unsigned long limit) 125 + { 126 + pgd_t *pgd; 127 + 128 + if (current->active_mm == mm) { 129 + clear_user_asce(); 130 + __tlb_flush_mm(mm); 131 + } 132 + while (mm->context.asce_limit > limit) { 133 + pgd = mm->pgd; 134 + switch (pgd_val(*pgd) & _REGION_ENTRY_TYPE_MASK) { 135 + case _REGION_ENTRY_TYPE_R2: 136 + mm->context.asce_limit = 1UL << 42; 137 + mm->context.asce_bits = _ASCE_TABLE_LENGTH | 138 + _ASCE_USER_BITS | 139 + _ASCE_TYPE_REGION3; 140 + break; 141 + case _REGION_ENTRY_TYPE_R3: 142 + mm->context.asce_limit = 1UL << 31; 143 + mm->context.asce_bits = _ASCE_TABLE_LENGTH | 144 + _ASCE_USER_BITS | 145 + _ASCE_TYPE_SEGMENT; 146 + break; 147 + default: 148 + BUG(); 149 + } 150 + mm->pgd = (pgd_t *) (pgd_val(*pgd) & _REGION_ENTRY_ORIGIN); 151 + mm->task_size = mm->context.asce_limit; 152 + crst_table_free(mm, (unsigned long *) pgd); 153 + } 154 + if (current->active_mm == mm) 155 + set_user_asce(mm); 156 + } 157 + 158 + static inline unsigned int atomic_xor_bits(atomic_t *v, unsigned int bits) 159 + { 160 + unsigned int old, new; 161 + 162 + do { 163 + old = atomic_read(v); 164 + new = old ^ bits; 165 + } while (atomic_cmpxchg(v, old, new) != old); 166 + return new; 167 + } 168 + 169 + /* 170 + * page table entry allocation/free routines. 171 + */ 172 + unsigned long *page_table_alloc(struct mm_struct *mm) 173 + { 174 + unsigned long *table; 175 + struct page *page; 176 + unsigned int mask, bit; 177 + 178 + /* Try to get a fragment of a 4K page as a 2K page table */ 179 + if (!mm_alloc_pgste(mm)) { 180 + table = NULL; 181 + spin_lock_bh(&mm->context.list_lock); 182 + if (!list_empty(&mm->context.pgtable_list)) { 183 + page = list_first_entry(&mm->context.pgtable_list, 184 + struct page, lru); 185 + mask = atomic_read(&page->_mapcount); 186 + mask = (mask | (mask >> 4)) & 3; 187 + if (mask != 3) { 188 + table = (unsigned long *) page_to_phys(page); 189 + bit = mask & 1; /* =1 -> second 2K */ 190 + if (bit) 191 + table += PTRS_PER_PTE; 192 + atomic_xor_bits(&page->_mapcount, 1U << bit); 193 + list_del(&page->lru); 194 + } 195 + } 196 + spin_unlock_bh(&mm->context.list_lock); 197 + if (table) 198 + return table; 199 + } 200 + /* Allocate a fresh page */ 201 + page = alloc_page(GFP_KERNEL|__GFP_REPEAT); 202 + if (!page) 203 + return NULL; 204 + if (!pgtable_page_ctor(page)) { 205 + __free_page(page); 206 + return NULL; 207 + } 208 + /* Initialize page table */ 209 + table = (unsigned long *) page_to_phys(page); 210 + if (mm_alloc_pgste(mm)) { 211 + /* Return 4K page table with PGSTEs */ 212 + atomic_set(&page->_mapcount, 3); 213 + clear_table(table, _PAGE_INVALID, PAGE_SIZE/2); 214 + clear_table(table + PTRS_PER_PTE, 0, PAGE_SIZE/2); 215 + } else { 216 + /* Return the first 2K fragment of the page */ 217 + atomic_set(&page->_mapcount, 1); 218 + clear_table(table, _PAGE_INVALID, PAGE_SIZE); 219 + spin_lock_bh(&mm->context.list_lock); 220 + list_add(&page->lru, &mm->context.pgtable_list); 221 + spin_unlock_bh(&mm->context.list_lock); 222 + } 223 + return table; 224 + } 225 + 226 + void page_table_free(struct mm_struct *mm, unsigned long *table) 227 + { 228 + struct page *page; 229 + unsigned int bit, mask; 230 + 231 + page = pfn_to_page(__pa(table) >> PAGE_SHIFT); 232 + if (!mm_alloc_pgste(mm)) { 233 + /* Free 2K page table fragment of a 4K page */ 234 + bit = (__pa(table) & ~PAGE_MASK)/(PTRS_PER_PTE*sizeof(pte_t)); 235 + spin_lock_bh(&mm->context.list_lock); 236 + mask = atomic_xor_bits(&page->_mapcount, 1U << bit); 237 + if (mask & 3) 238 + list_add(&page->lru, &mm->context.pgtable_list); 239 + else 240 + list_del(&page->lru); 241 + spin_unlock_bh(&mm->context.list_lock); 242 + if (mask != 0) 243 + return; 244 + } 245 + 246 + pgtable_page_dtor(page); 247 + atomic_set(&page->_mapcount, -1); 248 + __free_page(page); 249 + } 250 + 251 + void page_table_free_rcu(struct mmu_gather *tlb, unsigned long *table, 252 + unsigned long vmaddr) 253 + { 254 + struct mm_struct *mm; 255 + struct page *page; 256 + unsigned int bit, mask; 257 + 258 + mm = tlb->mm; 259 + page = pfn_to_page(__pa(table) >> PAGE_SHIFT); 260 + if (mm_alloc_pgste(mm)) { 261 + gmap_unlink(mm, table, vmaddr); 262 + table = (unsigned long *) (__pa(table) | 3); 263 + tlb_remove_table(tlb, table); 264 + return; 265 + } 266 + bit = (__pa(table) & ~PAGE_MASK) / (PTRS_PER_PTE*sizeof(pte_t)); 267 + spin_lock_bh(&mm->context.list_lock); 268 + mask = atomic_xor_bits(&page->_mapcount, 0x11U << bit); 269 + if (mask & 3) 270 + list_add_tail(&page->lru, &mm->context.pgtable_list); 271 + else 272 + list_del(&page->lru); 273 + spin_unlock_bh(&mm->context.list_lock); 274 + table = (unsigned long *) (__pa(table) | (1U << bit)); 275 + tlb_remove_table(tlb, table); 276 + } 277 + 278 + static void __tlb_remove_table(void *_table) 279 + { 280 + unsigned int mask = (unsigned long) _table & 3; 281 + void *table = (void *)((unsigned long) _table ^ mask); 282 + struct page *page = pfn_to_page(__pa(table) >> PAGE_SHIFT); 283 + 284 + switch (mask) { 285 + case 0: /* pmd or pud */ 286 + free_pages((unsigned long) table, 2); 287 + break; 288 + case 1: /* lower 2K of a 4K page table */ 289 + case 2: /* higher 2K of a 4K page table */ 290 + if (atomic_xor_bits(&page->_mapcount, mask << 4) != 0) 291 + break; 292 + /* fallthrough */ 293 + case 3: /* 4K page table with pgstes */ 294 + pgtable_page_dtor(page); 295 + atomic_set(&page->_mapcount, -1); 296 + __free_page(page); 297 + break; 298 + } 299 + } 300 + 301 + static void tlb_remove_table_smp_sync(void *arg) 302 + { 303 + /* Simply deliver the interrupt */ 304 + } 305 + 306 + static void tlb_remove_table_one(void *table) 307 + { 308 + /* 309 + * This isn't an RCU grace period and hence the page-tables cannot be 310 + * assumed to be actually RCU-freed. 311 + * 312 + * It is however sufficient for software page-table walkers that rely 313 + * on IRQ disabling. See the comment near struct mmu_table_batch. 314 + */ 315 + smp_call_function(tlb_remove_table_smp_sync, NULL, 1); 316 + __tlb_remove_table(table); 317 + } 318 + 319 + static void tlb_remove_table_rcu(struct rcu_head *head) 320 + { 321 + struct mmu_table_batch *batch; 322 + int i; 323 + 324 + batch = container_of(head, struct mmu_table_batch, rcu); 325 + 326 + for (i = 0; i < batch->nr; i++) 327 + __tlb_remove_table(batch->tables[i]); 328 + 329 + free_page((unsigned long)batch); 330 + } 331 + 332 + void tlb_table_flush(struct mmu_gather *tlb) 333 + { 334 + struct mmu_table_batch **batch = &tlb->batch; 335 + 336 + if (*batch) { 337 + call_rcu_sched(&(*batch)->rcu, tlb_remove_table_rcu); 338 + *batch = NULL; 339 + } 340 + } 341 + 342 + void tlb_remove_table(struct mmu_gather *tlb, void *table) 343 + { 344 + struct mmu_table_batch **batch = &tlb->batch; 345 + 346 + tlb->mm->context.flush_mm = 1; 347 + if (*batch == NULL) { 348 + *batch = (struct mmu_table_batch *) 349 + __get_free_page(GFP_NOWAIT | __GFP_NOWARN); 350 + if (*batch == NULL) { 351 + __tlb_flush_mm_lazy(tlb->mm); 352 + tlb_remove_table_one(table); 353 + return; 354 + } 355 + (*batch)->nr = 0; 356 + } 357 + (*batch)->tables[(*batch)->nr++] = table; 358 + if ((*batch)->nr == MAX_TABLE_BATCH) 359 + tlb_flush_mmu(tlb); 360 + }
+456 -1245
arch/s390/mm/pgtable.c
··· 24 24 #include <asm/tlbflush.h> 25 25 #include <asm/mmu_context.h> 26 26 27 - unsigned long *crst_table_alloc(struct mm_struct *mm) 27 + static inline pte_t ptep_flush_direct(struct mm_struct *mm, 28 + unsigned long addr, pte_t *ptep) 28 29 { 29 - struct page *page = alloc_pages(GFP_KERNEL, 2); 30 + int active, count; 31 + pte_t old; 30 32 31 - if (!page) 32 - return NULL; 33 - return (unsigned long *) page_to_phys(page); 34 - } 35 - 36 - void crst_table_free(struct mm_struct *mm, unsigned long *table) 37 - { 38 - free_pages((unsigned long) table, 2); 39 - } 40 - 41 - static void __crst_table_upgrade(void *arg) 42 - { 43 - struct mm_struct *mm = arg; 44 - 45 - if (current->active_mm == mm) { 46 - clear_user_asce(); 47 - set_user_asce(mm); 48 - } 49 - __tlb_flush_local(); 50 - } 51 - 52 - int crst_table_upgrade(struct mm_struct *mm, unsigned long limit) 53 - { 54 - unsigned long *table, *pgd; 55 - unsigned long entry; 56 - int flush; 57 - 58 - BUG_ON(limit > TASK_MAX_SIZE); 59 - flush = 0; 60 - repeat: 61 - table = crst_table_alloc(mm); 62 - if (!table) 63 - return -ENOMEM; 64 - spin_lock_bh(&mm->page_table_lock); 65 - if (mm->context.asce_limit < limit) { 66 - pgd = (unsigned long *) mm->pgd; 67 - if (mm->context.asce_limit <= (1UL << 31)) { 68 - entry = _REGION3_ENTRY_EMPTY; 69 - mm->context.asce_limit = 1UL << 42; 70 - mm->context.asce_bits = _ASCE_TABLE_LENGTH | 71 - _ASCE_USER_BITS | 72 - _ASCE_TYPE_REGION3; 73 - } else { 74 - entry = _REGION2_ENTRY_EMPTY; 75 - mm->context.asce_limit = 1UL << 53; 76 - mm->context.asce_bits = _ASCE_TABLE_LENGTH | 77 - _ASCE_USER_BITS | 78 - _ASCE_TYPE_REGION2; 79 - } 80 - crst_table_init(table, entry); 81 - pgd_populate(mm, (pgd_t *) table, (pud_t *) pgd); 82 - mm->pgd = (pgd_t *) table; 83 - mm->task_size = mm->context.asce_limit; 84 - table = NULL; 85 - flush = 1; 86 - } 87 - spin_unlock_bh(&mm->page_table_lock); 88 - if (table) 89 - crst_table_free(mm, table); 90 - if (mm->context.asce_limit < limit) 91 - goto repeat; 92 - if (flush) 93 - on_each_cpu(__crst_table_upgrade, mm, 0); 94 - return 0; 95 - } 96 - 97 - void crst_table_downgrade(struct mm_struct *mm, unsigned long limit) 98 - { 99 - pgd_t *pgd; 100 - 101 - if (current->active_mm == mm) { 102 - clear_user_asce(); 103 - __tlb_flush_mm(mm); 104 - } 105 - while (mm->context.asce_limit > limit) { 106 - pgd = mm->pgd; 107 - switch (pgd_val(*pgd) & _REGION_ENTRY_TYPE_MASK) { 108 - case _REGION_ENTRY_TYPE_R2: 109 - mm->context.asce_limit = 1UL << 42; 110 - mm->context.asce_bits = _ASCE_TABLE_LENGTH | 111 - _ASCE_USER_BITS | 112 - _ASCE_TYPE_REGION3; 113 - break; 114 - case _REGION_ENTRY_TYPE_R3: 115 - mm->context.asce_limit = 1UL << 31; 116 - mm->context.asce_bits = _ASCE_TABLE_LENGTH | 117 - _ASCE_USER_BITS | 118 - _ASCE_TYPE_SEGMENT; 119 - break; 120 - default: 121 - BUG(); 122 - } 123 - mm->pgd = (pgd_t *) (pgd_val(*pgd) & _REGION_ENTRY_ORIGIN); 124 - mm->task_size = mm->context.asce_limit; 125 - crst_table_free(mm, (unsigned long *) pgd); 126 - } 127 - if (current->active_mm == mm) 128 - set_user_asce(mm); 129 - } 130 - 131 - #ifdef CONFIG_PGSTE 132 - 133 - /** 134 - * gmap_alloc - allocate a guest address space 135 - * @mm: pointer to the parent mm_struct 136 - * @limit: maximum address of the gmap address space 137 - * 138 - * Returns a guest address space structure. 139 - */ 140 - struct gmap *gmap_alloc(struct mm_struct *mm, unsigned long limit) 141 - { 142 - struct gmap *gmap; 143 - struct page *page; 144 - unsigned long *table; 145 - unsigned long etype, atype; 146 - 147 - if (limit < (1UL << 31)) { 148 - limit = (1UL << 31) - 1; 149 - atype = _ASCE_TYPE_SEGMENT; 150 - etype = _SEGMENT_ENTRY_EMPTY; 151 - } else if (limit < (1UL << 42)) { 152 - limit = (1UL << 42) - 1; 153 - atype = _ASCE_TYPE_REGION3; 154 - etype = _REGION3_ENTRY_EMPTY; 155 - } else if (limit < (1UL << 53)) { 156 - limit = (1UL << 53) - 1; 157 - atype = _ASCE_TYPE_REGION2; 158 - etype = _REGION2_ENTRY_EMPTY; 159 - } else { 160 - limit = -1UL; 161 - atype = _ASCE_TYPE_REGION1; 162 - etype = _REGION1_ENTRY_EMPTY; 163 - } 164 - gmap = kzalloc(sizeof(struct gmap), GFP_KERNEL); 165 - if (!gmap) 166 - goto out; 167 - INIT_LIST_HEAD(&gmap->crst_list); 168 - INIT_RADIX_TREE(&gmap->guest_to_host, GFP_KERNEL); 169 - INIT_RADIX_TREE(&gmap->host_to_guest, GFP_ATOMIC); 170 - spin_lock_init(&gmap->guest_table_lock); 171 - gmap->mm = mm; 172 - page = alloc_pages(GFP_KERNEL, 2); 173 - if (!page) 174 - goto out_free; 175 - page->index = 0; 176 - list_add(&page->lru, &gmap->crst_list); 177 - table = (unsigned long *) page_to_phys(page); 178 - crst_table_init(table, etype); 179 - gmap->table = table; 180 - gmap->asce = atype | _ASCE_TABLE_LENGTH | 181 - _ASCE_USER_BITS | __pa(table); 182 - gmap->asce_end = limit; 183 - down_write(&mm->mmap_sem); 184 - list_add(&gmap->list, &mm->context.gmap_list); 185 - up_write(&mm->mmap_sem); 186 - return gmap; 187 - 188 - out_free: 189 - kfree(gmap); 190 - out: 191 - return NULL; 192 - } 193 - EXPORT_SYMBOL_GPL(gmap_alloc); 194 - 195 - static void gmap_flush_tlb(struct gmap *gmap) 196 - { 197 - if (MACHINE_HAS_IDTE) 198 - __tlb_flush_asce(gmap->mm, gmap->asce); 33 + old = *ptep; 34 + if (unlikely(pte_val(old) & _PAGE_INVALID)) 35 + return old; 36 + active = (mm == current->active_mm) ? 1 : 0; 37 + count = atomic_add_return(0x10000, &mm->context.attach_count); 38 + if (MACHINE_HAS_TLB_LC && (count & 0xffff) <= active && 39 + cpumask_equal(mm_cpumask(mm), cpumask_of(smp_processor_id()))) 40 + __ptep_ipte_local(addr, ptep); 199 41 else 200 - __tlb_flush_global(); 42 + __ptep_ipte(addr, ptep); 43 + atomic_sub(0x10000, &mm->context.attach_count); 44 + return old; 201 45 } 202 46 203 - static void gmap_radix_tree_free(struct radix_tree_root *root) 47 + static inline pte_t ptep_flush_lazy(struct mm_struct *mm, 48 + unsigned long addr, pte_t *ptep) 204 49 { 205 - struct radix_tree_iter iter; 206 - unsigned long indices[16]; 207 - unsigned long index; 208 - void **slot; 209 - int i, nr; 50 + int active, count; 51 + pte_t old; 210 52 211 - /* A radix tree is freed by deleting all of its entries */ 212 - index = 0; 213 - do { 214 - nr = 0; 215 - radix_tree_for_each_slot(slot, root, &iter, index) { 216 - indices[nr] = iter.index; 217 - if (++nr == 16) 218 - break; 219 - } 220 - for (i = 0; i < nr; i++) { 221 - index = indices[i]; 222 - radix_tree_delete(root, index); 223 - } 224 - } while (nr > 0); 225 - } 226 - 227 - /** 228 - * gmap_free - free a guest address space 229 - * @gmap: pointer to the guest address space structure 230 - */ 231 - void gmap_free(struct gmap *gmap) 232 - { 233 - struct page *page, *next; 234 - 235 - /* Flush tlb. */ 236 - if (MACHINE_HAS_IDTE) 237 - __tlb_flush_asce(gmap->mm, gmap->asce); 238 - else 239 - __tlb_flush_global(); 240 - 241 - /* Free all segment & region tables. */ 242 - list_for_each_entry_safe(page, next, &gmap->crst_list, lru) 243 - __free_pages(page, 2); 244 - gmap_radix_tree_free(&gmap->guest_to_host); 245 - gmap_radix_tree_free(&gmap->host_to_guest); 246 - down_write(&gmap->mm->mmap_sem); 247 - list_del(&gmap->list); 248 - up_write(&gmap->mm->mmap_sem); 249 - kfree(gmap); 250 - } 251 - EXPORT_SYMBOL_GPL(gmap_free); 252 - 253 - /** 254 - * gmap_enable - switch primary space to the guest address space 255 - * @gmap: pointer to the guest address space structure 256 - */ 257 - void gmap_enable(struct gmap *gmap) 258 - { 259 - S390_lowcore.gmap = (unsigned long) gmap; 260 - } 261 - EXPORT_SYMBOL_GPL(gmap_enable); 262 - 263 - /** 264 - * gmap_disable - switch back to the standard primary address space 265 - * @gmap: pointer to the guest address space structure 266 - */ 267 - void gmap_disable(struct gmap *gmap) 268 - { 269 - S390_lowcore.gmap = 0UL; 270 - } 271 - EXPORT_SYMBOL_GPL(gmap_disable); 272 - 273 - /* 274 - * gmap_alloc_table is assumed to be called with mmap_sem held 275 - */ 276 - static int gmap_alloc_table(struct gmap *gmap, unsigned long *table, 277 - unsigned long init, unsigned long gaddr) 278 - { 279 - struct page *page; 280 - unsigned long *new; 281 - 282 - /* since we dont free the gmap table until gmap_free we can unlock */ 283 - page = alloc_pages(GFP_KERNEL, 2); 284 - if (!page) 285 - return -ENOMEM; 286 - new = (unsigned long *) page_to_phys(page); 287 - crst_table_init(new, init); 288 - spin_lock(&gmap->mm->page_table_lock); 289 - if (*table & _REGION_ENTRY_INVALID) { 290 - list_add(&page->lru, &gmap->crst_list); 291 - *table = (unsigned long) new | _REGION_ENTRY_LENGTH | 292 - (*table & _REGION_ENTRY_TYPE_MASK); 293 - page->index = gaddr; 294 - page = NULL; 295 - } 296 - spin_unlock(&gmap->mm->page_table_lock); 297 - if (page) 298 - __free_pages(page, 2); 299 - return 0; 300 - } 301 - 302 - /** 303 - * __gmap_segment_gaddr - find virtual address from segment pointer 304 - * @entry: pointer to a segment table entry in the guest address space 305 - * 306 - * Returns the virtual address in the guest address space for the segment 307 - */ 308 - static unsigned long __gmap_segment_gaddr(unsigned long *entry) 309 - { 310 - struct page *page; 311 - unsigned long offset, mask; 312 - 313 - offset = (unsigned long) entry / sizeof(unsigned long); 314 - offset = (offset & (PTRS_PER_PMD - 1)) * PMD_SIZE; 315 - mask = ~(PTRS_PER_PMD * sizeof(pmd_t) - 1); 316 - page = virt_to_page((void *)((unsigned long) entry & mask)); 317 - return page->index + offset; 318 - } 319 - 320 - /** 321 - * __gmap_unlink_by_vmaddr - unlink a single segment via a host address 322 - * @gmap: pointer to the guest address space structure 323 - * @vmaddr: address in the host process address space 324 - * 325 - * Returns 1 if a TLB flush is required 326 - */ 327 - static int __gmap_unlink_by_vmaddr(struct gmap *gmap, unsigned long vmaddr) 328 - { 329 - unsigned long *entry; 330 - int flush = 0; 331 - 332 - spin_lock(&gmap->guest_table_lock); 333 - entry = radix_tree_delete(&gmap->host_to_guest, vmaddr >> PMD_SHIFT); 334 - if (entry) { 335 - flush = (*entry != _SEGMENT_ENTRY_INVALID); 336 - *entry = _SEGMENT_ENTRY_INVALID; 337 - } 338 - spin_unlock(&gmap->guest_table_lock); 339 - return flush; 340 - } 341 - 342 - /** 343 - * __gmap_unmap_by_gaddr - unmap a single segment via a guest address 344 - * @gmap: pointer to the guest address space structure 345 - * @gaddr: address in the guest address space 346 - * 347 - * Returns 1 if a TLB flush is required 348 - */ 349 - static int __gmap_unmap_by_gaddr(struct gmap *gmap, unsigned long gaddr) 350 - { 351 - unsigned long vmaddr; 352 - 353 - vmaddr = (unsigned long) radix_tree_delete(&gmap->guest_to_host, 354 - gaddr >> PMD_SHIFT); 355 - return vmaddr ? __gmap_unlink_by_vmaddr(gmap, vmaddr) : 0; 356 - } 357 - 358 - /** 359 - * gmap_unmap_segment - unmap segment from the guest address space 360 - * @gmap: pointer to the guest address space structure 361 - * @to: address in the guest address space 362 - * @len: length of the memory area to unmap 363 - * 364 - * Returns 0 if the unmap succeeded, -EINVAL if not. 365 - */ 366 - int gmap_unmap_segment(struct gmap *gmap, unsigned long to, unsigned long len) 367 - { 368 - unsigned long off; 369 - int flush; 370 - 371 - if ((to | len) & (PMD_SIZE - 1)) 372 - return -EINVAL; 373 - if (len == 0 || to + len < to) 374 - return -EINVAL; 375 - 376 - flush = 0; 377 - down_write(&gmap->mm->mmap_sem); 378 - for (off = 0; off < len; off += PMD_SIZE) 379 - flush |= __gmap_unmap_by_gaddr(gmap, to + off); 380 - up_write(&gmap->mm->mmap_sem); 381 - if (flush) 382 - gmap_flush_tlb(gmap); 383 - return 0; 384 - } 385 - EXPORT_SYMBOL_GPL(gmap_unmap_segment); 386 - 387 - /** 388 - * gmap_mmap_segment - map a segment to the guest address space 389 - * @gmap: pointer to the guest address space structure 390 - * @from: source address in the parent address space 391 - * @to: target address in the guest address space 392 - * @len: length of the memory area to map 393 - * 394 - * Returns 0 if the mmap succeeded, -EINVAL or -ENOMEM if not. 395 - */ 396 - int gmap_map_segment(struct gmap *gmap, unsigned long from, 397 - unsigned long to, unsigned long len) 398 - { 399 - unsigned long off; 400 - int flush; 401 - 402 - if ((from | to | len) & (PMD_SIZE - 1)) 403 - return -EINVAL; 404 - if (len == 0 || from + len < from || to + len < to || 405 - from + len - 1 > TASK_MAX_SIZE || to + len - 1 > gmap->asce_end) 406 - return -EINVAL; 407 - 408 - flush = 0; 409 - down_write(&gmap->mm->mmap_sem); 410 - for (off = 0; off < len; off += PMD_SIZE) { 411 - /* Remove old translation */ 412 - flush |= __gmap_unmap_by_gaddr(gmap, to + off); 413 - /* Store new translation */ 414 - if (radix_tree_insert(&gmap->guest_to_host, 415 - (to + off) >> PMD_SHIFT, 416 - (void *) from + off)) 417 - break; 418 - } 419 - up_write(&gmap->mm->mmap_sem); 420 - if (flush) 421 - gmap_flush_tlb(gmap); 422 - if (off >= len) 423 - return 0; 424 - gmap_unmap_segment(gmap, to, len); 425 - return -ENOMEM; 426 - } 427 - EXPORT_SYMBOL_GPL(gmap_map_segment); 428 - 429 - /** 430 - * __gmap_translate - translate a guest address to a user space address 431 - * @gmap: pointer to guest mapping meta data structure 432 - * @gaddr: guest address 433 - * 434 - * Returns user space address which corresponds to the guest address or 435 - * -EFAULT if no such mapping exists. 436 - * This function does not establish potentially missing page table entries. 437 - * The mmap_sem of the mm that belongs to the address space must be held 438 - * when this function gets called. 439 - */ 440 - unsigned long __gmap_translate(struct gmap *gmap, unsigned long gaddr) 441 - { 442 - unsigned long vmaddr; 443 - 444 - vmaddr = (unsigned long) 445 - radix_tree_lookup(&gmap->guest_to_host, gaddr >> PMD_SHIFT); 446 - return vmaddr ? (vmaddr | (gaddr & ~PMD_MASK)) : -EFAULT; 447 - } 448 - EXPORT_SYMBOL_GPL(__gmap_translate); 449 - 450 - /** 451 - * gmap_translate - translate a guest address to a user space address 452 - * @gmap: pointer to guest mapping meta data structure 453 - * @gaddr: guest address 454 - * 455 - * Returns user space address which corresponds to the guest address or 456 - * -EFAULT if no such mapping exists. 457 - * This function does not establish potentially missing page table entries. 458 - */ 459 - unsigned long gmap_translate(struct gmap *gmap, unsigned long gaddr) 460 - { 461 - unsigned long rc; 462 - 463 - down_read(&gmap->mm->mmap_sem); 464 - rc = __gmap_translate(gmap, gaddr); 465 - up_read(&gmap->mm->mmap_sem); 466 - return rc; 467 - } 468 - EXPORT_SYMBOL_GPL(gmap_translate); 469 - 470 - /** 471 - * gmap_unlink - disconnect a page table from the gmap shadow tables 472 - * @gmap: pointer to guest mapping meta data structure 473 - * @table: pointer to the host page table 474 - * @vmaddr: vm address associated with the host page table 475 - */ 476 - static void gmap_unlink(struct mm_struct *mm, unsigned long *table, 477 - unsigned long vmaddr) 478 - { 479 - struct gmap *gmap; 480 - int flush; 481 - 482 - list_for_each_entry(gmap, &mm->context.gmap_list, list) { 483 - flush = __gmap_unlink_by_vmaddr(gmap, vmaddr); 484 - if (flush) 485 - gmap_flush_tlb(gmap); 486 - } 487 - } 488 - 489 - /** 490 - * gmap_link - set up shadow page tables to connect a host to a guest address 491 - * @gmap: pointer to guest mapping meta data structure 492 - * @gaddr: guest address 493 - * @vmaddr: vm address 494 - * 495 - * Returns 0 on success, -ENOMEM for out of memory conditions, and -EFAULT 496 - * if the vm address is already mapped to a different guest segment. 497 - * The mmap_sem of the mm that belongs to the address space must be held 498 - * when this function gets called. 499 - */ 500 - int __gmap_link(struct gmap *gmap, unsigned long gaddr, unsigned long vmaddr) 501 - { 502 - struct mm_struct *mm; 503 - unsigned long *table; 504 - spinlock_t *ptl; 505 - pgd_t *pgd; 506 - pud_t *pud; 507 - pmd_t *pmd; 508 - int rc; 509 - 510 - /* Create higher level tables in the gmap page table */ 511 - table = gmap->table; 512 - if ((gmap->asce & _ASCE_TYPE_MASK) >= _ASCE_TYPE_REGION1) { 513 - table += (gaddr >> 53) & 0x7ff; 514 - if ((*table & _REGION_ENTRY_INVALID) && 515 - gmap_alloc_table(gmap, table, _REGION2_ENTRY_EMPTY, 516 - gaddr & 0xffe0000000000000UL)) 517 - return -ENOMEM; 518 - table = (unsigned long *)(*table & _REGION_ENTRY_ORIGIN); 519 - } 520 - if ((gmap->asce & _ASCE_TYPE_MASK) >= _ASCE_TYPE_REGION2) { 521 - table += (gaddr >> 42) & 0x7ff; 522 - if ((*table & _REGION_ENTRY_INVALID) && 523 - gmap_alloc_table(gmap, table, _REGION3_ENTRY_EMPTY, 524 - gaddr & 0xfffffc0000000000UL)) 525 - return -ENOMEM; 526 - table = (unsigned long *)(*table & _REGION_ENTRY_ORIGIN); 527 - } 528 - if ((gmap->asce & _ASCE_TYPE_MASK) >= _ASCE_TYPE_REGION3) { 529 - table += (gaddr >> 31) & 0x7ff; 530 - if ((*table & _REGION_ENTRY_INVALID) && 531 - gmap_alloc_table(gmap, table, _SEGMENT_ENTRY_EMPTY, 532 - gaddr & 0xffffffff80000000UL)) 533 - return -ENOMEM; 534 - table = (unsigned long *)(*table & _REGION_ENTRY_ORIGIN); 535 - } 536 - table += (gaddr >> 20) & 0x7ff; 537 - /* Walk the parent mm page table */ 538 - mm = gmap->mm; 539 - pgd = pgd_offset(mm, vmaddr); 540 - VM_BUG_ON(pgd_none(*pgd)); 541 - pud = pud_offset(pgd, vmaddr); 542 - VM_BUG_ON(pud_none(*pud)); 543 - pmd = pmd_offset(pud, vmaddr); 544 - VM_BUG_ON(pmd_none(*pmd)); 545 - /* large pmds cannot yet be handled */ 546 - if (pmd_large(*pmd)) 547 - return -EFAULT; 548 - /* Link gmap segment table entry location to page table. */ 549 - rc = radix_tree_preload(GFP_KERNEL); 550 - if (rc) 551 - return rc; 552 - ptl = pmd_lock(mm, pmd); 553 - spin_lock(&gmap->guest_table_lock); 554 - if (*table == _SEGMENT_ENTRY_INVALID) { 555 - rc = radix_tree_insert(&gmap->host_to_guest, 556 - vmaddr >> PMD_SHIFT, table); 557 - if (!rc) 558 - *table = pmd_val(*pmd); 53 + old = *ptep; 54 + if (unlikely(pte_val(old) & _PAGE_INVALID)) 55 + return old; 56 + active = (mm == current->active_mm) ? 1 : 0; 57 + count = atomic_add_return(0x10000, &mm->context.attach_count); 58 + if ((count & 0xffff) <= active) { 59 + pte_val(*ptep) |= _PAGE_INVALID; 60 + mm->context.flush_mm = 1; 559 61 } else 560 - rc = 0; 561 - spin_unlock(&gmap->guest_table_lock); 562 - spin_unlock(ptl); 563 - radix_tree_preload_end(); 564 - return rc; 62 + __ptep_ipte(addr, ptep); 63 + atomic_sub(0x10000, &mm->context.attach_count); 64 + return old; 565 65 } 566 66 567 - /** 568 - * gmap_fault - resolve a fault on a guest address 569 - * @gmap: pointer to guest mapping meta data structure 570 - * @gaddr: guest address 571 - * @fault_flags: flags to pass down to handle_mm_fault() 572 - * 573 - * Returns 0 on success, -ENOMEM for out of memory conditions, and -EFAULT 574 - * if the vm address is already mapped to a different guest segment. 575 - */ 576 - int gmap_fault(struct gmap *gmap, unsigned long gaddr, 577 - unsigned int fault_flags) 67 + static inline pgste_t pgste_get_lock(pte_t *ptep) 578 68 { 579 - unsigned long vmaddr; 580 - int rc; 581 - bool unlocked; 69 + unsigned long new = 0; 70 + #ifdef CONFIG_PGSTE 71 + unsigned long old; 582 72 583 - down_read(&gmap->mm->mmap_sem); 73 + preempt_disable(); 74 + asm( 75 + " lg %0,%2\n" 76 + "0: lgr %1,%0\n" 77 + " nihh %0,0xff7f\n" /* clear PCL bit in old */ 78 + " oihh %1,0x0080\n" /* set PCL bit in new */ 79 + " csg %0,%1,%2\n" 80 + " jl 0b\n" 81 + : "=&d" (old), "=&d" (new), "=Q" (ptep[PTRS_PER_PTE]) 82 + : "Q" (ptep[PTRS_PER_PTE]) : "cc", "memory"); 83 + #endif 84 + return __pgste(new); 85 + } 584 86 585 - retry: 586 - unlocked = false; 587 - vmaddr = __gmap_translate(gmap, gaddr); 588 - if (IS_ERR_VALUE(vmaddr)) { 589 - rc = vmaddr; 590 - goto out_up; 591 - } 592 - if (fixup_user_fault(current, gmap->mm, vmaddr, fault_flags, 593 - &unlocked)) { 594 - rc = -EFAULT; 595 - goto out_up; 596 - } 87 + static inline void pgste_set_unlock(pte_t *ptep, pgste_t pgste) 88 + { 89 + #ifdef CONFIG_PGSTE 90 + asm( 91 + " nihh %1,0xff7f\n" /* clear PCL bit */ 92 + " stg %1,%0\n" 93 + : "=Q" (ptep[PTRS_PER_PTE]) 94 + : "d" (pgste_val(pgste)), "Q" (ptep[PTRS_PER_PTE]) 95 + : "cc", "memory"); 96 + preempt_enable(); 97 + #endif 98 + } 99 + 100 + static inline pgste_t pgste_get(pte_t *ptep) 101 + { 102 + unsigned long pgste = 0; 103 + #ifdef CONFIG_PGSTE 104 + pgste = *(unsigned long *)(ptep + PTRS_PER_PTE); 105 + #endif 106 + return __pgste(pgste); 107 + } 108 + 109 + static inline void pgste_set(pte_t *ptep, pgste_t pgste) 110 + { 111 + #ifdef CONFIG_PGSTE 112 + *(pgste_t *)(ptep + PTRS_PER_PTE) = pgste; 113 + #endif 114 + } 115 + 116 + static inline pgste_t pgste_update_all(pte_t pte, pgste_t pgste, 117 + struct mm_struct *mm) 118 + { 119 + #ifdef CONFIG_PGSTE 120 + unsigned long address, bits, skey; 121 + 122 + if (!mm_use_skey(mm) || pte_val(pte) & _PAGE_INVALID) 123 + return pgste; 124 + address = pte_val(pte) & PAGE_MASK; 125 + skey = (unsigned long) page_get_storage_key(address); 126 + bits = skey & (_PAGE_CHANGED | _PAGE_REFERENCED); 127 + /* Transfer page changed & referenced bit to guest bits in pgste */ 128 + pgste_val(pgste) |= bits << 48; /* GR bit & GC bit */ 129 + /* Copy page access key and fetch protection bit to pgste */ 130 + pgste_val(pgste) &= ~(PGSTE_ACC_BITS | PGSTE_FP_BIT); 131 + pgste_val(pgste) |= (skey & (_PAGE_ACC_BITS | _PAGE_FP_BIT)) << 56; 132 + #endif 133 + return pgste; 134 + 135 + } 136 + 137 + static inline void pgste_set_key(pte_t *ptep, pgste_t pgste, pte_t entry, 138 + struct mm_struct *mm) 139 + { 140 + #ifdef CONFIG_PGSTE 141 + unsigned long address; 142 + unsigned long nkey; 143 + 144 + if (!mm_use_skey(mm) || pte_val(entry) & _PAGE_INVALID) 145 + return; 146 + VM_BUG_ON(!(pte_val(*ptep) & _PAGE_INVALID)); 147 + address = pte_val(entry) & PAGE_MASK; 597 148 /* 598 - * In the case that fixup_user_fault unlocked the mmap_sem during 599 - * faultin redo __gmap_translate to not race with a map/unmap_segment. 149 + * Set page access key and fetch protection bit from pgste. 150 + * The guest C/R information is still in the PGSTE, set real 151 + * key C/R to 0. 600 152 */ 601 - if (unlocked) 602 - goto retry; 603 - 604 - rc = __gmap_link(gmap, gaddr, vmaddr); 605 - out_up: 606 - up_read(&gmap->mm->mmap_sem); 607 - return rc; 608 - } 609 - EXPORT_SYMBOL_GPL(gmap_fault); 610 - 611 - static void gmap_zap_swap_entry(swp_entry_t entry, struct mm_struct *mm) 612 - { 613 - if (!non_swap_entry(entry)) 614 - dec_mm_counter(mm, MM_SWAPENTS); 615 - else if (is_migration_entry(entry)) { 616 - struct page *page = migration_entry_to_page(entry); 617 - 618 - dec_mm_counter(mm, mm_counter(page)); 619 - } 620 - free_swap_and_cache(entry); 153 + nkey = (pgste_val(pgste) & (PGSTE_ACC_BITS | PGSTE_FP_BIT)) >> 56; 154 + nkey |= (pgste_val(pgste) & (PGSTE_GR_BIT | PGSTE_GC_BIT)) >> 48; 155 + page_set_storage_key(address, nkey, 0); 156 + #endif 621 157 } 622 158 623 - /* 624 - * this function is assumed to be called with mmap_sem held 625 - */ 626 - void __gmap_zap(struct gmap *gmap, unsigned long gaddr) 159 + static inline pgste_t pgste_set_pte(pte_t *ptep, pgste_t pgste, pte_t entry) 627 160 { 628 - unsigned long vmaddr, ptev, pgstev; 629 - pte_t *ptep, pte; 630 - spinlock_t *ptl; 631 - pgste_t pgste; 632 - 633 - /* Find the vm address for the guest address */ 634 - vmaddr = (unsigned long) radix_tree_lookup(&gmap->guest_to_host, 635 - gaddr >> PMD_SHIFT); 636 - if (!vmaddr) 637 - return; 638 - vmaddr |= gaddr & ~PMD_MASK; 639 - /* Get pointer to the page table entry */ 640 - ptep = get_locked_pte(gmap->mm, vmaddr, &ptl); 641 - if (unlikely(!ptep)) 642 - return; 643 - pte = *ptep; 644 - if (!pte_swap(pte)) 645 - goto out_pte; 646 - /* Zap unused and logically-zero pages */ 647 - pgste = pgste_get_lock(ptep); 648 - pgstev = pgste_val(pgste); 649 - ptev = pte_val(pte); 650 - if (((pgstev & _PGSTE_GPS_USAGE_MASK) == _PGSTE_GPS_USAGE_UNUSED) || 651 - ((pgstev & _PGSTE_GPS_ZERO) && (ptev & _PAGE_INVALID))) { 652 - gmap_zap_swap_entry(pte_to_swp_entry(pte), gmap->mm); 653 - pte_clear(gmap->mm, vmaddr, ptep); 654 - } 655 - pgste_set_unlock(ptep, pgste); 656 - out_pte: 657 - pte_unmap_unlock(ptep, ptl); 658 - } 659 - EXPORT_SYMBOL_GPL(__gmap_zap); 660 - 661 - void gmap_discard(struct gmap *gmap, unsigned long from, unsigned long to) 662 - { 663 - unsigned long gaddr, vmaddr, size; 664 - struct vm_area_struct *vma; 665 - 666 - down_read(&gmap->mm->mmap_sem); 667 - for (gaddr = from; gaddr < to; 668 - gaddr = (gaddr + PMD_SIZE) & PMD_MASK) { 669 - /* Find the vm address for the guest address */ 670 - vmaddr = (unsigned long) 671 - radix_tree_lookup(&gmap->guest_to_host, 672 - gaddr >> PMD_SHIFT); 673 - if (!vmaddr) 674 - continue; 675 - vmaddr |= gaddr & ~PMD_MASK; 676 - /* Find vma in the parent mm */ 677 - vma = find_vma(gmap->mm, vmaddr); 678 - size = min(to - gaddr, PMD_SIZE - (gaddr & ~PMD_MASK)); 679 - zap_page_range(vma, vmaddr, size, NULL); 680 - } 681 - up_read(&gmap->mm->mmap_sem); 682 - } 683 - EXPORT_SYMBOL_GPL(gmap_discard); 684 - 685 - static LIST_HEAD(gmap_notifier_list); 686 - static DEFINE_SPINLOCK(gmap_notifier_lock); 687 - 688 - /** 689 - * gmap_register_ipte_notifier - register a pte invalidation callback 690 - * @nb: pointer to the gmap notifier block 691 - */ 692 - void gmap_register_ipte_notifier(struct gmap_notifier *nb) 693 - { 694 - spin_lock(&gmap_notifier_lock); 695 - list_add(&nb->list, &gmap_notifier_list); 696 - spin_unlock(&gmap_notifier_lock); 697 - } 698 - EXPORT_SYMBOL_GPL(gmap_register_ipte_notifier); 699 - 700 - /** 701 - * gmap_unregister_ipte_notifier - remove a pte invalidation callback 702 - * @nb: pointer to the gmap notifier block 703 - */ 704 - void gmap_unregister_ipte_notifier(struct gmap_notifier *nb) 705 - { 706 - spin_lock(&gmap_notifier_lock); 707 - list_del_init(&nb->list); 708 - spin_unlock(&gmap_notifier_lock); 709 - } 710 - EXPORT_SYMBOL_GPL(gmap_unregister_ipte_notifier); 711 - 712 - /** 713 - * gmap_ipte_notify - mark a range of ptes for invalidation notification 714 - * @gmap: pointer to guest mapping meta data structure 715 - * @gaddr: virtual address in the guest address space 716 - * @len: size of area 717 - * 718 - * Returns 0 if for each page in the given range a gmap mapping exists and 719 - * the invalidation notification could be set. If the gmap mapping is missing 720 - * for one or more pages -EFAULT is returned. If no memory could be allocated 721 - * -ENOMEM is returned. This function establishes missing page table entries. 722 - */ 723 - int gmap_ipte_notify(struct gmap *gmap, unsigned long gaddr, unsigned long len) 724 - { 725 - unsigned long addr; 726 - spinlock_t *ptl; 727 - pte_t *ptep, entry; 728 - pgste_t pgste; 729 - bool unlocked; 730 - int rc = 0; 731 - 732 - if ((gaddr & ~PAGE_MASK) || (len & ~PAGE_MASK)) 733 - return -EINVAL; 734 - down_read(&gmap->mm->mmap_sem); 735 - while (len) { 736 - unlocked = false; 737 - /* Convert gmap address and connect the page tables */ 738 - addr = __gmap_translate(gmap, gaddr); 739 - if (IS_ERR_VALUE(addr)) { 740 - rc = addr; 741 - break; 161 + #ifdef CONFIG_PGSTE 162 + if ((pte_val(entry) & _PAGE_PRESENT) && 163 + (pte_val(entry) & _PAGE_WRITE) && 164 + !(pte_val(entry) & _PAGE_INVALID)) { 165 + if (!MACHINE_HAS_ESOP) { 166 + /* 167 + * Without enhanced suppression-on-protection force 168 + * the dirty bit on for all writable ptes. 169 + */ 170 + pte_val(entry) |= _PAGE_DIRTY; 171 + pte_val(entry) &= ~_PAGE_PROTECT; 742 172 } 743 - /* Get the page mapped */ 744 - if (fixup_user_fault(current, gmap->mm, addr, FAULT_FLAG_WRITE, 745 - &unlocked)) { 746 - rc = -EFAULT; 747 - break; 748 - } 749 - /* While trying to map mmap_sem got unlocked. Let us retry */ 750 - if (unlocked) 751 - continue; 752 - rc = __gmap_link(gmap, gaddr, addr); 753 - if (rc) 754 - break; 755 - /* Walk the process page table, lock and get pte pointer */ 756 - ptep = get_locked_pte(gmap->mm, addr, &ptl); 757 - VM_BUG_ON(!ptep); 758 - /* Set notification bit in the pgste of the pte */ 759 - entry = *ptep; 760 - if ((pte_val(entry) & (_PAGE_INVALID | _PAGE_PROTECT)) == 0) { 761 - pgste = pgste_get_lock(ptep); 762 - pgste_val(pgste) |= PGSTE_IN_BIT; 763 - pgste_set_unlock(ptep, pgste); 764 - gaddr += PAGE_SIZE; 765 - len -= PAGE_SIZE; 766 - } 767 - pte_unmap_unlock(ptep, ptl); 173 + if (!(pte_val(entry) & _PAGE_PROTECT)) 174 + /* This pte allows write access, set user-dirty */ 175 + pgste_val(pgste) |= PGSTE_UC_BIT; 768 176 } 769 - up_read(&gmap->mm->mmap_sem); 770 - return rc; 177 + #endif 178 + *ptep = entry; 179 + return pgste; 771 180 } 772 - EXPORT_SYMBOL_GPL(gmap_ipte_notify); 773 181 774 - /** 775 - * gmap_do_ipte_notify - call all invalidation callbacks for a specific pte. 776 - * @mm: pointer to the process mm_struct 777 - * @addr: virtual address in the process address space 778 - * @pte: pointer to the page table entry 779 - * 780 - * This function is assumed to be called with the page table lock held 781 - * for the pte to notify. 782 - */ 783 - void gmap_do_ipte_notify(struct mm_struct *mm, unsigned long vmaddr, pte_t *pte) 182 + static inline pgste_t pgste_ipte_notify(struct mm_struct *mm, 183 + unsigned long addr, 184 + pte_t *ptep, pgste_t pgste) 784 185 { 785 - unsigned long offset, gaddr; 786 - unsigned long *table; 787 - struct gmap_notifier *nb; 788 - struct gmap *gmap; 789 - 790 - offset = ((unsigned long) pte) & (255 * sizeof(pte_t)); 791 - offset = offset * (4096 / sizeof(pte_t)); 792 - spin_lock(&gmap_notifier_lock); 793 - list_for_each_entry(gmap, &mm->context.gmap_list, list) { 794 - table = radix_tree_lookup(&gmap->host_to_guest, 795 - vmaddr >> PMD_SHIFT); 796 - if (!table) 797 - continue; 798 - gaddr = __gmap_segment_gaddr(table) + offset; 799 - list_for_each_entry(nb, &gmap_notifier_list, list) 800 - nb->notifier_call(gmap, gaddr); 186 + #ifdef CONFIG_PGSTE 187 + if (pgste_val(pgste) & PGSTE_IN_BIT) { 188 + pgste_val(pgste) &= ~PGSTE_IN_BIT; 189 + ptep_notify(mm, addr, ptep); 801 190 } 802 - spin_unlock(&gmap_notifier_lock); 191 + #endif 192 + return pgste; 803 193 } 804 - EXPORT_SYMBOL_GPL(gmap_do_ipte_notify); 805 194 806 - int set_guest_storage_key(struct mm_struct *mm, unsigned long addr, 807 - unsigned long key, bool nq) 195 + static inline pgste_t ptep_xchg_start(struct mm_struct *mm, 196 + unsigned long addr, pte_t *ptep) 808 197 { 809 - spinlock_t *ptl; 810 - pgste_t old, new; 811 - pte_t *ptep; 812 - bool unlocked; 198 + pgste_t pgste = __pgste(0); 813 199 814 - down_read(&mm->mmap_sem); 815 - retry: 816 - unlocked = false; 817 - ptep = get_locked_pte(mm, addr, &ptl); 818 - if (unlikely(!ptep)) { 819 - up_read(&mm->mmap_sem); 820 - return -EFAULT; 200 + if (mm_has_pgste(mm)) { 201 + pgste = pgste_get_lock(ptep); 202 + pgste = pgste_ipte_notify(mm, addr, ptep, pgste); 821 203 } 822 - if (!(pte_val(*ptep) & _PAGE_INVALID) && 823 - (pte_val(*ptep) & _PAGE_PROTECT)) { 824 - pte_unmap_unlock(ptep, ptl); 825 - /* 826 - * We do not really care about unlocked. We will retry either 827 - * way. But this allows fixup_user_fault to enable userfaultfd. 828 - */ 829 - if (fixup_user_fault(current, mm, addr, FAULT_FLAG_WRITE, 830 - &unlocked)) { 831 - up_read(&mm->mmap_sem); 832 - return -EFAULT; 204 + return pgste; 205 + } 206 + 207 + static inline void ptep_xchg_commit(struct mm_struct *mm, 208 + unsigned long addr, pte_t *ptep, 209 + pgste_t pgste, pte_t old, pte_t new) 210 + { 211 + if (mm_has_pgste(mm)) { 212 + if (pte_val(old) & _PAGE_INVALID) 213 + pgste_set_key(ptep, pgste, new, mm); 214 + if (pte_val(new) & _PAGE_INVALID) { 215 + pgste = pgste_update_all(old, pgste, mm); 216 + if ((pgste_val(pgste) & _PGSTE_GPS_USAGE_MASK) == 217 + _PGSTE_GPS_USAGE_UNUSED) 218 + pte_val(old) |= _PAGE_UNUSED; 833 219 } 834 - goto retry; 835 - } 836 - 837 - new = old = pgste_get_lock(ptep); 838 - pgste_val(new) &= ~(PGSTE_GR_BIT | PGSTE_GC_BIT | 839 - PGSTE_ACC_BITS | PGSTE_FP_BIT); 840 - pgste_val(new) |= (key & (_PAGE_CHANGED | _PAGE_REFERENCED)) << 48; 841 - pgste_val(new) |= (key & (_PAGE_ACC_BITS | _PAGE_FP_BIT)) << 56; 842 - if (!(pte_val(*ptep) & _PAGE_INVALID)) { 843 - unsigned long address, bits, skey; 844 - 845 - address = pte_val(*ptep) & PAGE_MASK; 846 - skey = (unsigned long) page_get_storage_key(address); 847 - bits = skey & (_PAGE_CHANGED | _PAGE_REFERENCED); 848 - skey = key & (_PAGE_ACC_BITS | _PAGE_FP_BIT); 849 - /* Set storage key ACC and FP */ 850 - page_set_storage_key(address, skey, !nq); 851 - /* Merge host changed & referenced into pgste */ 852 - pgste_val(new) |= bits << 52; 853 - } 854 - /* changing the guest storage key is considered a change of the page */ 855 - if ((pgste_val(new) ^ pgste_val(old)) & 856 - (PGSTE_ACC_BITS | PGSTE_FP_BIT | PGSTE_GR_BIT | PGSTE_GC_BIT)) 857 - pgste_val(new) |= PGSTE_UC_BIT; 858 - 859 - pgste_set_unlock(ptep, new); 860 - pte_unmap_unlock(ptep, ptl); 861 - up_read(&mm->mmap_sem); 862 - return 0; 863 - } 864 - EXPORT_SYMBOL(set_guest_storage_key); 865 - 866 - unsigned long get_guest_storage_key(struct mm_struct *mm, unsigned long addr) 867 - { 868 - spinlock_t *ptl; 869 - pgste_t pgste; 870 - pte_t *ptep; 871 - uint64_t physaddr; 872 - unsigned long key = 0; 873 - 874 - down_read(&mm->mmap_sem); 875 - ptep = get_locked_pte(mm, addr, &ptl); 876 - if (unlikely(!ptep)) { 877 - up_read(&mm->mmap_sem); 878 - return -EFAULT; 879 - } 880 - pgste = pgste_get_lock(ptep); 881 - 882 - if (pte_val(*ptep) & _PAGE_INVALID) { 883 - key |= (pgste_val(pgste) & PGSTE_ACC_BITS) >> 56; 884 - key |= (pgste_val(pgste) & PGSTE_FP_BIT) >> 56; 885 - key |= (pgste_val(pgste) & PGSTE_GR_BIT) >> 48; 886 - key |= (pgste_val(pgste) & PGSTE_GC_BIT) >> 48; 220 + pgste = pgste_set_pte(ptep, pgste, new); 221 + pgste_set_unlock(ptep, pgste); 887 222 } else { 888 - physaddr = pte_val(*ptep) & PAGE_MASK; 889 - key = page_get_storage_key(physaddr); 890 - 891 - /* Reflect guest's logical view, not physical */ 892 - if (pgste_val(pgste) & PGSTE_GR_BIT) 893 - key |= _PAGE_REFERENCED; 894 - if (pgste_val(pgste) & PGSTE_GC_BIT) 895 - key |= _PAGE_CHANGED; 223 + *ptep = new; 896 224 } 897 - 898 - pgste_set_unlock(ptep, pgste); 899 - pte_unmap_unlock(ptep, ptl); 900 - up_read(&mm->mmap_sem); 901 - return key; 902 - } 903 - EXPORT_SYMBOL(get_guest_storage_key); 904 - 905 - static int page_table_allocate_pgste_min = 0; 906 - static int page_table_allocate_pgste_max = 1; 907 - int page_table_allocate_pgste = 0; 908 - EXPORT_SYMBOL(page_table_allocate_pgste); 909 - 910 - static struct ctl_table page_table_sysctl[] = { 911 - { 912 - .procname = "allocate_pgste", 913 - .data = &page_table_allocate_pgste, 914 - .maxlen = sizeof(int), 915 - .mode = S_IRUGO | S_IWUSR, 916 - .proc_handler = proc_dointvec, 917 - .extra1 = &page_table_allocate_pgste_min, 918 - .extra2 = &page_table_allocate_pgste_max, 919 - }, 920 - { } 921 - }; 922 - 923 - static struct ctl_table page_table_sysctl_dir[] = { 924 - { 925 - .procname = "vm", 926 - .maxlen = 0, 927 - .mode = 0555, 928 - .child = page_table_sysctl, 929 - }, 930 - { } 931 - }; 932 - 933 - static int __init page_table_register_sysctl(void) 934 - { 935 - return register_sysctl_table(page_table_sysctl_dir) ? 0 : -ENOMEM; 936 - } 937 - __initcall(page_table_register_sysctl); 938 - 939 - #else /* CONFIG_PGSTE */ 940 - 941 - static inline void gmap_unlink(struct mm_struct *mm, unsigned long *table, 942 - unsigned long vmaddr) 943 - { 944 225 } 945 226 946 - #endif /* CONFIG_PGSTE */ 947 - 948 - static inline unsigned int atomic_xor_bits(atomic_t *v, unsigned int bits) 227 + pte_t ptep_xchg_direct(struct mm_struct *mm, unsigned long addr, 228 + pte_t *ptep, pte_t new) 949 229 { 950 - unsigned int old, new; 230 + pgste_t pgste; 231 + pte_t old; 951 232 952 - do { 953 - old = atomic_read(v); 954 - new = old ^ bits; 955 - } while (atomic_cmpxchg(v, old, new) != old); 956 - return new; 233 + pgste = ptep_xchg_start(mm, addr, ptep); 234 + old = ptep_flush_direct(mm, addr, ptep); 235 + ptep_xchg_commit(mm, addr, ptep, pgste, old, new); 236 + return old; 957 237 } 238 + EXPORT_SYMBOL(ptep_xchg_direct); 958 239 959 - /* 960 - * page table entry allocation/free routines. 961 - */ 962 - unsigned long *page_table_alloc(struct mm_struct *mm) 240 + pte_t ptep_xchg_lazy(struct mm_struct *mm, unsigned long addr, 241 + pte_t *ptep, pte_t new) 963 242 { 964 - unsigned long *table; 965 - struct page *page; 966 - unsigned int mask, bit; 243 + pgste_t pgste; 244 + pte_t old; 967 245 968 - /* Try to get a fragment of a 4K page as a 2K page table */ 969 - if (!mm_alloc_pgste(mm)) { 970 - table = NULL; 971 - spin_lock_bh(&mm->context.list_lock); 972 - if (!list_empty(&mm->context.pgtable_list)) { 973 - page = list_first_entry(&mm->context.pgtable_list, 974 - struct page, lru); 975 - mask = atomic_read(&page->_mapcount); 976 - mask = (mask | (mask >> 4)) & 3; 977 - if (mask != 3) { 978 - table = (unsigned long *) page_to_phys(page); 979 - bit = mask & 1; /* =1 -> second 2K */ 980 - if (bit) 981 - table += PTRS_PER_PTE; 982 - atomic_xor_bits(&page->_mapcount, 1U << bit); 983 - list_del(&page->lru); 984 - } 985 - } 986 - spin_unlock_bh(&mm->context.list_lock); 987 - if (table) 988 - return table; 246 + pgste = ptep_xchg_start(mm, addr, ptep); 247 + old = ptep_flush_lazy(mm, addr, ptep); 248 + ptep_xchg_commit(mm, addr, ptep, pgste, old, new); 249 + return old; 250 + } 251 + EXPORT_SYMBOL(ptep_xchg_lazy); 252 + 253 + pte_t ptep_modify_prot_start(struct mm_struct *mm, unsigned long addr, 254 + pte_t *ptep) 255 + { 256 + pgste_t pgste; 257 + pte_t old; 258 + 259 + pgste = ptep_xchg_start(mm, addr, ptep); 260 + old = ptep_flush_lazy(mm, addr, ptep); 261 + if (mm_has_pgste(mm)) { 262 + pgste = pgste_update_all(old, pgste, mm); 263 + pgste_set(ptep, pgste); 989 264 } 990 - /* Allocate a fresh page */ 991 - page = alloc_page(GFP_KERNEL|__GFP_REPEAT); 992 - if (!page) 993 - return NULL; 994 - if (!pgtable_page_ctor(page)) { 995 - __free_page(page); 996 - return NULL; 997 - } 998 - /* Initialize page table */ 999 - table = (unsigned long *) page_to_phys(page); 1000 - if (mm_alloc_pgste(mm)) { 1001 - /* Return 4K page table with PGSTEs */ 1002 - atomic_set(&page->_mapcount, 3); 1003 - clear_table(table, _PAGE_INVALID, PAGE_SIZE/2); 1004 - clear_table(table + PTRS_PER_PTE, 0, PAGE_SIZE/2); 265 + return old; 266 + } 267 + EXPORT_SYMBOL(ptep_modify_prot_start); 268 + 269 + void ptep_modify_prot_commit(struct mm_struct *mm, unsigned long addr, 270 + pte_t *ptep, pte_t pte) 271 + { 272 + pgste_t pgste; 273 + 274 + if (mm_has_pgste(mm)) { 275 + pgste = pgste_get(ptep); 276 + pgste_set_key(ptep, pgste, pte, mm); 277 + pgste = pgste_set_pte(ptep, pgste, pte); 278 + pgste_set_unlock(ptep, pgste); 1005 279 } else { 1006 - /* Return the first 2K fragment of the page */ 1007 - atomic_set(&page->_mapcount, 1); 1008 - clear_table(table, _PAGE_INVALID, PAGE_SIZE); 1009 - spin_lock_bh(&mm->context.list_lock); 1010 - list_add(&page->lru, &mm->context.pgtable_list); 1011 - spin_unlock_bh(&mm->context.list_lock); 280 + *ptep = pte; 1012 281 } 1013 - return table; 1014 282 } 283 + EXPORT_SYMBOL(ptep_modify_prot_commit); 1015 284 1016 - void page_table_free(struct mm_struct *mm, unsigned long *table) 285 + static inline pmd_t pmdp_flush_direct(struct mm_struct *mm, 286 + unsigned long addr, pmd_t *pmdp) 1017 287 { 1018 - struct page *page; 1019 - unsigned int bit, mask; 288 + int active, count; 289 + pmd_t old; 1020 290 1021 - page = pfn_to_page(__pa(table) >> PAGE_SHIFT); 1022 - if (!mm_alloc_pgste(mm)) { 1023 - /* Free 2K page table fragment of a 4K page */ 1024 - bit = (__pa(table) & ~PAGE_MASK)/(PTRS_PER_PTE*sizeof(pte_t)); 1025 - spin_lock_bh(&mm->context.list_lock); 1026 - mask = atomic_xor_bits(&page->_mapcount, 1U << bit); 1027 - if (mask & 3) 1028 - list_add(&page->lru, &mm->context.pgtable_list); 1029 - else 1030 - list_del(&page->lru); 1031 - spin_unlock_bh(&mm->context.list_lock); 1032 - if (mask != 0) 1033 - return; 291 + old = *pmdp; 292 + if (pmd_val(old) & _SEGMENT_ENTRY_INVALID) 293 + return old; 294 + if (!MACHINE_HAS_IDTE) { 295 + __pmdp_csp(pmdp); 296 + return old; 1034 297 } 1035 - 1036 - pgtable_page_dtor(page); 1037 - atomic_set(&page->_mapcount, -1); 1038 - __free_page(page); 1039 - } 1040 - 1041 - void page_table_free_rcu(struct mmu_gather *tlb, unsigned long *table, 1042 - unsigned long vmaddr) 1043 - { 1044 - struct mm_struct *mm; 1045 - struct page *page; 1046 - unsigned int bit, mask; 1047 - 1048 - mm = tlb->mm; 1049 - page = pfn_to_page(__pa(table) >> PAGE_SHIFT); 1050 - if (mm_alloc_pgste(mm)) { 1051 - gmap_unlink(mm, table, vmaddr); 1052 - table = (unsigned long *) (__pa(table) | 3); 1053 - tlb_remove_table(tlb, table); 1054 - return; 1055 - } 1056 - bit = (__pa(table) & ~PAGE_MASK) / (PTRS_PER_PTE*sizeof(pte_t)); 1057 - spin_lock_bh(&mm->context.list_lock); 1058 - mask = atomic_xor_bits(&page->_mapcount, 0x11U << bit); 1059 - if (mask & 3) 1060 - list_add_tail(&page->lru, &mm->context.pgtable_list); 298 + active = (mm == current->active_mm) ? 1 : 0; 299 + count = atomic_add_return(0x10000, &mm->context.attach_count); 300 + if (MACHINE_HAS_TLB_LC && (count & 0xffff) <= active && 301 + cpumask_equal(mm_cpumask(mm), cpumask_of(smp_processor_id()))) 302 + __pmdp_idte_local(addr, pmdp); 1061 303 else 1062 - list_del(&page->lru); 1063 - spin_unlock_bh(&mm->context.list_lock); 1064 - table = (unsigned long *) (__pa(table) | (1U << bit)); 1065 - tlb_remove_table(tlb, table); 304 + __pmdp_idte(addr, pmdp); 305 + atomic_sub(0x10000, &mm->context.attach_count); 306 + return old; 1066 307 } 1067 308 1068 - static void __tlb_remove_table(void *_table) 309 + static inline pmd_t pmdp_flush_lazy(struct mm_struct *mm, 310 + unsigned long addr, pmd_t *pmdp) 1069 311 { 1070 - unsigned int mask = (unsigned long) _table & 3; 1071 - void *table = (void *)((unsigned long) _table ^ mask); 1072 - struct page *page = pfn_to_page(__pa(table) >> PAGE_SHIFT); 312 + int active, count; 313 + pmd_t old; 1073 314 1074 - switch (mask) { 1075 - case 0: /* pmd or pud */ 1076 - free_pages((unsigned long) table, 2); 1077 - break; 1078 - case 1: /* lower 2K of a 4K page table */ 1079 - case 2: /* higher 2K of a 4K page table */ 1080 - if (atomic_xor_bits(&page->_mapcount, mask << 4) != 0) 1081 - break; 1082 - /* fallthrough */ 1083 - case 3: /* 4K page table with pgstes */ 1084 - pgtable_page_dtor(page); 1085 - atomic_set(&page->_mapcount, -1); 1086 - __free_page(page); 1087 - break; 1088 - } 315 + old = *pmdp; 316 + if (pmd_val(old) & _SEGMENT_ENTRY_INVALID) 317 + return old; 318 + active = (mm == current->active_mm) ? 1 : 0; 319 + count = atomic_add_return(0x10000, &mm->context.attach_count); 320 + if ((count & 0xffff) <= active) { 321 + pmd_val(*pmdp) |= _SEGMENT_ENTRY_INVALID; 322 + mm->context.flush_mm = 1; 323 + } else if (MACHINE_HAS_IDTE) 324 + __pmdp_idte(addr, pmdp); 325 + else 326 + __pmdp_csp(pmdp); 327 + atomic_sub(0x10000, &mm->context.attach_count); 328 + return old; 1089 329 } 1090 330 1091 - static void tlb_remove_table_smp_sync(void *arg) 331 + pmd_t pmdp_xchg_direct(struct mm_struct *mm, unsigned long addr, 332 + pmd_t *pmdp, pmd_t new) 1092 333 { 1093 - /* Simply deliver the interrupt */ 1094 - } 334 + pmd_t old; 1095 335 1096 - static void tlb_remove_table_one(void *table) 336 + old = pmdp_flush_direct(mm, addr, pmdp); 337 + *pmdp = new; 338 + return old; 339 + } 340 + EXPORT_SYMBOL(pmdp_xchg_direct); 341 + 342 + pmd_t pmdp_xchg_lazy(struct mm_struct *mm, unsigned long addr, 343 + pmd_t *pmdp, pmd_t new) 1097 344 { 1098 - /* 1099 - * This isn't an RCU grace period and hence the page-tables cannot be 1100 - * assumed to be actually RCU-freed. 1101 - * 1102 - * It is however sufficient for software page-table walkers that rely 1103 - * on IRQ disabling. See the comment near struct mmu_table_batch. 1104 - */ 1105 - smp_call_function(tlb_remove_table_smp_sync, NULL, 1); 1106 - __tlb_remove_table(table); 345 + pmd_t old; 346 + 347 + old = pmdp_flush_lazy(mm, addr, pmdp); 348 + *pmdp = new; 349 + return old; 1107 350 } 1108 - 1109 - static void tlb_remove_table_rcu(struct rcu_head *head) 1110 - { 1111 - struct mmu_table_batch *batch; 1112 - int i; 1113 - 1114 - batch = container_of(head, struct mmu_table_batch, rcu); 1115 - 1116 - for (i = 0; i < batch->nr; i++) 1117 - __tlb_remove_table(batch->tables[i]); 1118 - 1119 - free_page((unsigned long)batch); 1120 - } 1121 - 1122 - void tlb_table_flush(struct mmu_gather *tlb) 1123 - { 1124 - struct mmu_table_batch **batch = &tlb->batch; 1125 - 1126 - if (*batch) { 1127 - call_rcu_sched(&(*batch)->rcu, tlb_remove_table_rcu); 1128 - *batch = NULL; 1129 - } 1130 - } 1131 - 1132 - void tlb_remove_table(struct mmu_gather *tlb, void *table) 1133 - { 1134 - struct mmu_table_batch **batch = &tlb->batch; 1135 - 1136 - tlb->mm->context.flush_mm = 1; 1137 - if (*batch == NULL) { 1138 - *batch = (struct mmu_table_batch *) 1139 - __get_free_page(GFP_NOWAIT | __GFP_NOWARN); 1140 - if (*batch == NULL) { 1141 - __tlb_flush_mm_lazy(tlb->mm); 1142 - tlb_remove_table_one(table); 1143 - return; 1144 - } 1145 - (*batch)->nr = 0; 1146 - } 1147 - (*batch)->tables[(*batch)->nr++] = table; 1148 - if ((*batch)->nr == MAX_TABLE_BATCH) 1149 - tlb_flush_mmu(tlb); 1150 - } 351 + EXPORT_SYMBOL(pmdp_xchg_lazy); 1151 352 1152 353 #ifdef CONFIG_TRANSPARENT_HUGEPAGE 1153 - static inline void thp_split_vma(struct vm_area_struct *vma) 1154 - { 1155 - unsigned long addr; 1156 - 1157 - for (addr = vma->vm_start; addr < vma->vm_end; addr += PAGE_SIZE) 1158 - follow_page(vma, addr, FOLL_SPLIT); 1159 - } 1160 - 1161 - static inline void thp_split_mm(struct mm_struct *mm) 1162 - { 1163 - struct vm_area_struct *vma; 1164 - 1165 - for (vma = mm->mmap; vma != NULL; vma = vma->vm_next) { 1166 - thp_split_vma(vma); 1167 - vma->vm_flags &= ~VM_HUGEPAGE; 1168 - vma->vm_flags |= VM_NOHUGEPAGE; 1169 - } 1170 - mm->def_flags |= VM_NOHUGEPAGE; 1171 - } 1172 - #else 1173 - static inline void thp_split_mm(struct mm_struct *mm) 1174 - { 1175 - } 1176 - #endif /* CONFIG_TRANSPARENT_HUGEPAGE */ 1177 - 1178 - /* 1179 - * switch on pgstes for its userspace process (for kvm) 1180 - */ 1181 - int s390_enable_sie(void) 1182 - { 1183 - struct mm_struct *mm = current->mm; 1184 - 1185 - /* Do we have pgstes? if yes, we are done */ 1186 - if (mm_has_pgste(mm)) 1187 - return 0; 1188 - /* Fail if the page tables are 2K */ 1189 - if (!mm_alloc_pgste(mm)) 1190 - return -EINVAL; 1191 - down_write(&mm->mmap_sem); 1192 - mm->context.has_pgste = 1; 1193 - /* split thp mappings and disable thp for future mappings */ 1194 - thp_split_mm(mm); 1195 - up_write(&mm->mmap_sem); 1196 - return 0; 1197 - } 1198 - EXPORT_SYMBOL_GPL(s390_enable_sie); 1199 - 1200 - /* 1201 - * Enable storage key handling from now on and initialize the storage 1202 - * keys with the default key. 1203 - */ 1204 - static int __s390_enable_skey(pte_t *pte, unsigned long addr, 1205 - unsigned long next, struct mm_walk *walk) 1206 - { 1207 - unsigned long ptev; 1208 - pgste_t pgste; 1209 - 1210 - pgste = pgste_get_lock(pte); 1211 - /* 1212 - * Remove all zero page mappings, 1213 - * after establishing a policy to forbid zero page mappings 1214 - * following faults for that page will get fresh anonymous pages 1215 - */ 1216 - if (is_zero_pfn(pte_pfn(*pte))) { 1217 - ptep_flush_direct(walk->mm, addr, pte); 1218 - pte_val(*pte) = _PAGE_INVALID; 1219 - } 1220 - /* Clear storage key */ 1221 - pgste_val(pgste) &= ~(PGSTE_ACC_BITS | PGSTE_FP_BIT | 1222 - PGSTE_GR_BIT | PGSTE_GC_BIT); 1223 - ptev = pte_val(*pte); 1224 - if (!(ptev & _PAGE_INVALID) && (ptev & _PAGE_WRITE)) 1225 - page_set_storage_key(ptev & PAGE_MASK, PAGE_DEFAULT_KEY, 1); 1226 - pgste_set_unlock(pte, pgste); 1227 - return 0; 1228 - } 1229 - 1230 - int s390_enable_skey(void) 1231 - { 1232 - struct mm_walk walk = { .pte_entry = __s390_enable_skey }; 1233 - struct mm_struct *mm = current->mm; 1234 - struct vm_area_struct *vma; 1235 - int rc = 0; 1236 - 1237 - down_write(&mm->mmap_sem); 1238 - if (mm_use_skey(mm)) 1239 - goto out_up; 1240 - 1241 - mm->context.use_skey = 1; 1242 - for (vma = mm->mmap; vma; vma = vma->vm_next) { 1243 - if (ksm_madvise(vma, vma->vm_start, vma->vm_end, 1244 - MADV_UNMERGEABLE, &vma->vm_flags)) { 1245 - mm->context.use_skey = 0; 1246 - rc = -ENOMEM; 1247 - goto out_up; 1248 - } 1249 - } 1250 - mm->def_flags &= ~VM_MERGEABLE; 1251 - 1252 - walk.mm = mm; 1253 - walk_page_range(0, TASK_SIZE, &walk); 1254 - 1255 - out_up: 1256 - up_write(&mm->mmap_sem); 1257 - return rc; 1258 - } 1259 - EXPORT_SYMBOL_GPL(s390_enable_skey); 1260 - 1261 - /* 1262 - * Reset CMMA state, make all pages stable again. 1263 - */ 1264 - static int __s390_reset_cmma(pte_t *pte, unsigned long addr, 1265 - unsigned long next, struct mm_walk *walk) 1266 - { 1267 - pgste_t pgste; 1268 - 1269 - pgste = pgste_get_lock(pte); 1270 - pgste_val(pgste) &= ~_PGSTE_GPS_USAGE_MASK; 1271 - pgste_set_unlock(pte, pgste); 1272 - return 0; 1273 - } 1274 - 1275 - void s390_reset_cmma(struct mm_struct *mm) 1276 - { 1277 - struct mm_walk walk = { .pte_entry = __s390_reset_cmma }; 1278 - 1279 - down_write(&mm->mmap_sem); 1280 - walk.mm = mm; 1281 - walk_page_range(0, TASK_SIZE, &walk); 1282 - up_write(&mm->mmap_sem); 1283 - } 1284 - EXPORT_SYMBOL_GPL(s390_reset_cmma); 1285 - 1286 - /* 1287 - * Test and reset if a guest page is dirty 1288 - */ 1289 - bool gmap_test_and_clear_dirty(unsigned long address, struct gmap *gmap) 1290 - { 1291 - pte_t *pte; 1292 - spinlock_t *ptl; 1293 - bool dirty = false; 1294 - 1295 - pte = get_locked_pte(gmap->mm, address, &ptl); 1296 - if (unlikely(!pte)) 1297 - return false; 1298 - 1299 - if (ptep_test_and_clear_user_dirty(gmap->mm, address, pte)) 1300 - dirty = true; 1301 - 1302 - spin_unlock(ptl); 1303 - return dirty; 1304 - } 1305 - EXPORT_SYMBOL_GPL(gmap_test_and_clear_dirty); 1306 - 1307 - #ifdef CONFIG_TRANSPARENT_HUGEPAGE 1308 - int pmdp_clear_flush_young(struct vm_area_struct *vma, unsigned long address, 1309 - pmd_t *pmdp) 1310 - { 1311 - VM_BUG_ON(address & ~HPAGE_PMD_MASK); 1312 - /* No need to flush TLB 1313 - * On s390 reference bits are in storage key and never in TLB */ 1314 - return pmdp_test_and_clear_young(vma, address, pmdp); 1315 - } 1316 - 1317 - int pmdp_set_access_flags(struct vm_area_struct *vma, 1318 - unsigned long address, pmd_t *pmdp, 1319 - pmd_t entry, int dirty) 1320 - { 1321 - VM_BUG_ON(address & ~HPAGE_PMD_MASK); 1322 - 1323 - entry = pmd_mkyoung(entry); 1324 - if (dirty) 1325 - entry = pmd_mkdirty(entry); 1326 - if (pmd_same(*pmdp, entry)) 1327 - return 0; 1328 - pmdp_invalidate(vma, address, pmdp); 1329 - set_pmd_at(vma->vm_mm, address, pmdp, entry); 1330 - return 1; 1331 - } 1332 - 1333 354 void pgtable_trans_huge_deposit(struct mm_struct *mm, pmd_t *pmdp, 1334 355 pgtable_t pgtable) 1335 356 { ··· 390 1369 return pgtable; 391 1370 } 392 1371 #endif /* CONFIG_TRANSPARENT_HUGEPAGE */ 1372 + 1373 + #ifdef CONFIG_PGSTE 1374 + void ptep_set_pte_at(struct mm_struct *mm, unsigned long addr, 1375 + pte_t *ptep, pte_t entry) 1376 + { 1377 + pgste_t pgste; 1378 + 1379 + /* the mm_has_pgste() check is done in set_pte_at() */ 1380 + pgste = pgste_get_lock(ptep); 1381 + pgste_val(pgste) &= ~_PGSTE_GPS_ZERO; 1382 + pgste_set_key(ptep, pgste, entry, mm); 1383 + pgste = pgste_set_pte(ptep, pgste, entry); 1384 + pgste_set_unlock(ptep, pgste); 1385 + } 1386 + 1387 + void ptep_set_notify(struct mm_struct *mm, unsigned long addr, pte_t *ptep) 1388 + { 1389 + pgste_t pgste; 1390 + 1391 + pgste = pgste_get_lock(ptep); 1392 + pgste_val(pgste) |= PGSTE_IN_BIT; 1393 + pgste_set_unlock(ptep, pgste); 1394 + } 1395 + 1396 + static void ptep_zap_swap_entry(struct mm_struct *mm, swp_entry_t entry) 1397 + { 1398 + if (!non_swap_entry(entry)) 1399 + dec_mm_counter(mm, MM_SWAPENTS); 1400 + else if (is_migration_entry(entry)) { 1401 + struct page *page = migration_entry_to_page(entry); 1402 + 1403 + dec_mm_counter(mm, mm_counter(page)); 1404 + } 1405 + free_swap_and_cache(entry); 1406 + } 1407 + 1408 + void ptep_zap_unused(struct mm_struct *mm, unsigned long addr, 1409 + pte_t *ptep, int reset) 1410 + { 1411 + unsigned long pgstev; 1412 + pgste_t pgste; 1413 + pte_t pte; 1414 + 1415 + /* Zap unused and logically-zero pages */ 1416 + pgste = pgste_get_lock(ptep); 1417 + pgstev = pgste_val(pgste); 1418 + pte = *ptep; 1419 + if (pte_swap(pte) && 1420 + ((pgstev & _PGSTE_GPS_USAGE_MASK) == _PGSTE_GPS_USAGE_UNUSED || 1421 + (pgstev & _PGSTE_GPS_ZERO))) { 1422 + ptep_zap_swap_entry(mm, pte_to_swp_entry(pte)); 1423 + pte_clear(mm, addr, ptep); 1424 + } 1425 + if (reset) 1426 + pgste_val(pgste) &= ~_PGSTE_GPS_USAGE_MASK; 1427 + pgste_set_unlock(ptep, pgste); 1428 + } 1429 + 1430 + void ptep_zap_key(struct mm_struct *mm, unsigned long addr, pte_t *ptep) 1431 + { 1432 + unsigned long ptev; 1433 + pgste_t pgste; 1434 + 1435 + /* Clear storage key */ 1436 + pgste = pgste_get_lock(ptep); 1437 + pgste_val(pgste) &= ~(PGSTE_ACC_BITS | PGSTE_FP_BIT | 1438 + PGSTE_GR_BIT | PGSTE_GC_BIT); 1439 + ptev = pte_val(*ptep); 1440 + if (!(ptev & _PAGE_INVALID) && (ptev & _PAGE_WRITE)) 1441 + page_set_storage_key(ptev & PAGE_MASK, PAGE_DEFAULT_KEY, 1); 1442 + pgste_set_unlock(ptep, pgste); 1443 + } 1444 + 1445 + /* 1446 + * Test and reset if a guest page is dirty 1447 + */ 1448 + bool test_and_clear_guest_dirty(struct mm_struct *mm, unsigned long addr) 1449 + { 1450 + spinlock_t *ptl; 1451 + pgste_t pgste; 1452 + pte_t *ptep; 1453 + pte_t pte; 1454 + bool dirty; 1455 + 1456 + ptep = get_locked_pte(mm, addr, &ptl); 1457 + if (unlikely(!ptep)) 1458 + return false; 1459 + 1460 + pgste = pgste_get_lock(ptep); 1461 + dirty = !!(pgste_val(pgste) & PGSTE_UC_BIT); 1462 + pgste_val(pgste) &= ~PGSTE_UC_BIT; 1463 + pte = *ptep; 1464 + if (dirty && (pte_val(pte) & _PAGE_PRESENT)) { 1465 + pgste = pgste_ipte_notify(mm, addr, ptep, pgste); 1466 + __ptep_ipte(addr, ptep); 1467 + if (MACHINE_HAS_ESOP || !(pte_val(pte) & _PAGE_WRITE)) 1468 + pte_val(pte) |= _PAGE_PROTECT; 1469 + else 1470 + pte_val(pte) |= _PAGE_INVALID; 1471 + *ptep = pte; 1472 + } 1473 + pgste_set_unlock(ptep, pgste); 1474 + 1475 + spin_unlock(ptl); 1476 + return dirty; 1477 + } 1478 + EXPORT_SYMBOL_GPL(test_and_clear_guest_dirty); 1479 + 1480 + int set_guest_storage_key(struct mm_struct *mm, unsigned long addr, 1481 + unsigned char key, bool nq) 1482 + { 1483 + unsigned long keyul; 1484 + spinlock_t *ptl; 1485 + pgste_t old, new; 1486 + pte_t *ptep; 1487 + 1488 + down_read(&mm->mmap_sem); 1489 + ptep = get_locked_pte(mm, addr, &ptl); 1490 + if (unlikely(!ptep)) { 1491 + up_read(&mm->mmap_sem); 1492 + return -EFAULT; 1493 + } 1494 + 1495 + new = old = pgste_get_lock(ptep); 1496 + pgste_val(new) &= ~(PGSTE_GR_BIT | PGSTE_GC_BIT | 1497 + PGSTE_ACC_BITS | PGSTE_FP_BIT); 1498 + keyul = (unsigned long) key; 1499 + pgste_val(new) |= (keyul & (_PAGE_CHANGED | _PAGE_REFERENCED)) << 48; 1500 + pgste_val(new) |= (keyul & (_PAGE_ACC_BITS | _PAGE_FP_BIT)) << 56; 1501 + if (!(pte_val(*ptep) & _PAGE_INVALID)) { 1502 + unsigned long address, bits, skey; 1503 + 1504 + address = pte_val(*ptep) & PAGE_MASK; 1505 + skey = (unsigned long) page_get_storage_key(address); 1506 + bits = skey & (_PAGE_CHANGED | _PAGE_REFERENCED); 1507 + skey = key & (_PAGE_ACC_BITS | _PAGE_FP_BIT); 1508 + /* Set storage key ACC and FP */ 1509 + page_set_storage_key(address, skey, !nq); 1510 + /* Merge host changed & referenced into pgste */ 1511 + pgste_val(new) |= bits << 52; 1512 + } 1513 + /* changing the guest storage key is considered a change of the page */ 1514 + if ((pgste_val(new) ^ pgste_val(old)) & 1515 + (PGSTE_ACC_BITS | PGSTE_FP_BIT | PGSTE_GR_BIT | PGSTE_GC_BIT)) 1516 + pgste_val(new) |= PGSTE_UC_BIT; 1517 + 1518 + pgste_set_unlock(ptep, new); 1519 + pte_unmap_unlock(ptep, ptl); 1520 + up_read(&mm->mmap_sem); 1521 + return 0; 1522 + } 1523 + EXPORT_SYMBOL(set_guest_storage_key); 1524 + 1525 + unsigned char get_guest_storage_key(struct mm_struct *mm, unsigned long addr) 1526 + { 1527 + unsigned char key; 1528 + spinlock_t *ptl; 1529 + pgste_t pgste; 1530 + pte_t *ptep; 1531 + 1532 + down_read(&mm->mmap_sem); 1533 + ptep = get_locked_pte(mm, addr, &ptl); 1534 + if (unlikely(!ptep)) { 1535 + up_read(&mm->mmap_sem); 1536 + return -EFAULT; 1537 + } 1538 + pgste = pgste_get_lock(ptep); 1539 + 1540 + if (pte_val(*ptep) & _PAGE_INVALID) { 1541 + key = (pgste_val(pgste) & PGSTE_ACC_BITS) >> 56; 1542 + key |= (pgste_val(pgste) & PGSTE_FP_BIT) >> 56; 1543 + key |= (pgste_val(pgste) & PGSTE_GR_BIT) >> 48; 1544 + key |= (pgste_val(pgste) & PGSTE_GC_BIT) >> 48; 1545 + } else { 1546 + key = page_get_storage_key(pte_val(*ptep) & PAGE_MASK); 1547 + 1548 + /* Reflect guest's logical view, not physical */ 1549 + if (pgste_val(pgste) & PGSTE_GR_BIT) 1550 + key |= _PAGE_REFERENCED; 1551 + if (pgste_val(pgste) & PGSTE_GC_BIT) 1552 + key |= _PAGE_CHANGED; 1553 + } 1554 + 1555 + pgste_set_unlock(ptep, pgste); 1556 + pte_unmap_unlock(ptep, ptl); 1557 + up_read(&mm->mmap_sem); 1558 + return key; 1559 + } 1560 + EXPORT_SYMBOL(get_guest_storage_key); 1561 + #endif
+1 -1
arch/s390/oprofile/Makefile
··· 6 6 oprofilefs.o oprofile_stats.o \ 7 7 timer_int.o ) 8 8 9 - oprofile-y := $(DRIVER_OBJS) init.o backtrace.o 9 + oprofile-y := $(DRIVER_OBJS) init.o 10 10 oprofile-y += hwsampler.o
-78
arch/s390/oprofile/backtrace.c
··· 1 - /* 2 - * S390 Version 3 - * Copyright IBM Corp. 2005 4 - * Author(s): Andreas Krebbel <Andreas.Krebbel@de.ibm.com> 5 - */ 6 - 7 - #include <linux/oprofile.h> 8 - 9 - #include <asm/processor.h> /* for struct stack_frame */ 10 - 11 - static unsigned long 12 - __show_trace(unsigned int *depth, unsigned long sp, 13 - unsigned long low, unsigned long high) 14 - { 15 - struct stack_frame *sf; 16 - struct pt_regs *regs; 17 - 18 - while (*depth) { 19 - if (sp < low || sp > high - sizeof(*sf)) 20 - return sp; 21 - sf = (struct stack_frame *) sp; 22 - (*depth)--; 23 - oprofile_add_trace(sf->gprs[8]); 24 - 25 - /* Follow the backchain. */ 26 - while (*depth) { 27 - low = sp; 28 - sp = sf->back_chain; 29 - if (!sp) 30 - break; 31 - if (sp <= low || sp > high - sizeof(*sf)) 32 - return sp; 33 - sf = (struct stack_frame *) sp; 34 - (*depth)--; 35 - oprofile_add_trace(sf->gprs[8]); 36 - 37 - } 38 - 39 - if (*depth == 0) 40 - break; 41 - 42 - /* Zero backchain detected, check for interrupt frame. */ 43 - sp = (unsigned long) (sf + 1); 44 - if (sp <= low || sp > high - sizeof(*regs)) 45 - return sp; 46 - regs = (struct pt_regs *) sp; 47 - (*depth)--; 48 - oprofile_add_trace(sf->gprs[8]); 49 - low = sp; 50 - sp = regs->gprs[15]; 51 - } 52 - return sp; 53 - } 54 - 55 - void s390_backtrace(struct pt_regs * const regs, unsigned int depth) 56 - { 57 - unsigned long head, frame_size; 58 - struct stack_frame* head_sf; 59 - 60 - if (user_mode(regs)) 61 - return; 62 - 63 - frame_size = STACK_FRAME_OVERHEAD + sizeof(struct pt_regs); 64 - head = regs->gprs[15]; 65 - head_sf = (struct stack_frame*)head; 66 - 67 - if (!head_sf->back_chain) 68 - return; 69 - 70 - head = head_sf->back_chain; 71 - 72 - head = __show_trace(&depth, head, 73 - S390_lowcore.async_stack + frame_size - ASYNC_SIZE, 74 - S390_lowcore.async_stack + frame_size); 75 - 76 - __show_trace(&depth, head, S390_lowcore.thread_info, 77 - S390_lowcore.thread_info + THREAD_SIZE); 78 - }
+19 -2
arch/s390/oprofile/init.c
··· 20 20 21 21 #include "../../../drivers/oprofile/oprof.h" 22 22 23 - extern void s390_backtrace(struct pt_regs * const regs, unsigned int depth); 24 - 25 23 #include "hwsampler.h" 26 24 #include "op_counter.h" 27 25 ··· 454 456 case 0x2097: case 0x2098: ops->cpu_type = "s390/z10"; break; 455 457 case 0x2817: case 0x2818: ops->cpu_type = "s390/z196"; break; 456 458 case 0x2827: case 0x2828: ops->cpu_type = "s390/zEC12"; break; 459 + case 0x2964: case 0x2965: ops->cpu_type = "s390/z13"; break; 457 460 default: return -ENODEV; 458 461 } 459 462 } ··· 491 492 static void oprofile_hwsampler_exit(void) 492 493 { 493 494 hwsampler_shutdown(); 495 + } 496 + 497 + static int __s390_backtrace(void *data, unsigned long address) 498 + { 499 + unsigned int *depth = data; 500 + 501 + if (*depth == 0) 502 + return 1; 503 + (*depth)--; 504 + oprofile_add_trace(address); 505 + return 0; 506 + } 507 + 508 + static void s390_backtrace(struct pt_regs *regs, unsigned int depth) 509 + { 510 + if (user_mode(regs)) 511 + return; 512 + dump_trace(__s390_backtrace, &depth, NULL, regs->gprs[15]); 494 513 } 495 514 496 515 int __init oprofile_arch_init(struct oprofile_operations *ops)
+5 -6
arch/s390/pci/pci.c
··· 637 637 638 638 int pcibios_add_device(struct pci_dev *pdev) 639 639 { 640 - struct zpci_dev *zdev = to_zpci(pdev); 641 640 struct resource *res; 642 641 int i; 643 642 644 - zdev->pdev = pdev; 645 643 pdev->dev.groups = zpci_attr_groups; 646 644 zpci_map_resources(pdev); 647 645 ··· 662 664 { 663 665 struct zpci_dev *zdev = to_zpci(pdev); 664 666 665 - zdev->pdev = pdev; 666 - zpci_debug_init_device(zdev); 667 + zpci_debug_init_device(zdev, dev_name(&pdev->dev)); 667 668 zpci_fmb_enable_device(zdev); 668 669 669 670 return pci_enable_resources(pdev, mask); ··· 674 677 675 678 zpci_fmb_disable_device(zdev); 676 679 zpci_debug_exit_device(zdev); 677 - zdev->pdev = NULL; 678 680 } 679 681 680 682 #ifdef CONFIG_HIBERNATE_CALLBACKS ··· 860 864 861 865 static int zpci_mem_init(void) 862 866 { 867 + BUILD_BUG_ON(!is_power_of_2(__alignof__(struct zpci_fmb)) || 868 + __alignof__(struct zpci_fmb) < sizeof(struct zpci_fmb)); 869 + 863 870 zdev_fmb_cache = kmem_cache_create("PCI_FMB_cache", sizeof(struct zpci_fmb), 864 - 16, 0, NULL); 871 + __alignof__(struct zpci_fmb), 0, NULL); 865 872 if (!zdev_fmb_cache) 866 873 goto error_fmb; 867 874
+235 -12
arch/s390/pci/pci_clp.c
··· 8 8 #define KMSG_COMPONENT "zpci" 9 9 #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt 10 10 11 + #include <linux/compat.h> 11 12 #include <linux/kernel.h> 13 + #include <linux/miscdevice.h> 12 14 #include <linux/slab.h> 13 15 #include <linux/err.h> 14 16 #include <linux/delay.h> 15 17 #include <linux/pci.h> 18 + #include <linux/uaccess.h> 16 19 #include <asm/pci_debug.h> 17 20 #include <asm/pci_clp.h> 21 + #include <asm/compat.h> 22 + #include <asm/clp.h> 23 + #include <uapi/asm/clp.h> 18 24 19 25 static inline void zpci_err_clp(unsigned int rsp, int rc) 20 26 { ··· 33 27 } 34 28 35 29 /* 36 - * Call Logical Processor 37 - * Retry logic is handled by the caller. 30 + * Call Logical Processor with c=1, lps=0 and command 1 31 + * to get the bit mask of installed logical processors 38 32 */ 39 - static inline u8 clp_instr(void *data) 33 + static inline int clp_get_ilp(unsigned long *ilp) 34 + { 35 + unsigned long mask; 36 + int cc = 3; 37 + 38 + asm volatile ( 39 + " .insn rrf,0xb9a00000,%[mask],%[cmd],8,0\n" 40 + "0: ipm %[cc]\n" 41 + " srl %[cc],28\n" 42 + "1:\n" 43 + EX_TABLE(0b, 1b) 44 + : [cc] "+d" (cc), [mask] "=d" (mask) : [cmd] "a" (1) 45 + : "cc"); 46 + *ilp = mask; 47 + return cc; 48 + } 49 + 50 + /* 51 + * Call Logical Processor with c=0, the give constant lps and an lpcb request. 52 + */ 53 + static inline int clp_req(void *data, unsigned int lps) 40 54 { 41 55 struct { u8 _[CLP_BLK_SIZE]; } *req = data; 42 56 u64 ignored; 43 - u8 cc; 57 + int cc = 3; 44 58 45 59 asm volatile ( 46 - " .insn rrf,0xb9a00000,%[ign],%[req],0x0,0x2\n" 47 - " ipm %[cc]\n" 60 + " .insn rrf,0xb9a00000,%[ign],%[req],0,%[lps]\n" 61 + "0: ipm %[cc]\n" 48 62 " srl %[cc],28\n" 49 - : [cc] "=d" (cc), [ign] "=d" (ignored), "+m" (*req) 50 - : [req] "a" (req) 63 + "1:\n" 64 + EX_TABLE(0b, 1b) 65 + : [cc] "+d" (cc), [ign] "=d" (ignored), "+m" (*req) 66 + : [req] "a" (req), [lps] "i" (lps) 51 67 : "cc"); 52 68 return cc; 53 69 } ··· 118 90 rrb->response.hdr.len = sizeof(rrb->response); 119 91 rrb->request.pfgid = pfgid; 120 92 121 - rc = clp_instr(rrb); 93 + rc = clp_req(rrb, CLP_LPS_PCI); 122 94 if (!rc && rrb->response.hdr.rsp == CLP_RC_OK) 123 95 clp_store_query_pci_fngrp(zdev, &rrb->response); 124 96 else { ··· 171 143 rrb->response.hdr.len = sizeof(rrb->response); 172 144 rrb->request.fh = fh; 173 145 174 - rc = clp_instr(rrb); 146 + rc = clp_req(rrb, CLP_LPS_PCI); 175 147 if (!rc && rrb->response.hdr.rsp == CLP_RC_OK) { 176 148 rc = clp_store_query_pci_fn(zdev, &rrb->response); 177 149 if (rc) ··· 242 214 rrb->request.oc = command; 243 215 rrb->request.ndas = nr_dma_as; 244 216 245 - rc = clp_instr(rrb); 217 + rc = clp_req(rrb, CLP_LPS_PCI); 246 218 if (rrb->response.hdr.rsp == CLP_RC_SETPCIFN_BUSY) { 247 219 retries--; 248 220 if (retries < 0) ··· 308 280 rrb->request.resume_token = resume_token; 309 281 310 282 /* Get PCI function handle list */ 311 - rc = clp_instr(rrb); 283 + rc = clp_req(rrb, CLP_LPS_PCI); 312 284 if (rc || rrb->response.hdr.rsp != CLP_RC_OK) { 313 285 zpci_err("List PCI FN:\n"); 314 286 zpci_err_clp(rrb->response.hdr.rsp, rc); ··· 419 391 clp_free_block(rrb); 420 392 return rc; 421 393 } 394 + 395 + static int clp_base_slpc(struct clp_req *req, struct clp_req_rsp_slpc *lpcb) 396 + { 397 + unsigned long limit = PAGE_SIZE - sizeof(lpcb->request); 398 + 399 + if (lpcb->request.hdr.len != sizeof(lpcb->request) || 400 + lpcb->response.hdr.len > limit) 401 + return -EINVAL; 402 + return clp_req(lpcb, CLP_LPS_BASE) ? -EOPNOTSUPP : 0; 403 + } 404 + 405 + static int clp_base_command(struct clp_req *req, struct clp_req_hdr *lpcb) 406 + { 407 + switch (lpcb->cmd) { 408 + case 0x0001: /* store logical-processor characteristics */ 409 + return clp_base_slpc(req, (void *) lpcb); 410 + default: 411 + return -EINVAL; 412 + } 413 + } 414 + 415 + static int clp_pci_slpc(struct clp_req *req, struct clp_req_rsp_slpc *lpcb) 416 + { 417 + unsigned long limit = PAGE_SIZE - sizeof(lpcb->request); 418 + 419 + if (lpcb->request.hdr.len != sizeof(lpcb->request) || 420 + lpcb->response.hdr.len > limit) 421 + return -EINVAL; 422 + return clp_req(lpcb, CLP_LPS_PCI) ? -EOPNOTSUPP : 0; 423 + } 424 + 425 + static int clp_pci_list(struct clp_req *req, struct clp_req_rsp_list_pci *lpcb) 426 + { 427 + unsigned long limit = PAGE_SIZE - sizeof(lpcb->request); 428 + 429 + if (lpcb->request.hdr.len != sizeof(lpcb->request) || 430 + lpcb->response.hdr.len > limit) 431 + return -EINVAL; 432 + if (lpcb->request.reserved2 != 0) 433 + return -EINVAL; 434 + return clp_req(lpcb, CLP_LPS_PCI) ? -EOPNOTSUPP : 0; 435 + } 436 + 437 + static int clp_pci_query(struct clp_req *req, 438 + struct clp_req_rsp_query_pci *lpcb) 439 + { 440 + unsigned long limit = PAGE_SIZE - sizeof(lpcb->request); 441 + 442 + if (lpcb->request.hdr.len != sizeof(lpcb->request) || 443 + lpcb->response.hdr.len > limit) 444 + return -EINVAL; 445 + if (lpcb->request.reserved2 != 0 || lpcb->request.reserved3 != 0) 446 + return -EINVAL; 447 + return clp_req(lpcb, CLP_LPS_PCI) ? -EOPNOTSUPP : 0; 448 + } 449 + 450 + static int clp_pci_query_grp(struct clp_req *req, 451 + struct clp_req_rsp_query_pci_grp *lpcb) 452 + { 453 + unsigned long limit = PAGE_SIZE - sizeof(lpcb->request); 454 + 455 + if (lpcb->request.hdr.len != sizeof(lpcb->request) || 456 + lpcb->response.hdr.len > limit) 457 + return -EINVAL; 458 + if (lpcb->request.reserved2 != 0 || lpcb->request.reserved3 != 0 || 459 + lpcb->request.reserved4 != 0) 460 + return -EINVAL; 461 + return clp_req(lpcb, CLP_LPS_PCI) ? -EOPNOTSUPP : 0; 462 + } 463 + 464 + static int clp_pci_command(struct clp_req *req, struct clp_req_hdr *lpcb) 465 + { 466 + switch (lpcb->cmd) { 467 + case 0x0001: /* store logical-processor characteristics */ 468 + return clp_pci_slpc(req, (void *) lpcb); 469 + case 0x0002: /* list PCI functions */ 470 + return clp_pci_list(req, (void *) lpcb); 471 + case 0x0003: /* query PCI function */ 472 + return clp_pci_query(req, (void *) lpcb); 473 + case 0x0004: /* query PCI function group */ 474 + return clp_pci_query_grp(req, (void *) lpcb); 475 + default: 476 + return -EINVAL; 477 + } 478 + } 479 + 480 + static int clp_normal_command(struct clp_req *req) 481 + { 482 + struct clp_req_hdr *lpcb; 483 + void __user *uptr; 484 + int rc; 485 + 486 + rc = -EINVAL; 487 + if (req->lps != 0 && req->lps != 2) 488 + goto out; 489 + 490 + rc = -ENOMEM; 491 + lpcb = clp_alloc_block(GFP_KERNEL); 492 + if (!lpcb) 493 + goto out; 494 + 495 + rc = -EFAULT; 496 + uptr = (void __force __user *)(unsigned long) req->data_p; 497 + if (copy_from_user(lpcb, uptr, PAGE_SIZE) != 0) 498 + goto out_free; 499 + 500 + rc = -EINVAL; 501 + if (lpcb->fmt != 0 || lpcb->reserved1 != 0 || lpcb->reserved2 != 0) 502 + goto out_free; 503 + 504 + switch (req->lps) { 505 + case 0: 506 + rc = clp_base_command(req, lpcb); 507 + break; 508 + case 2: 509 + rc = clp_pci_command(req, lpcb); 510 + break; 511 + } 512 + if (rc) 513 + goto out_free; 514 + 515 + rc = -EFAULT; 516 + if (copy_to_user(uptr, lpcb, PAGE_SIZE) != 0) 517 + goto out_free; 518 + 519 + rc = 0; 520 + 521 + out_free: 522 + clp_free_block(lpcb); 523 + out: 524 + return rc; 525 + } 526 + 527 + static int clp_immediate_command(struct clp_req *req) 528 + { 529 + void __user *uptr; 530 + unsigned long ilp; 531 + int exists; 532 + 533 + if (req->cmd > 1 || clp_get_ilp(&ilp) != 0) 534 + return -EINVAL; 535 + 536 + uptr = (void __force __user *)(unsigned long) req->data_p; 537 + if (req->cmd == 0) { 538 + /* Command code 0: test for a specific processor */ 539 + exists = test_bit_inv(req->lps, &ilp); 540 + return put_user(exists, (int __user *) uptr); 541 + } 542 + /* Command code 1: return bit mask of installed processors */ 543 + return put_user(ilp, (unsigned long __user *) uptr); 544 + } 545 + 546 + static long clp_misc_ioctl(struct file *filp, unsigned int cmd, 547 + unsigned long arg) 548 + { 549 + struct clp_req req; 550 + void __user *argp; 551 + 552 + if (cmd != CLP_SYNC) 553 + return -EINVAL; 554 + 555 + argp = is_compat_task() ? compat_ptr(arg) : (void __user *) arg; 556 + if (copy_from_user(&req, argp, sizeof(req))) 557 + return -EFAULT; 558 + if (req.r != 0) 559 + return -EINVAL; 560 + return req.c ? clp_immediate_command(&req) : clp_normal_command(&req); 561 + } 562 + 563 + static int clp_misc_release(struct inode *inode, struct file *filp) 564 + { 565 + return 0; 566 + } 567 + 568 + static const struct file_operations clp_misc_fops = { 569 + .owner = THIS_MODULE, 570 + .open = nonseekable_open, 571 + .release = clp_misc_release, 572 + .unlocked_ioctl = clp_misc_ioctl, 573 + .compat_ioctl = clp_misc_ioctl, 574 + .llseek = no_llseek, 575 + }; 576 + 577 + static struct miscdevice clp_misc_device = { 578 + .minor = MISC_DYNAMIC_MINOR, 579 + .name = "clp", 580 + .fops = &clp_misc_fops, 581 + }; 582 + 583 + static int __init clp_misc_init(void) 584 + { 585 + return misc_register(&clp_misc_device); 586 + } 587 + 588 + device_initcall(clp_misc_init);
+2 -3
arch/s390/pci/pci_debug.c
··· 128 128 .release = single_release, 129 129 }; 130 130 131 - void zpci_debug_init_device(struct zpci_dev *zdev) 131 + void zpci_debug_init_device(struct zpci_dev *zdev, const char *name) 132 132 { 133 - zdev->debugfs_dev = debugfs_create_dir(dev_name(&zdev->pdev->dev), 134 - debugfs_root); 133 + zdev->debugfs_dev = debugfs_create_dir(name, debugfs_root); 135 134 if (IS_ERR(zdev->debugfs_dev)) 136 135 zdev->debugfs_dev = NULL; 137 136
+12 -9
arch/s390/pci/pci_dma.c
··· 217 217 dma_free_cpu_table(table); 218 218 } 219 219 220 - static unsigned long __dma_alloc_iommu(struct zpci_dev *zdev, 220 + static unsigned long __dma_alloc_iommu(struct device *dev, 221 221 unsigned long start, int size) 222 222 { 223 + struct zpci_dev *zdev = to_zpci(to_pci_dev(dev)); 223 224 unsigned long boundary_size; 224 225 225 - boundary_size = ALIGN(dma_get_seg_boundary(&zdev->pdev->dev) + 1, 226 + boundary_size = ALIGN(dma_get_seg_boundary(dev) + 1, 226 227 PAGE_SIZE) >> PAGE_SHIFT; 227 228 return iommu_area_alloc(zdev->iommu_bitmap, zdev->iommu_pages, 228 229 start, size, 0, boundary_size, 0); 229 230 } 230 231 231 - static unsigned long dma_alloc_iommu(struct zpci_dev *zdev, int size) 232 + static unsigned long dma_alloc_iommu(struct device *dev, int size) 232 233 { 234 + struct zpci_dev *zdev = to_zpci(to_pci_dev(dev)); 233 235 unsigned long offset, flags; 234 236 int wrap = 0; 235 237 236 238 spin_lock_irqsave(&zdev->iommu_bitmap_lock, flags); 237 - offset = __dma_alloc_iommu(zdev, zdev->next_bit, size); 239 + offset = __dma_alloc_iommu(dev, zdev->next_bit, size); 238 240 if (offset == -1) { 239 241 /* wrap-around */ 240 - offset = __dma_alloc_iommu(zdev, 0, size); 242 + offset = __dma_alloc_iommu(dev, 0, size); 241 243 wrap = 1; 242 244 } 243 245 ··· 253 251 return offset; 254 252 } 255 253 256 - static void dma_free_iommu(struct zpci_dev *zdev, unsigned long offset, int size) 254 + static void dma_free_iommu(struct device *dev, unsigned long offset, int size) 257 255 { 256 + struct zpci_dev *zdev = to_zpci(to_pci_dev(dev)); 258 257 unsigned long flags; 259 258 260 259 spin_lock_irqsave(&zdev->iommu_bitmap_lock, flags); ··· 296 293 297 294 /* This rounds up number of pages based on size and offset */ 298 295 nr_pages = iommu_num_pages(pa, size, PAGE_SIZE); 299 - iommu_page_index = dma_alloc_iommu(zdev, nr_pages); 296 + iommu_page_index = dma_alloc_iommu(dev, nr_pages); 300 297 if (iommu_page_index == -1) { 301 298 ret = -ENOSPC; 302 299 goto out_err; ··· 322 319 return dma_addr + (offset & ~PAGE_MASK); 323 320 324 321 out_free: 325 - dma_free_iommu(zdev, iommu_page_index, nr_pages); 322 + dma_free_iommu(dev, iommu_page_index, nr_pages); 326 323 out_err: 327 324 zpci_err("map error:\n"); 328 325 zpci_err_dma(ret, pa); ··· 349 346 350 347 atomic64_add(npages, &zdev->unmapped_pages); 351 348 iommu_page_index = (dma_addr - zdev->start_dma) >> PAGE_SHIFT; 352 - dma_free_iommu(zdev, iommu_page_index, npages); 349 + dma_free_iommu(dev, iommu_page_index, npages); 353 350 } 354 351 355 352 static void *s390_dma_alloc(struct device *dev, size_t size,
+11 -2
arch/s390/pci/pci_event.c
··· 46 46 static void __zpci_event_error(struct zpci_ccdf_err *ccdf) 47 47 { 48 48 struct zpci_dev *zdev = get_zdev_by_fid(ccdf->fid); 49 - struct pci_dev *pdev = zdev ? zdev->pdev : NULL; 49 + struct pci_dev *pdev = NULL; 50 50 51 51 zpci_err("error CCDF:\n"); 52 52 zpci_err_hex(ccdf, sizeof(*ccdf)); 53 + 54 + if (zdev) 55 + pdev = pci_get_slot(zdev->bus, ZPCI_DEVFN); 53 56 54 57 pr_err("%s: Event 0x%x reports an error for PCI function 0x%x\n", 55 58 pdev ? pci_name(pdev) : "n/a", ccdf->pec, ccdf->fid); ··· 61 58 return; 62 59 63 60 pdev->error_state = pci_channel_io_perm_failure; 61 + pci_dev_put(pdev); 64 62 } 65 63 66 64 void zpci_event_error(void *data) ··· 73 69 static void __zpci_event_availability(struct zpci_ccdf_avail *ccdf) 74 70 { 75 71 struct zpci_dev *zdev = get_zdev_by_fid(ccdf->fid); 76 - struct pci_dev *pdev = zdev ? zdev->pdev : NULL; 72 + struct pci_dev *pdev = NULL; 77 73 int ret; 74 + 75 + if (zdev) 76 + pdev = pci_get_slot(zdev->bus, ZPCI_DEVFN); 78 77 79 78 pr_info("%s: Event 0x%x reconfigured PCI function 0x%x\n", 80 79 pdev ? pci_name(pdev) : "n/a", ccdf->pec, ccdf->fid); ··· 145 138 default: 146 139 break; 147 140 } 141 + if (pdev) 142 + pci_dev_put(pdev); 148 143 } 149 144 150 145 void zpci_event_availability(void *data)
+6 -2
drivers/pci/hotplug/s390_pci_hpc.c
··· 93 93 static int disable_slot(struct hotplug_slot *hotplug_slot) 94 94 { 95 95 struct slot *slot = hotplug_slot->private; 96 + struct pci_dev *pdev; 96 97 int rc; 97 98 98 99 if (!zpci_fn_configured(slot->zdev->state)) 99 100 return -EIO; 100 101 101 - if (slot->zdev->pdev) 102 - pci_stop_and_remove_bus_device_locked(slot->zdev->pdev); 102 + pdev = pci_get_slot(slot->zdev->bus, ZPCI_DEVFN); 103 + if (pdev) { 104 + pci_stop_and_remove_bus_device_locked(pdev); 105 + pci_dev_put(pdev); 106 + } 103 107 104 108 rc = zpci_disable_device(slot->zdev); 105 109 if (rc)
+172 -118
drivers/s390/block/dasd_alias.c
··· 185 185 */ 186 186 int dasd_alias_make_device_known_to_lcu(struct dasd_device *device) 187 187 { 188 - struct dasd_eckd_private *private; 188 + struct dasd_eckd_private *private = device->private; 189 189 unsigned long flags; 190 190 struct alias_server *server, *newserver; 191 191 struct alias_lcu *lcu, *newlcu; 192 192 struct dasd_uid uid; 193 - 194 - private = (struct dasd_eckd_private *) device->private; 195 193 196 194 device->discipline->get_uid(device, &uid); 197 195 spin_lock_irqsave(&aliastree.lock, flags); ··· 242 244 */ 243 245 void dasd_alias_disconnect_device_from_lcu(struct dasd_device *device) 244 246 { 245 - struct dasd_eckd_private *private; 247 + struct dasd_eckd_private *private = device->private; 246 248 unsigned long flags; 247 249 struct alias_lcu *lcu; 248 250 struct alias_server *server; 249 251 int was_pending; 250 252 struct dasd_uid uid; 251 253 252 - private = (struct dasd_eckd_private *) device->private; 253 254 lcu = private->lcu; 254 255 /* nothing to do if already disconnected */ 255 256 if (!lcu) ··· 313 316 struct dasd_device *pos) 314 317 { 315 318 316 - struct dasd_eckd_private *private; 319 + struct dasd_eckd_private *private = device->private; 317 320 struct alias_pav_group *group; 318 321 struct dasd_uid uid; 319 - unsigned long flags; 320 322 321 - private = (struct dasd_eckd_private *) device->private; 322 - 323 - /* only lock if not already locked */ 324 - if (device != pos) 325 - spin_lock_irqsave_nested(get_ccwdev_lock(device->cdev), flags, 326 - CDEV_NESTED_SECOND); 327 323 private->uid.type = lcu->uac->unit[private->uid.real_unit_addr].ua_type; 328 324 private->uid.base_unit_addr = 329 325 lcu->uac->unit[private->uid.real_unit_addr].base_ua; 330 326 uid = private->uid; 331 - 332 - if (device != pos) 333 - spin_unlock_irqrestore(get_ccwdev_lock(device->cdev), flags); 334 327 335 328 /* if we have no PAV anyway, we don't need to bother with PAV groups */ 336 329 if (lcu->pav == NO_PAV) { ··· 357 370 static void _remove_device_from_lcu(struct alias_lcu *lcu, 358 371 struct dasd_device *device) 359 372 { 360 - struct dasd_eckd_private *private; 373 + struct dasd_eckd_private *private = device->private; 361 374 struct alias_pav_group *group; 362 375 363 - private = (struct dasd_eckd_private *) device->private; 364 376 list_move(&device->alias_list, &lcu->inactive_devices); 365 377 group = private->pavgroup; 366 378 if (!group) ··· 395 409 return 1; 396 410 397 411 return 0; 412 + } 413 + 414 + /* 415 + * This function tries to lock all devices on an lcu via trylock 416 + * return NULL on success otherwise return first failed device 417 + */ 418 + static struct dasd_device *_trylock_all_devices_on_lcu(struct alias_lcu *lcu, 419 + struct dasd_device *pos) 420 + 421 + { 422 + struct alias_pav_group *pavgroup; 423 + struct dasd_device *device; 424 + 425 + list_for_each_entry(device, &lcu->active_devices, alias_list) { 426 + if (device == pos) 427 + continue; 428 + if (!spin_trylock(get_ccwdev_lock(device->cdev))) 429 + return device; 430 + } 431 + list_for_each_entry(device, &lcu->inactive_devices, alias_list) { 432 + if (device == pos) 433 + continue; 434 + if (!spin_trylock(get_ccwdev_lock(device->cdev))) 435 + return device; 436 + } 437 + list_for_each_entry(pavgroup, &lcu->grouplist, group) { 438 + list_for_each_entry(device, &pavgroup->baselist, alias_list) { 439 + if (device == pos) 440 + continue; 441 + if (!spin_trylock(get_ccwdev_lock(device->cdev))) 442 + return device; 443 + } 444 + list_for_each_entry(device, &pavgroup->aliaslist, alias_list) { 445 + if (device == pos) 446 + continue; 447 + if (!spin_trylock(get_ccwdev_lock(device->cdev))) 448 + return device; 449 + } 450 + } 451 + return NULL; 452 + } 453 + 454 + /* 455 + * unlock all devices except the one that is specified as pos 456 + * stop if enddev is specified and reached 457 + */ 458 + static void _unlock_all_devices_on_lcu(struct alias_lcu *lcu, 459 + struct dasd_device *pos, 460 + struct dasd_device *enddev) 461 + 462 + { 463 + struct alias_pav_group *pavgroup; 464 + struct dasd_device *device; 465 + 466 + list_for_each_entry(device, &lcu->active_devices, alias_list) { 467 + if (device == pos) 468 + continue; 469 + if (device == enddev) 470 + return; 471 + spin_unlock(get_ccwdev_lock(device->cdev)); 472 + } 473 + list_for_each_entry(device, &lcu->inactive_devices, alias_list) { 474 + if (device == pos) 475 + continue; 476 + if (device == enddev) 477 + return; 478 + spin_unlock(get_ccwdev_lock(device->cdev)); 479 + } 480 + list_for_each_entry(pavgroup, &lcu->grouplist, group) { 481 + list_for_each_entry(device, &pavgroup->baselist, alias_list) { 482 + if (device == pos) 483 + continue; 484 + if (device == enddev) 485 + return; 486 + spin_unlock(get_ccwdev_lock(device->cdev)); 487 + } 488 + list_for_each_entry(device, &pavgroup->aliaslist, alias_list) { 489 + if (device == pos) 490 + continue; 491 + if (device == enddev) 492 + return; 493 + spin_unlock(get_ccwdev_lock(device->cdev)); 494 + } 495 + } 496 + } 497 + 498 + /* 499 + * this function is needed because the locking order 500 + * device lock -> lcu lock 501 + * needs to be assured when iterating over devices in an LCU 502 + * 503 + * if a device is specified in pos then the device lock is already hold 504 + */ 505 + static void _trylock_and_lock_lcu_irqsave(struct alias_lcu *lcu, 506 + struct dasd_device *pos, 507 + unsigned long *flags) 508 + { 509 + struct dasd_device *failed; 510 + 511 + do { 512 + spin_lock_irqsave(&lcu->lock, *flags); 513 + failed = _trylock_all_devices_on_lcu(lcu, pos); 514 + if (failed) { 515 + _unlock_all_devices_on_lcu(lcu, pos, failed); 516 + spin_unlock_irqrestore(&lcu->lock, *flags); 517 + cpu_relax(); 518 + } 519 + } while (failed); 520 + } 521 + 522 + static void _trylock_and_lock_lcu(struct alias_lcu *lcu, 523 + struct dasd_device *pos) 524 + { 525 + struct dasd_device *failed; 526 + 527 + do { 528 + spin_lock(&lcu->lock); 529 + failed = _trylock_all_devices_on_lcu(lcu, pos); 530 + if (failed) { 531 + _unlock_all_devices_on_lcu(lcu, pos, failed); 532 + spin_unlock(&lcu->lock); 533 + cpu_relax(); 534 + } 535 + } while (failed); 398 536 } 399 537 400 538 static int read_unit_address_configuration(struct dasd_device *device, ··· 597 487 list_for_each_entry_safe(device, tempdev, &pavgroup->baselist, 598 488 alias_list) { 599 489 list_move(&device->alias_list, &lcu->active_devices); 600 - private = (struct dasd_eckd_private *) device->private; 490 + private = device->private; 601 491 private->pavgroup = NULL; 602 492 } 603 493 list_for_each_entry_safe(device, tempdev, &pavgroup->aliaslist, 604 494 alias_list) { 605 495 list_move(&device->alias_list, &lcu->active_devices); 606 - private = (struct dasd_eckd_private *) device->private; 496 + private = device->private; 607 497 private->pavgroup = NULL; 608 498 } 609 499 list_del(&pavgroup->group); ··· 615 505 if (rc) 616 506 return rc; 617 507 618 - /* need to take cdev lock before lcu lock */ 619 - spin_lock_irqsave_nested(get_ccwdev_lock(refdev->cdev), flags, 620 - CDEV_NESTED_FIRST); 621 - spin_lock(&lcu->lock); 508 + _trylock_and_lock_lcu_irqsave(lcu, NULL, &flags); 622 509 lcu->pav = NO_PAV; 623 510 for (i = 0; i < MAX_DEVICES_PER_LCU; ++i) { 624 511 switch (lcu->uac->unit[i].ua_type) { ··· 634 527 alias_list) { 635 528 _add_device_to_lcu(lcu, device, refdev); 636 529 } 637 - spin_unlock(&lcu->lock); 638 - spin_unlock_irqrestore(get_ccwdev_lock(refdev->cdev), flags); 530 + _unlock_all_devices_on_lcu(lcu, NULL, NULL); 531 + spin_unlock_irqrestore(&lcu->lock, flags); 639 532 return 0; 640 533 } 641 534 ··· 715 608 716 609 int dasd_alias_add_device(struct dasd_device *device) 717 610 { 718 - struct dasd_eckd_private *private; 611 + struct dasd_eckd_private *private = device->private; 719 612 struct alias_lcu *lcu; 720 613 unsigned long flags; 721 614 int rc; 722 615 723 - private = (struct dasd_eckd_private *) device->private; 724 616 lcu = private->lcu; 725 617 rc = 0; 726 - 727 - /* need to take cdev lock before lcu lock */ 728 618 spin_lock_irqsave(get_ccwdev_lock(device->cdev), flags); 729 619 spin_lock(&lcu->lock); 730 620 if (!(lcu->flags & UPDATE_PENDING)) { ··· 740 636 741 637 int dasd_alias_update_add_device(struct dasd_device *device) 742 638 { 743 - struct dasd_eckd_private *private; 744 - private = (struct dasd_eckd_private *) device->private; 639 + struct dasd_eckd_private *private = device->private; 640 + 745 641 private->lcu->flags |= UPDATE_PENDING; 746 642 return dasd_alias_add_device(device); 747 643 } 748 644 749 645 int dasd_alias_remove_device(struct dasd_device *device) 750 646 { 751 - struct dasd_eckd_private *private; 752 - struct alias_lcu *lcu; 647 + struct dasd_eckd_private *private = device->private; 648 + struct alias_lcu *lcu = private->lcu; 753 649 unsigned long flags; 754 650 755 - private = (struct dasd_eckd_private *) device->private; 756 - lcu = private->lcu; 757 651 /* nothing to do if already removed */ 758 652 if (!lcu) 759 653 return 0; ··· 763 661 764 662 struct dasd_device *dasd_alias_get_start_dev(struct dasd_device *base_device) 765 663 { 766 - 664 + struct dasd_eckd_private *alias_priv, *private = base_device->private; 665 + struct alias_pav_group *group = private->pavgroup; 666 + struct alias_lcu *lcu = private->lcu; 767 667 struct dasd_device *alias_device; 768 - struct alias_pav_group *group; 769 - struct alias_lcu *lcu; 770 - struct dasd_eckd_private *private, *alias_priv; 771 668 unsigned long flags; 772 669 773 - private = (struct dasd_eckd_private *) base_device->private; 774 - group = private->pavgroup; 775 - lcu = private->lcu; 776 670 if (!group || !lcu) 777 671 return NULL; 778 672 if (lcu->pav == NO_PAV || ··· 804 706 group->next = list_first_entry(&alias_device->alias_list, 805 707 struct dasd_device, alias_list); 806 708 spin_unlock_irqrestore(&lcu->lock, flags); 807 - alias_priv = (struct dasd_eckd_private *) alias_device->private; 709 + alias_priv = alias_device->private; 808 710 if ((alias_priv->count < private->count) && !alias_device->stopped && 809 711 !test_bit(DASD_FLAG_OFFLINE, &alias_device->flags)) 810 712 return alias_device; ··· 852 754 struct alias_pav_group *pavgroup; 853 755 struct dasd_device *device; 854 756 struct dasd_eckd_private *private; 855 - unsigned long flags; 856 757 857 758 /* active and inactive list can contain alias as well as base devices */ 858 759 list_for_each_entry(device, &lcu->active_devices, alias_list) { 859 - private = (struct dasd_eckd_private *) device->private; 860 - spin_lock_irqsave(get_ccwdev_lock(device->cdev), flags); 861 - if (private->uid.type != UA_BASE_DEVICE) { 862 - spin_unlock_irqrestore(get_ccwdev_lock(device->cdev), 863 - flags); 760 + private = device->private; 761 + if (private->uid.type != UA_BASE_DEVICE) 864 762 continue; 865 - } 866 - spin_unlock_irqrestore(get_ccwdev_lock(device->cdev), flags); 867 763 dasd_schedule_block_bh(device->block); 868 764 dasd_schedule_device_bh(device); 869 765 } 870 766 list_for_each_entry(device, &lcu->inactive_devices, alias_list) { 871 - private = (struct dasd_eckd_private *) device->private; 872 - spin_lock_irqsave(get_ccwdev_lock(device->cdev), flags); 873 - if (private->uid.type != UA_BASE_DEVICE) { 874 - spin_unlock_irqrestore(get_ccwdev_lock(device->cdev), 875 - flags); 767 + private = device->private; 768 + if (private->uid.type != UA_BASE_DEVICE) 876 769 continue; 877 - } 878 - spin_unlock_irqrestore(get_ccwdev_lock(device->cdev), flags); 879 770 dasd_schedule_block_bh(device->block); 880 771 dasd_schedule_device_bh(device); 881 772 } ··· 899 812 spin_lock_irqsave(&lcu->lock, flags); 900 813 list_for_each_entry_safe(device, temp, &lcu->active_devices, 901 814 alias_list) { 902 - private = (struct dasd_eckd_private *) device->private; 815 + private = device->private; 903 816 if (private->uid.type == UA_BASE_DEVICE) 904 817 continue; 905 818 list_move(&device->alias_list, &active); ··· 921 834 if (device == list_first_entry(&active, 922 835 struct dasd_device, alias_list)) { 923 836 list_move(&device->alias_list, &lcu->active_devices); 924 - private = (struct dasd_eckd_private *) device->private; 837 + private = device->private; 925 838 private->pavgroup = NULL; 926 839 } 927 840 } 928 841 spin_unlock_irqrestore(&lcu->lock, flags); 929 842 } 930 843 931 - static void __stop_device_on_lcu(struct dasd_device *device, 932 - struct dasd_device *pos) 933 - { 934 - /* If pos == device then device is already locked! */ 935 - if (pos == device) { 936 - dasd_device_set_stop_bits(pos, DASD_STOPPED_SU); 937 - return; 938 - } 939 - spin_lock(get_ccwdev_lock(pos->cdev)); 940 - dasd_device_set_stop_bits(pos, DASD_STOPPED_SU); 941 - spin_unlock(get_ccwdev_lock(pos->cdev)); 942 - } 943 - 944 - /* 945 - * This function is called in interrupt context, so the 946 - * cdev lock for device is already locked! 947 - */ 948 - static void _stop_all_devices_on_lcu(struct alias_lcu *lcu, 949 - struct dasd_device *device) 844 + static void _stop_all_devices_on_lcu(struct alias_lcu *lcu) 950 845 { 951 846 struct alias_pav_group *pavgroup; 952 - struct dasd_device *pos; 847 + struct dasd_device *device; 953 848 954 - list_for_each_entry(pos, &lcu->active_devices, alias_list) 955 - __stop_device_on_lcu(device, pos); 956 - list_for_each_entry(pos, &lcu->inactive_devices, alias_list) 957 - __stop_device_on_lcu(device, pos); 849 + list_for_each_entry(device, &lcu->active_devices, alias_list) 850 + dasd_device_set_stop_bits(device, DASD_STOPPED_SU); 851 + list_for_each_entry(device, &lcu->inactive_devices, alias_list) 852 + dasd_device_set_stop_bits(device, DASD_STOPPED_SU); 958 853 list_for_each_entry(pavgroup, &lcu->grouplist, group) { 959 - list_for_each_entry(pos, &pavgroup->baselist, alias_list) 960 - __stop_device_on_lcu(device, pos); 961 - list_for_each_entry(pos, &pavgroup->aliaslist, alias_list) 962 - __stop_device_on_lcu(device, pos); 854 + list_for_each_entry(device, &pavgroup->baselist, alias_list) 855 + dasd_device_set_stop_bits(device, DASD_STOPPED_SU); 856 + list_for_each_entry(device, &pavgroup->aliaslist, alias_list) 857 + dasd_device_set_stop_bits(device, DASD_STOPPED_SU); 963 858 } 964 859 } 965 860 ··· 949 880 { 950 881 struct alias_pav_group *pavgroup; 951 882 struct dasd_device *device; 952 - unsigned long flags; 953 883 954 - list_for_each_entry(device, &lcu->active_devices, alias_list) { 955 - spin_lock_irqsave(get_ccwdev_lock(device->cdev), flags); 884 + list_for_each_entry(device, &lcu->active_devices, alias_list) 956 885 dasd_device_remove_stop_bits(device, DASD_STOPPED_SU); 957 - spin_unlock_irqrestore(get_ccwdev_lock(device->cdev), flags); 958 - } 959 - 960 - list_for_each_entry(device, &lcu->inactive_devices, alias_list) { 961 - spin_lock_irqsave(get_ccwdev_lock(device->cdev), flags); 886 + list_for_each_entry(device, &lcu->inactive_devices, alias_list) 962 887 dasd_device_remove_stop_bits(device, DASD_STOPPED_SU); 963 - spin_unlock_irqrestore(get_ccwdev_lock(device->cdev), flags); 964 - } 965 - 966 888 list_for_each_entry(pavgroup, &lcu->grouplist, group) { 967 - list_for_each_entry(device, &pavgroup->baselist, alias_list) { 968 - spin_lock_irqsave(get_ccwdev_lock(device->cdev), flags); 889 + list_for_each_entry(device, &pavgroup->baselist, alias_list) 969 890 dasd_device_remove_stop_bits(device, DASD_STOPPED_SU); 970 - spin_unlock_irqrestore(get_ccwdev_lock(device->cdev), 971 - flags); 972 - } 973 - list_for_each_entry(device, &pavgroup->aliaslist, alias_list) { 974 - spin_lock_irqsave(get_ccwdev_lock(device->cdev), flags); 891 + list_for_each_entry(device, &pavgroup->aliaslist, alias_list) 975 892 dasd_device_remove_stop_bits(device, DASD_STOPPED_SU); 976 - spin_unlock_irqrestore(get_ccwdev_lock(device->cdev), 977 - flags); 978 - } 979 893 } 980 894 } 981 895 ··· 984 932 spin_unlock_irqrestore(get_ccwdev_lock(device->cdev), flags); 985 933 reset_summary_unit_check(lcu, device, suc_data->reason); 986 934 987 - spin_lock_irqsave(&lcu->lock, flags); 935 + _trylock_and_lock_lcu_irqsave(lcu, NULL, &flags); 988 936 _unstop_all_devices_on_lcu(lcu); 989 937 _restart_all_base_devices_on_lcu(lcu); 990 938 /* 3. read new alias configuration */ 991 939 _schedule_lcu_update(lcu, device); 992 940 lcu->suc_data.device = NULL; 993 941 dasd_put_device(device); 942 + _unlock_all_devices_on_lcu(lcu, NULL, NULL); 994 943 spin_unlock_irqrestore(&lcu->lock, flags); 995 944 } 996 945 ··· 1001 948 void dasd_alias_handle_summary_unit_check(struct dasd_device *device, 1002 949 struct irb *irb) 1003 950 { 951 + struct dasd_eckd_private *private = device->private; 1004 952 struct alias_lcu *lcu; 1005 953 char reason; 1006 - struct dasd_eckd_private *private; 1007 954 char *sense; 1008 - 1009 - private = (struct dasd_eckd_private *) device->private; 1010 955 1011 956 sense = dasd_get_sense(irb); 1012 957 if (sense) { ··· 1025 974 " unit check (no lcu structure)"); 1026 975 return; 1027 976 } 1028 - spin_lock(&lcu->lock); 1029 - _stop_all_devices_on_lcu(lcu, device); 1030 - /* prepare for lcu_update */ 1031 - private->lcu->flags |= NEED_UAC_UPDATE | UPDATE_PENDING; 977 + _trylock_and_lock_lcu(lcu, device); 1032 978 /* If this device is about to be removed just return and wait for 1033 979 * the next interrupt on a different device 1034 980 */ ··· 1033 985 DBF_DEV_EVENT(DBF_WARNING, device, "%s", 1034 986 "device is in offline processing," 1035 987 " don't do summary unit check handling"); 988 + _unlock_all_devices_on_lcu(lcu, device, NULL); 1036 989 spin_unlock(&lcu->lock); 1037 990 return; 1038 991 } ··· 1042 993 DBF_DEV_EVENT(DBF_WARNING, device, "%s", 1043 994 "previous instance of summary unit check worker" 1044 995 " still pending"); 996 + _unlock_all_devices_on_lcu(lcu, device, NULL); 1045 997 spin_unlock(&lcu->lock); 1046 998 return ; 1047 999 } 1000 + _stop_all_devices_on_lcu(lcu); 1001 + /* prepare for lcu_update */ 1002 + private->lcu->flags |= NEED_UAC_UPDATE | UPDATE_PENDING; 1048 1003 lcu->suc_data.reason = reason; 1049 1004 lcu->suc_data.device = device; 1050 1005 dasd_get_device(device); 1006 + _unlock_all_devices_on_lcu(lcu, device, NULL); 1051 1007 spin_unlock(&lcu->lock); 1052 1008 if (!schedule_work(&lcu->suc_data.worker)) 1053 1009 dasd_put_device(device);
+4 -6
drivers/s390/block/dasd_devmap.c
··· 214 214 else if (len == 8 && !strncmp(str, "failfast", 8)) 215 215 features |= DASD_FEATURE_FAILFAST; 216 216 else { 217 - pr_warning("%*s is not a supported device option\n", 218 - len, str); 217 + pr_warn("%*s is not a supported device option\n", 218 + len, str); 219 219 rc = -EINVAL; 220 220 } 221 221 str += len; ··· 224 224 str++; 225 225 } 226 226 if (*str != ')') { 227 - pr_warning("A closing parenthesis ')' is missing in the " 228 - "dasd= parameter\n"); 227 + pr_warn("A closing parenthesis ')' is missing in the dasd= parameter\n"); 229 228 rc = -EINVAL; 230 229 } else 231 230 str++; ··· 347 348 return str + 1; 348 349 if (*str == '\0') 349 350 return str; 350 - pr_warning("The dasd= parameter value %s has an invalid ending\n", 351 - str); 351 + pr_warn("The dasd= parameter value %s has an invalid ending\n", str); 352 352 return ERR_PTR(-EINVAL); 353 353 } 354 354
+30 -39
drivers/s390/block/dasd_diag.c
··· 104 104 mdsk_init_io(struct dasd_device *device, unsigned int blocksize, 105 105 blocknum_t offset, blocknum_t *end_block) 106 106 { 107 - struct dasd_diag_private *private; 108 - struct dasd_diag_init_io *iib; 107 + struct dasd_diag_private *private = device->private; 108 + struct dasd_diag_init_io *iib = &private->iib; 109 109 int rc; 110 110 111 - private = (struct dasd_diag_private *) device->private; 112 - iib = &private->iib; 113 111 memset(iib, 0, sizeof (struct dasd_diag_init_io)); 114 112 115 113 iib->dev_nr = private->dev_id.devno; ··· 128 130 static inline int 129 131 mdsk_term_io(struct dasd_device * device) 130 132 { 131 - struct dasd_diag_private *private; 132 - struct dasd_diag_init_io *iib; 133 + struct dasd_diag_private *private = device->private; 134 + struct dasd_diag_init_io *iib = &private->iib; 133 135 int rc; 134 136 135 - private = (struct dasd_diag_private *) device->private; 136 - iib = &private->iib; 137 137 memset(iib, 0, sizeof (struct dasd_diag_init_io)); 138 138 iib->dev_nr = private->dev_id.devno; 139 139 rc = dia250(iib, TERM_BIO); ··· 149 153 rc = mdsk_init_io(device, device->block->bp_block, 0, NULL); 150 154 if (rc == 4) { 151 155 if (!(test_and_set_bit(DASD_FLAG_DEVICE_RO, &device->flags))) 152 - pr_warning("%s: The access mode of a DIAG device " 153 - "changed to read-only\n", 154 - dev_name(&device->cdev->dev)); 156 + pr_warn("%s: The access mode of a DIAG device changed to read-only\n", 157 + dev_name(&device->cdev->dev)); 155 158 rc = 0; 156 159 } 157 160 if (rc) 158 - pr_warning("%s: DIAG ERP failed with " 159 - "rc=%d\n", dev_name(&device->cdev->dev), rc); 161 + pr_warn("%s: DIAG ERP failed with rc=%d\n", 162 + dev_name(&device->cdev->dev), rc); 160 163 } 161 164 162 165 /* Start a given request at the device. Return zero on success, non-zero ··· 175 180 cqr->status = DASD_CQR_ERROR; 176 181 return -EIO; 177 182 } 178 - private = (struct dasd_diag_private *) device->private; 179 - dreq = (struct dasd_diag_req *) cqr->data; 183 + private = device->private; 184 + dreq = cqr->data; 180 185 181 186 private->iob.dev_nr = private->dev_id.devno; 182 187 private->iob.key = 0; ··· 315 320 static int 316 321 dasd_diag_check_device(struct dasd_device *device) 317 322 { 318 - struct dasd_block *block; 319 - struct dasd_diag_private *private; 323 + struct dasd_diag_private *private = device->private; 320 324 struct dasd_diag_characteristics *rdc_data; 321 - struct dasd_diag_bio bio; 322 325 struct vtoc_cms_label *label; 323 - blocknum_t end_block; 326 + struct dasd_block *block; 327 + struct dasd_diag_bio bio; 324 328 unsigned int sb, bsize; 329 + blocknum_t end_block; 325 330 int rc; 326 331 327 - private = (struct dasd_diag_private *) device->private; 328 332 if (private == NULL) { 329 - private = kzalloc(sizeof(struct dasd_diag_private),GFP_KERNEL); 333 + private = kzalloc(sizeof(*private), GFP_KERNEL); 330 334 if (private == NULL) { 331 335 DBF_DEV_EVENT(DBF_WARNING, device, "%s", 332 336 "Allocating memory for private DASD data " ··· 333 339 return -ENOMEM; 334 340 } 335 341 ccw_device_get_id(device->cdev, &private->dev_id); 336 - device->private = (void *) private; 342 + device->private = private; 337 343 } 338 344 block = dasd_alloc_block(); 339 345 if (IS_ERR(block)) { ··· 347 353 block->base = device; 348 354 349 355 /* Read Device Characteristics */ 350 - rdc_data = (void *) &(private->rdc_data); 356 + rdc_data = &private->rdc_data; 351 357 rdc_data->dev_nr = private->dev_id.devno; 352 358 rdc_data->rdc_len = sizeof (struct dasd_diag_characteristics); 353 359 ··· 371 377 private->pt_block = 2; 372 378 break; 373 379 default: 374 - pr_warning("%s: Device type %d is not supported " 375 - "in DIAG mode\n", dev_name(&device->cdev->dev), 376 - private->rdc_data.vdev_class); 380 + pr_warn("%s: Device type %d is not supported in DIAG mode\n", 381 + dev_name(&device->cdev->dev), 382 + private->rdc_data.vdev_class); 377 383 rc = -EOPNOTSUPP; 378 384 goto out; 379 385 } ··· 414 420 private->iob.flaga = DASD_DIAG_FLAGA_DEFAULT; 415 421 rc = dia250(&private->iob, RW_BIO); 416 422 if (rc == 3) { 417 - pr_warning("%s: A 64-bit DIAG call failed\n", 418 - dev_name(&device->cdev->dev)); 423 + pr_warn("%s: A 64-bit DIAG call failed\n", 424 + dev_name(&device->cdev->dev)); 419 425 rc = -EOPNOTSUPP; 420 426 goto out_label; 421 427 } ··· 424 430 break; 425 431 } 426 432 if (bsize > PAGE_SIZE) { 427 - pr_warning("%s: Accessing the DASD failed because of an " 428 - "incorrect format (rc=%d)\n", 429 - dev_name(&device->cdev->dev), rc); 433 + pr_warn("%s: Accessing the DASD failed because of an incorrect format (rc=%d)\n", 434 + dev_name(&device->cdev->dev), rc); 430 435 rc = -EIO; 431 436 goto out_label; 432 437 } ··· 443 450 block->s2b_shift++; 444 451 rc = mdsk_init_io(device, block->bp_block, 0, NULL); 445 452 if (rc && (rc != 4)) { 446 - pr_warning("%s: DIAG initialization failed with rc=%d\n", 447 - dev_name(&device->cdev->dev), rc); 453 + pr_warn("%s: DIAG initialization failed with rc=%d\n", 454 + dev_name(&device->cdev->dev), rc); 448 455 rc = -EIO; 449 456 } else { 450 457 if (rc == 4) ··· 594 601 dasd_diag_fill_info(struct dasd_device * device, 595 602 struct dasd_information2_t * info) 596 603 { 597 - struct dasd_diag_private *private; 604 + struct dasd_diag_private *private = device->private; 598 605 599 - private = (struct dasd_diag_private *) device->private; 600 606 info->label_block = (unsigned int) private->pt_block; 601 607 info->FBA_layout = 1; 602 608 info->format = DASD_FORMAT_LDL; 603 - info->characteristics_size = sizeof (struct dasd_diag_characteristics); 604 - memcpy(info->characteristics, 605 - &((struct dasd_diag_private *) device->private)->rdc_data, 606 - sizeof (struct dasd_diag_characteristics)); 609 + info->characteristics_size = sizeof(private->rdc_data); 610 + memcpy(info->characteristics, &private->rdc_data, 611 + sizeof(private->rdc_data)); 607 612 info->confdata_size = 0; 608 613 return 0; 609 614 }
+145 -166
drivers/s390/block/dasd_eckd.c
··· 212 212 struct DE_eckd_data *data, 213 213 struct dasd_device *device) 214 214 { 215 - struct dasd_eckd_private *private; 215 + struct dasd_eckd_private *private = device->private; 216 216 int rc; 217 217 218 - private = (struct dasd_eckd_private *) device->private; 219 218 if (!private->rdc_data.facilities.XRC_supported) 220 219 return 0; 221 220 ··· 236 237 define_extent(struct ccw1 *ccw, struct DE_eckd_data *data, unsigned int trk, 237 238 unsigned int totrk, int cmd, struct dasd_device *device) 238 239 { 239 - struct dasd_eckd_private *private; 240 + struct dasd_eckd_private *private = device->private; 240 241 u32 begcyl, endcyl; 241 242 u16 heads, beghead, endhead; 242 243 int rc = 0; 243 - 244 - private = (struct dasd_eckd_private *) device->private; 245 244 246 245 ccw->cmd_code = DASD_ECKD_CCW_DEFINE_EXTENT; 247 246 ccw->flags = 0; ··· 319 322 static int check_XRC_on_prefix(struct PFX_eckd_data *pfxdata, 320 323 struct dasd_device *device) 321 324 { 322 - struct dasd_eckd_private *private; 325 + struct dasd_eckd_private *private = device->private; 323 326 int rc; 324 327 325 - private = (struct dasd_eckd_private *) device->private; 326 328 if (!private->rdc_data.facilities.XRC_supported) 327 329 return 0; 328 330 ··· 342 346 struct dasd_device *device, unsigned int reclen, 343 347 unsigned int tlf) 344 348 { 345 - struct dasd_eckd_private *private; 349 + struct dasd_eckd_private *private = device->private; 346 350 int sector; 347 351 int dn, d; 348 - 349 - private = (struct dasd_eckd_private *) device->private; 350 352 351 353 memset(data, 0, sizeof(*data)); 352 354 sector = 0; ··· 482 488 u16 heads, beghead, endhead; 483 489 int rc = 0; 484 490 485 - basepriv = (struct dasd_eckd_private *) basedev->private; 486 - startpriv = (struct dasd_eckd_private *) startdev->private; 491 + basepriv = basedev->private; 492 + startpriv = startdev->private; 487 493 dedata = &pfxdata->define_extent; 488 494 lredata = &pfxdata->locate_record; 489 495 ··· 625 631 unsigned int rec_on_trk, int no_rec, int cmd, 626 632 struct dasd_device * device, int reclen) 627 633 { 628 - struct dasd_eckd_private *private; 634 + struct dasd_eckd_private *private = device->private; 629 635 int sector; 630 636 int dn, d; 631 - 632 - private = (struct dasd_eckd_private *) device->private; 633 637 634 638 DBF_DEV_EVENT(DBF_INFO, device, 635 639 "Locate: trk %d, rec %d, no_rec %d, cmd %d, reclen %d", ··· 792 800 */ 793 801 static int dasd_eckd_generate_uid(struct dasd_device *device) 794 802 { 795 - struct dasd_eckd_private *private; 803 + struct dasd_eckd_private *private = device->private; 796 804 unsigned long flags; 797 805 798 - private = (struct dasd_eckd_private *) device->private; 799 806 if (!private) 800 807 return -ENODEV; 801 808 if (!private->ned || !private->gneq) ··· 807 816 808 817 static int dasd_eckd_get_uid(struct dasd_device *device, struct dasd_uid *uid) 809 818 { 810 - struct dasd_eckd_private *private; 819 + struct dasd_eckd_private *private = device->private; 811 820 unsigned long flags; 812 821 813 - if (device->private) { 814 - private = (struct dasd_eckd_private *)device->private; 822 + if (private) { 815 823 spin_lock_irqsave(get_ccwdev_lock(device->cdev), flags); 816 824 *uid = private->uid; 817 825 spin_unlock_irqrestore(get_ccwdev_lock(device->cdev), flags); ··· 1024 1034 1025 1035 static void dasd_eckd_clear_conf_data(struct dasd_device *device) 1026 1036 { 1027 - struct dasd_eckd_private *private; 1037 + struct dasd_eckd_private *private = device->private; 1028 1038 int i; 1029 1039 1030 - private = (struct dasd_eckd_private *) device->private; 1031 1040 private->conf_data = NULL; 1032 1041 private->conf_len = 0; 1033 1042 for (i = 0; i < 8; i++) { ··· 1047 1058 struct dasd_uid *uid; 1048 1059 char print_path_uid[60], print_device_uid[60]; 1049 1060 1050 - private = (struct dasd_eckd_private *) device->private; 1061 + private = device->private; 1051 1062 path_data = &device->path_data; 1052 1063 opm = ccw_device_get_path_mask(device->cdev); 1053 1064 conf_data_saved = 0; ··· 1180 1191 1181 1192 static int verify_fcx_max_data(struct dasd_device *device, __u8 lpm) 1182 1193 { 1183 - struct dasd_eckd_private *private; 1194 + struct dasd_eckd_private *private = device->private; 1184 1195 int mdc; 1185 1196 u32 fcx_max_data; 1186 1197 1187 - private = (struct dasd_eckd_private *) device->private; 1188 1198 if (private->fcx_max_data) { 1189 1199 mdc = ccw_device_get_mdc(device->cdev, lpm); 1190 1200 if ((mdc < 0)) { ··· 1209 1221 static int rebuild_device_uid(struct dasd_device *device, 1210 1222 struct path_verification_work_data *data) 1211 1223 { 1212 - struct dasd_eckd_private *private; 1213 - struct dasd_path *path_data; 1214 - __u8 lpm, opm; 1215 - int rc; 1216 - 1217 - rc = -ENODEV; 1218 - private = (struct dasd_eckd_private *) device->private; 1219 - path_data = &device->path_data; 1220 - opm = device->path_data.opm; 1224 + struct dasd_eckd_private *private = device->private; 1225 + struct dasd_path *path_data = &device->path_data; 1226 + __u8 lpm, opm = path_data->opm; 1227 + int rc = -ENODEV; 1221 1228 1222 1229 for (lpm = 0x80; lpm; lpm >>= 1) { 1223 1230 if (!(lpm & opm)) ··· 1446 1463 1447 1464 static int dasd_eckd_read_features(struct dasd_device *device) 1448 1465 { 1466 + struct dasd_eckd_private *private = device->private; 1449 1467 struct dasd_psf_prssd_data *prssdp; 1450 1468 struct dasd_rssd_features *features; 1451 1469 struct dasd_ccw_req *cqr; 1452 1470 struct ccw1 *ccw; 1453 1471 int rc; 1454 - struct dasd_eckd_private *private; 1455 1472 1456 - private = (struct dasd_eckd_private *) device->private; 1457 1473 memset(&private->features, 0, sizeof(struct dasd_rssd_features)); 1458 1474 cqr = dasd_smalloc_request(DASD_ECKD_MAGIC, 1 /* PSF */ + 1 /* RSSD */, 1459 1475 (sizeof(struct dasd_psf_prssd_data) + ··· 1587 1605 static int dasd_eckd_validate_server(struct dasd_device *device, 1588 1606 unsigned long flags) 1589 1607 { 1590 - int rc; 1591 - struct dasd_eckd_private *private; 1592 - int enable_pav; 1608 + struct dasd_eckd_private *private = device->private; 1609 + int enable_pav, rc; 1593 1610 1594 - private = (struct dasd_eckd_private *) device->private; 1595 1611 if (private->uid.type == UA_BASE_PAV_ALIAS || 1596 1612 private->uid.type == UA_HYPER_PAV_ALIAS) 1597 1613 return 0; ··· 1642 1662 1643 1663 static u32 get_fcx_max_data(struct dasd_device *device) 1644 1664 { 1645 - int tpm, mdc; 1665 + struct dasd_eckd_private *private = device->private; 1646 1666 int fcx_in_css, fcx_in_gneq, fcx_in_features; 1647 - struct dasd_eckd_private *private; 1667 + int tpm, mdc; 1648 1668 1649 1669 if (dasd_nofcx) 1650 1670 return 0; 1651 1671 /* is transport mode supported? */ 1652 - private = (struct dasd_eckd_private *) device->private; 1653 1672 fcx_in_css = css_general_characteristics.fcx; 1654 1673 fcx_in_gneq = private->gneq->reserved2[7] & 0x04; 1655 1674 fcx_in_features = private->features.feature[40] & 0x80; ··· 1673 1694 static int 1674 1695 dasd_eckd_check_characteristics(struct dasd_device *device) 1675 1696 { 1676 - struct dasd_eckd_private *private; 1697 + struct dasd_eckd_private *private = device->private; 1677 1698 struct dasd_block *block; 1678 1699 struct dasd_uid temp_uid; 1679 1700 int rc, i; ··· 1692 1713 dev_info(&device->cdev->dev, 1693 1714 "The DASD is not operating in multipath mode\n"); 1694 1715 } 1695 - private = (struct dasd_eckd_private *) device->private; 1696 1716 if (!private) { 1697 1717 private = kzalloc(sizeof(*private), GFP_KERNEL | GFP_DMA); 1698 1718 if (!private) { ··· 1700 1722 "failed\n"); 1701 1723 return -ENOMEM; 1702 1724 } 1703 - device->private = (void *) private; 1725 + device->private = private; 1704 1726 } else { 1705 1727 memset(private, 0, sizeof(*private)); 1706 1728 } ··· 1815 1837 1816 1838 static void dasd_eckd_uncheck_device(struct dasd_device *device) 1817 1839 { 1818 - struct dasd_eckd_private *private; 1840 + struct dasd_eckd_private *private = device->private; 1819 1841 int i; 1820 1842 1821 - private = (struct dasd_eckd_private *) device->private; 1822 1843 dasd_alias_disconnect_device_from_lcu(device); 1823 1844 private->ned = NULL; 1824 1845 private->sneq = NULL; ··· 1840 1863 static struct dasd_ccw_req * 1841 1864 dasd_eckd_analysis_ccw(struct dasd_device *device) 1842 1865 { 1843 - struct dasd_eckd_private *private; 1866 + struct dasd_eckd_private *private = device->private; 1844 1867 struct eckd_count *count_data; 1845 1868 struct LO_eckd_data *LO_data; 1846 1869 struct dasd_ccw_req *cqr; 1847 1870 struct ccw1 *ccw; 1848 1871 int cplength, datasize; 1849 1872 int i; 1850 - 1851 - private = (struct dasd_eckd_private *) device->private; 1852 1873 1853 1874 cplength = 8; 1854 1875 datasize = sizeof(struct DE_eckd_data) + 2*sizeof(struct LO_eckd_data); ··· 1921 1946 static void dasd_eckd_analysis_callback(struct dasd_ccw_req *init_cqr, 1922 1947 void *data) 1923 1948 { 1924 - struct dasd_eckd_private *private; 1925 - struct dasd_device *device; 1949 + struct dasd_device *device = init_cqr->startdev; 1950 + struct dasd_eckd_private *private = device->private; 1926 1951 1927 - device = init_cqr->startdev; 1928 - private = (struct dasd_eckd_private *) device->private; 1929 1952 private->init_cqr_status = dasd_eckd_analysis_evaluation(init_cqr); 1930 1953 dasd_sfree_request(init_cqr, device); 1931 1954 dasd_kick_device(device); ··· 1950 1977 1951 1978 static int dasd_eckd_end_analysis(struct dasd_block *block) 1952 1979 { 1953 - struct dasd_device *device; 1954 - struct dasd_eckd_private *private; 1980 + struct dasd_device *device = block->base; 1981 + struct dasd_eckd_private *private = device->private; 1955 1982 struct eckd_count *count_area; 1956 1983 unsigned int sb, blk_per_trk; 1957 1984 int status, i; 1958 1985 struct dasd_ccw_req *init_cqr; 1959 1986 1960 - device = block->base; 1961 - private = (struct dasd_eckd_private *) device->private; 1962 1987 status = private->init_cqr_status; 1963 1988 private->init_cqr_status = -1; 1964 1989 if (status == INIT_CQR_ERROR) { ··· 2054 2083 2055 2084 static int dasd_eckd_do_analysis(struct dasd_block *block) 2056 2085 { 2057 - struct dasd_eckd_private *private; 2086 + struct dasd_eckd_private *private = block->base->private; 2058 2087 2059 - private = (struct dasd_eckd_private *) block->base->private; 2060 2088 if (private->init_cqr_status < 0) 2061 2089 return dasd_eckd_start_analysis(block); 2062 2090 else ··· 2082 2112 static int 2083 2113 dasd_eckd_fill_geometry(struct dasd_block *block, struct hd_geometry *geo) 2084 2114 { 2085 - struct dasd_eckd_private *private; 2115 + struct dasd_eckd_private *private = block->base->private; 2086 2116 2087 - private = (struct dasd_eckd_private *) block->base->private; 2088 2117 if (dasd_check_blocksize(block->bp_block) == 0) { 2089 2118 geo->sectors = recs_per_track(&private->rdc_data, 2090 2119 0, block->bp_block); ··· 2120 2151 if (!startdev) 2121 2152 startdev = base; 2122 2153 2123 - start_priv = (struct dasd_eckd_private *) startdev->private; 2124 - base_priv = (struct dasd_eckd_private *) base->private; 2154 + start_priv = startdev->private; 2155 + base_priv = base->private; 2125 2156 2126 2157 rpt = recs_per_track(&base_priv->rdc_data, 0, fdata->blksize); 2127 2158 ··· 2318 2349 * when formatting CDL 2319 2350 */ 2320 2351 if ((intensity & 0x08) && 2321 - fdata->start_unit == 0) { 2352 + address.cyl == 0 && address.head == 0) { 2322 2353 if (i < 3) { 2323 2354 ect->kl = 4; 2324 2355 ect->dl = sizes_trk0[i] - 4; 2325 2356 } 2326 2357 } 2327 2358 if ((intensity & 0x08) && 2328 - fdata->start_unit == 1) { 2359 + address.cyl == 0 && address.head == 1) { 2329 2360 ect->kl = 44; 2330 2361 ect->dl = LABEL_SIZE - 44; 2331 2362 } ··· 2355 2386 return fcp; 2356 2387 } 2357 2388 2358 - static int 2359 - dasd_eckd_format_device(struct dasd_device *base, 2360 - struct format_data_t *fdata, 2361 - int enable_pav) 2389 + /* 2390 + * Wrapper function to build a CCW request depending on input data 2391 + */ 2392 + static struct dasd_ccw_req * 2393 + dasd_eckd_format_build_ccw_req(struct dasd_device *base, 2394 + struct format_data_t *fdata, int enable_pav) 2362 2395 { 2363 - struct dasd_ccw_req *cqr, *n; 2364 - struct dasd_block *block; 2365 - struct dasd_eckd_private *private; 2366 - struct list_head format_queue; 2367 - struct dasd_device *device; 2368 - int old_stop, format_step; 2369 - int step, rc = 0, sleep_rc; 2396 + return dasd_eckd_build_format(base, fdata, enable_pav); 2397 + } 2370 2398 2371 - block = base->block; 2372 - private = (struct dasd_eckd_private *) base->private; 2399 + /* 2400 + * Sanity checks on format_data 2401 + */ 2402 + static int dasd_eckd_format_sanity_checks(struct dasd_device *base, 2403 + struct format_data_t *fdata) 2404 + { 2405 + struct dasd_eckd_private *private = base->private; 2373 2406 2374 - /* Sanity checks. */ 2375 2407 if (fdata->start_unit >= 2376 2408 (private->real_cyl * private->rdc_data.trk_per_cyl)) { 2377 2409 dev_warn(&base->cdev->dev, ··· 2399 2429 fdata->blksize); 2400 2430 return -EINVAL; 2401 2431 } 2432 + return 0; 2433 + } 2434 + 2435 + /* 2436 + * This function will process format_data originally coming from an IOCTL 2437 + */ 2438 + static int dasd_eckd_format_process_data(struct dasd_device *base, 2439 + struct format_data_t *fdata, 2440 + int enable_pav) 2441 + { 2442 + struct dasd_eckd_private *private = base->private; 2443 + struct dasd_ccw_req *cqr, *n; 2444 + struct list_head format_queue; 2445 + struct dasd_device *device; 2446 + int old_start, old_stop, format_step; 2447 + int step, retry; 2448 + int rc; 2449 + 2450 + rc = dasd_eckd_format_sanity_checks(base, fdata); 2451 + if (rc) 2452 + return rc; 2402 2453 2403 2454 INIT_LIST_HEAD(&format_queue); 2404 2455 2456 + old_start = fdata->start_unit; 2405 2457 old_stop = fdata->stop_unit; 2406 - while (fdata->start_unit <= 1) { 2407 - fdata->stop_unit = fdata->start_unit; 2408 - cqr = dasd_eckd_build_format(base, fdata, enable_pav); 2409 - list_add(&cqr->blocklist, &format_queue); 2410 2458 2411 - fdata->stop_unit = old_stop; 2412 - fdata->start_unit++; 2459 + format_step = DASD_CQR_MAX_CCW / recs_per_track(&private->rdc_data, 0, 2460 + fdata->blksize); 2461 + do { 2462 + retry = 0; 2463 + while (fdata->start_unit <= old_stop) { 2464 + step = fdata->stop_unit - fdata->start_unit + 1; 2465 + if (step > format_step) { 2466 + fdata->stop_unit = 2467 + fdata->start_unit + format_step - 1; 2468 + } 2413 2469 2414 - if (fdata->start_unit > fdata->stop_unit) 2415 - goto sleep; 2416 - } 2470 + cqr = dasd_eckd_format_build_ccw_req(base, fdata, 2471 + enable_pav); 2472 + if (IS_ERR(cqr)) { 2473 + rc = PTR_ERR(cqr); 2474 + if (rc == -ENOMEM) { 2475 + if (list_empty(&format_queue)) 2476 + goto out; 2477 + /* 2478 + * not enough memory available, start 2479 + * requests retry after first requests 2480 + * were finished 2481 + */ 2482 + retry = 1; 2483 + break; 2484 + } 2485 + goto out_err; 2486 + } 2487 + list_add_tail(&cqr->blocklist, &format_queue); 2417 2488 2418 - retry: 2419 - format_step = 255 / recs_per_track(&private->rdc_data, 0, 2420 - fdata->blksize); 2421 - while (fdata->start_unit <= old_stop) { 2422 - step = fdata->stop_unit - fdata->start_unit + 1; 2423 - if (step > format_step) 2424 - fdata->stop_unit = fdata->start_unit + format_step - 1; 2425 - 2426 - cqr = dasd_eckd_build_format(base, fdata, enable_pav); 2427 - if (IS_ERR(cqr)) { 2428 - if (PTR_ERR(cqr) == -ENOMEM) { 2429 - /* 2430 - * not enough memory available 2431 - * go to out and start requests 2432 - * retry after first requests were finished 2433 - */ 2434 - fdata->stop_unit = old_stop; 2435 - goto sleep; 2436 - } else 2437 - return PTR_ERR(cqr); 2489 + fdata->start_unit = fdata->stop_unit + 1; 2490 + fdata->stop_unit = old_stop; 2438 2491 } 2439 - list_add(&cqr->blocklist, &format_queue); 2440 2492 2441 - fdata->start_unit = fdata->stop_unit + 1; 2442 - fdata->stop_unit = old_stop; 2443 - } 2493 + rc = dasd_sleep_on_queue(&format_queue); 2444 2494 2445 - sleep: 2446 - sleep_rc = dasd_sleep_on_queue(&format_queue); 2495 + out_err: 2496 + list_for_each_entry_safe(cqr, n, &format_queue, blocklist) { 2497 + device = cqr->startdev; 2498 + private = device->private; 2499 + if (cqr->status == DASD_CQR_FAILED) 2500 + rc = -EIO; 2501 + list_del_init(&cqr->blocklist); 2502 + dasd_sfree_request(cqr, device); 2503 + private->count--; 2504 + } 2447 2505 2448 - list_for_each_entry_safe(cqr, n, &format_queue, blocklist) { 2449 - device = cqr->startdev; 2450 - private = (struct dasd_eckd_private *) device->private; 2451 - if (cqr->status == DASD_CQR_FAILED) 2452 - rc = -EIO; 2453 - list_del_init(&cqr->blocklist); 2454 - dasd_sfree_request(cqr, device); 2455 - private->count--; 2456 - } 2506 + if (rc) 2507 + goto out; 2457 2508 2458 - if (sleep_rc) 2459 - return sleep_rc; 2509 + } while (retry); 2460 2510 2461 - /* 2462 - * in case of ENOMEM we need to retry after 2463 - * first requests are finished 2464 - */ 2465 - if (fdata->start_unit <= fdata->stop_unit) 2466 - goto retry; 2511 + out: 2512 + fdata->start_unit = old_start; 2513 + fdata->stop_unit = old_stop; 2467 2514 2468 2515 return rc; 2516 + } 2517 + 2518 + static int dasd_eckd_format_device(struct dasd_device *base, 2519 + struct format_data_t *fdata, int enable_pav) 2520 + { 2521 + return dasd_eckd_format_process_data(base, fdata, enable_pav); 2469 2522 } 2470 2523 2471 2524 static void dasd_eckd_handle_terminated_request(struct dasd_ccw_req *cqr) ··· 2536 2543 { 2537 2544 char mask; 2538 2545 char *sense = NULL; 2539 - struct dasd_eckd_private *private; 2546 + struct dasd_eckd_private *private = device->private; 2540 2547 2541 - private = (struct dasd_eckd_private *) device->private; 2542 2548 /* first of all check for state change pending interrupt */ 2543 2549 mask = DEV_STAT_ATTENTION | DEV_STAT_DEV_END | DEV_STAT_UNIT_EXCEP; 2544 2550 if ((scsw_dstat(&irb->scsw) & mask) == mask) { ··· 2626 2634 struct dasd_device *basedev; 2627 2635 2628 2636 basedev = block->base; 2629 - private = (struct dasd_eckd_private *) basedev->private; 2637 + private = basedev->private; 2630 2638 if (rq_data_dir(req) == READ) 2631 2639 cmd = DASD_ECKD_CCW_READ_MT; 2632 2640 else if (rq_data_dir(req) == WRITE) ··· 2982 2990 2983 2991 2984 2992 /* setup prefix data */ 2985 - basepriv = (struct dasd_eckd_private *) basedev->private; 2986 - startpriv = (struct dasd_eckd_private *) startdev->private; 2993 + basepriv = basedev->private; 2994 + startpriv = startdev->private; 2987 2995 dedata = &pfxdata.define_extent; 2988 2996 lredata = &pfxdata.locate_record; 2989 2997 ··· 3270 3278 struct dasd_ccw_req *cqr; 3271 3279 3272 3280 basedev = block->base; 3273 - private = (struct dasd_eckd_private *) basedev->private; 3281 + private = basedev->private; 3274 3282 3275 3283 /* Calculate number of blocks/records per track. */ 3276 3284 blksize = block->bp_block; ··· 3495 3503 3496 3504 if (!dasd_page_cache) 3497 3505 goto out; 3498 - private = (struct dasd_eckd_private *) cqr->block->base->private; 3506 + private = cqr->block->base->private; 3499 3507 blksize = cqr->block->bp_block; 3500 3508 blk_per_trk = recs_per_track(&private->rdc_data, 0, blksize); 3501 3509 recid = blk_rq_pos(req) >> cqr->block->s2b_shift; ··· 3579 3587 startdev = dasd_alias_get_start_dev(base); 3580 3588 if (!startdev) 3581 3589 startdev = base; 3582 - private = (struct dasd_eckd_private *) startdev->private; 3590 + private = startdev->private; 3583 3591 if (private->count >= DASD_ECKD_CHANQ_MAX_SIZE) 3584 3592 return ERR_PTR(-EBUSY); 3585 3593 ··· 3602 3610 unsigned long flags; 3603 3611 3604 3612 spin_lock_irqsave(get_ccwdev_lock(cqr->memdev->cdev), flags); 3605 - private = (struct dasd_eckd_private *) cqr->memdev->private; 3613 + private = cqr->memdev->private; 3606 3614 private->count--; 3607 3615 spin_unlock_irqrestore(get_ccwdev_lock(cqr->memdev->cdev), flags); 3608 3616 return dasd_eckd_free_cp(cqr, req); ··· 3612 3620 dasd_eckd_fill_info(struct dasd_device * device, 3613 3621 struct dasd_information2_t * info) 3614 3622 { 3615 - struct dasd_eckd_private *private; 3623 + struct dasd_eckd_private *private = device->private; 3616 3624 3617 - private = (struct dasd_eckd_private *) device->private; 3618 3625 info->label_block = 2; 3619 3626 info->FBA_layout = private->uses_cdl ? 0 : 1; 3620 3627 info->format = private->uses_cdl ? DASD_FORMAT_CDL : DASD_FORMAT_LDL; 3621 - info->characteristics_size = sizeof(struct dasd_eckd_characteristics); 3628 + info->characteristics_size = sizeof(private->rdc_data); 3622 3629 memcpy(info->characteristics, &private->rdc_data, 3623 - sizeof(struct dasd_eckd_characteristics)); 3630 + sizeof(private->rdc_data)); 3624 3631 info->confdata_size = min((unsigned long)private->conf_len, 3625 3632 sizeof(info->configuration_data)); 3626 3633 memcpy(info->configuration_data, private->conf_data, ··· 3932 3941 static int 3933 3942 dasd_eckd_get_attrib(struct dasd_device *device, void __user *argp) 3934 3943 { 3935 - struct dasd_eckd_private *private = 3936 - (struct dasd_eckd_private *)device->private; 3944 + struct dasd_eckd_private *private = device->private; 3937 3945 struct attrib_data_t attrib = private->attrib; 3938 3946 int rc; 3939 3947 ··· 3956 3966 static int 3957 3967 dasd_eckd_set_attrib(struct dasd_device *device, void __user *argp) 3958 3968 { 3959 - struct dasd_eckd_private *private = 3960 - (struct dasd_eckd_private *)device->private; 3969 + struct dasd_eckd_private *private = device->private; 3961 3970 struct attrib_data_t attrib; 3962 3971 3963 3972 if (!capable(CAP_SYS_ADMIN)) ··· 4419 4430 4420 4431 static int dasd_eckd_restore_device(struct dasd_device *device) 4421 4432 { 4422 - struct dasd_eckd_private *private; 4433 + struct dasd_eckd_private *private = device->private; 4423 4434 struct dasd_eckd_characteristics temp_rdc_data; 4424 4435 int rc; 4425 4436 struct dasd_uid temp_uid; 4426 4437 unsigned long flags; 4427 4438 unsigned long cqr_flags = 0; 4428 - 4429 - private = (struct dasd_eckd_private *) device->private; 4430 4439 4431 4440 /* Read Configuration Data */ 4432 4441 rc = dasd_eckd_read_conf(device); ··· 4489 4502 4490 4503 static int dasd_eckd_reload_device(struct dasd_device *device) 4491 4504 { 4492 - struct dasd_eckd_private *private; 4505 + struct dasd_eckd_private *private = device->private; 4493 4506 int rc, old_base; 4494 4507 char print_uid[60]; 4495 4508 struct dasd_uid uid; 4496 4509 unsigned long flags; 4497 - 4498 - private = (struct dasd_eckd_private *) device->private; 4499 4510 4500 4511 spin_lock_irqsave(get_ccwdev_lock(device->cdev), flags); 4501 4512 old_base = private->uid.base_unit_addr; ··· 4541 4556 { 4542 4557 struct dasd_rssd_messages *message_buf; 4543 4558 struct dasd_psf_prssd_data *prssdp; 4544 - struct dasd_eckd_private *private; 4545 4559 struct dasd_ccw_req *cqr; 4546 4560 struct ccw1 *ccw; 4547 4561 int rc; 4548 4562 4549 - private = (struct dasd_eckd_private *) device->private; 4550 4563 cqr = dasd_smalloc_request(DASD_ECKD_MAGIC, 1 /* PSF */ + 1 /* RSSD */, 4551 4564 (sizeof(struct dasd_psf_prssd_data) + 4552 4565 sizeof(struct dasd_rssd_messages)), ··· 4669 4686 __u8 lpum, 4670 4687 struct dasd_cuir_message *cuir) 4671 4688 { 4672 - struct dasd_eckd_private *private; 4689 + struct dasd_eckd_private *private = device->private; 4673 4690 struct dasd_conf_data *conf_data; 4674 4691 int path, pos; 4675 4692 4676 - private = (struct dasd_eckd_private *) device->private; 4677 4693 if (cuir->record_selector == 0) 4678 4694 goto out; 4679 4695 for (path = 0x80, pos = 0; path; path >>= 1, pos++) { ··· 4697 4715 static int dasd_eckd_cuir_scope(struct dasd_device *device, __u8 lpum, 4698 4716 struct dasd_cuir_message *cuir) 4699 4717 { 4718 + struct dasd_eckd_private *private = device->private; 4700 4719 struct dasd_conf_data *ref_conf_data; 4701 4720 unsigned long bitmask = 0, mask = 0; 4702 - struct dasd_eckd_private *private; 4703 4721 struct dasd_conf_data *conf_data; 4704 4722 unsigned int pos, path; 4705 4723 char *ref_gneq, *gneq; ··· 4712 4730 !(cuir->neq_map[0] | cuir->neq_map[1] | cuir->neq_map[2])) 4713 4731 return lpum; 4714 4732 4715 - private = (struct dasd_eckd_private *) device->private; 4716 4733 /* get reference conf data */ 4717 4734 ref_conf_data = dasd_eckd_get_ref_conf(device, lpum, cuir); 4718 4735 /* reference ned is determined by ned_map field */ ··· 4810 4829 struct subchannel_id sch_id, 4811 4830 struct dasd_cuir_message *cuir) 4812 4831 { 4832 + struct dasd_eckd_private *private = device->private; 4813 4833 struct alias_pav_group *pavgroup, *tempgroup; 4814 - struct dasd_eckd_private *private; 4815 4834 struct dasd_device *dev, *n; 4816 4835 unsigned long paths = 0; 4817 4836 unsigned long flags; 4818 4837 int tbcpm; 4819 4838 4820 - private = (struct dasd_eckd_private *) device->private; 4821 4839 /* active devices */ 4822 4840 list_for_each_entry_safe(dev, n, &private->lcu->active_devices, 4823 4841 alias_list) { ··· 4872 4892 struct subchannel_id sch_id, 4873 4893 struct dasd_cuir_message *cuir) 4874 4894 { 4895 + struct dasd_eckd_private *private = device->private; 4875 4896 struct alias_pav_group *pavgroup, *tempgroup; 4876 - struct dasd_eckd_private *private; 4877 4897 struct dasd_device *dev, *n; 4878 4898 unsigned long paths = 0; 4879 4899 int tbcpm; 4880 4900 4881 - private = (struct dasd_eckd_private *) device->private; 4882 4901 /* 4883 4902 * the path may have been added through a generic path event before 4884 4903 * only trigger path verification if the path is not already in use
+12 -16
drivers/s390/block/dasd_fba.c
··· 125 125 static int 126 126 dasd_fba_check_characteristics(struct dasd_device *device) 127 127 { 128 - struct dasd_block *block; 129 - struct dasd_fba_private *private; 128 + struct dasd_fba_private *private = device->private; 130 129 struct ccw_device *cdev = device->cdev; 131 - int rc; 132 - int readonly; 130 + struct dasd_block *block; 131 + int readonly, rc; 133 132 134 - private = (struct dasd_fba_private *) device->private; 135 133 if (!private) { 136 134 private = kzalloc(sizeof(*private), GFP_KERNEL | GFP_DMA); 137 135 if (!private) { ··· 138 140 "data failed\n"); 139 141 return -ENOMEM; 140 142 } 141 - device->private = (void *) private; 143 + device->private = private; 142 144 } else { 143 145 memset(private, 0, sizeof(*private)); 144 146 } ··· 190 192 191 193 static int dasd_fba_do_analysis(struct dasd_block *block) 192 194 { 193 - struct dasd_fba_private *private; 195 + struct dasd_fba_private *private = block->base->private; 194 196 int sb, rc; 195 197 196 - private = (struct dasd_fba_private *) block->base->private; 197 198 rc = dasd_check_blocksize(private->rdc_data.blk_size); 198 199 if (rc) { 199 200 DBF_DEV_EVENT(DBF_WARNING, block->base, "unknown blocksize %d", ··· 251 254 struct dasd_block *block, 252 255 struct request *req) 253 256 { 254 - struct dasd_fba_private *private; 257 + struct dasd_fba_private *private = block->base->private; 255 258 unsigned long *idaws; 256 259 struct LO_fba_data *LO_data; 257 260 struct dasd_ccw_req *cqr; ··· 264 267 unsigned int blksize, off; 265 268 unsigned char cmd; 266 269 267 - private = (struct dasd_fba_private *) block->base->private; 268 270 if (rq_data_dir(req) == READ) { 269 271 cmd = DASD_FBA_CCW_READ; 270 272 } else if (rq_data_dir(req) == WRITE) { ··· 375 379 static int 376 380 dasd_fba_free_cp(struct dasd_ccw_req *cqr, struct request *req) 377 381 { 378 - struct dasd_fba_private *private; 382 + struct dasd_fba_private *private = cqr->block->base->private; 379 383 struct ccw1 *ccw; 380 384 struct req_iterator iter; 381 385 struct bio_vec bv; ··· 385 389 386 390 if (!dasd_page_cache) 387 391 goto out; 388 - private = (struct dasd_fba_private *) cqr->block->base->private; 389 392 blksize = cqr->block->bp_block; 390 393 ccw = cqr->cpaddr; 391 394 /* Skip over define extent & locate record. */ ··· 431 436 dasd_fba_fill_info(struct dasd_device * device, 432 437 struct dasd_information2_t * info) 433 438 { 439 + struct dasd_fba_private *private = device->private; 440 + 434 441 info->label_block = 1; 435 442 info->FBA_layout = 1; 436 443 info->format = DASD_FORMAT_LDL; 437 - info->characteristics_size = sizeof(struct dasd_fba_characteristics); 438 - memcpy(info->characteristics, 439 - &((struct dasd_fba_private *) device->private)->rdc_data, 440 - sizeof (struct dasd_fba_characteristics)); 444 + info->characteristics_size = sizeof(private->rdc_data); 445 + memcpy(info->characteristics, &private->rdc_data, 446 + sizeof(private->rdc_data)); 441 447 info->confdata_size = 0; 442 448 return 0; 443 449 }
+2 -2
drivers/s390/block/dasd_genhd.c
··· 178 178 /* Register to static dasd major 94 */ 179 179 rc = register_blkdev(DASD_MAJOR, "dasd"); 180 180 if (rc != 0) { 181 - pr_warning("Registering the device driver with major number " 182 - "%d failed\n", DASD_MAJOR); 181 + pr_warn("Registering the device driver with major number %d failed\n", 182 + DASD_MAJOR); 183 183 return rc; 184 184 } 185 185 return 0;
+8 -1
drivers/s390/block/dasd_int.h
··· 241 241 typedef struct dasd_ccw_req *(*dasd_erp_fn_t) (struct dasd_ccw_req *); 242 242 243 243 /* 244 + * A single CQR can only contain a maximum of 255 CCWs. It is limited by 245 + * the locate record and locate record extended count value which can only hold 246 + * 1 Byte max. 247 + */ 248 + #define DASD_CQR_MAX_CCW 255 249 + 250 + /* 244 251 * Unique identifier for dasd device. 245 252 */ 246 253 #define UA_NOT_CONFIGURED 0x00 ··· 445 438 /* Device discipline stuff. */ 446 439 struct dasd_discipline *discipline; 447 440 struct dasd_discipline *base_discipline; 448 - char *private; 441 + void *private; 449 442 struct dasd_path path_data; 450 443 451 444 /* Device state and target state. */
+7 -29
drivers/s390/block/dasd_ioctl.c
··· 203 203 dasd_format(struct dasd_block *block, struct format_data_t *fdata) 204 204 { 205 205 struct dasd_device *base; 206 - int enable_pav = 1; 207 - int rc, retries; 208 - int start, stop; 206 + int rc; 209 207 210 208 base = block->base; 211 209 if (base->discipline->format_device == NULL) ··· 231 233 bdput(bdev); 232 234 } 233 235 234 - retries = 255; 235 - /* backup start- and endtrack for retries */ 236 - start = fdata->start_unit; 237 - stop = fdata->stop_unit; 238 - do { 239 - rc = base->discipline->format_device(base, fdata, enable_pav); 240 - if (rc) { 241 - if (rc == -EAGAIN) { 242 - retries--; 243 - /* disable PAV in case of errors */ 244 - enable_pav = 0; 245 - fdata->start_unit = start; 246 - fdata->stop_unit = stop; 247 - } else 248 - return rc; 249 - } else 250 - /* success */ 251 - break; 252 - } while (retries); 236 + rc = base->discipline->format_device(base, fdata, 1); 237 + if (rc == -EAGAIN) 238 + rc = base->discipline->format_device(base, fdata, 0); 253 239 254 - if (!retries) 255 - return -EIO; 256 - else 257 - return 0; 240 + return rc; 258 241 } 259 242 260 243 /* ··· 265 286 return -EFAULT; 266 287 } 267 288 if (bdev != bdev->bd_contains) { 268 - pr_warning("%s: The specified DASD is a partition and cannot " 269 - "be formatted\n", 270 - dev_name(&base->cdev->dev)); 289 + pr_warn("%s: The specified DASD is a partition and cannot be formatted\n", 290 + dev_name(&base->cdev->dev)); 271 291 dasd_put_device(base); 272 292 return -EINVAL; 273 293 }
+2 -3
drivers/s390/block/dasd_proc.c
··· 322 322 return user_len; 323 323 out_parse_error: 324 324 rc = -EINVAL; 325 - pr_warning("%s is not a supported value for /proc/dasd/statistics\n", 326 - str); 325 + pr_warn("%s is not a supported value for /proc/dasd/statistics\n", str); 327 326 out_error: 328 327 vfree(buffer); 329 328 return rc; 330 329 #else 331 - pr_warning("/proc/dasd/statistics: is not activated in this kernel\n"); 330 + pr_warn("/proc/dasd/statistics: is not activated in this kernel\n"); 332 331 return user_len; 333 332 #endif /* CONFIG_DASD_PROFILE */ 334 333 }
+6 -7
drivers/s390/block/dcssblk.c
··· 738 738 dev_info = dcssblk_get_device_by_name(local_buf); 739 739 if (dev_info == NULL) { 740 740 up_write(&dcssblk_devices_sem); 741 - pr_warning("Device %s cannot be removed because it is not a " 742 - "known device\n", local_buf); 741 + pr_warn("Device %s cannot be removed because it is not a known device\n", 742 + local_buf); 743 743 rc = -ENODEV; 744 744 goto out_buf; 745 745 } 746 746 if (atomic_read(&dev_info->use_count) != 0) { 747 747 up_write(&dcssblk_devices_sem); 748 - pr_warning("Device %s cannot be removed while it is in " 749 - "use\n", local_buf); 748 + pr_warn("Device %s cannot be removed while it is in use\n", 749 + local_buf); 750 750 rc = -EBUSY; 751 751 goto out_buf; 752 752 } ··· 850 850 case SEG_TYPE_SC: 851 851 /* cannot write to these segments */ 852 852 if (bio_data_dir(bio) == WRITE) { 853 - pr_warning("Writing to %s failed because it " 854 - "is a read-only device\n", 855 - dev_name(&dev_info->dev)); 853 + pr_warn("Writing to %s failed because it is a read-only device\n", 854 + dev_name(&dev_info->dev)); 856 855 goto fail; 857 856 } 858 857 }
+5 -5
drivers/s390/char/monreader.c
··· 257 257 memcpy(&monpriv->msg_array[monpriv->write_index]->msg, 258 258 msg, sizeof(*msg)); 259 259 if (atomic_inc_return(&monpriv->msglim_count) == MON_MSGLIM) { 260 - pr_warning("The read queue for monitor data is full\n"); 260 + pr_warn("The read queue for monitor data is full\n"); 261 261 monpriv->msg_array[monpriv->write_index]->msglim_reached = 1; 262 262 } 263 263 monpriv->write_index = (monpriv->write_index + 1) % MON_MSGLIM; ··· 342 342 if (monpriv->path) { 343 343 rc = iucv_path_sever(monpriv->path, user_data_sever); 344 344 if (rc) 345 - pr_warning("Disconnecting the z/VM *MONITOR system " 346 - "service failed with rc=%i\n", rc); 345 + pr_warn("Disconnecting the z/VM *MONITOR system service failed with rc=%i\n", 346 + rc); 347 347 iucv_path_free(monpriv->path); 348 348 } 349 349 ··· 469 469 if (monpriv->path) { 470 470 rc = iucv_path_sever(monpriv->path, user_data_sever); 471 471 if (rc) 472 - pr_warning("Disconnecting the z/VM *MONITOR system " 473 - "service failed with rc=%i\n", rc); 472 + pr_warn("Disconnecting the z/VM *MONITOR system service failed with rc=%i\n", 473 + rc); 474 474 iucv_path_free(monpriv->path); 475 475 } 476 476 atomic_set(&monpriv->iucv_severed, 0);
+12 -15
drivers/s390/char/sclp_cmd.c
··· 67 67 68 68 /* Check response. */ 69 69 if (request->status != SCLP_REQ_DONE) { 70 - pr_warning("sync request failed (cmd=0x%08x, " 71 - "status=0x%02x)\n", cmd, request->status); 70 + pr_warn("sync request failed (cmd=0x%08x, status=0x%02x)\n", 71 + cmd, request->status); 72 72 rc = -EIO; 73 73 } 74 74 out: ··· 122 122 if (rc) 123 123 goto out; 124 124 if (sccb->header.response_code != 0x0010) { 125 - pr_warning("readcpuinfo failed (response=0x%04x)\n", 126 - sccb->header.response_code); 125 + pr_warn("readcpuinfo failed (response=0x%04x)\n", 126 + sccb->header.response_code); 127 127 rc = -EIO; 128 128 goto out; 129 129 } ··· 160 160 case 0x0120: 161 161 break; 162 162 default: 163 - pr_warning("configure cpu failed (cmd=0x%08x, " 164 - "response=0x%04x)\n", cmd, 165 - sccb->header.response_code); 163 + pr_warn("configure cpu failed (cmd=0x%08x, response=0x%04x)\n", 164 + cmd, sccb->header.response_code); 166 165 rc = -EIO; 167 166 break; 168 167 } ··· 229 230 case 0x0120: 230 231 break; 231 232 default: 232 - pr_warning("assign storage failed (cmd=0x%08x, " 233 - "response=0x%04x, rn=0x%04x)\n", cmd, 234 - sccb->header.response_code, rn); 233 + pr_warn("assign storage failed (cmd=0x%08x, response=0x%04x, rn=0x%04x)\n", 234 + cmd, sccb->header.response_code, rn); 235 235 rc = -EIO; 236 236 break; 237 237 } ··· 673 675 case 0x0450: 674 676 break; 675 677 default: 676 - pr_warning("configure channel-path failed " 677 - "(cmd=0x%08x, response=0x%04x)\n", cmd, 678 - sccb->header.response_code); 678 + pr_warn("configure channel-path failed (cmd=0x%08x, response=0x%04x)\n", 679 + cmd, sccb->header.response_code); 679 680 rc = -EIO; 680 681 break; 681 682 } ··· 741 744 if (rc) 742 745 goto out; 743 746 if (sccb->header.response_code != 0x0010) { 744 - pr_warning("read channel-path info failed " 745 - "(response=0x%04x)\n", sccb->header.response_code); 747 + pr_warn("read channel-path info failed (response=0x%04x)\n", 748 + sccb->header.response_code); 746 749 rc = -EIO; 747 750 goto out; 748 751 }
+2 -4
drivers/s390/char/sclp_cpi_sys.c
··· 154 154 wait_for_completion(&completion); 155 155 156 156 if (req->status != SCLP_REQ_DONE) { 157 - pr_warning("request failed (status=0x%02x)\n", 158 - req->status); 157 + pr_warn("request failed (status=0x%02x)\n", req->status); 159 158 rc = -EIO; 160 159 goto out_free_req; 161 160 } 162 161 163 162 response = ((struct cpi_sccb *) req->sccb)->header.response_code; 164 163 if (response != 0x0020) { 165 - pr_warning("request failed with response code 0x%x\n", 166 - response); 164 + pr_warn("request failed with response code 0x%x\n", response); 167 165 rc = -EIO; 168 166 } 169 167
+2 -2
drivers/s390/char/tape_core.c
··· 699 699 */ 700 700 DBF_EVENT(3, "(%08x): Drive in use vanished!\n", 701 701 device->cdev_id); 702 - pr_warning("%s: A tape unit was detached while in " 703 - "use\n", dev_name(&device->cdev->dev)); 702 + pr_warn("%s: A tape unit was detached while in use\n", 703 + dev_name(&device->cdev->dev)); 704 704 tape_state_set(device, TS_NOT_OPER); 705 705 __tape_discard_requests(device); 706 706 spin_unlock_irq(get_ccwdev_lock(device->cdev));
+2 -4
drivers/s390/char/vmlogrdr.c
··· 343 343 if (logptr->autorecording) { 344 344 ret = vmlogrdr_recording(logptr,1,logptr->autopurge); 345 345 if (ret) 346 - pr_warning("vmlogrdr: failed to start " 347 - "recording automatically\n"); 346 + pr_warn("vmlogrdr: failed to start recording automatically\n"); 348 347 } 349 348 350 349 /* create connection to the system service */ ··· 395 396 if (logptr->autorecording) { 396 397 ret = vmlogrdr_recording(logptr,0,logptr->autopurge); 397 398 if (ret) 398 - pr_warning("vmlogrdr: failed to stop " 399 - "recording automatically\n"); 399 + pr_warn("vmlogrdr: failed to stop recording automatically\n"); 400 400 } 401 401 logptr->dev_in_use = 0; 402 402
+4 -5
drivers/s390/cio/blacklist.c
··· 51 51 { 52 52 if ((from_ssid > to_ssid) || ((from_ssid == to_ssid) && (from > to))) { 53 53 if (msgtrigger) 54 - pr_warning("0.%x.%04x to 0.%x.%04x is not a valid " 55 - "range for cio_ignore\n", from_ssid, from, 56 - to_ssid, to); 54 + pr_warn("0.%x.%04x to 0.%x.%04x is not a valid range for cio_ignore\n", 55 + from_ssid, from, to_ssid, to); 57 56 58 57 return 1; 59 58 } ··· 139 140 rc = 0; 140 141 out: 141 142 if (rc && msgtrigger) 142 - pr_warning("%s is not a valid device for the cio_ignore " 143 - "kernel parameter\n", str); 143 + pr_warn("%s is not a valid device for the cio_ignore kernel parameter\n", 144 + str); 144 145 145 146 return rc; 146 147 }
+6 -7
drivers/s390/cio/ccwreq.c
··· 333 333 334 334 for (chp = 0; chp < 8; chp++) { 335 335 if ((0x80 >> chp) & sch->schib.pmcw.lpum) 336 - pr_warning("%s: No interrupt was received within %lus " 337 - "(CS=%02x, DS=%02x, CHPID=%x.%02x)\n", 338 - dev_name(&cdev->dev), req->timeout / HZ, 339 - scsw_cstat(&sch->schib.scsw), 340 - scsw_dstat(&sch->schib.scsw), 341 - sch->schid.cssid, 342 - sch->schib.pmcw.chpid[chp]); 336 + pr_warn("%s: No interrupt was received within %lus (CS=%02x, DS=%02x, CHPID=%x.%02x)\n", 337 + dev_name(&cdev->dev), req->timeout / HZ, 338 + scsw_cstat(&sch->schib.scsw), 339 + scsw_dstat(&sch->schib.scsw), 340 + sch->schid.cssid, 341 + sch->schib.pmcw.chpid[chp]); 343 342 } 344 343 345 344 if (!ccwreq_next_path(cdev)) {
+1 -1
drivers/s390/cio/cio.c
··· 656 656 657 657 sch_no = cio_get_console_sch_no(); 658 658 if (sch_no == -1) { 659 - pr_warning("No CCW console was found\n"); 659 + pr_warn("No CCW console was found\n"); 660 660 return ERR_PTR(-ENODEV); 661 661 } 662 662 init_subchannel_id(&schid);
+10 -13
drivers/s390/cio/device.c
··· 364 364 cdev->private->state == DEV_STATE_DISCONNECTED)); 365 365 /* Inform the user if set offline failed. */ 366 366 if (cdev->private->state == DEV_STATE_BOXED) { 367 - pr_warning("%s: The device entered boxed state while " 368 - "being set offline\n", dev_name(&cdev->dev)); 367 + pr_warn("%s: The device entered boxed state while being set offline\n", 368 + dev_name(&cdev->dev)); 369 369 } else if (cdev->private->state == DEV_STATE_NOT_OPER) { 370 - pr_warning("%s: The device stopped operating while " 371 - "being set offline\n", dev_name(&cdev->dev)); 370 + pr_warn("%s: The device stopped operating while being set offline\n", 371 + dev_name(&cdev->dev)); 372 372 } 373 373 /* Give up reference from ccw_device_set_online(). */ 374 374 put_device(&cdev->dev); ··· 429 429 spin_unlock_irq(cdev->ccwlock); 430 430 /* Inform the user that set online failed. */ 431 431 if (cdev->private->state == DEV_STATE_BOXED) { 432 - pr_warning("%s: Setting the device online failed " 433 - "because it is boxed\n", 434 - dev_name(&cdev->dev)); 432 + pr_warn("%s: Setting the device online failed because it is boxed\n", 433 + dev_name(&cdev->dev)); 435 434 } else if (cdev->private->state == DEV_STATE_NOT_OPER) { 436 - pr_warning("%s: Setting the device online failed " 437 - "because it is not operational\n", 438 - dev_name(&cdev->dev)); 435 + pr_warn("%s: Setting the device online failed because it is not operational\n", 436 + dev_name(&cdev->dev)); 439 437 } 440 438 /* Give up online reference since onlining failed. */ 441 439 put_device(&cdev->dev); ··· 617 619 618 620 rc = chsc_siosl(sch->schid); 619 621 if (rc < 0) { 620 - pr_warning("Logging for subchannel 0.%x.%04x failed with " 621 - "errno=%d\n", 622 - sch->schid.ssid, sch->schid.sch_no, rc); 622 + pr_warn("Logging for subchannel 0.%x.%04x failed with errno=%d\n", 623 + sch->schid.ssid, sch->schid.sch_no, rc); 623 624 return rc; 624 625 } 625 626 pr_notice("Logging for subchannel 0.%x.%04x was triggered\n",
+2 -2
drivers/s390/net/lcs.c
··· 1761 1761 lcs_schedule_recovery(card); 1762 1762 break; 1763 1763 case LCS_CMD_STOPLAN: 1764 - pr_warning("Stoplan for %s initiated by LGW.\n", 1765 - card->dev->name); 1764 + pr_warn("Stoplan for %s initiated by LGW\n", 1765 + card->dev->name); 1766 1766 if (card->dev) 1767 1767 netif_carrier_off(card->dev); 1768 1768 break;
+1 -1
drivers/s390/net/qeth_l3_main.c
··· 3624 3624 return rc; 3625 3625 } 3626 3626 #else 3627 - pr_warning("There is no IPv6 support for the layer 3 discipline\n"); 3627 + pr_warn("There is no IPv6 support for the layer 3 discipline\n"); 3628 3628 #endif 3629 3629 return 0; 3630 3630 }