Received: by 2002:a25:86ce:0:0:0:0:0 with SMTP id y14csp167860ybm; Wed, 22 May 2019 00:52:00 -0700 (PDT) X-Google-Smtp-Source: APXvYqyoC3omnj+eXPreOxdL5edh47ApiACOAfrZW7YU9lHDRYgqipSwdJxg2vLE0pqnh4tE/DlZ X-Received: by 2002:a63:2248:: with SMTP id t8mr44936077pgm.358.1558511520401; Wed, 22 May 2019 00:52:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558511520; cv=none; d=google.com; s=arc-20160816; b=b1uukLKX0UoQzeSsfzeXylhYs7C4nM53hUfdzeVnpdkNg+B0+DBoF5WEqb9Jt2bRiL br9fNc+QIU5PA5UIEulqgJTLACRzZ81dt/rnF8PIxwWtCvRcSwvWp0zpol3FL5gBaQTA xe2H2lm6+P5MdG4O301hArqZGibUzv70BkX4Lar9oiNGhI0gk64SofwQGmL3MXLzzVMJ t/XVFaJV+p/nJLKrMt0WuLpD9iG+5cEFPiVxRMyNXNVQjx2iaR88BokRpj7Qx38297c4 7Bh+SYkSNhjyVJ+0ZPsGx19ttOHDkGuRg7CzVedtn0pZSYYy0Fh2dozdjQMNxTk4H95y k9jQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version; bh=VaX5n9Y4+kdsUYd/DwkTtH11TWtmPeaSdyXahzJcElc=; b=rFx5g6vRFr7+mc1haWma/9K9fRYPQGaAgfXxb5XHUnCG1R6DWSkoyyVP7l2FdgH//Z ya1sqkp+SITgdzSteZtjW78gYyaW1O1n6VXp1uFBujFNpUCqP84DffucNa5ofA6Jmq7l MyHGto8M4VZrfSpuBIxUdGzVspJyOeim9uw137Yy8gbvYdZmOAkkz7gL/lw3s0vKShU3 RDuLLfxNgSim5dXdzIlVbb3IU7JRSFmlJhRSPHq8GCP6EfCS8JI0a8o4mnfyON6OUOuD h+JDuO+lBX0RtQVp98RNz0gRsYrCrOQvdMCPhiMtJN8xauiw5WyYoup0zjNGuQOQP29t 2eTw== 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 r3si23336359plb.121.2019.05.22.00.51.44; Wed, 22 May 2019 00:52:00 -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 S1728654AbfEVHua (ORCPT + 99 others); Wed, 22 May 2019 03:50:30 -0400 Received: from mail-vs1-f68.google.com ([209.85.217.68]:42672 "EHLO mail-vs1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726514AbfEVHua (ORCPT ); Wed, 22 May 2019 03:50:30 -0400 Received: by mail-vs1-f68.google.com with SMTP id z11so828157vsq.9; Wed, 22 May 2019 00:50:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=VaX5n9Y4+kdsUYd/DwkTtH11TWtmPeaSdyXahzJcElc=; b=J6SZ4MFkN0QH+9oAJxgWMX+ZnSOj8Ger0hdktNpn6Ai/6FrBdK4gZbY7aVkvgXfV87 PIruYTXy2F4CCYZ8md872K3TqMoS3ktRBzBLBuGYa9/vj4trKugnwehCBGoQ5joSPvFz GYHXoyxdES6s/sfCtFA4nlhCUVRD8b7JmU06V70xmZmmuXqH1dGGy5Afq/BYcl57Cqko DMzoyZzHQFaEBG9jJrI2hgy7hCvvB0aHn4N8j6KI7msx74yPLCNwMUM6LgzhP6l6H0AK fyYAmqurPjZcfcy06UFzzxtsaLLo1bYKsMSR3QCp5296E7/GeV42qa97NqNyosTjltdK jyew== X-Gm-Message-State: APjAAAX1pc+PSMJ4Fz9xgTGxKgAFTRk2YgyDCqUhqRCq86+GMdPiAHJg vDdR40R8Yv38nsx5tbD0hjDad3AZI2YVGDcmSnQ= X-Received: by 2002:a67:f589:: with SMTP id i9mr11310444vso.152.1558511429417; Wed, 22 May 2019 00:50:29 -0700 (PDT) MIME-Version: 1.0 References: <20190423224748.3765-1-fancer.lancer@gmail.com> <20190423224748.3765-5-fancer.lancer@gmail.com> <20190521155309.GB24470@rapoport-lnx> <20190521163928.yo75uskjachtw2nt@mobilestation> In-Reply-To: <20190521163928.yo75uskjachtw2nt@mobilestation> From: Geert Uytterhoeven Date: Wed, 22 May 2019 09:50:17 +0200 Message-ID: Subject: Re: [PATCH 04/12] mips: Reserve memory for the kernel image resources To: Serge Semin Cc: Mike Rapoport , Ralf Baechle , Paul Burton , James Hogan , Matt Redfearn , Andrew Morton , Michal Hocko , Greg Kroah-Hartman , Thomas Bogendoerfer , Huacai Chen , Stefan Agner , Stephen Rothwell , Alexandre Belloni , Juergen Gross , linux-mips@vger.kernel.org, Linux Kernel Mailing List , Atsushi Nemoto Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Serge, On Tue, May 21, 2019 at 6:39 PM Serge Semin wrote: > On Tue, May 21, 2019 at 06:53:10PM +0300, Mike Rapoport wrote: > > On Tue, May 21, 2019 at 04:56:39PM +0200, Geert Uytterhoeven wrote: > > > On Wed, Apr 24, 2019 at 12:50 AM Serge Semin wrote: > > > > The reserved_end variable had been used by the bootmem_init() code > > > > to find a lowest limit of memory available for memmap blob. The original > > > > code just tried to find a free memory space higher than kernel was placed. > > > > This limitation seems justified for the memmap ragion search process, but > > > > I can't see any obvious reason to reserve the unused space below kernel > > > > seeing some platforms place it much higher than standard 1MB. Moreover > > > > the RELOCATION config enables it to be loaded at any memory address. > > > > So lets reserve the memory occupied by the kernel only, leaving the region > > > > below being free for allocations. After doing this we can now discard the > > > > code freeing a space between kernel _text and VMLINUX_LOAD_ADDRESS symbols > > > > since it's going to be free anyway (unless marked as reserved by > > > > platforms). > > > > > > > > Signed-off-by: Serge Semin > > > > > > This is now commit b93ddc4f9156205e ("mips: Reserve memory for the kernel > > > image resources") in v5.2-rc1, which causes rbtx4927 to crash during boot: > > > > > > VFS: Mounted root (nfs filesystem) on device 0:13. > > > devtmpfs: mounted > > > BUG: Bad page state in process swapper pfn:00001 > > > page:804b7820 refcount:0 mapcount:-128 mapping:00000000 index:0x1 > > > flags: 0x0() > > > raw: 00000000 00000100 00000200 00000000 00000001 00000000 ffffff7f 00000000 > > > page dumped because: nonzero mapcount > > > Modules linked in: > > > CPU: 0 PID: 1 Comm: swapper Not tainted > > > 5.2.0-rc1-rbtx4927-00468-g3c05ea3d4077b756-dirty #137 > > > Stack : 00000000 10008400 8040dd2c 87c1b974 8044af63 8040dd2c > > > 00000001 804a3490 > > > 00000001 81000000 0030f231 80148558 00000003 10008400 > > > 87c1dd80 7599ee13 > > > 00000000 00000000 804b0000 00000000 00000007 00000000 > > > 00000085 00000000 > > > 62722d31 00000084 804b0000 39347874 00000000 804b7820 > > > 8040cef8 81000010 > > > 00000001 00000007 00000001 81000000 00000008 8021de24 > > > 00000000 804a0000 > > > ... > > > Call Trace: > > > [<8010adec>] show_stack+0x74/0x104 > > > [<801a5e44>] bad_page+0x130/0x138 > > > [<801a654c>] free_pcppages_bulk+0x17c/0x3b0 > > > [<801a789c>] free_unref_page+0x40/0x68 > > > [<801120f4>] free_init_pages+0xec/0x104 > > > [<803bdde8>] free_initmem+0x10/0x58 > > > [<803bdb8c>] kernel_init+0x20/0x100 > > > [<801057c8>] ret_from_kernel_thread+0x14/0x1c > > > Disabling lock debugging due to kernel taint > > > BUG: Bad page state in process swapper pfn:00002 > > > [...] > > > > > The root cause of the problem most likely is in prom_free_prom_memory() method of > arch/mips/txx9/generic/setup.c: > void __init prom_free_prom_memory(void) > { > unsigned long saddr = PAGE_SIZE; > unsigned long eaddr = __pa_symbol(&_text); > > if (saddr < eaddr) > free_init_pages("prom memory", saddr, eaddr); > } > > As you can see the txx9 platform tries to free a memory which isn't reserved > and set free from the very beginning due to the patch above. So as soon as you > remove the free_init_pages("prom memory", ...) the problem shall be fixed. > Could you try it and send a result to us whether it helped? Thanks, that does the trick! Will send a patch shortly... Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds