Commit 25664756 authored by Jing Li's avatar Jing Li Committed by guzitao
Browse files

sw64: fix kernel crash caused by unaligned access exception

Sunway inclusion
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/IBDJNZ



--------------------------------

If ACPI enabled, unaligned access occurs when parsing ACPI tables in
function acpi_boot_table_init(). since SW64 does not support handling
unaligned access exception via hardware, the related trap entry should
be initialized first.

A feasible solution for this issue is that BIOS register the trap entry
and make it as a runtime service. But this solution causes the kernel to
have an ugly dependence on BIOS. To address this issue within the
kernel, this commit invoke trap_init() at the beginning of setup_arch().

BTW, there is a redundant call to the function trap_init() for the
bootstrap core, which may be deprecated some day.

Signed-off-by: default avatarJing Li <jingli@wxiat.com>
Reviewed-by: default avatarHe Sheng <hesheng@wxiat.com>
Signed-off-by: default avatarGu Zitao <guzitao@wxiat.com>
parent 1bc99f56
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@
#include <linux/of_platform.h>
#include <linux/genalloc.h>
#include <linux/acpi.h>
#include <linux/cpu.h>

#include <asm/efi.h>
#include <asm/kvm_cma.h>
@@ -764,6 +765,12 @@ void __init sw64_kvm_reserve(void)
void __init
setup_arch(char **cmdline_p)
{
	/**
	 * Work around the unaligned access exception to parse ACPI
	 * tables in the following function acpi_boot_table_init().
	 */
	trap_init();

	jump_label_init();
	setup_cpu_info();
	setup_run_mode();