Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp175773ybv; Tue, 4 Feb 2020 18:58:23 -0800 (PST) X-Google-Smtp-Source: APXvYqzBA8IhNpH6rSAWNoryVkOiS7FV0ZPPUwivI+drRnOyiH5kluGc6sHPDBkDHLzC6EbPD2v6 X-Received: by 2002:a54:4003:: with SMTP id x3mr1429168oie.0.1580871503057; Tue, 04 Feb 2020 18:58:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580871503; cv=none; d=google.com; s=arc-20160816; b=D8YowoGXXxcY9AwfDnbs3euGPDFLPwDGS7HlnBT7LVRzfdMnvK74VxfRAvcYO/V3vF Wl+KdpUcai66W9bnTRv3mdGSM5ImSCgVQ2JU0HvouMkbAoHvUTqmopXou1jQwwdhb5N6 kzRyU7YG81/exOp0RnObtwV/eRxJaVcbhtH8+c/bw6asWuVLSCiQU3wdEub3nzr5aq0O k1+N9EKdWPsE4+sZS7EtyAvJ0DP0DCGCgg4anKdSeePTPMR2oEfGiabfuILDWNXeyy+z lkBxB75stVUy/uS7kx9g07tl1f6rigXiOEA1sdOZdHB4xhwLgvEnPQdXYXdndNhgGOoj JOuw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from; bh=8qc2k1WR2uT0eBUuo9Dh2Q1QlDRcmul6tR0WkUa+TG8=; b=Nk87uM2/0ahFP2qQmoohNuGso9p4Kytmk6RcewBshqB+eBHthvvMyn+izpiojAzMBv ugBoqLjrRjBGD85E3jEhE0m2CqNWnhG5rBN1JNCedaYUL4QBOjEpQVLZ/+8yJAlLJLg2 0I9Spr0HtJO4KEEg/T8VSDP92zueyOj/mZUjgJgt/cJ9Ma2opmDC1OTKnfkWf96eLQJM mef9FAKe1ploi2sYUkLqLYsVmTybOAunJQUkEQLx9T4i8h7PCQkuT5XJKirpmJM9G/dg sg7USTfo140SFMAY+sYNkkXJhMGWFFxedgsbhL1nM+qtQclSBeOkqMX5xPeiFi5RzNQc YQ2A== 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 w23si7901406otm.256.2020.02.04.18.58.11; Tue, 04 Feb 2020 18:58:23 -0800 (PST) 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 S1727885AbgBEC4j (ORCPT + 99 others); Tue, 4 Feb 2020 21:56:39 -0500 Received: from szxga05-in.huawei.com ([45.249.212.191]:9698 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727854AbgBEC4j (ORCPT ); Tue, 4 Feb 2020 21:56:39 -0500 Received: from DGGEMS406-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id A0E227E85F07CB2E5BCB; Wed, 5 Feb 2020 10:56:36 +0800 (CST) Received: from huawei.com (10.175.124.28) by DGGEMS406-HUB.china.huawei.com (10.3.19.206) with Microsoft SMTP Server id 14.3.439.0; Wed, 5 Feb 2020 10:56:26 +0800 From: Jason Yan To: , , , , , , , , , CC: , , Jason Yan Subject: [PATCH v2 0/6] implement KASLR for powerpc/fsl_booke/64 Date: Wed, 5 Feb 2020 10:55:21 +0800 Message-ID: <20200205025527.28640-1-yanaijie@huawei.com> X-Mailer: git-send-email 2.17.2 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 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 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. 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 .../{kaslr-booke32.rst => kaslr-booke.rst} | 35 +++++++-- arch/powerpc/Kconfig | 2 +- arch/powerpc/kernel/exceptions-64e.S | 21 ++++++ arch/powerpc/kernel/head_64.S | 14 ++++ arch/powerpc/kernel/setup_64.c | 4 +- arch/powerpc/mm/mmu_decl.h | 3 +- arch/powerpc/mm/nohash/kaslr_booke.c | 71 +++++++++++++------ 7 files changed, 122 insertions(+), 28 deletions(-) rename Documentation/powerpc/{kaslr-booke32.rst => kaslr-booke.rst} (59%) -- 2.17.2