Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp4536974ybi; Tue, 30 Jul 2019 03:50:56 -0700 (PDT) X-Google-Smtp-Source: APXvYqwqbc153bPX7XE52rKYQYlOdO1uDlF0qQhUi63WU24zQd0tmXaRzFiwhmzzhUa9zIPiSyR2 X-Received: by 2002:aa7:8d88:: with SMTP id i8mr41983863pfr.28.1564483856206; Tue, 30 Jul 2019 03:50:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564483856; cv=none; d=google.com; s=arc-20160816; b=tMdDVGtYVndpdyWD9rfrn/2ruxx7kI4IY10W0nhLXCzoPCeI2+G+/Aq0noCfDNMwBx KG27Lob+4QnKKwLs+fGGYQVSJc+gupmODIyCT+0qGuox0lkpXu5qEZXiryO6aZZOx+65 RhqtRtSJ+iCIC+6+lCDucgz7b8lob42v+ot31DzVd/ivBBPQfcuxHQV5uzba56pdO0QN uJ98sZIeL5tEdDwso4iWgxIPx7ibCLYmepJIztpxXEbJM0FVFsmuuVygidA3hgE1eooC nH2+hvvlRhkhP9YB/FjU7XEJZi60t7HNrBLRID21OQh/0BY568UkuP38UEXcb/c0RxN7 i6hg== 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=MgNi5rZwle1ESH0e+PvcL44X8d1a5i0u3apWU/8g3TE=; b=f/bopE+cBGTRqcwOc/c/GvkaKRh+n0OYu+5EfZ83btVxSUYthHWAEZaYB78ob/9C10 Bh7EUNP44tXD5ypIiAwwk8zC+AaT76cWeUoILkXevXJndCQ0JuhteW/UEd1DXVD60AGw FwkLl1j7CBYn6aaCmcy7PjNA3cKnlrAY6Joo8UJ7qku7ffal7FcXSpdefgakK8sJ3bA1 2DKGDMtGPU2B46IepPJmC93er8wQP0j27MbAlaGMpszvLHGwlIOsO+VNgHhrf1O/j1q+ 35Hp/u/3p5a6sFq+K+DLWuWvyElGCkMbmqV3d+GrJnw8yz0ZyzqR70gvyZdwYqFah4KM 7nBQ== 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 f15si27493335plr.260.2019.07.30.03.50.41; Tue, 30 Jul 2019 03:50:56 -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 S1730404AbfG3HZw (ORCPT + 99 others); Tue, 30 Jul 2019 03:25:52 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:3218 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729883AbfG3HZq (ORCPT ); Tue, 30 Jul 2019 03:25:46 -0400 Received: from DGGEMS413-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 170E226DFD5825E74FC3; Tue, 30 Jul 2019 15:25:40 +0800 (CST) Received: from huawei.com (10.175.124.28) by DGGEMS413-HUB.china.huawei.com (10.3.19.213) with Microsoft SMTP Server id 14.3.439.0; Tue, 30 Jul 2019 15:25:30 +0800 From: Jason Yan To: , , , , , , , , CC: , , , , , , , Jason Yan Subject: [PATCH v2 09/10] powerpc/fsl_booke/kaslr: support nokaslr cmdline parameter Date: Tue, 30 Jul 2019 15:42:24 +0800 Message-ID: <20190730074225.39544-10-yanaijie@huawei.com> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190730074225.39544-1-yanaijie@huawei.com> References: <20190730074225.39544-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 f032ac119457..74dfe879acec 100644 --- a/arch/powerpc/kernel/kaslr_booke.c +++ b/arch/powerpc/kernel/kaslr_booke.c @@ -373,6 +373,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 @@ -388,6 +400,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