mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Jan Beulich" <JBeulich@suse.com>
To: <mingo@elte.hu>, <tglx@linutronix.de>, <hpa@zytor.com>
Cc: <linux-kernel@vger.kernel.org>
Subject: [PATCH] x86: fix alignment determination in range_to_mtrr()
Date: Fri, 06 Jul 2012 15:07:48 +0100	[thread overview]
Message-ID: <4FF70D54020000780008E179@nat28.tlf.novell.com> (raw)

With the variable operated on being of "unsigned long" type, neither
ffs() nor fls() are suitable to use on them, as those truncate their
arguments to 32 bits. Using __ffs() and __fls() respectively at once
eliminates the need t subtract 1 from their results.

Additionally, with the alignment value subsequently used as a shift
count, it must be enforced to be less than BITS_PER_LONG (and on 64-bit
there's no need for it to be any smaller).

Signed-off-by: Jan Beulich <jbeulich@suse.com>

---
 arch/x86/kernel/cpu/mtrr/cleanup.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

--- 3.5-rc5/arch/x86/kernel/cpu/mtrr/cleanup.c
+++ 3.5-rc5-x86-mtrr-cleanup-types/arch/x86/kernel/cpu/mtrr/cleanup.c
@@ -258,11 +258,11 @@ range_to_mtrr(unsigned int reg, unsigned
 
 		/* Compute the maximum size with which we can make a range: */
 		if (range_startk)
-			max_align = ffs(range_startk) - 1;
+			max_align = __ffs(range_startk);
 		else
-			max_align = 32;
+			max_align = BITS_PER_LONG - 1;
 
-		align = fls(range_sizek) - 1;
+		align = __fls(range_sizek);
 		if (align > max_align)
 			align = max_align;
 




             reply	other threads:[~2012-07-06 14:06 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-06 14:07 Jan Beulich [this message]
2012-07-10  9:55 ` [tip:x86/asm] x86/mm/mtrr: Fix " tip-bot for Jan Beulich

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=4FF70D54020000780008E179@nat28.tlf.novell.com \
    --to=jbeulich@suse.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=tglx@linutronix.de \
    /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

all inboxes | Powered by JetHome®