Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp3235588ybb; Mon, 13 Apr 2020 03:47:22 -0700 (PDT) X-Google-Smtp-Source: APiQypKYpMuwfngRW0/23B9MABFueB9oQpZ3sn/xuNUkJnbVeO/I+y/+Bwl/Vp4kQoKZ4vnJxEOs X-Received: by 2002:a05:6402:22cc:: with SMTP id dm12mr4696121edb.159.1586774841892; Mon, 13 Apr 2020 03:47:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586774841; cv=none; d=google.com; s=arc-20160816; b=CJFaRL2bGjEP84pOtSnlmbW/ntuk0qP9ZDwQIYjmZnQpBFii8Fjom1eAeQn0pUlERb pXc1BIxPa/54Ig6Uq6gtbnP9qls3/BTjv816xA/Sj3LIyqKVHMU12v6dXqTPQQ242wNS +HSBx8TQ6BjE+qo7Q/gypce3MT8d7P1/aghOeqcVebnShs8tMYwGFJoAUSr76pqPftYi Dt/Z+CE8HZwnaVKpzQWKy38UsRiNhjTfpZIkupIAFAeMTmK7bGlt0Rd+uDoErSbthPpp C3Q27z+91hpPSTkn1396YB+0RKSzByB25r3vEVZbrEirETzrbqDfnaUJ9cFKGNhgAxQc w0og== 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:in-reply-to :mime-version:user-agent:date:message-id:from:references:cc:to :subject; bh=6+MkzPqt2VOOQWTwsJoVacq/IQQQ6WXVB5yi5SOyPcs=; b=ueJTO4M1G+JgjBzb6VSNSbszUsHfkob79bXCRPJhCfM2N4ox2H19vfm3hx67QYJOxW 9kuaNP/qtFZUzH/QdWaHxD+TrktYhwWaINguOc0zF7YGJKDKOG5ICePne6/9/FvhLFm3 6q5iHTkEfaRyLNmiclYQNJm+aWmN5gssP/djSMtuRkoK+P8nJ5Mmj/G2iXb3Jp0LZ9T9 36eiGnHJY8WRGh0xav4X+en7RTe/pRp3nnoPleZlzIccyowPASJSlUvpcps41ydDbLN6 moyj3pWN1aNtjvQyGxZGQEpJCeW5eXClEpKCC9QU59zUgt6ls+BNEdgzZl9/4MURJB+R chmQ== 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 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y13si6143999ede.200.2020.04.13.03.46.51; Mon, 13 Apr 2020 03:47:21 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726936AbgDMBXh (ORCPT + 99 others); Sun, 12 Apr 2020 21:23:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.18]:58044 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726917AbgDMBXh (ORCPT ); Sun, 12 Apr 2020 21:23:37 -0400 Received: from huawei.com (szxga05-in.huawei.com [45.249.212.191]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 65398C0A3BE0 for ; Sun, 12 Apr 2020 18:23:37 -0700 (PDT) Received: from DGGEMS406-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 84931C6D573870651A49; Mon, 13 Apr 2020 09:23:34 +0800 (CST) Received: from [127.0.0.1] (10.173.221.195) by DGGEMS406-HUB.china.huawei.com (10.3.19.206) with Microsoft SMTP Server id 14.3.487.0; Mon, 13 Apr 2020 09:23:24 +0800 Subject: Re: [PATCH v5 0/6] implement KASLR for powerpc/fsl_booke/64 To: , , , , , , , , , CC: , , References: <20200330022023.3691-1-yanaijie@huawei.com> From: Jason Yan Message-ID: <433bb006-aa45-524d-c57e-79657d01c685@huawei.com> Date: Mon, 13 Apr 2020 09:23:23 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko/20100101 Thunderbird/68.4.2 MIME-Version: 1.0 In-Reply-To: <20200330022023.3691-1-yanaijie@huawei.com> Content-Type: text/plain; charset="gbk"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [10.173.221.195] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org ping... ?? 2020/3/30 10:20, Jason Yan ะด??: > This is a try to implement KASLR for Freescale BookE64 which is based on > my earlier implementation for Freescale BookE32: > https://patchwork.ozlabs.org/project/linuxppc-dev/list/?series=131718&state=* > > The implementation for Freescale BookE64 is similar as BookE32. One > difference is that Freescale BookE64 set up a TLB mapping of 1G during > booting. Another difference is that ppc64 needs the kernel to be > 64K-aligned. So we can randomize the kernel in this 1G mapping and make > it 64K-aligned. This can save some code to creat another TLB map at > early boot. The disadvantage is that we only have about 1G/64K = 16384 > slots to put the kernel in. > > KERNELBASE > > 64K |--> kernel <--| > | | | > +--+--+--+ +--+--+--+--+--+--+--+--+--+ +--+--+ > | | | |....| | | | | | | | | |....| | | > +--+--+--+ +--+--+--+--+--+--+--+--+--+ +--+--+ > | | 1G > |-----> offset <-----| > > kernstart_virt_addr > > I'm not sure if the slot numbers is enough or the design has any > defects. If you have some better ideas, I would be happy to hear that. > > Thank you all. > > v4->v5: > Fix "-Werror=maybe-uninitialized" compile error. > Fix typo "similar as" -> "similar to". > v3->v4: > Do not define __kaslr_offset as a fixed symbol. Reference __run_at_load and > __kaslr_offset by symbol instead of magic offsets. > Use IS_ENABLED(CONFIG_PPC32) instead of #ifdef CONFIG_PPC32. > Change kaslr-booke32 to kaslr-booke in index.rst > Switch some instructions to 64-bit. > v2->v3: > Fix build error when KASLR is disabled. > v1->v2: > Add __kaslr_offset for the secondary cpu boot up. > > Jason Yan (6): > powerpc/fsl_booke/kaslr: refactor kaslr_legal_offset() and > kaslr_early_init() > powerpc/fsl_booke/64: introduce reloc_kernel_entry() helper > powerpc/fsl_booke/64: implement KASLR for fsl_booke64 > powerpc/fsl_booke/64: do not clear the BSS for the second pass > powerpc/fsl_booke/64: clear the original kernel if randomized > powerpc/fsl_booke/kaslr: rename kaslr-booke32.rst to kaslr-booke.rst > and add 64bit part > > Documentation/powerpc/index.rst | 2 +- > .../{kaslr-booke32.rst => kaslr-booke.rst} | 35 ++++++- > arch/powerpc/Kconfig | 2 +- > arch/powerpc/kernel/exceptions-64e.S | 23 +++++ > arch/powerpc/kernel/head_64.S | 13 +++ > arch/powerpc/kernel/setup_64.c | 3 + > arch/powerpc/mm/mmu_decl.h | 23 +++-- > arch/powerpc/mm/nohash/kaslr_booke.c | 91 +++++++++++++------ > 8 files changed, 147 insertions(+), 45 deletions(-) > rename Documentation/powerpc/{kaslr-booke32.rst => kaslr-booke.rst} (59%) >