Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp5731902ybi; Wed, 31 Jul 2019 02:27:30 -0700 (PDT) X-Google-Smtp-Source: APXvYqz0gfjMliwaJEGQ0G0jz/ghrk2CVxiqRFlrN2ZILTiVBJ3dgJSUi2DLWBYNAc5apdaGiwK0 X-Received: by 2002:a65:5144:: with SMTP id g4mr60565431pgq.202.1564565249788; Wed, 31 Jul 2019 02:27:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564565249; cv=none; d=google.com; s=arc-20160816; b=JDPKA4eyps/jKFcP966ogx6ok5iDJE80FU7zzOzG/n4R8WXEe8XLLAumE6Q7U6UgCW fkiGnVVPyg/YM+CXOoS2TTKj5CWOrg8MbnxqqXpzbIVf6UltpvVjOqU4Z8cPfHYZpNrx WmERgLAfhdxNafQBLFR36oomcxc20X864vvtNnbhT6w2cl0Gkr+GK8BEx2rxJ/IFEg5h ANc1KcJbNgjuO4oMS/xEbIFHTC376k6fmnrGBQTzgbAz7WKDtXRAIFWJ8t+MdPtwTk/k ZURP6qqEaFoM3Em3bSuTQ0jEPOmBp+FtXQHw1Vc2jax+c6vJHr5sqnpPnuK5xCrEgbbJ wyGA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=pCb7LYf3gHlsJ/JYsc5o6SIleiMDIerwJy3so+E1hnA=; b=skn6g47x2TtHyVhBVvPKlDXj04vDjGP3cHB3FjnGgLtAmfMa2RqNMS5kPFdCnRlTTM xa97WyXLy9rOnRTSZQwwOILvLdMEKx2BIV4uQbQqXe/+F4qQhUuwTQU+lU+6qc3NsQi1 4AMj0o3MKANk5lHSQWUQNegpNIF9f2bxWQYT2BaFK7frV1atXH3itucHlpi9bpeDkFel iApLtulSc5zmbYMzgNoWH3fPYo8ALYj+bSc77N1ZGJOzalax5bJMgvxolJEovMF/DE8H lA0UqD5otyFHzH4uSOoJNzEHTwMpT0rEvj8dAK7ZJS65+CzQdUOl8YRkWIMRdsBdWuqp dklg== 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 i3si29034301plb.205.2019.07.31.02.27.14; Wed, 31 Jul 2019 02:27:29 -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; 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 S1728831AbfGaJ0d (ORCPT + 99 others); Wed, 31 Jul 2019 05:26:33 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:42418 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2387463AbfGaJ0Y (ORCPT ); Wed, 31 Jul 2019 05:26:24 -0400 Received: from DGGEMS405-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 736E88F53039865D0D4F; Wed, 31 Jul 2019 17:26:23 +0800 (CST) Received: from huawei.com (10.175.124.28) by DGGEMS405-HUB.china.huawei.com (10.3.19.205) with Microsoft SMTP Server id 14.3.439.0; Wed, 31 Jul 2019 17:26:17 +0800 From: Jason Yan To: , , , , , , , , CC: , , , , , , , Jason Yan Subject: [PATCH v3 09/10] powerpc/fsl_booke/kaslr: support nokaslr cmdline parameter Date: Wed, 31 Jul 2019 17:43:17 +0800 Message-ID: <20190731094318.26538-10-yanaijie@huawei.com> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190731094318.26538-1-yanaijie@huawei.com> References: <20190731094318.26538-1-yanaijie@huawei.com> 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 One may want to disable kaslr when boot, so provide a cmdline parameter 'nokaslr' to support this. 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/kaslr_booke.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/arch/powerpc/kernel/kaslr_booke.c b/arch/powerpc/kernel/kaslr_booke.c index 4b3f19a663fc..7c3cb41e7122 100644 --- a/arch/powerpc/kernel/kaslr_booke.c +++ b/arch/powerpc/kernel/kaslr_booke.c @@ -361,6 +361,18 @@ static unsigned long __init kaslr_choose_location(void *dt_ptr, phys_addr_t size return kaslr_offset; } +static inline __init bool kaslr_disabled(void) +{ + char *str; + + str = strstr(boot_command_line, "nokaslr"); + if ((str == boot_command_line) || + (str > boot_command_line && *(str - 1) == ' ')) + return true; + + return false; +} + /* * To see if we need to relocate the kernel to a random offset * void *dt_ptr - address of the device tree @@ -376,6 +388,8 @@ notrace void __init kaslr_early_init(void *dt_ptr, phys_addr_t size) kernel_sz = (unsigned long)_end - KERNELBASE; kaslr_get_cmdline(dt_ptr); + if (kaslr_disabled()) + return; offset = kaslr_choose_location(dt_ptr, size, kernel_sz); -- 2.17.2