From patchwork Tue Sep 3 15:14:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincenzo Frascino X-Patchwork-Id: 13788874 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0520BCD342A for ; Tue, 3 Sep 2024 15:15:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 972388D0194; Tue, 3 Sep 2024 11:15:13 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9237D8D016E; Tue, 3 Sep 2024 11:15:13 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 74E3B8D0194; Tue, 3 Sep 2024 11:15:13 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 4BE868D016E for ; Tue, 3 Sep 2024 11:15:13 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id F02F1A0543 for ; Tue, 3 Sep 2024 15:15:12 +0000 (UTC) X-FDA: 82523775264.02.C936337 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf09.hostedemail.com (Postfix) with ESMTP id 46DF5140037 for ; Tue, 3 Sep 2024 15:15:11 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf09.hostedemail.com: domain of vincenzo.frascino@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=vincenzo.frascino@arm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1725376441; a=rsa-sha256; cv=none; b=FZra+ArAxR4xb174gCm9JqxzeRGcS8rDDfReqtB5iPL6dpJcVtduNpMMPZ4gUfIOwkQ/m+ x4r88PxWHHYuv+BOz/nOlSMS5aqIlVZuroug4/9BSxwfMkwVP2KI10sw+rita14TZBTJiX BqRkGj3/xuDtr2Tvd6w/XT8RgbS0yr0= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf09.hostedemail.com: domain of vincenzo.frascino@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=vincenzo.frascino@arm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1725376441; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=rC/iA80uwkvDwsKaNyrrlxed1oIdfzptoKFE7lCI1/A=; b=xMN+PCmy5oWpnlaNF8J7y5KEhA7sKthIWcBFT2y0COxxaSr3QbLnsbqx7zKVZZcpAZXQVe W1wuM2ipnioCz6SaShJyRH7X/wKdc3oneSfF9AqluJEY4YzVIlqLdHSqCw1DZzqjSenMK3 RjYbUraeBT3Gm7XxhahZIR457UVxCO0= Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id D484B1063; Tue, 3 Sep 2024 08:15:36 -0700 (PDT) Received: from e119884-lin.cambridge.arm.com (e119884-lin.cambridge.arm.com [10.1.196.72]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 7E6113F66E; Tue, 3 Sep 2024 08:15:07 -0700 (PDT) From: Vincenzo Frascino To: linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, linux-mm@kvack.org Cc: Vincenzo Frascino , Andy Lutomirski , Thomas Gleixner , "Jason A . Donenfeld" , Christophe Leroy , Michael Ellerman , Nicholas Piggin , Naveen N Rao , Ingo Molnar , Borislav Petkov , Dave Hansen , "H . Peter Anvin" , Theodore Ts'o , Arnd Bergmann , Andrew Morton , Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers Subject: [PATCH 5/9] vdso: Split linux/minmax.h Date: Tue, 3 Sep 2024 16:14:33 +0100 Message-Id: <20240903151437.1002990-6-vincenzo.frascino@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240903151437.1002990-1-vincenzo.frascino@arm.com> References: <20240903151437.1002990-1-vincenzo.frascino@arm.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 46DF5140037 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: 4aakb1j6a955gigoow8ioridfibz9en3 X-HE-Tag: 1725376511-884244 X-HE-Meta: U2FsdGVkX1/Shmwj+Qz+bqP90R7FmqIHL1t7vTIIKEVsMzQTkAnF9p/lXxrYBi0AWdIU0tpBD15hWQJiRWtaBTD0ScN1guuXGKqLXNPI8ZN8PyHiUuKLdlJVvMSyaUY2x5g+exCQei+zZcU+Exj6lFaI3EB7X1vx3pUW7lGfP91zGlGprTRcBWbnE/Pwjvsu5pdemYiyEnwy3WE7FvVtt4zmc3vHUajKaL/H3872tfixWftgQqaP1UgwQ4Ez1O3iDrCoJPUq4G7nLu+Qb+CYzNPsY+Dzes4E3OUKNeu0wcvHc7npX3nRA+NS1T4a0ZlbaGD2ancSp5n+kSXUZBI2JJ0mhx5RSN7GPNWx9mvc6gpCyYQeubLLtncZxoCAirAq0vcDywefx+SkWYuJZXE7E7VzuLYZo7oepNn0QN+euKqqMn2iZP0J3DS00SYw9Mp2PhXLp+LR3eRVMLSUix3po6Na+8GVTqKo6b43y15WYO0ULfvNEMilK5T/9cpC3EacSYStVDV6wt6kOoDXwc5rUNxH94wm1swwK/F+YXiE9xho4IhkQHVvqNGzXpzuQDS7Zn9WCgoYWL19LswbpQqIIEHNms0Nuqb2o8uGYYXwIaXKg/CZcxA7etiMCXiJKLv6ybAMKt6WO49mAi3PTuxGsGDWJYb4jsVaOjp8uuFXucFL0b0CKFZSJsZnkVmks3827IFKP5QxbqaNpBYCEhEhHMZEE1d+dShmpkxUpWbCMq2m+wgx6WatSnFjneRHJNy0BC/tNUMl4CDNif2M7WMNbfLLXsLTrWng9il9x6ilDqINncWoI1AvlCf/Skpeep2Az13hBBw1D8ITx86TYeCp5PutJfWsAR/LEAFLLud19Hv1WgNmv3suLjv9O9NWKfiCJi9NPXjDgF2SU4GBQ7DcF1MSIy7Vf+Td07Bvd/ZogvZJW/c5flphqehihT7Q3tcHQXjGjLQyylvUVYryPMG 0kvBJT+7 GpCiOq8c86uMleQvATxWv37TeINfhZa2QsxgfPFMEi7hYHRsEeuA/0YKJJYZsX7OgQoBqRvOfzNorH/VD3GGyOHMISs5Gl6RiB3FZx9OTLe++1kjGoyFt3RG3W7AyhRwXstwchpSNsqtGqcz0PKGYtkeMI3eHQiBeWkPFOZovKhY7XoR92FiyES0yZSP+szbsKRm2Q9IyzQHUmtN5f9v/DAozQ6lWbGKDF3KACNBeXyx3P5o= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: The VDSO implementation includes headers from outside of the vdso/ namespace. Split linux/minmax.h to make sure that the generic library uses only the allowed namespace. Cc: Andy Lutomirski Cc: Thomas Gleixner Cc: Jason A. Donenfeld Signed-off-by: Vincenzo Frascino --- include/linux/minmax.h | 28 +--------------------------- include/vdso/minmax.h | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 27 deletions(-) create mode 100644 include/vdso/minmax.h diff --git a/include/linux/minmax.h b/include/linux/minmax.h index 98008dd92153..846e3fa65c96 100644 --- a/include/linux/minmax.h +++ b/include/linux/minmax.h @@ -6,6 +6,7 @@ #include #include #include +#include /* * min()/max()/clamp() macros must accomplish three things: @@ -84,17 +85,6 @@ #define __types_ok3(x,y,z,ux,uy,uz) \ (__sign_use(x,ux) & __sign_use(y,uy) & __sign_use(z,uz)) -#define __cmp_op_min < -#define __cmp_op_max > - -#define __cmp(op, x, y) ((x) __cmp_op_##op (y) ? (x) : (y)) - -#define __cmp_once_unique(op, type, x, y, ux, uy) \ - ({ type ux = (x); type uy = (y); __cmp(op, ux, uy); }) - -#define __cmp_once(op, type, x, y) \ - __cmp_once_unique(op, type, x, y, __UNIQUE_ID(x_), __UNIQUE_ID(y_)) - #define __careful_cmp_once(op, x, y, ux, uy) ({ \ __auto_type ux = (x); __auto_type uy = (y); \ BUILD_BUG_ON_MSG(!__types_ok(x,y,ux,uy), \ @@ -204,22 +194,6 @@ * Or not use min/max/clamp at all, of course. */ -/** - * min_t - return minimum of two values, using the specified type - * @type: data type to use - * @x: first value - * @y: second value - */ -#define min_t(type, x, y) __cmp_once(min, type, x, y) - -/** - * max_t - return maximum of two values, using the specified type - * @type: data type to use - * @x: first value - * @y: second value - */ -#define max_t(type, x, y) __cmp_once(max, type, x, y) - /* * Do not check the array parameter using __must_be_array(). * In the following legit use-case where the "array" passed is a simple pointer, diff --git a/include/vdso/minmax.h b/include/vdso/minmax.h new file mode 100644 index 000000000000..26724f34c513 --- /dev/null +++ b/include/vdso/minmax.h @@ -0,0 +1,38 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef __VDSO_MINMAX_H +#define __VDSO_MINMAX_H + +#ifndef __ASSEMBLY__ + +#include + +#define __cmp_op_min < +#define __cmp_op_max > + +#define __cmp(op, x, y) ((x) __cmp_op_##op (y) ? (x) : (y)) + +#define __cmp_once_unique(op, type, x, y, ux, uy) \ + ({ type ux = (x); type uy = (y); __cmp(op, ux, uy); }) + +#define __cmp_once(op, type, x, y) \ + __cmp_once_unique(op, type, x, y, __UNIQUE_ID(x_), __UNIQUE_ID(y_)) + +/** + * min_t - return minimum of two values, using the specified type + * @type: data type to use + * @x: first value + * @y: second value + */ +#define min_t(type, x, y) __cmp_once(min, type, x, y) + +/** + * max_t - return maximum of two values, using the specified type + * @type: data type to use + * @x: first value + * @y: second value + */ +#define max_t(type, x, y) __cmp_once(max, type, x, y) + +#endif /* !__ASSEMBLY__ */ + +#endif /* __VDSO_MINMAX_H */