From nobody Sun Jul 20 00:26:00 2025 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 4bl47s4ZmQz62XHB; Sun, 20 Jul 2025 00:26:01 +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 "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4bl47s0ZvGz3XWS; Sun, 20 Jul 2025 00:26:01 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1752971161; 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=7l0Tt+IjVJaAv2r+XeLVd+kN2IV6su7qgVQb4hTGJ3k=; b=yZfXwh60QB2oKulQTHOS3Ix/39U9yaAOyZDIw00W6qldi1v5/ps9h1Wv/i4kQK2RpYY0/I sBzCzxPaEiy2Oy6Zypp0qsS4q3Og771G7Hy9uTxhgLoz46MllMcM6iI3pNVY2m8p2KRpSG rDNeDM54ny5p0AsEmiIOEUo04voOK+17rmU7dly36RJK7dT7zB7g4beYOhUXYfQeydnSyp 7mu0UAFLFxtexqmaoOXCqvYATnnFDB3/bfYJ6rdg0F6GLgClD8+KwjQJDMDlgBYQMFlJWB RlsTAWtaUYM5tWWfh0Sp/NaqB05OXBpKe5+TJRxw23dZSvnhIfTWmLdMyaH3sg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1752971161; 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=7l0Tt+IjVJaAv2r+XeLVd+kN2IV6su7qgVQb4hTGJ3k=; b=tB43AHyyqnxrDsQeRx7/jADxomXOeN0IKTaoNLkTSCeXBZa6vf86cb3TObYdKXMlc92xc7 8zpnI52Gvvg2GLffMMiIwtS/RtEfkp+/Bu9Sonfjlr0yTwK9UlU0tGL7swWy1F4p7ClvXX cIOaMtWj23LMlYFMASbWOOvigfykpCRZ8S7UofayIZDG5NzSqj+A1tnBrCbl6pkw144yGq cxM/Curelw7hYa1ZuIPllWe3qocyL+iyZSozL0AjkRBQJWTDTHwGaR3JXV9Adi5oIXzmrF LWueYgZ3uwOq6m40AfrNaBEv9rnZe+KQoQdd43e4KFKCDJZnCVtWTeeSWRX16Q== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1752971161; a=rsa-sha256; cv=none; b=WSHE5qcYRzGN835J1pM/WTfe2TovYlpDWfBVd/cunkYBOfK0eQLEoxmaOrVqnqB3op0WFA jSj4+UoJ33x0dnyiu4vjPwFNcHVcEus8iPmv1kE4qQXQsOit1VBnA1Os31cRasdnG5lC7e MPQD4OyqN3SQL7WuCaFiXHNKnzbMbT77B38AhHaJjf9NdVLXtx852DPzuWHYeaEv7NLLcH mr/X+Ew13eQ4yMxsEKuLmlqB40BIa6HwZ3zoQ1p2icN3P7aX2QASJXnhDAacoAQma4LqQT aLyYm5N+Q4QtWSi2Ye2OxeMUpJOOnWjnQ/sWaGOgWT89KsiMswBufDzxWTmG/g== 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 4bl47s02Nkzq6P; Sun, 20 Jul 2025 00:26:01 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 56K0Q03S093398; Sun, 20 Jul 2025 00:26:00 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 56K0Q0WG093395; Sun, 20 Jul 2025 00:26:00 GMT (envelope-from git) Date: Sun, 20 Jul 2025 00:26:00 GMT Message-Id: <202507200026.56K0Q0WG093395@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: 31afa16f92df - main - amd64 pmap: for LA57 move large map out of kernel pml4 slot 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: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 31afa16f92df9ed2cee96b8ee56449ea60a9ccf1 Auto-Submitted: auto-generated The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=31afa16f92df9ed2cee96b8ee56449ea60a9ccf1 commit 31afa16f92df9ed2cee96b8ee56449ea60a9ccf1 Author: Konstantin Belousov AuthorDate: 2025-07-16 23:55:49 +0000 Commit: Konstantin Belousov CommitDate: 2025-07-20 00:25:45 +0000 amd64 pmap: for LA57 move large map out of kernel pml4 slot and allow it to consume up to 32 pml5 slots (32 x 2048 TB), same as DMAP. Reviewed by: alc, markj Sponsored by: The FreeBSD Foundation Differential revision: https://reviews.freebsd.org/D51364 --- sys/amd64/amd64/pmap.c | 42 ++++++++++++++++++++++++++++++------------ sys/amd64/include/pmap.h | 7 ++++++- 2 files changed, 36 insertions(+), 13 deletions(-) diff --git a/sys/amd64/amd64/pmap.c b/sys/amd64/amd64/pmap.c index a7d17db19a3e..0850b326bc3a 100644 --- a/sys/amd64/amd64/pmap.c +++ b/sys/amd64/amd64/pmap.c @@ -497,8 +497,8 @@ struct kva_layout_s kva_layout_la57 = { .kva_min = KV5ADDR(NPML5EPG / 2, 0, 0, 0, 0), /* == rec_pt */ .dmap_low = KV5ADDR(DMPML5I, 0, 0, 0, 0), .dmap_high = KV5ADDR(DMPML5I + NDMPML5E, 0, 0, 0, 0), - .lm_low = KV4ADDR(LMSPML4I, 0, 0, 0), - .lm_high = KV4ADDR(LMEPML4I + 1, 0, 0, 0), + .lm_low = KV5ADDR(LMSPML5I, 0, 0, 0, 0), + .lm_high = KV5ADDR(LMEPML5I + 1, 0, 0, 0, 0), .km_low = KV4ADDR(KPML4BASE, 0, 0, 0), .km_high = KV4ADDR(KPML4BASE + NKPML4E - 1, NPDPEPG - 1, NPDEPG - 1, NPTEPG - 1), @@ -2626,6 +2626,15 @@ pmap_init(void) printf("pmap: cannot create large map\n"); lm_ents = 0; } + if (la57) { + for (i = 0; i < howmany((vm_offset_t)NBPML4 * + lm_ents, NBPML5); i++) { + m = pmap_large_map_getptp_unlocked(); + kernel_pmap->pm_pmltop[LMSPML5I + i] = X86_PG_V | + X86_PG_RW | X86_PG_A | X86_PG_M | + pg_nx | VM_PAGE_TO_PHYS(m); + } + } for (i = 0; i < lm_ents; i++) { m = pmap_large_map_getptp_unlocked(); pml4e = pmap_pml4e(kernel_pmap, kva_layout.lm_low + @@ -10768,19 +10777,28 @@ pmap_large_map_getptp(void) static pdp_entry_t * pmap_large_map_pdpe(vm_offset_t va) { + pml4_entry_t *pm4; vm_pindex_t pml4_idx; vm_paddr_t mphys; - pml4_idx = pmap_pml4e_index(va); - KASSERT(LMSPML4I <= pml4_idx && pml4_idx < LMSPML4I + lm_ents, - ("pmap_large_map_pdpe: va %#jx out of range idx %#jx LMSPML4I " - "%#jx lm_ents %d", - (uintmax_t)va, (uintmax_t)pml4_idx, LMSPML4I, lm_ents)); - KASSERT((kernel_pml4[pml4_idx] & X86_PG_V) != 0, - ("pmap_large_map_pdpe: invalid pml4 for va %#jx idx %#jx " - "LMSPML4I %#jx lm_ents %d", - (uintmax_t)va, (uintmax_t)pml4_idx, LMSPML4I, lm_ents)); - mphys = kernel_pml4[pml4_idx] & PG_FRAME; + KASSERT(va >= kva_layout.lm_low && va < kva_layout.lm_low + + (vm_offset_t)NBPML4 * lm_ents, ("va %#lx not in large map", va)); + if (la57) { + pm4 = pmap_pml4e(kernel_pmap, va); + mphys = *pm4 & PG_FRAME; + } else { + pml4_idx = pmap_pml4e_index(va); + + KASSERT(LMSPML4I <= pml4_idx && pml4_idx < LMSPML4I + lm_ents, + ("pmap_large_map_pdpe: va %#jx out of range idx %#jx " + "LMSPML4I %#jx lm_ents %d", + (uintmax_t)va, (uintmax_t)pml4_idx, LMSPML4I, lm_ents)); + KASSERT((kernel_pml4[pml4_idx] & X86_PG_V) != 0, + ("pmap_large_map_pdpe: invalid pml4 for va %#jx idx %#jx " + "LMSPML4I %#jx lm_ents %d", + (uintmax_t)va, (uintmax_t)pml4_idx, LMSPML4I, lm_ents)); + mphys = kernel_pml4[pml4_idx] & PG_FRAME; + } return ((pdp_entry_t *)PHYS_TO_DMAP(mphys) + pmap_pdpe_index(va)); } diff --git a/sys/amd64/include/pmap.h b/sys/amd64/include/pmap.h index 08e96027a5ed..a0ca97f2d5a0 100644 --- a/sys/amd64/include/pmap.h +++ b/sys/amd64/include/pmap.h @@ -202,9 +202,14 @@ #define KMSANSHADPML4I (KPML4BASE - NKMSANSHADPML4E) #define KMSANORIGPML4I (DMPML4I - NKMSANORIGPML4E) -/* Large map: index of the first and max last pml4 entry */ +/* + * Large map: index of the first and max last pml4/la48 and pml5/la57 + * entry. + */ #define LMSPML4I (PML4PML4I + 1) #define LMEPML4I (KASANPML4I - 1) +#define LMSPML5I (DMPML5I + NDMPML5E) +#define LMEPML5I (LMSPML5I + 32 - 1) /* 32 slots for large map */ /* * XXX doesn't really belong here I guess...