Received: by 2002:a25:b794:0:0:0:0:0 with SMTP id n20csp2358432ybh; Sun, 4 Aug 2019 23:28:39 -0700 (PDT) X-Google-Smtp-Source: APXvYqxp0+dBhIONHa6swQBlIrFiPxZaneHbS3AI3+0UwixKBX2H1mRmN+oVr/A5ti0dghRLDM83 X-Received: by 2002:a17:902:7488:: with SMTP id h8mr69173623pll.168.1564986519881; Sun, 04 Aug 2019 23:28:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564986519; cv=none; d=google.com; s=arc-20160816; b=BQK/oxvbnXvlWrRu3WY9JbciDa682fzrw6Wp2bV5NwC1LEOWbKd7jK8FsH9KnwcJtK z243i8MsZXPA1iRD1Dgs8t1ImGD63lUXQp8XWZsC8WK5snSULJazsWwuSDwsbKePaYYX sPstIkVw4gG2CNJqbGZ4gd8GEXndpm61sebiAJwBplUwM73dvijZFO74+h9tY5aRFDEq KFqQyvwTz4BP3x7JJxXR7WbhCDKOVxK2AzxtZ+tQsZg+yZidfuFpSbd0TCeMFEf2PdOx ofb9eLglODsfxYRGvvsxs1EZnT0iDTlJleIKqeI6ErQZ4mTa6gg/i6h58tsEWTFYnan4 BuGw== 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=HysN9QApsBtHatyeqna4DdR4DOMCkw0OMVBlANvy5jo=; b=YtuvkHhcyQ2h+oMsq1WtP+Itm1t35GTsOEP5nILvabOHigQPWTeDjjmT27QW3vAIDu fSWXpiCDZw4Mt5ocOxiSfx1oEWho0+npkMAl+4MFpTJL6TtP1mc/4ecwgBQly4othCOU aHO4t1OMv1oLEaFJOJUaobiXrQEKCZ0ynKWtjwHKvMAGTgWLRYy9QS/GfMC+LSqTMxgT Q5B+/tWftVp+iMaXCQNh2htYbJAW7plHdWV1E3yHNQwiWqJZbmPQq4DV6JWZ4d01NjEM IeKIMDGHmD8LQOaG3617+/6GOBcl4/ClQDn9GQyITXuZG10TLooU2YeMyNxYiYVPT3ew Decw== 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 185si45347665pgc.522.2019.08.04.23.28.24; Sun, 04 Aug 2019 23:28:39 -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 S1727501AbfHEG0r (ORCPT + 99 others); Mon, 5 Aug 2019 02:26:47 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:4172 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727385AbfHEG0n (ORCPT ); Mon, 5 Aug 2019 02:26:43 -0400 Received: from DGGEMS414-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 41AFBE3D100840E7D288; Mon, 5 Aug 2019 14:26:42 +0800 (CST) Received: from huawei.com (10.175.124.28) by DGGEMS414-HUB.china.huawei.com (10.3.19.214) with Microsoft SMTP Server id 14.3.439.0; Mon, 5 Aug 2019 14:26:33 +0800 From: Jason Yan To: , , , , , , , , CC: , , , , , , , Jason Yan Subject: [PATCH v4 09/10] powerpc/fsl_booke/kaslr: support nokaslr cmdline parameter Date: Mon, 5 Aug 2019 14:43:34 +0800 Message-ID: <20190805064335.19156-10-yanaijie@huawei.com> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190805064335.19156-1-yanaijie@huawei.com> References: <20190805064335.19156-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 --- 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