Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp1061234ybh; Wed, 22 Jul 2020 22:24:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx0nl1osN+cX9a7Ge6mLW5Z5m1TZw3V1lsYQFMnissZBFox4CTVyGcBINCp1lMquYi6zq1x X-Received: by 2002:aa7:c98d:: with SMTP id c13mr2590627edt.188.1595481884418; Wed, 22 Jul 2020 22:24:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595481884; cv=none; d=google.com; s=arc-20160816; b=LEgBOeZnYepHMTtRrbAsuTn5v/cpPmpTx+xA9j8CX8ZXOe2rbVhbJMADH0zdAKoa94 6qibKRI5vWhLKHwAszwJsWakMzIUiq/Ev1WvCg7xoXqvKSWbIkpSF5sahJx/d8oGonMO xurt32zWA39HwAZsgkO9HIbr//I16stzCcg+CFfhmWHSehybDpsubAdRQ0Pc8RBnujQW MzAdSJMinX79JF7jKc8KD/LyNwtXOi3jw9KGJ1MizrclIiBZKYB6+UCBtBylYmXRuEh/ 6XiJvOZucpxupxHg1jDUmKRWxANaaVM9n4QrAoK//3035AEV7bKyo4J6YTL86E3IK5kM WAKw== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=d67dN9503ToLzK1DyLlplOslH8BOQvoXOO9Xki7FDQs=; b=P7CzpEOcooVL5qoWL5nRc7tjfsw+Fi9UrhvRyWQoJkEUNJxba2wzCmvt5PMxowPEr9 uQ8/bdpD1GF/HEKEdHfduMCeX+tOGK3w3pR9thyHzeFYdWmktNKgweOG3kBQDn22ovSe 3hEBziZSK/BxO/poAwZWh5vpYeoz/UUFyLKZgstdFjk+VJMJwZmew/nHisKANsjakoxj NsI3g0vt4fCBeXJJDxDnG6R4BRGZUTTDB4MjzwoLNQqxH4NFdsHMSVxTMOFqp/FkMVWo Gb0MCdU7U8/Cm1FMyBsMMJK9wovtaLbbXc3MegrLRYuBeNXilJOE/8hBQ9xMQVk4xtcG PKMQ== 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 l9si1458937ejq.427.2020.07.22.22.24.21; Wed, 22 Jul 2020 22:24:44 -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 S1726021AbgGWFWB (ORCPT + 99 others); Thu, 23 Jul 2020 01:22:01 -0400 Received: from relay3-d.mail.gandi.net ([217.70.183.195]:46983 "EHLO relay3-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725773AbgGWFWA (ORCPT ); Thu, 23 Jul 2020 01:22:00 -0400 X-Originating-IP: 90.112.45.105 Received: from [192.168.1.14] (lfbn-gre-1-325-105.w90-112.abo.wanadoo.fr [90.112.45.105]) (Authenticated sender: alex@ghiti.fr) by relay3-d.mail.gandi.net (Postfix) with ESMTPSA id 722BD60002; Thu, 23 Jul 2020 05:21:51 +0000 (UTC) Subject: Re: [PATCH v5 1/4] riscv: Move kernel mapping to vmalloc zone To: Benjamin Herrenschmidt , 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 References: <7cb2285e-68ba-6827-5e61-e33a4b65ac03@ghiti.fr> <54af168083aee9dbda1b531227521a26b77ba2c8.camel@kernel.crashing.org> From: Alex Ghiti Message-ID: Date: Thu, 23 Jul 2020 01:21:50 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <54af168083aee9dbda1b531227521a26b77ba2c8.camel@kernel.crashing.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: fr Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Benjamin, Le 7/21/20 à 7:11 PM, Benjamin Herrenschmidt a écrit : > 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 ? > ARCH_HAS_STRICT_KERNEL_RWX prevents the use of a hugepage for the kernel mapping in the direct mapping as it sets different permissions to different part of the kernel (data, text..etc). > 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. > Yes that's done in this patch and indeed there is an overhead to those functions. > Cheers, > Ben. > > Thanks, Alex