From nobody Sat Feb 17 21:33:15 2024 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 4Tchqc247fz59lGy; Sat, 17 Feb 2024 21:33:16 +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 4Tchqb4lCjz4hpB; Sat, 17 Feb 2024 21:33:15 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1708205595; 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=ZqtI1TPuG1Re5S27KgPo3NVzqnJaizk7RxH4cu2DJmU=; b=Zlpel87wSZmTm/H9qMuFBLaXd+nPQEQmGbZV1Kkca/OJh8yvouBlH9Uf4xi9hVkyAUqb0D UCJFyBdVh/0PFMs/zXnkaYo0Ufk98iP0usK2DF5Ij3f+zTWr42LMQodIVIe5CVESWx7+WW PNZtmZysNpyWkWQ2dLpd9q59YZ0qQL2SYHllJzRTmDcROuBXNwtNhZake5G6HBVachMyZm AoZVUGmZ+SyE4rPKpNVqVALnFMP1nQ/KiuwuJF14Yb2/0ZmCxN3qy8T/zaXXIwsPKYK8V7 Oyf2w9rp8An28qWBiGsnXOVOHPS88vVBjUxUAUImF9XuLffOOgX7vRtdQ19JBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1708205595; 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=ZqtI1TPuG1Re5S27KgPo3NVzqnJaizk7RxH4cu2DJmU=; b=N+w+wHQun+z6OhWT2JStep64ZjpV7iLnFUiS8v6CDrr+JfFJHyplZS2zcARotNKT14bOsg wpRj6irKqlEhs/266aWvWd+wNU1gg0tRZ3uYpUvI2FfHulb+pUgETEUMWCYCTNklzyVGDK Vi4seQDTM7EtxO594WYEGNvXpek/EAksXZIMAdvN51HZvtMCCvsqx7CQwAd/Tb6aphEnSB EKf3Vu5YDMOBD4ReXnYWM9vXItG3Ue4yOsFXHev2qkaw85Gakp9ntK4vjrZxsq79bWifmq lwYzulJPjGPHMQNoZI2GALknYDmOyYrimhDIdvcdDHAtCvmIx7+kAdMtxjcLvA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1708205595; a=rsa-sha256; cv=none; b=iF20ziDGizUO5ShWL3Af90oaPIkzvUdVmqI6ch7HqyifmTEGudDWYcBxXROfBa8d9K0H+X 4iXOsEy1+1qcGnQUMYJTf2bFL4uHrNA1XE5wIj/clRZXDT804BBEnsoffUS4TkrJMz7w19 wLszY43ZYOxA19LsEfZ3OUNJfMLaXPUkooQvg91/dcixQJzcd3tUthSvkwFZ74uBvRwYvJ +80M9sMgHBN2kOw1odRtqS8LO4Juy2Dp3ZBunxF4lepdpgCbiJ+47RuAF0C+nUYotYgngK Ve7eoj/pnDXpZyV8oak7cSJmEqr7qNS5HPPR5NVz8TVsfrFfM/Z/YFHXcD2poA== 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 4Tchqb3l5MzPdJ; Sat, 17 Feb 2024 21:33:15 +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 41HLXFNZ021400; Sat, 17 Feb 2024 21:33:15 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 41HLXFD6021397; Sat, 17 Feb 2024 21:33:15 GMT (envelope-from git) Date: Sat, 17 Feb 2024 21:33:15 GMT Message-Id: <202402172133.41HLXFD6021397@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Vladimir Kondratyev Subject: git: 06e0d2934d5c - stable/14 - LinuxKPI: Add x86_vendor field to struct cpuinfo_x86 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: wulf X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: 06e0d2934d5c38f8f7ae1fc2e6a38e5c464742be Auto-Submitted: auto-generated The branch stable/14 has been updated by wulf: URL: https://cgit.FreeBSD.org/src/commit/?id=06e0d2934d5c38f8f7ae1fc2e6a38e5c464742be commit 06e0d2934d5c38f8f7ae1fc2e6a38e5c464742be Author: Vladimir Kondratyev AuthorDate: 2023-12-24 08:20:00 +0000 Commit: Vladimir Kondratyev CommitDate: 2024-02-17 20:58:39 +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 (cherry picked from commit b8c88a61750174f62db45784d6b4dc98de4073b1) --- 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 9e784396c63a..1165702e0652 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 b076a66ded77..c74021e32561 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 @@ -2633,17 +2634,37 @@ 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; for (i = 0; i < MAXCPU; i++) { __cpu_data[i].x86_clflush_size = cpu_clflush_line_size; __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");