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 'loongarch-fixes-6.14-2' of git://git.kernel.org/pub/scm/linux/kernel/git/chenhuacai/linux-loongson

Pull LoongArch fixes from Huacai Chen:
"Fix bugs in kernel build, hibernation, memory management and KVM"

* tag 'loongarch-fixes-6.14-2' of git://git.kernel.org/pub/scm/linux/kernel/git/chenhuacai/linux-loongson:
LoongArch: KVM: Fix GPA size issue about VM
LoongArch: KVM: Reload guest CSR registers after sleep
LoongArch: KVM: Add interrupt checking for AVEC
LoongArch: Set hugetlb mmap base address aligned with pmd size
LoongArch: Set max_pfn with the PFN of the last page
LoongArch: Use polling play_dead() when resuming from hibernation
LoongArch: Eliminate superfluous get_numa_distances_cnt()
LoongArch: Convert unreachable() to BUG()

+75 -18
-12
arch/loongarch/kernel/acpi.c
··· 249 249 return acpi_map_pxm_to_node(pxm); 250 250 } 251 251 252 - /* 253 - * Callback for SLIT parsing. pxm_to_node() returns NUMA_NO_NODE for 254 - * I/O localities since SRAT does not list them. I/O localities are 255 - * not supported at this point. 256 - */ 257 - unsigned int numa_distance_cnt; 258 - 259 - static inline unsigned int get_numa_distances_cnt(struct acpi_table_slit *slit) 260 - { 261 - return slit->locality_count; 262 - } 263 - 264 252 void __init numa_set_distance(int from, int to, int distance) 265 253 { 266 254 if ((u8)distance != distance || (from == to && distance != LOCAL_DISTANCE)) {
+2 -2
arch/loongarch/kernel/machine_kexec.c
··· 126 126 /* All secondary cpus go to kexec_smp_wait */ 127 127 if (smp_processor_id() > 0) { 128 128 relocated_kexec_smp_wait(NULL); 129 - unreachable(); 129 + BUG(); 130 130 } 131 131 #endif 132 132 133 133 do_kexec = (void *)reboot_code_buffer; 134 134 do_kexec(efi_boot, cmdline_ptr, systable_ptr, start_addr, first_ind_entry); 135 135 136 - unreachable(); 136 + BUG(); 137 137 } 138 138 139 139
+3
arch/loongarch/kernel/setup.c
··· 387 387 */ 388 388 static void __init arch_mem_init(char **cmdline_p) 389 389 { 390 + /* Recalculate max_low_pfn for "mem=xxx" */ 391 + max_pfn = max_low_pfn = PHYS_PFN(memblock_end_of_DRAM()); 392 + 390 393 if (usermem) 391 394 pr_info("User-defined physical RAM map overwrite\n"); 392 395
+46 -1
arch/loongarch/kernel/smp.c
··· 19 19 #include <linux/smp.h> 20 20 #include <linux/threads.h> 21 21 #include <linux/export.h> 22 + #include <linux/suspend.h> 22 23 #include <linux/syscore_ops.h> 23 24 #include <linux/time.h> 24 25 #include <linux/tracepoint.h> ··· 424 423 mb(); 425 424 } 426 425 427 - void __noreturn arch_cpu_idle_dead(void) 426 + static void __noreturn idle_play_dead(void) 428 427 { 429 428 register uint64_t addr; 430 429 register void (*init_fn)(void); ··· 447 446 init_fn(); 448 447 BUG(); 449 448 } 449 + 450 + #ifdef CONFIG_HIBERNATION 451 + static void __noreturn poll_play_dead(void) 452 + { 453 + register uint64_t addr; 454 + register void (*init_fn)(void); 455 + 456 + idle_task_exit(); 457 + __this_cpu_write(cpu_state, CPU_DEAD); 458 + 459 + __smp_mb(); 460 + do { 461 + __asm__ __volatile__("nop\n\t"); 462 + addr = iocsr_read64(LOONGARCH_IOCSR_MBUF0); 463 + } while (addr == 0); 464 + 465 + init_fn = (void *)TO_CACHE(addr); 466 + iocsr_write32(0xffffffff, LOONGARCH_IOCSR_IPI_CLEAR); 467 + 468 + init_fn(); 469 + BUG(); 470 + } 471 + #endif 472 + 473 + static void (*play_dead)(void) = idle_play_dead; 474 + 475 + void __noreturn arch_cpu_idle_dead(void) 476 + { 477 + play_dead(); 478 + BUG(); /* play_dead() doesn't return */ 479 + } 480 + 481 + #ifdef CONFIG_HIBERNATION 482 + int hibernate_resume_nonboot_cpu_disable(void) 483 + { 484 + int ret; 485 + 486 + play_dead = poll_play_dead; 487 + ret = suspend_disable_secondary_cpus(); 488 + play_dead = idle_play_dead; 489 + 490 + return ret; 491 + } 492 + #endif 450 493 451 494 #endif 452 495
+6
arch/loongarch/kvm/exit.c
··· 669 669 struct kvm_run *run = vcpu->run; 670 670 unsigned long badv = vcpu->arch.badv; 671 671 672 + /* Inject ADE exception if exceed max GPA size */ 673 + if (unlikely(badv >= vcpu->kvm->arch.gpa_size)) { 674 + kvm_queue_exception(vcpu, EXCCODE_ADE, EXSUBCODE_ADEM); 675 + return RESUME_GUEST; 676 + } 677 + 672 678 ret = kvm_handle_mm_fault(vcpu, badv, write); 673 679 if (ret) { 674 680 /* Treat as MMIO */
+7
arch/loongarch/kvm/main.c
··· 317 317 kvm_debug("GCFG:%lx GSTAT:%lx GINTC:%lx GTLBC:%lx", 318 318 read_csr_gcfg(), read_csr_gstat(), read_csr_gintc(), read_csr_gtlbc()); 319 319 320 + /* 321 + * HW Guest CSR registers are lost after CPU suspend and resume. 322 + * Clear last_vcpu so that Guest CSR registers forced to reload 323 + * from vCPU SW state. 324 + */ 325 + this_cpu_ptr(vmcs)->last_vcpu = NULL; 326 + 320 327 return 0; 321 328 } 322 329
+1 -1
arch/loongarch/kvm/vcpu.c
··· 311 311 { 312 312 int ret = RESUME_GUEST; 313 313 unsigned long estat = vcpu->arch.host_estat; 314 - u32 intr = estat & 0x1fff; /* Ignore NMI */ 314 + u32 intr = estat & CSR_ESTAT_IS; 315 315 u32 ecode = (estat & CSR_ESTAT_EXC) >> CSR_ESTAT_EXC_SHIFT; 316 316 317 317 vcpu->mode = OUTSIDE_GUEST_MODE;
+5 -1
arch/loongarch/kvm/vm.c
··· 48 48 if (kvm_pvtime_supported()) 49 49 kvm->arch.pv_features |= BIT(KVM_FEATURE_STEAL_TIME); 50 50 51 - kvm->arch.gpa_size = BIT(cpu_vabits - 1); 51 + /* 52 + * cpu_vabits means user address space only (a half of total). 53 + * GPA size of VM is the same with the size of user address space. 54 + */ 55 + kvm->arch.gpa_size = BIT(cpu_vabits); 52 56 kvm->arch.root_level = CONFIG_PGTABLE_LEVELS - 1; 53 57 kvm->arch.invalid_ptes[0] = 0; 54 58 kvm->arch.invalid_ptes[1] = (unsigned long)invalid_pte_table;
+5 -1
arch/loongarch/mm/mmap.c
··· 3 3 * Copyright (C) 2020-2022 Loongson Technology Corporation Limited 4 4 */ 5 5 #include <linux/export.h> 6 + #include <linux/hugetlb.h> 6 7 #include <linux/io.h> 7 8 #include <linux/kfence.h> 8 9 #include <linux/memblock.h> ··· 64 63 } 65 64 66 65 info.length = len; 67 - info.align_mask = do_color_align ? (PAGE_MASK & SHM_ALIGN_MASK) : 0; 68 66 info.align_offset = pgoff << PAGE_SHIFT; 67 + if (filp && is_file_hugepages(filp)) 68 + info.align_mask = huge_page_mask_align(filp); 69 + else 70 + info.align_mask = do_color_align ? (PAGE_MASK & SHM_ALIGN_MASK) : 0; 69 71 70 72 if (dir == DOWN) { 71 73 info.flags = VM_UNMAPPED_AREA_TOPDOWN;