From: Borislav Petkov <bp@amd64.org>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Borislav Petkov <bp@amd64.org>, "H. Peter Anvin" <hpa@zytor.com>,
Ingo Molnar <mingo@elte.hu>, Thomas Gleixner <tglx@linutronix.de>,
LKML <linux-kernel@vger.kernel.org>,
"Przywara, Andre" <Andre.Przywara@amd.com>,
"Pohlack, Martin" <Martin.Pohlack@amd.com>
Subject: Re: [PATCH] x86, AMD: Correct F15h IC aliasing issue
Date: Wed, 27 Jul 2011 19:10:15 +0200 [thread overview]
Message-ID: <20110727171015.GD19477@aftab> (raw)
In-Reply-To: <CA+55aFze=w7tjmyGa2w=D8b6roDuL5O0gmDKkSzLKBLLYZ_a+A@mail.gmail.com>
On Sun, Jul 24, 2011 at 01:39:25PM -0400, Linus Torvalds wrote:
> > Yeah, I like the BITS() thing - will change. I actually have a similar
> > macro GENMASK(o, hi) in <drivers/edac/amd64_edac.h> - I should move it
> > to <linux/bitops.h> and rename it to BITS().
>
> So it may be that BITS() is much too generic a name, and will cause
> problems. A quick "git grep -w BITS" certainly finds a fair number of
> hits. So I don't think it's usable as-is, it was meant more as
> pseudo-code.
How about something like the following instead - it should take care
of all your bitmask generating needs. There are also a couple of
GENMASK/BITMASK identical definitions around the tree which can be
unified while I'm at it too.
diff --git a/include/linux/bitops.h b/include/linux/bitops.h
index a3ef66a..b1970e3 100644
--- a/include/linux/bitops.h
+++ b/include/linux/bitops.h
@@ -6,6 +6,19 @@
#define BIT(nr) (1UL << (nr))
#define BIT_MASK(nr) (1UL << ((nr) % BITS_PER_LONG))
#define BIT_WORD(nr) ((nr) / BITS_PER_LONG)
+
+/*
+ * Create a contiguous bitmask starting at bit position @lo and ending at
+ * position @hi. For example
+ *
+ * GENMASK_ULL(21, 39) gives us the 64bit vector 0x000000ffffe00000.
+ */
+#define _GENMASK_T(cast, type, lo, hi) \
+ (((cast)(1##type << ((hi) - (lo) + 1)) - 1) << (lo))
+#define GENMASK(lo, hi) _GENMASK_T(unsigned, U, lo, hi)
+#define GENMASK_UL(lo, hi) _GENMASK_T(unsigned long, UL, lo, hi)
+#define GENMASK_ULL(lo, hi) _GENMASK_T(unsigned long long, ULL, lo, hi)
+
#define BITS_PER_BYTE 8
#define BITS_TO_LONGS(nr) DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(long))
#endif
--
Regards/Gruss,
Boris.
Advanced Micro Devices GmbH
Einsteinring 24, 85609 Dornach
GM: Alberto Bozzo
Reg: Dornach, Landkreis Muenchen
HRB Nr. 43632 WEEE Registernr: 129 19551
next prev parent reply other threads:[~2011-07-27 17:10 UTC|newest]
Thread overview: 46+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-07-22 13:15 [PATCH] x86, AMD: Correct F15h IC aliasing issue Borislav Petkov
2011-07-24 11:13 ` Ingo Molnar
2011-07-24 13:40 ` Borislav Petkov
2011-07-24 13:47 ` Ingo Molnar
2011-07-24 16:16 ` Andrew Morton
2011-07-26 18:33 ` Borislav Petkov
2011-07-24 16:04 ` Linus Torvalds
2011-07-24 17:22 ` Borislav Petkov
2011-07-24 17:39 ` Linus Torvalds
2011-07-24 18:12 ` Ingo Molnar
2011-07-24 18:23 ` Borislav Petkov
2011-07-24 18:30 ` Ingo Molnar
2011-07-24 19:07 ` Borislav Petkov
2011-07-24 20:44 ` Ingo Molnar
2011-07-25 20:00 ` Borislav Petkov
2011-07-25 20:06 ` Ingo Molnar
2011-07-25 21:53 ` Borislav Petkov
2011-07-26 5:58 ` Ray Lee
2011-07-26 17:28 ` Borislav Petkov
2011-07-26 18:34 ` Ingo Molnar
2011-07-26 18:39 ` Borislav Petkov
2011-07-26 18:47 ` Ingo Molnar
2011-07-26 19:33 ` Borislav Petkov
2011-07-27 17:10 ` Borislav Petkov [this message]
2011-07-27 17:16 ` H. Peter Anvin
2011-07-28 13:44 ` Borislav Petkov
2011-07-28 14:02 ` H. Peter Anvin
2011-07-28 14:13 ` Borislav Petkov
2011-07-28 14:18 ` H. Peter Anvin
2011-07-28 14:35 ` Borislav Petkov
2011-07-26 17:59 ` Avi Kivity
2011-07-26 18:13 ` Borislav Petkov
2011-07-26 18:16 ` H. Peter Anvin
2011-07-26 18:37 ` Borislav Petkov
2011-07-26 18:38 ` H. Peter Anvin
2011-07-26 19:42 ` Andre Przywara
2011-07-26 22:34 ` H. Peter Anvin
2011-07-27 4:14 ` Avi Kivity
2011-07-27 6:21 ` Borislav Petkov
2011-07-27 6:59 ` Ingo Molnar
2011-07-27 9:30 ` Avi Kivity
2011-07-27 15:37 ` Borislav Petkov
2011-07-27 15:45 ` Avi Kivity
2011-07-27 15:49 ` Borislav Petkov
2011-07-27 15:57 ` Avi Kivity
2011-07-27 16:42 ` Borislav Petkov
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=20110727171015.GD19477@aftab \
--to=bp@amd64.org \
--cc=Andre.Przywara@amd.com \
--cc=Martin.Pohlack@amd.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.org \
/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