Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp773541ybh; Wed, 22 Jul 2020 12:53:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxjuOqpcSkY/j66e2vGUe/0OqSrMtUB2QWM3yXZvG04Kd6q03CX+oUW+XfD2tdgDad2WnnK X-Received: by 2002:a50:ec8b:: with SMTP id e11mr1033498edr.344.1595447594805; Wed, 22 Jul 2020 12:53:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595447594; cv=none; d=google.com; s=arc-20160816; b=eQFkASWA76iIsWogHZZJJGeDq6MDZLKX6umUud0h89HDPZXurPJevCT92D6awEjuZR ru3t84PYMMkeJN8vhKHiqYpXGNTwQsaMJ810w3dOpNxA/0KK22PAK8rqc5SSBDr9J3vl rygowGTKbKkEB25Go3jeQYd2P7hDz396JlUu8Mzm/H+hOMKq6VRCNa79HOra7TjNLjz6 PnA3Yb/vU+RycaLMMiJ5b/mLmjK7NlJ/2G6W+3oBDNnLJJ3DxfbnTvcPjNrDGR7n8PuQ J4zXnz4R732G44RmNwGNEC9Jt2HqiPQoBL7t4D/TYLd9bxmDApFI8OWd2Fg/yfboizey 7FYQ== 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 :message-id:to:from:cc:in-reply-to:subject:date:dkim-signature; bh=1cGKIJpjawJti4g8SzXEonfEdlP5yq0CvN8z5K3Dldw=; b=dRFSK8m+dzz+URtfuJQXsYh3p3J1ZoXE92veQ7tdxJY12UyC2Y2/9D/1XR6o9gX5XT td2os6I+F/rBZgutoTq6wrnTwpOj3TiC0VT2ujSPkEAampx0RtQ1RHfWblUvnbLBCxg6 04+y0GJ93oXSTO/JrxjndG9ctjZMgi9OE2KwfdZDizKEocxjXAbXq8mpWhNBB1pS9w2f 706hZx8iwKqviANdxKHQO694m4Ch3MPYLnXx10YGwokL1P4zIaaqNXJQDF3QiY/ZEqIK U30JpHqlW2LX7P9R14sUpsu9fQKS0D6OXFT4NByk6zRt5N4Ov3JSjoaqne686wu5w6LC FqCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@dabbelt-com.20150623.gappssmtp.com header.s=20150623 header.b=Yoy1F4D5; 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 q3si631219ejb.105.2020.07.22.12.52.51; Wed, 22 Jul 2020 12:53:14 -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; dkim=pass header.i=@dabbelt-com.20150623.gappssmtp.com header.s=20150623 header.b=Yoy1F4D5; 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 S1726685AbgGVTwn (ORCPT + 99 others); Wed, 22 Jul 2020 15:52:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45822 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726157AbgGVTwm (ORCPT ); Wed, 22 Jul 2020 15:52:42 -0400 Received: from mail-pg1-x543.google.com (mail-pg1-x543.google.com [IPv6:2607:f8b0:4864:20::543]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 41120C0619DC for ; Wed, 22 Jul 2020 12:52:41 -0700 (PDT) Received: by mail-pg1-x543.google.com with SMTP id j19so1844244pgm.11 for ; Wed, 22 Jul 2020 12:52:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dabbelt-com.20150623.gappssmtp.com; s=20150623; h=date:subject:in-reply-to:cc:from:to:message-id:mime-version :content-transfer-encoding; bh=1cGKIJpjawJti4g8SzXEonfEdlP5yq0CvN8z5K3Dldw=; b=Yoy1F4D5SdX59+ds7mcQz5JHUDBl4fr7U9s03rPcO/LhScRFnIG9oYi04943Pyg2ap QO8rRLplFMiQLcJhq6abEof80+wc3Cq6YgtwLMpVrrfBBOLBgDW9EtB8SRwK7b5TouNo FG7RpEdSt3aWO6VpWh5zPY+WHf6SYyc+NMhPEgpsdu+1hdfzb5rqGk7Mk2vGBCpiLMfk M2WMXdpC7+mWmSRDiq6A2yI2qfWzI9/2a5PLaIDTVfkIW+UfI26AMELRrElSVaArF2AH f+NZ0cHy9P0lcCkdQ8Agh4YYefdHQyxAnmIhKl992R0eGV3Njth6PWUOMpPlFy1YKm3v Muug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:subject:in-reply-to:cc:from:to:message-id :mime-version:content-transfer-encoding; bh=1cGKIJpjawJti4g8SzXEonfEdlP5yq0CvN8z5K3Dldw=; b=TqPXVUnlrpU4dInPM85SelmrFXRyi2JdRXc4tbejPO1zYo+rIqYujHURIS7b+uKDPW aef0Rs1H1e66wkOpVADgOhIMJYiYQnNWbfaey45fbKmDp+oH0r01A7cFLa+ocJPuwjUX /XWUK9dKHUnLr5VAJ+D9Bf+fbBYsXTcU2h2VHHp+eTfyQorEEmbgSv8NfX+udT1BoZg5 1VVloFcvlkb8O+FyFzmg+nQm8zLV967EDbDl4FNGJDH6pJ5bK0BE6p82BDqoZlRggU5x 0FECCHa7sbghD/caoBDH1FZBiupAXHJLhL7KXGYPI8iqXMPcjczanq0iXBG8sE9HOBtB Ij8Q== X-Gm-Message-State: AOAM532sNbHOdOoGG1w+dnSuZTg0g47GwW/b0+0vfIejlxpNR25G4OQ4 zWgW/vWu08qvlUIONEpu310jiw== X-Received: by 2002:a63:8c4f:: with SMTP id q15mr1206804pgn.373.1595447560352; Wed, 22 Jul 2020 12:52:40 -0700 (PDT) Received: from localhost (76-210-143-223.lightspeed.sntcca.sbcglobal.net. [76.210.143.223]) by smtp.gmail.com with ESMTPSA id q13sm443560pfk.8.2020.07.22.12.52.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Jul 2020 12:52:39 -0700 (PDT) Date: Wed, 22 Jul 2020 12:52:39 -0700 (PDT) X-Google-Original-Date: Wed, 22 Jul 2020 12:52:36 PDT (-0700) Subject: Re: [PATCH v5 1/4] riscv: Move kernel mapping to vmalloc zone In-Reply-To: CC: alex@ghiti.fr, aou@eecs.berkeley.edu, benh@kernel.crashing.org, linux-mm@kvack.org, mpe@ellerman.id.au, Anup Patel , linux-kernel@vger.kernel.org, Atish Patra , paulus@samba.org, zong.li@sifive.com, Paul Walmsley , linux-riscv@lists.infradead.org, linuxppc-dev@lists.ozlabs.org From: Palmer Dabbelt To: Arnd Bergmann Message-ID: Mime-Version: 1.0 (MHng) Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 22 Jul 2020 02:43:50 PDT (-0700), Arnd Bergmann wrote: > 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. OK, I guess maybe it's not so bad. Our 32-bit defconfig is 10MiB, but I wouldn't really put much weight behind that number as it's just a 64-bit defconfig built for 32-bit. We don't have any 32-bit hardware anyway, so if this becomes an issue later I guess we can just deal with it then. > 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. Ya, I think we decided not to do that, at least for now. I guess the right answer there will depend on what 32-bit systems look like, and since we don't have any I'm inclined to just stick to the fast option. > 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? They have the load in their mapping functions, as far as I can tell that's required to do this sort of thing. We do as well to handle some of the implicit boot stuff for now, but I was assuming that we'd want to get rid of that for performance reasons. That said, maybe it just doesn't matter?