Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp1004188ybv; Wed, 5 Feb 2020 19:00:53 -0800 (PST) X-Google-Smtp-Source: APXvYqzUX3seoLlXv0kDZzsjX+8WyPwlSPQC3BWk+KfgP4mnpoU2xZZLMZsT3xMnBJzpocM3VtF7 X-Received: by 2002:aca:1b17:: with SMTP id b23mr5639281oib.95.1580958053685; Wed, 05 Feb 2020 19:00:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580958053; cv=none; d=google.com; s=arc-20160816; b=QlsnnzXA8CCCdrxswqvONCgbU6nN0kkBheFaWgsXMXsBUkICB75v5Oo6XnTzAn3l1r NYjabfZPSPCXIwpinrI8yUevvjXrTKeYAqPRPtEeNiAjpGk7zVkqEkv5VCFeUxrRxRM6 jwhNtMuT+iSVMKdrttQdqyqMdAGfRAFobQlInPKdLFmTQdW7J274YhMvTfvryOpONUUa YomFpFuVjNBSjUZs2vA7ox+SNshx9XDJF47GxCvLPcHGPWRamlAeniPpF4DnXaMAij+B +r9qBM3q1tk1uKY6qNHN8SNsS9ru823zhFKDUYk83cAoge+Z8fL44zd00ggEoVEwEMPY tzTg== 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=zxUL/erQBKB4rOyX2fNKiJnXO92deJpDvms1RECLllg=; b=PR6cUiLNUpCaPGsMwQ0HDIUkixaHtG0bagI1RyPkQS0GzhZY2v22mUEw9KjW/ABQwF DdLyPykXTjIaEpe6GCP15fQkYPotWMM58tY5jy/yOIyY4tbdfZoR4+bAMPstEihJ/DD1 kdU1SuD/chV/DXgNtdsHseu5SEI56N+v5u8hEQI5mCDdIcIhHTk6nyq/YZwRlpDoX8cu F3NyetoTirBoGeZSzqmzKqwyu8YDoZT/AalgE7PYFs9+DFKrY2XfzlxvDa1UUwlN9qpD vKlLNrXYo86NyOCuwmiHkagHA4UW8OOU+ATyY6AsyOjrkqtzpWhnKqTp8I2u8V0/72J1 eRvg== 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 p8si1070579otq.170.2020.02.05.19.00.41; Wed, 05 Feb 2020 19:00:53 -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 S1727818AbgBFC7m (ORCPT + 99 others); Wed, 5 Feb 2020 21:59:42 -0500 Received: from szxga07-in.huawei.com ([45.249.212.35]:38962 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727307AbgBFC7i (ORCPT ); Wed, 5 Feb 2020 21:59:38 -0500 Received: from DGGEMS401-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 2D99B7C3F8276CE31737; Thu, 6 Feb 2020 10:59:35 +0800 (CST) Received: from huawei.com (10.175.124.28) by DGGEMS401-HUB.china.huawei.com (10.3.19.201) with Microsoft SMTP Server id 14.3.439.0; Thu, 6 Feb 2020 10:59:25 +0800 From: Jason Yan To: , , , , , , , , , CC: , , Jason Yan Subject: [PATCH v3 0/6] implement KASLR for powerpc/fsl_booke/64 Date: Thu, 6 Feb 2020 10:58:19 +0800 Message-ID: <20200206025825.22934-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. 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 .../{kaslr-booke32.rst => kaslr-booke.rst} | 35 +++++++-- arch/powerpc/Kconfig | 2 +- arch/powerpc/kernel/exceptions-64e.S | 23 ++++++ arch/powerpc/kernel/head_64.S | 14 ++++ arch/powerpc/kernel/setup_64.c | 4 +- arch/powerpc/mm/mmu_decl.h | 19 ++--- arch/powerpc/mm/nohash/kaslr_booke.c | 71 +++++++++++++------ 7 files changed, 132 insertions(+), 36 deletions(-) rename Documentation/powerpc/{kaslr-booke32.rst => kaslr-booke.rst} (59%) -- 2.17.2