Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp1994152ybb; Sun, 29 Mar 2020 19:23:03 -0700 (PDT) X-Google-Smtp-Source: ADFU+vvNTuAHh7iKnS94CL5XuefsMSRcc2I90I1Aldwt1kTri8+8mh0G1ojpB1JC+kvQMTng4mYe X-Received: by 2002:a05:6830:18f4:: with SMTP id d20mr7727130otf.91.1585534983405; Sun, 29 Mar 2020 19:23:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585534983; cv=none; d=google.com; s=arc-20160816; b=o7egkmINv5JVZbrlYUEi3Dzz7KEwmAik/N4j+5uoUGQrzPT50aOuIpuBVtGXtBYY3p CNa/20hhuAOeI4Q8XuFrLJ/FiDUrudwSTRIRVwi09N1RMAMsEWtj5Wq+tYwam1xscUiv 2j8aHF4zJPzlswSw1DYFgo/rTIXp/XVSOIXQr1kABhj645RHTy9IEtZBUHOaW5Wf6non qIfAZYbwCZzAy06k02kNwMb7JlL9HsoYAYJxy2O8av8X4vr0gdEIt4yIafHGeEwoPkvG tmbJ9FsQoux1w+OERXCLKJyom3BIQQew2rsob/OsGK6k2v0mpbew79QcyPS5k4CNYCSb NfWg== 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=OcbPLDDjp8p9/0k5qe+0VUCh+ODOV044h7nOajF/bWU=; b=x03TMpZsvuJenUp7IT6xxbCBcrGD2ccnR298sYhxKnovHdfp20R1A4OY8T0BIwtk8m RE+xX5yY8ii03c55R36o7OWAw4gkgRkb+j4dDeJ9OBi5qm42saJoKMhokIbqUjbBmLvo VrlK2N1Fw1Oth6gATE1KashdBvF5I10b9WstdaKpualkjq6gqSaCu61K7SUmKCScq2x0 MBiJFsg0xlejTTj/Dw/A/YviZbU8npoOYPgL9deuMgyWqFqldQBKHJ8L/oqpG943VVha 5QSWZCD9TwGIvNBpTUG1NYQRQqAn5TGfXjDQmVKrGg21vuIp9cxQSK+u4rCQUnB2ULtm FH7g== 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 n10si2581718otk.171.2020.03.29.19.22.51; Sun, 29 Mar 2020 19:23:03 -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 S1728490AbgC3CWb (ORCPT + 99 others); Sun, 29 Mar 2020 22:22:31 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:37812 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728056AbgC3CWb (ORCPT ); Sun, 29 Mar 2020 22:22:31 -0400 Received: from DGGEMS411-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 74D964324CAF6412B92F; Mon, 30 Mar 2020 10:22:28 +0800 (CST) Received: from huawei.com (10.175.124.28) by DGGEMS411-HUB.china.huawei.com (10.3.19.211) with Microsoft SMTP Server id 14.3.487.0; Mon, 30 Mar 2020 10:22:21 +0800 From: Jason Yan To: , , , , , , , , , CC: , , , Jason Yan Subject: [PATCH v5 2/6] powerpc/fsl_booke/64: introduce reloc_kernel_entry() helper Date: Mon, 30 Mar 2020 10:20:19 +0800 Message-ID: <20200330022023.3691-3-yanaijie@huawei.com> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20200330022023.3691-1-yanaijie@huawei.com> References: <20200330022023.3691-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 Like the 32bit code, we introduce reloc_kernel_entry() helper to prepare for the KASLR 64bit version. And move the C declaration of this function out of CONFIG_PPC32 and use long instead of int for the parameter 'addr'. Signed-off-by: Jason Yan Cc: Scott Wood 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/exceptions-64e.S | 13 +++++++++++++ arch/powerpc/mm/mmu_decl.h | 3 ++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/arch/powerpc/kernel/exceptions-64e.S b/arch/powerpc/kernel/exceptions-64e.S index e4076e3c072d..1b9b174bee86 100644 --- a/arch/powerpc/kernel/exceptions-64e.S +++ b/arch/powerpc/kernel/exceptions-64e.S @@ -1679,3 +1679,16 @@ _GLOBAL(setup_ehv_ivors) _GLOBAL(setup_lrat_ivor) SET_IVOR(42, 0x340) /* LRAT Error */ 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 diff --git a/arch/powerpc/mm/mmu_decl.h b/arch/powerpc/mm/mmu_decl.h index 7097e07a209a..605129b5ccdf 100644 --- a/arch/powerpc/mm/mmu_decl.h +++ b/arch/powerpc/mm/mmu_decl.h @@ -140,9 +140,10 @@ 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_kaslr_tlb_entry(int entry, unsigned long virt, phys_addr_t phys); -void reloc_kernel_entry(void *fdt, int addr); extern int is_second_reloc; #endif + +void reloc_kernel_entry(void *fdt, long addr); extern void loadcam_entry(unsigned int index); extern void loadcam_multi(int first_idx, int num, int tmp_idx); -- 2.17.2