From nobody Thu Jan 05 23:31:35 2023 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 4Np2mS2SRQz2qnMw; Thu, 5 Jan 2023 23:31:36 +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 4Np2mS21Hjz3vfY; Thu, 5 Jan 2023 23:31:36 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1672961496; 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=62dR97w3F6mecuRrNJ9K2xl6ja007SKllxzrJxpgHyY=; b=wD0EEfcPre4G9RND34/ihDxo4xwEjLu70g2mMaCx8y7+uTeziguxLDBB5RmmfHtJM8HWeD UfkxiLe7eEA4j86Cp7eIWY1LZCl3302pTJzkOzERF1Hg7ufFF5lGhylS81ds4+/FIlM4AJ j6K7bRUaDka0U+9SoZ58u/Wz51WUOjkJuyqkc0esv5SWQ6q1zMYcvXrlGyM0ZZC9SfZqvr nsr+1L8G13MjYGnx7M2UC19/2PZUwdJ8CbLjuFz2x034fcCtTwM+gUvfgnyR5ThFTyJznq lJ3jYc/LQ2eI9RPIPHglcoT3I25KU1LTA7lskWNy3yY586OUBdMn93vySEMTAQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1672961496; 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=62dR97w3F6mecuRrNJ9K2xl6ja007SKllxzrJxpgHyY=; b=QaE2QbMwIx0N2opll8JNMZPD/C7PTQEHvOHbJwdT9EOSGti212IBIK3Emryr26NQuqwSn3 EU0T9bMW3fm7LKT1mYU011cJLAgoYEZQlIotr7iZu+XngJtLIu+zDMRtwKEiujWgIcVlAn p9BvaYqMpPFGfITrtPSxTTM2VR2m2T7a/1miMFaz+U3P36RRmVXPhnK/DVMJU17iTik0ME UBuucxcTdUjCzIK50gz9IQCn4ZfRZZuFpWxG3oxuyg7SCLNxDtyOKteZV1pAT/+xE9Y13B XpDNF78bJTamzWkqT0j/yDa7vQ3I72HhES11UUC5RAZfhJrmuSzcZ2rRiY1Ekg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1672961496; a=rsa-sha256; cv=none; b=Ek8VJaJky6EgUkZfdqleNUCwB/dBDvKo7yOLSR2voQj7LP62UBY7Hj1HdCJJ+4CkUDIw66 yyZsmYwqmKw4OUj+UP/cN1nm9ZslJEIYU5zvUMp/awDopz2IWqxie5wuyiNYfKiGbF8vyH e9F4Z7uJ6yy1UVbwzf/s7saPWYMq2riZRas24u7Ip84f6XB4SKFfQYPVbPCHyVfPtZTiRn LQljMz/etngIn+aXihOd8MQQjOrbvBqgAkXk8YB6hfaIVF3mMVMsYQcNdpRyR+t70b4pdI 87Trbf20tZL9YT8YoMXbk9zdeNQHCaR0nNSG5mpUTUUnAU+YbYpz566ZsA4+rQ== 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 4Np2mS0mJhz17xN; Thu, 5 Jan 2023 23:31:36 +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 305NVac0020077; Thu, 5 Jan 2023 23:31:36 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 305NVZgN020076; Thu, 5 Jan 2023 23:31:35 GMT (envelope-from git) Date: Thu, 5 Jan 2023 23:31:35 GMT Message-Id: <202301052331.305NVZgN020076@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: a2c08eba43a2 - main - amd64: be more precise when enabling the AlderLake small core PCID workaround 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: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: a2c08eba43a2c0ebeac7117f708fb9392022a300 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=a2c08eba43a2c0ebeac7117f708fb9392022a300 commit a2c08eba43a2c0ebeac7117f708fb9392022a300 Author: Konstantin Belousov AuthorDate: 2023-01-03 10:13:07 +0000 Commit: Konstantin Belousov CommitDate: 2023-01-05 23:30:29 +0000 amd64: be more precise when enabling the AlderLake small core PCID workaround In particular, do not enable the workaround if INVPCID is not supported by the core. Reported by: "Chen, Alvin W" Reviewed by: markj Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D37940 --- sys/amd64/amd64/initcpu.c | 35 ++++++++++++++++++++++------------- sys/amd64/amd64/machdep.c | 8 ++++++++ sys/amd64/amd64/pmap.c | 3 --- sys/amd64/include/md_var.h | 1 + 4 files changed, 31 insertions(+), 16 deletions(-) diff --git a/sys/amd64/amd64/initcpu.c b/sys/amd64/amd64/initcpu.c index 08385d3095d0..cddf8502437e 100644 --- a/sys/amd64/amd64/initcpu.c +++ b/sys/amd64/amd64/initcpu.c @@ -247,6 +247,26 @@ cpu_auxmsr(void) return (PCPU_GET(cpuid)); } +void +cpu_init_small_core(void) +{ + u_int r[4]; + + if (cpu_high < 0x1a) + return; + + cpuid_count(0x1a, 0, r); + if ((r[0] & CPUID_HYBRID_CORE_MASK) != CPUID_HYBRID_SMALL_CORE) + return; + + PCPU_SET(small_core, 1); + if (pmap_pcid_enabled && invpcid_works && + pmap_pcid_invlpg_workaround_uena) { + PCPU_SET(pcid_invlpg_workaround, 1); + pmap_pcid_invlpg_workaround = 1; + } +} + /* * Initialize CPU control registers */ @@ -255,7 +275,6 @@ initializecpu(void) { uint64_t msr; uint32_t cr4; - u_int r[4]; cr4 = rcr4(); if ((cpu_feature & CPUID_XMM) && (cpu_feature & CPUID_FXSR)) { @@ -319,18 +338,8 @@ initializecpu(void) (cpu_stdext_feature2 & CPUID_STDEXT2_RDPID) != 0) wrmsr(MSR_TSC_AUX, cpu_auxmsr()); - if (cpu_high >= 0x1a) { - cpuid_count(0x1a, 0, r); - if ((r[0] & CPUID_HYBRID_CORE_MASK) == - CPUID_HYBRID_SMALL_CORE) { - PCPU_SET(small_core, 1); - if (pmap_pcid_enabled && - pmap_pcid_invlpg_workaround_uena) { - PCPU_SET(pcid_invlpg_workaround, 1); - pmap_pcid_invlpg_workaround = 1; - } - } - } + if (!IS_BSP()) + cpu_init_small_core(); } void diff --git a/sys/amd64/amd64/machdep.c b/sys/amd64/amd64/machdep.c index 05342b31d2aa..a14c3e408541 100644 --- a/sys/amd64/amd64/machdep.c +++ b/sys/amd64/amd64/machdep.c @@ -1341,6 +1341,14 @@ hammer_time(u_int64_t modulep, u_int64_t physfree) pmap_pcid_enabled = 0; } + /* + * Now we can do small core initialization, after the PCID + * CPU features and user knobs are evaluated. + */ + TUNABLE_INT_FETCH("vm.pmap.pcid_invlpg_workaround", + &pmap_pcid_invlpg_workaround_uena); + cpu_init_small_core(); + link_elf_ireloc(kmdp); /* diff --git a/sys/amd64/amd64/pmap.c b/sys/amd64/amd64/pmap.c index 2d2e673e7622..a86487310aff 100644 --- a/sys/amd64/amd64/pmap.c +++ b/sys/amd64/amd64/pmap.c @@ -2566,9 +2566,6 @@ pmap_init(void) VM_PAGE_TO_PHYS(m); } } - - TUNABLE_INT_FETCH("vm.pmap.pcid_invlpg_workaround", - &pmap_pcid_invlpg_workaround_uena); } SYSCTL_UINT(_vm_pmap, OID_AUTO, large_map_pml4_entries, diff --git a/sys/amd64/include/md_var.h b/sys/amd64/include/md_var.h index f014c66c0d06..f5cbdb6bbd9d 100644 --- a/sys/amd64/include/md_var.h +++ b/sys/amd64/include/md_var.h @@ -72,6 +72,7 @@ void amd64_bsp_ist_init(struct pcpu *pc); void amd64_syscall(struct thread *td, int traced); void amd64_syscall_ret_flush_l1d(int error); void amd64_syscall_ret_flush_l1d_recalc(void); +void cpu_init_small_core(void); void doreti_iret(void) __asm(__STRING(doreti_iret)); void doreti_iret_fault(void) __asm(__STRING(doreti_iret_fault)); void flush_l1d_sw_abi(void);