From: Stephen Rothwell <sfr@canb.auug.org.au>
To: "Paolo Bonzini" <pbonzini@redhat.com>,
"Lucas De Marchi" <lucas.demarchi@intel.com>,
"Oded Gabbay" <ogabbay@kernel.org>,
"Thomas Hellström" <thomas.hellstrom@linux.intel.com>
Cc: DRM XE List <intel-xe@lists.freedesktop.org>,
KVM <kvm@vger.kernel.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Linux Next Mailing List <linux-next@vger.kernel.org>,
Yury Norov <yury.norov@gmail.com>
Subject: linux-next: manual merge of the kvm tree with the drm-xe tree
Date: Thu, 22 Feb 2024 14:58:42 +1100 [thread overview]
Message-ID: <20240222145842.1714b195@canb.auug.org.au> (raw)
[-- Attachment #1: Type: text/plain, Size: 3552 bytes --]
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 */
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
next reply other threads:[~2024-02-22 3:58 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-22 3:58 Stephen Rothwell [this message]
2024-02-22 10:42 ` linux-next: manual merge of the kvm tree with the drm-xe tree Paolo Bonzini
2024-03-01 18:17 ` Lucas De Marchi
2024-03-01 18:38 ` Paolo Bonzini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240222145842.1714b195@canb.auug.org.au \
--to=sfr@canb.auug.org.au \
--cc=intel-xe@lists.freedesktop.org \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-next@vger.kernel.org \
--cc=lucas.demarchi@intel.com \
--cc=ogabbay@kernel.org \
--cc=pbonzini@redhat.com \
--cc=thomas.hellstrom@linux.intel.com \
--cc=yury.norov@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).