[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240222145842.1714b195@canb.auug.org.au>
Date: Thu, 22 Feb 2024 14:58:42 +1100
From: Stephen Rothwell <sfr@...b.auug.org.au>
To: Paolo Bonzini <pbonzini@...hat.com>, Lucas De Marchi
<lucas.demarchi@...el.com>, Oded Gabbay <ogabbay@...nel.org>, Thomas
Hellström <thomas.hellstrom@...ux.intel.com>
Cc: DRM XE List <intel-xe@...ts.freedesktop.org>, KVM <kvm@...r.kernel.org>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>, Linux Next
Mailing List <linux-next@...r.kernel.org>, Yury Norov
<yury.norov@...il.com>
Subject: linux-next: manual merge of the kvm tree with the drm-xe tree
Hi all,
Today's linux-next merge of the kvm tree got a conflict in:
include/linux/bits.h
between commits:
b77cb9640f1f ("bits: introduce fixed-type genmasks")
34b80df456ca ("bits: Introduce fixed-type BIT")
from the drm-xe tree and commit:
3c7a8e190bc5 ("uapi: introduce uapi-friendly macros for GENMASK")
from the kvm tree.
I fixed it up (see below) and can carry the fix as necessary. This
is now fixed as far as linux-next is concerned, but any non trivial
conflicts should be mentioned to your upstream maintainer when your tree
is submitted for merging. You may also want to consider cooperating
with the maintainer of the conflicting tree to minimise any particularly
complex conflicts.
--
Cheers,
Stephen Rothwell
diff --cc include/linux/bits.h
index 811846ce110e,0eb24d21aac2..000000000000
--- a/include/linux/bits.h
+++ b/include/linux/bits.h
@@@ -4,10 -4,9 +4,11 @@@
#include <linux/const.h>
#include <vdso/bits.h>
+ #include <uapi/linux/bits.h>
#include <asm/bitsperlong.h>
+#define BITS_PER_TYPE(type) (sizeof(type) * BITS_PER_BYTE)
+
#define BIT_MASK(nr) (UL(1) << ((nr) % BITS_PER_LONG))
#define BIT_WORD(nr) ((nr) / BITS_PER_LONG)
#define BIT_ULL_MASK(nr) (ULL(1) << ((nr) % BITS_PER_LONG_LONG))
@@@ -33,42 -29,11 +34,42 @@@
* disable the input check if that is the case.
*/
#define GENMASK_INPUT_CHECK(h, l) 0
+#define BIT_INPUT_CHECK(type, b) 0
#endif
-#define GENMASK(h, l) \
- (GENMASK_INPUT_CHECK(h, l) + __GENMASK(h, l))
-#define GENMASK_ULL(h, l) \
- (GENMASK_INPUT_CHECK(h, l) + __GENMASK_ULL(h, l))
+/*
+ * Generate a mask for the specified type @t. Additional checks are made to
+ * guarantee the value returned fits in that type, relying on
+ * shift-count-overflow compiler check to detect incompatible arguments.
+ * For example, all these create build errors or warnings:
+ *
+ * - GENMASK(15, 20): wrong argument order
+ * - GENMASK(72, 15): doesn't fit unsigned long
+ * - GENMASK_U32(33, 15): doesn't fit in a u32
+ */
- #define __GENMASK(t, h, l) \
++#define ___GENMASK(t, h, l) \
+ (GENMASK_INPUT_CHECK(h, l) + \
+ (((t)~0ULL - ((t)(1) << (l)) + 1) & \
+ ((t)~0ULL >> (BITS_PER_TYPE(t) - 1 - (h)))))
+
- #define GENMASK(h, l) __GENMASK(unsigned long, h, l)
- #define GENMASK_ULL(h, l) __GENMASK(unsigned long long, h, l)
- #define GENMASK_U8(h, l) __GENMASK(u8, h, l)
- #define GENMASK_U16(h, l) __GENMASK(u16, h, l)
- #define GENMASK_U32(h, l) __GENMASK(u32, h, l)
- #define GENMASK_U64(h, l) __GENMASK(u64, h, l)
++#define GENMASK(h, l) ___GENMASK(unsigned long, h, l)
++#define GENMASK_ULL(h, l) ___GENMASK(unsigned long long, h, l)
++#define GENMASK_U8(h, l) ___GENMASK(u8, h, l)
++#define GENMASK_U16(h, l) ___GENMASK(u16, h, l)
++#define GENMASK_U32(h, l) ___GENMASK(u32, h, l)
++#define GENMASK_U64(h, l) ___GENMASK(u64, h, l)
+
+/*
- * Fixed-type variants of BIT(), with additional checks like __GENMASK(). The
++ * Fixed-type variants of BIT(), with additional checks like ___GENMASK() The
+ * following examples generate compiler warnings due to shift-count-overflow:
+ *
+ * - BIT_U8(8)
+ * - BIT_U32(-1)
+ * - BIT_U32(40)
+ */
+#define BIT_U8(b) ((u8)(BIT_INPUT_CHECK(u8, b) + BIT(b)))
+#define BIT_U16(b) ((u16)(BIT_INPUT_CHECK(u16, b) + BIT(b)))
+#define BIT_U32(b) ((u32)(BIT_INPUT_CHECK(u32, b) + BIT(b)))
+#define BIT_U64(b) ((u64)(BIT_INPUT_CHECK(u64, b) + BIT(b)))
#endif /* __LINUX_BITS_H */
Content of type "application/pgp-signature" skipped
Powered by blists - more mailing lists