From nobody Mon Mar 14 14:46:09 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 0FC691A26D62; Mon, 14 Mar 2022 14:46:11 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4KHK9F6Xrfz3hFZ; Mon, 14 Mar 2022 14:46:09 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1647269170; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=ZTk+mBtjuuAeQJ/wArZVhtzrv/fr+IYkiWXPns5rSng=; b=i4RI/QSaJGdrUQm8PU0L/qwnK4oTq41MOzlYoyAbthwfB1EqRDbsg079oY4kJ18h7aL6Bp nMHE40Y5nqNDuu/avZbzjhN4K19bnRGW/47nEqo1DvvRc7869ZtsWW1V6ALI/XGnXZtrf9 rhrsjW0gHBfMs3+fheycNOXNO1nu03SYlohKRA7PiBR8YvBe4vauM2fEwcPEaSHenxDKUe x8INiAxTRIWQdLrZQsHe30E6NfdbjLcMXN7GBYkmD4CFCFe62k2FL5ZSNfyGOlAUijEi5q xD6q+ydqyBdmyhxViPQBKd4IMM6ouvCrP6k4+Qi2crha6cAnp+SFXIL0EFhl5A== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 6ED38761E; Mon, 14 Mar 2022 14:46:09 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 22EEk9og051950; Mon, 14 Mar 2022 14:46:09 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 22EEk9bu051949; Mon, 14 Mar 2022 14:46:09 GMT (envelope-from git) Date: Mon, 14 Mar 2022 14:46:09 GMT Message-Id: <202203141446.22EEk9bu051949@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: 879863f7e1c5 - stable/13 - riscv: Define a SV48 memory map List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 879863f7e1c5b79b2bb9817ba62832e47f894281 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1647269170; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=ZTk+mBtjuuAeQJ/wArZVhtzrv/fr+IYkiWXPns5rSng=; b=bYk5TfAKrk2eyabY46SIVpdMbxly4XPsCUwkCrGxc1IWiY6bxv74XHyJ4Gm0ZgeHrN+Xau la9kbrTYKE0WgmBsa3MZzf3UdYyH9tDLbt0dvefTEZ0TS3JxvDZqVbtKgbObs4AZqWbDBZ vPNs94ri3SYLTRe8yhyJziox8FTP1lJVPT7W/ouzawKCphHLvLtrnYIwfOZ8xfHhu01p1J Avu5tX4kl5nRQnkEdt5JFaY6IavIWQqnvcyBe+niDU6PUOm5MzSvjQi6o+kbcNGtqZ8sE0 +kbneypJ5zXZhD6759kYtoH/9AA+EPXpcFrM3lii9n38Yg7+BZIR+AXgOXFhfA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1647269170; a=rsa-sha256; cv=none; b=l/DW6QjT6Z2U3hjcKEgmfVDa6WTuOd9qyDJgfLakgoJy2yAPambgoxYSlYqCGPAwSt19qI ehkI5daMerAkfMCNmGLryGtxV+WF2g14Ekg62t4HHcYiK9iN3cm3MbKLR+bpBpsoE+sVRQ n2wWj2JoDgEYwtj4qhzrLrv9k1uASKQ1QhbHS+lBGimyFv8rRRXCgmqureRFtak6opNjUv jEf9b2STjoIEIsFMZtsK0vHkF1ivUyYVZEM/OHssmaES876OPkt9PBcgLjz1mqmNJtWbQY s0tuaHAoSrkP/mJzWYlIAU349Kvc8CMTGoegYro3RQshHj8m9VaotKSMcThizw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=879863f7e1c5b79b2bb9817ba62832e47f894281 commit 879863f7e1c5b79b2bb9817ba62832e47f894281 Author: Mark Johnston AuthorDate: 2022-03-01 14:04:38 +0000 Commit: Mark Johnston CommitDate: 2022-03-14 14:45:34 +0000 riscv: Define a SV48 memory map No functional change intended. Reviewed by: kib, jhb Sponsored by: The FreeBSD Foundation (cherry picked from commit 35d0f443cfaaa32afa43f4ffca986590fc56d827) --- sys/riscv/include/vmparam.h | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/sys/riscv/include/vmparam.h b/sys/riscv/include/vmparam.h index d65664eff94e..35f82638cd70 100644 --- a/sys/riscv/include/vmparam.h +++ b/sys/riscv/include/vmparam.h @@ -116,14 +116,19 @@ * Address space layout. * * RISC-V implements multiple paging modes with different virtual address space - * sizes: SV32, SV39 and SV48. SV39 permits a virtual address space size of - * 512GB and uses a three-level page table. Since this is large enough for most - * purposes, we currently use SV39 for both userland and the kernel, avoiding - * the extra translation step required by SV48. + * sizes: SV32, SV39, SV48 and SV57. Only SV39 and SV48 are supported by + * FreeBSD. SV39 provides a 512GB virtual address space and uses three-level + * page tables, while SV48 provides a 256TB virtual address space and uses + * four-level page tables. 64-bit RISC-V implementations are required to provide + * at least SV39 mode; locore initially enables SV39 mode while bootstrapping + * page tables, and pmap_bootstrap() optionally switches to SV48 mode. * * The address space is split into two regions at each end of the 64-bit address - * space: + * space; the lower region is for use by user mode software, while the upper + * region is used for various kernel maps. The kernel map layout in SV48 mode + * is currently identical to that used in SV39 mode. * + * SV39 memory map: * 0x0000000000000000 - 0x0000003fffffffff 256GB user map * 0x0000004000000000 - 0xffffffbfffffffff unmappable * 0xffffffc000000000 - 0xffffffc7ffffffff 32GB kernel map @@ -131,6 +136,15 @@ * 0xffffffd000000000 - 0xffffffefffffffff 128GB direct map * 0xfffffff000000000 - 0xffffffffffffffff 64GB unused * + * SV48 memory map: + * 0x0000000000000000 - 0x00007fffffffffff 128TB user map + * 0x0000800000000000 - 0xffff7fffffffffff unmappable + * 0xffff800000000000 - 0xffffffc7ffffffff 127.75TB hole + * 0xffffffc000000000 - 0xffffffc7ffffffff 32GB kernel map + * 0xffffffc800000000 - 0xffffffcfffffffff 32GB unused + * 0xffffffd000000000 - 0xffffffefffffffff 128GB direct map + * 0xfffffff000000000 - 0xffffffffffffffff 64GB unused + * * The kernel is loaded at the beginning of the kernel map. * * We define some interesting address constants: @@ -180,9 +194,9 @@ ((va) - DMAP_MIN_ADDRESS) + dmap_phys_base; \ }) -#define VM_MIN_USER_ADDRESS_SV39 (0x0000000000000000UL) +#define VM_MIN_USER_ADDRESS (0x0000000000000000UL) #define VM_MAX_USER_ADDRESS_SV39 (0x0000004000000000UL) -#define VM_MIN_USER_ADDRESS VM_MIN_USER_ADDRESS_SV39 +#define VM_MAX_USER_ADDRESS_SV48 (0x0000800000000000UL) #define VM_MAX_USER_ADDRESS VM_MAX_USER_ADDRESS_SV39 #define VM_MINUSER_ADDRESS (VM_MIN_USER_ADDRESS) @@ -194,9 +208,13 @@ #define KERNBASE (VM_MIN_KERNEL_ADDRESS) #define SHAREDPAGE_SV39 (VM_MAX_USER_ADDRESS_SV39 - PAGE_SIZE) +#define SHAREDPAGE_SV48 (VM_MAX_USER_ADDRESS_SV48 - PAGE_SIZE) #define SHAREDPAGE SHAREDPAGE_SV39 -#define USRSTACK SHAREDPAGE_SV39 +#define USRSTACK_SV39 SHAREDPAGE_SV39 +#define USRSTACK_SV48 SHAREDPAGE_SV48 +#define USRSTACK USRSTACK_SV39 #define PS_STRINGS_SV39 (USRSTACK_SV39 - sizeof(struct ps_strings)) +#define PS_STRINGS_SV48 (USRSTACK_SV48 - sizeof(struct ps_strings)) #define VM_EARLY_DTB_ADDRESS (VM_MAX_KERNEL_ADDRESS - (2 * L2_SIZE))