From nobody Mon Feb 13 21:09:56 2023 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 4PFxn055mCz3q5QW; Mon, 13 Feb 2023 21:09:56 +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 4PFxn02cq3z4STX; Mon, 13 Feb 2023 21:09:56 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1676322596; 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=gJ9mYL0gg+Td9no5K8/FI1Ai9k79JonRLUHI/nGiWOM=; b=B1GCn+pOhZzGUIPEPn92ZMNJI1uMZ6GmFbRaAUO2to6OE487sXfyt9be/bj2EwhSoJovRn z5+Sz+suMV+zEkuxqeojy7qrHj3zV+fYrQyGbN378Kb50LXUGJmN+hSrmvA85QK+XKH3oM acgMK4KiBbxszIbLR3pXV6P+9hDJh8+fkaarSXosF0a8KWHdcdTFIyXPT5Tff8/6sXGF+G hrk4EwQVC5sJzyBGUfxzRlCuUnsyCH8RnA+8Uhc1cDjqy+F7r0M79NhuywMcZ8cBw504gD 0h72uvxkpW10ThIf1v9M6msH26mvmdfqHU8UAj+YWCqCDPIsgcl6QbBko0GRnw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1676322596; 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=gJ9mYL0gg+Td9no5K8/FI1Ai9k79JonRLUHI/nGiWOM=; b=jRk6GFmKGR4xpGxxEC6SYWJA+pEHGaI4it3d5HDBEstClsP5lGKDJB3iu6XbCtjF+NujPv pAqsxXBxQ2IXRfRL6U5Osz8ccqqYPWWBJFOadkxIhy3AFn9X4HBef1Znl3IIiWtWT0DqGl KfEo2Hc1qI3TPOIyJqJEXmQqVOT4cyi3L8nSlRemKxML+n2ioksK40mggH6Txhl4q8uYVl oiYIrUaFjjmOCbW/6h11gn+xkBc4acK6Cmrn9DbaxLWlkwP+27twDI0DrAlQpnaoghnVOF 6pgt83OPPyCRWuW+8Zx8MPOkehcHzW4JmgSyVdJ0pMEhuUWOJdUzwwMsxls7zA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1676322596; a=rsa-sha256; cv=none; b=qbJiGp1jLmGCqo67qzTC3+aNtpp5OVIK6CvQDutDsSm+YGQvGuAqpShF/465gWUvBf5KqN eqkO0DWGDoAirFlbiLpAvF1ul5zVUDD5nxXTyirZscu7qUyqzWI/HY8WXlUSOOLfJeH/ak 2KwO9RoqkblyT8AO2zzzNeZLQO8flzTfGH41MmzFjD8W1zWL94mW/JzIlsVwBZyXtSgXLg bHE1QF06htaHY2CQeu5tsXhq2EQaqvQcaVVj4mcF85GXAzRAG4HTlA6E8BRYEY2167quXq ke4hv+3usDfKvF52/kZLTtDjYbd4N/WDkXkFr8sRnav3dEQGMrcp/cpJ2J+KqA== 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 4PFxn01hZzzXQ0; Mon, 13 Feb 2023 21:09:56 +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 31DL9uPQ056598; Mon, 13 Feb 2023 21:09:56 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 31DL9uxk056597; Mon, 13 Feb 2023 21:09:56 GMT (envelope-from git) Date: Mon, 13 Feb 2023 21:09:56 GMT Message-Id: <202302132109.31DL9uxk056597@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: =?utf-8?Q?Jean-S=C3=A9bastien=20P=C3=A9dron?= Subject: git: a27902c18388 - main - linuxkpi: Define `cpu_data(cpu)` 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: dumbbell X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: a27902c1838836b3fb00cd660ce37a4f20bd7991 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by dumbbell (ports committer): URL: https://cgit.FreeBSD.org/src/commit/?id=a27902c1838836b3fb00cd660ce37a4f20bd7991 commit a27902c1838836b3fb00cd660ce37a4f20bd7991 Author: Jean-Sébastien Pédron AuthorDate: 2023-02-10 15:38:43 +0000 Commit: Jean-Sébastien Pédron CommitDate: 2023-02-13 21:09:32 +0000 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 --- sys/compat/linuxkpi/common/include/asm/intel-family.h | 3 +++ sys/compat/linuxkpi/common/include/asm/processor.h | 3 +++ sys/compat/linuxkpi/common/src/linux_compat.c | 11 ++++++++++- 3 files changed, 16 insertions(+), 1 deletion(-) 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 30cc094a5222..8a2473e82d66 100644 --- a/sys/compat/linuxkpi/common/src/linux_compat.c +++ b/sys/compat/linuxkpi/common/src/linux_compat.c @@ -2745,6 +2745,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 * @@ -2767,7 +2768,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");