Received: by 2002:a25:b323:0:0:0:0:0 with SMTP id l35csp1530960ybj; Fri, 20 Sep 2019 12:01:22 -0700 (PDT) X-Google-Smtp-Source: APXvYqwGkHHQmHjHmaDY2MKDaL/ak25SxaXSi2H7Wrfq4x41YF5jVv8JNYj4hgSA5XDAtB8dL/BE X-Received: by 2002:aa7:d803:: with SMTP id v3mr23751007edq.146.1569006081887; Fri, 20 Sep 2019 12:01:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569006081; cv=none; d=google.com; s=arc-20160816; b=CwGZDANZrOZgP2jwPxBqp/WUW88vdchDVF81razuHit0OIWsNTHPSlqq9msGg43bNJ /OpJ3tAVdPxp5iChjS+ZRScP3jo/juhsKRIdJ48WZJWaoHbbEq7wX8dOoWqDpbj4zkJv RaR0iEQLtZgncKNH/Dct5UUBZI5VCpzdLMkxA/Mut9xVua6IV+OlUQOyZ6lE8H20RKJe caBTDFXuf9goTnWkpi3XdEKRXIqvD8iGnWAdwDfOkwdjvrVNeQx47F4NBRsN+JlzUFBh 4cc2FmieiJM2TlRPz3d7zME6FnfSl1jUa4ojTJsfr81znPItNro8JW8zJZRIgCiVF/ns dp+Q== 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=78yce1QNjemFqfPSbuklzd6tFOd77sICMEMCUuDig0k=; b=pHyKPOOGCr+wYm8gEdqEpZl3gY4p1fdI2wWeoS+6HqDPSzE1rH7/Iq4N41vrgvYkz9 A0vZmtVwmz3fAraZ12Ivy2u9y3dB6+PHlvaEAmqT6Goyyn1/dgLOirFgJU9D2jRd55h/ qWAcS1v8YLF4sz6cnja1pAHg4VPn0SV1kux+q/ZzDqtFLwvnS9ByI0iNyJojgbCy+zZW FJoLr6x1VgJauczxnfePRDA7isbhfgirRvd2oHkgZhwK1v52F6UwGkpbnaJpxwBluu/U ZYtNd3mcoTqVu8PBJtlUTrHofunPHMexhPY4S8jexHneKi6Di6BAYlkOgCAUfTLxiBqt aqvA== 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 w21si2082299edc.93.2019.09.20.12.00.56; Fri, 20 Sep 2019 12:01:21 -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 S2408554AbfITJ0G (ORCPT + 99 others); Fri, 20 Sep 2019 05:26:06 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:55850 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2408503AbfITJZf (ORCPT ); Fri, 20 Sep 2019 05:25:35 -0400 Received: from DGGEMS406-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 8CF3B624368C4D3EB17C; Fri, 20 Sep 2019 17:25:34 +0800 (CST) Received: from huawei.com (10.175.124.28) by DGGEMS406-HUB.china.huawei.com (10.3.19.206) with Microsoft SMTP Server id 14.3.439.0; Fri, 20 Sep 2019 17:25:24 +0800 From: Jason Yan To: , , , , , , , , CC: , , , , , , , Jason Yan Subject: [PATCH v7 09/12] powerpc/fsl_booke/kaslr: support nokaslr cmdline parameter Date: Fri, 20 Sep 2019 17:45:43 +0800 Message-ID: <20190920094546.44948-10-yanaijie@huawei.com> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190920094546.44948-1-yanaijie@huawei.com> References: <20190920094546.44948-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/mm/nohash/kaslr_booke.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/arch/powerpc/mm/nohash/kaslr_booke.c b/arch/powerpc/mm/nohash/kaslr_booke.c index aa1b60c782e7..4a75f2d9bf0e 100644 --- a/arch/powerpc/mm/nohash/kaslr_booke.c +++ b/arch/powerpc/mm/nohash/kaslr_booke.c @@ -281,6 +281,11 @@ static unsigned long __init kaslr_legal_offset(void *dt_ptr, unsigned long index return koffset; } +static inline __init bool kaslr_disabled(void) +{ + return strstr(boot_command_line, "nokaslr") != NULL; +} + static unsigned long __init kaslr_choose_location(void *dt_ptr, phys_addr_t size, unsigned long kernel_sz) { @@ -290,6 +295,8 @@ static unsigned long __init kaslr_choose_location(void *dt_ptr, phys_addr_t size unsigned long index; kaslr_get_cmdline(dt_ptr); + if (kaslr_disabled()) + return 0; random = get_boot_seed(dt_ptr); -- 2.17.2