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

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 's390-6.7-2' of git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux

Pull more s390 updates from Vasily Gorbik:

- Get rid of s390 specific use of two PTEs per 4KB page with complex
half-used pages tracking. Using full 4KB pages for 2KB PTEs increases
the memory footprint of page tables but drastically simplify mm code,
removing a common blocker for common code changes and adaptations

- Simplify and rework "cmma no-dat" handling. This is a follow up for
recent fixes which prevent potential incorrect guest TLB flushes

- Add perf user stack unwinding as well as USER_STACKTRACE support for
user space built with -mbackchain compile option

- Add few missing conversion from tlb_remove_table to tlb_remove_ptdesc

- Fix crypto cards vanishing in a secure execution environment due to
asynchronous errors

- Avoid reporting crypto cards or queues in check-stop state as online

- Fix null-ptr deference in AP bus code triggered by early config
change via SCLP

- Couple of stability improvements in AP queue interrupt handling

* tag 's390-6.7-2' of git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux:
s390/mm: make pte_free_tlb() similar to pXd_free_tlb()
s390/mm: use compound page order to distinguish page tables
s390/mm: use full 4KB page for 2KB PTE
s390/cmma: rework no-dat handling
s390/cmma: move arch_set_page_dat() to header file
s390/cmma: move set_page_stable() and friends to header file
s390/cmma: move parsing of cmma kernel parameter to early boot code
s390/cmma: cleanup inline assemblies
s390/ap: fix vanishing crypto cards in SE environment
s390/zcrypt: don't report online if card or queue is in check-stop state
s390: add USER_STACKTRACE support
s390/perf: implement perf_callchain_user()
s390/ap: fix AP bus crash on early config change callback invocation
s390/ap: re-enable interrupt for AP queues
s390/ap: rework to use irq info from ap queue status
s390/mm: add missing conversion to use ptdescs

