Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp82618ybl; Fri, 9 Aug 2019 02:53:21 -0700 (PDT) X-Google-Smtp-Source: APXvYqwftJt6YiVp2cVk1dCF1enmf+pgSFEIViRaIUnQFlylqOu0uva5Q/N5BiMUj81C5leuqSja X-Received: by 2002:a63:4522:: with SMTP id s34mr16609555pga.362.1565344400977; Fri, 09 Aug 2019 02:53:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565344400; cv=none; d=google.com; s=arc-20160816; b=F8N/9ZZ7CVMy9gzLTl3bjzJXhZcocc6RQQwTRXd/lCUMDJhBLVM99sPFwCWbrcYmZ0 7/fy2waSh/AENQ4BvfjDvjCTaWJgVuTKqcV0CtljCGT5i3kR9JqCmqunar/VWeUIx091 gBTItU/XMQsWGV+z9gmKdjFMKNIU/TBpMkJFHAcB7S4G21GYF4ZO0DT8VtWtWy+tOpqu ljuCfGO/YNkvRvx4MxE6K59Ow9iiBU6TL5j0mh/iaYpnmFOOfGCXk3lyKkbg++1eEh9e yphHF4pAwDb7nHd49IS5F1y1S6WO3cNmNMNziKpgDy3YJ438twBVdqglGVZ5nXEQvnkA ujMg== 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=9tJoJg6730PvafDx29/5HU3uURC9wX3pRR1Gv4wyDF0=; b=mHLtWGT6eKxzmjt49oHQaBbDkXnrzDiwmZ8lNDzr6ej5LWiNoCdtTj3teL8cX9lCFk pCHxIrbkeeAQKqmUlRsvpH/njfwKmQb4Aemlqs5QmQPV40EfqcZkNdgQ3quusBKsnbbk 6DGUfko8QmVT11ECzddP4nfPmx4DCYVByFe317EBMw3b6F7VyPak46EKw+IfNOjzo+6u ZHHl4mdlcEB3bO6J4ZX4k+5x2tbBxpf1V08oscJglTdC8V3wVx25MCiD2msAxQy4Unoe 3wfGrd9z4CZ1S7PG/Cn152f1sbn0xhjh1EB8QbEZSN7kr60ukl0tO+OrcEugoB2L0BGe H8Hw== 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 b11si47940945plz.307.2019.08.09.02.53.05; Fri, 09 Aug 2019 02:53:20 -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 S2406305AbfHIJwU (ORCPT + 99 others); Fri, 9 Aug 2019 05:52:20 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:4227 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2406139AbfHIJwG (ORCPT ); Fri, 9 Aug 2019 05:52:06 -0400 Received: from DGGEMS403-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 4FF0EE10D3E1526A2AC2; Fri, 9 Aug 2019 17:52:03 +0800 (CST) Received: from huawei.com (10.175.124.28) by DGGEMS403-HUB.china.huawei.com (10.3.19.203) with Microsoft SMTP Server id 14.3.439.0; Fri, 9 Aug 2019 17:51:56 +0800 From: Jason Yan To: , , , , , , , , CC: , , , , , , , Jason Yan Subject: [PATCH v6 09/12] powerpc/fsl_booke/kaslr: support nokaslr cmdline parameter Date: Fri, 9 Aug 2019 18:07:57 +0800 Message-ID: <20190809100800.5426-10-yanaijie@huawei.com> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190809100800.5426-1-yanaijie@huawei.com> References: <20190809100800.5426-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 | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/arch/powerpc/kernel/kaslr_booke.c b/arch/powerpc/kernel/kaslr_booke.c index 9a360b6124ed..fd32ae10c218 100644 --- a/arch/powerpc/kernel/kaslr_booke.c +++ b/arch/powerpc/kernel/kaslr_booke.c @@ -334,6 +334,11 @@ static unsigned long __init kaslr_choose_location(void *dt_ptr, phys_addr_t size return kaslr_offset; } +static inline __init bool kaslr_disabled(void) +{ + return strstr(boot_command_line, "nokaslr") != NULL; +} + /* * To see if we need to relocate the kernel to a random offset * void *dt_ptr - address of the device tree @@ -349,6 +354,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