Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp534772ybi; Wed, 17 Jul 2019 00:50:55 -0700 (PDT) X-Google-Smtp-Source: APXvYqxUijF3EPS4da/J1ac3tlUMEeKrK3Vx9yx3nj9Jboc/I0YtTGm0FtmsFEeqvBFu8YHjremP X-Received: by 2002:a65:6401:: with SMTP id a1mr39654660pgv.42.1563349855740; Wed, 17 Jul 2019 00:50:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563349855; cv=none; d=google.com; s=arc-20160816; b=Bd3TTFnrhT8pG/dqLYzXt1uFfSF5P6G6uosyRx53PmG/9MYqTe84Y6uE5GsGxktc4Q 3Cw+iV3Fe3DFCCJRSpPDEyRrxeIR20+u6b1B/jTKMFm9M6+3jF0a55FE0GzF1OpUxtmO tNZClYWc0SQ3aWIbfqdpUIF3dwgUMzzMkTeqkB3RH3pSr5UUuii06GGYpSf7FkCR8EYz V2dEZG0ZOrxlGhoH0dv2VORiytYR42fEvYsS1XvO6Rv9ntBz/HSn1J9gIn4+A1Q9Wfi2 PR1Efh3JyYCDzzS68oKXBqgmVuIO8Tu+3m7dqdrEy4tHDMajx8bL78hWJfuOPrR2VRzv VAQQ== 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=c4DIacV7AGkKouUB4qSQvfqWbJTQi2mSR98Hk7Gcayc=; b=s2YVOR7msydJJj3frH4cxX5uThw3VY8ayhFKvbo0ySNRq5i96dL1pE348d39LSLI0c /a+0c8CioLLYzWu1WHivlWfQ29K1UA5qXKiiVOZizN3l1KXQW86tl4oHvOvdiGUQdGtB IKhoON79+tXi/X3arJFFOX/iAlay1i70XyAwL3fAxdapZd0BvStZDCYL70+HtJ4y0WUW 1p0Rec+Z5t6FXGka+c7MfLYuIx5zqKvpyvkwDvbZJk79NWLiEtuRyFCJSe0mv5stuM+W OdhJ2W0Z/aj03cIwiHtSlw+RFACbGmRRweLDTJyQAPvxt/xt0e6fDGDDLt1ToVRi69Ka ykhg== 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 i71si21922238pge.3.2019.07.17.00.50.39; Wed, 17 Jul 2019 00:50: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 S1728220AbfGQHt0 (ORCPT + 99 others); Wed, 17 Jul 2019 03:49:26 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:2279 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727753AbfGQHtZ (ORCPT ); Wed, 17 Jul 2019 03:49:25 -0400 Received: from DGGEMS402-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id DB25CE1F6348E98241FB; Wed, 17 Jul 2019 15:49:23 +0800 (CST) Received: from huawei.com (10.175.124.28) by DGGEMS402-HUB.china.huawei.com (10.3.19.202) with Microsoft SMTP Server id 14.3.439.0; Wed, 17 Jul 2019 15:49:15 +0800 From: Jason Yan To: , , , , , , , , CC: , , , , , , Jason Yan Subject: [RFC PATCH 05/10] powerpc/fsl_booke/32: introduce reloc_kernel_entry() helper Date: Wed, 17 Jul 2019 16:06:16 +0800 Message-ID: <20190717080621.40424-6-yanaijie@huawei.com> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190717080621.40424-1-yanaijie@huawei.com> References: <20190717080621.40424-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 | 16 ++++++++++++++++ arch/powerpc/mm/mmu_decl.h | 1 + 2 files changed, 17 insertions(+) diff --git a/arch/powerpc/kernel/head_fsl_booke.S b/arch/powerpc/kernel/head_fsl_booke.S index a57d44638031..ce40f96dae20 100644 --- a/arch/powerpc/kernel/head_fsl_booke.S +++ b/arch/powerpc/kernel/head_fsl_booke.S @@ -1144,6 +1144,22 @@ _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 + li r8,(MSR_IS | MSR_DS) + andc r7,r7,r8 + + mtspr SPRN_SRR0,r4 + mtspr SPRN_SRR1,r7 + isync + sync + 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 d7737cf97cee..dae8e9177574 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); extern void create_tlb_entry(phys_addr_t phys, unsigned long virt, int entry); +extern 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