Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp83053ybl; Fri, 9 Aug 2019 02:53:55 -0700 (PDT) X-Google-Smtp-Source: APXvYqx2bhL8qMAC0DvorwVndOmEdAzyqz6c8KPlT01fVpLv+/5pzKHG8o9SdkOBLspziaTA/SUw X-Received: by 2002:a17:90a:ff17:: with SMTP id ce23mr8523126pjb.47.1565344435372; Fri, 09 Aug 2019 02:53:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565344435; cv=none; d=google.com; s=arc-20160816; b=teS2ql3RPcsJUqbyg6S5lH00C4AhDRIT7PHIvbeotsB+TVcuA/4kgzu5Lgq14jcjeI XwgLCySBtFCB5Z6AcpY+3ciQk3SoD3wvoxFYkJIs5QWHmdee1n9HRdTW/IW0WuNi629B zmOh/jq4UrSVcPERZwOfcBGt5Op36e7Bd+TqZPV+/npGSAi/uQVdwxcbHkpa1tZEUWPG k5z7CF4MSD+BvhQ/wnuczLEIS4dPywJ8qhaudpJ0RWjShRK/7pxuK/D5AUPa/vnbHePO Z1giiccAx26+b2XkT28/Bf5Q+m1FFhNDvDjlEgMFfwET845Wh4Ed0EiFUwKJApe8kdvv +Rjg== 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=C61SvJEnVCWjRPRaY1uR7KmmzyvqKEoTCdho39BYaXaXIbbxaPVB56B1dBs8bSVQMB B0XFXKBKhcQn3hPS9kfLAb8GhWnA14Jsf4h+sB7qqvhKTTVWeHvLCWKlZ9uvEsxYQPQP kYa9xQM2QS80yfhytHJGEX6IxO9LSzIFvZXF3VmQe1tEMQ+XYg+iAIwcYUQbhsgLdhU4 4zhWFJ/ythixfQNvu7+QpG4K0c6N9cEWWdKwZn4hE+UnuUhp0z8nnKZGeCWQ6NvDQ4ge cHAxUrJl69+Vy4APWL88L4MJ89pKj4GJddoQ5w2HeUaFq48WpH+k+PmZb0rIAFIgFhRn 7OTQ== 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 5si7094710plx.417.2019.08.09.02.53.39; Fri, 09 Aug 2019 02:53:55 -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 S2406233AbfHIJwG (ORCPT + 99 others); Fri, 9 Aug 2019 05:52:06 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:4224 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2406125AbfHIJwF (ORCPT ); Fri, 9 Aug 2019 05:52:05 -0400 Received: from DGGEMS403-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 272EB2ECE5F4466CC0EA; Fri, 9 Aug 2019 17:52:03 +0800 (CST) Received: from huawei.com (10.175.124.28) by DGGEMS403-HUB.china.huawei.com (10.3.19.203) with Microsoft SMTP Server id 14.3.439.0; Fri, 9 Aug 2019 17:51:53 +0800 From: Jason Yan To: , , , , , , , , CC: , , , , , , , Jason Yan Subject: [PATCH v6 05/12] powerpc/fsl_booke/32: introduce reloc_kernel_entry() helper Date: Fri, 9 Aug 2019 18:07:53 +0800 Message-ID: <20190809100800.5426-6-yanaijie@huawei.com> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190809100800.5426-1-yanaijie@huawei.com> References: <20190809100800.5426-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