Commit 055c7e75 authored by Tiezhu Yang's avatar Tiezhu Yang Committed by Huacai Chen
Browse files

LoongArch: Handle percpu handler address for ORC unwinder



After commit 4cd641a7 ("LoongArch: Remove unnecessary checks for ORC
unwinder"), the system can not boot normally under some configs (such as
enable KASAN), there are many error messages "cannot find unwind pc".

The kernel boots normally with the defconfig, so no problem found out at
the first time. Here is one way to reproduce:

  cd linux
  make mrproper defconfig -j"$(nproc)"
  scripts/config -e KASAN
  make olddefconfig all -j"$(nproc)"
  sudo make modules_install
  sudo make install
  sudo reboot

The address that can not unwind is not a valid kernel address which is
between "pcpu_handlers[cpu]" and "pcpu_handlers[cpu] + vec_sz" due to
the code of eentry was copied to the new area of pcpu_handlers[cpu] in
setup_tlb_handler(), handle this special case to get the valid address
to unwind normally.

Cc: stable@vger.kernel.org
Signed-off-by: default avatarTiezhu Yang <yangtiezhu@loongson.cn>
Signed-off-by: default avatarHuacai Chen <chenhuacai@loongson.cn>
parent 77403a06
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -7,6 +7,7 @@
#define _LOONGARCH_SETUP_H

#include <linux/types.h>
#include <linux/threads.h>
#include <asm/sections.h>
#include <uapi/asm/setup.h>

@@ -14,6 +15,8 @@

extern unsigned long eentry;
extern unsigned long tlbrentry;
extern unsigned long pcpu_handlers[NR_CPUS];
extern long exception_handlers[VECSIZE * 128 / sizeof(long)];
extern char init_command_line[COMMAND_LINE_SIZE];
extern void tlb_init(int cpu);
extern void cpu_cache_init(void);
+16 −0
Original line number Diff line number Diff line
@@ -352,6 +352,22 @@ static inline unsigned long bt_address(unsigned long ra)
{
	extern unsigned long eentry;

#if defined(CONFIG_NUMA) && !defined(CONFIG_PREEMPT_RT)
	int cpu;
	int vec_sz = sizeof(exception_handlers);

	for_each_possible_cpu(cpu) {
		if (!pcpu_handlers[cpu])
			continue;

		if (ra >= pcpu_handlers[cpu] &&
		    ra < pcpu_handlers[cpu] + vec_sz) {
			ra = ra + eentry - pcpu_handlers[cpu];
			break;
		}
	}
#endif

	if (ra >= eentry && ra < eentry +  EXCCODE_INT_END * VECSIZE) {
		unsigned long func;
		unsigned long type = (ra - eentry) / VECSIZE;