Commit a361474b authored by Linus Torvalds's avatar Linus Torvalds
Browse files

Merge tag 'loongarch-fixes-7.0-2' of...

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()
parents 196ef74a 6bcfb7f4
Loading
Loading
Loading
Loading
+36 −0
Original line number Diff line number Diff line
@@ -41,4 +41,40 @@
	.cfi_endproc;					\
	SYM_END(name, SYM_T_NONE)

/*
 * This is for the signal handler trampoline, which is used as the return
 * address of the signal handlers in userspace instead of called normally.
 * The long standing libgcc bug https://gcc.gnu.org/PR124050 requires a
 * nop between .cfi_startproc and the actual address of the trampoline, so
 * we cannot simply use SYM_FUNC_START.
 *
 * This wrapper also contains all the .cfi_* directives for recovering
 * the content of the GPRs and the "return address" (where the rt_sigreturn
 * syscall will jump to), assuming there is a struct rt_sigframe (where
 * a struct sigcontext containing those information we need to recover) at
 * $sp.  The "DWARF for the LoongArch(TM) Architecture" manual states
 * column 0 is for $zero, but it does not make too much sense to
 * save/restore the hardware zero register.  Repurpose this column here
 * for the return address (here it's not the content of $ra we cannot use
 * the default column 3).
 */
#define SYM_SIGFUNC_START(name)				\
	.cfi_startproc;					\
	.cfi_signal_frame;				\
	.cfi_def_cfa 3, RT_SIGFRAME_SC;			\
	.cfi_return_column 0;				\
	.cfi_offset 0, SC_PC;				\
							\
	.irp num, 1,  2,  3,  4,  5,  6,  7,  8, 	\
		  9,  10, 11, 12, 13, 14, 15, 16,	\
		  17, 18, 19, 20, 21, 22, 23, 24,	\
		  25, 26, 27, 28, 29, 30, 31;		\
	.cfi_offset \num, SC_REGS + \num * SZREG;	\
	.endr;						\
							\
	nop;						\
	SYM_START(name, SYM_L_GLOBAL, SYM_A_ALIGN)

#define SYM_SIGFUNC_END(name) SYM_FUNC_END(name)

#endif
+9 −0
Original line number Diff line number Diff line
/* SPDX-License-Identifier: GPL-2.0+ */

#include <asm/siginfo.h>
#include <asm/ucontext.h>

struct rt_sigframe {
	struct siginfo rs_info;
	struct ucontext rs_uctx;
};
+2 −0
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@
#include <asm/ptrace.h>
#include <asm/processor.h>
#include <asm/ftrace.h>
#include <asm/sigframe.h>
#include <vdso/datapage.h>

static void __used output_ptreg_defines(void)
@@ -220,6 +221,7 @@ static void __used output_sc_defines(void)
	COMMENT("Linux sigcontext offsets.");
	OFFSET(SC_REGS, sigcontext, sc_regs);
	OFFSET(SC_PC, sigcontext, sc_pc);
	OFFSET(RT_SIGFRAME_SC, rt_sigframe, rs_uctx.uc_mcontext);
	BLANK();
}

+3 −4
Original line number Diff line number Diff line
@@ -42,16 +42,15 @@ static int __init init_cpu_fullname(void)
	int cpu, ret;
	char *cpuname;
	const char *model;
	struct device_node *root;

	/* Parsing cpuname from DTS model property */
	root = of_find_node_by_path("/");
	ret = of_property_read_string(root, "model", &model);
	ret = of_property_read_string(of_root, "model", &model);
	if (ret == 0) {
		cpuname = kstrdup(model, GFP_KERNEL);
		if (!cpuname)
			return -ENOMEM;
		loongson_sysconf.cpuname = strsep(&cpuname, " ");
	}
	of_node_put(root);

	if (loongson_sysconf.cpuname && !strncmp(loongson_sysconf.cpuname, "Loongson", 8)) {
		for (cpu = 0; cpu < NR_CPUS; cpu++)
+1 −5
Original line number Diff line number Diff line
@@ -35,6 +35,7 @@
#include <asm/cpu-features.h>
#include <asm/fpu.h>
#include <asm/lbt.h>
#include <asm/sigframe.h>
#include <asm/ucontext.h>
#include <asm/vdso.h>

@@ -51,11 +52,6 @@
#define lock_lbt_owner()	({ preempt_disable(); pagefault_disable(); })
#define unlock_lbt_owner()	({ pagefault_enable(); preempt_enable(); })

struct rt_sigframe {
	struct siginfo rs_info;
	struct ucontext rs_uctx;
};

struct _ctx_layout {
	struct sctx_info *addr;
	unsigned int size;
Loading