From nobody Tue May 02 11:39:54 2023 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 4Q9dRG4CtDz48tRL; Tue, 2 May 2023 11:39:54 +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 4Q9dRG3nR0z3q9l; Tue, 2 May 2023 11:39:54 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1683027594; 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=VCdIENffwrLjZb0tFlUh/KZB0WC9BCONd3614CwLCt8=; b=jr1w6Obkf0aEfaxFtVR9ni1mXBlGqcYYCyGiF3NPnM8ZwAdmiWiUOIEI0Tx3n2M8yDi2lJ oCZPUD9M0W37MBkONnDeudPAFcuJYCnrzP2Kf1ICnEnzfHvhqAxt/mfPtlPR1dBXC09Bwr 5wbRpWbVvOewQgKfPBdUr9KBS3FXsQNs1lEscxQVcAY1soF0dgk3tnWJpTbrwshot+x4hW bvdCmsvOf/YXqr/80QmE64fPue72iwziNHGfioEAweb4owBjuEd4+TDYSYrVEtrqFmi2cC rAmqGenBtrC+euFmuAMpvr5/w/mscgDKbzK2liLMNeYMk+j03Mo+wIJGEHcgYA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1683027594; 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=VCdIENffwrLjZb0tFlUh/KZB0WC9BCONd3614CwLCt8=; b=Lp7wAhPYxeXzjayHsEZM8ZFcDEyf6ri3Oi/QKkSjti2+4E6hGg0HbHzzr2/c5/EP6NtB+b n64PyU7byDumo7ZBys0NmOopiaHhp1eVpN73nAV1QLByiseCiHID2uSd+5Jf9Jj4sNqXbN wQUxBoEtQNDv92JVhxJ2/gRxqy/FXXe1MhztVeuqvaeC9s8L0BPqYNwTAvhhXVyWv1Zr6o L7wbPqNNi3XKYpqp1sVCHJ5MGEFO4rcj5/5t3HNLy+2xZYlRZ72M8Qkuqs3RzciQKYuAy3 HwkO6LYziXNR8OUGcMuU2rSkzvph1U3k0Hbvhq1F5LbB2/XXg8xjfPeD1q0d8w== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1683027594; a=rsa-sha256; cv=none; b=dP90mQsHnZw0NAMdC50+S8ukKnqT+/qee5/NtIfqPVWc24lADp4naJ+TruGAicI3lv5Nel H3tf2GcqD6GiobX0ZTlZ6s5gJCZnWpGaidEvHSZHNxISaFfbJHTfai9ptn/U2l6JuhE9kV KAhNjEBvnDPKL0+m/s6gkG6aRvwa/3IvaqxIvRR/h3u0qTm7gWJp8dX85zpu+nKjmzf2px r/QW5Wbzru7v0ZgxawrrEe1yNU8h2K+Wbq1HrMqnIlp2mw/ch6I6nZmD2rxrS0AZQzDd6x hsBLpCAwiDwBcF3+leHnqxK9Uk3qVr0FizaIt4fBbyrZ8D9ODjZNakHVLB11nw== 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 4Q9dRG2d0dzmRm; Tue, 2 May 2023 11:39:54 +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 342Bds9H092350; Tue, 2 May 2023 11:39:54 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 342BdsGp092349; Tue, 2 May 2023 11:39:54 GMT (envelope-from git) Date: Tue, 2 May 2023 11:39:54 GMT Message-Id: <202305021139.342BdsGp092349@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: 9c8cbf381985 - main - amd64 pmap_pcid_alloc(): pass a pointer to struct pmap_pcid instead of cpuid 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: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 9c8cbf3819854d9acbf4c0fba43942036f956786 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=9c8cbf3819854d9acbf4c0fba43942036f956786 commit 9c8cbf3819854d9acbf4c0fba43942036f956786 Author: Konstantin Belousov AuthorDate: 2023-05-01 11:35:48 +0000 Commit: Konstantin Belousov CommitDate: 2023-05-02 11:32:40 +0000 amd64 pmap_pcid_alloc(): pass a pointer to struct pmap_pcid instead of cpuid Cpuid is used to index the pmap->pm_pcids array only. Reviewed by: markj Tested by: pho Sponsored by: The FreeBSD Foundation Differential revision: https://reviews.freebsd.org/D39890 --- sys/amd64/amd64/pmap.c | 47 ++++++++++++++++++++++++----------------------- 1 file changed, 24 insertions(+), 23 deletions(-) diff --git a/sys/amd64/amd64/pmap.c b/sys/amd64/amd64/pmap.c index 16bfe9986c6b..a7716d7f394e 100644 --- a/sys/amd64/amd64/pmap.c +++ b/sys/amd64/amd64/pmap.c @@ -9926,20 +9926,20 @@ out: } static uint64_t -pmap_pcid_alloc(pmap_t pmap, u_int cpuid) +pmap_pcid_alloc(pmap_t pmap, struct pmap_pcid *pcidp) { uint32_t gen, new_gen, pcid_next; CRITICAL_ASSERT(curthread); gen = PCPU_GET(pcid_gen); - if (pmap->pm_pcids[cpuid].pm_pcid == PMAP_PCID_KERN) + if (pcidp->pm_pcid == PMAP_PCID_KERN) return (pti ? 0 : CR3_PCID_SAVE); - if (pmap->pm_pcids[cpuid].pm_gen == gen) + if (pcidp->pm_gen == gen) return (CR3_PCID_SAVE); pcid_next = PCPU_GET(pcid_next); KASSERT((!pti && pcid_next <= PMAP_PCID_OVERMAX) || (pti && pcid_next <= PMAP_PCID_OVERMAX_KERN), - ("cpu %d pcid_next %#x", cpuid, pcid_next)); + ("cpu %d pcid_next %#x", PCPU_GET(cpuid), pcid_next)); if ((!pti && pcid_next == PMAP_PCID_OVERMAX) || (pti && pcid_next == PMAP_PCID_OVERMAX_KERN)) { new_gen = gen + 1; @@ -9950,25 +9950,23 @@ pmap_pcid_alloc(pmap_t pmap, u_int cpuid) } else { new_gen = gen; } - pmap->pm_pcids[cpuid].pm_pcid = pcid_next; - pmap->pm_pcids[cpuid].pm_gen = new_gen; + pcidp->pm_pcid = pcid_next; + pcidp->pm_gen = new_gen; PCPU_SET(pcid_next, pcid_next + 1); return (0); } static uint64_t -pmap_pcid_alloc_checked(pmap_t pmap, u_int cpuid) +pmap_pcid_alloc_checked(pmap_t pmap, struct pmap_pcid *pcidp) { uint64_t cached; - cached = pmap_pcid_alloc(pmap, cpuid); - KASSERT(pmap->pm_pcids[cpuid].pm_pcid < PMAP_PCID_OVERMAX, - ("pmap %p cpu %d pcid %#x", pmap, cpuid, - pmap->pm_pcids[cpuid].pm_pcid)); - KASSERT(pmap->pm_pcids[cpuid].pm_pcid != PMAP_PCID_KERN || - pmap == kernel_pmap, + cached = pmap_pcid_alloc(pmap, pcidp); + KASSERT(pcidp->pm_pcid < PMAP_PCID_OVERMAX, + ("pmap %p cpu %d pcid %#x", pmap, PCPU_GET(cpuid), pcidp->pm_pcid)); + KASSERT(pcidp->pm_pcid != PMAP_PCID_KERN || pmap == kernel_pmap, ("non-kernel pmap pmap %p cpu %d pcid %#x", - pmap, cpuid, pmap->pm_pcids[cpuid].pm_pcid)); + pmap, PCPU_GET(cpuid), pcidp->pm_pcid)); return (cached); } @@ -9984,6 +9982,7 @@ static void pmap_activate_sw_pcid_pti(struct thread *td, pmap_t pmap, u_int cpuid) { pmap_t old_pmap; + struct pmap_pcid *pcidp, *old_pcidp; uint64_t cached, cr3, kcr3, ucr3; KASSERT((read_rflags() & PSL_I) == 0, @@ -9994,17 +9993,18 @@ pmap_activate_sw_pcid_pti(struct thread *td, pmap_t pmap, u_int cpuid) PCPU_SET(ucr3_load_mask, PMAP_UCR3_NOMASK); old_pmap = PCPU_GET(curpmap); MPASS(old_pmap->pm_ucr3 != PMAP_NO_CR3); - old_pmap->pm_pcids[cpuid].pm_gen = 0; + old_pcidp = &old_pmap->pm_pcids[cpuid]; + old_pcidp->pm_gen = 0; } - cached = pmap_pcid_alloc_checked(pmap, cpuid); + pcidp = &pmap->pm_pcids[cpuid]; + cached = pmap_pcid_alloc_checked(pmap, pcidp); cr3 = rcr3(); if ((cr3 & ~CR3_PCID_MASK) != pmap->pm_cr3) - load_cr3(pmap->pm_cr3 | pmap->pm_pcids[cpuid].pm_pcid); + load_cr3(pmap->pm_cr3 | pcidp->pm_pcid); PCPU_SET(curpmap, pmap); - kcr3 = pmap->pm_cr3 | pmap->pm_pcids[cpuid].pm_pcid; - ucr3 = pmap->pm_ucr3 | pmap->pm_pcids[cpuid].pm_pcid | - PMAP_PCID_USER_PT; + kcr3 = pmap->pm_cr3 | pcidp->pm_pcid; + ucr3 = pmap->pm_ucr3 | pcidp->pm_pcid | PMAP_PCID_USER_PT; if (!cached && pmap->pm_ucr3 != PMAP_NO_CR3) PCPU_SET(ucr3_load_mask, ~CR3_PCID_SAVE); @@ -10021,16 +10021,17 @@ static void pmap_activate_sw_pcid_nopti(struct thread *td __unused, pmap_t pmap, u_int cpuid) { + struct pmap_pcid *pcidp; uint64_t cached, cr3; KASSERT((read_rflags() & PSL_I) == 0, ("PCID needs interrupts disabled in pmap_activate_sw()")); - cached = pmap_pcid_alloc_checked(pmap, cpuid); + pcidp = &pmap->pm_pcids[cpuid]; + cached = pmap_pcid_alloc_checked(pmap, pcidp); cr3 = rcr3(); if (!cached || (cr3 & ~CR3_PCID_MASK) != pmap->pm_cr3) - load_cr3(pmap->pm_cr3 | pmap->pm_pcids[cpuid].pm_pcid | - cached); + load_cr3(pmap->pm_cr3 | pcidp->pm_pcid | cached); PCPU_SET(curpmap, pmap); if (cached) counter_u64_add(pcid_save_cnt, 1);