From nobody Sun Dec 24 08:23:21 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 4SyYvZ13KKz54HQc; Sun, 24 Dec 2023 08:23:22 +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 4SyYvY4B6Wz4Y7f; Sun, 24 Dec 2023 08:23:21 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1703406201; 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=CBznooTkox0uYzeB/It04dkmicYZ8PJFKqVfkNc/vbY=; b=ZcbbaayOQgyzhHrIYyb/pZvJChh6Rcuc24kcuUy9qb12GyZVuzuxSBKw94q/L+BtI1Vw0b A8Ylf/Sfin9QgspTre1cNck+JNvFoptGEElEduoc0SP/qcpUbO6NinyUQ3bbPS/5eMf+Nz +pwd0GvJ8owJxPFuirm2016HTLluKi/xhTzrndEydaGoOt1gy6OWVTFB5gkHPL5NIucxYd Ax6wNiAXDyFUvlpOpja7m7XMzw02un+NhfRJmNA8XOvQ461Kd1SdlNJ48of5UL2q6/4+sf g7cBvbr2IJwON5p8+aAFrJN4DwPhUdd6h5NKiUyU+XWuiqXEkr+hO6s4yxnQWg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1703406201; a=rsa-sha256; cv=none; b=mi9A0Xa2TYQyZ4muR/i+7I9DTJGABSsJbn1rr3YcvEWXi47UZYqUtJzJ3qxIbuesVBxlbb P9uRMKDckTBfPBGXM7EuYYxmiocfCT9u6uyQooU2GSRok0/5cADF/sgn7lcawzd5cuJTII ZFrCUt3f4XqhL4BrbUGKBC7rG3gx34HPVk4+aovI8CCynjW19jXsHNSBrLBUsV1maXguH3 DZEOaIOV2lHFnYKxT267oR3hrHd7DJ6GLbHyQ3Yj3fnpUeWu57KxHJBWCUh43ogA5lFMYj dNYsD3AbdttqxtgNtaWCaT4OIcZSP0ZLoXFCcP4R0g1Bv08PXG/O4c9NHAAViA== 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=1703406201; 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=CBznooTkox0uYzeB/It04dkmicYZ8PJFKqVfkNc/vbY=; b=tqQCzoxQVIqioG6wGAqb7d7fp8h9mJ4qCGLtZ00RspAk5rIEaMIRxlnT4kGxd9tjA/893R Y5iL/5SAdfs8K7153Larou+iWna9UzoP5tz6z3bG/axcz6LdZWNEF72T4Pf+OfAVqOETPP dfM5Svd27QA/9A8tT/5If82lYbljUxze11h9BMp7kh0tj3vDmF3bs9HJeB0NmtGDTj23ts JF9k66IKORZZSExou2WqBhHJBHtgO726BO6Sw+3bDT9VFNgAchVYkJIcvKnO8i0qRz4u5u D54ehl6f06IcX027yX2G7OJvCJsdE6manlLrfjiMOBLF9rvSQD8gCwBeRd3TDQ== 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 4SyYvY3Hvrz5R3; Sun, 24 Dec 2023 08:23:21 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 3BO8NLuC087655; Sun, 24 Dec 2023 08:23:21 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 3BO8NLWg087652; Sun, 24 Dec 2023 08:23:21 GMT (envelope-from git) Date: Sun, 24 Dec 2023 08:23:21 GMT Message-Id: <202312240823.3BO8NLWg087652@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Vladimir Kondratyev Subject: git: b8c88a617501 - main - LinuxKPI: Add x86_vendor field to struct cpuinfo_x86 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: wulf X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: b8c88a61750174f62db45784d6b4dc98de4073b1 Auto-Submitted: auto-generated The branch main has been updated by wulf: URL: https://cgit.FreeBSD.org/src/commit/?id=b8c88a61750174f62db45784d6b4dc98de4073b1 commit b8c88a61750174f62db45784d6b4dc98de4073b1 Author: Vladimir Kondratyev AuthorDate: 2023-12-24 08:20:00 +0000 Commit: Vladimir Kondratyev CommitDate: 2023-12-24 08:20:00 +0000 LinuxKPI: Add x86_vendor field to struct cpuinfo_x86 and initialize it at linuxkpi module load. Sponsored by: Serenity Cyber Security, LLC Reviewed by: manu MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D42820 --- sys/compat/linuxkpi/common/include/asm/processor.h | 13 +++++++++++++ sys/compat/linuxkpi/common/src/linux_compat.c | 21 +++++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/sys/compat/linuxkpi/common/include/asm/processor.h b/sys/compat/linuxkpi/common/include/asm/processor.h index c55238d33505..2bc4b6532544 100644 --- a/sys/compat/linuxkpi/common/include/asm/processor.h +++ b/sys/compat/linuxkpi/common/include/asm/processor.h @@ -33,11 +33,24 @@ #include #if defined(__i386__) || defined(__amd64__) +#define X86_VENDOR_INTEL 0 +#define X86_VENDOR_CYRIX 1 +#define X86_VENDOR_AMD 2 +#define X86_VENDOR_UMC 3 +#define X86_VENDOR_CENTAUR 5 +#define X86_VENDOR_TRANSMETA 7 +#define X86_VENDOR_NSC 8 +#define X86_VENDOR_HYGON 9 +#define X86_VENDOR_NUM 12 + +#define X86_VENDOR_UNKNOWN 0xff + struct cpuinfo_x86 { uint8_t x86; uint8_t x86_model; uint16_t x86_clflush_size; uint16_t x86_max_cores; + uint8_t x86_vendor; }; extern struct cpuinfo_x86 boot_cpu_data; diff --git a/sys/compat/linuxkpi/common/src/linux_compat.c b/sys/compat/linuxkpi/common/src/linux_compat.c index 664ba220e721..4a998a557514 100644 --- a/sys/compat/linuxkpi/common/src/linux_compat.c +++ b/sys/compat/linuxkpi/common/src/linux_compat.c @@ -63,6 +63,7 @@ #include #if defined(__i386__) || defined(__amd64__) +#include #include #endif @@ -2622,11 +2623,30 @@ linux_compat_init(void *arg) int i; #if defined(__i386__) || defined(__amd64__) + static const uint32_t x86_vendors[X86_VENDOR_NUM] = { + [X86_VENDOR_INTEL] = CPU_VENDOR_INTEL, + [X86_VENDOR_CYRIX] = CPU_VENDOR_CYRIX, + [X86_VENDOR_AMD] = CPU_VENDOR_AMD, + [X86_VENDOR_UMC] = CPU_VENDOR_UMC, + [X86_VENDOR_CENTAUR] = CPU_VENDOR_CENTAUR, + [X86_VENDOR_TRANSMETA] = CPU_VENDOR_TRANSMETA, + [X86_VENDOR_NSC] = CPU_VENDOR_NSC, + [X86_VENDOR_HYGON] = CPU_VENDOR_HYGON, + }; + uint8_t x86_vendor = X86_VENDOR_UNKNOWN; + + for (i = 0; i < X86_VENDOR_NUM; i++) { + if (cpu_vendor_id != 0 && cpu_vendor_id == x86_vendors[i]) { + x86_vendor = i; + break; + } + } linux_cpu_has_clflush = (cpu_feature & CPUID_CLFSH); boot_cpu_data.x86_clflush_size = cpu_clflush_line_size; boot_cpu_data.x86_max_cores = mp_ncpus; boot_cpu_data.x86 = CPUID_TO_FAMILY(cpu_id); boot_cpu_data.x86_model = CPUID_TO_MODEL(cpu_id); + boot_cpu_data.x86_vendor = x86_vendor; __cpu_data = mallocarray(mp_maxid + 1, sizeof(*__cpu_data), M_KMALLOC, M_WAITOK | M_ZERO); @@ -2635,6 +2655,7 @@ linux_compat_init(void *arg) __cpu_data[i].x86_max_cores = mp_ncpus; __cpu_data[i].x86 = CPUID_TO_FAMILY(cpu_id); __cpu_data[i].x86_model = CPUID_TO_MODEL(cpu_id); + __cpu_data[i].x86_vendor = x86_vendor; } #endif rw_init(&linux_vma_lock, "lkpi-vma-lock");