+320 -538
+1
arch/s390/Kconfig
··· 236 236 select THREAD_INFO_IN_TASK 237 237 select TRACE_IRQFLAGS_SUPPORT 238 238 select TTY 239 + select USER_STACKTRACE_SUPPORT 239 240 select VIRT_CPU_ACCOUNTING 240 241 select ZONE_DMA 241 242 # Note: keep the above list sorted alphabetically
+8
arch/s390/boot/ipl_parm.c
··· 3 3 #include <linux/init.h> 4 4 #include <linux/ctype.h> 5 5 #include <linux/pgtable.h> 6 + #include <asm/page-states.h> 6 7 #include <asm/ebcdic.h> 7 8 #include <asm/sclp.h> 8 9 #include <asm/sections.h> ··· 25 24 struct ipl_parameter_block __bootdata_preserved(ipl_block); 26 25 int __bootdata_preserved(ipl_block_valid); 27 26 int __bootdata_preserved(__kaslr_enabled); 27 + int __bootdata_preserved(cmma_flag) = 1; 28 28 29 29 unsigned long vmalloc_size = VMALLOC_DEFAULT_SIZE; 30 30 unsigned long memory_limit; ··· 296 294 297 295 if (!strcmp(param, "nokaslr")) 298 296 __kaslr_enabled = 0; 297 + 298 + if (!strcmp(param, "cmma")) { 299 + rc = kstrtobool(val, &enabled); 300 + if (!rc && !enabled) 301 + cmma_flag = 0; 302 + } 299 303 300 304 #if IS_ENABLED(CONFIG_KVM) 301 305 if (!strcmp(param, "prot_virt")) {
+44
arch/s390/boot/startup.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0 2 2 #include <linux/string.h> 3 3 #include <linux/elf.h> 4 + #include <asm/page-states.h> 4 5 #include <asm/boot_data.h> 5 6 #include <asm/sections.h> 6 7 #include <asm/maccess.h> ··· 56 55 machine.has_edat2 = 1; 57 56 if (test_facility(130)) 58 57 machine.has_nx = 1; 58 + } 59 + 60 + static int cmma_test_essa(void) 61 + { 62 + unsigned long reg1, reg2, tmp = 0; 63 + int rc = 1; 64 + psw_t old; 65 + 66 + /* Test ESSA_GET_STATE */ 67 + asm volatile( 68 + " mvc 0(16,%[psw_old]),0(%[psw_pgm])\n" 69 + " epsw %[reg1],%[reg2]\n" 70 + " st %[reg1],0(%[psw_pgm])\n" 71 + " st %[reg2],4(%[psw_pgm])\n" 72 + " larl %[reg1],1f\n" 73 + " stg %[reg1],8(%[psw_pgm])\n" 74 + " .insn rrf,0xb9ab0000,%[tmp],%[tmp],%[cmd],0\n" 75 + " la %[rc],0\n" 76 + "1: mvc 0(16,%[psw_pgm]),0(%[psw_old])\n" 77 + : [reg1] "=&d" (reg1), 78 + [reg2] "=&a" (reg2), 79 + [rc] "+&d" (rc), 80 + [tmp] "=&d" (tmp), 81 + "+Q" (S390_lowcore.program_new_psw), 82 + "=Q" (old) 83 + : [psw_old] "a" (&old), 84 + [psw_pgm] "a" (&S390_lowcore.program_new_psw), 85 + [cmd] "i" (ESSA_GET_STATE) 86 + : "cc", "memory"); 87 + return rc; 88 + } 89 + 90 + static void cmma_init(void) 91 + { 92 + if (!cmma_flag) 93 + return; 94 + if (cmma_test_essa()) { 95 + cmma_flag = 0; 96 + return; 97 + } 98 + if (test_facility(147)) 99 + cmma_flag = 2; 59 100 } 60 101 61 102 static void setup_lpp(void) ··· 349 306 setup_boot_command_line(); 350 307 parse_boot_command_line(); 351 308 detect_facilities(); 309 + cmma_init(); 352 310 sanitize_prot_virt_host(); 353 311 max_physmem_end = detect_max_physmem_end(); 354 312 setup_ident_map_size(max_physmem_end);
+17
arch/s390/boot/vmem.c
··· 2 2 #include <linux/sched/task.h> 3 3 #include <linux/pgtable.h> 4 4 #include <linux/kasan.h> 5 + #include <asm/page-states.h> 5 6 #include <asm/pgalloc.h> 6 7 #include <asm/facility.h> 7 8 #include <asm/sections.h> ··· 71 70 crst_table_init((unsigned long *)kasan_early_shadow_pud, pud_val(pud_z)); 72 71 crst_table_init((unsigned long *)kasan_early_shadow_pmd, pmd_val(pmd_z)); 73 72 memset64((u64 *)kasan_early_shadow_pte, pte_val(pte_z), PTRS_PER_PTE); 73 + __arch_set_page_dat(kasan_early_shadow_p4d, 1UL << CRST_ALLOC_ORDER); 74 + __arch_set_page_dat(kasan_early_shadow_pud, 1UL << CRST_ALLOC_ORDER); 75 + __arch_set_page_dat(kasan_early_shadow_pmd, 1UL << CRST_ALLOC_ORDER); 76 + __arch_set_page_dat(kasan_early_shadow_pte, 1); 74 77 75 78 /* 76 79 * Current memory layout: ··· 228 223 229 224 table = (unsigned long *)physmem_alloc_top_down(RR_VMEM, size, size); 230 225 crst_table_init(table, val); 226 + __arch_set_page_dat(table, 1UL << CRST_ALLOC_ORDER); 231 227 return table; 232 228 } 233 229 ··· 244 238 if (!pte_leftover) { 245 239 pte_leftover = (void *)physmem_alloc_top_down(RR_VMEM, PAGE_SIZE, PAGE_SIZE); 246 240 pte = pte_leftover + _PAGE_TABLE_SIZE; 241 + __arch_set_page_dat(pte, 1); 247 242 } else { 248 243 pte = pte_leftover; 249 244 pte_leftover = NULL; ··· 425 418 unsigned long asce_bits; 426 419 int i; 427 420 421 + /* 422 + * Mark whole memory as no-dat. This must be done before any 423 + * page tables are allocated, or kernel image builtin pages 424 + * are marked as dat tables. 425 + */ 426 + for_each_physmem_online_range(i, &start, &end) 427 + __arch_set_page_nodat((void *)start, (end - start) >> PAGE_SHIFT); 428 + 428 429 if (asce_limit == _REGION1_SIZE) { 429 430 asce_type = _REGION2_ENTRY_EMPTY; 430 431 asce_bits = _ASCE_TYPE_REGION2 | _ASCE_TABLE_LENGTH; ··· 444 429 445 430 crst_table_init((unsigned long *)swapper_pg_dir, asce_type); 446 431 crst_table_init((unsigned long *)invalid_pg_dir, _REGION3_ENTRY_EMPTY); 432 + __arch_set_page_dat((void *)swapper_pg_dir, 1UL << CRST_ALLOC_ORDER); 433 + __arch_set_page_dat((void *)invalid_pg_dir, 1UL << CRST_ALLOC_ORDER); 447 434 448 435 /* 449 436 * To allow prefixing the lowcore must be mapped with 4KB pages.
-2
arch/s390/include/asm/mmu.h
··· 11 11 cpumask_t cpu_attach_mask; 12 12 atomic_t flush_count; 13 13 unsigned int flush_mm; 14 - struct list_head pgtable_list; 15 14 struct list_head gmap_list; 16 15 unsigned long gmap_asce; 17 16 unsigned long asce; ··· 38 39 39 40 #define INIT_MM_CONTEXT(name) \ 40 41 .context.lock = __SPIN_LOCK_UNLOCKED(name.context.lock), \ 41 - .context.pgtable_list = LIST_HEAD_INIT(name.context.pgtable_list), \ 42 42 .context.gmap_list = LIST_HEAD_INIT(name.context.gmap_list), 43 43 44 44 #endif
-1
arch/s390/include/asm/mmu_context.h
··· 22 22 unsigned long asce_type, init_entry; 23 23 24 24 spin_lock_init(&mm->context.lock); 25 - INIT_LIST_HEAD(&mm->context.pgtable_list); 26 25 INIT_LIST_HEAD(&mm->context.gmap_list); 27 26 cpumask_clear(&mm->context.cpu_attach_mask); 28 27 atomic_set(&mm->context.flush_count, 0);
+59
arch/s390/include/asm/page-states.h
··· 7 7 #ifndef PAGE_STATES_H 8 8 #define PAGE_STATES_H 9 9 10 + #include <asm/sections.h> 11 + #include <asm/page.h> 12 + 10 13 #define ESSA_GET_STATE 0 11 14 #define ESSA_SET_STABLE 1 12 15 #define ESSA_SET_UNUSED 2 ··· 20 17 #define ESSA_SET_STABLE_NODAT 7 21 18 22 19 #define ESSA_MAX ESSA_SET_STABLE_NODAT 20 + 21 + extern int __bootdata_preserved(cmma_flag); 22 + 23 + static __always_inline unsigned long essa(unsigned long paddr, unsigned char cmd) 24 + { 25 + unsigned long rc; 26 + 27 + asm volatile( 28 + " .insn rrf,0xb9ab0000,%[rc],%[paddr],%[cmd],0" 29 + : [rc] "=d" (rc) 30 + : [paddr] "d" (paddr), 31 + [cmd] "i" (cmd)); 32 + return rc; 33 + } 34 + 35 + static __always_inline void __set_page_state(void *addr, unsigned long num_pages, unsigned char cmd) 36 + { 37 + unsigned long paddr = __pa(addr) & PAGE_MASK; 38 + 39 + while (num_pages--) { 40 + essa(paddr, cmd); 41 + paddr += PAGE_SIZE; 42 + } 43 + } 44 + 45 + static inline void __set_page_unused(void *addr, unsigned long num_pages) 46 + { 47 + __set_page_state(addr, num_pages, ESSA_SET_UNUSED); 48 + } 49 + 50 + static inline void __set_page_stable_dat(void *addr, unsigned long num_pages) 51 + { 52 + __set_page_state(addr, num_pages, ESSA_SET_STABLE); 53 + } 54 + 55 + static inline void __set_page_stable_nodat(void *addr, unsigned long num_pages) 56 + { 57 + __set_page_state(addr, num_pages, ESSA_SET_STABLE_NODAT); 58 + } 59 + 60 + static inline void __arch_set_page_nodat(void *addr, unsigned long num_pages) 61 + { 62 + if (!cmma_flag) 63 + return; 64 + if (cmma_flag < 2) 65 + __set_page_stable_dat(addr, num_pages); 66 + else 67 + __set_page_stable_nodat(addr, num_pages); 68 + } 69 + 70 + static inline void __arch_set_page_dat(void *addr, unsigned long num_pages) 71 + { 72 + if (!cmma_flag) 73 + return; 74 + __set_page_stable_dat(addr, num_pages); 75 + } 23 76 24 77 #endif
-1
arch/s390/include/asm/page.h
··· 164 164 struct page; 165 165 void arch_free_page(struct page *page, int order); 166 166 void arch_alloc_page(struct page *page, int order); 167 - void arch_set_page_dat(struct page *page, int order); 168 167 169 168 static inline int devmem_is_allowed(unsigned long pfn) 170 169 {
-1
arch/s390/include/asm/pgalloc.h
··· 25 25 unsigned long *page_table_alloc(struct mm_struct *); 26 26 struct page *page_table_alloc_pgste(struct mm_struct *mm); 27 27 void page_table_free(struct mm_struct *, unsigned long *); 28 - void page_table_free_rcu(struct mmu_gather *, unsigned long *, unsigned long); 29 28 void page_table_free_pgste(struct page *page); 30 29 extern int page_table_allocate_pgste; 31 30
-3
arch/s390/include/asm/setup.h
··· 125 125 126 126 void report_user_fault(struct pt_regs *regs, long signr, int is_mm_fault); 127 127 128 - void cmma_init(void); 129 - void cmma_init_nodat(void); 130 - 131 128 extern void (*_machine_restart)(char *command); 132 129 extern void (*_machine_halt)(void); 133 130 extern void (*_machine_power_off)(void);
+7
arch/s390/include/asm/stacktrace.h
··· 6 6 #include <linux/ptrace.h> 7 7 #include <asm/switch_to.h> 8 8 9 + struct stack_frame_user { 10 + unsigned long back_chain; 11 + unsigned long empty1[5]; 12 + unsigned long gprs[10]; 13 + unsigned long empty2[4]; 14 + }; 15 + 9 16 enum stack_type { 10 17 STACK_TYPE_UNKNOWN, 11 18 STACK_TYPE_TASK,
+5 -8
arch/s390/include/asm/tlb.h
··· 69 69 tlb->mm->context.flush_mm = 1; 70 70 tlb->freed_tables = 1; 71 71 tlb->cleared_pmds = 1; 72 - /* 73 - * page_table_free_rcu takes care of the allocation bit masks 74 - * of the 2K table fragments in the 4K page table page, 75 - * then calls tlb_remove_table. 76 - */ 77 - page_table_free_rcu(tlb, (unsigned long *) pte, address); 72 + if (mm_alloc_pgste(tlb->mm)) 73 + gmap_unlink(tlb->mm, (unsigned long *)pte, address); 74 + tlb_remove_ptdesc(tlb, pte); 78 75 } 79 76 80 77 /* ··· 109 112 __tlb_adjust_range(tlb, address, PAGE_SIZE); 110 113 tlb->mm->context.flush_mm = 1; 111 114 tlb->freed_tables = 1; 112 - tlb_remove_table(tlb, p4d); 115 + tlb_remove_ptdesc(tlb, p4d); 113 116 } 114 117 115 118 /* ··· 127 130 tlb->mm->context.flush_mm = 1; 128 131 tlb->freed_tables = 1; 129 132 tlb->cleared_p4ds = 1; 130 - tlb_remove_table(tlb, pud); 133 + tlb_remove_ptdesc(tlb, pud); 131 134 } 132 135 133 136
+1
arch/s390/kernel/early.c
··· 46 46 decompressor_handled_param(dfltcc); 47 47 decompressor_handled_param(facilities); 48 48 decompressor_handled_param(nokaslr); 49 + decompressor_handled_param(cmma); 49 50 #if IS_ENABLED(CONFIG_KVM) 50 51 decompressor_handled_param(prot_virt); 51 52 #endif
+41
arch/s390/kernel/perf_event.c
··· 15 15 #include <linux/export.h> 16 16 #include <linux/seq_file.h> 17 17 #include <linux/spinlock.h> 18 + #include <linux/uaccess.h> 19 + #include <linux/compat.h> 18 20 #include <linux/sysfs.h> 21 + #include <asm/stacktrace.h> 19 22 #include <asm/irq.h> 20 23 #include <asm/cpu_mf.h> 21 24 #include <asm/lowcore.h> ··· 213 210 if (!addr || perf_callchain_store(entry, addr)) 214 211 return; 215 212 } 213 + } 214 + 215 + void perf_callchain_user(struct perf_callchain_entry_ctx *entry, 216 + struct pt_regs *regs) 217 + { 218 + struct stack_frame_user __user *sf; 219 + unsigned long ip, sp; 220 + bool first = true; 221 + 222 + if (is_compat_task()) 223 + return; 224 + perf_callchain_store(entry, instruction_pointer(regs)); 225 + sf = (void __user *)user_stack_pointer(regs); 226 + pagefault_disable(); 227 + while (entry->nr < entry->max_stack) { 228 + if (__get_user(sp, &sf->back_chain)) 229 + break; 230 + if (__get_user(ip, &sf->gprs[8])) 231 + break; 232 + if (ip & 0x1) { 233 + /* 234 + * If the instruction address is invalid, and this 235 + * is the first stack frame, assume r14 has not 236 + * been written to the stack yet. Otherwise exit. 237 + */ 238 + if (first && !(regs->gprs[14] & 0x1)) 239 + ip = regs->gprs[14]; 240 + else 241 + break; 242 + } 243 + perf_callchain_store(entry, ip); 244 + /* Sanity check: ABI requires SP to be aligned 8 bytes. */ 245 + if (!sp || sp & 0x7) 246 + break; 247 + sf = (void __user *)sp; 248 + first = false; 249 + } 250 + pagefault_enable(); 216 251 } 217 252 218 253 /* Perf definitions for PMU event attributes in sysfs */
+43
arch/s390/kernel/stacktrace.c
··· 6 6 */ 7 7 8 8 #include <linux/stacktrace.h> 9 + #include <linux/uaccess.h> 10 + #include <linux/compat.h> 9 11 #include <asm/stacktrace.h> 10 12 #include <asm/unwind.h> 11 13 #include <asm/kprobes.h> 14 + #include <asm/ptrace.h> 12 15 13 16 void arch_stack_walk(stack_trace_consume_fn consume_entry, void *cookie, 14 17 struct task_struct *task, struct pt_regs *regs) ··· 60 57 if (unwind_error(&state)) 61 58 return -EINVAL; 62 59 return 0; 60 + } 61 + 62 + void arch_stack_walk_user(stack_trace_consume_fn consume_entry, void *cookie, 63 + const struct pt_regs *regs) 64 + { 65 + struct stack_frame_user __user *sf; 66 + unsigned long ip, sp; 67 + bool first = true; 68 + 69 + if (is_compat_task()) 70 + return; 71 + if (!consume_entry(cookie, instruction_pointer(regs))) 72 + return; 73 + sf = (void __user *)user_stack_pointer(regs); 74 + pagefault_disable(); 75 + while (1) { 76 + if (__get_user(sp, &sf->back_chain)) 77 + break; 78 + if (__get_user(ip, &sf->gprs[8])) 79 + break; 80 + if (ip & 0x1) { 81 + /* 82 + * If the instruction address is invalid, and this 83 + * is the first stack frame, assume r14 has not 84 + * been written to the stack yet. Otherwise exit. 85 + */ 86 + if (first && !(regs->gprs[14] & 0x1)) 87 + ip = regs->gprs[14]; 88 + else 89 + break; 90 + } 91 + if (!consume_entry(cookie, ip)) 92 + break; 93 + /* Sanity check: ABI requires SP to be aligned 8 bytes. */ 94 + if (!sp || sp & 0x7) 95 + break; 96 + sf = (void __user *)sp; 97 + first = false; 98 + } 99 + pagefault_enable(); 63 100 }
+2 -2
arch/s390/mm/gmap.c
··· 18 18 #include <linux/ksm.h> 19 19 #include <linux/mman.h> 20 20 #include <linux/pgtable.h> 21 - 21 + #include <asm/page-states.h> 22 22 #include <asm/pgalloc.h> 23 23 #include <asm/gmap.h> 24 24 #include <asm/page.h> ··· 33 33 page = alloc_pages(GFP_KERNEL_ACCOUNT, CRST_ALLOC_ORDER); 34 34 if (!page) 35 35 return NULL; 36 - arch_set_page_dat(page, CRST_ALLOC_ORDER); 36 + __arch_set_page_dat(page_to_virt(page), 1UL << CRST_ALLOC_ORDER); 37 37 return page; 38 38 } 39 39
-4
arch/s390/mm/init.c
··· 164 164 165 165 pv_init(); 166 166 kfence_split_mapping(); 167 - /* Setup guest page hinting */ 168 - cmma_init(); 169 167 170 168 /* this will put all low memory onto the freelists */ 171 169 memblock_free_all(); 172 170 setup_zero_pages(); /* Setup zeroed pages. */ 173 - 174 - cmma_init_nodat(); 175 171 } 176 172 177 173 void free_initmem(void)
+6 -207
arch/s390/mm/page-states.c
··· 7 7 * Author(s): Martin Schwidefsky <schwidefsky@de.ibm.com> 8 8 */ 9 9 10 - #include <linux/kernel.h> 11 - #include <linux/errno.h> 12 - #include <linux/types.h> 13 10 #include <linux/mm.h> 14 - #include <linux/memblock.h> 15 - #include <linux/gfp.h> 16 - #include <linux/init.h> 17 - #include <asm/asm-extable.h> 18 - #include <asm/facility.h> 19 11 #include <asm/page-states.h> 12 + #include <asm/sections.h> 13 + #include <asm/page.h> 20 14 21 - static int cmma_flag = 1; 22 - 23 - static int __init cmma(char *str) 24 - { 25 - bool enabled; 26 - 27 - if (!kstrtobool(str, &enabled)) 28 - cmma_flag = enabled; 29 - return 1; 30 - } 31 - __setup("cmma=", cmma); 32 - 33 - static inline int cmma_test_essa(void) 34 - { 35 - unsigned long tmp = 0; 36 - int rc = -EOPNOTSUPP; 37 - 38 - /* test ESSA_GET_STATE */ 39 - asm volatile( 40 - " .insn rrf,0xb9ab0000,%[tmp],%[tmp],%[cmd],0\n" 41 - "0: la %[rc],0\n" 42 - "1:\n" 43 - EX_TABLE(0b,1b) 44 - : [rc] "+&d" (rc), [tmp] "+&d" (tmp) 45 - : [cmd] "i" (ESSA_GET_STATE)); 46 - return rc; 47 - } 48 - 49 - void __init cmma_init(void) 50 - { 51 - if (!cmma_flag) 52 - return; 53 - if (cmma_test_essa()) { 54 - cmma_flag = 0; 55 - return; 56 - } 57 - if (test_facility(147)) 58 - cmma_flag = 2; 59 - } 60 - 61 - static inline void set_page_unused(struct page *page, int order) 62 - { 63 - int i, rc; 64 - 65 - for (i = 0; i < (1 << order); i++) 66 - asm volatile(".insn rrf,0xb9ab0000,%0,%1,%2,0" 67 - : "=&d" (rc) 68 - : "a" (page_to_phys(page + i)), 69 - "i" (ESSA_SET_UNUSED)); 70 - } 71 - 72 - static inline void set_page_stable_dat(struct page *page, int order) 73 - { 74 - int i, rc; 75 - 76 - for (i = 0; i < (1 << order); i++) 77 - asm volatile(".insn rrf,0xb9ab0000,%0,%1,%2,0" 78 - : "=&d" (rc) 79 - : "a" (page_to_phys(page + i)), 80 - "i" (ESSA_SET_STABLE)); 81 - } 82 - 83 - static inline void set_page_stable_nodat(struct page *page, int order) 84 - { 85 - int i, rc; 86 - 87 - for (i = 0; i < (1 << order); i++) 88 - asm volatile(".insn rrf,0xb9ab0000,%0,%1,%2,0" 89 - : "=&d" (rc) 90 - : "a" (page_to_phys(page + i)), 91 - "i" (ESSA_SET_STABLE_NODAT)); 92 - } 93 - 94 - static void mark_kernel_pmd(pud_t *pud, unsigned long addr, unsigned long end) 95 - { 96 - unsigned long next; 97 - struct page *page; 98 - pmd_t *pmd; 99 - 100 - pmd = pmd_offset(pud, addr); 101 - do { 102 - next = pmd_addr_end(addr, end); 103 - if (pmd_none(*pmd) || pmd_large(*pmd)) 104 - continue; 105 - page = phys_to_page(pmd_val(*pmd)); 106 - set_bit(PG_arch_1, &page->flags); 107 - } while (pmd++, addr = next, addr != end); 108 - } 109 - 110 - static void mark_kernel_pud(p4d_t *p4d, unsigned long addr, unsigned long end) 111 - { 112 - unsigned long next; 113 - struct page *page; 114 - pud_t *pud; 115 - int i; 116 - 117 - pud = pud_offset(p4d, addr); 118 - do { 119 - next = pud_addr_end(addr, end); 120 - if (pud_none(*pud) || pud_large(*pud)) 121 - continue; 122 - if (!pud_folded(*pud)) { 123 - page = phys_to_page(pud_val(*pud)); 124 - for (i = 0; i < 4; i++) 125 - set_bit(PG_arch_1, &page[i].flags); 126 - } 127 - mark_kernel_pmd(pud, addr, next); 128 - } while (pud++, addr = next, addr != end); 129 - } 130 - 131 - static void mark_kernel_p4d(pgd_t *pgd, unsigned long addr, unsigned long end) 132 - { 133 - unsigned long next; 134 - struct page *page; 135 - p4d_t *p4d; 136 - int i; 137 - 138 - p4d = p4d_offset(pgd, addr); 139 - do { 140 - next = p4d_addr_end(addr, end); 141 - if (p4d_none(*p4d)) 142 - continue; 143 - if (!p4d_folded(*p4d)) { 144 - page = phys_to_page(p4d_val(*p4d)); 145 - for (i = 0; i < 4; i++) 146 - set_bit(PG_arch_1, &page[i].flags); 147 - } 148 - mark_kernel_pud(p4d, addr, next); 149 - } while (p4d++, addr = next, addr != end); 150 - } 151 - 152 - static void mark_kernel_pgd(void) 153 - { 154 - unsigned long addr, next, max_addr; 155 - struct page *page; 156 - pgd_t *pgd; 157 - int i; 158 - 159 - addr = 0; 160 - /* 161 - * Figure out maximum virtual address accessible with the 162 - * kernel ASCE. This is required to keep the page table walker 163 - * from accessing non-existent entries. 164 - */ 165 - max_addr = (S390_lowcore.kernel_asce.val & _ASCE_TYPE_MASK) >> 2; 166 - max_addr = 1UL << (max_addr * 11 + 31); 167 - pgd = pgd_offset_k(addr); 168 - do { 169 - next = pgd_addr_end(addr, max_addr); 170 - if (pgd_none(*pgd)) 171 - continue; 172 - if (!pgd_folded(*pgd)) { 173 - page = phys_to_page(pgd_val(*pgd)); 174 - for (i = 0; i < 4; i++) 175 - set_bit(PG_arch_1, &page[i].flags); 176 - } 177 - mark_kernel_p4d(pgd, addr, next); 178 - } while (pgd++, addr = next, addr != max_addr); 179 - } 180 - 181 - void __init cmma_init_nodat(void) 182 - { 183 - struct page *page; 184 - unsigned long start, end, ix; 185 - int i; 186 - 187 - if (cmma_flag < 2) 188 - return; 189 - /* Mark pages used in kernel page tables */ 190 - mark_kernel_pgd(); 191 - page = virt_to_page(&swapper_pg_dir); 192 - for (i = 0; i < 4; i++) 193 - set_bit(PG_arch_1, &page[i].flags); 194 - page = virt_to_page(&invalid_pg_dir); 195 - for (i = 0; i < 4; i++) 196 - set_bit(PG_arch_1, &page[i].flags); 197 - 198 - /* Set all kernel pages not used for page tables to stable/no-dat */ 199 - for_each_mem_pfn_range(i, MAX_NUMNODES, &start, &end, NULL) { 200 - page = pfn_to_page(start); 201 - for (ix = start; ix < end; ix++, page++) { 202 - if (__test_and_clear_bit(PG_arch_1, &page->flags)) 203 - continue; /* skip page table pages */ 204 - if (!list_empty(&page->lru)) 205 - continue; /* skip free pages */ 206 - set_page_stable_nodat(page, 0); 207 - } 208 - } 209 - } 15 + int __bootdata_preserved(cmma_flag); 210 16 211 17 void arch_free_page(struct page *page, int order) 212 18 { 213 19 if (!cmma_flag) 214 20 return; 215 - set_page_unused(page, order); 21 + __set_page_unused(page_to_virt(page), 1UL << order); 216 22 } 217 23 218 24 void arch_alloc_page(struct page *page, int order) ··· 26 220 if (!cmma_flag) 27 221 return; 28 222 if (cmma_flag < 2) 29 - set_page_stable_dat(page, order); 223 + __set_page_stable_dat(page_to_virt(page), 1UL << order); 30 224 else 31 - set_page_stable_nodat(page, order); 32 - } 33 - 34 - void arch_set_page_dat(struct page *page, int order) 35 - { 36 - if (!cmma_flag) 37 - return; 38 - set_page_stable_dat(page, order); 225 + __set_page_stable_nodat(page_to_virt(page), 1UL << order); 39 226 }
+31 -267
arch/s390/mm/pgalloc.c
··· 10 10 #include <linux/slab.h> 11 11 #include <linux/mm.h> 12 12 #include <asm/mmu_context.h> 13 + #include <asm/page-states.h> 13 14 #include <asm/pgalloc.h> 14 15 #include <asm/gmap.h> 15 16 #include <asm/tlb.h> ··· 44 43 unsigned long *crst_table_alloc(struct mm_struct *mm) 45 44 { 46 45 struct ptdesc *ptdesc = pagetable_alloc(GFP_KERNEL, CRST_ALLOC_ORDER); 46 + unsigned long *table; 47 47 48 48 if (!ptdesc) 49 49 return NULL; 50 - arch_set_page_dat(ptdesc_page(ptdesc), CRST_ALLOC_ORDER); 51 - return (unsigned long *) ptdesc_to_virt(ptdesc); 50 + table = ptdesc_to_virt(ptdesc); 51 + __arch_set_page_dat(table, 1UL << CRST_ALLOC_ORDER); 52 + return table; 52 53 } 53 54 54 55 void crst_table_free(struct mm_struct *mm, unsigned long *table) ··· 133 130 return -ENOMEM; 134 131 } 135 132 136 - static inline unsigned int atomic_xor_bits(atomic_t *v, unsigned int bits) 137 - { 138 - return atomic_fetch_xor(bits, v) ^ bits; 139 - } 140 - 141 133 #ifdef CONFIG_PGSTE 142 134 143 135 struct page *page_table_alloc_pgste(struct mm_struct *mm) ··· 143 145 ptdesc = pagetable_alloc(GFP_KERNEL, 0); 144 146 if (ptdesc) { 145 147 table = (u64 *)ptdesc_to_virt(ptdesc); 146 - arch_set_page_dat(virt_to_page(table), 0); 148 + __arch_set_page_dat(table, 1); 147 149 memset64(table, _PAGE_INVALID, PTRS_PER_PTE); 148 150 memset64(table + PTRS_PER_PTE, 0, PTRS_PER_PTE); 149 151 } ··· 157 159 158 160 #endif /* CONFIG_PGSTE */ 159 161 160 - /* 161 - * A 2KB-pgtable is either upper or lower half of a normal page. 162 - * The second half of the page may be unused or used as another 163 - * 2KB-pgtable. 164 - * 165 - * Whenever possible the parent page for a new 2KB-pgtable is picked 166 - * from the list of partially allocated pages mm_context_t::pgtable_list. 167 - * In case the list is empty a new parent page is allocated and added to 168 - * the list. 169 - * 170 - * When a parent page gets fully allocated it contains 2KB-pgtables in both 171 - * upper and lower halves and is removed from mm_context_t::pgtable_list. 172 - * 173 - * When 2KB-pgtable is freed from to fully allocated parent page that 174 - * page turns partially allocated and added to mm_context_t::pgtable_list. 175 - * 176 - * If 2KB-pgtable is freed from the partially allocated parent page that 177 - * page turns unused and gets removed from mm_context_t::pgtable_list. 178 - * Furthermore, the unused parent page is released. 179 - * 180 - * As follows from the above, no unallocated or fully allocated parent 181 - * pages are contained in mm_context_t::pgtable_list. 182 - * 183 - * The upper byte (bits 24-31) of the parent page _refcount is used 184 - * for tracking contained 2KB-pgtables and has the following format: 185 - * 186 - * PP AA 187 - * 01234567 upper byte (bits 24-31) of struct page::_refcount 188 - * || || 189 - * || |+--- upper 2KB-pgtable is allocated 190 - * || +---- lower 2KB-pgtable is allocated 191 - * |+------- upper 2KB-pgtable is pending for removal 192 - * +-------- lower 2KB-pgtable is pending for removal 193 - * 194 - * (See commit 620b4e903179 ("s390: use _refcount for pgtables") on why 195 - * using _refcount is possible). 196 - * 197 - * When 2KB-pgtable is allocated the corresponding AA bit is set to 1. 198 - * The parent page is either: 199 - * - added to mm_context_t::pgtable_list in case the second half of the 200 - * parent page is still unallocated; 201 - * - removed from mm_context_t::pgtable_list in case both hales of the 202 - * parent page are allocated; 203 - * These operations are protected with mm_context_t::lock. 204 - * 205 - * When 2KB-pgtable is deallocated the corresponding AA bit is set to 0 206 - * and the corresponding PP bit is set to 1 in a single atomic operation. 207 - * Thus, PP and AA bits corresponding to the same 2KB-pgtable are mutually 208 - * exclusive and may never be both set to 1! 209 - * The parent page is either: 210 - * - added to mm_context_t::pgtable_list in case the second half of the 211 - * parent page is still allocated; 212 - * - removed from mm_context_t::pgtable_list in case the second half of 213 - * the parent page is unallocated; 214 - * These operations are protected with mm_context_t::lock. 215 - * 216 - * It is important to understand that mm_context_t::lock only protects 217 - * mm_context_t::pgtable_list and AA bits, but not the parent page itself 218 - * and PP bits. 219 - * 220 - * Releasing the parent page happens whenever the PP bit turns from 1 to 0, 221 - * while both AA bits and the second PP bit are already unset. Then the 222 - * parent page does not contain any 2KB-pgtable fragment anymore, and it has 223 - * also been removed from mm_context_t::pgtable_list. It is safe to release 224 - * the page therefore. 225 - * 226 - * PGSTE memory spaces use full 4KB-pgtables and do not need most of the 227 - * logic described above. Both AA bits are set to 1 to denote a 4KB-pgtable 228 - * while the PP bits are never used, nor such a page is added to or removed 229 - * from mm_context_t::pgtable_list. 230 - * 231 - * pte_free_defer() overrides those rules: it takes the page off pgtable_list, 232 - * and prevents both 2K fragments from being reused. pte_free_defer() has to 233 - * guarantee that its pgtable cannot be reused before the RCU grace period 234 - * has elapsed (which page_table_free_rcu() does not actually guarantee). 235 - * But for simplicity, because page->rcu_head overlays page->lru, and because 236 - * the RCU callback might not be called before the mm_context_t has been freed, 237 - * pte_free_defer() in this implementation prevents both fragments from being 238 - * reused, and delays making the call to RCU until both fragments are freed. 239 - */ 240 162 unsigned long *page_table_alloc(struct mm_struct *mm) 241 163 { 242 - unsigned long *table; 243 164 struct ptdesc *ptdesc; 244 - unsigned int mask, bit; 165 + unsigned long *table; 245 166 246 - /* Try to get a fragment of a 4K page as a 2K page table */ 247 - if (!mm_alloc_pgste(mm)) { 248 - table = NULL; 249 - spin_lock_bh(&mm->context.lock); 250 - if (!list_empty(&mm->context.pgtable_list)) { 251 - ptdesc = list_first_entry(&mm->context.pgtable_list, 252 - struct ptdesc, pt_list); 253 - mask = atomic_read(&ptdesc->_refcount) >> 24; 254 - /* 255 - * The pending removal bits must also be checked. 256 - * Failure to do so might lead to an impossible 257 - * value of (i.e 0x13 or 0x23) written to _refcount. 258 - * Such values violate the assumption that pending and 259 - * allocation bits are mutually exclusive, and the rest 260 - * of the code unrails as result. That could lead to 261 - * a whole bunch of races and corruptions. 262 - */ 263 - mask = (mask | (mask >> 4)) & 0x03U; 264 - if (mask != 0x03U) { 265 - table = (unsigned long *) ptdesc_to_virt(ptdesc); 266 - bit = mask & 1; /* =1 -> second 2K */ 267 - if (bit) 268 - table += PTRS_PER_PTE; 269 - atomic_xor_bits(&ptdesc->_refcount, 270 - 0x01U << (bit + 24)); 271 - list_del_init(&ptdesc->pt_list); 272 - } 273 - } 274 - spin_unlock_bh(&mm->context.lock); 275 - if (table) 276 - return table; 277 - } 278 - /* Allocate a fresh page */ 279 167 ptdesc = pagetable_alloc(GFP_KERNEL, 0); 280 168 if (!ptdesc) 281 169 return NULL; ··· 169 285 pagetable_free(ptdesc); 170 286 return NULL; 171 287 } 172 - arch_set_page_dat(ptdesc_page(ptdesc), 0); 173 - /* Initialize page table */ 174 - table = (unsigned long *) ptdesc_to_virt(ptdesc); 175 - if (mm_alloc_pgste(mm)) { 176 - /* Return 4K page table with PGSTEs */ 177 - INIT_LIST_HEAD(&ptdesc->pt_list); 178 - atomic_xor_bits(&ptdesc->_refcount, 0x03U << 24); 179 - memset64((u64 *)table, _PAGE_INVALID, PTRS_PER_PTE); 180 - memset64((u64 *)table + PTRS_PER_PTE, 0, PTRS_PER_PTE); 181 - } else { 182 - /* Return the first 2K fragment of the page */ 183 - atomic_xor_bits(&ptdesc->_refcount, 0x01U << 24); 184 - memset64((u64 *)table, _PAGE_INVALID, 2 * PTRS_PER_PTE); 185 - spin_lock_bh(&mm->context.lock); 186 - list_add(&ptdesc->pt_list, &mm->context.pgtable_list); 187 - spin_unlock_bh(&mm->context.lock); 188 - } 288 + table = ptdesc_to_virt(ptdesc); 289 + __arch_set_page_dat(table, 1); 290 + /* pt_list is used by gmap only */ 291 + INIT_LIST_HEAD(&ptdesc->pt_list); 292 + memset64((u64 *)table, _PAGE_INVALID, PTRS_PER_PTE); 293 + memset64((u64 *)table + PTRS_PER_PTE, 0, PTRS_PER_PTE); 189 294 return table; 190 295 } 191 296 192 - static void page_table_release_check(struct page *page, void *table, 193 - unsigned int half, unsigned int mask) 297 + static void pagetable_pte_dtor_free(struct ptdesc *ptdesc) 194 298 { 195 - char msg[128]; 196 - 197 - if (!IS_ENABLED(CONFIG_DEBUG_VM)) 198 - return; 199 - if (!mask && list_empty(&page->lru)) 200 - return; 201 - snprintf(msg, sizeof(msg), 202 - "Invalid pgtable %p release half 0x%02x mask 0x%02x", 203 - table, half, mask); 204 - dump_page(page, msg); 205 - } 206 - 207 - static void pte_free_now(struct rcu_head *head) 208 - { 209 - struct ptdesc *ptdesc; 210 - 211 - ptdesc = container_of(head, struct ptdesc, pt_rcu_head); 212 299 pagetable_pte_dtor(ptdesc); 213 300 pagetable_free(ptdesc); 214 301 } 215 302 216 303 void page_table_free(struct mm_struct *mm, unsigned long *table) 217 304 { 218 - unsigned int mask, bit, half; 219 305 struct ptdesc *ptdesc = virt_to_ptdesc(table); 220 306 221 - if (!mm_alloc_pgste(mm)) { 222 - /* Free 2K page table fragment of a 4K page */ 223 - bit = ((unsigned long) table & ~PAGE_MASK)/(PTRS_PER_PTE*sizeof(pte_t)); 224 - spin_lock_bh(&mm->context.lock); 225 - /* 226 - * Mark the page for delayed release. The actual release 227 - * will happen outside of the critical section from this 228 - * function or from __tlb_remove_table() 229 - */ 230 - mask = atomic_xor_bits(&ptdesc->_refcount, 0x11U << (bit + 24)); 231 - mask >>= 24; 232 - if ((mask & 0x03U) && !folio_test_active(ptdesc_folio(ptdesc))) { 233 - /* 234 - * Other half is allocated, and neither half has had 235 - * its free deferred: add page to head of list, to make 236 - * this freed half available for immediate reuse. 237 - */ 238 - list_add(&ptdesc->pt_list, &mm->context.pgtable_list); 239 - } else { 240 - /* If page is on list, now remove it. */ 241 - list_del_init(&ptdesc->pt_list); 242 - } 243 - spin_unlock_bh(&mm->context.lock); 244 - mask = atomic_xor_bits(&ptdesc->_refcount, 0x10U << (bit + 24)); 245 - mask >>= 24; 246 - if (mask != 0x00U) 247 - return; 248 - half = 0x01U << bit; 249 - } else { 250 - half = 0x03U; 251 - mask = atomic_xor_bits(&ptdesc->_refcount, 0x03U << 24); 252 - mask >>= 24; 253 - } 254 - 255 - page_table_release_check(ptdesc_page(ptdesc), table, half, mask); 256 - if (folio_test_clear_active(ptdesc_folio(ptdesc))) 257 - call_rcu(&ptdesc->pt_rcu_head, pte_free_now); 258 - else 259 - pte_free_now(&ptdesc->pt_rcu_head); 307 + pagetable_pte_dtor_free(ptdesc); 260 308 } 261 309 262 - void page_table_free_rcu(struct mmu_gather *tlb, unsigned long *table, 263 - unsigned long vmaddr) 310 + void __tlb_remove_table(void *table) 264 311 { 265 - struct mm_struct *mm; 266 - unsigned int bit, mask; 267 312 struct ptdesc *ptdesc = virt_to_ptdesc(table); 313 + struct page *page = ptdesc_page(ptdesc); 268 314 269 - mm = tlb->mm; 270 - if (mm_alloc_pgste(mm)) { 271 - gmap_unlink(mm, table, vmaddr); 272 - table = (unsigned long *) ((unsigned long)table | 0x03U); 273 - tlb_remove_ptdesc(tlb, table); 274 - return; 275 - } 276 - bit = ((unsigned long) table & ~PAGE_MASK) / (PTRS_PER_PTE*sizeof(pte_t)); 277 - spin_lock_bh(&mm->context.lock); 278 - /* 279 - * Mark the page for delayed release. The actual release will happen 280 - * outside of the critical section from __tlb_remove_table() or from 281 - * page_table_free() 282 - */ 283 - mask = atomic_xor_bits(&ptdesc->_refcount, 0x11U << (bit + 24)); 284 - mask >>= 24; 285 - if ((mask & 0x03U) && !folio_test_active(ptdesc_folio(ptdesc))) { 286 - /* 287 - * Other half is allocated, and neither half has had 288 - * its free deferred: add page to end of list, to make 289 - * this freed half available for reuse once its pending 290 - * bit has been cleared by __tlb_remove_table(). 291 - */ 292 - list_add_tail(&ptdesc->pt_list, &mm->context.pgtable_list); 293 - } else { 294 - /* If page is on list, now remove it. */ 295 - list_del_init(&ptdesc->pt_list); 296 - } 297 - spin_unlock_bh(&mm->context.lock); 298 - table = (unsigned long *) ((unsigned long) table | (0x01U << bit)); 299 - tlb_remove_table(tlb, table); 300 - } 301 - 302 - void __tlb_remove_table(void *_table) 303 - { 304 - unsigned int mask = (unsigned long) _table & 0x03U, half = mask; 305 - void *table = (void *)((unsigned long) _table ^ mask); 306 - struct ptdesc *ptdesc = virt_to_ptdesc(table); 307 - 308 - switch (half) { 309 - case 0x00U: /* pmd, pud, or p4d */ 315 + if (compound_order(page) == CRST_ALLOC_ORDER) { 316 + /* pmd, pud, or p4d */ 310 317 pagetable_free(ptdesc); 311 318 return; 312 - case 0x01U: /* lower 2K of a 4K page table */ 313 - case 0x02U: /* higher 2K of a 4K page table */ 314 - mask = atomic_xor_bits(&ptdesc->_refcount, mask << (4 + 24)); 315 - mask >>= 24; 316 - if (mask != 0x00U) 317 - return; 318 - break; 319 - case 0x03U: /* 4K page table with pgstes */ 320 - mask = atomic_xor_bits(&ptdesc->_refcount, 0x03U << 24); 321 - mask >>= 24; 322 - break; 323 319 } 324 - 325 - page_table_release_check(ptdesc_page(ptdesc), table, half, mask); 326 - if (folio_test_clear_active(ptdesc_folio(ptdesc))) 327 - call_rcu(&ptdesc->pt_rcu_head, pte_free_now); 328 - else 329 - pte_free_now(&ptdesc->pt_rcu_head); 320 + pagetable_pte_dtor_free(ptdesc); 330 321 } 331 322 332 323 #ifdef CONFIG_TRANSPARENT_HUGEPAGE 324 + static void pte_free_now(struct rcu_head *head) 325 + { 326 + struct ptdesc *ptdesc = container_of(head, struct ptdesc, pt_rcu_head); 327 + 328 + pagetable_pte_dtor_free(ptdesc); 329 + } 330 + 333 331 void pte_free_defer(struct mm_struct *mm, pgtable_t pgtable) 334 332 { 335 - struct page *page; 333 + struct ptdesc *ptdesc = virt_to_ptdesc(pgtable); 336 334 337 - page = virt_to_page(pgtable); 338 - SetPageActive(page); 339 - page_table_free(mm, (unsigned long *)pgtable); 335 + call_rcu(&ptdesc->pt_rcu_head, pte_free_now); 340 336 /* 341 - * page_table_free() does not do the pgste gmap_unlink() which 342 - * page_table_free_rcu() does: warn us if pgste ever reaches here. 337 + * THPs are not allowed for KVM guests. Warn if pgste ever reaches here. 338 + * Turn to the generic pte_free_defer() version once gmap is removed. 343 339 */ 344 340 WARN_ON_ONCE(mm_has_pgste(mm)); 345 341 }
+2 -2
arch/s390/mm/vmem.c
··· 50 50 if (!table) 51 51 return NULL; 52 52 crst_table_init(table, val); 53 - if (slab_is_available()) 54 - arch_set_page_dat(virt_to_page(table), CRST_ALLOC_ORDER); 53 + __arch_set_page_dat(table, 1UL << CRST_ALLOC_ORDER); 55 54 return table; 56 55 } 57 56 ··· 66 67 if (!pte) 67 68 return NULL; 68 69 memset64((u64 *)pte, _PAGE_INVALID, PTRS_PER_PTE); 70 + __arch_set_page_dat(pte, 1); 69 71 return pte; 70 72 } 71 73
+24 -23
drivers/s390/crypto/ap_bus.c
··· 352 352 /* 353 353 * ap_queue_info(): Check and get AP queue info. 354 354 * Returns: 1 if APQN exists and info is filled, 355 - * 0 if APQN seems to exit but there is no info 355 + * 0 if APQN seems to exist but there is no info 356 356 * available (eg. caused by an asynch pending error) 357 357 * -1 invalid APQN, TAPQ error or AP queue status which 358 358 * indicates there is no APQN. ··· 373 373 /* call TAPQ on this APQN */ 374 374 status = ap_test_queue(qid, ap_apft_available(), &tapq_info); 375 375 376 - /* handle pending async error with return 'no info available' */ 377 - if (status.async) 378 - return 0; 379 - 380 376 switch (status.response_code) { 381 377 case AP_RESPONSE_NORMAL: 382 378 case AP_RESPONSE_RESET_IN_PROGRESS: 383 379 case AP_RESPONSE_DECONFIGURED: 384 380 case AP_RESPONSE_CHECKSTOPPED: 385 381 case AP_RESPONSE_BUSY: 386 - /* 387 - * According to the architecture in all these cases the 388 - * info should be filled. All bits 0 is not possible as 389 - * there is at least one of the mode bits set. 390 - */ 391 - if (WARN_ON_ONCE(!tapq_info.value)) 392 - return 0; 393 - *q_type = tapq_info.at; 394 - *q_fac = tapq_info.fac; 395 - *q_depth = tapq_info.qd; 396 - *q_ml = tapq_info.ml; 397 - *q_decfg = status.response_code == AP_RESPONSE_DECONFIGURED; 398 - *q_cstop = status.response_code == AP_RESPONSE_CHECKSTOPPED; 399 - return 1; 382 + /* For all these RCs the tapq info should be available */ 383 + break; 400 384 default: 401 - /* 402 - * A response code which indicates, there is no info available. 403 - */ 404 - return -1; 385 + /* On a pending async error the info should be available */ 386 + if (!status.async) 387 + return -1; 388 + break; 405 389 } 390 + 391 + /* There should be at least one of the mode bits set */ 392 + if (WARN_ON_ONCE(!tapq_info.value)) 393 + return 0; 394 + 395 + *q_type = tapq_info.at; 396 + *q_fac = tapq_info.fac; 397 + *q_depth = tapq_info.qd; 398 + *q_ml = tapq_info.ml; 399 + *q_decfg = status.response_code == AP_RESPONSE_DECONFIGURED; 400 + *q_cstop = status.response_code == AP_RESPONSE_CHECKSTOPPED; 401 + 402 + return 1; 406 403 } 407 404 408 405 void ap_wait(enum ap_sm_wait wait) ··· 1019 1022 1020 1023 void ap_bus_force_rescan(void) 1021 1024 { 1025 + /* Only trigger AP bus scans after the initial scan is done */ 1026 + if (atomic64_read(&ap_scan_bus_count) <= 0) 1027 + return; 1028 + 1022 1029 /* processing a asynchronous bus rescan */ 1023 1030 del_timer(&ap_config_timer); 1024 1031 queue_work(system_long_wq, &ap_scan_work);
-1
drivers/s390/crypto/ap_bus.h
··· 206 206 bool config; /* configured state */ 207 207 bool chkstop; /* checkstop state */ 208 208 ap_qid_t qid; /* AP queue id. */ 209 - bool interrupt; /* indicate if interrupts are enabled */ 210 209 bool se_bound; /* SE bound state */ 211 210 unsigned int assoc_idx; /* SE association index */ 212 211 int queue_count; /* # messages currently on AP queue. */
+24 -12
drivers/s390/crypto/ap_queue.c
··· 200 200 return AP_SM_WAIT_AGAIN; 201 201 } 202 202 aq->sm_state = AP_SM_STATE_IDLE; 203 - return AP_SM_WAIT_NONE; 203 + break; 204 204 case AP_RESPONSE_NO_PENDING_REPLY: 205 205 if (aq->queue_count > 0) 206 - return aq->interrupt ? 206 + return status.irq_enabled ? 207 207 AP_SM_WAIT_INTERRUPT : AP_SM_WAIT_HIGH_TIMEOUT; 208 208 aq->sm_state = AP_SM_STATE_IDLE; 209 - return AP_SM_WAIT_NONE; 209 + break; 210 210 default: 211 211 aq->dev_state = AP_DEV_STATE_ERROR; 212 212 aq->last_err_rc = status.response_code; ··· 215 215 AP_QID_CARD(aq->qid), AP_QID_QUEUE(aq->qid)); 216 216 return AP_SM_WAIT_NONE; 217 217 } 218 + /* Check and maybe enable irq support (again) on this queue */ 219 + if (!status.irq_enabled && status.queue_empty) { 220 + void *lsi_ptr = ap_airq_ptr(); 221 + 222 + if (lsi_ptr && ap_queue_enable_irq(aq, lsi_ptr) == 0) { 223 + aq->sm_state = AP_SM_STATE_SETIRQ_WAIT; 224 + return AP_SM_WAIT_AGAIN; 225 + } 226 + } 227 + return AP_SM_WAIT_NONE; 218 228 } 219 229 220 230 /** ··· 264 254 fallthrough; 265 255 case AP_RESPONSE_Q_FULL: 266 256 aq->sm_state = AP_SM_STATE_QUEUE_FULL; 267 - return aq->interrupt ? 257 + return status.irq_enabled ? 268 258 AP_SM_WAIT_INTERRUPT : AP_SM_WAIT_HIGH_TIMEOUT; 269 259 case AP_RESPONSE_RESET_IN_PROGRESS: 270 260 aq->sm_state = AP_SM_STATE_RESET_WAIT; ··· 317 307 case AP_RESPONSE_NORMAL: 318 308 case AP_RESPONSE_RESET_IN_PROGRESS: 319 309 aq->sm_state = AP_SM_STATE_RESET_WAIT; 320 - aq->interrupt = false; 321 310 aq->rapq_fbit = 0; 322 311 aq->se_bound = false; 323 312 return AP_SM_WAIT_LOW_TIMEOUT; ··· 392 383 393 384 if (status.irq_enabled == 1) { 394 385 /* Irqs are now enabled */ 395 - aq->interrupt = true; 396 386 aq->sm_state = (aq->queue_count > 0) ? 397 387 AP_SM_STATE_WORKING : AP_SM_STATE_IDLE; 398 388 } ··· 634 626 struct device_attribute *attr, char *buf) 635 627 { 636 628 struct ap_queue *aq = to_ap_queue(dev); 629 + struct ap_queue_status status; 637 630 int rc = 0; 638 631 639 632 spin_lock_bh(&aq->lock); 640 - if (aq->sm_state == AP_SM_STATE_SETIRQ_WAIT) 633 + if (aq->sm_state == AP_SM_STATE_SETIRQ_WAIT) { 641 634 rc = sysfs_emit(buf, "Enable Interrupt pending.\n"); 642 - else if (aq->interrupt) 643 - rc = sysfs_emit(buf, "Interrupts enabled.\n"); 644 - else 645 - rc = sysfs_emit(buf, "Interrupts disabled.\n"); 635 + } else { 636 + status = ap_tapq(aq->qid, NULL); 637 + if (status.irq_enabled) 638 + rc = sysfs_emit(buf, "Interrupts enabled.\n"); 639 + else 640 + rc = sysfs_emit(buf, "Interrupts disabled.\n"); 641 + } 646 642 spin_unlock_bh(&aq->lock); 643 + 647 644 return rc; 648 645 } 649 646 ··· 1045 1032 if (ap_sb_available() && is_prot_virt_guest()) 1046 1033 aq->ap_dev.device.groups = ap_queue_dev_sb_attr_groups; 1047 1034 aq->qid = qid; 1048 - aq->interrupt = false; 1049 1035 spin_lock_init(&aq->lock); 1050 1036 INIT_LIST_HEAD(&aq->pendingq); 1051 1037 INIT_LIST_HEAD(&aq->requestq);
+2 -2
drivers/s390/crypto/zcrypt_card.c
··· 52 52 { 53 53 struct zcrypt_card *zc = dev_get_drvdata(dev); 54 54 struct ap_card *ac = to_ap_card(dev); 55 - int online = ac->config && zc->online ? 1 : 0; 55 + int online = ac->config && !ac->chkstop && zc->online ? 1 : 0; 56 56 57 57 return sysfs_emit(buf, "%d\n", online); 58 58 } ··· 70 70 if (sscanf(buf, "%d\n", &online) != 1 || online < 0 || online > 1) 71 71 return -EINVAL; 72 72 73 - if (online && !ac->config) 73 + if (online && (!ac->config || ac->chkstop)) 74 74 return -ENODEV; 75 75 76 76 zc->online = online;
+3 -2
drivers/s390/crypto/zcrypt_queue.c
··· 42 42 { 43 43 struct zcrypt_queue *zq = dev_get_drvdata(dev); 44 44 struct ap_queue *aq = to_ap_queue(dev); 45 - int online = aq->config && zq->online ? 1 : 0; 45 + int online = aq->config && !aq->chkstop && zq->online ? 1 : 0; 46 46 47 47 return sysfs_emit(buf, "%d\n", online); 48 48 } ··· 59 59 if (sscanf(buf, "%d\n", &online) != 1 || online < 0 || online > 1) 60 60 return -EINVAL; 61 61 62 - if (online && (!aq->config || !aq->card->config)) 62 + if (online && (!aq->config || !aq->card->config || 63 + aq->chkstop || aq->card->chkstop)) 63 64 return -ENODEV; 64 65 if (online && !zc->online) 65 66 return -EINVAL;