Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp184810img; Mon, 18 Mar 2019 00:20:04 -0700 (PDT) X-Google-Smtp-Source: APXvYqyHUvqpz4tET/PMTe7zlYtQ3Tk3cjBzFE5M4u60ezumlysk0KoCGGzTuE4tNmf+xdEpS7fv X-Received: by 2002:a63:6bc6:: with SMTP id g189mr16547305pgc.427.1552893604613; Mon, 18 Mar 2019 00:20:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552893604; cv=none; d=google.com; s=arc-20160816; b=k+JzYHj/xYCNCjEmXK26KndETn8xP5kuqy2z59BEGOgpolY8l644ZGjuXnZHpUrTyf yKaOr/G/nyae+dQJgz3/BSVhUjYXAwVu+nkGdlOsw/qA02Vl0Ipa2nvYBdCVYskdJXoi RnDOsd5a1PN2qL0LQo2LviX8ed7FtsiLAg4QzsXmjPAw5ddmLSlTdxmdE/NVMy7nVVbx S3hyJ6yFseb5niWu/bhUzFiJ91AbHSSTArwfX8g2AgTK906fh4q0Y0mNyz2lsAoaxD76 /IwGi5kn6cM2PP9t3AhI0/e7xRrSGvlL6lkHA6RmIFEdkoLtAl26fj1qMcxdNMSSBdMA rdXA== 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=hLEXDUIn+pALJ4MABs2DTPPHHdmmo7kmkwngvJhDvpc=; b=XbGPml0M7V0WLzr0CQ4QqHNeGxInl5mN1UJIbx4qpO5Egbct8XEOPM8Xmv8nchofQG xEgR+22mkVd8DTrXUfCsr2Ymbz2E1s6o9kq6nqc5n1NkR+kpLLJ2HBuTsGJjKuEzRB2S PxjX4zdEdWxHztzSXXl48igOb3WzuYslznrbPv+MtuciChTdYmBeA0oeGIwwTsBPiPvg GgFrFq7Tauf4fOpaIa9bv/RG3U4zNhh1Z7XaMlR55G8Q2EqqQGdsZNXv4CdPWhnNvrZ3 MhAOKouDiMo94OQJfEBbf8wpR6JFliGId4GVxH6A40VnC5y+LrrV+DQqTQcvEptn8tBO CwNw== 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 d12si9019248pgt.59.2019.03.18.00.19.37; Mon, 18 Mar 2019 00:20:04 -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 S1726916AbfCRHSm (ORCPT + 99 others); Mon, 18 Mar 2019 03:18:42 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:39408 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726135AbfCRHSm (ORCPT ); Mon, 18 Mar 2019 03:18:42 -0400 Received: from pps.filterd (m0098409.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x2I7GNkZ046579 for ; Mon, 18 Mar 2019 03:18:40 -0400 Received: from e06smtp03.uk.ibm.com (e06smtp03.uk.ibm.com [195.75.94.99]) by mx0a-001b2d01.pphosted.com with ESMTP id 2ra44twknp-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 18 Mar 2019 03:18:40 -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 07:18:36 -0000 Received: from b06cxnps3075.portsmouth.uk.ibm.com (9.149.109.195) 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 07:18:33 -0000 Received: from b06wcsmtp001.portsmouth.uk.ibm.com (b06wcsmtp001.portsmouth.uk.ibm.com [9.149.105.160]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x2I7IXGc26935510 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 18 Mar 2019 07:18:33 GMT Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B99FFA4054; Mon, 18 Mar 2019 07:18:33 +0000 (GMT) Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id CC798A4068; Mon, 18 Mar 2019 07:18:32 +0000 (GMT) Received: from rapoport-lnx (unknown [9.148.205.203]) by b06wcsmtp001.portsmouth.uk.ibm.com (Postfix) with ESMTPS; Mon, 18 Mar 2019 07:18:32 +0000 (GMT) Date: Mon, 18 Mar 2019 09:18:31 +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-1-anup.patel@wdc.com> <20190312220752.128141-4-anup.patel@wdc.com> <20190313183121.GB28630@rapoport-lnx> <20190314065311.GC24380@rapoport-lnx> <20190315155828.GB920@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: 19031807-0012-0000-0000-0000030425B1 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19031807-0013-0000-0000-0000213B2E09 Message-Id: <20190318071829.GF21385@rapoport-lnx> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-03-18_05:,, 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-1903180056 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. 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. > > Regards, > Anup > -- Sincerely yours, Mike.