Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp422991img; Mon, 18 Mar 2019 06:17:52 -0700 (PDT) X-Google-Smtp-Source: APXvYqxeyRTc8mJsO05cEFqnZ1pCMfK0g/Api8qeALJmLACHUfrL/lsbClw1O1l2wWjJF3gVbx8n X-Received: by 2002:a17:902:b708:: with SMTP id d8mr19352272pls.322.1552915072181; Mon, 18 Mar 2019 06:17:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552915072; cv=none; d=google.com; s=arc-20160816; b=fEkSvWtkC0PyDJ3zHkq/gTA/+dC3l4e4QkUJOT16cMFt0QOtgFne8MuxOi+6hSvW3H ETWwh8X88POHHjD+/zTSA+XyCwLqlzMLHF4HeV+wMbqkp+rWw+lpb7tAXRllv85hVvM9 yl+RenCTDvRHvi9zCez/GdztkebLnEmIg0HMZHIvydUXnW8tOJjrWyyzcd/fA3anBJMC CEiqVjXkk4cjDgs+9l1qx4aR9c1gxz6fjLswrE7dK6EL8mH4E3AGCXFAzqd5iKg0rdOT nnJHOmkdQlLXzAxvfbsf1sGDTGzDcNOCP0U8JQrKRqnEOwtIFM3jAAoprSeEbK2WaTKE OtNg== 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:dkim-signature; bh=g64YoHzuEN2SBtL+x9K2khDJvdrcnFpjx98k9Faec1E=; b=uIh147yqN2/4nyvb8PeyPQk3WGoc/oAB2PvdjrOJErdiImNxKiXZetWbyyNT8bJhA5 9AcqcltlBLptxn9YWlPhPi4dikXIOqy1mRIbPdZciL6ndg+AbwyWNAsa/vt1t9EvgbNA qMr/M44l27ErEtA6ZsjihJEqBiA3iID0gWpStaWHzj4XK2wlalurmu7linNX5nQU100P VahTJBkMHNPeQxfZdgwUrE4THSmppUJKwyyRPoV/4q/5bfdLum/7cYOygw/YBk/+TnPk KmaVE2/f6otB5vucORIgnFFhadIBnjE36cb2THaDW5XaQF/E23+9W99hj7xq6hBvZmPQ /gkg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@brainfault-org.20150623.gappssmtp.com header.s=20150623 header.b=IjQ7m1re; 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 i97si9816114plb.213.2019.03.18.06.17.36; Mon, 18 Mar 2019 06:17:52 -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; dkim=pass header.i=@brainfault-org.20150623.gappssmtp.com header.s=20150623 header.b=IjQ7m1re; 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 S1726889AbfCRNQb (ORCPT + 99 others); Mon, 18 Mar 2019 09:16:31 -0400 Received: from mail-wm1-f67.google.com ([209.85.128.67]:37759 "EHLO mail-wm1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726643AbfCRNQb (ORCPT ); Mon, 18 Mar 2019 09:16:31 -0400 Received: by mail-wm1-f67.google.com with SMTP id v14so4233100wmf.2 for ; Mon, 18 Mar 2019 06:16:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brainfault-org.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=g64YoHzuEN2SBtL+x9K2khDJvdrcnFpjx98k9Faec1E=; b=IjQ7m1re3QhOrFkjpRa8gPCk6ZQg94EHRttEgzMETq750OcSRs860cr7WChXMyjPIm 1NAN9/3JR9ghnYd19PZOReUrZ0BFjTVfJA9XjJ36v1IfnTlhBN0z4z6STrcXJoIDjSnW lKoRkDH6FcFD5MIRRXXIuzNW41mm4+bA/12zDi4OpoF0drDEDvzkaZ57QAmkyO1tEn85 pFyIY7+O8MvEBRRhlL2J7+GFibduEh5BYVgW7fVHbpXUK10kuYSkBCL9gVvoN+wFwlHp xbl1wEIQJXKqicKJDzoF2o3ShaLzX1Tw2hWZdrYGUiU+6UiYC0dz2HEg26bxNIl46Ewg mWJg== 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=g64YoHzuEN2SBtL+x9K2khDJvdrcnFpjx98k9Faec1E=; b=qkKPQEDNyTuqQ91T58y0p0VaWAmogTNvii65yJUMtfqhHhOB6UeZIUud8YwsJsMATY HHP7qHA1jqcI7VF5af1FSxqhdYujew30RuQ+ws4QRLmQPHdMeFgMpwHFxZ1YbcMLF1DI 41dw588OhntVEkfoS4+rBpcBWffSg3LU84KH08ChGG4/4FPl08KVjO/K56X1KvUKjigR tgBtF9a8pM3TiKWEuyUSYcA5ZbYDTKoTO9JSAuYJeJ4c+uAHedoAbBlaZQgTL0GjgeZg 4HmLr7crdDWtyjixJGwUDAgb6m9lnHvfrgpADSbHyE/1ML5tMh9VVGpl36lXgxfrnu6J sOeg== X-Gm-Message-State: APjAAAVoI28xQxF8P9g2gXlvdP6YSBdZQjuc7mEDeXkvn9KM/+mR6h6d +HQECyguJ0D/0xQMYwCHR/e0iJFvpj1xxvO6CBm0ng== X-Received: by 2002:a1c:700e:: with SMTP id l14mr10370733wmc.132.1552914989569; Mon, 18 Mar 2019 06:16:29 -0700 (PDT) MIME-Version: 1.0 References: <20190312220752.128141-1-anup.patel@wdc.com> <20190312220752.128141-4-anup.patel@wdc.com> <20190313183121.GB28630@rapoport-lnx> <20190314065311.GC24380@rapoport-lnx> <20190315155828.GB920@rapoport-lnx> <20190318071829.GF21385@rapoport-lnx> In-Reply-To: <20190318071829.GF21385@rapoport-lnx> From: Anup Patel Date: Mon, 18 Mar 2019 18:46:18 +0530 Message-ID: Subject: Re: [PATCH 3/3] RISC-V: Allow booting kernel from any 4KB aligned address To: Mike Rapoport Cc: Anup Patel , Palmer Dabbelt , Albert Ou , Atish Patra , Paul Walmsley , Christoph Hellwig , "linux-riscv@lists.infradead.org" , "linux-kernel@vger.kernel.org" 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 On Mon, Mar 18, 2019 at 12:48 PM Mike Rapoport wrote: > > On Sat, Mar 16, 2019 at 04:55:30AM +0530, Anup Patel wrote: > > On Fri, Mar 15, 2019 at 9:52 PM Anup Patel wrote: > > > > > > On Fri, Mar 15, 2019 at 9:28 PM Mike Rapoport wrote: > > > > > > > > I still don't get why it is that important to relax alignment of the kernel > > > > load address. Provided you can use the memory below the kernel, it really > > > > should not matter. > > > > > > Irrespective to constraint on kernel load address, we certainly need > > > to allow memory below kernel to be usable but that's a separate change. > > > > > > Currently, the memory below kernel is ignored by > > > early_init_dt_add_memory_arch() in > > > drivers/of/fdt.c > > > > > > > I explored the possibility of re-claiming memory below kernel but then > > we have an issue in this case. > > > > For RISC-V kernel, PAGE_OFFSET is mapped to kernel load address > > (i.e. load_pa in this code). The va_pa_offset is based on load_pa so linear > > conversion of VA-to-PA and PA-to-VA won't be possible on the memory > > below kernel. I guess this is why early_init_dt_add_memory_arch() is > > marking memory below kernel as reserved. Is there better way to do it?? > > > > We started exploring ways to re-claim memory below kernel because > > we are trying to get Linux working on Kendryte K210 board > > (https://kendryte.com/). This board has dual-core 64bit RISC-V but it > > only has 8MB RAM. > > Huh, 8MB of RAM is tough... > > It is possible to use the memory below the kernel, e.g x86-64 does that. > But it is definitely a separate change and with such RAM diet using 4K > pages seems unavoidable. > > I still have concern about using 4K pages whenever the load address is not > 2M (4M) aligned. People tend to not pay enough attention to such details > and they would load the kernel at an arbitrary address and get the > performance hit. > > I think the default should remain as is and the ability to map the kernel > with 4K pages (and use 4K aligned load address) should be a Kconfig option. I agree people will tend to not pay attention on the load address alignment but this is also possible with current approach. Currently, if user boots kernel form any non-2M aligned address then we don't see any prints at all which let's users think it to be kernel bug. In fact, I have done same mistake couple of times. Another approach (apart from kconfig option) would be to throw big-fat warning when users boot kernel form 4K aligned load address this way atleast kernel boots instead of no prints. Your thoughts?? > > Another thing I'd like to suggest is to completely split swapper_pg_dir > initialization from setup_vm() and keep this function solely for > initialization of the trampoline_pg_dir. The trampoline_pg_dir can use > large pages and the memory below the kernel start can be mapped there > simply by mapping the entire large page containing the kernel start. > Then, the swapper_pg_dir setup can run with virtual memory enabled and can > have much more flexibility. Sure, this is a good suggestion. I will add this as separate patch in this series. Regards, Anup