From nobody Thu Dec 8 12:41:56 2022 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 4NSYgm490hz4jNjf; Thu, 8 Dec 2022 12:41: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 4NSYgm3ccKz3F0n; Thu, 8 Dec 2022 12:41:56 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1670503316; 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=qZGL87QiXQx3l+JUImtWPZDPjw4z0qvxn/VSxPydA4w=; b=xRrgXVqnoJnkSyHc5S3i2FmoMyE3GUYTY2l895gLyfX1zCDvTLw6SIQUCVTb6GTKVKFz4I jK3AaV2oV2hzekCtjTCAVklu1I291an2AWmHO6CnhiZx3QuVHT72KHsHUw4g/59V8w1tPL cgwf8BCTBqJ5hDnNDvYLSceXd9vcQDGoemIWM/GuRL+EaadBOv/dQGFlVBXulhV/K0td3j Q6Medw0WKNCiA6HYi11HIowCR6NqkbL4VTrV/Cs3z9REJGZ4ndbugh07MlDqY5AUtryfZL ClsqW/RtPsESj1xzV0MVLeB0FZ4NRHbatP1qiUI5MFyYjAUKvKTM9DJkd2IXFQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1670503316; 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=qZGL87QiXQx3l+JUImtWPZDPjw4z0qvxn/VSxPydA4w=; b=jK8nXaBxtKRtA8UbqOsuK45UeBI2r2F+eAMl5jV011OIQCHi7t/X60qDyquMSk86V06TSG Vh49PszqpHIVet8TrBbtP0RBOBMgwDljsS7KpmI8rdEIweub0O9HLCv+cofIOehpP3SqMW N2+Yuu9H+WD+4PCOTpuowxnonRLeUf37guGphKYzyM/QkVR7BNR8JPyXo6r61pa1QMzL2L 7ow5qH79BkVl1Fc3uvkNzydeh3l5xAUTeUIiVwyCsUIocis+oLiPhZQ/3pXnZJ6QGt3to1 hSm2hgrmsRTxH/SUmw2OSrqQ+j3fahwuT8AJkdCeo1wUN+eNAVJONZToGQjsog== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1670503316; a=rsa-sha256; cv=none; b=IMBrU0iVnuw6q2WMxWaKqkbliN79XZfxjqBmWXXe6dCO/0ls6P9RcdQpxfnC6MZJ8a3u79 jEE5Gv7Ywhcsy1xyI4Ta7qyE9WRw6hkvDkTolj0e0eM0jRpCF3O5j0Y+RuF0ig7ipuHtg5 UCCyQQJHi3bMvNV2QCQrugODUdug8v6pfwEnsuQC/hy5BiI+WHnP6c/QXNoYYmvq/3n5IN 1pDgN8LYMvBBNn9ZlBeKNhaFhmV5CpZSaiqKI6Lo7EBIxZ+YXh/YbQwz7WIhBuuuYzRWvx seSN6Ghcv/ZFvMORbI/PomqhiHkOBAvuKpqzid9eedid+9B9cOKl1C8hDDpGvQ== 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 4NSYgm2h1Szwfb; Thu, 8 Dec 2022 12:41: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 2B8Cfu2h068730; Thu, 8 Dec 2022 12:41:56 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 2B8Cfu6Q068729; Thu, 8 Dec 2022 12:41:56 GMT (envelope-from git) Date: Thu, 8 Dec 2022 12:41:56 GMT Message-Id: <202212081241.2B8Cfu6Q068729@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: =?utf-8?Q?Corvin=20K=C3=B6hne?= Subject: git: 6820a0512fa6 - stable/13 - linuxkpi/dmi: don't match exactly on DMI_MATCH 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: corvink X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 6820a0512fa6616ee1da46cb0075da80478776f0 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by corvink: URL: https://cgit.FreeBSD.org/src/commit/?id=6820a0512fa6616ee1da46cb0075da80478776f0 commit 6820a0512fa6616ee1da46cb0075da80478776f0 Author: Corvin Köhne AuthorDate: 2022-06-03 14:20:45 +0000 Commit: Corvin Köhne CommitDate: 2022-12-08 12:33:16 +0000 linuxkpi/dmi: don't match exactly on DMI_MATCH Linux has two defines to check dmi data. DMI_MATCH checks if the dmi string includes substr. DMI_EXACT_MATCH checks if the dmi string exactly matches substr. Compat layer should have the same behaviour. The new definition of dmi_strmatch shouldn't break any driver. A driver would break if it uses the highest bit of the slot field. Nevertheless, linux uses the same definition and FreeBSD uses dmi_field values as slot which are lower than 128. Sponsored by: Beckhoff Automation GmbH & Co. KG MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D35395 (cherry picked from commit 99902b1c52219bae4b9f3684e3ebd83152a1add4) LinuxKPI: Fix dmi_matches() function Make sure to check for NULL pointers and also check all search criterias, not only the first one! Bump the FreeBSD version. Reviewed by: manu@ Differential Revision: https://reviews.freebsd.org/D35403 MFC after: 1 week Sponsored by: NVIDIA Networking (cherry picked from commit 85d7875d42913c2cb10a007a1be05b210dc6aab2) --- .../linuxkpi/common/include/linux/mod_devicetable.h | 5 +++-- sys/compat/linuxkpi/common/src/linux_dmi.c | 17 +++++++++++++---- sys/sys/param.h | 2 +- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/sys/compat/linuxkpi/common/include/linux/mod_devicetable.h b/sys/compat/linuxkpi/common/include/linux/mod_devicetable.h index 89adcbc6e969..804fbb1df198 100644 --- a/sys/compat/linuxkpi/common/include/linux/mod_devicetable.h +++ b/sys/compat/linuxkpi/common/include/linux/mod_devicetable.h @@ -55,7 +55,8 @@ enum dmi_field { }; struct dmi_strmatch { - unsigned char slot; + unsigned char slot : 7; + unsigned char exact_match : 1; char substr[79]; }; @@ -67,7 +68,7 @@ struct dmi_system_id { }; #define DMI_MATCH(a, b) { .slot = a, .substr = b } -#define DMI_EXACT_MATCH(a, b) { .slot = a, .substr = b, } +#define DMI_EXACT_MATCH(a, b) { .slot = a, .substr = b, .exact_match = 1 } #define I2C_NAME_SIZE 20 #define I2C_MODULE_PREFIX "i2c:" diff --git a/sys/compat/linuxkpi/common/src/linux_dmi.c b/sys/compat/linuxkpi/common/src/linux_dmi.c index c0bb9a9f50d6..70d56c246c10 100644 --- a/sys/compat/linuxkpi/common/src/linux_dmi.c +++ b/sys/compat/linuxkpi/common/src/linux_dmi.c @@ -77,16 +77,25 @@ linux_dmi_match(enum dmi_field f, const char *str) static bool linux_dmi_matches(const struct dmi_system_id *dsi) { + enum dmi_field slot; int i; for (i = 0; i < nitems(dsi->matches); i++) { - if (dsi->matches[i].slot == DMI_NONE) + slot = dsi->matches[i].slot; + if (slot == DMI_NONE) break; - if (dmi_match(dsi->matches[i].slot, - dsi->matches[i].substr) == false) + if (slot >= DMI_STRING_MAX || + dmi_data[slot] == NULL) return (false); + if (dsi->matches[i].exact_match) { + if (dmi_match(slot, dsi->matches[i].substr)) + continue; + } else if (strstr(dmi_data[slot], + dsi->matches[i].substr) != NULL) { + continue; + } + return (false); } - return (true); } diff --git a/sys/sys/param.h b/sys/sys/param.h index e417fed4149b..57cf5937d952 100644 --- a/sys/sys/param.h +++ b/sys/sys/param.h @@ -60,7 +60,7 @@ * in the range 5 to 9. */ #undef __FreeBSD_version -#define __FreeBSD_version 1301509 /* Master, propagated to newvers */ +#define __FreeBSD_version 1301510 /* Master, propagated to newvers */ /* * __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD,