From patchwork Tue May 9 17:29:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liviu Dudau X-Patchwork-Id: 13236051 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C3BA7C77B7C for ; Tue, 9 May 2023 17:45:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229523AbjEIRpC (ORCPT ); Tue, 9 May 2023 13:45:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51160 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229491AbjEIRpC (ORCPT ); Tue, 9 May 2023 13:45:02 -0400 X-Greylist: delayed 600 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Tue, 09 May 2023 10:45:00 PDT Received: from smtp.dudau.co.uk (dliviu.plus.com [80.229.23.120]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 8B74430F9; Tue, 9 May 2023 10:45:00 -0700 (PDT) Received: from mail.dudau.co.uk (bart.dudau.co.uk [192.168.14.2]) by smtp.dudau.co.uk (Postfix) with SMTP id 18C8A41D13BF; Tue, 9 May 2023 18:29:44 +0100 (BST) Received: by mail.dudau.co.uk (sSMTP sendmail emulation); Tue, 09 May 2023 18:29:44 +0100 From: Liviu Dudau To: Thomas Bogendoerfer Cc: Paul Burton , John Crispin , =?utf-8?b?QXLEsW7DpyDDnE5BTA==?= , Sergio Paracuellos , linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, Liviu Dudau Subject: [PATCH] mips: Move initrd_start check after initrd address sanitisation. Date: Tue, 9 May 2023 18:29:21 +0100 Message-Id: <20230509172921.295700-1-liviu@dudau.co.uk> X-Mailer: git-send-email 2.40.0 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-mips@vger.kernel.org PAGE_OFFSET is technically a virtual address so when checking the value of initrd_start against it we should make sure that it has been sanitised from the values passed by the bootloader. Without this change, even with a bootloader that passes correct addresses for an initrd, we are failing to load it on MT7621 boards, for example. Signed-off-by: Liviu Dudau --- arch/mips/kernel/setup.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/arch/mips/kernel/setup.c b/arch/mips/kernel/setup.c index febdc5564638e..c0e65135481b7 100644 --- a/arch/mips/kernel/setup.c +++ b/arch/mips/kernel/setup.c @@ -158,10 +158,6 @@ static unsigned long __init init_initrd(void) pr_err("initrd start must be page aligned\n"); goto disable; } - if (initrd_start < PAGE_OFFSET) { - pr_err("initrd start < PAGE_OFFSET\n"); - goto disable; - } /* * Sanitize initrd addresses. For example firmware @@ -174,6 +170,11 @@ static unsigned long __init init_initrd(void) initrd_end = (unsigned long)__va(end); initrd_start = (unsigned long)__va(__pa(initrd_start)); + if (initrd_start < PAGE_OFFSET) { + pr_err("initrd start < PAGE_OFFSET\n"); + goto disable; + } + ROOT_DEV = Root_RAM0; return PFN_UP(end); disable: