Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp576252img; Mon, 18 Mar 2019 09:28:37 -0700 (PDT) X-Google-Smtp-Source: APXvYqxgflVxUuSpjzwg/QXoBUZvE0N+rbwgKsBQTxMihM7t/MsYEdHNWqvBYgPm11VOha3UnDJY X-Received: by 2002:a17:902:8c8a:: with SMTP id t10mr21055522plo.160.1552926517472; Mon, 18 Mar 2019 09:28:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552926517; cv=none; d=google.com; s=arc-20160816; b=oYWn5xEE7cZLTsw3m/QnRvGRvMkq54Ta0KGLl+a3N9ewc9F4NOTHdPtZ5I7vVc5W0L 6XEAuHFAfCWgd+/aJtD7D5M6xKQAhU4cZfmyEvlADPj4CkcK0xDtmFNZlYsLn2/l5xfc izv/bHahPF3z0uiBvJ8GbdEOT+mQeZixYmM6O/VJLfI4pJ5jl41ick5NE56PlxDXlPBG J1TAmrmwywMRWLlscogt9MPpUu2BL93Msz+JI7ecVhtps/+yP2/1+Fzk9MibTWkdFzal 7qTUcM91nOWa5uxPbNLRplz3NOkOeBhCgPaz4500kppUKtDX+V75R4JQJck4Odria16z Z8rQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:user-agent:in-reply-to :content-disposition:mime-version:references:subject:cc:to:from:date; bh=fCppToRgY5mOzvRA9QY4d6tBKdf+hazpLyhyhXv0Uhc=; b=uyjGgUDGncNRi9hyA0gTSHRrUQqHLuVGmF5tKw+n3Jre0jBnR52oBI6UwEBNG4FZde SrB1PCjy5R8kz9nsPhbady2WHopkPpBQl2AKNvOZrBIJtVtUhFsxcIdsoaGAohiy81p/ Bvwj+5fijOHhTzh8rgIg5q4IrFl3EV/dcY/N8+2FNYXrsd6f/0U0hXdVTVkBTXy/BWOd 7ZLY2KW1GSf3GWVufDcpOx+iqfu7NK6YzdmRxF7muot6qsBKjogXkoXAGp4sngUSn/+A NXHF8zlX+oCcIMA3qQT33oi1seSQ2FxXD6fKFMDAQDu3Q6Q4ImntsITOXcOmnPPEAvIf h2Sw== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l7si9443428pff.162.2019.03.18.09.28.21; Mon, 18 Mar 2019 09:28:37 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727244AbfCRQ1o (ORCPT + 99 others); Mon, 18 Mar 2019 12:27:44 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:37298 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726719AbfCRQ1o (ORCPT ); Mon, 18 Mar 2019 12:27:44 -0400 Received: from pps.filterd (m0098404.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x2IGKOqY066648 for ; Mon, 18 Mar 2019 12:27:43 -0400 Received: from e06smtp03.uk.ibm.com (e06smtp03.uk.ibm.com [195.75.94.99]) by mx0a-001b2d01.pphosted.com with ESMTP id 2racc3qv6v-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 18 Mar 2019 12:27:42 -0400 Received: from localhost by e06smtp03.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 18 Mar 2019 16:27:38 -0000 Received: from b06cxnps4076.portsmouth.uk.ibm.com (9.149.109.198) by e06smtp03.uk.ibm.com (192.168.101.133) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Mon, 18 Mar 2019 16:27:35 -0000 Received: from d06av24.portsmouth.uk.ibm.com (mk.ibm.com [9.149.105.60]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x2IGRZ4K36110512 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 18 Mar 2019 16:27:35 GMT Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id AB06A42041; Mon, 18 Mar 2019 16:27:35 +0000 (GMT) Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C6F7242042; Mon, 18 Mar 2019 16:27:34 +0000 (GMT) Received: from rapoport-lnx (unknown [9.148.205.228]) by d06av24.portsmouth.uk.ibm.com (Postfix) with ESMTPS; Mon, 18 Mar 2019 16:27:34 +0000 (GMT) Date: Mon, 18 Mar 2019 18:27:33 +0200 From: Mike Rapoport To: Anup Patel Cc: Anup Patel , Palmer Dabbelt , Albert Ou , Atish Patra , Paul Walmsley , Christoph Hellwig , "linux-riscv@lists.infradead.org" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH 3/3] RISC-V: Allow booting kernel from any 4KB aligned address References: <20190312220752.128141-4-anup.patel@wdc.com> <20190313183121.GB28630@rapoport-lnx> <20190314065311.GC24380@rapoport-lnx> <20190315155828.GB920@rapoport-lnx> <20190318071829.GF21385@rapoport-lnx> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) X-TM-AS-GCONF: 00 x-cbid: 19031816-0012-0000-0000-000003045A51 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19031816-0013-0000-0000-0000213B6537 Message-Id: <20190318162732.GB4408@rapoport-lnx> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-03-18_11:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1903180121 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 06:46:18PM +0530, Anup Patel wrote: > 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?? That should be panic() rather than warning. If the trampoline_pg_dir will map everything, it can be emitted during the initialization of swapper_pg_dir. > > > > 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 > -- Sincerely yours, Mike.