From patchwork Wed Jan 8 03:00:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?V2VpamllIEdhbyAo6auY5oOf5p2wKQ==?= X-Patchwork-Id: 1219240 X-Patchwork-Delegate: daniel.schwierzeck@googlemail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=mediatek.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=mediatek.com header.i=@mediatek.com header.b="LkUYe2ce"; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47svCR2D2Rz9sPK for ; Wed, 8 Jan 2020 14:01:19 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 421B4816DA; Wed, 8 Jan 2020 04:01:11 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=mediatek.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=mediatek.com header.i=@mediatek.com header.b="LkUYe2ce"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 0E03E8171F; Wed, 8 Jan 2020 04:01:10 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: * X-Spam-Status: No, score=1.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MIME_BASE64_TEXT,RDNS_NONE,SPF_HELO_NONE, UNPARSEABLE_RELAY,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.2 Received: from mailgw02.mediatek.com (unknown [1.203.163.81]) by phobos.denx.de (Postfix) with ESMTP id 59231803D4 for ; Wed, 8 Jan 2020 04:01:06 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=mediatek.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=weijie.gao@mediatek.com X-UUID: 1a14dd31d21145419a7cd6ca78296b88-20200108 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Transfer-Encoding:Content-Type:MIME-Version:Message-ID:Date:Subject:CC:To:From; bh=jKqSlF9HPyKh4S2UUkbbT1H1iO65WDJGchFMSpkSclU=; b=LkUYe2cejA7r/gAu5yW6dAYH6RjP86FkPOu0s9LORwSu03crzERaiW/T2Z5jTePSS/4cyJSd0MlodsTCfAXKONhLaLyzQ5I+/xofR3LZWywjodOE4/GG6iprR+pm7VKGdeueyZ8LG1wFxu9txs5HfVC7K1m3xNKBvWuBZ5wuhUo=; X-UUID: 1a14dd31d21145419a7cd6ca78296b88-20200108 Received: from mtkcas32.mediatek.inc [(172.27.4.253)] by mailgw02.mediatek.com (envelope-from ) (mailgw01.mediatek.com ESMTP with TLS) with ESMTP id 1301056907; Wed, 08 Jan 2020 11:01:01 +0800 Received: from MTKCAS32.mediatek.inc (172.27.4.184) by MTKMBS31N1.mediatek.inc (172.27.4.69) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Wed, 8 Jan 2020 11:00:23 +0800 Received: from mcddlt001.mediatek.inc (10.19.240.15) by MTKCAS32.mediatek.inc (172.27.4.170) with Microsoft SMTP Server id 15.0.1395.4 via Frontend Transport; Wed, 8 Jan 2020 11:01:17 +0800 From: Weijie Gao To: Subject: [PATCH 02/16] mips: add support to restore exception vector base before booting linux Date: Wed, 8 Jan 2020 11:00:55 +0800 Message-ID: <1578452455-6761-1-git-send-email-weijie.gao@mediatek.com> X-Mailer: git-send-email 1.9.1 MIME-Version: 1.0 X-TM-SNTS-SMTP: A76741C7D63CAD0C036D935580856DDBFD1D73182018DAEF9B07AFFF6B27F4242000:8 X-MTK: N X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.26 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Stefan Roese , Stefan Roese , GSS_MTK_Uboot_upstream Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.101.4 at phobos.denx.de X-Virus-Status: Clean In U-Boot the exception vector base will be moved to top of memory, to be used to display register dump when exception occurs. But some old linux kernel does not honor the base set in CP0_EBASE. A modified exception vector base will cause kernel crash. This patch adds an option to enable reset exception vector base to 0x80000000 before booting linux kernel. Signed-off-by: Weijie Gao --- arch/mips/Kconfig | 13 +++++++++++++ arch/mips/lib/bootm.c | 9 +++++++++ 2 files changed, 22 insertions(+) diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig index a3ae603044..4688717593 100644 --- a/arch/mips/Kconfig +++ b/arch/mips/Kconfig @@ -287,6 +287,19 @@ config MIPS_RELOCATION_TABLE_SIZE If unsure, leave at the default value. +config RESTORE_EXCEPTION_VECTOR_BASE + bool "Restore exception vector base before booting linux kernel" + default n + help + In U-Boot the exception vector base will be moved to top of memory, + to be used to display register dump when exception occurs. + But some old linux kernel does not honor the base set in CP0_EBASE. + A modified exception vector base will cause kernel crash. + + This option will set exception vector base to 0x80000000. + + If unsure, say N. + endmenu menu "OS boot interface" diff --git a/arch/mips/lib/bootm.c b/arch/mips/lib/bootm.c index 8c0d7672f2..86ea082fd0 100644 --- a/arch/mips/lib/bootm.c +++ b/arch/mips/lib/bootm.c @@ -294,6 +294,15 @@ static void boot_jump_linux(bootm_headers_t *images) bootstage_report(); #endif +#ifdef CONFIG_RESTORE_EXCEPTION_VECTOR_BASE + /* Restore EBASE for compatibility */ + set_c0_status(ST0_BEV); + execution_hazard_barrier(); + write_c0_ebase(KSEG0); + clear_c0_status(ST0_BEV); + execution_hazard_barrier(); +#endif + if (images->ft_len) kernel(-2, (ulong)images->ft_addr, 0, 0); else