Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp5731801ybi; Wed, 31 Jul 2019 02:27:23 -0700 (PDT) X-Google-Smtp-Source: APXvYqwEJKtZHXbTd18evwyaa8YR5fiCdYDF4LJdE+wOoKKv3WJpuf5oOWfznQtO7Gi1FM/fSSxa X-Received: by 2002:a63:c23:: with SMTP id b35mr79083554pgl.265.1564565243318; Wed, 31 Jul 2019 02:27:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564565243; cv=none; d=google.com; s=arc-20160816; b=Lr+s6+r9Rzu04Tmdj8nAR1Evsp/WNDy/sU/0u4r9AzubY8wpxFN8A7tm/LFsuBKLyd uAk+wGomLkVXEvGXLU5vLN2hz8a3wFHz0mJUDCVjK+oyhUQYkuS5K7qucx+4kw3etKZi 8LU2Nd3XhhTepho0Z91EvEf7tjPAV6lXA7yXW8Q4fMHhnHEHAG+a8SSXbcFyOGB9Q9eD J8jYNUR1Woh8Mvr7zdGucQxjOJATiERG0yDCRJLBX/V2wbck57uE56tAiRPiIjr3mcLC VjYvvpU2WEGD6OESkv/SdAHGUGBueLYqfsbmRPA4seVJLRFZOpT+wsACW5CXyWKyQ6Gx c++g== 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=qMDv+ArD7DlnjZEWE5RrJ9vZLbJ9tGy3guT/UxE0s1I=; b=U5Gt8pM8S2TjcJcTMygn5VoQiiNQB27cP43tCCrnlxh0sGdgNxUiLY/osGDQFF3DEb qdjqaFj7/Uw8b+kFxiko6TxREYncfR75fs9XsMw7vwdugAu+wGQ4SdmXbhX2yW3Hl+td L2lwQN6blEnd37vKhVYuxvMcQ8iK61qlpX2Lu2CYqAwgsK+iSRHTi06yuXXGQZ8Y+tKR G8Mg2tQbLiCwwiRGJhjd2TDhGGoF34IcdMSoKGNxVsld2rcR1Rxp7iMczWgRX0re5NIf uVzvj+p5xZDf545LyoyhOobq5waPg3VC8TPI26tkb0u2rtwObI5A6Ly266ioWUst/6di Imlw== 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 u15si33274409pgn.178.2019.07.31.02.27.07; Wed, 31 Jul 2019 02:27:23 -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 S1728748AbfGaJ00 (ORCPT + 99 others); Wed, 31 Jul 2019 05:26:26 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:42438 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2387464AbfGaJ0Y (ORCPT ); Wed, 31 Jul 2019 05:26:24 -0400 Received: from DGGEMS405-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 79E502E14D9CF9EC46E7; Wed, 31 Jul 2019 17:26:23 +0800 (CST) Received: from huawei.com (10.175.124.28) by DGGEMS405-HUB.china.huawei.com (10.3.19.205) with Microsoft SMTP Server id 14.3.439.0; Wed, 31 Jul 2019 17:26:13 +0800 From: Jason Yan To: , , , , , , , , CC: , , , , , , , Jason Yan Subject: [PATCH v3 05/10] powerpc/fsl_booke/32: introduce reloc_kernel_entry() helper Date: Wed, 31 Jul 2019 17:43:13 +0800 Message-ID: <20190731094318.26538-6-yanaijie@huawei.com> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190731094318.26538-1-yanaijie@huawei.com> References: <20190731094318.26538-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 --- 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