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

Pull LoongArch fixes from Huacai Chen:
"Fix missing NULL checks for kstrdup(), workaround LS2K/LS7A GPU
DMA hang bug, emit GNU_EH_FRAME for vDSO correctly, and fix some
KVM-related bugs"

* tag 'loongarch-fixes-7.0-2' of git://git.kernel.org/pub/scm/linux/kernel/git/chenhuacai/linux-loongson:
LoongArch: KVM: Fix base address calculation in kvm_eiointc_regs_access()
LoongArch: KVM: Handle the case that EIOINTC's coremap is empty
LoongArch: KVM: Make kvm_get_vcpu_by_cpuid() more robust
LoongArch: vDSO: Emit GNU_EH_FRAME correctly
LoongArch: Workaround LS2K/LS7A GPU DMA hang bug
LoongArch: Fix missing NULL checks for kstrdup()

+147 -22
+36
arch/loongarch/include/asm/linkage.h
··· 41 41 .cfi_endproc; \ 42 42 SYM_END(name, SYM_T_NONE) 43 43 44 + /* 45 + * This is for the signal handler trampoline, which is used as the return 46 + * address of the signal handlers in userspace instead of called normally. 47 + * The long standing libgcc bug https://gcc.gnu.org/PR124050 requires a 48 + * nop between .cfi_startproc and the actual address of the trampoline, so 49 + * we cannot simply use SYM_FUNC_START. 50 + * 51 + * This wrapper also contains all the .cfi_* directives for recovering 52 + * the content of the GPRs and the "return address" (where the rt_sigreturn 53 + * syscall will jump to), assuming there is a struct rt_sigframe (where 54 + * a struct sigcontext containing those information we need to recover) at 55 + * $sp. The "DWARF for the LoongArch(TM) Architecture" manual states 56 + * column 0 is for $zero, but it does not make too much sense to 57 + * save/restore the hardware zero register. Repurpose this column here 58 + * for the return address (here it's not the content of $ra we cannot use 59 + * the default column 3). 60 + */ 61 + #define SYM_SIGFUNC_START(name) \ 62 + .cfi_startproc; \ 63 + .cfi_signal_frame; \ 64 + .cfi_def_cfa 3, RT_SIGFRAME_SC; \ 65 + .cfi_return_column 0; \ 66 + .cfi_offset 0, SC_PC; \ 67 + \ 68 + .irp num, 1, 2, 3, 4, 5, 6, 7, 8, \ 69 + 9, 10, 11, 12, 13, 14, 15, 16, \ 70 + 17, 18, 19, 20, 21, 22, 23, 24, \ 71 + 25, 26, 27, 28, 29, 30, 31; \ 72 + .cfi_offset \num, SC_REGS + \num * SZREG; \ 73 + .endr; \ 74 + \ 75 + nop; \ 76 + SYM_START(name, SYM_L_GLOBAL, SYM_A_ALIGN) 77 + 78 + #define SYM_SIGFUNC_END(name) SYM_FUNC_END(name) 79 + 44 80 #endif
+9
arch/loongarch/include/asm/sigframe.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0+ */ 2 + 3 + #include <asm/siginfo.h> 4 + #include <asm/ucontext.h> 5 + 6 + struct rt_sigframe { 7 + struct siginfo rs_info; 8 + struct ucontext rs_uctx; 9 + };
+2
arch/loongarch/kernel/asm-offsets.c
··· 16 16 #include <asm/ptrace.h> 17 17 #include <asm/processor.h> 18 18 #include <asm/ftrace.h> 19 + #include <asm/sigframe.h> 19 20 #include <vdso/datapage.h> 20 21 21 22 static void __used output_ptreg_defines(void) ··· 221 220 COMMENT("Linux sigcontext offsets."); 222 221 OFFSET(SC_REGS, sigcontext, sc_regs); 223 222 OFFSET(SC_PC, sigcontext, sc_pc); 223 + OFFSET(RT_SIGFRAME_SC, rt_sigframe, rs_uctx.uc_mcontext); 224 224 BLANK(); 225 225 } 226 226
+3 -4
arch/loongarch/kernel/env.c
··· 42 42 int cpu, ret; 43 43 char *cpuname; 44 44 const char *model; 45 - struct device_node *root; 46 45 47 46 /* Parsing cpuname from DTS model property */ 48 - root = of_find_node_by_path("/"); 49 - ret = of_property_read_string(root, "model", &model); 47 + ret = of_property_read_string(of_root, "model", &model); 50 48 if (ret == 0) { 51 49 cpuname = kstrdup(model, GFP_KERNEL); 50 + if (!cpuname) 51 + return -ENOMEM; 52 52 loongson_sysconf.cpuname = strsep(&cpuname, " "); 53 53 } 54 - of_node_put(root); 55 54 56 55 if (loongson_sysconf.cpuname && !strncmp(loongson_sysconf.cpuname, "Loongson", 8)) { 57 56 for (cpu = 0; cpu < NR_CPUS; cpu++)
+1 -5
arch/loongarch/kernel/signal.c
··· 35 35 #include <asm/cpu-features.h> 36 36 #include <asm/fpu.h> 37 37 #include <asm/lbt.h> 38 + #include <asm/sigframe.h> 38 39 #include <asm/ucontext.h> 39 40 #include <asm/vdso.h> 40 41 ··· 51 50 /* Make sure we will not lose LBT ownership */ 52 51 #define lock_lbt_owner() ({ preempt_disable(); pagefault_disable(); }) 53 52 #define unlock_lbt_owner() ({ pagefault_enable(); preempt_enable(); }) 54 - 55 - struct rt_sigframe { 56 - struct siginfo rs_info; 57 - struct ucontext rs_uctx; 58 - }; 59 53 60 54 struct _ctx_layout { 61 55 struct sctx_info *addr;
+8 -8
arch/loongarch/kvm/intc/eiointc.c
··· 83 83 84 84 if (!(s->status & BIT(EIOINTC_ENABLE_CPU_ENCODE))) { 85 85 cpuid = ffs(cpuid) - 1; 86 - cpuid = (cpuid >= 4) ? 0 : cpuid; 86 + cpuid = ((cpuid < 0) || (cpuid >= 4)) ? 0 : cpuid; 87 87 } 88 88 89 89 vcpu = kvm_get_vcpu_by_cpuid(s->kvm, cpuid); ··· 472 472 switch (addr) { 473 473 case EIOINTC_NODETYPE_START ... EIOINTC_NODETYPE_END: 474 474 offset = (addr - EIOINTC_NODETYPE_START) / 4; 475 - p = s->nodetype + offset * 4; 475 + p = (void *)s->nodetype + offset * 4; 476 476 break; 477 477 case EIOINTC_IPMAP_START ... EIOINTC_IPMAP_END: 478 478 offset = (addr - EIOINTC_IPMAP_START) / 4; 479 - p = &s->ipmap + offset * 4; 479 + p = (void *)&s->ipmap + offset * 4; 480 480 break; 481 481 case EIOINTC_ENABLE_START ... EIOINTC_ENABLE_END: 482 482 offset = (addr - EIOINTC_ENABLE_START) / 4; 483 - p = s->enable + offset * 4; 483 + p = (void *)s->enable + offset * 4; 484 484 break; 485 485 case EIOINTC_BOUNCE_START ... EIOINTC_BOUNCE_END: 486 486 offset = (addr - EIOINTC_BOUNCE_START) / 4; 487 - p = s->bounce + offset * 4; 487 + p = (void *)s->bounce + offset * 4; 488 488 break; 489 489 case EIOINTC_ISR_START ... EIOINTC_ISR_END: 490 490 offset = (addr - EIOINTC_ISR_START) / 4; 491 - p = s->isr + offset * 4; 491 + p = (void *)s->isr + offset * 4; 492 492 break; 493 493 case EIOINTC_COREISR_START ... EIOINTC_COREISR_END: 494 494 if (cpu >= s->num_cpu) 495 495 return -EINVAL; 496 496 497 497 offset = (addr - EIOINTC_COREISR_START) / 4; 498 - p = s->coreisr[cpu] + offset * 4; 498 + p = (void *)s->coreisr[cpu] + offset * 4; 499 499 break; 500 500 case EIOINTC_COREMAP_START ... EIOINTC_COREMAP_END: 501 501 offset = (addr - EIOINTC_COREMAP_START) / 4; 502 - p = s->coremap + offset * 4; 502 + p = (void *)s->coremap + offset * 4; 503 503 break; 504 504 default: 505 505 kvm_err("%s: unknown eiointc register, addr = %d\n", __func__, addr);
+3
arch/loongarch/kvm/vcpu.c
··· 588 588 { 589 589 struct kvm_phyid_map *map; 590 590 591 + if (cpuid < 0) 592 + return NULL; 593 + 591 594 if (cpuid >= KVM_MAX_PHYID) 592 595 return NULL; 593 596
+80
arch/loongarch/pci/pci.c
··· 5 5 #include <linux/kernel.h> 6 6 #include <linux/init.h> 7 7 #include <linux/acpi.h> 8 + #include <linux/delay.h> 8 9 #include <linux/types.h> 9 10 #include <linux/pci.h> 10 11 #include <linux/vgaarb.h> 12 + #include <linux/io-64-nonatomic-lo-hi.h> 11 13 #include <asm/cacheflush.h> 12 14 #include <asm/loongson.h> 13 15 ··· 17 15 #define PCI_DEVICE_ID_LOONGSON_DC1 0x7a06 18 16 #define PCI_DEVICE_ID_LOONGSON_DC2 0x7a36 19 17 #define PCI_DEVICE_ID_LOONGSON_DC3 0x7a46 18 + #define PCI_DEVICE_ID_LOONGSON_GPU1 0x7a15 19 + #define PCI_DEVICE_ID_LOONGSON_GPU2 0x7a25 20 + #define PCI_DEVICE_ID_LOONGSON_GPU3 0x7a35 20 21 21 22 int raw_pci_read(unsigned int domain, unsigned int bus, unsigned int devfn, 22 23 int reg, int len, u32 *val) ··· 104 99 DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_LOONGSON, PCI_DEVICE_ID_LOONGSON_DC1, pci_fixup_vgadev); 105 100 DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_LOONGSON, PCI_DEVICE_ID_LOONGSON_DC2, pci_fixup_vgadev); 106 101 DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_LOONGSON, PCI_DEVICE_ID_LOONGSON_DC3, pci_fixup_vgadev); 102 + 103 + #define CRTC_NUM_MAX 2 104 + #define CRTC_OUTPUT_ENABLE 0x100 105 + 106 + static void loongson_gpu_fixup_dma_hang(struct pci_dev *pdev, bool on) 107 + { 108 + u32 i, val, count, crtc_offset, device; 109 + void __iomem *crtc_reg, *base, *regbase; 110 + static u32 crtc_status[CRTC_NUM_MAX] = { 0 }; 111 + 112 + base = pdev->bus->ops->map_bus(pdev->bus, pdev->devfn + 1, 0); 113 + device = readw(base + PCI_DEVICE_ID); 114 + 115 + regbase = ioremap(readq(base + PCI_BASE_ADDRESS_0) & ~0xffull, SZ_64K); 116 + if (!regbase) { 117 + pci_err(pdev, "Failed to ioremap()\n"); 118 + return; 119 + } 120 + 121 + switch (device) { 122 + case PCI_DEVICE_ID_LOONGSON_DC2: 123 + crtc_reg = regbase + 0x1240; 124 + crtc_offset = 0x10; 125 + break; 126 + case PCI_DEVICE_ID_LOONGSON_DC3: 127 + crtc_reg = regbase; 128 + crtc_offset = 0x400; 129 + break; 130 + } 131 + 132 + for (i = 0; i < CRTC_NUM_MAX; i++, crtc_reg += crtc_offset) { 133 + val = readl(crtc_reg); 134 + 135 + if (!on) 136 + crtc_status[i] = val; 137 + 138 + /* No need to fixup if the status is off at startup. */ 139 + if (!(crtc_status[i] & CRTC_OUTPUT_ENABLE)) 140 + continue; 141 + 142 + if (on) 143 + val |= CRTC_OUTPUT_ENABLE; 144 + else 145 + val &= ~CRTC_OUTPUT_ENABLE; 146 + 147 + mb(); 148 + writel(val, crtc_reg); 149 + 150 + for (count = 0; count < 40; count++) { 151 + val = readl(crtc_reg) & CRTC_OUTPUT_ENABLE; 152 + if ((on && val) || (!on && !val)) 153 + break; 154 + udelay(1000); 155 + } 156 + 157 + pci_info(pdev, "DMA hang fixup at reg[0x%lx]: 0x%x\n", 158 + (unsigned long)crtc_reg & 0xffff, readl(crtc_reg)); 159 + } 160 + 161 + iounmap(regbase); 162 + } 163 + 164 + static void pci_fixup_dma_hang_early(struct pci_dev *pdev) 165 + { 166 + loongson_gpu_fixup_dma_hang(pdev, false); 167 + } 168 + DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_LOONGSON, PCI_DEVICE_ID_LOONGSON_GPU2, pci_fixup_dma_hang_early); 169 + DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_LOONGSON, PCI_DEVICE_ID_LOONGSON_GPU3, pci_fixup_dma_hang_early); 170 + 171 + static void pci_fixup_dma_hang_final(struct pci_dev *pdev) 172 + { 173 + loongson_gpu_fixup_dma_hang(pdev, true); 174 + } 175 + DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_LOONGSON, PCI_DEVICE_ID_LOONGSON_GPU2, pci_fixup_dma_hang_final); 176 + DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_LOONGSON, PCI_DEVICE_ID_LOONGSON_GPU3, pci_fixup_dma_hang_final);
+2 -2
arch/loongarch/vdso/Makefile
··· 26 26 $(filter -W%,$(filter-out -Wa$(comma)%,$(KBUILD_CFLAGS))) \ 27 27 -std=gnu11 -fms-extensions -O2 -g -fno-strict-aliasing -fno-common -fno-builtin \ 28 28 -fno-stack-protector -fno-jump-tables -DDISABLE_BRANCH_PROFILING \ 29 - $(call cc-option, -fno-asynchronous-unwind-tables) \ 29 + $(call cc-option, -fasynchronous-unwind-tables) \ 30 30 $(call cc-option, -fno-stack-protector) 31 31 aflags-vdso := $(ccflags-vdso) \ 32 32 -D__ASSEMBLY__ -Wa,-gdwarf-2 ··· 41 41 42 42 # VDSO linker flags. 43 43 ldflags-y := -Bsymbolic --no-undefined -soname=linux-vdso.so.1 \ 44 - $(filter -E%,$(KBUILD_CFLAGS)) -shared --build-id -T 44 + $(filter -E%,$(KBUILD_CFLAGS)) -shared --build-id --eh-frame-hdr -T 45 45 46 46 # 47 47 # Shared build commands.
+3 -3
arch/loongarch/vdso/sigreturn.S
··· 12 12 13 13 #include <asm/regdef.h> 14 14 #include <asm/asm.h> 15 + #include <asm/asm-offsets.h> 15 16 16 17 .section .text 17 - .cfi_sections .debug_frame 18 18 19 - SYM_FUNC_START(__vdso_rt_sigreturn) 19 + SYM_SIGFUNC_START(__vdso_rt_sigreturn) 20 20 21 21 li.w a7, __NR_rt_sigreturn 22 22 syscall 0 23 23 24 - SYM_FUNC_END(__vdso_rt_sigreturn) 24 + SYM_SIGFUNC_END(__vdso_rt_sigreturn)