Received: by 2002:a25:b794:0:0:0:0:0 with SMTP id n20csp5060729ybh; Tue, 6 Aug 2019 23:41:48 -0700 (PDT) X-Google-Smtp-Source: APXvYqxiMFrIOUIHDF/rSPAGFe2CGrGr1TXbAmyBAnQsDFM2IXRlwrHdluidZe+j8uSTwPNyGGH3 X-Received: by 2002:a62:ae02:: with SMTP id q2mr7603370pff.1.1565160108658; Tue, 06 Aug 2019 23:41:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565160108; cv=none; d=google.com; s=arc-20160816; b=dUFU5d51/TJkoGD1OQTh00b41RYgczdPjocKRWma2d8RSrbn4np6IXbSBs8x+D4DhL 2Np4MisnsGRs1oHd65IEgWr1Moe1B1Sl4iR2hO3GYaEr/WmHniuZaNFOX8pdZAq2sHiS vsZ4QxigJ2M+OH7bcuPhuzS3jlGaTssCYTywqWmD+qWwZ5gmrYgX6yHaMk6psIX0t3H0 caOXTkNYGIza9DJYZqc8JupV0C5aF8YH5fZP1EfnO3NlM37DRPBBs4ChgXn7jA2r6031 wp++VOA8w3+FMyamy4zY1ouf1nSfnNCuDAsR2i3SlZ2g6+vgYYGoqNKoT/SpzK2RItCi 41Bg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=nR7hTLXJf0wLSNA5BsWZ69ImkXoz6fISrhlJchcwV3U=; b=MJe4Vx96bDLLyGykB0ZhEl3/twu7NCC+VDrB1WU1dBsp4TtaSO0arnOQYRuPtgnHyL DL3+2B9um1/7bmlK7MeJweiw9IdXsI4iV26bw7Ejc9u81r3EYoZfNkpIy85KsdPXkqqz XvsmCOxCMPmZ++ydv3fJOu35zHeFQOEoJwC633IA7BtExQvAV7UfujTaD2CAL23buPuU 31ypJ1hUzFxs5YQ+LI2IQwuwrHxKrET6SNJERsgzZJBq0H5AJzzPYote+uMRNlAYWc9U EkPRmRCcgzwIeZTmDg1pvePE1PWZ8ZC2OwvX4pFKJUv0GuYF9hx6yW4zXTKg8+o7NRUl VHeA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z12si48183000pgp.342.2019.08.06.23.41.33; Tue, 06 Aug 2019 23:41:48 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727839AbfHGGkf (ORCPT + 99 others); Wed, 7 Aug 2019 02:40:35 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:3772 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727308AbfHGGkK (ORCPT ); Wed, 7 Aug 2019 02:40:10 -0400 Received: from DGGEMS412-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 0DA08C934C20C18C1B1B; Wed, 7 Aug 2019 14:40:08 +0800 (CST) Received: from huawei.com (10.175.124.28) by DGGEMS412-HUB.china.huawei.com (10.3.19.212) with Microsoft SMTP Server id 14.3.439.0; Wed, 7 Aug 2019 14:39:59 +0800 From: Jason Yan To: , , , , , , , , CC: , , , , , , , Jason Yan Subject: [PATCH v5 05/10] powerpc/fsl_booke/32: introduce reloc_kernel_entry() helper Date: Wed, 7 Aug 2019 14:57:01 +0800 Message-ID: <20190807065706.11411-6-yanaijie@huawei.com> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190807065706.11411-1-yanaijie@huawei.com> References: <20190807065706.11411-1-yanaijie@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.175.124.28] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add a new helper reloc_kernel_entry() to jump back to the start of the new kernel. After we put the new kernel in a randomized place we can use this new helper to enter the kernel and begin to relocate again. Signed-off-by: Jason Yan Cc: Diana Craciun Cc: Michael Ellerman Cc: Christophe Leroy Cc: Benjamin Herrenschmidt Cc: Paul Mackerras Cc: Nicholas Piggin Cc: Kees Cook Reviewed-by: Christophe Leroy Reviewed-by: Diana Craciun Tested-by: Diana Craciun --- arch/powerpc/kernel/head_fsl_booke.S | 13 +++++++++++++ arch/powerpc/mm/mmu_decl.h | 1 + 2 files changed, 14 insertions(+) diff --git a/arch/powerpc/kernel/head_fsl_booke.S b/arch/powerpc/kernel/head_fsl_booke.S index 04d124fee17d..2083382dd662 100644 --- a/arch/powerpc/kernel/head_fsl_booke.S +++ b/arch/powerpc/kernel/head_fsl_booke.S @@ -1143,6 +1143,19 @@ _GLOBAL(create_tlb_entry) sync blr +/* + * Return to the start of the relocated kernel and run again + * r3 - virtual address of fdt + * r4 - entry of the kernel + */ +_GLOBAL(reloc_kernel_entry) + mfmsr r7 + rlwinm r7, r7, 0, ~(MSR_IS | MSR_DS) + + mtspr SPRN_SRR0,r4 + mtspr SPRN_SRR1,r7 + rfi + /* * Create a tlb entry with the same effective and physical address as * the tlb entry used by the current running code. But set the TS to 1. diff --git a/arch/powerpc/mm/mmu_decl.h b/arch/powerpc/mm/mmu_decl.h index a09f89d3aa0f..804da298beb3 100644 --- a/arch/powerpc/mm/mmu_decl.h +++ b/arch/powerpc/mm/mmu_decl.h @@ -143,6 +143,7 @@ extern void adjust_total_lowmem(void); extern int switch_to_as1(void); extern void restore_to_as0(int esel, int offset, void *dt_ptr, int bootcpu); void create_tlb_entry(phys_addr_t phys, unsigned long virt, int entry); +void reloc_kernel_entry(void *fdt, int addr); #endif extern void loadcam_entry(unsigned int index); extern void loadcam_multi(int first_idx, int num, int tmp_idx); -- 2.17.2