Received: by 2002:a25:b794:0:0:0:0:0 with SMTP id n20csp5060515ybh; Tue, 6 Aug 2019 23:41:31 -0700 (PDT) X-Google-Smtp-Source: APXvYqwFH4v8GOYNtt1ycIohOXeeUfDBxbTfymGYlRuK6kKLa8zPHCBgCOHzjjIi+H1U3TOTak4l X-Received: by 2002:a17:902:2b8a:: with SMTP id l10mr6733383plb.283.1565160091465; Tue, 06 Aug 2019 23:41:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565160091; cv=none; d=google.com; s=arc-20160816; b=UjYRmw8qt8as+5JsLCn/eAs0fru9A1ysggidKVGMJBOetN2T93MGvQyWAUPkknp++t YIfG2MCC5wbRXdvzrHA3ZXn5s3omisWjiBrg6DayXhN/Munso1BmhON4cuP9sGCu7VsP JIAS13IRozuv22LeddsTsPiJ3snsvpN7dtFVd3eMP9lt7dVITzhFaVxBgs18rdhVyrmn L0rDs1OiLHMmH/yq6I30Wbt/RG6XRLjhU78YDe8XCZXFIoCuN/WaDPH2yXVYiwnXMYdN oYs1/D8rNiHvQU249zbd40H9j0G3c1uxP57w8euALUmkDQX4U2oDHNmk7ZyLsHdnbFJA lLMw== 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=pK+hHy6Go8ywbM5LC3bZKEI1id/5MjfcWai7dPEy7P8=; b=xmTgUeVQjTa+yGM+vvpwuYNoXJPp6SaUPgu4RMCl6sqmvQJ3LhshjdsrSHP2X3B/Gn 3Y69fQe8q4hQzuyKiYfkAB4RNo0EM0aJKeRrRZpioETVJfU8VLRL7zO3f9SQJbDdoft7 E7hZKNW5rQucx9xJE4+WPGNGq1LMym/7RUdy+kd/z3FlGtX4OykD4BaPd8YWXLOJmSM1 htyDTiKUmuEhYofY2lQx7rnn2CL27HaULkVuNUBNChlXNZjrBaKnkG7nD1ckIyt72A4/ h5GHxLFACJD/Sgwgh8oslZOJCOY6rtQoOXCuh2FQjo38WW3+2ywZEBocY7kwgL4Au2lL uUTw== 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 a89si48308474pla.60.2019.08.06.23.41.16; Tue, 06 Aug 2019 23:41:31 -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 S1727697AbfHGGkT (ORCPT + 99 others); Wed, 7 Aug 2019 02:40:19 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:3778 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727602AbfHGGkO (ORCPT ); Wed, 7 Aug 2019 02:40:14 -0400 Received: from DGGEMS412-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id F3D97FB352D7951C6ED3; Wed, 7 Aug 2019 14:40:12 +0800 (CST) Received: from huawei.com (10.175.124.28) by DGGEMS412-HUB.china.huawei.com (10.3.19.212) with Microsoft SMTP Server id 14.3.439.0; Wed, 7 Aug 2019 14:40:03 +0800 From: Jason Yan To: , , , , , , , , CC: , , , , , , , Jason Yan Subject: [PATCH v5 09/10] powerpc/fsl_booke/kaslr: support nokaslr cmdline parameter Date: Wed, 7 Aug 2019 14:57:05 +0800 Message-ID: <20190807065706.11411-10-yanaijie@huawei.com> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190807065706.11411-1-yanaijie@huawei.com> References: <20190807065706.11411-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 Reviewed-by: Diana Craciun Tested-by: Diana Craciun Reviewed-by: Christophe Leroy --- 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 c6b326424b54..436f9a03f385 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