[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240903151437.1002990-6-vincenzo.frascino@arm.com>
Date: Tue, 3 Sep 2024 16:14:33 +0100
From: Vincenzo Frascino <vincenzo.frascino@....com>
To: linux-kernel@...r.kernel.org,
linux-arch@...r.kernel.org,
linux-mm@...ck.org
Cc: Vincenzo Frascino <vincenzo.frascino@....com>,
Andy Lutomirski <luto@...nel.org>,
Thomas Gleixner <tglx@...utronix.de>,
"Jason A . Donenfeld" <Jason@...c4.com>,
Christophe Leroy <christophe.leroy@...roup.eu>,
Michael Ellerman <mpe@...erman.id.au>,
Nicholas Piggin <npiggin@...il.com>,
Naveen N Rao <naveen@...nel.org>,
Ingo Molnar <mingo@...hat.com>,
Borislav Petkov <bp@...en8.de>,
Dave Hansen <dave.hansen@...ux.intel.com>,
"H . Peter Anvin" <hpa@...or.com>,
Theodore Ts'o <tytso@....edu>,
Arnd Bergmann <arnd@...db.de>,
Andrew Morton <akpm@...ux-foundation.org>,
Steven Rostedt <rostedt@...dmis.org>,
Masami Hiramatsu <mhiramat@...nel.org>,
Mathieu Desnoyers <mathieu.desnoyers@...icios.com>
Subject: [PATCH 5/9] vdso: Split linux/minmax.h
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 <luto@...nel.org>
Cc: Thomas Gleixner <tglx@...utronix.de>
Cc: Jason A. Donenfeld <Jason@...c4.com>
Signed-off-by: Vincenzo Frascino <vincenzo.frascino@....com>
---
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 <linux/compiler.h>
#include <linux/const.h>
#include <linux/types.h>
+#include <vdso/minmax.h>
/*
* 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 <linux/compiler.h>
+
+#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 */
--
2.34.1
Powered by blists - more mailing lists