Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp370535ybh; Wed, 22 Jul 2020 02:47:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxTyxFWMvhlSebNnjXT/9uViuz63JgPbVslsilX5iJBYyENVn7+cVGS6dmjCk2sLjDTv8bT X-Received: by 2002:a17:906:ca56:: with SMTP id jx22mr28377459ejb.494.1595411221502; Wed, 22 Jul 2020 02:47:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595411221; cv=none; d=google.com; s=arc-20160816; b=AFp5LKPEDM/L2ppAezJhPtmX1AnVAGFnKR+WxSMdNXUGm7TsAiewJnV63BZo5otN4r tp03xm63mnDVypWsmljaxrMBXSD5MW8Rc4gUh7MwsyUFKMtF6Lv0MMyE4UGLn64mOxG0 DE5DKI39ob1xgIhvzlMPXDsi6SdOtbrI3I4noTfuu4sMq2vTSbM8aXLGX/vGYHT8Qfas vKgDzEqbdZm2acBIMrS12AegVST6cEkZ3wsmUbahw1X8PSGWtKlXPWW2rIhG+HpzXmdm aoIp/3KR+SErlTyGgzpmUKqi1c9oH1ldRcemP7WufCdqzFMcZ+dWr0hTuDykY0Kn4t5C bJgg== 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; bh=KgyS91+5Z2BgwLwOHb/+0uw/4r/LJSOO17QhwOW8gMA=; b=b2Gh72Heb8dwhlDLTIqvRjTXUlkf2vBZJkfems8KWh4temzQJelvKFgx+PZChP436W +JunwEjOUDDqAJ20xHTz1LEWj6loNmLEg4vaNQs+OO2wUUXblx8kgtxM/UOYbC++5/nT XE2Zr5wa7hwT5DLR4D8g/Xu+5e5EAX7YJbCngSDRw9nWY+sordb9fFCHWKAr2zHXLMh+ JQ/YE0SYPxuI5FHd1ZbuYqLUaDA8fJUqIDiDUinkxJJSV/9s55ghu7thaNOPtgZz+hWJ Abr2FLtM4h6kQBzzXmwR7XH1Vu/+Y2SlWylQzkROzmcMihhR+tTfCIaUUqVKtBiiB21W jrXw== 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 cn1si13919578edb.354.2020.07.22.02.46.38; Wed, 22 Jul 2020 02:47:01 -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 S1731439AbgGVJoK (ORCPT + 99 others); Wed, 22 Jul 2020 05:44:10 -0400 Received: from mout.kundenserver.de ([212.227.17.13]:40587 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727819AbgGVJoK (ORCPT ); Wed, 22 Jul 2020 05:44:10 -0400 Received: from mail-qt1-f174.google.com ([209.85.160.174]) by mrelayeu.kundenserver.de (mreue106 [212.227.15.145]) with ESMTPSA (Nemesis) id 1M3DeV-1jxLwj0sXt-003bxP for ; Wed, 22 Jul 2020 11:44:08 +0200 Received: by mail-qt1-f174.google.com with SMTP id o22so1094451qtt.13 for ; Wed, 22 Jul 2020 02:44:08 -0700 (PDT) X-Gm-Message-State: AOAM532xPoNGxTTlGnE/1BHACRiL6bGtjvM/0Xc6QV3O1glN11ttle9s ALfjToL5QDcHRMh5YNg8oWp7yQYAq3bEznfkQ/0= X-Received: by 2002:ac8:7587:: with SMTP id s7mr33522432qtq.304.1595411047084; Wed, 22 Jul 2020 02:44:07 -0700 (PDT) MIME-Version: 1.0 References: <7cb2285e-68ba-6827-5e61-e33a4b65ac03@ghiti.fr> In-Reply-To: From: Arnd Bergmann Date: Wed, 22 Jul 2020 11:43:50 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v5 1/4] riscv: Move kernel mapping to vmalloc zone To: Palmer Dabbelt Cc: Alexandre Ghiti , Albert Ou , Benjamin Herrenschmidt , Linux-MM , Michael Ellerman , Anup Patel , "linux-kernel@vger.kernel.org" , Atish Patra , Paul Mackerras , Zong Li , Paul Walmsley , linux-riscv , linuxppc-dev Content-Type: text/plain; charset="UTF-8" X-Provags-ID: V03:K1:UdL+knbubfZO1AGP4zdXTM6MPoW1ddEKSJ9gnTlGDCvNqCZOZEw h7xYd4Z82KexpL1F5SWl0llW+VV4zjyqCDMNJgmfoWPfeyfElOaHZbUNEPml4/4BVHj9NTd u9ZLALnOmGXCNNalKf5YntaxDIT7NGyXxFtlRqLPMC3f4VI8Yu/bPk3ndzTtLuwo7145vO8 t7fnWFT+GXcm+NrVfwyeA== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1;V03:K0:rPhSp6j4HFc=:D0mTTq/+TBMJicx/ruZrBq prQE0fqVtH6TDtF3OUlsR7jsujvzoc645Jnvc3Vqje2ezGonwPEE4a7UIJpa8+yfSg5vrEN0a eK0BLZBXp95dHTewqa5V35SafwaZOLccXVxNl4S5cA+HH7hVvbONC2WmJBQRPZkr24wT+1tgx M2xPKgJOj1SlSHkALc1OZ1wAGpMqlFqFr8rrnwH0c2uaMvTfBbqWiMqV3ntjwvkvn77yd1bO+ UsWyxG7WumXCbTvEKRgtOMy8T70Df2fvSgP9kerk6NmFLXyL3fmMNW7oiSqYrORTApMXuaI2m q+UAgYIU1UfyQzoyGo9xvBm2yF6Ecie2Ckh75gYP9lh5UkXIBMiKzMpvxQpZtd9LEo0S0YtWL fxmrC3gbJ696D8HDsDzwyVhLh3XjIBSpSXN7N/OW8TfaRsM+OLdmrCFAeZWXT9ZbmV1ybi4n4 c5exjUWTWLCMRiDXddMkfJCIJzX+VYZui1Snp97S/wm4QvYKTty08WqzCYU64qnLHw/NyM0So ziKJpHbWO4fZfQvGW+NNdhxJLEc43WbXF9QFDZn50Vik9Qpt7QBGT726iuitsvLADAO0VH5dc 10SsKjwPJ25UDm7XNV8gy+KIbO+JdTAOw+uobVWvSofgomKHzEnEH4sg8vAzUQTBMa+FKfhRs h5reHE1hloNRWlvs44zN0bsC42YgNtdYwtx6XRD1rfgpblqf1Dvx7Z/Z1A57f/VmP7gaDDu8i qBvIGAIHqG2vwQmP5Gop4pYDICQvWuNpYYH+PEYkJc00HJIGgQc1GPux7cEvG8f79Cz/Elj7l wxADClbXeRepMILenVuXdmwyNNkhK4vzg4qQub6j82lUlbI4wUi+3nfRwFeLLjybfUb6riuQ+ FPMeGfR0QFe0hFF5laLv0ZCi2/dCI6gaK73A34Pp1CbY6yyfbgot8CukGda1vDGNX+eY4/t3N 5r2cKbCbrUzQxEwylj+veETrpqYCgh8kSw505JfTHgJaoqdCvKwMv Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jul 21, 2020 at 9:06 PM Palmer Dabbelt wrote: > > On Tue, 21 Jul 2020 11:36:10 PDT (-0700), alex@ghiti.fr wrote: > > Let's try to make progress here: I add linux-mm in CC to get feedback on > > this patch as it blocks sv48 support too. > > Sorry for being slow here. I haven't replied because I hadn't really fleshed > out the design yet, but just so everyone's on the same page my problems with > this are: > > * We waste vmalloc space on 32-bit systems, where there isn't a lot of it. There is actually an ongoing work to make 32-bit Arm kernels move vmlinux into the vmalloc space, as part of the move to avoid highmem. Overall, a 32-bit system would waste about 0.1% of its virtual address space by having the kernel be located in both the linear map and the vmalloc area. It's not zero, but not that bad either. With the typical split of 3072 MB user, 768MB linear and 256MB vmalloc, it's also around 1.5% of the available vmalloc area (assuming a 4MB vmlinux in a typical 32-bit kernel), but the boundaries can be changed arbitrarily if needed. The eventual goal is to have a split of 3840MB for either user or linear map plus and 256MB for vmalloc, including the kernel. Switching between linear and user has a noticeable runtime overhead, but it relaxes both the limits for user memory and lowmem, and it provides a somewhat stronger address space isolation. Another potential idea would be to completely randomize the physical addresses underneath the kernel by using a random permutation of the pages in the kernel image. This adds even more overhead (virt_to_phys may need to call vmalloc_to_page or similar) and may cause problems with DMA into kernel .data across page boundaries, > * Sort out how to maintain a linear map as the canonical hole moves around > between the VA widths without adding a bunch of overhead to the virt2phys and > friends. This is probably going to be the trickiest part, but I think if we > just change the page table code to essentially lie about VAs when an sv39 > system runs an sv48+sv39 kernel we could make it work -- there'd be some > logical complexity involved, but it would remain fast. I assume you can't use the trick that x86 has where all kernel addresses are at the top of the 64-bit address space and user addresses are at the bottom, regardless of the size of the page tables? Arnd