Skip to content

Commit 786adae

Browse files
committed
Revert "Redo cpuid feature detection, part 2"
This reverts commit ad3d9f7.
1 parent 1b65a8c commit 786adae

File tree

6 files changed

+36
-22
lines changed

6 files changed

+36
-22
lines changed

include/os/windows/spl/sys/processor.h

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
#define _SPL_PROCESSOR_H
44

55
#include <sys/types.h>
6-
#include <intrin.h>
76

87
extern uint32_t getcpuid();
98

@@ -15,22 +14,41 @@ extern int __cpuid_count(unsigned int __level, unsigned int __sublevel,
1514
unsigned int __eax, unsigned int __ebx,
1615
unsigned int __ecx, unsigned int __edx);
1716

17+
#define __cpuid_count(level, count, a, b, c, d) \
18+
__asm__("xchg{l}\t{%%}ebx, %1\n\t" \
19+
"cpuid\n\t" \
20+
"xchg{l}\t{%%}ebx, %1\n\t" \
21+
: "=a" (a), "=r" (b), "=c" (c), "=d" (d) \
22+
: "0" (level), "2" (count))
23+
24+
#define __cpuid(level, a, b, c, d) \
25+
__asm__("xchg{l}\t{%%}ebx, %1\n\t" \
26+
"cpuid\n\t" \
27+
"xchg{l}\t{%%}ebx, %1\n\t" \
28+
: "=a" (a), "=r" (b), "=c" (c), "=d" (d) \
29+
: "0" (level))
30+
1831
static inline unsigned int
1932
__get_cpuid_max(unsigned int __ext, unsigned int *__sig)
2033
{
21-
#ifdef _WIN32
22-
int32_t r[4];
23-
__cpuid(r, __ext);
24-
if (__sig)
25-
*__sig = (uint32_t)r[1];
26-
return ((uint32_t)r[0]);
27-
#else
2834
unsigned int __eax, __ebx, __ecx, __edx;
2935
__cpuid(__ext, __eax, __ebx, __ecx, __edx);
3036
if (__sig)
3137
*__sig = __ebx;
3238
return (__eax);
33-
#endif
39+
}
40+
41+
/* macOS does have do_cpuid() macro */
42+
static inline int
43+
__get_cpuid(unsigned int __level,
44+
unsigned int *__eax, unsigned int *__ebx,
45+
unsigned int *__ecx, unsigned int *__edx)
46+
{
47+
unsigned int __ext = __level & 0x80000000;
48+
if (__get_cpuid_max(__ext, 0) < __level)
49+
return (0);
50+
__cpuid(__level, *__eax, *__ebx, *__ecx, *__edx);
51+
return (1);
3452
}
3553

3654
#endif // x86

include/os/windows/spl/sys/simd.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -262,12 +262,8 @@ __cpuid_check_feature(const cpuid_feature_desc_t *desc)
262262
* for AVX2. It is a macro, so return parameters
263263
* are passed by value.
264264
*/
265-
#ifdef _WIN32
266-
__cpuidex((int32_t *)r, desc->leaf, desc->subleaf);
267-
#else
268265
__cpuid_count(desc->leaf, desc->subleaf,
269266
r[EAX], r[EBX], r[ECX], r[EDX]);
270-
#endif
271267
return ((r[desc->reg] & desc->flag) == desc->flag);
272268
}
273269
return (B_FALSE);

module/icp/algs/blake3/blake3_impl.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,10 +355,10 @@ blake3_param_set(const char *val, zfs_kernel_param_t *unused)
355355
int
356356
win32_blake3_param_set(ZFS_MODULE_PARAM_ARGS)
357357
{
358-
static char buffer[PAGE_SIZE]; /* Looks like they use page size */
359358
*type = ZT_TYPE_STRING;
360359

361360
if (set == B_FALSE) {
361+
char buffer[PAGE_SIZE]; /* Looks like they use page size */
362362
blake3_param_get(buffer, NULL);
363363
*ptr = buffer;
364364
*len = strlen(buffer);

module/icp/algs/modes/gcm.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1031,15 +1031,15 @@ icp_gcm_impl_get(char *buffer, zfs_kernel_param_t *kp)
10311031
int
10321032
win32_icp_gcm_impl_set(ZFS_MODULE_PARAM_ARGS)
10331033
{
1034-
static char buffer[PAGE_SIZE] = "";
1034+
static char str[1024] = "";
10351035

10361036
*type = ZT_TYPE_STRING;
10371037

10381038
if (set == B_FALSE) {
10391039
if (gcm_impl_initialized)
1040-
icp_gcm_impl_get(buffer, NULL);
1041-
*ptr = buffer;
1042-
*len = strlen(buffer);
1040+
icp_gcm_impl_get(str, NULL);
1041+
*ptr = str;
1042+
*len = strlen(str);
10431043
return (0);
10441044
}
10451045

module/os/windows/zfs/sysctl_os.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,7 @@ param_set_arc_int(ZFS_MODULE_PARAM_ARGS)
567567
int
568568
param_set_active_allocator(ZFS_MODULE_PARAM_ARGS)
569569
{
570-
static char buf[16];
570+
char buf[16];
571571

572572
*type = ZT_TYPE_STRING;
573573

@@ -668,7 +668,7 @@ param_set_deadman_ziotime(ZFS_MODULE_PARAM_ARGS)
668668
int
669669
param_set_deadman_failmode(ZFS_MODULE_PARAM_ARGS)
670670
{
671-
static char buf[16];
671+
char buf[16];
672672

673673
*type = ZT_TYPE_STRING;
674674

module/zfs/spa.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1485,7 +1485,7 @@ spa_taskq_write_param(ZFS_MODULE_PARAM_ARGS)
14851485
static int
14861486
win32_spa_taskq_read_param_set(ZFS_MODULE_PARAM_ARGS)
14871487
{
1488-
static char str[1024] = "";
1488+
char str[1024] = "";
14891489

14901490
*type = ZT_TYPE_STRING;
14911491

@@ -1506,7 +1506,7 @@ win32_spa_taskq_read_param_set(ZFS_MODULE_PARAM_ARGS)
15061506
static int
15071507
win32_spa_taskq_write_param_set(ZFS_MODULE_PARAM_ARGS)
15081508
{
1509-
static char str[1024] = "";
1509+
char str[1024] = "";
15101510

15111511
*type = ZT_TYPE_STRING;
15121512

0 commit comments

Comments
 (0)