From nobody Tue Mar 01 14:40:01 2022 X-Original-To: dev-commits-src-main@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 55FD219DAEF9; Tue, 1 Mar 2022 14:40:02 +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 4K7Kf96R8dz3Fhv; Tue, 1 Mar 2022 14:40:01 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1646145602; 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=iLnOzvyPwubAebW02ne5aD1tEGBNY11tJGEJ9oPzpuU=; b=jXWfJAkkD5DpSLixA+xoD01GAlOPGccq/M7mTYpJ26s0wZcB3XonULh1wLA5ctsh3/vdhY F7kzP5+ZuH200Zjqpb2bx18gW7RjE6R4k7eCMiS42WDgtMGngXXEiNptpcHbBWwdCv0H6t 1LQ38zlko8VwE2j5cWdWdaB8WFQKj1B2ZyMcUiawzKjuEoSM1ALhcTsNf+k4t6sVpylb7o Luif6MZpLMMJhusCHFdH5rZP9Nv6iEvRFQX0ikvRrMRLEmKZ2FrmCf4G3YKNxaW8J/qSFK 6a/dcTaEU2/3NuRhAeHAb1ADCm6NcXL/dLosEuE2krJpLOtKDnQ8Fz15Fc/CbQ== 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 86C8711633; Tue, 1 Mar 2022 14:40:01 +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 221Ee1aO040271; Tue, 1 Mar 2022 14:40:01 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 221Ee1EI040258; Tue, 1 Mar 2022 14:40:01 GMT (envelope-from git) Date: Tue, 1 Mar 2022 14:40:01 GMT Message-Id: <202203011440.221Ee1EI040258@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: 35d0f443cfaa - main - riscv: Define a SV48 memory map List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@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/main X-Git-Reftype: branch X-Git-Commit: 35d0f443cfaaa32afa43f4ffca986590fc56d827 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1646145602; 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=iLnOzvyPwubAebW02ne5aD1tEGBNY11tJGEJ9oPzpuU=; b=xvJe8gGgfWdPzduBcyJ5NV1Dw3Nqzy1cYuWJpDTd5bOAVuIk0VJzc0kYNtQOYiu+yNa9vS 5+dnW83H3iOwXd1pOgkGKE0xBme7khBbVcBcDJmVxI8gFVwCIRLe1s9ntLIvtB8HTdFoQm dSaQxTWFqafbWwIRfxqAVkF1uZuGts2AvFIPfTOAUQsXdOCne7ciD2JjRd02Ryf/GPdmDr VliwTGsqPSgG6TqIXeBAIUAzj4xJSnKsAgI3r0R5AF/jGVtZJpHRlZStjsO0xlTXSjRZqb oE3/+lTePieEcTbiLgL7YWvry/lduV2lQuBPsFVHSex9GbJvwHlzUfbcBK0xAQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1646145602; a=rsa-sha256; cv=none; b=UnoG5d6g3w32n9i9xPLCUBlffPDEs5F40v/hgInCxASdkd16MFINMTxhJ0U17HJ6c3rrj4 yP4nIyPnJ7OSLIfNWJ/Nbf2Jp+yon0BdXxWkdzgmLlcQvrx8ibhLdfXD2UE+ThPAz71XAl Gn6Ob4bSlC+EUag0r0+glAk3Q+9sk+6u+gK+QAjv96GRrcu25f+UKvUPfQ9uRLVhV7iZMs 7le6TLdRaOwKlNZeoNHDufy/HRTDd3ZTtsZ/vrgSyz1/XuKVf3fPZi8Dap1wfrAiRcyRrK i+EphKaKwqXv6L/FK0pVKMafC7Jm2cJsFwdARWnjcm6XwJhWSbDRMItWoGC2rA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=35d0f443cfaaa32afa43f4ffca986590fc56d827 commit 35d0f443cfaaa32afa43f4ffca986590fc56d827 Author: Mark Johnston AuthorDate: 2022-03-01 14:04:38 +0000 Commit: Mark Johnston CommitDate: 2022-03-01 14:39:43 +0000 riscv: Define a SV48 memory map No functional change intended. Reviewed by: kib, jhb MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D34273 --- 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))