From nobody Sat Jan 22 19:36:34 2022 X-Original-To: dev-commits-src-branches@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 16A22196BB58; Sat, 22 Jan 2022 19:36:39 +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 4Jh61x5XTTz3RCH; Sat, 22 Jan 2022 19:36:37 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1642880198; 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=EE+8jM2WP+X9lAXOgxgZ62VpzXxcj/Z+09H1gF9W3UQ=; b=TG+9l62/ozf+aFJl392XlHxCpTL7Yde9IPOA+DJ1s34o6PeTkFrDObO7zMhy2O6zya9DH7 hoxpa1e5r3jWw9/2SvXtmqYabs91eT7PF8D6txWJlLow9inyuJexraFjs1KhC96mQEKKZD pP/aLYjjmyQB8x2wuhpK4IJ7EafTchIs/Ah6aAb1EHS8Khm9bVp05/1ZBDHUN8U6PL03PA sWiTh3ZEJobE2PCdaCUK117DK9yHyZSRvxnsd9NPBxZykQqPzUppV3HqXPjPQ6ysH/pZbT bfeeThVnVeSRZT7ukQYTRL8o4bpewNpsfn5SC26ZJAfPdTxD3tJFLNnBsVpe7A== 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 21D9915036; Sat, 22 Jan 2022 19:36:34 +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 20MJaYbT000297; Sat, 22 Jan 2022 19:36:34 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 20MJaYGu000296; Sat, 22 Jan 2022 19:36:34 GMT (envelope-from git) Date: Sat, 22 Jan 2022 19:36:34 GMT Message-Id: <202201221936.20MJaYGu000296@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: b42bc4d602ff - stable/13 - LinuxKPI: Add static_cpu_has() implementation List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@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/13 X-Git-Reftype: branch X-Git-Commit: b42bc4d602fff9f29e9b249f2b6f1961d12185fd Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1642880198; 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=EE+8jM2WP+X9lAXOgxgZ62VpzXxcj/Z+09H1gF9W3UQ=; b=A3dwHuPCNc96blvrqrMNyj8/2sx0TQR9dXTE06TdrpzrYTsZ/LG4SdjqPiqAy75qn9lQRs /X28XRPI6e/WzCKbRSi9448911t9KdxF2j+3YtTED/LEnxqU9V3iuicw3WN8zuN/9H13jF DHQl8sXlcpuOSOzHq95LV9ISIbzlA/C3uLzoSD7wQd94rqVOFFUpzzRdGcotQVw8RJ/32N +PEFzc54ZDIsLpGVnT8mBhuis1Qh5z93yUzuL6a0DI2ydpGRzBsc3/oJwU+tiZIlVfLtBn wD/dbQR1vsjenwAL4A1H2eneD3uBDVZKwmoOirh/M9hImmUMJbBWO1d22TwXSQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1642880198; a=rsa-sha256; cv=none; b=ETj6GYtX36TW/Lg39ej9FMLhneMiv+UwWdqs86qpTB+vVo3lzmNbqg+LbWTe7uZVm+lE7i nUvNfZuDBIzbS31RLVJmPUKy0Lgk5G42LNkaHbhdnntFZiihXsR1JbTHpDUkvK4oIgwL0t k4bcS68s8AcnAh3ArNbPy+zzx5/e3OklX1p2sticWbIjQBbE0eXr5YNmlOaQxg+4XH9+gO 8diqBb8dmKKygkGveTHba+uKZmhii/IE9ibCFKO8Dd0klJvY5dHx4jDWBWHlz0gz3cxUPC yrZ6FsWMMWWa0NN6l7bKrqJB7CMAzofwetGYh6J5td+cyPkArirKcJlO2ZZ8Zg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by wulf: URL: https://cgit.FreeBSD.org/src/commit/?id=b42bc4d602fff9f29e9b249f2b6f1961d12185fd commit b42bc4d602fff9f29e9b249f2b6f1961d12185fd Author: Vladimir Kondratyev AuthorDate: 2021-12-06 10:18:03 +0000 Commit: Vladimir Kondratyev CommitDate: 2022-01-22 19:34:37 +0000 LinuxKPI: Add static_cpu_has() implementation static_cpu_has returns true if CPU supports requested feature. Obtained from: OpenBSD MFC after: 1 week Reviewed by: hselasky, manu Differential Revision: https://reviews.freebsd.org/D33301 (cherry picked from commit f3ddb82d9a99d36ea585d034ccbdea1dfc5b1def) --- .../linuxkpi/common/include/asm/cpufeature.h | 37 ++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/sys/compat/linuxkpi/common/include/asm/cpufeature.h b/sys/compat/linuxkpi/common/include/asm/cpufeature.h new file mode 100644 index 000000000000..049088648aa3 --- /dev/null +++ b/sys/compat/linuxkpi/common/include/asm/cpufeature.h @@ -0,0 +1,37 @@ +/* Public domain. */ + +#ifndef _ASM_CPUFEATURE_H +#define _ASM_CPUFEATURE_H + +#if defined(__amd64__) || defined(__i386__) + +#include +#include + +#define X86_FEATURE_CLFLUSH 1 +#define X86_FEATURE_XMM4_1 2 +#define X86_FEATURE_PAT 3 +#define X86_FEATURE_HYPERVISOR 4 + +static inline bool +static_cpu_has(uint16_t f) +{ + switch (f) { + case X86_FEATURE_CLFLUSH: + return ((cpu_feature & CPUID_CLFSH) != 0); + case X86_FEATURE_XMM4_1: + return ((cpu_feature2 & CPUID2_SSE41) != 0); + case X86_FEATURE_PAT: + return ((cpu_feature & CPUID_PAT) != 0); + case X86_FEATURE_HYPERVISOR: + return ((cpu_feature2 & CPUID2_HV) != 0); + default: + return (false); + } +} + +#define boot_cpu_has(x) static_cpu_has(x) + +#endif + +#endif