Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp4750997ybi; Tue, 30 Jul 2019 07:31:39 -0700 (PDT) X-Google-Smtp-Source: APXvYqyghJprIsE20dFQN7BR7o/vhLu/LvOMFAWGtHec2/SKJvCLz8s3lYXNZXvCjkxFpir5ymlN X-Received: by 2002:a63:6056:: with SMTP id u83mr104801692pgb.181.1564497098504; Tue, 30 Jul 2019 07:31:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564497098; cv=none; d=google.com; s=arc-20160816; b=xAE46qAiX93FeyZBYrWiNX43YzEdy+NtPeU2x/1p2sWYJjqrCw6KDIGpndhae2/bOX M+BkE5serCrID+HPj8jeAIsfTX/8dNpFcRdjGzPlAyywvm5LUCOZzO2eo+PEc5u8CNTi 5wJGQG8g4OLHK82lRfCvSY4E9rHvw8EQj3nWRHp4j0ECGzLpqQxZZfEOIrV2RhLC6Edy 2gdvUkG8w0wv27yybs2e4JK7tqGcNlmRxdWDvLDmaqG0AYKn4p0cHlhfHVgNcdryODa+ I2Bw4/B/pwMuZ0j3mCMfK2qn8VrP4dJxpr/ns67ydxGhgbd0lTwfUHPXJWQDMeD0NbSX BLxQ== 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=j0RQRk5ZtsknLZE83Ak+6j67Go1MKzLcNwMdYBK1SKA=; b=stmdtpR4kAzgUO2OpjIYp52n+FYyMiGZnTsfa+0JFGlwZow5JM/oo7Z+eHQtdZ5dcF 7nmKMZAmmpWiNEbW8+M8GIGx7UJpwpdX7uaIZTvhIrllFizVeHLTppZjs2puWCHpfwt6 FO6PUEE8MD6MuBB617fmf/R4+Vvk6iDNBW9hY9kVjr8/xz7RI1RUtUkzbxiAHwnV9XEd B3p0wF2fvRHyq91krbrxMtxiDqQTLfdBLkWhd8f86BYuFXLNq7PeT7S1DuCkkv2lY7Ai yfjYJ3wuFg/6JNR/rFOnJVuAB7Hq3pLN2tBzlwaKVtMVRWX3LlxvkYmgC5Fql3x79P86 y47w== 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 u3si29236699pgb.317.2019.07.30.07.31.23; Tue, 30 Jul 2019 07:31:38 -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 S1730293AbfG3H0M (ORCPT + 99 others); Tue, 30 Jul 2019 03:26:12 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:3212 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729740AbfG3HZi (ORCPT ); Tue, 30 Jul 2019 03:25:38 -0400 Received: from DGGEMS413-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 0EAB7D7E48C26E614D4E; Tue, 30 Jul 2019 15:25:35 +0800 (CST) Received: from huawei.com (10.175.124.28) by DGGEMS413-HUB.china.huawei.com (10.3.19.213) with Microsoft SMTP Server id 14.3.439.0; Tue, 30 Jul 2019 15:25:26 +0800 From: Jason Yan To: , , , , , , , , CC: , , , , , , , Jason Yan Subject: [PATCH v2 05/10] powerpc/fsl_booke/32: introduce reloc_kernel_entry() helper Date: Tue, 30 Jul 2019 15:42:20 +0800 Message-ID: <20190730074225.39544-6-yanaijie@huawei.com> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190730074225.39544-1-yanaijie@huawei.com> References: <20190730074225.39544-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 --- 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