From nobody Sun Apr 27 22:32:46 2025 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 4Zm1YW5kv2z5vQr0; Sun, 27 Apr 2025 22:32:47 +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 "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Zm1YW0M8bz3tRN; Sun, 27 Apr 2025 22:32:47 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1745793167; 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=Va7atqt+btig8cb4kYQrvVi0UMPCZTpHkvhNxrGGZe0=; b=nH4/HZjSkN9QLBoQNRgK81IjVH9dPNGuqmxSWqWPJGOcQX9OpCX7DMArrjdwYEYunOyVQF prYaxsQoeoCJY9SvyDorgauLLcOyvmwJwyHjagvTlk1ULiik9twol+Thoc5tdwOaioXpd+ qbS5DItl8l7NANZZKE7hpFybPhK9OxghzkVomdqR3vJme19xPv8Jw6uI7nGeEhINnghBac CVw/OKt/N82/u9SFE3nBWsSjas5ZnmoY7j+pR+niHWLUGB8qyDElD0z6NPRBRKKZNMDRHe 5iupaFHxMslhoAiXad3iKT+6ckPYOW7mR4qZUs2VBcSsEpejConEU0f9krRqlw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1745793167; a=rsa-sha256; cv=none; b=psZTP+f4E8CgW/sgw1s93Ce7V106oggJ3l0u2Laexc8nOUoZBZpP0qmLWJ+SxV5nawNaaZ V7HeM+dkQZ1LDwXRpg48s1vzliGEehxhbPRb9hGdM5Lozm4sx2QS2aAHWh9o3iIQLisCx6 nEobCyGTawccnsayo8BObYF9Wkbzi8Sgu344usVowWUbYUxgu/X9K67sxqN4QAse4RMGpE ruVRIgGci5cm3y8Xyp6FSHBvWy3PVaC7npXaZff0POMJOthtwAgsFPqSGnfWWAMba2Ns93 LJAVWlS2DZ+ROO2j0Ucc9lknBt/7vIxgK2xEjINVRlPyuSB07Y7YDAqaeDIuZA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1745793167; 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=Va7atqt+btig8cb4kYQrvVi0UMPCZTpHkvhNxrGGZe0=; b=MSJj2lZWjswtRnjr2jJ6yKLelwt0zdVl87ej9XiM05hdqrv51DHFFLMXgkYPP+Be99pvTC Rxchd7Hf8ed8/JARo4/zrZD7MDb8dZwx7bz0120URj4/Vfn2ikjTpqzpglSS4c6/nzq/86 CmDXyl99Y6efRAzQF72WCrwmaMNMf/JcUkc18to6zjyfpswmMEhBzoIGyOM2dpTaKkzNhd hcQNu9ip7soFhCMh08/l8oji7gqzG4pI4BSEY88P9Y6n3aXtgMg6xkLd2QXKAyuunlMeEI rQ3IL18xYL44h5u5FKfGjZVQWeZXfiCweaUyURU3guJ1zh0shb4EM1YwJsKWWQ== 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 4Zm1YV6M1Kz1NQ0; Sun, 27 Apr 2025 22:32:46 +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 53RMWkLU069435; Sun, 27 Apr 2025 22:32:46 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 53RMWkkH069432; Sun, 27 Apr 2025 22:32:46 GMT (envelope-from git) Date: Sun, 27 Apr 2025 22:32:46 GMT Message-Id: <202504272232.53RMWkkH069432@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: 011a3493610c - main - x86: add cpu_stdext_feature4 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: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-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: 011a3493610cc69e9337c857d4947b0bbc462c0a Auto-Submitted: auto-generated The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=011a3493610cc69e9337c857d4947b0bbc462c0a commit 011a3493610cc69e9337c857d4947b0bbc462c0a Author: Konstantin Belousov AuthorDate: 2024-10-24 02:28:05 +0000 Commit: Konstantin Belousov CommitDate: 2025-04-27 22:24:33 +0000 x86: add cpu_stdext_feature4 which corresponds to CPUID leaf 7 %ecx = 1 %eax report. Decode only LASS and LAM for now. Sponsored by: The FreeBSD Foundation MFC after: 1 week --- sys/x86/include/x86_var.h | 1 + sys/x86/x86/identcpu.c | 21 ++++++++++++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/sys/x86/include/x86_var.h b/sys/x86/include/x86_var.h index dbb4e9557ed0..701b982e6afb 100644 --- a/sys/x86/include/x86_var.h +++ b/sys/x86/include/x86_var.h @@ -50,6 +50,7 @@ extern u_int cpu_clflush_line_size; extern u_int cpu_stdext_feature; extern u_int cpu_stdext_feature2; extern u_int cpu_stdext_feature3; +extern u_int cpu_stdext_feature4; extern uint64_t cpu_ia32_arch_caps; extern u_int cpu_high; extern u_int cpu_id; diff --git a/sys/x86/x86/identcpu.c b/sys/x86/x86/identcpu.c index 3f8f11fda011..4d64eaf78b29 100644 --- a/sys/x86/x86/identcpu.c +++ b/sys/x86/x86/identcpu.c @@ -111,9 +111,12 @@ char cpu_vendor[20]; /* CPU Origin code */ u_int cpu_vendor_id; /* CPU vendor ID */ u_int cpu_mxcsr_mask; /* Valid bits in mxcsr */ u_int cpu_clflush_line_size = 32; +/* leaf 7 %ecx = 0 */ u_int cpu_stdext_feature; /* %ebx */ u_int cpu_stdext_feature2; /* %ecx */ u_int cpu_stdext_feature3; /* %edx */ +/* leaf 7 %ecx = 1 */ +u_int cpu_stdext_feature4; /* %eax */ uint64_t cpu_ia32_arch_caps; u_int cpu_max_ext_state_size; u_int cpu_mon_mwait_flags; /* MONITOR/MWAIT flags (CPUID.05H.ECX) */ @@ -1043,6 +1046,16 @@ printcpuinfo(void) "\040SSBD" ); } +#define STDEXT4_MASK (CPUID_STDEXT4_LASS | CPUID_STDEXT4_LAM) + if ((cpu_stdext_feature4 & STDEXT4_MASK) != 0) { + printf("\n Structured Extended Features4=0x%b", + cpu_stdext_feature4 & STDEXT4_MASK, + "\020" + "\007LASS" + "\033LAM" + ); + } +#undef STDEXT4_MASK if ((cpu_feature2 & CPUID2_XSAVE) != 0) { cpuid_count(0xd, 0x1, regs); @@ -1562,7 +1575,7 @@ identify_cpu1(void) void identify_cpu2(void) { - u_int regs[4], cpu_stdext_disable; + u_int regs[4], cpu_stdext_disable, max_eax_l7; if (cpu_high >= 6) { cpuid_count(6, 0, regs); @@ -1575,6 +1588,7 @@ identify_cpu2(void) if (cpu_high >= 7) { cpuid_count(7, 0, regs); cpu_stdext_feature = regs[1]; + max_eax_l7 = regs[0]; /* * Some hypervisors failed to filter out unsupported @@ -1591,6 +1605,11 @@ identify_cpu2(void) if ((cpu_stdext_feature3 & CPUID_STDEXT3_ARCH_CAP) != 0) cpu_ia32_arch_caps = rdmsr(MSR_IA32_ARCH_CAP); + + if (max_eax_l7 >= 1) { + cpuid_count(7, 1, regs); + cpu_stdext_feature4 = regs[0]; + } } }