Received: by 2002:a25:b794:0:0:0:0:0 with SMTP id n20csp2358341ybh; Sun, 4 Aug 2019 23:28:31 -0700 (PDT) X-Google-Smtp-Source: APXvYqwilGyURDUBuj+UFecswTpBsW0HPHfZZDbgykJ9SHyRkziyLw4+pipRpxB7uUTKj4Ouv97n X-Received: by 2002:a62:ce07:: with SMTP id y7mr68908925pfg.12.1564986511574; Sun, 04 Aug 2019 23:28:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564986511; cv=none; d=google.com; s=arc-20160816; b=YjWVPup6cdMqX+pkPaiFIcgR2ZaZPAeGXO7y9MOZiMKpOKcMQpJzYABR1uxZl9Uw7m 4e8u0jGOXK5hQCcR8wJGiC5O1CIkoPft4XFg+z70hK1PW9MYy4cJvGzbcVcZh8EsnT6+ CGRVmpaHQBU8APljqZirZ9Zq7DUY3TsIhy/lCCYPMtWzRZ9qB2+2fnsptFqVZg0pCHYR TlCUAGk4hrASpl2zIqsU6xhAblARnSmI8Uks1W/RlvnZc4ZDPPdMkX3MJkOyqfX4NhUy 2OmgQdD9OXcfxuastXdV0i7++ijQ8v0vbXVKUAs2DPVqVRkY6QgFBd7K/0UrHEIIYLVj hkyA== 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=Qm+VQGdYUDjpMHxS94HIvJcWIhkjfMWt4xLaxV+sa41NUR6oRG8r1JxlasxjPMyr4M 6qxsUIu5LU4srdb5ZzkbQA5kPURd4r5U6CMbIo//JTws6R9O2WRYEUhblHmfysyUmNYu t0rQB68Ugd8qeqV+88012RWijqYstixHRT5nqO6XQJzRsPSgOuUHAI5Qcg2SIws5jIO5 OzKEXY+Tw0Me+vucel/J1oLZX3zMcCggel2bMLfrFs+jMSpjYlQq9otjKW/6yoISSaBf /5iXvvno42ztKbD/LwMNTwCqaZcaWgAmgmzxlp59xgk5mNzkz6mO8Ok1hP9WS4MqKFR1 kSrA== 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 a33si44534914pgl.436.2019.08.04.23.28.16; Sun, 04 Aug 2019 23:28:31 -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 S1727447AbfHEG0p (ORCPT + 99 others); Mon, 5 Aug 2019 02:26:45 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:42452 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727328AbfHEG0i (ORCPT ); Mon, 5 Aug 2019 02:26:38 -0400 Received: from DGGEMS414-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 356A26152D7CDC293207; Mon, 5 Aug 2019 14:26:37 +0800 (CST) Received: from huawei.com (10.175.124.28) by DGGEMS414-HUB.china.huawei.com (10.3.19.214) with Microsoft SMTP Server id 14.3.439.0; Mon, 5 Aug 2019 14:26:30 +0800 From: Jason Yan To: , , , , , , , , CC: , , , , , , , Jason Yan Subject: [PATCH v4 05/10] powerpc/fsl_booke/32: introduce reloc_kernel_entry() helper Date: Mon, 5 Aug 2019 14:43:30 +0800 Message-ID: <20190805064335.19156-6-yanaijie@huawei.com> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190805064335.19156-1-yanaijie@huawei.com> References: <20190805064335.19156-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