Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp4559369ybi; Tue, 30 Jul 2019 04:13:35 -0700 (PDT) X-Google-Smtp-Source: APXvYqyKHAbhL6yP4Cg1PMkltcGLPZywxeNSEx1RObqaiGycj6hL9MyGCoFpPn5vXtLvJY9lu7IA X-Received: by 2002:a17:902:24e:: with SMTP id 72mr71894347plc.65.1564485215583; Tue, 30 Jul 2019 04:13:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564485215; cv=none; d=google.com; s=arc-20160816; b=O280nGEKJPSkwyhTUkehEUsbrkSr/OOgeZBkZQqkSRf+Z9hxJIBXRLqtFY0NrjK8Vn EZRFc1GANDhRNei6r+YmKYLHsk76sVHpPdoqbw+dgikPpDwYcPIMiQkM++eI9vNH3q/7 5AMQDT2My7WMcAUjcmMu9YaJN/+OvebYpIglgQvZ7satlSVhLh2XXNlWRBJRGdOC30rV EcmlzwcyfvjYO6Fa0MB3NHQkmFCaTvtzy6/E/JR5cWTDBRDurq3yojyU8XaEpumlXN25 h9uC91kkM3+xZA8YJZrLpa253+QA16h7ii9jXnJ0eFO133FsZI8nedS8LE51tSAICVAL PDgg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=W494YaqgUnZA2FNm31/aP5pf5NOo4mChfve8KHyIrgo=; b=cvD4PqyDFSDV+JPzy2pOqLAT7il/5VrgfpTh6wvGNdNyw0clVvkOcUvRc9J4ukWsF0 ksitbsDQ0iZHtTA2nH6Bix8TYl5Q2ncjVIOGpH/sC9FA6Z8pkzJ39iiYz2yJYbMzttDh 2EvW2cz4So7IGFZoilLcoHpwWHGvtjFn2SZJi3CFxuGdRe0JzDwd/qkzNxTsHaIMbnhd RbCm6jttYJy0fsYc89W5RxTwJiIyNu6qoj4UbDYBYGQkWXNdEy/X/pggwWKgrM+K2yzS jj4tWMjoBTr886+/tmOvUmB7hGBp+FCDev7rnUInqDyfoRWh6JKeP37m8EAaYKQa7tFm MUjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@c-s.fr header.s=mail header.b=LguhQ+mC; 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 x6si28287008pjn.10.2019.07.30.04.13.21; Tue, 30 Jul 2019 04:13:35 -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; dkim=pass header.i=@c-s.fr header.s=mail header.b=LguhQ+mC; 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 S1731307AbfG3J0Z (ORCPT + 99 others); Tue, 30 Jul 2019 05:26:25 -0400 Received: from pegase1.c-s.fr ([93.17.236.30]:36291 "EHLO pegase1.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729566AbfG3J0Y (ORCPT ); Tue, 30 Jul 2019 05:26:24 -0400 Received: from localhost (mailhub1-int [192.168.12.234]) by localhost (Postfix) with ESMTP id 45yWQQ4Dlkz9v6rL; Tue, 30 Jul 2019 11:26:22 +0200 (CEST) Authentication-Results: localhost; dkim=pass reason="1024-bit key; insecure key" header.d=c-s.fr header.i=@c-s.fr header.b=LguhQ+mC; dkim-adsp=pass; dkim-atps=neutral X-Virus-Scanned: Debian amavisd-new at c-s.fr Received: from pegase1.c-s.fr ([192.168.12.234]) by localhost (pegase1.c-s.fr [192.168.12.234]) (amavisd-new, port 10024) with ESMTP id KZgfe_18yVyX; Tue, 30 Jul 2019 11:26:22 +0200 (CEST) Received: from messagerie.si.c-s.fr (messagerie.si.c-s.fr [192.168.25.192]) by pegase1.c-s.fr (Postfix) with ESMTP id 45yWQQ358Sz9v6rD; Tue, 30 Jul 2019 11:26:22 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=c-s.fr; s=mail; t=1564478782; bh=W494YaqgUnZA2FNm31/aP5pf5NOo4mChfve8KHyIrgo=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=LguhQ+mCh1Cl3JcH0/tMBY4TpGOZyqIb++mijiTCVHZV09QnAoXuaDmUQdnmZ57bd uf6sUo38sJhtq7e2HwZwA24AxJF+bkaGLEpd049BpDFMLI3hds8qFwgxi7w51ec2+X +hsuVhzyeJirIeuY8ttS9wqtcP8mSTxpvyoaAOyM= Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 848AD8B800; Tue, 30 Jul 2019 11:26:23 +0200 (CEST) X-Virus-Scanned: amavisd-new at c-s.fr Received: from messagerie.si.c-s.fr ([127.0.0.1]) by localhost (messagerie.si.c-s.fr [127.0.0.1]) (amavisd-new, port 10023) with ESMTP id jTKB_g-k_myc; Tue, 30 Jul 2019 11:26:23 +0200 (CEST) Received: from [172.25.230.101] (po15451.idsi0.si.c-s.fr [172.25.230.101]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 40AC08B74F; Tue, 30 Jul 2019 11:26:23 +0200 (CEST) Subject: Re: [PATCH v2 05/10] powerpc/fsl_booke/32: introduce reloc_kernel_entry() helper To: Jason Yan , mpe@ellerman.id.au, linuxppc-dev@lists.ozlabs.org, diana.craciun@nxp.com, benh@kernel.crashing.org, paulus@samba.org, npiggin@gmail.com, keescook@chromium.org, kernel-hardening@lists.openwall.com Cc: linux-kernel@vger.kernel.org, wangkefeng.wang@huawei.com, yebin10@huawei.com, thunder.leizhen@huawei.com, jingxiangfeng@huawei.com, fanchengyang@huawei.com, zhaohongjiang@huawei.com References: <20190730074225.39544-1-yanaijie@huawei.com> <20190730074225.39544-6-yanaijie@huawei.com> From: Christophe Leroy Message-ID: Date: Tue, 30 Jul 2019 11:26:23 +0200 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: <20190730074225.39544-6-yanaijie@huawei.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: fr Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Le 30/07/2019 à 09:42, Jason Yan a écrit : > 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 > --- > 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); >