Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp313246ybg; Wed, 3 Jun 2020 01:15:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyKrrkHBjbKG+I+r7HTRoYUBT73Eh6QqiwwkSKKh0EYukrdwXEtNOuatgBHiA21uWysp6+o X-Received: by 2002:a50:e08c:: with SMTP id f12mr30152209edl.233.1591172157709; Wed, 03 Jun 2020 01:15:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591172157; cv=none; d=google.com; s=arc-20160816; b=D9FbdT/k445LNNumBHxmJat7vBg9LZu4jztxcZguT5W+JNBH7mTxNoH5EXLyPOxPPy OVjUTCcXH3p97RHLZejXuX0KYcSra942xOSd1Pken7SRYsu6b3tKa6TyZ9DK+vHx9IQb A5mr2/sUWE6iqvkqrDxQOJ1X8Kt38Ap/SQ6ubmUcD6B3KUwuhB8EAfka6kAIFE61JW/n EZrc/T+dxWLtXgwg7GcQX3VV+TO+WUCjqlEqwZDaY7LGCRcUqZAsA0V1nD7Kayb6MGoS XA7H0xiVlMIe4nuIKBZWk++MuPpKksUEx6vTy0tBPk4Zj0XeQM75hHHrsLtKKGS5uanN CcYg== 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:date:subject:cc:to:from; bh=JKPUbmfv6F+qcIVtqq07w8ROazuaiqhc4AUEbUSVA9g=; b=vRJnMElZaLjZRJA5td709YJIugkd+0fxxjZA8otmex5IlHzOTDbrkfUxJlaWT2KwO7 sLPMtReCikFaCXEEy/bO5SGBXiDv00P6nHPzP3EPsmZdFF/BQqUd0RMuSU5UYBZ53XAA KD7XKEX57o/b6uICZ6Tm33wOojwYWdWvrKjnEsHDL0+cqf6H08YLllB3Hl7Y7POquopd EGK4w/dNj09sk3ojQvxvYruyee0AnuYxCKwnvJRHVeAyPr+Zg0YbaZcmaXBQh3x8Gmx5 OBhzK158Ir6I2Ha9a3NTUnMJZiWM1OoUA4kEVKTQOcY+jYg+QapvprMnLzXV3zPJB6UU KF+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 cb1si748069ejb.42.2020.06.03.01.15.32; Wed, 03 Jun 2020 01:15:57 -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 S1726123AbgFCILL (ORCPT + 99 others); Wed, 3 Jun 2020 04:11:11 -0400 Received: from relay10.mail.gandi.net ([217.70.178.230]:56089 "EHLO relay10.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725275AbgFCILL (ORCPT ); Wed, 3 Jun 2020 04:11:11 -0400 Received: from debian.home (lfbn-gre-1-325-105.w90-112.abo.wanadoo.fr [90.112.45.105]) (Authenticated sender: alex@ghiti.fr) by relay10.mail.gandi.net (Postfix) with ESMTPSA id 096D024000F; Wed, 3 Jun 2020 08:11:05 +0000 (UTC) From: Alexandre Ghiti To: Paul Walmsley , Palmer Dabbelt , Zong Li , Anup Patel , Christoph Hellwig , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Alexandre Ghiti Subject: [PATCH v2 0/8] Introduce sv48 support Date: Wed, 3 Jun 2020 04:10:56 -0400 Message-Id: <20200603081104.14004-1-alex@ghiti.fr> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patchset implements sv48 support at runtime. The kernel will try to boot with 4-level page table and will fallback to 3-level if the HW does not support it. The biggest advantage is that we only have one kernel for 64bit, which is way easier to maintain. Folding the 4th level into a 3-level page table has almost no cost at runtime. But as mentioned Palmer, the relocatable code generated is less performant. At the moment, there is no way to build a 3-level page table non-relocatable 64bit kernel. We agreed that distributions will use this runtime configuration anyway, but Palmer proposed to introduce a new Kconfig, which I will do later as sv48 support was asked for 5.8. Finally, the user can now ask for sv39 explicitly by using the device-tree which will reduce memory footprint and reduce the number of memory accesses in case of TLB miss. Changes in v2: * Move variable declarations to pgtable.h in patch 5/7 as suggested by Anup * Restore mmu-type properties in patch 6 as suggested by Anup * Fix unused variable in patch 5 that was used in patch 6 * Fix SPARSEMEM build (patch 2 was modified so I dropped the Reviewed-by) * Applied various Reviewed-by Alexandre Ghiti (8): riscv: Get rid of compile time logic with MAX_EARLY_MAPPING_SIZE riscv: Allow to dynamically define VA_BITS riscv: Simplify MAXPHYSMEM config riscv: Prepare ptdump for vm layout dynamic addresses riscv: Implement sv48 support riscv: Allow user to downgrade to sv39 when hw supports sv48 riscv: Use pgtable_l4_enabled to output mmu type in cpuinfo riscv: Explicit comment about user virtual address space size arch/riscv/Kconfig | 34 ++--- arch/riscv/include/asm/csr.h | 3 +- arch/riscv/include/asm/fixmap.h | 1 + arch/riscv/include/asm/page.h | 15 +++ arch/riscv/include/asm/pgalloc.h | 36 ++++++ arch/riscv/include/asm/pgtable-64.h | 97 +++++++++++++- arch/riscv/include/asm/pgtable.h | 31 ++++- arch/riscv/include/asm/sparsemem.h | 6 +- arch/riscv/kernel/cpu.c | 23 ++-- arch/riscv/kernel/head.S | 3 +- arch/riscv/mm/context.c | 2 +- arch/riscv/mm/init.c | 194 ++++++++++++++++++++++++---- arch/riscv/mm/ptdump.c | 49 +++++-- 13 files changed, 412 insertions(+), 82 deletions(-) -- 2.20.1