From patchwork Thu Apr 4 15:18:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Horatiu Vultur X-Patchwork-Id: 10885777 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D9E271669 for ; Thu, 4 Apr 2019 15:18:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C50C728712 for ; Thu, 4 Apr 2019 15:18:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B914D28AB0; Thu, 4 Apr 2019 15:18:47 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4DADB28712 for ; Thu, 4 Apr 2019 15:18:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726942AbfDDPSq (ORCPT ); Thu, 4 Apr 2019 11:18:46 -0400 Received: from esa3.microchip.iphmx.com ([68.232.153.233]:8500 "EHLO esa3.microchip.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726694AbfDDPSq (ORCPT ); Thu, 4 Apr 2019 11:18:46 -0400 X-IronPort-AV: E=Sophos;i="5.60,308,1549954800"; d="scan'208";a="29661063" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa3.microchip.iphmx.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 04 Apr 2019 08:18:46 -0700 Received: from soft-dev3.microsemi.net (10.10.76.4) by chn-sv-exch02.mchp-main.com (10.10.76.38) with Microsoft SMTP Server id 14.3.352.0; Thu, 4 Apr 2019 08:18:45 -0700 From: Horatiu Vultur To: , , , , CC: Horatiu Vultur Subject: [PATCH] arch: mips: Fix initrd_start and initrd_end when read from DT Date: Thu, 4 Apr 2019 17:18:20 +0200 Message-ID: <1554391100-10060-1-git-send-email-horatiu.vultur@microchip.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 Sender: linux-mips-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mips@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When the bootloader passes arguments to linux kernel through device tree, it passes the address of initrd_start and initrd_stop, which are in kseg0. But when linux kernel reads these addresses from device tree, it converts them to virtual addresses inside the function __early_init_dt_declare_initrd. At a later point then in the function init_initrd, it is checking for initrd_start to be lower than PAGE_OFFSET, which for a 32 CPU it is not, therefore it would disable the initrd by setting 0 to initrd_start and initrd_stop. The fix consists of checking if linux kernel received a device tree and not having enable extended virtual address and in that case convert them back to physical addresses that point in kseg0 as expected. Signed-off-by: Horatiu Vultur --- arch/mips/kernel/setup.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/arch/mips/kernel/setup.c b/arch/mips/kernel/setup.c index 8d1dc6c..b232784 100644 --- a/arch/mips/kernel/setup.c +++ b/arch/mips/kernel/setup.c @@ -264,6 +264,17 @@ static unsigned long __init init_initrd(void) pr_err("initrd start must be page aligned\n"); goto disable; } + + /* + * In case the initrd_start and initrd_end are read from DT, + * then they are converted to virtual address, therefore convert + * them back to physical address. + */ + if (!IS_ENABLED(CONFIG_EVA) && fw_arg0 == -2) { + initrd_start = __pa(initrd_start); + initrd_end = __pa(initrd_end); + } + if (initrd_start < PAGE_OFFSET) { pr_err("initrd start < PAGE_OFFSET\n"); goto disable;