Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp55877ybh; Tue, 21 Jul 2020 16:16:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzL0GtZH8b9o3XA+yn7LwhaPoV+1DTfgu8i/B1yNri4upsAuYyDLx8s8/ucjxVzdzxFADJi X-Received: by 2002:a17:906:6b95:: with SMTP id l21mr28224643ejr.32.1595373371820; Tue, 21 Jul 2020 16:16:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595373371; cv=none; d=google.com; s=arc-20160816; b=cGdyOyVxiDROH4AaXVwptCOEGdqCxwJx/6GK8twVEIPMFs4hdOQblmvMeNGRDDtxb2 t60ounG1kPnKfrrpCaQlzJxvkwcSYaWalr1yMFgfgxbXIcb/8+mFl44lp4C0Eg2j9cUT pgx0W56GmkEoiqZIHKyH5W9tI89HbRxs/FgkYE++yjrn2pKZwIvMxq3/e5NkXD6pf55E /O1pOUJAFH0LXg5POsIC//7PNDVL9K2vM0oHErP6thUqT8vRX8NV4yp6cpjynvdrsKtx 8DI1FiNfuI9WRWm9qA0L5gG8dwJQ9pLFkp6SRtdkDlucwXc+sE46wkMLGy4D/gSdSKCQ GBmg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:date:cc:to:from:subject:message-id; bh=JANQOgoffzGKE7pjUd+kUnJE/Gq9eeWtR63pIxjRhlM=; b=qssvJOWxhXCAPesRw5fRnTYttns5+cJi5S31GqXJwbHJh+RHbu/9QIdvC6oxbUCQjR jmBa7nCkCdg4gTmd9+IBGxOFuBWjN2o2hDY45/rg2LuEdYEdZn7V2nRq1FczTbAiuLwx pbN1vMxKWvaFCNrDDUiKbGVeOHP+ok2m5OlpKOy6hI2KIx5COtPXqE0nxXDS34T6kH9m 0M4n8XUITGVACgmI4PxYhhY9mHffRf15IJtkP3TYn6Eaz0CiNhWXrGFRnIiYTBw0yf4l QsvBka223A2GhnsM5g21GZF3cG7EumOjcJj/ACMaBF8QcMzNOkmSgJsAvsmwbQJROIet g4/Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b21si13322373eds.107.2020.07.21.16.15.48; Tue, 21 Jul 2020 16:16:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731406AbgGUXML (ORCPT + 99 others); Tue, 21 Jul 2020 19:12:11 -0400 Received: from kernel.crashing.org ([76.164.61.194]:41664 "EHLO kernel.crashing.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726148AbgGUXML (ORCPT ); Tue, 21 Jul 2020 19:12:11 -0400 Received: from localhost (gate.crashing.org [63.228.1.57]) (authenticated bits=0) by kernel.crashing.org (8.14.7/8.14.7) with ESMTP id 06LNB4EP017146 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 21 Jul 2020 18:11:11 -0500 Message-ID: <54af168083aee9dbda1b531227521a26b77ba2c8.camel@kernel.crashing.org> Subject: Re: [PATCH v5 1/4] riscv: Move kernel mapping to vmalloc zone From: Benjamin Herrenschmidt To: Alex Ghiti , Palmer Dabbelt Cc: mpe@ellerman.id.au, paulus@samba.org, Paul Walmsley , aou@eecs.berkeley.edu, Anup Patel , Atish Patra , zong.li@sifive.com, linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-mm@kvack.org Date: Wed, 22 Jul 2020 09:11:02 +1000 In-Reply-To: <7cb2285e-68ba-6827-5e61-e33a4b65ac03@ghiti.fr> References: <7cb2285e-68ba-6827-5e61-e33a4b65ac03@ghiti.fr> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.28.5-0ubuntu0.18.04.2 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 2020-07-21 at 14:36 -0400, Alex Ghiti wrote: > > > I guess I don't understand why this is necessary at all. > > > Specifically: why > > > can't we just relocate the kernel within the linear map? That would > > > let the > > > bootloader put the kernel wherever it wants, modulo the physical > > > memory size we > > > support. We'd need to handle the regions that are coupled to the > > > kernel's > > > execution address, but we could just put them in an explicit memory > > > region > > > which is what we should probably be doing anyway. > > > > Virtual relocation in the linear mapping requires to move the kernel > > physically too. Zong implemented this physical move in its KASLR RFC > > patchset, which is cumbersome since finding an available physical spot > > is harder than just selecting a virtual range in the vmalloc range. > > > > In addition, having the kernel mapping in the linear mapping prevents > > the use of hugepage for the linear mapping resulting in performance loss > > (at least for the GB that encompasses the kernel). > > > > Why do you find this "ugly" ? The vmalloc region is just a bunch of > > available virtual addresses to whatever purpose we want, and as noted by > > Zong, arm64 uses the same scheme. I don't get it :-) At least on powerpc we move the kernel in the linear mapping and it works fine with huge pages, what is your problem there ? You rely on punching small-page size holes in there ? At least in the old days, there were a number of assumptions that the kernel text/data/bss resides in the linear mapping. If you change that you need to ensure that it's still physically contiguous and you'll have to tweak __va and __pa, which might induce extra overhead. Cheers, Ben.