aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Sébastien Pédron <dumbbell@FreeBSD.org>2023-02-10 15:38:43 +0000
committerJean-Sébastien Pédron <dumbbell@FreeBSD.org>2023-02-16 11:55:20 +0000
commit708dc3db0417b2e53d70e88cabb48a3018b632f3 (patch)
tree55802921053ac29cf4d2288657048771e7da0714
parent1d5100d9be2d97d2c74fe15f29a7a42cbada144b (diff)
downloadsrc-708dc3db0417b2e53d70e88cabb48a3018b632f3.tar.gz
src-708dc3db0417b2e53d70e88cabb48a3018b632f3.zip
linuxkpi: Define `cpu_data(cpu)`
`cpu_data(cpu)` evaluates to a `struct cpuinfo_x86` filled with attributes of the given CPU number. The CPU number is an index in the `__cpu_data[]` array with MAXCPU entries. On FreeBSD, we simply initialize all of them like we do with `boot_cpu_data`. While here, we add the `x86_model` field to the `struct cpuinfo_x86`. We use `CPUID_TO_MODEL()` to set it. At the same time, we fix the value of `x86` which should have been set to the CPU family. It was using the same implementation as `CPUID_TO_MODEL()` before. It now uses `CPUID_TO_FAMILY()`. Reviewed by: manu Approved by: manu Differential Revision: https://reviews.freebsd.org/D38542 (cherry picked from commit a27902c1838836b3fb00cd660ce37a4f20bd7991)
-rw-r--r--sys/compat/linuxkpi/common/include/asm/intel-family.h3
-rw-r--r--sys/compat/linuxkpi/common/include/asm/processor.h3
-rw-r--r--sys/compat/linuxkpi/common/src/linux_compat.c11
3 files changed, 16 insertions, 1 deletions
diff --git a/sys/compat/linuxkpi/common/include/asm/intel-family.h b/sys/compat/linuxkpi/common/include/asm/intel-family.h
new file mode 100644
index 000000000000..1dae979b3c5e
--- /dev/null
+++ b/sys/compat/linuxkpi/common/include/asm/intel-family.h
@@ -0,0 +1,3 @@
+/* Public domain. */
+
+#define INTEL_FAM6_ROCKETLAKE 0xA7
diff --git a/sys/compat/linuxkpi/common/include/asm/processor.h b/sys/compat/linuxkpi/common/include/asm/processor.h
index 86d4ab9de98f..9e784396c63a 100644
--- a/sys/compat/linuxkpi/common/include/asm/processor.h
+++ b/sys/compat/linuxkpi/common/include/asm/processor.h
@@ -35,11 +35,14 @@
#if defined(__i386__) || defined(__amd64__)
struct cpuinfo_x86 {
uint8_t x86;
+ uint8_t x86_model;
uint16_t x86_clflush_size;
uint16_t x86_max_cores;
};
extern struct cpuinfo_x86 boot_cpu_data;
+extern struct cpuinfo_x86 __cpu_data[];
+#define cpu_data(cpu) __cpu_data[cpu]
#endif
#define cpu_relax() cpu_spinwait()
diff --git a/sys/compat/linuxkpi/common/src/linux_compat.c b/sys/compat/linuxkpi/common/src/linux_compat.c
index 0714106ca418..4ceb33c348f6 100644
--- a/sys/compat/linuxkpi/common/src/linux_compat.c
+++ b/sys/compat/linuxkpi/common/src/linux_compat.c
@@ -2747,6 +2747,7 @@ io_mapping_create_wc(resource_size_t base, unsigned long size)
#if defined(__i386__) || defined(__amd64__)
bool linux_cpu_has_clflush;
struct cpuinfo_x86 boot_cpu_data;
+struct cpuinfo_x86 __cpu_data[MAXCPU];
#endif
cpumask_t *
@@ -2769,7 +2770,15 @@ linux_compat_init(void *arg)
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 = ((cpu_id & 0xf0000) >> 12) | ((cpu_id & 0xf0) >> 4);
+ boot_cpu_data.x86 = CPUID_TO_FAMILY(cpu_id);
+ boot_cpu_data.x86_model = CPUID_TO_MODEL(cpu_id);
+
+ 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);
+ }
#endif
rw_init(&linux_vma_lock, "lkpi-vma-lock");