mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] x86: fix alignment determination in range_to_mtrr()
@ 2012-07-06 14:07 Jan Beulich
  2012-07-10  9:55 ` [tip:x86/asm] x86/mm/mtrr: Fix " tip-bot for Jan Beulich
  0 siblings, 1 reply; 2+ messages in thread
From: Jan Beulich @ 2012-07-06 14:07 UTC (permalink / raw)
  To: mingo, tglx, hpa; +Cc: linux-kernel

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;
 




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-07-10  9:56 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-07-06 14:07 [PATCH] x86: fix alignment determination in range_to_mtrr() Jan Beulich
2012-07-10  9:55 ` [tip:x86/asm] x86/mm/mtrr: Fix " tip-bot for Jan Beulich

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®