Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3290774ybi; Mon, 29 Jul 2019 04:09:04 -0700 (PDT) X-Google-Smtp-Source: APXvYqwuUAIXit6ISlSXEvC6dael7agVt2Lbop14inL1zEI2RYqidORKtTenot5bVg1INURCOhws X-Received: by 2002:a17:90a:cb97:: with SMTP id a23mr15408910pju.67.1564398544688; Mon, 29 Jul 2019 04:09:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564398544; cv=none; d=google.com; s=arc-20160816; b=uWlR7YxIp0UnpL98hCT8YrIMgXQExdXTh2+jlHLdczWjqKbk2wB0AcVIIpIGuDHOj7 /ougPFzb0ZG0dKVhgsS9vY+zV0AVmp1NIr0VhSyk0qwNN8aDeW1g+BwMKUfbh8CxIsgQ s/a0KCI+gxqV4cCRJHk3Z46VY7XTy2QIgW9edOgEPKLSGaTmGAaR6Ck2ArtuqvsSh+uk 2uTb0sVJimMx5ZWIJQJ3IcUkoMc9Nnh//6FYY+6Yi8yI1E7/NoWk5U5wwDXcbwAplVp9 Xkjxs3V2YNYGTisDilhLXLwj555gg7bQSlrmS6TRhcem0ne9yql8BLRSPf4kHjZcw+w8 QxCg== 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=5INwHw7XbuC/K2OjMZ4KYRax0cv2G+pbjXkMo1syWiI=; b=Ok3PCZM1zH1iN5/fri+kYtiOEjgfSv9nb7IVWP/v//ZKOe/XqIht3hBeg8EnIkogl9 wK509LsI1uP4DTah8gyNre+atRWgbZEAtbl4hPYdmJnytTmPT9+vNNyfvdZzujxeVo0q Mi477QtRa0SVD63xAQYoY9Lud/bOcNeUY5ocw+ZbYPOp4RvMYJlGYBVvma/GhYcWPExu 6AEhYw9CqM93mIE/vCCCULLXRbsl9S2RavRhqOROnxyg5bOHsOjnRfOndYAuytYB7FnJ hDC29ZxM7osZqei6L49bi3yb9fs7lTghGs3tSvpJOua5gL4mGbbe6JSJugsxusFeR9Kk uXUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@c-s.fr header.s=mail header.b=arONxYLf; 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 u16si28687278pjb.15.2019.07.29.04.08.49; Mon, 29 Jul 2019 04:09:04 -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=arONxYLf; 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 S2387572AbfG2LIK (ORCPT + 99 others); Mon, 29 Jul 2019 07:08:10 -0400 Received: from pegase1.c-s.fr ([93.17.236.30]:15122 "EHLO pegase1.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387457AbfG2LIK (ORCPT ); Mon, 29 Jul 2019 07:08:10 -0400 Received: from localhost (mailhub1-int [192.168.12.234]) by localhost (Postfix) with ESMTP id 45xxkC44QKz9v9MV; Mon, 29 Jul 2019 13:08:03 +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=arONxYLf; 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 ESTVg6lnoUGW; Mon, 29 Jul 2019 13:08:03 +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 45xxkC2ztgz9v9Lx; Mon, 29 Jul 2019 13:08:03 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=c-s.fr; s=mail; t=1564398483; bh=5INwHw7XbuC/K2OjMZ4KYRax0cv2G+pbjXkMo1syWiI=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=arONxYLfYazH1Zuv1sjYhl+98rYh7/IMm8wcB9t915KfBP0mg7p23qtwKyOzwnotp W40nOf8zFdXdk+whAYptqqCcrHrHC6a8ulMz3YYeOFBKwQhFMNHEzDbTqPDV1UtWXJ Wm699DyCi1utuj1uMB5IRkKVDDV3wBaTlHP6sh5E= Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 449968B7CB; Mon, 29 Jul 2019 13:08:08 +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 vS0yC_BC0m1Z; Mon, 29 Jul 2019 13:08:08 +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 13A6E8B7B3; Mon, 29 Jul 2019 13:08:08 +0200 (CEST) Subject: Re: [RFC PATCH 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 References: <20190717080621.40424-1-yanaijie@huawei.com> <20190717080621.40424-6-yanaijie@huawei.com> From: Christophe Leroy Message-ID: Date: Mon, 29 Jul 2019 13:08:08 +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: <20190717080621.40424-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 17/07/2019 à 10:06, 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 > --- > 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 Instead of the li/andc, what about the following: rlwinm r7, r7, 0, ~(MSR_IS | MSR_DS) > + > + mtspr SPRN_SRR0,r4 > + mtspr SPRN_SRR1,r7 > + isync > + sync > + rfi Are the isync/sync really necessary ? AFAIK, rfi is context synchronising. > + > /* > * 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); No new 'extern' please, see https://openpower.xyz/job/snowpatch/job/snowpatch-linux-checkpatch/8125//artifact/linux/checkpatch.log > #endif > extern void loadcam_entry(unsigned int index); > extern void loadcam_multi(int first_idx, int num, int tmp_idx); > Christophe